diff --git a/modules/blocktopmenu/blocktopmenu.php b/modules/blocktopmenu/blocktopmenu.php
index abac27748..f607f3d2a 100644
--- a/modules/blocktopmenu/blocktopmenu.php
+++ b/modules/blocktopmenu/blocktopmenu.php
@@ -32,6 +32,22 @@ class blocktopmenu extends Module
private $_menu = '';
private $_html = '';
+ /*
+ * Pattern for matching config values
+ */
+ private $pattern = '/^([A-Z_]*)[0-9]+/';
+
+ /*
+ * Name of the controller
+ * Used to set item selected or not in top menu
+ */
+ private $page_name = '';
+
+ /*
+ * Spaces per depth in BO
+ */
+ private $spacer_size = '5';
+
public function __construct()
{
$this->name = 'blocktopmenu';
@@ -95,7 +111,9 @@ class blocktopmenu extends Module
public function getContent()
{
- global $cookie;
+ $id_lang = Shop::getContextShopID();
+ $spacer = str_repeat(' ', $this->spacer_size);
+
if(Tools::isSubmit('submitBlocktopmenu'))
{
if (Configuration::updateValue('MOD_BLOCKTOPMENU_ITEMS', Tools::getValue('items')))
@@ -104,7 +122,7 @@ class blocktopmenu extends Module
$this->_html .= $this->displayError($this->l('Unable to update settings'));
Configuration::updateValue('MOD_BLOCKTOPMENU_SEARCH', (bool)Tools::getValue('search'));
}
- if(Tools::isSubmit('submitBlocktopmenuLinks'))
+ else if(Tools::isSubmit('submitBlocktopmenuLinks'))
{
if(Tools::getValue('link') == '')
{
@@ -116,7 +134,7 @@ class blocktopmenu extends Module
$this->_html .= $this->displayConfirmation($this->l('The link has been added'));
}
}
- if(Tools::isSubmit('submitBlocktopmenuRemove'))
+ else if(Tools::isSubmit('submitBlocktopmenuRemove'))
{
$id_linksmenutop = Tools::getValue('id_linksmenutop', 0);
MenuTopLinks::remove($id_linksmenutop, (int)$this->context->shop->id);
@@ -151,44 +169,43 @@ class blocktopmenu extends Module
<< '.$this->l('Add').'
@@ -208,7 +225,8 @@ class blocktopmenu extends Module
$("#availableItems option:selected").each(function(i){
var val = $(this).val();
var text = $(this).text();
- if(val == "PRODUCT")
+ text = text.replace(/(^\s*)|(\s*$)/gi,"");
+ if (val == "PRODUCT")
{
val = prompt("'.$this->l('Set ID product').'");
if(val == null || val == "" || isNaN(val))
@@ -249,10 +267,11 @@ class blocktopmenu extends Module
';
- $defaultLanguage = intval(Configuration::get('PS_LANG_DEFAULT'));
- $languages = Language::getLanguages();
+ $defaultLanguage = intval($this->context->language->id);
+ $languages = $this->context->controller->getLanguages();
$iso = Language::getIsoById($defaultLanguage);
$divLangName = 'link_label';
+
$this->_html .= '
';
+ $links = MenuTopLinks::gets($id_lang, null, Shop::getContextShopID());
+
+ if (!count($links))
+ return $this->_html;
+
$this->_html .= '
|