aboutsummaryrefslogtreecommitdiffstats
path: root/search.php
diff options
context:
space:
mode:
authorjwangen <jwangen>2002-10-27 23:55:57 +0000
committerjwangen <jwangen>2002-10-27 23:55:57 +0000
commit05c3bde0c29128d803d98b69b337ccfebe4c1732 (patch)
tree367cc8dc817556900f1fa2dd3200fc4b80e4bb6d /search.php
parent8f7bbd8ea0aa7ec0ae35dbfe66c3772651501aca (diff)
downloadphpicalendar-05c3bde0c29128d803d98b69b337ccfebe4c1732.tar.gz
phpicalendar-05c3bde0c29128d803d98b69b337ccfebe4c1732.tar.bz2
phpicalendar-05c3bde0c29128d803d98b69b337ccfebe4c1732.zip
Search furthur implimented
Diffstat (limited to 'search.php')
-rw-r--r--search.php331
1 files changed, 202 insertions, 129 deletions
diff --git a/search.php b/search.php
index a2ab225..4ffa0c8 100644
--- a/search.php
+++ b/search.php
@@ -4,20 +4,218 @@ define('BASE','./');
$current_view = 'search';
include('./functions/ical_parser.php');
+if (isset($HTTP_SERVER_VARS['HTTP_REFERER']) && $HTTP_SERVER_VARS['HTTP_REFERER'] != '') {
+ $back_page = $HTTP_SERVER_VARS['HTTP_REFERER'];
+} else {
+ $back_page = BASE.$default_view.'.php?cal='.$cal.'&getdate='.$getdate;
+}
+
+$search_valid = false;
+if (isset($HTTP_GET_VARS['query']) && $HTTP_GET_VARS['query'] != '') {
+ $query = $HTTP_GET_VARS['query'];
+ $search_valid = true;
+}
+
+$formatted_start_range = localizeDate($dateFormat_week, $start_range_time);
+$formatted_end_range = localizeDate($dateFormat_week, $end_range_time);
+
+$search_box = '';
// yet to be implemented
switch($HTTP_GET_VARS['mode']) {
case 'advanced_search':
// display advanced search stuff
+
break;
case 'search':
// display simple search stuff
+ $search_box .=
+ '<form action="search.php" method="GET">'."\n".
+ '<input type="text" size="15" name="query" value="'.$query.'">'."\n".
+ '<input type="submit" value="Search">'."\n".
+ '</form>';
break;
case 'results':
// display results of either simple or advanced search
break;
default:
// some generic thing, maybe same as search
+ $search_box .=
+ '<form action="search.php" method="GET">'."\n".
+ '<input type="text" size="15" name="query" value="'.$query.'">'."\n".
+ '<input type="submit" value="Search">'."\n".
+ '</form>';
+}
+
+$search_started = getmicrotime();
+if ($search_valid) {
+ $format_search_arr = format_search($query);
+ $formatted_search = $format_search_arr[0];
+ if (isset($master_array) && is_array($master_array)) {
+ foreach($master_array as $date_key_tmp => $date_tmp) {
+ if (is_array($date_tmp)) {
+ foreach($date_tmp as $time_tmp) {
+ if (is_array($time_tmp)) {
+ foreach ($time_tmp as $event_tmp) {
+ if (is_array($event_tmp)) {
+ $results1 = search_boolean($format_search_arr,$event_tmp['event_text']);
+ if (!$results1) {
+ $results2 = search_boolean($format_search_arr,$event_tmp['description']);
+ }
+ if ($results1 || $results2) {
+ $event_tmp['date'] = $date_key_tmp;
+ $the_arr[] = $event_tmp;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+} else {
+ $formatted_search = '<b>No query given</b>';
}
+$search_ended = getmicrotime();
+
+$search_took = number_format(($search_ended-$search_started),3);
+
+?>
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
+<html>
+<head>
+ <meta http-equiv="content-type" content="text/html;charset=UTF-8">
+ <title><?php echo "$calendar_name - $results_lang"; ?></title>
+ <link rel="stylesheet" type="text/css" href="styles/<?php echo $style_sheet.'/default.css'; ?>">
+</head>
+<body bgcolor="#FFFFFF">
+<center>
+<table border="0" width="700" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF" class="calborder">
+ <tr>
+ <td>
+ <table width="100%" border="0" cellspacing="0" cellpadding="0">
+ <tr>
+ <td align="left" width="90" class="navback"><?php echo '<a href="'.$back_page.'"><img src="styles/'.$style_sheet.'/back.gif" alt="" border="0" align="left"></a>'; ?></td>
+ <td class="navback">
+ <table width="100%" border="0" cellspacing="0" cellpadding="0">
+ <tr>
+ <td align="center" class="navback" nowrap valign="middle"><font class="H20"><?php echo $results_lang; ?></font></td>
+ </tr>
+ </table>
+ </td>
+ <td align="right" width="90" class="navback">
+ <table width="90" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td><?php echo '<a class="psf" href="day.php?cal='.$cal.'&getdate='.$getdate.'"><img src="styles/'.$style_sheet.'/day_on.gif" alt="" border="0"></td>'; ?>
+ <td><?php echo '<a class="psf" href="week.php?cal='.$cal.'&getdate='.$getdate.'"><img src="styles/'.$style_sheet.'/week_on.gif" alt="" border="0"></td>'; ?>
+ <td><?php echo '<a class="psf" href="month.php?cal='.$cal.'&getdate='.$getdate.'"><img src="styles/'.$style_sheet.'/month_on.gif" alt="" border="0"></td>'; ?>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="3" class="dayborder"><img src="images/spacer.gif" width="1" height="5"></td>
+ </tr>
+ <tr>
+ <td colspan="3">
+ <table border="0" cellspacing="0" cellpadding="0" width="100%">
+ <tr>
+ <td align="center" valign="top">
+ <table width="100%" border="0" cellspacing="0" cellpadding="0">
+ <tr>
+ <td colspan="3" height="1"></td>
+ </tr>
+ <tr>
+ <td colspan="3" class="G10B" align="center"><?php echo $search_box; ?></td>
+ </tr>
+ <tr>
+ <td colspan="3" class="G10B" align="center"><?php echo $query_lang.$formatted_search; ?></td>
+ </tr>
+ <tr>
+ <td colspan="3" class="G10B">&nbsp;</td>
+ </tr>
+ <?php
+ if (isset($the_arr) && is_array($the_arr)) {
+ foreach($the_arr as $val) {
+ $key = $val['date'];
+ $dayofmonth = strtotime ($key);
+ $dayofmonth = localizeDate ($dateFormat_day, $dayofmonth);
+ echo "<tr><td width=\"10\"><img src=\"images/spacer.gif\" width=\"10\" height=\"1\"></td>\n";
+ echo "<td align=\"left\" colspan=\"2\"><font class=\"V12\"><b><a class=\"ps3\" href=\"day.php?cal=$cal&getdate=$key\">$dayofmonth</a></b></font></td></tr>";
+ echo "<tr><td colspan=\"3\"><img src=\"images/spacer.gif\" width=\"1\" height=\"5\"></td></tr>\n";
+
+ if ($val["event_text"]) {
+ $event_text = stripslashes(urldecode($val["event_text"]));
+ $description = stripslashes(urldecode($val["description"]));
+ $event_start = $val["event_start"];
+ $event_end = $val["event_end"];
+ $event_start = date ($timeFormat, strtotime ("$event_start"));
+ $event_end = date ($timeFormat, strtotime ("$event_end"));
+ $event_start = "$event_start - $event_end";
+ if (!$val["event_start"]) {
+ $event_start = "$all_day_lang";
+ $event_start2 = '';
+ $event_end = '';
+ }
+ echo "<tr>\n";
+ echo "<td width=\"10\"><img src=\"images/spacer.gif\" width=\"10\" height=\"1\"></td>\n";
+ echo "<td width=\"10\"><img src=\"images/spacer.gif\" width=\"10\" height=\"1\"></td>\n";
+ echo "<td align=\"left\">\n";
+ echo "<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"1\">\n";
+ echo "<tr>\n";
+ echo "<td width=\"100\" class=\"G10BOLD\">$time_lang:</td>\n";
+ echo "<td align=\"left\" class=\"G10B\">$event_start</td>\n";
+ echo "</tr>\n";
+ echo "<tr>\n";
+ echo "<td valign=\"top\" width=\"100\" class=\"G10BOLD\">$summary_lang:</td>\n";
+ echo "<td valign=\"top\" align=\"left\" class=\"G10B\">$event_text</td>\n";
+ echo "</tr>\n";
+ if ($val["description"]) {
+ echo "<tr>\n";
+ echo "<td valign=\"top\" width=\"100\" class=\"G10BOLD\">$description_lang:</td>\n";
+ echo "<td valign=\"top\" align=\"left\" class=\"G10B\">$description</td>\n";
+ echo "</tr>\n";
+ }
+ echo "</table>\n";
+ echo "</td>\n";
+ echo "</tr>\n";
+ echo "<tr><td colspan=\"3\"><img src=\"images/spacer.gif\" width=\"1\" height=\"10\"></td></tr>\n";
+ }
+ }
+ } else {
+ echo '<tr><td colspan="3" class="G10B" align="center">';
+ echo $no_results_lang;
+ echo '</td></tr><tr><td class="G10B">&nbsp;</td></tr>';
+ }
+
+
+
+ ?>
+ <tr>
+ <td colspan="3" class="G10B" align="center">
+ <?php
+ echo 'Recurring events searched in range:<br>';
+ echo '<b>'.$formatted_start_range.' - '.$formatted_end_range.'</b><br>';
+ echo '<font class="V9G">Search took '.$search_took.' seconds</font><br><br>';
+ ?>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+</table>
+</center>
+<?php include (BASE.'footer.inc.php'); ?>
+</body>
+</html>
+<?php
// takes a boolean search and formats it into an array
// use with sister function search_boolean()
@@ -143,133 +341,8 @@ function search_boolean($needle_arr, $haystack) {
return true;
}
-$search_string = 'final';
-
-$format_search_arr = format_search($search_string);
-$formatted_search = $format_search_arr[0];
-
-if (isset($master_array) && is_array($master_array)) {
- foreach($master_array as $date_key_tmp => $date_tmp) {
- if (is_array($date_tmp)) {
- foreach($date_tmp as $time_tmp) {
- if (is_array($time_tmp)) {
- foreach ($time_tmp as $event_tmp) {
- if (is_array($event_tmp)) {
- $results1 = search_boolean($format_search_arr,$event_tmp['event_text']);
- if (!$results1) {
- $results2 = search_boolean($format_search_arr,$event_tmp['description']);
- }
- if ($results1 || $results2) {
- $event_tmp['date'] = $date_key_tmp;
- $the_arr[] = $event_tmp;
- }
- }
- }
- }
- }
- }
- }
+function getmicrotime() {
+ list($usec, $sec) = explode(' ',microtime());
+ return ((float)$usec + (float)$sec);
}
-
-?>
-
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
- "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
-<html>
-<head>
- <meta http-equiv="content-type" content="text/html;charset=UTF-8">
- <title><?php echo "$calendar_name - Search Results"; ?></title>
- <link rel="stylesheet" type="text/css" href="styles/<?php echo "$style_sheet/default.css"; ?>">
- <?php include "functions/event.js"; ?>
-</head>
-<body>
-<center>
-<table border="0" width="520" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF" class="calborder">
- <tr>
- <td align="left" valign="top" width="1" class="sideback"><?php echo "<img src=\"images/spacer.gif\" alt=\"right\" width=\"1\" height=\"20\" border=\"0\" align=\"left\">"; ?></td>
- <td align="center" class="sideback"><font class="G10BOLD"><?php print "Search Results" ?></font></td>
- <td align="right" valign="top" width="1" class="sideback"><?php echo "<img src=\"images/spacer.gif\" alt=\"right\" width=\"1\" height=\"20\" border=\"0\" align=\"right\">"; ?></td>
- </tr>
- <tr>
- <td colspan="3">
- <table border="0" cellspacing="0" cellpadding="0" width="100%">
- <tr>
- <td align="center" valign="top">
- <table width="100%" border="0" cellspacing="0" cellpadding="0">
- <tr>
- <td align="left" valign="top" width="1" height="20" class="montheventtop"><?php echo "<img src=\"images/spacer.gif\" alt=\"right\" width=\"1\" height=\"20\" border=\"0\" align=\"left\">"; ?></td>
- <td align="center" class="montheventtop" height="20" width="320" nowrap><font class="G10B"><?php echo 'Search: '.$formatted_search; ?></font></td>
- <td align="right" valign="top" width="1" height="20" class="montheventtop"><?php echo "<img src=\"images/spacer.gif\" alt=\"right\" width=\"1\" height=\"20\" border=\"0\" align=\"right\">"; ?></td>
- </tr>
- <tr>
- <td colspan="3" height="1"></td>
- </tr>
- <?php
- // Iterate the search results
- if (is_array($the_arr)) {
- echo "<tr>\n";
- echo "<td colspan=\"3\"><table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\">\n";
- foreach($the_arr as $val) {
- $thedate = $val['date'];
- $dayofmonth = strtotime ($thedate);
- $dayofmonth = localizeDate ($dateFormat_week_list, $dayofmonth);
- $i = 0;
- if ($getdate == $thedate) {
- $fontclass="class=\"G10BOLD\"";
- } else {
- $fontclass="class=\"G10B\"";
- }
- if ($val["event_text"]) {
- $event_text = stripslashes(urldecode($val["event_text"]));
- $event_text2 = addslashes($val["event_text"]);
- $event_text2 = str_replace("\"", "&quot;", $event_text2);
- $event_text2 = urlencode($event_text2);
- $description = addslashes($val["description"]);
- $description = str_replace("\"", "&quot;", $description);
- $event_start = $val["event_start"];
- $event_end = $val["event_end"];
- $event_start = date ($timeFormat, strtotime ("$event_start"));
- $event_end = date ($timeFormat, strtotime ("$event_end"));
- $event_text = str_replace ("<br>", "", $event_text);
- $event_start2 = $event_start;
- if (strlen($event_text) > 70) {
- $event_text = substr("$event_text", 0, 65);
- $event_text = $event_text . "...";
- }
- if (!$val["event_start"]) {
- $event_start = "$all_day_lang";
- $event_start2 = '';
- $event_end = '';
- }
- echo "<tr><td width=\"30%\" class=\"montheventline\" nowrap align=\"left\" valign=\"top\"><font $fontclass>&nbsp;<a class=\"psf\" href=\"day.php?cal=$cal&getdate=$thedate\">$dayofmonth</a></font> <font class=\"V9G\">($event_start)</font></td>\n";
- echo "<td width=\"30%\" class=\"montheventline\" nowrap align=\"left\" valign=\"top\">\n";
- echo "&nbsp;<a class=\"psf\" href=\"javascript:openEventInfo('$event_text2', '$calendar_name', '$event_start2', '$event_end', '$description')\"><font class=\"G10B\">$event_text</font></a>\n";
- echo "</td>\n";
- echo "<td align=\"left\" valign=\"top\" nowrap>\n";
- echo '<font class="G10B">'.htmlspecialchars(urldecode($val["description"])).'</font>';
- echo "</td></tr>\n";
- }
- }
- echo "</table></td>\n";
- echo "</tr>\n";
-
- } else {
- echo "<tr>\n";
- echo "<td colspan=\"3\" align=\"center\"><font class=\"G10B\">No results found</font></td>\n";
- echo "</tr>\n";
- }
-
- ?>
- </table>
- </td>
- </tr>
- </table>
-
-
- </td>
- </tr>
-</table>
-<?php include (BASE.'footer.inc.php'); ?>
-</center>
-</body>
-</html>
+?> \ No newline at end of file

© 2014-2024 Faster IT GmbH | imprint | privacy policy