diff --git a/admin-dev/tabs/AdminGenders.php b/admin-dev/tabs/AdminGenders.php index c1faeca23..3564b03a0 100644 --- a/admin-dev/tabs/AdminGenders.php +++ b/admin-dev/tabs/AdminGenders.php @@ -34,6 +34,8 @@ class AdminGenders extends AdminTab $this->lang = true; $this->edit = true; $this->delete = true; + $this->defaultImageHeight = 16; + $this->defaultImageWidth = 16; $this->fieldImageSettings = array('name' => 'image', 'dir' => 'genders'); $this->fieldsDisplay = array( @@ -95,11 +97,22 @@ class AdminGenders extends AdminTab echo '
'; - echo ' '; + echo ' '; if ($obj->getImage()) echo ''; echo '
-
'; +
+ +
+ +

'.$this->l('Image width in pixel. "0" to use original size').'

+
+
+ +
+ +

'.$this->l('Image height in pixel. "0" to use original size').'

+
'; echo '
@@ -108,4 +121,28 @@ class AdminGenders extends AdminTab
'; } + + protected function postImage($id) + { + if (isset($this->fieldImageSettings['name']) AND isset($this->fieldImageSettings['dir'])) + { + if(!Validate::isInt(Tools::getValue('img_width')) || !Validate::isInt(Tools::getValue('img_height'))) + $this->_errors[] = Tools::displayError('Width and height must be a numeric'); + else + { + if ((int)Tools::getValue('img_width') > 0 && (int)Tools::getValue('img_height') > 0) + { + $width = (int)Tools::getValue('img_width'); + $height = (int)Tools::getValue('img_height'); + } + else + { + $width = NULL; + $height = NULL; + } + return $this->uploadImage($id, $this->fieldImageSettings['name'], $this->fieldImageSettings['dir'].'/', false, $width, $height); + } + } + return !sizeof($this->_errors) ? true : false; + } } diff --git a/classes/AdminTab.php b/classes/AdminTab.php index 675acc9aa..071d62531 100644 --- a/classes/AdminTab.php +++ b/classes/AdminTab.php @@ -1037,7 +1037,7 @@ abstract class AdminTabCore return true; } - protected function uploadImage($id, $name, $dir, $ext = false) + protected function uploadImage($id, $name, $dir, $ext = false, $width = NULL, $height = NULL) { if (isset($_FILES[$name]['tmp_name']) AND !empty($_FILES[$name]['tmp_name'])) { @@ -1058,7 +1058,7 @@ abstract class AdminTabCore { $_FILES[$name]['tmp_name'] = $tmpName; // Copy new image - if (!imageResize($tmpName, _PS_IMG_DIR_.$dir.$id.'.'.$this->imageType, NULL, NULL, ($ext ? $ext : $this->imageType))) + if (!imageResize($tmpName, _PS_IMG_DIR_.$dir.$id.'.'.$this->imageType, (int)$width, (int)$height, ($ext ? $ext : $this->imageType))) $this->_errors[] = Tools::displayError('An error occurred while uploading image.'); if (sizeof($this->_errors)) return false; diff --git a/translations/fr/admin.php b/translations/fr/admin.php index bc0e50159..52c2c7c84 100644 --- a/translations/fr/admin.php +++ b/translations/fr/admin.php @@ -946,12 +946,17 @@ $_LANGADM['AdminGenders49ee3087348e8d44e1feda1917443987'] = 'Nom'; $_LANGADM['AdminGendersa1fa27779242b4902f7ae3bdd5c6d508'] = 'Type'; $_LANGADM['AdminGenders63889cfb9d3cbe05d1bd2be5cc9953fd'] = 'Homme'; $_LANGADM['AdminGendersb719ce180ec7bd9641fece2f920f4817'] = 'Femme'; +$_LANGADM['AdminGenderse9bb5320b3890b6747c91b5a71ae5a01'] = 'Neutre'; $_LANGADM['AdminGendersbe53a0541a6d36f6ecb879fa2c584b08'] = 'Image'; $_LANGADM['AdminGenders019ec3132cdf8ee0f2e2a75cf5d3e459'] = 'Sexe'; $_LANGADM['AdminGenders4e140ba723a03baa6948340bf90e2ef6'] = 'Nom:'; -$_LANGADM['AdminGenders6252c0f2c2ed83b7b06dfca86d4650bb'] = 'Caractères invalides:'; -$_LANGADM['AdminGenderse659b52eba1f0299b2d8ca3483919e72'] = 'Type:'; -$_LANGADM['AdminGenders461900b74731e07320ca79366df3e809'] = 'Image:'; +$_LANGADM['AdminGenders6252c0f2c2ed83b7b06dfca86d4650bb'] = 'Caractères invalides :'; +$_LANGADM['AdminGenderse659b52eba1f0299b2d8ca3483919e72'] = 'Type :'; +$_LANGADM['AdminGenders461900b74731e07320ca79366df3e809'] = 'Image :'; +$_LANGADM['AdminGenders5db76c4f753ae0875becc0aacea74b85'] = 'Largeur de l\'image:'; +$_LANGADM['AdminGenders3278973f0260849b8b58597a7aed17be'] = 'Largeur de l\'image en pixel. \"0\" pour utiliser la taille originale'; +$_LANGADM['AdminGenders7ff8263c405723baa07f9f747db48f99'] = 'Hauteur de l\'image :'; +$_LANGADM['AdminGenders8131c4756e4219c8d4b816222f07a6a1'] = 'Hauteur de l\'image en pixel. \"0\" pour utiliser la taille originale'; $_LANGADM['AdminGenders38fb7d24e0d60a048f540ecb18e13376'] = 'Enregistrer'; $_LANGADM['AdminGenders19f823c6453c2b1ffd09cb715214813d'] = 'Champ obligatoire'; $_LANGADM['AdminGeneratorad11acdc8759d7a20ca3b868a8db30ae'] = 'Génération du fichier Htaccess';