owls

annotate nav.inc.php @ 17:081ba8764994

The wiki-like system became a content-rendering system This is a single changeset to include all the changes throughout the last years. Owls no longer supports editing pages but only renders them. Also, it no longer uses a database to store the contents but reads the contents from the filesystem. All this made owls simpler ... anyway, it just reflects my needs.
author markus schnalke <meillo@marmaro.de>
date Sat, 23 Jul 2016 21:39:17 +0200
parents Nav.inc.php@3e3fa7725abb
children
rev   line source
meillo@0 1 <ul id="nav">
meillo@0 2
meillo@0 3 <?php
meillo@2 4
meillo@17 5 define('BASE', 'data/');
meillo@2 6
meillo@17 7 echo ' <li><a href="."'. (empty($_GET['path']) ? ' id="selected"' : '') .">Home</a></li>";
meillo@17 8 // build nav tree
meillo@17 9 echo ' '. navtree("") ."\n";
meillo@0 10 ?>
meillo@0 11
meillo@0 12
meillo@0 13 </ul>
meillo@0 14
meillo@0 15 <?php
meillo@0 16
meillo@2 17
meillo@0 18
meillo@17 19 /* recursive function creates the output for the nav tree */
meillo@17 20 function navtree($root) {
meillo@2 21
meillo@17 22 if (!empty($root)) {
meillo@17 23 $root .= '/';
meillo@17 24 }
meillo@17 25 $files = scandir(BASE."$root");
meillo@17 26 $return = '';
meillo@17 27 foreach ($files as $f) {
meillo@17 28 if (!is_dir(BASE."$root$f") || substr($f, 0, 1) == '.') {
meillo@17 29 continue;
meillo@17 30 }
meillo@17 31 $return .= "<li><a href=\"?path=$root$f\"". ((isset($_GET['path']) && $_GET['path'] == "$root$f") ? ' id="selected"' : '') .">$f</a>";
meillo@17 32 $subtree = navtree("$root$f");
meillo@17 33 if (!empty($subtree)) {
meillo@17 34 $return .= "<ul>$subtree</ul>";
meillo@17 35 }
meillo@17 36 unset($subtree);
meillo@17 37 }
meillo@17 38 $return .= '</li>';
meillo@17 39 return $return;
meillo@17 40 }
meillo@0 41
meillo@0 42 ?>