<?php

#############################################################################
#                              Site@School
# menu2.php: last changed 29/06/2006  , version: 2.4.02
# by Fred Stuurman  (fc.stuurman@hccnet.nl)
# LICENSE INFORMATION: see LICENCE.txt in starnet directory
#$Id: menu2.php,v 1.1 2006/10/03 11:13:17 fstuurman Exp $
#############################################################################
if (!defined('IN_SAS'))
{
	die("Hacking attempt");
}

print "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"160\" bgcolor=\"$menu_parm[2]\">
<tr height=\"30\"><td>&nbsp</td></tr>";

$query = "SELECT id, name FROM $table_sections WHERE invisible != 'yes' ORDER BY sort";
$result = mysql_query($query) or die_script($query, mysql_error());
while ($sectionmenu = mysql_fetch_array($result))
{
	print "<tr><td align=\"right\">";
	if ($sectionmenu[0] == $section)
	{
		print "<a href=index.php?section=$sectionmenu[0]><img border=\"0\" src=\"$cmsdir/themes/$themelocation/tree_collapse.gif\"></a>";
	}
	else
	{
		print "<a href=index.php?section=$sectionmenu[0]><img border=\"0\" src=\"$cmsdir/themes/$themelocation/tree_expand.gif\"></a>";
	}

	print "</td><td height=\"20\"><b>
	        <a href=index.php?section=$sectionmenu[0] STYLE=\"font-family: $menu_parm[6];font-size : $menu_parm[7];
			color: $menu_parm[3]\">$sectionmenu[1] </a></b></td>
	        </tr>";
	if ($sectionmenu[0] == $section)
	{
		$query1 = "SELECT id, category FROM $table_pages WHERE section = '$section' GROUP BY category"; // getting catlist
		$result1 = mysql_query($query1) or die_script($query1, mysql_error());
		print "<tr><td align=\"center\">&nbsp;</td><td>";
		while ($cat_list = mysql_fetch_array($result1))
		{
			$category1 = htmlspecialchars(rawurlencode($cat_list[1]));

			print "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
			if (!empty ($cat_list[1])) //only display when category has no blanks
			{
				if ($cat_list[1] == $category)
				{
					print "<tr><td height=\"20\" align=\"right\"><img src=\"$cmsdir/themes/$themelocation/tree_collapse.gif\"></td>";
				}
				else
				{
					print "<tr><td height=\"20\" align=\"right\"><img src=\"$cmsdir/themes/$themelocation/tree_expand.gif\"></td>";
				}
				$query2 = "SELECT id FROM $table_pages 
										WHERE category = '$cat_list[1]' AND section = '$section' AND invisible != 'yes' 
										ORDER BY sort"; // getting starpage category
				$result2 = mysql_query($query2) or die_script($query2, mysql_error());
				$startpage = mysql_result($result2, 0, 0);
				print "<td><b><span class=\"menulink\"><a href=index.php?section=$sectionmenu[0]&category=$category1&page=$startpage 
									STYLE=\"font-family: $menu_parm[6];font-size : $menu_parm[7];color: $menu_parm[4]\">$cat_list[1]</a><br>
								   </span></b></td></tr>";
			}
			if ($cat_list[1] == $category)
			{
				$query2 = "SELECT id, name, module, invisible FROM $table_pages 
										WHERE category = '$category' AND section = '$section' AND invisible != 'yes' 
										ORDER BY sort"; // getting pagelist
				$result2 = mysql_query($query2) or die_script($query2, mysql_error());
				print "<tr><td>&nbsp;</td><td><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
				while ($page_list = mysql_fetch_array($result2)) //loop through pages
				{
					print "<tr><td height=\"20\"><img src=\"$cmsdir/themes/$themelocation/leaf.gif\"></td>";
					if (substr($page_list[2], 0, 5) == "http:")
					{
						print "<td><b><span class=\"menulink\"><a href=$page_list[2] target=\"_blank\" STYLE=\"font-family: $menu_parm[6];
													font-size : $menu_parm[7];color: $menu_parm[5]\">$page_list[1]</a><br>
													</span></b></td></tr>";
					}
					elseif (substr($page_list[2], 0, 5) == "file:")
					{
						$link = substr($page_list[2], 7);
						print "<td><b><span class=\"menulink\"><a href=$link target=\"_blank\" STYLE=\"font-family: $menu_parm[6];
													font-size : $menu_parm[7];color: $menu_parm[5]\">$page_list[1]</a><br>
													</span></b></td></tr>";
					}
					else
					{
						print "<td><b><span class=\"menulink\"><a href=index.php?section=$sectionmenu[0]&category=$category1&page=$page_list[0] 
													STYLE=\"font-family: $menu_parm[6];font-size : $menu_parm[7];color: $menu_parm[5]\">$page_list[1]</a><br>
												   </span></b></td></tr>";
					}
				}
				print "</table></td></tr>";
			}
			print "</td></tr></table>";
		}
	}
}
print "</table>";
//print "<tr><td colspan=\"2\">&nbsp;</td></tr>
//		<tr><td colspan=\"2\" align=\"center\"><img src=\"starnet/graphics/logo.gif\" alt=\"SiteSchool\" title=\"SiteSchool\"></td></tr></table>" ;
?>