<?php

/*
** DGS Search
** $Id: stats.php,v 1.2 2006/01/24 07:08:09 sella Exp $
** Copyright (c) 2000-2001 Digital Genesis Software, LLC. All Rights Reserved.
** Released under the GPL Version 2 License.
** http://www.digitalgenesis.com
*/

function stats($retVal, $sq, $timer) {
	global $config, $css, $lang;

	$size = ($sq['s'] < 1) ? count($retVal) : $sq['s'];
	$target = $config['target'];
	$lowerBound = $sq['o'] + 1;
	$upperBound = ($sq['r'] + $sq['o'] < $size) ? $sq['o'] + $sq['r'] : $size;
	$searchTime = sprintf('%.1f', getTime() - $timer);
	$searchTime = ($searchTime > 0.0) ? $searchTime : 0.1;
	$cleanQ = $sq['cleanQ'];

	printf("\t<DIV CLASS=\"%s\"> <!-- Display Module: stats -->\n\t\t", $css['stats']);
	if ($size > 0) {
		$lang['stats'] = str_replace('@QUERY@', $cleanQ, $lang['stats']);
		$lang['stats'] = str_replace('@SEARCHTIME@', $searchTime, $lang['stats']);
		$lang['stats'] = str_replace('@LOWERBOUND@', $lowerBound, $lang['stats']);
		$lang['stats'] = str_replace('@UPPERBOUND@', $upperBound, $lang['stats']);
		$lang['stats'] = str_replace('@TOTALRESULTS@', $size, $lang['stats']);
		printf("%s", $lang['stats']);
	} else if (!$cleanQ) {
		$lang['noQuery'] = str_replace('@QUERY@', $cleanQ, $lang['noQuery']);
		$lang['noQuery'] = str_replace('@SEARCHTIME@', $searchTime, $lang['noQuery']);
		printf("%s", $lang['noQuery']);
	} else {
		$lang['noResults'] = str_replace('@QUERY@', $cleanQ, $lang['noResults']);
		$lang['noResults'] = str_replace('@SEARCHTIME@', $searchTime, $lang['noResults']);
		printf("%s", $lang['noResults']);
	}
	if ($config['timed'] && $cleanQ) {
		$lang['searchTime'] = str_replace('@QUERY@', $cleanQ, $lang['searchTime']);
		$lang['searchTime'] = str_replace('@TOTALRESULTS@', $size, $lang['searchTime']);
		$lang['searchTime'] = str_replace('@SEARCHTIME@', $searchTime, $lang['searchTime']);
		printf(' %s', $lang['searchTime']);
	}
	printf("\n\t</DIV>\n");

	return true;
}

/*
** Local Variables:
** c-basic-offset: 3
** tab-width: 3
** End:
** vim:
** vim: noet ts=3 sw=3
*/

?>
