From: <ji...@us...> - 2008-12-27 10:58:56
|
Update of /cvsroot/phpicalendar/phpicalendar/functions In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv29598/functions Modified Files: date_functions.php ical_parser.php template.php Log Message: rewrite and condense master array writing in end_vevent.php. Condense draw_week in template.php. bump vers Index: date_functions.php =================================================================== RCS file: /cvsroot/phpicalendar/phpicalendar/functions/date_functions.php,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** date_functions.php 26 Dec 2008 22:33:33 -0000 1.44 --- date_functions.php 27 Dec 2008 10:58:51 -0000 1.45 *************** *** 167,170 **** --- 167,171 ---- 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)) { *************** *** 249,252 **** --- 250,254 ---- // Pull out the date and time values. Minimum year is 1970. preg_match ('/([0-9]{4})([0-9]{2})([0-9]{2})T{0,1}([0-9]{0,2})([0-9]{0,2})/', $data, $regs); + if (!isset ($regs[1])) return; if ($regs[1] < 1970) { $regs[1] = '1971'; Index: ical_parser.php =================================================================== RCS file: /cvsroot/phpicalendar/phpicalendar/functions/ical_parser.php,v retrieving revision 1.233 retrieving revision 1.234 diff -C2 -d -r1.233 -r1.234 *** ical_parser.php 26 Dec 2008 22:33:33 -0000 1.233 --- ical_parser.php 27 Dec 2008 10:58:51 -0000 1.234 *************** *** 481,486 **** #print '<pre>'; #var_dump($phpiCal_config); ! //print_r($master_array); ! //print_r($overlap_array); //print_r($day_array); //print_r($rrule_array); --- 481,486 ---- #print '<pre>'; #var_dump($phpiCal_config); ! #print_r($master_array); ! #var_dump($overlap_array['20081211']); //print_r($day_array); //print_r($rrule_array); Index: template.php =================================================================== RCS file: /cvsroot/phpicalendar/phpicalendar/functions/template.php,v retrieving revision 1.103 retrieving revision 1.104 diff -C2 -d -r1.103 -r1.104 *** template.php 26 Dec 2008 22:33:33 -0000 1.103 --- template.php 27 Dec 2008 10:58:51 -0000 1.104 *************** *** 251,255 **** // Figure out colspans and initialize weekarray - $dayborder = 0; $thisdate = $start_week_time; $swt = $start_week_time; --- 251,254 ---- *************** *** 268,274 **** } $weekarray[$i] = $thisday; $thisdate = ($thisdate + (25 * 60 * 60)); } ! #echo "<pre>";print_r($nbrGridCols); // Replaces the allday events preg_match("!<\!-- loop allday on -->(.*)<\!-- loop allday off -->!Uis", $this->page, $match1); --- 267,274 ---- } $weekarray[$i] = $thisday; + $event_length[$thisday] = array (); $thisdate = ($thisdate + (25 * 60 * 60)); } ! // Replaces the allday events preg_match("!<\!-- loop allday on -->(.*)<\!-- loop allday off -->!Uis", $this->page, $match1); *************** *** 302,326 **** $loop_dof = trim($match1[1]); $start_wt = strtotime(dateOfWeek($getdate, $phpiCal_config->week_start_day)); - $start_day = strtotime($phpiCal_config->week_start_day); $weekday_loop = ''; for ($i=0; $i<$phpiCal_config->week_length; $i++) { - $day_num = date("w", $start_day); $daylink = date('Ymd', $start_wt); ! if ($current_view == 'day') { ! $weekday = $daysofweek_lang[$day_num]; ! } else { ! $weekday = localizeDate($dateFormat_week_list, strtotime($daylink)); ! } ! if ($daylink == $getdate) { $row1 = 'rowToday'; $row2 = 'rowOn'; $row3 = 'rowToday'; ! } else { $row1 = 'rowOff'; $row2 = 'rowOn'; $row3 = 'rowOff'; } - $start_day = strtotime("+1 day", $start_day); $start_wt = strtotime("+1 day", $start_wt); $colspan = 'colspan="'.$nbrGridCols[$daylink].'"'; --- 302,318 ---- $loop_dof = trim($match1[1]); $start_wt = strtotime(dateOfWeek($getdate, $phpiCal_config->week_start_day)); $weekday_loop = ''; for ($i=0; $i<$phpiCal_config->week_length; $i++) { $daylink = date('Ymd', $start_wt); ! $weekday = localizeDate($dateFormat_week_list, strtotime($daylink)); if ($daylink == $getdate) { $row1 = 'rowToday'; $row2 = 'rowOn'; $row3 = 'rowToday'; ! }else{ $row1 = 'rowOff'; $row2 = 'rowOn'; $row3 = 'rowOff'; } $start_wt = strtotime("+1 day", $start_wt); $colspan = 'colspan="'.$nbrGridCols[$daylink].'"'; *************** *** 345,354 **** $this_year = $day_array2[1]; $thisdate = $swt; ! for ($i=0; $i < 7; $i++) { ! $thisday = date("Ymd", $thisdate); ! $event_length[$thisday] = array (); ! $thisdate = ($thisdate + (25 * 60 * 60)); ! } $weekdisplay = ''; foreach ($day_array as $key) { $cal_time = $key; --- 337,344 ---- $this_year = $day_array2[1]; $thisdate = $swt; ! $weekdisplay = ''; + + #day_array is an array of time blocks of length $phpiCal_config->gridLength foreach ($day_array as $key) { $cal_time = $key; *************** *** 372,426 **** $weekdisplay .= '<td bgcolor="#a1a5a9" width="1" height="' . $phpiCal_config->gridLength . '"></td>'; } ! ! // initialize $thisdate again ! $thisdate = $swt; ! ! // loop this part 7 times, one for each day ! for ($week_loop=0; $week_loop<$phpiCal_config->week_length; $week_loop++) { ! $thisday = date("Ymd", $thisdate); ! $dayborder = 0; ! unset($this_time_arr); ! if ($phpiCal_config->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) { ! if (is_array($time_arr) && $time_key != '-1') { ! foreach($time_arr as $uid => $event_tmp) { ! if ((int)$event_tmp['event_end'] > (int)$cal_time) { ! $this_time_arr[$uid] = $event_tmp; ! } ! } ! } ! } else { ! break; } } } else { if (isset($master_array[$thisday][$cal_time]) && sizeof($master_array[$thisday][$cal_time]) > 0) { ! $this_time_arr = $master_array[$thisday][$cal_time]; } } - - // check for eventstart - if (isset($this_time_arr) && sizeof($this_time_arr) > 0) { - #print "<pre>";print_r ($this_time_arr);print "</pre>"; ! foreach ($this_time_arr as $eventKey => $loopevent) { ! $drawEvent = drawEventTimes ($cal_time, $loopevent["event_end"]); ! $j = 0; ! while (isset($event_length[$thisday][$j])) { ! if ($event_length[$thisday][$j]["state"] == "ended") { ! $event_length[$thisday][$j] = array ("length" => ($drawEvent["draw_length"] / $phpiCal_config->gridLength), "key" => $eventKey, "overlap" => $loopevent["event_overlap"],"state" => "begin"); ! break; ! } ! $j++; ! } ! if ($j == sizeof($event_length[$thisday])) { ! array_push ($event_length[$thisday], array ("length" => ($drawEvent["draw_length"] / $phpiCal_config->gridLength), "key" => $eventKey, "overlap" => $loopevent["event_overlap"],"state" => "begin")); } } } ! ! if (sizeof($event_length[$thisday]) == 0) { if ($dayborder == 0) { $class = ' class="weekborder"'; --- 362,404 ---- $weekdisplay .= '<td bgcolor="#a1a5a9" width="1" height="' . $phpiCal_config->gridLength . '"></td>'; } ! ! /* add columns in the $cal_time grid slot for each day ! each cell will have $this_time_arr of events */ ! foreach ($weekarray as $thisday) { ! $this_time_arr = array(); ! $dayborder = 0; if ($phpiCal_config->day_start == $cal_time && isset($master_array[$thisday]) && is_array($master_array[$thisday])) { + # want to pile up all the events before day_start that end in the displayed times foreach($master_array[$thisday] as $time_key => $time_arr) { ! if ((int)$time_key <= (int)$cal_time && is_array($time_arr) && $time_key != '-1') { ! foreach($time_arr as $uid => $event_tmp) { ! if ((int)$event_tmp['display_end'] > (int)$cal_time) $this_time_arr[$uid] = $event_tmp; ! } } } } else { + # events that start in internal cal_times the grid if (isset($master_array[$thisday][$cal_time]) && sizeof($master_array[$thisday][$cal_time]) > 0) { ! $this_time_arr = $master_array[$thisday][$cal_time]; } } ! // go through $this_time_array and fill the event_length array ! foreach ($this_time_arr as $eventKey => $loopevent) { ! $drawEvent = drawEventTimes ($cal_time, $loopevent["display_end"]); ! $j = 0; ! while (isset($event_length[$thisday][$j])) { ! if ($event_length[$thisday][$j]["state"] == "ended") { ! $event_length[$thisday][$j] = array ("length" => ($drawEvent["draw_length"] / $phpiCal_config->gridLength), "key" => $eventKey, "overlap" => $loopevent["event_overlap"],"state" => "begin"); ! break; } + $j++; + } + if ($j == sizeof(@$event_length[$thisday])) { + $event_length[$thisday][] = array ("length" => ($drawEvent["draw_length"] / $phpiCal_config->gridLength), "key" => $eventKey, "overlap" => $loopevent["event_overlap"],"state" => "begin"); } } ! if (empty($event_length[$thisday])) { ! # no events if ($dayborder == 0) { $class = ' class="weekborder"'; *************** *** 429,447 **** $class = ''; $dayborder = 0; ! } ! $drawWidth = 1; $colspan_width = round((80 / $nbrGridCols[$thisday]) * $drawWidth); ! $weekdisplay .= '<td width="' . $colspan_width . '" colspan="' . $nbrGridCols[$thisday] . '" ' . $class . '> </td>'."\n"; ! } else { $emptyWidth = $nbrGridCols[$thisday]; // Used to "join" ended events, so the ended case below results in one colspan'd td instead of multiple tds. $ended_counter = 0; ! 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": if ($ended_counter) { --- 407,423 ---- $class = ''; $dayborder = 0; ! } $drawWidth = 1; $colspan_width = round((80 / $nbrGridCols[$thisday]) * $drawWidth); ! $weekdisplay .= '<td width="' . $colspan_width . '" colspan="' . $nbrGridCols[$thisday] . '" ' . $class . '> </td>'."\n"; } else { + # have events $emptyWidth = $nbrGridCols[$thisday]; // Used to "join" ended events, so the ended case below results in one colspan'd td instead of multiple tds. $ended_counter = 0; ! foreach($event_length[$thisday] as $i=>$el) { ! $drawWidth = $nbrGridCols[$thisday] / ($el["overlap"] + 1); $emptyWidth = $emptyWidth - $drawWidth; ! switch ($el["state"]) { case "begin": if ($ended_counter) { *************** *** 503,507 **** } } - $thisdate = ($thisdate + (25 * 60 * 60)); } $weekdisplay .= "</tr>\n"; --- 479,482 ---- *************** *** 861,864 **** --- 836,841 ---- function draw_month($template_p, $offset = '+0', $type) { global $phpiCal_config, $getdate, $master_array, $this_year, $this_month, $dateFormat_month, $cal, $minical_view, $month_event_lines, $daysofweekreallyshort_lang, $daysofweekshort_lang, $daysofweek_lang, $timeFormat_small, $timeFormat; + + $unique_colors = $phpiCal_config->unique_colors; preg_match("!<\!-- loop weekday on -->(.*)<\!-- loop weekday off -->!Uis", $template_p, $match1); preg_match("!<\!-- loop monthdays on -->(.*)<\!-- loop monthdays off -->!Uis", $template_p, $match2); *************** *** 939,944 **** foreach ($event_times as $uid => $val) { $event_calno = $val['calnumber']; ! $event_calno = (($event_calno - 1) % $phpiCal_config->unique_colors) + 1; ! if (!isset($val['event_start'])) { 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" />'; --- 916,921 ---- foreach ($event_times as $uid => $val) { $event_calno = $val['calnumber']; ! $event_calno = (($event_calno - 1) % $unique_colors) + 1; ! if ($cal_time == -1) { 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" />'; |