aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Hu <jimhu@users.sourceforge.net>2006-04-10 01:10:39 +0000
committerJim Hu <jimhu@users.sourceforge.net>2006-04-10 01:10:39 +0000
commitd2a7fb9c3e1c88811183cf138cc40e8aee56f73d (patch)
tree14c772abad1381d4c727fb5d634e1bc4ea466873
parent2ac05785444035fe6de6f8e06bda0076f026eb22 (diff)
downloadphpicalendar-d2a7fb9c3e1c88811183cf138cc40e8aee56f73d.tar.gz
phpicalendar-d2a7fb9c3e1c88811183cf138cc40e8aee56f73d.tar.bz2
phpicalendar-d2a7fb9c3e1c88811183cf138cc40e8aee56f73d.zip
modify template to use default if tpl file not found in alternate template folder
-rw-r--r--functions/template.php32
-rw-r--r--preferences.php2
2 files changed, 21 insertions, 13 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) {
diff --git a/preferences.php b/preferences.php
index 96c1932..1bc5bd3 100644
--- a/preferences.php
+++ b/preferences.php
@@ -29,7 +29,7 @@ $cpath = $_REQUEST['cpath'];
if ($action == 'setcookie') {
$cookie_language = $_POST['cookie_language'];
- $cookie_cpath = $_POST['cpath'];
+ $cookie_cpath = $_POST['cpath'];
$cookie_calendar = $_POST['cookie_calendar'];
$cookie_view = $_POST['cookie_view'];
$cookie_style = $_POST['cookie_style'];

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