2010-06-01 00:49:14 +09:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* StatusNet, the distributed open-source microblogging tool
|
|
|
|
*
|
|
|
|
* Form for choosing a design
|
|
|
|
*
|
|
|
|
* PHP version 5
|
|
|
|
*
|
|
|
|
* LICENCE: This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* @category Form
|
|
|
|
* @package StatusNet
|
|
|
|
* @author Evan Prodromou <evan@status.net>
|
|
|
|
* @author Sarven Capadisli <csarven@status.net>
|
|
|
|
* @copyright 2009 StatusNet, Inc.
|
|
|
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
|
|
|
* @link http://status.net/
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Form for choosing a design
|
|
|
|
*
|
|
|
|
* Used for choosing a site design, user design, or group design.
|
|
|
|
*
|
|
|
|
* @category Form
|
|
|
|
* @package StatusNet
|
|
|
|
* @author Evan Prodromou <evan@status.net>
|
|
|
|
* @author Sarven Capadisli <csarven@status.net>
|
|
|
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
|
|
|
* @link http://status.net/
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
class DesignForm extends Form
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Return-to args
|
|
|
|
*/
|
|
|
|
|
|
|
|
var $design = null;
|
|
|
|
var $actionurl = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*
|
|
|
|
* @param HTMLOutputter $out output channel
|
|
|
|
* @param Design $design initial design
|
|
|
|
* @param Design $actionurl url of action (for form posting)
|
|
|
|
*/
|
|
|
|
function __construct($out, $design, $actionurl)
|
|
|
|
{
|
|
|
|
parent::__construct($out);
|
|
|
|
|
|
|
|
$this->design = $design;
|
|
|
|
$this->actionurl = $actionurl;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ID of the form
|
|
|
|
*
|
|
|
|
* @return int ID of the form
|
|
|
|
*/
|
|
|
|
function id()
|
|
|
|
{
|
|
|
|
return 'design';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* class of the form
|
|
|
|
*
|
|
|
|
* @return string class of the form
|
|
|
|
*/
|
|
|
|
function formClass()
|
|
|
|
{
|
|
|
|
return 'form_design';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Action of the form
|
|
|
|
*
|
|
|
|
* @return string URL of the action
|
|
|
|
*/
|
|
|
|
function action()
|
|
|
|
{
|
|
|
|
return $this->actionurl;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Legend of the Form
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function formLegend()
|
|
|
|
{
|
2011-04-02 02:46:40 +09:00
|
|
|
// TRANS: Form legend of form for changing the page design.
|
2010-06-01 00:49:14 +09:00
|
|
|
$this->out->element('legend', null, _('Change design'));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Data elements of the form
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function formData()
|
2010-06-01 01:04:29 +09:00
|
|
|
{
|
|
|
|
$this->backgroundData();
|
|
|
|
|
|
|
|
$this->out->elementEnd('fieldset');
|
|
|
|
|
|
|
|
$this->out->elementStart('fieldset', array('id' => 'settings_design_color'));
|
2010-12-08 03:50:05 +09:00
|
|
|
// TRANS: Fieldset legend on profile design page to change profile page colours.
|
2010-06-01 01:04:29 +09:00
|
|
|
$this->out->element('legend', null, _('Change colours'));
|
|
|
|
$this->colourData();
|
|
|
|
$this->out->elementEnd('fieldset');
|
|
|
|
|
|
|
|
$this->out->elementStart('fieldset');
|
|
|
|
|
2010-12-08 03:50:05 +09:00
|
|
|
// TRANS: Button text on profile design page to immediately reset all colour settings to default.
|
2010-06-01 01:04:29 +09:00
|
|
|
$this->out->submit('defaults', _('Use defaults'), 'submit form_action-default',
|
2010-12-08 03:50:05 +09:00
|
|
|
// TRANS: Title for button on profile design page to reset all colour settings to default.
|
2011-04-02 02:46:40 +09:00
|
|
|
'defaults', _('Restore default designs.'));
|
2010-06-01 01:04:29 +09:00
|
|
|
|
|
|
|
$this->out->element('input', array('id' => 'settings_design_reset',
|
|
|
|
'type' => 'reset',
|
2010-12-08 03:50:05 +09:00
|
|
|
// TRANS: Button text on profile design page to reset all colour settings to default without saving.
|
|
|
|
'value' => _m('BUTTON', 'Reset'),
|
2010-06-01 01:04:29 +09:00
|
|
|
'class' => 'submit form_action-primary',
|
2010-12-08 03:50:05 +09:00
|
|
|
// TRANS: Title for button on profile design page to reset all colour settings to default without saving.
|
2011-04-02 02:46:40 +09:00
|
|
|
'title' => _('Reset back to default.')));
|
2010-06-01 01:04:29 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
function backgroundData()
|
2010-06-01 00:49:14 +09:00
|
|
|
{
|
|
|
|
$this->out->elementStart('ul', 'form_data');
|
|
|
|
$this->out->elementStart('li');
|
|
|
|
$this->out->element('label', array('for' => 'design_background-image_file'),
|
2010-12-08 03:50:05 +09:00
|
|
|
// TRANS: Label in form on profile design page.
|
|
|
|
// TRANS: Field contains file name on user's computer that could be that user's custom profile background image.
|
2010-06-01 00:49:14 +09:00
|
|
|
_('Upload file'));
|
|
|
|
$this->out->element('input', array('name' => 'design_background-image_file',
|
|
|
|
'type' => 'file',
|
|
|
|
'id' => 'design_background-image_file'));
|
2010-12-08 03:50:05 +09:00
|
|
|
// TRANS: Instructions for form on profile design page.
|
2010-06-01 00:49:14 +09:00
|
|
|
$this->out->element('p', 'form_guide', _('You can upload your personal ' .
|
2011-04-02 02:46:40 +09:00
|
|
|
'background image. The maximum file size is 2MB.'));
|
2010-06-01 00:49:14 +09:00
|
|
|
$this->out->element('input', array('name' => 'MAX_FILE_SIZE',
|
|
|
|
'type' => 'hidden',
|
|
|
|
'id' => 'MAX_FILE_SIZE',
|
|
|
|
'value' => ImageFile::maxFileSizeInt()));
|
|
|
|
$this->out->elementEnd('li');
|
|
|
|
|
2010-09-12 05:16:38 +09:00
|
|
|
if (!empty($this->design->backgroundimage)) {
|
2010-06-01 00:49:14 +09:00
|
|
|
|
|
|
|
$this->out->elementStart('li', array('id' =>
|
|
|
|
'design_background-image_onoff'));
|
|
|
|
|
|
|
|
$this->out->element('img', array('src' =>
|
2010-09-12 05:16:38 +09:00
|
|
|
Design::url($this->design->backgroundimage)));
|
2010-06-01 00:49:14 +09:00
|
|
|
|
|
|
|
$attrs = array('name' => 'design_background-image_onoff',
|
|
|
|
'type' => 'radio',
|
|
|
|
'id' => 'design_background-image_on',
|
|
|
|
'class' => 'radio',
|
|
|
|
'value' => 'on');
|
|
|
|
|
2010-09-12 05:16:38 +09:00
|
|
|
if ($this->design->disposition & BACKGROUND_ON) {
|
2010-06-01 00:49:14 +09:00
|
|
|
$attrs['checked'] = 'checked';
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->out->element('input', $attrs);
|
|
|
|
|
|
|
|
$this->out->element('label', array('for' => 'design_background-image_on',
|
|
|
|
'class' => 'radio'),
|
2010-12-08 03:50:05 +09:00
|
|
|
// TRANS: Radio button on profile design page that will enable use of the uploaded profile image.
|
|
|
|
_m('RADIO', 'On'));
|
2010-06-01 00:49:14 +09:00
|
|
|
|
|
|
|
$attrs = array('name' => 'design_background-image_onoff',
|
|
|
|
'type' => 'radio',
|
|
|
|
'id' => 'design_background-image_off',
|
|
|
|
'class' => 'radio',
|
|
|
|
'value' => 'off');
|
|
|
|
|
2010-09-12 05:16:38 +09:00
|
|
|
if ($this->design->disposition & BACKGROUND_OFF) {
|
2010-06-01 00:49:14 +09:00
|
|
|
$attrs['checked'] = 'checked';
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->out->element('input', $attrs);
|
|
|
|
|
|
|
|
$this->out->element('label', array('for' => 'design_background-image_off',
|
|
|
|
'class' => 'radio'),
|
2010-12-08 03:50:05 +09:00
|
|
|
// TRANS: Radio button on profile design page that will disable use of the uploaded profile image.
|
|
|
|
_m('RADIO', 'Off'));
|
|
|
|
// TRANS: Form guide for a set of radio buttons on the profile design page that will enable or disable
|
|
|
|
// TRANS: use of the uploaded profile image.
|
2010-06-01 00:49:14 +09:00
|
|
|
$this->out->element('p', 'form_guide', _('Turn background image on or off.'));
|
|
|
|
$this->out->elementEnd('li');
|
|
|
|
|
|
|
|
$this->out->elementStart('li');
|
|
|
|
$this->out->checkbox('design_background-image_repeat',
|
2010-12-08 03:50:05 +09:00
|
|
|
// TRANS: Checkbox label on profile design page that will cause the profile image to be tiled.
|
2010-06-01 00:49:14 +09:00
|
|
|
_('Tile background image'),
|
2010-09-12 05:16:38 +09:00
|
|
|
($this->design->disposition & BACKGROUND_TILE) ? true : false);
|
2010-06-01 00:49:14 +09:00
|
|
|
$this->out->elementEnd('li');
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->out->elementEnd('ul');
|
2010-06-01 01:04:29 +09:00
|
|
|
}
|
2010-06-01 00:49:14 +09:00
|
|
|
|
2010-06-01 01:04:29 +09:00
|
|
|
function colourData()
|
|
|
|
{
|
2010-06-01 00:49:14 +09:00
|
|
|
$this->out->elementStart('ul', 'form_data');
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
2010-09-12 05:16:38 +09:00
|
|
|
$bgcolor = new WebColor($this->design->backgroundcolor);
|
2010-06-01 00:49:14 +09:00
|
|
|
|
|
|
|
$this->out->elementStart('li');
|
2010-12-08 03:50:05 +09:00
|
|
|
// TRANS: Label on profile design page for setting a profile page background colour.
|
2010-06-01 00:49:14 +09:00
|
|
|
$this->out->element('label', array('for' => 'swatch-1'), _('Background'));
|
|
|
|
$this->out->element('input', array('name' => 'design_background',
|
|
|
|
'type' => 'text',
|
|
|
|
'id' => 'swatch-1',
|
|
|
|
'class' => 'swatch',
|
|
|
|
'maxlength' => '7',
|
|
|
|
'size' => '7',
|
|
|
|
'value' => ''));
|
|
|
|
$this->out->elementEnd('li');
|
|
|
|
|
2010-09-12 05:16:38 +09:00
|
|
|
$ccolor = new WebColor($this->design->contentcolor);
|
2010-06-01 00:49:14 +09:00
|
|
|
|
|
|
|
$this->out->elementStart('li');
|
2010-12-08 03:50:05 +09:00
|
|
|
// TRANS: Label on profile design page for setting a profile page content colour.
|
2010-06-01 00:49:14 +09:00
|
|
|
$this->out->element('label', array('for' => 'swatch-2'), _('Content'));
|
|
|
|
$this->out->element('input', array('name' => 'design_content',
|
|
|
|
'type' => 'text',
|
|
|
|
'id' => 'swatch-2',
|
|
|
|
'class' => 'swatch',
|
|
|
|
'maxlength' => '7',
|
|
|
|
'size' => '7',
|
|
|
|
'value' => ''));
|
|
|
|
$this->out->elementEnd('li');
|
|
|
|
|
2010-09-12 05:16:38 +09:00
|
|
|
$sbcolor = new WebColor($this->design->sidebarcolor);
|
2010-06-01 00:49:14 +09:00
|
|
|
|
|
|
|
$this->out->elementStart('li');
|
2010-12-08 03:50:05 +09:00
|
|
|
// TRANS: Label on profile design page for setting a profile page sidebar colour.
|
2010-06-01 00:49:14 +09:00
|
|
|
$this->out->element('label', array('for' => 'swatch-3'), _('Sidebar'));
|
|
|
|
$this->out->element('input', array('name' => 'design_sidebar',
|
|
|
|
'type' => 'text',
|
|
|
|
'id' => 'swatch-3',
|
|
|
|
'class' => 'swatch',
|
|
|
|
'maxlength' => '7',
|
|
|
|
'size' => '7',
|
|
|
|
'value' => ''));
|
|
|
|
$this->out->elementEnd('li');
|
|
|
|
|
2010-09-12 05:16:38 +09:00
|
|
|
$tcolor = new WebColor($this->design->textcolor);
|
2010-06-01 00:49:14 +09:00
|
|
|
|
|
|
|
$this->out->elementStart('li');
|
2010-12-08 03:50:05 +09:00
|
|
|
// TRANS: Label on profile design page for setting a profile page text colour.
|
2010-06-01 00:49:14 +09:00
|
|
|
$this->out->element('label', array('for' => 'swatch-4'), _('Text'));
|
|
|
|
$this->out->element('input', array('name' => 'design_text',
|
|
|
|
'type' => 'text',
|
|
|
|
'id' => 'swatch-4',
|
|
|
|
'class' => 'swatch',
|
|
|
|
'maxlength' => '7',
|
|
|
|
'size' => '7',
|
|
|
|
'value' => ''));
|
|
|
|
$this->out->elementEnd('li');
|
|
|
|
|
2010-09-12 05:16:38 +09:00
|
|
|
$lcolor = new WebColor($this->design->linkcolor);
|
2010-06-01 00:49:14 +09:00
|
|
|
|
|
|
|
$this->out->elementStart('li');
|
2010-12-08 03:50:05 +09:00
|
|
|
// TRANS: Label on profile design page for setting a profile page links colour.
|
2010-06-01 00:49:14 +09:00
|
|
|
$this->out->element('label', array('for' => 'swatch-5'), _('Links'));
|
|
|
|
$this->out->element('input', array('name' => 'design_links',
|
|
|
|
'type' => 'text',
|
|
|
|
'id' => 'swatch-5',
|
|
|
|
'class' => 'swatch',
|
|
|
|
'maxlength' => '7',
|
|
|
|
'size' => '7',
|
|
|
|
'value' => ''));
|
|
|
|
$this->out->elementEnd('li');
|
|
|
|
|
|
|
|
} catch (WebColorException $e) {
|
2010-09-12 05:16:38 +09:00
|
|
|
common_log(LOG_ERR, 'Bad color values in design ID: ' .$this->design->id);
|
2010-06-01 00:49:14 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
$this->out->elementEnd('ul');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Action elements
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
|
|
|
|
function formActions()
|
|
|
|
{
|
2010-12-08 03:50:05 +09:00
|
|
|
// TRANS: Button text on profile design page to save settings.
|
|
|
|
$this->out->submit('save', _m('BUTTON','Save'), 'submit form_action-secondary',
|
|
|
|
// TRANS: Title for button on profile design page to save settings.
|
2011-04-02 02:46:40 +09:00
|
|
|
'save', _('Save design.'));
|
2010-06-01 00:49:14 +09:00
|
|
|
}
|
|
|
|
}
|