Progressed on generalizing functions.
This commit is contained in:
@ -254,13 +254,13 @@ function removeFolderGently($folder, $exclude) {
|
||||
* @param string $folder Determines the folder (say, template) to use for PDF generation.
|
||||
* @param string $texFilename Name of the TeX file. Used without its ending.
|
||||
* @param string $filename Filename as it should be shown to the user.
|
||||
* @param boolean $title Title of the overall output.
|
||||
* @param boolean $pdfSettings Additional parameters to use \def for.
|
||||
* @param boolean $lang Language. Optional.
|
||||
* @param boolean $debug Enables/disables debug mode. Optional.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function runPDF($folder, $texFilename, $filename, $title, $lang = "de", $debug = false) {
|
||||
function runPDF($folder, $texFilename, $filename, $pdfSettings, $lang = "de", $debug = false) {
|
||||
|
||||
if (!is_dir("./tmp")) mkdir("./tmp");
|
||||
|
||||
@ -270,7 +270,7 @@ function runPDF($folder, $texFilename, $filename, $title, $lang = "de", $debug =
|
||||
copyFolder("$folder", "./tmp/$uniqid");
|
||||
copy("$texFilename.tex", "./tmp/$uniqid/$texFilename.tex");
|
||||
|
||||
$generateUserSettings = function($lang, $title) {
|
||||
$generateUserSettings = function($lang, $pdfSettings) {
|
||||
$babelPackages = [
|
||||
"en" => "english",
|
||||
"de" => "german",
|
||||
@ -282,9 +282,10 @@ function runPDF($folder, $texFilename, $filename, $title, $lang = "de", $debug =
|
||||
else $lan = "en";
|
||||
|
||||
return '\\usepackage[' . $babelPackages[$lan] . ']{babel}
|
||||
\\def \\pageTitle {' . transform($title) . '}' . PHP_EOL;
|
||||
\\def \\pageTitle {' . transform($pdfSettings['title']) . '}' . PHP_EOL . '
|
||||
\\def \\pageTitleImg {' . transform($pdfSettings['bgImg']) . '}' . PHP_EOL;
|
||||
};
|
||||
$userSettings = $generateUserSettings($lang, $title);
|
||||
$userSettings = $generateUserSettings($lang, $pdfSettings);
|
||||
|
||||
file_put_contents("./tmp/$uniqid/pdfSettings.tex", $userSettings);
|
||||
|
||||
@ -318,10 +319,11 @@ function runPDF($folder, $texFilename, $filename, $title, $lang = "de", $debug =
|
||||
* @param string $lang Language. Optional
|
||||
* @param array $availableLangs Page description. Optional.
|
||||
* @param string $descriptions Page description. Optional.
|
||||
* @param string $pdfLink Link to brochure. Optional.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function printHTMLPage(string $title, string $contents, string $lang = "en", array $availableLangs = ["en"], string $descriptions = "") {
|
||||
function printHTMLPage(string $title, string $contents, string $lang = "en", array $availableLangs = ["en"], string $descriptions = "", $pdfLink = "brochure") {
|
||||
|
||||
$output = '<!DOCTYPE html>
|
||||
<html lang="' . $lang . '" id="' . str_replace(":", "", str_replace(" ", "", $title)) . '">
|
||||
@ -349,14 +351,15 @@ function printHTMLPage(string $title, string $contents, string $lang = "en", arr
|
||||
<body id="start">
|
||||
|
||||
<nav id="mainNav">
|
||||
<a href="#start">Top</a>
|
||||
<a href="./?t=about#start">Home</a>
|
||||
<a href="./?t=press#start">Pressespiegel</a>
|
||||
<a href="#bottom"></a>
|
||||
</nav>
|
||||
|
||||
';
|
||||
$output .= $contents . '
|
||||
<footer id="bottom">
|
||||
<a href="pdf/' . $lang . '/brochure.pdf" class="buttonLike">PDF</a>
|
||||
<a href="pdf/' . $lang . '/' . $pdfLink . '.pdf" class="buttonLike">PDF</a>
|
||||
</footer>
|
||||
|
||||
<footer id="optionsFooter">
|
||||
@ -379,7 +382,7 @@ function printHTMLPage(string $title, string $contents, string $lang = "en", arr
|
||||
</footer>
|
||||
|
||||
<script src="./js/tracking.js"></script>
|
||||
<noscript><p><img src="https://www.jrenslin.de/museum-digital/piwik/piwik.php?idsite=1" style="border:0;" alt="" ></p></noscript>
|
||||
<noscript><p><img src="https://www.jrenslin.de/museum-digital/piwik/piwik.php?idsite=1" /></p></noscript>
|
||||
|
||||
</html>';
|
||||
|
||||
|
Reference in New Issue
Block a user