@@ -44,15 +44,14 @@
{foreach $fields_display AS $key => $params}
{block name="open_td"}
- |
{else}
>
diff --git a/classes/controller/AdminController.php b/classes/controller/AdminController.php
index 0dc46d22e..460e6f750 100644
--- a/classes/controller/AdminController.php
+++ b/classes/controller/AdminController.php
@@ -202,15 +202,8 @@ class AdminControllerCore extends Controller
protected $is_cms = false;
- protected $is_dnd_identifier = false;
-
- protected $identifiersDnd = array(
- 'id_product' => 'id_product',
- 'id_category' => 'id_category_to_move',
- 'id_cms_category' => 'id_cms_category_to_move',
- 'id_cms' => 'id_cms',
- 'id_attribute' => 'id_attribute'
- );
+ /** @var string identifier to use for changing positions in lists (can be omitted if positions cannot be changed) */
+ protected $position_identifier;
/** @var boolean Table records are not deleted but marked as deleted if set to true */
protected $deleted = false;
@@ -1542,6 +1535,7 @@ class AdminControllerCore extends Controller
$helper->allow_employee_form_lang = $this->allow_employee_form_lang;
$helper->multiple_fieldsets = $this->multiple_fieldsets;
$helper->row_hover = $this->row_hover;
+ $helper->position_identifier = $this->position_identifier;
// For each action, try to add the corresponding skip elements list
$helper->list_skip_actions = $this->list_skip_actions;
diff --git a/classes/helper/HelperList.php b/classes/helper/HelperList.php
index 1b1bc40f3..ced2129a2 100644
--- a/classes/helper/HelperList.php
+++ b/classes/helper/HelperList.php
@@ -66,7 +66,7 @@ class HelperListCore extends Helper
protected $is_cms = false;
- protected $is_dnd_identifier = false;
+ public $position_identifier;
/**
* @var string Customize list display
@@ -100,18 +100,6 @@ class HelperListCore extends Helper
/** @var bool If true, activates color on hover */
public $row_hover = true;
- protected $identifiersDnd = array(
- 'id_product' => 'id_product',
- 'id_category' => 'id_category_to_move',
- 'id_cms_category' => 'id_cms_category_to_move',
- 'id_cms' => 'id_cms',
- 'id_attribute' => 'id_attribute',
- 'id_attribute_group' => 'id_attribute_group',
- 'id_carrier' => 'id_carrier',
- 'id_tab' => 'id_tab',
- 'id_feature' => 'id_feature'
- );
-
/** @var if not null, a title will be added on that list */
public $title = null;
@@ -137,9 +125,6 @@ class HelperListCore extends Helper
*/
public function generateList($list, $fields_display)
{
- /*if ($this->edit && (!isset($this->noAdd) || !$this->noAdd))
- $this->displayAddButton();*/
-
// Append when we get a syntax error in SQL query
if ($list === false)
{
@@ -192,10 +177,10 @@ class HelperListCore extends Helper
public function displayListContent()
{
- if ($this->is_dnd_identifier)
+ if ($this->position_identifier)
$id_category = (int)Tools::getValue('id_'.($this->is_cms ? 'cms_' : '').'category', '1');
else
- $id_category = Category::getRootCategory();
+ $id_category = Category::getRootCategory()->id;
if (isset($this->fieldsDisplay['position']))
{
@@ -258,10 +243,10 @@ class HelperListCore extends Helper
$this->_list[$index][$key] = array(
'position' => $tr[$key],
'position_url_down' => $this->currentIndex.
- '&'.$key_to_get.'='.(int)$id_category.'&'.$this->identifiersDnd[$this->identifier].'='.$id.
+ '&'.$key_to_get.'='.(int)$id_category.'&'.$this->position_identifier.'='.$id.
'&way=1&position='.((int)$tr['position'] + 1).'&token='.$this->token,
'position_url_up' => $this->currentIndex.
- '&'.$key_to_get.'='.(int)$id_category.'&'.$this->identifiersDnd[$this->identifier].'='.$id.
+ '&'.$key_to_get.'='.(int)$id_category.'&'.$this->position_identifier.'='.$id.
'&way=0&position='.((int)$tr['position'] - 1).'&token='.$this->token
);
}
@@ -321,7 +306,7 @@ class HelperListCore extends Helper
$this->content_tpl->assign(array_merge($this->tpl_vars, array(
'shop_link_type' => $this->shopLinkType,
'name' => isset($name) ? $name : null,
- 'is_dnd_identifier' => $this->is_dnd_identifier,
+ 'position_identifier' => $this->position_identifier,
'identifier' => $this->identifier,
'table' => $this->table,
'token' => $this->token,
@@ -539,16 +524,14 @@ class HelperListCore extends Helper
isset($this->context->cookie->{$this->table.'_pagination'}) ? $this->context->cookie->{$this->table.'_pagination'} : null
);
- $this->is_dnd_identifier = array_key_exists($this->identifier, $this->identifiersDnd);
-
// Cleaning links
if (Tools::getValue($this->table.'Orderby') && Tools::getValue($this->table.'Orderway'))
$this->currentIndex = preg_replace('/&'.$this->table.'Orderby=([a-z _]*)&'.$this->table.'Orderway=([a-z]*)/i', '', $this->currentIndex);
- if (array_key_exists($this->identifier, $this->identifiersDnd) && (int)Tools::getValue($this->identifiersDnd[$this->identifier], 1))
+ if ($this->position_identifier && (int)Tools::getValue($this->position_identifier, 1))
$table_id = substr($this->identifier, 3, strlen($this->identifier));
- if (array_key_exists($this->identifier, $this->identifiersDnd) && ($this->orderBy == 'position' && $this->orderWay != 'DESC'))
+ if ($this->position_identifier && ($this->orderBy == 'position' && $this->orderWay != 'DESC'))
$table_dnd = true;
foreach ($this->fieldsDisplay as $key => $params)
@@ -610,7 +593,7 @@ class HelperListCore extends Helper
'selected_pagination' => $selected_pagination,
'pagination' => $this->_pagination,
'list_total' => $this->listTotal,
- 'is_order_position' => array_key_exists($this->identifier, $this->identifiersDnd) && $this->orderBy == 'position',
+ 'is_order_position' => $this->position_identifier && $this->orderBy == 'position',
'order_way' => $this->orderWay,
'order_by' => $this->orderBy,
'token' => $this->token,
diff --git a/controllers/admin/AdminAttributesGroupsController.php b/controllers/admin/AdminAttributesGroupsController.php
index 82e0d3dc4..f2dc0d4e7 100644
--- a/controllers/admin/AdminAttributesGroupsController.php
+++ b/controllers/admin/AdminAttributesGroupsController.php
@@ -28,6 +28,7 @@
class AdminAttributesGroupsControllerCore extends AdminController
{
protected $id_attribute;
+ protected $position_identifier = 'id_attribute_group';
public function __construct()
{
@@ -157,6 +158,7 @@ class AdminAttributesGroupsControllerCore extends AdminController
$helper->simple_header = true;
$helper->show_toolbar = false;
$helper->bulk_actions = $this->bulk_actions;
+ $helper->position_identifier = 'id_attribute';
$content = $helper->generateList($this->_list, $this->fieldsDisplay);
die (Tools::jsonEncode(array('use_parent_structure' => false, 'data' => $content)));
diff --git a/controllers/admin/AdminCarriersController.php b/controllers/admin/AdminCarriersController.php
index f9f45c3c1..caaefe1c1 100644
--- a/controllers/admin/AdminCarriersController.php
+++ b/controllers/admin/AdminCarriersController.php
@@ -27,6 +27,8 @@
class AdminCarriersControllerCore extends AdminController
{
+ protected $position_identifier = 'id_carrier';
+
public function __construct()
{
$this->table = 'carrier';
diff --git a/controllers/admin/AdminCategoriesController.php b/controllers/admin/AdminCategoriesController.php
index 0e980d6bc..b42f7ffb6 100644
--- a/controllers/admin/AdminCategoriesController.php
+++ b/controllers/admin/AdminCategoriesController.php
@@ -31,6 +31,7 @@ class AdminCategoriesControllerCore extends AdminController
* @var object Category() instance for navigation
*/
private $_category = null;
+ protected $position_identifier = 'id_category_to_move';
public function __construct()
{
diff --git a/controllers/admin/AdminCmsCategoriesController.php b/controllers/admin/AdminCmsCategoriesController.php
index 7dcc35a5e..de82e966e 100644
--- a/controllers/admin/AdminCmsCategoriesController.php
+++ b/controllers/admin/AdminCmsCategoriesController.php
@@ -28,7 +28,9 @@
class AdminCmsCategoriesControllerCore extends AdminController
{
/** @var object CMSCategory() instance for navigation*/
- private $_CMSCategory;
+ protected $_CMSCategory;
+
+ protected $position_identifier = 'id_cms_category_to_move';
public function __construct()
{
diff --git a/controllers/admin/AdminCmsController.php b/controllers/admin/AdminCmsController.php
index 9a8bdff30..e748d5407 100644
--- a/controllers/admin/AdminCmsController.php
+++ b/controllers/admin/AdminCmsController.php
@@ -31,6 +31,8 @@ class AdminCmsControllerCore extends AdminController
public $id_cms_category;
+ protected $position_identifier = 'id_cms';
+
public function __construct()
{
$this->table = 'cms';
diff --git a/controllers/admin/AdminFeaturesController.php b/controllers/admin/AdminFeaturesController.php
index 2c871a772..188f655e3 100644
--- a/controllers/admin/AdminFeaturesController.php
+++ b/controllers/admin/AdminFeaturesController.php
@@ -26,6 +26,8 @@
*/
class AdminFeaturesControllerCore extends AdminController
{
+ protected $position_identifier = 'id_feature';
+
public function __construct()
{
$this->table = 'feature';
diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php
index d6223a760..4e5aaf0e3 100644
--- a/controllers/admin/AdminProductsController.php
+++ b/controllers/admin/AdminProductsController.php
@@ -68,6 +68,8 @@ class AdminProductsControllerCore extends AdminController
protected $available_tabs_lang = array();
+ protected $position_identifier = 'id_product';
+
public function __construct()
{
$this->table = 'product';
diff --git a/controllers/admin/AdminTabsController.php b/controllers/admin/AdminTabsController.php
index dd92aa9cb..f13605a6b 100644
--- a/controllers/admin/AdminTabsController.php
+++ b/controllers/admin/AdminTabsController.php
@@ -27,6 +27,8 @@
class AdminTabsControllerCore extends AdminController
{
+ protected $position_identifier = 'id_tab';
+
public function __construct()
{
$this->context = Context::getContext();
@@ -226,6 +228,7 @@ class AdminTabsControllerCore extends AdminController
$helper->currentIndex = self::$currentIndex;
$helper->token = $this->token;
$helper->table = $this->table;
+ $helper->position_identifier = $this->position_identifier;
// Force render - no filter, form, js, sorting ...
$helper->simple_header = true;
$content = $helper->generateList($this->_list, $this->fieldsDisplay);
|