2014-06-22 12:03:37 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Icinga\Web\Controller;
|
|
|
|
|
2014-06-22 13:49:21 +02:00
|
|
|
use Zend_Controller_Request_Abstract as Request;
|
|
|
|
use Zend_Controller_Response_Abstract as Response;
|
|
|
|
|
2014-06-22 12:03:37 +02:00
|
|
|
class ModuleActionController extends ActionController
|
|
|
|
{
|
|
|
|
private $config;
|
|
|
|
|
|
|
|
private $configs = array();
|
|
|
|
|
2014-06-22 13:49:21 +02:00
|
|
|
protected $moduleName;
|
|
|
|
|
|
|
|
public function __construct(
|
|
|
|
Request $request,
|
|
|
|
Response $response,
|
|
|
|
array $invokeArgs = array()
|
|
|
|
) {
|
|
|
|
parent::__construct($request, $response, $invokeArgs);
|
|
|
|
$this->moduleName = $request->getModuleName();
|
|
|
|
$this->view->translationDomain = $this->moduleName;
|
2014-06-22 13:54:02 +02:00
|
|
|
$this->moduleInit();
|
2014-06-22 13:49:21 +02:00
|
|
|
}
|
|
|
|
|
2014-06-22 12:03:37 +02:00
|
|
|
public function Config($file = null)
|
|
|
|
{
|
|
|
|
$module = $this->getRequest()->getModuleName();
|
|
|
|
|
|
|
|
$this->moduleName = $module;
|
|
|
|
|
|
|
|
if ($tile === null) {
|
|
|
|
if ($this->config === null) {
|
|
|
|
$this->config = Config::module($module);
|
|
|
|
}
|
|
|
|
return $this->config;
|
|
|
|
} else {
|
|
|
|
if (! array_key_exists($file, $this->configs)) {
|
|
|
|
$this->configs[$file] = Config::module($module, $file);
|
|
|
|
}
|
|
|
|
return $this->configs[$file];
|
|
|
|
}
|
|
|
|
}
|
2014-06-22 13:54:02 +02:00
|
|
|
|
2014-06-22 15:08:20 +02:00
|
|
|
public function postDispatch()
|
|
|
|
{
|
|
|
|
$req = $this->getRequest();
|
|
|
|
$resp = $this->getResponse();
|
|
|
|
$layout = $this->_helper->layout();
|
|
|
|
|
|
|
|
$layout->moduleName = $this->moduleName;
|
2014-06-22 16:04:55 +02:00
|
|
|
if ($this->isXhr()) {
|
2014-06-22 15:08:20 +02:00
|
|
|
$resp->setHeader('X-Icinga-Module', $layout->moduleName);
|
|
|
|
}
|
|
|
|
|
|
|
|
parent::postDispatch();
|
|
|
|
}
|
2014-06-22 13:54:02 +02:00
|
|
|
|
|
|
|
protected function moduleInit()
|
|
|
|
{
|
|
|
|
}
|
2014-06-22 12:03:37 +02:00
|
|
|
}
|