84 lines
3.7 KiB
PHP
84 lines
3.7 KiB
PHP
<?php
|
|
class AdvSliderGetContentController
|
|
{
|
|
public function __construct($module, $file, $path)
|
|
{
|
|
$this->file = $file;
|
|
$this->module = $module;
|
|
$this->context = Context::getContext();
|
|
$this->_path = $path;
|
|
}
|
|
|
|
public function processConfiguration()
|
|
{
|
|
if (Tools::isSubmit('submitAdvsliderconfig')) {
|
|
$enable_date = Tools::getValue('enable_date');
|
|
$enable_groups = Tools::getValue('enable_groups');
|
|
Configuration::updateValue('ADVSLIDER_RESTRICT_DATE', $enable_date);
|
|
Configuration::updateValue('ADVSLIDER_RESTRICT_GROUP', $enable_groups);
|
|
$this->context->smarty->assign('confirmation', 'ok');
|
|
}
|
|
}
|
|
|
|
public function renderForm()
|
|
{
|
|
$fields_form = array(
|
|
'form' => array(
|
|
'legend' => array(
|
|
'title' => $this->module->l('AdvSlider configuration'),
|
|
'icon' => 'icon-envelope'
|
|
),
|
|
'input' => array(
|
|
array(
|
|
'type' => 'switch',
|
|
'label' => $this->module->l('Enable Date restriction:'),
|
|
'name' => 'enable_date',
|
|
'desc' => $this->module->l('Enable restriction by date.'),
|
|
'values' => array(
|
|
array('id' => 'enable_date_1', 'value' => 1, 'label' => $this->module->l('Enabled')),
|
|
array('id' => 'enable_date_0', 'value' => 0, 'label' => $this->module->l('Disabled'))
|
|
),
|
|
),
|
|
array(
|
|
'type' => 'switch',
|
|
'label' => $this->module->l('Enable Groups Restriction:'),
|
|
'name' => 'enable_groups',
|
|
'desc' => $this->module->l('Enable restriction by user groups.'),
|
|
'values' => array(
|
|
array('id' => 'enable_groups_1', 'value' => 1, 'label' => $this->module->l('Enabled')),
|
|
array('id' => 'enable_groups_0', 'value' => 0, 'label' => $this->module->l('Disabled'))
|
|
),
|
|
|
|
),
|
|
),
|
|
'submit' => array('title' => $this->module->l('Save'))
|
|
)
|
|
);
|
|
|
|
$helper = new HelperForm();
|
|
$helper->table = 'advslider';
|
|
$helper->default_form_language = (int)Configuration::get('PS_LANG_DEFAULT');
|
|
$helper->allow_employee_form_lang = (int)Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG');
|
|
$helper->submit_action = 'submitAdvsliderconfig';
|
|
$helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->module->name.'&tab_module='.$this->module->tab.'&module_name='.$this->module->name;
|
|
$helper->token = Tools::getAdminTokenLite('AdminModules');
|
|
$helper->tpl_vars = array(
|
|
'fields_value' => array(
|
|
'enable_date' => Tools::getValue('enable_date', Configuration::get('ADVSLIDER_RESTRICT_DATE')),
|
|
'enable_groups' => Tools::getValue('enable_groups', Configuration::get('ADVSLIDER_RESTRICT_GROUP')),
|
|
),
|
|
'languages' => $this->context->controller->getLanguages()
|
|
);
|
|
|
|
return $helper->generateForm(array($fields_form));
|
|
}
|
|
|
|
public function run()
|
|
{
|
|
$this->processConfiguration();
|
|
$html_confirmation_message = $this->module->display($this->file, 'getContent.tpl');
|
|
$html_form = $this->renderForm();
|
|
return $html_confirmation_message.$html_form;
|
|
}
|
|
}
|