2014-05-23 09:40:00 +02:00
|
|
|
<?php
|
2015-02-04 10:46:36 +01:00
|
|
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
2014-05-23 09:40:00 +02:00
|
|
|
|
2015-08-27 14:39:15 +02:00
|
|
|
namespace Icinga\Module\Doc\Controllers;
|
|
|
|
|
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
|
|
|
|
2015-08-27 14:39:15 +02:00
|
|
|
class IcingawebController extends DocController
|
2014-05-23 09:40:00 +02:00
|
|
|
{
|
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
|
|
|
|
*
|
2015-08-27 14:40:49 +02:00
|
|
|
* @throws \Icinga\Exception\Http\HttpNotFoundException 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:55:24 +01:00
|
|
|
$path = Icinga::app()->getBaseDir('doc');
|
|
|
|
if (is_dir($path)) {
|
|
|
|
return $path;
|
|
|
|
}
|
2014-12-09 14:27:02 +01:00
|
|
|
if (($path = $this->Config()->get('documentation', 'icingaweb2')) !== null) {
|
|
|
|
if (is_dir($path)) {
|
|
|
|
return $path;
|
|
|
|
}
|
|
|
|
}
|
2015-07-28 11:54:00 +02:00
|
|
|
$this->httpNotFound($this->translate('Documentation for Icinga Web 2 is not available'));
|
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:28:58 +01:00
|
|
|
$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
|
|
|
|
*
|
2015-07-28 13:59:39 +02:00
|
|
|
* @throws \Icinga\Exception\MissingParameterException If the required parameter 'chapter' is missing
|
2014-05-27 15:07:49 +02:00
|
|
|
*/
|
|
|
|
public function chapterAction()
|
|
|
|
{
|
2015-07-28 13:59:39 +02:00
|
|
|
$chapter = $this->params->getRequired('chapter');
|
2014-12-09 14:28:58 +01:00
|
|
|
$this->renderChapter(
|
2014-12-09 14:27:02 +01:00
|
|
|
$this->getPath(),
|
2015-02-10 17:09:56 +01:00
|
|
|
$chapter,
|
2014-08-19 11:30:56 +02:00
|
|
|
'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:28:58 +01:00
|
|
|
$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
|
|
|
}
|