Added option to switch themes.

Added standalone pages for:
 - Exhibitions
 - Events
 - Institutions
 - Collections
Added option to limit display to only a given set of institutions.
This commit is contained in:
Joshua Ramon Enslin 2018-06-18 10:43:22 +02:00 committed by Stefan Rohde-Enslin
parent 2ae4196546
commit bb8fa74cd6
18 changed files with 916 additions and 33 deletions

View File

@ -25,5 +25,8 @@ if (!in_array($_GET['area'], ['events', 'exhibitions'])) {
ensureEnvironment();
echo queryCachePage($settings['mdVersion'] . "?" . urldecode($_GET['args']), $_GET['area'], $settings);
$output = queryCachePage($settings['mdVersion'] . "?" . urldecode($_GET['args']), $_GET['area'], $settings);
$output = str_replace("index.php?t=exhibition&", "exhibition.php?", $output);
$output = str_replace("index.php?t=event&", "event.php?", $output);
echo $output;

71
collection.php Normal file
View File

@ -0,0 +1,71 @@
<?PHP
/**
* This file displays object detail pages as fetched from museum-digital.
*
* @author Joshua Ramon Enslin <joshua@jrenslin.de>
*/
// Include functions and settings.
require_once __DIR__ . "/inc/functions.php";
// Check validity of request.
if (!isset($_GET['id']) or !is_numeric($_GET['id'])) {
echo printErrorPage("Collection does not exist.");
return;
}
// Ensure working environment for frontend.
ensureEnvironment();
$pages = loadPublicPages(); // Load overview of pages.
$contents = json_decode(queryCachePage($settings['mdVersion'] . "?t=sammlung&gesusa=" . urlencode($_GET['id']) . "&output=json", "institution", $settings), true);
if (!$contents || (isset($contents[0]) and $contents[0] == "There is no collection with this ID yet.")) {
echo printErrorPage("Temporarily unavailable.");
return;
}
if ($settings['limitToInstitutions'] != [] and !in_array($contents['collection_id'], $settings['limitToInstitutions'])) {
echo printErrorPage("This collection does not belong to an enabled institution.");
return;
}
/*
* Output
*/
$addToHead = '
<link rel="canonical" href="' . $settings['mdVersion'] . 'index.php?t=sammlung&gesusa=' . $contents['collection_id'] . '" />';
echo printPublicHead($settings, $_GET['id'], $settings['pageTitle'] . " - " . $contents['collection_name'], $settings['logo'], $addToHead);
echo printPublicHeader($settings['pageTitle']);
echo printStaticPagePart("banner", "header"); // Print aside (if need be)
echo generatePublicNav($pages);
echo '
<div id="mainWrapper">
';
// Print main content
echo '
<main>';
echo drawCollectionDetails($contents, $settings);
echo '
</main>
';
echo printStaticPagePart("aside", "aside"); // Print aside (if need be)
echo '
</div>';
echo printStaticPagePart("footer", "footer"); // Print footer (if need be)
echo printPublicEnd();
?>

View File

@ -19,6 +19,14 @@ require_once __DIR__ . '/standardHTML.php';
*/
function ensureBackendEnv() {
// Ensure secure session cookies are used.
ini_set('session.cookie_secure', '1');
ini_set('session.cookie_httponly', '1');
ini_set('session.use_only_cookies', '1');
// Ensure session is started
if (session_status() != PHP_SESSION_ACTIVE) {
session_start();
}

View File

@ -29,28 +29,42 @@ document.addEventListener("DOMContentLoaded", function() {
let translations = {
"en" : {
"uploadFile" : "Upload file",
"submit" : "Submit",
"generate" : "Generate",
"embedCodeGenerator" : "Generator for embed code",
"helpEmbedCode" : "Here you can create embed code.",
"singleObjectTile" : "Single object (tile)",
"singleObjectDetails": "Single object (details)",
"singleCollection" : "Single collection",
"exhibitionCalendar" : "Exhibition calendar",
"eventCalendar" : "Event calendar",
"uploadFile" : "Upload file",
"submit" : "Submit",
"generate" : "Generate",
"embedCodeGenerator" : "Generator for embed code",
"helpEmbedCode" : "Here you can create embed code.",
"singleObjectTile" : "Single object (tile)",
"singleObjectDetails" : "Single object (details)",
"singleCollectionTile" : "Single collection (tile)",
"singleCollectionDetails" : "Single collection (details)",
"singleInstitutionTile" : "Single institution (tile)",
"singleInstitutionDetails" : "Single institution (details)",
"singleExhibitionTile" : "Single exhibition (tile)",
"singleExhibitionDetails" : "Single exhibition (details)",
"singleEventTile" : "Single event (tile)",
"singleEventDetails" : "Single event (details)",
"exhibitionCalendar" : "Exhibition calendar",
"eventCalendar" : "Event calendar",
},
"de" : {
"uploadFile" : "Eine Datei heraufladen",
"submit" : "Abschicken",
"generate" : "Generieren",
"embedCodeGenerator" : "Generator für Einbettungen",
"helpEmbedCode" : "Hier können sie den embed-code generieren.",
"singleObjectTile" : "Einzelobjekt (Kachel)",
"singleObjectDetails": "Einzelobjekt (Details)",
"singleCollection" : "Einzelsammlung",
"exhibitionCalendar" : "Ausstellungskalender",
"eventCalendar" : "Veranstaltungen (Kalender)",
"uploadFile" : "Eine Datei heraufladen",
"submit" : "Abschicken",
"generate" : "Generieren",
"embedCodeGenerator" : "Generator für Einbettungen",
"helpEmbedCode" : "Hier können sie den embed-code generieren.",
"singleObjectTile" : "Einzelobjekt (Kachel)",
"singleObjectDetails" : "Einzelobjekt (Details)",
"singleCollectionTile" : "Einzelsammlung (Kachel)",
"singleCollectionDetails" : "Einzelsammlung (Details)",
"singleInstitutionTile" : "Einzelinstitution (Kachel)",
"singleInstitutionDetails" : "Einzelinstitution (Details)",
"singleExhibitionTile" : "Einzelne Ausstellung (Kachel)",
"singleExhibitionDetails" : "Einzelne Ausstellung (Details)",
"singleEventTile" : "Einzelne Veranstaltung (Kachel)",
"singleEventDetails" : "Einzelne Veranstaltung (Details)",
"exhibitionCalendar" : "Ausstellungskalender",
"eventCalendar" : "Veranstaltungen (Kalender)",
}
};
@ -273,11 +287,18 @@ document.addEventListener("DOMContentLoaded", function() {
let generatorTypes = [
["", "", false],
["singleObjectTile", getTranslation(translations, "singleObjectTile"), true],
["singleObjectDetails", getTranslation(translations, "singleObjectDetails"), true],
["singleCollectionTile", getTranslation(translations, "singleCollection"), true],
["exhibitionCalendar", getTranslation(translations, "exhibitionCalendar"), true],
["eventCalendar", getTranslation(translations, "eventCalendar"), true],
["singleObjectTile", getTranslation(translations, "singleObjectTile"), true],
["singleObjectDetails", getTranslation(translations, "singleObjectDetails"), true],
["singleCollectionTile", getTranslation(translations, "singleCollectionTile"), true],
["singleCollectionDetails", getTranslation(translations, "singleCollectionDetails"), true],
["singleInstitutionTile", getTranslation(translations, "singleInstitutionTile"), true],
["singleInstitutionDetails", getTranslation(translations, "singleInstitutionDetails"), true],
["singleExhibitionTile", getTranslation(translations, "singleExhibitionTile"), true],
["singleExhibitionDetails", getTranslation(translations, "singleExhibitionDetails"), true],
["singleEventTile", getTranslation(translations, "singleEventTile"), true],
["singleEventDetails", getTranslation(translations, "singleEventDetails"), true],
["exhibitionCalendar", getTranslation(translations, "exhibitionCalendar"), true],
["eventCalendar", getTranslation(translations, "eventCalendar"), true],
];
// Add help tooltip

View File

@ -57,12 +57,13 @@ if (isset($task)) {
else if ($task == "delete") {
if (isset($id)) {
if (!isset($id)) {
echo printErrorPage($translations['specifyToDelete']); return;
}
unlink(__DIR__ . "/../data/static/$id.json");
generateStaticPgCaches();
header('Location: pages.php');
}
}

View File

@ -22,7 +22,7 @@ $pages = loadPages(); // Load overview of pages.
*/
// Check for vars.
loadHttpToGlobals(["task", "startPage", "pageTitle", "logo", "url", "mdVersion", "mdImgFolder", "cacheRefreshInterval", "maxFileSize", "defaultLang"]);
loadHttpToGlobals(["task", "startPage", "pageTitle", "logo", "url", "css", "hideInstitution", "mdVersion", "mdImgFolder", "cacheRefreshInterval", "limitToInstitutions", "maxFileSize", "defaultLang"]);
if (isset($task) and $task == "update") { // Adding new users.
@ -35,7 +35,8 @@ if (isset($task) and $task == "update") { // Adding new users.
if (isset($mdVersion)) $mdVersion = rtrim($mdVersion, "/") . "/";
if (isset($mdImgFolder)) $mdImgFolder = rtrim($mdImgFolder, "/") . "/";
foreach (["startPage", "pageTitle", "logo", "url", "mdVersion", "mdImgFolder", "cacheRefreshInterval", "maxFileSize", "defaultLang"] as $var) {
if (isset($limitToInstitutions)) $settings['limitToInstitutions'] = array_diff(explode(',', $limitToInstitutions), ['']);
foreach (["startPage", "pageTitle", "logo", "url", "css", "hideInstitution", "mdVersion", "mdImgFolder", "cacheRefreshInterval", "maxFileSize", "defaultLang"] as $var) {
if (isset($$var)) $settings[$var] = $$var;
}
@ -109,6 +110,32 @@ echo '
<td>' . generateHelpToolTip("helpURL", $translations['url'], $translations['helpURL']) . '</td>
</tr>
<!-- CSS -->
<tr>
<th><label for="settingsUsedCSS">' . $translations['settingsUsedCSS'] . '</label></th>
<td>
<select name="css" id="settingsUsedCSS">
';
foreach (scanDirConts(__DIR__ . "/../themes") as $cssOption) {
echo '<option value="' . $cssOption . '"';
if ($settings['css'] == $cssOption) echo ' selected';
echo '>' . $cssOption . '</option>';
}
echo '
</select>
</td>
<td>' . generateHelpToolTip("helpSettingsUsedCSS", $translations['settingsUsedCSS'], $translations['helpSettingsUsedCSS']) . '</td>
</tr>
<!-- Hiding attribution (if the page is for only one museum) or not -->
<tr>
<th><label for="hideInstitution">' . $translations['hideInstitution'] . '</label></th>
<td>
<input name="hideInstitution" id="hideInstitution" type="range" min="0" max="1" value="' . (string)$settings['hideInstitution'] . '" />
</td>
<td>' . generateHelpToolTip("helpHideInstitution", $translations['hideInstitution'], $translations['helpHideInstitution']) . '</td>
</tr>
<!-- MD Version -->
<tr>
<th><label for="mdVersion">' . $translations['mdVersion'] . '</label></th>
@ -130,6 +157,13 @@ echo '
<td>' . generateHelpToolTip("helpCacheRefreshInterval", $translations['cacheRefreshInterval'], $translations['helpCacheRefreshInterval']) . '</td>
</tr>
<!-- Restricting inputs to given institutions -->
<tr>
<th><label for="limitToInstitutions">' . $translations['limitToInstitutions'] . '</label></th>
<td><input type="text" id="limitToInstitutions" name="limitToInstitutions" placeholder="' . $translations['limitToInstitutions']. '" value="'.implode(',', $settings['limitToInstitutions']).'" /></td>
<td>' . generateHelpToolTip("helpLimitToInstitutions", $translations['limitToInstitutions'], $translations['helpLimitToInstitutions']) . '</td>
</tr>
<!-- Max Upload Size -->
<tr>
<th><label for="maxFileSize">' . $translations['maxFileSize'] . '</label></th>

View File

@ -109,6 +109,8 @@ table.obj_cha_maintable button:only-child,
table.obj_cha_maintable input:only-child { width: 100%; }
table.obj_cha_maintable textarea:only-child { width: 100%; height: 14em; }
table.obj_cha_maintable input[type="range"]:only-child { margin: .5em -1em 0 0; }
@media screen and (min-width:65em) {
table.obj_cha_maintable th { width: 16em; }
}

View File

@ -51,6 +51,13 @@ $translations = [
<li>Using a high value, means data could be slightly outdated, but makes loading much faster.</li>
</ul>
</p>",
"settingsUsedCSS" => "Theme",
"helpSettingsUsedCSS" => "<p>Select the used theme. New themes can be installed using FTP.</p>",
"hideInstitution" => "Hide institution",
"helpHideInstitution" => "<p>If this page is used for only a single museum, you can opt to not display the institution on tiles for exhibitions, collections, etc. by moving the slider to the right.</p>",
"limitToInstitutions" => "Limit to institutions",
"helpLimitToInstitutions" => "<p>The CMS offers the option to display objects, exhibitions, etc. from museum-digital based on their ID. By default all objects can be accessed using this functionality. To not display data that is not yours, you can restrict the data by the linked institution.</p>
<p>Enter IDs of institutions separated by commas.</p>",
"IDatMD" => "ID at museum-digital",
"embedFromMD" => "Embed from museum-digital",

71
event.php Normal file
View File

@ -0,0 +1,71 @@
<?PHP
/**
* This file displays object detail pages as fetched from museum-digital.
*
* @author Joshua Ramon Enslin <joshua@jrenslin.de>
*/
// Include functions and settings.
require_once __DIR__ . "/inc/functions.php";
// Check validity of request.
if (!isset($_GET['id']) or !is_numeric($_GET['id'])) {
echo printErrorPage("Exhibition does not exist.");
return;
}
// Ensure working environment for frontend.
ensureEnvironment();
$pages = loadPublicPages(); // Load overview of pages.
$contents = json_decode(queryCachePage($settings['mdVersion'] . "?t=event&id=" . urlencode($_GET['id']) . "&output=json", "event", $settings), true);
if (!$contents || (isset($contents[0]) and $contents[0] == "There is no event with this ID yet.")) {
echo printErrorPage("Temporarily unavailable.");
return;
}
if ($settings['limitToInstitutions'] != [] and !in_array($contents['institution_id'], $settings['limitToInstitutions'])) {
echo printErrorPage("This exhibition does not belong to an enabled institution.");
return;
}
/*
* Output
*/
$addToHead = '
<link rel="canonical" href="' . $settings['mdVersion'] . 'index.php?t=event&id=' . $contents['appointment_id'] . '" />';
echo printPublicHead($settings, $_GET['id'], $settings['pageTitle'] . " - " . $contents['name'], $settings['logo'], $addToHead);
echo printPublicHeader($settings['pageTitle']);
echo printStaticPagePart("banner", "header"); // Print aside (if need be)
echo generatePublicNav($pages);
echo '
<div id="mainWrapper">
';
// Print main content
echo '
<main>';
echo drawEventDetails($contents, $settings);
echo '
</main>
';
echo printStaticPagePart("aside", "aside"); // Print aside (if need be)
echo '
</div>';
echo printStaticPagePart("footer", "footer"); // Print footer (if need be)
echo printPublicEnd();
?>

71
exhibition.php Normal file
View File

@ -0,0 +1,71 @@
<?PHP
/**
* This file displays object detail pages as fetched from museum-digital.
*
* @author Joshua Ramon Enslin <joshua@jrenslin.de>
*/
// Include functions and settings.
require_once __DIR__ . "/inc/functions.php";
// Check validity of request.
if (!isset($_GET['id']) or !is_numeric($_GET['id'])) {
echo printErrorPage("Exhibition does not exist.");
return;
}
// Ensure working environment for frontend.
ensureEnvironment();
$pages = loadPublicPages(); // Load overview of pages.
$contents = json_decode(queryCachePage($settings['mdVersion'] . "?t=exhibition&id=" . urlencode($_GET['id']) . "&output=json", "exhibition", $settings), true);
if (!$contents || (isset($contents[0]) and $contents[0] == "There is no exhibition with this ID yet.")) {
echo printErrorPage("Temporarily unavailable.");
return;
}
if ($settings['limitToInstitutions'] != [] and !in_array($contents['institution_id'], $settings['limitToInstitutions'])) {
echo printErrorPage("This exhibition does not belong to an enabled institution.");
return;
}
/*
* Output
*/
$addToHead = '
<link rel="canonical" href="' . $settings['mdVersion'] . 'index.php?t=exhibition&id=' . $contents['exhibition_id'] . '" />';
echo printPublicHead($settings, $_GET['id'], $settings['pageTitle'] . " - " . $contents['name'], $settings['logo'], $addToHead);
echo printPublicHeader($settings['pageTitle']);
echo printStaticPagePart("banner", "header"); // Print aside (if need be)
echo generatePublicNav($pages);
echo '
<div id="mainWrapper">
';
// Print main content
echo '
<main>';
echo drawExhibitionDetails($contents, $settings);
echo '
</main>
';
echo printStaticPagePart("aside", "aside"); // Print aside (if need be)
echo '
</div>';
echo printStaticPagePart("footer", "footer"); // Print footer (if need be)
echo printPublicEnd();
?>

View File

@ -73,9 +73,12 @@ function ensureEnvironment() {
"pageTitle" => "md:cms",
"logo" => "",
"url" => "",
"css" => "default",
"hideInstitution" => 0,
"cacheRefreshInterval" => 0,
"mdVersion" => "https://rlp.museum-digital.de/",
"mdImgFolder" => "https://rlp.museum-digital.de/data/rlp/",
"limitToInstitutions" => [],
"maxFileSize" => 300000,
"defaultLang" => "en"
],

View File

@ -22,6 +22,11 @@ function checkForEmbeds(string $text, array $settings):string {
"singleObjectTile",
"singleObjectDetails",
"singleCollectionTile",
"singleCollectionDetails",
"singleInstitutionTile",
"singleInstitutionDetails",
"singleExhibitionDetails",
"singleEventDetails",
"exhibitionCalendar",
"eventCalendar"
];
@ -50,12 +55,30 @@ function checkForEmbeds(string $text, array $settings):string {
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;
}
}
@ -89,8 +112,11 @@ function drawObjectTile(array $contents, array $settings):string {
$output .= '
<div>
<h4>' . $contents['object_name'] . '</h4>
<h4>' . $contents['object_name'] . '</h4>';
if (!$settings['hideInstitution']) $output .= '
<a>' . $contents['object_institution']['institution_name'] . '<a>';
$output .= '
<div>
<a href="./object.php?id=' . $contents['object_id'] . '" class="toTranslate" data-content="More"></a>
<a href="' . $settings['mdVersion'] . '?t=objekt&oges=' . $contents['object_id'] . '" class="toTranslate" data-content="MoreAtMuseumDigital">' . $contents['object_name'] . '</a>
@ -282,6 +308,360 @@ function embedObject(array $arguments, array $settings, bool $showDetails = fals
}
/**
* Function drawInstitutionDetails generates a detail area
* containing data fetched from the institution API at museum-digital.
*
* @param string[] $contents Input data fetched from the institution API at museum-digital.
* @param array $settings Settings variable.
*
* @return string
*/
function drawInstitutionDetails(array $contents, array $settings):string {
$output = '
<div class="objDetails institutionDetails">
';
if (isset($contents['institution_image']) and $contents['institution_image']) {
$output .= '
<img class="objMainImg" src="' . $settings['mdImgFolder'] . $contents['institution_image'] . '" />';
}
$output .= '
<h2>' . $contents['institution_name'] . '</h2>
<p>' . $contents['institution_description'] . '</p>
';
$output .= '
<fieldset>';
if ($contents['institution_street']) $output .= $contents['institution_street'] . '<br />';
if ($contents['institution_zipcode']) $output .= $contents['institution_zipcode'] . " " . $contents['institution_place'] . "<br />";
if ($contents['institution_telnr']) $output .= "<a href='tel:" . $contents['institution_telnr'] . "'>" . $contents['institution_telnr'] . "</a><br />";
$output .= '
</fieldset>';
if (count($contents['collections']) >= 1) {
$output .= '
<h3 class="toTranslate" data-content="Collections"></h3>
<ul>';
foreach ($contents['collections'] as $collection) {
$output .= '
<li><a href="collection.php?id=' . $collection['collection_id'] . '">' . $collection['collection_name'] . '</a></li>
';
}
$output .= '</ul>';
}
$output .= '
<p class="metadataLine">
<span><span class="toTranslate" data-content="Metadata"></span></span>
<span><a class="toTranslate" data-content="InstitutionAtMuseumDigital" href="' . $settings['mdVersion'] . '?t=institution&instnr=' . $contents['institution_id'] . '"></a></span>
</p>
</div>
';
return $output;
}
/**
* Function drawInstitutionTile creates a tile with just the most basic information on an institiution.
*
* @param string[] $contents Input data fetched from the collection API at museum-digital.
* @param array $settings Settings variable.
*
* @return string
*/
function drawInstitutionTile(array $contents, array $settings):string {
$output = '
<div class="objTile institutionTile">
';
if (isset($contents['institution_image']) and $contents['institution_image']) {
$output .= '
<img src="' . $settings['mdImgFolder'] . $contents['institution_image'] . '" />';
}
$output .= '
<div>
<h4>' . $contents['institution_name'] . '</h4>
<p>
' . $contents['institution_street'] . '
' . $contents['institution_zipcode'] . " " . $contents['institution_place'] . '<br />
</p>
<div>
<a href="./collection.php?id=' . $contents['institution_id'] . '" class="toTranslate" data-content="More"></a>
<a href="' . $settings['mdVersion'] . '?t=institution&instnr=' . $contents['institution_id'] . '" class="toTranslate" data-content="MoreAtMuseumDigital">' . $contents['institution_name'] . '</a>
</div>
</div>
</div>
';
return $output;
}
/**
* Function for displaying institution.
*
* @param array $arguments Arguments / GET parameters for urls to query.
* @param array $settings Settings variable.
* @param boolean $showDetails Optional. By default, only a tile with most basic information is displayed.
*
* @return string
*/
function embedInstitution(array $arguments, array $settings, bool $showDetails = false):string {
$toIgnore = ["t=", "output="];
$srcArgs = "t=institution";
foreach ($arguments as $arg) {
if (startsWithAny($arg, $toIgnore)) continue;
$srcArgs .= "&" . $arg;
}
$srcArgs .= "&output=json";
$contents = json_decode(queryCachePage($settings['mdVersion'] . "?$srcArgs", "institution", $settings), true);
if (!$showDetails) return drawInstitutionTile($contents, $settings);
else return drawInstitutionDetails($contents, $settings);
}
/**
* Function drawCollectionDetails generates a detail area.
*
* @param string[] $contents Input data fetched from the collections API at museum-digital.
* @param array $settings Settings variable.
*
* @return string
*/
function drawCollectionDetails(array $contents, array $settings):string {
$output = '
<div class="objDetails collectionDetails">
';
if (isset($contents['collection_image']) and $contents['collection_image']) {
$output .= '
<img class="objMainImg" src="' . $settings['mdImgFolder'] . $contents['collection_image'] . '" />';
}
$output .= '
<h2>' . $contents['collection_name'] . '</h2>
<p>' . $contents['collection_description'] . '</p>
';
if (!$settings['hideInstitution']) $output .= '
<a> ' . $contents['collection_institution']['institution_name'] . '</a>
';
$output .= '
<p class="metadataLine">
<span><span class="toTranslate" data-content="Metadata"></span></span>
<span><a class="toTranslate" data-content="CollectionAtMuseumDigital" href="' . $settings['mdVersion'] . '?t=sammlung&gesusa=' . $contents['collection_id'] . '"></a></span>
</p>
</div>
';
return $output;
}
/**
* Function drawCollectionTile creates a tile with just the most basic information on a collection.
*
* @param string[] $contents Input data fetched from the collection API at museum-digital.
* @param array $settings Settings variable.
*
* @return string
*/
function drawCollectionTile(array $contents, array $settings):string {
$output = '
<div class="objTile collectionTile">
';
if (isset($contents['collection_image']) and $contents['collection_image']) {
$output .= '
<img src="' . $settings['mdImgFolder'] . $contents['collection_image'] . '" />';
}
$output .= '
<div>
<h4>' . $contents['collection_name'] . '</h4>
<p>' . createTextSnippet($contents['collection_description'], 180) . '</p>
';
if (!$settings['hideInstitution']) $output .= '
<a> ' . $contents['collection_institution']['institution_name'] . '</a>';
$output .= '
<div>
<a href="./collection.php?id=' . $contents['collection_id'] . '" class="toTranslate" data-content="More"></a>
<a href="' . $settings['mdVersion'] . '?t=sammlung&gesusa=' . $contents['collection_id'] . '" class="toTranslate" data-content="MoreAtMuseumDigital">' . $contents['collection_name'] . '</a>
</div>
</div>
</div>
';
return $output;
}
/**
* Function for displaying collections.
*
* @param array $arguments Arguments / GET parameters for urls to query.
* @param array $settings Settings variable.
* @param boolean $showDetails Optional. By default, only a tile with most basic information is displayed.
*
* @return string
*/
function embedCollection(array $arguments, array $settings, bool $showDetails = false):string {
$toIgnore = ["t=", "output="];
$srcArgs = "t=sammlung";
foreach ($arguments as $arg) {
if (startsWithAny($arg, $toIgnore)) continue;
$srcArgs .= "&" . $arg;
}
$srcArgs .= "&output=json";
$contents = json_decode(queryCachePage($settings['mdVersion'] . "?$srcArgs", "collection", $settings), true);
if (!$showDetails) return drawCollectionTile($contents, $settings);
else return drawCollectionDetails($contents, $settings);
}
/**
* Function drawExhibitionDetails creates a tile with just the most basic information on an exhibition.
*
* @param string[] $contents Input data fetched from the collection API at museum-digital.
* @param array $settings Settings variable.
*
* @return string
*/
function drawExhibitionDetails(array $contents, array $settings):string {
$output = '
<div class="objDetails exhibitionDetails">
';
if (isset($contents['image']) and $contents['image']) {
$output .= '
<img class="objMainImg" src="' . $settings['mdVersion'] . $contents['image'] . '" />';
}
$output .= '
<h1>' . $contents['name'] . '</h1>
<p class="timeNotifLine">
<time>' . $contents['start'] . '</time> - <time>' . $contents['end'] . '</time>
</p>
<p>' . $contents['description'] . '</p>
';
$output .= '
<p>
<a href="institution.php?id=' . $contents['institution_id'] . '"> ' . $contents['institution_name'] . ' (' . $contents['institution_ort'] . ')</a>
</p>';
$output .= '
<p class="metadataLine">
<span><span class="toTranslate" data-content="Metadata"></span></span>
<span><a class="toTranslate" data-content="ExhibitionAtMuseumDigital" href="' . $settings['mdVersion'] . '?t=exhibition&id=' . $contents['exhibition_id'] . '"></a></span>
</p>
</div>
';
return $output;
}
/**
* Function drawExhibitionTile creates a tile with just the most basic information on an exhibition.
*
* @param string[] $contents Input data fetched from the collection API at museum-digital.
* @param array $settings Settings variable.
*
* @return string
*/
function drawExhibitionTile(array $contents, array $settings):string {
$output = '
<div class="objTile exhibitionTile">
';
if (isset($contents['image']) and $contents['image']) {
$output .= '
<img src="' . $settings['mdImgFolder'] . $contents['image'] . '" />';
}
$output .= '
<div>
<h4>' . $contents['name'] . '</h4>
';
if (!$settings['hideInstitution']) $output .= '
<a href="' . $contents['institution_id'] . '"> ' . $contents['institution_name'] . '</a>';
$output .= '
<div>
<a href="./exhibition.php?id=' . $contents['exhibition_id'] . '" class="toTranslate" data-content="More"></a>
<a href="' . $settings['mdVersion'] . '?t=exhibition&id=' . $contents['exhibition_id'] . '" class="toTranslate" data-content="MoreAtMuseumDigital">' . $contents['name'] . '</a>
</div>
</div>
</div>
';
return $output;
}
/**
* Function for displaying exhibition.
*
* @param array $arguments Arguments / GET parameters for urls to query.
* @param array $settings Settings variable.
* @param boolean $showDetails Optional. By default, only a tile with most basic information is displayed.
*
* @return string
*/
function embedExhibition(array $arguments, array $settings, bool $showDetails = false):string {
$toIgnore = ["t=", "output="];
$srcArgs = "t=exhibition";
foreach ($arguments as $arg) {
if (startsWithAny($arg, $toIgnore)) continue;
$srcArgs .= "&" . $arg;
}
$srcArgs .= "&output=json";
$contents = json_decode(queryCachePage($settings['mdVersion'] . "?$srcArgs", "exhibition", $settings), true);
if (!$showDetails) return drawExhibitionTile($contents, $settings);
else return drawExhibitionDetails($contents, $settings);
}
/**
* Function for embedding event calendar.
*
@ -322,6 +702,122 @@ function embedExhibitionCalendar(array $arguments):string {
return $output;
}
/**
* Function drawEventDetails creates a tile with just the most basic information on an event.
*
* @param string[] $contents Input data fetched from the event API at museum-digital.
* @param array $settings Settings variable.
*
* @return string
*/
function drawEventDetails(array $contents, array $settings):string {
$output = '
<div class="objDetails eventDetails">
';
if (isset($contents['image']) and $contents['image']) {
$output .= '
<img class="objMainImg" src="' . $settings['mdVersion'] . $contents['image'] . '" />';
}
$output .= '
<h1>' . $contents['name'] . '</h1>
<p class="timeNotifLine">
<time>' . $contents['start'] . '</time> - <time>' . $contents['end'] . '</time>
</p>
<p>' . $contents['description'] . '</p>
';
$output .= '
<p>
<a href="institution.php?id=' . $contents['institution_id'] . '"> ' . $contents['institution_name'] . ' (' . $contents['institution_ort'] . ')</a>
</p>';
$output .= '
<p class="metadataLine">
<span><span class="toTranslate" data-content="Metadata"></span></span>
<span><a class="toTranslate" data-content="ExhibitionAtMuseumDigital" href="' . $settings['mdVersion'] . '?t=event&id=' . $contents['appointment_id'] . '"></a></span>
</p>
</div>
';
return $output;
}
/**
* Function drawEventTile creates a tile with just the most basic information on an event.
*
* @param string[] $contents Input data fetched from the event API at museum-digital.
* @param array $settings Settings variable.
*
* @return string
*/
function drawEventTile(array $contents, array $settings):string {
$output = '
<div class="objTile eventTile">
';
if (isset($contents['image']) and $contents['image']) {
$output .= '
<img src="' . $settings['mdVersion'] . $contents['image'] . '" />';
}
$output .= '
<div>
<h4>' . $contents['name'] . '</h4>
';
if (!$settings['hideInstitution']) $output .= '
<a href="' . $contents['institution_id'] . '"> ' . $contents['institution_name'] . '</a>';
$output .= '
<div>
<a href="./event.php?id=' . $contents['appointment_id'] . '" class="toTranslate" data-content="More"></a>
<a href="' . $settings['mdVersion'] . '?t=event&id=' . $contents['appointment_id'] . '" class="toTranslate" data-content="MoreAtMuseumDigital">' . $contents['name'] . '</a>
</div>
</div>
</div>
';
return $output;
}
/**
* Function for displaying events.
*
* @param array $arguments Arguments / GET parameters for urls to query.
* @param array $settings Settings variable.
* @param boolean $showDetails Optional. By default, only a tile with most basic information is displayed.
*
* @return string
*/
function embedEvent(array $arguments, array $settings, bool $showDetails = false):string {
$toIgnore = ["t=", "output="];
$srcArgs = "t=event";
foreach ($arguments as $arg) {
if (startsWithAny($arg, $toIgnore)) continue;
$srcArgs .= "&" . $arg;
}
$srcArgs .= "&output=json";
$contents = json_decode(queryCachePage($settings['mdVersion'] . "?$srcArgs", "event", $settings), true);
if (!$showDetails) return drawEventTile($contents, $settings);
else return drawEventDetails($contents, $settings);
}
/**
* Function for embedding event calendar.
*

View File

@ -21,14 +21,14 @@
function printPublicHead(array $settings, string $page = "home", string $title = "Home", string $icon = "", $additional = ""):string {
$output = '<!DOCTYPE html>
<html lang="en" id="' . $page . '">
<html lang="' . $settings['defaultLang'] . '" id="' . $page . '">
<head>
<!-- Content Security policies -->
<meta http-equiv="Content-Security-Policy" content="default-src \'none\'; script-src \'self\'; connect-src \'self\' ' . $settings['mdVersion'] . '; img-src \'self\' ' . $settings['mdVersion'] . '; style-src \'self\' \'unsafe-inline\'; font-src \'self\';" />
<title>' . $title . '</title>
<link rel="stylesheet" type="text/css" href="themes/default/default.css" />
<link rel="stylesheet" type="text/css" href="themes/' . $settings['css'] . '/theme.css" />
<link rel="stylesheet" type="text/css" href="themes/imports.css" />
<meta http-equiv="content-type" content="text/html;charset=utf-8" />';

71
institution.php Normal file
View File

@ -0,0 +1,71 @@
<?PHP
/**
* This file displays object detail pages as fetched from museum-digital.
*
* @author Joshua Ramon Enslin <joshua@jrenslin.de>
*/
// Include functions and settings.
require_once __DIR__ . "/inc/functions.php";
// Check validity of request.
if (!isset($_GET['id']) or !is_numeric($_GET['id'])) {
echo printErrorPage("Institution does not exist.");
return;
}
// Ensure working environment for frontend.
ensureEnvironment();
$pages = loadPublicPages(); // Load overview of pages.
$contents = json_decode(queryCachePage($settings['mdVersion'] . "?t=institution&instnr=" . urlencode($_GET['id']) . "&output=json", "institution", $settings), true);
if (!$contents || (isset($contents[0]) and $contents[0] == "There is no institution with this ID yet.")) {
echo printErrorPage("Temporarily unavailable.");
return;
}
if ($settings['limitToInstitutions'] != [] and !in_array($_GET['id'], $settings['limitToInstitutions'])) {
echo printErrorPage("This object does not belong to an enabled institution.");
return;
}
/*
* Output
*/
$addToHead = '
<link rel="canonical" href="' . $settings['mdVersion'] . 'index.php?t=institution&instnr=' . $contents['institution_id'] . '" />';
echo printPublicHead($settings, $_GET['id'], $settings['pageTitle'] . " - " . $contents['institution_name'], $settings['logo'], $addToHead);
echo printPublicHeader($settings['pageTitle']);
echo printStaticPagePart("banner", "header"); // Print aside (if need be)
echo generatePublicNav($pages);
echo '
<div id="mainWrapper">
';
// Print main content
echo '
<main>';
echo drawInstitutionDetails($contents, $settings);
echo '
</main>
';
echo printStaticPagePart("aside", "aside"); // Print aside (if need be)
echo '
</div>';
echo printStaticPagePart("footer", "footer"); // Print footer (if need be)
echo printPublicEnd();
?>

View File

@ -17,7 +17,12 @@ document.addEventListener("DOMContentLoaded", function() {
"More" : "More",
"MoreAtMuseumDigital" : "museum-digital",
"ObjectAtMuseumDigital" : "Object entry at museum-digital",
"InstitutionAtMuseumDigital": "Institution at museum-digital",
"CollectionAtMuseumDigital" : "Collection at museum-digital",
"ExhibitionAtMuseumDigital" : "Exhibition at museum-digital",
"EventAtMuseumDigital" : "Event at museum-digital",
"Collection" : "Collection",
"Collections" : "Collections",
"object_material_technique" : "Material / Technique",
"object_dimensions" : "Dimensions",
"Metadata" : "Metadata",
@ -41,7 +46,12 @@ document.addEventListener("DOMContentLoaded", function() {
"More" : "Mehr",
"MoreAtMuseumDigital" : "museum-digital",
"ObjectAtMuseumDigital" : "Objekt bei museum-digital",
"InstitutionAtMuseumDigital": "Institution bei museum-digital",
"CollectionAtMuseumDigital" : "Sammlung bei museum-digital",
"ExhibitionAtMuseumDigital" : "Ausstellung bei museum-digital",
"EventAtMuseumDigital" : "Veranstaltung bei museum-digital",
"Collection" : "Sammlung",
"Collection" : "Sammlungen",
"object_material_technique" : "Material / Technik",
"object_dimensions" : "Ausmaße",
"Metadata" : "Metadaten",

View File

@ -28,6 +28,11 @@ if (!$contents || (isset($contents[0]) and $contents[0] == "There is no object w
return;
}
if ($settings['limitToInstitutions'] != [] and !in_array($contents['object_institution']['institution_id'], $settings['limitToInstitutions'])) {
echo printErrorPage("This object does not belong to an enabled institution.");
return;
}
/*
* Output
*/

View File

@ -24,12 +24,13 @@ a.navicurrent { background: #D6D6D6; }
/**********
* Simple tiles for displaying an object.
* This class also builds the base for other tiles.
*/
div.objTile { display: inline-block; width: 200px; border: 1px solid #D6D6D6; text-align: center;
transition: background .4s, box-shadow .4s; }
div.objTile > div { position: relative; padding: .5em .5em 1.5em .5em; }
div.objTile h4 { margin: 0; padding: 0 .5em; }
div.objTile h4 { margin: 0; padding: 0 .5em; text-align: center; }
div.objTile img { max-width: 198px; }
div.objTile:hover { background: #F2F2F2; box-shadow: 1px 1px 3px #D6D6D6, -1px -1px 3px #D6D6D6; }
@ -57,6 +58,12 @@ div.objDetails .objMainImg:hover { max-width: 100vw; max-height: 80vh; float: in
.metadataLine { margin-top: 2.5em; color: #666; border-top: 1px solid #D6D6D6; }
.metadataLine > span { margin-right: 2em; font-size: .95em; font-style: italic; }
/**********
* Collection tiles.
*/
.objTile.collectionTile { text-align: left; }
.objTile.collectionTile h4 { padding: 0 0; }
/*****
* Events on object detail page.
*/

View File

@ -30,6 +30,8 @@ body { margin: 0; padding: 0; font-family: sourceSansPro;
* { box-sizing: border-box; z-index: 1; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4, h5, h6 { text-align: left; }
a.buttonLike { display: inline-block; }
a.buttonLike,