This repository has been archived on 2023-10-25. You can view files and clone it, but cannot push or open issues or pull requests.
about-brochure/index.php

65 lines
1.8 KiB
PHP
Raw Normal View History

2018-06-01 22:35:44 +02:00
<?PHP
/**
* This file serves the HTML output of the main about page.
*/
error_reporting(E_ALL);
ini_set('display_errors', 1);
// Load required files and ensure environment.
require_once __DIR__ . "/functions.php";
require_once __DIR__ . "/htmlToTeX.php";
ensureEnvironment();
2018-06-04 01:54:32 +02:00
if (!isset($_GET['t']) or $_GET['t'] == "about") {
$sourceFolder = "contents";
$sourceFile = "brochure";
$sourceTeXFile = "contentsFrontend";
}
else if (!isset($_GET['t']) or $_GET['t'] == "press") {
$sourceFolder = "press";
$sourceFile = "press_review";
$sourceTeXFile = "contentsIntroductionPress";
}
2018-06-01 22:35:44 +02:00
// Find out current language
2018-06-04 01:54:32 +02:00
$availableLangs = scanDirConts(__DIR__ . "/$sourceFolder"); // Those languages are available, for which there are files
2018-06-01 22:35:44 +02:00
foreach ($availableLangs as $key => $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();
2018-06-04 01:54:32 +02:00
$content->load(__DIR__ . "/$sourceFolder/$lang.htm");
2018-06-01 22:35:44 +02:00
// Find out title
$title = $content->getElementsByTagName("h1")[0]->nodeValue;
// Generate PDF if need be.
2018-06-04 01:54:32 +02:00
if (filemtime(__DIR__ . "/tex/$lang/$sourceTeXFile.tex") -5000 < filemtime(__DIR__ . "/$sourceFolder/$lang.htm")) {
2018-06-01 22:35:44 +02:00
foreach ($content->getElementsByTagName("section") as $c) {
DOMtoTeX($c, "tex/$lang");
}
2018-06-04 01:54:32 +02:00
runPDF("tex/$lang", "$sourceFile", "$sourceFile", $title, $lang, true);
2018-06-01 22:35:44 +02:00
2018-06-04 01:54:32 +02:00
}
2018-06-01 22:35:44 +02:00
// Print HTML page.
2018-06-04 01:54:32 +02:00
$content = file_get_contents(__DIR__ . "/$sourceFolder/$lang.htm");
2018-06-01 22:35:44 +02:00
2018-06-04 01:54:32 +02:00
$content = str_replace("\\today", date("Y-m-d", filemtime(__DIR__ . "/$sourceFolder/$lang.htm")), $content);
2018-06-01 22:35:44 +02:00
2018-06-02 16:57:00 +02:00
echo printHTMLPage("about:" . $title, $content, $lang, $availableLangs);
2018-06-01 22:35:44 +02:00
?>