aboutsummaryrefslogtreecommitdiffstats
path: root/functions
diff options
context:
space:
mode:
authorChad Little <clittle@users.sourceforge.net>2004-01-29 08:08:56 +0000
committerChad Little <clittle@users.sourceforge.net>2004-01-29 08:08:56 +0000
commit1e61f021e7e145361cf4885706253aebba3e5ba4 (patch)
tree775b612e1520a931bee7e1cb463ac569c5200678 /functions
parentc05af993979e7a97765659c4ab94ee3285001b1a (diff)
downloadphpicalendar-1e61f021e7e145361cf4885706253aebba3e5ba4.tar.gz
phpicalendar-1e61f021e7e145361cf4885706253aebba3e5ba4.tar.bz2
phpicalendar-1e61f021e7e145361cf4885706253aebba3e5ba4.zip
Added draw_month first pass. Updated sidebar.
Diffstat (limited to 'functions')
-rw-r--r--functions/template.php86
1 files changed, 85 insertions, 1 deletions
diff --git a/functions/template.php b/functions/template.php
index 68f4b81..f191011 100644
--- a/functions/template.php
+++ b/functions/template.php
@@ -1,5 +1,78 @@
<?php
+function draw_month($template, $offset = '+0') {
+ ob_start();
+ include($template);
+ $template = ob_get_contents();
+ ob_end_clean();
+ preg_match("!<\!-- loop weekday on -->(.*)<\!-- loop weekday off -->!is", $template, $match1);
+ preg_match("!<\!-- loop monthweeks on -->(.*)<\!-- loop monthweeks off -->!is", $template, $match2);
+ preg_match("!<\!-- switch notthismonth on -->(.*)<\!-- switch notthismonth off -->!is", $template, $match3);
+ preg_match("!<\!-- switch notevent on -->(.*)<\!-- switch notevent off -->!is", $template, $match4);
+ preg_match("!<\!-- switch isevent on -->(.*)<\!-- switch isevent off -->!is", $template, $match5);
+ preg_match("!<\!-- loop monthweeks on -->(.*)<\!-- switch notthismonth on -->!is", $template, $match6);
+ preg_match("!<\!-- switch notevent off -->(.*)<\!-- loop monthweeks off -->!is", $template, $match7);
+
+ $loop_wd = trim($match1[1]);
+ $loop_w = trim($match2[1]);
+ $notthismonth = trim($match3[1]);
+ $notevent = trim($match4[1]);
+ $isevent = trim($match5[1]);
+ $startweek = trim($match6[1]);
+ $endweek = trim($match7[1]);
+ $fake_getdate_time = strtotime($this_year.'-'.$this_month.'-15');
+ $start_day = strtotime($week_start_day);
+ $month_title = localizeDate ($dateFormat_month, strtotime($getdate));
+
+ for ($i=0; $i<7; $i++) {
+ $day_num = date("w", $start_day);
+ $weekday = $daysofweekreallyshort_lang[$day_num];
+ $start_day = strtotime("+1 day", $start_day);
+ $loop_tmp = str_replace('{LOOP_WEEKDAY}', $weekday, $loop_wd);
+ $weekday_loop .= $loop_tmp;
+ }
+
+ $minical_time = $fake_getdate_time;
+ $minical_month = date("m", $minical_time);
+ $minical_year = date("Y", $minical_time);
+ $first_of_month = $minical_year.$minical_month."01";
+ $start_day = strtotime(dateOfWeek($first_of_month, $week_start_day));
+ $i = 0;
+ $whole_month = TRUE;
+ $to_replace = array('{DAY}', '{CAL}', '{DAYLINK}', '{MINICAL_VIEW}');
+
+
+ do {
+ if ($i == 0) $middle .= $startweek;
+ $day = date ("j", $start_day);
+ $daylink = date ("Ymd", $start_day);
+ $check_month = date ("m", $start_day);
+ if ($check_month != $minical_month) {
+ $middle .= str_replace($to_replace, array($day, $cal, $daylink, $minical_view) , $notthismonth);
+ } elseif (isset($master_array[$daylink]) && ($check_month == $minical_month)) {
+ $middle .= str_replace($to_replace, array($day, $cal, $daylink, $minical_view) , $isevent);
+ } else {
+ $middle .= str_replace($to_replace, array($day, $cal, $daylink, $minical_view) , $notevent);
+ }
+
+ $start_day = strtotime("+1 day", $start_day);
+
+ $i++;
+ if ($i == 7) {
+ $i = 0;
+ $middle .= $endweek;
+ $checkagain = date ("m", $start_day);
+ if ($checkagain != $minical_month) $whole_month = FALSE;
+ }
+ } while ($whole_month == TRUE);
+
+ $return = eregi_replace('<!-- loop weekday on -->(.*)<!-- loop weekday off -->', $weekday_loop, $template);
+ $return = eregi_replace('<!-- loop monthweeks on -->(.*)<!-- loop monthweeks off -->', $middle, $return);
+
+ return $return;
+
+}
+
class Page {
var $page;
function Page($template = 'std.tpl') {
@@ -16,7 +89,7 @@ class Page {
ob_end_clean();
return $buffer;
}
-
+
function replace_tags($tags = array()) {
if (sizeof($tags) > 0)
foreach ($tags as $tag => $data) {
@@ -32,6 +105,7 @@ class Page {
// This replaces any tags
$this->page = eregi_replace('{' . $tag . '}', $data, $this->page);
}
+
else
die('No tags designated for replacement.');
}
@@ -43,6 +117,16 @@ class Page {
}
function output() {
+ preg_match_all ('!(\{MONTH_SMALL\|[+|-][0-9]\})!is', $this->page, $match);
+ if (sizeof($match) > 0) {
+ foreach ($match[1] as $key => $val) {
+ $template = 'templates/default/month_small.tpl';
+ $offset = str_replace('}', '', $val);
+ $offset = str_replace('{MONTH_SMALL|', '', $offset);
+ $data = draw_month($template, $offset);
+ $this->page = str_replace($val, $data, $this->page);
+ }
+ }
print($this->page);
}
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy