// Fix #PSTEST-231 - AdminSearch

This commit is contained in:
tDidierjean
2012-01-02 14:17:30 +00:00
parent a259d4bf94
commit 051e24afe1
3 changed files with 44 additions and 29 deletions
+2 -2
View File
@@ -162,9 +162,9 @@ function getPath($urlBase, $id_category, $path = '', $highlight = '', $categoryT
$nCategories = (int)sizeof($categories); $nCategories = (int)sizeof($categories);
foreach ($categories AS $category) foreach ($categories AS $category)
{ {
$edit = '<a href="'.$urlBase.'&id_category='.(int)$category['id_category'].'&'.(($category['id_category'] == 1 || $home) ? 'viewcategory' : 'addcategory').'&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)$context->employee->id).'" title="'.($category['id_category'] == 1 ? 'Home' : 'Modify').'"><img src="../img/admin/'.(($category['id_category'] == 1 || $home) ? 'home' : 'edit').'.gif" alt="" /></a> '; $edit = '<a href="'.$urlBase.'&id_category='.(int)$category['id_category'].'&'.(($category['id_category'] == 1 || $home) ? 'viewcategory' : 'updatecategory').'&token='.Tools::getAdminToken('AdminCategories'.(int)(Tab::getIdFromClassName('AdminCategories')).(int)$context->employee->id).'" title="'.($category['id_category'] == 1 ? 'Home' : 'Modify').'"><img src="../img/admin/'.(($category['id_category'] == 1 || $home) ? 'home' : 'edit').'.gif" alt="" /></a> ';
$fullPath .= $edit. $fullPath .= $edit.
($n < $nCategories ? '<a href="'.$urlBase.'&id_category='.(int)$category['id_category'].'&viewcategory&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)$context->employee->id).'" title="'.htmlentities($category['name'], ENT_NOQUOTES, 'UTF-8').'">' : ''). ($n < $nCategories ? '<a href="'.$urlBase.'&id_category='.(int)$category['id_category'].'&viewcategory&token='.Tools::getAdminToken('AdminCategories'.(int)(Tab::getIdFromClassName('AdminCategories')).(int)$context->employee->id).'" title="'.htmlentities($category['name'], ENT_NOQUOTES, 'UTF-8').'">' : '').
(!empty($highlight) ? str_ireplace($highlight, '<span class="highlight">'.htmlentities($highlight, ENT_NOQUOTES, 'UTF-8').'</span>', $category['name']) : $category['name']). (!empty($highlight) ? str_ireplace($highlight, '<span class="highlight">'.htmlentities($highlight, ENT_NOQUOTES, 'UTF-8').'</span>', $category['name']) : $category['name']).
($n < $nCategories ? '</a>' : ''). ($n < $nCategories ? '</a>' : '').
(($n++ != $nCategories OR !empty($path)) ? ' > ' : ''); (($n++ != $nCategories OR !empty($path)) ? ' > ' : '');
+6 -3
View File
@@ -288,13 +288,16 @@ class LinkCore
} }
/** /**
* use controller name to create link with correct token * Use controller name to create a link
* *
* @param string $controller * @param string $controller
* @param boolean $with_token include or not the token in the url
* @return controller url
*/ */
public function getAdminLink($controller) public function getAdminLink($controller, $with_token = true)
{ {
return Dispatcher::getInstance()->createUrl($controller, array('token' => Tools::getAdminTokenLite($controller)), false); $params = $with_token ? array('token' => Tools::getAdminTokenLite($controller)) : array();
return Dispatcher::getInstance()->createUrl($controller, $params, false);
} }
/** /**
+36 -24
View File
@@ -49,7 +49,7 @@ class AdminSearchControllerCore extends AdminController
/* Handle product ID */ /* Handle product ID */
if ($searchType == 1 AND (int)$this->query AND Validate::isUnsignedInt((int)$this->query)) if ($searchType == 1 AND (int)$this->query AND Validate::isUnsignedInt((int)$this->query))
if ($product = new Product((int)$this->query) AND Validate::isLoadedObject($product)) if ($product = new Product((int)$this->query) AND Validate::isLoadedObject($product))
Tools::redirectAdmin('index.php?tab=AdminCatalog&id_product='.(int)($product->id).'&addproduct'.'&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)$this->context->employee->id)); Tools::redirectAdmin('index.php?tab=AdminProducts&id_product='.(int)($product->id).'&addproduct'.'&token='.Tools::getAdminTokenLite('AdminProducts'));
/* Normal catalog search */ /* Normal catalog search */
$this->searchCatalog(); $this->searchCatalog();
@@ -190,15 +190,15 @@ class AdminSearchControllerCore extends AdminController
$genders[$gender->id] = $gender->name; $genders[$gender->id] = $gender->name;
} }
$this->fieldsDisplay['customers'] = (array( $this->fieldsDisplay['customers'] = (array(
'id_customer' => array('title' => $this->l('ID'), 'align' => 'center'), 'id_customer' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
'id_gender' => array('title' => $this->l('Gender'), 'align' => 'center', 'icon' => $genders_icon, 'list' => $genders), 'id_gender' => array('title' => $this->l('Gender'), 'align' => 'center', 'icon' => $genders_icon, 'list' => $genders, 'width' => 25),
'firstname' => array('title' => $this->l('Name'), 'align' => 'center'), 'firstname' => array('title' => $this->l('First Name'), 'align' => 'left', 'width' => 150),
'lastname' => array('title' => $this->l('Name'), 'align' => 'center'), 'lastname' => array('title' => $this->l('Name'), 'align' => 'left', 'width' => 'auto'),
'email' => array('title' => $this->l('E-mail address'), 'align' => 'center'), 'email' => array('title' => $this->l('E-mail address'), 'align' => 'left', 'width' => 250),
'birthday' => array('title' => $this->l('Birth date'), 'align' => 'center', 'type' => 'date'), 'birthday' => array('title' => $this->l('Birth date'), 'align' => 'center', 'type' => 'date', 'width' => 75),
'date_add' => array('title' => $this->l('Register date'), 'align' => 'center', 'type' => 'date'), 'date_add' => array('title' => $this->l('Register date'), 'align' => 'center', 'type' => 'date', 'width' => 75),
'orders' => array('title' => $this->l('Orders'), 'align' => 'center'), 'orders' => array('title' => $this->l('Orders'), 'align' => 'center', 'width' => 50),
'active' => array('title' => $this->l('Enabled'),'align' => 'center','active' => 'status','type' => 'bool'), 'active' => array('title' => $this->l('Enabled'),'align' => 'center','active' => 'status','type' => 'bool', 'width' => 25),
)); ));
} }
@@ -206,13 +206,13 @@ class AdminSearchControllerCore extends AdminController
{ {
$this->show_toolbar = false; $this->show_toolbar = false;
$this->fieldsDisplay['products'] = (array( $this->fieldsDisplay['products'] = (array(
'id_product' => array('title' => $this->l('ID')), 'id_product' => array('title' => $this->l('ID'), 'width' => 25),
'manufacturer_name' => array('title' => $this->l('Manufacturer'), 'align' => 'center'), 'manufacturer_name' => array('title' => $this->l('Manufacturer'), 'align' => 'center', 'width' => 200),
'reference' => array('title' => $this->l('Reference'), 'align' => 'center'), 'reference' => array('title' => $this->l('Reference'), 'align' => 'center', 'width' => 150),
'name' => array('title' => $this->l('Name')), 'name' => array('title' => $this->l('Name'), 'width' => 'auto'),
'price_tax_excl' => array('title' => $this->l('Price tax excl'), 'align' => 'right', 'type' => 'price'), 'price_tax_excl' => array('title' => $this->l('Price tax excl'), 'align' => 'right', 'type' => 'price', 'width' => 60),
'price_tax_incl' => array('title' => $this->l('Price tax incl'), 'align' => 'right', 'type' => 'price'), 'price_tax_incl' => array('title' => $this->l('Price tax incl'), 'align' => 'right', 'type' => 'price', 'width' => 60),
'status' => array('title' => $this->l('Status'), 'align' => 'center'), 'status' => array('title' => $this->l('Status'), 'align' => 'center', 'width' => 25),
)); ));
} }
@@ -241,27 +241,30 @@ class AdminSearchControllerCore extends AdminController
return parent::renderView(); return parent::renderView();
else else
{ {
$helper = new HelperList();
$helper->currentIndex = self::$currentIndex;
$helper->token = $this->token;
$helper->shopLinkType = '';
$helper->simple_header = true;
if (isset($this->_list['features'])) if (isset($this->_list['features']))
$this->tpl_view_vars['features'] = $this->_list['features']; $this->tpl_view_vars['features'] = $this->_list['features'];
if (isset($this->_list['categories'])) if (isset($this->_list['categories']))
{ {
$categories = array(); $categories = array();
foreach($this->_list['categories'] as $category) foreach($this->_list['categories'] as $category)
$categories[] = getPath(self::$currentIndex.'?tab=AdminCatalog', (int)$category['id_category']); $categories[] = getPath($this->context->link->getAdminLink('AdminCategories', false), $category['id_category']);
$this->tpl_view_vars['categories'] = $categories; $this->tpl_view_vars['categories'] = $categories;
} }
if (isset($this->_list['products'])) if (isset($this->_list['products']))
{ {
$view = ''; $view = '';
$this->initProductList(); $this->initProductList();
$helper = new HelperList();
$helper->shopLinkType = '';
$helper->simple_header = true;
$helper->identifier = 'id_product'; $helper->identifier = 'id_product';
$helper->actions = array('edit', 'view'); $helper->actions = array('edit');
$helper->show_toolbar = false; $helper->show_toolbar = false;
$helper->table = 'product';
$helper->currentIndex = $this->context->link->getAdminLink('AdminProducts', false);
$helper->token = Tools::getAdminTokenLite('AdminProducts');
if ($this->_list['products']) if ($this->_list['products'])
$view = $helper->generateList($this->_list['products'], $this->fieldsDisplay['products']); $view = $helper->generateList($this->_list['products'], $this->fieldsDisplay['products']);
@@ -271,8 +274,17 @@ class AdminSearchControllerCore extends AdminController
{ {
$view = ''; $view = '';
$this->initCustomerList(); $this->initCustomerList();
$helper = new HelperList();
$helper->shopLinkType = '';
$helper->simple_header = true;
$helper->identifier = 'id_customer'; $helper->identifier = 'id_customer';
$helper->actions = array('edit', 'view'); $helper->actions = array('edit', 'view');
$helper->show_toolbar = false;
$helper->table = 'customer';
$helper->currentIndex = $this->context->link->getAdminLink('AdminCustomers', false);
$helper->token = Tools::getAdminTokenLite('AdminCustomers');
if ($this->_list['customers']) if ($this->_list['customers'])
{ {
foreach($this->_list['customers'] as $key => $val) foreach($this->_list['customers'] as $key => $val)