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