From 1e61f021e7e145361cf4885706253aebba3e5ba4 Mon Sep 17 00:00:00 2001 From: Chad Little Date: Thu, 29 Jan 2004 08:08:56 +0000 Subject: Added draw_month first pass. Updated sidebar. --- functions/template.php | 86 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 85 insertions(+), 1 deletion(-) (limited to 'functions') 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 @@ (.*)<\!-- 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('(.*)', $weekday_loop, $template); + $return = eregi_replace('(.*)', $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); } } -- cgit v1.2.3