// Fix tab display in menu when there are no subtabs

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@12376 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
tDidierjean
2012-01-11 17:12:16 +00:00
parent 7e52ee8a7b
commit e9c83be015
+10 -9
View File
@@ -60,7 +60,7 @@ class AdminControllerCore extends Controller
/** @var integer Tab id */ /** @var integer Tab id */
public $id = -1; public $id = -1;
/** @var array noTabLink array of admintab names witch have no content */ /** @var array noTabLink array of admintab names which have no content */
public $noTabLink = array('AdminCatalog', 'AdminTools', 'AdminStock', 'AdminAccounting'); public $noTabLink = array('AdminCatalog', 'AdminTools', 'AdminStock', 'AdminAccounting');
public $required_database = false; public $required_database = false;
@@ -1237,8 +1237,6 @@ class AdminControllerCore extends Controller
$tabs = Tab::getTabs($this->context->language->id, 0); $tabs = Tab::getTabs($this->context->language->id, 0);
$current_id = Tab::getCurrentParentId(); $current_id = Tab::getCurrentParentId();
foreach ($tabs as $index => $tab) foreach ($tabs as $index => $tab)
{
if (Tab::checkTabRights($tab['id_tab']) === true AND (bool)$tab['active'])
{ {
if ($tab['name'] == 'Stock' && Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') == 0) if ($tab['name'] == 'Stock' && Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') == 0)
{ {
@@ -1265,20 +1263,23 @@ class AdminControllerCore extends Controller
$tabs[$index]['href'] = $this->context->link->getAdminLink($tab['class_name']); $tabs[$index]['href'] = $this->context->link->getAdminLink($tab['class_name']);
$sub_tabs = Tab::getTabs($this->context->language->id, $tab['id_tab']); $sub_tabs = Tab::getTabs($this->context->language->id, $tab['id_tab']);
// Add parent tab to sub_tabs list
array_unshift($sub_tabs, $tab);
foreach ($sub_tabs as $index2 => $sub_tab) foreach ($sub_tabs as $index2 => $sub_tab)
{ {
// class_name is the name of the class controller // class_name is the name of the class controller
if (Tab::checkTabRights($sub_tab['id_tab']) === true AND (bool)$sub_tab['active']) if (Tab::checkTabRights($sub_tab['id_tab']) === true
&& (bool)$sub_tab['active']
&& !in_array($sub_tab['class_name'], $this->noTabLink)) // check that tab is not in "do not display" list
$sub_tabs[$index2]['href'] = $this->context->link->getAdminLink($sub_tab['class_name']); $sub_tabs[$index2]['href'] = $this->context->link->getAdminLink($sub_tab['class_name']);
else else
unset($sub_tabs[$index2]); unset($sub_tabs[$index2]);
} }
$tabs[$index]['sub_tabs'] = $sub_tabs; $tabs[$index]['sub_tabs'] = $sub_tabs;
// @todo need a better way than using noTabLink property, keeping the fact to avoid db modification
if (!in_array($tab['class_name'], $this->noTabLink)) // If there are no subtabs, we don't want to display the parent tab in menu
array_unshift($tabs[$index]['sub_tabs'], $tabs[$index]); if (empty($sub_tabs))
}
else
unset($tabs[$index]); unset($tabs[$index]);
} }