diff options
author | Bernie Innocenti <bernie@codewiz.org> | 2011-03-01 00:55:41 (GMT) |
---|---|---|
committer | Bernie Innocenti <bernie@codewiz.org> | 2011-03-01 00:55:41 (GMT) |
commit | 64474c14afdb45961cd232d30cc443f0c318f292 (patch) | |
tree | 5b2e7102550544b48a1fd1e52548b6082dabd2a3 /index.php |
Sugar Labs website 2010
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/index.php b/index.php new file mode 100644 index 0000000..f5eb22d --- /dev/null +++ b/index.php @@ -0,0 +1,43 @@ +<?php + + $xslfilename = 'index'; + if (isset($_GET['template'])) { + $xslfilename = ctype_alpha($_GET['template']) ? $_GET['template'] : 'index'; + } + + // get additional arguments + $arguments = array( + 'page' => $_GET['page'], + 'article' => $_GET['article'], + 'language' => $_GET['language'] + ); + $page = $_GET['page']; + $article = $_GET['article']; + $language = $_GET['language']; + $cached_name = "cache/$xslfilename$page$article$language.xml"; + + // does a cached version exist? + if (file_exists($cached_name)) { + readfile($cached_name); + } else { + // load the xml file and stylesheet as domdocuments + $xsl = new DomDocument(); + $xsl->load("xsl/$xslfilename.xsl"); + + $xml = new DomDocument(); + $xml->load("xml/index.xml"); + $xml->Xinclude(); + + // create the processor and import the stylesheet + $proc = new XsltProcessor(); + $xsl = $proc->importStylesheet($xsl); + $proc->setParameter(null, $arguments); + + // transform and output the xml document, caching result + $output = $proc->transformToDoc($xml)->saveXML(); + + // enable this line on server to enable caching + file_put_contents($cached_name, $output); + print $output; + } +?> |