From 0cf68ade909a64b5621099bc8cdb4a95b5a5b7bb Mon Sep 17 00:00:00 2001 From: Vincent Augagneur Date: Thu, 26 Sep 2013 15:09:18 +0200 Subject: [PATCH] //productscategory now use bootstrap design --- modules/productscategory/productscategory.php | 81 +++++++++++++++---- 1 file changed, 65 insertions(+), 16 deletions(-) diff --git a/modules/productscategory/productscategory.php b/modules/productscategory/productscategory.php index fb1f74e36..7fbc24841 100644 --- a/modules/productscategory/productscategory.php +++ b/modules/productscategory/productscategory.php @@ -71,28 +71,16 @@ class productsCategory extends Module public function getContent() { $this->_html = ''; - if (Tools::isSubmit('submitCross') AND Tools::getValue('displayPrice') != 0 AND Tools::getValue('displayPrice') != 1) + if (Tools::isSubmit('submitCross') AND Tools::getValue('PRODUCTSCATEGORY_DISPLAY_PRICE') != 0 AND Tools::getValue('PRODUCTSCATEGORY_DISPLAY_PRICE') != 1) $this->_html .= $this->displayError('Invalid displayPrice'); elseif (Tools::isSubmit('submitCross')) { - Configuration::updateValue('PRODUCTSCATEGORY_DISPLAY_PRICE', Tools::getValue('displayPrice')); + Configuration::updateValue('PRODUCTSCATEGORY_DISPLAY_PRICE', Tools::getValue('PRODUCTSCATEGORY_DISPLAY_PRICE')); $this->_clearCache('productscategory.tpl'); $this->_html .= $this->displayConfirmation($this->l('Settings updated successfully')); } - $this->_html .= ' -
-
'.$this->l('Settings').' - -
- - - - -

'.$this->l('Show the price on the products in the block.').'

-
-
-
-
'; + $this->_html .= $this->renderForm(); + return $this->_html; } @@ -203,4 +191,65 @@ class productsCategory extends Module { $this->_clearCache('productscategory.tpl'); } + + public function renderForm() + { + $fields_form = array( + 'form' => array( + 'legend' => array( + 'title' => $this->l('Settings'), + 'icon' => 'icon-cogs' + ), + 'input' => array( + array( + 'type' => 'switch', + 'label' => $this->l('Display price on products'), + 'desc' => $this->l('Show the price on the products in the block.'), + 'name' => 'PRODUCTSCATEGORY_DISPLAY_PRICE', + 'values' => array( + array( + 'id' => 'active_on', + 'value' => 1, + 'label' => $this->l('Enabled') + ), + array( + 'id' => 'active_off', + 'value' => 0, + 'label' => $this->l('Disabled') + ) + ), + ), + ), + '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 = 'submitCross'; + $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( + 'PRODUCTSCATEGORY_DISPLAY_PRICE' => Tools::getValue('PRODUCTSCATEGORY_DISPLAY_PRICE', Configuration::get('PRODUCTSCATEGORY_DISPLAY_PRICE')), + ); + } + }