<?php

#############################################################################
#                              Site@School Sitemap module
# Site@School is a website management system designed for schools.
# This is a sitemap module which can be used in Site@School.
#
# coded by Fred Stuurman (fc.stuurman@hccnet.nl)
############################################################################
# view_sitemap.php: last changed 25/11/2005  version 1.0.2
#                   by Fred Stuurman (fc.stuurman@hccnet.nl)
#$Id: view_sitemap_date.php,v 1.1 2006/10/03 10:34:54 fstuurman Exp $
############################################################################
#                        LICENSE INFORMATION
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
##############################################################################
if (!defined('IN_SAS'))
{
	die("Hacking attempt");
}
$query = "SELECT id, name, frontpage, invisible FROM $table_sections WHERE parent = '' AND invisible != 'yes' ORDER BY sort";
$result = mysql_query($query) or die_script($query, mysql_error());

load_language($cmsdir . '/', 'sn_sitemap'); //load language file

$item = $sas_lang['sitemap'];

if (!empty ($sas_config['sitemap_welcome_text']))
{
	print "<center><h2>" . $sas_config['sitemap_welcome_text'] . "</h2></center>";
}

while ($section_list = mysql_fetch_array($result))
{
	$i = 1;
	print "<a href=\"index.php?section=$section_list[0]\" style =\"color: #0000FF\"><b>$section_list[1]</b></a>";

	$query1 = "SELECT id, category FROM $table_pages WHERE section = '$section_list[0]' GROUP BY category"; // getting catlist
	$result1 = mysql_query($query1) or die_script($query1, mysql_error());

	while ($cat_list = mysql_fetch_array($result1)) //loop through categories
	{

		$category1 = htmlspecialchars(rawurlencode($cat_list[1]));

		if (!empty ($cat_list[1])) //only display when categrory has no blanks
		{
			if ($i == 1)
			{
				print "<ul>";
			} //only print the first time
			$i++;
			print "<li><a href=index.php?option=pagemanager&category=$category1&section=$section>$cat_list[1]</li>";
		}

		$query2 = "SELECT id, name, module, invisible, UNIX_TIMESTAMP(lastupdate) FROM $table_pages 
						WHERE category = '$cat_list[1]' and section = '$section_list[0]' AND invisible != 'yes' ORDER BY sort";
		$result2 = mysql_query($query2) or die_script($query2, mysql_error());

		print "<ul>";
		while ($page_list = mysql_fetch_array($result2))
		{
			$date = strftime($sas_config[dateformat], $page_list[4]);
			print "<table width=100%><tr><td width=20%>";
			if (substr($page_list[2], 0, 5) == "http:")
			{
				print "<li><a href=\"$page_list[2]\" target=\"_blank\">$page_list[1]</a></li>";
			}
			else
			{
				print "<li><a href=\"index.php?section=$section_list[0]&page=$page_list[0]\">$page_list[1]</a></li>";
			}
			print "<td><font size=2>&nbsp; - &nbsp;($date)</li></td></tr></table>";
		}

		print "</ul>";

	}
	if ($i > 1)
	{
		print "</ul>";
	}
	if ($i == 1)
	{
		print "<br>";
	}
}
?>
