Mercurial > SimpleWebPresenter
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 38:42533600214b | 39:bd82b719a0de |
|---|---|
| 37 $name = $param->getAttribute("id"); | 37 $name = $param->getAttribute("id"); |
| 38 $conf = $options->getName(); | 38 $conf = $options->getName(); |
| 39 if (!$conf) | 39 if (!$conf) |
| 40 $conf = $param->getAttribute("default"); | 40 $conf = $param->getAttribute("default"); |
| 41 | 41 |
| 42 $confFile = "${lang}/${conf}.xml"; | 42 $confFile = $options->getBasePath() . "/${lang}/${conf}.xml"; |
| 43 if (!file_exists($confFile)) { | |
| 44 errorPage("Resource not available"); | |
| 45 } | |
| 46 $options->getCache()->cache_time($confFile); | 43 $options->getCache()->cache_time($confFile); |
| 47 $doc = new DOMDocument(); | 44 $doc = new DOMDocument(); |
| 48 $doc->load($confFile); | 45 $doc->load($confFile); |
| 49 | 46 |
| 50 $toplevel = $doc->getElementsByTagName("toplevel"); | 47 $toplevel = $doc->getElementsByTagName("toplevel"); |
| 61 errorPage('Recursion limit exceeded', 500); | 58 errorPage('Recursion limit exceeded', 500); |
| 62 } | 59 } |
| 63 foreach ($includes as $include) { | 60 foreach ($includes as $include) { |
| 64 $src = $include->getAttribute("src"); | 61 $src = $include->getAttribute("src"); |
| 65 $subdoc = new DOMDocument(); | 62 $subdoc = new DOMDocument(); |
| 66 $subfile = "${lang}/${src}"; | 63 $subfile = $options->getBasePath() . "/${lang}/${src}"; |
| 67 $subdoc->load("$subfile"); | 64 $subdoc->load("$subfile"); |
| 68 $options->getCache()->cache_time($subfile); | 65 $options->getCache()->cache_time($subfile); |
| 69 $parent = $include->parentNode; | 66 $parent = $include->parentNode; |
| 70 $xml = getElementByTagName($subdoc,"xml"); | 67 $xml = getElementByTagName($subdoc,"xml"); |
| 71 foreach($xml->childNodes as $child) { | 68 foreach($xml->childNodes as $child) { |
| 76 $parent->removeChild($include); | 73 $parent->removeChild($include); |
| 77 } | 74 } |
| 78 $includes = $doc->getElementsByTagName("include"); | 75 $includes = $doc->getElementsByTagName("include"); |
| 79 } | 76 } |
| 80 | 77 |
| 81 $head=getElementByTagName($doc,"head"); | 78 $head = getElementByTagName($doc, "head"); |
| 82 $title=$head->getAttribute("title"); | 79 $title = $head->getAttribute("title"); |
| 83 | 80 |
| 84 if($title) { | 81 if($title) { |
| 85 $values=$master->getElementsByTagName("param"); | 82 $values=$master->getElementsByTagName("param"); |
| 86 foreach ($values as $value) { | 83 foreach ($values as $value) { |
| 87 if ($value->getAttribute("type")=="input_config") { | 84 if ($value->getAttribute("type")=="input_config") { |
| 94 } | 91 } |
| 95 } | 92 } |
| 96 } | 93 } |
| 97 } | 94 } |
| 98 | 95 |
| 99 $css=getElementByTagName($head,"css"); | 96 $css = getElementByTagName($head,"css"); |
| 100 $css=$doc->saveXML($css); | 97 $css = $doc->saveXML($css); |
| 101 $css=preg_replace('/\s*<\/?\s*css\s*>\s*/s', '', $css); | 98 $css = preg_replace('/\s*<\/?\s*css\s*>\s*/s', '', $css); |
| 102 | 99 |
| 103 if($css) { | 100 if($css) { |
| 104 $values=$master->getElementsByTagName("param"); | 101 $values = $master->getElementsByTagName("param"); |
| 105 foreach ($values as $value) { | 102 foreach ($values as $value) { |
| 106 if ($value->getAttribute("type")=="input_config") { | 103 if ($value->getAttribute("type") == "input_config") { |
| 107 if ($value->getAttribute("id")=="css") { | 104 if ($value->getAttribute("id") == "css") { |
| 108 $tmp = new DOMDocument(); | 105 $tmp = new DOMDocument(); |
| 109 $tmp->loadXml("<xml>${css}</xml>"); | 106 $tmp->loadXml("<xml>${css}</xml>"); |
| 110 $parent=$value->parentNode; | 107 $parent=$value->parentNode; |
| 111 foreach($tmp->firstChild->childNodes as $node) { | 108 foreach($tmp->firstChild->childNodes as $node) { |
| 112 $clonedChild=$master->importNode($node,true); | 109 $clonedChild=$master->importNode($node,true); |
| 125 foreach ($files as $file) { | 122 foreach ($files as $file) { |
| 126 $script=$file->getAttribute("script"); | 123 $script=$file->getAttribute("script"); |
| 127 if ($script) { | 124 if ($script) { |
| 128 $cacheable = false; | 125 $cacheable = false; |
| 129 $src=""; | 126 $src=""; |
| 130 $cwd=getcwd(); | 127 $cwd = getcwd(); |
| 131 | 128 |
| 132 $matches=array(); | 129 $matches=array(); |
| 133 preg_match('/(.*\/)/', $script, $matches); | 130 preg_match('/(.*\/)/', $script, $matches); |
| 134 $dirname=$matches[0]; | 131 $dirname=$matches[0]; |
| 135 preg_match('/([^\/]*)$/', $script, $matches); | 132 preg_match('/([^\/]*)$/', $script, $matches); |
| 139 $file_content = stream_get_contents($pipe); | 136 $file_content = stream_get_contents($pipe); |
| 140 chdir("${cwd}"); | 137 chdir("${cwd}"); |
| 141 } | 138 } |
| 142 else { | 139 else { |
| 143 $src = $file->getAttribute("src"); | 140 $src = $file->getAttribute("src"); |
| 144 $fname = "${lang}/${src}"; | 141 $fname = $options->getBasePath() . "/${lang}/${src}"; |
| 145 $file_content = $options->getCache()->loadFile($fname); | 142 $file_content = $options->getCache()->loadFile($fname); |
| 146 } | 143 } |
| 147 if(floatval($file_content)<0) { | 144 if(floatval($file_content)<0) { |
| 148 errorPage("Resource not found '${lang}/${src}'"); | 145 errorPage("Resource not found '${lang}/${src}'"); |
| 149 } | 146 } |
| 162 $callString .= ",\$param_value[$i]"; | 159 $callString .= ",\$param_value[$i]"; |
| 163 $i++; | 160 $i++; |
| 164 } | 161 } |
| 165 } | 162 } |
| 166 $callString .= ");"; | 163 $callString .= ");"; |
| 167 //print $callString; | |
| 168 //exit; | |
| 169 eval($callString); | 164 eval($callString); |
| 170 } | 165 } |
| 171 $out.= $file_content; | 166 $out.= $file_content; |
| 172 } | 167 } |
| 173 | 168 |
