owls

diff 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
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/nav.inc.php	Sat Jul 23 21:39:17 2016 +0200
     1.3 @@ -0,0 +1,42 @@
     1.4 +  <ul id="nav">
     1.5 +
     1.6 +<?php
     1.7 +
     1.8 +	define('BASE', 'data/');
     1.9 +
    1.10 +	echo '    <li><a href="."'. (empty($_GET['path']) ? ' id="selected"' : '') .">Home</a></li>";
    1.11 +	// build nav tree
    1.12 +	echo '    '. navtree("") ."\n";
    1.13 +?>
    1.14 +
    1.15 +
    1.16 +  </ul>
    1.17 +
    1.18 +<?php
    1.19 +
    1.20 +
    1.21 +
    1.22 +/* recursive function creates the output for the nav tree */
    1.23 +function navtree($root) {
    1.24 +
    1.25 +	if (!empty($root)) {
    1.26 +		$root .= '/';
    1.27 +	}
    1.28 +	$files = scandir(BASE."$root");
    1.29 +	$return = '';
    1.30 +	foreach ($files as $f) {
    1.31 +		if (!is_dir(BASE."$root$f") || substr($f, 0, 1) == '.') {
    1.32 +			continue;
    1.33 +		}
    1.34 +		$return .= "<li><a href=\"?path=$root$f\"". ((isset($_GET['path']) && $_GET['path'] == "$root$f") ? ' id="selected"' : '') .">$f</a>";
    1.35 +		$subtree = navtree("$root$f");
    1.36 +		if (!empty($subtree)) {
    1.37 +			$return .= "<ul>$subtree</ul>";
    1.38 +		}
    1.39 +		unset($subtree);
    1.40 +	}
    1.41 +	$return .= '</li>';
    1.42 +	return $return;
    1.43 +}
    1.44 +
    1.45 +?>