From 02712b393dc8be0b00074684a2365ea419bcb888 Mon Sep 17 00:00:00 2001 From: jwangen Date: Thu, 24 Oct 2002 02:41:38 +0000 Subject: Modified search function --- search.php | 112 ++++++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 74 insertions(+), 38 deletions(-) (limited to 'search.php') diff --git a/search.php b/search.php index d31d461..6196a22 100644 --- a/search.php +++ b/search.php @@ -1,26 +1,28 @@ '.$final_str_arr[0].''; } - + + return array($formatted_search, $and_arr, $or_arr, $not_arr); +} + +// takes an array made by format_search() and checks to see if it +// it matches against a string +function search_boolean($needle_arr, $haystack) { + // init arrays + $and_arr = $needle_arr[1]; + $or_arr = $needle_arr[2]; + $not_arr = $needle_arr[3]; + + // compare lowercase versions of the strings + $haystack = strtolower($haystack); + // check against the NOT foreach($not_arr as $s) { if (ereg($s, $haystack) == true) { - return array(false,$formatted_search); + return false; } } // check against the AND foreach($and_arr as $s) { if (ereg($s,$haystack) == false) { - return array(false,$formatted_search); + return false; } } @@ -95,19 +111,27 @@ function search_boolean($needle,$haystack) { foreach($or_arr as $or) { $is_false = true; foreach($or as $s) { - if (ereg($s,$haystack) == true) { + if (substr($s,0,1) == '-') { + if (ereg(substr($s,1),$haystack) == false) { + $is_false = false; + break; + } + } elseif (ereg($s,$haystack) == true) { $is_false = false; break; } } - if ($is_false) return array(false,$formatted_search); + if ($is_false) return false; } // if we haven't returned false, then we return true - return array(true,$formatted_search); + return true; } -$search_string = 'final japan'; +$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) { @@ -116,12 +140,11 @@ if (isset($master_array) && is_array($master_array)) { if (is_array($time_tmp)) { foreach ($time_tmp as $event_tmp) { if (is_array($event_tmp)) { - $results1 = search_boolean($search_string,$event_tmp['event_text']); - $formatted_search = $results1[1]; - if (!$results1[0]) { - $results2 = search_boolean($search_string,$event_tmp['description']); + $results1 = search_boolean($format_search_arr,$event_tmp['event_text']); + if (!$results1) { + $results2 = search_boolean($format_search_arr,$event_tmp['description']); } - if ($results1[0] || $results2[0]) { + if ($results1 || $results2) { $event_tmp['date'] = $date_key_tmp; $the_arr[] = $event_tmp; } @@ -140,17 +163,20 @@ if (isset($master_array) && is_array($master_array)) { - <?php echo "$calendar_name - $display_month"; ?> + <?php echo "$calendar_name - Search Results"; ?> ">
- +
+ +
+ - + - + + + + +
\"right\""; ?>"; ?> \"right\""; ?>"; ?>
@@ -159,9 +185,9 @@ if (isset($master_array) && is_array($master_array)) { - - - + + + @@ -169,11 +195,14 @@ if (isset($master_array) && is_array($master_array)) { \n"; + echo "\n"; + echo "\n"; + } else { echo "\n"; - echo "\n"; + echo "\n"; echo "\n"; } @@ -224,9 +257,12 @@ if (isset($master_array) && is_array($master_array)) {
"; ?>"; ?>"; ?>"; ?>
\n"; foreach($the_arr as $val) { - $dayofmonth = strtotime ($val['date']); + $thedate = $val['date']; + $dayofmonth = strtotime ($thedate); $dayofmonth = localizeDate ($dateFormat_week_list, $dayofmonth); $i = 0; - if ($getdate == $val['date']) { + if ($getdate == $thedate) { $fontclass="class=\"G10BOLD\""; } else { $fontclass="class=\"G10B\""; @@ -200,17 +229,21 @@ if (isset($master_array) && is_array($master_array)) { $event_start2 = ''; $event_end = ''; } - echo "\n"; - echo "\n"; - echo "\n"; + echo "\n"; - echo "\n"; + echo "\n"; } } + echo "
 $dayofmonth ($event_start)\n"; + echo "
 $dayofmonth ($event_start)\n"; echo " $event_text\n"; echo "
\n"; + echo ''.htmlspecialchars(urldecode($val["description"])).''; + echo "
No results foundNo results found
- -
-
'.$powered_by_lang.' PHP iCalendar '.$version_lang.''; ?> +
+
'.$powered_by_lang.' PHP iCalendar '.$version_lang.''; ?>
-- cgit v1.2.3