addmirrorwizard.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <?php
  2. /**
  3. * StatusNet, the distributed open-source microblogging tool
  4. * PHP version 5
  5. *
  6. * LICENCE: This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Affero General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Affero General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. *
  19. * @package StatusNet
  20. * @copyright 2010-2011 StatusNet, Inc.
  21. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  22. * @link http://status.net/
  23. */
  24. if (!defined('STATUSNET') && !defined('LACONICA')) {
  25. exit(1);
  26. }
  27. class AddMirrorWizard extends Widget
  28. {
  29. /**
  30. * Name of the form
  31. *
  32. * Sub-classes should overload this with the name of their form.
  33. *
  34. * @return void
  35. */
  36. function formLegend()
  37. {
  38. }
  39. /**
  40. * Visible or invisible data elements
  41. *
  42. * Display the form fields that make up the data of the form.
  43. * Sub-classes should overload this to show their data.
  44. *
  45. * @return void
  46. */
  47. function show()
  48. {
  49. $this->out->elementStart('div', array('id' => 'add-mirror-wizard'));
  50. $providers = $this->providers();
  51. $this->showProviders($providers);
  52. $this->out->elementEnd('div');
  53. }
  54. function providers()
  55. {
  56. return array(
  57. /*
  58. // We could accept hostname & username combos here, or
  59. // webfingery combinations as for remote users.
  60. array(
  61. 'id' => 'gnusocial',
  62. 'name' => _m('GNU social'),
  63. ),
  64. */
  65. /*
  66. // WordPress was on our list some whiles ago, but not sure
  67. // what we can actually do here. Search on Wordpress.com hosted
  68. // sites, or ?
  69. array(
  70. 'id' => 'wordpress',
  71. 'name' => _m('WordPress'),
  72. ),
  73. */
  74. array(
  75. 'id' => 'feed',
  76. // TRANS: Name for possible feed provider.
  77. 'name' => _m('RSS or Atom feed'),
  78. ),
  79. );
  80. }
  81. function showProviders(array $providers)
  82. {
  83. $out = $this->out;
  84. $out->elementStart('div', 'provider-list');
  85. // TRANS: Heading for feed mirroring selection form.
  86. $out->element('h2', null, _m('Select a feed provider'));
  87. $out->elementStart('table');
  88. foreach ($providers as $provider) {
  89. $icon = common_path('plugins/SubMirror/images/providers/' . $provider['id'] . '.png');
  90. $targetUrl = common_local_url('mirrorsettings', array('provider' => $provider['id']));
  91. $out->elementStart('tr', array('class' => 'provider'));
  92. $out->elementStart('td');
  93. $out->elementStart('div', 'provider-heading');
  94. $out->element('img', array('src' => $icon));
  95. $out->element('a', array('href' => $targetUrl), $provider['name']);
  96. $out->elementEnd('div');
  97. $out->elementEnd('td');
  98. $out->elementEnd('tr');
  99. }
  100. $out->elementEnd('table');
  101. $out->elementEnd('div');
  102. }
  103. /**
  104. * Buttons for form actions
  105. *
  106. * Submit and cancel buttons (or whatever)
  107. * Sub-classes should overload this to show their own buttons.
  108. *
  109. * @return void
  110. */
  111. function formActions()
  112. {
  113. }
  114. /**
  115. * ID of the form
  116. *
  117. * Should be unique on the page. Sub-classes should overload this
  118. * to show their own IDs.
  119. *
  120. * @return string ID of the form
  121. */
  122. function id()
  123. {
  124. return 'add-mirror-wizard';
  125. }
  126. /**
  127. * Action of the form.
  128. *
  129. * URL to post to. Should be overloaded by subclasses to give
  130. * somewhere to post to.
  131. *
  132. * @return string URL to post to
  133. */
  134. function action()
  135. {
  136. return common_local_url('addmirror');
  137. }
  138. /**
  139. * Class of the form.
  140. *
  141. * @return string the form's class
  142. */
  143. function formClass()
  144. {
  145. return 'form_settings';
  146. }
  147. }