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 //This is a JSON object in the DB field. Here for testing. Remove later.
102 $userSwatch = '{"body":{"background-color":"#F0F2F5"},'.
103 '"#content":{"background-color":"#FFFFFF"},'.
104 '"#aside_primary":{"background-color":"#CEE1E9"},'.
105 '"html body":{"color":"#000000"},'.
106 '"a":{"color":"#002E6E"}}';
108 //Default theme swatch -- Where should this be stored?
109 $defaultSwatch = array('body' => array('background-color' => '#F0F2F5'),
110 '#content' => array('background-color' => '#FFFFFF'),
111 '#aside_primary' => array('background-color' => '#CEE1E9'),
112 'html body' => array('color' => '#000000'),
113 'a' => array('color' => '#002E6E'));
115 $userSwatch = ($userSwatch) ? json_decode($userSwatch, true) : $defaultSwatch;
118 $labelSwatch = array('Background',
123 foreach($userSwatch as $propertyvalue => $value) {
124 $foo = array_values($value);
125 $this->elementStart('li');
126 $this->element('label', array('for' => 'swatch-'.$s), _($labelSwatch[$s]));
127 $this->element('input', array('name' => 'swatch-'.$s, //prefer swatch[$s] ?
129 'id' => 'swatch-'.$s,
133 'value' => $foo[0]));
134 $this->elementEnd('li');
138 $this->elementEnd('ul');
139 $this->elementEnd('fieldset');
141 $this->element('input', array('id' => 'settings_design_reset',
144 'class' => 'submit form_action-primary',
145 'title' => _('Reset back to default')));
146 $this->submit('save', _('Save'), 'submit form_action-secondary', 'save', _('Save design'));
148 /*TODO: Check submitted form values:
149 json_encode(form values)
150 if submitted Swatch == DefaultSwatch, don't store in DB.
153 $this->elementEnd('fieldset');
154 $this->elementEnd('form');
160 * Validate input and save changes. Reload the form with a success
166 function handlePost()
168 // TODO: implement this
173 * Add the Farbtastic stylesheet
178 function showStylesheets()
180 parent::showStylesheets();
182 common_path('theme/base/css/farbtastic.css?version='.LACONICA_VERSION);
184 $this->element('link', array('rel' => 'stylesheet',
185 'type' => 'text/css',
186 'href' => $farbtasticStyle,
187 'media' => 'screen, projection, tv'));
191 * Add the Farbtastic scripts
196 function showScripts()
198 parent::showScripts();
200 $farbtasticPack = common_path('js/farbtastic/farbtastic.js');
201 $farbtasticGo = common_path('js/farbtastic/farbtastic.go.js');
203 $this->element('script', array('type' => 'text/javascript',
204 'src' => $farbtasticPack));
205 $this->element('script', array('type' => 'text/javascript',
206 'src' => $farbtasticGo));