diff inputParser.inc @ 39:bd82b719a0de

Make CacheTimeCheck a singleton. Robustify if_modified_since check. Quiet warnings. Set debug levels. Fix basepath references.
author Tom Fredrik "BFG" Klaussen <bfg@blenning.no>
date Fri, 05 Oct 2012 00:21:27 +0200
parents 42533600214b
children 2cfea6e84694
line wrap: on
line diff
--- a/inputParser.inc	Thu Oct 04 22:07:19 2012 +0200
+++ b/inputParser.inc	Fri Oct 05 00:21:27 2012 +0200
@@ -39,10 +39,7 @@
   if (!$conf)
     $conf = $param->getAttribute("default");
 
-  $confFile = "${lang}/${conf}.xml";
-  if (!file_exists($confFile)) {
-     errorPage("Resource not available");
-  }
+  $confFile = $options->getBasePath() . "/${lang}/${conf}.xml";
   $options->getCache()->cache_time($confFile);
   $doc = new DOMDocument();
   $doc->load($confFile);
@@ -63,7 +60,7 @@
     foreach ($includes as $include) {
 	$src = $include->getAttribute("src");
 	$subdoc = new DOMDocument();
-	$subfile = "${lang}/${src}";
+	$subfile = $options->getBasePath() . "/${lang}/${src}";
 	$subdoc->load("$subfile");
 	$options->getCache()->cache_time($subfile);
 	$parent = $include->parentNode;
@@ -78,8 +75,8 @@
     $includes = $doc->getElementsByTagName("include");
   }
 
-  $head=getElementByTagName($doc,"head");
-  $title=$head->getAttribute("title");
+  $head = getElementByTagName($doc, "head");
+  $title = $head->getAttribute("title");
 
   if($title) {
     $values=$master->getElementsByTagName("param");
@@ -96,15 +93,15 @@
     }
   }
 
-  $css=getElementByTagName($head,"css");
-  $css=$doc->saveXML($css);
-  $css=preg_replace('/\s*<\/?\s*css\s*>\s*/s', '', $css);
+  $css = getElementByTagName($head,"css");
+  $css = $doc->saveXML($css);
+  $css = preg_replace('/\s*<\/?\s*css\s*>\s*/s', '', $css);
 
   if($css) {
-    $values=$master->getElementsByTagName("param");
+    $values = $master->getElementsByTagName("param");
     foreach ($values as $value) {
-      if ($value->getAttribute("type")=="input_config") {
-        if ($value->getAttribute("id")=="css") {
+      if ($value->getAttribute("type") == "input_config") {
+        if ($value->getAttribute("id") == "css") {
           $tmp = new DOMDocument();
           $tmp->loadXml("<xml>${css}</xml>");
 	  $parent=$value->parentNode;
@@ -127,7 +124,7 @@
     if ($script) {
       $cacheable = false;
       $src="";
-      $cwd=getcwd();
+      $cwd = getcwd();
 
       $matches=array();
       preg_match('/(.*\/)/', $script, $matches);
@@ -141,7 +138,7 @@
     }
     else {
       $src = $file->getAttribute("src");
-      $fname = "${lang}/${src}";
+      $fname = $options->getBasePath() . "/${lang}/${src}";
       $file_content = $options->getCache()->loadFile($fname);
     }
     if(floatval($file_content)<0) {
@@ -164,8 +161,6 @@
 	  }
       }
       $callString .= ");";
-      //print $callString;
-      //exit;
       eval($callString);
     }
     $out.= $file_content;