aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjwangen <jwangen>2002-10-28 05:20:08 +0000
committerjwangen <jwangen>2002-10-28 05:20:08 +0000
commit328a925bafcd69ecfda5fc8101e1a0dc667c5434 (patch)
treef03fe04d6b8fe194f0c0cd5307f44a4419fc19fc
parent0c7763fe4fd132ef293e37382537f9b4a246a1dc (diff)
downloadphpicalendar-328a925bafcd69ecfda5fc8101e1a0dc667c5434.tar.gz
phpicalendar-328a925bafcd69ecfda5fc8101e1a0dc667c5434.tar.bz2
phpicalendar-328a925bafcd69ecfda5fc8101e1a0dc667c5434.zip
spruced up search, fixed a few bugs in sidebar and month_bottom, and a
few various changes in the parser and date_functions
-rw-r--r--functions/date_functions.php2
-rw-r--r--functions/ical_parser.php48
-rw-r--r--month_bottom.php10
-rw-r--r--search.php157
-rw-r--r--sidebar.php12
5 files changed, 194 insertions, 35 deletions
diff --git a/functions/date_functions.php b/functions/date_functions.php
index 4683caa..893e61a 100644
--- a/functions/date_functions.php
+++ b/functions/date_functions.php
@@ -1 +1 @@
-<?php // date_functions.php // functions for returning or comparing dates // not a date function, but I didn't know where to put it // for backwards compatibility if (phpversion() < '4.1') { function array_key_exists($key, $arr) { if (!is_array($arr)) return false; foreach (array_keys($arr) as $k) { if ("$k" == "$key") return true; } return false; } } // takes Apple's 2 character day format and makes it into 3 characters function two2threeCharDays($day) { switch($day) { case 'SU': $day_longer = 'sun'; break; case 'MO': $day_longer = 'mon'; break; case 'TU': $day_longer = 'tue'; break; case 'WE': $day_longer = 'wed'; break; case 'TH': $day_longer = 'thu'; break; case 'FR': $day_longer = 'fri'; break; case 'SA': $day_longer = 'sat'; break; } return $day_longer; } // dateOfWeek() takes a date in Ymd and a day of week in 3 letters or more // and returns the date of that day. (ie: "sun" or "sunday" would be acceptable values of $day but not "su") function dateOfWeek($Ymd, $day) { global $week_start_day; if (!isset($week_start_day)) $week_start_day = 'Sunday'; $timestamp = strtotime($Ymd); $num = date('w', strtotime($week_start_day)); $start_day_time = strtotime((date('w',$timestamp)==$num ? "$week_start_day" : "last $week_start_day"), $timestamp); $ret_unixtime = strtotime($day,$start_day_time); $ret_unixtime = strtotime('+12 hours', $ret_unixtime); $ret = date('Ymd',$ret_unixtime); return $ret; } // function to compare to dates in Ymd and return the number of weeks // that differ between them. requires dateOfWeek() function weekCompare($now, $then) { global $week_start_day; $sun_now = dateOfWeek($now, $week_start_day); $sun_then = dateOfWeek($then, $week_start_day); $seconds_now = strtotime($sun_now); $seconds_then = strtotime($sun_then); $diff_seconds = $seconds_now - $seconds_then; $diff_minutes = $diff_seconds/60; $diff_hours = $diff_minutes/60; $diff_days = round($diff_hours/24); $diff_weeks = $diff_days/7; return $diff_weeks; } // function to compare to dates in Ymd and return the number of days // that differ between them. function dayCompare($now, $then) { $seconds_now = strtotime($now); $seconds_then = strtotime($then); $diff_seconds = $seconds_now - $seconds_then; $diff_minutes = $diff_seconds/60; $diff_hours = $diff_minutes/60; $diff_days = round($diff_hours/24); return $diff_days; } // function to compare to dates in Ymd and return the number of months // that differ between them. function monthCompare($now, $then) { ereg ("([0-9]{4})([0-9]{2})([0-9]{2})", $now, $date_now); ereg ("([0-9]{4})([0-9]{2})([0-9]{2})", $then, $date_then); $diff_years = $date_now[1] - $date_then[1]; $diff_months = $date_now[2] - $date_then[2]; if ($date_now[2] < $date_then[2]) { $diff_years -= 1; $diff_months = ($diff_months + 12) % 12; } $diff_months = ($diff_years * 12) + $diff_months; return $diff_months; } function yearCompare($now, $then) { ereg ("([0-9]{4})([0-9]{2})([0-9]{2})", $now, $date_now); ereg ("([0-9]{4})([0-9]{2})([0-9]{2})", $then, $date_then); $diff_years = $date_now[1] - $date_then[1]; return $diff_years; } // localizeDate() - similar to strftime but uses our preset arrays of localized // months and week days and only supports %A, %a, %B, %b, %e, and %Y // more can be added as needed but trying to keep it small while we can function localizeDate($format, $timestamp) { global $daysofweek_lang, $daysofweekshort_lang, $daysofweekreallyshort_lang, $monthsofyear_lang, $monthsofyear_lang, $monthsofyearshort_lang; $year = date("Y", $timestamp); $month = date("n", $timestamp)-1; $day = date("j", $timestamp); $dayofweek = date("w", $timestamp); $date = str_replace('%Y', $year, $format); $date = str_replace('%e', $day, $date); $date = str_replace('%B', $monthsofyear_lang[$month], $date); $date = str_replace('%b', $monthsofyearshort_lang[$month], $date); $date = str_replace('%A', $daysofweek_lang[$dayofweek], $date); $date = str_replace('%a', $daysofweekshort_lang[$dayofweek], $date); return $date; } // calcOffset takes an offset (ie, -0500) and returns it in the number of seconds function calcOffset($offset_str) { $sign = substr($offset_str, 0, 1); $hours = substr($offset_str, 1, 2); $mins = substr($offset_str, 3, 2); $secs = ((int)$hours * 3600) + ((int)$mins * 60); if ($sign == '-') $secs = 0 - $secs; return $secs; } // calcTime calculates the unixtime of a new offset by comparing it to the current offset // $have is the current offset (ie, '-0500') // $want is the wanted offset (ie, '-0700') // $time is the unixtime relative to $have function calcTime($have, $want, $time) { if ($have == 'none' || $want == 'none') return $time; $have_secs = calcOffset($have); $want_secs = calcOffset($want); $diff = $want_secs - $have_secs; $time += $diff; return $time; } function chooseOffset($time) { global $timezone, $tz_array; if (!isset($timezone)) $timezone = ''; switch ($timezone) { case '': $offset = 'none'; break; case 'Same as Server': $offset = date('O', $time); break; default: if (is_array($tz_array) && array_key_exists($timezone, $tz_array)) { $dlst = date('I', $time); $offset = $tz_array[$timezone][$dlst]; } else { $offset = '+0000'; } } return $offset; } ?> \ No newline at end of file
+<?php // date_functions.php // functions for returning or comparing dates // not a date function, but I didn't know where to put it // for backwards compatibility if (phpversion() < '4.1') { function array_key_exists($key, $arr) { if (!is_array($arr)) return false; foreach (array_keys($arr) as $k) { if ("$k" == "$key") return true; } return false; } } // takes iCalendar 2 day format and makes it into 3 characters // if $txt is true, it returns the 3 letters, otherwise it returns the // integer of that day; 0=Sun, 1=Mon, etc. function two2threeCharDays($day, $txt=true) { switch($day) { case 'SU': return ($txt ? 'sun' : '0'); case 'MO': return ($txt ? 'mon' : '1'); case 'TU': return ($txt ? 'tue' : '2'); case 'WE': return ($txt ? 'wed' : '3'); case 'TH': return ($txt ? 'thu' : '4'); case 'FR': return ($txt ? 'fri' : '5'); case 'SA': return ($txt ? 'sat' : '6'); } } // dateOfWeek() takes a date in Ymd and a day of week in 3 letters or more // and returns the date of that day. (ie: "sun" or "sunday" would be acceptable values of $day but not "su") function dateOfWeek($Ymd, $day) { global $week_start_day; if (!isset($week_start_day)) $week_start_day = 'Sunday'; $timestamp = strtotime($Ymd); $num = date('w', strtotime($week_start_day)); $start_day_time = strtotime((date('w',$timestamp)==$num ? "$week_start_day" : "last $week_start_day"), $timestamp); $ret_unixtime = strtotime($day,$start_day_time); $ret_unixtime = strtotime('+12 hours', $ret_unixtime); $ret = date('Ymd',$ret_unixtime); return $ret; } // function to compare to dates in Ymd and return the number of weeks // that differ between them. requires dateOfWeek() function weekCompare($now, $then) { global $week_start_day; $sun_now = dateOfWeek($now, $week_start_day); $sun_then = dateOfWeek($then, $week_start_day); $seconds_now = strtotime($sun_now); $seconds_then = strtotime($sun_then); $diff_seconds = $seconds_now - $seconds_then; $diff_minutes = $diff_seconds/60; $diff_hours = $diff_minutes/60; $diff_days = round($diff_hours/24); $diff_weeks = $diff_days/7; return $diff_weeks; } // function to compare to dates in Ymd and return the number of days // that differ between them. function dayCompare($now, $then) { $seconds_now = strtotime($now); $seconds_then = strtotime($then); $diff_seconds = $seconds_now - $seconds_then; $diff_minutes = $diff_seconds/60; $diff_hours = $diff_minutes/60; $diff_days = round($diff_hours/24); return $diff_days; } // function to compare to dates in Ymd and return the number of months // that differ between them. function monthCompare($now, $then) { ereg ("([0-9]{4})([0-9]{2})([0-9]{2})", $now, $date_now); ereg ("([0-9]{4})([0-9]{2})([0-9]{2})", $then, $date_then); $diff_years = $date_now[1] - $date_then[1]; $diff_months = $date_now[2] - $date_then[2]; if ($date_now[2] < $date_then[2]) { $diff_years -= 1; $diff_months = ($diff_months + 12) % 12; } $diff_months = ($diff_years * 12) + $diff_months; return $diff_months; } function yearCompare($now, $then) { ereg ("([0-9]{4})([0-9]{2})([0-9]{2})", $now, $date_now); ereg ("([0-9]{4})([0-9]{2})([0-9]{2})", $then, $date_then); $diff_years = $date_now[1] - $date_then[1]; return $diff_years; } // localizeDate() - similar to strftime but uses our preset arrays of localized // months and week days and only supports %A, %a, %B, %b, %e, and %Y // more can be added as needed but trying to keep it small while we can function localizeDate($format, $timestamp) { global $daysofweek_lang, $daysofweekshort_lang, $daysofweekreallyshort_lang, $monthsofyear_lang, $monthsofyear_lang, $monthsofyearshort_lang; $year = date("Y", $timestamp); $month = date("n", $timestamp)-1; $day = date("j", $timestamp); $dayofweek = date("w", $timestamp); $date = str_replace('%Y', $year, $format); $date = str_replace('%e', $day, $date); $date = str_replace('%B', $monthsofyear_lang[$month], $date); $date = str_replace('%b', $monthsofyearshort_lang[$month], $date); $date = str_replace('%A', $daysofweek_lang[$dayofweek], $date); $date = str_replace('%a', $daysofweekshort_lang[$dayofweek], $date); return $date; } // calcOffset takes an offset (ie, -0500) and returns it in the number of seconds function calcOffset($offset_str) { $sign = substr($offset_str, 0, 1); $hours = substr($offset_str, 1, 2); $mins = substr($offset_str, 3, 2); $secs = ((int)$hours * 3600) + ((int)$mins * 60); if ($sign == '-') $secs = 0 - $secs; return $secs; } // calcTime calculates the unixtime of a new offset by comparing it to the current offset // $have is the current offset (ie, '-0500') // $want is the wanted offset (ie, '-0700') // $time is the unixtime relative to $have function calcTime($have, $want, $time) { if ($have == 'none' || $want == 'none') return $time; $have_secs = calcOffset($have); $want_secs = calcOffset($want); $diff = $want_secs - $have_secs; $time += $diff; return $time; } function chooseOffset($time) { global $timezone, $tz_array; if (!isset($timezone)) $timezone = ''; switch ($timezone) { case '': $offset = 'none'; break; case 'Same as Server': $offset = date('O', $time); break; default: if (is_array($tz_array) && array_key_exists($timezone, $tz_array)) { $dlst = date('I', $time); $offset = $tz_array[$timezone][$dlst]; } else { $offset = '+0000'; } } return $offset; } ?> \ No newline at end of file
diff --git a/functions/ical_parser.php b/functions/ical_parser.php
index 4a9eeb7..f06e982 100644
--- a/functions/ical_parser.php
+++ b/functions/ical_parser.php
@@ -180,10 +180,11 @@ if ($parse_file) {
}
if (($end > $mArray_begin) && ($end < $mArray_end)) {
while ($start != $end) {
- $start_date = date('Ymd', $start);
- $master_array[($start_date)][('-1')][$uid]= array ('event_text' => $summary, 'description' => $description);
+ $start_date2 = date('Ymd', $start);
+ $master_array[($start_date2)][('-1')][$uid]= array ('event_text' => $summary, 'description' => $description);
$start = strtotime('+1 day', $start);
}
+ if (!$write_processed) $master_array[($start_date)]['-1'][$uid]['exception'] = true;
}
}
@@ -191,7 +192,7 @@ if ($parse_file) {
if ((isset($start_time) && $start_time != '') && (!isset($allday_start) || $allday_start == '')) {
$nbrOfOverlaps = checkOverlap($start_date, $start_time, $end_time);
$master_array[($start_date)][($hour.$minute)][$uid] = array ('event_start' => $start_time, 'event_text' => $summary, 'event_end' => $end_time, 'event_length' => $length, 'event_overlap' => $nbrOfOverlaps, 'description' => $description);
-
+ if (!$write_processed) $master_array[($start_date)][($hour.$minute)][$uid]['exception'] = true;
}
// Handling of the recurring events, RRULE
@@ -201,6 +202,8 @@ if ($parse_file) {
// if ((is_array($rrule_array)) && ($allday_written != TRUE)) {
if (is_array($rrule_array)) {
if (isset($allday_start) && $allday_start != '') {
+ $hour = '-';
+ $minute = '1';
$rrule_array['START_DAY'] = $allday_start;
$rrule_array['END_DAY'] = $allday_end;
$rrule_array['END'] = 'end';
@@ -248,9 +251,11 @@ if ($parse_file) {
case 'MINUTELY': $freq_type = 'minute'; break;
case 'SECONDLY': $freq_type = 'second'; break;
}
+ $master_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = ucfirst($freq_type);
break;
case 'COUNT':
$count = $val;
+ $master_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $count;
break;
case 'UNTIL':
$until = ereg_replace('T', '', $val);
@@ -274,47 +279,59 @@ if ($parse_file) {
if ($regs[4] < 12)
$until = strtotime('-1 day', $until);
}
+ $master_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = localizeDate($dateFormat_week,$until);
break;
case 'INTERVAL':
$number = $val;
+ $master_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $number;
break;
case 'BYSECOND':
$bysecond = $val;
$bysecond = split (',', $bysecond);
+ $master_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $bysecond;
break;
case 'BYMINUTE':
$byminute = $val;
$byminute = split (',', $byminute);
+ $master_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $byminute;
break;
case 'BYHOUR':
$byhour = $val;
$byhour = split (',', $byhour);
+ $master_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $byhour;
break;
case 'BYDAY':
$byday = $val;
$byday = split (',', $byday);
+ $master_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $byday;
break;
case 'BYMONTHDAY':
$bymonthday = $val;
$bymonthday = split (',', $bymonthday);
+ $master_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $bymonthday;
break;
case 'BYYEARDAY':
$byyearday = $val;
$byyearday = split (',', $byyearday);
+ $master_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $byyearday;
break;
case 'BYWEEKNO':
$byweekno = $val;
$byweekno = split (',', $byweekno);
+ $master_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $byweekno;
break;
case 'BYMONTH':
$bymonth = $val;
$bymonth = split (',', $bymonth);
+ $master_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $bymonth;
break;
case 'BYSETPOS':
$bysetpos = $val;
+ $master_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $bysetpos;
break;
case 'WKST':
$wkst = $val;
+ $master_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $wkst;
break;
case 'END':
@@ -368,10 +385,10 @@ if ($parse_file) {
if (is_array($bymonthday)) {
// loop through the days on which this event happens
foreach($bymonthday as $day) {
- if ($day != '0') {
- $day = str_pad($day, 2, '0', STR_PAD_LEFT);
- $next_date_time = strtotime(date('Y-m-',$next_range_time).$day);
- $next_date = date('Ymd', $next_date_time);
+ $year = date('Y', $next_range_time);
+ $month = date('m', $next_range_time);
+ if (checkdate($month,$day,$year)) {
+ $next_date_time = mktime(0,0,0,$month,$day,$year);
$recur_data[] = $next_date_time;
}
}
@@ -379,9 +396,9 @@ if ($parse_file) {
} else {
// loop through the days on which this event happens
foreach($byday as $day) {
- ereg ('([0-9]{1})([A-Z]{2})', $day, $byday_arr);
- $nth = $byday_arr[1]-1;
- $on_day = two2threeCharDays($byday_arr[2]);
+ ereg ('([\-\+]{0,1})([0-9]{1})([A-Z]{2})', $day, $byday_arr);
+ $nth = $byday_arr[2]-1;
+ $on_day = two2threeCharDays($byday_arr[3]);
$next_date_time = strtotime($on_day.' +'.$nth.' week', $next_range_time);
$next_date = date('Ymd', $next_date_time);
$recur_data[] = $next_date_time;
@@ -392,18 +409,17 @@ if ($parse_file) {
if (!isset($bymonth)) $bymonth[] = date('m', $start_date_time);
foreach($bymonth as $month) {
$year = date('Y', $next_range_time);
- $month = str_pad($month, 2, '0', STR_PAD_LEFT);
if (is_array($byday)) {
- $checkdate_time = strtotime($year.$month.'01');
+ $checkdate_time = mktime(0,0,0,$month,1,$year);
foreach($byday as $day) {
- ereg ('([0-9]{1})([A-Z]{2})', $day, $byday_arr);
- $nth = $byday_arr[1]-1;
- $on_day = two2threeCharDays($byday_arr[2]);
+ ereg ('([\-\+]{0,1})([0-9]{1})([A-Z]{2})', $day, $byday_arr);
+ $nth = $byday_arr[2]-1;
+ $on_day = two2threeCharDays($byday_arr[3]);
$next_date_time = strtotime($on_day.' +'.$nth.' week', $checkdate_time);
}
} else {
$day = date('d', $start_date_time);
- $next_date_time = strtotime($year.$month.$day);
+ $next_date_time = mktime(0,0,0,$month,$day,$year);
}
$recur_data[] = $next_date_time;
}
diff --git a/month_bottom.php b/month_bottom.php
index 925bd6f..41c3c5d 100644
--- a/month_bottom.php
+++ b/month_bottom.php
@@ -8,6 +8,8 @@
$next_day = date("Ymd", strtotime("+1 day", $unix_time));
$prev_day = date("Ymd", strtotime("-1 day", $unix_time));
+
+ $fake_getdate_time = strtotime($this_year.'-'.$this_month.'-15');
?>
<br>
<table border="0" width="737" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF" class="calborder">
@@ -27,7 +29,7 @@
<table width="160" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="left" valign="top" width="1"><img src="images/spacer.gif" width="1" height="20"></td>
- <td align="center"><font class="G10BOLD"><?php print (localizeDate ($dateFormat_month, strtotime("-1 month", strtotime($getdate)))); ?></font></td>
+ <td align="center"><font class="G10BOLD"><?php print (localizeDate ($dateFormat_month, strtotime("-1 month", $fake_getdate_time))); ?></font></td>
<td align="right" valign="top" width="1"></td>
</tr>
<tr>
@@ -57,7 +59,7 @@
<td colspan="7"><img src="images/spacer.gif" width="1" height="3" alt=""></td>
</tr>
<?php
- $minical_time = strtotime("-1 month", strtotime($getdate));
+ $minical_time = strtotime("-1 month", $fake_getdate_time);
$minical_month = date("m", $minical_time);
$minical_year = date("Y", $minical_time);
$first_of_month = $minical_year.$minical_month."01";
@@ -254,7 +256,7 @@
<table width="160" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="left" valign="top" width="1"><img src="images/spacer.gif" width="1" height="20"></td>
- <td align="center"><font class="G10BOLD"><?php print (localizeDate ($dateFormat_month, strtotime("+1 month", strtotime($getdate)))); ?></font></td>
+ <td align="center"><font class="G10BOLD"><?php print (localizeDate ($dateFormat_month, strtotime("+1 month", $fake_getdate_time))); ?></font></td>
<td align="right" valign="top" width="1"></td>
</tr>
<tr>
@@ -284,7 +286,7 @@
<td colspan="7"><img src="images/spacer.gif" width="1" height="3" alt=""></td>
</tr>
<?php
- $minical_time = strtotime("+1 month", strtotime($getdate));
+ $minical_time = strtotime("+1 month", $fake_getdate_time);
$minical_month = date("m", $minical_time);
$minical_year = date("Y", $minical_time);
$first_of_month = $minical_year.$minical_month."01";
diff --git a/search.php b/search.php
index 5943694..b99faed 100644
--- a/search.php
+++ b/search.php
@@ -39,7 +39,7 @@ $search_box .=
'<form action="search.php" method="GET">'."\n".
'<input type="hidden" name="cal" value="'.$cal.'">'."\n".
'<input type="hidden" name="getdate" value="'.$getdate.'">'."\n".
- '<input type="text" size="15" class="search_style" name="query" value="'.$query.'">'."\n".
+ '<input type="text" size="15" name="query" value="'.$query.'">'."\n".
'<INPUT type="image" src="styles/'.$style_sheet.'/search.gif" border=0 height="19" width="18" name="submit" value="Search">'."\n".
'</form>';
@@ -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 "<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 (isset($val['recur'])) {
+ $recur = $val['recur'];
+ echo "<tr>\n";
+ echo "<td valign=\"top\" width=\"100\" class=\"G10BOLD\">Recurring event:</td>\n";
+ echo "<td valign=\"top\" align=\"left\" class=\"G10B\">$recur</td>\n";
+ echo "</tr>\n";
+ }
if ($val["description"]) {
echo "<tr>\n";
echo "<td valign=\"top\" width=\"100\" class=\"G10BOLD\">$description_lang:</td>\n";
@@ -178,6 +194,61 @@ $search_took = number_format(($search_ended-$search_started),3);
echo "</td>\n";
echo "</tr>\n";
echo "<tr><td colspan=\"3\"><img src=\"images/spacer.gif\" width=\"1\" height=\"10\"></td></tr>\n";
+ if (isset($val['exceptions'])) {
+ foreach($val['exceptions'] as $val2) {
+ $key = $val2['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=\"V10\"><i>Exception:</i> <a class=\"ps3\" href=\"day.php?cal=$cal&getdate=$key\">$dayofmonth</a></font></td></tr>";
+ echo "<tr><td colspan=\"3\"><img src=\"images/spacer.gif\" width=\"1\" height=\"5\"></td></tr>\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 "<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 (isset($val2['recur'])) {
+ $recur = $val2['recur'];
+ echo "<tr>\n";
+ echo "<td valign=\"top\" width=\"100\" class=\"G10BOLD\">Recurring event:</td>\n";
+ echo "<td valign=\"top\" align=\"left\" class=\"G10B\">$recur</td>\n";
+ echo "</tr>\n";
+ }
+ if ($val2["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 {
@@ -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);
diff --git a/sidebar.php b/sidebar.php
index 1c929fb..fa9469a 100644
--- a/sidebar.php
+++ b/sidebar.php
@@ -225,7 +225,9 @@
</tr>
</table>
<br>
-<?php } ?>
+<?php }
+ $fake_getdate_time = strtotime($this_year.'-'.$this_month.'-15');
+?>
<table cellpadding="0" cellspacing="0" border="0" width="170">
<tr>
<td valign="center" align="center">
@@ -233,7 +235,7 @@
<tr>
<td align="left" valign="top" width="1" class="sideback"><img src="images/spacer.gif" width="1" height="20"></td>
- <td align="center" class="sideback"><font class="G10BOLD"><?php print (localizeDate ($dateFormat_month, strtotime("-1 month", strtotime($getdate)))); ?></font></td>
+ <td align="center" class="sideback"><font class="G10BOLD"><?php print (localizeDate ($dateFormat_month, strtotime("-1 month", $fake_getdate_time))); ?></font></td>
<td align="right" valign="top" width="1" class="sideback"></td>
</tr>
<tr>
@@ -263,7 +265,7 @@
<td colspan="7"><img src="images/spacer.gif" width="1" height="3" alt=""></td>
</tr>
<?php
- $minical_time = strtotime("-1 month", strtotime($getdate));
+ $minical_time = strtotime("-1 month", $fake_getdate_time);
$minical_month = date("m", $minical_time);
$minical_year = date("Y", $minical_time);
$first_of_month = $minical_year.$minical_month."01";
@@ -343,7 +345,7 @@
<td colspan="7"><img src="images/spacer.gif" width="1" height="3" alt=""></td>
</tr>
<?php
- $minical_time = strtotime($getdate);
+ $minical_time = $fake_getdate_time;
$minical_month = date("m", $minical_time);
$minical_year = date("Y", $minical_time);
$first_of_month = $minical_year.$minical_month."01";
@@ -423,7 +425,7 @@
<td colspan="7"><img src="images/spacer.gif" width="1" height="3" alt=""></td>
</tr>
<?php
- $minical_time = strtotime("+1 month", strtotime($getdate));
+ $minical_time = strtotime("+1 month", $fake_getdate_time);
$minical_month = date("m", $minical_time);
$minical_year = date("Y", $minical_time);
$first_of_month = $minical_year.$minical_month."01";

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