X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Fdesignsettings.php;h=4955e9219954c2bf000124ae8f0f8911c512bca7;hb=bd74f05a665df73078134c37f059cc1797d1a0ea;hp=1b0e62166926ac7dbe60db6b5b1a8058fd862b68;hpb=f81dcbd5b71395d4b3b268f420e26f1a616816b5;p=quix0rs-gnu-social.git diff --git a/lib/designsettings.php b/lib/designsettings.php index 1b0e621669..4955e92199 100644 --- a/lib/designsettings.php +++ b/lib/designsettings.php @@ -1,6 +1,6 @@ . * * @category Settings - * @package Laconica - * @author Sarven Capadisli - * @author Zach Copley - * @copyright 2008-2009 Control Yourself, Inc. + * @package StatusNet + * @author Sarven Capadisli + * @author Zach Copley + * @copyright 2008-2009 StatusNet, Inc. * @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://status.net/ */ -if (!defined('LACONICA')) { +if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } @@ -42,11 +42,11 @@ require_once INSTALLDIR . '/lib/webcolor.php'; * background images, and fetching a default design * * @category Settings - * @package Laconica - * @author Zach Copley - * @author Sarven Capadisli + * @package StatusNet + * @author Zach Copley + * @author Sarven Capadisli * @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://status.net/ */ class DesignSettingsAction extends AccountSettingsAction @@ -107,7 +107,7 @@ class DesignSettingsAction extends AccountSettingsAction 'type' => 'file', 'id' => 'design_background-image_file')); $this->element('p', 'form_guide', _('You can upload your personal ' . - 'background image. The maximum file size is 2Mb.')); + 'background image. The maximum file size is 2MB.')); $this->element('input', array('name' => 'MAX_FILE_SIZE', 'type' => 'hidden', 'id' => 'MAX_FILE_SIZE', @@ -271,17 +271,20 @@ class DesignSettingsAction extends AccountSettingsAction function handlePost() { - // XXX: Robin's workaround for a bug in PHP where $_POST - // and $_FILE are empty in the case that the uploaded - // file is bigger than PHP is configured to handle. - if ($_SERVER['REQUEST_METHOD'] == 'POST') { - if (empty($_POST) && $_SERVER['CONTENT_LENGTH']) { + // Workaround for PHP returning empty $_POST and $_FILES when POST + // length > post_max_size in php.ini + + if (empty($_FILES) + && empty($_POST) + && ($_SERVER['CONTENT_LENGTH'] > 0) + ) { $msg = _('The server was unable to handle that much POST ' . 'data (%s bytes) due to its current configuration.'); $this->showForm(sprintf($msg, $_SERVER['CONTENT_LENGTH'])); + return; } } @@ -311,13 +314,7 @@ class DesignSettingsAction extends AccountSettingsAction function showStylesheets() { parent::showStylesheets(); - $farbtasticStyle = - common_path('theme/base/css/farbtastic.css?version='.LACONICA_VERSION); - - $this->element('link', array('rel' => 'stylesheet', - 'type' => 'text/css', - 'href' => $farbtasticStyle, - 'media' => 'screen, projection, tv')); + $this->cssLink('js/farbtastic/farbtastic.css',null,'screen, projection, tv'); } /** @@ -330,56 +327,10 @@ class DesignSettingsAction extends AccountSettingsAction { parent::showScripts(); - $farbtasticPack = common_path('js/farbtastic/farbtastic.js'); - $userDesignGo = common_path('js/userdesign.go.js'); - - $this->element('script', array('type' => 'text/javascript', - 'src' => $farbtasticPack)); - $this->element('script', array('type' => 'text/javascript', - 'src' => $userDesignGo)); - } - - /** - * Get a default design - * - * @return Design design - */ - - function defaultDesign() - { - $defaults = common_config('site', 'design'); - - $design = new Design(); - - try { - - $color = new WebColor(); + $this->script('farbtastic/farbtastic.js'); + $this->script('userdesign.go.js'); - $color->parseColor($defaults['backgroundcolor']); - $design->backgroundcolor = $color->intValue(); - - $color->parseColor($defaults['contentcolor']); - $design->contentcolor = $color->intValue(); - - $color->parseColor($defaults['sidebarcolor']); - $design->sidebarcolor = $color->intValue(); - - $color->parseColor($defaults['textcolor']); - $design->textcolor = $color->intValue(); - - $color->parseColor($defaults['linkcolor']); - $design->linkcolor = $color->intValue(); - - $design->backgroundimage = $defaults['backgroundimage']; - - $design->disposition = $defaults['disposition']; - - } catch (WebColorException $e) { - common_log(LOG_ERR, _('Bad default color settings: ' . - $e->getMessage())); - } - - return $design; + $this->autofocus('design_background-image_file'); } /** @@ -451,24 +402,17 @@ class DesignSettingsAction extends AccountSettingsAction function restoreDefaults() { - $design = $this->getWorkingDesign(); - $default = $this->defaultDesign(); - $original = clone($design); + $design = $this->getWorkingDesign(); - $design->backgroundcolor = $default->backgroundcolor; - $design->contentcolor = $default->contentcolor; - $design->sidebarcolor = $default->sidebarcolor; - $design->textcolor = $default->textcolor; - $design->linkcolor = $default->linkcolor; + if (!empty($design)) { - $design->setDisposition(false, true, false); + $result = $design->delete(); - $result = $design->update($original); - - if ($result === false) { - common_log_db_error($design, 'UPDATE', __FILE__); - $this->showForm(_('Couldn\'t update your design.')); - return; + if ($result === false) { + common_log_db_error($design, 'DELETE', __FILE__); + $this->showForm(_('Couldn\'t update your design.')); + return; + } } $this->showForm(_('Design defaults restored.'), true);