From 328a925bafcd69ecfda5fc8101e1a0dc667c5434 Mon Sep 17 00:00:00 2001 From: jwangen Date: Mon, 28 Oct 2002 05:20:08 +0000 Subject: spruced up search, fixed a few bugs in sidebar and month_bottom, and a few various changes in the parser and date_functions --- search.php | 157 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 148 insertions(+), 9 deletions(-) (limited to 'search.php') diff --git a/search.php b/search.php index 5943694..b99faed 100644 --- a/search.php +++ b/search.php @@ -39,7 +39,7 @@ $search_box .= '
'."\n". ''."\n". ''."\n". - ''."\n". + ''."\n". ''."\n". '
'; @@ -52,15 +52,24 @@ if ($search_valid) { if (is_array($date_tmp)) { foreach($date_tmp as $time_tmp) { if (is_array($time_tmp)) { - foreach ($time_tmp as $event_tmp) { + foreach ($time_tmp as $uid_tmp => $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; + if (!isset($the_arr[$uid_tmp]) || isset($event_tmp['exception'])) { + $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; + if (isset($event_tmp['recur'])) { + $event_tmp['recur'] = format_recur($event_tmp['recur']); + } + if (isset($the_arr[$uid_tmp])) { + $the_arr[$uid_tmp]['exceptions'][] = $event_tmp; + } else { + $the_arr[$uid_tmp] = $event_tmp; + } + } } } } @@ -168,6 +177,13 @@ $search_took = number_format(($search_ended-$search_started),3); echo "$summary_lang:\n"; echo "$event_text\n"; echo "\n"; + if (isset($val['recur'])) { + $recur = $val['recur']; + echo "\n"; + echo "Recurring event:\n"; + echo "$recur\n"; + echo "\n"; + } if ($val["description"]) { echo "\n"; echo "$description_lang:\n"; @@ -178,6 +194,61 @@ $search_took = number_format(($search_ended-$search_started),3); echo "\n"; echo "\n"; echo "\n"; + if (isset($val['exceptions'])) { + foreach($val['exceptions'] as $val2) { + $key = $val2['date']; + $dayofmonth = strtotime ($key); + $dayofmonth = localizeDate ($dateFormat_day, $dayofmonth); + echo "\n"; + echo "Exception: $dayofmonth"; + echo "\n"; + + if ($val2["event_text"]) { + $event_text = stripslashes(urldecode($val2["event_text"])); + $description = stripslashes(urldecode($val2["description"])); + $event_start = $val2["event_start"]; + $event_end = $val2["event_end"]; + $event_start = date ($timeFormat, strtotime ("$event_start")); + $event_end = date ($timeFormat, strtotime ("$event_end")); + $event_start = "$event_start - $event_end"; + if (!$val2["event_start"]) { + $event_start = "$all_day_lang"; + $event_start2 = ''; + $event_end = ''; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + if (isset($val2['recur'])) { + $recur = $val2['recur']; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + if ($val2["description"]) { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + echo "
$time_lang:$event_start
$summary_lang:$event_text
Recurring event:$recur
$description_lang:$description
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + } + } } } } else { @@ -339,6 +410,74 @@ function search_boolean($needle_arr, $haystack) { return true; } +function format_recur($arr) { + global $monthsofyearshort_lang, $daysofweekshort_lang; + $freq = $arr['FREQ'].(($arr['INTERVAL'] == 1) ? ' ' : 's '); + $int = $arr['INTERVAL']; + if (isset($arr['COUNT'])) $times = $arr['COUNT'].' time'.(($arr['COUNT'] == 1) ? ' ' : 's '); + if (isset($arr['UNTIL'])) $until = 'until '.$arr['UNTIL'].' '; + $by = ''; + if (isset($arr['BYMONTH'])) { + $by .= 'on '; + $count = count($arr['BYMONTH']); + $last = $count - 1; + if ($count == 1) { + $month = $arr['BYMONTH'][0]; + $by .= $monthsofyearshort_lang[($month-1)]; + } else { + foreach ($arr['BYMONTH'] as $key => $month) { + if ($key == $last) $by .= $monthsofyearshort_lang[($month-1)]; + else $by .= $monthsofyearshort_lang[($month-1)].', '; + } + } + $by .= ' '; + } + + if (isset($arr['BYMONTHDAY'])) { + $by .= 'on '; + $last = count($arr['BYMONTHDAY']) - 1; + if ($arr['BYMONTHDAY'][$last] == '0') unset($arr['BYMONTHDAY'][$last]); + $count = count($arr['BYMONTHDAY']); + $last = $count - 1; + if ($count == 1) { + ereg('([\-]{0,1})([0-9]{1,2})',$arr['BYMONTHDAY'][0],$regs); + list($junk,$sign,$day) = $regs; + $by .= $day; + } else { + foreach ($arr['BYMONTHDAY'] as $key => $day) { + ereg('([\-]{0,1})([0-9]{1,2})',$day,$regs); + list($junk,$sign,$day) = $regs; + if ($key == $last) $by .= $day; + else $by .= $day.', '; + } + } + $by .= ' '; + } + if (isset($arr['BYDAY'])) { + $by .= 'on '; + $count = count($arr['BYDAY']); + $last = $count-1; + if ($count == 1) { + ereg('([\-]{0,1})([0-9]{0,1})([A-Z]{2})',$arr['BYDAY'][0],$regs); + list($junk,$sign,$day_num,$day_txt) = $regs; + $num = two2threeCharDays($day_txt,false); + if ($day_num != '') $by .= $day_num.' '; + $by .= $daysofweekshort_lang[$num]; + } else { + foreach ($arr['BYDAY'] as $key => $day) { + ereg('([\-]{0,1})([0-9]{0,1})([A-Z]{2})',$day,$regs); + list($junk,$sign,$day_num,$day_txt) = $regs; + $num = two2threeCharDays($day_txt,false); + if ($day_num != '') $by .= $day_num.' '; + if ($key == $last) $by .= $daysofweekshort_lang[$num]; + else $by .= $daysofweekshort_lang[$num].', '; + } + } + $by .= ' '; + } + return 'Every '.$int.' '.$freq.$times.$until.$by; +} + function getmicrotime() { list($usec, $sec) = explode(' ',microtime()); return ((float)$usec + (float)$sec); -- cgit v1.2.3