From d0e29dae1d0c9d44d0e5ba19f5ea0dc54e0d4751 Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Mon, 26 Jun 2023 18:26:40 +0200 Subject: [PATCH] [MAINTENANCE] Initialize metadata array with empty values in abstract Doc class (#961) Co-authored-by: Sebastian Meyer --- Classes/Common/Doc.php | 41 +++++++++++++++++++++++++++++++++ Classes/Common/IiifManifest.php | 32 +++---------------------- Classes/Common/MetsDocument.php | 33 +++----------------------- 3 files changed, 47 insertions(+), 59 deletions(-) diff --git a/Classes/Common/Doc.php b/Classes/Common/Doc.php index 032bab5e6..73cd93c89 100644 --- a/Classes/Common/Doc.php +++ b/Classes/Common/Doc.php @@ -889,6 +889,47 @@ public function registerNamespaces(&$obj) } } + /** + * Initialize metadata array with empty values. + * + * @access protected + * + * @param string $format of the document eg. METS + * + * @return array + */ + protected function initializeMetadata($format) { + return [ + 'title' => [], + 'title_sorting' => [], + 'description' => [], + 'author' => [], + 'holder' => [], + 'place' => [], + 'year' => [], + 'prod_id' => [], + 'record_id' => [], + 'opac_id' => [], + 'union_id' => [], + 'urn' => [], + 'purl' => [], + 'type' => [], + 'volume' => [], + 'volume_sorting' => [], + 'date' => [], + 'license' => [], + 'terms' => [], + 'restrictions' => [], + 'out_of_print' => [], + 'rights_info' => [], + 'collection' => [], + 'owner' => [], + 'mets_label' => [], + 'mets_orderlabel' => [], + 'document_format' => [$format] + ]; + } + /** * This returns $this->cPid via __get() * diff --git a/Classes/Common/IiifManifest.php b/Classes/Common/IiifManifest.php index 687dc5d01..c56ae0033 100644 --- a/Classes/Common/IiifManifest.php +++ b/Classes/Common/IiifManifest.php @@ -615,35 +615,9 @@ public function getMetadata($id, $cPid = 0) if (!empty($this->metadataArray[$id]) && $this->metadataArray[0] == $cPid) { return $this->metadataArray[$id]; } - // Initialize metadata array with empty values. - // TODO initialize metadata in abstract class - $metadata = [ - 'title' => [], - 'title_sorting' => [], - 'author' => [], - 'place' => [], - 'year' => [], - 'prod_id' => [], - 'record_id' => [], - 'opac_id' => [], - 'union_id' => [], - 'urn' => [], - 'purl' => [], - 'type' => [], - 'volume' => [], - 'volume_sorting' => [], - 'date' => [], - 'license' => [], - 'terms' => [], - 'restrictions' => [], - 'out_of_print' => [], - 'rights_info' => [], - 'collection' => [], - 'owner' => [], - 'mets_label' => [], - 'mets_orderlabel' => [], - 'document_format' => ['IIIF'], - ]; + + $metadata = $this->initializeMetadata('IIIF'); + $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) ->getQueryBuilderForTable('tx_dlf_metadata'); // Get hidden records, too. diff --git a/Classes/Common/MetsDocument.php b/Classes/Common/MetsDocument.php index 1f9d63660..d2b705134 100644 --- a/Classes/Common/MetsDocument.php +++ b/Classes/Common/MetsDocument.php @@ -442,36 +442,9 @@ public function getMetadata($id, $cPid = 0) ) { return $this->metadataArray[$id]; } - // Initialize metadata array with empty values. - $metadata = [ - 'title' => [], - 'title_sorting' => [], - 'description' => [], - 'author' => [], - 'holder' => [], - 'place' => [], - 'year' => [], - 'prod_id' => [], - 'record_id' => [], - 'opac_id' => [], - 'union_id' => [], - 'urn' => [], - 'purl' => [], - 'type' => [], - 'volume' => [], - 'volume_sorting' => [], - 'date' => [], - 'license' => [], - 'terms' => [], - 'restrictions' => [], - 'out_of_print' => [], - 'rights_info' => [], - 'collection' => [], - 'owner' => [], - 'mets_label' => [], - 'mets_orderlabel' => [], - 'document_format' => ['METS'], - ]; + + $metadata = $this->initializeMetadata('METS'); + $mdIds = $this->getMetadataIds($id); if (empty($mdIds)) { // There is no metadata section for this structure node.