[*] Classes : images.inc.php functions are now all deprecated, use the new class ImageManager instead

This commit is contained in:
rMalie
2012-01-23 10:21:51 +00:00
parent 6f98c3b8f5
commit 84f4d0838c
32 changed files with 569 additions and 427 deletions
+6 -6
View File
@@ -369,7 +369,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 (!ImageManager::resize($dir.$image, $newDir.substr($image, 0, -4).'-'.stripslashes($imageType['name']).'.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,7 +385,7 @@ class AdminImagesControllerCore extends AdminController
foreach ($type AS $k => $imageType)
{
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 (!ImageManager::resize($dir.$imageObj->getExistingImgPath().'.jpg', $dir.$imageObj->getExistingImgPath().'-'.stripslashes($imageType['name']).'.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';
@@ -408,7 +408,7 @@ class AdminImagesControllerCore extends AdminController
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 (!ImageManager::resize($file, $dir.$language['iso_code'].'-default-'.stripslashes($imageType['name']).'.jpg', (int)$imageType['width'], (int)$imageType['height']))
$errors = true;
}
}
@@ -424,14 +424,14 @@ class AdminImagesControllerCore extends AdminController
LEFT JOIN `'._DB_PREFIX_.'hook` h ON hm.`id_hook` = h.`id_hook`
WHERE h.`name` = \'watermark\' AND m.`active` = 1');
if ($result AND sizeof($result))
if ($result && count($result))
{
$productsImages = Image::getAllImages();
foreach ($productsImages AS $k => $image)
foreach ($productsImages as $image)
{
$imageObj = new Image($image['id_image']);
if (file_exists($dir.$imageObj->getExistingImgPath().'.jpg'))
foreach ($result AS $k => $module)
foreach ($result as $module)
{
if ($moduleInstance = Module::getInstanceByName($module['name']) AND is_callable(array($moduleInstance, 'hookwatermark')))
call_user_func(array($moduleInstance, 'hookwatermark'), array('id_image' => $imageObj->id, 'id_product' => $imageObj->id_product));