Web\Window: fix it's usage, add helper function

Improved window handling, fixed controllers using it.
This commit is contained in:
Thomas Gelf 2014-06-22 13:09:48 +02:00
parent b350e3640d
commit ef5e1b54fd
2 changed files with 18 additions and 10 deletions

View File

@ -81,7 +81,7 @@ class ActionController extends Zend_Controller_Action
private $reloadCss = false; private $reloadCss = false;
private $windowId; private $window;
protected $isRedirect = false; protected $isRedirect = false;
@ -109,7 +109,7 @@ class ActionController extends Zend_Controller_Action
->_setInvokeArgs($invokeArgs); ->_setInvokeArgs($invokeArgs);
$this->_helper = new Zend_Controller_Action_HelperBroker($this); $this->_helper = new Zend_Controller_Action_HelperBroker($this);
$this->_helper->addPath('../application/controllers/helpers'); $this->_helper->addPath('../application/controllers/helpers');
$this->handleWindowId(); $this->handlerBrowserWindows();
$module = $request->getModuleName(); $module = $request->getModuleName();
$this->view->translationDomain = $module === 'default' ? 'icinga' : $module; $this->view->translationDomain = $module === 'default' ? 'icinga' : $module;
@ -151,11 +151,23 @@ class ActionController extends Zend_Controller_Action
return $this->auth; return $this->auth;
} }
protected function handleWindowId() public function Window()
{
if ($this->window === null) {
$this->window = new Window(
$this->_request->getHeader('X-Icinga-WindowId', Window::UNDEFINED)
);
}
return $this->window;
}
protected function handlerBrowserWindows()
{ {
if ($this->_request->isXmlHttpRequest()) { if ($this->_request->isXmlHttpRequest()) {
$windowId = $this->_request->getHeader('X-Icinga-WindowId', null); $id = $this->_request->getHeader('X-Icinga-WindowId', null);
if ($windowId === Window::UNDEFINED) {
if ($id === Window::UNDEFINED) {
$this->window = new Window($id);
$this->_response->setHeader('X-Icinga-WindowId', Window::generateId()); $this->_response->setHeader('X-Icinga-WindowId', Window::generateId());
} }
} }
@ -419,10 +431,6 @@ class ActionController extends Zend_Controller_Action
} }
} }
protected function Window()
{
}
protected function sendAsPdf() protected function sendAsPdf()
{ {
$pdf = new Pdf(); $pdf = new Pdf();

View File

@ -70,7 +70,7 @@ class Monitoring_TimelineController extends Controller
$timeline->setDisplayRange($displayRange); $timeline->setDisplayRange($displayRange);
$timeline->setForecastRange($forecastRange); $timeline->setForecastRange($forecastRange);
$beingExtended = $this->getRequest()->getParam('extend') == 1; $beingExtended = $this->getRequest()->getParam('extend') == 1;
$timeline->setSession($this->getWindowSession('timeline', !$beingExtended)); $timeline->setSession($this->Window()->getSessionNamespace('timeline', !$beingExtended));
$this->view->timeline = $timeline; $this->view->timeline = $timeline;
$this->view->nextRange = $forecastRange; $this->view->nextRange = $forecastRange;