]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/SubMirror/lib/addmirrorwizard.php
920db0bc9c0319d5ce857a12fea7717fd75e49ad
[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                 'name' => _m('Twitter'),
77             ),
78             /*
79             // WordPress was on our list some whiles ago, but not sure
80             // what we can actually do here. Search on Wordpress.com hosted
81             // sites, or ?
82             array(
83                 'id' => 'wordpress',
84                 'name' => _m('WordPress'),
85             ),
86              */
87             /*
88             // In theory, Facebook lets you pull public updates over RSS,
89             // but the URLs for your own update feed that I can find from
90             // 2009-era websites no longer seem to work and there's no
91             // good current documentation. May not still be available...
92             // Mirroring from an FB account is probably better done with
93             // the dedicated plugin. (As of March 2011)
94             array(
95                 'id' => 'facebook',
96                 'name' => _m('Facebook'),
97             ),
98              */
99             /*
100             // LinkedIn doesn't currently seem to have public feeds
101             // for users or groups (March 2011)
102             array(
103                 'id' => 'linkedin',
104                 'name' => _m('LinkedIn'),
105             ),
106              */
107             array(
108                 'id' => 'feed',
109                 'name' => _m('RSS or Atom feed'),
110             ),
111         );
112     }
113
114     function showProviders(array $providers)
115     {
116         $out = $this->out;
117
118         $out->elementStart('div', 'provider-list');
119         $out->element('h2', null, _m('Select a feed provider'));
120         $out->elementStart('table');
121         foreach ($providers as $provider) {
122             $icon = common_path('plugins/SubMirror/images/providers/' . $provider['id'] . '.png');
123             $targetUrl = common_local_url('mirrorsettings', array('provider' => $provider['id']));
124
125             $out->elementStart('tr', array('class' => 'provider'));
126             $out->elementStart('td');
127
128             $out->elementStart('div', 'provider-heading');
129             $out->element('img', array('src' => $icon));
130             $out->element('a', array('href' => $targetUrl), $provider['name']);
131             $out->elementEnd('div');
132
133             $out->elementEnd('td');
134             $out->elementEnd('tr');
135         }
136         $out->elementEnd('table');
137         $out->elementEnd('div');
138     }
139
140     /**
141      * Buttons for form actions
142      *
143      * Submit and cancel buttons (or whatever)
144      * Sub-classes should overload this to show their own buttons.
145      *
146      * @return void
147      */
148     function formActions()
149     {
150     }
151
152     /**
153      * ID of the form
154      *
155      * Should be unique on the page. Sub-classes should overload this
156      * to show their own IDs.
157      *
158      * @return string ID of the form
159      */
160     function id()
161     {
162         return 'add-mirror-wizard';
163     }
164
165     /**
166      * Action of the form.
167      *
168      * URL to post to. Should be overloaded by subclasses to give
169      * somewhere to post to.
170      *
171      * @return string URL to post to
172      */
173     function action()
174     {
175         return common_local_url('addmirror');
176     }
177
178     /**
179      * Class of the form.
180      *
181      * @return string the form's class
182      */
183     function formClass()
184     {
185         return 'form_settings';
186     }
187 }