68 lines
2 KiB
PHP
68 lines
2 KiB
PHP
|
<?php
|
||
|
require_once $_SERVER["DOCUMENT_ROOT"]."/sys/site.php";
|
||
|
class Navbar {
|
||
|
function __construct($page) {
|
||
|
$nav_name = "Navigator";
|
||
|
if (gmdate('n') == 6 && rand(0, 10) == 1) {
|
||
|
$nav_name = "Navigaytor";
|
||
|
}
|
||
|
?>
|
||
|
<nav id="navigator">
|
||
|
<div class="title-bar"><h1><?=$nav_name?></h1></div>
|
||
|
<script src="/js/nav-toggle.js"></script>
|
||
|
<?php Navbar::construct_ul(Site::sitemap(), $page); ?>
|
||
|
</nav>
|
||
|
<?php
|
||
|
}
|
||
|
static function construct_ul($list,$page,$full = false) {
|
||
|
if ($page == NULL) {
|
||
|
$page = new Page("", "", [], NULL);
|
||
|
}
|
||
|
?>
|
||
|
<ul class="tree">
|
||
|
<?php
|
||
|
foreach ($list as $value) {
|
||
|
if (substr(basename($value->url),0,1) == "_") {
|
||
|
continue; // Don't list pages with an _ at the start of their title
|
||
|
}
|
||
|
|
||
|
$icon = $value->icon;
|
||
|
if ($icon == NULL) {
|
||
|
if (count($value->subpages) > 0) {
|
||
|
$icon = 'folder';
|
||
|
} else {
|
||
|
$icon = 'document';
|
||
|
}
|
||
|
if ($value->url == '/') {
|
||
|
$icon = 'folder_home';
|
||
|
}
|
||
|
}
|
||
|
if (($icon == 'folder' || $icon == 'folder_blue' || $icon == 'folder_cyan' || $icon == 'folder_green' || $icon == 'folder_grey' || $icon == 'folder_orange' || $icon == 'folder_red' || $icon == 'folder_violet' || $icon == 'folder_yellow') && (($value->url == $page->url) || (substr($page->url,0,strlen($value->url)) == $value->url) || $full)) {
|
||
|
$icon = $icon . '_open';
|
||
|
}
|
||
|
?>
|
||
|
<li class="<?php
|
||
|
if (count($value->subpages) > 0 && (($value->url == $page->url) || (substr($page->url,0,strlen($value->url)) == $value->url) || $full)) {
|
||
|
echo "down ";
|
||
|
}
|
||
|
if ($value->url == $page->url) {
|
||
|
echo "in";
|
||
|
}
|
||
|
?>">
|
||
|
<img class="icon" src="/assets/hicolor/<?=$icon?>.png" role="presentation" />
|
||
|
<a href="<?=$value->url?>"<?= ($value->url == $page->url) ? ' class="active"' : '' ?>><?=$value->title?></a>
|
||
|
<?php
|
||
|
if (count($value->subpages) > 0 && (($value->url == $page->url) || (substr($page->url,0,strlen($value->url)) == $value->url) || $full)) {
|
||
|
Navbar::construct_ul($value->subpages, $page, $full);
|
||
|
}
|
||
|
?>
|
||
|
</li>
|
||
|
<?php
|
||
|
}
|
||
|
?>
|
||
|
</ul>
|
||
|
<?php
|
||
|
}
|
||
|
}
|
||
|
?>
|