$value) {
$availableLangs[$key] = str_replace(".htm", "", $value);
}
if (isset($_GET['lang'])) $lang = $_GET['lang'];
else $lang = lang_getfrombrowser($availableLangs, 'de', null, false);
// Load HTML document to PHP DOMDocument
$content = new DOMDocument();
$content->load(__DIR__ . "/contents/$lang.htm");
// Find out title
$title = $content->getElementsByTagName("h1")[0]->nodeValue;
// Generate PDF if need be.
if (filemtime(__DIR__ . "/tex/$lang/contentsFrontend.tex") < filemtime(__DIR__ . "/contents/$lang.htm")) {
foreach ($content->getElementsByTagName("section") as $c) {
DOMtoTeX($c, "tex/$lang");
}
runPDF("tex/$lang", "brochure", "brochure.pdf", $title, $lang, true);
}
// Print HTML page.
$content = file_get_contents(__DIR__ . "/contents/$lang.htm");
$content = str_replace("\\today", date("Y-m-d", filemtime("contents/$lang.htm")), $content);
echo printHTMLPage("about:" . $title, $content, $lang);
?>