2014-05-23 03:40:00 -04:00
|
|
|
<?php
|
|
|
|
|
// {{{ICINGA_LICENSE_HEADER}}}
|
|
|
|
|
// {{{ICINGA_LICENSE_HEADER}}}
|
|
|
|
|
|
2014-09-04 08:53:00 -04:00
|
|
|
use \Zend_Controller_Action_Exception;
|
2014-05-27 08:50:48 -04:00
|
|
|
use Icinga\Application\Icinga;
|
|
|
|
|
use Icinga\Module\Doc\DocController;
|
2014-05-23 03:40:00 -04:00
|
|
|
|
|
|
|
|
class Doc_IcingawebController extends DocController
|
|
|
|
|
{
|
2014-12-09 06:50:29 -05:00
|
|
|
/**
|
|
|
|
|
* Get the path to Icinga Web 2's documentation
|
2014-12-09 08:27:02 -05:00
|
|
|
*
|
|
|
|
|
* @return string
|
|
|
|
|
*
|
|
|
|
|
* @throws Zend_Controller_Action_Exception If Icinga Web 2's documentation is not available
|
2014-12-09 06:50:29 -05:00
|
|
|
*/
|
2014-12-09 08:27:02 -05:00
|
|
|
protected function getPath()
|
2014-12-09 06:50:29 -05:00
|
|
|
{
|
2014-12-09 08:55:24 -05:00
|
|
|
$path = Icinga::app()->getBaseDir('doc');
|
|
|
|
|
if (is_dir($path)) {
|
|
|
|
|
return $path;
|
|
|
|
|
}
|
2014-12-09 08:27:02 -05:00
|
|
|
if (($path = $this->Config()->get('documentation', 'icingaweb2')) !== null) {
|
|
|
|
|
if (is_dir($path)) {
|
|
|
|
|
return $path;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
throw new Zend_Controller_Action_Exception(
|
|
|
|
|
$this->translate('Documentation for Icinga Web 2 is not available'),
|
|
|
|
|
404
|
|
|
|
|
);
|
2014-12-09 06:50:29 -05:00
|
|
|
}
|
|
|
|
|
|
2014-05-27 08:50:48 -04:00
|
|
|
/**
|
2014-07-28 13:17:03 -04:00
|
|
|
* View the toc of Icinga Web 2's documentation
|
2014-05-27 08:50:48 -04:00
|
|
|
*/
|
|
|
|
|
public function tocAction()
|
2014-05-23 03:40:00 -04:00
|
|
|
{
|
2014-12-09 08:28:58 -05:00
|
|
|
$this->renderToc($this->getPath(), 'Icinga Web 2', 'doc/icingaweb/chapter');
|
2014-05-23 03:40:00 -04:00
|
|
|
}
|
2014-05-27 09:07:49 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* View a chapter of Icinga Web 2's documentation
|
|
|
|
|
*
|
2014-08-19 03:45:53 -04:00
|
|
|
* @throws Zend_Controller_Action_Exception If the required parameter 'chapterId' is missing
|
2014-05-27 09:07:49 -04:00
|
|
|
*/
|
|
|
|
|
public function chapterAction()
|
|
|
|
|
{
|
2014-08-19 03:45:53 -04:00
|
|
|
$chapterId = $this->getParam('chapterId');
|
|
|
|
|
if ($chapterId === null) {
|
2014-07-28 13:17:03 -04:00
|
|
|
throw new Zend_Controller_Action_Exception(
|
2014-12-09 08:28:10 -05:00
|
|
|
sprintf($this->translate('Missing parameter \'%s\''), 'chapterId'),
|
2014-07-28 13:17:03 -04:00
|
|
|
404
|
|
|
|
|
);
|
2014-05-27 09:07:49 -04:00
|
|
|
}
|
2014-12-09 08:28:58 -05:00
|
|
|
$this->renderChapter(
|
2014-12-09 08:27:02 -05:00
|
|
|
$this->getPath(),
|
2014-08-19 05:30:56 -04:00
|
|
|
$chapterId,
|
|
|
|
|
'doc/icingaweb/toc',
|
|
|
|
|
'doc/icingaweb/chapter'
|
|
|
|
|
);
|
2014-07-28 13:17:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* View Icinga Web 2's documentation as PDF
|
|
|
|
|
*/
|
|
|
|
|
public function pdfAction()
|
|
|
|
|
{
|
2014-12-09 08:28:58 -05:00
|
|
|
$this->renderPdf($this->getPath(), 'Icinga Web 2', 'doc/icingaweb/chapter');
|
2014-05-27 09:07:49 -04:00
|
|
|
}
|
2014-05-23 03:40:00 -04:00
|
|
|
}
|