From a02ca8fd76dfa6b0f280780f76fb9bfce5a9fd36 Mon Sep 17 00:00:00 2001 From: Jim Hu Date: Fri, 26 Dec 2008 16:59:10 +0000 Subject: eliminate negative event lengths and adjust display lengths for short events --- calendars/test.ics | 40 ++++++++++++++++++++++++++++++++++++++++ config.inc.php | 3 ++- functions/parse/end_vevent.php | 11 ++++++++--- functions/template.php | 8 +++++--- includes/event.php | 20 ++++++-------------- languages/english.inc.php | 1 + templates/default/event.tpl | 3 +++ 7 files changed, 65 insertions(+), 21 deletions(-) diff --git a/calendars/test.ics b/calendars/test.ics index ecfe9f3..c24019f 100644 --- a/calendars/test.ics +++ b/calendars/test.ics @@ -24,6 +24,45 @@ TZNAME:PDT END:DAYLIGHT END:VTIMEZONE +BEGIN:VEVENT +UID:20081128T075152Z-3660-100-1-5@sietchtabr +DTSTAMP:20081128T075151Z +LAST-MODIFIED:20081128T075152 +SUMMARY:Witchcraft Paris +CATEGORIES:jdr +DTSTART;TZID=/softwarestudio.org/Tzfile/Europe/Paris:20081213T210000 +DTEND;TZID=/softwarestudio.org/Tzfile/Europe/Paris:20081213T230000 +CLASS:PUBLIC +SEQUENCE:1 +CREATED:20081128T075152 +END:VEVENT + +BEGIN:VEVENT +UID:20081128T075152Z-3660-100-1-6@sietchtabr2 +DTSTAMP:20081128T075151Z +LAST-MODIFIED:20081128T075152 +SUMMARY:Witchcraft PST +CATEGORIES:jdr +DTSTART;TZID=US/Pacific:20081213T210000 +DTEND;TZID=US/Pacific:20081213T230000 +CLASS:PUBLIC +SEQUENCE:1 +CREATED:20081128T075152 +END:VEVENT + +BEGIN:VEVENT +UID:20081128T075152Z-3660-100-1-7@sietchtabr2 +DTSTAMP:20081128T075151Z +LAST-MODIFIED:20081128T075152 +SUMMARY:daylight test PST +CATEGORIES:jdr +DTSTART;TZID=US/Pacific:20060331T010000 +DTEND;TZID=US/Pacific:20060331T020000 +RRULE:FREQ=DAILY; +CLASS:PUBLIC +SEQUENCE:1 +CREATED:20081128T075152 +END:VEVENT BEGIN:VEVENT DTSTAMP:20070616T185152Z @@ -47,6 +86,7 @@ STATUS:CONFIRMED DURATION:PT1H30M DTSTART;TZID=US/Eastern:20100902T090000 RRULE:FREQ=DAILY;COUNT=10 +URL:http://google.com END:VEVENT BEGIN:VEVENT diff --git a/config.inc.php b/config.inc.php index 4eb7eb2..e961a05 100644 --- a/config.inc.php +++ b/config.inc.php @@ -15,7 +15,8 @@ $configs = array( # 'show_todos' => 'no', 'show_completed' => 'no', # 'timezone' => 'US/Central', - 'timezone' => 'America/Bogota', +# 'timezone' => 'America/Bogota', + 'timezone' => 'Europe/Paris', # 'second_offset' => $secs, # 'cookie_uri' => '' ); diff --git a/functions/parse/end_vevent.php b/functions/parse/end_vevent.php index 4c5c352..3f14924 100644 --- a/functions/parse/end_vevent.php +++ b/functions/parse/end_vevent.php @@ -48,7 +48,12 @@ if (isset($start_time) && isset($end_time)) { $allday_end = ($start_date + 1); } } - +# disallow events with negative length +if ($end_unixtime < $start_unixtime){ + $end_date = $start_date; + $end_time = $start_time; + $end_unixtime = $start_unixtime; +} # look for events that span more than one day if (isset($start_unixtime,$end_unixtime) && date('Ymd',$start_unixtime) != date('Ymd',$end_unixtime)) { $spans_day = true; @@ -63,9 +68,9 @@ if (isset($start_time) && $start_time != '') { preg_match ('/([0-9]{2})([0-9]{2})/', $start_time, $time); preg_match ('/([0-9]{2})([0-9]{2})/', $end_time, $time2); if (isset($start_unixtime) && isset($end_unixtime)) { - $length = $end_unixtime - $start_unixtime; + $length = $end_unixtime - $start_unixtime; } else { - $length = ($time2[1]*60+$time2[2]) - ($time[1]*60+$time[2]); + $length = ($time2[1]*60+$time2[2]) - ($time[1]*60+$time[2]); } $drawKey = drawEventTimes($start_time, $end_time); diff --git a/functions/template.php b/functions/template.php index 4df442c..bf4f340 100644 --- a/functions/template.php +++ b/functions/template.php @@ -359,7 +359,6 @@ class Page { $key = mktime($regs_tmp[1],$regs_tmp[2],0,$this_month,$this_day,$this_year); $key = date ($timeFormat, $key); - if (ereg("([0-9]{1,2}):00", $key)) { $weekdisplay .= ''; $weekdisplay .= ''.$key.''; @@ -466,11 +465,14 @@ class Page { $confirmed .= ' '; } $colspan_width = round((80 / $nbrGridCols[$thisday]) * $drawWidth); + $event_temp = $loop_event; + $event = openevent($thisday, $cal_time, $uid, $this_time_arr[$uid], $phpiCal_config->week_events_lines, 25, 'ps'); + # adjust length by rough guess to word wrapping + $event_text_lines = ceil((strlen(strip_tags(trim($event))) * 8)/$colspan_width) + 1; + if ($event_length[$thisday][$i]['length'] < $event_text_lines) $event_length[$thisday][$i]['length'] = $event_text_lines; $weekdisplay .= ''."\n"; // Start drawing the event - $event_temp = $loop_event; - $event = openevent($thisday, $cal_time, $uid, $this_time_arr[$uid], $phpiCal_config->week_events_lines, 25, 'ps'); $event_temp = str_replace('{EVENT}', $event, $event_temp); $event_temp = str_replace('{EVENT_START}', $event_start, $event_temp); $event_temp = str_replace('{CONFIRMED}', $confirmed, $event_temp); diff --git a/includes/event.php b/includes/event.php index d5ac529..fe03042 100644 --- a/includes/event.php +++ b/includes/event.php @@ -43,20 +43,10 @@ if (isset($attendee) && is_array($attendee)) { } $attendee = implode(', ',$attendees); } - -if (isset($event['location'])) { - if ($event['url'] != '') $event['location'] = ''.stripslashes($event['location']).''; -}else{ - $event['location'] = stripslashes($event['location']); -} - -if (!isset($event['location']) && isset($event['url'])) { - $event['location'] = ''.$event['url'].''; - $lang['l_location'] = 'URL'; -} - +if (isset($event['location'])) $event['location'] = stripslashes($event['location']); if (sizeof($attendee) == 0) $attendee = ''; if (sizeof($organizer) == 0) $organizer = ''; +if ($event['url'] != '') $event['url'] = ''.$event['url'].''; switch ($event['status']){ case 'CONFIRMED': @@ -83,7 +73,8 @@ $page->replace_tags(array( 'organizer' => $organizer, 'attendee' => $attendee, 'status' => $event['status'], - 'location' => stripslashes($event['location']), + 'location' => $event['location'], + 'url' => $event['url'], 'cal_title_full' => $event['calname'].' '.$lang['l_calendar'], 'template' => $phpiCal_config->template, 'l_summary' => $lang['l_summary'], @@ -91,7 +82,8 @@ $page->replace_tags(array( 'l_organizer' => $lang['l_organizer'], 'l_attendee' => $lang['l_attendee'], 'l_status' => $lang['l_status'], - 'l_location' => $lang['l_location'] + 'l_location' => $lang['l_location'], + 'l_url' => $lang['l_url'] )); diff --git a/languages/english.inc.php b/languages/english.inc.php index 1d9dd8a..c174be1 100644 --- a/languages/english.inc.php +++ b/languages/english.inc.php @@ -94,6 +94,7 @@ $lang['l_unset_prefs'] = 'Unset preferences'; $lang['l_organizer'] = 'Organizer'; $lang['l_attendee'] = 'Attendee'; $lang['l_location'] = 'Location'; +$lang['l_url'] = 'URL'; $lang['l_admin_header'] = 'PHP iCalendar Administration'; $lang['l_username'] = 'Username'; $lang['l_password'] = 'Password'; diff --git a/templates/default/event.tpl b/templates/default/event.tpl index 48a1572..b0a9a7f 100644 --- a/templates/default/event.tpl +++ b/templates/default/event.tpl @@ -32,6 +32,9 @@ {L_LOCATION}: {LOCATION}
+ + {L_URL}: {URL}
+

-- cgit v1.2.3