[PSR-2] Fix braces
This commit is contained in:
+205
-215
@@ -84,14 +84,17 @@ class Blocktopmenu extends Module
|
|||||||
!$this->registerHook('actionObjectProductDeleteAfter') ||
|
!$this->registerHook('actionObjectProductDeleteAfter') ||
|
||||||
!$this->registerHook('actionObjectProductAddAfter') ||
|
!$this->registerHook('actionObjectProductAddAfter') ||
|
||||||
!$this->registerHook('categoryUpdate') ||
|
!$this->registerHook('categoryUpdate') ||
|
||||||
!$this->registerHook('actionShopDataDuplication'))
|
!$this->registerHook('actionShopDataDuplication')) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$this->clearMenuCache();
|
$this->clearMenuCache();
|
||||||
|
|
||||||
if ($delete_params)
|
if ($delete_params) {
|
||||||
if (!$this->installDb() || !Configuration::updateGlobalValue('MOD_BLOCKTOPMENU_ITEMS', 'CAT3,CAT26') || !Configuration::updateGlobalValue('MOD_BLOCKTOPMENU_SEARCH', '1'))
|
if (!$this->installDb() || !Configuration::updateGlobalValue('MOD_BLOCKTOPMENU_ITEMS', 'CAT3,CAT26') || !Configuration::updateGlobalValue('MOD_BLOCKTOPMENU_SEARCH', '1')) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -118,14 +121,17 @@ class Blocktopmenu extends Module
|
|||||||
|
|
||||||
public function uninstall($delete_params = true)
|
public function uninstall($delete_params = true)
|
||||||
{
|
{
|
||||||
if (!parent::uninstall())
|
if (!parent::uninstall()) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$this->clearMenuCache();
|
$this->clearMenuCache();
|
||||||
|
|
||||||
if ($delete_params)
|
if ($delete_params) {
|
||||||
if (!$this->uninstallDB() || !Configuration::deleteByName('MOD_BLOCKTOPMENU_ITEMS') || !Configuration::deleteByName('MOD_BLOCKTOPMENU_SEARCH'))
|
if (!$this->uninstallDB() || !Configuration::deleteByName('MOD_BLOCKTOPMENU_ITEMS') || !Configuration::deleteByName('MOD_BLOCKTOPMENU_SEARCH')) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -139,10 +145,12 @@ class Blocktopmenu extends Module
|
|||||||
|
|
||||||
public function reset()
|
public function reset()
|
||||||
{
|
{
|
||||||
if (!$this->uninstall(false))
|
if (!$this->uninstall(false)) {
|
||||||
return false;
|
return false;
|
||||||
if (!$this->install(false))
|
}
|
||||||
|
if (!$this->install(false)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -162,49 +170,44 @@ class Blocktopmenu extends Module
|
|||||||
|
|
||||||
$update_cache = false;
|
$update_cache = false;
|
||||||
|
|
||||||
if (Tools::isSubmit('submitBlocktopmenu'))
|
if (Tools::isSubmit('submitBlocktopmenu')) {
|
||||||
{
|
|
||||||
$errors_update_shops = array();
|
$errors_update_shops = array();
|
||||||
$items = Tools::getValue('items');
|
$items = Tools::getValue('items');
|
||||||
$shops = Shop::getContextListShopID();
|
$shops = Shop::getContextListShopID();
|
||||||
|
|
||||||
|
|
||||||
foreach ($shops as $shop_id)
|
foreach ($shops as $shop_id) {
|
||||||
{
|
|
||||||
$shop_group_id = Shop::getGroupFromShop($shop_id);
|
$shop_group_id = Shop::getGroupFromShop($shop_id);
|
||||||
$updated = true;
|
$updated = true;
|
||||||
|
|
||||||
if (count($shops) == 1)
|
if (count($shops) == 1) {
|
||||||
{
|
if (is_array($items) && count($items)) {
|
||||||
if (is_array($items) && count($items))
|
|
||||||
$updated = Configuration::updateValue('MOD_BLOCKTOPMENU_ITEMS', (string)implode(',', $items), false, (int)$shop_group_id, (int)$shop_id);
|
$updated = Configuration::updateValue('MOD_BLOCKTOPMENU_ITEMS', (string)implode(',', $items), false, (int)$shop_group_id, (int)$shop_id);
|
||||||
else
|
} else {
|
||||||
$updated = Configuration::updateValue('MOD_BLOCKTOPMENU_ITEMS', '', false, (int)$shop_group_id, (int)$shop_id);
|
$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)
|
if (!$updated) {
|
||||||
{
|
|
||||||
$shop = new Shop($shop_id);
|
$shop = new Shop($shop_id);
|
||||||
$errors_update_shops[] = $shop->name;
|
$errors_update_shops[] = $shop->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!count($errors_update_shops))
|
if (!count($errors_update_shops)) {
|
||||||
$this->_html .= $this->displayConfirmation($this->l('The settings have been updated.'));
|
$this->_html .= $this->displayConfirmation($this->l('The settings have been updated.'));
|
||||||
else
|
} else {
|
||||||
$this->_html .= $this->displayError(sprintf($this->l('Unable to update settings for the following shop(s): %s'), implode(', ', $errors_update_shops)));
|
$this->_html .= $this->displayError(sprintf($this->l('Unable to update settings for the following shop(s): %s'), implode(', ', $errors_update_shops)));
|
||||||
|
}
|
||||||
|
|
||||||
$update_cache = true;
|
$update_cache = true;
|
||||||
}
|
} else {
|
||||||
else if (Tools::isSubmit('submitBlocktopmenuLinks'))
|
if (Tools::isSubmit('submitBlocktopmenuLinks')) {
|
||||||
{
|
|
||||||
$errors_add_link = array();
|
$errors_add_link = array();
|
||||||
|
|
||||||
foreach ($languages as $key => $val)
|
foreach ($languages as $key => $val) {
|
||||||
{
|
|
||||||
$links_label[$val['id_lang']] = Tools::getValue('link_'.(int)$val['id_lang']);
|
$links_label[$val['id_lang']] = Tools::getValue('link_'.(int)$val['id_lang']);
|
||||||
$labels[$val['id_lang']] = Tools::getValue('label_'.(int)$val['id_lang']);
|
$labels[$val['id_lang']] = Tools::getValue('label_'.(int)$val['id_lang']);
|
||||||
}
|
}
|
||||||
@@ -212,78 +215,65 @@ class Blocktopmenu extends Module
|
|||||||
$count_links_label = count($links_label);
|
$count_links_label = count($links_label);
|
||||||
$count_label = count($labels);
|
$count_label = count($labels);
|
||||||
|
|
||||||
if ($count_links_label || $count_label)
|
if ($count_links_label || $count_label) {
|
||||||
{
|
if (!$count_links_label) {
|
||||||
if (!$count_links_label)
|
|
||||||
$this->_html .= $this->displayError($this->l('Please complete the "Link" field.'));
|
$this->_html .= $this->displayError($this->l('Please complete the "Link" field.'));
|
||||||
elseif (!$count_label)
|
} elseif (!$count_label) {
|
||||||
$this->_html .= $this->displayError($this->l('Please add a label.'));
|
$this->_html .= $this->displayError($this->l('Please add a label.'));
|
||||||
elseif (!isset($labels[$default_language]))
|
} elseif (!isset($labels[$default_language])) {
|
||||||
$this->_html .= $this->displayError($this->l('Please add a label for your default language.'));
|
$this->_html .= $this->displayError($this->l('Please add a label for your default language.'));
|
||||||
else
|
} else {
|
||||||
{
|
|
||||||
$shops = Shop::getContextListShopID();
|
$shops = Shop::getContextListShopID();
|
||||||
|
|
||||||
foreach ($shops as $shop_id)
|
foreach ($shops as $shop_id) {
|
||||||
{
|
|
||||||
$added = MenuTopLinks::add($links_label, $labels, Tools::getValue('new_window', 0), (int)$shop_id);
|
$added = MenuTopLinks::add($links_label, $labels, Tools::getValue('new_window', 0), (int)$shop_id);
|
||||||
|
|
||||||
if (!$added)
|
if (!$added) {
|
||||||
{
|
|
||||||
$shop = new Shop($shop_id);
|
$shop = new Shop($shop_id);
|
||||||
$errors_add_link[] = $shop->name;
|
$errors_add_link[] = $shop->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!count($errors_add_link))
|
if (!count($errors_add_link)) {
|
||||||
$this->_html .= $this->displayConfirmation($this->l('The link has been added.'));
|
$this->_html .= $this->displayConfirmation($this->l('The link has been added.'));
|
||||||
else
|
} else {
|
||||||
$this->_html .= $this->displayError(sprintf($this->l('Unable to add link for the following shop(s): %s'), implode(', ', $errors_add_link)));
|
$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'))
|
$update_cache = true;
|
||||||
{
|
} elseif (Tools::isSubmit('deletelinksmenutop')) {
|
||||||
$errors_delete_link = array();
|
$errors_delete_link = array();
|
||||||
$id_linksmenutop = Tools::getValue('id_linksmenutop', 0);
|
$id_linksmenutop = Tools::getValue('id_linksmenutop', 0);
|
||||||
$shops = Shop::getContextListShopID();
|
$shops = Shop::getContextListShopID();
|
||||||
|
|
||||||
foreach ($shops as $shop_id)
|
foreach ($shops as $shop_id) {
|
||||||
{
|
|
||||||
$deleted = MenuTopLinks::remove($id_linksmenutop, (int)$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')));
|
Configuration::updateValue('MOD_BLOCKTOPMENU_ITEMS', str_replace(array('LNK'.$id_linksmenutop.',', 'LNK'.$id_linksmenutop), '', Configuration::get('MOD_BLOCKTOPMENU_ITEMS')));
|
||||||
|
|
||||||
if (!$deleted)
|
if (!$deleted) {
|
||||||
{
|
|
||||||
$shop = new Shop($shop_id);
|
$shop = new Shop($shop_id);
|
||||||
$errors_delete_link[] = $shop->name;
|
$errors_delete_link[] = $shop->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!count($errors_delete_link))
|
if (!count($errors_delete_link)) {
|
||||||
$this->_html .= $this->displayConfirmation($this->l('The link has been removed.'));
|
$this->_html .= $this->displayConfirmation($this->l('The link has been removed.'));
|
||||||
else
|
} else {
|
||||||
$this->_html .= $this->displayError(sprintf($this->l('Unable to remove link for the following shop(s): %s'), implode(', ', $errors_delete_link)));
|
$this->_html .= $this->displayError(sprintf($this->l('Unable to remove link for the following shop(s): %s'), implode(', ', $errors_delete_link)));
|
||||||
|
}
|
||||||
|
|
||||||
$update_cache = true;
|
$update_cache = true;
|
||||||
}
|
} elseif (Tools::isSubmit('updatelinksmenutop')) {
|
||||||
elseif (Tools::isSubmit('updatelinksmenutop'))
|
|
||||||
{
|
|
||||||
$id_linksmenutop = (int)Tools::getValue('id_linksmenutop', 0);
|
$id_linksmenutop = (int)Tools::getValue('id_linksmenutop', 0);
|
||||||
$id_shop = (int)Shop::getContextShopID();
|
$id_shop = (int)Shop::getContextShopID();
|
||||||
|
|
||||||
if (Tools::isSubmit('updatelink'))
|
if (Tools::isSubmit('updatelink')) {
|
||||||
{
|
|
||||||
$link = array();
|
$link = array();
|
||||||
$label = array();
|
$label = array();
|
||||||
$new_window = (int)Tools::getValue('new_window', 0);
|
$new_window = (int)Tools::getValue('new_window', 0);
|
||||||
|
|
||||||
foreach (Language::getLanguages(false) as $lang)
|
foreach (Language::getLanguages(false) as $lang) {
|
||||||
{
|
|
||||||
$link[$lang['id_lang']] = Tools::getValue('link_'.(int)$lang['id_lang']);
|
$link[$lang['id_lang']] = Tools::getValue('link_'.(int)$lang['id_lang']);
|
||||||
$label[$lang['id_lang']] = Tools::getValue('label_'.(int)$lang['id_lang']);
|
$label[$lang['id_lang']] = Tools::getValue('label_'.(int)$lang['id_lang']);
|
||||||
}
|
}
|
||||||
@@ -293,27 +283,33 @@ class Blocktopmenu extends Module
|
|||||||
}
|
}
|
||||||
$update_cache = true;
|
$update_cache = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($update_cache)
|
if ($update_cache) {
|
||||||
$this->clearMenuCache();
|
$this->clearMenuCache();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$shops = Shop::getContextListShopID();
|
$shops = Shop::getContextListShopID();
|
||||||
$links = array();
|
$links = array();
|
||||||
|
|
||||||
if (count($shops) > 1)
|
if (count($shops) > 1) {
|
||||||
$this->_html .= $this->getWarningMultishopHtml();
|
$this->_html .= $this->getWarningMultishopHtml();
|
||||||
|
}
|
||||||
|
|
||||||
if (Shop::isFeatureActive())
|
if (Shop::isFeatureActive()) {
|
||||||
$this->_html .= $this->getCurrentShopInfoMsg();
|
$this->_html .= $this->getCurrentShopInfoMsg();
|
||||||
|
}
|
||||||
|
|
||||||
$this->_html .= $this->renderForm().$this->renderAddForm();
|
$this->_html .= $this->renderForm().$this->renderAddForm();
|
||||||
|
|
||||||
foreach ($shops as $shop_id)
|
foreach ($shops as $shop_id) {
|
||||||
$links = array_merge($links, MenuTopLinks::gets((int)$id_lang, null, (int)$shop_id));
|
$links = array_merge($links, MenuTopLinks::gets((int)$id_lang, null, (int)$shop_id));
|
||||||
|
}
|
||||||
|
|
||||||
if (!count($links))
|
if (!count($links)) {
|
||||||
return $this->_html;
|
return $this->_html;
|
||||||
|
}
|
||||||
|
|
||||||
$this->_html .= $this->renderList();
|
$this->_html .= $this->renderList();
|
||||||
return $this->_html;
|
return $this->_html;
|
||||||
@@ -330,12 +326,15 @@ class Blocktopmenu extends Module
|
|||||||
{
|
{
|
||||||
$shop_info = null;
|
$shop_info = null;
|
||||||
|
|
||||||
if (Shop::getContext() == Shop::CONTEXT_SHOP)
|
if (Shop::getContext() == Shop::CONTEXT_SHOP) {
|
||||||
$shop_info = sprintf($this->l('The modifications will be applied to shop: %s'), $this->context->shop->name);
|
$shop_info = sprintf($this->l('The modifications will be applied to shop: %s'), $this->context->shop->name);
|
||||||
else if (Shop::getContext() == Shop::CONTEXT_GROUP)
|
} else {
|
||||||
|
if (Shop::getContext() == Shop::CONTEXT_GROUP) {
|
||||||
$shop_info = sprintf($this->l('The modifications will be applied to this group: %s'), Shop::getContextShopGroup()->name);
|
$shop_info = sprintf($this->l('The modifications will be applied to this group: %s'), Shop::getContextShopGroup()->name);
|
||||||
else
|
} else {
|
||||||
$shop_info = $this->l('The modifications will be applied to all shops');
|
$shop_info = $this->l('The modifications will be applied to all shops');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return '<div class="alert alert-info">'.
|
return '<div class="alert alert-info">'.
|
||||||
$shop_info.
|
$shop_info.
|
||||||
@@ -345,34 +344,30 @@ class Blocktopmenu extends Module
|
|||||||
protected function getMenuItems()
|
protected function getMenuItems()
|
||||||
{
|
{
|
||||||
$items = Tools::getValue('items');
|
$items = Tools::getValue('items');
|
||||||
if (is_array($items) && count($items))
|
if (is_array($items) && count($items)) {
|
||||||
return $items;
|
return $items;
|
||||||
else
|
} else {
|
||||||
{
|
|
||||||
$shops = Shop::getContextListShopID();
|
$shops = Shop::getContextListShopID();
|
||||||
$conf = null;
|
$conf = null;
|
||||||
|
|
||||||
if (count($shops) > 1)
|
if (count($shops) > 1) {
|
||||||
{
|
foreach ($shops as $key => $shop_id) {
|
||||||
foreach ($shops as $key => $shop_id)
|
|
||||||
{
|
|
||||||
$shop_group_id = Shop::getGroupFromShop($shop_id);
|
$shop_group_id = Shop::getGroupFromShop($shop_id);
|
||||||
$conf .= (string)($key > 1 ? ',' : '').Configuration::get('MOD_BLOCKTOPMENU_ITEMS', null, $shop_group_id, $shop_id);
|
$conf .= (string)($key > 1 ? ',' : '').Configuration::get('MOD_BLOCKTOPMENU_ITEMS', null, $shop_group_id, $shop_id);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$shop_id = (int)$shops[0];
|
$shop_id = (int)$shops[0];
|
||||||
$shop_group_id = Shop::getGroupFromShop($shop_id);
|
$shop_group_id = Shop::getGroupFromShop($shop_id);
|
||||||
$conf = Configuration::get('MOD_BLOCKTOPMENU_ITEMS', null, $shop_group_id, $shop_id);
|
$conf = Configuration::get('MOD_BLOCKTOPMENU_ITEMS', null, $shop_group_id, $shop_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen($conf))
|
if (strlen($conf)) {
|
||||||
return explode(',', $conf);
|
return explode(',', $conf);
|
||||||
else
|
} else {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected function makeMenuOption()
|
protected function makeMenuOption()
|
||||||
{
|
{
|
||||||
@@ -382,38 +377,41 @@ class Blocktopmenu extends Module
|
|||||||
$id_lang = (int)$this->context->language->id;
|
$id_lang = (int)$this->context->language->id;
|
||||||
|
|
||||||
$html = '<select multiple="multiple" name="items[]" id="items" style="width: 300px; height: 160px;">';
|
$html = '<select multiple="multiple" name="items[]" id="items" style="width: 300px; height: 160px;">';
|
||||||
foreach ($menu_item as $item)
|
foreach ($menu_item as $item) {
|
||||||
{
|
if (!$item) {
|
||||||
if (!$item)
|
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
preg_match($this->pattern, $item, $values);
|
preg_match($this->pattern, $item, $values);
|
||||||
$id = (int)substr($item, strlen($values[1]), strlen($item));
|
$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':
|
case 'CAT':
|
||||||
$category = new Category((int)$id, (int)$id_lang);
|
$category = new Category((int)$id, (int)$id_lang);
|
||||||
if (Validate::isLoadedObject($category))
|
if (Validate::isLoadedObject($category)) {
|
||||||
$html .= '<option selected="selected" value="CAT'.$id.'">'.$category->name.'</option>'.PHP_EOL;
|
$html .= '<option selected="selected" value="CAT'.$id.'">'.$category->name.'</option>'.PHP_EOL;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'PRD':
|
case 'PRD':
|
||||||
$product = new Product((int)$id, true, (int)$id_lang);
|
$product = new Product((int)$id, true, (int)$id_lang);
|
||||||
if (Validate::isLoadedObject($product))
|
if (Validate::isLoadedObject($product)) {
|
||||||
$html .= '<option selected="selected" value="PRD'.$id.'">'.$product->name.'</option>'.PHP_EOL;
|
$html .= '<option selected="selected" value="PRD'.$id.'">'.$product->name.'</option>'.PHP_EOL;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'CMS':
|
case 'CMS':
|
||||||
$cms = new CMS((int)$id, (int)$id_lang);
|
$cms = new CMS((int)$id, (int)$id_lang);
|
||||||
if (Validate::isLoadedObject($cms))
|
if (Validate::isLoadedObject($cms)) {
|
||||||
$html .= '<option selected="selected" value="CMS'.$id.'">'.$cms->meta_title.'</option>'.PHP_EOL;
|
$html .= '<option selected="selected" value="CMS'.$id.'">'.$cms->meta_title.'</option>'.PHP_EOL;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'CMS_CAT':
|
case 'CMS_CAT':
|
||||||
$category = new CMSCategory((int)$id, (int)$id_lang);
|
$category = new CMSCategory((int)$id, (int)$id_lang);
|
||||||
if (Validate::isLoadedObject($category))
|
if (Validate::isLoadedObject($category)) {
|
||||||
$html .= '<option selected="selected" value="CMS_CAT'.$id.'">'.$category->name.'</option>'.PHP_EOL;
|
$html .= '<option selected="selected" value="CMS_CAT'.$id.'">'.$category->name.'</option>'.PHP_EOL;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Case to handle the option to show all Manufacturers
|
// Case to handle the option to show all Manufacturers
|
||||||
@@ -423,8 +421,9 @@ class Blocktopmenu extends Module
|
|||||||
|
|
||||||
case 'MAN':
|
case 'MAN':
|
||||||
$manufacturer = new Manufacturer((int)$id, (int)$id_lang);
|
$manufacturer = new Manufacturer((int)$id, (int)$id_lang);
|
||||||
if (Validate::isLoadedObject($manufacturer))
|
if (Validate::isLoadedObject($manufacturer)) {
|
||||||
$html .= '<option selected="selected" value="MAN'.$id.'">'.$manufacturer->name.'</option>'.PHP_EOL;
|
$html .= '<option selected="selected" value="MAN'.$id.'">'.$manufacturer->name.'</option>'.PHP_EOL;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Case to handle the option to show all Suppliers
|
// Case to handle the option to show all Suppliers
|
||||||
@@ -434,16 +433,15 @@ class Blocktopmenu extends Module
|
|||||||
|
|
||||||
case 'SUP':
|
case 'SUP':
|
||||||
$supplier = new Supplier((int)$id, (int)$id_lang);
|
$supplier = new Supplier((int)$id, (int)$id_lang);
|
||||||
if (Validate::isLoadedObject($supplier))
|
if (Validate::isLoadedObject($supplier)) {
|
||||||
$html .= '<option selected="selected" value="SUP'.$id.'">'.$supplier->name.'</option>'.PHP_EOL;
|
$html .= '<option selected="selected" value="SUP'.$id.'">'.$supplier->name.'</option>'.PHP_EOL;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'LNK':
|
case 'LNK':
|
||||||
$link = MenuTopLinks::get((int)$id, (int)$id_lang, (int)$id_shop);
|
$link = MenuTopLinks::get((int)$id, (int)$id_lang, (int)$id_shop);
|
||||||
if (count($link))
|
if (count($link)) {
|
||||||
{
|
if (!isset($link[0]['label']) || ($link[0]['label'] == '')) {
|
||||||
if (!isset($link[0]['label']) || ($link[0]['label'] == ''))
|
|
||||||
{
|
|
||||||
$default_language = Configuration::get('PS_LANG_DEFAULT');
|
$default_language = Configuration::get('PS_LANG_DEFAULT');
|
||||||
$link = MenuTopLinks::get($link[0]['id_linksmenutop'], (int)$default_language, (int)Shop::getContextShopID());
|
$link = MenuTopLinks::get($link[0]['id_linksmenutop'], (int)$default_language, (int)Shop::getContextShopID());
|
||||||
}
|
}
|
||||||
@@ -453,8 +451,9 @@ class Blocktopmenu extends Module
|
|||||||
|
|
||||||
case 'SHOP':
|
case 'SHOP':
|
||||||
$shop = new Shop((int)$id);
|
$shop = new Shop((int)$id);
|
||||||
if (Validate::isLoadedObject($shop))
|
if (Validate::isLoadedObject($shop)) {
|
||||||
$html .= '<option selected="selected" value="SHOP'.(int)$id.'">'.$shop->name.'</option>'.PHP_EOL;
|
$html .= '<option selected="selected" value="SHOP'.(int)$id.'">'.$shop->name.'</option>'.PHP_EOL;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -468,16 +467,15 @@ class Blocktopmenu extends Module
|
|||||||
$id_lang = (int)$this->context->language->id;
|
$id_lang = (int)$this->context->language->id;
|
||||||
$id_shop = (int)Shop::getContextShopID();
|
$id_shop = (int)Shop::getContextShopID();
|
||||||
|
|
||||||
foreach ($menu_items as $item)
|
foreach ($menu_items as $item) {
|
||||||
{
|
if (!$item) {
|
||||||
if (!$item)
|
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
preg_match($this->pattern, $item, $value);
|
preg_match($this->pattern, $item, $value);
|
||||||
$id = (int)substr($item, strlen($value[1]), strlen($item));
|
$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':
|
case 'CAT':
|
||||||
$this->_menu .= $this->generateCategoriesMenu(Category::getNestedCategories($id, $id_lang, false, $this->user_groups));
|
$this->_menu .= $this->generateCategoriesMenu(Category::getNestedCategories($id, $id_lang, false, $this->user_groups));
|
||||||
break;
|
break;
|
||||||
@@ -485,21 +483,22 @@ class Blocktopmenu extends Module
|
|||||||
case 'PRD':
|
case 'PRD':
|
||||||
$selected = ($this->page_name == 'product' && (Tools::getValue('id_product') == $id)) ? ' class="sfHover"' : '';
|
$selected = ($this->page_name == 'product' && (Tools::getValue('id_product') == $id)) ? ' class="sfHover"' : '';
|
||||||
$product = new Product((int)$id, true, (int)$id_lang);
|
$product = new Product((int)$id, true, (int)$id_lang);
|
||||||
if (!is_null($product->id))
|
if (!is_null($product->id)) {
|
||||||
$this->_menu .= '<li'.$selected.'><a href="'.Tools::HtmlEntitiesUTF8($product->getLink()).'" title="'.$product->name.'">'.$product->name.'</a></li>'.PHP_EOL;
|
$this->_menu .= '<li'.$selected.'><a href="'.Tools::HtmlEntitiesUTF8($product->getLink()).'" title="'.$product->name.'">'.$product->name.'</a></li>'.PHP_EOL;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'CMS':
|
case 'CMS':
|
||||||
$selected = ($this->page_name == 'cms' && (Tools::getValue('id_cms') == $id)) ? ' class="sfHover"' : '';
|
$selected = ($this->page_name == 'cms' && (Tools::getValue('id_cms') == $id)) ? ' class="sfHover"' : '';
|
||||||
$cms = CMS::getLinks((int)$id_lang, array($id));
|
$cms = CMS::getLinks((int)$id_lang, array($id));
|
||||||
if (count($cms))
|
if (count($cms)) {
|
||||||
$this->_menu .= '<li'.$selected.'><a href="'.Tools::HtmlEntitiesUTF8($cms[0]['link']).'" title="'.Tools::safeOutput($cms[0]['meta_title']).'">'.Tools::safeOutput($cms[0]['meta_title']).'</a></li>'.PHP_EOL;
|
$this->_menu .= '<li'.$selected.'><a href="'.Tools::HtmlEntitiesUTF8($cms[0]['link']).'" title="'.Tools::safeOutput($cms[0]['meta_title']).'">'.Tools::safeOutput($cms[0]['meta_title']).'</a></li>'.PHP_EOL;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'CMS_CAT':
|
case 'CMS_CAT':
|
||||||
$category = new CMSCategory((int)$id, (int)$id_lang);
|
$category = new CMSCategory((int)$id, (int)$id_lang);
|
||||||
if (count($category))
|
if (count($category)) {
|
||||||
{
|
|
||||||
$this->_menu .= '<li><a href="'.Tools::HtmlEntitiesUTF8($category->getLink()).'" title="'.$category->name.'">'.$category->name.'</a>';
|
$this->_menu .= '<li><a href="'.Tools::HtmlEntitiesUTF8($category->getLink()).'" title="'.$category->name.'">'.$category->name.'</a>';
|
||||||
$this->getCMSMenuItems($category->id);
|
$this->getCMSMenuItems($category->id);
|
||||||
$this->_menu .= '</li>'.PHP_EOL;
|
$this->_menu .= '</li>'.PHP_EOL;
|
||||||
@@ -511,20 +510,21 @@ class Blocktopmenu extends Module
|
|||||||
$link = new Link;
|
$link = new Link;
|
||||||
$this->_menu .= '<li><a href="'.$link->getPageLink('manufacturer').'" title="'.$this->l('All manufacturers').'">'.$this->l('All manufacturers').'</a><ul>'.PHP_EOL;
|
$this->_menu .= '<li><a href="'.$link->getPageLink('manufacturer').'" title="'.$this->l('All manufacturers').'">'.$this->l('All manufacturers').'</a><ul>'.PHP_EOL;
|
||||||
$manufacturers = Manufacturer::getManufacturers();
|
$manufacturers = Manufacturer::getManufacturers();
|
||||||
foreach ($manufacturers as $key => $manufacturer)
|
foreach ($manufacturers as $key => $manufacturer) {
|
||||||
$this->_menu .= '<li><a href="'.$link->getManufacturerLink((int)$manufacturer['id_manufacturer'], $manufacturer['link_rewrite']).'" title="'.Tools::safeOutput($manufacturer['name']).'">'.Tools::safeOutput($manufacturer['name']).'</a></li>'.PHP_EOL;
|
$this->_menu .= '<li><a href="'.$link->getManufacturerLink((int)$manufacturer['id_manufacturer'], $manufacturer['link_rewrite']).'" title="'.Tools::safeOutput($manufacturer['name']).'">'.Tools::safeOutput($manufacturer['name']).'</a></li>'.PHP_EOL;
|
||||||
|
}
|
||||||
$this->_menu .= '</ul>';
|
$this->_menu .= '</ul>';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'MAN':
|
case 'MAN':
|
||||||
$selected = ($this->page_name == 'manufacturer' && (Tools::getValue('id_manufacturer') == $id)) ? ' class="sfHover"' : '';
|
$selected = ($this->page_name == 'manufacturer' && (Tools::getValue('id_manufacturer') == $id)) ? ' class="sfHover"' : '';
|
||||||
$manufacturer = new Manufacturer((int)$id, (int)$id_lang);
|
$manufacturer = new Manufacturer((int)$id, (int)$id_lang);
|
||||||
if (!is_null($manufacturer->id))
|
if (!is_null($manufacturer->id)) {
|
||||||
{
|
if (intval(Configuration::get('PS_REWRITING_SETTINGS'))) {
|
||||||
if (intval(Configuration::get('PS_REWRITING_SETTINGS')))
|
|
||||||
$manufacturer->link_rewrite = Tools::link_rewrite($manufacturer->name);
|
$manufacturer->link_rewrite = Tools::link_rewrite($manufacturer->name);
|
||||||
else
|
} else {
|
||||||
$manufacturer->link_rewrite = 0;
|
$manufacturer->link_rewrite = 0;
|
||||||
|
}
|
||||||
$link = new Link;
|
$link = new Link;
|
||||||
$this->_menu .= '<li'.$selected.'><a href="'.Tools::HtmlEntitiesUTF8($link->getManufacturerLink((int)$id, $manufacturer->link_rewrite)).'" title="'.Tools::safeOutput($manufacturer->name).'">'.Tools::safeOutput($manufacturer->name).'</a></li>'.PHP_EOL;
|
$this->_menu .= '<li'.$selected.'><a href="'.Tools::HtmlEntitiesUTF8($link->getManufacturerLink((int)$id, $manufacturer->link_rewrite)).'" title="'.Tools::safeOutput($manufacturer->name).'">'.Tools::safeOutput($manufacturer->name).'</a></li>'.PHP_EOL;
|
||||||
}
|
}
|
||||||
@@ -535,16 +535,16 @@ class Blocktopmenu extends Module
|
|||||||
$link = new Link;
|
$link = new Link;
|
||||||
$this->_menu .= '<li><a href="'.$link->getPageLink('supplier').'" title="'.$this->l('All suppliers').'">'.$this->l('All suppliers').'</a><ul>'.PHP_EOL;
|
$this->_menu .= '<li><a href="'.$link->getPageLink('supplier').'" title="'.$this->l('All suppliers').'">'.$this->l('All suppliers').'</a><ul>'.PHP_EOL;
|
||||||
$suppliers = Supplier::getSuppliers();
|
$suppliers = Supplier::getSuppliers();
|
||||||
foreach ($suppliers as $key => $supplier)
|
foreach ($suppliers as $key => $supplier) {
|
||||||
$this->_menu .= '<li><a href="'.$link->getSupplierLink((int)$supplier['id_supplier'], $supplier['link_rewrite']).'" title="'.Tools::safeOutput($supplier['name']).'">'.Tools::safeOutput($supplier['name']).'</a></li>'.PHP_EOL;
|
$this->_menu .= '<li><a href="'.$link->getSupplierLink((int)$supplier['id_supplier'], $supplier['link_rewrite']).'" title="'.Tools::safeOutput($supplier['name']).'">'.Tools::safeOutput($supplier['name']).'</a></li>'.PHP_EOL;
|
||||||
|
}
|
||||||
$this->_menu .= '</ul>';
|
$this->_menu .= '</ul>';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'SUP':
|
case 'SUP':
|
||||||
$selected = ($this->page_name == 'supplier' && (Tools::getValue('id_supplier') == $id)) ? ' class="sfHover"' : '';
|
$selected = ($this->page_name == 'supplier' && (Tools::getValue('id_supplier') == $id)) ? ' class="sfHover"' : '';
|
||||||
$supplier = new Supplier((int)$id, (int)$id_lang);
|
$supplier = new Supplier((int)$id, (int)$id_lang);
|
||||||
if (!is_null($supplier->id))
|
if (!is_null($supplier->id)) {
|
||||||
{
|
|
||||||
$link = new Link;
|
$link = new Link;
|
||||||
$this->_menu .= '<li'.$selected.'><a href="'.Tools::HtmlEntitiesUTF8($link->getSupplierLink((int)$id, $supplier->link_rewrite)).'" title="'.$supplier->name.'">'.$supplier->name.'</a></li>'.PHP_EOL;
|
$this->_menu .= '<li'.$selected.'><a href="'.Tools::HtmlEntitiesUTF8($link->getSupplierLink((int)$id, $supplier->link_rewrite)).'" title="'.$supplier->name.'">'.$supplier->name.'</a></li>'.PHP_EOL;
|
||||||
}
|
}
|
||||||
@@ -553,18 +553,15 @@ class Blocktopmenu extends Module
|
|||||||
case 'SHOP':
|
case 'SHOP':
|
||||||
$selected = ($this->page_name == 'index' && ($this->context->shop->id == $id)) ? ' class="sfHover"' : '';
|
$selected = ($this->page_name == 'index' && ($this->context->shop->id == $id)) ? ' class="sfHover"' : '';
|
||||||
$shop = new Shop((int)$id);
|
$shop = new Shop((int)$id);
|
||||||
if (Validate::isLoadedObject($shop))
|
if (Validate::isLoadedObject($shop)) {
|
||||||
{
|
|
||||||
$link = new Link;
|
$link = new Link;
|
||||||
$this->_menu .= '<li'.$selected.'><a href="'.Tools::HtmlEntitiesUTF8($shop->getBaseURL()).'" title="'.$shop->name.'">'.$shop->name.'</a></li>'.PHP_EOL;
|
$this->_menu .= '<li'.$selected.'><a href="'.Tools::HtmlEntitiesUTF8($shop->getBaseURL()).'" title="'.$shop->name.'">'.$shop->name.'</a></li>'.PHP_EOL;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'LNK':
|
case 'LNK':
|
||||||
$link = MenuTopLinks::get((int)$id, (int)$id_lang, (int)$id_shop);
|
$link = MenuTopLinks::get((int)$id, (int)$id_lang, (int)$id_shop);
|
||||||
if (count($link))
|
if (count($link)) {
|
||||||
{
|
if (!isset($link[0]['label']) || ($link[0]['label'] == '')) {
|
||||||
if (!isset($link[0]['label']) || ($link[0]['label'] == ''))
|
|
||||||
{
|
|
||||||
$default_language = Configuration::get('PS_LANG_DEFAULT');
|
$default_language = Configuration::get('PS_LANG_DEFAULT');
|
||||||
$link = MenuTopLinks::get($link[0]['id_linksmenutop'], $default_language, (int)Shop::getContextShopID());
|
$link = MenuTopLinks::get($link[0]['id_linksmenutop'], $default_language, (int)Shop::getContextShopID());
|
||||||
}
|
}
|
||||||
@@ -579,18 +576,16 @@ class Blocktopmenu extends Module
|
|||||||
{
|
{
|
||||||
$html = '';
|
$html = '';
|
||||||
|
|
||||||
foreach ($categories as $key => $category)
|
foreach ($categories as $key => $category) {
|
||||||
{
|
if (isset($items_to_skip) /*&& !in_array('CAT'.(int)$category['id_category'], $items_to_skip)*/) {
|
||||||
if (isset($items_to_skip) /*&& !in_array('CAT'.(int)$category['id_category'], $items_to_skip)*/)
|
|
||||||
{
|
|
||||||
$shop = (object) Shop::getShop((int)$category['id_shop']);
|
$shop = (object) Shop::getShop((int)$category['id_shop']);
|
||||||
$html .= '<option value="CAT'.(int)$category['id_category'].'">'
|
$html .= '<option value="CAT'.(int)$category['id_category'].'">'
|
||||||
.str_repeat(' ', $this->spacer_size * (int)$category['level_depth']).$category['name'].' ('.$shop->name.')</option>';
|
.str_repeat(' ', $this->spacer_size * (int)$category['level_depth']).$category['name'].' ('.$shop->name.')</option>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($category['children']) && !empty($category['children']))
|
if (isset($category['children']) && !empty($category['children'])) {
|
||||||
$html .= $this->generateCategoriesOption($category['children'], $items_to_skip);
|
$html .= $this->generateCategoriesOption($category['children'], $items_to_skip);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
@@ -599,15 +594,13 @@ class Blocktopmenu extends Module
|
|||||||
{
|
{
|
||||||
$html = '';
|
$html = '';
|
||||||
|
|
||||||
foreach ($categories as $key => $category)
|
foreach ($categories as $key => $category) {
|
||||||
{
|
if ($category['level_depth'] > 1) {
|
||||||
if ($category['level_depth'] > 1)
|
|
||||||
{
|
|
||||||
$cat = new Category($category['id_category']);
|
$cat = new Category($category['id_category']);
|
||||||
$link = Tools::HtmlEntitiesUTF8($cat->getLink());
|
$link = Tools::HtmlEntitiesUTF8($cat->getLink());
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
$link = $this->context->link->getPageLink('index');
|
$link = $this->context->link->getPageLink('index');
|
||||||
|
}
|
||||||
|
|
||||||
/* Whenever a category is not active we shouldnt display it to customer */
|
/* Whenever a category is not active we shouldnt display it to customer */
|
||||||
if ((bool)$category['active'] === false) {
|
if ((bool)$category['active'] === false) {
|
||||||
@@ -618,24 +611,23 @@ class Blocktopmenu extends Module
|
|||||||
&& (int)Tools::getValue('id_category') == (int)$category['id_category']) ? ' class="sfHoverForce"' : '').'>';
|
&& (int)Tools::getValue('id_category') == (int)$category['id_category']) ? ' class="sfHoverForce"' : '').'>';
|
||||||
$html .= '<a href="'.$link.'" title="'.$category['name'].'">'.$category['name'].'</a>';
|
$html .= '<a href="'.$link.'" title="'.$category['name'].'">'.$category['name'].'</a>';
|
||||||
|
|
||||||
if (isset($category['children']) && !empty($category['children']))
|
if (isset($category['children']) && !empty($category['children'])) {
|
||||||
{
|
|
||||||
$html .= '<ul>';
|
$html .= '<ul>';
|
||||||
$html .= $this->generateCategoriesMenu($category['children'], 1);
|
$html .= $this->generateCategoriesMenu($category['children'], 1);
|
||||||
|
|
||||||
if ((int)$category['level_depth'] > 1 && !$is_children)
|
if ((int)$category['level_depth'] > 1 && !$is_children) {
|
||||||
{
|
|
||||||
$files = scandir(_PS_CAT_IMG_DIR_);
|
$files = scandir(_PS_CAT_IMG_DIR_);
|
||||||
|
|
||||||
if (count(preg_grep('/^'.$category['id_category'].'-([0-9])?_thumb.jpg/i', $files)) > 0)
|
if (count(preg_grep('/^'.$category['id_category'].'-([0-9])?_thumb.jpg/i', $files)) > 0) {
|
||||||
{
|
|
||||||
$html .= '<li class="category-thumbnail">';
|
$html .= '<li class="category-thumbnail">';
|
||||||
|
|
||||||
foreach ($files as $file)
|
foreach ($files as $file) {
|
||||||
if (preg_match('/^'.$category['id_category'].'-([0-9])?_thumb.jpg/i', $file) === 1)
|
if (preg_match('/^'.$category['id_category'].'-([0-9])?_thumb.jpg/i', $file) === 1) {
|
||||||
$html .= '<div><img src="'.$this->context->link->getMediaLink(_THEME_CAT_DIR_.$file)
|
$html .= '<div><img src="'.$this->context->link->getMediaLink(_THEME_CAT_DIR_.$file)
|
||||||
.'" alt="'.Tools::SafeOutput($category['name']).'" title="'
|
.'" alt="'.Tools::SafeOutput($category['name']).'" title="'
|
||||||
.Tools::SafeOutput($category['name']).'" class="imgm" /></div>';
|
.Tools::SafeOutput($category['name']).'" class="imgm" /></div>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$html .= '</li>';
|
$html .= '</li>';
|
||||||
}
|
}
|
||||||
@@ -654,18 +646,17 @@ class Blocktopmenu extends Module
|
|||||||
{
|
{
|
||||||
$id_lang = $id_lang ? (int)$id_lang : (int)Context::getContext()->language->id;
|
$id_lang = $id_lang ? (int)$id_lang : (int)Context::getContext()->language->id;
|
||||||
|
|
||||||
if ($depth > 3)
|
if ($depth > 3) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$categories = $this->getCMSCategories(false, (int)$parent, (int)$id_lang);
|
$categories = $this->getCMSCategories(false, (int)$parent, (int)$id_lang);
|
||||||
$pages = $this->getCMSPages((int)$parent);
|
$pages = $this->getCMSPages((int)$parent);
|
||||||
|
|
||||||
if (count($categories) || count($pages))
|
if (count($categories) || count($pages)) {
|
||||||
{
|
|
||||||
$this->_menu .= '<ul>';
|
$this->_menu .= '<ul>';
|
||||||
|
|
||||||
foreach ($categories as $category)
|
foreach ($categories as $category) {
|
||||||
{
|
|
||||||
$cat = new CMSCategory((int)$category['id_cms_category'], (int)$id_lang);
|
$cat = new CMSCategory((int)$category['id_cms_category'], (int)$id_lang);
|
||||||
|
|
||||||
$this->_menu .= '<li>';
|
$this->_menu .= '<li>';
|
||||||
@@ -674,8 +665,7 @@ class Blocktopmenu extends Module
|
|||||||
$this->_menu .= '</li>';
|
$this->_menu .= '</li>';
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($pages as $page)
|
foreach ($pages as $page) {
|
||||||
{
|
|
||||||
$cms = new CMS($page['id_cms'], (int)$id_lang);
|
$cms = new CMS($page['id_cms'], (int)$id_lang);
|
||||||
$links = $cms->getLinks((int)$id_lang, array((int)$cms->id));
|
$links = $cms->getLinks((int)$id_lang, array((int)$cms->id));
|
||||||
|
|
||||||
@@ -699,16 +689,18 @@ class Blocktopmenu extends Module
|
|||||||
|
|
||||||
$spacer = str_repeat(' ', $this->spacer_size * (int)$depth);
|
$spacer = str_repeat(' ', $this->spacer_size * (int)$depth);
|
||||||
|
|
||||||
foreach ($categories as $category)
|
foreach ($categories as $category) {
|
||||||
{
|
if (isset($items_to_skip) && !in_array('CMS_CAT'.$category['id_cms_category'], $items_to_skip)) {
|
||||||
if (isset($items_to_skip) && !in_array('CMS_CAT'.$category['id_cms_category'], $items_to_skip))
|
|
||||||
$html .= '<option value="CMS_CAT'.$category['id_cms_category'].'" style="font-weight: bold;">'.$spacer.$category['name'].'</option>';
|
$html .= '<option value="CMS_CAT'.$category['id_cms_category'].'" style="font-weight: bold;">'.$spacer.$category['name'].'</option>';
|
||||||
|
}
|
||||||
$html .= $this->getCMSOptions($category['id_cms_category'], (int)$depth + 1, (int)$id_lang, $items_to_skip);
|
$html .= $this->getCMSOptions($category['id_cms_category'], (int)$depth + 1, (int)$id_lang, $items_to_skip);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($pages as $page)
|
foreach ($pages as $page) {
|
||||||
if (isset($items_to_skip) && !in_array('CMS'.$page['id_cms'], $items_to_skip))
|
if (isset($items_to_skip) && !in_array('CMS'.$page['id_cms'], $items_to_skip)) {
|
||||||
$html .= '<option value="CMS'.$page['id_cms'].'">'.$spacer.$page['meta_title'].'</option>';
|
$html .= '<option value="CMS'.$page['id_cms'].'">'.$spacer.$page['meta_title'].'</option>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
@@ -733,10 +725,10 @@ class Blocktopmenu extends Module
|
|||||||
$this->user_groups = ($this->context->customer->isLogged() ?
|
$this->user_groups = ($this->context->customer->isLogged() ?
|
||||||
$this->context->customer->getGroups() : array(Configuration::get('PS_UNIDENTIFIED_GROUP')));
|
$this->context->customer->getGroups() : array(Configuration::get('PS_UNIDENTIFIED_GROUP')));
|
||||||
$this->page_name = Dispatcher::getInstance()->getController();
|
$this->page_name = Dispatcher::getInstance()->getController();
|
||||||
if (!$this->isCached('blocktopmenu.tpl', $this->getCacheId()))
|
if (!$this->isCached('blocktopmenu.tpl', $this->getCacheId())) {
|
||||||
{
|
if (Tools::isEmpty($this->_menu)) {
|
||||||
if (Tools::isEmpty($this->_menu))
|
|
||||||
$this->makeMenu();
|
$this->makeMenu();
|
||||||
|
}
|
||||||
|
|
||||||
$shop_id = (int)$this->context->shop->id;
|
$shop_id = (int)$this->context->shop->id;
|
||||||
$shop_group_id = Shop::getGroupFromShop($shop_id);
|
$shop_group_id = Shop::getGroupFromShop($shop_id);
|
||||||
@@ -762,15 +754,13 @@ class Blocktopmenu extends Module
|
|||||||
$join_shop = '';
|
$join_shop = '';
|
||||||
$where_shop = '';
|
$where_shop = '';
|
||||||
|
|
||||||
if (Tools::version_compare(_PS_VERSION_, '1.6.0.12', '>=') == true)
|
if (Tools::version_compare(_PS_VERSION_, '1.6.0.12', '>=') == true) {
|
||||||
{
|
|
||||||
$join_shop = ' INNER JOIN `'._DB_PREFIX_.'cms_category_shop` cs
|
$join_shop = ' INNER JOIN `'._DB_PREFIX_.'cms_category_shop` cs
|
||||||
ON (bcp.`id_cms_category` = cs.`id_cms_category`)';
|
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)
|
if ($recursive === false) {
|
||||||
{
|
|
||||||
$sql = 'SELECT bcp.`id_cms_category`, bcp.`id_parent`, bcp.`level_depth`, bcp.`active`, bcp.`position`, cl.`name`, cl.`link_rewrite`
|
$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'.
|
FROM `'._DB_PREFIX_.'cms_category` bcp'.
|
||||||
$join_shop.'
|
$join_shop.'
|
||||||
@@ -781,9 +771,7 @@ class Blocktopmenu extends Module
|
|||||||
$where_shop;
|
$where_shop;
|
||||||
|
|
||||||
return Db::getInstance()->executeS($sql);
|
return Db::getInstance()->executeS($sql);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$sql = 'SELECT bcp.`id_cms_category`, bcp.`id_parent`, bcp.`level_depth`, bcp.`active`, bcp.`position`, cl.`name`, cl.`link_rewrite`
|
$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'.
|
FROM `'._DB_PREFIX_.'cms_category` bcp'.
|
||||||
$join_shop.'
|
$join_shop.'
|
||||||
@@ -794,17 +782,16 @@ class Blocktopmenu extends Module
|
|||||||
$where_shop;
|
$where_shop;
|
||||||
|
|
||||||
$results = Db::getInstance()->executeS($sql);
|
$results = Db::getInstance()->executeS($sql);
|
||||||
foreach ($results as $result)
|
foreach ($results as $result) {
|
||||||
{
|
|
||||||
$sub_categories = $this->getCMSCategories(true, $result['id_cms_category'], (int)$id_lang);
|
$sub_categories = $this->getCMSCategories(true, $result['id_cms_category'], (int)$id_lang);
|
||||||
if ($sub_categories && count($sub_categories) > 0)
|
if ($sub_categories && count($sub_categories) > 0) {
|
||||||
$result['sub_categories'] = $sub_categories;
|
$result['sub_categories'] = $sub_categories;
|
||||||
|
}
|
||||||
$categories[] = $result;
|
$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)
|
protected function getCMSPages($id_cms_category, $id_shop = false, $id_lang = false, $id_shop = false)
|
||||||
@@ -813,8 +800,9 @@ class Blocktopmenu extends Module
|
|||||||
$id_lang = $id_lang ? (int)$id_lang : (int)Context::getContext()->language->id;
|
$id_lang = $id_lang ? (int)$id_lang : (int)Context::getContext()->language->id;
|
||||||
|
|
||||||
$where_shop = '';
|
$where_shop = '';
|
||||||
if (Tools::version_compare(_PS_VERSION_, '1.6.0.12', '>=') == true)
|
if (Tools::version_compare(_PS_VERSION_, '1.6.0.12', '>=') == true) {
|
||||||
$where_shop = ' AND cl.`id_shop` = '.(int)$id_shop;
|
$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
|
FROM `'._DB_PREFIX_.'cms` c
|
||||||
@@ -925,8 +913,7 @@ class Blocktopmenu extends Module
|
|||||||
WHERE id_shop = '.(int)$params['old_id_shop']
|
WHERE id_shop = '.(int)$params['old_id_shop']
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ($linksmenutop as $id => $link)
|
foreach ($linksmenutop as $id => $link) {
|
||||||
{
|
|
||||||
Db::getInstance()->execute('
|
Db::getInstance()->execute('
|
||||||
INSERT IGNORE INTO '._DB_PREFIX_.'linksmenutop (id_linksmenutop, id_shop, new_window)
|
INSERT IGNORE INTO '._DB_PREFIX_.'linksmenutop (id_linksmenutop, id_shop, new_window)
|
||||||
VALUES (null, '.(int)$params['new_id_shop'].', '.(int)$link['new_window'].')');
|
VALUES (null, '.(int)$params['new_id_shop'].', '.(int)$link['new_window'].')');
|
||||||
@@ -934,25 +921,25 @@ class Blocktopmenu extends Module
|
|||||||
$linksmenutop[$id]['new_id_linksmenutop'] = Db::getInstance()->Insert_ID();
|
$linksmenutop[$id]['new_id_linksmenutop'] = Db::getInstance()->Insert_ID();
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($linksmenutop as $id => $link)
|
foreach ($linksmenutop as $id => $link) {
|
||||||
{
|
|
||||||
$lang = Db::getInstance()->executeS('
|
$lang = Db::getInstance()->executeS('
|
||||||
SELECT id_lang, '.(int)$params['new_id_shop'].', label, link
|
SELECT id_lang, '.(int)$params['new_id_shop'].', label, link
|
||||||
FROM '._DB_PREFIX_.'linksmenutop_lang
|
FROM '._DB_PREFIX_.'linksmenutop_lang
|
||||||
WHERE id_linksmenutop = '.(int)$link['id_linksmenutop'].' AND id_shop = '.(int)$params['old_id_shop']);
|
WHERE id_linksmenutop = '.(int)$link['id_linksmenutop'].' AND id_shop = '.(int)$params['old_id_shop']);
|
||||||
|
|
||||||
foreach ($lang as $l)
|
foreach ($lang as $l) {
|
||||||
Db::getInstance()->execute('
|
Db::getInstance()->execute('
|
||||||
INSERT IGNORE INTO '._DB_PREFIX_.'linksmenutop_lang (id_linksmenutop, id_lang, id_shop, label, link)
|
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'].' )');
|
VALUES ('.(int)$link['new_id_linksmenutop'].', '.(int)$l['id_lang'].', '.(int)$params['new_id_shop'].', '.(int)$l['label'].', '.(int)$l['link'].' )');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function renderForm()
|
public function renderForm()
|
||||||
{
|
{
|
||||||
$shops = Shop::getContextListShopID();
|
$shops = Shop::getContextListShopID();
|
||||||
|
|
||||||
if (count($shops) == 1)
|
if (count($shops) == 1) {
|
||||||
$fields_form = array(
|
$fields_form = array(
|
||||||
'form' => array(
|
'form' => array(
|
||||||
'legend' => array(
|
'legend' => array(
|
||||||
@@ -991,7 +978,7 @@ class Blocktopmenu extends Module
|
|||||||
)
|
)
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
else
|
} else {
|
||||||
$fields_form = array(
|
$fields_form = array(
|
||||||
'form' => array(
|
'form' => array(
|
||||||
'legend' => array(
|
'legend' => array(
|
||||||
@@ -1026,6 +1013,7 @@ class Blocktopmenu extends Module
|
|||||||
)
|
)
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$helper = new HelperForm();
|
$helper = new HelperForm();
|
||||||
$helper->show_toolbar = false;
|
$helper->show_toolbar = false;
|
||||||
@@ -1107,14 +1095,14 @@ class Blocktopmenu extends Module
|
|||||||
$helper->identifier = $this->identifier;
|
$helper->identifier = $this->identifier;
|
||||||
$helper->fields_value = $this->getAddLinkFieldsValues();
|
$helper->fields_value = $this->getAddLinkFieldsValues();
|
||||||
|
|
||||||
if (Tools::getIsset('updatelinksmenutop') && !Tools::getValue('updatelinksmenutop'))
|
if (Tools::getIsset('updatelinksmenutop') && !Tools::getValue('updatelinksmenutop')) {
|
||||||
$fields_form['form']['submit'] = array(
|
$fields_form['form']['submit'] = array(
|
||||||
'name' => 'updatelinksmenutop',
|
'name' => 'updatelinksmenutop',
|
||||||
'title' => $this->l('Update')
|
'title' => $this->l('Update')
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (Tools::isSubmit('updatelinksmenutop'))
|
if (Tools::isSubmit('updatelinksmenutop')) {
|
||||||
{
|
|
||||||
$fields_form['form']['input'][] = array('type' => 'hidden', 'name' => 'updatelink');
|
$fields_form['form']['input'][] = array('type' => 'hidden', 'name' => 'updatelink');
|
||||||
$fields_form['form']['input'][] = array('type' => 'hidden', 'name' => 'id_linksmenutop');
|
$fields_form['form']['input'][] = array('type' => 'hidden', 'name' => 'id_linksmenutop');
|
||||||
$helper->fields_value['updatelink'] = '';
|
$helper->fields_value['updatelink'] = '';
|
||||||
@@ -1144,9 +1132,11 @@ class Blocktopmenu extends Module
|
|||||||
// Option to show all Suppliers
|
// Option to show all Suppliers
|
||||||
$html .= '<option value="ALLSUP0">'.$this->l('All suppliers').'</option>';
|
$html .= '<option value="ALLSUP0">'.$this->l('All suppliers').'</option>';
|
||||||
$suppliers = Supplier::getSuppliers(false, $this->context->language->id);
|
$suppliers = Supplier::getSuppliers(false, $this->context->language->id);
|
||||||
foreach ($suppliers as $supplier)
|
foreach ($suppliers as $supplier) {
|
||||||
if (!in_array('SUP'.$supplier['id_supplier'], $items))
|
if (!in_array('SUP'.$supplier['id_supplier'], $items)) {
|
||||||
$html .= '<option value="SUP'.$supplier['id_supplier'].'">'.$spacer.$supplier['name'].'</option>';
|
$html .= '<option value="SUP'.$supplier['id_supplier'].'">'.$spacer.$supplier['name'].'</option>';
|
||||||
|
}
|
||||||
|
}
|
||||||
$html .= '</optgroup>';
|
$html .= '</optgroup>';
|
||||||
|
|
||||||
// BEGIN Manufacturer
|
// BEGIN Manufacturer
|
||||||
@@ -1154,9 +1144,11 @@ class Blocktopmenu extends Module
|
|||||||
// Option to show all Manufacturers
|
// Option to show all Manufacturers
|
||||||
$html .= '<option value="ALLMAN0">'.$this->l('All manufacturers').'</option>';
|
$html .= '<option value="ALLMAN0">'.$this->l('All manufacturers').'</option>';
|
||||||
$manufacturers = Manufacturer::getManufacturers(false, $this->context->language->id);
|
$manufacturers = Manufacturer::getManufacturers(false, $this->context->language->id);
|
||||||
foreach ($manufacturers as $manufacturer)
|
foreach ($manufacturers as $manufacturer) {
|
||||||
if (!in_array('MAN'.$manufacturer['id_manufacturer'], $items))
|
if (!in_array('MAN'.$manufacturer['id_manufacturer'], $items)) {
|
||||||
$html .= '<option value="MAN'.$manufacturer['id_manufacturer'].'">'.$spacer.$manufacturer['name'].'</option>';
|
$html .= '<option value="MAN'.$manufacturer['id_manufacturer'].'">'.$spacer.$manufacturer['name'].'</option>';
|
||||||
|
}
|
||||||
|
}
|
||||||
$html .= '</optgroup>';
|
$html .= '</optgroup>';
|
||||||
|
|
||||||
// BEGIN Categories
|
// BEGIN Categories
|
||||||
@@ -1165,23 +1157,24 @@ class Blocktopmenu extends Module
|
|||||||
|
|
||||||
$shops_to_get = Shop::getContextListShopID();
|
$shops_to_get = Shop::getContextListShopID();
|
||||||
|
|
||||||
foreach ($shops_to_get as $shop_id)
|
foreach ($shops_to_get as $shop_id) {
|
||||||
$html .= $this->generateCategoriesOption($this->customGetNestedCategories($shop_id, null, (int)$this->context->language->id, false), $items);
|
$html .= $this->generateCategoriesOption($this->customGetNestedCategories($shop_id, null, (int)$this->context->language->id, false), $items);
|
||||||
|
}
|
||||||
$html .= '</optgroup>';
|
$html .= '</optgroup>';
|
||||||
|
|
||||||
// BEGIN Shops
|
// BEGIN Shops
|
||||||
if (Shop::isFeatureActive())
|
if (Shop::isFeatureActive()) {
|
||||||
{
|
|
||||||
$html .= '<optgroup label="'.$this->l('Shops').'">';
|
$html .= '<optgroup label="'.$this->l('Shops').'">';
|
||||||
$shops = Shop::getShopsCollection();
|
$shops = Shop::getShopsCollection();
|
||||||
foreach ($shops as $shop)
|
foreach ($shops as $shop) {
|
||||||
{
|
if (!$shop->setUrl() && !$shop->getBaseURL()) {
|
||||||
if (!$shop->setUrl() && !$shop->getBaseURL())
|
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!in_array('SHOP'.(int)$shop->id, $items))
|
if (!in_array('SHOP'.(int)$shop->id, $items)) {
|
||||||
$html .= '<option value="SHOP'.(int)$shop->id.'">'.$spacer.$shop->name.'</option>';
|
$html .= '<option value="SHOP'.(int)$shop->id.'">'.$spacer.$shop->name.'</option>';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$html .= '</optgroup>';
|
$html .= '</optgroup>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1193,18 +1186,17 @@ class Blocktopmenu extends Module
|
|||||||
// BEGIN Menu Top Links
|
// BEGIN Menu Top Links
|
||||||
$html .= '<optgroup label="'.$this->l('Menu Top Links').'">';
|
$html .= '<optgroup label="'.$this->l('Menu Top Links').'">';
|
||||||
$links = MenuTopLinks::gets($this->context->language->id, null, (int)Shop::getContextShopID());
|
$links = MenuTopLinks::gets($this->context->language->id, null, (int)Shop::getContextShopID());
|
||||||
foreach ($links as $link)
|
foreach ($links as $link) {
|
||||||
{
|
if ($link['label'] == '') {
|
||||||
if ($link['label'] == '')
|
|
||||||
{
|
|
||||||
$default_language = Configuration::get('PS_LANG_DEFAULT');
|
$default_language = Configuration::get('PS_LANG_DEFAULT');
|
||||||
$link = MenuTopLinks::get($link['id_linksmenutop'], $default_language, (int)Shop::getContextShopID());
|
$link = MenuTopLinks::get($link['id_linksmenutop'], $default_language, (int)Shop::getContextShopID());
|
||||||
if (!in_array('LNK'.(int)$link[0]['id_linksmenutop'], $items))
|
if (!in_array('LNK'.(int)$link[0]['id_linksmenutop'], $items)) {
|
||||||
$html .= '<option value="LNK'.(int)$link[0]['id_linksmenutop'].'">'.$spacer.Tools::safeOutput($link[0]['label']).'</option>';
|
$html .= '<option value="LNK'.(int)$link[0]['id_linksmenutop'].'">'.$spacer.Tools::safeOutput($link[0]['label']).'</option>';
|
||||||
}
|
}
|
||||||
elseif (!in_array('LNK'.(int)$link['id_linksmenutop'], $items))
|
} elseif (!in_array('LNK'.(int)$link['id_linksmenutop'], $items)) {
|
||||||
$html .= '<option value="LNK'.(int)$link['id_linksmenutop'].'">'.$spacer.Tools::safeOutput($link['label']).'</option>';
|
$html .= '<option value="LNK'.(int)$link['id_linksmenutop'].'">'.$spacer.Tools::safeOutput($link['label']).'</option>';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$html .= '</optgroup>';
|
$html .= '</optgroup>';
|
||||||
$html .= '</select>';
|
$html .= '</select>';
|
||||||
return $html;
|
return $html;
|
||||||
@@ -1213,20 +1205,22 @@ class Blocktopmenu extends Module
|
|||||||
|
|
||||||
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 = '')
|
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))
|
if (isset($root_category) && !Validate::isInt($root_category)) {
|
||||||
die(Tools::displayError());
|
die(Tools::displayError());
|
||||||
|
}
|
||||||
|
|
||||||
if (!Validate::isBool($active))
|
if (!Validate::isBool($active)) {
|
||||||
die(Tools::displayError());
|
die(Tools::displayError());
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($groups) && Group::isFeatureActive() && !is_array($groups))
|
if (isset($groups) && Group::isFeatureActive() && !is_array($groups)) {
|
||||||
$groups = (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) : ''));
|
.(isset($groups) && Group::isFeatureActive() ? implode('', $groups) : ''));
|
||||||
|
|
||||||
if (!Cache::isStored($cache_id))
|
if (!Cache::isStored($cache_id)) {
|
||||||
{
|
|
||||||
$result = Db::getInstance()->executeS('
|
$result = Db::getInstance()->executeS('
|
||||||
SELECT c.*, cl.*
|
SELECT c.*, cl.*
|
||||||
FROM `'._DB_PREFIX_.'category` c
|
FROM `'._DB_PREFIX_.'category` c
|
||||||
@@ -1244,16 +1238,16 @@ class Blocktopmenu extends Module
|
|||||||
$categories = array();
|
$categories = array();
|
||||||
$buff = array();
|
$buff = array();
|
||||||
|
|
||||||
foreach ($result as $row)
|
foreach ($result as $row) {
|
||||||
{
|
|
||||||
$current = &$buff[$row['id_category']];
|
$current = &$buff[$row['id_category']];
|
||||||
$current = $row;
|
$current = $row;
|
||||||
|
|
||||||
if ($row['id_parent'] == 0)
|
if ($row['id_parent'] == 0) {
|
||||||
$categories[$row['id_category']] = &$current;
|
$categories[$row['id_category']] = &$current;
|
||||||
else
|
} else {
|
||||||
$buff[$row['id_parent']]['children'][$row['id_category']] = &$current;
|
$buff[$row['id_parent']]['children'][$row['id_category']] = &$current;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Cache::store($cache_id, $categories);
|
Cache::store($cache_id, $categories);
|
||||||
}
|
}
|
||||||
@@ -1266,11 +1260,9 @@ class Blocktopmenu extends Module
|
|||||||
$shops = Shop::getContextListShopID();
|
$shops = Shop::getContextListShopID();
|
||||||
$is_search_on = true;
|
$is_search_on = true;
|
||||||
|
|
||||||
foreach ($shops as $shop_id)
|
foreach ($shops as $shop_id) {
|
||||||
{
|
|
||||||
$shop_group_id = Shop::getGroupFromShop($shop_id);
|
$shop_group_id = Shop::getGroupFromShop($shop_id);
|
||||||
$is_search_on &= (bool)Configuration::get('MOD_BLOCKTOPMENU_SEARCH', null, $shop_group_id, $shop_id);
|
$is_search_on &= (bool)Configuration::get('MOD_BLOCKTOPMENU_SEARCH', null, $shop_group_id, $shop_id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
@@ -1284,12 +1276,12 @@ class Blocktopmenu extends Module
|
|||||||
$labels_edit = '';
|
$labels_edit = '';
|
||||||
$new_window_edit = '';
|
$new_window_edit = '';
|
||||||
|
|
||||||
if (Tools::isSubmit('updatelinksmenutop'))
|
if (Tools::isSubmit('updatelinksmenutop')) {
|
||||||
{
|
|
||||||
$link = MenuTopLinks::getLinkLang(Tools::getValue('id_linksmenutop'), (int)Shop::getContextShopID());
|
$link = MenuTopLinks::getLinkLang(Tools::getValue('id_linksmenutop'), (int)Shop::getContextShopID());
|
||||||
|
|
||||||
foreach ($link['link'] as $key => $label)
|
foreach ($link['link'] as $key => $label) {
|
||||||
$link['link'][$key] = Tools::htmlentitiesDecodeUTF8($label);
|
$link['link'][$key] = Tools::htmlentitiesDecodeUTF8($label);
|
||||||
|
}
|
||||||
|
|
||||||
$links_label_edit = $link['link'];
|
$links_label_edit = $link['link'];
|
||||||
$labels_edit = $link['label'];
|
$labels_edit = $link['label'];
|
||||||
@@ -1301,22 +1293,19 @@ class Blocktopmenu extends Module
|
|||||||
'id_linksmenutop' => Tools::getValue('id_linksmenutop'),
|
'id_linksmenutop' => Tools::getValue('id_linksmenutop'),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (Tools::getValue('submitAddmodule'))
|
if (Tools::getValue('submitAddmodule')) {
|
||||||
{
|
foreach (Language::getLanguages(false) as $lang) {
|
||||||
foreach (Language::getLanguages(false) as $lang)
|
|
||||||
{
|
|
||||||
$fields_values['label'][$lang['id_lang']] = '';
|
$fields_values['label'][$lang['id_lang']] = '';
|
||||||
$fields_values['link'][$lang['id_lang']] = '';
|
$fields_values['link'][$lang['id_lang']] = '';
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
foreach (Language::getLanguages(false) as $lang) {
|
||||||
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']]) ?
|
$fields_values['label'][$lang['id_lang']] = Tools::getValue('label_'.(int)$lang['id_lang'], isset($labels_edit[$lang['id_lang']]) ?
|
||||||
$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']] : '');
|
$links_label_edit[$lang['id_lang']] : '');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $fields_values;
|
return $fields_values;
|
||||||
}
|
}
|
||||||
@@ -1326,8 +1315,9 @@ class Blocktopmenu extends Module
|
|||||||
$shops = Shop::getContextListShopID();
|
$shops = Shop::getContextListShopID();
|
||||||
$links = array();
|
$links = array();
|
||||||
|
|
||||||
foreach ($shops as $shop_id)
|
foreach ($shops as $shop_id) {
|
||||||
$links = array_merge($links, MenuTopLinks::gets((int)$this->context->language->id, null, (int)$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(
|
'id_linksmenutop' => array(
|
||||||
|
|||||||
+13
-9
@@ -58,8 +58,7 @@ class MenuTopLinks
|
|||||||
$label = array();
|
$label = array();
|
||||||
$new_window = false;
|
$new_window = false;
|
||||||
|
|
||||||
foreach ($ret as $line)
|
foreach ($ret as $line) {
|
||||||
{
|
|
||||||
$link[$line['id_lang']] = Tools::safeOutput($line['link']);
|
$link[$line['id_lang']] = Tools::safeOutput($line['link']);
|
||||||
$label[$line['id_lang']] = Tools::safeOutput($line['label']);
|
$label[$line['id_lang']] = Tools::safeOutput($line['label']);
|
||||||
$new_window = (bool)$line['new_window'];
|
$new_window = (bool)$line['new_window'];
|
||||||
@@ -70,10 +69,12 @@ class MenuTopLinks
|
|||||||
|
|
||||||
public static function add($link, $label, $newWindow = 0, $id_shop)
|
public static function add($link, $label, $newWindow = 0, $id_shop)
|
||||||
{
|
{
|
||||||
if(!is_array($label))
|
if (!is_array($label)) {
|
||||||
return false;
|
return false;
|
||||||
if(!is_array($link))
|
}
|
||||||
|
if (!is_array($link)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
Db::getInstance()->insert(
|
Db::getInstance()->insert(
|
||||||
'linksmenutop',
|
'linksmenutop',
|
||||||
@@ -86,7 +87,7 @@ class MenuTopLinks
|
|||||||
|
|
||||||
$result = true;
|
$result = true;
|
||||||
|
|
||||||
foreach ($label as $id_lang=>$label)
|
foreach ($label as $id_lang=>$label) {
|
||||||
$result &= Db::getInstance()->insert(
|
$result &= Db::getInstance()->insert(
|
||||||
'linksmenutop_lang',
|
'linksmenutop_lang',
|
||||||
array(
|
array(
|
||||||
@@ -97,16 +98,19 @@ class MenuTopLinks
|
|||||||
'link'=>pSQL($link[$id_lang])
|
'link'=>pSQL($link[$id_lang])
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function update($link, $labels, $newWindow = 0, $id_shop, $id_link)
|
public static function update($link, $labels, $newWindow = 0, $id_shop, $id_link)
|
||||||
{
|
{
|
||||||
if(!is_array($labels))
|
if (!is_array($labels)) {
|
||||||
return false;
|
return false;
|
||||||
if(!is_array($link))
|
}
|
||||||
|
if (!is_array($link)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
Db::getInstance()->update(
|
Db::getInstance()->update(
|
||||||
'linksmenutop',
|
'linksmenutop',
|
||||||
@@ -117,7 +121,7 @@ class MenuTopLinks
|
|||||||
'id_linksmenutop = '.(int)$id_link
|
'id_linksmenutop = '.(int)$id_link
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ($labels as $id_lang => $label)
|
foreach ($labels as $id_lang => $label) {
|
||||||
Db::getInstance()->update(
|
Db::getInstance()->update(
|
||||||
'linksmenutop_lang',
|
'linksmenutop_lang',
|
||||||
array(
|
array(
|
||||||
@@ -128,6 +132,7 @@ class MenuTopLinks
|
|||||||
'id_linksmenutop = '.(int)$id_link.' AND id_lang = '.(int)$id_lang
|
'id_linksmenutop = '.(int)$id_link.' AND id_lang = '.(int)$id_lang
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function remove($id_linksmenutop, $id_shop)
|
public static function remove($id_linksmenutop, $id_shop)
|
||||||
@@ -138,5 +143,4 @@ class MenuTopLinks
|
|||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
if (!defined('_PS_VERSION_'))
|
if (!defined('_PS_VERSION_')) {
|
||||||
exit;
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
function upgrade_module_1_6($object)
|
function upgrade_module_1_6($object)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,8 +23,9 @@
|
|||||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||||
* International Registered Trademark & Property of PrestaShop SA
|
* International Registered Trademark & Property of PrestaShop SA
|
||||||
*/
|
*/
|
||||||
if (!defined('_PS_VERSION_'))
|
if (!defined('_PS_VERSION_')) {
|
||||||
exit;
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
function upgrade_module_2_1_1($object)
|
function upgrade_module_2_1_1($object)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user