//productscategory now use bootstrap design

This commit is contained in:
Vincent Augagneur
2013-09-26 15:09:18 +02:00
parent 157ab0c8b9
commit 0cf68ade90
+65 -16
View File
@@ -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 .= '
<form action="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'" method="post">
<fieldset><legend><img src="'.$this->_path.'logo.gif" alt="" title="" />'.$this->l('Settings').'</legend>
<label>'.$this->l('Display price on products').'</label>
<div class="margin-form">
<input type="radio" name="displayPrice" id="display_on" value="1" '.(Configuration::get('PRODUCTSCATEGORY_DISPLAY_PRICE') ? 'checked="checked" ' : '').'/>
<label class="t" for="display_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>
<input type="radio" name="displayPrice" id="display_off" value="0" '.(!Configuration::get('PRODUCTSCATEGORY_DISPLAY_PRICE') ? 'checked="checked" ' : '').'/>
<label class="t" for="display_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
<p class="clear">'.$this->l('Show the price on the products in the block.').'</p>
</div>
<center><input type="submit" name="submitCross" value="'.$this->l('Save').'" class="button" /></center>
</fieldset>
</form>';
$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')),
);
}
}