[*] BO & FO : Add image in the description of product (CC008)
This commit is contained in:
@@ -2804,6 +2804,110 @@ class AdminProducts extends AdminTab
|
||||
echo '<p class="clear"></p>
|
||||
</td>
|
||||
</tr>';
|
||||
$images = Image::getImages($this->context->language->id, $obj->id);
|
||||
if($images)
|
||||
{
|
||||
echo '
|
||||
<tr>
|
||||
<td class="col-left"></td>
|
||||
<td style="padding-bottom:5px;">
|
||||
<div style="display:block;width:620px;" class="hint clear">
|
||||
'.$this->l('You want an image associated with the product in your description ?').'
|
||||
<span class="addImageDescription" style="cursor:pointer">'.$this->l('Click here').'</span>.
|
||||
<table id="createImageDescription" style="display:none;">
|
||||
<tr>
|
||||
<td colspan="2" height="10"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-left">'.$this->l('Select your image:').'</td>
|
||||
<td style="padding-bottom:5px;">
|
||||
<ul>';
|
||||
foreach($images as $key => $image)
|
||||
{
|
||||
$checked = ($key == 0) ? 'checked' : '';
|
||||
echo '
|
||||
<li>
|
||||
<input type="radio" name="smallImage" id="smallImage_'.$key.'" value="'.$image['id_image'].'" '.$checked.'>';
|
||||
$urlImage = $this->context->link->getImageLink($obj->link_rewrite[$this->context->language->id], $obj->id.'-'.$image['id_image'], 'small');
|
||||
echo '
|
||||
<label for="smallImage_'.$key.'" class="t"><img src="'.$urlImage.'" alt="'.$image['legend'].'" /></label>
|
||||
</li>';
|
||||
}
|
||||
echo '
|
||||
</ul>
|
||||
<p class="clear"></p>
|
||||
</td>
|
||||
</tr>';
|
||||
echo '
|
||||
<tr>
|
||||
<td class="col-left">'.$this->l('Where to place ?').'</td>
|
||||
<td style="padding-bottom:5px;">
|
||||
<input type="radio" name="leftRight" id="leftRight_1" value="left" checked>
|
||||
<label for="leftRight_1" class="t">'.$this->l('left').'</label>
|
||||
<br />
|
||||
<input type="radio" name="leftRight" id="leftRight_2" value="right">
|
||||
<label for="leftRight_2" class="t">'.$this->l('right').'</label>
|
||||
<p class="clear"></p>
|
||||
</td>
|
||||
</tr>';
|
||||
echo '
|
||||
<tr>
|
||||
<td class="col-left">'.$this->l('Select the type of picture:').'</td>
|
||||
<td style="padding-bottom:5px;">';
|
||||
$imageTypes = ImageType::getImagesTypes('products');
|
||||
foreach($imageTypes as $key => $type)
|
||||
{
|
||||
$checked = ($key == 0) ? 'checked' : '';
|
||||
echo '
|
||||
<input type="radio" name="imageTypes" id="imageTypes_'.$key.'" value="'.$type['name'].'" '.$checked.'>
|
||||
<label for="imageTypes_'.$key.'" class="t">'.$type['name'].' <span>('.$type['width'].'px par '.$type['height'].'px)</span></label>
|
||||
<br />';
|
||||
}
|
||||
echo '
|
||||
<p class="clear"></p>
|
||||
</td>
|
||||
</tr>';
|
||||
echo '
|
||||
<tr>
|
||||
<td class="col-left">'.$this->l('Tag of the image to insert:').'</td>
|
||||
<td style="padding-bottom:5px;">
|
||||
<input type="text" id="resultImage" name="resultImage" />
|
||||
<p>'.$this->l('The tag is to copy / paste in the description.').'</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<p class="clear"></p>
|
||||
</td>
|
||||
</tr>';
|
||||
echo '
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
changeTagImage();
|
||||
$("#createImageDescription input").change(function(){
|
||||
changeTagImage();
|
||||
});
|
||||
|
||||
var i = 0;
|
||||
$(".addImageDescription").click(function(){
|
||||
if(i == 0){
|
||||
$("#createImageDescription").animate({opacity: 1, height: "toggle"}, 500);
|
||||
i = 1;
|
||||
}else{
|
||||
$("#createImageDescription").animate({opacity: 0, height: "toggle"}, 500);
|
||||
i = 0;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function changeTagImage(){
|
||||
var smallImage = $("input[name=smallImage]:checked").attr("value");
|
||||
var leftRight = $("input[name=leftRight]:checked").attr("value");
|
||||
var imageTypes = $("input[name=imageTypes]:checked").attr("value");
|
||||
$("#resultImage").val("{img-"+smallImage+"-"+leftRight+"-"+imageTypes+"}");
|
||||
}
|
||||
</script>';
|
||||
}
|
||||
echo '
|
||||
<tr>
|
||||
<td class="col-left">'.$this->l('Tags:').'</td>
|
||||
|
||||
Vendored
+2
@@ -92,6 +92,8 @@
|
||||
'FeatureValue' => 'override/classes/FeatureValue.php',
|
||||
'FileLoggerCore' => 'classes/FileLogger.php',
|
||||
'FileLogger' => 'override/classes/FileLogger.php',
|
||||
'FileUploaderCore' => 'classes/FileUploader.php',
|
||||
'FileUploader' => '',
|
||||
'FrontControllerCore' => 'classes/FrontController.php',
|
||||
'FrontController' => 'override/classes/FrontController.php',
|
||||
'GroupCore' => 'classes/Group.php',
|
||||
|
||||
@@ -346,6 +346,8 @@ class ProductControllerCore extends FrontController
|
||||
// Pack management
|
||||
$this->context->smarty->assign('packItems', $this->product->cache_is_pack ? Pack::getItemTable($this->product->id, $this->context->language->id, true) : array());
|
||||
$this->context->smarty->assign('packs', Pack::getPacksTable($this->product->id, $this->context->language->id, true, 1));
|
||||
|
||||
$this->product->description = $this->transformDescriptionWithImg($this->product->description);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -372,6 +374,19 @@ class ProductControllerCore extends FrontController
|
||||
parent::displayContent();
|
||||
$this->context->smarty->display(_PS_THEME_DIR_.'product.tpl');
|
||||
}
|
||||
|
||||
public function transformDescriptionWithImg($desc)
|
||||
{
|
||||
$reg = '/{img-([0-9]+)-(left|right)-([a-z]+)}/';
|
||||
while (preg_match($reg, $desc, $matches))
|
||||
{
|
||||
$linkImg = $this->context->link->getImageLink($this->product->link_rewrite, $this->product->id.'-'.$matches[1], $matches[3]);
|
||||
$class = $matches[2] == 'left' ? 'class="imageFloatLeft"' : 'class="imageFloatRight"';
|
||||
$htmlImg = '<img src="'.$linkImg.'" alt="" '.$class.'/>';
|
||||
$desc = str_replace($matches[0], $htmlImg, $desc);
|
||||
}
|
||||
return $desc;
|
||||
}
|
||||
|
||||
public function pictureUpload(Product $product, Cart $cart)
|
||||
{
|
||||
|
||||
@@ -1700,4 +1700,12 @@ div.progressBarImage
|
||||
#progressBarImage div.ui-progressbar-value
|
||||
{
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
#createImageDescription ul li{
|
||||
list-style-type: none;
|
||||
display: block;
|
||||
width: 50px;
|
||||
text-align: center;
|
||||
float: left;
|
||||
}
|
||||
@@ -157,3 +157,19 @@
|
||||
{
|
||||
margin-top: 5px
|
||||
}
|
||||
|
||||
#more_info_block .imageFloatLeft
|
||||
{
|
||||
float:left;
|
||||
display:block;
|
||||
clear: both;
|
||||
margin:10px 10px 0 0
|
||||
}
|
||||
|
||||
#more_info_block .imageFloatRight
|
||||
{
|
||||
float:right;
|
||||
display:block;
|
||||
clear: both;
|
||||
margin:10px 0 0 10px
|
||||
}
|
||||
|
||||
@@ -2210,6 +2210,7 @@ $_LANGADM['AdminProducts3e565755572fa5df48eb811c62619098'] = 'Message quand en s
|
||||
$_LANGADM['AdminProducts3e053943605d9e4bf7dd7588ea19e9d2'] = 'Caractères interdits :';
|
||||
$_LANGADM['AdminProducts627b9f5acc2dcec1e8e341dd09df9768'] = 'Message lorsque hors-stock mais commandable :';
|
||||
$_LANGADM['AdminProducts915f8462b0f5459dcca1d52b0a2297d5'] = 'Date de disponibilité :';
|
||||
$_LANGADM['AdminProducts4b5ecb6f4e1496fb2c2b28fa0f41872a'] = 'La date de disponibilité du produit lorsqu\'il n\'est plus en stock';
|
||||
$_LANGADM['AdminProducts24a1199bf4dcbef398db7660409a61d9'] = 'Si rupture de stock :';
|
||||
$_LANGADM['AdminProductsf072da215c080d985d44361e96a3cf60'] = 'Refuser les commandes';
|
||||
$_LANGADM['AdminProducts119a7c88cf8f1c685c57981abff26f43'] = 'Accepter les commandes';
|
||||
@@ -2240,6 +2241,15 @@ $_LANGADM['AdminProducts92ab5edf4194cb5a84d6808cb8d8b696'] = 'Le lien vers la fi
|
||||
$_LANGADM['AdminProducts234078adec0a64008b6ae77653776cfa'] = 'Résumé :';
|
||||
$_LANGADM['AdminProducts38d301f7ef549a79620e99fd8b51fa34'] = 'apparaît dans les listings produits et au haut des fiches produits';
|
||||
$_LANGADM['AdminProducts9be976b8052c984a95997e4a4f8eef96'] = 'apparaît sur les pages produits';
|
||||
$_LANGADM['AdminProductsab9a907ec2b0b624d4506713ab5507df'] = 'Vous souhaitez mettre une image associé à ce produit dans votre description ?';
|
||||
$_LANGADM['AdminProducts936ccdb97115e9f35a11d35e3d5b5cad'] = 'Cliquez ici';
|
||||
$_LANGADM['AdminProducts8300b58d12ed9de055d7a727c72ef55a'] = 'Sélectionner votre image :';
|
||||
$_LANGADM['AdminProductscba45f08ce11e3ed5624f853e3cb6f08'] = 'Où la placer ?';
|
||||
$_LANGADM['AdminProducts811882fecd5c7618d7099ebbd39ea254'] = 'Gauche';
|
||||
$_LANGADM['AdminProducts7c4f29407893c334a6cb7a87bf045c0d'] = 'Droite';
|
||||
$_LANGADM['AdminProducts03e895d6310cdab805586fce4123ed08'] = 'Sélectionner le type d\'image :';
|
||||
$_LANGADM['AdminProductsd5b6a6e5d16e7061897360b9ef925b28'] = 'Code à insérer dans la description :';
|
||||
$_LANGADM['AdminProducts29e6c2eef6a0b578f4c0395c1b8f5b88'] = 'Ce code est à copier/coller dans la description.';
|
||||
$_LANGADM['AdminProducts32b502f33a535f75dcbf63f6753c631e'] = 'Tags :';
|
||||
$_LANGADM['AdminProducts8fca858b27c5837dcb22c398aca5e0fc'] = 'Tags séparés par des virgules (ex : dvd, lecteur dvd, hifi)';
|
||||
$_LANGADM['AdminProductsbe26ade2055790d0e8d19eed69309574'] = 'Accessoires :';
|
||||
@@ -2278,7 +2288,6 @@ $_LANGADM['AdminProductsad802655c2e83ad378868d5f448677c7'] = 'Impact sur le prix
|
||||
$_LANGADM['AdminProducts487fd4fe388baed0928898b641050983'] = 'Eco-participation :';
|
||||
$_LANGADM['AdminProductsf445f4a540768234833908cab83f9214'] = 'écrase l\'information d\'éco-participation du produit';
|
||||
$_LANGADM['AdminProducts24bf9597daf212b5cfab26ca381e7008'] = 'Mouvement de stock :';
|
||||
$_LANGADM['AdminProducts4b5ecb6f4e1496fb2c2b28fa0f41872a'] = 'La date de disponibilité du produit lorsqu\'il n\'est plus en stock';
|
||||
$_LANGADM['AdminProducts461900b74731e07320ca79366df3e809'] = 'Image :';
|
||||
$_LANGADM['AdminProducts29d7b46b863639e29ae8452d2320530a'] = 'Faire de cette déclinaison celle par défaut pour ce produit';
|
||||
$_LANGADM['AdminProductsadbabbab7becdf5ef8736a64466df260'] = 'Ajouter cette déclinaison';
|
||||
|
||||
Reference in New Issue
Block a user