forked from GNUsocial/gnu-social
Reworked output for design settings page
This commit is contained in:
parent
d0eb2058a5
commit
946d016df2
@ -22,6 +22,7 @@
|
|||||||
* @category Settings
|
* @category Settings
|
||||||
* @package Laconica
|
* @package Laconica
|
||||||
* @author Sarven Capadisli <csarven@controlyourself.ca>
|
* @author Sarven Capadisli <csarven@controlyourself.ca>
|
||||||
|
* @author Zach Copley <zach@controlyourself.ca>
|
||||||
* @copyright 2008-2009 Control Yourself, Inc.
|
* @copyright 2008-2009 Control Yourself, Inc.
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
* @link http://laconi.ca/
|
* @link http://laconi.ca/
|
||||||
@ -104,42 +105,73 @@ class DesignsettingsAction extends AccountSettingsAction
|
|||||||
$design = $this->defaultDesign();
|
$design = $this->defaultDesign();
|
||||||
}
|
}
|
||||||
|
|
||||||
$labelSwatch = array('Background',
|
$this->elementStart('li');
|
||||||
'Content',
|
$this->element('label', array('for' => 'swatch-5'), _('Background'));
|
||||||
'Sidebar',
|
$this->element('input', array('name' => 'design_background',
|
||||||
'Text',
|
'type' => 'text',
|
||||||
'Links');
|
'id' => 'swatch-5',
|
||||||
|
'class' => 'swatch',
|
||||||
|
'maxlength' => '7',
|
||||||
|
'size' => '7',
|
||||||
|
'value' => $design->backgroundcolor));
|
||||||
|
$this->elementEnd('li');
|
||||||
|
|
||||||
foreach($userSwatch as $propertyvalue => $value) {
|
$this->elementStart('li');
|
||||||
$foo = array_values($value);
|
$this->element('label', array('for' => 'swatch-1'), _('Content'));
|
||||||
$this->elementStart('li');
|
$this->element('input', array('name' => 'design_content',
|
||||||
$this->element('label', array('for' => 'swatch-'.$s), _($labelSwatch[$s]));
|
'type' => 'text',
|
||||||
$this->element('input', array('name' => 'swatch-'.$s, //prefer swatch[$s] ?
|
'id' => 'swatch-1',
|
||||||
'type' => 'text',
|
'class' => 'swatch',
|
||||||
'id' => 'swatch-'.$s,
|
'maxlength' => '7',
|
||||||
'class' => 'swatch',
|
'size' => '7',
|
||||||
'maxlength' => '7',
|
'value' => $design->contentcolor));
|
||||||
'size' => '7',
|
$this->elementEnd('li');
|
||||||
'value' => $foo[0]));
|
|
||||||
$this->elementEnd('li');
|
|
||||||
$s++;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->elementEnd('ul');
|
$this->elementStart('li');
|
||||||
$this->elementEnd('fieldset');
|
$this->element('label', array('for' => 'swatch-2'), _('Sidebar'));
|
||||||
|
$this->element('input', array('name' => 'design_sidebar',
|
||||||
|
'type' => 'text',
|
||||||
|
'id' => 'swatch-2',
|
||||||
|
'class' => 'swatch',
|
||||||
|
'maxlength' => '7',
|
||||||
|
'size' => '7',
|
||||||
|
'value' => $design->sidebarcolor));
|
||||||
|
$this->elementEnd('li');
|
||||||
|
|
||||||
$this->element('input', array('id' => 'settings_design_reset',
|
$this->elementStart('li');
|
||||||
'type' => 'reset',
|
$this->element('label', array('for' => 'swatch-3'), _('Text'));
|
||||||
'value' => 'Reset',
|
$this->element('input', array('name' => 'design_text',
|
||||||
'class' => 'submit form_action-primary',
|
'type' => 'text',
|
||||||
'title' => _('Reset back to default')));
|
'id' => 'swatch-3',
|
||||||
$this->submit('save', _('Save'), 'submit form_action-secondary', 'save', _('Save design'));
|
'class' => 'swatch',
|
||||||
|
'maxlength' => '7',
|
||||||
|
'size' => '7',
|
||||||
|
'value' => $design->textcolor));
|
||||||
|
$this->elementEnd('li');
|
||||||
|
|
||||||
/*TODO: Check submitted form values:
|
$this->elementStart('li');
|
||||||
json_encode(form values)
|
$this->element('label', array('for' => 'swatch-4'), _('Links'));
|
||||||
if submitted Swatch == DefaultSwatch, don't store in DB.
|
$this->element('input', array('name' => 'design_links',
|
||||||
else store in BD
|
'type' => 'text',
|
||||||
*/
|
'id' => 'swatch-4',
|
||||||
|
'class' => 'swatch',
|
||||||
|
'maxlength' => '7',
|
||||||
|
'size' => '7',
|
||||||
|
'value' => $design->linkcolor));
|
||||||
|
|
||||||
|
$this->elementEnd('li');
|
||||||
|
|
||||||
|
$this->elementEnd('ul');
|
||||||
|
$this->elementEnd('fieldset');
|
||||||
|
|
||||||
|
$this->element('input', array('id' => 'settings_design_reset',
|
||||||
|
'type' => 'reset',
|
||||||
|
'value' => 'Reset',
|
||||||
|
'class' => 'submit form_action-primary',
|
||||||
|
'title' => _('Reset back to default')));
|
||||||
|
|
||||||
|
$this->submit('save', _('Save'), 'submit form_action-secondary',
|
||||||
|
'save', _('Save design'));
|
||||||
|
|
||||||
$this->elementEnd('fieldset');
|
$this->elementEnd('fieldset');
|
||||||
$this->elementEnd('form');
|
$this->elementEnd('form');
|
||||||
@ -156,8 +188,21 @@ class DesignsettingsAction extends AccountSettingsAction
|
|||||||
|
|
||||||
function handlePost()
|
function handlePost()
|
||||||
{
|
{
|
||||||
// TODO: implement this
|
// CSRF protection
|
||||||
return;
|
$token = $this->trimmed('token');
|
||||||
|
if (!$token || $token != common_session_token()) {
|
||||||
|
$this->showForm(_('There was a problem with your session token. '.
|
||||||
|
'Try again, please.'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->arg('save')) {
|
||||||
|
$this->saveDesign();
|
||||||
|
} else if ($this->arg('reset')) {
|
||||||
|
$this->resetDesign();
|
||||||
|
} else {
|
||||||
|
$this->showForm(_('Unexpected form submission.'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -196,4 +241,53 @@ class DesignsettingsAction extends AccountSettingsAction
|
|||||||
$this->element('script', array('type' => 'text/javascript',
|
$this->element('script', array('type' => 'text/javascript',
|
||||||
'src' => $farbtasticGo));
|
'src' => $farbtasticGo));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a default user design
|
||||||
|
*
|
||||||
|
* @return Design design
|
||||||
|
*/
|
||||||
|
|
||||||
|
function defaultDesign()
|
||||||
|
{
|
||||||
|
$defaults = common_config('site', 'design');
|
||||||
|
|
||||||
|
$design = new Design();
|
||||||
|
$design->backgroundcolor = $defaults['backgroundcolor'];
|
||||||
|
$design->contentcolor = $defaults['contentcolor'];
|
||||||
|
$design->sidebarcolor = $defaults['sidebarcolor'];
|
||||||
|
$design->textcolor = $defaults['textcolor'];
|
||||||
|
$design->linkcolor = $defaults['linkcolor'];
|
||||||
|
$design->backgroundimage = $defaults['backgroundimage'];
|
||||||
|
|
||||||
|
return $design;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save the user's design settings
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function saveDesign()
|
||||||
|
{
|
||||||
|
$user = common_current_user();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$this->showForm(_('Design preferences saved.'), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset design settings to previous saved value if any, or
|
||||||
|
* the defaults
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function resetDesign()
|
||||||
|
{
|
||||||
|
$this->showForm(_('Design preferences reset.'), true);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -72,6 +72,13 @@ $config =
|
|||||||
'server' => $_server,
|
'server' => $_server,
|
||||||
'theme' => 'default',
|
'theme' => 'default',
|
||||||
'skin' => 'default',
|
'skin' => 'default',
|
||||||
|
'design' =>
|
||||||
|
array('backgroundcolor' => '#F0F2F5',
|
||||||
|
'contentcolor' => '#FFFFFF',
|
||||||
|
'sidebarcolor' => '#CEE1E9',
|
||||||
|
'textcolor' => '#000000',
|
||||||
|
'linkcolor' => '#002E6E',
|
||||||
|
'backgroundimage' => null),
|
||||||
'path' => $_path,
|
'path' => $_path,
|
||||||
'logfile' => null,
|
'logfile' => null,
|
||||||
'logo' => null,
|
'logo' => null,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user