// ImageType is now applied to a them
This commit is contained in:
@@ -154,7 +154,9 @@ class qqUploadedFileXhr
|
||||
{
|
||||
$imagesTypes = ImageType::getImagesTypes('products');
|
||||
foreach ($imagesTypes AS $k => $imageType)
|
||||
if (!imageResize($tmpName, $new_path.'-'.stripslashes($imageType['name']).'.'.$image->image_format, $imageType['width'], $imageType['height'], $image->image_format))
|
||||
{
|
||||
$theme = (Shop::isFeatureActive() ? '-'.$imageType['id_theme'] : '');
|
||||
if (!imageResize($tmpName, $new_path.'-'.stripslashes($imageType['name']).$theme.'.'.$image->image_format, $imageType['width'], $imageType['height'], $image->image_format))
|
||||
return array('error' => Tools::displayError('An error occurred while copying image:').' '.stripslashes($imageType['name']));
|
||||
}
|
||||
unlink($tmpName);
|
||||
|
||||
+8
-5
@@ -238,12 +238,13 @@ class ImageCore extends ObjectModel
|
||||
$new_path = $image_new->getPathForCreation();
|
||||
foreach ($images_types as $image_type)
|
||||
{
|
||||
if (file_exists(_PS_PROD_IMG_DIR_.$image_old->getExistingImgPath().'-'.$image_type['name'].'.jpg'))
|
||||
$theme = (Shop::isFeatureActive() ? '-'.$image_type['id_theme'] : '');
|
||||
if (file_exists(_PS_PROD_IMG_DIR_.$image_old->getExistingImgPath().'-'.$image_type['name'].$theme.'.jpg'))
|
||||
{
|
||||
if (!Configuration::get('PS_LEGACY_IMAGES'))
|
||||
$image_new->createImgFolder();
|
||||
copy(_PS_PROD_IMG_DIR_.$image_old->getExistingImgPath().'-'.$image_type['name'].'.jpg',
|
||||
$new_path.'-'.$image_type['name'].'.jpg');
|
||||
copy(_PS_PROD_IMG_DIR_.$image_old->getExistingImgPath().'-'.$image_type['name'].$theme.'.jpg',
|
||||
$new_path.'-'.$image_type['name'].$theme.'.jpg');
|
||||
}
|
||||
}
|
||||
if (file_exists(_PS_PROD_IMG_DIR_.$image_old->getExistingImgPath().'.jpg'))
|
||||
@@ -401,8 +402,10 @@ class ImageCore extends ObjectModel
|
||||
// Delete auto-generated images
|
||||
$image_types = ImageType::getImagesTypes();
|
||||
foreach ($image_types as $image_type)
|
||||
$files_to_delete[] = $this->image_dir.$this->getExistingImgPath().'-'.$image_type['name'].'.'.$this->image_format;
|
||||
|
||||
{
|
||||
$theme = (Shop::isFeatureActive() ? '-'.$image_type['id_theme'] : '');
|
||||
$files_to_delete[] = $this->image_dir.$this->getExistingImgPath().'-'.$image_type['name'].$theme.'.'.$this->image_format;
|
||||
}
|
||||
// Delete watermark image
|
||||
$files_to_delete[] = $this->image_dir.$this->getExistingImgPath().'-watermark.'.$this->image_format;
|
||||
// delete index.php
|
||||
|
||||
+11
-6
@@ -29,6 +29,9 @@ class ImageTypeCore extends ObjectModel
|
||||
{
|
||||
public $id;
|
||||
|
||||
/** @var string id_theme */
|
||||
public $id_theme;
|
||||
|
||||
/** @var string Name */
|
||||
public $name;
|
||||
|
||||
@@ -63,6 +66,7 @@ class ImageTypeCore extends ObjectModel
|
||||
'table' => 'image_type',
|
||||
'primary' => 'id_image_type',
|
||||
'fields' => array(
|
||||
'id_theme' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
|
||||
'name' => array('type' => self::TYPE_STRING, 'validate' => 'isImageTypeName', 'required' => true, 'size' => 16),
|
||||
'width' => array('type' => self::TYPE_INT, 'validate' => 'isImageSize', 'required' => true),
|
||||
'height' => array('type' => self::TYPE_INT, 'validate' => 'isImageSize', 'required' => true),
|
||||
@@ -88,16 +92,17 @@ class ImageTypeCore extends ObjectModel
|
||||
* @param string|null Image type
|
||||
* @return array Image type definitions
|
||||
*/
|
||||
public static function getImagesTypes($type = NULL)
|
||||
public static function getImagesTypes($type = NULL, $id_theme = false)
|
||||
{
|
||||
if (!isset(self::$images_types_cache[$type]))
|
||||
if (!isset(self::$images_types_cache[$type.($id_theme ? '-'.$id_theme : '')]))
|
||||
{
|
||||
$where = 'WHERE 1';
|
||||
if ($id_theme)
|
||||
$where .= ' AND id_theme='.(int)$id_theme;
|
||||
if (!empty($type))
|
||||
$where = 'WHERE ' . pSQL($type) . ' = 1 ';
|
||||
else
|
||||
$where = '';
|
||||
$where .= ' AND ' . pSQL($type) . ' = 1 ';
|
||||
|
||||
$query = 'SELECT * FROM `'._DB_PREFIX_.'image_type`'.$where.'ORDER BY `name` ASC';
|
||||
$query = 'SELECT * FROM `'._DB_PREFIX_.'image_type`'.$where.' ORDER BY `name` ASC';
|
||||
self::$images_types_cache[$type] = Db::getInstance()->executeS($query);
|
||||
}
|
||||
|
||||
|
||||
+10
-6
@@ -306,12 +306,16 @@ class LinkCore
|
||||
public function getImageLink($name, $ids, $type = null)
|
||||
{
|
||||
// legacy mode or default image
|
||||
$theme = ((Shop::isFeatureActive() && file_exists(_PS_PROD_IMG_DIR_.$ids.($type ? '-'.$type : '').'-'.(int)Context::getContext()->shop->id_theme.'.jpg')) ? '-'.Context::getContext()->shop->id_theme : '');
|
||||
if ((Configuration::get('PS_LEGACY_IMAGES')
|
||||
&& (file_exists(_PS_PROD_IMG_DIR_.$ids.($type ? '-'.$type : '').'.jpg')))
|
||||
&& (file_exists(_PS_PROD_IMG_DIR_.$ids.($type ? '-'.$type : '').$theme.'.jpg')))
|
||||
|| strpos($ids, 'default') !== false)
|
||||
{
|
||||
if ($this->allow == 1)
|
||||
$uri_path = __PS_BASE_URI__.$ids.($type ? '-'.$type : '').'/'.$name.'.jpg';
|
||||
if ($this->allow == 1)
|
||||
$uri_path = __PS_BASE_URI__.$ids.($type ? '-'.$type : '').$theme.'/'.$name.'.jpg';
|
||||
else
|
||||
$uri_path = _THEME_PROD_DIR_.$ids.($type ? '-'.$type : '').$theme.'.jpg';
|
||||
}
|
||||
else
|
||||
$uri_path = _THEME_PROD_DIR_.$ids.($type ? '-'.$type : '').'.jpg';
|
||||
}else
|
||||
@@ -319,11 +323,11 @@ class LinkCore
|
||||
// if ids if of the form id_product-id_image, we want to extract the id_image part
|
||||
$split_ids = explode('-', $ids);
|
||||
$id_image = (isset($split_ids[1]) ? $split_ids[1] : $split_ids[0]);
|
||||
|
||||
$theme = ((Shop::isFeatureActive() && file_exists(_PS_PROD_IMG_DIR_.Image::getImgFolderStatic($id_image).$id_image.($type ? '-'.$type : '').'-'.(int)Context::getContext()->shop->id_theme.'.jpg')) ? '-'.Context::getContext()->shop->id_theme : '');
|
||||
if ($this->allow == 1)
|
||||
$uri_path = __PS_BASE_URI__.$id_image.($type ? '-'.$type : '').'/'.$name.'.jpg';
|
||||
$uri_path = __PS_BASE_URI__.$id_image.($type ? '-'.$type : '').$theme.'/'.$name.'.jpg';
|
||||
else
|
||||
$uri_path = _THEME_PROD_DIR_.Image::getImgFolderStatic($id_image).$id_image.($type ? '-'.$type : '').'.jpg';
|
||||
$uri_path = _THEME_PROD_DIR_.Image::getImgFolderStatic($id_image).$id_image.($type ? '-'.$type : '').$theme.'.jpg';
|
||||
}
|
||||
|
||||
return $this->protocol_content.Tools::getMediaServer($uri_path).$uri_path;
|
||||
|
||||
+5
-5
@@ -1566,8 +1566,8 @@ class ToolsCore
|
||||
fwrite($write_fd, "# Images\n");
|
||||
if (Configuration::get('PS_LEGACY_IMAGES'))
|
||||
{
|
||||
fwrite($write_fd, 'RewriteRule ^([a-z0-9]+)\-([a-z0-9]+)(\-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-\pL]*\.jpg$ '._PS_PROD_IMG_.'$1-$2$3.jpg [L]'."\n");
|
||||
fwrite($write_fd, 'RewriteRule ^([0-9]+)\-([0-9]+)/[_a-zA-Z0-9-\pL]*\.jpg$ '._PS_PROD_IMG_.'$1-$2.jpg [L]'."\n");
|
||||
fwrite($write_fd, 'RewriteRule (*UTF8)^([a-z0-9]+)\-([a-z0-9]+)(\-[_a-zA-Z0-9-]*)(-[0-9]+)?/[_a-zA-Z0-9-\pL]*\.jpg$ '._PS_PROD_IMG_.'$1-$2$3$4.jpg [L]'."\n");
|
||||
fwrite($write_fd, 'RewriteRule (*UTF8)^([0-9]+)\-([0-9]+)(-[0-9]+)?/[_a-zA-Z0-9-\pL]*\.jpg$ '._PS_PROD_IMG_.'$1-$2$3.jpg [L]'."\n");
|
||||
}
|
||||
|
||||
// Rewrite product images < 100 millions
|
||||
@@ -1580,10 +1580,10 @@ class ToolsCore
|
||||
$img_name .= '$'.$j;
|
||||
}
|
||||
$img_name .= '$'.$j;
|
||||
fwrite($write_fd, 'RewriteRule ^'.str_repeat('([0-9])', $i).'(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-\pL]*\.jpg$ '._PS_PROD_IMG_.$img_path.$img_name.".jpg [L]\n");
|
||||
fwrite($write_fd, 'RewriteRule (*UTF8)^'.str_repeat('([0-9])', $i).'(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/[_a-zA-Z0-9-\pL]*\.jpg$ '._PS_PROD_IMG_.$img_path.$img_name.'$'.($j+1).".jpg [L]\n");
|
||||
}
|
||||
fwrite($write_fd, 'RewriteRule ^c/([0-9]+)(\-[_a-zA-Z0-9-\pL]*)/[_a-zA-Z0-9-]*\.jpg$ img/c/$1$2.jpg [L]'."\n");
|
||||
fwrite($write_fd, 'RewriteRule ^c/([a-zA-Z-]+)/[a-zA-Z0-9-\pL]+\.jpg$ img/c/$1.jpg [L]'."\n");
|
||||
fwrite($write_fd, 'RewriteRule (*UTF8)^c/([0-9]+)(\-[_a-zA-Z0-9-\pL]*)(-[0-9]+)?/[_a-zA-Z0-9-]*\.jpg$ img/c/$1$2$3.jpg [L]'."\n");
|
||||
fwrite($write_fd, 'RewriteRule (*UTF8)^c/([a-zA-Z-]+)(-[0-9]+)?/[a-zA-Z0-9-\pL]+\.jpg$ img/c/$1$2.jpg [L]'."\n");
|
||||
}
|
||||
|
||||
// Redirections to dispatcher
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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']
|
||||
);
|
||||
@@ -189,7 +190,7 @@ class AdminScenesControllerCore extends AdminController
|
||||
.(Tools::getMaxUploadSize() / 1024).''.$this->l('KB max.').' '
|
||||
.$this->l('If larger than the image size setting, the image will be reduced to ')
|
||||
.' '.$large_scene_image_type['width'].'x'.$large_scene_image_type['height'].'px '
|
||||
.$this->l('(width x height). If smaller than the image-size setting, a white background will be added in order to achieve the
|
||||
.$this->l('(width x height). If smaller than the image-size setting, a white background will be added in order to achieve the
|
||||
correct image size.').'.<br />'.
|
||||
$this->l('Note: To change image dimensions, please change the \'large_scene\' image type settings to the desired size (in Back Office > Preferences > Images).');
|
||||
if ($obj->id && file_exists(_PS_SCENE_IMG_DIR_.$obj->id.'-large_scene.jpg'))
|
||||
@@ -203,7 +204,7 @@ class AdminScenesControllerCore extends AdminController
|
||||
$image_to_map_desc .= '
|
||||
<div id="ajax_choose_product" style="display:none; padding:6px; padding-top:2px; width:600px;">
|
||||
'.$this->l('Begin typing the first letters of the product name, then select the product from the drop-down list:').'
|
||||
<br /><input type="text" value="" id="product_autocomplete_input" />
|
||||
<br /><input type="text" value="" id="product_autocomplete_input" />
|
||||
<input type="button" class="button" value="'.$this->l('OK').'" onclick="$(this).prev().search();" />
|
||||
<input type="button" class="button" value="'.$this->l('Delete').'" onclick="undoEdit();" />
|
||||
</div>
|
||||
|
||||
@@ -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']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -867,6 +867,7 @@ CREATE TABLE `PREFIX_image_lang` (
|
||||
|
||||
CREATE TABLE `PREFIX_image_type` (
|
||||
`id_image_type` int(10) unsigned NOT NULL auto_increment,
|
||||
`id_theme` INT(11) unsigned NOT NULL,
|
||||
`name` varchar(16) NOT NULL,
|
||||
`width` int(10) unsigned NOT NULL,
|
||||
`height` int(10) unsigned NOT NULL,
|
||||
@@ -877,7 +878,7 @@ CREATE TABLE `PREFIX_image_type` (
|
||||
`scenes` tinyint(1) NOT NULL default '1',
|
||||
`stores` tinyint(1) NOT NULL default '1',
|
||||
PRIMARY KEY (`id_image_type`),
|
||||
KEY `image_type_name` (`name`)
|
||||
UNIQUE KEY `image_type_name` (`id_theme`, `name`)
|
||||
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `PREFIX_lang` (
|
||||
|
||||
@@ -339,11 +339,7 @@ INSERT INTO `PREFIX_configuration` (`id_configuration`, `name`, `value`, `date_a
|
||||
(162, 'PS_UNIDENTIFIED_GROUP', '1', NOW(), NOW()),
|
||||
(163, 'PS_GUEST_GROUP', '2', NOW(), NOW()),
|
||||
(164, 'PS_CUSTOMER_GROUP', '3', NOW(), NOW()),
|
||||
(165, 'PS_SMARTY_CONSOLE', 0, NOW(), NOW()),
|
||||
(166, 'PS_B2B_ENABLE', '0', NOW(), NOW()),
|
||||
(167, 'PS_INVOICE_MODEL', 'invoice', NOW(), NOW()),
|
||||
(168, 'PS_LIMIT_UPLOAD_IMAGE_VALUE', '2', NOW(), NOW()),
|
||||
(169, 'PS_LIMIT_UPLOAD_FILE_VALUE', '2', NOW(), NOW());
|
||||
(165, 'PS_SMARTY_CONSOLE', 0, NOW(), NOW());
|
||||
|
||||
INSERT INTO `PREFIX_configuration_lang` (`id_configuration`, `id_lang`, `value`, `date_upd`) VALUES
|
||||
(36, 1, 'IN', NOW()),(36, 2, 'FA', NOW()),(36, 3, 'CU', NOW()),(36, 4, 'FA', NOW()),(36, 5, 'FA', NOW()),
|
||||
@@ -908,15 +904,15 @@ INSERT INTO `PREFIX_currency` (`name`, `iso_code`, `iso_code_num`, `sign`, `blan
|
||||
('Singapour Dollar', 'SGD', '702', '$', 1, 1.77, 2, 0, 0), ('Baht', 'THB', '764', '฿', 1, 40.96, 2, 0, 0), ('Rand', 'ZAR', '710', 'R', 1, 9.38, 2, 0, 0);*/
|
||||
INSERT INTO `PREFIX_currency_shop` (`id_currency`, `id_shop`) VALUES (1,1), (2,1), (3,1);
|
||||
|
||||
INSERT INTO `PREFIX_image_type` (`id_image_type`, `name`, `width`, `height`, `products`, `categories`, `manufacturers`, `suppliers`, `scenes`, `stores`) VALUES
|
||||
(1, 'small', 45, 45, 1, 1, 1, 1, 0, 0),
|
||||
(2, 'medium', 58, 58, 1, 1, 1, 1, 0, 1),
|
||||
(3, 'large', 264, 264, 1, 1, 1, 1, 0, 0),
|
||||
(4, 'thickbox', 600, 600, 1, 0, 0, 0, 0, 0),
|
||||
(5, 'category', 500, 150, 0, 1, 0, 0, 0, 0),
|
||||
(6, 'home', 124, 124, 1, 0, 0, 0, 0, 0),
|
||||
(7, 'large_scene', 556, 200, 0, 0, 0, 0, 1, 0),
|
||||
(8, 'thumb_scene', 161, 58, 0, 0, 0, 0, 1, 0);
|
||||
INSERT INTO `PREFIX_image_type` (`id_image_type`, `id_theme`, `name`, `width`, `height`, `products`, `categories`, `manufacturers`, `suppliers`, `scenes`, `stores`) VALUES
|
||||
(1, 1, 'small', 45, 45, 1, 1, 1, 1, 0, 0),
|
||||
(2, 1, 'medium', 58, 58, 1, 1, 1, 1, 0, 1),
|
||||
(3, 1, 'large', 264, 264, 1, 1, 1, 1, 0, 0),
|
||||
(4, 1, 'thickbox', 600, 600, 1, 0, 0, 0, 0, 0),
|
||||
(5, 1, 'category', 500, 150, 0, 1, 0, 0, 0, 0),
|
||||
(6, 1, 'home', 124, 124, 1, 0, 0, 0, 0, 0),
|
||||
(7, 1, 'large_scene', 556, 200, 0, 0, 0, 0, 1, 0),
|
||||
(8, 1, 'thumb_scene', 161, 58, 0, 0, 0, 0, 1, 0);
|
||||
|
||||
INSERT INTO `PREFIX_contact_shop` (`id_contact`, `id_shop`) VALUES (1,1), (2,1);
|
||||
|
||||
|
||||
@@ -420,6 +420,10 @@ WHERE `class_name` = 'AdminAccounting';
|
||||
|
||||
ALTER TABLE `PREFIX_order_slip_detail` CHANGE `amount` `amount_tax_excl` DECIMAL( 10, 2 ) default NULL;
|
||||
ALTER TABLE `PREFIX_order_slip_detail` ADD COLUMN `amount_tax_incl` DECIMAL(10,2) default NULL AFTER `amount_tax_excl`;
|
||||
ALTER TABLE `PREFIX_image_type` DROP INDEX `name`;
|
||||
ALTER TABLE `PREFIX_image_type` ADD `id_theme` INT(11) NOT NULL AFTER `id_image_type`;
|
||||
ALTER TABLE `PREFIX_image_type` ADD UNIQUE (`id_theme` ,`name`);
|
||||
UPDATE `PREFIX_image_type` SET `id_theme`=1;
|
||||
|
||||
CREATE TABLE `PREFIX_webservice_account_shop` (
|
||||
`id_webservice_account` INT( 11 ) UNSIGNED NOT NULL,
|
||||
|
||||
@@ -392,30 +392,14 @@ class ThemeInstallator extends Module
|
||||
}
|
||||
}
|
||||
|
||||
private function updateImages()
|
||||
private function updateImages($id_theme)
|
||||
{
|
||||
foreach ($this->xml->images->image as $row)
|
||||
{
|
||||
$foo = Db::getInstance()->getRow('
|
||||
SELECT name FROM `'._DB_PREFIX_.'image_type` i
|
||||
WHERE i.name LIKE \''.pSQL($row['name']).'\'');
|
||||
if ((int)(Tools::getValue('imagesConfig')) == 1 AND $foo)
|
||||
continue ;
|
||||
if ($foo)
|
||||
Db::getInstance()->execute('
|
||||
UPDATE `'._DB_PREFIX_.'image_type` i
|
||||
SET `width` = '.(int)($row['width']).',
|
||||
`height` = '.(int)($row['height']).',
|
||||
`products` = '.($row['products'] == 'true' ? 1 : 0).',
|
||||
`categories` = '.($row['categories'] == 'true' ? 1 : 0).',
|
||||
`manufacturers` = '.($row['manufacturers'] == 'true' ? 1 : 0).',
|
||||
`suppliers` = '.($row['suppliers'] == 'true' ? 1 : 0).',
|
||||
`scenes` = '.($row['scenes'] == 'true' ? 1 : 0).'
|
||||
WHERE i.name LIKE \''.pSQL($row['name']).'\'');
|
||||
else
|
||||
Db::getInstance()->execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'image_type` (`name`, `width`, `height`, `products`, `categories`, `manufacturers`, `suppliers`, `scenes`)
|
||||
VALUES (
|
||||
|
||||
Db::getInstance()->execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'image_type` (`id_theme`, `name`, `width`, `height`, `products`, `categories`, `manufacturers`, `suppliers`, `scenes`)
|
||||
VALUES ('.(int)$id_theme.',
|
||||
\''.pSQL($row['name']).'\',
|
||||
'.(int)($row['width']).',
|
||||
'.(int)($row['height']).',
|
||||
@@ -540,12 +524,13 @@ class ThemeInstallator extends Module
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((int)(Tools::getValue('imagesConfig')) != 3 AND self::updateImages())
|
||||
$msg .= '<br /><b>'.$this->l('Images have been correctly updated in database').'</b><br />';
|
||||
|
||||
$theme = new Theme();
|
||||
$theme->name = (string)$this->xml['name'];
|
||||
$theme->add();
|
||||
|
||||
if ((int)(Tools::getValue('imagesConfig')) != 3 AND self::updateImages((int)$theme->id))
|
||||
$msg .= '<br /><b>'.$this->l('Images have been correctly updated in database').'</b><br />';
|
||||
|
||||
$this->_msg .= parent::displayConfirmation($msg);
|
||||
$this->_html .= '
|
||||
<input type="submit" class="button" name="submitThemes" value="'.$this->l('Previous').'" />
|
||||
|
||||
Reference in New Issue
Block a user