sitemapadminpanel.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <?php
  2. /**
  3. * StatusNet, the distributed open-source microblogging tool
  4. *
  5. * Sitemap administration panel
  6. *
  7. * PHP version 5
  8. *
  9. * LICENCE: This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License as published by
  11. * the Free Software Foundation, either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. *
  22. * @category Sitemap
  23. * @package StatusNet
  24. * @author Evan Prodromou <evan@status.net>
  25. * @copyright 2010 StatusNet, Inc.
  26. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  27. * @link http://status.net/
  28. */
  29. if (!defined('STATUSNET')) {
  30. exit(1);
  31. }
  32. /**
  33. * Administer sitemap settings
  34. *
  35. * @category Sitemap
  36. * @package StatusNet
  37. * @author Evan Prodromou <evan@status.net>
  38. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  39. * @link http://status.net/
  40. */
  41. class SitemapadminpanelAction extends AdminPanelAction
  42. {
  43. /**
  44. * Returns the page title
  45. *
  46. * @return string page title
  47. */
  48. function title()
  49. {
  50. // TRANS: Title for sitemap.
  51. return _m('Sitemap');
  52. }
  53. /**
  54. * Instructions for using this form.
  55. *
  56. * @return string instructions
  57. */
  58. function getInstructions()
  59. {
  60. // TRANS: Instructions for sitemap.
  61. return _m('Sitemap settings for this StatusNet site');
  62. }
  63. /**
  64. * Show the site admin panel form
  65. *
  66. * @return void
  67. */
  68. function showForm()
  69. {
  70. $form = new SitemapAdminPanelForm($this);
  71. $form->show();
  72. return;
  73. }
  74. /**
  75. * Save settings from the form
  76. *
  77. * @return void
  78. */
  79. function saveSettings()
  80. {
  81. static $settings = array('sitemap' => array('yahookey', 'bingkey'));
  82. $values = array();
  83. foreach ($settings as $section => $parts) {
  84. foreach ($parts as $setting) {
  85. $values[$section][$setting] = $this->trimmed($setting);
  86. }
  87. }
  88. // This throws an exception on validation errors
  89. $this->validate($values);
  90. // assert(all values are valid);
  91. $config = new Config();
  92. $config->query('BEGIN');
  93. foreach ($settings as $section => $parts) {
  94. foreach ($parts as $setting) {
  95. Config::save($section, $setting, $values[$section][$setting]);
  96. }
  97. }
  98. $config->query('COMMIT');
  99. return;
  100. }
  101. function validate(&$values)
  102. {
  103. }
  104. }
  105. /**
  106. * Form for the sitemap admin panel
  107. */
  108. class SitemapAdminPanelForm extends AdminForm
  109. {
  110. /**
  111. * ID of the form
  112. *
  113. * @return int ID of the form
  114. */
  115. function id()
  116. {
  117. return 'form_sitemap_admin_panel';
  118. }
  119. /**
  120. * class of the form
  121. *
  122. * @return string class of the form
  123. */
  124. function formClass()
  125. {
  126. return 'form_sitemap';
  127. }
  128. /**
  129. * Action of the form
  130. *
  131. * @return string URL of the action
  132. */
  133. function action()
  134. {
  135. return common_local_url('sitemapadminpanel');
  136. }
  137. /**
  138. * Data elements of the form
  139. *
  140. * @return void
  141. */
  142. function formData()
  143. {
  144. $this->out->elementStart('ul', 'form_data');
  145. $this->li();
  146. $this->input('yahookey',
  147. // TRANS: Field label.
  148. _m('Yahoo key'),
  149. // TRANS: Title for field label.
  150. _m('Yahoo! Site Explorer verification key.'),
  151. 'sitemap');
  152. $this->unli();
  153. $this->li();
  154. $this->input('bingkey',
  155. // TRANS: Field label.
  156. _m('Bing key'),
  157. // TRANS: Title for field label.
  158. _m('Bing Webmaster Tools verification key.'),
  159. 'sitemap');
  160. $this->unli();
  161. $this->out->elementEnd('ul');
  162. }
  163. /**
  164. * Action elements
  165. *
  166. * @return void
  167. */
  168. function formActions()
  169. {
  170. $this->out->submit('submit',
  171. // TRANS: Submit button text to save sitemap settings.
  172. _m('BUTTON','Save'),
  173. 'submit',
  174. null,
  175. // TRANS: Submit button title to save sitemap settings.
  176. _m('Save sitemap settings.'));
  177. }
  178. }