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:
498
inc/mdEmbeds.php
498
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 .= '
|
||||
<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.
|
||||
*
|
||||
|
Reference in New Issue
Block a user