From dee423c49443ee8ee8ef3e99ef870160a0076ff0 Mon Sep 17 00:00:00 2001 From: mMarinetti Date: Mon, 31 Oct 2011 16:35:45 +0000 Subject: [PATCH] // added title for helperlist, admincontroller factorisation of helper list usage --- classes/AdminController.php | 31 +++++++++++++++++++++++++++---- classes/HelperList.php | 4 ++++ 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/classes/AdminController.php b/classes/AdminController.php index 5229966cb..ddd70b4ee 100644 --- a/classes/AdminController.php +++ b/classes/AdminController.php @@ -76,6 +76,12 @@ class AdminControllerCore extends Controller /** @var array Errors displayed after post processing */ public $_errors = array(); + /** @var define if the header of the list contains filter and sorting links or not */ + protected $list_simple_header; + + /** @var define if the header of the list contains filter and sorting links or not */ + protected $list_title; + /** @var array list to be generated */ protected $fieldsDisplay; @@ -947,11 +953,15 @@ class AdminControllerCore extends Controller { if (Tab::checkTabRights($tab['id_tab']) === true) { - $img_exists_cache = Tools::file_exists_cache(_PS_ADMIN_DIR_.'/themes/'.$this->context->employee->bo_theme.'/img/t/'.$tab['class_name'].'.gif'); - $img = ($img_exists_cache ? 'themes/'.Context::getContext()->employee->bo_theme.'/img/' : _PS_IMG_).'t/'.$tab['class_name'].'.gif'; + $img_exists_cache = Tools::file_exists_cache(_PS_ADMIN_DIR_.'/themes/'.$this->context->employee->bo_theme.'/img/t/'.$tab['class_name'].'.png'); + $img = ($img_exists_cache ? 'themes/'.Context::getContext()->employee->bo_theme.'/img/' : _PS_IMG_).'t/'.$tab['class_name'].'.png'; if (trim($tab['module']) != '') - $img = _MODULE_DIR_.$tab['module'].'/'.$tab['class_name'].'.gif'; + $img = _MODULE_DIR_.$tab['module'].'/'.$tab['class_name'].'.png'; + + // retrocompatibility + if(!file_exists($img)) + $img = str_replace('png', 'gif', $img); // tab[class_name] does not contains the "Controller" suffix $tabs[$index]['current'] = ($tab['class_name'].'Controller' == get_class($this)) || (Tab::getCurrentParentId() == $tab['id_tab']); @@ -1151,7 +1161,21 @@ class AdminControllerCore extends Controller $this->actions[] = $action; } + $this->setHelperListDisplay($helper); + return $helper->generateList($this->_list, $this->fieldsDisplay); + } + + /** + * this function set various display option for helper list + * + * @param Helper $helper + * @return void + */ + public function setHelperListDisplay(Helper $helper) + { $helper->actions = $this->actions; + $helper->simple_header = $this->list_simple_header; + $helper->title = $this->list_title; $helper->toolbar_btn = $this->toolbar_btn; $helper->bulk_actions = $this->bulk_actions; $helper->currentIndex = self::$currentIndex; @@ -1173,7 +1197,6 @@ class AdminControllerCore extends Controller // For each action, try to add the corresponding skip elements list $helper->list_skip_actions = $this->list_skip_actions; - return $helper->generateList($this->_list, $this->fieldsDisplay); } /** diff --git a/classes/HelperList.php b/classes/HelperList.php index 5b3fa847e..714547ef3 100644 --- a/classes/HelperList.php +++ b/classes/HelperList.php @@ -99,6 +99,9 @@ class HelperListCore extends Helper 'id_carrier' => 'id_carrier' ); + /** @var if not null, a title will be added on that list */ + public $title = null; + /** @var boolean ask for simple header : no filters, no paginations and no sorting */ public $simple_header = false; @@ -513,6 +516,7 @@ class HelperListCore extends Helper 'action' => $action, 'page' => $page, 'simple_header' => $this->simple_header, + 'title' => $this->title, 'total_pages' => $total_pages, 'selected_pagination' => $selected_pagination, 'pagination' => $this->_pagination,