// fix on attribute positions in FO (Attribute constructor was incorrect)

This commit is contained in:
vChabot
2011-10-27 12:52:04 +00:00
parent 2b7340d9d9
commit d09855f02c
5 changed files with 70 additions and 5 deletions
+12
View File
@@ -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);
}
}
+21 -3
View File
@@ -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
<tbody>';
$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 '
<tr'.($nbrow++ % 2 ? ' class="'.$class.'alt_row"' : '').' id="tr_'.$attribute['id_attribute_group'].'_'.$attribute['id_attribute'].'_'.$attribute['position'].'">
@@ -306,7 +311,7 @@ class AdminAttributesGroups extends AdminTab
'.($tr['is_color_group'] ? '<div style="float: left; width: 18px; height: 12px; border: 1px solid #996633; background-color: '.$attribute['color'].'; margin-right: 4px;"></div>' : '')
.$attribute['name'].'
</td>
<td class="dragHandle">';
<td class="dragHandle" '.(isset($attribute['position']) ? ' id="td_'.(isset($id_category) && $id_category ? $id_category : 0).'_'.$attribute['id_attribute'].'"' : '').'">';
echo '<a'.(!($attribute['position'] != $attributes[sizeof($attributes) - 1]['position']) ? ' style="display: none;"' : '').' href="'.self::$currentIndex.
'&id_attribute_group='.(int)($attribute['id_attribute_group']).'&id_attribute='.$attribute['id_attribute'].'
@@ -337,6 +342,19 @@ class AdminAttributesGroups extends AdminTab
onclick="changeFormParam(this.form, \''.self::$currentIndex.'\', '.$id.'); return confirm(\''.$this->l('Delete selected items?', __CLASS__, true, false).'\');" /></p>
</div>';
}
/**
* 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);
}
}
+13
View File
@@ -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);
}
}
+2 -2
View File
@@ -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()
+22
View File
@@ -107,6 +107,27 @@ class HelperOptionsCore extends Helper
}
}
// pre-assign vars to the tpl
if ($field['type'] == 'maintenance_ip')
{
$field['script_ip'] = '
<script type="text/javascript">
function addRemoteAddr()
{
var length = $(\'input[name=PS_MAINTENANCE_IP]\').attr(\'value\').length;
if (length > 0)
$(\'input[name=PS_MAINTENANCE_IP]\').attr(\'value\',$(\'input[name=PS_MAINTENANCE_IP]\').attr(\'value\') +\','.Tools::getRemoteAddr().'\');
else
$(\'input[name=PS_MAINTENANCE_IP]\').attr(\'value\',\''.Tools::getRemoteAddr().'\');
}
</script>';
$field['link_remove_ip'] = ' &nbsp<a href="#" class="button" onclick="addRemoteAddr(); return false;">'.$this->l('Add my IP').'</a>';
} 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;