diff options
author | Chad Little <clittle@users.sourceforge.net> | 2004-02-04 22:39:45 +0000 |
---|---|---|
committer | Chad Little <clittle@users.sourceforge.net> | 2004-02-04 22:39:45 +0000 |
commit | 4a55f1bbc2a95855d912728b2674d47c81b75b49 (patch) | |
tree | 1697f5ea48ad82b0e7167f90e27bde54502a7a6a /functions | |
parent | a8de1c81133802b00a31104b31ba97439a56e830 (diff) | |
download | phpicalendar-4a55f1bbc2a95855d912728b2674d47c81b75b49.tar.gz phpicalendar-4a55f1bbc2a95855d912728b2674d47c81b75b49.tar.bz2 phpicalendar-4a55f1bbc2a95855d912728b2674d47c81b75b49.zip |
Code optimization.
Diffstat (limited to 'functions')
-rw-r--r-- | functions/template.php | 49 |
1 files changed, 19 insertions, 30 deletions
diff --git a/functions/template.php b/functions/template.php index 774bcea..d5cdd7b 100644 --- a/functions/template.php +++ b/functions/template.php @@ -222,39 +222,28 @@ class Page { function output() { global $template, $php_started, $lang; - // Small month builder - preg_match_all ('!(\{MONTH_SMALL\|[+|-][0-9]\})!is', $this->page, $match); - if (sizeof($match) > 0) { - $template_file = $this->parse('templates/'.$template.'/month_small.tpl'); - foreach ($match[1] as $key => $val) { - $offset = str_replace('}', '', $val); - $offset = str_replace('{MONTH_SMALL|', '', $offset); - $data = $this->draw_month($template_file, $offset, 'small'); - $this->page = str_replace($val, $data, $this->page); - } - } - - // Medium month builder - preg_match_all ('!(\{MONTH_MEDIUM\|[0-9][0-9]\})!is', $this->page, $match); - if (sizeof($match) > 0) { - $template_file = $this->parse('templates/'.$template.'/month_medium.tpl'); - foreach ($match[1] as $key => $val) { - $offset = str_replace('}', '', $val); - $offset = str_replace('{MONTH_MEDIUM|', '', $offset); - $data = $this->draw_month($template_file, $offset, 'medium'); - $this->page = str_replace($val, $data, $this->page); - } - } - // Large month builder - preg_match_all ('!(\{MONTH_LARGE\|[+|-][0-9]\})!is', $this->page, $match); + // Looks for {MONTH} before sending page out + preg_match_all ('!\{MONTH_([A-Z]*)\|?([+|-])([0-9]{1,2})\}!is', $this->page, $match); if (sizeof($match) > 0) { - $template_file = $this->parse('templates/'.$template.'/month_large.tpl'); + $i=0; foreach ($match[1] as $key => $val) { - $offset = str_replace('}', '', $val); - $offset = str_replace('{MONTH_LARGE|', '', $offset); - $data = $this->draw_month($template_file, $offset, 'large'); - $this->page = str_replace($val, $data, $this->page); + if ($match[1][$i] == 'SMALL') { + $template_file = $this->parse('templates/'.$template.'/month_small.tpl'); + $type = 'small'; + $offset = $match[2][$i].$match[3][$i]; + } elseif ($match[1][$i] == 'MEDIUM') { + $template_file = $this->parse('templates/'.$template.'/month_medium.tpl'); + $type = 'medium'; + $offset = $match[3][$i]; + } else { + $template_file = $this->parse('templates/'.$template.'/month_large.tpl'); + $type = 'large'; + $offset = $match[2][$i].$match[3][$i]; + } + $data = $this->draw_month($template_file, $offset, $type); + $this->page = str_replace($match[0][$i], $data, $this->page); + $i++; } } |