|
From: <cl...@us...> - 2004-02-08 08:13:38
|
Update of /cvsroot/phpicalendar/phpicalendar/functions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16894/functions Modified Files: template.php Log Message: Continued work on week.tpl. Allday is now wired. Replaced all ereg's on tempate with preg to increase template speed. Index: template.php =================================================================== RCS file: /cvsroot/phpicalendar/phpicalendar/functions/template.php,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** template.php 8 Feb 2004 00:43:14 -0000 1.26 --- template.php 8 Feb 2004 08:10:30 -0000 1.27 *************** *** 13,19 **** $dayofmonth = strtotime ($key); $dayofmonth = localizeDate ($dateFormat_day, $dayofmonth); - echo "<tr><td width=\"10\"><img src=\"images/spacer.gif\" width=\"10\" height=\"1\" alt=\" \"></td>\n"; - echo "<td align=\"left\" colspan=\"2\"><font class=\"V12\"><b>$dayofmonth</b></font></td></tr>"; - echo "<tr><td colspan=\"3\"><img src=\"images/spacer.gif\" width=\"1\" height=\"5\" alt=\" \"></td></tr>\n"; // Pull out each day --- 13,16 ---- *************** *** 52,57 **** } function draw_day($template_p) { ! global $template, $getdate, $cal, $master_array, $daysofweek_lang, $week_start_day; // Replaces the allday events --- 49,127 ---- } + function draw_week($template_p) { + global $start_week_time, $template, $getdate, $cal, $master_array, $daysofweek_lang, $week_start_day, $dateFormat_week_list, $current_view; + + for ($i=0; $i<7; $i++) { + $thisdate = date ('Ymd', $start_week_time); + $weekarray[$i] = $thisdate; + $start_week_time = strtotime('+1 day', $start_week_time); + } + + // Replaces the allday events + preg_match("!<\!-- loop allday on -->(.*)<\!-- loop allday off -->!is", $this->page, $match1); + preg_match("!<\!-- loop alldaysofweek on -->(.*)<\!-- loop allday on -->!is", $this->page, $match2); + preg_match("!<\!-- loop allday off -->(.*)<\!-- loop alldaysofweek off -->!is", $this->page, $match3); + $loop_ad = trim($match1[1]); + $loop_begin = trim($match2[1]); + $loop_end = trim($match3[1]); + foreach ($weekarray as $key => $get_date) { + $replace = $loop_begin; + if (is_array($master_array[$get_date]['-1'])) { + foreach ($master_array[$get_date]['-1'] as $allday) { + $event_calno = $allday['calnumber']; + $event_calna = $allday['calname']; + $event_url = $allday['url']; + if ($event_calno < 1) $event_calno=1; + if ($event_calno > 7) $event_calno=7; + $event = openevent($event_calna, '', '', $allday, 1, 11, '<span class="V9W">', '</span>', 'psf', $event_url); + $loop_tmp = str_replace('{EVENT}', $event, $loop_ad); + $loop_tmp = str_replace('{CALNO}', $event_calno, $loop_tmp); + $replace .= $loop_tmp; + } + } + $replace .= $loop_end; + $weekreplace .= $replace; + } + $this->page = preg_replace('!<\!-- loop alldaysofweek on -->(.*)<\!-- loop alldaysofweek off -->!is', $weekreplace, $this->page); + + // Replaces the daysofweek + preg_match("!<\!-- loop daysofweek on -->(.*)<\!-- loop daysofweek off -->!is", $this->page, $match1); + $loop_dof = trim($match1[1]); + $start_wt = strtotime(dateOfWeek($getdate, $week_start_day)); + $start_day = strtotime($week_start_day); + for ($i=0; $i<7; $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); + $loop_tmp = str_replace('{DAY}', $weekday, $loop_dof); + $loop_tmp = str_replace('{DAYLINK}', $daylink, $loop_tmp); + $loop_tmp = str_replace('{ROW1}', $row1, $loop_tmp); + $loop_tmp = str_replace('{ROW2}', $row2, $loop_tmp); + $loop_tmp = str_replace('{ROW3}', $row3, $loop_tmp); + $weekday_loop .= $loop_tmp; + } + $this->page = preg_replace('!<\!-- loop daysofweek on -->(.*)<\!-- loop daysofweek off -->!is', $weekday_loop, $this->page); + + + } + function draw_day($template_p) { ! global $template, $getdate, $cal, $master_array, $daysofweek_lang, $week_start_day, $dateFormat_week_list, $current_view; // Replaces the allday events *************** *** 72,76 **** } } ! $this->page = ereg_replace('<!-- loop allday on -->(.*)<!-- loop allday off -->', $replace, $this->page); // Replaces the daysofweek --- 142,146 ---- } } ! $this->page = preg_replace('!<\!-- loop allday on -->(.*)<\!-- loop allday off -->!is', $replace, $this->page); // Replaces the daysofweek *************** *** 81,86 **** for ($i=0; $i<7; $i++) { $day_num = date("w", $start_day); - $weekday = $daysofweek_lang[$day_num]; $daylink = date('Ymd', $start_wt); if ($daylink == $getdate) { $row1 = 'rowToday'; --- 151,160 ---- for ($i=0; $i<7; $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'; *************** *** 101,105 **** $weekday_loop .= $loop_tmp; } ! $this->page = ereg_replace('<!-- loop daysofweek on -->(.*)<!-- loop daysofweek off -->', $weekday_loop, $this->page); } --- 175,179 ---- $weekday_loop .= $loop_tmp; } ! $this->page = preg_replace('!<\!-- loop daysofweek on -->(.*)<\!-- loop daysofweek off -->!is', $weekday_loop, $this->page); } *************** *** 140,149 **** } ! $this->page = ereg_replace('<!-- switch t_allday on -->(.*)<!-- switch t_allday off -->', $replace_ad, $this->page); ! $this->page = ereg_replace('<!-- switch t_event on -->(.*)<!-- switch t_event off -->', $replace_e, $this->page); } else { ! $this->page = ereg_replace('<!-- switch tomorrows_events on -->(.*)<!-- switch tomorrows_events off -->', '', $this->page); } --- 214,223 ---- } ! $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); } *************** *** 204,208 **** } } ! $this->page = ereg_replace('<!-- switch show_completed on -->(.*)<!-- switch show_normal off -->', $nugget2, $this->page); } } --- 278,282 ---- } } ! $this->page = preg_replace('!<\!-- switch show_completed on -->(.*)<\!-- switch show_normal off -->!is', $nugget2, $this->page); } } *************** *** 329,333 **** $return = preg_replace('!<\!-- loop weekday on -->(.*)<\!-- loop weekday off -->!is', $weekday_loop, $template_p); ! $return = ereg_replace('<!-- loop monthweeks on -->(.*)<!-- loop monthweeks off -->', $middle, $return); $return = str_replace('{MONTH_TITLE}', $month_title, $return); $return = str_replace('{CAL}', $cal, $return); --- 403,407 ---- $return = preg_replace('!<\!-- loop weekday on -->(.*)<\!-- loop weekday off -->!is', $weekday_loop, $template_p); ! $return = preg_replace('!<\!-- loop monthweeks on -->(.*)<\!-- loop monthweeks off -->!is', $middle, $return); $return = str_replace('{MONTH_TITLE}', $month_title, $return); $return = str_replace('{CAL}', $cal, $return); *************** *** 386,390 **** } while ($this_month == $check_month); ! $this->page = ereg_replace('<!-- loop showbottomevents_odd on -->(.*)<!-- loop showbottomevents_even off -->', $middle, $this->page); } --- 460,464 ---- } while ($this_month == $check_month); ! $this->page = preg_replace('!<\!-- loop showbottomevents_odd on -->(.*)<\!-- loop showbottomevents_even off -->!is', $middle, $this->page); } *************** *** 414,418 **** // This removes any unfilled tags if (!$data) { ! $this->page = ereg_replace('<!-- switch ' . $tag . ' on -->(.*)<!-- switch ' . $tag . ' off -->', '', $this->page); } --- 488,492 ---- // This removes any unfilled tags if (!$data) { ! $this->page = preg_replace('!<\!-- switch ' . $tag . ' on -->(.*)<\!-- switch ' . $tag . ' off -->!is', '', $this->page); } |