From 3e269f211c2031a86f2a323063935decebafde9a Mon Sep 17 00:00:00 2001 From: Vincent Augagneur Date: Wed, 16 Oct 2013 14:15:22 +0200 Subject: [PATCH] //blockadvertising now use boostrap design --- modules/blockadvertising/blockadvertising.php | 106 +++++++++++------- 1 file changed, 64 insertions(+), 42 deletions(-) diff --git a/modules/blockadvertising/blockadvertising.php b/modules/blockadvertising/blockadvertising.php index 70b616cfa..3a1ac73f1 100644 --- a/modules/blockadvertising/blockadvertising.php +++ b/modules/blockadvertising/blockadvertising.php @@ -171,48 +171,7 @@ class BlockAdvertising extends Module public function getContent() { $this->postProcess(); - $output = ' -
-
- '.$this->l('Advertising block configuration').''; - if ($this->adv_img) - { - $output .= ' - - '.$this->adv_title.' - '; - if ($this->adv_imgname == 'advertising') - $output .= $this->l('You cannot delete the default image (but you can change it below).'); - else - $output .= ''; - } - else - $output .= '
'.$this->l('No image').'
'; - $output .= '

- -
- -

'.$this->l('Image will be displayed as 155x163').'

-
-
- -
- -
-
- -
- -
-
-
- -
-
-
-
'; - return $output; + return $this->renderForm(); } public function hookRightColumn($params) @@ -236,4 +195,67 @@ class BlockAdvertising extends Module { $this->context->controller->addCSS($this->_path.'blockadvertising.css', 'all'); } + + public function renderForm() + { + $fields_form = array( + 'form' => array( + 'legend' => array( + 'title' => $this->l('Configuration'), + 'icon' => 'icon-cogs' + ), + 'input' => array( + array( + 'type' => 'file', + 'label' => $this->l('Block image'), + 'name' => 'adv_img', + 'desc' => $this->l('Image will be displayed as 155x163'), + 'thumb' => '../modules/'.$this->name.'/advertising.jpg', + ), + array( + 'type' => 'text', + 'label' => $this->l('Image link'), + 'name' => 'adv_link', + 'desc' => $this->l('Such as bank branch, IBAN number, BIC, etc...') + ), + array( + 'type' => 'text', + 'label' => $this->l('Title'), + 'name' => 'adv_title', + ), + ), + 'submit' => array( + 'title' => $this->l('Save'), + 'class' => 'btn btn-primary') + ), + ); + + $helper = new HelperForm(); + $helper->show_toolbar = false; + $helper->table = $this->table; + $lang = new Language((int)Configuration::get('PS_LANG_DEFAULT')); + $helper->default_form_language = $lang->id; + $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0; + $this->fields_form = array(); + $helper->id = (int)Tools::getValue('id_carrier'); + $helper->identifier = $this->identifier; + $helper->submit_action = 'submitAdvConf'; + $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name; + $helper->token = Tools::getAdminTokenLite('AdminModules'); + $helper->tpl_vars = array( + 'fields_value' => $this->getConfigFieldsValues(), + 'languages' => $this->context->controller->getLanguages(), + 'id_language' => $this->context->language->id + ); + + return $helper->generateForm(array($fields_form)); + } + + public function getConfigFieldsValues() + { + return array( + 'adv_link' => Tools::getValue('adv_link', Configuration::get('BLOCKADVERT_LINK')), + 'adv_title' => Tools::getValue('adv_title', Configuration::get('BLOCKADVERT_TITLE')), + ); + } } \ No newline at end of file