From 0c511dead5e48fc74297ffe85d005c72ce481b72 Mon Sep 17 00:00:00 2001 From: gRoussac Date: Thu, 19 Sep 2013 16:28:19 +0200 Subject: [PATCH] [*] FIX #PSCFV-8106 do not regenerate thumbnails if not --- .../controllers/import/helpers/form/form.tpl | 235 +++++++----------- .../controllers/import/helpers/view/view.tpl | 103 ++++---- controllers/admin/AdminImportController.php | 29 ++- 3 files changed, 161 insertions(+), 206 deletions(-) diff --git a/admin-dev/themes/default/template/controllers/import/helpers/form/form.tpl b/admin-dev/themes/default/template/controllers/import/helpers/form/form.tpl index c1949da21..58a183cb8 100644 --- a/admin-dev/themes/default/template/controllers/import/helpers/form/form.tpl +++ b/admin-dev/themes/default/template/controllers/import/helpers/form/form.tpl @@ -1,81 +1,35 @@ {* * 2007-2013 PrestaShop -* +** * NOTICE OF LICENSE -* -* This source file is subject to the Academic Free License (AFL 3.0) +** +* This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: -* http://opensource.org/licenses/afl-3.0.php +* http://opensource.org/licenses/osl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. -* +** * DISCLAIMER -* +** * Do not edit or add to this file if you wish to upgrade PrestaShop to newer * versions in the future. If you wish to customize PrestaShop for your * needs please refer to http://www.prestashop.com for more information. -* +** * @author PrestaShop SA * @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA +** *} - {include file="toolbar.tpl" toolbar_btn=$toolbar_btn toolbar_scroll=$toolbar_scroll title=$title}
{block name="leadin"}{/block}
- {if $module_confirmation}
{l s='Your .CSV file has been sucessfully imported into your shop.'}
{/if} - - - -{** - * Upload fancybox - *}
 
@@ -97,19 +51,8 @@
-
 
- -{** - * Import fieldset - *} -
- +
{l s='Import '} @@ -117,7 +60,7 @@ {if count($files_to_import)} {/if} @@ -151,7 +94,6 @@ {/foreach} -
- +
- +
{l s='If you don\'t use this option, all ID\'s will be auto-incremented.'}
+ +
+ +
{if empty($files_to_import)}{l s='You must upload a file in order to proceed to the next step'}{/if} @@ -209,13 +155,10 @@ {/if}
-
- {l s='Available fields'} -
{$available_fields}
@@ -223,74 +166,88 @@


{l s='* Required field'}
-
-
 
- + \ No newline at end of file diff --git a/admin-dev/themes/default/template/controllers/import/helpers/view/view.tpl b/admin-dev/themes/default/template/controllers/import/helpers/view/view.tpl index 618d1a819..b35bd5e1f 100644 --- a/admin-dev/themes/default/template/controllers/import/helpers/view/view.tpl +++ b/admin-dev/themes/default/template/controllers/import/helpers/view/view.tpl @@ -22,20 +22,14 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA *} - {extends file="helpers/view/view.tpl"} - {block name="override_tpl"} -

{l s='View your data'}

- {l s='Save and load your configuration for importing files'} :

- - {l s='Save'}

+ {l s='Save and load your configuration for importing files'} :

+ + {l s='Save'}

{l s='lines'} + {if $fields_value.truncate} @@ -72,49 +63,8 @@ {if $fields_value.match_ref} {/if} - - - - + +
@@ -136,8 +86,45 @@
-
-{/block} + +{/block} \ No newline at end of file diff --git a/controllers/admin/AdminImportController.php b/controllers/admin/AdminImportController.php index 5a1136499..7f28c0a6d 100644 --- a/controllers/admin/AdminImportController.php +++ b/controllers/admin/AdminImportController.php @@ -471,14 +471,19 @@ class AdminImportControllerCore extends AdminController $entity_selected = $this->entities[$this->l(Tools::ucfirst(Tools::getValue('import_type')))]; $this->context->cookie->entity_selected = $entity_selected; } - elseif(isset($this->context->cookie->entity_selected)) + elseif (isset($this->context->cookie->entity_selected)) $entity_selected = (int)$this->context->cookie->entity_selected; + + $csv_selected = ''; + if (isset($this->context->cookie->csv_selected)) + $csv_selected = pSQL($this->context->cookie->csv_selected); $this->tpl_form_vars = array( 'module_confirmation' => (Tools::getValue('import')) && (isset($this->warnings) && !count($this->warnings)), 'path_import' => _PS_ADMIN_DIR_.'/import/', 'entities' => $this->entities, 'entity_selected' => $entity_selected, + 'csv_selected' => $csv_selected, 'files_to_import' => $files_to_import, 'languages' => Language::getLanguages(false), 'id_language' => $this->context->language->id, @@ -508,6 +513,8 @@ class AdminImportControllerCore extends AdminController if ($entity_selected = (int)Tools::getValue('entity')) $this->context->cookie->entity_selected = $entity_selected; + if ($csv_selected = Tools::getValue('csv')) + $this->context->cookie->csv_selected = $csv_selected; $this->tpl_view_vars = array( 'import_matchs' => Db::getInstance()->executeS('SELECT * FROM '._DB_PREFIX_.'import_match'), @@ -518,6 +525,7 @@ class AdminImportControllerCore extends AdminController 'iso_lang' => Tools::getValue('iso_lang'), 'truncate' => Tools::getValue('truncate'), 'forceIDs' => Tools::getValue('forceIDs'), + 'regenerate' => Tools::getValue('regenerate'), 'match_ref' => Tools::getValue('match_ref'), 'separator' => $this->separator, 'multiple_value_separator' => $this->multiple_value_separator @@ -807,7 +815,7 @@ class AdminImportControllerCore extends AdminController * @param string entity 'products' or 'categories' * @return void */ - protected static function copyImg($id_entity, $id_image = null, $url, $entity = 'products') + protected static function copyImg($id_entity, $id_image = null, $url, $entity = 'products', $regenerate = true) { $tmpfile = tempnam(_PS_TMP_IMG_DIR_, 'ps_import'); $watermark_types = explode(',', Configuration::get('WATERMARK_TYPES')); @@ -835,11 +843,14 @@ class AdminImportControllerCore extends AdminController { ImageManager::resize($tmpfile, $path.'.jpg'); $images_types = ImageType::getImagesTypes($entity); - foreach ($images_types as $image_type) - ImageManager::resize($tmpfile, $path.'-'.stripslashes($image_type['name']).'.jpg', $image_type['width'], $image_type['height']); - if (in_array($image_type['id_image_type'], $watermark_types)) - Hook::exec('actionWatermark', array('id_image' => $id_image, 'id_product' => $id_entity)); + if ($regenerate) + foreach ($images_types as $image_type) + { + ImageManager::resize($tmpfile, $path.'-'.stripslashes($image_type['name']).'.jpg', $image_type['width'], $image_type['height']); + if (in_array($image_type['id_image_type'], $watermark_types)) + Hook::exec('actionWatermark', array('id_image' => $id_image, 'id_product' => $id_entity)); + } } else { @@ -988,7 +999,7 @@ class AdminImportControllerCore extends AdminController } //copying images of categories if (isset($category->image) && !empty($category->image)) - if (!(AdminImportController::copyImg($category->id, null, $category->image, 'categories'))) + if (!(AdminImportController::copyImg($category->id, null, $category->image, 'categories', !Tools::getValue('regenerate')))) $this->warnings[] = $category->image.' '.Tools::displayError('cannot be copied.'); // If both failed, mysql error if (!$res) @@ -1450,7 +1461,7 @@ class AdminImportControllerCore extends AdminController { // associate image to selected shops $image->associateTo($shops); - if (!AdminImportController::copyImg($product->id, $image->id, $url)) + if (!AdminImportController::copyImg($product->id, $image->id, $url, 'products', !Tools::getValue('regenerate'))) { $image->delete(); $this->warnings[] = sprintf(Tools::displayError('Error copying image: %s'), $url); @@ -1576,7 +1587,7 @@ class AdminImportControllerCore extends AdminController if ($field_error === true && $lang_field_error === true && $image->add()) { $image->associateTo($id_shop_list); - if (!AdminImportController::copyImg($product->id, $image->id, $url)) + if (!AdminImportController::copyImg($product->id, $image->id, $url, 'products', !Tools::getValue('regenerate'))) { $this->warnings[] = sprintf(Tools::displayError('Error copying image: %s'), $url); $image->delete();