From dfa59fa8f7bce36786ebf89001a312e1fa367af0 Mon Sep 17 00:00:00 2001 From: Jerome Nadaud Date: Tue, 22 Oct 2013 19:04:11 +0200 Subject: [PATCH] // Fix blockcategories --- modules/blockcategories/blockcategories.php | 16 +++++++++++++--- .../views/blockcategories_admin.tpl | 6 +++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/modules/blockcategories/blockcategories.php b/modules/blockcategories/blockcategories.php index 6304ecb28..4d592bd26 100644 --- a/modules/blockcategories/blockcategories.php +++ b/modules/blockcategories/blockcategories.php @@ -117,9 +117,12 @@ class BlockCategories extends Module public function hookDisplayBackOfficeCategory($params) { + for ($i=0;$i<3;$i++) + $images[$i] = ImageManager::thumbnail(_PS_CAT_IMG_DIR_.Tools::getValue('id_category').'-'.$i.'_thumb.jpg', $this->context->controller->table.'_'.(int)Tools::getValue('id_category').'-'.$i.'_thumb.jpg', 100, 'jpg', true); + $this->smarty->assign(array( 'name' => 'thumb', - 'images' => array() + 'images' => $images )); return $this->display(__FILE__, 'views/blockcategories_admin.tpl'); @@ -152,7 +155,7 @@ class BlockCategories extends Module $errors[] = Tools::displayError('Due to memory limit restrictions, this image cannot be loaded. Please increase your memory_limit value via your server\'s configuration settings. '); // Copy new image - if (empty($errors) && !ImageManager::resize($tmp_name, _PS_CAT_IMG_DIR_.Tools::getValue('id_category').'-'.$i.'_thumb.jpg')) + if (empty($errors) && !ImageManager::resize($tmp_name, _PS_CAT_IMG_DIR_.(int)Tools::getValue('id_category').'-'.$i.'_thumb.jpg')) $errors[] = Tools::displayError('An error occurred while uploading the image.'); if (count($errors)) @@ -161,8 +164,15 @@ class BlockCategories extends Module unlink($tmp_name); } + if (($id_thumb = Tools::getValue('deleteThumb', false)) !== false) + { + if (file_exists(_PS_CAT_IMG_DIR_.(int)Tools::getValue('id_category').'-'.(int)$id_thumb.'_thumb.jpg') + && !unlink(_PS_CAT_IMG_DIR_.(int)Tools::getValue('id_category').'-'.(int)$id_thumb.'_thumb.jpg')) + $this->context->controller->errors[] = Tools::displayError('Error while delet'); + } + if (count($total_errors)) - ;//TODO : Show errors + $this->context->controller->errors = array_merge($this->context->controller->errors, $total_errors); } public function hookLeftColumn($params) diff --git a/modules/blockcategories/views/blockcategories_admin.tpl b/modules/blockcategories/views/blockcategories_admin.tpl index 727d46539..94f44c300 100644 --- a/modules/blockcategories/views/blockcategories_admin.tpl +++ b/modules/blockcategories/views/blockcategories_admin.tpl @@ -12,10 +12,10 @@ {if isset($images.$foo) && $images.$foo}
 
-
- {$images.$foo.image} +
+ {$images.$foo}