From c280253f23269aba97a30af5da9b3ef809b3b87e Mon Sep 17 00:00:00 2001 From: rMalie Date: Thu, 26 Jan 2012 14:44:24 +0000 Subject: [PATCH] // Normalize --- modules/bankwire/bankwire.php | 34 ++++++------- modules/blockadvertising/blockadvertising.php | 14 +++--- modules/blockbestsellers/blockbestsellers.php | 24 ++++----- modules/blockcart/blockcart.php | 22 ++++---- modules/blockcategories/blockcategories.php | 50 +++++++++---------- 5 files changed, 68 insertions(+), 76 deletions(-) diff --git a/modules/bankwire/bankwire.php b/modules/bankwire/bankwire.php index c0947e00b..5a0a87d45 100644 --- a/modules/bankwire/bankwire.php +++ b/modules/bankwire/bankwire.php @@ -33,9 +33,9 @@ class BankWire extends PaymentModule private $_html = ''; private $_postErrors = array(); - public $details; - public $owner; - public $address; + public $details; + public $owner; + public $address; public function __construct() { @@ -60,15 +60,15 @@ class BankWire extends PaymentModule $this->displayName = $this->l('Bank Wire'); $this->description = $this->l('Accept payments by bank wire.'); $this->confirmUninstall = $this->l('Are you sure you want to delete your details?'); - if (!isset($this->owner) OR !isset($this->details) OR !isset($this->address)) + if (!isset($this->owner) || !isset($this->details) || !isset($this->address)) $this->warning = $this->l('Account owner and details must be configured in order to use this module correctly.'); - if (!sizeof(Currency::checkPaymentCurrencies($this->id))) + if (!count(Currency::checkPaymentCurrencies($this->id))) $this->warning = $this->l('No currency set for this module'); } public function install() { - if (!parent::install() OR !$this->registerHook('payment') OR !$this->registerHook('paymentReturn')) + if (!parent::install() || !$this->registerHook('payment') || !$this->registerHook('paymentReturn')) return false; return true; } @@ -76,9 +76,9 @@ class BankWire extends PaymentModule public function uninstall() { if (!Configuration::deleteByName('BANK_WIRE_DETAILS') - OR !Configuration::deleteByName('BANK_WIRE_OWNER') - OR !Configuration::deleteByName('BANK_WIRE_ADDRESS') - OR !parent::uninstall()) + || !Configuration::deleteByName('BANK_WIRE_OWNER') + || !Configuration::deleteByName('BANK_WIRE_ADDRESS') + || !parent::uninstall()) return false; return true; } @@ -147,11 +147,11 @@ class BankWire extends PaymentModule if (Tools::isSubmit('btnSubmit')) { $this->_postValidation(); - if (!sizeof($this->_postErrors)) + if (!count($this->_postErrors)) $this->_postProcess(); else - foreach ($this->_postErrors AS $err) - $this->_html .= '
'. $err .'
'; + foreach ($this->_postErrors as $err) + $this->_html .= '
'.$err.'
'; } else $this->_html .= '
'; @@ -172,7 +172,7 @@ class BankWire extends PaymentModule $cart = Context::getContext()->cart; if (!$this->active) - return ; + return; if (!$this->_checkCurrency($cart)) Tools::redirect('index.php?controller=order'); @@ -195,9 +195,9 @@ class BankWire extends PaymentModule public function hookPayment($params) { if (!$this->active) - return ; + return; if (!$this->checkCurrency($params['cart'])) - return ; + return; $this->smarty->assign(array( @@ -210,10 +210,10 @@ class BankWire extends PaymentModule public function hookPaymentReturn($params) { if (!$this->active) - return ; + return; $state = $params['objOrder']->getCurrentState(); - if ($state == Configuration::get('PS_OS_BANKWIRE') OR $state == Configuration::get('PS_OS_OUTOFSTOCK')) + if ($state == Configuration::get('PS_OS_BANKWIRE') || $state == Configuration::get('PS_OS_OUTOFSTOCK')) { $this->smarty->assign(array( 'total_to_pay' => Tools::displayPrice($params['total_to_pay'], $params['currencyObj'], false), diff --git a/modules/blockadvertising/blockadvertising.php b/modules/blockadvertising/blockadvertising.php index b98033a35..f85ac8a5f 100644 --- a/modules/blockadvertising/blockadvertising.php +++ b/modules/blockadvertising/blockadvertising.php @@ -92,7 +92,7 @@ class BlockAdvertising extends Module if (!file_exists(_PS_MODULE_DIR_.$this->name.'/advertising.jpg')) $this->adv_imgname = ''; else - Configuration::updateValue('BLOCKADVERT_IMG_EXT','jpg'); + Configuration::updateValue('BLOCKADVERT_IMG_EXT', 'jpg'); } if (!empty($this->adv_imgname)) @@ -140,25 +140,24 @@ class BlockAdvertising extends Module if (Tools::isSubmit('submitAdvConf')) { - $file = false; - if (isset($_FILES['adv_img']) AND isset($_FILES['adv_img']['tmp_name']) AND !empty($_FILES['adv_img']['tmp_name'])) + if (isset($_FILES['adv_img']) && isset($_FILES['adv_img']['tmp_name']) && !empty($_FILES['adv_img']['tmp_name'])) { if ($error = ImageManager::validateUpload($_FILES['adv_img'], Tools::convertBytes(ini_get('upload_max_filesize')))) $errors .= $error; - elseif ($dot_pos = strrpos($_FILES['adv_img']['name'],'.')) + elseif ($dot_pos = strrpos($_FILES['adv_img']['name'], '.')) { // as checkImage tell us it's a good image, we'll just copy the extension $this->_deleteCurrentImg(); $this->adv_imgname = 'advertising'; - $ext = substr($_FILES['adv_img']['name'], $dot_pos+1); + $ext = substr($_FILES['adv_img']['name'], $dot_pos + 1); $newname = 'advertising_custom'.'-'.(int)$this->context->shop->id; - if (!move_uploaded_file($_FILES['adv_img']['tmp_name'],_PS_MODULE_DIR_.$this->name.'/'.$newname.'.'.$ext)) + if (!move_uploaded_file($_FILES['adv_img']['tmp_name'], _PS_MODULE_DIR_.$this->name.'/'.$newname.'.'.$ext)) $errors .= $this->l('Error move uploaded file'); else $this->adv_imgname = $newname; - Configuration::updateValue('BLOCKADVERT_IMG_EXT',$ext); + Configuration::updateValue('BLOCKADVERT_IMG_EXT', $ext); $this->adv_img = Tools::getMediaServer($this->name)._MODULE_DIR_.$this->name.'/'.$this->adv_imgname.'.'.Configuration::get('BLOCKADVERT_IMG_EXT'); } } @@ -185,7 +184,6 @@ class BlockAdvertising extends Module */ public function getContent() { - $this->postProcess(); $output = '
diff --git a/modules/blockbestsellers/blockbestsellers.php b/modules/blockbestsellers/blockbestsellers.php index f97b68772..33c008043 100644 --- a/modules/blockbestsellers/blockbestsellers.php +++ b/modules/blockbestsellers/blockbestsellers.php @@ -52,10 +52,10 @@ class BlockBestSellers extends Module */ public function install() { - if (!parent::install() OR - !$this->registerHook('rightColumn') OR - !$this->registerHook('header') OR - !$this->registerHook('updateOrderStatus') OR + if (!parent::install() || + !$this->registerHook('rightColumn') || + !$this->registerHook('header') || + !$this->registerHook('updateOrderStatus') || !ProductSale::fillProductSales()) return false; return true; @@ -97,17 +97,17 @@ class BlockBestSellers extends Module public function hookRightColumn($params) { if (Configuration::get('PS_CATALOG_MODE')) - return ; + return; - $currency = new Currency((int)($params['cookie']->id_currency)); + $currency = new Currency($params['cookie']->id_currency); $bestsellers = ProductSale::getBestSalesLight((int)($params['cookie']->id_lang), 0, 5); - if (!$bestsellers AND !Configuration::get('PS_BLOCK_BESTSELLERS_DISPLAY')) + if (!$bestsellers && !Configuration::get('PS_BLOCK_BESTSELLERS_DISPLAY')) return; $best_sellers = array(); - if($bestsellers) - foreach ($bestsellers AS $bestseller) + if ($bestsellers) + foreach ($bestsellers as $bestseller) { $bestseller['price'] = Tools::displayPrice(Product::getPriceStatic((int)($bestseller['id_product'])), $currency); $best_sellers[] = $bestseller; @@ -129,14 +129,14 @@ class BlockBestSellers extends Module public function hookHeader($params) { if (Configuration::get('PS_CATALOG_MODE')) - return ; + return; $this->context->controller->addCSS(($this->_path).'blockbestsellers.css', 'all'); } public function hookHome($params) { if (Configuration::get('PS_CATALOG_MODE')) - return ; + return; $currency = new Currency($params['cookie']->id_currency); $bestsellers = ProductSale::getBestSalesLight((int)$params['cookie']->id_lang, 0, 4); @@ -145,7 +145,7 @@ class BlockBestSellers extends Module $best_sellers = array(); if ($bestsellers) - foreach ($bestsellers AS $bestseller) + foreach ($bestsellers as $bestseller) { $bestseller['price'] = Tools::displayPrice(Product::getPriceStatic((int)($bestseller['id_product'])), $currency); $best_sellers[] = $bestseller; diff --git a/modules/blockcart/blockcart.php b/modules/blockcart/blockcart.php index 07a00a5ed..d6a6540b2 100644 --- a/modules/blockcart/blockcart.php +++ b/modules/blockcart/blockcart.php @@ -68,13 +68,13 @@ class BlockCart extends Module $products = $params['cart']->getProducts(true); $nbTotalProducts = 0; - foreach ($products AS $product) + foreach ($products as $product) $nbTotalProducts += (int)$product['cart_quantity']; $wrappingCost = (float)($params['cart']->getOrderTotal($useTax, Cart::ONLY_WRAPPING)); $totalToPay = $params['cart']->getOrderTotal($useTax); - if ($useTax AND Configuration::get('PS_TAX_DISPLAY') == 1) + if ($useTax && Configuration::get('PS_TAX_DISPLAY') == 1) { $totalToPayWithoutTaxes = $params['cart']->getOrderTotal(false); $this->smarty->assign('tax_cost', Tools::displayPrice($totalToPay - $totalToPayWithoutTaxes, $currency)); @@ -97,9 +97,9 @@ class BlockCart extends Module 'ajax_allowed' => (int)(Configuration::get('PS_BLOCK_CART_AJAX')) == 1 ? true : false, 'static_token' => Tools::getToken(false) )); - if (sizeof($errors)) + if (count($errors)) $this->smarty->assign('errors', $errors); - if(isset($this->context->cookie->ajax_blockcart_display)) + if (isset($this->context->cookie->ajax_blockcart_display)) $this->smarty->assign('colapseExpandStatus', $this->context->cookie->ajax_blockcart_display); } @@ -109,12 +109,10 @@ class BlockCart extends Module if (Tools::isSubmit('submitBlockCart')) { $ajax = Tools::getValue('cart_ajax'); - if ($ajax != 0 AND $ajax != 1) + if ($ajax != 0 && $ajax != 1) $output .= '
'.$this->l('Ajax : Invalid choice.').'
'; else - { Configuration::updateValue('PS_BLOCK_CART_AJAX', (int)($ajax)); - } $output .= '
'.$this->l('Confirmation').''.$this->l('Settings updated').'
'; } return $output.$this->displayForm(); @@ -143,13 +141,11 @@ class BlockCart extends Module public function install() { - if - ( + if ( parent::install() == false - OR $this->registerHook('top') == false - OR $this->registerHook('header') == false - OR Configuration::updateValue('PS_BLOCK_CART_AJAX', 1) == false - ) + || $this->registerHook('top') == false + || $this->registerHook('header') == false + || Configuration::updateValue('PS_BLOCK_CART_AJAX', 1) == false) return false; return true; } diff --git a/modules/blockcategories/blockcategories.php b/modules/blockcategories/blockcategories.php index 1190402ae..da961eeef 100644 --- a/modules/blockcategories/blockcategories.php +++ b/modules/blockcategories/blockcategories.php @@ -45,15 +45,15 @@ class BlockCategories extends Module public function install() { - if (!parent::install() OR - !$this->registerHook('leftColumn') OR - !$this->registerHook('header') OR + if (!parent::install() || + !$this->registerHook('leftColumn') || + !$this->registerHook('header') || // Temporary hooks. Do NOT hook any module on it. Some CRUD hook will replace them as soon as possible. - !$this->registerHook('categoryAddition') OR - !$this->registerHook('categoryUpdate') OR - !$this->registerHook('categoryDeletion') OR - !$this->registerHook('afterSaveAdminMeta') OR - !Configuration::updateValue('BLOCK_CATEG_MAX_DEPTH', 3) OR + !$this->registerHook('categoryAddition') || + !$this->registerHook('categoryUpdate') || + !$this->registerHook('categoryDeletion') || + !$this->registerHook('afterSaveAdminMeta') || + !Configuration::updateValue('BLOCK_CATEG_MAX_DEPTH', 3) || !Configuration::updateValue('BLOCK_CATEG_DHTML', 1)) return false; return true; @@ -61,8 +61,8 @@ class BlockCategories extends Module public function uninstall() { - if (!parent::uninstall() OR - !Configuration::deleteByName('BLOCK_CATEG_MAX_DEPTH') OR + if (!parent::uninstall() || + !Configuration::deleteByName('BLOCK_CATEG_MAX_DEPTH') || !Configuration::deleteByName('BLOCK_CATEG_DHTML')) return false; return true; @@ -75,10 +75,10 @@ class BlockCategories extends Module { $maxDepth = (int)(Tools::getValue('maxDepth')); $dhtml = Tools::getValue('dhtml'); - $nbrColumns = Tools::getValue('nbrColumns',4); + $nbrColumns = Tools::getValue('nbrColumns', 4); if ($maxDepth < 0) $output .= '
'.$this->l('Maximum depth: Invalid number.').'
'; - elseif ($dhtml != 0 AND $dhtml != 1) + elseif ($dhtml != 0 && $dhtml != 1) $output .= '
'.$this->l('Dynamic HTML: Invalid choice.').'
'; else { @@ -143,7 +143,7 @@ class BlockCategories extends Module $id_category = $this->context->shop->getCategory(); $children = array(); - if (isset($resultParents[$id_category]) AND sizeof($resultParents[$id_category]) AND ($maxDepth == 0 OR $currentDepth < $maxDepth)) + if (isset($resultParents[$id_category]) && count($resultParents[$id_category]) && ($maxDepth == 0 || $currentDepth < $maxDepth)) foreach ($resultParents[$id_category] as $subcat) $children[] = $this->getTree($resultParents, $resultIds, $maxDepth, $subcat['id_category'], $currentDepth + 1); if (!isset($resultIds[$id_category])) @@ -190,8 +190,7 @@ class BlockCategories extends Module '.((int)($maxdepth) != 0 ? ' AND `level_depth` <= '.(int)($maxdepth) : '').' AND cg.`id_group` IN ('.pSQL($groups).') GROUP BY id_category - ORDER BY `level_depth` ASC, '.(Configuration::get('BLOCK_CATEG_SORT') ? 'cl.`name`' : 'c.`position`').' '.(Configuration::get('BLOCK_CATEG_SORT_WAY') ? 'DESC' : 'ASC')) - ) + ORDER BY `level_depth` ASC, '.(Configuration::get('BLOCK_CATEG_SORT') ? 'cl.`name`' : 'c.`position`').' '.(Configuration::get('BLOCK_CATEG_SORT_WAY') ? 'DESC' : 'ASC'))) return Tools::restoreCacheSettings(); @@ -215,13 +214,13 @@ class BlockCategories extends Module } if (Tools::isSubmit('id_product')) { - if (!isset($this->context->cookie->last_visited_category) OR !Product::idIsOnCategoryId($id_product, array('0' => array('id_category' => $this->context->cookie->last_visited_category)))) + if (!isset($this->context->cookie->last_visited_category) || !Product::idIsOnCategoryId($id_product, array('0' => array('id_category' => $this->context->cookie->last_visited_category)))) { $product = new Product($id_product); - if (isset($product) AND Validate::isLoadedObject($product)) + if (isset($product) && Validate::isLoadedObject($product)) $this->context->cookie->last_visited_category = (int)($product->id_category_default); } - $this->smarty->assign('currentCategoryId', (int)($this->context->cookie->last_visited_category)); + $this->smarty->assign('currentCategoryId', (int)$this->context->cookie->last_visited_category); } $this->smarty->assign('blockCategTree', $blockCategTree); @@ -262,8 +261,7 @@ class BlockCategories extends Module WHERE (c.`active` = 1 OR c.`id_category` = 1) '.((int)($maxdepth) != 0 ? ' AND `level_depth` <= '.(int)($maxdepth) : '').' AND cg.`id_group` IN ('.pSQL($groups).') - ORDER BY `level_depth` ASC, '.(Configuration::get('BLOCK_CATEG_SORT') ? 'cl.`name`' : 'c.`position`').' '.(Configuration::get('BLOCK_CATEG_SORT_WAY') ? 'DESC' : 'ASC')) - ) + ORDER BY `level_depth` ASC, '.(Configuration::get('BLOCK_CATEG_SORT') ? 'cl.`name`' : 'c.`position`').' '.(Configuration::get('BLOCK_CATEG_SORT_WAY') ? 'DESC' : 'ASC'))) return; $resultParents = array(); $resultIds = array(); @@ -275,10 +273,10 @@ class BlockCategories extends Module } //$nbrColumns = Configuration::get('BLOCK_CATEG_NBR_COLUMNS_FOOTER'); $nbrColumns = Configuration::get('BLOCK_CATEG_NBR_COLUMN_FOOTER'); - if(!$nbrColumns) - $nbrColumns=3; - $numberColumn = abs(sizeof($result)/$nbrColumns); - $widthColumn= floor(100/$nbrColumns); + if (!$nbrColumns) + $nbrColumns = 3; + $numberColumn = abs(count($result) / $nbrColumns); + $widthColumn = floor(100 / $nbrColumns); $this->smarty->assign('numberColumn', $numberColumn); $this->smarty->assign('widthColumn', $widthColumn); @@ -294,10 +292,10 @@ class BlockCategories extends Module } if (Tools::isSubmit('id_product')) { - if (!isset($this->context->cookie->last_visited_category) OR !Product::idIsOnCategoryId($id_product, array('0' => array('id_category' => $this->context->cookie->last_visited_category)))) + if (!isset($this->context->cookie->last_visited_category) || !Product::idIsOnCategoryId($id_product, array('0' => array('id_category' => $this->context->cookie->last_visited_category)))) { $product = new Product($id_product); - if (isset($product) AND Validate::isLoadedObject($product)) + if (isset($product) && Validate::isLoadedObject($product)) $this->context->cookie->last_visited_category = (int)($product->id_category_default); } $this->smarty->assign('currentCategoryId', (int)($this->context->cookie->last_visited_category));