2014-02-03 15:39:53 +01:00
|
|
|
<?php
|
2015-02-04 10:46:36 +01:00
|
|
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
2014-02-03 15:39:53 +01:00
|
|
|
|
|
|
|
namespace Icinga\Module\Doc;
|
|
|
|
|
2014-07-01 12:42:55 +02:00
|
|
|
use Icinga\Web\Controller\ModuleActionController;
|
2014-02-03 15:39:53 +01:00
|
|
|
|
2014-07-01 12:42:55 +02:00
|
|
|
class DocController extends ModuleActionController
|
2014-02-03 15:39:53 +01:00
|
|
|
{
|
|
|
|
/**
|
2014-07-28 19:17:03 +02:00
|
|
|
* Render a chapter
|
2014-02-03 15:39:53 +01:00
|
|
|
*
|
2014-07-28 19:17:03 +02:00
|
|
|
* @param string $path Path to the documentation
|
2014-08-19 09:45:53 +02:00
|
|
|
* @param string $chapterId ID of the chapter
|
2014-08-19 11:30:56 +02:00
|
|
|
* @param string $tocUrl
|
2014-07-28 19:17:03 +02:00
|
|
|
* @param string $url
|
|
|
|
* @param array $urlParams
|
2014-02-03 15:39:53 +01:00
|
|
|
*/
|
2014-08-19 11:30:56 +02:00
|
|
|
protected function renderChapter($path, $chapterId, $tocUrl, $url, array $urlParams = array())
|
2014-02-03 15:39:53 +01:00
|
|
|
{
|
2014-05-27 15:06:48 +02:00
|
|
|
$parser = new DocParser($path);
|
2014-07-28 19:17:03 +02:00
|
|
|
$this->view->sectionRenderer = new SectionRenderer(
|
|
|
|
$parser->getDocTree(),
|
2014-08-19 09:45:53 +02:00
|
|
|
SectionRenderer::decodeUrlParam($chapterId),
|
2014-08-19 11:30:56 +02:00
|
|
|
$tocUrl,
|
2014-07-28 19:17:03 +02:00
|
|
|
$url,
|
|
|
|
$urlParams
|
|
|
|
);
|
2014-08-19 13:38:18 +02:00
|
|
|
$this->view->title = $chapterId;
|
2014-12-09 14:24:45 +01:00
|
|
|
$this->render('chapter', null, true);
|
2014-02-03 15:39:53 +01:00
|
|
|
}
|
2014-05-27 14:49:32 +02:00
|
|
|
|
|
|
|
/**
|
2014-07-28 19:17:03 +02:00
|
|
|
* Render a toc
|
2014-05-27 14:49:32 +02:00
|
|
|
*
|
2014-07-28 19:17:03 +02:00
|
|
|
* @param string $path Path to the documentation
|
|
|
|
* @param string $name Name of the documentation
|
|
|
|
* @param string $url
|
|
|
|
* @param array $urlParams
|
2014-05-27 14:49:32 +02:00
|
|
|
*/
|
2014-07-28 19:17:03 +02:00
|
|
|
protected function renderToc($path, $name, $url, array $urlParams = array())
|
2014-05-27 14:49:32 +02:00
|
|
|
{
|
|
|
|
$parser = new DocParser($path);
|
2014-07-28 19:17:03 +02:00
|
|
|
$this->view->tocRenderer = new TocRenderer($parser->getDocTree(), $url, $urlParams);
|
2014-08-19 13:38:18 +02:00
|
|
|
$name = ucfirst($name);
|
2014-05-27 14:49:32 +02:00
|
|
|
$this->view->docName = $name;
|
2014-08-19 16:22:22 +02:00
|
|
|
$this->view->title = sprintf($this->translate('%s Documentation'), $name);
|
2014-12-09 14:24:45 +01:00
|
|
|
$this->render('toc', null, true);
|
2014-07-28 19:17:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Render a pdf
|
|
|
|
*
|
|
|
|
* @param string $path Path to the documentation
|
|
|
|
* @param string $name Name of the documentation
|
|
|
|
* @param string $url
|
|
|
|
* @param array $urlParams
|
|
|
|
*/
|
|
|
|
protected function renderPdf($path, $name, $url, array $urlParams = array())
|
|
|
|
{
|
|
|
|
$parser = new DocParser($path);
|
|
|
|
$docTree = $parser->getDocTree();
|
|
|
|
$this->view->tocRenderer = new TocRenderer($docTree, $url, $urlParams);
|
|
|
|
$this->view->sectionRenderer = new SectionRenderer(
|
|
|
|
$docTree,
|
|
|
|
null,
|
2014-08-19 11:30:56 +02:00
|
|
|
null,
|
2014-07-28 19:17:03 +02:00
|
|
|
$url,
|
|
|
|
$urlParams
|
|
|
|
);
|
|
|
|
$this->view->docName = $name;
|
|
|
|
$this->_request->setParam('format', 'pdf');
|
2014-12-09 14:24:45 +01:00
|
|
|
$this->render('pdf', null, true);
|
2014-05-27 14:49:32 +02:00
|
|
|
}
|
2014-05-23 09:36:14 +02:00
|
|
|
}
|