]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/designform.php
Only unbind privacy checkbox when actually on mobile profile, oops.
[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 class DesignForm extends Form
49 {
50     /**
51      * Return-to args
52      */
53
54     var $design     = null;
55     var $actionurl  = null;
56
57     /**
58      * Constructor
59      *
60      * @param HTMLOutputter $out       output channel
61      * @param Design        $design    initial design
62      * @param Design        $actionurl url of action (for form posting)
63      */
64     function __construct($out, $design, $actionurl)
65     {
66         parent::__construct($out);
67
68         $this->design     = $design;
69         $this->actionurl = $actionurl;
70     }
71
72     /**
73      * ID of the form
74      *
75      * @return int ID of the form
76      */
77     function id()
78     {
79         return 'design';
80     }
81
82     /**
83      * class of the form
84      *
85      * @return string class of the form
86      */
87     function formClass()
88     {
89         return 'form_design';
90     }
91
92     /**
93      * Action of the form
94      *
95      * @return string URL of the action
96      */
97     function action()
98     {
99         return $this->actionurl;
100     }
101
102     /**
103      * Legend of the Form
104      *
105      * @return void
106      */
107     function formLegend()
108     {
109         // TRANS: Form legend of form for changing the page design.
110         $this->out->element('legend', null, _('Change design'));
111     }
112
113     /**
114      * Data elements of the form
115      *
116      * @return void
117      */
118     function formData()
119     {
120         $this->backgroundData();
121
122         $this->out->elementEnd('fieldset');
123
124         $this->out->elementStart('fieldset', array('id' => 'settings_design_color'));
125         // TRANS: Fieldset legend on profile design page to change profile page colours.
126         $this->out->element('legend', null, _('Change colours'));
127         $this->colourData();
128         $this->out->elementEnd('fieldset');
129
130         $this->out->elementStart('fieldset');
131
132         // TRANS: Button text on profile design page to immediately reset all colour settings to default.
133         $this->out->submit('defaults', _('Use defaults'), 'submit form_action-default',
134                            // TRANS: Title for button on profile design page to reset all colour settings to default.
135                            'defaults', _('Restore default designs.'));
136
137         $this->out->element('input', array('id' => 'settings_design_reset',
138                                            'type' => 'reset',
139                                            // TRANS: Button text on profile design page to reset all colour settings to default without saving.
140                                            'value' => _m('BUTTON', 'Reset'),
141                                            'class' => 'submit form_action-primary',
142                                            // TRANS: Title for button on profile design page to reset all colour settings to default without saving.
143                                            'title' => _('Reset back to default.')));
144     }
145
146     function backgroundData()
147     {
148         $this->out->elementStart('ul', 'form_data');
149         $this->out->elementStart('li');
150         $this->out->element('label', array('for' => 'design_background-image_file'),
151                             // TRANS: Label in form on profile design page.
152                             // TRANS: Field contains file name on user's computer that could be that user's custom profile background image.
153                             _('Upload file'));
154         $this->out->element('input', array('name' => 'design_background-image_file',
155                                            'type' => 'file',
156                                            'id' => 'design_background-image_file'));
157         // TRANS: Instructions for form on profile design page.
158         $this->out->element('p', 'form_guide', _('You can upload your personal ' .
159                                                  'background image. The maximum file size is 2MB.'));
160         $this->out->element('input', array('name' => 'MAX_FILE_SIZE',
161                                            'type' => 'hidden',
162                                            'id' => 'MAX_FILE_SIZE',
163                                            'value' => ImageFile::maxFileSizeInt()));
164         $this->out->elementEnd('li');
165
166         if (!empty($this->design->backgroundimage)) {
167
168             $this->out->elementStart('li', array('id' =>
169                                                  'design_background-image_onoff'));
170
171             $this->out->element('img', array('src' =>
172                                              Design::url($this->design->backgroundimage)));
173
174             $attrs = array('name' => 'design_background-image_onoff',
175                            'type' => 'radio',
176                            'id' => 'design_background-image_on',
177                            'class' => 'radio',
178                            'value' => 'on');
179
180             if ($this->design->disposition & BACKGROUND_ON) {
181                 $attrs['checked'] = 'checked';
182             }
183
184             $this->out->element('input', $attrs);
185
186             $this->out->element('label', array('for' => 'design_background-image_on',
187                                                'class' => 'radio'),
188                                 // TRANS: Radio button on profile design page that will enable use of the uploaded profile image.
189                                 _m('RADIO', 'On'));
190
191             $attrs = array('name' => 'design_background-image_onoff',
192                            'type' => 'radio',
193                            'id' => 'design_background-image_off',
194                            'class' => 'radio',
195                            'value' => 'off');
196
197             if ($this->design->disposition & BACKGROUND_OFF) {
198                 $attrs['checked'] = 'checked';
199             }
200
201             $this->out->element('input', $attrs);
202
203             $this->out->element('label', array('for' => 'design_background-image_off',
204                                                'class' => 'radio'),
205                                 // TRANS: Radio button on profile design page that will disable use of the uploaded profile image.
206                                 _m('RADIO', 'Off'));
207             // TRANS: Form guide for a set of radio buttons on the profile design page that will enable or disable
208             // TRANS: use of the uploaded profile image.
209             $this->out->element('p', 'form_guide', _('Turn background image on or off.'));
210             $this->out->elementEnd('li');
211
212             $this->out->elementStart('li');
213             $this->out->checkbox('design_background-image_repeat',
214                                  // TRANS: Checkbox label on profile design page that will cause the profile image to be tiled.
215                                  _('Tile background image'),
216                                  ($this->design->disposition & BACKGROUND_TILE) ? true : false);
217             $this->out->elementEnd('li');
218         }
219
220         $this->out->elementEnd('ul');
221     }
222
223     function colourData()
224     {
225         $this->out->elementStart('ul', 'form_data');
226
227         try {
228
229             $bgcolor = new WebColor($this->design->backgroundcolor);
230
231             $this->out->elementStart('li');
232             // TRANS: Label on profile design page for setting a profile page background colour.
233             $this->out->element('label', array('for' => 'swatch-1'), _('Background'));
234             $this->out->element('input', array('name' => 'design_background',
235                                                'type' => 'text',
236                                                'id' => 'swatch-1',
237                                                'class' => 'swatch',
238                                                'maxlength' => '7',
239                                                'size' => '7',
240                                                'value' => ''));
241             $this->out->elementEnd('li');
242
243             $ccolor = new WebColor($this->design->contentcolor);
244
245             $this->out->elementStart('li');
246             // TRANS: Label on profile design page for setting a profile page content colour.
247             $this->out->element('label', array('for' => 'swatch-2'), _('Content'));
248             $this->out->element('input', array('name' => 'design_content',
249                                                'type' => 'text',
250                                                'id' => 'swatch-2',
251                                                'class' => 'swatch',
252                                                'maxlength' => '7',
253                                                'size' => '7',
254                                                'value' => ''));
255             $this->out->elementEnd('li');
256
257             $sbcolor = new WebColor($this->design->sidebarcolor);
258
259             $this->out->elementStart('li');
260             // TRANS: Label on profile design page for setting a profile page sidebar colour.
261             $this->out->element('label', array('for' => 'swatch-3'), _('Sidebar'));
262             $this->out->element('input', array('name' => 'design_sidebar',
263                                                'type' => 'text',
264                                                'id' => 'swatch-3',
265                                                'class' => 'swatch',
266                                                'maxlength' => '7',
267                                                'size' => '7',
268                                                'value' => ''));
269             $this->out->elementEnd('li');
270
271             $tcolor = new WebColor($this->design->textcolor);
272
273             $this->out->elementStart('li');
274             // TRANS: Label on profile design page for setting a profile page text colour.
275             $this->out->element('label', array('for' => 'swatch-4'), _('Text'));
276             $this->out->element('input', array('name' => 'design_text',
277                                                'type' => 'text',
278                                                'id' => 'swatch-4',
279                                                'class' => 'swatch',
280                                                'maxlength' => '7',
281                                                'size' => '7',
282                                                'value' => ''));
283             $this->out->elementEnd('li');
284
285             $lcolor = new WebColor($this->design->linkcolor);
286
287             $this->out->elementStart('li');
288             // TRANS: Label on profile design page for setting a profile page links colour.
289             $this->out->element('label', array('for' => 'swatch-5'), _('Links'));
290             $this->out->element('input', array('name' => 'design_links',
291                                                'type' => 'text',
292                                                'id' => 'swatch-5',
293                                                'class' => 'swatch',
294                                                'maxlength' => '7',
295                                                'size' => '7',
296                                                'value' => ''));
297             $this->out->elementEnd('li');
298
299         } catch (WebColorException $e) {
300             common_log(LOG_ERR, 'Bad color values in design ID: ' .$this->design->id);
301         }
302
303         $this->out->elementEnd('ul');
304     }
305
306     /**
307      * Action elements
308      *
309      * @return void
310      */
311
312     function formActions()
313     {
314         // TRANS: Button text on profile design page to save settings.
315         $this->out->submit('save', _m('BUTTON','Save'), 'submit form_action-secondary',
316                            // TRANS: Title for button on profile design page to save settings.
317                            'save', _('Save design.'));
318     }
319 }