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;
|
|
|
|
|
2015-02-11 14:10:12 +01:00
|
|
|
use Icinga\Module\Doc\Renderer\DocSectionRenderer;
|
|
|
|
use Icinga\Module\Doc\Renderer\DocTocRenderer;
|
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
|
|
|
*
|
2015-02-10 17:09:56 +01:00
|
|
|
* @param string $path Path to the documentation
|
|
|
|
* @param string $chapter ID of the chapter
|
|
|
|
* @param string $url URL to replace links with
|
|
|
|
* @param array $urlParams Additional URL parameters
|
2014-02-03 15:39:53 +01:00
|
|
|
*/
|
2015-02-10 17:09:56 +01:00
|
|
|
protected function renderChapter($path, $chapter, $url, array $urlParams = array())
|
2014-02-03 15:39:53 +01:00
|
|
|
{
|
2014-05-27 15:06:48 +02:00
|
|
|
$parser = new DocParser($path);
|
2015-02-11 14:01:19 +01:00
|
|
|
$section = new DocSectionRenderer($parser->getDocTree(), DocSectionRenderer::decodeUrlParam($chapter));
|
2015-02-10 17:09:56 +01:00
|
|
|
$this->view->section = $section
|
|
|
|
->setUrl($url)
|
2015-02-11 13:21:01 +01:00
|
|
|
->setUrlParams($urlParams)
|
|
|
|
->setHighlightSearch($this->params->get('highlight-search'));
|
2015-02-10 17:09:56 +01:00
|
|
|
$this->view->title = $chapter;
|
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
|
|
|
*
|
2015-02-10 17:09:56 +01:00
|
|
|
* @param string $path Path to the documentation
|
|
|
|
* @param string $name Name of the documentation
|
|
|
|
* @param string $url URL to replace links with
|
|
|
|
* @param array $urlParams Additional URL parameters
|
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);
|
2015-02-11 14:02:12 +01:00
|
|
|
$toc = new DocTocRenderer($parser->getDocTree()->getIterator());
|
2015-02-10 17:09:56 +01:00
|
|
|
$this->view->toc = $toc
|
|
|
|
->setUrl($url)
|
|
|
|
->setUrlParams($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
|
|
|
}
|