require("code/parse_structure.php");
if (count($elements) <= 0)
die("Error: structure.xml contains no content!");
// now, $version and $elements are set; we're going to use $elements primarily
// handle user input
if (!isset($_REQUEST["curfeature"]))
die("Error: no feature selected!");
$thispage = $elements[$_REQUEST["curfeature"]];
if ($thispage["type"] != "document")
die("Error: requested ID is not a document");
// ----------------------
// begin template engine
// ----------------------
require_once("../../rendering/template.php");
function process_comments($matches)
{
global $elements, $version, $thispage;
ob_start();
// main content
if ($matches[1] == "content")
{
if (is_readable($thispage["location"]))
include($thispage["location"]);
else
print "document does not exist, place it at \"".$thispage["location"]."\"!";
}
// properties
else if ($matches[1] == "property:")
{
$args = explode(":", $matches[1], 2);
print $thispage[$args[1]];
}
else if ($matches[1] == "version")
{
print $version;
}
// navigation
else if ($matches[1] == "leftnav")
{
if ($_REQUEST["curfeature"] > 0)
print "\n";
}
else if ($matches[1] == "rightnav")
{
if (($_REQUEST["curfeature"]+1) != count($elements))
print "\n";
}
// get the text from the print commands, put it in a string, send it back
$text = ob_get_contents();
ob_end_clean();
return $text;
}
LoadTemplate("../templates/document.html", "process_comments");
?>