blob: c20c7ee5ce4c9b0b56b1774e11d5cb3f96c4c0bf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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;
}
?>
|