From c43cda26ba84dd40d786e364f4319e7ecd7fb326 Mon Sep 17 00:00:00 2001 From: tDidierjean Date: Tue, 28 Feb 2012 17:28:35 +0000 Subject: [PATCH] // fix AdminMeta options form and toolbar --- classes/controller/AdminController.php | 7 +---- controllers/admin/AdminMetaController.php | 38 +++++++++++++++++++++-- 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/classes/controller/AdminController.php b/classes/controller/AdminController.php index 620c4f1cd..14209ce7b 100644 --- a/classes/controller/AdminController.php +++ b/classes/controller/AdminController.php @@ -119,7 +119,7 @@ class AdminControllerCore extends Controller /** @var array list of toolbar buttons */ protected $toolbar_btn = null; - /** @var array list of toolbar buttons */ + /** @var boolean scrolling toolbar */ protected $toolbar_fix = true; /** @var boolean set to false to hide toolbar and page title */ @@ -984,7 +984,6 @@ class AdminControllerCore extends Controller { switch ($this->display) { - // @todo defining default buttons case 'add': case 'edit': // Default save button - action dynamically handled in javascript @@ -1440,7 +1439,6 @@ class AdminControllerCore extends Controller } $list = $helper->generateList($this->_list, $this->fieldsDisplay); - $this->toolbar_fix = false; return $list; } @@ -1455,7 +1453,6 @@ class AdminControllerCore extends Controller $helper->tpl_vars = $this->tpl_view_vars; !is_null($this->base_tpl_view) ? $helper->base_tpl = $this->base_tpl_view : ''; $view = $helper->generateView(); - $this->toolbar_fix = false; return $view; } @@ -1490,7 +1487,6 @@ class AdminControllerCore extends Controller $helper->tpl_vars['back'] = Tools::safeOutput(Tools::getValue(self::$currentIndex.'&token='.$this->token)); } $form = $helper->generateForm($this->fields_form); - $this->toolbar_fix = false; return $form; } @@ -1511,7 +1507,6 @@ class AdminControllerCore extends Controller $helper->id = $this->id; $helper->tpl_vars = $this->tpl_option_vars; $options = $helper->generateOptions($this->options); - $this->toolbar_fix = false; return $options; } diff --git a/controllers/admin/AdminMetaController.php b/controllers/admin/AdminMetaController.php index 5749f0407..69f6e9aa5 100644 --- a/controllers/admin/AdminMetaController.php +++ b/controllers/admin/AdminMetaController.php @@ -30,6 +30,7 @@ class AdminMetaControllerCore extends AdminController public $table = 'meta'; public $className = 'Meta'; public $lang = true; + protected $toolbar_fix = false; public function __construct() { @@ -85,10 +86,17 @@ class AdminMetaControllerCore extends AdminController $this->addFieldRoute('cms_rule', $this->l('Route to CMS page')); $this->addFieldRoute('cms_category_rule', $this->l('Route to CMS category')); $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() { parent::setMedia(); @@ -174,6 +182,7 @@ class AdminMetaControllerCore extends AdminController 'label' => $this->l('Rewritten URL:'), 'name' => 'url_rewrite', 'lang' => true, + 'required' => true, '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'), 'size' => 50 @@ -297,4 +306,29 @@ class AdminMetaControllerCore extends AdminController { $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; + } + } }