[xml configuration file Olivier Schwander **20110309193314 Ignore-this: 4109b7e6c2752990cba8e527ceee0a2f ] hunk ./example/_config/pages.xml 1 - - - SymphoniX - Accueil - - rmfile ./example/_config/pages.xml rmdir ./example/_config addfile ./example/uphp.xml hunk ./example/uphp.xml 1 + + + + + + + + + + + + + SymphoniX - Accueil + + + hunk ./uphp.php 3 -function html5_header() { - print ""; - print ""; - print ' '; - print ' <title/>'; - print "</head>"; - print "<html>"; - print " <body>"; +function html5_header($common, $page) { + print "<!DOCTYPE html>\n"; + print "<html>\n"; + print " <head>\n"; + foreach (array($common, $page) as $headers) { + foreach ($headers as $h) { +# simplexml closes empty tags with <tag /> and not <tag></tag> which +# is harmful for <script> + print sprintf(" %s\n", + preg_replace('/<script(.*)\/>/', '<script$1></script>', $h->asXML()) + ); + }; + }; + print " </head>\n"; + print " <body>\n"; hunk ./uphp.php 21 - print " </body>"; - print "</html>"; + print " </body>\n"; + print "</html>\n"; hunk ./uphp.php 25 -session_start(); - -$page = $_GET['q']; +$q = $_GET['q']; hunk ./uphp.php 28 -html5_header(); +$xml = simplexml_load_file("uphp.xml"); + +$common = $xml->xpath("/uphp/page"); +$result = $xml->xpath("//page[@name='$q']"); +if (count($result) > 0) { + $page = $result[0]; + $common = $common[0]; + + if ($page['driver'] == "html") { + session_start(); + + html5_header($common->children(), $page->children()); + + include 'includes/header.php'; + + print " <div id=\"content\">\n"; + include sprintf('html/%s.html', $q); + print " </div>\n"; hunk ./uphp.php 47 -include 'includes/header.php'; -include sprintf('html/%s.html', $page); -include 'includes/footer.php'; + include 'includes/footer.php'; hunk ./uphp.php 49 -html5_footer(); + html5_footer(); + exit(0); + } +} +else { + # Does not work + header("HTTP/1.0 404 Not Found"); + /* header("Status: 404 Not Found"); */ +}