parent
88e13c378d
commit
f96974fc79
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
// @codingStandardsIgnoreStart
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
use Icinga\Web\Controller\ActionController;
|
||||
use Icinga\Web\Menu;
|
||||
use Icinga\Web\Url;
|
||||
|
||||
class LayoutController extends ActionController
|
||||
{
|
||||
public function menuAction()
|
||||
{
|
||||
$this->view->url = Url::fromRequest()->getRelativeUrl();
|
||||
$this->view->items = Menu::fromConfig()->getChildren();
|
||||
$this->view->sub = false;
|
||||
}
|
||||
}
|
||||
// @codingStandardsIgnoreEnd
|
|
@ -1,9 +1,12 @@
|
|||
<?php echo $this->render('parts/topbar.phtml') ?>
|
||||
<div class="row">
|
||||
|
||||
<!-- Only required for left/right tabs -->
|
||||
<div class="col-sm-12 col-xs-12 col-md-2 col-lg-2" id="menu">
|
||||
<?php echo $this->render('parts/navigation.phtml') ?>
|
||||
<div class="col-sm-12 col-xs-12 col-md-2 col-lg-2">
|
||||
<?= $this->partial('layout/menu.phtml', 'default', array(
|
||||
'url' => \Icinga\Web\Url::fromRequest()->getRelativeUrl(),
|
||||
'items' => \Icinga\Web\Menu::fromConfig()->getChildren(),
|
||||
'sub' => false
|
||||
)); ?>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-12 col-xs-12 col-md-10 col-lg-10">
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
<ul>
|
||||
<?php
|
||||
|
||||
foreach ($this->items as $item) {
|
||||
|
||||
printf(
|
||||
' <li%s><a href="%s">%s%s</a>',
|
||||
$this->href($this->url) === $this->href($item->getUrl()) ? ' class="active"' : '',
|
||||
$item->getUrl() ? $this->href($item->getUrl()) : '#',
|
||||
$item->getIcon() ? $this->img(
|
||||
$item->getIcon(),
|
||||
array('height' => '16px', 'width' => '16px')
|
||||
) . ' ' : '',
|
||||
$item->getTitle()
|
||||
);
|
||||
|
||||
if ($item->hasChildren()) {
|
||||
echo $this->partial(
|
||||
'parts/menu.phtml',
|
||||
array('items' => $item->getChildren(), 'url' => $this->url)
|
||||
);
|
||||
}
|
||||
|
||||
echo "</li>\n";
|
||||
}
|
||||
|
||||
?>
|
||||
</ul>
|
|
@ -1,7 +1,5 @@
|
|||
<?php
|
||||
// determine current key
|
||||
$url = Icinga\Web\Url::fromRequest()->getRelativeUrl();
|
||||
$menu = Icinga\Web\Menu::fromConfig();
|
||||
|
||||
|
||||
if ($this->auth()->isAuthenticated()) {
|
||||
echo $this->partial(
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
<ul>
|
||||
<?= $sub ? '<ul>' : '<ul class="nav nav-stacked" role="navigation" id="icinganavigation">' ?>
|
||||
<?php foreach ($items as $item): ?>
|
||||
<?php
|
||||
$itemClass = '';
|
||||
if ($sub) {
|
||||
$itemClass .= 'submenu ';
|
||||
}
|
||||
if ($this->href($url) === $this->href($item->getUrl())) {
|
||||
$itemClass .= 'active ';
|
||||
}
|
||||
?>
|
||||
<li <?php if (!empty($itemClass)): ?>class="<?= $itemClass ?>"<?php endif ?>>
|
||||
<?php if($item->getUrl()): ?>
|
||||
<a href="<?= $this->href($item->getUrl()); ?>">
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
if ($icon = $item->getIcon()) {
|
||||
echo $this->img($icon, array('height' => '16px', 'width' => '16px'));
|
||||
}
|
||||
?>
|
||||
<?php if ($iconClass = $item->getIconClass()): ?>
|
||||
<i class="<?= $iconClass ?>"></i>
|
||||
<?php endif ?>
|
||||
<?= $item->getTitle();?>
|
||||
<?php if($item->getUrl()): ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
if($item->hasChildren()) {
|
||||
echo $this->partial(
|
||||
'layout/menu.phtml',
|
||||
'default',
|
||||
array('items' => $item->getChildren(), 'sub' => true, 'url' => $this->url)
|
||||
);
|
||||
}
|
||||
?>
|
||||
</li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
|
@ -3,13 +3,16 @@
|
|||
<?php else: ?>
|
||||
<div class="row">
|
||||
<div class="col-sm-12 col-xs-12 col-md-2 col-lg-2">
|
||||
<ul class="nav nav-pills nav-stacked" role="navigation">
|
||||
<?php foreach ($toc as $i): ?>
|
||||
<li class="toc-h<?= $i['level'] ?>">
|
||||
<a href="#<?= $i['fragment'] ?>"><?= $this->escape($i['heading']); ?></a>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?= $this->partial(
|
||||
'layout/menu.phtml',
|
||||
'default',
|
||||
array(
|
||||
'items' => $toc->getChildren(),
|
||||
'sub' => false,
|
||||
'url' => ''
|
||||
)
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
<div class="col-sm-12 col-xs-12 col-md-10 col-lg-10">
|
||||
<?= $html ?>
|
||||
|
|
|
@ -6,6 +6,7 @@ namespace Icinga\Module\Doc;
|
|||
|
||||
use Icinga\Module\Doc\DocParser;
|
||||
use Icinga\Web\Controller\ActionController;
|
||||
use Icinga\Web\Menu;
|
||||
|
||||
class Controller extends ActionController
|
||||
{
|
||||
|
|
|
@ -6,10 +6,12 @@ namespace Icinga\Module\Doc;
|
|||
|
||||
require_once 'vendor/Parsedown/Parsedown.php';
|
||||
|
||||
use \Exception;
|
||||
use \SplStack;
|
||||
use \RecursiveIteratorIterator;
|
||||
use \RecursiveDirectoryIterator;
|
||||
use \Exception;
|
||||
use \Parsedown;
|
||||
use Icinga\Web\Menu;
|
||||
|
||||
/**
|
||||
* Parser for documentation written in Markdown
|
||||
|
@ -33,8 +35,9 @@ class DocParser
|
|||
);
|
||||
$fileInfos = iterator_to_array($iter);
|
||||
natcasesort($fileInfos);
|
||||
$cat = array();
|
||||
$toc = array();
|
||||
$cat = array();
|
||||
$toc = new Menu('doc');
|
||||
$stack = new SplStack();
|
||||
foreach ($fileInfos as $fileInfo) {
|
||||
try {
|
||||
$fileObject = $fileInfo->openFile();
|
||||
|
@ -52,14 +55,24 @@ class DocParser
|
|||
) {
|
||||
// Atx-style
|
||||
$level = strlen($match[0]);
|
||||
$heading = trim(strip_tags(substr($line, $level)));
|
||||
$heading = str_replace('.', '.', trim(strip_tags(substr($line, $level))));
|
||||
$fragment = urlencode($heading);
|
||||
$toc[] = array(
|
||||
'heading' => $heading,
|
||||
'level' => $level,
|
||||
'fragment' => $fragment
|
||||
);
|
||||
$line = '<span id="' . $fragment . '">' . "\n" . $line;
|
||||
$line = '<span id="' . $fragment . '">' . "\n" . $line;
|
||||
$stack->rewind();
|
||||
while ($stack->valid() && $stack->current()->level >= $level) {
|
||||
$stack->pop();
|
||||
$stack->next();
|
||||
}
|
||||
$parent = $stack->current();
|
||||
if ($parent === null) {
|
||||
$item = $toc->addChild($heading, array('url' => '#' . $fragment));
|
||||
} else {
|
||||
$item = $parent->item->addChild($heading, array('url' => '#' . $fragment));
|
||||
}
|
||||
$stack->push((object) array(
|
||||
'level' => $level,
|
||||
'item' => $item
|
||||
));
|
||||
} elseif (
|
||||
$line &&
|
||||
($line[0] === '=' || $line[0] === '-') &&
|
||||
|
@ -70,17 +83,27 @@ class DocParser
|
|||
// H1
|
||||
$level = 1;
|
||||
} else {
|
||||
// H2
|
||||
// H
|
||||
$level = 2;
|
||||
}
|
||||
$heading = trim(strip_tags(end($cat)));
|
||||
$fragment = urlencode($heading);
|
||||
$toc[] = array(
|
||||
'heading' => $heading,
|
||||
'level' => $level,
|
||||
'fragment' => $fragment
|
||||
);
|
||||
$line = '<span id="' . $fragment . '">' . "\n" . $line;
|
||||
$line = '<span id="' . $fragment . '">' . "\n" . $line;
|
||||
$stack->rewind();
|
||||
while ($stack->valid() && $stack->current()->level >= $level) {
|
||||
$stack->pop();
|
||||
$stack->next();
|
||||
}
|
||||
$parent = $stack->current();
|
||||
if ($parent === null) {
|
||||
$item = $toc->addChild($heading, array('url' => '#' . $fragment));
|
||||
} else {
|
||||
$item = $parent->item->addChild($heading, array('url' => '#' . $fragment));
|
||||
}
|
||||
$stack->push((object) array(
|
||||
'level' => $level,
|
||||
'item' => $item
|
||||
));
|
||||
}
|
||||
$cat[] = $line;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue