2014-01-24 16:41:37 +01:00
|
|
|
<?php
|
|
|
|
// {{{ICINGA_LICENSE_HEADER}}}
|
|
|
|
// {{{ICINGA_LICENSE_HEADER}}}
|
|
|
|
|
2014-05-27 14:53:25 +02:00
|
|
|
use \Zend_Controller_Action_Exception;
|
2014-01-24 16:41:37 +01:00
|
|
|
use Icinga\Application\Icinga;
|
2014-05-27 14:53:25 +02:00
|
|
|
use Icinga\Module\Doc\DocController;
|
2014-01-24 16:41:37 +01:00
|
|
|
|
2014-02-03 15:39:53 +01:00
|
|
|
class Doc_ModuleController extends DocController
|
2014-01-24 16:41:37 +01:00
|
|
|
{
|
|
|
|
/**
|
2014-05-23 14:06:28 +02:00
|
|
|
* List available modules
|
2014-01-24 16:41:37 +01:00
|
|
|
*/
|
|
|
|
public function indexAction()
|
|
|
|
{
|
2014-02-03 15:39:53 +01:00
|
|
|
$this->view->enabledModules = Icinga::app()->getModuleManager()->listEnabledModules();
|
2014-01-24 16:41:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-05-27 14:53:25 +02:00
|
|
|
* Assert that the given module is enabled
|
2014-01-24 16:41:37 +01:00
|
|
|
*
|
2014-05-27 14:53:25 +02:00
|
|
|
* @param $moduleName
|
2014-01-24 16:41:37 +01:00
|
|
|
*
|
2014-05-27 14:53:25 +02:00
|
|
|
* @throws Zend_Controller_Action_Exception
|
2014-01-24 16:41:37 +01:00
|
|
|
*/
|
2014-05-27 14:53:25 +02:00
|
|
|
protected function assertModuleEnabled($moduleName)
|
2014-01-24 16:41:37 +01:00
|
|
|
{
|
2014-05-27 14:53:25 +02:00
|
|
|
if ($moduleName === null) {
|
|
|
|
throw new Zend_Controller_Action_Exception('Missing parameter "moduleName"', 404);
|
|
|
|
}
|
2014-05-23 14:06:28 +02:00
|
|
|
$moduleManager = Icinga::app()->getModuleManager();
|
2014-05-27 14:53:25 +02:00
|
|
|
if (! $moduleManager->hasInstalled($moduleName)) {
|
|
|
|
throw new Zend_Controller_Action_Exception('Module ' . $moduleName . ' is not installed', 404);
|
|
|
|
}
|
2014-05-23 14:06:28 +02:00
|
|
|
if (! $moduleManager->hasEnabled($moduleName)) {
|
2014-05-27 14:53:25 +02:00
|
|
|
throw new Zend_Controller_Action_Exception('Module ' . $moduleName. ' is not enabled', 404);
|
2014-01-24 16:41:37 +01:00
|
|
|
}
|
2014-05-27 14:53:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* View toc of a module's documentation
|
|
|
|
*/
|
|
|
|
public function tocAction()
|
|
|
|
{
|
|
|
|
$moduleName = $this->getParam('moduleName');
|
|
|
|
$this->assertModuleEnabled($moduleName);
|
|
|
|
$moduleManager = Icinga::app()->getModuleManager();
|
2014-05-28 17:19:24 +02:00
|
|
|
$this->populateToc($moduleManager->getModuleDir($moduleName, '/doc'), $moduleName);
|
|
|
|
$this->view->moduleName = $moduleName;
|
2014-01-24 16:41:37 +01:00
|
|
|
}
|
2014-05-27 15:09:01 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* View a chapter of a module's documentation
|
|
|
|
*
|
|
|
|
* @throws Zend_Controller_Action_Exception
|
|
|
|
*/
|
|
|
|
public function chapterAction()
|
|
|
|
{
|
|
|
|
$moduleName = $this->getParam('moduleName');
|
|
|
|
$this->assertModuleEnabled($moduleName);
|
|
|
|
$chapterName = $this->getParam('chapterName');
|
|
|
|
if ($chapterName === null) {
|
|
|
|
throw new Zend_Controller_Action_Exception('Missing parameter "chapterName"', 404);
|
|
|
|
}
|
|
|
|
$moduleManager = Icinga::app()->getModuleManager();
|
2014-06-06 14:10:35 +02:00
|
|
|
$this->populateChapter($chapterName, $moduleManager->getModuleDir($moduleName, '/doc'));
|
|
|
|
$this->view->moduleName = $moduleName;
|
2014-05-27 15:09:01 +02:00
|
|
|
}
|
2014-01-24 16:41:37 +01:00
|
|
|
}
|