From 50c88dc4def4f6565bbd80c7e709d70f594bb7b7 Mon Sep 17 00:00:00 2001 From: gRoussac Date: Mon, 24 Jun 2013 14:50:10 +0200 Subject: [PATCH] [-] BO : Fix bug #PSCFV-7353 can not see the thumb for a scene --- classes/Scene.php | 17 ++++------- controllers/admin/AdminScenesController.php | 31 ++++++++++++--------- 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/classes/Scene.php b/classes/Scene.php index 86b53036e..b3bc32f5a 100644 --- a/classes/Scene.php +++ b/classes/Scene.php @@ -116,19 +116,12 @@ class SceneCore extends ObjectModel } public function deleteImage($force_delete = false) - { - // Hack to prevent the main scene image from being deleted in AdminController::uploadImage() when a thumb image is uploaded - if (isset($_FILES['thumb']) && (!isset($_FILES['image']) || empty($_FILES['image']['name']))) - return true; - - if (parent::deleteImage()) - { - if (file_exists($this->image_dir.'thumbs/'.$this->id.'-thumb_scene.'.$this->image_format) - && !unlink($this->image_dir.'thumbs/'.$this->id.'-thumb_scene.'.$this->image_format)) - return false; - } - else + { + if (file_exists($this->image_dir.'thumbs/'.$this->id.'-m_scene_default.'.$this->image_format) + && !unlink($this->image_dir.'thumbs/'.$this->id.'-m_scene_default.'.$this->image_format)) return false; + if (!(isset($_FILES) && count($_FILES))) + return parent::deleteImage(); return true; } diff --git a/controllers/admin/AdminScenesController.php b/controllers/admin/AdminScenesController.php index 7f9ef8b91..346a5543b 100644 --- a/controllers/admin/AdminScenesController.php +++ b/controllers/admin/AdminScenesController.php @@ -75,16 +75,15 @@ class AdminScenesControllerCore extends AdminController $images_types = ImageType::getImagesTypes('scenes'); foreach ($images_types as $k => $image_type) - { - if ($image_type['name'] == 'scene_default' && isset($_FILES['image'])) + { + if ($image_type['name'] == 'scene_default' AND isset($_FILES['image']) AND isset($_FILES['image']['tmp_name']) AND !$_FILES['image']['error']) ImageManager::resize( $base_img_path, _PS_SCENE_IMG_DIR_.$obj->id.'-'.stripslashes($image_type['name']).'.jpg', (int)$image_type['width'], - (int)$image_type['height'] - ); + (int)$image_type['height']); else if ($image_type['name'] == 'm_scene_default') - { + { if (isset($_FILES['thumb']) && !$_FILES['thumb']['error']) $base_thumb_path = _PS_SCENE_THUMB_IMG_DIR_.$obj->id.'.jpg'; else @@ -93,8 +92,7 @@ class AdminScenesControllerCore extends AdminController $base_thumb_path, _PS_SCENE_THUMB_IMG_DIR_.$obj->id.'-'.stripslashes($image_type['name']).'.jpg', (int)$image_type['width'], - (int)$image_type['height'] - ); + (int)$image_type['height']); } } } @@ -207,20 +205,20 @@ class AdminScenesControllerCore extends AdminController $this->addJqueryPlugin('imgareaselect'); $this->addJs(_PS_JS_DIR_.'admin-scene-cropping.js' ); $image_to_map_desc .= '

'; + _THEME_SCENE_DIR_.$obj->id.'-scene_default.jpg?rand='.(int)rand().'" />
'; $image_to_map_desc .= ' '; - if ($obj->id && file_exists(_PS_SCENE_IMG_DIR_.'thumbs/'.$obj->id.'-thumb_scene.jpg')) + if ($obj->id && file_exists(_PS_SCENE_IMG_DIR_.'thumbs/'.$obj->id.'-m_scene_default.jpg')) $image_to_map_desc .= '
- +
'; $img_alt_desc = ''; @@ -229,7 +227,7 @@ class AdminScenesControllerCore extends AdminController .$this->l('File size:').' '.(Tools::getMaxUploadSize() / 1024).''.$this->l('Kb max.').' ' .sprintf($this->l('Automatically resized to %1$d x %2$dpx (width x height).'), $thumb_scene_image_type['width'], $thumb_scene_image_type['height']).'.
' - .$this->l('Note: To change image dimensions, please change the \'thumb_scene\' image type settings to the desired size (in Back Office > Preferences > Images).'); + .$this->l('Note: To change image dimensions, please change the \'m_scene_default\' image type settings to the desired size (in Back Office > Preferences > Images).'); $input_img_alt = array( 'type' => 'file', @@ -312,7 +310,14 @@ class AdminScenesControllerCore extends AdminController if (!Tools::isSubmit('zones') || !count(Tools::getValue('zones'))) $this->errors[] = Tools::displayError('You should create at least one zone.'); } - + + if (Tools::isSubmit('delete'.$this->table)) + { + if (Validate::isLoadedObject($object = $this->loadObject())) + $object->deleteImage(false); + else + return false; + } parent::postProcess(); } }