From: David F. <da...@d2...> - 2005-05-05 19:54:15
Attachments:
openevent.patch
|
Attached is a borderline-2.0 worthy cleanup of openevent/event.php. It simplifies the function by changing the data-passing to use the date/time/uid to then lookup the event info in $master_array in event.php, instead of passing the raw data. It's possibly a precursor to even more cleanup of that whole process, by turning the popups into simple links instead of using the hidden form to pass data around. Note this assumes that the UIDs are unique across calendars, which seems to be a valid assumption given how $master_array is structured (if it's a bogus assumption, then events with the same $uid are going to be overwriting each other anyways). If this is valid, I should also clean up how todo.php works (amusingly, in a totally different fashion, using a base64-encoded get string. lends more validity to "the right way" being removing the hidden form stuff completely, but it's a big enough structure change I want to make sure there wasn't some other valid reason I just don't know about for doing it). This patch also fixes an actual bug - the event.php popup should have had the title be "$calname $lang['l_calendar']" - i.e., "US Holidays Calendar" - it was using the old translation syntax, and thus was just showing up as "US Holidays". Actually, this is probably worth going into 2.0, as I realized it's a decently-smaller HTML render, as now all the event info isn't included in the page for every event (twice). called openevent.patch look, diffstat says it's good! :) davef@rake-l:phpicalendar-working 539 > diffstat openevent.patch functions/date_functions.php | 38 ++++------- functions/draw_functions.php | 2 functions/event.js | 30 ++------ functions/ical_parser.php | 14 ++-- functions/template.php | 148 ++++++++++++++++++------------------------- includes/event.php | 45 +++++-------- templates/default/event.tpl | 2 templates/default/header.tpl | 15 +--- 8 files changed, 118 insertions(+), 176 deletions(-) I'm also working on a post-2.0 enhancement that adds human-readable recurrence info to event.php. Cool feature, needs a decent amount more work to support all the various ways recurrence info could exist. I stuck the function that does this in ical_parser.php, which probably isn't right. Please let me know if you'd like to see the work-in-progress. dave |
From: Chad L. <ch...@ch...> - 2005-09-15 22:00:39
Attachments:
npawl.ics
|
Hi David, just a quick look at this its really great and lightens up the code -- which is a big plus. Small bug though, it seems to fail on the popup when the event doesn't start at 00 or 30. I've attached an example, should be an easy fix if you have the time. If not let me know and I can take a crack next week. Thanks! -Chad |
From: David F. <da...@d2...> - 2005-09-15 22:54:30
|
fixed, I just had to pass the right time through the openevent call. Makes the code not quite as nice, but it works. ;) Eventually, we should fix master_array to just be an array of cal+uids, and have some sort of schedule_array that has the rendered out time info, but this will work for now. dave Chad Little wrote: > Hi David, just a quick look at this its really great and lightens up > the code -- which is a big plus. Small bug though, it seems to fail on > the popup when the event doesn't start at 00 or 30. I've attached an > example, should be an easy fix if you have the time. If not let me know > and I can take a crack next week. > > Thanks! > -Chad > > > ------------------------------------------------------------------------ > > BEGIN:VCALENDAR > VERSION > :2.0 > PRODID > :-//Mozilla.org/NONSGML Mozilla Calendar V1.0//EN > BEGIN:VEVENT > UID > :bb1dfd22-2010-11da-b0c5-a1d3cf6ca8c3 > SUMMARY > :somthing here > LOCATION > :home > STATUS > :TENTATIVE > CLASS > :PRIVATE > X-MOZILLA-ALARM-DEFAULT-LENGTH > :0 > DTSTART > :20050909T223500 > DTEND > :20050909T233500 > DTSTAMP > :20050908T023152Z > END:VEVENT > BEGIN:VEVENT > UID > :dd728244-25a1-11da-ac6f-b813383d47aa > SUMMARY > :Welcome to somthing new > STATUS > :TENTATIVE > CLASS > :PUBLIC > X-MOZILLA-ALARM-DEFAULT-LENGTH > :0 > DTSTART > :20050916T003500 > DTEND > :20050916T013500 > DTSTAMP > :20050915T043318Z > END:VEVENT > BEGIN:VEVENT > UID > :c1fc0b42-25a2-11da-a540-96b008ecd756 > SUMMARY > :fafsdffffffffffffffff > DESCRIPTION > :asdffffffffffffffffffffffffffffffffffa\nasdffffffffffffffffffffffffffffffff > ffaasdffffffffffffffffffffffffffffffffffa\nasdfffffffffffffffffffffffffffff > fffffa\nasdffffffffffffffffffffffffffffffffffa\nasdfffffffffffffffffffffff > fffffffffffav\nv\nasdffffffffffffffffffffffffffffffffffa\nasdffffffffffff > ffffffffffffffffffffffa > LOCATION > :asdfffffffffffffffffffffffffff > STATUS > :CONFIRMED > CLASS > :PUBLIC > X-MOZILLA-ALARM-DEFAULT-LENGTH > :0 > DTSTART > :20050915T004000 > DTEND > :20050915T014000 > DTSTAMP > :20050915T043936Z > END:VEVENT > END:VCALENDAR > > > ------------------------------------------------------------------------ > > > > On May 5, 2005, at 12:54 PM, David Fallon wrote: > >> Attached is a borderline-2.0 worthy cleanup of openevent/event.php. >> It simplifies the function by changing the data-passing to use the >> date/time/uid to then lookup the event info in $master_array in >> event.php, instead of passing the raw data. It's possibly a precursor >> to even more cleanup of that whole process, by turning the popups >> into simple links instead of using the hidden form to pass data >> around. Note this assumes that the UIDs are unique across calendars, >> which seems to be a valid assumption given how $master_array is >> structured (if it's a bogus assumption, then events with the same >> $uid are going to be overwriting each other anyways). If this is >> valid, I should also clean up how todo.php works (amusingly, in a >> totally different fashion, using a base64- encoded get string. lends >> more validity to "the right way" being removing the hidden form stuff >> completely, but it's a big enough structure change I want to make >> sure there wasn't some other valid reason I just don't know about for >> doing it). >> >> This patch also fixes an actual bug - the event.php popup should have >> had the title be "$calname $lang['l_calendar']" - i.e., "US Holidays >> Calendar" - it was using the old translation syntax, and thus was >> just showing up as "US Holidays". >> >> Actually, this is probably worth going into 2.0, as I realized it's a >> decently-smaller HTML render, as now all the event info isn't >> included in the page for every event (twice). >> >> called openevent.patch >> >> look, diffstat says it's good! :) >> >> davef@rake-l:phpicalendar-working 539 > diffstat openevent.patch >> functions/date_functions.php | 38 ++++------- >> functions/draw_functions.php | 2 >> functions/event.js | 30 ++------ >> functions/ical_parser.php | 14 ++-- >> functions/template.php | 148 +++++++++++++++++ >> +------------------------- >> includes/event.php | 45 +++++-------- >> templates/default/event.tpl | 2 >> templates/default/header.tpl | 15 +--- >> 8 files changed, 118 insertions(+), 176 deletions(-) >> >> I'm also working on a post-2.0 enhancement that adds human-readable >> recurrence info to event.php. Cool feature, needs a decent amount >> more work to support all the various ways recurrence info could >> exist. I stuck the function that does this in ical_parser.php, which >> probably isn't right. Please let me know if you'd like to see the >> work-in-progress. >> >> dave >> Index: functions/date_functions.php >> =================================================================== >> RCS file: /cvsroot/phpicalendar/phpicalendar/functions/ >> date_functions.php,v >> retrieving revision 1.26 >> diff -u -r1.26 date_functions.php >> --- functions/date_functions.php 26 Oct 2004 19:12:29 -0000 1.26 >> +++ functions/date_functions.php 5 May 2005 19:48:53 -0000 >> @@ -162,44 +162,38 @@ >> return $offset; >> } >> >> -function openevent($calendar_name, $start, $end, $arr, $lines, >> $wrap, $pre_text, $post_text, $link_class, $url) { >> +function openevent($event_date, $uid, $arr, $lines = 0, $length = 0, >> $link_class = '', $pre_text = '', $post_text = '') { >> + >> $event_text = stripslashes(urldecode($arr["event_text"])); >> if (empty($start)) { >> $title = $event_text; >> } else { >> - $title = $start.' - '.$end.': '.$event_text; >> + $title = $arr['event_start'].' - '.$arr['event_end'].': '. >> $event_text; >> } >> # for iCal pseudo tag <http> comptability >> - if (ereg("<([[:alpha:]]+://)([^<>[:space:]]+)>",$event_text, >> $matches)) { >> - $full_event_text = $matches[1] . $matches[2]; >> + if (ereg("<([[:alpha:]]+://)([^<>[:space:]]+)>",$event_text, >> $matches)) { >> + $full_event_text = $matches[1] . $matches[2]; >> $event_text = $matches[2]; >> - } else { >> + } else { >> $full_event_text = $event_text; >> $event_text = strip_tags($event_text, '<b><i><u>'); >> } >> >> - if (isset($arr["organizer"])) $organizer = addslashes($arr >> ["organizer"]); >> - if (isset($arr["attendee"])) $attendee = addslashes($arr >> ["attendee"]); >> - if (isset($arr["location"])) $location = addslashes($arr >> ["location"]); >> - if (isset($arr["status"])) $status = addslashes($arr["status"]); >> - if (isset($arr["description"])) $description = addslashes >> (stripslashes(urldecode($arr["description"]))); >> - if (isset($arr["url"])) $url = addslashes(stripslashes >> (urldecode($arr["url"]))); >> - >> - if (!empty($event_text)) { >> + if (!empty($event_text)) { >> if ($lines > 0) { >> - $event_text = word_wrap($event_text, $wrap, $lines); >> + $event_text = word_wrap($event_text, $length, $lines); >> } >> >> - if ((!(ereg("([[:alpha:]]+://[^<>[:space:]]+)", >> $full_event_text, $res))) || ($description)) { >> - $escaped_event = addslashes($full_event_text); >> - $escaped_calendar = addslashes($calendar_name); >> - $escaped_start = addslashes($start); >> - $escaped_end = addslashes($end); >> + if ((!(ereg("([[:alpha:]]+://[^<>[:space:]]+)", >> $full_event_text, $res))) || ($arr['description'])) { >> + $escaped_date = addslashes($event_date); >> + $escaped_time = addslashes($arr['event_start']); >> + if (!$escaped_time) $escaped_time = -1; >> + $escaped_uid = addslashes($uid); >> // fix for URL-length bug in IE: populate and submit a >> hidden form on click >> static $popup_data_index = 0; >> $return = " >> <script language=\"Javascript\" type=\"text/javascript\"><!-- >> - var eventData = new EventData('$escaped_event', >> '$escaped_calendar', '$escaped_start', '$escaped_end', >> '$description', '$status', '$location', '$organizer', '$attendee', >> '$url'); >> + var eventData = new EventData('$escaped_date', '$escaped_time', >> '$escaped_uid'); >> document.popup_data[$popup_data_index] = eventData; >> // --></script>"; >> >> @@ -210,9 +204,7 @@ >> } >> $return .= $pre_text.$event_text.$post_text.'</a>'."\n"; >> } >> - >> + >> return $return; >> } >> - >> - >> ?> >> Index: functions/draw_functions.php >> =================================================================== >> RCS file: /cvsroot/phpicalendar/phpicalendar/functions/ >> draw_functions.php,v >> retrieving revision 1.5 >> diff -u -r1.5 draw_functions.php >> --- functions/draw_functions.php 20 May 2004 06:04:14 -0000 1.5 >> +++ functions/draw_functions.php 5 May 2005 19:48:53 -0000 >> @@ -46,4 +46,4 @@ >> } >> return $str; >> } >> -?> >> \ No newline at end of file >> +?> >> Index: functions/event.js >> =================================================================== >> RCS file: /cvsroot/phpicalendar/phpicalendar/functions/event.js,v >> retrieving revision 1.13 >> diff -u -r1.13 event.js >> --- functions/event.js 12 Aug 2004 20:32:50 -0000 1.13 >> +++ functions/event.js 5 May 2005 19:48:53 -0000 >> @@ -4,16 +4,9 @@ >> // populate the hidden form >> var data = document.popup_data[num]; >> var form = document.forms.eventPopupForm; >> - form.elements.event.value = data.event; >> - form.elements.cal.value = data.cal; >> - form.elements.start.value = data.start; >> - form.elements.end.value = data.end; >> - form.elements.description.value = data.description; >> - form.elements.status.value = data.status; >> - form.elements.location.value = data.location; >> - form.elements.organizer.value = data.organizer; >> - form.elements.attendee.value = data.attendee; >> - form.elements.url.value = data.url; >> + form.elements.date.value = data.date; >> + form.elements.time.value = data.time; >> + form.elements.uid.value = data.uid; >> >> // open a new window >> var w = window.open('', 'Popup', >> 'scrollbars=yes,width=460,height=275'); >> @@ -21,17 +14,10 @@ >> form.submit(); >> } >> >> -function EventData(event, cal, start, end, description, status, >> location, organizer, attendee, url) { >> - this.event = event; >> - this.cal = cal; >> - this.start = start; >> - this.end = end; >> - this.description = description; >> - this.status = status; >> - this.location = location; >> - this.organizer = organizer; >> - this.attendee = attendee; >> - this.url = url; >> +function EventData(date, time, uid) { >> + this.date = date; >> + this.time = time; >> + this.uid = uid; >> } >> >> function openTodoInfo(vtodo_array) { >> @@ -45,4 +31,4 @@ >> >> document.popup_data = new Array(); >> //--> >> -</script> >> \ No newline at end of file >> +</script> >> Index: functions/ical_parser.php >> =================================================================== >> RCS file: /cvsroot/phpicalendar/phpicalendar/functions/ ical_parser.php,v >> retrieving revision 1.186 >> diff -u -r1.186 ical_parser.php >> --- functions/ical_parser.php 9 Nov 2004 20:53:11 -0000 1.186 >> +++ functions/ical_parser.php 5 May 2005 19:48:54 -0000 >> @@ -462,7 +462,9 @@ >> $master_array[($start_date)] >> [($hour.$minute)][$uid]['recur'][$key] = $wkst; >> break; >> case 'END': >> - >> + >> + $recur = $master_array[($start_date)] >> [($hour.$minute)][$uid]['recur']; >> + >> // Modify the COUNT based on BYDAY >> if ((is_array($byday)) && (isset >> ($count))) { >> $blah = sizeof($byday); >> @@ -669,7 +671,7 @@ >> $end_time2 = >> strtotime('+'.$diff_allday_days.' days', $recur_data_time); >> while >> ($start_time2 < $end_time2) { >> $start_date2 >> = date('Ymd', $start_time2); >> - >> $master_array[($start_date2)][('-1')][] = array ('event_text' => >> $summary, 'description' => $description, 'location' => $location, >> 'organizer' => serialize($organizer), 'attendee' => serialize >> ($attendee), 'calnumber' => $calnumber, 'calname' => $actual_calname, >> 'url' => $url, 'status' => $status, 'class' => $class ); >> + >> $master_array[($start_date2)][('-1')][$uid] = array ('event_text' => >> $summary, 'description' => $description, 'location' => $location, >> 'organizer' => serialize($organizer), 'attendee' => >> serialize($attendee), 'calnumber' => $calnumber, 'calname' => >> $actual_calname, 'url' => $url, 'status' => $status, 'class' => >> $class, 'recur' => $recur ); >> $start_time2 >> = strtotime('+1 day', $start_time2); >> } >> } else { >> @@ -699,7 +701,7 @@ >> >> $until_check = $start_date_tmp.$time_tmp.'00'; >> if >> ($abs_until > $until_check) { >> >> $nbrOfOverlaps = checkOverlap($start_date_tmp, $start_time_tmp, >> $end_time_tmp, $uid); >> - >> $master_array[$start_date_tmp][$time_tmp][$uid] = array >> ('event_start' => $start_time_tmp, 'event_end' => $end_time_tmp, >> 'display_end' => $display_end_tmp, 'start_unixtime' => >> $start_unixtime_tmp, 'end_unixtime' => $end_unixtime_tmp, >> 'event_text' => $summary, 'event_length' => $length, 'event_overlap' >> => $nbrOfOverlaps, 'description' => $description, 'status' => >> $status, 'class' => $class, 'spans_day' => true, 'location' => >> $location, 'organizer' => serialize($organizer), 'attendee' => >> serialize($attendee), 'calnumber' => $calnumber, 'calname' => >> $actual_calname, 'url' => $url) ; >> + >> $master_array[$start_date_tmp][$time_tmp][$uid] = array >> ('event_start' => $start_time_tmp, 'event_end' => $end_time_tmp, >> 'display_end' => $display_end_tmp, 'start_unixtime' => >> $start_unixtime_tmp, 'end_unixtime' => $end_unixtime_tmp, >> 'event_text' => $summary, 'event_length' => $length, 'event_overlap' >> => $nbrOfOverlaps, 'description' => $description, 'status' => >> $status, 'class' => $class, 'spans_day' => true, 'location' => >> $location, 'organizer' => serialize($organizer), 'attendee' => >> serialize($attendee), 'calnumber' => $calnumber, 'calname' => >> $actual_calname, 'url' => $url, 'recur' => $recur) ; >> } >> >> $start_tmp = strtotime('+1 day',$start_tmp); >> } >> @@ -715,7 +717,7 @@ >> $until_check >> = $recur_data_date.$hour.$minute.'00'; >> if >> ($abs_until > $until_check) { >> >> $nbrOfOverlaps = checkOverlap($recur_data_date, $start_time, >> $end_time_tmp1, $uid); >> - >> $master_array[($recur_data_date)][($hour.$minute)][$uid] = array >> ('event_start' => $start_time, 'event_end' => $end_time_tmp1, >> 'display_end' => $display_end_tmp, 'start_unixtime' => >> $start_unixtime_tmp, 'end_unixtime' => $end_unixtime_tmp, >> 'event_text' => $summary, 'event_length' => $length, 'event_overlap' >> => $nbrOfOverlaps, 'description' => $description, 'status' => >> $status, 'class' => $class, 'spans_day' => false, 'location' => >> $location, 'organizer' => serialize($organizer), 'attendee' => >> serialize($attendee), 'calnumber' => $calnumber, 'calname' => >> $actual_calname, 'url' => $url); >> + >> $master_array[($recur_data_date)][($hour.$minute)][$uid] = array >> ('event_start' => $start_time, 'event_end' => $end_time_tmp1, >> 'display_end' => $display_end_tmp, 'start_unixtime' => >> $start_unixtime_tmp, 'end_unixtime' => $end_unixtime_tmp, >> 'event_text' => $summary, 'event_length' => $length, 'event_overlap' >> => $nbrOfOverlaps, 'description' => $description, 'status' => >> $status, 'class' => $class, 'spans_day' => false, 'location' => >> $location, 'organizer' => serialize($organizer), 'attendee' => >> serialize($attendee), 'calnumber' => $calnumber, 'calname' => >> $actual_calname, 'url' => $url, 'recur' => $recur); >> } >> } >> } >> @@ -1176,7 +1178,7 @@ >> //print_r($overlap_array); >> //print_r($day_array); >> //print_r($rrule_array); >> -//print_r($recurrence_delete); >> +//print_r($recurrence_delete); >> //print '</pre>'; >> >> // Set a calender name for all calenders combined >> @@ -1185,5 +1187,5 @@ >> } >> >> $template_started = getmicrotime(); >> - >> + >> ?> >> Index: functions/template.php >> =================================================================== >> RCS file: /cvsroot/phpicalendar/phpicalendar/functions/template.php,v >> retrieving revision 1.68 >> diff -u -r1.68 template.php >> --- functions/template.php 5 May 2005 07:07:50 -0000 1.68 >> +++ functions/template.php 5 May 2005 19:48:54 -0000 >> @@ -264,17 +264,15 @@ >> $loop_ad = trim($match1[1]); >> $loop_begin = trim($match2[1]); >> $loop_end = trim($match3[1]); >> - foreach ($weekarray as $key => $get_date) { >> + foreach ($weekarray as $get_date) { >> $replace = $loop_begin; >> $colspan = 'colspan="'.$nbrGridCols[$get_date].'"'; >> $replace = str_replace('{COLSPAN}', $colspan, >> $replace); >> if (is_array($master_array[$get_date]['-1'])) { >> - foreach ($master_array[$get_date]['-1'] as $allday) { >> + foreach ($master_array[$get_date]['-1'] as $uid => >> $allday) { >> $event_calno = $allday['calnumber']; >> - $event_calna = $allday['calname']; >> - $event_url = $allday['url']; >> if ($event_calno > $unique_colors) $event_calno >> = ($event_calno - $unique_colors); >> - $event = openevent($event_calna, '', >> '', $allday, 1, 11, '', '', 'psf', $event_url); >> + $event = openevent($get_date, $uid, >> $allday, 1, 11, 'psf'); >> $loop_tmp = str_replace('{ALLDAY}', >> $event, $loop_ad); >> $loop_tmp = str_replace('{CALNO}', >> $event_calno, $loop_tmp); >> $replace .= $loop_tmp; >> @@ -365,7 +363,7 @@ >> $thisday = date("Ymd", $thisdate); >> $dayborder = 0; >> unset($this_time_arr); >> - >> + >> if ($day_start == $cal_time && isset($master_array >> [$thisday]) && is_array($master_array[$thisday])) { >> foreach($master_array[$thisday] as $time_key => >> $time_arr) { >> if ((int)$time_key <= (int)$cal_time) { >> @@ -424,18 +422,17 @@ >> } else { >> $emptyWidth = $nbrGridCols[$thisday]; >> for ($i=0;$i<sizeof($event_length[$thisday]);$i >> ++) { >> - >> + >> $drawWidth = $nbrGridCols[$thisday] / >> ($event_length[$thisday][$i]["overlap"] + 1); >> $emptyWidth = $emptyWidth - $drawWidth; >> switch ($event_length[$thisday][$i] ["state"]) { >> case "begin": >> $event_length[$thisday][$i] ["state"] >> = "started"; >> - $event_start = $this_time_arr >> [($event_length[$thisday][$i]["key"])]['start_unixtime']; >> + $uid = $event_length[$thisday][$i] >> ["key"]; >> + $event_start = $this_time_arr >> [$uid]['start_unixtime']; >> $event_start = date >> ($timeFormat_small, $event_start); >> - $event_calno = $this_time_arr >> [($event_length[$thisday][$i]['key'])]['calnumber']; >> - $event_calna = $this_time_arr >> [($event_length[$thisday][$i]['key'])]['calname']; >> - $event_url = $this_time_arr >> [($event_length[$thisday][$i]['key'])]['url']; >> - $event_status = strtolower >> ($this_time_arr[($event_length[$thisday][$i]['key'])]['status']); >> + $event_calno = $this_time_arr >> [$uid]['calnumber']; >> + $event_status = strtolower >> ($this_time_arr[$uid]['status']); >> if ($event_calno > $unique_colors) >> $event_calno = ($event_calno - $unique_colors); >> if ($event_status != '') { >> $confirmed = '<img >> src="images/'.$event_status.'.gif" width="9" height="9" alt="" >> border="0" hspace="0" vspace="0" /> '; >> @@ -443,13 +440,9 @@ >> $colspan_width = round((80 / >> $nbrGridCols[$thisday]) * $drawWidth); >> $weekdisplay .= '<td width="'. >> $colspan_width.'" rowspan="' . $event_length[$thisday][$i] ['length'] >> . '" colspan="' . $drawWidth . '" align="left" valign="top" >> class="eventbg2_'.$event_calno.'">'."\n"; >> >> - $event_end = $this_time_arr >> [($event_length[$thisday][$i]["key"])]["end_unixtime"]; >> - if (isset($this_time_arr >> [($event_length[$thisday][$i]["key"])]['display_end'])) $event_end = >> strtotime ($this_time_arr[($event_length[$thisday][$i]["key"])] >> ['display_end']); >> - $event_end = date ($timeFormat, >> $event_end); >> - >> // Start drawing the event >> - $event_temp = $loop_event; >> - $event = openevent >> ($event_calna, $event_start, $event_end, $this_time_arr >> [($event_length[$thisday][$i]["key"])], $week_events_lines, 25, '', >> '', 'ps', $event_url); >> + $event_temp = $loop_event; >> + $event = openevent >> ($thisday, $uid, $this_time_arr[$uid], $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); >> @@ -457,7 +450,7 @@ >> $weekdisplay .= $event_temp; >> $weekdisplay .= '</td>'; >> // End event drawing >> - >> + >> break; >> case "started": >> break; >> @@ -482,34 +475,30 @@ >> } >> $weekdisplay .= "</tr>\n"; >> } >> - >> + >> $this->page = preg_replace('!<\!-- loop row on -->(.*)< \!-- >> loop event off -->!is', $weekdisplay, $this->page); >> - >> - >> - >> + >> } >> - >> + >> function draw_day($template_p) { >> global $template, $getdate, $cal, $master_array, >> $unique_colors, $daysofweek_lang, $week_start_day, >> $dateFormat_week_list, $current_view, $day_array, $timeFormat, >> $gridLength, $day_start; >> - >> + >> // Replaces the allday events >> $replace = ''; >> if (is_array($master_array[$getdate]['-1'])) { >> preg_match("!<\!-- loop allday on -->(.*)<\!-- loop >> allday off -->!is", $this->page, $match1); >> $loop_ad = trim($match1[1]); >> - foreach ($master_array[$getdate]['-1'] as $allday) { >> + foreach ($master_array[$getdate]['-1'] as $uid => >> $allday) { >> $event_calno = $allday['calnumber']; >> - $event_calna = $allday['calname']; >> - $event_url = $allday['url']; >> if ($event_calno > $unique_colors) $event_calno = >> ($event_calno - $unique_colors); >> - $event = openevent($event_calna, '', '', >> $allday, 0, '', '', '', '', $event_url); >> + $event = openevent($getdate, $uid, >> $allday); >> $loop_tmp = str_replace('{ALLDAY}', $event, >> $loop_ad); >> $loop_tmp = str_replace('{CALNO}', >> $event_calno, $loop_tmp); >> $replace .= $loop_tmp; >> } >> } >> $this->page = preg_replace('!<\!-- loop allday on -->(.*)< >> \!-- loop allday off -->!is', $replace, $this->page); >> - >> + >> // Replaces the daysofweek >> preg_match("!<\!-- loop daysofweek on -->(.*)<\!-- loop >> daysofweek off -->!is", $this->page, $match1); >> $loop_dof = trim($match1[1]); >> @@ -588,12 +577,12 @@ >> } >> } >> } else { >> - // add events that overlap the start time >> - if (isset($master_array[$getdate][$cal_time]) && sizeof >> ($master_array[$getdate][$cal_time]) > 0) { >> - $this_time_arr = $master_array[$getdate][$cal_time]; >> + // add events that overlap the start time >> + if (isset($master_array[$getdate][$cal_time]) && >> sizeof($master_array[$getdate][$cal_time]) > 0) { >> + $this_time_arr = $master_array[$getdate] >> [$cal_time]; >> + } >> } >> - } >> - >> + >> // check for eventstart >> if (isset($this_time_arr) && sizeof($this_time_arr) > 0) { >> foreach ($this_time_arr as $eventKey => $loopevent) { >> @@ -642,14 +631,15 @@ >> switch ($event_length[$i]['state']) { >> case 'begin': >> $event_length[$i]['state'] = 'started'; >> - $event_start = strtotime >> ($this_time_arr[($event_length[$i]['key'])]['event_start']); >> - $event_end = strtotime ($this_time_arr >> [($event_length[$i]['key'])]['event_end']); >> - if (isset($this_time_arr[($event_length >> [$i]['key'])]['display_end'])) $event_end = strtotime >> ($this_time_arr[($event_length[$i]['key'])]['display_end']); >> + $uid = $event_length[$i]['key']; >> + $event_start = strtotime >> ($this_time_arr[$uid]['event_start']); >> + $event_end = strtotime ($this_time_arr >> [$uid]['event_end']); >> + if (isset($this_time_arr[$uid] >> ['display_end'])) $event_end = strtotime ($this_time_arr[$uid] >> ['display_end']); >> $event_start = date ($timeFormat, >> $event_start); >> $event_end = date ($timeFormat, >> $event_end); >> - $event_calno = $this_time_arr >> [($event_length[$i]['key'])]['calnumber']; >> - $event_recur = $this_time_arr >> [($event_length[$i]['key'])]['recur']; >> - $event_status = strtolower($this_time_arr >> [($event_length[$i]['key'])]['status']); >> + $event_calno = $this_time_arr[$uid] >> ['calnumber']; >> + $event_recur = $this_time_arr[$uid] >> ['recur']; >> + $event_status = strtolower($this_time_arr >> [$uid]['status']); >> if ($event_calno > $unique_colors) >> $event_calno = ($event_calno - $unique_colors); >> if ($event_status != '') { >> $confirmed = '<img src="images/'. >> $event_status.'.gif" width="9" height="9" alt="" border="0" >> hspace="0" vspace="0" /> '; >> @@ -661,14 +651,12 @@ >> >> // Start drawing the event >> $event_temp = $loop_event; >> - $event_calna = $this_time_arr >> [($event_length[$i]['key'])]['calname']; >> - $event_url = $this_time_arr >> [($event_length[$i]['key'])]['url']; >> - $event = openevent($event_calna, >> $event_start, $event_end, $this_time_arr[($event_length[$i] ['key'])], >> '', 0, '', '', 'ps', $event_url); >> - $event_temp = str_replace('{EVENT}', >> $event, $event_temp); >> - $event_temp = str_replace >> ('{EVENT_START}', $event_start, $event_temp); >> - $event_temp = str_replace ('{EVENT_END}', >> $event_end, $event_temp); >> - $event_temp = str_replace ('{CONFIRMED}', >> $confirmed, $event_temp); >> - $event_temp = str_replace >> ('{EVENT_CALNO}', $event_calno, $event_temp); >> + $event = openevent($getdate, $uid, >> $this_time_arr[$uid], 0, 0, 'ps'); >> + $event_temp = str_replace('{EVENT}', >> $event, $event_temp); >> + $event_temp = str_replace >> ('{EVENT_START}', $event_start, $event_temp); >> + $event_temp = str_replace ('{EVENT_END}', >> $event_end, $event_temp); >> + $event_temp = str_replace ('{CONFIRMED}', >> $confirmed, $event_temp); >> + $event_temp = str_replace >> ('{EVENT_CALNO}', $event_calno, $event_temp); >> $daydisplay .= $event_temp; >> $daydisplay .= '</td>'; >> // End event drawing >> @@ -711,40 +699,34 @@ >> $loop_t_e = trim($match2[1]); >> $return_adtmp = ''; >> $return_etmp = ''; >> - >> + >> if (is_array($master_array[$next_day]) && sizeof >> ($master_array[$next_day]) > 0) { >> foreach ($master_array[$next_day] as $event_times) { >> - foreach ($event_times as $val) { >> + foreach ($event_times as $uid => $val) { >> $event_text = stripslashes(urldecode($val >> ["event_text"])); >> $event_text = strip_tags($event_text, '<b><i><u>'); >> - if ($event_text != "") { >> - $event_calna = $val["calname"]; >> - $event_url = $val["url"]; >> - $event_start = date ($timeFormat, $val >> ["start_unixtime"]); >> - $event_end = date ($timeFormat, >> $val["end_unixtime"]); >> - if (!isset($val["event_start"])) { >> - $event_start = $lang['l_all_day']; >> - $event_end = ''; >> - $return_adtmp = openevent ($event_calna, >> $event_start, $event_end, $val, $tomorrows_events_lines, 21, '', '', >> 'psf', $event_url); >> - $replace_ad .= str_replace >> ('{T_ALLDAY}', $return_adtmp, $loop_t_ad); >> - } else { >> - $return_etmp = openevent >> ($event_calna, $event_start, $event_end, $val, >> $tomorrows_events_lines, 21, '', '', 'ps3', $event_url); >> - $replace_e .= str_replace >> ('{T_EVENT}', $return_etmp, $loop_t_e); >> + if ($event_text != "") { >> + if (!isset($val["event_start"])) { >> + $return_adtmp = openevent($next_day, >> $uid, $val, $tomorrows_events_lines, 21, 'psf'); >> + $replace_ad .= str_replace >> ('{T_ALLDAY}', $return_adtmp, $loop_t_ad); >> + } else { >> + $return_etmp = openevent($next_day, >> $uid, $val, $tomorrows_events_lines, 21, 'ps3'); >> + $replace_e .= str_replace ('{T_EVENT}', >> $return_etmp, $loop_t_e); >> } >> } >> } >> } >> - >> + >> $this->page = preg_replace('!<\!-- switch t_allday on >> -->(.*)<\!-- switch t_allday off -->!is', $replace_ad, $this->page); >> $this->page = preg_replace('!<\!-- switch t_event on -- >> >(.*)<\!-- switch t_event off -->!is', $replace_e, $this->page); >> - >> + >> } else { >> - >> + >> $this->page = preg_replace('!<\!-- switch >> tomorrows_events on -->(.*)<\!-- switch tomorrows_events off -->! is', >> '', $this->page); >> - >> + >> } >> } >> - >> + >> function get_vtodo() { >> global $template, $getdate, $master_array, $next_day, >> $timeFormat, $tomorrows_events_lines, $show_completed, $show_todos; >> >> @@ -891,28 +873,22 @@ >> if ($master_array[$daylink]) { >> if ($type != 'small') { >> foreach ($master_array[$daylink] as $event_times) { >> - foreach ($event_times as $val) { >> + foreach ($event_times as $uid => $val) { >> $event_calno = $val['calnumber']; >> if ($event_calno > $unique_colors) >> $event_calno = ($event_calno - $unique_colors); >> - $event_calna = $val['calname']; >> - $event_url = $val['url']; >> if (!isset($val['event_start'])) { >> if ($type == 'large') { >> $switch['ALLDAY'] .= '<div >> class="V10"><img src="templates/'.$template.'/images/monthdot_'. >> $event_calno.'.gif" alt="" width="9" height="9" border="0" />'; >> - $switch['ALLDAY'] .= openevent >> ($event_calna, '', '', $val, $month_event_lines, 15, '', '', 'psf', >> $event_url); >> + $switch['ALLDAY'] .= openevent >> ($daylink, $uid, $val, $month_event_lines, 15, 'psf'); >> $switch['ALLDAY'] .= '</div>'; >> } else { >> $switch['ALLDAY'] .= '<img >> src="templates/'.$template.'/images/allday_dot.gif" alt=" " >> width="11" height="10" border="0" />'; >> } >> } else { >> - $event_start = $val ['start_unixtime']; >> - $event_end = (isset($val >> ['display_end'])) ? $val['display_end'] : $val["event_end"]; >> - $event_start = date($timeFormat, >> $val['start_unixtime']); >> $start2 = date >> ($timeFormat_small, $val['start_unixtime']); >> - $event_end = date($timeFormat, >> @strtotime ($event_end)); >> if ($type == 'large') { >> $switch['EVENT'] .= '<div >> class="V9"><img src="templates/'.$template.'/images/monthdot_'. >> $event_calno.'.gif" alt="" width="9" height="9" border="0" />'; >> - $switch['EVENT'] .= openevent >> ($event_calna, $event_start, $event_end, $val, $month_event_lines, >> 10, "$start2 ", '', 'ps3', $event_url).'<br />'; >> + $switch['EVENT'] .= openevent >> ($daylink, $uid, $val, $month_event_lines, 10, 'ps3', "$start2 >> ").'<br />'; >> $switch['EVENT'] .= '</div>'; >> } else { >> $switch['EVENT'] = '<img >> src="templates/'.$template.'/images/event_dot.gif" alt=" " width="11" >> height="10" border="0" />'; >> @@ -971,22 +947,22 @@ >> foreach ($master_array[$m_start] as $event_times) { >> $switch['CAL'] = $cal; >> $switch['START_DATE'] = localizeDate >> ($dateFormat_week_list, $u_start); >> - foreach ($event_times as $val) { >> + foreach ($event_times as $uid => $val) { >> $switch['CALNAME'] = $val['calname']; >> - $switch['URL'] = $val['url']; >> if (!isset($val['event_start'])) { >> $switch['START_TIME'] = $lang >> ['l_all_day']; >> + $switch['EVENT_TEXT'] = openevent >> ($m_start, $uid, $val, $month_event_lines, 15, 'psf'); >> $switch['DESCRIPTION'] = urldecode >> ($val['description']); >> - $switch['EVENT_TEXT'] = openevent >> ($switch['CALNAME'], '', '', $val, $month_event_lines, 15, '', '', >> 'psf', $switch['URL']); >> - } else { >> + } else { >> $event_start = $val['start_unixtime']; >> $event_end = (isset($val >> ['display_end'])) ? $val['display_end'] : $val["event_end"]; >> $event_start = date($timeFormat, $val >> ['start_unixtime']); >> $event_end = date($timeFormat, >> @strtotime ($event_end)); >> $switch['START_TIME'] = $event_start >> . ' - ' . $event_end; >> - $switch['EVENT_TEXT'] = openevent >> ($switch['CALNAME'], $event_start, $event_end, $val, 0, 15, '', '', >> 'psf', $switch['URL']); >> + $switch['EVENT_TEXT'] = openevent >> ($m_start, $uid, $val, 0, 15, 'psf'); >> $switch['DESCRIPTION'] = urldecode >> ($val['description']); >> } >> + >> if ($switch['EVENT_TEXT'] != '') { >> $switch['DAYLINK'] = $m_start; >> $temp = $loop[$i]; >> @@ -1004,11 +980,11 @@ >> $check_month = date('m', $u_start); >> unset ($switch); >> } while ($this_month == $check_month); >> - >> + >> $this->page = preg_replace('!<\!-- loop showbottomevents_odd >> on -->(.*)<\!-- loop showbottomevents_even off -->!is', $middle, >> $this->page); >> - >> + >> } >> - >> + >> function Page($template = 'std.tpl') { >> if (file_exists($template)) >> $this->page = join('', file($template)); >> Index: includes/event.php >> =================================================================== >> RCS file: /cvsroot/phpicalendar/phpicalendar/includes/event.php,v >> retrieving revision 1.30 >> diff -u -r1.30 event.php >> --- includes/event.php 2 Sep 2004 18:41:13 -0000 1.30 >> +++ includes/event.php 5 May 2005 19:48:54 -0000 >> @@ -1,6 +1,8 @@ >> <?php >> define('BASE', '../'); >> +$getdate = $_POST['date']; >> include_once(BASE.'functions/init.inc.php'); >> +include_once(BASE.'functions/ical_parser.php'); >> require_once(BASE.'functions/template.php'); >> >> function decode_popup ($item) { >> @@ -9,29 +11,20 @@ >> return $item; >> } >> >> -$event = (isset($_POST['event'])) ? decode_popup($_POST >> ['event']) : (''); >> -$description = (isset($_POST['description'])) ? decode_popup >> ($_POST['description']) : (''); >> -$cal = (isset($_POST['cal'])) ? decode_popup($_POST >> ['cal']) : (''); >> -$start = (isset($_POST['start'])) ? decode_popup($_POST >> ['start']) : (''); >> -$end = (isset($_POST['end'])) ? decode_popup($_POST >> ['end']) : (''); >> -$status = (isset($_POST['status'])) ? decode_popup >> ($_POST['status']) : (''); >> -$location = (isset($_POST['location'])) ? decode_popup >> ($_POST['location']) : (''); >> -$url = (isset($_POST['url'])) ? decode_popup($_POST >> ['url']) : (''); >> -$organizer = (isset($_POST['organizer'])) ? ($_POST >> ['organizer']) : (''); >> -$organizer = unserialize (decode_popup ($organizer)); >> -$attendee = (isset($_POST['attendee'])) ? ($_POST >> ['attendee']) : (''); >> -$attendee = unserialize (decode_popup ($attendee)); >> -$cal_title_full = $cal.' '.$calendar_lang; >> +$event = $master_array[$_POST['date']][$_POST['time']] >> [decode_popup($_POST['uid'])]; >> +$organizer = unserialize($event['organizer']); >> +$attendee = unserialize($event['attendee']); >> >> // Format event time >> -if (($start) && ($end)) { >> - $event_times = $start . ' - ' . $end; >> -} >> -if ($start == '' && $end == '' && (isset($start) && isset($end))) { >> +// All day >> +if ($_POST['time'] == -1) { >> $event_times = $lang['l_all_day']; >> +} else { >> + $event_times = date($timeFormat, $event['start_unixtime']) . ' - >> ' . date($timeFormat, $event['end_unixtime']); >> } >> >> -if ($description) $description = ereg_replace("[[:alpha:]]+://[^<> >> [:space:]]+[[:alnum:]/]",'<a target="_new" href="\0">\0</a>', >> $description); >> +if ($event['description']) $event['description'] = ereg_replace >> ("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]",'<a target="_new" >> href="\0">\0</a>',$event['description']); >> + >> if (is_array($organizer)) { >> $i=0; >> $display .= $organizer_lang . ' - '; >> @@ -51,8 +44,8 @@ >> $attendee = substr($attendees,0,-2); >> } >> >> -if ($location) { >> - if ($url != '') $location = '<a href="'.$url.'" >> target="_blank">'.$location.'</a>'; >> +if ($event['location']) { >> + if ($event['url'] != '') $event['location'] = '<a href="'. >> $event['url'].'" target="_blank">'.$event['location'].'</a>'; >> } >> >> if (sizeof($attendee) == 0) $attendee = ''; >> @@ -61,15 +54,15 @@ >> $page = new Page(BASE.'templates/'.$template.'/event.tpl'); >> > >> $page->replace_tags(array( >> - 'cal' => $cal, >> - 'event' => $event, >> + 'cal' => $event['calname'], >> + 'event_text' => urldecode($event['event_text']), >> 'event_times' => $event_times, >> - 'description' => $description, >> + 'description' => $event['description'], >> 'organizer' => $organizer, >> 'attendee' => $attendee, >> - 'status' => $status, >> - 'location' => $location, >> - 'cal_title_full' => $cal_title_full, >> + 'status' => $event['status'], >> + 'location' => $event['location'], >> + 'cal_title_full' => $event['calname'].' '.$lang['l_calendar'], >> 'template' => $template, >> 'l_organizer' => $lang['l_organizer'], >> 'l_attendee' => $lang['l_attendee'], >> Index: templates/default/event.tpl >> =================================================================== >> RCS file: /cvsroot/phpicalendar/phpicalendar/templates/default/ >> event.tpl,v >> retrieving revision 1.8 >> diff -u -r1.8 event.tpl >> --- templates/default/event.tpl 31 Oct 2004 19:50:15 -0000 1.8 >> +++ templates/default/event.tpl 5 May 2005 19:48:54 -0000 >> @@ -15,7 +15,7 @@ >> <tr> >> <td align="left" class="V12"> >> <div style="margin-left: 10px; margin-bottom:10px;"> >> - <p>{EVENT} - <span class="V9">(<i>{EVENT_TIMES} >> </i>)</span></p> >> + <p>{EVENT_TEXT} - <span class="V9">(<i> >> {EVENT_TIMES}</i>)</span></p> >> <!-- switch description on --> >> <p>{DESCRIPTION}</p> >> <!-- switch description off --> >> Index: templates/default/header.tpl >> =================================================================== >> RCS file: /cvsroot/phpicalendar/phpicalendar/templates/default/ >> header.tpl,v >> retrieving revision 1.10 >> diff -u -r1.10 header.tpl >> --- templates/default/header.tpl 12 Aug 2004 20:32:50 -0000 1.10 >> +++ templates/default/header.tpl 5 May 2005 19:48:54 -0000 >> @@ -12,14 +12,7 @@ >> </head> >> <body> >> <form name="eventPopupForm" id="eventPopupForm" method="post" >> action="includes/event.php" style="display: none;"> >> - <input type="hidden" name="event" id="event" value="" /> >> - <input type="hidden" name="cal" id="cal" value="" /> >> - <input type="hidden" name="start" id="start" value="" /> >> - <input type="hidden" name="end" id="end" value="" /> >> - <input type="hidden" name="description" id="description" value="" /> >> - <input type="hidden" name="status" id="status" value="" /> >> - <input type="hidden" name="location" id="location" value="" /> >> - <input type="hidden" name="organizer" id="organizer" value="" /> >> - <input type="hidden" name="attendee" id="attendee" value="" /> >> - <input type="hidden" name="url" id="url" value="" /> >> -</form> >> \ No newline at end of file >> + <input type="hidden" name="date" id="date" value="" /> >> + <input type="hidden" name="time" id="time" value="" /> >> + <input type="hidden" name="uid" id="uid" value="" /> >> +</form> >> > |