From cbb1d81fa552f1faecdb1bd79fda6db6996298b9 Mon Sep 17 00:00:00 2001 From: rMalie Date: Mon, 5 Mar 2012 10:31:27 +0000 Subject: [PATCH] // Normalize git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@13834 b9a71923-0436-4b27-9f14-aed3839534dd --- modules/watermark/watermark.php | 65 ++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 30 deletions(-) diff --git a/modules/watermark/watermark.php b/modules/watermark/watermark.php index ce07b38d4..0d32b91a4 100644 --- a/modules/watermark/watermark.php +++ b/modules/watermark/watermark.php @@ -64,13 +64,13 @@ class Watermark extends Module $this->displayName = $this->l('Watermark'); $this->description = $this->l('Protect image by watermark.'); $this->confirmUninstall = $this->l('Are you sure you want to delete your details ?'); - if (!isset($this->transparency) OR !isset($this->xAlign) OR !isset($this->yAlign)) + if (!isset($this->transparency) || !isset($this->xAlign) || !isset($this->yAlign)) $this->warning = $this->l('Watermark image must be uploaded in order for this module to work correctly.'); } public function install() { - if (!parent::install() OR !$this->registerHook('watermark')) + if (!parent::install() || !$this->registerHook('watermark')) return false; Configuration::updateValue('WATERMARK_TRANSPARENCY', 60); Configuration::updateValue('WATERMARK_Y_ALIGN', 'bottom'); @@ -81,10 +81,10 @@ class Watermark extends Module public function uninstall() { return (parent::uninstall() - AND Configuration::deleteByName('WATERMARK_TYPES') - AND Configuration::deleteByName('WATERMARK_TRANSPARENCY') - AND Configuration::deleteByName('WATERMARK_Y_ALIGN') - AND Configuration::deleteByName('WATERMARK_X_ALIGN')); + && Configuration::deleteByName('WATERMARK_TYPES') + && Configuration::deleteByName('WATERMARK_TRANSPARENCY') + && Configuration::deleteByName('WATERMARK_Y_ALIGN') + && Configuration::deleteByName('WATERMARK_X_ALIGN')); } private function _postValidation() @@ -96,33 +96,32 @@ class Watermark extends Module if (empty($transparency)) $this->_postErrors[] = $this->l('Transparency required.'); - elseif($transparency < 0 || $transparency > 100) + elseif ($transparency < 0 || $transparency > 100) $this->_postErrors[] = $this->l('Transparency is not in allowed range.'); if (empty($yalign)) $this->_postErrors[] = $this->l('Y-Align is required.'); - elseif(!in_array($yalign, $this->yaligns)) + elseif (!in_array($yalign, $this->yaligns)) $this->_postErrors[] = $this->l('Y-Align is not in allowed range.'); if (empty($xalign)) $this->_postErrors[] = $this->l('X-Align is required.'); - elseif(!in_array($xalign, $this->xaligns)) + elseif (!in_array($xalign, $this->xaligns)) $this->_postErrors[] = $this->l('X-Align is not in allowed range.'); if (empty($image_types)) $this->_postErrors[] = $this->l('At least one image type is required.'); - if (isset($_FILES['PS_WATERMARK']['tmp_name']) AND !empty($_FILES['PS_WATERMARK']['tmp_name'])) + if (isset($_FILES['PS_WATERMARK']['tmp_name']) && !empty($_FILES['PS_WATERMARK']['tmp_name'])) { if (!ImageManager::isRealImage($_FILES['PS_WATERMARK']['tmp_name'], $_FILES['PS_WATERMARK']['type'], array('image/gif'))) $this->_postErrors[] = $this->l('Image must be in GIF format.'); } - return !sizeof($this->_postErrors) ? true : false; + return !count($this->_postErrors) ? true : false; } private function _postProcess() - { - + { Configuration::updateValue('WATERMARK_TYPES', implode(',', Tools::getValue('image_types'))); Configuration::updateValue('WATERMARK_Y_ALIGN', Tools::getValue('yalign')); Configuration::updateValue('WATERMARK_X_ALIGN', Tools::getValue('xalign')); @@ -139,11 +138,11 @@ class Watermark extends Module if ($error = ImageManager::validateUpload($_FILES['PS_WATERMARK'])) $this->_errors[] = $error; /* Copy new watermark */ - elseif(!copy($_FILES['PS_WATERMARK']['tmp_name'], dirname(__FILE__).'/watermark'.$str_shop.'.gif')) + elseif (!copy($_FILES['PS_WATERMARK']['tmp_name'], dirname(__FILE__).'/watermark'.$str_shop.'.gif')) $this->_errors[] = Tools::displayError('an error occurred while uploading watermark: '.$_FILES['PS_WATERMARK']['tmp_name'].' to '.$dest); } - if($this->_errors) + if ($this->_errors) foreach ($this->_errors as $error) $this->_html .= '
'.$this->l('ok').' '.$this->l($error).'
'; else @@ -180,7 +179,7 @@ class Watermark extends Module '.$this->l('Watermark X align').' @@ -188,14 +187,14 @@ class Watermark extends Module '.$this->l('Watermark Y align').' '.$this->l('Choose image types for watermark protection.').''; $selected_types = explode(',', Configuration::get('WATERMARK_TYPES')); - foreach(ImageType::getImagesTypes('products') as $type) + foreach (ImageType::getImagesTypes('products') as $type) { $this->_html .= '