diff --git a/admin-dev/themes/default/template/controllers/attributes/helpers/form/form.tpl b/admin-dev/themes/default/template/controllers/attributes/helpers/form/form.tpl index 78dda884d..1e00b4530 100644 --- a/admin-dev/themes/default/template/controllers/attributes/helpers/form/form.tpl +++ b/admin-dev/themes/default/template/controllers/attributes/helpers/form/form.tpl @@ -36,6 +36,17 @@ {/block} +{block name="start_field_block"} +
+ {if $input.name == 'current_texture'} + {if isset($imageTextureExists) && $imageTextureExists} + {l s='Texture'} + {else} + {l s='None'} + {/if} + {/if} +{/block} + {block name="end_field_block"} {if $input.type == 'text' && $input.name == 'texture'}
diff --git a/admin-dev/themes/default/template/controllers/attributes/helpers/list/list_content.tpl b/admin-dev/themes/default/template/controllers/attributes/helpers/list/list_content.tpl index f44a653bd..4af6587d8 100644 --- a/admin-dev/themes/default/template/controllers/attributes/helpers/list/list_content.tpl +++ b/admin-dev/themes/default/template/controllers/attributes/helpers/list/list_content.tpl @@ -95,7 +95,11 @@ {elseif isset($params.callback)} {$tr.$key} {elseif isset($tr.$key) && $key == 'color'} -
+ {if isset($tr.$key['texture']) && $tr.$key['texture']|count_characters > 1} + + {else} +
+ {/if} {elseif isset($tr.$key)} {$tr.$key|escape:'htmlall':'UTF-8'} {else} diff --git a/controllers/admin/AdminAttributesGroupsController.php b/controllers/admin/AdminAttributesGroupsController.php index 8541079f1..c58bc5f22 100644 --- a/controllers/admin/AdminAttributesGroupsController.php +++ b/controllers/admin/AdminAttributesGroupsController.php @@ -64,6 +64,8 @@ class AdminAttributesGroupsControllerCore extends AdminController $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'))); + $this->fieldImageSettings = array('name' => 'texture', 'dir' => 'co'); + parent::__construct(); } @@ -310,9 +312,9 @@ class AdminAttributesGroupsControllerCore extends AdminController ); $this->fields_form['input'][] = array( - 'type' => 'text', + 'type' => 'current_texture', 'label' => $this->l('Current texture:'), - 'name' => 'texture' + 'name' => 'current_texture' ); $this->fields_form['submit'] = array( @@ -326,7 +328,6 @@ class AdminAttributesGroupsControllerCore extends AdminController $this->identifier = 'id_attribute'; $this->lang = true; $this->tpl_folder = 'attributes/'; - $this->fieldImageSettings = array('name' => 'texture', 'dir' => 'co'); // Create object Attribute if (!$obj = new Attribute((int)Tools::getValue($this->identifier))) @@ -336,11 +337,12 @@ class AdminAttributesGroupsControllerCore extends AdminController foreach ($attributes_groups as $attribute_group) $str_attributes_groups .= '"'.$attribute_group['id_attribute_group'].'" : '.($attribute_group['group_type'] == 'color' ? '1' : '0' ).', '; - $image = _PS_IMG_DIR_.$this->fieldImageSettings['dir'].'/'.$obj->id.'.jpg'; + $image = '../img/'.$this->fieldImageSettings['dir'].'/'.(int)$obj->id.'.jpg'; + $this->tpl_form_vars = array( 'strAttributesGroups' => $str_attributes_groups, 'colorAttributeProperties' => Validate::isLoadedObject($obj) && $obj->isColorAttribute(), - 'imageTextureExists' => file_exists($image), + 'imageTextureExists' => file_exists(_PS_IMG_DIR_.$this->fieldImageSettings['dir'].'/'.(int)$obj->id.'.jpg'), 'imageTexture' => $image, 'imageTextureUrl' => Tools::safeOutput($_SERVER['REQUEST_URI']).'&deleteImage=1' ); @@ -651,18 +653,27 @@ class AdminAttributesGroupsControllerCore extends AdminController { parent::getList($id_lang, $order_by, $order_way, $start, $limit, $id_lang_shop); - $nb_items = count($this->_list); - for ($i = 0; $i < $nb_items; ++$i) + if ($this->ajax) { - $item = &$this->_list[$i]; + foreach ($this->_list as &$list) + if (file_exists(_PS_IMG_DIR_.$this->fieldImageSettings['dir'].'/'.(int)$list['id_attribute'].'.jpg')) + $list['color']['texture'] = '../img/'.$this->fieldImageSettings['dir'].'/'.(int)$list['id_attribute'].'.jpg'; + } + else + { + $nb_items = count($this->_list); + for ($i = 0; $i < $nb_items; ++$i) + { + $item = &$this->_list[$i]; - $query = new DbQuery(); - $query->select('COUNT(id_attribute) as count_values'); - $query->from('attribute', 'a'); - $query->where('a.id_attribute_group ='.(int)$item['id_attribute_group']); - $res = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query); - $item['count_values'] = (int)$res; - unset($query); + $query = new DbQuery(); + $query->select('COUNT(id_attribute) as count_values'); + $query->from('attribute', 'a'); + $query->where('a.id_attribute_group ='.(int)$item['id_attribute_group']); + $res = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query); + $item['count_values'] = (int)$res; + unset($query); + } } }