owls

view nav.inc.php @ 18:98983ba58e2e

Added tag owls-2.0 for changeset 081ba8764994
author markus schnalke <meillo@marmaro.de>
date Sat, 23 Jul 2016 21:39:40 +0200
parents 3e3fa7725abb
children
line source
1 <ul id="nav">
3 <?php
5 define('BASE', 'data/');
7 echo ' <li><a href="."'. (empty($_GET['path']) ? ' id="selected"' : '') .">Home</a></li>";
8 // build nav tree
9 echo ' '. navtree("") ."\n";
10 ?>
13 </ul>
15 <?php
19 /* recursive function creates the output for the nav tree */
20 function navtree($root) {
22 if (!empty($root)) {
23 $root .= '/';
24 }
25 $files = scandir(BASE."$root");
26 $return = '';
27 foreach ($files as $f) {
28 if (!is_dir(BASE."$root$f") || substr($f, 0, 1) == '.') {
29 continue;
30 }
31 $return .= "<li><a href=\"?path=$root$f\"". ((isset($_GET['path']) && $_GET['path'] == "$root$f") ? ' id="selected"' : '') .">$f</a>";
32 $subtree = navtree("$root$f");
33 if (!empty($subtree)) {
34 $return .= "<ul>$subtree</ul>";
35 }
36 unset($subtree);
37 }
38 $return .= '</li>';
39 return $return;
40 }
42 ?>