diff --git a/modules/blocktopmenu/blocktopmenu.php b/modules/blocktopmenu/blocktopmenu.php
index f9a34eddc..5eabbbe96 100644
--- a/modules/blocktopmenu/blocktopmenu.php
+++ b/modules/blocktopmenu/blocktopmenu.php
@@ -27,7 +27,7 @@
require dirname(__FILE__).'/menutoplinks.class.php';
-class blocktopmenu extends Module
+class Blocktopmenu extends Module
{
private $_menu = '';
private $_html = '';
@@ -63,7 +63,7 @@ class blocktopmenu extends Module
public function install()
{
- if(!parent::install() ||
+ if (!parent::install() ||
!$this->registerHook('top') ||
!Configuration::updateGlobalValue('MOD_BLOCKTOPMENU_ITEMS', 'CAT1,CMS1,CMS2,PRD1') ||
!Configuration::updateGlobalValue('MOD_BLOCKTOPMENU_SEARCH', '1') ||
@@ -81,7 +81,7 @@ class blocktopmenu extends Module
`new_window` TINYINT( 1 ) NOT NULL,
`link` VARCHAR( 128 ) NOT NULL,
INDEX (`id_shop`)
- ) ENGINE = '._MYSQL_ENGINE_.' CHARACTER SET utf8 COLLATE utf8_general_ci;') AND
+ ) ENGINE = '._MYSQL_ENGINE_.' CHARACTER SET utf8 COLLATE utf8_general_ci;') &&
Db::getInstance()->execute('
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'linksmenutop_lang` (
`id_linksmenutop` INT NOT NULL,
@@ -114,7 +114,7 @@ class blocktopmenu extends Module
$id_lang = Shop::getContextShopID();
$spacer = str_repeat(' ', $this->spacer_size);
- if(Tools::isSubmit('submitBlocktopmenu'))
+ if (Tools::isSubmit('submitBlocktopmenu'))
{
if (Configuration::updateValue('MOD_BLOCKTOPMENU_ITEMS', Tools::getValue('items')))
$this->_html .= $this->displayConfirmation($this->l('Settings Updated'));
@@ -122,19 +122,17 @@ class blocktopmenu extends Module
$this->_html .= $this->displayError($this->l('Unable to update settings'));
Configuration::updateValue('MOD_BLOCKTOPMENU_SEARCH', (bool)Tools::getValue('search'));
}
- else if(Tools::isSubmit('submitBlocktopmenuLinks'))
+ else if (Tools::isSubmit('submitBlocktopmenuLinks'))
{
- if(Tools::getValue('link') == '')
- {
+ if (Tools::getValue('link') == '')
$this->_html .= $this->displayError($this->l('Unable to add this link'));
- }
else
{
MenuTopLinks::add(Tools::getValue('link'), Tools::getValue('label'), Tools::getValue('new_window', 0), (int)$this->context->shop->id);
$this->_html .= $this->displayConfirmation($this->l('The link has been added'));
}
}
- else 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);
@@ -178,14 +176,14 @@ class blocktopmenu extends Module
// BEGIN SUPPLIER
$this->_html .= '';
// BEGIN Manufacturer
$this->_html .= '';
@@ -202,7 +200,7 @@ class blocktopmenu extends Module
// BEGIN Menu Top Links
$this->_html .= '';
@@ -229,7 +227,7 @@ class blocktopmenu extends Module
if (val == "PRODUCT")
{
val = prompt("'.$this->l('Set ID product').'");
- if(val == null || val == "" || isNaN(val))
+ if (val == null || val == "" || isNaN(val))
return;
text = "'.$this->l('Product ID').' "+val;
val = "PRD"+val;
@@ -321,7 +319,7 @@ class blocktopmenu extends Module
';
- foreach($links as $link)
+ foreach ($links as $link)
{
$this->_html .= '
@@ -354,7 +352,7 @@ class blocktopmenu extends Module
$id_lang = (int)$this->context->language->id;
$id_shop = (int)Shop::getContextShopID();
- foreach($menu_item as $type => $item)
+ foreach ($menu_item as $type => $item)
{
if (!$item)
continue;
@@ -364,39 +362,45 @@ class blocktopmenu extends Module
switch (substr($item, 0, strlen($values[1])))
{
- case'CAT':
+ case 'CAT':
$category = new Category($id, $id_lang);
- if(!is_null($category->id))
+ if (!is_null($category->id))
$this->_html .= ''.PHP_EOL;
break;
- case'PRD':
+
+ case 'PRD':
$product = new Product($id, true, $id_lang);
- if(!is_null($product->id))
+ if (!is_null($product->id))
$this->_html .= ''.PHP_EOL;
break;
- case'CMS':
+
+ case 'CMS':
$cms = new CMS($id, $id_lang);
if (count($cms))
$this->_html .= ''.PHP_EOL;
break;
- case'CMS_CAT':
+
+ case 'CMS_CAT':
$category = new CMSCategory($id, $id_lang);
if (count($category))
$this->_html .= ''.PHP_EOL;
break;
- case'MAN':
+
+ case 'MAN':
$manufacturer = new Manufacturer($id, $id_lang);
- if(!is_null($manufacturer->id))
+ if (!is_null($manufacturer->id))
$this->_html .= ''.PHP_EOL;
break;
- case'SUP':
+
+ case 'SUP':
$supplier = new Supplier($id, $id_lang);
- if(!is_null($supplier->id))
+ if (!is_null($supplier->id))
$this->_html .= ''.PHP_EOL;
break;
- case'LNK':
+
+ case 'LNK':
$link = MenuTopLinks::get($id, $id_lang, $id_shop);
- if(count($link))
+ if (count($link))
$this->_html .= ''.PHP_EOL;
break;
}
@@ -405,14 +409,13 @@ class blocktopmenu extends Module
private function makeMenu()
{
- if (isset($this->context->controller->php_self))
- $this->page_name = $this->context->controller->php_self;
+ $this->page_name = Dispatcher::getInstance()->getController();
$menu_items = $this->getMenuItems();
$id_lang = (int)$this->context->language->id;
$id_shop = (int)Shop::getContextShopID();
- foreach($menu_items as $type => $item)
+ foreach ($menu_items as $type => $item)
{
if (!$item)
continue;
@@ -420,24 +423,27 @@ class blocktopmenu extends Module
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':
+ case 'CAT':
$this->getCategory($id);
break;
- case'PRD':
+
+ case 'PRD':
$selected = ($this->page_name == 'product' && (Tools::getValue('id_product') == $id)) ? ' class="sfHover"' : '';
$product = new Product($id, true, $id_lang);
if (!is_null($product->id))
$this->_menu .= ''.$product->name.''.PHP_EOL;
break;
- case'CMS':
+
+ case 'CMS':
$selected = ($this->page_name == 'cms' && (Tools::getValue('id_cms') == $id)) ? ' class="sfHover"' : '';
$cms = CMS::getLinks($id_lang, array($id));
if (count($cms))
$this->_menu .= ''.$cms[0]['meta_title'].''.PHP_EOL;
break;
- case'CMS_CAT':
+
+ case 'CMS_CAT':
$category = new CMSCategory($id, $id_lang);
if (count($category))
{
@@ -446,7 +452,8 @@ class blocktopmenu extends Module
$this->_menu .= ''.PHP_EOL;
}
break;
- case'MAN':
+
+ case 'MAN':
$selected = ($this->page_name == 'manufacturer' && (Tools::getValue('id_manufacturer') == $id)) ? ' class="sfHover"' : '';
$manufacturer = new Manufacturer($id, $id_lang);
if (!is_null($manufacturer->id))
@@ -459,7 +466,8 @@ class blocktopmenu extends Module
$this->_menu .= ''.$manufacturer->name.''.PHP_EOL;
}
break;
- case'SUP':
+
+ case 'SUP':
$selected = ($this->page_name == 'supplier' && (Tools::getValue('id_supplier') == $id)) ? ' class="sfHover"' : '';
$supplier = new Supplier($id, $id_lang);
if (!is_null($supplier->id))
@@ -468,7 +476,8 @@ class blocktopmenu extends Module
$this->_menu .= ''.$supplier->name.''.PHP_EOL;
}
break;
- case'LNK':
+
+ case 'LNK':
$link = MenuTopLinks::get($id, $id_lang, $id_shop);
if (count($link))
$this->_menu .= ''.$link[0]['label'].''.PHP_EOL;
@@ -494,7 +503,7 @@ class blocktopmenu extends Module
$this->_html .= '';
if (isset($childrens) && count($childrens))
- foreach($childrens as $children)
+ foreach ($childrens as $children)
$this->getCategoryOption((int)$children['id_category'], $id_lang);
}
@@ -515,7 +524,7 @@ class blocktopmenu extends Module
{
$this->_menu .= '';
- foreach($childrens as $children)
+ foreach ($childrens as $children)
$this->getCategory($children['id_category'], $id_lang);
$this->_menu .= '
';
@@ -586,6 +595,10 @@ class blocktopmenu extends Module
$smarty->assign('MENU', $this->_menu);
$smarty->assign('this_path', $this->_path);
+ $this->context->controller->addJS($this->_path.'js/hoverIntent.js');
+ $this->context->controller->addJS($this->_path.'js/superfish-modified.js');
+ $this->context->controller->addCSS($this->_path.'css/superfish-modified.css');
+
return $this->display(__FILE__, 'blocktopmenu.tpl');
}
diff --git a/modules/blocktopmenu/blocktopmenu.tpl b/modules/blocktopmenu/blocktopmenu.tpl
index 2d29a4fd1..0313d4026 100644
--- a/modules/blocktopmenu/blocktopmenu.tpl
+++ b/modules/blocktopmenu/blocktopmenu.tpl
@@ -1,22 +1,21 @@
- {if $MENU != ''}
-
-
-
-
-
-
-
-
-
- {/if}
\ No newline at end of file
+{if $MENU != ''}
+
+
+
+
+
+
+
+
+{/if}
\ No newline at end of file