view nav.inc.php @ 17:081ba8764994 owls-2.0

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 wrap: on
line source

  <ul id="nav">

<?php

	define('BASE', 'data/');

	echo '    <li><a href="."'. (empty($_GET['path']) ? ' id="selected"' : '') .">Home</a></li>";
	// build nav tree
	echo '    '. navtree("") ."\n";
?>


  </ul>

<?php



/* recursive function creates the output for the nav tree */
function navtree($root) {

	if (!empty($root)) {
		$root .= '/';
	}
	$files = scandir(BASE."$root");
	$return = '';
	foreach ($files as $f) {
		if (!is_dir(BASE."$root$f") || substr($f, 0, 1) == '.') {
			continue;
		}
		$return .= "<li><a href=\"?path=$root$f\"". ((isset($_GET['path']) && $_GET['path'] == "$root$f") ? ' id="selected"' : '') .">$f</a>";
		$subtree = navtree("$root$f");
		if (!empty($subtree)) {
			$return .= "<ul>$subtree</ul>";
		}
		unset($subtree);
	}
	$return .= '</li>';
	return $return;
}

?>