Readied error pages for variable themes.
Fixed error in parsing pseudocode.
This commit is contained in:
@ -83,7 +83,7 @@ function ensureEnvironment() {
|
||||
"sendHTTPHeaders" => 1,
|
||||
"CSPimageSources" => "",
|
||||
"CSPobjectSources" => "",
|
||||
"maxFileSize" => 300000,
|
||||
"maxFileSize" => 300000000,
|
||||
],
|
||||
json_decode(file_get_contents(__DIR__ . "/../data/settings.json"), true)
|
||||
);
|
||||
@ -138,7 +138,8 @@ function queryCachePage(string $url, string $area = "", array $settings = ['cach
|
||||
|
||||
// Ignore caching if cacheRefreshInterval equals zero.
|
||||
if ($settings['cacheRefreshInterval'] == 0) {
|
||||
return file_get_contents($url);
|
||||
$content = file_get_contents($url);
|
||||
return $content;
|
||||
}
|
||||
|
||||
$fileDir = __DIR__ . "/../data/caches/$area";
|
||||
|
@ -33,52 +33,56 @@ function checkForEmbeds(string $text, array $settings):string {
|
||||
|
||||
foreach ($embedOptions as $option) {
|
||||
|
||||
if (strpos($text, $option) === false) continue;
|
||||
$position = strpos($text, $option) - 1;
|
||||
$i = 0;
|
||||
while (strpos($text, $option) !== false) {
|
||||
$position = strpos($text, $option) - 1;
|
||||
|
||||
$nextTag = $nextWhitespace = strlen($text);
|
||||
if (strpos($text, "<", $position) !== false) $nextTag = strpos($text, "<", $position);
|
||||
if (strpos($text, " ", $position) !== false) $nextWhitespace = strpos($text, " ", $position);
|
||||
$nextTag = $nextWhitespace = $nextNBSP = strlen($text);
|
||||
if (strpos($text, "<", $position) !== false) $nextTag = strpos($text, "<", $position);
|
||||
if (strpos($text, " ", $position) !== false) $nextWhitespace = strpos($text, " ", $position);
|
||||
if (strpos($text, " ", $position) !== false) $nextNBSP = strpos($text, " ", $position);
|
||||
|
||||
$end = min($nextTag, $nextWhitespace);
|
||||
// The pseudocode ends with a whitespace. No two tiles can be immediately after each other.
|
||||
$end = min($nextTag, $nextWhitespace, $nextNBSP);
|
||||
|
||||
$pseudocode = substr($text, $position, $end - $position);
|
||||
$pseudocode = substr($text, $position, $end - $position);
|
||||
|
||||
$command = substr($pseudocode, 1, strpos($pseudocode, "]") - 1);
|
||||
$arguments = [];
|
||||
if (strpos($pseudocode, "{") !== false) $arguments = explode("&", substr($pseudocode, strpos($pseudocode, "{") + 1, -1));
|
||||
$command = substr($pseudocode, 1, strpos($pseudocode, "]") - 1);
|
||||
$arguments = [];
|
||||
if (strpos($pseudocode, "{") !== false) $arguments = explode("&", substr($pseudocode, strpos($pseudocode, "{") + 1, -1));
|
||||
|
||||
switch ($command) {
|
||||
case "singleObjectTile":
|
||||
$text = str_replace($pseudocode, embedObject($arguments, $settings), $text);
|
||||
break;
|
||||
case "singleObjectDetails":
|
||||
$text = str_replace($pseudocode, embedObject($arguments, $settings, true), $text);
|
||||
break;
|
||||
case "singleCollectionTile":
|
||||
$text = str_replace($pseudocode, embedCollection($arguments, $settings), $text);
|
||||
break;
|
||||
case "singleCollectionDetails":
|
||||
$text = str_replace($pseudocode, embedCollection($arguments, $settings, true), $text);
|
||||
break;
|
||||
case "singleInstitutionTile":
|
||||
$text = str_replace($pseudocode, embedInstitution($arguments, $settings), $text);
|
||||
break;
|
||||
case "singleInstitutionDetails":
|
||||
$text = str_replace($pseudocode, embedInstitution($arguments, $settings, true), $text);
|
||||
break;
|
||||
case "exhibitionCalendar":
|
||||
$text = str_replace($pseudocode, embedExhibitionCalendar($arguments), $text);
|
||||
break;
|
||||
case "singleExhibitionDetails":
|
||||
$text = str_replace($pseudocode, embedExhibition($arguments, $settings, true), $text);
|
||||
break;
|
||||
case "eventCalendar":
|
||||
$text = str_replace($pseudocode, embedEventCalendar($arguments), $text);
|
||||
break;
|
||||
case "singleEventDetails":
|
||||
$text = str_replace($pseudocode, embedEvent($arguments, $settings, true), $text);
|
||||
break;
|
||||
switch ($command) {
|
||||
case "singleObjectTile":
|
||||
$text = str_replace($pseudocode, embedObject($arguments, $settings), $text);
|
||||
break;
|
||||
case "singleObjectDetails":
|
||||
$text = str_replace($pseudocode, embedObject($arguments, $settings, true), $text);
|
||||
break;
|
||||
case "singleCollectionTile":
|
||||
$text = str_replace($pseudocode, embedCollection($arguments, $settings), $text);
|
||||
break;
|
||||
case "singleCollectionDetails":
|
||||
$text = str_replace($pseudocode, embedCollection($arguments, $settings, true), $text);
|
||||
break;
|
||||
case "singleInstitutionTile":
|
||||
$text = str_replace($pseudocode, embedInstitution($arguments, $settings), $text);
|
||||
break;
|
||||
case "singleInstitutionDetails":
|
||||
$text = str_replace($pseudocode, embedInstitution($arguments, $settings, true), $text);
|
||||
break;
|
||||
case "exhibitionCalendar":
|
||||
$text = str_replace($pseudocode, embedExhibitionCalendar($arguments), $text);
|
||||
break;
|
||||
case "singleExhibitionDetails":
|
||||
$text = str_replace($pseudocode, embedExhibition($arguments, $settings, true), $text);
|
||||
break;
|
||||
case "eventCalendar":
|
||||
$text = str_replace($pseudocode, embedEventCalendar($arguments), $text);
|
||||
break;
|
||||
case "singleEventDetails":
|
||||
$text = str_replace($pseudocode, embedEvent($arguments, $settings, true), $text);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -134,11 +134,12 @@ function printStaticPagePart(string $file, string $elem):string {
|
||||
/**
|
||||
* This function prints an error page.
|
||||
*
|
||||
* @param string $content The error message.
|
||||
* @param array $settings General site settings / including the CSS.
|
||||
* @param string $content The error message.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function printErrorPage(string $content):string {
|
||||
function printErrorPage(array $settings, string $content):string {
|
||||
|
||||
$output = '
|
||||
<!DOCTYPE html>
|
||||
@ -149,7 +150,7 @@ function printErrorPage(string $content):string {
|
||||
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
|
||||
<meta charset="UTF-8" />
|
||||
<title>' . $content . '</title>
|
||||
<link rel="stylesheet" type="text/css" href="themes/default/default.css" />
|
||||
<link rel="stylesheet" type="text/css" href="themes/' . $settings['css'] . '/theme.css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
Reference in New Issue
Block a user