search is now template based

This commit is contained in:
skeeter 2000-12-02 08:53:17 +00:00
parent 0be3ad6331
commit 87abaada86
3 changed files with 65 additions and 48 deletions

View File

@ -26,22 +26,17 @@
$error = "";
if (strlen($keywords) == 0)
$error = lang("You must enter one or more search keywords.");
if (strlen($keywords) == 0) {
echo "<b>".lang("Error").":</b>";
echo lang("You must enter one or more search keywords.");
$phpgw->common->phpgw_footer();
exit;
}
$matches = 0;
?>
<H2><FONT COLOR="<?php echo $H2COLOR . "\">" . lang("Search Results"); ?></FONT></H2>
<?php
// There is currently a problem searching in with repeated events.
// It spits back out the date it was entered. I would like to to say that
// it is a repeated event.
if (strlen($error)) {
echo "<B>" . lang("Error") . ":</B> $error";
} else {
$ids = array();
$words = split(" ", $keywords);
for ($i = 0; $i < count($words); $i++) {
@ -66,32 +61,44 @@
. $phpgw->common->show_date($phpgw->db->f(2)) . ")";
}
}
}
if ($matches > 0)
$matches = count($ids);
if ($matches == 1)
echo "<B>1 match found.</B><P>";
$quantity = "1 match found.";
else if ($matches > 0)
echo "<B>" . lang("x matches found",$matches) . ".</B><P>";
$quantity = lang("x matches found",$matches).".";
else
$error = lang("no matches found.");
if($error) {
echo "<b>".lang("Error").":</b>";
echo $error;
$phpgw->common->phpgw_footer();
exit;
}
$phpgw->template->set_file(array("search_t" => "search.tpl",
"search_list" => "search_list.tpl"));
$phpgw->template->set_block("search_t","search_list");
$phpgw->template->set_var("color",$phpgw_info["theme"]["bg_text"]);
$phpgw->template->set_var("search_text",lang("Search Results"));
$phpgw->template->set_var("quantity",$quantity);
// now sort by number of hits
if (! strlen($error)) {
arsort ($ids);
for (reset($ids); $key = key($ids); next($ids)) {
echo "<LI><A HREF=\"" . $phpgw->link("view.php","id=$key") . "\">" . $info[$key] . "</A>\n";
$phpgw->template->set_var("url_result",$phpgw->link("view.php","id=$key"));
$phpgw->template->set_var("result_desc",$info[$key]);
$phpgw->template->parse("output","search_list",True);
}
} else {
echo $error;
}
?>
$phpgw->template->pparse("out","search_t");
<P>
<?php
$phpgw->common->phpgw_footer();
?>

View File

@ -0,0 +1,6 @@
<!-- $Id$ -->
<h2><font color="{color}">{search_text}</font></h2>
<b>{quantity}</b><p>
{output}
<p>

View File

@ -0,0 +1,4 @@
<!-- $Id$ -->
<!-- BEGIN search_list -->
<li><a href="{url_result}">{result_desc}</a>
<!-- END search_list -->