diff --git a/modules/blockcms/blockcms.php b/modules/blockcms/blockcms.php index 08bb4b789..f669d5cc8 100755 --- a/modules/blockcms/blockcms.php +++ b/modules/blockcms/blockcms.php @@ -52,7 +52,7 @@ class BlockCms extends Module public function install() { - if (!parent::install() OR !$this->registerHook('leftColumn') OR !$this->registerHook('rightColumn') OR !$this->registerHook('footer') OR !$this->registerHook('header') OR + if (!parent::install() || !$this->registerHook('leftColumn') || !$this->registerHook('rightColumn') || !$this->registerHook('footer') || !$this->registerHook('header') || !Db::getInstance()->execute(' CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'cms_block`( `id_cms_block` int(10) unsigned NOT NULL auto_increment, @@ -61,14 +61,14 @@ class BlockCms extends Module `position` int(10) unsigned NOT NULL default \'0\', `display_store` tinyint(1) unsigned NOT NULL default \'1\', PRIMARY KEY (`id_cms_block`) - ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8') OR + ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8') || !Db::getInstance()->execute(' CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'cms_block_lang`( `id_cms_block` int(10) unsigned NOT NULL, `id_lang` int(10) unsigned NOT NULL, `name` varchar(40) NOT NULL default \'\', PRIMARY KEY (`id_cms_block`, `id_lang`) - ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8') OR + ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8') || !Db::getInstance()->execute(' CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'cms_block_page`( `id_cms_block_page` int(10) unsigned NOT NULL auto_increment, @@ -76,15 +76,15 @@ class BlockCms extends Module `id_cms` int(10) unsigned NOT NULL, `is_category` tinyint(1) unsigned NOT NULL, PRIMARY KEY (`id_cms_block_page`) - ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8') OR + ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8') || !Db::getInstance()->execute(' CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'cms_block_shop` ( `id_cms_block` int(10) unsigned NOT NULL auto_increment, `id_shop` int(10) unsigned NOT NULL, PRIMARY KEY (`id_cms_block`, `id_shop`) - ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8') OR - !Configuration::updateValue('FOOTER_CMS', '') OR - !Configuration::updateValue('FOOTER_BLOCK_ACTIVATION', 1) OR + ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8') || + !Configuration::updateValue('FOOTER_CMS', '') || + !Configuration::updateValue('FOOTER_BLOCK_ACTIVATION', 1) || !Configuration::updateValue('FOOTER_POWEREDBY', 1)) return false; @@ -97,7 +97,7 @@ class BlockCms extends Module return false; $id_cms_block = Db::getInstance()->Insert_ID(); $result = true; - $shops = Shop::getShops(true, null, true); + $shops = Shop::getShops(true, null, true); foreach ($shops as $shop) $result &= Db::getInstance()->insert('cms_block_shop', array( 'id_cms_block' => $id_cms_block, @@ -124,10 +124,10 @@ class BlockCms extends Module public function uninstall() { - if (!parent::uninstall() OR - !Configuration::deleteByName('FOOTER_CMS') OR - !Configuration::deleteByName('FOOTER_BLOCK_ACTIVATION') OR - !Configuration::deleteByName('FOOTER_POWEREDBY') OR + if (!parent::uninstall() || + !Configuration::deleteByName('FOOTER_CMS') || + !Configuration::deleteByName('FOOTER_BLOCK_ACTIVATION') || + !Configuration::deleteByName('FOOTER_POWEREDBY') || !Db::getInstance()->execute('DROP TABLE `'._DB_PREFIX_.'cms_block` , `'._DB_PREFIX_.'cms_block_page`, `'._DB_PREFIX_.'cms_block_lang`, `'._DB_PREFIX_.'cms_block_shop`')) return false; return true; @@ -142,7 +142,7 @@ class BlockCms extends Module WHERE cb.`id_cms_block` = '.(int)$id_cms_block); $store_display_update = array(0, $size = count($cmsBlocks), $display = Configuration::get('PS_STORES_DISPLAY_FOOTER')); - foreach ($cmsBlocks AS $cmsBlock) + foreach ($cmsBlocks as $cmsBlock) { $cmsBlocks['name'][(int)$cmsBlock['id_lang']] = $cmsBlock['name']; if ($store_display_update['0'] < $store_display_update['1']) @@ -154,7 +154,6 @@ class BlockCms extends Module private function getBlocksCMS($location) { - return Db::getInstance()->executeS(' SELECT bc.`id_cms_block`, bcl.`name` block_name, ccl.`name` category_name, bc.`position`, bc.`id_cms_category`, bc.`display_store` FROM `'._DB_PREFIX_.'cms_block` bc @@ -169,7 +168,7 @@ class BlockCms extends Module return array_merge($this->getBlocksCMS(self::LEFT_COLUMN), $this->getBlocksCMS(self::RIGHT_COLUMN)); } - static public function getCMStitlesFooter() + public static function getCMStitlesFooter() { $context = Context::getContext(); @@ -179,7 +178,7 @@ class BlockCms extends Module $cmsCategories = explode('|', $footerCms); $content = array(); - foreach ($cmsCategories AS $cmsCategory) + foreach ($cmsCategories as $cmsCategory) { $ids = explode('_', $cmsCategory); if ($ids[0] == 1) @@ -211,7 +210,7 @@ class BlockCms extends Module return $content; } - static public function getCMStitles($location) + public static function getCMStitles($location) { $context = Context::getContext(); @@ -226,8 +225,8 @@ class BlockCms extends Module $content = array(); - if (is_array($cmsCategories) AND sizeof($cmsCategories)) - foreach ($cmsCategories AS $cmsCategory) + if (is_array($cmsCategories) && count($cmsCategories)) + foreach ($cmsCategories as $cmsCategory) { $key = (int)$cmsCategory['id_cms_block']; $content[$key]['display_store'] = $cmsCategory['display_store']; @@ -238,15 +237,16 @@ class BlockCms extends Module INNER JOIN `'._DB_PREFIX_.'cms_lang` cl ON (bcp.`id_cms` = cl.`id_cms`) INNER JOIN `'._DB_PREFIX_.'cms` c ON (bcp.`id_cms` = c.`id_cms`) WHERE bcp.`id_cms_block` = '.(int)$cmsCategory['id_cms_block'].' AND cl.`id_lang` = '.(int)$context->language->id.' AND bcp.`is_category` = 0 AND c.`active` = 1 - ORDER BY `position`'); + ORDER BY `position` + '); $links = array(); - if (sizeof($content[$key]['cms'])) - foreach ($content[$key]['cms'] AS $row) - { - $row['link'] = $context->link->getCMSLink((int)($row['id_cms']), $row['link_rewrite']); - $links[] = $row; - } + if (count($content[$key]['cms'])) + foreach ($content[$key]['cms'] as $row) + { + $row['link'] = $context->link->getCMSLink((int)($row['id_cms']), $row['link_rewrite']); + $links[] = $row; + } $content[$key]['cms'] = $links; @@ -259,12 +259,12 @@ class BlockCms extends Module AND bcp.`is_category` = 1'); $links = array(); - if (sizeof($content[$key]['categories'])) - foreach ($content[$key]['categories'] as $row) - { - $row['link'] = $context->link->getCMSCategoryLink((int)$row['id_cms'], $row['link_rewrite']); - $links[] = $row; - } + if (count($content[$key]['categories'])) + foreach ($content[$key]['categories'] as $row) + { + $row['link'] = $context->link->getCMSCategoryLink((int)$row['id_cms'], $row['link_rewrite']); + $links[] = $row; + } $content[$key]['categories'] = $links; $content[$key]['name'] = $cmsCategory['block_name']; @@ -278,12 +278,12 @@ class BlockCms extends Module public function getAllCMSTitles() { $titles = array(); - foreach(self::getCMStitles(self::LEFT_COLUMN) AS $key => $title) + foreach (self::getCMStitles(self::LEFT_COLUMN) as $key => $title) { unset($title['categories'], $title['name'], $title['category_link'], $title['category_name']); $titles[$key] = $title; } - foreach(self::getCMStitles(self::RIGHT_COLUMN) AS $key => $title) + foreach (self::getCMStitles(self::RIGHT_COLUMN) as $key => $title) { unset($title['categories'], $title['name'], $title['category_link'], $title['category_name']); $titles[$key] = $title; @@ -295,7 +295,7 @@ class BlockCms extends Module { static $irow = 0; - $img = $categories['level_depth'] == 0 ? 'lv1.gif' : 'lv'.($categories['level_depth'] + 1).'_'.((sizeof($categories['cms']) OR isset($categories['children'])) ? 'b' : 'f').'.gif'; + $img = $categories['level_depth'] == 0 ? 'lv1.gif' : 'lv'.($categories['level_depth'] + 1).'_'.((count($categories['cms']) || isset($categories['children'])) ? 'b' : 'f').'.gif'; $this->_html .= ' @@ -312,7 +312,7 @@ class BlockCms extends Module foreach ($categories['children'] as $key => $category) { $has_suite[$categories['level_depth']] = 1; - if (sizeof($categories['children']) == $key + 1 AND !sizeof($categories['cms'])) + if (count($categories['children']) == $key + 1 && !count($categories['cms'])) $has_suite[$categories['level_depth']] = 0; $this->displayRecurseCheckboxes($category, $selected, $has_suite, 0); } @@ -328,7 +328,7 @@ class BlockCms extends Module '; for ($i = 0; $i < $categories['level_depth']; $i++) $this->_html .= ''; - $this->_html .= '   + $this->_html .= '   '; } @@ -341,7 +341,7 @@ class BlockCms extends Module $cms_blocks_right = $this->getBlocksCMS(1); $isoTinyMCE = (file_exists(_PS_ROOT_DIR_.'/js/tiny_mce/langs/'.$this->context->language->iso_code.'.js') ? $this->context->language->iso_code : 'en'); - $ad = dirname($_SERVER["PHP_SELF"]); + $ad = dirname($_SERVER['PHP_SELF']); $this->_html .= ' '; - /* Add a link */ + // Add a link if (isset($_POST['submitLinkAdd'])) { - if (empty($_POST['text_'.Configuration::get('PS_LANG_DEFAULT')]) OR empty($_POST['url'])) + if (empty($_POST['text_'.Configuration::get('PS_LANG_DEFAULT')]) || empty($_POST['url'])) $this->_html .= $this->displayError($this->l('You must fill in all fields')); elseif (!Validate::isUrl(str_replace('http://', '', $_POST['url']))) $this->_html .= $this->displayError($this->l('Bad URL')); @@ -231,13 +230,13 @@ class BlockLink extends Module else $this->_html .= $this->displayError($this->l('An error occurred during link creation.')); } - /* Update the block title */ + // Update the block title elseif (isset($_POST['submitTitle'])) { if (empty($_POST['title_'.Configuration::get('PS_LANG_DEFAULT')])) $this->_html .= $this->displayError($this->l('"title" field cannot be empty.')); - elseif (!empty($_POST['title_url']) AND !Validate::isUrl(str_replace('http://', '', $_POST['title_url']))) + elseif (!empty($_POST['title_url']) && !Validate::isUrl(str_replace('http://', '', $_POST['title_url']))) $this->_html .= $this->displayError($this->l('The \'title\' field is invalid')); elseif (!Validate::isGenericName($_POST['title_'.Configuration::get('PS_LANG_DEFAULT')])) $this->_html .= $this->displayError($this->l('The \'title\' field is invalid')); @@ -246,12 +245,11 @@ class BlockLink extends Module else $this->_html .= $this->displayConfirmation($this->l('The block title has been updated.')); } - - /* Delete a link*/ + // Delete a link elseif (Tools::getValue('delete_link') && isset($_GET['id'])) { - if (!is_numeric($_GET['id']) OR !$this->deleteLink()) + if (!is_numeric($_GET['id']) || !$this->deleteLink()) $this->_html .= $this->displayError($this->l('An error occurred during link deletion.')); else $this->_html .= $this->displayConfirmation($this->l('The link has been deleted.')); @@ -343,14 +341,14 @@ class BlockLink extends Module foreach ($languages as $language) $this->_html .= '
- * + *
'; $this->_html .= $this->displayFlags($languages, $defaultLanguage, $divLangName, 'title', true); $this->_html .= '
-
+
@@ -380,10 +378,10 @@ class BlockLink extends Module var currentUrl = \''.AdminController::$currentIndex.'&configure='.$this->name.'\'; var token=\''.Tools::getValue('token').'\'; var links = new Array();'; - foreach ($links AS $link) + foreach ($links as $link) { $this->_html .= 'links['.$link['id'].'] = new Array(\''.addslashes($link['url']).'\', '.$link['newWindow']; - foreach ($languages AS $language) + foreach ($languages as $language) if (isset($link['text_'.$language['id_lang']])) $this->_html .= ', \''.addslashes($link['text_'.$language['id_lang']]).'\''; else @@ -408,7 +406,7 @@ class BlockLink extends Module '.$this->l('There are no links.').' '; else - foreach ($links AS $link) + foreach ($links as $link) $this->_html .= ' '.$link['id'].' @@ -422,17 +420,15 @@ class BlockLink extends Module $i = 0; $nb = count($languages); $idLng = 0; - while($i < $nb) + while ($i < $nb) { if ($languages[$i]['id_lang'] == (int)Configuration::get('PS_LANG_DEFAULT')) - { $idLng = $i; - } $i++; } $this->_html .= ' - '; + '; } } diff --git a/modules/blockmanufacturer/blockmanufacturer.php b/modules/blockmanufacturer/blockmanufacturer.php index 278ee3744..fde787617 100644 --- a/modules/blockmanufacturer/blockmanufacturer.php +++ b/modules/blockmanufacturer/blockmanufacturer.php @@ -30,7 +30,7 @@ if (!defined('_PS_VERSION_')) class BlockManufacturer extends Module { - function __construct() + public function __construct() { $this->name = 'blockmanufacturer'; $this->tab = 'front_office_features'; @@ -44,16 +44,16 @@ class BlockManufacturer extends Module $this->description = $this->l('Displays a block of manufacturers/brands'); } - function install() - { + public function install() + { Configuration::updateValue('MANUFACTURER_DISPLAY_TEXT', true); Configuration::updateValue('MANUFACTURER_DISPLAY_TEXT_NB', 5); Configuration::updateValue('MANUFACTURER_DISPLAY_FORM', true); - return (parent::install() AND $this->registerHook('leftColumn') AND $this->registerHook('header')); + return parent::install() && $this->registerHook('leftColumn') && $this->registerHook('header'); } - function hookLeftColumn($params) - { + public function hookLeftColumn($params) + { $this->smarty->assign(array( 'manufacturers' => Manufacturer::getManufacturers(), 'text_list' => Configuration::get('MANUFACTURER_DISPLAY_TEXT'), @@ -64,12 +64,12 @@ class BlockManufacturer extends Module return $this->display(__FILE__, 'blockmanufacturer.tpl'); } - function hookRightColumn($params) + public function hookRightColumn($params) { return $this->hookLeftColumn($params); } - function getContent() + public function getContent() { $output = '

'.$this->displayName.'

'; if (Tools::isSubmit('submitBlockManufacturers')) @@ -77,9 +77,9 @@ class BlockManufacturer extends Module $text_list = (int)(Tools::getValue('text_list')); $text_nb = (int)(Tools::getValue('text_nb')); $form_list = (int)(Tools::getValue('form_list')); - if ($text_list AND !Validate::isUnsignedInt($text_nb)) + if ($text_list && !Validate::isUnsignedInt($text_nb)) $errors[] = $this->l('Invalid number of elements'); - elseif (!$text_list AND !$form_list) + elseif (!$text_list && !$form_list) $errors[] = $this->l('Please activate at least one system list'); else { @@ -87,7 +87,7 @@ class BlockManufacturer extends Module Configuration::updateValue('MANUFACTURER_DISPLAY_TEXT_NB', $text_nb); Configuration::updateValue('MANUFACTURER_DISPLAY_FORM', $form_list); } - if (isset($errors) AND sizeof($errors)) + if (isset($errors) && count($errors)) $output .= $this->displayError(implode('
', $errors)); else $output .= $this->displayConfirmation($this->l('Settings updated')); @@ -123,7 +123,7 @@ class BlockManufacturer extends Module return $output; } - function hookHeader($params) + public function hookHeader($params) { $this->context->controller->addCSS(($this->_path).'blockmanufacturer.css', 'all'); } diff --git a/modules/blockmyaccount/blockmyaccount.php b/modules/blockmyaccount/blockmyaccount.php index cb9c8f59c..4f2ee64ad 100644 --- a/modules/blockmyaccount/blockmyaccount.php +++ b/modules/blockmyaccount/blockmyaccount.php @@ -56,7 +56,7 @@ class BlockMyAccount extends Module public function uninstall() { - return (parent::uninstall() AND $this->removeMyAccountBlockHook()); + return (parent::uninstall() && $this->removeMyAccountBlockHook()); } public function hookDisplayLeftColumn($params) diff --git a/modules/blockmyaccountfooter/blockmyaccountfooter.php b/modules/blockmyaccountfooter/blockmyaccountfooter.php index ed3ada0df..f64fabbea 100644 --- a/modules/blockmyaccountfooter/blockmyaccountfooter.php +++ b/modules/blockmyaccountfooter/blockmyaccountfooter.php @@ -28,7 +28,7 @@ if (!defined('_PS_VERSION_')) exit; -class blockmyaccountfooter extends Module +class Blockmyaccountfooter extends Module { public function __construct() { @@ -46,14 +46,14 @@ class blockmyaccountfooter extends Module public function install() { - if (!$this->addMyAccountBlockHook() OR !parent::install() OR !$this->registerHook('footer') OR !$this->registerHook('header')) + if (!$this->addMyAccountBlockHook() || !parent::install() || !$this->registerHook('footer') || !$this->registerHook('header')) return false; return true; } public function uninstall() { - return (parent::uninstall() AND $this->removeMyAccountBlockHook()); + return parent::uninstall() && $this->removeMyAccountBlockHook(); } public function hookLeftColumn($params) @@ -84,11 +84,13 @@ class blockmyaccountfooter extends Module { return Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'hook` WHERE `name` = \'myAccountBlockfooter\''); } - function hookHeader($params) + + public function hookHeader($params) { $this->context->controller->addCSS(($this->_path).'blockmyaccount.css', 'all'); } - function hookFooter($params) + + public function hookFooter($params) { global $smarty; @@ -99,8 +101,4 @@ class blockmyaccountfooter extends Module )); return $this->display(__FILE__, $this->name.'.tpl'); } - } - - - diff --git a/modules/blocknewproducts/blocknewproducts.php b/modules/blocknewproducts/blocknewproducts.php index 2a402f9f5..c9fd9f5b1 100644 --- a/modules/blocknewproducts/blocknewproducts.php +++ b/modules/blocknewproducts/blocknewproducts.php @@ -46,7 +46,7 @@ class BlockNewProducts extends Module public function install() { - if (parent::install() == false OR $this->registerHook('rightColumn') == false OR $this->registerHook('header') == false OR Configuration::updateValue('NEW_PRODUCTS_NBR', 5) == false) + if (parent::install() == false || $this->registerHook('rightColumn') == false || $this->registerHook('header') == false || Configuration::updateValue('NEW_PRODUCTS_NBR', 5) == false) return false; return true; } @@ -56,7 +56,7 @@ class BlockNewProducts extends Module $output = '

'.$this->displayName.'

'; if (Tools::isSubmit('submitBlockNewProducts')) { - if (!$productNbr = Tools::getValue('productNbr') OR empty($productNbr)) + if (!($productNbr = Tools::getValue('productNbr')) || empty($productNbr)) $output .= '
'.$this->l('Please fill in the "products displayed" field.').'
'; elseif ((int)($productNbr) == 0) $output .= '
'.$this->l('Invalid number.').'
'; @@ -97,7 +97,7 @@ class BlockNewProducts extends Module public function hookRightColumn($params) { $newProducts = Product::getNewProducts((int)($params['cookie']->id_lang), 0, (int)(Configuration::get('NEW_PRODUCTS_NBR'))); - if (!$newProducts AND !Configuration::get('PS_BLOCK_NEWPRODUCTS_DISPLAY')) + if (!$newProducts && !Configuration::get('PS_BLOCK_NEWPRODUCTS_DISPLAY')) return; $this->smarty->assign(array( diff --git a/modules/blocknewsletter/blocknewsletter.php b/modules/blocknewsletter/blocknewsletter.php index 4d23d02a7..1de947918 100644 --- a/modules/blocknewsletter/blocknewsletter.php +++ b/modules/blocknewsletter/blocknewsletter.php @@ -62,7 +62,7 @@ class Blocknewsletter extends Module public function install() { - if (parent::install() == false OR $this->registerHook('leftColumn') == false OR $this->registerHook('header') == false) + if (parent::install() == false || $this->registerHook('leftColumn') == false || $this->registerHook('header') == false) return false; Configuration::updateValue('NW_SALT', Tools::passwdGen(16)); @@ -188,7 +188,7 @@ class Blocknewsletter extends Module */ private function newsletterRegistration() { - if (empty($_POST['email']) OR !Validate::isEmail($_POST['email'])) + if (empty($_POST['email']) || !Validate::isEmail($_POST['email'])) return $this->error = $this->l('Invalid e-mail address'); /* Unsubscription */ diff --git a/modules/blockpaymentlogo/blockpaymentlogo.php b/modules/blockpaymentlogo/blockpaymentlogo.php index 42b856fcb..6eef4a583 100644 --- a/modules/blockpaymentlogo/blockpaymentlogo.php +++ b/modules/blockpaymentlogo/blockpaymentlogo.php @@ -77,7 +77,7 @@ class BlockPaymentLogo extends Module $cmss = CMS::listCms($this->context->language->id); - if (!sizeof($cmss)) + if (!count($cmss)) $html .= $this->displayError($this->l('No CMS page is available')); else { @@ -109,7 +109,7 @@ class BlockPaymentLogo extends Module public function hookLeftColumn($params) { if (Configuration::get('PS_CATALOG_MODE')) - return ; + return; if (!Configuration::get('PS_PAYMENT_LOGO_CMS_ID')) @@ -133,7 +133,7 @@ class BlockPaymentLogo extends Module public function hookHeader($params) { if (Configuration::get('PS_CATALOG_MODE')) - return ; + return; $this->context->controller->addCSS(($this->_path).'blockpaymentlogo.css', 'all'); } diff --git a/modules/blockpermanentlinks/blockpermanentlinks.php b/modules/blockpermanentlinks/blockpermanentlinks.php index 8264ef098..b9b3e6f43 100644 --- a/modules/blockpermanentlinks/blockpermanentlinks.php +++ b/modules/blockpermanentlinks/blockpermanentlinks.php @@ -30,7 +30,7 @@ if (!defined('_PS_VERSION_')) class BlockPermanentLinks extends Module { - function __construct() + public function __construct() { $this->name = 'blockpermanentlinks'; $this->tab = 'front_office_features'; @@ -44,9 +44,9 @@ class BlockPermanentLinks extends Module $this->description = $this->l('Adds a block that displays permanent links such as sitemap, contact, etc.'); } - function install() + public function install() { - return (parent::install() AND $this->registerHook('top') AND $this->registerHook('header')); + return (parent::install() && $this->registerHook('top') && $this->registerHook('header')); } /** @@ -55,7 +55,7 @@ class BlockPermanentLinks extends Module * @param array $params Parameters * @return string Content */ - function hookTop($params) + public function hookTop($params) { return $this->display(__FILE__, 'blockpermanentlinks-header.tpl'); } @@ -66,22 +66,22 @@ class BlockPermanentLinks extends Module * @param array $params Parameters * @return string Content */ - function hookLeftColumn($params) + public function hookLeftColumn($params) { return $this->display(__FILE__, 'blockpermanentlinks.tpl'); } - function hookRightColumn($params) + public function hookRightColumn($params) { return $this->hookLeftColumn($params); } - - function hookFooter($params) + + public function hookFooter($params) { return $this->display(__FILE__, 'blockpermanentlinks-footer.tpl'); } - - function hookHeader($params) + + public function hookHeader($params) { $this->context->controller->addCSS(($this->_path).'blockpermanentlinks.css', 'all'); } diff --git a/modules/blockreinsurance/blockreinsurance.php b/modules/blockreinsurance/blockreinsurance.php index c0177d3d0..521c66c65 100644 --- a/modules/blockreinsurance/blockreinsurance.php +++ b/modules/blockreinsurance/blockreinsurance.php @@ -28,12 +28,12 @@ if (!defined('_CAN_LOAD_FILES_')) exit; -class blockreinsurance extends Module +class Blockreinsurance extends Module { public function __construct() { $this->name = 'blockreinsurance'; - if(version_compare(_PS_VERSION_, '1.4.0.0') >= 0) + if (version_compare(_PS_VERSION_, '1.4.0.0') >= 0) $this->tab = 'front_office_features'; else $this->tab = 'Blocks'; @@ -47,7 +47,7 @@ class blockreinsurance extends Module public function install() { - return (parent::install() AND $this->installDB() AND Configuration::updateValue('blockreinsurance_nbblocks', 5) AND $this->registerHook('footer')); + return (parent::install() && $this->installDB() && Configuration::updateValue('blockreinsurance_nbblocks', 5) && $this->registerHook('footer')); } public function installDB() @@ -63,8 +63,8 @@ class blockreinsurance extends Module public function uninstall() { - //Delete configuration - return (Configuration::deleteByName('blockreinsurance_nbblocks') AND $this->uninstallDB() AND parent::uninstall()); + // Delete configuration + return (Configuration::deleteByName('blockreinsurance_nbblocks') && $this->uninstallDB() && parent::uninstall()); } public function uninstallDB() @@ -75,24 +75,24 @@ class blockreinsurance extends Module public function addToDB() { - if(isset($_POST['nbblocks'])) + if (isset($_POST['nbblocks'])) { - for($i = 1; $i <= (int)$_POST['nbblocks']; $i++) + for ($i = 1; $i <= (int)$_POST['nbblocks']; $i++) { $filename = explode('.', $_FILES['info'.$i.'_file']['name']); - if (isset($_FILES['info'.$i.'_file']) AND isset($_FILES['info'.$i.'_file']['tmp_name']) AND !empty($_FILES['info'.$i.'_file']['tmp_name'])) + if (isset($_FILES['info'.$i.'_file']) && isset($_FILES['info'.$i.'_file']['tmp_name']) && !empty($_FILES['info'.$i.'_file']['tmp_name'])) { if ($error = ImageManager::validateUpload($_FILES['info'.$i.'_file'])) return false; - elseif (!$tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS') OR !move_uploaded_file($_FILES['info'.$i.'_file']['tmp_name'], $tmpName)) + elseif (!($tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS')) || !move_uploaded_file($_FILES['info'.$i.'_file']['tmp_name'], $tmpName)) return false; elseif (!ImageManager::resize($tmpName, dirname(__FILE__).'/img/'.$filename[0].'.jpg')) return false; unlink($tmpName); } Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'reinsurance` (`filename`,`text`) - VALUES ("'.((isset($filename[0]) AND $filename[0] != '') ? pSQL($filename[0]) : ''). - '", "'.((isset($_POST['info'.$i.'_text']) AND $_POST['info'.$i.'_text'] != '') ? pSQL($_POST['info'.$i.'_text']) : '').'")'); + VALUES ("'.((isset($filename[0]) && $filename[0] != '') ? pSQL($filename[0]) : ''). + '", "'.((isset($_POST['info'.$i.'_text']) && $_POST['info'.$i.'_text'] != '') ? pSQL($_POST['info'.$i.'_text']) : '').'")'); } return true; } else @@ -105,10 +105,8 @@ class blockreinsurance extends Module while (false !== ($file = readdir($dir))) { $path = dirname(__FILE__).'/img/'.$file; - if ($file != ".." AND $file != "." AND !is_dir($file)) - { + if ($file != '..' && $file != '.' && !is_dir($file)) unlink($path); - } } closedir($dir); @@ -125,8 +123,8 @@ class blockreinsurance extends Module // If we try to update the settings if (isset($_POST['submitModule'])) { - Configuration::updateValue('blockreinsurance_nbblocks', ((isset($_POST['nbblocks']) AND $_POST['nbblocks'] != '') ? (int)$_POST['nbblocks'] : '')); - if($this->removeFromDB() && $this->addToDB()) + Configuration::updateValue('blockreinsurance_nbblocks', ((isset($_POST['nbblocks']) && $_POST['nbblocks'] != '') ? (int)$_POST['nbblocks'] : '')); + if ($this->removeFromDB() && $this->addToDB()) echo '
'.$this->l('Configuration updated').'
'; else echo '
'.$this->l('An error occurred during the save').'
'; @@ -165,22 +163,20 @@ class blockreinsurance extends Module
 
'; // Show by default 5 blocks maximum - for($i = 1; $i <= 5; $i++) + for ($i = 1; $i <= 5; $i++) { $content .= '

'.$this->l('Block number').' '.$i.'

'. - ((!empty($infos[$i-1]) && $infos[$i-1]['filename'] != '') ? '' : ''). + ((!empty($infos[$i - 1]) && $infos[$i - 1]['filename'] != '') ? '' : ''). '
 

-

'; +

'; } $content .= '