addmirror.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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 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 AddMirrorForm extends Form
  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 formData()
  48. {
  49. $this->out->hidden('provider', 'feed');
  50. $this->out->elementStart('fieldset');
  51. $this->out->elementStart('ul');
  52. $this->li();
  53. $this->doInput('addmirror-feedurl',
  54. 'feedurl',
  55. // TRANS: Field label.
  56. _m('Web page or feed URL:'),
  57. $this->out->trimmed('feedurl'));
  58. $this->unli();
  59. $this->li();
  60. // TRANS: Button text for adding a feed.
  61. $this->out->submit('addmirror-save', _m('BUTTON','Add feed'));
  62. $this->unli();
  63. $this->out->elementEnd('ul');
  64. $this->out->elementEnd('fieldset');
  65. }
  66. protected function doInput($id, $name, $label, $value=null, $instructions=null)
  67. {
  68. $this->out->element('label', array('for' => $id), $label);
  69. $attrs = array('name' => $name,
  70. 'type' => 'text',
  71. 'id' => $id,
  72. 'style' => 'width: 80%');
  73. if ($value) {
  74. $attrs['value'] = $value;
  75. }
  76. $this->out->element('input', $attrs);
  77. if ($instructions) {
  78. $this->out->element('p', 'form_guide', $instructions);
  79. }
  80. }
  81. /**
  82. * Buttons for form actions
  83. *
  84. * Submit and cancel buttons (or whatever)
  85. * Sub-classes should overload this to show their own buttons.
  86. *
  87. * @return void
  88. */
  89. function formActions()
  90. {
  91. }
  92. /**
  93. * ID of the form
  94. *
  95. * Should be unique on the page. Sub-classes should overload this
  96. * to show their own IDs.
  97. *
  98. * @return string ID of the form
  99. */
  100. function id()
  101. {
  102. return 'add-mirror-form';
  103. }
  104. /**
  105. * Action of the form.
  106. *
  107. * URL to post to. Should be overloaded by subclasses to give
  108. * somewhere to post to.
  109. *
  110. * @return string URL to post to
  111. */
  112. function action()
  113. {
  114. return common_local_url('addmirror');
  115. }
  116. /**
  117. * Class of the form.
  118. *
  119. * @return string the form's class
  120. */
  121. function formClass()
  122. {
  123. return 'form_settings';
  124. }
  125. }