From 39d84759a37bd84a5868b07a2115ae0942b5f274 Mon Sep 17 00:00:00 2001 From: Vincent Augagneur Date: Mon, 23 Sep 2013 10:06:43 +0200 Subject: [PATCH] //blockviewed now use boostrap design --- modules/blockviewed/blockviewed.php | 77 ++++++++++++++++++++--------- 1 file changed, 55 insertions(+), 22 deletions(-) diff --git a/modules/blockviewed/blockviewed.php b/modules/blockviewed/blockviewed.php index 7b9bc5c40..aa6188f9d 100644 --- a/modules/blockviewed/blockviewed.php +++ b/modules/blockviewed/blockviewed.php @@ -58,36 +58,20 @@ class BlockViewed extends Module public function getContent() { - $output = '

'.$this->displayName.'

'; + $output = ''; if (Tools::isSubmit('submitBlockViewed')) { - if (!($productNbr = Tools::getValue('productNbr')) || empty($productNbr)) - $output .= '
'.$this->l('You must fill in the \'Products displayed\' field.').'
'; + if (!($productNbr = Tools::getValue('PRODUCTS_VIEWED_NBR')) || empty($productNbr)) + $output .= $this->displayErrors($this->l('You must fill in the \'Products displayed\' field.')); elseif ((int)($productNbr) == 0) - $output .= '
'.$this->l('Invalid number.').'
'; + $output .= $this->displayErrors($this->l('Invalid number.')); else { Configuration::updateValue('PRODUCTS_VIEWED_NBR', (int)$productNbr); - $output .= '
'.$this->l('Settings updated').'
'; + $output .= $this->displayConfirmation($this->l('Settings updated')); } } - return $output.$this->displayForm(); - } - - public function displayForm() - { - $output = ' -
-
'.$this->l('Settings').' - -
- -

'.$this->l('Define the number of products displayed in this block.').'

-
-
-
-
'; - return $output; + return $output.$this->renderForm(); } public function hookRightColumn($params) @@ -184,4 +168,53 @@ class BlockViewed extends Module { $this->context->controller->addCSS(($this->_path).'blockviewed.css', 'all'); } + + public function renderForm() + { + $fields_form = array( + 'form' => array( + 'legend' => array( + 'title' => $this->l('Settings'), + 'icon' => 'icon-cogs' + ), + 'input' => array( + array( + 'type' => 'text', + 'label' => $this->l('Products to display.'), + 'name' => 'PRODUCTS_VIEWED_NBR', + 'class' => 'fixed-width-xs', + 'desc' => $this->l('Define the number of products displayed in this block.') + ), + ), + '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; + $helper->identifier = $this->identifier; + $helper->submit_action = 'submitBlockViewed'; + $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( + 'PRODUCTS_VIEWED_NBR' => Tools::getValue('PRODUCTS_VIEWED_NBR', Configuration::get('PRODUCTS_VIEWED_NBR')), + ); + } }