Skip to content

Commit

Permalink
[MAINTENANCE] Initialize metadata array with empty values in abstract…
Browse files Browse the repository at this point in the history
… Doc class (#961)

Co-authored-by: Sebastian Meyer <[email protected]>
  • Loading branch information
beatrycze-volk and sebastian-meyer committed Jun 26, 2023
1 parent 7bda98d commit d0e29da
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 59 deletions.
41 changes: 41 additions & 0 deletions Classes/Common/Doc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
*
Expand Down
32 changes: 3 additions & 29 deletions Classes/Common/IiifManifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
33 changes: 3 additions & 30 deletions Classes/Common/MetsDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit d0e29da

Please sign in to comment.