From d09855f02c7098414d71e46662d73e8a10694d17 Mon Sep 17 00:00:00 2001 From: vChabot Date: Thu, 27 Oct 2011 12:52:04 +0000 Subject: [PATCH] // fix on attribute positions in FO (Attribute constructor was incorrect) --- admin-dev/tabs/AdminAttributes.php | 12 ++++++++++++ admin-dev/tabs/AdminAttributesGroups.php | 24 +++++++++++++++++++++--- admin-dev/tabs/AdminFeatures.php | 13 +++++++++++++ classes/Attribute.php | 4 ++-- classes/HelperOptions.php | 22 ++++++++++++++++++++++ 5 files changed, 70 insertions(+), 5 deletions(-) diff --git a/admin-dev/tabs/AdminAttributes.php b/admin-dev/tabs/AdminAttributes.php index cc29816f2..97edea1db 100644 --- a/admin-dev/tabs/AdminAttributes.php +++ b/admin-dev/tabs/AdminAttributes.php @@ -186,6 +186,18 @@ class AdminAttributes extends AdminTab } + /** + * Modifying initial getList method to display position feature (drag and drop) + */ + public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false) + { + if ($order_by && $this->context->cookie->__get($this->table.'Orderby')) + $order_by = $this->context->cookie->__get($this->table.'Orderby'); + else + $order_by = 'position'; + + parent::getList($id_lang, $order_by, $order_way, $start, $limit, $id_lang_shop); + } } diff --git a/admin-dev/tabs/AdminAttributesGroups.php b/admin-dev/tabs/AdminAttributesGroups.php index 0b3959fe2..2e7eecbbb 100644 --- a/admin-dev/tabs/AdminAttributesGroups.php +++ b/admin-dev/tabs/AdminAttributesGroups.php @@ -72,7 +72,7 @@ class AdminAttributesGroups extends AdminTab return; $this->adminAttributes->tabAccess = Profile::getProfileAccess(Context::getContext()->employee->id_profile, $this->id); - if (Tools::isSubmit('submitAddattribute') || Tools::isSubmit('submitDelattribute')) + if (Tools::isSubmit('submitAddattribute') || Tools::isSubmit('submitDelattribute') || (Tools::getValue('position') && Tools::getValue('id_attribute'))) $this->adminAttributes->postProcess($this->token); Module::hookExec('postProcessAttributeGroup', @@ -279,6 +279,10 @@ class AdminAttributesGroups extends AdminTab * displayListAttributes * * Display a list of attributes from a group + * @param integer $id + * @param integer $irow + * @param array $tr + * @return void */ public function displayListAttributes($id, $irow, $tr) { @@ -296,8 +300,9 @@ class AdminAttributesGroups extends AdminTab '; $attributes = AttributeGroup::getAttributes(Context::getContext()->language->id, $id); $nbrow = 0; - foreach ($attributes AS $attribute) + foreach ($attributes as $attribute) { + $id_category = 1; $class = ($irow % 2) ? '': 'not_'; echo ' @@ -306,7 +311,7 @@ class AdminAttributesGroups extends AdminTab '.($tr['is_color_group'] ? '
' : '') .$attribute['name'].' - '; + '; echo 'l('Delete selected items?', __CLASS__, true, false).'\');" />

'; } + + /** + * Modifying initial getList method to display position feature (drag and drop) + */ + public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false) + { + if ($order_by && $this->context->cookie->__get($this->table.'Orderby')) + $order_by = $this->context->cookie->__get($this->table.'Orderby'); + else + $order_by = 'position'; + + parent::getList($id_lang, $order_by, $order_way, $start, $limit, $id_lang_shop); + } } diff --git a/admin-dev/tabs/AdminFeatures.php b/admin-dev/tabs/AdminFeatures.php index de5793ed1..7ea36035b 100644 --- a/admin-dev/tabs/AdminFeatures.php +++ b/admin-dev/tabs/AdminFeatures.php @@ -281,4 +281,17 @@ class AdminFeatures extends AdminTab else parent::postProcess(); } + + /** + * Modifying initial getList method to display position feature (drag and drop) + */ + public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false) + { + if ($order_by && $this->context->cookie->__get($this->table.'Orderby')) + $order_by = $this->context->cookie->__get($this->table.'Orderby'); + else + $order_by = 'position'; + + parent::getList($id_lang, $order_by, $order_way, $start, $limit, $id_lang_shop); + } } diff --git a/classes/Attribute.php b/classes/Attribute.php index 7565a57c5..deaa9587d 100644 --- a/classes/Attribute.php +++ b/classes/Attribute.php @@ -54,11 +54,11 @@ class AttributeCore extends ObjectModel ), ); - public function __construct() + public function __construct($id = null, $id_lang = null, $id_shop = null) { $this->image_dir = _PS_COL_IMG_DIR_; - parent::__construct(); + parent::__construct($id, $id_lang, $id_shop); } public function getFields() diff --git a/classes/HelperOptions.php b/classes/HelperOptions.php index deeba9b32..4f643943c 100644 --- a/classes/HelperOptions.php +++ b/classes/HelperOptions.php @@ -107,6 +107,27 @@ class HelperOptionsCore extends Helper } } + // pre-assign vars to the tpl + if ($field['type'] == 'maintenance_ip') + { + $field['script_ip'] = ' + '; + $field['link_remove_ip'] = '  '.$this->l('Add my IP').''; + } else if ($field['type'] == 'price') + { + $field['currency_left'] = $this->context->currency->getSign('left'); + $field['currency_right'] = $this->context->currency->getSign('right').' '.$this->l('(tax excl.)'); + } + // Multishop default value $field['multishop_default'] = (Shop::isFeatureActive() && Context::shop() != Shop::CONTEXT_ALL && !$isInvisible); @@ -116,6 +137,7 @@ class HelperOptionsCore extends Helper // Is at least one required field present? if (isset($field['required']) && $field['required']) $required_fields = true; + } // Assign the modifications back to parent array $option_list[$category] = $category_data;