diff options
author | Jim Hu <jimhu@users.sourceforge.net> | 2006-04-10 01:10:39 +0000 |
---|---|---|
committer | Jim Hu <jimhu@users.sourceforge.net> | 2006-04-10 01:10:39 +0000 |
commit | d2a7fb9c3e1c88811183cf138cc40e8aee56f73d (patch) | |
tree | 14c772abad1381d4c727fb5d634e1bc4ea466873 /functions/template.php | |
parent | 2ac05785444035fe6de6f8e06bda0076f026eb22 (diff) | |
download | phpicalendar-d2a7fb9c3e1c88811183cf138cc40e8aee56f73d.tar.gz phpicalendar-d2a7fb9c3e1c88811183cf138cc40e8aee56f73d.tar.bz2 phpicalendar-d2a7fb9c3e1c88811183cf138cc40e8aee56f73d.zip |
modify template to use default if tpl file not found in alternate template folder
Diffstat (limited to 'functions/template.php')
-rw-r--r-- | functions/template.php | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/functions/template.php b/functions/template.php index 32e0b2d..95f4859 100644 --- a/functions/template.php +++ b/functions/template.php @@ -1027,23 +1027,31 @@ class Page { } - function Page($template = 'std.tpl') { - if (file_exists($template)) - $this->page = join('', file($template)); - else - die("Template file $template not found."); - } + function Page($file = 'std.tpl') { + global $template; + if (!file_exists($file)){ + #look for it in default if not found + $file = str_replace("templates/$template","templates/default",$file); + if (!file_exists($file)) die("Template file $file not found."); + } + $this->page = join('', file($file)); + } function parse($file) { - global $template; - ob_start(); - if (strpos($file, "$template") > 0 || $file =='./functions/event.js'){ + global $template; $lang; + if (basename(dirname($file)) == "$template" || $file =='./functions/event.js'){ + if (!is_file($file)){ + #look for it in default if not found + $file = str_replace("templates/$template","templates/default",$file); + } + if (!is_file($file)){ + exit(error($lang['l_error_path'], $file)); + } + ob_start(); include($file); $buffer = ob_get_contents(); ob_end_clean(); return $buffer; - }else{ - die('breakin attempt'); } } @@ -1069,7 +1077,7 @@ class Page { foreach ($tags as $tag => $data) { // This opens up another template and parses it as well. - $data = (file_exists($data)) ? $this->parse($data) : $data; + $data = $this->parse($data); // This removes any unfilled tags if (!$data) { |