// ImageType is now applied to a them

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@11700 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
rGaillard
2011-12-22 21:48:40 +00:00
parent 5768a6c688
commit e8a3c10175
19 changed files with 1714 additions and 1717 deletions
@@ -425,11 +425,14 @@ class AdminCategoriesControllerCore extends AdminController
{
$images_types = ImageType::getImagesTypes('categories');
foreach ($images_types as $k => $image_type)
{
$theme = (Shop::isFeatureActive() ? '-'.$image_type['id_theme'] : '');
imageResize(
_PS_CAT_IMG_DIR_.$id_category.'.jpg',
_PS_CAT_IMG_DIR_.$id_category.'-'.stripslashes($image_type['name']).'.jpg',
_PS_CAT_IMG_DIR_.$id_category.'-'.stripslashes($image_type['name']).$theme.'.jpg',
(int)$image_type['width'], (int)$image_type['height']
);
}
}
return $ret;
}
+18 -4
View File
@@ -69,6 +69,13 @@ class AdminImagesControllerCore extends AdminController
'title' => $this->l('Images'),
'image' => '../img/admin/picture.gif'
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Theme:'),
'name' => 'theme',
),
'input' => array(
array(
'type' => 'text',
@@ -363,6 +370,8 @@ class AdminImagesControllerCore extends AdminController
if (preg_match('/^[0-9]*\.jpg$/', $image))
foreach ($type AS $k => $imageType)
{
$theme = (Shop::isFeatureActive() ? '-'.$imageType['id_theme'] : '');
// Customizable writing dir
$newDir = $dir;
if ($imageType['name'] == 'thumb_scene')
@@ -370,7 +379,7 @@ class AdminImagesControllerCore extends AdminController
if (!file_exists($newDir))
continue;
if (!file_exists($newDir.substr($image, 0, -4).'-'.stripslashes($imageType['name']).'.jpg'))
if (!imageResize($dir.$image, $newDir.substr($image, 0, -4).'-'.stripslashes($imageType['name']).'.jpg', (int)($imageType['width']), (int)($imageType['height'])))
if (!imageResize($dir.$image, $newDir.substr($image, 0, -4).'-'.stripslashes($imageType['name']).$theme.'.jpg', (int)($imageType['width']), (int)($imageType['height'])))
$errors = true;
if (time() - $this->start_time > $this->max_execution_time - 4) // stop 4 seconds before the tiemout, just enough time to process the end of the page on a slow server
return 'timeout';
@@ -385,14 +394,16 @@ class AdminImagesControllerCore extends AdminController
if (file_exists($dir.$imageObj->getExistingImgPath().'.jpg'))
foreach ($type AS $k => $imageType)
{
$theme = (Shop::isFeatureActive() ? '-'.$imageType['id_theme'] : '');
if (!file_exists($dir.$imageObj->getExistingImgPath().'-'.stripslashes($imageType['name']).'.jpg'))
if (!imageResize($dir.$imageObj->getExistingImgPath().'.jpg', $dir.$imageObj->getExistingImgPath().'-'.stripslashes($imageType['name']).'.jpg', (int)($imageType['width']), (int)($imageType['height'])))
if (!imageResize($dir.$imageObj->getExistingImgPath().'.jpg', $dir.$imageObj->getExistingImgPath().'-'.stripslashes($imageType['name']).$theme.'.jpg', (int)($imageType['width']), (int)($imageType['height'])))
$errors = true;
if (time() - $this->start_time > $this->max_execution_time - 4) // stop 4 seconds before the tiemout, just enough time to process the end of the page on a slow server
return 'timeout';
}
}
}
}
return $errors;
}
@@ -401,15 +412,18 @@ class AdminImagesControllerCore extends AdminController
{
$errors = false;
foreach ($type AS $k => $imageType)
{
$theme = (Shop::isFeatureActive() ? '-'.$imageType['id_theme'] : '');
foreach ($languages AS $language)
{
$file = $dir.$language['iso_code'].'.jpg';
if (!file_exists($file))
$file = _PS_PROD_IMG_DIR_.Language::getIsoById((int)(Configuration::get('PS_LANG_DEFAULT'))).'.jpg';
if (!file_exists($dir.$language['iso_code'].'-default-'.stripslashes($imageType['name']).'.jpg'))
if (!imageResize($file, $dir.$language['iso_code'].'-default-'.stripslashes($imageType['name']).'.jpg', (int)($imageType['width']), (int)($imageType['height'])))
if (!imageResize($file, $dir.$language['iso_code'].'-default-'.stripslashes($imageType['name']).$theme.'.jpg', (int)($imageType['width']), (int)($imageType['height'])))
$errors = true;
}
}
return $errors;
}
+4 -1
View File
@@ -700,7 +700,10 @@ class AdminImportControllerCore extends AdminController
imageResize($tmpfile, $path.'.jpg');
$images_types = ImageType::getImagesTypes($entity);
foreach ($images_types as $k => $image_type)
imageResize($tmpfile, $path.'-'.stripslashes($image_type['name']).'.jpg', $image_type['width'], $image_type['height']);
{
$theme = (Shop::isFeatureActive() ? '-'.$image_type['id_theme'] : '');
imageResize($tmpfile, $path.'-'.stripslashes($image_type['name']).$theme.'.jpg', $image_type['width'], $image_type['height']);
}
if (in_array($image_type['id_image_type'], $watermark_types))
Hook::exec('watermark', array('id_image' => $id_image, 'id_product' => $id_entity));
}
@@ -433,11 +433,12 @@ class AdminLanguagesControllerCore extends AdminController
$images_types = ImageType::getImagesTypes('products');
foreach ($images_types as $k => $image_type)
{
if (!imageResize($tmp_name, _PS_IMG_DIR_.'p/'.$language.'-default-'.stripslashes($image_type['name']).'.jpg', $image_type['width'], $image_type['height']))
$theme = (Shop::isFeatureActive() ? '-'.$image_type['id_theme'] : '');
if (!imageResize($tmp_name, _PS_IMG_DIR_.'p/'.$language.'-default-'.stripslashes($image_type['name']).$theme.'.jpg', $image_type['width'], $image_type['height']))
$this->_errors[] = Tools::displayError('An error occurred while resizing no-picture image to your product directory.');
if (!imageResize($tmp_name, _PS_IMG_DIR_.'c/'.$language.'-default-'.stripslashes($image_type['name']).'.jpg', $image_type['width'], $image_type['height']))
if (!imageResize($tmp_name, _PS_IMG_DIR_.'c/'.$language.'-default-'.stripslashes($image_type['name']).$theme.'.jpg', $image_type['width'], $image_type['height']))
$this->_errors[] = Tools::displayError('An error occurred while resizing no-picture image to your category directory.');
if (!imageResize($tmp_name, _PS_IMG_DIR_.'m/'.$language.'-default-'.stripslashes($image_type['name']).'.jpg', $image_type['width'], $image_type['height']))
if (!imageResize($tmp_name, _PS_IMG_DIR_.'m/'.$language.'-default-'.stripslashes($image_type['name']).$theme.'.jpg', $image_type['width'], $image_type['height']))
$this->_errors[] = Tools::displayError('An error occurred while resizing no-picture image to your manufacturer directory.');
}
}
@@ -683,12 +683,15 @@ class AdminManufacturersControllerCore extends AdminController
{
$images_types = ImageType::getImagesTypes('manufacturers');
foreach ($images_types as $k => $image_type)
{
$theme = (Shop::isFeatureActive() ? '-'.$image_type['id_theme'] : '');
imageResize(
_PS_MANU_IMG_DIR_.$id_manufacturer.'.jpg',
_PS_MANU_IMG_DIR_.$id_manufacturer.'-'.stripslashes($image_type['name']).'.jpg',
_PS_MANU_IMG_DIR_.$id_manufacturer.'-'.stripslashes($image_type['name']).$theme.'.jpg',
(int)$image_type['width'],
(int)$image_type['height']
);
}
}
}
}
@@ -1370,8 +1370,11 @@ class AdminProductsControllerCore extends AdminController
{
$imagesTypes = ImageType::getImagesTypes('products');
foreach ($imagesTypes as $k => $image_type)
if (!imageResize($tmpName, $new_path.'-'.stripslashes($image_type['name']).'.'.$image->image_format, $image_type['width'], $image_type['height'], $image->image_format))
{
$theme = (Shop::isFeatureActive() ? '-'.$image_type['id_theme'] : '');
if (!imageResize($tmpName, $new_path.'-'.stripslashes($image_type['name']).$theme.'.'.$image->image_format, $image_type['width'], $image_type['height'], $image->image_format))
$this->_errors[] = Tools::displayError('An error occurred while copying image:').' '.stripslashes($image_type['name']);
}
}
@unlink($tmpName);
+3 -2
View File
@@ -74,10 +74,11 @@ class AdminScenesControllerCore extends AdminController
$images_types = ImageType::getImagesTypes('scenes');
foreach ($images_types as $k => $image_type)
{
$theme = (Shop::isFeatureActive() ? '-'.$image_type['id_theme'] : '');
if ($image_type['name'] == 'large_scene' && isset($_FILES['image']))
imageResize(
$_FILES['image']['tmp_name'],
_PS_SCENE_IMG_DIR_.$obj->id.'-'.stripslashes($image_type['name']).'.jpg',
_PS_SCENE_IMG_DIR_.$obj->id.'-'.stripslashes($image_type['name']).$theme.'.jpg',
(int)$image_type['width'],
(int)$image_type['height']
);
@@ -89,7 +90,7 @@ class AdminScenesControllerCore extends AdminController
$tmp_name = $_FILES['image']['tmp_name'];
imageResize(
$tmp_name,
_PS_SCENE_THUMB_IMG_DIR_.$obj->id.'-'.stripslashes($image_type['name']).'.jpg',
_PS_SCENE_THUMB_IMG_DIR_.$obj->id.'-'.stripslashes($image_type['name']).$theme.'.jpg',
(int)$image_type['width'],
(int)$image_type['height']
);
+4 -1
View File
@@ -373,10 +373,13 @@ class AdminStoresControllerCore extends AdminController
{
$images_types = ImageType::getImagesTypes('stores');
foreach ($images_types as $k => $image_type)
{
$theme = (Shop::isFeatureActive() ? '-'.$image_type['id_theme'] : '');
imageResize(_PS_STORE_IMG_DIR_.$id_store.'.jpg',
_PS_STORE_IMG_DIR_.$id_store.'-'.stripslashes($image_type['name']).'.jpg',
_PS_STORE_IMG_DIR_.$id_store.'-'.stripslashes($image_type['name']).$theme.'.jpg',
(int)$image_type['width'], (int)$image_type['height']
);
}
}
return $ret;
}
@@ -306,7 +306,8 @@ class AdminSuppliersControllerCore extends AdminController
foreach ($images_types as $k => $image_type)
{
$file = _PS_SUPP_IMG_DIR_.$id_supplier.'.jpg';
imageResize($file, _PS_SUPP_IMG_DIR_.$id_supplier.'-'.stripslashes($image_type['name']).'.jpg', (int)$image_type['width'], (int)$image_type['height']);
$theme = (Shop::isFeatureActive() ? '-'.$image_type['id_theme'] : '');
imageResize($file, _PS_SUPP_IMG_DIR_.$id_supplier.'-'.stripslashes($image_type['name']).$theme.'.jpg', (int)$image_type['width'], (int)$image_type['height']);
}
}
}