3 * StatusNet, the distributed open-source microblogging tool
5 * Form for choosing a design
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.
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.
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/>.
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/
31 if (!defined('STATUSNET') && !defined('LACONICA')) {
36 * Form for choosing a design
38 * Used for choosing a site design, user design, or group design.
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/
49 class DesignForm extends Form
56 var $actionurl = null;
61 * @param HTMLOutputter $out output channel
62 * @param Design $design initial design
63 * @param Design $actionurl url of action (for form posting)
66 function __construct($out, $design, $actionurl)
68 parent::__construct($out);
70 $this->design = $design;
71 $this->actionurl = $actionurl;
77 * @return int ID of the form
88 * @return string class of the form
99 * @return string URL of the action
104 return $this->actionurl;
112 function formLegend()
114 $this->out->element('legend', null, _('Change design'));
118 * Data elements of the form
125 $this->out->elementStart('ul', 'form_data');
126 $this->out->elementStart('li');
127 $this->out->element('label', array('for' => 'design_background-image_file'),
129 $this->out->element('input', array('name' => 'design_background-image_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',
136 'id' => 'MAX_FILE_SIZE',
137 'value' => ImageFile::maxFileSizeInt()));
138 $this->out->elementEnd('li');
140 if (!empty($design->backgroundimage)) {
142 $this->out->elementStart('li', array('id' =>
143 'design_background-image_onoff'));
145 $this->out->element('img', array('src' =>
146 Design::url($design->backgroundimage)));
148 $attrs = array('name' => 'design_background-image_onoff',
150 'id' => 'design_background-image_on',
154 if ($design->disposition & BACKGROUND_ON) {
155 $attrs['checked'] = 'checked';
158 $this->out->element('input', $attrs);
160 $this->out->element('label', array('for' => 'design_background-image_on',
164 $attrs = array('name' => 'design_background-image_onoff',
166 'id' => 'design_background-image_off',
170 if ($design->disposition & BACKGROUND_OFF) {
171 $attrs['checked'] = 'checked';
174 $this->out->element('input', $attrs);
176 $this->out->element('label', array('for' => 'design_background-image_off',
179 $this->out->element('p', 'form_guide', _('Turn background image on or off.'));
180 $this->out->elementEnd('li');
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');
189 $this->out->elementEnd('ul');
190 $this->out->elementEnd('fieldset');
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');
198 $bgcolor = new WebColor($design->backgroundcolor);
200 $this->out->elementStart('li');
201 $this->out->element('label', array('for' => 'swatch-1'), _('Background'));
202 $this->out->element('input', array('name' => 'design_background',
209 $this->out->elementEnd('li');
211 $ccolor = new WebColor($design->contentcolor);
213 $this->out->elementStart('li');
214 $this->out->element('label', array('for' => 'swatch-2'), _('Content'));
215 $this->out->element('input', array('name' => 'design_content',
222 $this->out->elementEnd('li');
224 $sbcolor = new WebColor($design->sidebarcolor);
226 $this->out->elementStart('li');
227 $this->out->element('label', array('for' => 'swatch-3'), _('Sidebar'));
228 $this->out->element('input', array('name' => 'design_sidebar',
235 $this->out->elementEnd('li');
237 $tcolor = new WebColor($design->textcolor);
239 $this->out->elementStart('li');
240 $this->out->element('label', array('for' => 'swatch-4'), _('Text'));
241 $this->out->element('input', array('name' => 'design_text',
248 $this->out->elementEnd('li');
250 $lcolor = new WebColor($design->linkcolor);
252 $this->out->elementStart('li');
253 $this->out->element('label', array('for' => 'swatch-5'), _('Links'));
254 $this->out->element('input', array('name' => 'design_links',
261 $this->out->elementEnd('li');
263 } catch (WebColorException $e) {
264 common_log(LOG_ERR, 'Bad color values in design ID: ' .$design->id);
267 $this->out->elementEnd('ul');
268 $this->out->elementEnd('fieldset');
270 $this->out->elementStart('fieldset');
272 $this->out->submit('defaults', _('Use defaults'), 'submit form_action-default',
273 'defaults', _('Restore default designs'));
275 $this->out->element('input', array('id' => 'settings_design_reset',
278 'class' => 'submit form_action-primary',
279 'title' => _('Reset back to default')));
288 function formActions()
290 $this->out->submit('save', _('Save'), 'submit form_action-secondary',
291 'save', _('Save design'));