diff --git a/modules/blockspecials/blockspecials.php b/modules/blockspecials/blockspecials.php
index 3be99ed9d..855434267 100644
--- a/modules/blockspecials/blockspecials.php
+++ b/modules/blockspecials/blockspecials.php
@@ -69,38 +69,14 @@ class BlockSpecials extends Module
public function getContent()
{
- $output = '
'.$this->displayName.'
';
+ $output = '';
if (Tools::isSubmit('submitSpecials'))
{
- Configuration::updateValue('PS_BLOCK_SPECIALS_DISPLAY', (int)Tools::getValue('always_display'));
+ Configuration::updateValue('PS_BLOCK_SPECIALS_DISPLAY', (int)Tools::getValue('PS_BLOCK_SPECIALS_DISPLAY'));
Configuration::updateValue('BLOCKSPECIALS_NB_CACHES', (int)Tools::getValue('BLOCKSPECIALS_NB_CACHES'));
- $output .= ''.$this->l('Settings updated').'
';
+ $output .= $this->displayConfirmation($this->l('Settings updated'));
}
- return $output.$this->displayForm();
- }
-
- public function displayForm()
- {
- return '
- ';
+ return $output.$this->renderForm();
}
public function hookRightColumn($params)
@@ -152,4 +128,71 @@ class BlockSpecials extends Module
{
$this->_clearCache('blockspecials.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('Always display this block.'),
+ 'name' => 'PS_BLOCK_SPECIALS_DISPLAY',
+ 'desc' => $this->l('Show the block even if no products are available.'),
+ 'values' => array(
+ array(
+ 'id' => 'active_on',
+ 'value' => 1,
+ 'label' => $this->l('Enabled')
+ ),
+ array(
+ 'id' => 'active_off',
+ 'value' => 0,
+ 'label' => $this->l('Disabled')
+ )
+ ),
+ ),
+ array(
+ 'type' => 'text',
+ 'label' => $this->l('Number of cache files.'),
+ 'name' => 'BLOCKSPECIALS_NB_CACHES',
+ 'desc' => $this->l('Specials are displayed randomly on the front end, but since it takes a lot of ressources, it is better to cache the results. Cache is reset everyday. 0 will disable the cache.'),
+ ),
+ ),
+ '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 = 'submitSpecials';
+ $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(
+ 'PS_BLOCK_SPECIALS_DISPLAY' => Tools::getValue('PS_BLOCK_SPECIALS_DISPLAY', Configuration::get('PS_BLOCK_SPECIALS_DISPLAY')),
+ 'BLOCKSPECIALS_NB_CACHES' => Tools::getValue('BLOCKSPECIALS_NB_CACHES', Configuration::get('BLOCKSPECIALS_NB_CACHES')),
+ );
+ }
}
\ No newline at end of file