diff --git a/apiMirror.php b/apiMirror.php index 5e0a49e..7cc8a27 100644 --- a/apiMirror.php +++ b/apiMirror.php @@ -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; diff --git a/collection.php b/collection.php new file mode 100644 index 0000000..c121af8 --- /dev/null +++ b/collection.php @@ -0,0 +1,71 @@ + + */ + +// 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 = ' + '; + +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 ' +
+'; + +// Print main content +echo ' +
'; + +echo drawCollectionDetails($contents, $settings); + +echo ' +
+'; + +echo printStaticPagePart("aside", "aside"); // Print aside (if need be) + +echo ' +
'; + +echo printStaticPagePart("footer", "footer"); // Print footer (if need be) + +echo printPublicEnd(); + +?> diff --git a/edit/inc/functions.php b/edit/inc/functions.php index 5adb428..c3c36ee 100644 --- a/edit/inc/functions.php +++ b/edit/inc/functions.php @@ -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(); } diff --git a/edit/js/main.js b/edit/js/main.js index 2b4b85e..05b5d01 100644 --- a/edit/js/main.js +++ b/edit/js/main.js @@ -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 diff --git a/edit/page.php b/edit/page.php index ca296ca..ac49142 100644 --- a/edit/page.php +++ b/edit/page.php @@ -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'); } } diff --git a/edit/settings.php b/edit/settings.php index 9a1abb9..5b9871c 100644 --- a/edit/settings.php +++ b/edit/settings.php @@ -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 ' ' . generateHelpToolTip("helpURL", $translations['url'], $translations['helpURL']) . ' + + + + + + + ' . generateHelpToolTip("helpSettingsUsedCSS", $translations['settingsUsedCSS'], $translations['helpSettingsUsedCSS']) . ' + + + + + + + + + ' . generateHelpToolTip("helpHideInstitution", $translations['hideInstitution'], $translations['helpHideInstitution']) . ' + + @@ -130,6 +157,13 @@ echo ' ' . generateHelpToolTip("helpCacheRefreshInterval", $translations['cacheRefreshInterval'], $translations['helpCacheRefreshInterval']) . ' + + + + + ' . generateHelpToolTip("helpLimitToInstitutions", $translations['limitToInstitutions'], $translations['helpLimitToInstitutions']) . ' + + diff --git a/edit/themes/default/default.css b/edit/themes/default/default.css index b5cca4b..735226f 100644 --- a/edit/themes/default/default.css +++ b/edit/themes/default/default.css @@ -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; } } diff --git a/edit/translations/en.php b/edit/translations/en.php index 33af482..e02c6ab 100644 --- a/edit/translations/en.php +++ b/edit/translations/en.php @@ -51,6 +51,13 @@ $translations = [
  • Using a high value, means data could be slightly outdated, but makes loading much faster.
  • ", + "settingsUsedCSS" => "Theme", + "helpSettingsUsedCSS" => "

    Select the used theme. New themes can be installed using FTP.

    ", + "hideInstitution" => "Hide institution", + "helpHideInstitution" => "

    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.

    ", + "limitToInstitutions" => "Limit to institutions", + "helpLimitToInstitutions" => "

    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.

    +

    Enter IDs of institutions separated by commas.

    ", "IDatMD" => "ID at museum-digital", "embedFromMD" => "Embed from museum-digital", diff --git a/event.php b/event.php new file mode 100644 index 0000000..f372648 --- /dev/null +++ b/event.php @@ -0,0 +1,71 @@ + + */ + +// 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 = ' + '; + +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 ' +
    +'; + +// Print main content +echo ' +
    '; + +echo drawEventDetails($contents, $settings); + +echo ' +
    +'; + +echo printStaticPagePart("aside", "aside"); // Print aside (if need be) + +echo ' +
    '; + +echo printStaticPagePart("footer", "footer"); // Print footer (if need be) + +echo printPublicEnd(); + +?> diff --git a/exhibition.php b/exhibition.php new file mode 100644 index 0000000..765d4a8 --- /dev/null +++ b/exhibition.php @@ -0,0 +1,71 @@ + + */ + +// 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 = ' + '; + +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 ' +
    +'; + +// Print main content +echo ' +
    '; + +echo drawExhibitionDetails($contents, $settings); + +echo ' +
    +'; + +echo printStaticPagePart("aside", "aside"); // Print aside (if need be) + +echo ' +
    '; + +echo printStaticPagePart("footer", "footer"); // Print footer (if need be) + +echo printPublicEnd(); + +?> diff --git a/inc/functions.php b/inc/functions.php index f685c8b..2fafc08 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -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" ], diff --git a/inc/mdEmbeds.php b/inc/mdEmbeds.php index 5d5d4e6..e772dca 100644 --- a/inc/mdEmbeds.php +++ b/inc/mdEmbeds.php @@ -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 .= '
    -

    ' . $contents['object_name'] . '

    +

    ' . $contents['object_name'] . '

    '; + if (!$settings['hideInstitution']) $output .= ' + ' . $contents['object_institution']['institution_name'] . ''; + $output .= '
    ' . $contents['object_name'] . ' @@ -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 = ' +
    + '; + + if (isset($contents['institution_image']) and $contents['institution_image']) { + $output .= ' + '; + } + + $output .= ' +

    ' . $contents['institution_name'] . '

    +

    ' . $contents['institution_description'] . '

    + '; + + $output .= ' +
    '; + if ($contents['institution_street']) $output .= $contents['institution_street'] . '
    '; + if ($contents['institution_zipcode']) $output .= $contents['institution_zipcode'] . " " . $contents['institution_place'] . "
    "; + if ($contents['institution_telnr']) $output .= "" . $contents['institution_telnr'] . "
    "; + $output .= ' +
    '; + + if (count($contents['collections']) >= 1) { + $output .= ' +

    + '; + } + + $output .= ' +

    + + +

    + +
    + '; + + 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 = ' +
    + '; + + if (isset($contents['institution_image']) and $contents['institution_image']) { + $output .= ' + '; + } + + $output .= ' +
    + +

    ' . $contents['institution_name'] . '

    +

    + ' . $contents['institution_street'] . ' + ' . $contents['institution_zipcode'] . " " . $contents['institution_place'] . '
    +

    + +
    + + ' . $contents['institution_name'] . ' +
    + +
    + +
    + '; + + 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 = ' +
    + '; + + if (isset($contents['collection_image']) and $contents['collection_image']) { + $output .= ' + '; + } + + $output .= ' +

    ' . $contents['collection_name'] . '

    +

    ' . $contents['collection_description'] . '

    + '; + if (!$settings['hideInstitution']) $output .= ' + ' . $contents['collection_institution']['institution_name'] . ' + '; + + $output .= ' +

    + + +

    + +
    + '; + + 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 = ' +
    + '; + + if (isset($contents['collection_image']) and $contents['collection_image']) { + $output .= ' + '; + } + + $output .= ' +
    + +

    ' . $contents['collection_name'] . '

    +

    ' . createTextSnippet($contents['collection_description'], 180) . '

    + '; + if (!$settings['hideInstitution']) $output .= ' + ' . $contents['collection_institution']['institution_name'] . ''; + + $output .= ' + +
    + + ' . $contents['collection_name'] . ' +
    + +
    + +
    + '; + + 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 = ' +
    + '; + + if (isset($contents['image']) and $contents['image']) { + $output .= ' + '; + } + + $output .= ' + +

    ' . $contents['name'] . '

    + +

    + - +

    + +

    ' . $contents['description'] . '

    + '; + $output .= ' +

    + ' . $contents['institution_name'] . ' (' . $contents['institution_ort'] . ') +

    '; + + $output .= ' +

    + + +

    + +
    + '; + + 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 = ' +
    + '; + + if (isset($contents['image']) and $contents['image']) { + $output .= ' + '; + } + + $output .= ' +
    + +

    ' . $contents['name'] . '

    + '; + if (!$settings['hideInstitution']) $output .= ' + ' . $contents['institution_name'] . ''; + + $output .= ' + +
    + + ' . $contents['name'] . ' +
    + +
    + +
    + '; + + 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 = ' +
    + '; + + if (isset($contents['image']) and $contents['image']) { + $output .= ' + '; + } + + $output .= ' + +

    ' . $contents['name'] . '

    + +

    + - +

    + +

    ' . $contents['description'] . '

    + '; + $output .= ' +

    + ' . $contents['institution_name'] . ' (' . $contents['institution_ort'] . ') +

    '; + + $output .= ' +

    + + +

    + +
    + '; + + 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 = ' +
    + '; + + if (isset($contents['image']) and $contents['image']) { + $output .= ' + '; + } + + $output .= ' +
    + +

    ' . $contents['name'] . '

    + '; + if (!$settings['hideInstitution']) $output .= ' + ' . $contents['institution_name'] . ''; + + $output .= ' + +
    + + ' . $contents['name'] . ' +
    + +
    + +
    + '; + + 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. * diff --git a/inc/standardHTML.php b/inc/standardHTML.php index a83850a..70aeb89 100644 --- a/inc/standardHTML.php +++ b/inc/standardHTML.php @@ -21,14 +21,14 @@ function printPublicHead(array $settings, string $page = "home", string $title = "Home", string $icon = "", $additional = ""):string { $output = ' - + ' . $title . ' - + '; diff --git a/institution.php b/institution.php new file mode 100644 index 0000000..377e52b --- /dev/null +++ b/institution.php @@ -0,0 +1,71 @@ + + */ + +// 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 = ' + '; + +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 ' +
    +'; + +// Print main content +echo ' +
    '; + +echo drawInstitutionDetails($contents, $settings); + +echo ' +
    +'; + +echo printStaticPagePart("aside", "aside"); // Print aside (if need be) + +echo ' +
    '; + +echo printStaticPagePart("footer", "footer"); // Print footer (if need be) + +echo printPublicEnd(); + +?> diff --git a/js/main.js b/js/main.js index 9f3cfda..9d6e913 100644 --- a/js/main.js +++ b/js/main.js @@ -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", diff --git a/object.php b/object.php index 10e2811..5845463 100644 --- a/object.php +++ b/object.php @@ -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 */ diff --git a/themes/default/mdEmbeds.css b/themes/default/mdEmbeds.css index 86488e7..3eb715b 100644 --- a/themes/default/mdEmbeds.css +++ b/themes/default/mdEmbeds.css @@ -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. */ diff --git a/themes/default/default.css b/themes/default/theme.css similarity index 99% rename from themes/default/default.css rename to themes/default/theme.css index 5f62db0..1f11512 100644 --- a/themes/default/default.css +++ b/themes/default/theme.css @@ -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,