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 | |
parent | a8de1c81133802b00a31104b31ba97439a56e830 (diff) | |
download | phpicalendar-4a55f1bbc2a95855d912728b2674d47c81b75b49.tar.gz phpicalendar-4a55f1bbc2a95855d912728b2674d47c81b75b49.tar.bz2 phpicalendar-4a55f1bbc2a95855d912728b2674d47c81b75b49.zip |
Code optimization.
-rw-r--r-- | config.inc.php | 6 | ||||
-rw-r--r-- | functions/template.php | 49 |
2 files changed, 22 insertions, 33 deletions
diff --git a/config.inc.php b/config.inc.php index 6f8de84..68e73df 100644 --- a/config.inc.php +++ b/config.inc.php @@ -1,12 +1,12 @@ <?php -// Configuration file for PHP iCalendar 1.2 +// Configuration file for PHP iCalendar 2.0 // // To set values, change the text between the single quotes // Follow instructions to the right for detailed information $style_sheet = 'silver'; // Themes support - silver, red, green, orange, grey, tan -$template = 'default'; +$template = 'default'; // Template support $default_view = 'day'; // Default view for calendars = 'day', 'week', 'month', 'year' $minical_view = 'current'; // Where do the mini-calendars go when clicked? = 'day', 'week', 'month', 'current' $default_cal = $ALL_CALENDARS_COMBINED; // Exact filename of calendar without .ics. Or set to $ALL_CALENDARS_COMBINED to open all calenders combined into one. @@ -24,7 +24,7 @@ $timezone = ''; // Set timezone. Read TIMEZONES file for more information $tmp_dir = '/tmp'; // The temporary directory on your system (/tmp is fine for UNIXes including Mac OS X) $calendar_path = ''; // Leave this blank on most installs, place your full path to calendars if they are outside the phpicalendar folder. $second_offset = '0'; // The time in seconds between your time and your server's time. -$bleed_time = ''; // This allows events past midnight to just be displayed on the starting date, only good up to 24 hours. Range from '0000' to '2359'. Is automatically set to $day_start if left blank. +$bleed_time = ''; // This allows events past midnight to just be displayed on the starting date, only good up to 24 hours. Range from '0000' to '2359', or '-1' for no bleed time. Is automatically set to $day_start if left blank. $cookie_uri = ''; // The HTTP URL to the PHP iCalendar directory, ie. http://www.example.com/phpicalendar -- AUTO SETTING -- Only set if you are having cookie issues. $download_uri = ''; // The HTTP URL to your calendars directory, ie. http://www.example.com/phpicalendar/calendars -- AUTO SETTING -- Only set if you are having subscribe issues. $default_path = 'http://www.example.com/phpicalendar'; // The HTTP URL to the PHP iCalendar directory, ie. http://www.example.com/phpicalendar 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++; } } |