From ea69499aedf78726f5e0d4d08522a17856fcf84b Mon Sep 17 00:00:00 2001 From: tDidierjean Date: Mon, 17 Oct 2011 15:08:43 +0000 Subject: [PATCH] [*] BO : #PSFV-94 - more AdminImagesController refactoring git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@9396 b9a71923-0436-4b27-9f14-aed3839534dd --- controllers/admin/AdminImagesController.php | 116 ++++++-------------- 1 file changed, 31 insertions(+), 85 deletions(-) diff --git a/controllers/admin/AdminImagesController.php b/controllers/admin/AdminImagesController.php index 1df93bbbd..cf941e8f4 100644 --- a/controllers/admin/AdminImagesController.php +++ b/controllers/admin/AdminImagesController.php @@ -235,6 +235,14 @@ class AdminImagesController extends AdminController public function postProcess() { + // When moving images, if duplicate images were found they are moved to a folder named duplicates/ + if (file_exists(_PS_PROD_IMG_DIR_.'duplicates/')) + { + $this->warnings[] = $this->l('Duplicate images were found when moving the product images. It is probably caused by unused demonstration images. Please make sure that the folder '). + _PS_PROD_IMG_DIR_.'duplicates/'. + $this->l(' only contains demonstration images then delete this folder.'); + } + if (Tools::getValue('submitRegenerate'.$this->table)) { if ($this->tabAccess['edit'] === '1') @@ -273,6 +281,7 @@ class AdminImagesController extends AdminController else $this->_errors[] = Tools::displayError('You do not have permission to edit here.'); } + else parent::postProcess(); } @@ -284,9 +293,9 @@ class AdminImagesController extends AdminController } /** - * Display form for thumbnails regeneration + * Init display for the thumbnails regeneration block */ - public function displayRegenerate() + public function initRegenerate() { $types = array( 'categories' => $this->l('Categories'), @@ -296,55 +305,15 @@ class AdminImagesController extends AdminController 'products' => $this->l('Products'), 'stores' => $this->l('Stores') ); - $this->content .= ' -

'.$this->l('Regenerate thumbnails').'

- '.$this->l('Regenerates thumbnails for all existing product images').'.

'; - $this->content .= '
'.$this->l('Please be patient, as this can take several minutes').'
'.$this->l('Be careful! Manually generated thumbnails will be erased by automatically generated thumbnails.').'
'; - $this->content .= '
-
+ $formats = array(); + foreach ($types as $i => $type) + $formats[$i] = ImageType::getImagesTypes($i); -
- '.$this->l('Regenerate thumbnails').'
- -
- -
'; - - foreach ($types AS $k => $type) - { - $formats = ImageType::getImagesTypes($k); - $this->content .= ' - - '; - } - $this->content .= ' - - -
- -

'.$this->l('Uncheck this checkbox only if your server timed out and you need to resume the regeneration.').'

-
-
-
-
-
'; + $this->context->smarty->assign(array( + 'types' => $types, + 'formats' => $formats, + )); } /** @@ -526,41 +495,14 @@ class AdminImagesController extends AdminController } /** - * Display the block for moving images + * Init display for move images block */ - public function displayMoveImages() + public function initMoveImages() { - $safe_mode = ini_get('safe_mode'); - - $this->content .= ' -

'.$this->l('Move images').'

'. - $this->l('A new storage system for product images is now used by PrestaShop. It offers better performance if your shop has a very large number of products.').'
'. - '
'; - if (file_exists(_PS_PROD_IMG_DIR_.'duplicates/')) - { - $this->content .= '
'; - $this->displayWarning($this->l('Duplicate images were found when moving the product images. It is probably caused by unused demonstration images. Please make sure that the folder '). - _PS_PROD_IMG_DIR_.'duplicates/'. - $this->l(' only contains demonstration images then delete this folder.')); - $this->content .= '
'; - } - if($safe_mode) - $this->displayWarning($this->l('PrestaShop has detected that your server configuration is not compatible with the new storage system (directive "safe_mode" is activated). You should continue to use the actual system.')); - else - $this->content .= ' -
-
- '.$this->l('Move images').'
'. - $this->l('You can choose to keep your images stored in the previous system - nothing wrong with that.').'
'. - $this->l('You can also decide to move your images to the new storage system: in this case, click on the "Move images" button below. Please be patient, as this can take several minutes.'). - '

 '. - $this->l('After moving all of your product images, for best performance go to the '). - ''.$this->l('product preferences tab').''. - $this->l(' and set "Use the legacy image filesystem" to NO.').' -
-
-
-
'; + $this->context->smarty->assign(array( + 'safe_mode' => ini_get('safe_mode'), + 'link_ppreferences' => 'index.php?tab=AdminPPreferences&token='.Tools::getAdminTokenLite('AdminPPreferences').'#PS_LEGACY_IMAGES_on', + )); } /** @@ -592,15 +534,19 @@ class AdminImagesController extends AdminController if ($this->display == 'list') { - $this->context->smarty->assign('list', true); $helper = new HelperOptions(); $helper->id = $this->id; $helper->currentIndex = self::$currentIndex; $this->content .= $helper->generateOptions($this->form_list['options_image_pref']); - $this->displayRegenerate(); - $this->displayMoveImages(); + $this->initRegenerate(); + $this->initMoveImages(); + + $this->context->smarty->assign(array( + 'display_regenerate' => true, + 'display_move' => true + )); } if ($this->display == 'edit')