// fix AdminMeta options form and toolbar

This commit is contained in:
tDidierjean
2012-02-28 17:28:35 +00:00
parent 44b99ff44c
commit c43cda26ba
2 changed files with 37 additions and 8 deletions
+1 -6
View File
@@ -119,7 +119,7 @@ class AdminControllerCore extends Controller
/** @var array list of toolbar buttons */ /** @var array list of toolbar buttons */
protected $toolbar_btn = null; protected $toolbar_btn = null;
/** @var array list of toolbar buttons */ /** @var boolean scrolling toolbar */
protected $toolbar_fix = true; protected $toolbar_fix = true;
/** @var boolean set to false to hide toolbar and page title */ /** @var boolean set to false to hide toolbar and page title */
@@ -984,7 +984,6 @@ class AdminControllerCore extends Controller
{ {
switch ($this->display) switch ($this->display)
{ {
// @todo defining default buttons
case 'add': case 'add':
case 'edit': case 'edit':
// Default save button - action dynamically handled in javascript // Default save button - action dynamically handled in javascript
@@ -1440,7 +1439,6 @@ class AdminControllerCore extends Controller
} }
$list = $helper->generateList($this->_list, $this->fieldsDisplay); $list = $helper->generateList($this->_list, $this->fieldsDisplay);
$this->toolbar_fix = false;
return $list; return $list;
} }
@@ -1455,7 +1453,6 @@ class AdminControllerCore extends Controller
$helper->tpl_vars = $this->tpl_view_vars; $helper->tpl_vars = $this->tpl_view_vars;
!is_null($this->base_tpl_view) ? $helper->base_tpl = $this->base_tpl_view : ''; !is_null($this->base_tpl_view) ? $helper->base_tpl = $this->base_tpl_view : '';
$view = $helper->generateView(); $view = $helper->generateView();
$this->toolbar_fix = false;
return $view; return $view;
} }
@@ -1490,7 +1487,6 @@ class AdminControllerCore extends Controller
$helper->tpl_vars['back'] = Tools::safeOutput(Tools::getValue(self::$currentIndex.'&token='.$this->token)); $helper->tpl_vars['back'] = Tools::safeOutput(Tools::getValue(self::$currentIndex.'&token='.$this->token));
} }
$form = $helper->generateForm($this->fields_form); $form = $helper->generateForm($this->fields_form);
$this->toolbar_fix = false;
return $form; return $form;
} }
@@ -1511,7 +1507,6 @@ class AdminControllerCore extends Controller
$helper->id = $this->id; $helper->id = $this->id;
$helper->tpl_vars = $this->tpl_option_vars; $helper->tpl_vars = $this->tpl_option_vars;
$options = $helper->generateOptions($this->options); $options = $helper->generateOptions($this->options);
$this->toolbar_fix = false;
return $options; return $options;
} }
+36 -2
View File
@@ -30,6 +30,7 @@ class AdminMetaControllerCore extends AdminController
public $table = 'meta'; public $table = 'meta';
public $className = 'Meta'; public $className = 'Meta';
public $lang = true; public $lang = true;
protected $toolbar_fix = false;
public function __construct() public function __construct()
{ {
@@ -85,10 +86,17 @@ class AdminMetaControllerCore extends AdminController
$this->addFieldRoute('cms_rule', $this->l('Route to CMS page')); $this->addFieldRoute('cms_rule', $this->l('Route to CMS page'));
$this->addFieldRoute('cms_category_rule', $this->l('Route to CMS category')); $this->addFieldRoute('cms_category_rule', $this->l('Route to CMS category'));
$this->addFieldRoute('module', $this->l('Route to modules')); $this->addFieldRoute('module', $this->l('Route to modules'));
$this->options['routes']['submit'] = array();
} }
} }
public function initProcess()
{
parent::initProcess();
// This is a composite page, we don't want the "options" display mode
if ($this->display == 'options')
$this->display = '';
}
public function setMedia() public function setMedia()
{ {
parent::setMedia(); parent::setMedia();
@@ -174,6 +182,7 @@ class AdminMetaControllerCore extends AdminController
'label' => $this->l('Rewritten URL:'), 'label' => $this->l('Rewritten URL:'),
'name' => 'url_rewrite', 'name' => 'url_rewrite',
'lang' => true, 'lang' => true,
'required' => true,
'hint' => $this->l('Invalid characters:').' <>;=#{}', 'hint' => $this->l('Invalid characters:').' <>;=#{}',
'desc' => $this->l('Example : "contacts" for http://mysite.com/shop/contacts to redirect to http://mysite.com/shop/contact-form.php'), 'desc' => $this->l('Example : "contacts" for http://mysite.com/shop/contacts to redirect to http://mysite.com/shop/contact-form.php'),
'size' => 50 'size' => 50
@@ -297,4 +306,29 @@ class AdminMetaControllerCore extends AdminController
{ {
$this->checkAndUpdateRoute('cms_category_rule'); $this->checkAndUpdateRoute('cms_category_rule');
} }
/**
* Function used to render the options for this controller
*/
public function renderOptions()
{
if (!Configuration::get('PS_REWRITING_SETTINGS'))
unset($this->options['routes']);
if ($this->options && is_array($this->options))
{
$helper = new HelperOptions($this);
$this->setHelperDisplay($helper);
$helper->toolbar_fix = true;
$helper->toolbar_btn = array('save' => array(
'href' => '#',
'desc' => $this->l('Save')
));
$helper->id = $this->id;
$helper->tpl_vars = $this->tpl_option_vars;
$options = $helper->generateOptions($this->options);
return $options;
}
}
} }