lang = TRUE; parent::__construct(); $this->imagelist = array( 'bmobile' => array($this->l('Bannière Mobile'), '500x178'), //'bsite' => array($this->l('Bannière Site'), '800x300'), ); } public function postProcess() { global $currentIndex, $cookie; if(Tools::isSubmit('submitBanners')) { foreach(Language::getLanguages(false) as $language) { Configuration::updateValue('ANT_PROMO_BANNER_2',Tools::getValue('enabled_fr', 0)); Configuration::updateValue('ANT_PROMO_BANNER_3',Tools::getValue('enabled_es', 0)); 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')) { HelperFormBootstrap::displayErrors($this->l('An error occured during the image upload.')); } } } } HelperFormBootstrap::displaySuccess('Mise à jour réussie'); } } public function display() { global $cookie, $currentIndex; $languages = Language::getLanguages(false); $images = array(); foreach(array_keys($this->imagelist) as $img) { $images[] = 'img_'.$img; } $divLangImgName = 'img_bmobile'; $helper = new HelperFormBootstrap(); $helper->_select2 = true; $helper->_inputSwitch = true; $html = $helper->renderStyle(); $html .= '

Bannière Promotionnelle

'; $input = array( 'type' => 'switch', 'name' => 'enabled_fr', 'title' => $this->l('Version FR'), 'class-group' => 'col-md-6', 'default' => (int)Configuration::get('ANT_PROMO_BANNER_2'), 'checked' => (int)Configuration::get('ANT_PROMO_BANNER_2'), 'required' => true, ); $html.= $helper->generateInput($input); $input = array( 'type' => 'switch', 'name' => 'enabled_es', 'title' => $this->l('Version ES'), 'class-group' => 'col-md-6', 'default' => (int)Configuration::get('ANT_PROMO_BANNER_3'), 'checked' => (int)Configuration::get('ANT_PROMO_BANNER_3'), 'required' => true, ); $html.= $helper->generateInput($input); $html.= '
'; foreach($this->imagelist as $k => $v) { $input = array( 'type' => 'uploadImage', 'lang' => true, 'label' => $v[0], 'name' => 'img_'.$k, 'name_img' => 'img_'.$k, 'id' => $k, 'help' => 'L\'image sera la même sur tous les écrans (évitez de charger un image trop lourde).
Privilégiez un ratio 500*178', 'languages' => $languages, 'default_language' => 2, 'input-class' => '', 'id_langs' => $divLangImgName, 'link_flag_img' => '../img/l/', 'url_imgs' => __PS_BASE_URI__.'modules/ant_promobanner/img/', 'url_to_show' => _PS_ROOT_DIR_.'/modules/ant_promobanner/img/', ); $html .= $helper->generateInput($input); $html .= '
'; } $html .='
'; $html .= $helper->renderScript(); echo $html; } }