From 19198aec8197891265e430c650f8e02fdd0d68d0 Mon Sep 17 00:00:00 2001 From: Jonathan Danse Date: Mon, 7 Jan 2013 11:11:28 +0100 Subject: [PATCH] [-] MO: coding standard --- modules/crossselling/crossselling.php | 37 +++++++++++++++++++-------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/modules/crossselling/crossselling.php b/modules/crossselling/crossselling.php index 1de6bb3ac..a6bf1eae1 100755 --- a/modules/crossselling/crossselling.php +++ b/modules/crossselling/crossselling.php @@ -1,6 +1,6 @@ -* @copyright 2007-2012 PrestaShop SA +* @copyright 2007-2013 PrestaShop SA * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA */ @@ -54,7 +54,8 @@ class CrossSelling extends Module !$this->registerHook('productFooter') OR !$this->registerHook('header') OR !$this->registerHook('shoppingCart') OR - !Configuration::updateValue('CROSSSELLING_DISPLAY_PRICE', 0)) + !Configuration::updateValue('CROSSSELLING_DISPLAY_PRICE', 0) OR + !Configuration::updateValue('CROSSSELLING_NBR', 10)) return false; return true; } @@ -65,7 +66,8 @@ class CrossSelling extends Module !$this->unregisterHook('productFooter') OR !$this->unregisterHook('header') OR !$this->unregisterHook('shoppingCart') OR - !Configuration::deleteByName('CROSSSELLING_DISPLAY_PRICE')) + !Configuration::deleteByName('CROSSSELLING_DISPLAY_PRICE') OR + !Configuration::deleteByName('CROSSSELLING_NBR')) return false; return true; } @@ -73,12 +75,21 @@ class CrossSelling extends Module public function getContent() { $this->_html = ''; - if (Tools::isSubmit('submitCross') AND Tools::getValue('displayPrice') != 0 AND Tools::getValue('displayPrice') != 1) - $this->_html .= $this->displayError('Invalid displayPrice'); - elseif (Tools::isSubmit('submitCross')) + + if (Tools::isSubmit('submitCross')) { - Configuration::updateValue('CROSSSELLING_DISPLAY_PRICE', (int)Tools::getValue('displayPrice')); - $this->_html .= $this->displayConfirmation($this->l('Settings updated successfully')); + if (Tools::getValue('displayPrice') != 0 AND Tools::getValue('displayPrice') != 1) + $this->_html .= $this->displayError('Invalid displayPrice'); + else if (!($productNbr = Tools::getValue('productNbr')) || empty($productNbr)) + $this->_html .= $this->displayError('You must fill in the \'Products displayed\' field.'); + elseif ((int)($productNbr) == 0) + $this->_html .= $this->displayError('Invalid number.'); + else + { + Configuration::updateValue('CROSSSELLING_DISPLAY_PRICE', (int)Tools::getValue('displayPrice')); + Configuration::updateValue('CROSSSELLING_NBR', (int)Tools::getValue('productNbr')); + $this->_html .= $this->displayConfirmation($this->l('Settings updated successfully')); + } } $this->_html .= '
@@ -90,6 +101,10 @@ class CrossSelling extends Module

'.$this->l('Show the price on the products in the block.').'

+ +
+ +

'.$this->l('Define the number of products displayed in this block').'

@@ -152,7 +167,7 @@ class CrossSelling extends Module AND i.cover = 1 AND product_shop.active = 1 ORDER BY RAND() - LIMIT 10 + LIMIT '.(int)Configuration::get('CROSSSELLING_NBR').' '); $taxCalc = Product::getTaxCalculationMethod(); @@ -206,7 +221,7 @@ class CrossSelling extends Module AND i.cover = 1 AND product_shop.active = 1 ORDER BY RAND() - LIMIT 10 + LIMIT '.(int)Configuration::get('CROSSSELLING_NBR').' '); $taxCalc = Product::getTaxCalculationMethod();