# HG changeset patch # User Tom Fredrik "BFG" Klaussen # Date 1348062618 -7200 # Node ID ee2c31392ea30c5e4473e514cc4575b6736d278d # Parent d5068ced2ad1eda871ecf2e297b7e1b57fd136c1# Parent a20bb1b51aadfc7b1918a50e810c8e7efe1d25ef Merge Regression, fast cache-checking has been removed. diff -r d5068ced2ad1 -r ee2c31392ea3 cache_check.inc --- a/cache_check.inc Wed Sep 19 14:41:22 2012 +0200 +++ b/cache_check.inc Wed Sep 19 15:50:18 2012 +0200 @@ -23,4 +23,11 @@ $newest = $mtime; } } + +function include_with_mtime($path) { + cache_time($path); + include($path); +} + +cache_time('php/cache_check.inc'); ?> \ No newline at end of file diff -r d5068ced2ad1 -r ee2c31392ea3 flag.php --- a/flag.php Wed Sep 19 14:41:22 2012 +0200 +++ b/flag.php Wed Sep 19 15:50:18 2012 +0200 @@ -1,4 +1,6 @@ >>>>>> other $URL_PARAMS=array('name', 'lang'); @@ -38,14 +53,17 @@ if(!$lang) { $lang="no"; $langs=acceptedLanguages(); - foreach ($langs as $l => $val) { - if (file_exists($l)) { - $lang=$l; - break; + if ($langs) { + foreach ($langs as $l => $val) { + if (file_exists($l)) { + $lang=$l; + break; + } } } } +<<<<<<< local $title="Dummy title"; $config=loadFile("${lang}/${name}.xml"); @@ -115,6 +133,8 @@
'; +======= +>>>>>>> other function getParam($param) { $param_type=$param->getAttribute("type"); $param_value; @@ -144,6 +164,91 @@ return $param_value; } +function getInput($master, $param) { + $out=''; + + $lang=$GLOBALS['lang']; + $name=$param->getAttribute("id"); + $conf=$_GET[$name]; + $GLOBALS[$name]=$conf; + if (!$conf) + $conf=$param->getAttribute("default"); + $config=loadFile("${lang}/${conf}.xml"); + + $confFile="${lang}/${conf}.xml"; + if (!file_exists($confFile)) { + errorPage("Resource not available"); + } + $doc = new DOMDocument(); + $doc->load($confFile); + + $includes=$doc->getElementsByTagName("include"); + $recurse=0; + + while($includes->length>0) { + if(++$recurse>MAX_RECURSE) { + errorPage('Recursion limit exceeded', 500); + } + foreach ($includes as $include) { + $src=$include->getAttribute("src"); + $subdoc = new DOMDocument(); + $subdoc->load("${lang}/${src}"); + $parent=$include->parentNode; + $xml=getElementByTagName($subdoc,"xml"); + foreach($xml->childNodes as $child) { + $text=$subdoc->saveXml($child); + $clonedChild=$doc->importNode($child,true); + $parent->insertBefore($clonedChild,$include); + } + $parent->removeChild($include); + } + $includes=$doc->getElementsByTagName("include"); + } + + $head=getElementByTagName($doc,"head"); + $title=$head->getAttribute("title"); + + if($title) { + $values=$master->getElementsByTagName("param"); + foreach ($values as $value) { + if ($value->getAttribute("type")=="input_config") { + if ($value->getAttribute("id")=="title") { + $tmp = new DOMDocument(); + $tmp->loadXml("${title}"); + $parent=$value->parentNode; + $parent->removeChild($value); + $parent->appendChild(new DOMText($tmp->textContent)); + } + } + } + } + + $css=getElementByTagName($head,"css"); + $css=$doc->saveXML($css); + $css=preg_replace('/\s*<\/?\s*css\s*>\s*/s', '', $css); + + if($css) { + $values=$master->getElementsByTagName("param"); + foreach ($values as $value) { + if ($value->getAttribute("type")=="input_config") { + if ($value->getAttribute("id")=="css") { + $tmp = new DOMDocument(); + $tmp->loadXml("${css}"); + $parent=$value->parentNode; + foreach($tmp->firstChild->childNodes as $node) { + $clonedChild=$master->importNode($node,true); + $parent->insertBefore($clonedChild,$value); + } + $parent->removeChild($value); + } + } + } + } + + + $body=getElementByTagName($doc,"body"); + $files=$body->getElementsByTagName("file"); + foreach ($files as $file) { if ($file->getAttribute("script")) { $cachable = false; @@ -208,6 +313,7 @@ $out.= $file_content; } +<<<<<<< local $out.=' @@ -215,6 +321,32 @@ '; +======= + $doc = new DOMDocument(); + $doc->loadXml("${out}"); +>>>>>>> other -print $out; + return $doc; +} + +$master = new DOMDocument(); +$master->load("master.xml"); + +$params=$master->getElementsByTagName("param"); +foreach ($params as $param) { + if ($param->getAttribute("type") == "input") { + $doc=getInput($master,$param); + + $parent=$param->parentNode; + foreach ($doc->firstChild->childNodes as $child) { + $clonedChild=$master->importNode($child,true); + $parent->insertBefore($clonedChild,$param); + } + $parent->removeChild($param); + + } +} + +print $master->saveXml($master); + ?>