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

	$GLOBALS['permnavcat'] = "";
	$GLOBALS['permnavitem'] = "";
	$GLOBALS['maindir'] = "";

	# 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');

		echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">";
		echo "<HTML>\n";
		echo "<HEAD>\n";
		echo "	<TITLE>$pageTitle</TITLE>\n";
		echo "	<LINK REL=StyleSheet HREF=\"" . $maindir . "mainstyle.css\" TYPE=\"text/css\" MEDIA=\"screen,print\">\n";
		if ($navItem == "Screenshots") {
			echo "	<LINK REL=StyleSheet HREF=\"" . $maindir . "screenshots.css\" TYPE=\"text/css\" MEDIA=\"screen,print\">\n";
			echo "	<LINK REL=StyleSheet HREF=\"" . $maindir . "highslide/highslide.css\" TYPE=\"text/css\" MEDIA=\"screen,print\">\n";
		}
		echo "	<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\">\n";
		echo "</HEAD>\n";
?>
<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">
			<DIV ID="titlecenter">
			<H1 ID="title"><?php echo($pageTitle) ?></H1>
		</DIV>
		</DIV>
<?php
			if ($navItem != "Donations") {
				echo "<DIV ID=\"titlenotif\">\n";
				echo "	 <P CLASS=\"notifhead\"><A HREF=\"" . $maindir . "donate.php\">Help Keep TDE Alive - Donate Now!</A>\n";
				echo "</DIV>\n";
			}

			$GLOBALS['permnavcat'] = $navCategory;
			$GLOBALS['permnavitem'] = $navItem;
			$GLOBALS['maindir'] = $maindir;
?>
		</DIV>
	</DIV>
	<DIV ID="intermediate">
		<DIV ID="textblock">
			<!--Content goes here-->
<?php
	} #end of doHeader


	function doFooter(){
        $navset = array(  #change this array to alter the navigation scheme
        "Home" =>  array("_" => $GLOBALS['maindir'] . "index.php",
                "News" => $GLOBALS['maindir'] . "news.php",
                "About" => $GLOBALS['maindir'] . "about.php",
                "Features" => $GLOBALS['maindir'] . "features.php",
                "Screenshots" => $GLOBALS['maindir'] . "screenshots.php",
                "Get Involved" => $GLOBALS['maindir'] . "helpwanted.php",
                "Donations" => $GLOBALS['maindir'] . "donate.php",
            ),
        "Get Trinity" => array("_" => $GLOBALS['maindir'] . "releases.php",
                "Packages" => $GLOBALS['maindir'] . "releases.php",
                "LiveCDs" => "https://wiki.trinitydesktop.org/LiveCDs",
            ),
        "Documentation" => array("_" => $GLOBALS['maindir'] . "docs/index.php",
                "Wiki" => "https://wiki.trinitydesktop.org/",
                "Installation" => "https://wiki.trinitydesktop.org/Category:Documentation#Installing_from_a_Package_Manager",
                "Applications" => $GLOBALS['maindir'] . "applications.php",
                "FAQ" => $GLOBALS['maindir'] . "faq/index.php",
            ),
        "Support" => array("_" => $GLOBALS['maindir'] . "support.php",
                "Bugs" => "https://mirror.git.trinitydesktop.org/gitea/issues",
                "Mailing Lists" => $GLOBALS['maindir'] . "mailinglist.php",
                "Service Alerts" => $GLOBALS['maindir'] . "servicealerts/",
                "TDE Team" => $GLOBALS['maindir'] . "contributors.php",
            ),
        "Development" => array("_" => $GLOBALS['maindir'] . "development.php",
                "TGW" => "https://mirror.git.trinitydesktop.org/gitea/TDE",
                "CGit" => "https://mirror.git.trinitydesktop.org/cgit/",
                "Translations" => "https://mirror.git.trinitydesktop.org/weblate",
                "Commit History" => $GLOBALS['maindir'] . "patches",
                "Resources" => $GLOBALS['maindir'] . "devresources.php",

            ),
        );


		echo('			<!--end content-->'."\n");
		echo('			<hr class="footer" />'."\n");
		date_default_timezone_set('UTC');   #else the interpreter whines
		echo('			<P ID="copyright">&copy; 2010-' . date('Y') . ' Trinity Desktop Project</P>'."\n");

?>
		</DIV>
		</DIV>

	</DIV>
	<DIV CLASS="equal" ID="main">
		<DIV CLASS="row">
			<DIV ID="sidebar">
			<DIV ID="sidetext">
<?php
     foreach ($navset as $navsectname => $urls){
         if ($navsectname != "Documentation") {
             echo("			<DIV CLASS=\"navblock\">\n");
         }
         if (($GLOBALS['permnavitem'] == "_") && ($navsectname == $GLOBALS['permnavcat'])) {
             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 ($GLOBALS['permnavitem'] == $navname) {
                 echo("			<P CLASS='nav' ID='curpage'><A HREF=\"$url\">$navname</A>\n");
             }
             else {
                 echo("			<P CLASS='nav'><A HREF=\"$url\">$navname</A>\n");
             }
             }
         }
         if ($navsectname != "Get Trinity") {
            echo("			</DIV>\n");
        }
     }
?>
		</DIV>
		</DIV>
	</DIV>
</BODY>
</HTML>

<?php
	} #end of doFooter
?>
