From 23ed744747f42b00cfdd2991a577f966e7f3ca9c Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Sun, 22 Jun 2014 20:06:45 +0200 Subject: [PATCH] params/_render: replace it everywhere Cleaning up controllers and JS, using headers only and respecting history. --- .../controllers/AuthenticationController.php | 15 ++---- application/controllers/ConfigController.php | 12 +---- application/controllers/IndexController.php | 7 +-- .../layouts/scripts/parts/navigation.phtml | 2 +- .../Web/Controller/ActionController.php | 48 +++++++++++++------ .../controllers/ListController.php | 3 +- public/js/icinga/loader.js | 17 ++++++- 7 files changed, 59 insertions(+), 45 deletions(-) diff --git a/application/controllers/AuthenticationController.php b/application/controllers/AuthenticationController.php index 4476ecebd..ef035a0ec 100644 --- a/application/controllers/AuthenticationController.php +++ b/application/controllers/AuthenticationController.php @@ -65,16 +65,12 @@ class AuthenticationController extends ActionController $this->view->title = $this->translate('Icingaweb Login'); try { - $redirectUrl = Url::fromPath($this->_request->getParam('redirect', 'dashboard')); - - if ($this->_request->isXmlHttpRequest()) { - $redirectUrl->setParam('_render', 'layout'); - } + $redirectUrl = Url::fromPath($this->params->get('redirect', 'dashboard')); $auth = AuthManager::getInstance(); if ($auth->isAuthenticated()) { - $this->redirectNow($redirectUrl); + $this->rerenderLayout()->redirectNow($redirectUrl); } try { @@ -99,7 +95,7 @@ class AuthenticationController extends ActionController $authenticated = $backend->authenticate($user); if ($authenticated === true) { $auth->setAuthenticated($user); - $this->redirectNow($redirectUrl); + $this->rerenderLayout()->redirectNow($redirectUrl); } } } @@ -123,7 +119,7 @@ class AuthenticationController extends ActionController } if ($authenticated === true) { $auth->setAuthenticated($user); - $this->redirectNow($redirectUrl); + $this->rerenderLayout()->redirectNow($redirectUrl); } } if ($backendsWithError === $backendsTried) { @@ -161,8 +157,7 @@ class AuthenticationController extends ActionController $this->_helper->layout->setLayout('login'); $this->_response->setHttpResponseCode(401); } else { - $this->_helper->layout->setLayout('inline'); - $this->redirectToLogin(); + $this->rerenderLayout()->redirectToLogin(); } } } diff --git a/application/controllers/ConfigController.php b/application/controllers/ConfigController.php index 9a17c7aae..208a14383 100644 --- a/application/controllers/ConfigController.php +++ b/application/controllers/ConfigController.php @@ -192,11 +192,7 @@ class ConfigController extends BaseConfigController $manager->enableModule($module); $manager->loadModule($module); Notification::success('Module "' . $module . '" enabled'); - $this->redirectNow(Url::fromPath('config/modules', array( - '_render' => 'layout', - '_reload' => 'css' - ))); - return; + $this->rerenderLayout()->reloadCss()->redirectNow('config/modules'); } catch (Exception $e) { $this->view->exceptionMesssage = $e->getMessage(); $this->view->moduleName = $module; @@ -215,11 +211,7 @@ class ConfigController extends BaseConfigController try { $manager->disableModule($module); Notification::success('Module "' . $module . '" disabled'); - $this->redirectNow(Url::fromPath('config/modules', array( - '_render' => 'layout', - '_reload' => 'css' - ))); - return; + $this->rerenderLayout()->reloadCss()->redirectNow('config/modules'); } catch (Exception $e) { $this->view->exceptionMessage = $e->getMessage(); $this->view->moduleName = $module; diff --git a/application/controllers/IndexController.php b/application/controllers/IndexController.php index 4998da58a..ff872c3aa 100644 --- a/application/controllers/IndexController.php +++ b/application/controllers/IndexController.php @@ -45,12 +45,7 @@ class IndexController extends ActionController public function preDispatch() { if ($this->getRequest()->getActionName() !== 'welcome') { - $url = Url::fromPath('dashboard'); - $render = $this->_request->getParam('_render'); - if ($render) { - $url->setParam('_render', $render); - } - $this->redirectNow($url); + $this->redirectNow('dashboard'); } } diff --git a/application/layouts/scripts/parts/navigation.phtml b/application/layouts/scripts/parts/navigation.phtml index 05d9582ce..106296173 100644 --- a/application/layouts/scripts/parts/navigation.phtml +++ b/application/layouts/scripts/parts/navigation.phtml @@ -9,7 +9,7 @@ if (! $this->auth()->isAuthenticated()) { } // Current url -$url = Url::fromRequest()->remove('_render')->getRelativeUrl(); +$url = Url::fromRequest()->getRelativeUrl(); $menu = Menu::fromConfig(); ?>