icingaweb2/application/layouts/scripts/parts/navigation.phtml

52 lines
1.4 KiB
PHTML
Raw Normal View History

<?php
// determine current key
$url = Zend_Controller_Front::getInstance()->getRequest()->getRequestUri();
$currentKey = isset($this->navkey) ? $this->navkey : $url;
$item = $this->navigation->keys("menu");
?>
<?php if ($this->auth()->isAuthenticated()): ?>
<ul class="nav nav-stacked" role="navigation" id="icinganavigation">
<?php
$activeSet = false;
foreach ($item as $itemName) {
if($itemName[0] == "_") {
?>
<li class="section-end"></li>
<?php
continue;
}
$item = $this->navigation->menu->$itemName;
$active = false;
$url = "";
2013-10-14 13:00:27 +02:00
$iconClass = '';
if (is_string($item)) {
$active = !$activeSet && $this->baseUrl($item) == $currentKey;
$url = $this->baseUrl($item);
} else {
$url = $this->baseUrl(isset($item->route) ? $item->route : "");
$itemName = isset($item->title) ? $item->title : $itemName;
$active = !$activeSet && (isset($item->key) ? $item->key : $url) === $currentKey;
2013-10-14 13:00:27 +02:00
if (isset($item->iconClass)) {
$iconClass = $item->iconClass;
}
}
$activeSet = $activeSet || $active;
?>
2013-10-16 14:48:22 +02:00
<li class="<?= $active ? "active" : "" ?>">
<a href="<?= $url ?>">
<?php if ($iconClass): ?>
<i class="<?= $iconClass; ?>"></i>
<?php endif; ?>
<?= $itemName ?>
</a>
</li>
<?php
$class = "";
}
?>
</ul>
<? endif ?>