]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/OpenX/openxadminpanel.php
More info for a proper, fancy-url lighttpd setup
[quix0rs-gnu-social.git] / plugins / OpenX / openxadminpanel.php
1 <?php
2 /**
3  * StatusNet, the distributed open-source microblogging tool
4  *
5  * OpenX 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  OpenX
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 openx settings
36  *
37  * @category OpenX
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 OpenXadminpanelAction extends AdminPanelAction
44 {
45     /**
46      * Returns the page title
47      *
48      * @return string page title
49      */
50     function title()
51     {
52         // TRANS: Page title for OpenX admin panel.
53         return _m('TITLE', 'OpenX');
54     }
55
56     /**
57      * Instructions for using this form.
58      *
59      * @return string instructions
60      */
61     function getInstructions()
62     {
63         // TRANS: Instructions for OpenX admin panel.
64         return _m('OpenX 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 OpenXAdminPanelForm($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('openx' => array('adScript', 'mediumRectangle', 'rectangle', 'leaderboard', 'wideSkyscraper'));
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         $config = new Config();
101
102         $config->query('BEGIN');
103
104         foreach ($settings as $section => $parts) {
105             foreach ($parts as $setting) {
106                 Config::save($section, $setting, $values[$section][$setting]);
107             }
108         }
109
110         $config->query('COMMIT');
111
112         return;
113     }
114
115     function validate(&$values)
116     {
117     }
118 }
119
120 /**
121  * Form for the openx admin panel
122  */
123 class OpenXAdminPanelForm extends AdminForm
124 {
125     /**
126      * ID of the form
127      *
128      * @return int ID of the form
129      */
130     function id()
131     {
132         return 'form_openx_admin_panel';
133     }
134
135     /**
136      * class of the form
137      *
138      * @return string class of the form
139      */
140     function formClass()
141     {
142         return 'form_openx';
143     }
144
145     /**
146      * Action of the form
147      *
148      * @return string URL of the action
149      */
150     function action()
151     {
152         return common_local_url('openxadminpanel');
153     }
154
155     /**
156      * Data elements of the form
157      *
158      * @return void
159      */
160     function formData()
161     {
162         $this->out->elementStart('fieldset', array('id' => 'openx_admin'));
163         $this->out->elementStart('ul', 'form_data');
164         $this->li();
165         $this->input('adScript',
166                      // TRANS: Form label in OpenX admin panel.
167                      _m('Ad script URL'),
168                      // TRANS: Tooltip for form label in OpenX admin panel.
169                      _m('Script URL'),
170                      'openx');
171         $this->unli();
172         $this->li();
173         $this->input('mediumRectangle',
174                      // TRANS: Form label in OpenX admin panel. Refers to advertisement format.
175                      _m('Medium rectangle'),
176                      // TRANS: Tooltip for form label in OpenX admin panel. Refers to advertisement format.
177                      _m('Medium rectangle zone'),
178                      'openx');
179         $this->unli();
180         $this->li();
181         $this->input('rectangle',
182                      // TRANS: Form label in OpenX admin panel. Refers to advertisement format.
183                      _m('Rectangle'),
184                      // TRANS: Tooltip for form label in OpenX admin panel. Refers to advertisement format.
185                      _m('Rectangle zone'),
186                      'openx');
187         $this->unli();
188         $this->li();
189         $this->input('leaderboard',
190                      // TRANS: Form label in OpenX admin panel. Refers to advertisement format.
191                      _m('Leaderboard'),
192                      // TRANS: Tooltip for form label in OpenX admin panel. Refers to advertisement format.
193                      _m('Leaderboard zone'),
194                      'openx');
195         $this->unli();
196         $this->li();
197         $this->input('wideSkyscraper',
198                      // TRANS: Form label in OpenX admin panel. Refers to advertisement format.
199                      _m('Skyscraper'),
200                      // TRANS: Tooltip for form label in OpenX admin panel. Refers to advertisement format.
201                      _m('Wide skyscraper zone'),
202                      'openx');
203         $this->unli();
204         $this->out->elementEnd('ul');
205     }
206
207     /**
208      * Action elements
209      *
210      * @return void
211      */
212     function formActions()
213     {
214         $this->out->submit('submit',
215                     // TRANS: Submit button text in OpenX admin panel.
216                     _m('BUTTON','Save'),
217                     'submit',
218                     null,
219                     // TRANS: Submit button title in OpenX admin panel.
220                     _m('Save OpenX settings.'));
221     }
222 }