[*] BO : Gender - Allow image resizing
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@8736 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -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 '<label>'.$this->l('Image:').' </label>
|
||||
<div class="margin-form">';
|
||||
echo ' <input type="file" name="image" /> ';
|
||||
echo ' <input type="file" name="image" />';
|
||||
if ($obj->getImage())
|
||||
echo '<img src="'.$obj->getImage().'" />';
|
||||
echo '</div>
|
||||
<div class="clear"></div>';
|
||||
<div class="clear"></div>
|
||||
<label>'.$this->l('Image Width:').' </label>
|
||||
<div class="margin-form">
|
||||
<input size="4" type="text" name="img_width" value="'.$this->defaultImageWidth.'" />
|
||||
<p>'.$this->l('Image width in pixel. "0" to use original size').'</p>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
<label>'.$this->l('Image Height:').' </label>
|
||||
<div class="margin-form">
|
||||
<input size="4" type="text" name="img_height" value="'.$this->defaultImageHeight.'" />
|
||||
<p>'.$this->l('Image height in pixel. "0" to use original size').'</p>
|
||||
</div>';
|
||||
|
||||
echo '<div class="margin-form">
|
||||
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
|
||||
@@ -108,4 +121,28 @@ class AdminGenders extends AdminTab
|
||||
</fieldset>
|
||||
</form><br />';
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user