From: <ji...@us...> - 2008-12-29 03:07:37
|
Update of /cvsroot/phpicalendar/phpicalendar/functions In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv10074/functions Modified Files: date_functions.php list_functions.php template.php Log Message: change handling of multiday allday events in week view; other misc changes Index: date_functions.php =================================================================== RCS file: /cvsroot/phpicalendar/phpicalendar/functions/date_functions.php,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** date_functions.php 28 Dec 2008 20:13:01 -0000 1.47 --- date_functions.php 29 Dec 2008 03:07:34 -0000 1.48 *************** *** 154,167 **** return $offset; } ! function openevent($event_date, $time, $uid, $arr, $lines = 0, $length = 0, $link_class = '', $pre_text = '', $post_text = '') { ! global $cpath, $master_array; $return = ''; $event_text = stripslashes(urldecode($arr["event_text"])); ! if (empty($start)) { $title = $event_text; } else { ! $title = $arr['event_start'].' - '.$arr['event_end'].': '.$event_text; } # for iCal pseudo tag <http> comptability if (ereg("<([[:alpha:]]+://)([^<>[:space:]]+)>",$event_text,$matches)) { --- 154,184 ---- return $offset; } ! /* Returns a string to make event text with a link to popup boxes ! $arr is a master array item ! $lines is the number of lines to restrict the event_text to, using word_wrap ! $length is the length of one line ! $link_class is a css class ! $pre_text and $post_text are to add tags around the link text (e.g. <b> or<i>) ! ! $title is the tooltip for the link ! */ function openevent($event_date, $time, $uid, $arr, $lines = 0, $length = 0, $link_class = '', $pre_text = '', $post_text = '') { ! global $cpath, $timeFormat, $dateFormat_week; $return = ''; $event_text = stripslashes(urldecode($arr["event_text"])); ! # build tooltip ! if ($time == -1) { ! $start = localizeDate($dateFormat_week, $arr['start_unixtime']); ! $end = localizeDate($dateFormat_week, ($arr['end_unixtime'] - 60)); $title = $event_text; + if ($start != $end) $title = "$start - $end $event_text"; } else { ! $start = date($timeFormat, $arr['start_unixtime']); ! $end = date($timeFormat, $arr['end_unixtime']); ! $title = "$start: $event_text"; ! if ($start != $end) $title = "$start - $end $event_text"; } + $title .= "\n".urldecode($arr['description'])."\n".urldecode($arr['location']); + $title = trim($title); # for iCal pseudo tag <http> comptability if (ereg("<([[:alpha:]]+://)([^<>[:space:]]+)>",$event_text,$matches)) { *************** *** 182,193 **** $escaped_time = addslashes($time); $escaped_uid = addslashes($uid); ! $event_data = addslashes(serialize ($master_array[$event_date][$time][$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_date', '$escaped_time', '$escaped_uid','$cpath','$event_data'); ! document.popup_data[$popup_data_index] = eventData; ! // --></script>"; $return .= '<a class="'.$link_class.'" title="'.$title.'" href="#" onclick="openEventWindow('.$popup_data_index.'); return false;">'; --- 199,210 ---- $escaped_time = addslashes($time); $escaped_uid = addslashes($uid); ! $event_data = addslashes(serialize ($arr)); // 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_date', '$escaped_time', '$escaped_uid','$cpath','$event_data'); ! document.popup_data[$popup_data_index] = eventData; ! // --></script>"; $return .= '<a class="'.$link_class.'" title="'.$title.'" href="#" onclick="openEventWindow('.$popup_data_index.'); return false;">'; Index: list_functions.php =================================================================== RCS file: /cvsroot/phpicalendar/phpicalendar/functions/list_functions.php,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** list_functions.php 20 Dec 2008 00:33:14 -0000 1.20 --- list_functions.php 29 Dec 2008 03:07:34 -0000 1.21 *************** *** 77,81 **** function list_weeks() { ! global $getdate, $this_year, $cal, $dateFormat_week_jump, $week_start_day; ereg ("([0-9]{4})([0-9]{2})([0-9]{2})", $getdate, $day_array2); $this_day = $day_array2[3]; --- 77,81 ---- function list_weeks() { ! global $getdate, $this_year, $cal, $dateFormat_week_jump, $phpiCal_config; ereg ("([0-9]{4})([0-9]{2})([0-9]{2})", $getdate, $day_array2); $this_day = $day_array2[3]; *************** *** 83,87 **** $this_year = $day_array2[1]; $check_week = strtotime($getdate); ! $start_week_time = strtotime(dateOfWeek(date("Ymd", strtotime("$this_year-01-01")), $week_start_day)); $end_week_time = $start_week_time + (6 * 25 * 60 * 60); $return = ''; --- 83,87 ---- $this_year = $day_array2[1]; $check_week = strtotime($getdate); ! $start_week_time = strtotime(dateOfWeek(date("Ymd", strtotime("$this_year-01-01")), $phpiCal_config->week_start_day)); $end_week_time = $start_week_time + (6 * 25 * 60 * 60); $return = ''; Index: template.php =================================================================== RCS file: /cvsroot/phpicalendar/phpicalendar/functions/template.php,v retrieving revision 1.108 retrieving revision 1.109 diff -C2 -d -r1.108 -r1.109 *** template.php 28 Dec 2008 19:30:41 -0000 1.108 --- template.php 29 Dec 2008 03:07:34 -0000 1.109 *************** *** 66,73 **** $seen_events = array(); $final = ''; foreach($master_array as $key => $val) { preg_match ('/([0-9]{6})([0-9]{2})/', $key, $regs); if (((@$regs[1] == $parse_month) && ($printview == 'month')) || (($key == $getdate) && ($printview == 'day')) || ((($key >= $week_start) && ($key <= $week_end)) && ($printview == 'week')) || ((substr(@$regs[1],0,4) == $parse_year) && ($printview == 'year'))) { ! @$events_week++; $dayofmonth = strtotime ($key); $dayofmonth = localizeDate ($dateFormat_day, $dayofmonth); --- 66,74 ---- $seen_events = array(); $final = ''; + $events_week = 0; foreach($master_array as $key => $val) { preg_match ('/([0-9]{6})([0-9]{2})/', $key, $regs); if (((@$regs[1] == $parse_month) && ($printview == 'month')) || (($key == $getdate) && ($printview == 'day')) || ((($key >= $week_start) && ($key <= $week_end)) && ($printview == 'week')) || ((substr(@$regs[1],0,4) == $parse_year) && ($printview == 'year'))) { ! $events_week++; $dayofmonth = strtotime ($key); $dayofmonth = localizeDate ($dateFormat_day, $dayofmonth); *************** *** 87,94 **** if (isset($new_val2['event_text'])) { $event_text = stripslashes(urldecode($new_val2['event_text'])); ! $location = stripslashes(urldecode(@$new_val2['location'])); ! $description = stripslashes(urldecode(@$new_val2['description'])); ! $event_start = @$new_val2['event_start']; ! $event_end = @$new_val2['event_end']; if (isset($new_val2['display_end'])) $event_end = $new_val2['display_end']; if (!isset($new_val2['event_start'])) { --- 88,95 ---- if (isset($new_val2['event_text'])) { $event_text = stripslashes(urldecode($new_val2['event_text'])); ! $location = stripslashes(urldecode($new_val2['location'])); ! $description = stripslashes(urldecode($new_val2['description'])); ! $event_start = $new_val2['event_start']; ! $event_end = $new_val2['event_end']; if (isset($new_val2['display_end'])) $event_end = $new_val2['display_end']; if (!isset($new_val2['event_start'])) { *************** *** 272,283 **** #echo "<pre>";print_r($nbrGridCols); // Replaces the allday events preg_match("!<\!-- loop allday on -->(.*)<\!-- loop allday off -->!Uis", $this->page, $match1); preg_match("!<\!-- loop alldaysofweek on -->(.*)<\!-- loop allday on -->!Uis", $this->page, $match2); preg_match("!<\!-- loop allday off -->(.*)<\!-- loop alldaysofweek off -->!Uis", $this->page, $match3); ! $loop_ad = trim($match1[1]); ! $loop_begin = trim($match2[1]); ! $loop_end = trim($match3[1]); $weekreplace = ''; ! foreach ($weekarray as $get_date) { $replace = $loop_begin; $colspan = 'colspan="'.$nbrGridCols[$get_date].'"'; --- 273,335 ---- #echo "<pre>";print_r($nbrGridCols); // Replaces the allday events + preg_match("!<\!-- loop allday row on -->(.*)<\!-- loop alldaysofweek on -->!Uis", $this->page, $match1); + $loop_row_begin = trim($match1[1]); # <tr>etc preg_match("!<\!-- loop allday on -->(.*)<\!-- loop allday off -->!Uis", $this->page, $match1); preg_match("!<\!-- loop alldaysofweek on -->(.*)<\!-- loop allday on -->!Uis", $this->page, $match2); preg_match("!<\!-- loop allday off -->(.*)<\!-- loop alldaysofweek off -->!Uis", $this->page, $match3); ! $loop_ad = trim($match1[1]); # one day cell ! $loop_begin = trim($match2[1]); # <td> ! $loop_end = trim($match3[1]); # </td> ! preg_match("!<\!-- loop alldaysofweek off -->(.*)<\!-- loop allday row off -->!Uis", $this->page, $match3); ! $loop_row_end = trim($match3[1]); # </tr> ! $allday_uids = array(); ! $allday_uid_dates = array(); $weekreplace = ''; ! foreach ($weekarray as $i=>$get_date){ ! if (isset($master_array[$get_date]['-1']) && is_array($master_array[$get_date]['-1']) && !empty($master_array[$get_date]['-1'])){ ! foreach ($master_array[$get_date]['-1'] as $uid => $allday){ ! if (!array_key_exists($uid, $allday_uids)) $allday_uids[$uid] = $get_date; ! $allday_uid_dates[$uid][] = $get_date; ! } ! } ! } ! # new allday routine is better for multiday events ! while(!empty($allday_uids)){ ! $row = $loop_row_begin; ! $day = 0; ! $replace =''; ! while ($day < $phpiCal_config->week_length){ ! $colspan = 0; ! $replace .= $loop_begin; # <td> ! if(array_search($weekarray[$day], $allday_uids)){ ! $uid = array_search($weekarray[$day], $allday_uids); ! unset($allday_uids[$uid]); ! $allday = $master_array[$weekarray[$day]]['-1'][$uid]; ! foreach ($allday_uid_dates[$uid] as $date){ ! #$ev = (!isset($ev)) ? " $uid ":""; ! #$replace .= $ev; ! $colspan += $nbrGridCols[$weekarray[$day]]; ! $day++; ! } ! $event_calno = $allday['calnumber']; ! $event_calno = (($event_calno - 1) % $phpiCal_config->unique_colors) + 1; ! $event = openevent($get_date, -1, $uid, $allday, $phpiCal_config->allday_week_lines, 11, 'psf'); ! $loop_tmp = str_replace('{ALLDAY}', $event, $loop_ad); ! $loop_tmp = str_replace('{CALNO}', $event_calno, $loop_tmp); ! $replace .= $loop_tmp; ! $replace .= $loop_end; ! }else{ ! $colspan = $nbrGridCols[$weekarray[$day]]; ! $replace .= $loop_end; ! $day++; ! } ! unset ($ev); ! $replace = str_replace('{COLSPAN}', "colspan='$colspan'", $replace); ! } ! $row .= "$replace $loop_row_end\n"; ! $weekreplace .= "$row\n"; ! } ! /* old routine ! foreach ($weekarray as $i=>$get_date) { $replace = $loop_begin; $colspan = 'colspan="'.$nbrGridCols[$get_date].'"'; *************** *** 287,291 **** $event_calno = $allday['calnumber']; $event_calno = (($event_calno - 1) % $phpiCal_config->unique_colors) + 1; ! $event = openevent($get_date, -1, $uid, $allday, 1, 11, 'psf'); $loop_tmp = str_replace('{ALLDAY}', $event, $loop_ad); $loop_tmp = str_replace('{CALNO}', $event_calno, $loop_tmp); --- 339,343 ---- $event_calno = $allday['calnumber']; $event_calno = (($event_calno - 1) % $phpiCal_config->unique_colors) + 1; ! $event = openevent($get_date, -1, $uid, $allday, $phpiCal_config->allday_week_lines, 11, 'psf'); $loop_tmp = str_replace('{ALLDAY}', $event, $loop_ad); $loop_tmp = str_replace('{CALNO}', $event_calno, $loop_tmp); *************** *** 296,299 **** --- 348,352 ---- $weekreplace .= $replace; } + */ $this->page = preg_replace('!<\!-- loop alldaysofweek on -->.*<\!-- loop alldaysofweek off -->!Uis', $weekreplace, $this->page); *************** *** 727,734 **** if ($event_text != "") { if (!isset($val["event_start"])) { ! $return_adtmp = openevent($next_day, $cal_time, $uid, $val, $tomorrows_events_lines, 21, 'psf'); $replace_ad .= str_replace('{T_ALLDAY}', $return_adtmp, $loop_t_ad); } else { ! $return_etmp = openevent($next_day, $cal_time, $uid, $val, $tomorrows_events_lines, 21, 'ps3'); $replace_e .= str_replace('{T_EVENT}', $return_etmp, $loop_t_e); } --- 780,787 ---- if ($event_text != "") { if (!isset($val["event_start"])) { ! $return_adtmp = openevent($next_day, $cal_time, $uid, $val, $phpiCal_config->tomorrows_events_lines, 21, 'psf'); $replace_ad .= str_replace('{T_ALLDAY}', $return_adtmp, $loop_t_ad); } else { ! $return_etmp = openevent($next_day, $cal_time, $uid, $val, $phpiCal_config->tomorrows_events_lines, 21, 'ps3'); $replace_e .= str_replace('{T_EVENT}', $return_etmp, $loop_t_e); } *************** *** 911,914 **** --- 964,968 ---- $temp = $t_month[2]; } + $switch['ALLDAY'] = $switch['EVENT'] = ''; if (isset($master_array[$daylink]) && $i <= $phpiCal_config->week_length) { if ($type != 'small') { *************** *** 921,925 **** if ($type == 'large') { $switch['ALLDAY'] .= '<div class="V10"><img src="templates/'.$phpiCal_config->template.'/images/monthdot_'.$event_calno.'.gif" alt="" width="9" height="9" border="0" />'; ! $switch['ALLDAY'] .= openevent($daylink, $cal_time, $uid, $val, $month_event_lines, 15, 'psf'); $switch['ALLDAY'] .= (isset($val['location']) && $val['location'] != '') ? $val['location']."<br />" : ''; $switch['ALLDAY'] .= '</div>'; --- 975,979 ---- if ($type == 'large') { $switch['ALLDAY'] .= '<div class="V10"><img src="templates/'.$phpiCal_config->template.'/images/monthdot_'.$event_calno.'.gif" alt="" width="9" height="9" border="0" />'; ! $switch['ALLDAY'] .= openevent($daylink, $cal_time, $uid, $val, $phpiCal_config->month_event_lines, 15, 'psf'); $switch['ALLDAY'] .= (isset($val['location']) && $val['location'] != '') ? $val['location']."<br />" : ''; $switch['ALLDAY'] .= '</div>'; *************** *** 930,935 **** $start2 = date($timeFormat_small, $val['start_unixtime']); if ($type == 'large') { ! @$switch['EVENT'] .= '<div class="V9"><img src="templates/'.$phpiCal_config->template.'/images/monthdot_'.$event_calno.'.gif" alt="" width="9" height="9" border="0" />'; ! $switch['EVENT'] .= openevent($daylink, $cal_time, $uid, $val, $month_event_lines, 10, 'ps3', "$start2 ").''; $switch['EVENT'] .= (isset($val['location']) && $val['location'] != '') ? "<br />".$val['location']."<br />" : ''; $switch['EVENT'] .= '</div>'; --- 984,989 ---- $start2 = date($timeFormat_small, $val['start_unixtime']); if ($type == 'large') { ! $switch['EVENT'] .= '<div class="V9"><img src="templates/'.$phpiCal_config->template.'/images/monthdot_'.$event_calno.'.gif" alt="" width="9" height="9" border="0" />'; ! $switch['EVENT'] .= openevent($daylink, $cal_time, $uid, $val, $phpiCal_config->month_event_lines, 10, 'ps3', "$start2 ").''; $switch['EVENT'] .= (isset($val['location']) && $val['location'] != '') ? "<br />".$val['location']."<br />" : ''; $switch['EVENT'] .= '</div>'; *************** *** 1009,1013 **** if (!isset($val['event_start'])) { $switch['START_TIME'] = $lang['l_all_day']; ! $switch['EVENT_TEXT'] = openevent($m_start, $cal_time, $uid, $val, @$month_event_lines, 15, 'psf'); $switch['DESCRIPTION'] = urldecode($val['description']); } else { --- 1063,1067 ---- if (!isset($val['event_start'])) { $switch['START_TIME'] = $lang['l_all_day']; ! $switch['EVENT_TEXT'] = openevent($m_start, $cal_time, $uid, $val, $phpiCal_config->month_event_lines, 15, 'psf'); $switch['DESCRIPTION'] = urldecode($val['description']); } else { |