From 845d74102427fd395b2a92bd9fbbe6f95ecbd0fc Mon Sep 17 00:00:00 2001 From: mMarinetti Date: Fri, 4 Nov 2011 10:59:10 +0000 Subject: [PATCH] // #PSFV-94 - fixed bug related to new breadcrumb system git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@9881 b9a71923-0436-4b27-9f14-aed3839534dd --- admin-dev/themes/template/header.tpl | 13 ------- .../template/helper/list/list_header.tpl | 19 ++++++---- admin-dev/themes/template/toolbar.tpl | 7 ---- classes/AdminController.php | 38 ++++++++++++------- classes/HelperList.php | 9 +++++ .../admin/AdminCategoriesController.php | 7 ++-- .../admin/AdminManufacturersController.php | 3 +- controllers/admin/AdminSearchController.php | 2 + 8 files changed, 51 insertions(+), 47 deletions(-) diff --git a/admin-dev/themes/template/header.tpl b/admin-dev/themes/template/header.tpl index 071f675d0..0f3e4d42e 100644 --- a/admin-dev/themes/template/header.tpl +++ b/admin-dev/themes/template/header.tpl @@ -306,19 +306,6 @@ $(document).ready(function() {/if} - {* We should display breadcrumb only if needed *} - {if count($tabs_breadcrumb)>1} -
- - {l s='Back Office'} - {foreach $tabs_breadcrumb AS $item} - > - {if isset($item.token)}{/if} - {$item.name} - {if isset($item.token)}{/if} - {/foreach} -
- {/if} {if $is_multishop && $shop_context != 'all'}
{if $shop_context == 'group'} diff --git a/admin-dev/themes/template/helper/list/list_header.tpl b/admin-dev/themes/template/helper/list/list_header.tpl index 04ba16dfb..a5c6993f0 100644 --- a/admin-dev/themes/template/helper/list/list_header.tpl +++ b/admin-dev/themes/template/helper/list/list_header.tpl @@ -56,17 +56,20 @@ }); - {if $show_toolbar} -
-

{block name=pageTitle} - {$page_title|default:' '} - {/block}

-
- {include file="toolbar.tpl" toolbar_btn=$toolbar_btn} - {/if} {/if}{* End if simple_header *} +{if $show_toolbar} +
+ {include file="toolbar.tpl" toolbar_btn=$toolbar_btn} +
+

{block name=pageTitle} + {$title|default:' '} + {/block}

+
+
+{/if} +{block name="leadin"}{/block}  
diff --git a/admin-dev/themes/template/toolbar.tpl b/admin-dev/themes/template/toolbar.tpl index 9b89bcfa6..4237bab7b 100644 --- a/admin-dev/themes/template/toolbar.tpl +++ b/admin-dev/themes/template/toolbar.tpl @@ -24,7 +24,6 @@ * International Registered Trademark & Property of PrestaShop SA *} -
{block name=toolbarBox}
    {foreach from=$toolbar_btn item=btn key=k} @@ -36,11 +35,6 @@ {/foreach}
-
-

{block name=pageTitle} - {$title|default:' '} - {/block}

-
{/block} -
diff --git a/classes/AdminController.php b/classes/AdminController.php index 8fbd9340f..90c4923de 100644 --- a/classes/AdminController.php +++ b/classes/AdminController.php @@ -262,6 +262,27 @@ class AdminControllerCore extends Controller $this->context->currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT')); } + /** + * set default toolbar_title to admin breadcrumb + * + * @return void + */ + public function initToolbarTitle() + { + // Breadcrumbs + $tabs= array(); + $tabs= Tab::recursiveTab($this->id, $tabs); + $tabs= array_reverse($tabs); + $bread = ''; + // note : this should use a tpl file + foreach ($tabs AS $key => $item) + $bread .= ''.$item['name'].' : '; + + $bread = rtrim($bread, ': '); + + $this->toolbar_title = $bread; + } + /** * Check rights to view the current tab * @@ -1014,18 +1035,6 @@ class AdminControllerCore extends Controller else unset($tabs[$index]); } - // Breadcrumbs - $home_token = Tools::getAdminToken('AdminHome'.intval(Tab::getIdFromClassName('AdminHome')).(int)$this->context->employee->id); - $tabs_breadcrumb = array(); - $tabs_breadcrumb = Tab::recursiveTab($this->id, $tabs_breadcrumb); - $tabs_breadcrumb = array_reverse($tabs_breadcrumb); - - foreach ($tabs_breadcrumb as $key => $item) - { - $tabs_count = count($tabs_breadcrumb) - 1; - for ($i = 0; $i < $tabs_count; $i++) - $tabs_breadcrumb[$key]['token'] = Tools::getAdminToken($item['class_name'].intval($item['id_tab']).(int)$this->context->employee->id); - } /* Hooks are volontary out the initialize array (need those variables already assigned) */ $bo_color = empty($this->context->employee->bo_color) ? '#FFFFFF' : $this->context->employee->bo_color; @@ -1066,8 +1075,6 @@ class AdminControllerCore extends Controller 'current_parent_id' => (int)Tab::getCurrentParentId(), 'tabs' => $tabs, 'install_dir_exists' => file_exists(_PS_ADMIN_DIR_.'/../install'), - 'home_token' => $home_token, - 'tabs_breadcrumb' => $tabs_breadcrumb, 'is_multishop' => $is_multishop, 'pic_dir' => _THEME_PROD_PIC_DIR_ )); @@ -1185,6 +1192,7 @@ class AdminControllerCore extends Controller $this->actions[] = $action; } + $helper->tpl_vars = $this->tpl_list_vars; $this->setHelperListDisplay($helper); return $helper->generateList($this->_list, $this->fieldsDisplay); } @@ -1204,6 +1212,8 @@ class AdminControllerCore extends Controller */ public function setHelperListDisplay(Helper $helper) { + if (empty($this->toolbar_title)) + $this->initToolbarTitle(); // @todo : move that in Helper $helper->actions = $this->actions; $helper->simple_header = $this->list_simple_header; diff --git a/classes/HelperList.php b/classes/HelperList.php index d7c49cdee..3a0c33392 100644 --- a/classes/HelperList.php +++ b/classes/HelperList.php @@ -344,6 +344,7 @@ class HelperListCore extends Helper 'has_actions' => !empty($this->actions), 'has_bulk_actions' => !empty($this->bulk_actions), 'list_skip_actions' => $this->list_skip_actions, + 'tpl_vars' => $this->tpl_vars )); return $this->content_tpl->fetch(); } @@ -593,6 +594,10 @@ class HelperListCore extends Helper 'name' => isset($name) ? $name : null, 'name_id' => isset($name_id) ? $name_id : null, 'show_toolbar' => $this->show_toolbar, + + 'back' => Tools::getValue('back'), + 'no_back' => $this->no_back, + 'tpl_vars' => $this->tpl_vars, )); return $this->header_tpl->fetch(); @@ -609,6 +614,10 @@ class HelperListCore extends Helper 'current' => $this->currentIndex, 'simple_header' => $this->simple_header, 'bulk_actions' => $this->bulk_actions, + + 'back' => Tools::getValue('back'), + 'no_back' => $this->no_back, + 'tpl_vars' =>$this->tpl_vars )); return $this->footer_tpl->fetch(); } diff --git a/controllers/admin/AdminCategoriesController.php b/controllers/admin/AdminCategoriesController.php index e71f4ca4a..14fdf56c6 100644 --- a/controllers/admin/AdminCategoriesController.php +++ b/controllers/admin/AdminCategoriesController.php @@ -103,8 +103,9 @@ class AdminCategoriesControllerCore extends AdminController $categories_tree = $this->_category->getParentsCategories($this->context->language->id); asort($categories_tree); - $this->context->smarty->assign('categories_name', stripslashes($this->_category->getName())); - $this->context->smarty->assign('categories_tree', $categories_tree); + $categories_name = stripslashes($this->_category->getName()); + $this->tpl_list_vars['categories_tree'] = $categories_tree; + $this->tpl_list_vars['categories_name'] = $categories_name; return parent::initList(); } @@ -129,7 +130,7 @@ class AdminCategoriesControllerCore extends AdminController public function initToolbar() { - $this->toolbar_title = stripslashes($this->_category->getName()); + // $this->toolbar_title = stripslashes($this->_category->getName()); if (empty($this->display)) $this->toolbar_btn['new'] = array( 'href' => self::$currentIndex.'&add'.$this->table.'&token='.$this->token, diff --git a/controllers/admin/AdminManufacturersController.php b/controllers/admin/AdminManufacturersController.php index 22c05d514..e359c88bd 100644 --- a/controllers/admin/AdminManufacturersController.php +++ b/controllers/admin/AdminManufacturersController.php @@ -88,7 +88,6 @@ class AdminManufacturersControllerCore extends AdminController public function initListManufacturer() { - $this->toolbar_title = $this->l('List of manufacturers:'); $this->addRowAction('view'); $this->addRowAction('edit'); $this->addRowAction('delete'); @@ -113,7 +112,7 @@ class AdminManufacturersControllerCore extends AdminController { - $this->toolbar_title = $this->l('Manufacturers addresses:'); + $this->toolbar_title = $this->l('Addresses'); // reset actions and query vars $this->actions = array(); unset($this->fieldsDisplay, $this->_select, $this->_join, $this->_group, $this->_filterHaving, $this->_filter); diff --git a/controllers/admin/AdminSearchController.php b/controllers/admin/AdminSearchController.php index 73a08de21..a89711572 100644 --- a/controllers/admin/AdminSearchController.php +++ b/controllers/admin/AdminSearchController.php @@ -201,6 +201,7 @@ class AdminSearchControllerCore extends AdminController protected function initProductList() { + $this->show_toolbar = false; $this->fieldsDisplay['products'] = (array( 'id_product' => array('title' => $this->l('ID')), 'manufacturer_name' => array('title' => $this->l('Manufacturer'), 'align' => 'center'), @@ -245,6 +246,7 @@ class AdminSearchControllerCore extends AdminController $this->initProductList(); $helper->identifier = 'id_product'; $helper->actions = array('edit', 'view'); + $helper->show_toolbar = false; if ($this->_list['products']) $view = $helper->generateList($this->_list['products'], $this->fieldsDisplay['products']); $this->context->smarty->assign('products', $view);