ActionController: add isXhr() method
Makes things easier as we use this a lot
This commit is contained in:
parent
331d756a2a
commit
3774eb6889
|
@ -158,7 +158,7 @@ class ActionController extends Zend_Controller_Action
|
|||
|
||||
protected function handlerBrowserWindows()
|
||||
{
|
||||
if ($this->_request->isXmlHttpRequest()) {
|
||||
if ($this->isXhr()) {
|
||||
$id = $this->_request->getHeader('X-Icinga-WindowId', null);
|
||||
|
||||
if ($id === Window::UNDEFINED) {
|
||||
|
@ -281,7 +281,7 @@ class ActionController extends Zend_Controller_Action
|
|||
|
||||
protected function ignoreXhrBody()
|
||||
{
|
||||
if ($this->getRequest()->isXmlHttpRequest()) {
|
||||
if ($this->isXhr()) {
|
||||
$this->getResponse()->setHeader('X-Icinga-Container', 'ignore');
|
||||
}
|
||||
}
|
||||
|
@ -315,13 +315,18 @@ class ActionController extends Zend_Controller_Action
|
|||
protected function redirectToLogin($afterLogin = '/dashboard')
|
||||
{
|
||||
$url = Url::fromPath('/authentication/login');
|
||||
if ($this->getRequest()->isXmlHttpRequest()) {
|
||||
if ($this->isXhr()) {
|
||||
$url->setParam('_render', 'layout');
|
||||
}
|
||||
$url->setParam('redirect', $afterLogin);
|
||||
$this->redirectNow($url);
|
||||
}
|
||||
|
||||
public function isXhr()
|
||||
{
|
||||
return $this->getRequest()->isXmlHttpRequest();
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirect to a specific url, updating the browsers URL field
|
||||
*
|
||||
|
@ -330,7 +335,7 @@ class ActionController extends Zend_Controller_Action
|
|||
public function redirectNow($url)
|
||||
{
|
||||
$url = preg_replace('~&~', '&', $url);
|
||||
if ($this->_request->isXmlHttpRequest()) {
|
||||
if ($this->isXhr()) {
|
||||
$this->getResponse()
|
||||
->setHeader('X-Icinga-Redirect', rawurlencode($url))
|
||||
->sendHeaders();
|
||||
|
@ -371,7 +376,7 @@ class ActionController extends Zend_Controller_Action
|
|||
exit;
|
||||
}
|
||||
|
||||
if ($req->isXmlHttpRequest()) {
|
||||
if ($this->isXhr()) {
|
||||
$this->postDispatchXhr();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue