<?php
	// (c) 2014 Trinity Desktop Project
	// All Rights Reserved
	// Authors: Elizabeth Liddell, Timothy Pearson, and Calvin Morrison

	#Outputs the Trinity page header, sidebar, and prefatory matter.  $pageTitle is the title of the 
	#page as it will appear in both the top banner and the browser's title bar, and $navCategory 
	#and $navItem point at the sidebar navigation item that are to be highlighted for this page.
	#If the string "_" is passed for $navItem, the top-level navigation category will be highlighted.
	#$maindir is the path to the top level site directory.  By default, it is empty.
	function doHeader($pageTitle, $navCategory, $navItem, $maindir = "/"){
		header('Content-Type: text/html; charset=utf-8');

		$navset = array(  #change this array to alter the navigation scheme
		"Home" =>  array("_" => $maindir . "index.php",
				"News" => $maindir . "news.php",
				"Features" => $maindir . "features.php",
				"About" => $maindir . "about.php",
				"Contact" => $maindir . "support.php",
				"Screenshots" => $maindir . "screenshots.php",
			),
		"Get Trinity" => array("_" => $maindir . "releases.php",
				"Packages" => $maindir . "releases.php",
				"LiveCDs" => "https://wiki.trinitydesktop.org/LiveCDs",
			),
		"Documentation" => array("_" => $maindir . "./docs/index.php",
				"FAQ" => $maindir . "faq/index.php",
				"Installation" => "https://wiki.trinitydesktop.org/Category:Documentation#Installing_from_a_Package_Manager",
				"Applications" => $maindir . "applications.php",
#				"Handbooks" => $maindir . "handbooks.php",
			),
		"Bugs" => array("_" => "https://bugs.trinitydesktop.org/buglist.cgi?quicksearch=ALL"),
		"Wiki" =>  array("_" => "https://wiki.trinitydesktop.org/"),
		"Support" => array("_" => $maindir . "support.php",
				"Wiki" => "https://wiki.trinitydesktop.org/",
				"Bugs" => "https://bugs.trinitydesktop.org/buglist.cgi?quicksearch=ALL",
				"Docs" => "https://wiki.trinitydesktop.org/Category:Documentation",
				"Mailing Lists" => $maindir . "mailinglist.php",
				"Service Alerts" => $maindir . "servicealerts/",
			),
		"Development" => array("_" => $maindir . "development.php",
				"GIT" => "http://mirror.git.trinitydesktop.org/cgit/",
				"Commit History" => "/patches",
				"Packaging GIT" => "http://mirror.git.trinitydesktop.org/cgit/tde-packaging/",
				"uLab GIT" => "http://mirror.git.trinitydesktop.org/cgit/ulab/",
				"Secure GIT" => "https://git.trinitydesktop.org/cgit/",
				"Nightly Builds" => "https://quickbuild.pearsoncomputing.net/~trinity/+archive/ubuntu/trinity-nightly-builds/",
				"API Docs" => $maindir . "apidocs.php",
				"Related Projects" => $maindir . "relatedprojects.php",
				"Supported RFEs" => $maindir . "crfe/",
				"Get Involved" => $maindir . "helpwanted.php",
				"CLAs" => $maindir . "cla/",
				"TDE Team" => $maindir . "contributors.php",
				"Donations" => $maindir . "donate.php",
			),
		);
?>
<?php
		echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">";
		echo "<HTML>";
		echo "<HEAD>";
		echo "	<TITLE>$pageTitle</TITLE>";
		echo "	<LINK REL=StyleSheet HREF=\"" . $maindir . "mainstyle.css\" TYPE=\"text/css\" MEDIA=\"screen,print\">";
		if ($navItem == "Screenshots") {
			echo "	<LINK REL=StyleSheet HREF=\"" . $maindir . "screenshots.css\" TYPE=\"text/css\" MEDIA=\"screen,print\">";
			echo "	<LINK REL=StyleSheet HREF=\"" . $maindir . "highslide/highslide.css\" TYPE=\"text/css\" MEDIA=\"screen,print\">";
		}
		echo "	<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\">";
		echo "</HEAD>";
?>
		<BODY>
		<DIV ID="all-wrapper">
			<DIV ID="banner">
			<IMG ALT="" ID="bannerimg" SRC=<?php echo('"' . $maindir . 'media/bannerswoosh.png"')?>>
			<DIV ID="logowrap">
				<A HREF="index.php"><IMG ALT="" ID="logo" SRC=<?php echo('"' . $maindir . 'media/tde-logo.png"')?>></A>
			</DIV>
			<DIV ID="titlewrap">
				<H1 ID="title"><?php echo($pageTitle) ?></H1>
			</DIV>
<?php
			if ($navItem != "Donations") {
				echo "<DIV ID=\"titlenotif\">";
				echo "	 <P CLASS=\"notifhead\"><A HREF=\"" . $maindir . "donate.php\">Help Keep TDE Alive - Donate Now!</A>";
				echo "</DIV>";
			}
?>
			</DIV>
			<DIV CLASS="equal" ID="main">
			<DIV CLASS="row">
				<DIV ID="sidebar">
				<DIV ID="sidetext">
	<?php
		foreach ($navset as $navsectname => $urls){
			if (($navItem == "_") && ($navsectname == $navCategory)) {
				echo("                        <P CLASS=\"navhead\" ID=\"curpage\"><A HREF=\"" . $urls["_"] . "\">$navsectname</A>\n");
			} 
			else {
				echo("                        <P CLASS=\"navhead\"><A HREF=\"" . $urls["_"] . "\">$navsectname</A>\n");
			}
			foreach ($urls as $navname => $url){
				if (!($navname == "_")) {
				if ($navItem == $navname) {
					echo("                            <P CLASS='nav' ID='curpage'><A HREF=\"$url\">$navname</A>\n");
				}
				else {
					echo("                            <P CLASS='nav'><A HREF=\"$url\">$navname</A>\n");
				}
				}
			}
		}
	?>
			</DIV>
		</DIV>
		<DIV ID="intermediate">
			<DIV ID="textblock">
				<!--Content goes here-->
<?php
		} #end of doHeader
?>
