]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/SubMirror/lib/addmirrorwizard.php
Update translator documentation.
[quix0rs-gnu-social.git] / plugins / SubMirror / lib / addmirrorwizard.php
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-2011 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
25 if (!defined('STATUSNET') && !defined('LACONICA')) {
26     exit(1);
27 }
28
29 class AddMirrorWizard extends Widget
30 {
31     /**
32      * Name of the form
33      *
34      * Sub-classes should overload this with the name of their form.
35      *
36      * @return void
37      */
38     function formLegend()
39     {
40     }
41
42     /**
43      * Visible or invisible data elements
44      *
45      * Display the form fields that make up the data of the form.
46      * Sub-classes should overload this to show their data.
47      *
48      * @return void
49      */
50     function show()
51     {
52         $this->out->elementStart('div', array('id' => 'add-mirror-wizard'));
53
54         $providers = $this->providers();
55         $this->showProviders($providers);
56
57         $this->out->elementEnd('div');
58     }
59
60     function providers()
61     {
62         return array(
63             /*
64             // We could accept hostname & username combos here, or
65             // webfingery combinations as for remote users.
66             array(
67                 'id' => 'statusnet',
68                 'name' => _m('StatusNet'),
69             ),
70              */
71             // Accepts a Twitter username and pulls their user timeline as a
72             // public Atom feed. Requires a working alternate hub which, one
73             // hopes, is getting timely updates.
74             array(
75                 'id' => 'twitter',
76                 // TRANS: Name for possible feed provider.
77                 'name' => _m('Twitter'),
78             ),
79             /*
80             // WordPress was on our list some whiles ago, but not sure
81             // what we can actually do here. Search on Wordpress.com hosted
82             // sites, or ?
83             array(
84                 'id' => 'wordpress',
85                 'name' => _m('WordPress'),
86             ),
87              */
88             /*
89             // In theory, Facebook lets you pull public updates over RSS,
90             // but the URLs for your own update feed that I can find from
91             // 2009-era websites no longer seem to work and there's no
92             // good current documentation. May not still be available...
93             // Mirroring from an FB account is probably better done with
94             // the dedicated plugin. (As of March 2011)
95             array(
96                 'id' => 'facebook',
97                 'name' => _m('Facebook'),
98             ),
99              */
100             /*
101             // LinkedIn doesn't currently seem to have public feeds
102             // for users or groups (March 2011)
103             array(
104                 'id' => 'linkedin',
105                 'name' => _m('LinkedIn'),
106             ),
107              */
108             array(
109                 'id' => 'feed',
110                 // TRANS: Name for possible feed provider.
111                 'name' => _m('RSS or Atom feed'),
112             ),
113         );
114     }
115
116     function showProviders(array $providers)
117     {
118         $out = $this->out;
119
120         $out->elementStart('div', 'provider-list');
121         // TRANS: Heading for feed mirroring selection form.
122         $out->element('h2', null, _m('Select a feed provider'));
123         $out->elementStart('table');
124         foreach ($providers as $provider) {
125             $icon = common_path('plugins/SubMirror/images/providers/' . $provider['id'] . '.png');
126             $targetUrl = common_local_url('mirrorsettings', array('provider' => $provider['id']));
127
128             $out->elementStart('tr', array('class' => 'provider'));
129             $out->elementStart('td');
130
131             $out->elementStart('div', 'provider-heading');
132             $out->element('img', array('src' => $icon));
133             $out->element('a', array('href' => $targetUrl), $provider['name']);
134             $out->elementEnd('div');
135
136             $out->elementEnd('td');
137             $out->elementEnd('tr');
138         }
139         $out->elementEnd('table');
140         $out->elementEnd('div');
141     }
142
143     /**
144      * Buttons for form actions
145      *
146      * Submit and cancel buttons (or whatever)
147      * Sub-classes should overload this to show their own buttons.
148      *
149      * @return void
150      */
151     function formActions()
152     {
153     }
154
155     /**
156      * ID of the form
157      *
158      * Should be unique on the page. Sub-classes should overload this
159      * to show their own IDs.
160      *
161      * @return string ID of the form
162      */
163     function id()
164     {
165         return 'add-mirror-wizard';
166     }
167
168     /**
169      * Action of the form.
170      *
171      * URL to post to. Should be overloaded by subclasses to give
172      * somewhere to post to.
173      *
174      * @return string URL to post to
175      */
176     function action()
177     {
178         return common_local_url('addmirror');
179     }
180
181     /**
182      * Class of the form.
183      *
184      * @return string the form's class
185      */
186     function formClass()
187     {
188         return 'form_settings';
189     }
190 }