diff --git a/blocktopmenu.php b/blocktopmenu.php index d048f3d..6e4841a 100644 --- a/blocktopmenu.php +++ b/blocktopmenu.php @@ -28,9 +28,9 @@ require (dirname(__FILE__).'/menutoplinks.class.php'); class Blocktopmenu extends Module { - protected $_menu = ''; - protected $_html = ''; - protected $user_groups; + protected $_menu = ''; + protected $_html = ''; + protected $user_groups; /* * Pattern for matching config values @@ -48,24 +48,24 @@ class Blocktopmenu extends Module */ protected $spacer_size = '5'; - public function __construct() - { - $this->name = 'blocktopmenu'; - $this->tab = 'front_office_features'; - $this->version = '2.2.1'; - $this->author = 'PrestaShop'; + public function __construct() + { + $this->name = 'blocktopmenu'; + $this->tab = 'front_office_features'; + $this->version = '2.2.1'; + $this->author = 'PrestaShop'; - $this->bootstrap = true; - parent::__construct(); + $this->bootstrap = true; + parent::__construct(); - $this->displayName = $this->l('Top horizontal menu'); - $this->description = $this->l('Adds a new horizontal menu to the top of your e-commerce website.'); - $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_); - } + $this->displayName = $this->l('Top horizontal menu'); + $this->description = $this->l('Adds a new horizontal menu to the top of your e-commerce website.'); + $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_); + } - public function install($delete_params = true) - { - if (!parent::install() || + public function install($delete_params = true) + { + if (!parent::install() || !$this->registerHook('header') || !$this->registerHook('displayTop') || !$this->registerHook('actionObjectCategoryUpdateAfter') || @@ -84,21 +84,24 @@ class Blocktopmenu extends Module !$this->registerHook('actionObjectProductDeleteAfter') || !$this->registerHook('actionObjectProductAddAfter') || !$this->registerHook('categoryUpdate') || - !$this->registerHook('actionShopDataDuplication')) - return false; + !$this->registerHook('actionShopDataDuplication')) { + return false; + } - $this->clearMenuCache(); + $this->clearMenuCache(); - if ($delete_params) - if (!$this->installDb() || !Configuration::updateGlobalValue('MOD_BLOCKTOPMENU_ITEMS', 'CAT3,CAT26') || !Configuration::updateGlobalValue('MOD_BLOCKTOPMENU_SEARCH', '1')) - return false; + if ($delete_params) { + if (!$this->installDb() || !Configuration::updateGlobalValue('MOD_BLOCKTOPMENU_ITEMS', 'CAT3,CAT26') || !Configuration::updateGlobalValue('MOD_BLOCKTOPMENU_SEARCH', '1')) { + return false; + } + } - return true; - } + return true; + } - public function installDb() - { - return (Db::getInstance()->execute(' + public function installDb() + { + return (Db::getInstance()->execute(' CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'linksmenutop` ( `id_linksmenutop` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, `id_shop` INT(11) UNSIGNED NOT NULL, @@ -114,306 +117,301 @@ class Blocktopmenu extends Module `link` VARCHAR( 128 ) NOT NULL , INDEX ( `id_linksmenutop` , `id_lang`, `id_shop`) ) ENGINE = '._MYSQL_ENGINE_.' CHARACTER SET utf8 COLLATE utf8_general_ci;')); - } + } - public function uninstall($delete_params = true) - { - if (!parent::uninstall()) - return false; + public function uninstall($delete_params = true) + { + if (!parent::uninstall()) { + return false; + } - $this->clearMenuCache(); + $this->clearMenuCache(); - if ($delete_params) - if (!$this->uninstallDB() || !Configuration::deleteByName('MOD_BLOCKTOPMENU_ITEMS') || !Configuration::deleteByName('MOD_BLOCKTOPMENU_SEARCH')) - return false; + if ($delete_params) { + if (!$this->uninstallDB() || !Configuration::deleteByName('MOD_BLOCKTOPMENU_ITEMS') || !Configuration::deleteByName('MOD_BLOCKTOPMENU_SEARCH')) { + return false; + } + } - return true; - } + return true; + } - protected function uninstallDb() - { - Db::getInstance()->execute('DROP TABLE `'._DB_PREFIX_.'linksmenutop`'); - Db::getInstance()->execute('DROP TABLE `'._DB_PREFIX_.'linksmenutop_lang`'); - return true; - } + protected function uninstallDb() + { + Db::getInstance()->execute('DROP TABLE `'._DB_PREFIX_.'linksmenutop`'); + Db::getInstance()->execute('DROP TABLE `'._DB_PREFIX_.'linksmenutop_lang`'); + return true; + } - public function reset() - { - if (!$this->uninstall(false)) - return false; - if (!$this->install(false)) - return false; + public function reset() + { + if (!$this->uninstall(false)) { + return false; + } + if (!$this->install(false)) { + return false; + } - return true; - } + return true; + } - public function getContent() - { - $this->context->controller->addjQueryPlugin('hoverIntent'); + public function getContent() + { + $this->context->controller->addjQueryPlugin('hoverIntent'); - $id_lang = (int)Context::getContext()->language->id; - $languages = $this->context->controller->getLanguages(); - $default_language = (int)Configuration::get('PS_LANG_DEFAULT'); + $id_lang = (int)Context::getContext()->language->id; + $languages = $this->context->controller->getLanguages(); + $default_language = (int)Configuration::get('PS_LANG_DEFAULT'); - $labels = Tools::getValue('label') ? array_filter(Tools::getValue('label'), 'strlen') : array(); - $links_label = Tools::getValue('link') ? array_filter(Tools::getValue('link'), 'strlen') : array(); - $spacer = str_repeat(' ', $this->spacer_size); - $divLangName = 'link_label'; + $labels = Tools::getValue('label') ? array_filter(Tools::getValue('label'), 'strlen') : array(); + $links_label = Tools::getValue('link') ? array_filter(Tools::getValue('link'), 'strlen') : array(); + $spacer = str_repeat(' ', $this->spacer_size); + $divLangName = 'link_label'; - $update_cache = false; + $update_cache = false; - if (Tools::isSubmit('submitBlocktopmenu')) - { - $errors_update_shops = array(); - $items = Tools::getValue('items'); - $shops = Shop::getContextListShopID(); + if (Tools::isSubmit('submitBlocktopmenu')) { + $errors_update_shops = array(); + $items = Tools::getValue('items'); + $shops = Shop::getContextListShopID(); - foreach ($shops as $shop_id) - { - $shop_group_id = Shop::getGroupFromShop($shop_id); - $updated = true; + foreach ($shops as $shop_id) { + $shop_group_id = Shop::getGroupFromShop($shop_id); + $updated = true; - if (count($shops) == 1) - { - if (is_array($items) && count($items)) - $updated = Configuration::updateValue('MOD_BLOCKTOPMENU_ITEMS', (string)implode(',', $items), false, (int)$shop_group_id, (int)$shop_id); - else - $updated = Configuration::updateValue('MOD_BLOCKTOPMENU_ITEMS', '', false, (int)$shop_group_id, (int)$shop_id); - } + if (count($shops) == 1) { + if (is_array($items) && count($items)) { + $updated = Configuration::updateValue('MOD_BLOCKTOPMENU_ITEMS', (string)implode(',', $items), false, (int)$shop_group_id, (int)$shop_id); + } else { + $updated = Configuration::updateValue('MOD_BLOCKTOPMENU_ITEMS', '', false, (int)$shop_group_id, (int)$shop_id); + } + } - $updated &= Configuration::updateValue('MOD_BLOCKTOPMENU_SEARCH', (bool)Tools::getValue('search'), false, (int)$shop_group_id, (int)$shop_id); + $updated &= Configuration::updateValue('MOD_BLOCKTOPMENU_SEARCH', (bool)Tools::getValue('search'), false, (int)$shop_group_id, (int)$shop_id); - if (!$updated) - { - $shop = new Shop($shop_id); - $errors_update_shops[] = $shop->name; - } + if (!$updated) { + $shop = new Shop($shop_id); + $errors_update_shops[] = $shop->name; + } + } - } + if (!count($errors_update_shops)) { + $this->_html .= $this->displayConfirmation($this->l('The settings have been updated.')); + } else { + $this->_html .= $this->displayError(sprintf($this->l('Unable to update settings for the following shop(s): %s'), implode(', ', $errors_update_shops))); + } - if (!count($errors_update_shops)) - $this->_html .= $this->displayConfirmation($this->l('The settings have been updated.')); - else - $this->_html .= $this->displayError(sprintf($this->l('Unable to update settings for the following shop(s): %s'), implode(', ', $errors_update_shops))); + $update_cache = true; + } else { + if (Tools::isSubmit('submitBlocktopmenuLinks')) { + $errors_add_link = array(); - $update_cache = true; - } - else if (Tools::isSubmit('submitBlocktopmenuLinks')) - { - $errors_add_link = array(); + foreach ($languages as $key => $val) { + $links_label[$val['id_lang']] = Tools::getValue('link_'.(int)$val['id_lang']); + $labels[$val['id_lang']] = Tools::getValue('label_'.(int)$val['id_lang']); + } - foreach ($languages as $key => $val) - { - $links_label[$val['id_lang']] = Tools::getValue('link_'.(int)$val['id_lang']); - $labels[$val['id_lang']] = Tools::getValue('label_'.(int)$val['id_lang']); - } + $count_links_label = count($links_label); + $count_label = count($labels); - $count_links_label = count($links_label); - $count_label = count($labels); + if ($count_links_label || $count_label) { + if (!$count_links_label) { + $this->_html .= $this->displayError($this->l('Please complete the "Link" field.')); + } elseif (!$count_label) { + $this->_html .= $this->displayError($this->l('Please add a label.')); + } elseif (!isset($labels[$default_language])) { + $this->_html .= $this->displayError($this->l('Please add a label for your default language.')); + } else { + $shops = Shop::getContextListShopID(); - if ($count_links_label || $count_label) - { - if (!$count_links_label) - $this->_html .= $this->displayError($this->l('Please complete the "Link" field.')); - elseif (!$count_label) - $this->_html .= $this->displayError($this->l('Please add a label.')); - elseif (!isset($labels[$default_language])) - $this->_html .= $this->displayError($this->l('Please add a label for your default language.')); - else - { - $shops = Shop::getContextListShopID(); + foreach ($shops as $shop_id) { + $added = MenuTopLinks::add($links_label, $labels, Tools::getValue('new_window', 0), (int)$shop_id); - foreach ($shops as $shop_id) - { - $added = MenuTopLinks::add($links_label, $labels, Tools::getValue('new_window', 0), (int)$shop_id); + if (!$added) { + $shop = new Shop($shop_id); + $errors_add_link[] = $shop->name; + } + } - if (!$added) - { - $shop = new Shop($shop_id); - $errors_add_link[] = $shop->name; - } + if (!count($errors_add_link)) { + $this->_html .= $this->displayConfirmation($this->l('The link has been added.')); + } else { + $this->_html .= $this->displayError(sprintf($this->l('Unable to add link for the following shop(s): %s'), implode(', ', $errors_add_link))); + } + } + } + $update_cache = true; + } elseif (Tools::isSubmit('deletelinksmenutop')) { + $errors_delete_link = array(); + $id_linksmenutop = Tools::getValue('id_linksmenutop', 0); + $shops = Shop::getContextListShopID(); - } + foreach ($shops as $shop_id) { + $deleted = MenuTopLinks::remove($id_linksmenutop, (int)$shop_id); + Configuration::updateValue('MOD_BLOCKTOPMENU_ITEMS', str_replace(array('LNK'.$id_linksmenutop.',', 'LNK'.$id_linksmenutop), '', Configuration::get('MOD_BLOCKTOPMENU_ITEMS'))); - if (!count($errors_add_link)) - $this->_html .= $this->displayConfirmation($this->l('The link has been added.')); - else - $this->_html .= $this->displayError(sprintf($this->l('Unable to add link for the following shop(s): %s'), implode(', ', $errors_add_link))); - } - } - $update_cache = true; + if (!$deleted) { + $shop = new Shop($shop_id); + $errors_delete_link[] = $shop->name; + } + } - } - elseif (Tools::isSubmit('deletelinksmenutop')) - { - $errors_delete_link = array(); - $id_linksmenutop = Tools::getValue('id_linksmenutop', 0); - $shops = Shop::getContextListShopID(); + if (!count($errors_delete_link)) { + $this->_html .= $this->displayConfirmation($this->l('The link has been removed.')); + } else { + $this->_html .= $this->displayError(sprintf($this->l('Unable to remove link for the following shop(s): %s'), implode(', ', $errors_delete_link))); + } - foreach ($shops as $shop_id) - { - $deleted = MenuTopLinks::remove($id_linksmenutop, (int)$shop_id); - Configuration::updateValue('MOD_BLOCKTOPMENU_ITEMS', str_replace(array('LNK'.$id_linksmenutop.',', 'LNK'.$id_linksmenutop), '', Configuration::get('MOD_BLOCKTOPMENU_ITEMS'))); + $update_cache = true; + } elseif (Tools::isSubmit('updatelinksmenutop')) { + $id_linksmenutop = (int)Tools::getValue('id_linksmenutop', 0); + $id_shop = (int)Shop::getContextShopID(); - if (!$deleted) - { - $shop = new Shop($shop_id); - $errors_delete_link[] = $shop->name; - } + if (Tools::isSubmit('updatelink')) { + $link = array(); + $label = array(); + $new_window = (int)Tools::getValue('new_window', 0); - } + foreach (Language::getLanguages(false) as $lang) { + $link[$lang['id_lang']] = Tools::getValue('link_'.(int)$lang['id_lang']); + $label[$lang['id_lang']] = Tools::getValue('label_'.(int)$lang['id_lang']); + } - if (!count($errors_delete_link)) - $this->_html .= $this->displayConfirmation($this->l('The link has been removed.')); - else - $this->_html .= $this->displayError(sprintf($this->l('Unable to remove link for the following shop(s): %s'), implode(', ', $errors_delete_link))); + MenuTopLinks::update($link, $label, $new_window, (int)$id_shop, (int)$id_linksmenutop, (int)$id_linksmenutop); + $this->_html .= $this->displayConfirmation($this->l('The link has been edited.')); + } + $update_cache = true; + } + } - $update_cache = true; - } - elseif (Tools::isSubmit('updatelinksmenutop')) - { - $id_linksmenutop = (int)Tools::getValue('id_linksmenutop', 0); - $id_shop = (int)Shop::getContextShopID(); - - if (Tools::isSubmit('updatelink')) - { - $link = array(); - $label = array(); - $new_window = (int)Tools::getValue('new_window', 0); - - foreach (Language::getLanguages(false) as $lang) - { - $link[$lang['id_lang']] = Tools::getValue('link_'.(int)$lang['id_lang']); - $label[$lang['id_lang']] = Tools::getValue('label_'.(int)$lang['id_lang']); - } - - MenuTopLinks::update($link, $label, $new_window, (int)$id_shop, (int)$id_linksmenutop, (int)$id_linksmenutop); - $this->_html .= $this->displayConfirmation($this->l('The link has been edited.')); - } - $update_cache = true; - } - - if ($update_cache) - $this->clearMenuCache(); + if ($update_cache) { + $this->clearMenuCache(); + } - $shops = Shop::getContextListShopID(); - $links = array(); + $shops = Shop::getContextListShopID(); + $links = array(); - if (count($shops) > 1) - $this->_html .= $this->getWarningMultishopHtml(); + if (count($shops) > 1) { + $this->_html .= $this->getWarningMultishopHtml(); + } - if (Shop::isFeatureActive()) - $this->_html .= $this->getCurrentShopInfoMsg(); + if (Shop::isFeatureActive()) { + $this->_html .= $this->getCurrentShopInfoMsg(); + } - $this->_html .= $this->renderForm().$this->renderAddForm(); + $this->_html .= $this->renderForm().$this->renderAddForm(); - foreach ($shops as $shop_id) - $links = array_merge($links, MenuTopLinks::gets((int)$id_lang, null, (int)$shop_id)); + foreach ($shops as $shop_id) { + $links = array_merge($links, MenuTopLinks::gets((int)$id_lang, null, (int)$shop_id)); + } - if (!count($links)) - return $this->_html; + if (!count($links)) { + return $this->_html; + } - $this->_html .= $this->renderList(); - return $this->_html; - } + $this->_html .= $this->renderList(); + return $this->_html; + } - protected function getWarningMultishopHtml() - { - return '

'. + protected function getWarningMultishopHtml() + { + return '

'. $this->l('You cannot manage top menu items from a "All Shops" or a "Group Shop" context, select directly the shop you want to edit'). '

'; - } + } - protected function getCurrentShopInfoMsg() - { - $shop_info = null; + protected function getCurrentShopInfoMsg() + { + $shop_info = null; - if (Shop::getContext() == Shop::CONTEXT_SHOP) - $shop_info = sprintf($this->l('The modifications will be applied to shop: %s'), $this->context->shop->name); - else if (Shop::getContext() == Shop::CONTEXT_GROUP) - $shop_info = sprintf($this->l('The modifications will be applied to this group: %s'), Shop::getContextShopGroup()->name); - else - $shop_info = $this->l('The modifications will be applied to all shops'); + if (Shop::getContext() == Shop::CONTEXT_SHOP) { + $shop_info = sprintf($this->l('The modifications will be applied to shop: %s'), $this->context->shop->name); + } else { + if (Shop::getContext() == Shop::CONTEXT_GROUP) { + $shop_info = sprintf($this->l('The modifications will be applied to this group: %s'), Shop::getContextShopGroup()->name); + } else { + $shop_info = $this->l('The modifications will be applied to all shops'); + } + } - return '
'. + return '
'. $shop_info. '
'; - } + } - protected function getMenuItems() - { - $items = Tools::getValue('items'); - if (is_array($items) && count($items)) - return $items; - else - { - $shops = Shop::getContextListShopID(); - $conf = null; + protected function getMenuItems() + { + $items = Tools::getValue('items'); + if (is_array($items) && count($items)) { + return $items; + } else { + $shops = Shop::getContextListShopID(); + $conf = null; - if (count($shops) > 1) - { - foreach ($shops as $key => $shop_id) - { - $shop_group_id = Shop::getGroupFromShop($shop_id); - $conf .= (string)($key > 1 ? ',' : '').Configuration::get('MOD_BLOCKTOPMENU_ITEMS', null, $shop_group_id, $shop_id); - } - } - else - { - $shop_id = (int)$shops[0]; - $shop_group_id = Shop::getGroupFromShop($shop_id); - $conf = Configuration::get('MOD_BLOCKTOPMENU_ITEMS', null, $shop_group_id, $shop_id); - } + if (count($shops) > 1) { + foreach ($shops as $key => $shop_id) { + $shop_group_id = Shop::getGroupFromShop($shop_id); + $conf .= (string)($key > 1 ? ',' : '').Configuration::get('MOD_BLOCKTOPMENU_ITEMS', null, $shop_group_id, $shop_id); + } + } else { + $shop_id = (int)$shops[0]; + $shop_group_id = Shop::getGroupFromShop($shop_id); + $conf = Configuration::get('MOD_BLOCKTOPMENU_ITEMS', null, $shop_group_id, $shop_id); + } - if (strlen($conf)) - return explode(',', $conf); - else - return array(); - } - } + if (strlen($conf)) { + return explode(',', $conf); + } else { + return array(); + } + } + } - protected function makeMenuOption() - { - $id_shop = (int)Shop::getContextShopID(); + protected function makeMenuOption() + { + $id_shop = (int)Shop::getContextShopID(); - $menu_item = $this->getMenuItems(); - $id_lang = (int)$this->context->language->id; + $menu_item = $this->getMenuItems(); + $id_lang = (int)$this->context->language->id; - $html = ''; + foreach ($menu_item as $item) { + if (!$item) { + continue; + } - preg_match($this->pattern, $item, $values); - $id = (int)substr($item, strlen($values[1]), strlen($item)); + preg_match($this->pattern, $item, $values); + $id = (int)substr($item, strlen($values[1]), strlen($item)); - switch (substr($item, 0, strlen($values[1]))) - { + switch (substr($item, 0, strlen($values[1]))) { case 'CAT': $category = new Category((int)$id, (int)$id_lang); - if (Validate::isLoadedObject($category)) - $html .= ''.PHP_EOL; + if (Validate::isLoadedObject($category)) { + $html .= ''.PHP_EOL; + } break; case 'PRD': $product = new Product((int)$id, true, (int)$id_lang); - if (Validate::isLoadedObject($product)) - $html .= ''.PHP_EOL; + if (Validate::isLoadedObject($product)) { + $html .= ''.PHP_EOL; + } break; case 'CMS': $cms = new CMS((int)$id, (int)$id_lang); - if (Validate::isLoadedObject($cms)) - $html .= ''.PHP_EOL; + if (Validate::isLoadedObject($cms)) { + $html .= ''.PHP_EOL; + } break; case 'CMS_CAT': $category = new CMSCategory((int)$id, (int)$id_lang); - if (Validate::isLoadedObject($category)) - $html .= ''.PHP_EOL; + if (Validate::isLoadedObject($category)) { + $html .= ''.PHP_EOL; + } break; // Case to handle the option to show all Manufacturers @@ -423,8 +421,9 @@ class Blocktopmenu extends Module case 'MAN': $manufacturer = new Manufacturer((int)$id, (int)$id_lang); - if (Validate::isLoadedObject($manufacturer)) - $html .= ''.PHP_EOL; + if (Validate::isLoadedObject($manufacturer)) { + $html .= ''.PHP_EOL; + } break; // Case to handle the option to show all Suppliers @@ -434,50 +433,49 @@ class Blocktopmenu extends Module case 'SUP': $supplier = new Supplier((int)$id, (int)$id_lang); - if (Validate::isLoadedObject($supplier)) - $html .= ''.PHP_EOL; + if (Validate::isLoadedObject($supplier)) { + $html .= ''.PHP_EOL; + } break; case 'LNK': $link = MenuTopLinks::get((int)$id, (int)$id_lang, (int)$id_shop); - if (count($link)) - { - if (!isset($link[0]['label']) || ($link[0]['label'] == '')) - { - $default_language = Configuration::get('PS_LANG_DEFAULT'); - $link = MenuTopLinks::get($link[0]['id_linksmenutop'], (int)$default_language, (int)Shop::getContextShopID()); - } - $html .= ''; + if (count($link)) { + if (!isset($link[0]['label']) || ($link[0]['label'] == '')) { + $default_language = Configuration::get('PS_LANG_DEFAULT'); + $link = MenuTopLinks::get($link[0]['id_linksmenutop'], (int)$default_language, (int)Shop::getContextShopID()); + } + $html .= ''; } break; case 'SHOP': $shop = new Shop((int)$id); - if (Validate::isLoadedObject($shop)) - $html .= ''.PHP_EOL; + if (Validate::isLoadedObject($shop)) { + $html .= ''.PHP_EOL; + } break; } - } + } - return $html.''; - } + return $html.''; + } - protected function makeMenu() - { - $menu_items = $this->getMenuItems(); - $id_lang = (int)$this->context->language->id; - $id_shop = (int)Shop::getContextShopID(); + protected function makeMenu() + { + $menu_items = $this->getMenuItems(); + $id_lang = (int)$this->context->language->id; + $id_shop = (int)Shop::getContextShopID(); - foreach ($menu_items as $item) - { - if (!$item) - continue; + foreach ($menu_items as $item) { + if (!$item) { + continue; + } - preg_match($this->pattern, $item, $value); - $id = (int)substr($item, strlen($value[1]), strlen($item)); + preg_match($this->pattern, $item, $value); + $id = (int)substr($item, strlen($value[1]), strlen($item)); - switch (substr($item, 0, strlen($value[1]))) - { + switch (substr($item, 0, strlen($value[1]))) { case 'CAT': $this->_menu .= $this->generateCategoriesMenu(Category::getNestedCategories($id, $id_lang, false, $this->user_groups)); break; @@ -485,24 +483,25 @@ class Blocktopmenu extends Module case 'PRD': $selected = ($this->page_name == 'product' && (Tools::getValue('id_product') == $id)) ? ' class="sfHover"' : ''; $product = new Product((int)$id, true, (int)$id_lang); - if (!is_null($product->id)) - $this->_menu .= ''.$product->name.''.PHP_EOL; + if (!is_null($product->id)) { + $this->_menu .= ''.$product->name.''.PHP_EOL; + } break; case 'CMS': $selected = ($this->page_name == 'cms' && (Tools::getValue('id_cms') == $id)) ? ' class="sfHover"' : ''; $cms = CMS::getLinks((int)$id_lang, array($id)); - if (count($cms)) - $this->_menu .= ''.Tools::safeOutput($cms[0]['meta_title']).''.PHP_EOL; + if (count($cms)) { + $this->_menu .= ''.Tools::safeOutput($cms[0]['meta_title']).''.PHP_EOL; + } break; case 'CMS_CAT': $category = new CMSCategory((int)$id, (int)$id_lang); - if (count($category)) - { - $this->_menu .= '
  • '.$category->name.''; - $this->getCMSMenuItems($category->id); - $this->_menu .= '
  • '.PHP_EOL; + if (count($category)) { + $this->_menu .= '
  • '.$category->name.''; + $this->getCMSMenuItems($category->id); + $this->_menu .= '
  • '.PHP_EOL; } break; @@ -511,22 +510,23 @@ class Blocktopmenu extends Module $link = new Link; $this->_menu .= '
  • '.$this->l('All manufacturers').''; break; case 'MAN': $selected = ($this->page_name == 'manufacturer' && (Tools::getValue('id_manufacturer') == $id)) ? ' class="sfHover"' : ''; $manufacturer = new Manufacturer((int)$id, (int)$id_lang); - if (!is_null($manufacturer->id)) - { - if (intval(Configuration::get('PS_REWRITING_SETTINGS'))) - $manufacturer->link_rewrite = Tools::link_rewrite($manufacturer->name); - else - $manufacturer->link_rewrite = 0; - $link = new Link; - $this->_menu .= ''.Tools::safeOutput($manufacturer->name).'
  • '.PHP_EOL; + if (!is_null($manufacturer->id)) { + if (intval(Configuration::get('PS_REWRITING_SETTINGS'))) { + $manufacturer->link_rewrite = Tools::link_rewrite($manufacturer->name); + } else { + $manufacturer->link_rewrite = 0; + } + $link = new Link; + $this->_menu .= ''.Tools::safeOutput($manufacturer->name).''.PHP_EOL; } break; @@ -535,243 +535,233 @@ class Blocktopmenu extends Module $link = new Link; $this->_menu .= '
  • '.$this->l('All suppliers').''; break; case 'SUP': $selected = ($this->page_name == 'supplier' && (Tools::getValue('id_supplier') == $id)) ? ' class="sfHover"' : ''; $supplier = new Supplier((int)$id, (int)$id_lang); - if (!is_null($supplier->id)) - { - $link = new Link; - $this->_menu .= ''.$supplier->name.'
  • '.PHP_EOL; + if (!is_null($supplier->id)) { + $link = new Link; + $this->_menu .= ''.$supplier->name.''.PHP_EOL; } break; case 'SHOP': $selected = ($this->page_name == 'index' && ($this->context->shop->id == $id)) ? ' class="sfHover"' : ''; $shop = new Shop((int)$id); - if (Validate::isLoadedObject($shop)) - { - $link = new Link; - $this->_menu .= ''.$shop->name.''.PHP_EOL; + if (Validate::isLoadedObject($shop)) { + $link = new Link; + $this->_menu .= ''.$shop->name.''.PHP_EOL; } break; case 'LNK': $link = MenuTopLinks::get((int)$id, (int)$id_lang, (int)$id_shop); - if (count($link)) - { - if (!isset($link[0]['label']) || ($link[0]['label'] == '')) - { - $default_language = Configuration::get('PS_LANG_DEFAULT'); - $link = MenuTopLinks::get($link[0]['id_linksmenutop'], $default_language, (int)Shop::getContextShopID()); - } - $this->_menu .= '
  • '.Tools::safeOutput($link[0]['label']).'
  • '.PHP_EOL; + if (count($link)) { + if (!isset($link[0]['label']) || ($link[0]['label'] == '')) { + $default_language = Configuration::get('PS_LANG_DEFAULT'); + $link = MenuTopLinks::get($link[0]['id_linksmenutop'], $default_language, (int)Shop::getContextShopID()); + } + $this->_menu .= '
  • '.Tools::safeOutput($link[0]['label']).'
  • '.PHP_EOL; } break; } - } - } + } + } - protected function generateCategoriesOption($categories, $items_to_skip = null) - { - $html = ''; + protected function generateCategoriesOption($categories, $items_to_skip = null) + { + $html = ''; - foreach ($categories as $key => $category) - { - if (isset($items_to_skip) /*&& !in_array('CAT'.(int)$category['id_category'], $items_to_skip)*/) - { - $shop = (object) Shop::getShop((int)$category['id_shop']); - $html .= ''; - } + } - if (isset($category['children']) && !empty($category['children'])) - $html .= $this->generateCategoriesOption($category['children'], $items_to_skip); + if (isset($category['children']) && !empty($category['children'])) { + $html .= $this->generateCategoriesOption($category['children'], $items_to_skip); + } + } + return $html; + } - } - return $html; - } + protected function generateCategoriesMenu($categories, $is_children = 0) + { + $html = ''; - protected function generateCategoriesMenu($categories, $is_children = 0) - { - $html = ''; - - foreach ($categories as $key => $category) - { - if ($category['level_depth'] > 1) - { - $cat = new Category($category['id_category']); - $link = Tools::HtmlEntitiesUTF8($cat->getLink()); - } - else - $link = $this->context->link->getPageLink('index'); + foreach ($categories as $key => $category) { + if ($category['level_depth'] > 1) { + $cat = new Category($category['id_category']); + $link = Tools::HtmlEntitiesUTF8($cat->getLink()); + } else { + $link = $this->context->link->getPageLink('index'); + } /* Whenever a category is not active we shouldnt display it to customer */ if ((bool)$category['active'] === false) { break; } - $html .= 'page_name == 'category' + $html .= 'page_name == 'category' && (int)Tools::getValue('id_category') == (int)$category['id_category']) ? ' class="sfHoverForce"' : '').'>'; - $html .= ''.$category['name'].''; + $html .= ''.$category['name'].''; - if (isset($category['children']) && !empty($category['children'])) - { - $html .= '
      '; - $html .= $this->generateCategoriesMenu($category['children'], 1); + if (isset($category['children']) && !empty($category['children'])) { + $html .= '
        '; + $html .= $this->generateCategoriesMenu($category['children'], 1); - if ((int)$category['level_depth'] > 1 && !$is_children) - { - $files = scandir(_PS_CAT_IMG_DIR_); + if ((int)$category['level_depth'] > 1 && !$is_children) { + $files = scandir(_PS_CAT_IMG_DIR_); - if (count(preg_grep('/^'.$category['id_category'].'-([0-9])?_thumb.jpg/i', $files)) > 0) - { - $html .= '
      • '; + if (count(preg_grep('/^'.$category['id_category'].'-([0-9])?_thumb.jpg/i', $files)) > 0) { + $html .= '
      • '; - foreach ($files as $file) - if (preg_match('/^'.$category['id_category'].'-([0-9])?_thumb.jpg/i', $file) === 1) - $html .= '
        context->link->getMediaLink(_THEME_CAT_DIR_.$file) .'" alt="'.Tools::SafeOutput($category['name']).'" title="' .Tools::SafeOutput($category['name']).'" class="imgm" />
        '; + } + } - $html .= '
      • '; - } - } + $html .= ''; + } + } - $html .= '
      '; - } + $html .= '
    '; + } - $html .= ''; - } + $html .= ''; + } - return $html; - } + return $html; + } - protected function getCMSMenuItems($parent, $depth = 1, $id_lang = false) - { - $id_lang = $id_lang ? (int)$id_lang : (int)Context::getContext()->language->id; + protected function getCMSMenuItems($parent, $depth = 1, $id_lang = false) + { + $id_lang = $id_lang ? (int)$id_lang : (int)Context::getContext()->language->id; - if ($depth > 3) - return; + if ($depth > 3) { + return; + } - $categories = $this->getCMSCategories(false, (int)$parent, (int)$id_lang); - $pages = $this->getCMSPages((int)$parent); + $categories = $this->getCMSCategories(false, (int)$parent, (int)$id_lang); + $pages = $this->getCMSPages((int)$parent); - if (count($categories) || count($pages)) - { - $this->_menu .= '
      '; + if (count($categories) || count($pages)) { + $this->_menu .= '
        '; - foreach ($categories as $category) - { - $cat = new CMSCategory((int)$category['id_cms_category'], (int)$id_lang); + foreach ($categories as $category) { + $cat = new CMSCategory((int)$category['id_cms_category'], (int)$id_lang); - $this->_menu .= '
      • '; - $this->_menu .= ''.$category['name'].''; - $this->getCMSMenuItems($category['id_cms_category'], (int)$depth + 1); - $this->_menu .= '
      • '; - } + $this->_menu .= '
      • '; + $this->_menu .= ''.$category['name'].''; + $this->getCMSMenuItems($category['id_cms_category'], (int)$depth + 1); + $this->_menu .= '
      • '; + } - foreach ($pages as $page) - { - $cms = new CMS($page['id_cms'], (int)$id_lang); - $links = $cms->getLinks((int)$id_lang, array((int)$cms->id)); + foreach ($pages as $page) { + $cms = new CMS($page['id_cms'], (int)$id_lang); + $links = $cms->getLinks((int)$id_lang, array((int)$cms->id)); - $selected = ($this->page_name == 'cms' && ((int)Tools::getValue('id_cms') == $page['id_cms'])) ? ' class="sfHoverForce"' : ''; - $this->_menu .= '
      • '; - $this->_menu .= ''.$cms->meta_title.''; - $this->_menu .= '
      • '; - } + $selected = ($this->page_name == 'cms' && ((int)Tools::getValue('id_cms') == $page['id_cms'])) ? ' class="sfHoverForce"' : ''; + $this->_menu .= '
      • '; + $this->_menu .= ''.$cms->meta_title.''; + $this->_menu .= '
      • '; + } - $this->_menu .= '
      '; - } - } + $this->_menu .= '
    '; + } + } - protected function getCMSOptions($parent = 0, $depth = 1, $id_lang = false, $items_to_skip = null, $id_shop = false) - { - $html = ''; - $id_lang = $id_lang ? (int)$id_lang : (int)Context::getContext()->language->id; - $id_shop = ($id_shop !== false) ? $id_shop : Context::getContext()->shop->id; - $categories = $this->getCMSCategories(false, (int)$parent, (int)$id_lang, (int)$id_shop); - $pages = $this->getCMSPages((int)$parent, false, (int)$id_lang, (int)$id_shop); + protected function getCMSOptions($parent = 0, $depth = 1, $id_lang = false, $items_to_skip = null, $id_shop = false) + { + $html = ''; + $id_lang = $id_lang ? (int)$id_lang : (int)Context::getContext()->language->id; + $id_shop = ($id_shop !== false) ? $id_shop : Context::getContext()->shop->id; + $categories = $this->getCMSCategories(false, (int)$parent, (int)$id_lang, (int)$id_shop); + $pages = $this->getCMSPages((int)$parent, false, (int)$id_lang, (int)$id_shop); - $spacer = str_repeat(' ', $this->spacer_size * (int)$depth); + $spacer = str_repeat(' ', $this->spacer_size * (int)$depth); - foreach ($categories as $category) - { - if (isset($items_to_skip) && !in_array('CMS_CAT'.$category['id_cms_category'], $items_to_skip)) - $html .= ''; - $html .= $this->getCMSOptions($category['id_cms_category'], (int)$depth + 1, (int)$id_lang, $items_to_skip); - } + foreach ($categories as $category) { + if (isset($items_to_skip) && !in_array('CMS_CAT'.$category['id_cms_category'], $items_to_skip)) { + $html .= ''; + } + $html .= $this->getCMSOptions($category['id_cms_category'], (int)$depth + 1, (int)$id_lang, $items_to_skip); + } - foreach ($pages as $page) - if (isset($items_to_skip) && !in_array('CMS'.$page['id_cms'], $items_to_skip)) - $html .= ''; + foreach ($pages as $page) { + if (isset($items_to_skip) && !in_array('CMS'.$page['id_cms'], $items_to_skip)) { + $html .= ''; + } + } - return $html; - } + return $html; + } - protected function getCacheId($name = null) - { - $page_name = in_array($this->page_name, array('category', 'supplier', 'manufacturer', 'cms', 'product')) ? $this->page_name : 'index'; - return parent::getCacheId().'|'.$page_name.($page_name != 'index' ? '|'.(int)Tools::getValue('id_'.$page_name) : ''); - } + protected function getCacheId($name = null) + { + $page_name = in_array($this->page_name, array('category', 'supplier', 'manufacturer', 'cms', 'product')) ? $this->page_name : 'index'; + return parent::getCacheId().'|'.$page_name.($page_name != 'index' ? '|'.(int)Tools::getValue('id_'.$page_name) : ''); + } - public function hookHeader() - { - $this->context->controller->addJS($this->_path.'js/hoverIntent.js'); - $this->context->controller->addJS($this->_path.'js/superfish-modified.js'); - $this->context->controller->addJS($this->_path.'js/blocktopmenu.js'); - $this->context->controller->addCSS($this->_path.'css/blocktopmenu.css'); - $this->context->controller->addCSS($this->_path.'css/superfish-modified.css'); - } + public function hookHeader() + { + $this->context->controller->addJS($this->_path.'js/hoverIntent.js'); + $this->context->controller->addJS($this->_path.'js/superfish-modified.js'); + $this->context->controller->addJS($this->_path.'js/blocktopmenu.js'); + $this->context->controller->addCSS($this->_path.'css/blocktopmenu.css'); + $this->context->controller->addCSS($this->_path.'css/superfish-modified.css'); + } - public function hookDisplayTop($param) - { - $this->user_groups = ($this->context->customer->isLogged() ? + public function hookDisplayTop($param) + { + $this->user_groups = ($this->context->customer->isLogged() ? $this->context->customer->getGroups() : array(Configuration::get('PS_UNIDENTIFIED_GROUP'))); - $this->page_name = Dispatcher::getInstance()->getController(); - if (!$this->isCached('blocktopmenu.tpl', $this->getCacheId())) - { - if (Tools::isEmpty($this->_menu)) - $this->makeMenu(); + $this->page_name = Dispatcher::getInstance()->getController(); + if (!$this->isCached('blocktopmenu.tpl', $this->getCacheId())) { + if (Tools::isEmpty($this->_menu)) { + $this->makeMenu(); + } - $shop_id = (int)$this->context->shop->id; - $shop_group_id = Shop::getGroupFromShop($shop_id); + $shop_id = (int)$this->context->shop->id; + $shop_group_id = Shop::getGroupFromShop($shop_id); - $this->smarty->assign('MENU_SEARCH', Configuration::get('MOD_BLOCKTOPMENU_SEARCH', null, $shop_group_id, $shop_id)); - $this->smarty->assign('MENU', $this->_menu); - $this->smarty->assign('this_path', $this->_path); - } + $this->smarty->assign('MENU_SEARCH', Configuration::get('MOD_BLOCKTOPMENU_SEARCH', null, $shop_group_id, $shop_id)); + $this->smarty->assign('MENU', $this->_menu); + $this->smarty->assign('this_path', $this->_path); + } - $html = $this->display(__FILE__, 'blocktopmenu.tpl', $this->getCacheId()); - return $html; - } + $html = $this->display(__FILE__, 'blocktopmenu.tpl', $this->getCacheId()); + return $html; + } - public function hookDisplayNav($params) - { - return $this->hookDisplayTop($params); - } + public function hookDisplayNav($params) + { + return $this->hookDisplayTop($params); + } - protected function getCMSCategories($recursive = false, $parent = 1, $id_lang = false, $id_shop = false) - { - $id_lang = $id_lang ? (int)$id_lang : (int)Context::getContext()->language->id; - $id_shop = ($id_shop !== false) ? $id_shop : Context::getContext()->shop->id; - $join_shop = ''; - $where_shop = ''; + protected function getCMSCategories($recursive = false, $parent = 1, $id_lang = false, $id_shop = false) + { + $id_lang = $id_lang ? (int)$id_lang : (int)Context::getContext()->language->id; + $id_shop = ($id_shop !== false) ? $id_shop : Context::getContext()->shop->id; + $join_shop = ''; + $where_shop = ''; - if (Tools::version_compare(_PS_VERSION_, '1.6.0.12', '>=') == true) - { - $join_shop = ' INNER JOIN `'._DB_PREFIX_.'cms_category_shop` cs + if (Tools::version_compare(_PS_VERSION_, '1.6.0.12', '>=') == true) { + $join_shop = ' INNER JOIN `'._DB_PREFIX_.'cms_category_shop` cs ON (bcp.`id_cms_category` = cs.`id_cms_category`)'; - $where_shop = ' AND cs.`id_shop` = '.(int)$id_shop.' AND cl.`id_shop` = '.(int)$id_shop; - } + $where_shop = ' AND cs.`id_shop` = '.(int)$id_shop.' AND cl.`id_shop` = '.(int)$id_shop; + } - if ($recursive === false) - { - $sql = 'SELECT bcp.`id_cms_category`, bcp.`id_parent`, bcp.`level_depth`, bcp.`active`, bcp.`position`, cl.`name`, cl.`link_rewrite` + if ($recursive === false) { + $sql = 'SELECT bcp.`id_cms_category`, bcp.`id_parent`, bcp.`level_depth`, bcp.`active`, bcp.`position`, cl.`name`, cl.`link_rewrite` FROM `'._DB_PREFIX_.'cms_category` bcp'. $join_shop.' INNER JOIN `'._DB_PREFIX_.'cms_category_lang` cl @@ -780,11 +770,9 @@ class Blocktopmenu extends Module AND bcp.`id_parent` = '.(int)$parent. $where_shop; - return Db::getInstance()->executeS($sql); - } - else - { - $sql = 'SELECT bcp.`id_cms_category`, bcp.`id_parent`, bcp.`level_depth`, bcp.`active`, bcp.`position`, cl.`name`, cl.`link_rewrite` + return Db::getInstance()->executeS($sql); + } else { + $sql = 'SELECT bcp.`id_cms_category`, bcp.`id_parent`, bcp.`level_depth`, bcp.`active`, bcp.`position`, cl.`name`, cl.`link_rewrite` FROM `'._DB_PREFIX_.'cms_category` bcp'. $join_shop.' INNER JOIN `'._DB_PREFIX_.'cms_category_lang` cl @@ -793,30 +781,30 @@ class Blocktopmenu extends Module AND bcp.`id_parent` = '.(int)$parent. $where_shop; - $results = Db::getInstance()->executeS($sql); - foreach ($results as $result) - { - $sub_categories = $this->getCMSCategories(true, $result['id_cms_category'], (int)$id_lang); - if ($sub_categories && count($sub_categories) > 0) - $result['sub_categories'] = $sub_categories; - $categories[] = $result; - } + $results = Db::getInstance()->executeS($sql); + foreach ($results as $result) { + $sub_categories = $this->getCMSCategories(true, $result['id_cms_category'], (int)$id_lang); + if ($sub_categories && count($sub_categories) > 0) { + $result['sub_categories'] = $sub_categories; + } + $categories[] = $result; + } - return isset($categories) ? $categories : false; - } + return isset($categories) ? $categories : false; + } + } - } + protected function getCMSPages($id_cms_category, $id_shop = false, $id_lang = false, $id_shop = false) + { + $id_shop = ($id_shop !== false) ? (int)$id_shop : (int)Context::getContext()->shop->id; + $id_lang = $id_lang ? (int)$id_lang : (int)Context::getContext()->language->id; - protected function getCMSPages($id_cms_category, $id_shop = false, $id_lang = false, $id_shop = false) - { - $id_shop = ($id_shop !== false) ? (int)$id_shop : (int)Context::getContext()->shop->id; - $id_lang = $id_lang ? (int)$id_lang : (int)Context::getContext()->language->id; + $where_shop = ''; + if (Tools::version_compare(_PS_VERSION_, '1.6.0.12', '>=') == true) { + $where_shop = ' AND cl.`id_shop` = '.(int)$id_shop; + } - $where_shop = ''; - if (Tools::version_compare(_PS_VERSION_, '1.6.0.12', '>=') == true) - $where_shop = ' AND cl.`id_shop` = '.(int)$id_shop; - - $sql = 'SELECT c.`id_cms`, cl.`meta_title`, cl.`link_rewrite` + $sql = 'SELECT c.`id_cms`, cl.`meta_title`, cl.`link_rewrite` FROM `'._DB_PREFIX_.'cms` c INNER JOIN `'._DB_PREFIX_.'cms_shop` cs ON (c.`id_cms` = cs.`id_cms`) @@ -829,131 +817,130 @@ class Blocktopmenu extends Module AND c.`active` = 1 ORDER BY `position`'; - return Db::getInstance()->executeS($sql); - } + return Db::getInstance()->executeS($sql); + } - public function hookActionObjectCategoryAddAfter($params) - { - $this->clearMenuCache(); - } + public function hookActionObjectCategoryAddAfter($params) + { + $this->clearMenuCache(); + } - public function hookActionObjectCategoryUpdateAfter($params) - { - $this->clearMenuCache(); - } + public function hookActionObjectCategoryUpdateAfter($params) + { + $this->clearMenuCache(); + } - public function hookActionObjectCategoryDeleteAfter($params) - { - $this->clearMenuCache(); - } + public function hookActionObjectCategoryDeleteAfter($params) + { + $this->clearMenuCache(); + } - public function hookActionObjectCmsUpdateAfter($params) - { - $this->clearMenuCache(); - } + public function hookActionObjectCmsUpdateAfter($params) + { + $this->clearMenuCache(); + } - public function hookActionObjectCmsDeleteAfter($params) - { - $this->clearMenuCache(); - } + public function hookActionObjectCmsDeleteAfter($params) + { + $this->clearMenuCache(); + } - public function hookActionObjectCmsAddAfter($params) - { - $this->clearMenuCache(); - } + public function hookActionObjectCmsAddAfter($params) + { + $this->clearMenuCache(); + } - public function hookActionObjectSupplierUpdateAfter($params) - { - $this->clearMenuCache(); - } + public function hookActionObjectSupplierUpdateAfter($params) + { + $this->clearMenuCache(); + } - public function hookActionObjectSupplierDeleteAfter($params) - { - $this->clearMenuCache(); - } + public function hookActionObjectSupplierDeleteAfter($params) + { + $this->clearMenuCache(); + } - public function hookActionObjectSupplierAddAfter($params) - { - $this->clearMenuCache(); - } + public function hookActionObjectSupplierAddAfter($params) + { + $this->clearMenuCache(); + } - public function hookActionObjectManufacturerUpdateAfter($params) - { - $this->clearMenuCache(); - } + public function hookActionObjectManufacturerUpdateAfter($params) + { + $this->clearMenuCache(); + } - public function hookActionObjectManufacturerDeleteAfter($params) - { - $this->clearMenuCache(); - } + public function hookActionObjectManufacturerDeleteAfter($params) + { + $this->clearMenuCache(); + } - public function hookActionObjectManufacturerAddAfter($params) - { - $this->clearMenuCache(); - } + public function hookActionObjectManufacturerAddAfter($params) + { + $this->clearMenuCache(); + } - public function hookActionObjectProductUpdateAfter($params) - { - $this->clearMenuCache(); - } + public function hookActionObjectProductUpdateAfter($params) + { + $this->clearMenuCache(); + } - public function hookActionObjectProductDeleteAfter($params) - { - $this->clearMenuCache(); - } + public function hookActionObjectProductDeleteAfter($params) + { + $this->clearMenuCache(); + } - public function hookActionObjectProductAddAfter($params) - { - $this->clearMenuCache(); - } + public function hookActionObjectProductAddAfter($params) + { + $this->clearMenuCache(); + } - public function hookCategoryUpdate($params) - { - $this->clearMenuCache(); - } + public function hookCategoryUpdate($params) + { + $this->clearMenuCache(); + } - protected function clearMenuCache() - { - $this->_clearCache('blocktopmenu.tpl'); - } + protected function clearMenuCache() + { + $this->_clearCache('blocktopmenu.tpl'); + } - public function hookActionShopDataDuplication($params) - { - $linksmenutop = Db::getInstance()->executeS(' + public function hookActionShopDataDuplication($params) + { + $linksmenutop = Db::getInstance()->executeS(' SELECT * FROM '._DB_PREFIX_.'linksmenutop WHERE id_shop = '.(int)$params['old_id_shop'] ); - foreach ($linksmenutop as $id => $link) - { - Db::getInstance()->execute(' + foreach ($linksmenutop as $id => $link) { + Db::getInstance()->execute(' INSERT IGNORE INTO '._DB_PREFIX_.'linksmenutop (id_linksmenutop, id_shop, new_window) VALUES (null, '.(int)$params['new_id_shop'].', '.(int)$link['new_window'].')'); - $linksmenutop[$id]['new_id_linksmenutop'] = Db::getInstance()->Insert_ID(); - } + $linksmenutop[$id]['new_id_linksmenutop'] = Db::getInstance()->Insert_ID(); + } - foreach ($linksmenutop as $id => $link) - { - $lang = Db::getInstance()->executeS(' + foreach ($linksmenutop as $id => $link) { + $lang = Db::getInstance()->executeS(' SELECT id_lang, '.(int)$params['new_id_shop'].', label, link FROM '._DB_PREFIX_.'linksmenutop_lang WHERE id_linksmenutop = '.(int)$link['id_linksmenutop'].' AND id_shop = '.(int)$params['old_id_shop']); - foreach ($lang as $l) - Db::getInstance()->execute(' + foreach ($lang as $l) { + Db::getInstance()->execute(' INSERT IGNORE INTO '._DB_PREFIX_.'linksmenutop_lang (id_linksmenutop, id_lang, id_shop, label, link) VALUES ('.(int)$link['new_id_linksmenutop'].', '.(int)$l['id_lang'].', '.(int)$params['new_id_shop'].', '.(int)$l['label'].', '.(int)$l['link'].' )'); - } - } + } + } + } - public function renderForm() - { - $shops = Shop::getContextListShopID(); + public function renderForm() + { + $shops = Shop::getContextListShopID(); - if (count($shops) == 1) - $fields_form = array( + if (count($shops) == 1) { + $fields_form = array( 'form' => array( 'legend' => array( 'title' => $this->l('Menu Top Link'), @@ -991,8 +978,8 @@ class Blocktopmenu extends Module ) ), ); - else - $fields_form = array( + } else { + $fields_form = array( 'form' => array( 'legend' => array( 'title' => $this->l('Menu Top Link'), @@ -1026,32 +1013,33 @@ class Blocktopmenu extends Module ) ), ); + } - $helper = new HelperForm(); - $helper->show_toolbar = false; - $helper->table = $this->table; - $lang = new Language((int)Configuration::get('PS_LANG_DEFAULT')); - $helper->default_form_language = $lang->id; - $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0; - $this->fields_form = array(); - $helper->module = $this; - $helper->identifier = $this->identifier; - $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false). + $helper = new HelperForm(); + $helper->show_toolbar = false; + $helper->table = $this->table; + $lang = new Language((int)Configuration::get('PS_LANG_DEFAULT')); + $helper->default_form_language = $lang->id; + $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0; + $this->fields_form = array(); + $helper->module = $this; + $helper->identifier = $this->identifier; + $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false). '&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name; - $helper->token = Tools::getAdminTokenLite('AdminModules'); - $helper->tpl_vars = array( + $helper->token = Tools::getAdminTokenLite('AdminModules'); + $helper->tpl_vars = array( 'fields_value' => $this->getConfigFieldsValues(), 'languages' => $this->context->controller->getLanguages(), 'id_language' => $this->context->language->id, 'choices' => $this->renderChoicesSelect(), 'selected_links' => $this->makeMenuOption(), ); - return $helper->generateForm(array($fields_form)); - } + return $helper->generateForm(array($fields_form)); + } - public function renderAddForm() - { - $fields_form = array( + public function renderAddForm() + { + $fields_form = array( 'form' => array( 'legend' => array( 'title' => (Tools::getIsset('updatelinksmenutop') && !Tools::getValue('updatelinksmenutop')) ? @@ -1097,137 +1085,143 @@ class Blocktopmenu extends Module ), ); - $helper = new HelperForm(); - $helper->show_toolbar = false; - $helper->table = $this->table; - $lang = new Language((int)Configuration::get('PS_LANG_DEFAULT')); - $helper->default_form_language = $lang->id; - $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0; - $this->fields_form = array(); - $helper->identifier = $this->identifier; - $helper->fields_value = $this->getAddLinkFieldsValues(); + $helper = new HelperForm(); + $helper->show_toolbar = false; + $helper->table = $this->table; + $lang = new Language((int)Configuration::get('PS_LANG_DEFAULT')); + $helper->default_form_language = $lang->id; + $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0; + $this->fields_form = array(); + $helper->identifier = $this->identifier; + $helper->fields_value = $this->getAddLinkFieldsValues(); - if (Tools::getIsset('updatelinksmenutop') && !Tools::getValue('updatelinksmenutop')) - $fields_form['form']['submit'] = array( + if (Tools::getIsset('updatelinksmenutop') && !Tools::getValue('updatelinksmenutop')) { + $fields_form['form']['submit'] = array( 'name' => 'updatelinksmenutop', 'title' => $this->l('Update') ); + } - if (Tools::isSubmit('updatelinksmenutop')) - { - $fields_form['form']['input'][] = array('type' => 'hidden', 'name' => 'updatelink'); - $fields_form['form']['input'][] = array('type' => 'hidden', 'name' => 'id_linksmenutop'); - $helper->fields_value['updatelink'] = ''; - } + if (Tools::isSubmit('updatelinksmenutop')) { + $fields_form['form']['input'][] = array('type' => 'hidden', 'name' => 'updatelink'); + $fields_form['form']['input'][] = array('type' => 'hidden', 'name' => 'id_linksmenutop'); + $helper->fields_value['updatelink'] = ''; + } - $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false). + $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false). '&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name; - $helper->token = Tools::getAdminTokenLite('AdminModules'); - $helper->languages = $this->context->controller->getLanguages(); - $helper->default_form_language = (int)$this->context->language->id; + $helper->token = Tools::getAdminTokenLite('AdminModules'); + $helper->languages = $this->context->controller->getLanguages(); + $helper->default_form_language = (int)$this->context->language->id; - return $helper->generateForm(array($fields_form)); - } + return $helper->generateForm(array($fields_form)); + } - public function renderChoicesSelect() - { - $spacer = str_repeat(' ', $this->spacer_size); - $items = $this->getMenuItems(); + public function renderChoicesSelect() + { + $spacer = str_repeat(' ', $this->spacer_size); + $items = $this->getMenuItems(); - $html = ''; + $html .= ''; + $html .= $this->getCMSOptions(0, 1, $this->context->language->id, $items); + $html .= ''; // BEGIN SUPPLIER $html .= ''; // Option to show all Suppliers $html .= ''; - $suppliers = Supplier::getSuppliers(false, $this->context->language->id); - foreach ($suppliers as $supplier) - if (!in_array('SUP'.$supplier['id_supplier'], $items)) - $html .= ''; - $html .= ''; + $suppliers = Supplier::getSuppliers(false, $this->context->language->id); + foreach ($suppliers as $supplier) { + if (!in_array('SUP'.$supplier['id_supplier'], $items)) { + $html .= ''; + } + } + $html .= ''; // BEGIN Manufacturer $html .= ''; // Option to show all Manufacturers $html .= ''; - $manufacturers = Manufacturer::getManufacturers(false, $this->context->language->id); - foreach ($manufacturers as $manufacturer) - if (!in_array('MAN'.$manufacturer['id_manufacturer'], $items)) - $html .= ''; - $html .= ''; + $manufacturers = Manufacturer::getManufacturers(false, $this->context->language->id); + foreach ($manufacturers as $manufacturer) { + if (!in_array('MAN'.$manufacturer['id_manufacturer'], $items)) { + $html .= ''; + } + } + $html .= ''; // BEGIN Categories $shop = new Shop((int)Shop::getContextShopID()); - $html .= ''; + $html .= ''; - $shops_to_get = Shop::getContextListShopID(); + $shops_to_get = Shop::getContextListShopID(); - foreach ($shops_to_get as $shop_id) - $html .= $this->generateCategoriesOption($this->customGetNestedCategories($shop_id, null, (int)$this->context->language->id, false), $items); - $html .= ''; + foreach ($shops_to_get as $shop_id) { + $html .= $this->generateCategoriesOption($this->customGetNestedCategories($shop_id, null, (int)$this->context->language->id, false), $items); + } + $html .= ''; // BEGIN Shops - if (Shop::isFeatureActive()) - { - $html .= ''; - $shops = Shop::getShopsCollection(); - foreach ($shops as $shop) - { - if (!$shop->setUrl() && !$shop->getBaseURL()) - continue; + if (Shop::isFeatureActive()) { + $html .= ''; + $shops = Shop::getShopsCollection(); + foreach ($shops as $shop) { + if (!$shop->setUrl() && !$shop->getBaseURL()) { + continue; + } - if (!in_array('SHOP'.(int)$shop->id, $items)) - $html .= ''; - } - $html .= ''; + if (!in_array('SHOP'.(int)$shop->id, $items)) { + $html .= ''; + } + } + $html .= ''; } // BEGIN Products $html .= ''; - $html .= ''; - $html .= ''; + $html .= ''; + $html .= ''; // BEGIN Menu Top Links $html .= ''; - $links = MenuTopLinks::gets($this->context->language->id, null, (int)Shop::getContextShopID()); - foreach ($links as $link) - { - if ($link['label'] == '') - { - $default_language = Configuration::get('PS_LANG_DEFAULT'); - $link = MenuTopLinks::get($link['id_linksmenutop'], $default_language, (int)Shop::getContextShopID()); - if (!in_array('LNK'.(int)$link[0]['id_linksmenutop'], $items)) - $html .= ''; - } - elseif (!in_array('LNK'.(int)$link['id_linksmenutop'], $items)) - $html .= ''; - } - $html .= ''; - $html .= ''; - return $html; - } + $links = MenuTopLinks::gets($this->context->language->id, null, (int)Shop::getContextShopID()); + foreach ($links as $link) { + if ($link['label'] == '') { + $default_language = Configuration::get('PS_LANG_DEFAULT'); + $link = MenuTopLinks::get($link['id_linksmenutop'], $default_language, (int)Shop::getContextShopID()); + if (!in_array('LNK'.(int)$link[0]['id_linksmenutop'], $items)) { + $html .= ''; + } + } elseif (!in_array('LNK'.(int)$link['id_linksmenutop'], $items)) { + $html .= ''; + } + } + $html .= ''; + $html .= ''; + return $html; + } - public function customGetNestedCategories($shop_id, $root_category = null, $id_lang = false, $active = false, $groups = null, $use_shop_restriction = true, $sql_filter = '', $sql_sort = '', $sql_limit = '') - { - if (isset($root_category) && !Validate::isInt($root_category)) - die(Tools::displayError()); + public function customGetNestedCategories($shop_id, $root_category = null, $id_lang = false, $active = false, $groups = null, $use_shop_restriction = true, $sql_filter = '', $sql_sort = '', $sql_limit = '') + { + if (isset($root_category) && !Validate::isInt($root_category)) { + die(Tools::displayError()); + } - if (!Validate::isBool($active)) - die(Tools::displayError()); + if (!Validate::isBool($active)) { + die(Tools::displayError()); + } - if (isset($groups) && Group::isFeatureActive() && !is_array($groups)) - $groups = (array)$groups; + if (isset($groups) && Group::isFeatureActive() && !is_array($groups)) { + $groups = (array)$groups; + } - $cache_id = 'Category::getNestedCategories_'.md5((int)$shop_id.(int)$root_category.(int)$id_lang.(int)$active.(int)$active + $cache_id = 'Category::getNestedCategories_'.md5((int)$shop_id.(int)$root_category.(int)$id_lang.(int)$active.(int)$active .(isset($groups) && Group::isFeatureActive() ? implode('', $groups) : '')); - if (!Cache::isStored($cache_id)) - { - $result = Db::getInstance()->executeS(' + if (!Cache::isStored($cache_id)) { + $result = Db::getInstance()->executeS(' SELECT c.*, cl.* FROM `'._DB_PREFIX_.'category` c INNER JOIN `'._DB_PREFIX_.'category_shop` category_shop ON (category_shop.`id_category` = c.`id_category` AND category_shop.`id_shop` = "'.(int)$shop_id.'") @@ -1241,95 +1235,91 @@ class Blocktopmenu extends Module '.($sql_limit != '' ? $sql_limit : '') ); - $categories = array(); - $buff = array(); + $categories = array(); + $buff = array(); - foreach ($result as $row) - { - $current = &$buff[$row['id_category']]; - $current = $row; + foreach ($result as $row) { + $current = &$buff[$row['id_category']]; + $current = $row; - if ($row['id_parent'] == 0) - $categories[$row['id_category']] = &$current; - else - $buff[$row['id_parent']]['children'][$row['id_category']] = &$current; - } + if ($row['id_parent'] == 0) { + $categories[$row['id_category']] = &$current; + } else { + $buff[$row['id_parent']]['children'][$row['id_category']] = &$current; + } + } - Cache::store($cache_id, $categories); - } + Cache::store($cache_id, $categories); + } - return Cache::retrieve($cache_id); - } + return Cache::retrieve($cache_id); + } - public function getConfigFieldsValues() - { - $shops = Shop::getContextListShopID(); - $is_search_on = true; + public function getConfigFieldsValues() + { + $shops = Shop::getContextListShopID(); + $is_search_on = true; - foreach ($shops as $shop_id) - { - $shop_group_id = Shop::getGroupFromShop($shop_id); - $is_search_on &= (bool)Configuration::get('MOD_BLOCKTOPMENU_SEARCH', null, $shop_group_id, $shop_id); + foreach ($shops as $shop_id) { + $shop_group_id = Shop::getGroupFromShop($shop_id); + $is_search_on &= (bool)Configuration::get('MOD_BLOCKTOPMENU_SEARCH', null, $shop_group_id, $shop_id); + } - } - - return array( + return array( 'search' => (int)$is_search_on ); - } + } - public function getAddLinkFieldsValues() - { - $links_label_edit = ''; - $labels_edit = ''; - $new_window_edit = ''; + public function getAddLinkFieldsValues() + { + $links_label_edit = ''; + $labels_edit = ''; + $new_window_edit = ''; - if (Tools::isSubmit('updatelinksmenutop')) - { - $link = MenuTopLinks::getLinkLang(Tools::getValue('id_linksmenutop'), (int)Shop::getContextShopID()); + if (Tools::isSubmit('updatelinksmenutop')) { + $link = MenuTopLinks::getLinkLang(Tools::getValue('id_linksmenutop'), (int)Shop::getContextShopID()); - foreach ($link['link'] as $key => $label) - $link['link'][$key] = Tools::htmlentitiesDecodeUTF8($label); + foreach ($link['link'] as $key => $label) { + $link['link'][$key] = Tools::htmlentitiesDecodeUTF8($label); + } - $links_label_edit = $link['link']; - $labels_edit = $link['label']; - $new_window_edit = $link['new_window']; - } + $links_label_edit = $link['link']; + $labels_edit = $link['label']; + $new_window_edit = $link['new_window']; + } - $fields_values = array( + $fields_values = array( 'new_window' => Tools::getValue('new_window', $new_window_edit), 'id_linksmenutop' => Tools::getValue('id_linksmenutop'), ); - if (Tools::getValue('submitAddmodule')) - { - foreach (Language::getLanguages(false) as $lang) - { - $fields_values['label'][$lang['id_lang']] = ''; - $fields_values['link'][$lang['id_lang']] = ''; - } - } - else - foreach (Language::getLanguages(false) as $lang) - { - $fields_values['label'][$lang['id_lang']] = Tools::getValue('label_'.(int)$lang['id_lang'], isset($labels_edit[$lang['id_lang']]) ? + if (Tools::getValue('submitAddmodule')) { + foreach (Language::getLanguages(false) as $lang) { + $fields_values['label'][$lang['id_lang']] = ''; + $fields_values['link'][$lang['id_lang']] = ''; + } + } else { + foreach (Language::getLanguages(false) as $lang) { + $fields_values['label'][$lang['id_lang']] = Tools::getValue('label_'.(int)$lang['id_lang'], isset($labels_edit[$lang['id_lang']]) ? $labels_edit[$lang['id_lang']] : ''); - $fields_values['link'][$lang['id_lang']] = Tools::getValue('link_'.(int)$lang['id_lang'], isset($links_label_edit[$lang['id_lang']]) ? + $fields_values['link'][$lang['id_lang']] = Tools::getValue('link_'.(int)$lang['id_lang'], isset($links_label_edit[$lang['id_lang']]) ? $links_label_edit[$lang['id_lang']] : ''); - } + } + } - return $fields_values; - } + return $fields_values; + } - public function renderList() - { - $shops = Shop::getContextListShopID(); - $links = array(); + public function renderList() + { + $shops = Shop::getContextListShopID(); + $links = array(); - foreach ($shops as $shop_id) - $links = array_merge($links, MenuTopLinks::gets((int)$this->context->language->id, null, (int)$shop_id)); + foreach ($shops as $shop_id) { + $links = array_merge($links, MenuTopLinks::gets((int)$this->context->language->id, null, (int)$shop_id)); + } - $fields_list = array( + $fields_list = array( 'id_linksmenutop' => array( 'title' => $this->l('Link ID'), 'type' => 'text', @@ -1354,18 +1344,18 @@ class Blocktopmenu extends Module ) ); - $helper = new HelperList(); - $helper->shopLinkType = ''; - $helper->simple_header = true; - $helper->identifier = 'id_linksmenutop'; - $helper->table = 'linksmenutop'; - $helper->actions = array('edit', 'delete'); - $helper->show_toolbar = false; - $helper->module = $this; - $helper->title = $this->l('Link list'); - $helper->token = Tools::getAdminTokenLite('AdminModules'); - $helper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name; + $helper = new HelperList(); + $helper->shopLinkType = ''; + $helper->simple_header = true; + $helper->identifier = 'id_linksmenutop'; + $helper->table = 'linksmenutop'; + $helper->actions = array('edit', 'delete'); + $helper->show_toolbar = false; + $helper->module = $this; + $helper->title = $this->l('Link list'); + $helper->token = Tools::getAdminTokenLite('AdminModules'); + $helper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name; - return $helper->generateList($links, $fields_list); - } + return $helper->generateList($links, $fields_list); + } } diff --git a/menutoplinks.class.php b/menutoplinks.class.php index c86dfb8..e5cdc9d 100644 --- a/menutoplinks.class.php +++ b/menutoplinks.class.php @@ -26,26 +26,26 @@ class MenuTopLinks { - public static function gets($id_lang, $id_linksmenutop = null, $id_shop) - { - $sql = 'SELECT l.id_linksmenutop, l.new_window, s.name, ll.link, ll.label + public static function gets($id_lang, $id_linksmenutop = null, $id_shop) + { + $sql = 'SELECT l.id_linksmenutop, l.new_window, s.name, ll.link, ll.label FROM '._DB_PREFIX_.'linksmenutop l LEFT JOIN '._DB_PREFIX_.'linksmenutop_lang ll ON (l.id_linksmenutop = ll.id_linksmenutop AND ll.id_lang = '.(int)$id_lang.' AND ll.id_shop='.(int)$id_shop.') LEFT JOIN '._DB_PREFIX_.'shop s ON l.id_shop = s.id_shop WHERE 1 '.((!is_null($id_linksmenutop)) ? ' AND l.id_linksmenutop = "'.(int)$id_linksmenutop.'"' : '').' AND l.id_shop IN (0, '.(int)$id_shop.')'; - return Db::getInstance()->executeS($sql); - } + return Db::getInstance()->executeS($sql); + } - public static function get($id_linksmenutop, $id_lang, $id_shop) - { - return self::gets($id_lang, $id_linksmenutop, $id_shop); - } + public static function get($id_linksmenutop, $id_lang, $id_shop) + { + return self::gets($id_lang, $id_linksmenutop, $id_shop); + } - public static function getLinkLang($id_linksmenutop, $id_shop) - { - $ret = Db::getInstance()->executeS(' + public static function getLinkLang($id_linksmenutop, $id_shop) + { + $ret = Db::getInstance()->executeS(' SELECT l.id_linksmenutop, l.new_window, ll.link, ll.label, ll.id_lang FROM '._DB_PREFIX_.'linksmenutop l LEFT JOIN '._DB_PREFIX_.'linksmenutop_lang ll ON (l.id_linksmenutop = ll.id_linksmenutop AND ll.id_shop='.(int)$id_shop.') @@ -54,40 +54,41 @@ class MenuTopLinks AND l.id_shop IN (0, '.(int)$id_shop.') '); - $link = array(); - $label = array(); - $new_window = false; + $link = array(); + $label = array(); + $new_window = false; - foreach ($ret as $line) - { - $link[$line['id_lang']] = Tools::safeOutput($line['link']); - $label[$line['id_lang']] = Tools::safeOutput($line['label']); - $new_window = (bool)$line['new_window']; - } + foreach ($ret as $line) { + $link[$line['id_lang']] = Tools::safeOutput($line['link']); + $label[$line['id_lang']] = Tools::safeOutput($line['label']); + $new_window = (bool)$line['new_window']; + } - return array('link' => $link, 'label' => $label, 'new_window' => $new_window); - } + return array('link' => $link, 'label' => $label, 'new_window' => $new_window); + } - public static function add($link, $label, $newWindow = 0, $id_shop) - { - if(!is_array($label)) - return false; - if(!is_array($link)) - return false; + public static function add($link, $label, $newWindow = 0, $id_shop) + { + if (!is_array($label)) { + return false; + } + if (!is_array($link)) { + return false; + } - Db::getInstance()->insert( + Db::getInstance()->insert( 'linksmenutop', array( 'new_window'=>(int)$newWindow, 'id_shop' => (int)$id_shop ) ); - $id_linksmenutop = Db::getInstance()->Insert_ID(); + $id_linksmenutop = Db::getInstance()->Insert_ID(); - $result = true; + $result = true; - foreach ($label as $id_lang=>$label) - $result &= Db::getInstance()->insert( + foreach ($label as $id_lang=>$label) { + $result &= Db::getInstance()->insert( 'linksmenutop_lang', array( 'id_linksmenutop'=>(int)$id_linksmenutop, @@ -97,18 +98,21 @@ class MenuTopLinks 'link'=>pSQL($link[$id_lang]) ) ); + } - return $result; - } + return $result; + } - public static function update($link, $labels, $newWindow = 0, $id_shop, $id_link) - { - if(!is_array($labels)) - return false; - if(!is_array($link)) - return false; + public static function update($link, $labels, $newWindow = 0, $id_shop, $id_link) + { + if (!is_array($labels)) { + return false; + } + if (!is_array($link)) { + return false; + } - Db::getInstance()->update( + Db::getInstance()->update( 'linksmenutop', array( 'new_window'=>(int)$newWindow, @@ -117,8 +121,8 @@ class MenuTopLinks 'id_linksmenutop = '.(int)$id_link ); - foreach ($labels as $id_lang => $label) - Db::getInstance()->update( + foreach ($labels as $id_lang => $label) { + Db::getInstance()->update( 'linksmenutop_lang', array( 'id_shop'=>(int)$id_shop, @@ -127,16 +131,16 @@ class MenuTopLinks ), 'id_linksmenutop = '.(int)$id_link.' AND id_lang = '.(int)$id_lang ); - } + } + } - public static function remove($id_linksmenutop, $id_shop) - { - $result = true; - $result &= Db::getInstance()->delete('linksmenutop', 'id_linksmenutop = '.(int)$id_linksmenutop.' AND id_shop = '.(int)$id_shop); - $result &= Db::getInstance()->delete('linksmenutop_lang', 'id_linksmenutop = '.(int)$id_linksmenutop); + public static function remove($id_linksmenutop, $id_shop) + { + $result = true; + $result &= Db::getInstance()->delete('linksmenutop', 'id_linksmenutop = '.(int)$id_linksmenutop.' AND id_shop = '.(int)$id_shop); + $result &= Db::getInstance()->delete('linksmenutop_lang', 'id_linksmenutop = '.(int)$id_linksmenutop); - return $result; - } - + return $result; + } } diff --git a/upgrade/install-1.6.php b/upgrade/install-1.6.php index 9018355..948aee7 100644 --- a/upgrade/install-1.6.php +++ b/upgrade/install-1.6.php @@ -1,9 +1,10 @@ registerHook('actionObjectCategoryAddAfter')); + return ($object->registerHook('actionObjectCategoryAddAfter')); } diff --git a/upgrade/install-2.1.1.php b/upgrade/install-2.1.1.php index aa0b006..56a666a 100644 --- a/upgrade/install-2.1.1.php +++ b/upgrade/install-2.1.1.php @@ -23,10 +23,11 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA */ -if (!defined('_PS_VERSION_')) - exit; +if (!defined('_PS_VERSION_')) { + exit; +} function upgrade_module_2_1_1($object) { - return ($object->registerHook('header')); + return ($object->registerHook('header')); }