3 * Laconica, the distributed open-source microblogging tool
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 Sarven Capadisli <csarven@controlyourself.ca>
25 * @copyright 2008-2009 Control Yourself, Inc.
26 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
27 * @link http://laconi.ca/
30 if (!defined('LACONICA')) {
34 require_once INSTALLDIR.'/lib/accountsettingsaction.php';
36 class DesignsettingsAction extends AccountSettingsAction
41 * @return string Title of the page
46 return _('Profile design');
50 * Instructions for use
52 * @return instructions for use
55 function getInstructions()
57 return _('Customize the way your profile looks with a background image and a colour palette of your choice.');
61 * Content area of the page
63 * Shows a form for changing the password
68 function showContent()
70 $user = common_current_user();
71 $this->elementStart('form', array('method' => 'POST',
72 'id' => 'form_settings_design',
73 'class' => 'form_settings',
75 common_local_url('designsettings')));
76 $this->elementStart('fieldset');
77 $this->hidden('token', common_session_token());
79 $this->elementStart('fieldset', array('id' => 'settings_design_background-image'));
80 $this->element('legend', null, _('Change background image'));
81 $this->elementStart('ul', 'form_data');
82 $this->elementStart('li');
83 $this->element('label', array('for' => 'design_ background-image_file'),
85 $this->element('input', array('name' => 'design_background-image_file',
87 'id' => 'design_background-image_file'));
88 $this->element('p', 'form_guide', _('You can upload your personal background image. The maximum file size is 2Mb.'));
89 $this->element('input', array('name' => 'MAX_FILE_SIZE',
91 'id' => 'MAX_FILE_SIZE',
92 'value' => ImageFile::maxFileSizeInt()));
93 $this->elementEnd('li');
94 $this->elementEnd('ul');
95 $this->elementEnd('fieldset');
97 $this->elementStart('fieldset', array('id' => 'settings_design_color'));
98 $this->element('legend', null, _('Change colours'));
99 $this->elementStart('ul', 'form_data');
101 $design = $user->getDesign();
103 if (empty($design)) {
104 $design = $this->defaultDesign();
107 $labelSwatch = array('Background',
113 foreach($userSwatch as $propertyvalue => $value) {
114 $foo = array_values($value);
115 $this->elementStart('li');
116 $this->element('label', array('for' => 'swatch-'.$s), _($labelSwatch[$s]));
117 $this->element('input', array('name' => 'swatch-'.$s, //prefer swatch[$s] ?
119 'id' => 'swatch-'.$s,
123 'value' => $foo[0]));
124 $this->elementEnd('li');
128 $this->elementEnd('ul');
129 $this->elementEnd('fieldset');
131 $this->element('input', array('id' => 'settings_design_reset',
134 'class' => 'submit form_action-primary',
135 'title' => _('Reset back to default')));
136 $this->submit('save', _('Save'), 'submit form_action-secondary', 'save', _('Save design'));
138 /*TODO: Check submitted form values:
139 json_encode(form values)
140 if submitted Swatch == DefaultSwatch, don't store in DB.
144 $this->elementEnd('fieldset');
145 $this->elementEnd('form');
151 * Validate input and save changes. Reload the form with a success
157 function handlePost()
159 // TODO: implement this
164 * Add the Farbtastic stylesheet
169 function showStylesheets()
171 parent::showStylesheets();
173 common_path('theme/base/css/farbtastic.css?version='.LACONICA_VERSION);
175 $this->element('link', array('rel' => 'stylesheet',
176 'type' => 'text/css',
177 'href' => $farbtasticStyle,
178 'media' => 'screen, projection, tv'));
182 * Add the Farbtastic scripts
187 function showScripts()
189 parent::showScripts();
191 $farbtasticPack = common_path('js/farbtastic/farbtastic.js');
192 $farbtasticGo = common_path('js/farbtastic/farbtastic.go.js');
194 $this->element('script', array('type' => 'text/javascript',
195 'src' => $farbtasticPack));
196 $this->element('script', array('type' => 'text/javascript',
197 'src' => $farbtasticGo));