configSetting("MetadataSchemaId")); $FieldGroups = $Plugin->getPhotoDisplayFields(); foreach ($FieldGroups as $FieldGroup) { $Details = []; foreach ($FieldGroup as $FieldName) { $Label = $FieldName; $Value = $Record->get($FieldName); if (is_null($Value) || (is_array($Value) && empty($Value))) { continue; } $Field = $Schema->getField($FieldName); switch ($Field->type()) { case MetadataSchema::MDFTYPE_NUMBER: switch ($FieldName) { case "Height": case "Width": $Label = "Image ".$Label; $Value = $Value ? number_format($Value)."px" : "-"; break; case "File Size in KB": $Label = "File Size"; $Value = $Value ? number_format($Value)." KB" : "-"; break; default: if (is_array($Value)) { $Value = join("
\n", $Value); } break; } break; case MetadataSchema::MDFTYPE_REFERENCE: foreach ($Value as $ReferenceId) { $RefRecord = new Record((int)$ReferenceId); $ReferenceUrl = $RefRecord->getViewPageUrl(); $ReferenceTitle = htmlspecialchars($RefRecord->getMapped("Title")); $Value = "".$ReferenceTitle.""; } break; case MetadataSchema::MDFTYPE_OPTION: case MetadataSchema::MDFTYPE_CONTROLLEDNAME: case MetadataSchema::MDFTYPE_TREE: $Urls = []; foreach ($Value as $ValueId => $ValueName) { $Urls[] = getSearchLinkedVersionOfValue( $ValueName, $Field ); } $Value = join("
\n", $Urls); break; default: if (is_array($Value)) { $Value = join("
\n", $Value); } break; } $Details[] = [ $Label, $Value ?? "-" ]; } if (count($Details)) { $DetailsTable = new HtmlTable(); $DetailsTable->setTableClass("table table-borderless bg-light"); $DetailsTable->addRowsWithHeaders($Details); $DetailsTables[] = $DetailsTable; } } return $DetailsTables; } /** * Get version of string value surrounded by tag linking it to search * results for value. * @param string $Value Value to link. * @param MetadataField $Field Field from which the value comes from. * @return string Value with search results link tag added. */ function getSearchLinkedVersionOfValue( string $Value, MetadataField $Field ): string { $SearchParams = new SearchParameterSet(); $SearchParams->addParameter("=".$Value, $Field); $SearchUrl = "index.php?P=SearchResults&".$SearchParams->UrlParameterString(); # italicize controlled name and tree values $AnchorValue = htmlspecialchars($Value); if ($Field->type() == MetadataSchema::MDFTYPE_CONTROLLEDNAME || $Field->type() == MetadataSchema::MDFTYPE_TREE) { $AnchorValue = "" . $AnchorValue . ""; } $Title = "Search for records where ".$Field->getDisplayName() ." is \"".htmlspecialchars($Value)."\""; return "" .$AnchorValue.""; } /** * Get HTML to display a photo. * @param Image $Photo Photo to display. * @return string HTML */ function getPhotoHtml(Image $Photo): string { # determine size of photo to display $Plugin = PhotoLibrary::getInstance(); $ImageSizeName = $Plugin->getConfigSetting("ImageSize") ?? "mv-image-largesquare"; # if IIIFImageViewer plugin is ready, use it to generate a fancy viewer $UseIIIF = PluginManager::getInstance()->pluginReady("IIIFImageViewer"); if ($UseIIIF) { return \Metavus\Plugins\IIIFImageViewer::getInstance() ->getHtmlForImageViewer($Photo->id(), $ImageSizeName); } # otherwise use Image's default html return $Photo->getHtml($ImageSizeName); } # ----- SETUP ---------------------------------------------------------------- $AF = ApplicationFramework::getInstance(); # make sure CSS styles specific to our page are loaded $AF->requireUIFile("P_PhotoGallery.css"); # if error then display error message and exit if (isset($H_ErrMsg)) { ?>

userCanEdit($User)) { $EditLink = $H_Record->getEditPageUrl(); } $DownloadOriginalImageButton = new HtmlButton("Download Original Image"); $DownloadOriginalImageButton->setIcon("Download.svg"); $DownloadOriginalImageButton->setLink("index.php?P=P_PhotoLibrary_DisplayPhoto&ID=" . $H_Record->id() . "&DL=1"); # ----- DISPLAY -------------------------------------------------------------- $AF->setPageTitle("Display Photo"); ?>

## getMapped("Title") ?>

getButtonsForPage() as $Button) { print $FRHelper->getButtonHtml( $Button["Label"], $Button["Link"], $Button["Title"], $Button["IconName"], $Button["AdditionalCssClasses"], $Button["Attributes"] ); } if (isset($EditLink)) { print $FRHelper->getButtonHtml("Edit", $EditLink, "Edit", "Pencil"); } ?>
getMapped("Description") ?>
getHtml() ?>
getHtml(); ?>