mirrorsettings.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <?php
  2. /**
  3. * StatusNet, the distributed open-source microblogging tool
  4. *
  5. * PHP version 5
  6. *
  7. * LICENCE: This program is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU Affero General Public License as published by
  9. * the Free Software Foundation, either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU Affero General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Affero General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. *
  20. * @category Plugins
  21. * @package StatusNet
  22. * @author Brion Vibber <brion@status.net>
  23. * @copyright 2010 StatusNet, Inc.
  24. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  25. * @link http://status.net/
  26. */
  27. if (!defined('GNUSOCIAL') && !defined('STATUSNET')) { exit(1); }
  28. class MirrorSettingsAction extends SettingsAction
  29. {
  30. /**
  31. * Title of the page
  32. *
  33. * @return string Page title
  34. */
  35. function title()
  36. {
  37. // TRANS: Page title.
  38. return _m('Feed mirror settings');
  39. }
  40. /**
  41. * Instructions for use
  42. *
  43. * @return string Instructions for use
  44. */
  45. function getInstructions()
  46. {
  47. // TRANS: Page instructions.
  48. return _m('You can mirror updates from many RSS and Atom feeds ' .
  49. 'into your GNU social timeline!');
  50. }
  51. /**
  52. * Show the form for OpenID management
  53. *
  54. * We have one form with a few different submit buttons to do different things.
  55. *
  56. * @return void
  57. */
  58. function showContent()
  59. {
  60. $user = common_current_user();
  61. $provider = $this->trimmed('provider');
  62. if ($provider) {
  63. $this->showAddFeedForm($provider);
  64. } else {
  65. $this->elementStart('div', array('id' => 'add-mirror'));
  66. $this->showAddWizard();
  67. $this->elementEnd('div');
  68. $mirror = new SubMirror();
  69. $mirror->subscriber = $user->id;
  70. if ($mirror->find()) {
  71. while ($mirror->fetch()) {
  72. $this->showFeedForm($mirror);
  73. }
  74. }
  75. }
  76. }
  77. function showAddWizard()
  78. {
  79. $form = new AddMirrorWizard($this);
  80. $form->show();
  81. }
  82. function showFeedForm($mirror)
  83. {
  84. $profile = Profile::getKV('id', $mirror->subscribed);
  85. if ($profile) {
  86. $form = new EditMirrorForm($this, $profile);
  87. $form->show();
  88. }
  89. }
  90. function showAddFeedForm()
  91. {
  92. switch ($this->arg('provider')) {
  93. case 'statusnet':
  94. break;
  95. case 'wordpress':
  96. break;
  97. case 'linkedin':
  98. break;
  99. case 'feed':
  100. default:
  101. $form = new AddMirrorForm($this);
  102. }
  103. $form->show();
  104. }
  105. /**
  106. *
  107. * @param array $args
  108. *
  109. * @todo move the ajax display handling to common code
  110. */
  111. function handle($args)
  112. {
  113. if ($this->boolean('ajax')) {
  114. $this->startHTML('text/xml;charset=utf-8');
  115. $this->elementStart('head');
  116. // TRANS: Title for page with form to add a mirror feed provider on.
  117. $this->element('title', null, _m('Provider add'));
  118. $this->elementEnd('head');
  119. $this->elementStart('body');
  120. $this->showAddFeedForm();
  121. $this->elementEnd('body');
  122. $this->endHTML();
  123. } else {
  124. return parent::handle($args);
  125. }
  126. }
  127. /**
  128. * Handle a POST request
  129. *
  130. * Muxes to different sub-functions based on which button was pushed
  131. *
  132. * @return void
  133. */
  134. function handlePost()
  135. {
  136. }
  137. /**
  138. * Show the local navigation menu
  139. *
  140. * This is the same for all settings, so we show it here.
  141. *
  142. * @return void
  143. */
  144. function showLocalNav()
  145. {
  146. $menu = new SettingsNav($this);
  147. $menu->show();
  148. }
  149. function showScripts()
  150. {
  151. parent::showScripts();
  152. $this->script('plugins/SubMirror/js/mirrorsettings.js');
  153. }
  154. function showStylesheets()
  155. {
  156. parent::showStylesheets();
  157. $this->cssLink('plugins/SubMirror/css/mirrorsettings.css');
  158. }
  159. }