From b4b1947362e1b6d92ce23b44b626ebbaabb401b4 Mon Sep 17 00:00:00 2001 From: Chad Little Date: Sun, 8 Feb 2004 08:10:28 +0000 Subject: Continued work on week.tpl. Allday is now wired. Replaced all ereg's on tempate with preg to increase template speed. --- functions/template.php | 102 ++++++++++++++++++++++++++++++++++++------ templates/default/day.tpl | 4 +- templates/default/default.css | 10 +++-- templates/default/week.tpl | 86 ++++++++++++++++++----------------- week.php | 2 +- 5 files changed, 143 insertions(+), 61 deletions(-) diff --git a/functions/template.php b/functions/template.php index 882ecf9..acd5d8d 100644 --- a/functions/template.php +++ b/functions/template.php @@ -12,9 +12,6 @@ class Page { $events_week++; $dayofmonth = strtotime ($key); $dayofmonth = localizeDate ($dateFormat_day, $dayofmonth); - echo "\"\n"; - echo "$dayofmonth"; - echo "\"\n"; // Pull out each day foreach ($val as $new_val) { @@ -51,8 +48,81 @@ class Page { } } + 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, '', '', '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; + global $template, $getdate, $cal, $master_array, $daysofweek_lang, $week_start_day, $dateFormat_week_list, $current_view; // Replaces the allday events $replace = ''; @@ -71,7 +141,7 @@ class Page { $replace .= $loop_tmp; } } - $this->page = ereg_replace('(.*)', $replace, $this->page); + $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); @@ -80,8 +150,12 @@ class Page { $start_day = strtotime($week_start_day); for ($i=0; $i<7; $i++) { $day_num = date("w", $start_day); - $weekday = $daysofweek_lang[$day_num]; $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'; @@ -100,7 +174,7 @@ class Page { $loop_tmp = str_replace('{ROW3}', $row3, $loop_tmp); $weekday_loop .= $loop_tmp; } - $this->page = ereg_replace('(.*)', $weekday_loop, $this->page); + $this->page = preg_replace('!<\!-- loop daysofweek on -->(.*)<\!-- loop daysofweek off -->!is', $weekday_loop, $this->page); } @@ -139,12 +213,12 @@ class Page { } } - $this->page = ereg_replace('(.*)', $replace_ad, $this->page); - $this->page = ereg_replace('(.*)', $replace_e, $this->page); + $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 = ereg_replace('(.*)', '', $this->page); + $this->page = preg_replace('!<\!-- switch tomorrows_events on -->(.*)<\!-- switch tomorrows_events off -->!is', '', $this->page); } } @@ -203,7 +277,7 @@ class Page { $nugget2 .= $nugget1; } } - $this->page = ereg_replace('(.*)', $nugget2, $this->page); + $this->page = preg_replace('!<\!-- switch show_completed on -->(.*)<\!-- switch show_normal off -->!is', $nugget2, $this->page); } } } @@ -328,7 +402,7 @@ class Page { } while ($whole_month == TRUE); $return = preg_replace('!<\!-- loop weekday on -->(.*)<\!-- loop weekday off -->!is', $weekday_loop, $template_p); - $return = ereg_replace('(.*)', $middle, $return); + $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); @@ -385,7 +459,7 @@ class Page { unset ($switch); } while ($this_month == $check_month); - $this->page = ereg_replace('(.*)', $middle, $this->page); + $this->page = preg_replace('!<\!-- loop showbottomevents_odd on -->(.*)<\!-- loop showbottomevents_even off -->!is', $middle, $this->page); } @@ -413,7 +487,7 @@ class Page { // This removes any unfilled tags if (!$data) { - $this->page = ereg_replace('(.*)', '', $this->page); + $this->page = preg_replace('!<\!-- switch ' . $tag . ' on -->(.*)<\!-- switch ' . $tag . ' off -->!is', '', $this->page); } // This replaces any tags diff --git a/templates/default/day.tpl b/templates/default/day.tpl index e2a3142..e2c214e 100644 --- a/templates/default/day.tpl +++ b/templates/default/day.tpl @@ -24,9 +24,9 @@ - +
- diff --git a/templates/default/default.css b/templates/default/default.css index 63b499d..40e7afe 100644 --- a/templates/default/default.css +++ b/templates/default/default.css @@ -15,9 +15,11 @@ table, td {font: 11px Verdana, Arial, sans-serif; color: #000;} .alldaybg_6 {background: url(images/allday_6.gif) repeat-x; height: 19px; padding-top: 5px; text-align: center;} .alldaybg_7 {background: url(images/allday_7.gif) repeat-x; height: 19px; padding-top: 5px; text-align: center;} -.rowOn { background-color: #cfc; } -.rowOff { background-color: #E1E8F1; } -.rowToday { background-color: #cff; } +.rowOn { background-color: #cfc; border-top: 1px solid #fff; border-left: 1px solid #fff; } +.rowOn2 { background-color: #cfc; border-top: 1px solid #fff; } +.rowOff { background-color: #E1E8F1; border-top: 1px solid #fff; border-left: 1px solid #fff; } +.rowOff2 { background-color: #E1E8F1; border-top: 1px solid #fff; border-left: } +.rowToday { background-color: #cff; border-top: 1px solid #fff; border-left: 1px solid #fff; } @@ -92,7 +94,7 @@ a.ps3 { text-decoration: none; } a.ps3:link { color: #000000; background-color: transparent; } a.ps3:visited { color: #000000; background-color: transparent; } a.ps3:active { color: #000000; background-color: transparent; } -a.ps3:hover { color: #000000; background-color: transparent; text-decoration: underline;} +a.ps3:hover { color: #000000; background-color: transparent; } /* Body attributes */ diff --git a/templates/default/week.tpl b/templates/default/week.tpl index 3fa2114..3d9eba7 100644 --- a/templates/default/week.tpl +++ b/templates/default/week.tpl @@ -30,124 +30,130 @@
+ «
- +
- - + + - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/week.php b/week.php index 88f4bd6..a9c42f9 100644 --- a/week.php +++ b/week.php @@ -70,7 +70,7 @@ $page->replace_tags(array( 'style_select' => $style_select )); -$page->draw_day($this->page); +$page->draw_week($this->page); $page->tomorrows_events($this->page); $page->get_vtodo($this->page); -- cgit v1.2.3
-   « + +
 «
- »   + +
 
+
+
 
+
+
» 
- {DAY} + + {DAY}
+
- +
- {EVENT} + {EVENT}
+ 8:00 AM +   +   +   +   +   +   +  
+   +   +   +   +   +   +  
+   +   +   +   +   +   +  
+   +   +   +   +   +   +