]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/designform.php
fix notices in dumpschema
[quix0rs-gnu-social.git] / lib / designform.php
1 <?php
2 /**
3  * StatusNet, the distributed open-source microblogging tool
4  *
5  * Form for choosing a design
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  Form
23  * @package   StatusNet
24  * @author    Evan Prodromou <evan@status.net>
25  * @author    Sarven Capadisli <csarven@status.net>
26  * @copyright 2009 StatusNet, Inc.
27  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
28  * @link      http://status.net/
29  */
30
31 if (!defined('STATUSNET') && !defined('LACONICA')) {
32     exit(1);
33 }
34
35 /**
36  * Form for choosing a design
37  *
38  * Used for choosing a site design, user design, or group design.
39  *
40  * @category Form
41  * @package  StatusNet
42  * @author   Evan Prodromou <evan@status.net>
43  * @author   Sarven Capadisli <csarven@status.net>
44  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
45  * @link     http://status.net/
46  *
47  */
48
49 class DesignForm extends Form
50 {
51     /**
52      * Return-to args
53      */
54
55     var $design     = null;
56     var $actionurl  = null;
57
58     /**
59      * Constructor
60      *
61      * @param HTMLOutputter $out       output channel
62      * @param Design        $design    initial design
63      * @param Design        $actionurl url of action (for form posting)
64      */
65
66     function __construct($out, $design, $actionurl)
67     {
68         parent::__construct($out);
69
70         $this->design     = $design;
71         $this->actionurl = $actionurl;
72     }
73
74     /**
75      * ID of the form
76      *
77      * @return int ID of the form
78      */
79
80     function id()
81     {
82         return 'design';
83     }
84
85     /**
86      * class of the form
87      *
88      * @return string class of the form
89      */
90
91     function formClass()
92     {
93         return 'form_design';
94     }
95
96     /**
97      * Action of the form
98      *
99      * @return string URL of the action
100      */
101
102     function action()
103     {
104         return $this->actionurl;
105     }
106
107     /**
108      * Legend of the Form
109      *
110      * @return void
111      */
112     function formLegend()
113     {
114         $this->out->element('legend', null, _('Change design'));
115     }
116
117     /**
118      * Data elements of the form
119      *
120      * @return void
121      */
122
123     function formData()
124     {
125         $this->out->elementStart('ul', 'form_data');
126         $this->out->elementStart('li');
127         $this->out->element('label', array('for' => 'design_background-image_file'),
128                             _('Upload file'));
129         $this->out->element('input', array('name' => 'design_background-image_file',
130                                            'type' => 'file',
131                                            'id' => 'design_background-image_file'));
132         $this->out->element('p', 'form_guide', _('You can upload your personal ' .
133                                                  'background image. The maximum file size is 2Mb.'));
134         $this->out->element('input', array('name' => 'MAX_FILE_SIZE',
135                                            'type' => 'hidden',
136                                            'id' => 'MAX_FILE_SIZE',
137                                            'value' => ImageFile::maxFileSizeInt()));
138         $this->out->elementEnd('li');
139
140         if (!empty($design->backgroundimage)) {
141
142             $this->out->elementStart('li', array('id' =>
143                                                  'design_background-image_onoff'));
144
145             $this->out->element('img', array('src' =>
146                                              Design::url($design->backgroundimage)));
147
148             $attrs = array('name' => 'design_background-image_onoff',
149                            'type' => 'radio',
150                            'id' => 'design_background-image_on',
151                            'class' => 'radio',
152                            'value' => 'on');
153
154             if ($design->disposition & BACKGROUND_ON) {
155                 $attrs['checked'] = 'checked';
156             }
157
158             $this->out->element('input', $attrs);
159
160             $this->out->element('label', array('for' => 'design_background-image_on',
161                                                'class' => 'radio'),
162                                 _('On'));
163
164             $attrs = array('name' => 'design_background-image_onoff',
165                            'type' => 'radio',
166                            'id' => 'design_background-image_off',
167                            'class' => 'radio',
168                            'value' => 'off');
169
170             if ($design->disposition & BACKGROUND_OFF) {
171                 $attrs['checked'] = 'checked';
172             }
173
174             $this->out->element('input', $attrs);
175
176             $this->out->element('label', array('for' => 'design_background-image_off',
177                                                'class' => 'radio'),
178                                 _('Off'));
179             $this->out->element('p', 'form_guide', _('Turn background image on or off.'));
180             $this->out->elementEnd('li');
181
182             $this->out->elementStart('li');
183             $this->out->checkbox('design_background-image_repeat',
184                                  _('Tile background image'),
185                                  ($design->disposition & BACKGROUND_TILE) ? true : false);
186             $this->out->elementEnd('li');
187         }
188
189         $this->out->elementEnd('ul');
190         $this->out->elementEnd('fieldset');
191
192         $this->out->elementStart('fieldset', array('id' => 'settings_design_color'));
193         $this->out->element('legend', null, _('Change colours'));
194         $this->out->elementStart('ul', 'form_data');
195
196         try {
197
198             $bgcolor = new WebColor($design->backgroundcolor);
199
200             $this->out->elementStart('li');
201             $this->out->element('label', array('for' => 'swatch-1'), _('Background'));
202             $this->out->element('input', array('name' => 'design_background',
203                                                'type' => 'text',
204                                                'id' => 'swatch-1',
205                                                'class' => 'swatch',
206                                                'maxlength' => '7',
207                                                'size' => '7',
208                                                'value' => ''));
209             $this->out->elementEnd('li');
210
211             $ccolor = new WebColor($design->contentcolor);
212
213             $this->out->elementStart('li');
214             $this->out->element('label', array('for' => 'swatch-2'), _('Content'));
215             $this->out->element('input', array('name' => 'design_content',
216                                                'type' => 'text',
217                                                'id' => 'swatch-2',
218                                                'class' => 'swatch',
219                                                'maxlength' => '7',
220                                                'size' => '7',
221                                                'value' => ''));
222             $this->out->elementEnd('li');
223
224             $sbcolor = new WebColor($design->sidebarcolor);
225
226             $this->out->elementStart('li');
227             $this->out->element('label', array('for' => 'swatch-3'), _('Sidebar'));
228             $this->out->element('input', array('name' => 'design_sidebar',
229                                                'type' => 'text',
230                                                'id' => 'swatch-3',
231                                                'class' => 'swatch',
232                                                'maxlength' => '7',
233                                                'size' => '7',
234                                                'value' => ''));
235             $this->out->elementEnd('li');
236
237             $tcolor = new WebColor($design->textcolor);
238
239             $this->out->elementStart('li');
240             $this->out->element('label', array('for' => 'swatch-4'), _('Text'));
241             $this->out->element('input', array('name' => 'design_text',
242                                                'type' => 'text',
243                                                'id' => 'swatch-4',
244                                                'class' => 'swatch',
245                                                'maxlength' => '7',
246                                                'size' => '7',
247                                                'value' => ''));
248             $this->out->elementEnd('li');
249
250             $lcolor = new WebColor($design->linkcolor);
251
252             $this->out->elementStart('li');
253             $this->out->element('label', array('for' => 'swatch-5'), _('Links'));
254             $this->out->element('input', array('name' => 'design_links',
255                                                'type' => 'text',
256                                                'id' => 'swatch-5',
257                                                'class' => 'swatch',
258                                                'maxlength' => '7',
259                                                'size' => '7',
260                                                'value' => ''));
261             $this->out->elementEnd('li');
262
263         } catch (WebColorException $e) {
264             common_log(LOG_ERR, 'Bad color values in design ID: ' .$design->id);
265         }
266
267         $this->out->elementEnd('ul');
268         $this->out->elementEnd('fieldset');
269
270         $this->out->elementStart('fieldset');
271
272         $this->out->submit('defaults', _('Use defaults'), 'submit form_action-default',
273                            'defaults', _('Restore default designs'));
274
275         $this->out->element('input', array('id' => 'settings_design_reset',
276                                            'type' => 'reset',
277                                            'value' => 'Reset',
278                                            'class' => 'submit form_action-primary',
279                                            'title' => _('Reset back to default')));
280     }
281
282     /**
283      * Action elements
284      *
285      * @return void
286      */
287
288     function formActions()
289     {
290         $this->out->submit('save', _('Save'), 'submit form_action-secondary',
291                            'save', _('Save design'));
292     }
293 }