change to update img promo banner

This commit is contained in:
Marion Muszynski 2017-10-24 18:24:17 +02:00
parent f5f865dc54
commit 20ab1d75d9
3 changed files with 27 additions and 7 deletions

View File

@ -558,11 +558,20 @@ class HelperFormBootstrap{
</div>
</span>
</div>';
if(isset($p['url_to_check']) && !empty($p['url_to_check']) && file_exists($p['url_to_check'].$p['name_img'].'_'.$language['id_lang'].'.jpg')) {
$this->_html .='<p><a href="'.$p['url_imgs'].$p['name_img'].'_'.$language['id_lang'].'.jpg" onclick="window.open(this.href); return false;"><span class="anticon anticon-image"></span> Image '.$language['iso_code'].'</a>'.(isset($p['img_delete']) && $p['img_delete']!=''?' - <a href="'.$p['img_delete'].'&id_lang='.$language['id_lang'].'"><span class="anticon anticon-bin"></span></a>':'').'</p>';
}
if(isset($p['url_to_show']) && !empty($p['url_to_show']) && file_exists($p['url_to_show'].$p['name_img'].'_'.$language['id_lang'].'.jpg')) {
$this->_html .='<p><img src="'.$p['url_imgs'].$p['name_img'].'_'.$language['id_lang'].'.jpg" />'.(isset($p['img_delete']) && $p['img_delete']!=''?' - <a href="'.$p['img_delete'].'&id_lang='.$language['id_lang'].'"><span class="anticon anticon-bin"></span></a>':'').'</p>';
if(isset($p['name_img_lang'])) {
if(isset($p['url_to_check']) && !empty($p['url_to_check']) && file_exists($p['url_to_check'].$p['name_img_lang'][$language['id_lang']].'_'.$language['id_lang'].'.jpg')) {
$this->_html .='<p><a href="'.$p['url_imgs'].$p['name_img_lang'][$language['id_lang']].'_'.$language['id_lang'].'.jpg" onclick="window.open(this.href); return false;"><span class="anticon anticon-image"></span> Image '.$language['iso_code'].'</a>'.(isset($p['img_delete']) && $p['img_delete']!=''?' - <a href="'.$p['img_delete'].'&id_lang='.$language['id_lang'].'"><span class="anticon anticon-bin"></span></a>':'').'</p>';
}
if(isset($p['url_to_show']) && !empty($p['url_to_show']) && file_exists($p['url_to_show'].$p['name_img_lang'][$language['id_lang']].'_'.$language['id_lang'].'.jpg')) {
$this->_html .='<p><img class="img-responsive" src="'.$p['url_imgs'].$p['name_img_lang'][$language['id_lang']].'_'.$language['id_lang'].'.jpg" />'.(isset($p['img_delete']) && $p['img_delete']!=''?' - <a href="'.$p['img_delete'].'&id_lang='.$language['id_lang'].'"><span class="anticon anticon-bin"></span></a>':'').'</p>';
}
} elseif(isset($p['name_img'])){
if(isset($p['url_to_check']) && !empty($p['url_to_check']) && file_exists($p['url_to_check'].$p['name_img'].'_'.$language['id_lang'].'.jpg')) {
$this->_html .='<p><a href="'.$p['url_imgs'].$p['name_img'].'_'.$language['id_lang'].'.jpg" onclick="window.open(this.href); return false;"><span class="anticon anticon-image"></span> Image '.$language['iso_code'].'</a>'.(isset($p['img_delete']) && $p['img_delete']!=''?' - <a href="'.$p['img_delete'].'&id_lang='.$language['id_lang'].'"><span class="anticon anticon-bin"></span></a>':'').'</p>';
}
if(isset($p['url_to_show']) && !empty($p['url_to_show']) && file_exists($p['url_to_show'].$p['name_img'].'_'.$language['id_lang'].'.jpg')) {
$this->_html .='<p><img src="'.$p['url_imgs'].$p['name_img'].'_'.$language['id_lang'].'.jpg" />'.(isset($p['img_delete']) && $p['img_delete']!=''?' - <a href="'.$p['img_delete'].'&id_lang='.$language['id_lang'].'"><span class="anticon anticon-bin"></span></a>':'').'</p>';
}
}
$this->_html .='</div>';
$this->_js .= '

View File

@ -27,9 +27,17 @@ class AdminAntPromobanner extends AdminTab
Configuration::updateValue('ANT_PROMO_BANNERURL_3',Tools::getValue('url_3', ''));
foreach(array_keys($this->imagelist) as $img) {
if(isset($_FILES['img_'.$img.'_'.$language['id_lang']]) && $_FILES['img_'.$img.'_'.$language['id_lang']]['name'] != '') {
if(!copy($_FILES['img_'.$img.'_'.$language['id_lang']]['tmp_name'], _PS_ROOT_DIR_.'/modules/ant_promobanner/img/img_'.$img.'_'.$language['id_lang'].'.jpg')) {
$random = Tools::passwdGen(7);
if (glob(_PS_ROOT_DIR_.'/modules/ant_promobanner/img/img_'.$img.'_*_'.$language['id_lang'].'.jpg')) {
foreach (glob(_PS_ROOT_DIR_.'/modules/ant_promobanner/img/img_'.$img.'_*_'.$language['id_lang'].'.jpg') as $filename) {
unlink($filename);
}
}
if(!copy($_FILES['img_'.$img.'_'.$language['id_lang']]['tmp_name'], _PS_ROOT_DIR_.'/modules/ant_promobanner/img/img_'.$img.'_'.$random.'_'.$language['id_lang'].'.jpg')) {
HelperFormBootstrap::displayErrors($this->l('An error occured during the image upload.'));
}
Configuration::updateValue('ANT_PROMO_BANNERNAME_'.$language['id_lang'], $random);
}
}
}
@ -115,7 +123,10 @@ class AdminAntPromobanner extends AdminTab
'lang' => true,
'label' => $v[0],
'name' => 'img_'.$k,
'name_img' => 'img_'.$k,
'name_img_lang' => array(
2 => 'img_'.$k.'_'.Configuration::get('ANT_PROMO_BANNERNAME_2'),
3 => 'img_'.$k.'_'.Configuration::get('ANT_PROMO_BANNERNAME_3'),
),
'id' => $k,
'help' => 'L\'image sera la même sur tous les écrans (évitez de charger un image trop lourde).<br>Privilégiez un ratio 500*178',
'languages' => $languages,

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 KiB