Removed search feature, already handled in own module
This commit is contained in:
+46
-175
@@ -93,7 +93,7 @@ class Blocktopmenu extends Module implements WidgetInterface
|
|||||||
$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')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -130,7 +130,7 @@ class Blocktopmenu extends Module implements WidgetInterface
|
|||||||
$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')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -190,8 +190,6 @@ class Blocktopmenu extends Module implements WidgetInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$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;
|
||||||
@@ -463,54 +461,22 @@ class Blocktopmenu extends Module implements WidgetInterface
|
|||||||
return $html.'</select>';
|
return $html.'</select>';
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getCMSMenuItems($id, $id_lang)
|
protected function makeNode(array $fields)
|
||||||
{
|
{
|
||||||
$nodes = [];
|
$defaults = [
|
||||||
|
'type' => '',
|
||||||
|
'label' => '',
|
||||||
|
'url' => '',
|
||||||
|
'children' => [],
|
||||||
|
'open_in_new_window' => false,
|
||||||
|
'image_urls' => []
|
||||||
|
];
|
||||||
|
|
||||||
$categories = $this->getCMSCategories(false, (int)$id, (int)$id_lang);
|
return array_merge($defaults, $fields);
|
||||||
ddd($categories);
|
|
||||||
|
|
||||||
return $nodes;
|
|
||||||
|
|
||||||
/*
|
|
||||||
$id_lang = $id_lang ? (int)$id_lang : (int)Context::getContext()->language->id;
|
|
||||||
|
|
||||||
if ($depth > 3) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$categories = $this->getCMSCategories(false, (int)$parent, (int)$id_lang);
|
|
||||||
$pages = $this->getCMSPages((int)$parent);
|
|
||||||
|
|
||||||
if (count($categories) || count($pages)) {
|
|
||||||
$this->_menu .= '<ul>';
|
|
||||||
|
|
||||||
foreach ($categories as $category) {
|
|
||||||
$cat = new CMSCategory((int)$category['id_cms_category'], (int)$id_lang);
|
|
||||||
|
|
||||||
$this->_menu .= '<li>';
|
|
||||||
$this->_menu .= '<a href="'.Tools::HtmlEntitiesUTF8($cat->getLink()).'">'.$category['name'].'</a>';
|
|
||||||
$this->getCMSMenuItems($category['id_cms_category'], (int)$depth + 1);
|
|
||||||
$this->_menu .= '</li>';
|
|
||||||
}
|
|
||||||
|
|
||||||
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 .= '<li '.$selected.'>';
|
|
||||||
$this->_menu .= '<a href="'.$links[0]['link'].'">'.$cms->meta_title.'</a>';
|
|
||||||
$this->_menu .= '</li>';
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->_menu .= '</ul>';
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function generateCMSCategoriesMenu($id_cms_category, $id_lang)
|
protected function generateCMSCategoriesMenu($id_cms_category, $id_lang)
|
||||||
{
|
{
|
||||||
$selected = false; // FIXME
|
|
||||||
$category = new CMSCategory($id_cms_category, $id_lang);
|
$category = new CMSCategory($id_cms_category, $id_lang);
|
||||||
|
|
||||||
$rawSubCategories = $this->getCMSCategories(false, $id_cms_category, $id_lang);
|
$rawSubCategories = $this->getCMSCategories(false, $id_cms_category, $id_lang);
|
||||||
@@ -521,8 +487,7 @@ class Blocktopmenu extends Module implements WidgetInterface
|
|||||||
}, $rawSubCategories);
|
}, $rawSubCategories);
|
||||||
|
|
||||||
$subPages = array_map(function ($page) use ($id_lang) {
|
$subPages = array_map(function ($page) use ($id_lang) {
|
||||||
$selected = false; // FIXME
|
return $this->makeNode([
|
||||||
return [
|
|
||||||
'type' => 'cms-page',
|
'type' => 'cms-page',
|
||||||
'label' => $page['meta_title'],
|
'label' => $page['meta_title'],
|
||||||
'url' => $this->context->link->getCMSLink(
|
'url' => $this->context->link->getCMSLink(
|
||||||
@@ -530,28 +495,26 @@ class Blocktopmenu extends Module implements WidgetInterface
|
|||||||
null, null,
|
null, null,
|
||||||
$id_lang
|
$id_lang
|
||||||
),
|
),
|
||||||
'current' => $selected
|
]);
|
||||||
];
|
|
||||||
}, $rawSubPages);
|
}, $rawSubPages);
|
||||||
|
|
||||||
$node = [
|
$node = $this->makeNode([
|
||||||
'type' => 'cms-category',
|
'type' => 'cms-category',
|
||||||
'label' => $category->name,
|
'label' => $category->name,
|
||||||
'url' => $category->getLink(),
|
'url' => $category->getLink(),
|
||||||
'current' => $selected,
|
|
||||||
'children' => array_merge($subCategories, $subPages)
|
'children' => array_merge($subCategories, $subPages)
|
||||||
];
|
]);
|
||||||
|
|
||||||
return $node;
|
return $node;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function makeMenu()
|
protected function makeMenu()
|
||||||
{
|
{
|
||||||
$root_node = [
|
$root_node = $this->makeNode([
|
||||||
'label' => null,
|
'label' => null,
|
||||||
'type' => 'root',
|
'type' => 'root',
|
||||||
'children' => []
|
'children' => []
|
||||||
];
|
]);
|
||||||
|
|
||||||
$menu_items = $this->getMenuItems();
|
$menu_items = $this->getMenuItems();
|
||||||
$id_lang = (int)$this->context->language->id;
|
$id_lang = (int)$this->context->language->id;
|
||||||
@@ -574,28 +537,24 @@ class Blocktopmenu extends Module implements WidgetInterface
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'PRD':
|
case 'PRD':
|
||||||
$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 ($product->id) {
|
if ($product->id) {
|
||||||
$root_node['children'][] = [
|
$root_node['children'][] = $this->makeNode([
|
||||||
'type' => 'product',
|
'type' => 'product',
|
||||||
'label' => $product->name,
|
'label' => $product->name,
|
||||||
'url' => $product->getLink(),
|
'url' => $product->getLink(),
|
||||||
'current' => $selected
|
]);
|
||||||
];
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'CMS':
|
case 'CMS':
|
||||||
$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)) {
|
||||||
$root_node['children'][] = [
|
$root_node['children'][] = $this->makeNode([
|
||||||
'type' => 'cms-page',
|
'type' => 'cms-page',
|
||||||
'label' => $cms[0]['meta_title'],
|
'label' => $cms[0]['meta_title'],
|
||||||
'url' => $cms[0]['link'],
|
'url' => $cms[0]['link']
|
||||||
'current' => $selected
|
]);
|
||||||
];
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -605,102 +564,86 @@ class Blocktopmenu extends Module implements WidgetInterface
|
|||||||
|
|
||||||
// Case to handle the option to show all Manufacturers
|
// Case to handle the option to show all Manufacturers
|
||||||
case 'ALLMAN':
|
case 'ALLMAN':
|
||||||
$current = false; // FIXME
|
|
||||||
|
|
||||||
$children = array_map(function ($manufacturer) use ($id_lang) {
|
$children = array_map(function ($manufacturer) use ($id_lang) {
|
||||||
$current = false; // FIXME
|
return $this->makeNode([
|
||||||
return [
|
|
||||||
'type' => 'manufacturer',
|
'type' => 'manufacturer',
|
||||||
'label' => $manufacturer['name'],
|
'label' => $manufacturer['name'],
|
||||||
'url' => $this->context->link->getManufacturerLink(
|
'url' => $this->context->link->getManufacturerLink(
|
||||||
new Manufacturer($manufacturer['id_manufacturer'], $id_lang),
|
new Manufacturer($manufacturer['id_manufacturer'], $id_lang),
|
||||||
null,
|
null,
|
||||||
$id_lang
|
$id_lang
|
||||||
),
|
)
|
||||||
'current' => false
|
]);
|
||||||
];
|
|
||||||
}, Manufacturer::getManufacturers());
|
}, Manufacturer::getManufacturers());
|
||||||
|
|
||||||
$root_node['children'][] = [
|
$root_node['children'][] = $this->makeNode([
|
||||||
'type' => 'manufacturers',
|
'type' => 'manufacturers',
|
||||||
'label' => $this->l('All manufacturers'),
|
'label' => $this->l('All manufacturers'),
|
||||||
'url' => $this->context->link->getPageLink('manufacturer'),
|
'url' => $this->context->link->getPageLink('manufacturer'),
|
||||||
'current' => $current,
|
|
||||||
'children' => $children
|
'children' => $children
|
||||||
];
|
]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'MAN':
|
case 'MAN':
|
||||||
$current = ($this->page_name == 'manufacturer' && (Tools::getValue('id_manufacturer') == $id));
|
|
||||||
$manufacturer = new Manufacturer($id, $id_lang);
|
$manufacturer = new Manufacturer($id, $id_lang);
|
||||||
if ($manufacturer->id) {
|
if ($manufacturer->id) {
|
||||||
$root_node['children'][] = [
|
$root_node['children'][] = $this->makeNode([
|
||||||
'type' => 'manufacturer',
|
'type' => 'manufacturer',
|
||||||
'label' => $manufacturer->name,
|
'label' => $manufacturer->name,
|
||||||
'url' => $this->context->link->getManufacturerLink(
|
'url' => $this->context->link->getManufacturerLink(
|
||||||
$manufacturer,
|
$manufacturer,
|
||||||
null,
|
null,
|
||||||
$id_lang
|
$id_lang
|
||||||
),
|
)
|
||||||
'current' => $current
|
]);
|
||||||
];
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Case to handle the option to show all Suppliers
|
// Case to handle the option to show all Suppliers
|
||||||
case 'ALLSUP':
|
case 'ALLSUP':
|
||||||
$current = false; // FIXME
|
|
||||||
|
|
||||||
$children = array_map(function ($supplier) use ($id_lang) {
|
$children = array_map(function ($supplier) use ($id_lang) {
|
||||||
$current = false; // FIXME
|
return $this->makeNode([
|
||||||
return [
|
|
||||||
'type' => 'supplier',
|
'type' => 'supplier',
|
||||||
'label' => $supplier['name'],
|
'label' => $supplier['name'],
|
||||||
'url' => $this->context->link->getManufacturerLink(
|
'url' => $this->context->link->getManufacturerLink(
|
||||||
new Manufacturer($supplier['id_manufacturer'], $id_lang),
|
new Supplier($supplier['id_supplier'], $id_lang),
|
||||||
null,
|
null,
|
||||||
$id_lang
|
$id_lang
|
||||||
),
|
)
|
||||||
'current' => false
|
]);
|
||||||
];
|
|
||||||
}, Supplier::getSuppliers());
|
}, Supplier::getSuppliers());
|
||||||
|
|
||||||
$root_node['children'][] = [
|
$root_node['children'][] = $this->makeNode([
|
||||||
'type' => 'suppliers',
|
'type' => 'suppliers',
|
||||||
'label' => $this->l('All suppliers'),
|
'label' => $this->l('All suppliers'),
|
||||||
'url' => $this->context->link->getPageLink('supplier'),
|
'url' => $this->context->link->getPageLink('supplier'),
|
||||||
'current' => $current,
|
|
||||||
'children' => $children
|
'children' => $children
|
||||||
];
|
]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'SUP':
|
case 'SUP':
|
||||||
$current = ($this->page_name == 'supplier' && (Tools::getValue('id_supplier') == $id));
|
|
||||||
$supplier = new Supplier($id, $id_lang);
|
$supplier = new Supplier($id, $id_lang);
|
||||||
if ($supplier->id) {
|
if ($supplier->id) {
|
||||||
$root_node['children'][] = [
|
$root_node['children'][] = $this->makeNode([
|
||||||
'type' => 'supplier',
|
'type' => 'supplier',
|
||||||
'label' => $supplier->name,
|
'label' => $supplier->name,
|
||||||
'url' => $this->context->link->getSupplierLink(
|
'url' => $this->context->link->getSupplierLink(
|
||||||
$supplier,
|
$supplier,
|
||||||
null,
|
null,
|
||||||
$id_lang
|
$id_lang
|
||||||
),
|
)
|
||||||
'current' => $current
|
]);
|
||||||
];
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'SHOP':
|
case 'SHOP':
|
||||||
$current = ($this->page_name == 'index' && ($this->context->shop->id == $id));
|
|
||||||
$shop = new Shop((int)$id);
|
$shop = new Shop((int)$id);
|
||||||
if (Validate::isLoadedObject($shop)) {
|
if (Validate::isLoadedObject($shop)) {
|
||||||
$root_node['children'][] = [
|
$root_node['children'][] = $this->makeNode([
|
||||||
'type' => 'shop',
|
'type' => 'shop',
|
||||||
'label' => $shop->name,
|
'label' => $shop->name,
|
||||||
'url' => $shop->getBaseURL(),
|
'url' => $shop->getBaseURL(),
|
||||||
'current' => $current
|
]);
|
||||||
];
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'LNK':
|
case 'LNK':
|
||||||
@@ -710,13 +653,12 @@ class Blocktopmenu extends Module implements WidgetInterface
|
|||||||
$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());
|
||||||
}
|
}
|
||||||
$root_node['children'][] = [
|
$root_node['children'][] = $this->makeNode([
|
||||||
'type' => 'link',
|
'type' => 'link',
|
||||||
'label' => $link[0]['label'],
|
'label' => $link[0]['label'],
|
||||||
'url' => $link[0]['link'],
|
'url' => $link[0]['link'],
|
||||||
'current' => false,
|
|
||||||
'open_in_new_window' => $link[0]['new_window']
|
'open_in_new_window' => $link[0]['new_window']
|
||||||
];
|
]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1037,24 +979,6 @@ class Blocktopmenu extends Module implements WidgetInterface
|
|||||||
'label' => '',
|
'label' => '',
|
||||||
'name' => 'link',
|
'name' => 'link',
|
||||||
'lang' => true,
|
'lang' => true,
|
||||||
),
|
|
||||||
array(
|
|
||||||
'type' => 'switch',
|
|
||||||
'label' => $this->l('Search bar'),
|
|
||||||
'name' => 'search',
|
|
||||||
'is_bool' => true,
|
|
||||||
'values' => array(
|
|
||||||
array(
|
|
||||||
'id' => 'active_on',
|
|
||||||
'value' => 1,
|
|
||||||
'label' => $this->l('Enabled')
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'id' => 'active_off',
|
|
||||||
'value' => 0,
|
|
||||||
'label' => $this->l('Disabled')
|
|
||||||
)
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'submit' => array(
|
'submit' => array(
|
||||||
@@ -1072,26 +996,6 @@ class Blocktopmenu extends Module implements WidgetInterface
|
|||||||
),
|
),
|
||||||
'info' => '<div class="alert alert-warning">'.
|
'info' => '<div class="alert alert-warning">'.
|
||||||
$this->l('All active products combinations quantities will be changed').'</div>',
|
$this->l('All active products combinations quantities will be changed').'</div>',
|
||||||
'input' => array(
|
|
||||||
array(
|
|
||||||
'type' => 'switch',
|
|
||||||
'label' => $this->l('Search bar'),
|
|
||||||
'name' => 'search',
|
|
||||||
'is_bool' => true,
|
|
||||||
'values' => array(
|
|
||||||
array(
|
|
||||||
'id' => 'active_on',
|
|
||||||
'value' => 1,
|
|
||||||
'label' => $this->l('Enabled')
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'id' => 'active_off',
|
|
||||||
'value' => 0,
|
|
||||||
'label' => $this->l('Disabled')
|
|
||||||
)
|
|
||||||
),
|
|
||||||
)
|
|
||||||
),
|
|
||||||
'submit' => array(
|
'submit' => array(
|
||||||
'name' => 'submitBlocktopmenu',
|
'name' => 'submitBlocktopmenu',
|
||||||
'title' => $this->l('Save')
|
'title' => $this->l('Save')
|
||||||
@@ -1113,7 +1017,6 @@ class Blocktopmenu extends Module implements WidgetInterface
|
|||||||
'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name;
|
'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name;
|
||||||
$helper->token = Tools::getAdminTokenLite('AdminModules');
|
$helper->token = Tools::getAdminTokenLite('AdminModules');
|
||||||
$helper->tpl_vars = array(
|
$helper->tpl_vars = array(
|
||||||
'fields_value' => $this->getConfigFieldsValues(),
|
|
||||||
'languages' => $this->context->controller->getLanguages(),
|
'languages' => $this->context->controller->getLanguages(),
|
||||||
'id_language' => $this->context->language->id,
|
'id_language' => $this->context->language->id,
|
||||||
'choices' => $this->renderChoicesSelect(),
|
'choices' => $this->renderChoicesSelect(),
|
||||||
@@ -1340,21 +1243,6 @@ class Blocktopmenu extends Module implements WidgetInterface
|
|||||||
return Cache::retrieve($cache_id);
|
return Cache::retrieve($cache_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
return array(
|
|
||||||
'search' => (int)$is_search_on
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAddLinkFieldsValues()
|
public function getAddLinkFieldsValues()
|
||||||
{
|
{
|
||||||
$links_label_edit = '';
|
$links_label_edit = '';
|
||||||
@@ -1446,29 +1334,12 @@ class Blocktopmenu extends Module implements WidgetInterface
|
|||||||
|
|
||||||
public function getWidgetVariables($hookName, array $configuration)
|
public function getWidgetVariables($hookName, array $configuration)
|
||||||
{
|
{
|
||||||
ddd($this->makeMenu());
|
return $this->makeMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function renderWidget($hookName, array $configuration)
|
public function renderWidget($hookName, array $configuration)
|
||||||
{
|
{
|
||||||
$variables = $this->getWidgetVariables($hookName, $configuration);
|
$variables = $this->getWidgetVariables($hookName, $configuration);
|
||||||
/*$this->user_groups = ($this->context->customer->isLogged() ?
|
ddd($variables);
|
||||||
$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();
|
|
||||||
}
|
|
||||||
|
|
||||||
$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);
|
|
||||||
}
|
|
||||||
|
|
||||||
$html = $this->display(__FILE__, 'blocktopmenu.tpl', $this->getCacheId());
|
|
||||||
return $html;*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user