<?php
if (!defined('IN_SAS'))
{
	die("Hacking attempt");
}

/*
** DGS Search
** nav.php written by James Sella
** Copyright (c) 2000-2001 Digital Genesis Software, LLC. All Rights Reserved.
** Released under the GPL Version 2 License.
** http://www.digitalgenesis.com
*#$Id: nav.php,v 1.1 2006/10/03 08:54:49 fstuurman Exp $
*/

function nav($retVal, $q, $r, $o, $s, $timer)
{
	global $config, $sas_lang, $serverpath, $site_url;

	$size = ($s < 1) ? count($retVal) : $s;
	$fonts = 'Arial, Sans-Serif, Helvetica';
	$navColor = '000000';
	$target = '_self';
	$installBase = "$serverpath/modules/dgs_search";
	$urlBase = $site_url;
	$siteBase = $serverpath;

	$searchURL = explode($siteBase, $installBase);
	/*	$searchURL = $urlBase . str_replace('\\', '/', $searchURL[1]) . '/search.php';*/
	$searchURL = $urlBase . 'index.php';

	//Fcs added for compatibilty with S@S	
	if (IsSet ($_GET['page']))
	{
		$page = $_GET['page'];
	}
	if (IsSet ($_GET['section']))
	{
		$section = $_GET['section'];
	}
	//Fcs end

	if ($size > 0)
	{
		printf("\t<DIV> <!-- Display Module: nav -->\n\t\t<DL>\n\t\t\t<DT>\n\t\t\t\t<FONT FACE=\"%s\" COLOR=\"%s\">%s: </FONT><FONT FACE=\"%s\">", $fonts, $navColor, $sas_lang['search_module_resultPages'], $fonts);
		$dispR = ($r == $config["maxResults"]) ? 0 : $r;
		$dispQ = str_replace(' ', '+', $q);
		$currPage = ($o + $r) / $r;
		if ($currPage > 1)
			printf("&nbsp;&nbsp;<A HREF=\"%s?section=$section&page=$page&q=%s&r=%d&o=%d&s=%d\" TARGET=\"%s\">%s</A> ", $searchURL, $dispQ, $r, $o - $r, $size, $target, $sas_lang['search_module_prev']);
		for ($i = 0; $i < $size / $r; $i++)
		{
			if ($currPage == $i +1)
				printf("<B>&nbsp;%d</B>", $i +1);
			else
				printf("&nbsp;&nbsp;<A HREF=\"%s?section=$section&page=$page&q=%s&r=%d&o=%d&s=%d\" TARGET=\"%s\">%d</A> ", $searchURL, $dispQ, $dispR, $i * $dispR, $size, $target, $i +1);
		}
		if ($currPage < $size / $r)
			printf("&nbsp;&nbsp;<A HREF=\"%s?section=$section&page=$page&q=%s&r=%d&o=%d&s=%d\" TARGET=\"%s\">%s</A> ", $searchURL, $dispQ, $r, $o + $r, $size, $target, $sas_lang['search_module_next']);
		printf("</FONT>\n\t\t\t</DT>\n\t\t</DL>\n\t</DIV>\n");
	}
	return true;
}
?>
