// Fix #PSCFV-4512

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@17751 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
rGaillard
2012-10-04 13:05:43 +00:00
parent f90f8011b8
commit 55a1ad4b5e
3 changed files with 120 additions and 56 deletions
+28 -28
View File
@@ -417,6 +417,33 @@ class AdminControllerCore extends Controller
*/
public function processFilter()
{
// Filter memorization
if (isset($_POST) && !empty($_POST) && isset($this->table))
foreach ($_POST as $key => $value)
{
if (is_array($this->table))
{
foreach ($this->table as $table)
if (stripos($key, $table.'Filter_') === 0 || stripos($key, 'submitFilter') === 0)
$this->context->cookie->$key = !is_array($value) ? $value : serialize($value);
}
elseif (stripos($key, $this->table.'Filter_') === 0 || stripos($key, 'submitFilter') === 0)
$this->context->cookie->$key = !is_array($value) ? $value : serialize($value);
}
if (isset($_GET) && !empty($_GET) && isset($this->table))
foreach ($_GET as $key => $value)
{
if (is_array($this->table))
{
foreach ($this->table as $table)
if (stripos($key, $table.'OrderBy') === 0 || stripos($key, $table.'Orderway') === 0)
$this->context->cookie->$key = $value;
}
elseif (stripos($key, $this->table.'OrderBy') === 0 || stripos($key, $this->table.'Orderway') === 0)
$this->context->cookie->$key = $value;
}
$filters = $this->context->cookie->getFamily($this->table.'Filter_');
foreach ($filters as $key => $value)
@@ -808,7 +835,6 @@ class AdminControllerCore extends Controller
public function processResetFilters()
{
$filters = $this->context->cookie->getFamily($this->table.'Filter_');
foreach ($filters as $cookie_key => $filter)
if (strncmp($cookie_key, $this->table.'Filter_', 7 + Tools::strlen($this->table)) == 0)
{
@@ -817,7 +843,7 @@ class AdminControllerCore extends Controller
$tmp_tab = explode('!', $key);
$key = (count($tmp_tab) > 1 ? $tmp_tab[1] : $tmp_tab[0]);
if (array_key_exists($key, $this->fields_list))
if (is_array($this->fields_list) && array_key_exists($key, $this->fields_list))
unset($this->context->cookie->$cookie_key);
}
@@ -1763,32 +1789,6 @@ class AdminControllerCore extends Controller
*/
public function initProcess()
{
// Filter memorization
if (isset($_POST) && !empty($_POST) && isset($this->table))
foreach ($_POST as $key => $value)
{
if (is_array($this->table))
{
foreach ($this->table as $table)
if (stripos($key, $table.'Filter_') === 0 || stripos($key, 'submitFilter') === 0)
$this->context->cookie->$key = !is_array($value) ? $value : serialize($value);
}
elseif (stripos($key, $this->table.'Filter_') === 0 || stripos($key, 'submitFilter') === 0)
$this->context->cookie->$key = !is_array($value) ? $value : serialize($value);
}
if (isset($_GET) && !empty($_GET) && isset($this->table))
foreach ($_GET as $key => $value)
{
if (is_array($this->table))
{
foreach ($this->table as $table)
if (stripos($key, $table.'OrderBy') === 0 || stripos($key, $table.'Orderway') === 0)
$this->context->cookie->$key = $value;
}
elseif (stripos($key, $this->table.'OrderBy') === 0 || stripos($key, $this->table.'Orderway') === 0)
$this->context->cookie->$key = $value;
}
// Manage list filtering
if (Tools::isSubmit('submitFilter'.$this->table) || $this->context->cookie->{'submitFilter'.$this->table} !== false)
$this->filter = true;
+7 -7
View File
@@ -161,7 +161,7 @@ class HelperListCore extends Helper
* @param int $id_product
* @return string
*/
protected function displayEnableLink($token, $id, $value, $active, $id_category = null, $id_product = null)
public function displayEnableLink($token, $id, $value, $active, $id_category = null, $id_product = null)
{
$tpl_enable = $this->createTemplate('list_action_enable.tpl');
$tpl_enable->assign(array(
@@ -332,7 +332,7 @@ class HelperListCore extends Helper
/**
* Display duplicate action link
*/
protected function displayDuplicateLink($token = null, $id, $name = null)
public function displayDuplicateLink($token = null, $id, $name = null)
{
$tpl = $this->createTemplate('list_action_duplicate.tpl');
if (!array_key_exists('Bad SQL query', self::$cache_lang))
@@ -374,7 +374,7 @@ class HelperListCore extends Helper
* fields_display: // attribute $fields_list of the admin controller
* }
*/
protected function displayDetailsLink($token = null, $id, $name = null)
public function displayDetailsLink($token = null, $id, $name = null)
{
$tpl = $this->createTemplate('list_action_details.tpl');
if (!array_key_exists('Details', self::$cache_lang))
@@ -398,7 +398,7 @@ class HelperListCore extends Helper
/**
* Display view action link
*/
protected function displayViewLink($token = null, $id, $name = null)
public function displayViewLink($token = null, $id, $name = null)
{
$tpl = $this->createTemplate('list_action_view.tpl');
if (!array_key_exists('View', self::$cache_lang))
@@ -416,7 +416,7 @@ class HelperListCore extends Helper
/**
* Display edit action link
*/
protected function displayEditLink($token = null, $id, $name = null)
public function displayEditLink($token = null, $id, $name = null)
{
$tpl = $this->createTemplate('list_action_edit.tpl');
if (!array_key_exists('Edit', self::$cache_lang))
@@ -434,7 +434,7 @@ class HelperListCore extends Helper
/**
* Display delete action link
*/
protected function displayDeleteLink($token = null, $id, $name = null)
public function displayDeleteLink($token = null, $id, $name = null)
{
$tpl = $this->createTemplate('list_action_delete.tpl');
@@ -467,7 +467,7 @@ class HelperListCore extends Helper
/**
* Display delete action link
*/
protected function displayDefaultLink($token = null, $id, $name = null)
public function displayDefaultLink($token = null, $id, $name = null)
{
$tpl = $this->createTemplate('list_action_default.tpl');
if (!array_key_exists('Default', self::$cache_lang))
+85 -21
View File
@@ -27,6 +27,8 @@
class AdminTrackingControllerCore extends AdminController
{
protected $_helper_list;
public function postprocess()
{
if (Tools::getValue('id_product') && Tools::isSubmit('statusproduct'))
@@ -51,6 +53,8 @@ class AdminTrackingControllerCore extends AdminController
public function initContent()
{
$this->_helper_list = new HelperList();
if (!Configuration::get('PS_STOCK_MANAGEMENT'))
$this->warnings[] = $this->l('List of products without available quantities for sale are not displayed because stock management is disabled.');
@@ -58,7 +62,12 @@ class AdminTrackingControllerCore extends AdminController
$tpl_vars['arrayList'] = array();
foreach ($methods as $method_name)
if (preg_match('#getCustomList(.+)#', $method_name, $matches))
{
$this->clearListOptions();
$this->content .= call_user_func(array($this,$matches[0]));
}
$this->content .= $this->getCustomListProductsDisabled();
$this->context->smarty->assign(array(
'content' => $this->content,
@@ -68,14 +77,14 @@ class AdminTrackingControllerCore extends AdminController
public function getCustomListCategoriesEmpty()
{
$this->clearListOptions();
$this->table = 'category';
$this->lang = true;
$this->className = 'Category';
$this->identifier = 'id_category';
$this->_orderBy = 'id_category';
$this->_orderWay = 'DESC';
self::$currentIndex = 'index.php?controller=AdminCategories';
$this->token = Tools::getAdminTokenLite('AdminCategories');
$this->_list_index = 'index.php?controller=AdminCategories';
$this->_list_token = Tools::getAdminTokenLite('AdminCategories');
$this->addRowAction('edit');
$this->addRowAction('delete');
@@ -85,7 +94,7 @@ class AdminTrackingControllerCore extends AdminController
$this->fields_list = (array(
'id_category' => array('title' => $this->l('ID'), 'width' => 50),
'name' => array('title' => $this->l('Name')),
'name' => array('title' => $this->l('Name'), 'filter_key' => 'b!name'),
'description' => array('title' => $this->l('Description')),
'active' => array('title' => $this->l('Status'), 'type' => 'bool', 'active' => 'status', 'width' => 50)
));
@@ -99,7 +108,9 @@ class AdminTrackingControllerCore extends AdminController
$this->tpl_list_vars = array('sub_title' => $this->l('List of empty categories:'));
return parent::renderList();
$this->clearFilters();
return $this->renderList();
}
public function getCustomListProductsAttributesNoStock()
@@ -107,14 +118,14 @@ class AdminTrackingControllerCore extends AdminController
if (!Configuration::get('PS_STOCK_MANAGEMENT'))
return;
$this->clearListOptions();
$this->table = 'product';
$this->lang = true;
$this->identifier = 'id_product';
$this->_orderBy = 'id_product';
$this->_orderWay = 'DESC';
self::$currentIndex = 'index.php?controller=AdminProducts';
$this->token = Tools::getAdminTokenLite('AdminProducts');
$this->className = 'Product';
$this->_list_index = 'index.php?controller=AdminProducts';
$this->_list_token = Tools::getAdminTokenLite('AdminProducts');
$this->show_toolbar = false;
$this->addRowAction('edit');
@@ -123,7 +134,7 @@ class AdminTrackingControllerCore extends AdminController
$this->fields_list = array(
'id_product' => array('title' => $this->l('ID'), 'width' => 50),
'reference' => array('title' => $this->l('Reference'), 'width' => 150),
'name' => array('title' => $this->l('Name')),
'name' => array('title' => $this->l('Name'), 'filter_key' => 'b!name'),
'active' => array('title' => $this->l('Status'), 'type' => 'bool', 'active' => 'status', 'width' => 50)
);
$this->_join = Shop::addSqlAssociation('product', 'a');
@@ -140,23 +151,25 @@ class AdminTrackingControllerCore extends AdminController
$this->tpl_list_vars = array('sub_title' => $this->l('List of products with attributes and without available quantities for sale:'));
return parent::renderList();
$this->clearFilters();
return $this->renderList();
}
public function getCustomListProductsNoStock()
{
{
if (!Configuration::get('PS_STOCK_MANAGEMENT'))
return;
$this->clearListOptions();
$this->table = 'product';
$this->className = 'Product';
$this->lang = true;
$this->identifier = 'id_product';
$this->_orderBy = 'id_product';
$this->_orderWay = 'DESC';
$this->show_toolbar = false;
self::$currentIndex = 'index.php?controller=AdminProducts';
$this->token = Tools::getAdminTokenLite('AdminProducts');
$this->_list_index = 'index.php?controller=AdminProducts';
$this->_list_token = Tools::getAdminTokenLite('AdminProducts');
$this->addRowAction('edit');
$this->addRowAction('delete');
@@ -180,24 +193,26 @@ class AdminTrackingControllerCore extends AdminController
)';
$this->tpl_list_vars = array('sub_title' => $this->l('List of products without attributes and without available quantities for sale:'));
return parent::renderList();
$this->clearFilters();
return $this->renderList();
}
public function getCustomListProductsDisabled()
{
$this->clearListOptions();
$this->table = 'product';
$this->className = 'Product';
$this->lang = true;
$this->identifier = 'id_product';
$this->_orderBy = 'id_product';
$this->_orderWay = 'DESC';
$this->_filter = 'AND a.`active` = 0';
$this->_filter = 'AND product_shop.`active` = 0';
$this->list_no_filter = true;
$this->tpl_list_vars = array('sub_title' => $this->l('List of disabled products:'));
$this->show_toolbar = false;
self::$currentIndex = 'index.php?controller=AdminProducts';
$this->token = Tools::getAdminTokenLite('AdminProducts');
$this->_list_index = 'index.php?controller=AdminProducts';
$this->_list_token = Tools::getAdminTokenLite('AdminProducts');
$this->addRowAction('edit');
$this->addRowAction('delete');
@@ -205,11 +220,54 @@ class AdminTrackingControllerCore extends AdminController
$this->fields_list = array(
'id_product' => array('title' => $this->l('ID'), 'width' => 50),
'reference' => array('title' => $this->l('Reference'), 'width' => 150),
'name' => array('title' => $this->l('Name'))
'name' => array('title' => $this->l('Name'), 'filter_key' => 'b!name')
);
$this->clearFilters();
$this->_join = Shop::addSqlAssociation('product', 'a');
return $this->renderList();
}
public function renderList()
{
$this->processFilter();
return parent::renderList();
}
public function displayEnableLink($token, $id, $value, $active, $id_category = null, $id_product = null)
{
$this->_helper_list->currentIndex = $this->_list_index;
$this->_helper_list->identifier = $this->identifier;
$this->_helper_list->table = $this->table;
return $this->_helper_list->displayEnableLink($this->_list_token, $id, $value, $active, $id_category, $id_product);
}
public function displayDeleteLink($token = null, $id, $name = null)
{
$this->_helper_list->currentIndex = $this->_list_index;
$this->_helper_list->identifier = $this->identifier;
$this->_helper_list->table = $this->table;
return $this->_helper_list->displayDeleteLink($this->_list_token, $id, $name);
}
public function displayEditLink($token = null, $id, $name = null)
{
$this->_helper_list->currentIndex = $this->_list_index;
$this->_helper_list->identifier = $this->identifier;
$this->_helper_list->table = $this->table;
return $this->_helper_list->displayEditLink($this->_list_token, $id, $name);
}
protected function clearFilters()
{
if ((Tools::isSubmit('submitResetcategory') && $this->table == 'category' ) || (Tools::isSubmit('submitResetproduct') && $this->table == 'product' ))
$this->processResetFilters();
}
public function clearListOptions()
{
@@ -221,8 +279,14 @@ class AdminTrackingControllerCore extends AdminController
$this->_orderWay = '';
$this->_filter = '';
$this->_group = '';
$this->_where = '';
$this->list_no_filter = true;
$this->list_title = $this->l('Product disabled');
}
public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false)
{
parent::getList($id_lang, $order_by, $order_way, $start, $limit, Context::getContext()->shop->id);
}
}