From: David F. <da...@d2...> - 2005-05-03 23:30:07
|
So, this is worth applying, but only if you don't apply my forthcoming patch - I'll shortly (maybe later today) have a reworked openevent/event.php setup that uses date+time+uid to lookup the event, instead of passing the data to the page. This leads to a few questions: 1. is this acceptable? I'm kinda running wild here since no one's saying anything, but obviously I'd like to run wild in the right direction. 2. if the patch goes in, it's significantly less data to pass through - which means we could remove the "changing the hidden form" hackery? If so, let me know, I'll put together a patch. 3. I noticed a two issues with the generation of master_array - first, the recur data wasn't being replicated to each instance of the event, only the first event - so (without iterating through the whole array) there was no good way to get it. So, I fixed that. This raises the size of master_array by a decent amount, so it's questionable, but necessary for me to implement recur details in the event popup. Second, all-day recurring events after the first one weren't getting set with valid uids - they were being added to the allday time w/ the "next" array key, instead of using the uid. This is less questionable, and a one-line fix - both fixes are in the patch, but if you want to cherry pick and would prefer this fix alone, let me know. So everyone knows, my immediate goals are: * adding recur info to the event.php popup, so it's more useful, and so I learn enough to do: * add basic event adding/editing. This obviously assumes that the phpicalendar "owns" the calendar, and thus will ignore locking/sync'ing beyond making sure it doesn't overwrite itself. This will be entirely optional (I'm happy to make it some sort of config option people have to turn on in general or per-calendar). * And then probably add a basic level of user support, so users can have their own calendars vs. shared calendars, etc. Simplistic calendar server. As always, I'd much prefer to do this the "right" way, in that maintaining a patch set against CVS sucks long term - so if there are way you'd prefer this done, please let me know and spare me the time reworking things later. phpicalendar has a *@(#ing awesome interface, by far the best I've seen so far, and the last piece I need to solve a few problems for me is the editing. (cc'd jim so you get the patch) dave David Fallon wrote: > while poking into the event stuff, I found there's a decent amount of > redundancy, specifically in the $url passing to openevent() - it's in > the $arr variable, and it's also then seperated out into it's own > argument (but the function ignores that, and uses the value from $arr if > it's there) - I went through all the calls to openevent, and cleaned it > up. Patch attached, decently tested - I didn't actually verify it's > being correctly passed for every value, but it's a pretty simple patch. > Against latest cvs, etc. etc. > > 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 3 May 2005 18:19:12 -0000 > @@ -162,7 +162,7 @@ > return $offset; > } > > -function openevent($calendar_name, $start, $end, $arr, $lines, $wrap, $pre_text, $post_text, $link_class, $url) { > +function openevent($calendar_name, $start, $end, $arr, $lines, $wrap, $pre_text, $post_text, $link_class) { > $event_text = stripslashes(urldecode($arr["event_text"])); > if (empty($start)) { > $title = $event_text; > Index: functions/template.php > =================================================================== > RCS file: /cvsroot/phpicalendar/phpicalendar/functions/template.php,v > retrieving revision 1.65 > diff -u -r1.65 template.php > --- functions/template.php 16 Apr 2005 20:39:00 -0000 1.65 > +++ functions/template.php 3 May 2005 18:19:12 -0000 > @@ -254,9 +254,8 @@ > foreach ($master_array[$get_date]['-1'] as $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($event_calna, '', '', $allday, 1, 11, '', '', 'psf'); > $loop_tmp = str_replace('{ALLDAY}', $event, $loop_ad); > $loop_tmp = str_replace('{CALNO}', $event_calno, $loop_tmp); > $replace .= $loop_tmp; > @@ -410,7 +409,6 @@ > $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']); > if ($event_calno > $unique_colors) $event_calno = ($event_calno - $unique_colors); > if ($event_status != '') { > @@ -425,7 +423,7 @@ > > // 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 = openevent($event_calna, $event_start, $event_end, $this_time_arr[($event_length[$thisday][$i]["key"])], $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); > @@ -476,9 +474,8 @@ > foreach ($master_array[$getdate]['-1'] as $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($event_calna, '', '', $allday, 0, '', '', '', ''); > $loop_tmp = str_replace('{ALLDAY}', $event, $loop_ad); > $loop_tmp = str_replace('{CALNO}', $event_calno, $loop_tmp); > $replace .= $loop_tmp; > @@ -636,8 +633,7 @@ > // 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 = openevent($event_calna, $event_start, $event_end, $this_time_arr[($event_length[$i]['key'])], '', 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); > @@ -693,16 +689,15 @@ > $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); > + $return_adtmp = openevent($event_calna, $event_start, $event_end, $val, $tomorrows_events_lines, 21, '', '', 'psf'); > $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); > + $return_etmp = openevent($event_calna, $event_start, $event_end, $val, $tomorrows_events_lines, 21, '', '', 'ps3'); > $replace_e .= str_replace('{T_EVENT}', $return_etmp, $loop_t_e); > } > } > @@ -869,11 +864,10 @@ > $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($event_calna, '', '', $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" />'; > @@ -886,7 +880,7 @@ > $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($event_calna, $event_start, $event_end, $val, $month_event_lines, 10, "$start2 ", '', 'ps3').'<br />'; > $switch['EVENT'] .= '</div>'; > } else { > $switch['EVENT'] = '<img src="templates/'.$template.'/images/event_dot.gif" alt=" " width="11" height="10" border="0" />'; > @@ -947,18 +941,17 @@ > $switch['START_DATE'] = localizeDate ($dateFormat_week_list, $u_start); > foreach ($event_times as $val) { > $switch['CALNAME'] = $val['calname']; > - $switch['URL'] = $val['url']; > if (!isset($val['event_start'])) { > $switch['START_TIME'] = $lang['l_all_day']; > $switch['DESCRIPTION'] = urldecode($val['description']); > - $switch['EVENT_TEXT'] = openevent($switch['CALNAME'], '', '', $val, $month_event_lines, 15, '', '', 'psf', $switch['URL']); > + $switch['EVENT_TEXT'] = openevent($switch['CALNAME'], '', '', $val, $month_event_lines, 15, '', '', 'psf'); > } 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($switch['CALNAME'], $event_start, $event_end, $val, 0, 15, '', '', 'psf'); > $switch['DESCRIPTION'] = urldecode($val['description']); > } > if ($switch['EVENT_TEXT'] != '') { |