Readied error pages for variable themes.
Fixed error in parsing pseudocode.
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user