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