]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/SubMirror/actions/mirrorsettings.php
Some cleanups:
[quix0rs-gnu-social.git] / plugins / SubMirror / actions / mirrorsettings.php
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
28 if (!defined('GNUSOCIAL') && !defined('STATUSNET')) { exit(1); }
29
30 class MirrorSettingsAction extends SettingsAction
31 {
32     /**
33      * Title of the page
34      *
35      * @return string Page title
36      */
37     function title()
38     {
39         // TRANS: Page title.
40         return _m('Feed mirror settings');
41     }
42
43     /**
44      * Instructions for use
45      *
46      * @return string Instructions for use
47      */
48
49     function getInstructions()
50     {
51         // TRANS: Page instructions.
52         return _m('You can mirror updates from many RSS and Atom feeds ' .
53                   'into your GNU social timeline!');
54     }
55
56     /**
57      * Show the form for OpenID management
58      *
59      * We have one form with a few different submit buttons to do different things.
60      *
61      * @return void
62      */
63     function showContent()
64     {
65         $user = common_current_user();
66         $provider = $this->trimmed('provider');
67         if ($provider) {
68             $this->showAddFeedForm($provider);
69         } else {
70             $this->elementStart('div', array('id' => 'add-mirror'));
71             $this->showAddWizard();
72             $this->elementEnd('div');
73
74             $mirror = new SubMirror();
75             $mirror->subscriber = $user->id;
76             if ($mirror->find()) {
77                 while ($mirror->fetch()) {
78                     $this->showFeedForm($mirror);
79                 }
80             }
81         }
82     }
83
84     function showAddWizard()
85     {
86         $form = new AddMirrorWizard($this);
87         $form->show();
88     }
89
90     function showFeedForm($mirror)
91     {
92         $profile = Profile::getKV('id', $mirror->subscribed);
93
94         if ($profile instanceof Profile) {
95             $form = new EditMirrorForm($this, $profile);
96             $form->show();
97         }
98     }
99
100     function showAddFeedForm()
101     {
102         switch ($this->arg('provider')) {
103         case 'statusnet':
104             break;
105         case 'wordpress':
106             break;
107         case 'linkedin':
108             break;
109         case 'feed':
110         default:
111             $form = new AddMirrorForm($this);
112         }
113         $form->show();
114     }
115
116     /**
117      *
118      * @param array $args
119      *
120      * @todo move the ajax display handling to common code
121      */
122     function handle($args)
123     {
124         if ($this->boolean('ajax')) {
125             $this->startHTML('text/xml;charset=utf-8');
126             $this->elementStart('head');
127             // TRANS: Title for page with form to add a mirror feed provider on.
128             $this->element('title', null, _m('Provider add'));
129             $this->elementEnd('head');
130             $this->elementStart('body');
131
132             $this->showAddFeedForm();
133
134             $this->elementEnd('body');
135             $this->endHTML();
136         } else {
137             return parent::handle($args);
138         }
139     }
140     /**
141      * Handle a POST request
142      *
143      * Muxes to different sub-functions based on which button was pushed
144      *
145      * @return void
146      */
147     function handlePost()
148     {
149     }
150
151     /**
152      * Show the local navigation menu
153      *
154      * This is the same for all settings, so we show it here.
155      *
156      * @return void
157      */
158     function showLocalNav()
159     {
160         $menu = new SettingsNav($this);
161         $menu->show();
162     }
163
164     function showScripts()
165     {
166         parent::showScripts();
167         $this->script('plugins/SubMirror/js/mirrorsettings.js');
168     }
169
170     function showStylesheets()
171     {
172         parent::showStylesheets();
173         $this->cssLink('plugins/SubMirror/css/mirrorsettings.css');
174     }
175 }