]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/designsettings.php
Merge branch '0.8.x' into userdesign
[quix0rs-gnu-social.git] / actions / designsettings.php
1 <?php
2 /**
3  * Laconica, the distributed open-source microblogging tool
4  *
5  * Change user password
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  Settings
23  * @package   Laconica
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/
28  */
29
30 if (!defined('LACONICA')) {
31     exit(1);
32 }
33
34 require_once INSTALLDIR.'/lib/accountsettingsaction.php';
35
36 class DesignsettingsAction extends AccountSettingsAction
37 {
38     /**
39      * Title of the page
40      *
41      * @return string Title of the page
42      */
43
44     function title()
45     {
46         return _('Profile design');
47     }
48
49     /**
50      * Instructions for use
51      *
52      * @return instructions for use
53      */
54
55     function getInstructions()
56     {
57         return _('Customize the way your profile looks with a background image and a colour palette of your choice.');
58     }
59
60     /**
61      * Content area of the page
62      *
63      * Shows a form for changing the password
64      *
65      * @return void
66      */
67
68     function showContent()
69     {
70         $user = common_current_user();
71         $this->elementStart('form', array('method' => 'post',
72                                           'id' => 'form_settings_design',
73                                           'class' => 'form_settings',
74                                           'action' =>
75                                           common_local_url('designsettings')));
76         $this->elementStart('fieldset');
77         $this->hidden('token', common_session_token());
78
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'), 
84                                 _('Upload file'));
85         $this->element('input', array('name' => 'design_background-image_file',
86                                       'type' => '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',
90                                       'type' => 'hidden',
91                                       'id' => 'MAX_FILE_SIZE',
92                                       'value' => ImageFile::maxFileSizeInt()));
93         $this->elementEnd('li');
94         $this->elementEnd('ul');
95         $this->elementEnd('fieldset');
96
97         $this->elementStart('fieldset', array('id' => 'settings_design_color'));
98         $this->element('legend', null, _('Change colours'));
99         $this->elementStart('ul', 'form_data');
100
101         $design = $user->getDesign();
102
103         if (empty($design)) {
104             $design = $this->defaultDesign();
105         }
106
107         $labelSwatch = array('Background',
108                              'Content',
109                              'Sidebar',
110                              'Text',
111                              'Links');
112
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] ?
118                                           'type' => 'text',
119                                           'id' => 'swatch-'.$s,
120                                           'class' => 'swatch',
121                                           'maxlength' => '7',
122                                           'size' => '7',
123                                           'value' => $foo[0]));
124             $this->elementEnd('li');
125             $s++;
126         }
127
128         $this->elementEnd('ul');
129         $this->elementEnd('fieldset');
130
131         $this->element('input', array('id' => 'settings_design_reset',
132                                       'type' => 'reset',
133                                       'value' => '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'));
137
138         /*TODO: Check submitted form values:
139          json_encode(form values)
140          if submitted Swatch == DefaultSwatch, don't store in DB.
141          else store in BD
142          */
143
144         $this->elementEnd('fieldset');
145         $this->elementEnd('form');
146     }
147
148     /**
149      * Handle a post
150      *
151      * Validate input and save changes. Reload the form with a success
152      * or error message.
153      *
154      * @return void
155      */
156
157     function handlePost()
158     {
159         // TODO: implement this
160         return;
161     }
162
163     /**
164      * Add the Farbtastic stylesheet
165      *
166      * @return void
167      */
168
169     function showStylesheets()
170     {
171         parent::showStylesheets();
172         $farbtasticStyle =
173           common_path('theme/base/css/farbtastic.css?version='.LACONICA_VERSION);
174
175         $this->element('link', array('rel' => 'stylesheet',
176                                      'type' => 'text/css',
177                                      'href' => $farbtasticStyle,
178                                      'media' => 'screen, projection, tv'));
179     }
180
181     /**
182      * Add the Farbtastic scripts
183      *
184      * @return void
185      */
186
187     function showScripts()
188     {
189         parent::showScripts();
190
191         $farbtasticPack = common_path('js/farbtastic/farbtastic.js');
192         $farbtasticGo   = common_path('js/farbtastic/farbtastic.go.js');
193
194         $this->element('script', array('type' => 'text/javascript',
195                                        'src' => $farbtasticPack));
196         $this->element('script', array('type' => 'text/javascript',
197                                        'src' => $farbtasticGo));
198     }
199 }