]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/Sitemap/sitemapadminpanel.php
3304cfd011df0aac3eafb1e688a672f75675439f
[quix0rs-gnu-social.git] / plugins / Sitemap / sitemapadminpanel.php
1 <?php
2 /**
3  * StatusNet, the distributed open-source microblogging tool
4  *
5  * Sitemap administration panel
6  *
7  * PHP version 5
8  *
9  * LICENCE: This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU Affero General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU Affero General Public License for more details.
18  *
19  * You should have received a copy of the GNU Affero General Public License
20  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21  *
22  * @category  Sitemap
23  * @package   StatusNet
24  * @author    Evan Prodromou <evan@status.net>
25  * @copyright 2010 StatusNet, Inc.
26  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
27  * @link      http://status.net/
28  */
29
30 if (!defined('STATUSNET')) {
31     exit(1);
32 }
33
34 /**
35  * Administer sitemap settings
36  *
37  * @category Sitemap
38  * @package  StatusNet
39  * @author   Evan Prodromou <evan@status.net>
40  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
41  * @link     http://status.net/
42  */
43 class SitemapadminpanelAction extends AdminPanelAction
44 {
45     /**
46      * Returns the page title
47      *
48      * @return string page title
49      */
50     function title()
51     {
52         // TRANS: Title for sitemap.
53         return _m('Sitemap');
54     }
55
56     /**
57      * Instructions for using this form.
58      *
59      * @return string instructions
60      */
61     function getInstructions()
62     {
63         // TRANS: Instructions for sitemap.
64         return _m('Sitemap settings for this StatusNet site');
65     }
66
67     /**
68      * Show the site admin panel form
69      *
70      * @return void
71      */
72     function showForm()
73     {
74         $form = new SitemapAdminPanelForm($this);
75         $form->show();
76         return;
77     }
78
79     /**
80      * Save settings from the form
81      *
82      * @return void
83      */
84     function saveSettings()
85     {
86         static $settings = array('sitemap' => array('googlekey', 'yahookey', 'bingkey'));
87
88         $values = array();
89
90         foreach ($settings as $section => $parts) {
91             foreach ($parts as $setting) {
92                 $values[$section][$setting] = $this->trimmed($setting);
93             }
94         }
95
96         // This throws an exception on validation errors
97         $this->validate($values);
98
99         // assert(all values are valid);
100
101         $config = new Config();
102
103         $config->query('BEGIN');
104
105         foreach ($settings as $section => $parts) {
106             foreach ($parts as $setting) {
107                 Config::save($section, $setting, $values[$section][$setting]);
108             }
109         }
110
111         $config->query('COMMIT');
112
113         return;
114     }
115
116     function validate(&$values)
117     {
118     }
119 }
120
121 /**
122  * Form for the sitemap admin panel
123  */
124 class SitemapAdminPanelForm extends AdminForm
125 {
126     /**
127      * ID of the form
128      *
129      * @return int ID of the form
130      */
131     function id()
132     {
133         return 'form_sitemap_admin_panel';
134     }
135
136     /**
137      * class of the form
138      *
139      * @return string class of the form
140      */
141     function formClass()
142     {
143         return 'form_sitemap';
144     }
145
146     /**
147      * Action of the form
148      *
149      * @return string URL of the action
150      */
151     function action()
152     {
153         return common_local_url('sitemapadminpanel');
154     }
155
156     /**
157      * Data elements of the form
158      *
159      * @return void
160      */
161     function formData()
162     {
163         $this->out->elementStart('ul', 'form_data');
164         $this->li();
165         $this->input('googlekey',
166                      // TRANS: Field label.
167                      _m('Google key'),
168                      // TRANS: Title for field label.
169                      _m('Google Webmaster Tools verification key.'),
170                      'sitemap');
171         $this->unli();
172         $this->li();
173         $this->input('yahookey',
174                      // TRANS: Field label.
175                      _m('Yahoo key'),
176                      // TRANS: Title for field label.
177                      _m('Yahoo! Site Explorer verification key.'),
178                      'sitemap');
179         $this->unli();
180         $this->li();
181         $this->input('bingkey',
182                      // TRANS: Field label.
183                      _m('Bing key'),
184                      // TRANS: Title for field label.
185                      _m('Bing Webmaster Tools verification key.'),
186                      'sitemap');
187         $this->unli();
188         $this->out->elementEnd('ul');
189     }
190
191     /**
192      * Action elements
193      *
194      * @return void
195      */
196     function formActions()
197     {
198         $this->out->submit('submit',
199                            // TRANS: Submit button text to save sitemap settings.
200                            _m('BUTTON','Save'),
201                            'submit',
202                            null,
203                            // TRANS: Submit button title to save sitemap settings.
204                            _m('Save sitemap settings.'));
205     }
206 }