[-] BO : delete id_theme in Image Type

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@12278 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
lLefevre
2012-01-09 16:04:34 +00:00
parent a9b4c401bb
commit b8f6ff16a6
10 changed files with 80 additions and 74 deletions
-4
View File
@@ -28,9 +28,6 @@
class ImageTypeCore extends ObjectModel
{
public $id;
/** @var string id_theme */
public $id_theme;
/** @var string Name */
public $name;
@@ -66,7 +63,6 @@ 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),
+2 -2
View File
@@ -1342,7 +1342,7 @@ abstract class ModuleCore
{
$output = '
<div class="module_error alert error">
<img src="'._PS_IMG_.'admin/warning.gif" alt="" title="" /> '.$error.'
'.$error.'
</div>';
$this->error = true;
return $output;
@@ -1352,7 +1352,7 @@ abstract class ModuleCore
{
$output = '
<div class="module_confirmation conf confirm">
<img src="'._PS_IMG_.'admin/ok.gif" alt="" title="" /> '.$string.'
'.$string.'
</div>';
return $output;
}
+3 -18
View File
@@ -76,17 +76,6 @@ class AdminImagesControllerCore extends AdminController
'required' => true,
'desc' => $this->l('Letters only (e.g., small, medium, large, extra-large)')
),
array(
'type' => 'select',
'label' => $this->l('Theme:'),
'name' => 'id_theme',
'required' => true,
'options' => array(
'query' => Theme::getThemes(),
'id' => 'id_theme',
'name' => 'name'
)
),
array(
'type' => 'text',
'label' => $this->l('Width:'),
@@ -373,8 +362,6 @@ 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')
@@ -382,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']).$theme.'.jpg', (int)($imageType['width']), (int)($imageType['height'])))
if (!imageResize($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';
@@ -397,9 +384,8 @@ 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']).$theme.'.jpg', (int)($imageType['width']), (int)($imageType['height'])))
if (!imageResize($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';
@@ -416,14 +402,13 @@ 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']).$theme.'.jpg', (int)($imageType['width']), (int)($imageType['height'])))
if (!imageResize($file, $dir.$language['iso_code'].'-default-'.stripslashes($imageType['name']).'.jpg', (int)($imageType['width']), (int)($imageType['height'])))
$errors = true;
}
}
+1 -2
View File
@@ -867,7 +867,6 @@ 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,
@@ -878,7 +877,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`),
UNIQUE KEY `image_type_name` (`id_theme`, `name`)
KEY `image_type_name` (`name`)
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
CREATE TABLE `PREFIX_lang` (
+9 -9
View File
@@ -907,15 +907,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`, `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_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_contact_shop` (`id_contact`, `id_shop`) VALUES (1,1), (2,1);
+2
View File
@@ -6,3 +6,5 @@ ALTER TABLE `PREFIX_order_state` ADD COLUMN `deleted` tinyint(1) UNSIGNED NOT NU
ALTER TABLE `PREFIX_category` ADD COLUMN `is_root_category` tinyint(1) NOT NULL default '0' AFTER `position`;
UPDATE `PREFIX_category` SET `is_root_category` = 1 WHERE `id_category` = 1;
ALTER TABLE `PREFIX_image_type` DROP `id_theme`;
+1 -2
View File
@@ -867,7 +867,6 @@ 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,
@@ -878,7 +877,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`),
UNIQUE KEY `image_type_name` (`id_theme`, `name`)
KEY `image_type_name` (`name`)
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
CREATE TABLE `PREFIX_lang` (
+8 -9
View File
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<entity_image_type>
<fields id="name" class="ImageType">
<field name="id_theme" relation="theme"/>
<field name="name"/>
<field name="width"/>
<field name="height"/>
@@ -13,13 +12,13 @@
<field name="stores"/>
</fields>
<entities>
<image_type id="small" id_theme="default" name="small" width="45" height="45" products="1" categories="1" manufacturers="1" suppliers="1" scenes="0" stores="0"/>
<image_type id="medium" id_theme="default" name="medium" width="58" height="58" products="1" categories="1" manufacturers="1" suppliers="1" scenes="0" stores="1"/>
<image_type id="large" id_theme="default" name="large" width="264" height="264" products="1" categories="1" manufacturers="1" suppliers="1" scenes="0" stores="0"/>
<image_type id="thickbox" id_theme="default" name="thickbox" width="600" height="600" products="1" categories="0" manufacturers="0" suppliers="0" scenes="0" stores="0"/>
<image_type id="category" id_theme="default" name="category" width="500" height="150" products="0" categories="1" manufacturers="0" suppliers="0" scenes="0" stores="0"/>
<image_type id="home" id_theme="default" name="home" width="124" height="124" products="1" categories="0" manufacturers="0" suppliers="0" scenes="0" stores="0"/>
<image_type id="large_scene" id_theme="default" name="large_scene" width="556" height="200" products="0" categories="0" manufacturers="0" suppliers="0" scenes="1" stores="0"/>
<image_type id="thumb_scene" id_theme="default" name="thumb_scene" width="161" height="58" products="0" categories="0" manufacturers="0" suppliers="0" scenes="1" stores="0"/>
<image_type id="small" name="small" width="45" height="45" products="1" categories="1" manufacturers="1" suppliers="1" scenes="0" stores="0"/>
<image_type id="medium" name="medium" width="58" height="58" products="1" categories="1" manufacturers="1" suppliers="1" scenes="0" stores="1"/>
<image_type id="large" name="large" width="264" height="264" products="1" categories="1" manufacturers="1" suppliers="1" scenes="0" stores="0"/>
<image_type id="thickbox" name="thickbox" width="600" height="600" products="1" categories="0" manufacturers="0" suppliers="0" scenes="0" stores="0"/>
<image_type id="category" name="category" width="500" height="150" products="0" categories="1" manufacturers="0" suppliers="0" scenes="0" stores="0"/>
<image_type id="home" name="home" width="124" height="124" products="1" categories="0" manufacturers="0" suppliers="0" scenes="0" stores="0"/>
<image_type id="large_scene" name="large_scene" width="556" height="200" products="0" categories="0" manufacturers="0" suppliers="0" scenes="1" stores="0"/>
<image_type id="thumb_scene" name="thumb_scene" width="161" height="58" products="0" categories="0" manufacturers="0" suppliers="0" scenes="1" stores="0"/>
</entities>
</entity_image_type>
+8 -4
View File
@@ -18,6 +18,11 @@ $_MODULE['<{themeinstallator}prestashop>themeinstallator_b857ef1f431c5f3290dc5b5
$_MODULE['<{themeinstallator}prestashop>themeinstallator_22c765d777eb4ca6b4292bcbb596872e'] = 'Les modules suivants ont été désactivés';
$_MODULE['<{themeinstallator}prestashop>themeinstallator_e501dc865768ac08d49c129a23c3ae09'] = 'Les modules suivants ont été activés';
$_MODULE['<{themeinstallator}prestashop>themeinstallator_0dfbf4744524c8573235d60589d8b66e'] = 'Les images ont bien été mises à jour dans la base de données';
$_MODULE['<{themeinstallator}prestashop>themeinstallator_a525cd013f76b049acb0320987c0d325'] = 'Attention : Copier / Coller vos erreurs si vous souhaitez définir manuellement ces images types (Dans l\'onglet Préférences > Images) :';
$_MODULE['<{themeinstallator}prestashop>themeinstallator_203c5dff06c7565ffd6713a914c62d16'] = 'Certain type d\'image nont pu être ajouté, car ils existent. Voici la liste :';
$_MODULE['<{themeinstallator}prestashop>themeinstallator_3b90370ac32dead2af37eabe3bdbb97f'] = 'Nom de l\'image type :';
$_MODULE['<{themeinstallator}prestashop>themeinstallator_48ccf48dcf2218a413ce473262f21a0c'] = 'Largeur :';
$_MODULE['<{themeinstallator}prestashop>themeinstallator_e933dc24fb245d863a43b4fefe9b45f5'] = 'Hauteur :';
$_MODULE['<{themeinstallator}prestashop>themeinstallator_dd1f775e443ff3b9a89270713580a51b'] = 'Précédent';
$_MODULE['<{themeinstallator}prestashop>themeinstallator_a20ddccbb6f808ec42cd66323e6c6061'] = 'Terminer';
$_MODULE['<{themeinstallator}prestashop>themeinstallator_33167fe8de7517798cf2e95c7680d6a4'] = 'Les thèmes suivants ont correctement été importés';
@@ -27,10 +32,6 @@ $_MODULE['<{themeinstallator}prestashop>themeinstallator_7651cc4a979c5e21ee50de9
$_MODULE['<{themeinstallator}prestashop>themeinstallator_8ab378b3ad05e14cbe61bff60c50afa6'] = 'Configuration actuelle';
$_MODULE['<{themeinstallator}prestashop>themeinstallator_f94545e00cff9d0395194458b2245702'] = 'Configuration du thème';
$_MODULE['<{themeinstallator}prestashop>themeinstallator_130c5b3473c57faa76e2a1c54e26f88e'] = 'Les deux';
$_MODULE['<{themeinstallator}prestashop>themeinstallator_c90ba3aaed0a2bafed18233111062cf0'] = 'Configuration des images du thème';
$_MODULE['<{themeinstallator}prestashop>themeinstallator_2a84d9915b12fcb0c1436709a77a8dd0'] = 'Ajouter la nouvelle configuration';
$_MODULE['<{themeinstallator}prestashop>themeinstallator_dd3acd810b479275ce68d69e78ed7a95'] = 'Tout ajouter (vous risquez de perdre votre configuration actuelle)';
$_MODULE['<{themeinstallator}prestashop>themeinstallator_332efbbfb2c4bd5a37fd7a55659b821a'] = 'Ne rien changer';
$_MODULE['<{themeinstallator}prestashop>themeinstallator_10ac3d04253ef7e1ddc73e6091c0cd55'] = 'Suivant';
$_MODULE['<{themeinstallator}prestashop>themeinstallator_5138a89d1b730dacf446855e15c24496'] = 'Vous êtes sur le point d\'installer les thèmes suivants';
$_MODULE['<{themeinstallator}prestashop>themeinstallator_f364da141450380ae79d7a45528f4c06'] = 'Ce thème est pour Prestashop';
@@ -40,7 +41,10 @@ $_MODULE['<{themeinstallator}prestashop>themeinstallator_caeedb303068f9915e8e5ce
$_MODULE['<{themeinstallator}prestashop>themeinstallator_2dd99d7426b4fe6dd04d7a98f5e32a62'] = 'Choisissez la déclinaison que vous souhaitez importer';
$_MODULE['<{themeinstallator}prestashop>themeinstallator_f956917da1716add289f33a8869b85d4'] = 'Thème principal';
$_MODULE['<{themeinstallator}prestashop>themeinstallator_1e3de51d693cd0c7e903bcf3769a0cdb'] = 'Décochez ce champs si vous ne souhaitez pas installer le thème principal';
$_MODULE['<{themeinstallator}prestashop>themeinstallator_d0594793a76c7e694f6bf7d4fea06a99'] = 'Nom du thème';
$_MODULE['<{themeinstallator}prestashop>themeinstallator_0205578268437a2c18d438b434b6d4cf'] = 'Répertoire du thème';
$_MODULE['<{themeinstallator}prestashop>themeinstallator_c49fbf2b822fd14929fd1fd76cdb0c96'] = 'Sélectionnez les variations que vous souhaitez importer';
$_MODULE['<{themeinstallator}prestashop>themeinstallator_dc87369c7dd7d760c8076a4e1a3805d0'] = 'Sélectionner le thème à exporter';
$_MODULE['<{themeinstallator}prestashop>themeinstallator_d1baba351b02042982a133c4df5d4924'] = 'Exporter un thème';
$_MODULE['<{themeinstallator}prestashop>themeinstallator_5092965125a28a17f49ee460fbc1f62c'] = 'Selectionner un thème';
$_MODULE['<{themeinstallator}prestashop>themeinstallator_0557cae4cf5b379e665910d701210f69'] = 'Exporter ce thème';
+46 -24
View File
@@ -395,24 +395,40 @@ class ThemeInstallator extends Module
}
}
private function updateImages($id_theme)
private function updateImages()
{
$return = array();
foreach ($this->xml->images->image as $row)
{
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']).',
if ($result = (bool)Db::getInstance()->executes(sprintf('SELECT * FROM `'._DB_PREFIX_.'image_type` WHERE `name` = \'%s\' ', pSQL($row['name']))))
{
$return['error'][] = array(
'name' => $row['name'],
'width' => (int)$row['width'],
'height' => (int)$row['height']
);
}
else
{
Db::getInstance()->execute('
INSERT INTO `'._DB_PREFIX_.'image_type` (`name`, `width`, `height`, `products`, `categories`, `manufacturers`, `suppliers`, `scenes`)
VALUES (\''.pSQL($row['name']).'\',
'.(int)$row['width'].',
'.(int)$row['height'].',
'.($row['products'] == 'true' ? 1 : 0).',
'.($row['categories'] == 'true' ? 1 : 0).',
'.($row['manufacturers'] == 'true' ? 1 : 0).',
'.($row['suppliers'] == 'true' ? 1 : 0).',
'.($row['scenes'] == 'true' ? 1 : 0).')');
$return['ok'][] = array(
'name' => $row['name'],
'width' => (int)$row['width'],
'height' => (int)$row['height']
);
}
}
return true;
return $return;
}
private function _displayForm4()
@@ -527,13 +543,28 @@ class ThemeInstallator extends Module
}
}
}
// note : theme was previously created at this point.
// note : theme was previously created at this point.
// It is now created during displayForm3
// @todo : imageType generation should be handled in a better way
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);
$result = $this->updateImages();
if (!isset($result['error']))
$msg .= $this->l('Images have been correctly updated in database');
else
{
$errors = '<em><strong>'.$this->l('Warning: Copy/Paste your errors if you want to manually set the image type (in the tab Preferences > Images):').'</em></strong><br />';
$errors .= $this->l('Some kind of image could not be added because they exists. Here\'s the list:');
$errors .= '<ul>';
foreach ($result['error'] as $error)
$errors .= '<li style="color:#D8000C">'.$this->l('Name image type:').' <strong>'.$error['name'].'</strong> ('.$this->l('Width:').' '.$error['width'].'px, '.$this->l('Height:').' '.$error['height'].'px)</li>';
$errors .= '</ul>';
}
if (!empty($msg))
$this->_msg .= parent::displayConfirmation($msg);
if (isset($error))
$this->_msg .= parent::displayError($errors);
$this->_html .= '
<input type="submit" class="button" name="submitThemes" value="'.$this->l('Previous').'" />
<input type="submit" class="button" name="Finish" value="'.$this->l('Finish').'" />
@@ -612,15 +643,6 @@ class ThemeInstallator extends Module
</ul>
</fieldset>
<p>&nbsp;</p>';
$this->_html .= '
<fieldset>
<legend>'.$this->l('Theme images configuration').'</legend>
<ul class="margin-form" style="list-style:none">
<li><input type="radio" name="imagesConfig" value="1" id="imageconfig1" checked /> <label style="display:bock;float:none" for="imageconfig1">'.$this->l('Add new configuration').'</label>
<li><input type="radio" name="imagesConfig" value="2" id="imageconfig2" /> <label style="display:bock;float:none" for="imageconfig2">'.$this->l('Add all (you may lose your current config)').'</label>
<li><input type="radio" name="imagesConfig" value="3" id="imageconfig3" /> <label style="display:bock;float:none" for="imageconfig3">'.$this->l('Don\'t change anything').'</label>
</ul>
</fieldset>';
$this->_html .= '
<p class="clear">&nbsp;</p>
<input type="submit" class="button" name="prevThemes" value="'.$this->l('Previous').'" />