[*] BO : #PSFV-481 - Refactor HelperList position management
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@14099 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
+1
-1
@@ -27,7 +27,7 @@
|
|||||||
{if count($list)}
|
{if count($list)}
|
||||||
{foreach $list AS $index => $tr}
|
{foreach $list AS $index => $tr}
|
||||||
<tr
|
<tr
|
||||||
{if $is_dnd_identifier}id="tr_{$tr.id_attribute_group}_{$tr.$identifier}_{if isset($tr.position['position'])}{$tr.position['position']}{else}0{/if}"{/if}
|
{if $position_identifier}id="tr_{$tr.id_attribute_group}_{$tr.$identifier}_{if isset($tr.position['position'])}{$tr.position['position']}{else}0{/if}"{/if}
|
||||||
{if $index is odd}class="alt_row"{/if}
|
{if $index is odd}class="alt_row"{/if}
|
||||||
{if isset($tr.color) && $color_on_bg}style="background-color: {$tr.color}"{/if}
|
{if isset($tr.color) && $color_on_bg}style="background-color: {$tr.color}"{/if}
|
||||||
>
|
>
|
||||||
|
|||||||
+1
-1
@@ -26,7 +26,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
{foreach $list AS $index => $tr}
|
{foreach $list AS $index => $tr}
|
||||||
<tr
|
<tr
|
||||||
{if $is_dnd_identifier}id="tr_{$id_category}_{$tr.$identifier}_{$tr.position['position']}"{/if}
|
{if $position_identifier}id="tr_{$id_category}_{$tr.$identifier}_{$tr.position['position']}"{/if}
|
||||||
{if $index is odd}class="alt_row"{/if}
|
{if $index is odd}class="alt_row"{/if}
|
||||||
{if isset($tr.color) && $color_on_bg}style="background-color: {$tr.color}"{/if}
|
{if isset($tr.color) && $color_on_bg}style="background-color: {$tr.color}"{/if}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
{if count($list)}
|
{if count($list)}
|
||||||
{foreach $list AS $index => $tr}
|
{foreach $list AS $index => $tr}
|
||||||
<tr
|
<tr
|
||||||
{if $is_dnd_identifier}id="tr_{$id_category}_{$tr.$identifier}_{if isset($tr.position['position'])}{$tr.position['position']}{else}0{/if}"{/if}
|
{if $position_identifier}id="tr_{$id_category}_{$tr.$identifier}_{if isset($tr.position['position'])}{$tr.position['position']}{else}0{/if}"{/if}
|
||||||
class="{if $index is odd}alt_row{/if} {if $row_hover}row_hover{/if}"
|
class="{if $index is odd}alt_row{/if} {if $row_hover}row_hover{/if}"
|
||||||
{if isset($tr.color) && $color_on_bg}style="background-color: {$tr.color}"{/if}
|
{if isset($tr.color) && $color_on_bg}style="background-color: {$tr.color}"{/if}
|
||||||
>
|
>
|
||||||
@@ -44,15 +44,14 @@
|
|||||||
</td>
|
</td>
|
||||||
{foreach $fields_display AS $key => $params}
|
{foreach $fields_display AS $key => $params}
|
||||||
{block name="open_td"}
|
{block name="open_td"}
|
||||||
<td
|
<td
|
||||||
{if isset($params.position)}
|
{if isset($params.position)}
|
||||||
id="td_{if !empty($id_category)}{$id_category}{else}0{/if}_{$tr.$identifier}"
|
id="td_{if !empty($id_category)}{$id_category}{else}0{/if}_{$tr.$identifier}"
|
||||||
{/if}
|
{/if}
|
||||||
class="{if !$no_link}pointer{/if}
|
class="{if !$no_link}pointer{/if}
|
||||||
{if isset($params.position) && $order_by == 'position'} dragHandle{/if}
|
{if isset($params.position) && $order_by == 'position'} dragHandle{/if}
|
||||||
{if isset($params.align)} {$params.align}{/if}"
|
{if isset($params.align)} {$params.align}{/if}"
|
||||||
|
{if (!isset($params.position) && !$no_link && !isset($params.remove_onclick))}
|
||||||
{if (!isset($params.position) && !$no_link && !isset($params.remove_onclick))}
|
|
||||||
onclick="document.location = '{$current_index}&{$identifier}={$tr.$identifier}{if $view}&view{else}&update{/if}{$table}&token={$token}'">
|
onclick="document.location = '{$current_index}&{$identifier}={$tr.$identifier}{if $view}&view{else}&update{/if}{$table}&token={$token}'">
|
||||||
{else}
|
{else}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -202,15 +202,8 @@ class AdminControllerCore extends Controller
|
|||||||
|
|
||||||
protected $is_cms = false;
|
protected $is_cms = false;
|
||||||
|
|
||||||
protected $is_dnd_identifier = false;
|
/** @var string identifier to use for changing positions in lists (can be omitted if positions cannot be changed) */
|
||||||
|
protected $position_identifier;
|
||||||
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 boolean Table records are not deleted but marked as deleted if set to true */
|
/** @var boolean Table records are not deleted but marked as deleted if set to true */
|
||||||
protected $deleted = false;
|
protected $deleted = false;
|
||||||
@@ -1542,6 +1535,7 @@ class AdminControllerCore extends Controller
|
|||||||
$helper->allow_employee_form_lang = $this->allow_employee_form_lang;
|
$helper->allow_employee_form_lang = $this->allow_employee_form_lang;
|
||||||
$helper->multiple_fieldsets = $this->multiple_fieldsets;
|
$helper->multiple_fieldsets = $this->multiple_fieldsets;
|
||||||
$helper->row_hover = $this->row_hover;
|
$helper->row_hover = $this->row_hover;
|
||||||
|
$helper->position_identifier = $this->position_identifier;
|
||||||
|
|
||||||
// For each action, try to add the corresponding skip elements list
|
// For each action, try to add the corresponding skip elements list
|
||||||
$helper->list_skip_actions = $this->list_skip_actions;
|
$helper->list_skip_actions = $this->list_skip_actions;
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ class HelperListCore extends Helper
|
|||||||
|
|
||||||
protected $is_cms = false;
|
protected $is_cms = false;
|
||||||
|
|
||||||
protected $is_dnd_identifier = false;
|
public $position_identifier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string Customize list display
|
* @var string Customize list display
|
||||||
@@ -100,18 +100,6 @@ class HelperListCore extends Helper
|
|||||||
/** @var bool If true, activates color on hover */
|
/** @var bool If true, activates color on hover */
|
||||||
public $row_hover = true;
|
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 */
|
/** @var if not null, a title will be added on that list */
|
||||||
public $title = null;
|
public $title = null;
|
||||||
|
|
||||||
@@ -137,9 +125,6 @@ class HelperListCore extends Helper
|
|||||||
*/
|
*/
|
||||||
public function generateList($list, $fields_display)
|
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
|
// Append when we get a syntax error in SQL query
|
||||||
if ($list === false)
|
if ($list === false)
|
||||||
{
|
{
|
||||||
@@ -192,10 +177,10 @@ class HelperListCore extends Helper
|
|||||||
|
|
||||||
public function displayListContent()
|
public function displayListContent()
|
||||||
{
|
{
|
||||||
if ($this->is_dnd_identifier)
|
if ($this->position_identifier)
|
||||||
$id_category = (int)Tools::getValue('id_'.($this->is_cms ? 'cms_' : '').'category', '1');
|
$id_category = (int)Tools::getValue('id_'.($this->is_cms ? 'cms_' : '').'category', '1');
|
||||||
else
|
else
|
||||||
$id_category = Category::getRootCategory();
|
$id_category = Category::getRootCategory()->id;
|
||||||
|
|
||||||
if (isset($this->fieldsDisplay['position']))
|
if (isset($this->fieldsDisplay['position']))
|
||||||
{
|
{
|
||||||
@@ -258,10 +243,10 @@ class HelperListCore extends Helper
|
|||||||
$this->_list[$index][$key] = array(
|
$this->_list[$index][$key] = array(
|
||||||
'position' => $tr[$key],
|
'position' => $tr[$key],
|
||||||
'position_url_down' => $this->currentIndex.
|
'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,
|
'&way=1&position='.((int)$tr['position'] + 1).'&token='.$this->token,
|
||||||
'position_url_up' => $this->currentIndex.
|
'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
|
'&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(
|
$this->content_tpl->assign(array_merge($this->tpl_vars, array(
|
||||||
'shop_link_type' => $this->shopLinkType,
|
'shop_link_type' => $this->shopLinkType,
|
||||||
'name' => isset($name) ? $name : null,
|
'name' => isset($name) ? $name : null,
|
||||||
'is_dnd_identifier' => $this->is_dnd_identifier,
|
'position_identifier' => $this->position_identifier,
|
||||||
'identifier' => $this->identifier,
|
'identifier' => $this->identifier,
|
||||||
'table' => $this->table,
|
'table' => $this->table,
|
||||||
'token' => $this->token,
|
'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
|
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
|
// Cleaning links
|
||||||
if (Tools::getValue($this->table.'Orderby') && Tools::getValue($this->table.'Orderway'))
|
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);
|
$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));
|
$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;
|
$table_dnd = true;
|
||||||
|
|
||||||
foreach ($this->fieldsDisplay as $key => $params)
|
foreach ($this->fieldsDisplay as $key => $params)
|
||||||
@@ -610,7 +593,7 @@ class HelperListCore extends Helper
|
|||||||
'selected_pagination' => $selected_pagination,
|
'selected_pagination' => $selected_pagination,
|
||||||
'pagination' => $this->_pagination,
|
'pagination' => $this->_pagination,
|
||||||
'list_total' => $this->listTotal,
|
'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_way' => $this->orderWay,
|
||||||
'order_by' => $this->orderBy,
|
'order_by' => $this->orderBy,
|
||||||
'token' => $this->token,
|
'token' => $this->token,
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
class AdminAttributesGroupsControllerCore extends AdminController
|
class AdminAttributesGroupsControllerCore extends AdminController
|
||||||
{
|
{
|
||||||
protected $id_attribute;
|
protected $id_attribute;
|
||||||
|
protected $position_identifier = 'id_attribute_group';
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
@@ -157,6 +158,7 @@ class AdminAttributesGroupsControllerCore extends AdminController
|
|||||||
$helper->simple_header = true;
|
$helper->simple_header = true;
|
||||||
$helper->show_toolbar = false;
|
$helper->show_toolbar = false;
|
||||||
$helper->bulk_actions = $this->bulk_actions;
|
$helper->bulk_actions = $this->bulk_actions;
|
||||||
|
$helper->position_identifier = 'id_attribute';
|
||||||
$content = $helper->generateList($this->_list, $this->fieldsDisplay);
|
$content = $helper->generateList($this->_list, $this->fieldsDisplay);
|
||||||
|
|
||||||
die (Tools::jsonEncode(array('use_parent_structure' => false, 'data' => $content)));
|
die (Tools::jsonEncode(array('use_parent_structure' => false, 'data' => $content)));
|
||||||
|
|||||||
@@ -27,6 +27,8 @@
|
|||||||
|
|
||||||
class AdminCarriersControllerCore extends AdminController
|
class AdminCarriersControllerCore extends AdminController
|
||||||
{
|
{
|
||||||
|
protected $position_identifier = 'id_carrier';
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->table = 'carrier';
|
$this->table = 'carrier';
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ class AdminCategoriesControllerCore extends AdminController
|
|||||||
* @var object Category() instance for navigation
|
* @var object Category() instance for navigation
|
||||||
*/
|
*/
|
||||||
private $_category = null;
|
private $_category = null;
|
||||||
|
protected $position_identifier = 'id_category_to_move';
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -28,7 +28,9 @@
|
|||||||
class AdminCmsCategoriesControllerCore extends AdminController
|
class AdminCmsCategoriesControllerCore extends AdminController
|
||||||
{
|
{
|
||||||
/** @var object CMSCategory() instance for navigation*/
|
/** @var object CMSCategory() instance for navigation*/
|
||||||
private $_CMSCategory;
|
protected $_CMSCategory;
|
||||||
|
|
||||||
|
protected $position_identifier = 'id_cms_category_to_move';
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ class AdminCmsControllerCore extends AdminController
|
|||||||
|
|
||||||
public $id_cms_category;
|
public $id_cms_category;
|
||||||
|
|
||||||
|
protected $position_identifier = 'id_cms';
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->table = 'cms';
|
$this->table = 'cms';
|
||||||
|
|||||||
@@ -26,6 +26,8 @@
|
|||||||
*/
|
*/
|
||||||
class AdminFeaturesControllerCore extends AdminController
|
class AdminFeaturesControllerCore extends AdminController
|
||||||
{
|
{
|
||||||
|
protected $position_identifier = 'id_feature';
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->table = 'feature';
|
$this->table = 'feature';
|
||||||
|
|||||||
@@ -68,6 +68,8 @@ class AdminProductsControllerCore extends AdminController
|
|||||||
|
|
||||||
protected $available_tabs_lang = array();
|
protected $available_tabs_lang = array();
|
||||||
|
|
||||||
|
protected $position_identifier = 'id_product';
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->table = 'product';
|
$this->table = 'product';
|
||||||
|
|||||||
@@ -27,6 +27,8 @@
|
|||||||
|
|
||||||
class AdminTabsControllerCore extends AdminController
|
class AdminTabsControllerCore extends AdminController
|
||||||
{
|
{
|
||||||
|
protected $position_identifier = 'id_tab';
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->context = Context::getContext();
|
$this->context = Context::getContext();
|
||||||
@@ -226,6 +228,7 @@ class AdminTabsControllerCore extends AdminController
|
|||||||
$helper->currentIndex = self::$currentIndex;
|
$helper->currentIndex = self::$currentIndex;
|
||||||
$helper->token = $this->token;
|
$helper->token = $this->token;
|
||||||
$helper->table = $this->table;
|
$helper->table = $this->table;
|
||||||
|
$helper->position_identifier = $this->position_identifier;
|
||||||
// Force render - no filter, form, js, sorting ...
|
// Force render - no filter, form, js, sorting ...
|
||||||
$helper->simple_header = true;
|
$helper->simple_header = true;
|
||||||
$content = $helper->generateList($this->_list, $this->fieldsDisplay);
|
$content = $helper->generateList($this->_list, $this->fieldsDisplay);
|
||||||
|
|||||||
Reference in New Issue
Block a user