# HG changeset patch # User Tom Fredrik "BFG" Klaussen # Date 1305927273 -7200 # Node ID 350a8c63bd14903f889542f504f61f9423be4d2e # Parent 6c0162497d561f9ce6558df5a3607bae28e44ffa Support for recursive includes. diff -r 6c0162497d56 -r 350a8c63bd14 index.php --- a/index.php Fri May 20 22:28:03 2011 +0200 +++ b/index.php Fri May 20 23:34:33 2011 +0200 @@ -1,5 +1,7 @@ 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");