//blockpaymentlogo now use boostrap design

This commit is contained in:
Vincent Augagneur
2013-09-20 17:02:15 +02:00
parent 4b4622a1c7
commit 24b6d3d387
+59 -22
View File
@@ -63,14 +63,12 @@ class BlockPaymentLogo extends Module
public function getContent()
{
$html = '
<h2>'.$this->l('Payment logo.').'</h2>
';
$html = '';
if (Tools::isSubmit('submitConfiguration'))
if (Validate::isUnsignedInt(Tools::getValue('id_cms')))
if (Validate::isUnsignedInt(Tools::getValue('PS_PAYMENT_LOGO_CMS_ID')))
{
Configuration::updateValue('PS_PAYMENT_LOGO_CMS_ID', (int)(Tools::getValue('id_cms')));
Configuration::updateValue('PS_PAYMENT_LOGO_CMS_ID', (int)(Tools::getValue('PS_PAYMENT_LOGO_CMS_ID')));
$this->_clearCache('blockpaymentlogo.tpl');
$html .= $this->displayConfirmation($this->l('The settings have been updated.'));
}
@@ -80,23 +78,8 @@ class BlockPaymentLogo extends Module
if (!count($cmss))
$html .= $this->displayError($this->l('No CMS page is available.'));
else
{
$html .= '
<form action="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'" method="post">
<fieldset>
<legend><img src="'.$this->_path.'/logo.gif" alt="" /> '.$this->l('Configure').'</legend>
<label>'.$this->l('Page CMS for link').':</label>
<div class="margin-form">
<select name="id_cms"><option value="0">('.$this->l('Select a page').')</option>';
foreach ($cmss as $cms)
$html .= '<option value="'.$cms['id_cms'].'"'.(Configuration::get('PS_PAYMENT_LOGO_CMS_ID') == $cms['id_cms'] ? ' selected="selected"' : '').'>'.$cms['meta_title'].'</option>';
$html .= '</select>
</div>
<p class="center"><input class="button" type="submit" name="submitConfiguration" value="'.$this->l('Save settings').'" /></p>
</fieldset>
</form>
';
}
$html .= $this->renderForm();
return $html;
}
@@ -139,6 +122,60 @@ class BlockPaymentLogo extends Module
return;
$this->context->controller->addCSS(($this->_path).'blockpaymentlogo.css', 'all');
}
public function renderForm()
{
$fields_form = array(
'form' => array(
'legend' => array(
'title' => $this->l('Settings'),
'icon' => 'icon-cogs'
),
'input' => array(
array(
'type' => 'select',
'label' => $this->l('Page CMS for link:'),
'name' => 'PS_PAYMENT_LOGO_CMS_ID',
'required' => false,
'default_value' => (int)$this->context->country->id,
'options' => array(
'query' => CMS::listCms($this->context->language->id),
'id' => 'id_cms',
'name' => 'meta_title'
)
),
),
'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 = 'submitConfiguration';
$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_PAYMENT_LOGO_CMS_ID' => Tools::getValue('PS_PAYMENT_LOGO_CMS_ID', Configuration::get('PS_PAYMENT_LOGO_CMS_ID')),
);
}
}