]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/SubMirror/lib/addmirrorwizard.php
Removed plugin Google-Analytics as this is free/libre and decentralized
[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' => 'gnusocial',
68                 'name' => _m('GNU social'),
69             ),
70              */
71             /*
72             // WordPress was on our list some whiles ago, but not sure
73             // what we can actually do here. Search on Wordpress.com hosted
74             // sites, or ?
75             array(
76                 'id' => 'wordpress',
77                 'name' => _m('WordPress'),
78             ),
79              */
80             array(
81                 'id' => 'feed',
82                 // TRANS: Name for possible feed provider.
83                 'name' => _m('RSS or Atom feed'),
84             ),
85         );
86     }
87
88     function showProviders(array $providers)
89     {
90         $out = $this->out;
91
92         $out->elementStart('div', 'provider-list');
93         // TRANS: Heading for feed mirroring selection form.
94         $out->element('h2', null, _m('Select a feed provider'));
95         $out->elementStart('table');
96         foreach ($providers as $provider) {
97             $icon = common_path('plugins/SubMirror/images/providers/' . $provider['id'] . '.png');
98             $targetUrl = common_local_url('mirrorsettings', array('provider' => $provider['id']));
99
100             $out->elementStart('tr', array('class' => 'provider'));
101             $out->elementStart('td');
102
103             $out->elementStart('div', 'provider-heading');
104             $out->element('img', array('src' => $icon));
105             $out->element('a', array('href' => $targetUrl), $provider['name']);
106             $out->elementEnd('div');
107
108             $out->elementEnd('td');
109             $out->elementEnd('tr');
110         }
111         $out->elementEnd('table');
112         $out->elementEnd('div');
113     }
114
115     /**
116      * Buttons for form actions
117      *
118      * Submit and cancel buttons (or whatever)
119      * Sub-classes should overload this to show their own buttons.
120      *
121      * @return void
122      */
123     function formActions()
124     {
125     }
126
127     /**
128      * ID of the form
129      *
130      * Should be unique on the page. Sub-classes should overload this
131      * to show their own IDs.
132      *
133      * @return string ID of the form
134      */
135     function id()
136     {
137         return 'add-mirror-wizard';
138     }
139
140     /**
141      * Action of the form.
142      *
143      * URL to post to. Should be overloaded by subclasses to give
144      * somewhere to post to.
145      *
146      * @return string URL to post to
147      */
148     function action()
149     {
150         return common_local_url('addmirror');
151     }
152
153     /**
154      * Class of the form.
155      *
156      * @return string the form's class
157      */
158     function formClass()
159     {
160         return 'form_settings';
161     }
162 }