mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-27 09:09:04 +01:00
search is now template based
This commit is contained in:
parent
0be3ad6331
commit
87abaada86
@ -26,72 +26,79 @@
|
|||||||
|
|
||||||
$error = "";
|
$error = "";
|
||||||
|
|
||||||
if (strlen($keywords) == 0)
|
if (strlen($keywords) == 0) {
|
||||||
$error = lang("You must enter one or more search keywords.");
|
echo "<b>".lang("Error").":</b>";
|
||||||
|
echo lang("You must enter one or more search keywords.");
|
||||||
|
$phpgw->common->phpgw_footer();
|
||||||
|
exit;
|
||||||
|
}
|
||||||
$matches = 0;
|
$matches = 0;
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
<H2><FONT COLOR="<?php echo $H2COLOR . "\">" . lang("Search Results"); ?></FONT></H2>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
// There is currently a problem searching in with repeated events.
|
// 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 spits back out the date it was entered. I would like to to say that
|
||||||
// it is a repeated event.
|
// it is a repeated event.
|
||||||
if (strlen($error)) {
|
$ids = array();
|
||||||
echo "<B>" . lang("Error") . ":</B> $error";
|
$words = split(" ", $keywords);
|
||||||
} else {
|
for ($i = 0; $i < count($words); $i++) {
|
||||||
$ids = array();
|
$sql = "SELECT DISTINCT calendar_entry.cal_id, calendar_entry.cal_name, "
|
||||||
$words = split(" ", $keywords);
|
. "calendar_entry.cal_datetime "
|
||||||
for ($i = 0; $i < count($words); $i++) {
|
. "FROM calendar_entry, calendar_entry_user "
|
||||||
$sql = "SELECT DISTINCT calendar_entry.cal_id, calendar_entry.cal_name, "
|
. "WHERE "
|
||||||
. "calendar_entry.cal_datetime "
|
. "(UPPER(calendar_entry.cal_name) LIKE UPPER('%".$words[$i]."%') OR "
|
||||||
. "FROM calendar_entry, calendar_entry_user "
|
. " UPPER(calendar_entry.cal_description) LIKE UPPER('%".$words[$i]."%')) AND "
|
||||||
. "WHERE "
|
. "calendar_entry_user.cal_id=calendar_entry.cal_id AND "
|
||||||
. "(UPPER(calendar_entry.cal_name) LIKE UPPER('%".$words[$i]."%') OR "
|
. "(((calendar_entry_user.cal_login=".$phpgw_info["user"]["account_id"].") AND "
|
||||||
. " UPPER(calendar_entry.cal_description) LIKE UPPER('%".$words[$i]."%')) AND "
|
. "(calendar_entry.cal_access='private')) "
|
||||||
. "calendar_entry_user.cal_id=calendar_entry.cal_id AND "
|
. $phpgw->calendar->group_search()
|
||||||
. "(((calendar_entry_user.cal_login=".$phpgw_info["user"]["account_id"].") AND "
|
. "OR calendar_entry.cal_access='public') "
|
||||||
. "(calendar_entry.cal_access='private')) "
|
. "ORDER BY cal_datetime";
|
||||||
. $phpgw->calendar->group_search()
|
|
||||||
. "OR calendar_entry.cal_access='public') "
|
|
||||||
. "ORDER BY cal_datetime";
|
|
||||||
|
|
||||||
$phpgw->db->query($sql);
|
$phpgw->db->query($sql);
|
||||||
while ($phpgw->db->next_record()) {
|
while ($phpgw->db->next_record()) {
|
||||||
$matches++;
|
$matches++;
|
||||||
$ids[strval( $phpgw->db->f(0) )]++;
|
$ids[strval( $phpgw->db->f(0) )]++;
|
||||||
$info[strval( $phpgw->db->f(0) )] = $phpgw->db->f(1) . " ("
|
$info[strval( $phpgw->db->f(0) )] = $phpgw->db->f(1) . " ("
|
||||||
. $phpgw->common->show_date($phpgw->db->f(2)) . ")";
|
. $phpgw->common->show_date($phpgw->db->f(2)) . ")";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($matches > 0)
|
if ($matches > 0)
|
||||||
$matches = count($ids);
|
$matches = count($ids);
|
||||||
|
|
||||||
if ($matches == 1)
|
if ($matches == 1)
|
||||||
echo "<B>1 match found.</B><P>";
|
$quantity = "1 match found.";
|
||||||
else if ($matches > 0)
|
else if ($matches > 0)
|
||||||
echo "<B>" . lang("x matches found",$matches) . ".</B><P>";
|
$quantity = lang("x matches found",$matches).".";
|
||||||
else
|
else
|
||||||
$error = lang("no matches found.");
|
$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
|
// now sort by number of hits
|
||||||
if (! strlen($error)) {
|
if (! strlen($error)) {
|
||||||
arsort ($ids);
|
arsort ($ids);
|
||||||
for (reset($ids); $key = key($ids); next($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();
|
$phpgw->common->phpgw_footer();
|
||||||
?>
|
?>
|
||||||
|
6
calendar/templates/default/search.tpl
Executable file
6
calendar/templates/default/search.tpl
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
<!-- $Id$ -->
|
||||||
|
<h2><font color="{color}">{search_text}</font></h2>
|
||||||
|
<b>{quantity}</b><p>
|
||||||
|
{output}
|
||||||
|
<p>
|
||||||
|
|
4
calendar/templates/default/search_list.tpl
Executable file
4
calendar/templates/default/search_list.tpl
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
<!-- $Id$ -->
|
||||||
|
<!-- BEGIN search_list -->
|
||||||
|
<li><a href="{url_result}">{result_desc}</a>
|
||||||
|
<!-- END search_list -->
|
Loading…
Reference in New Issue
Block a user