Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MAINTENANCE] Initialize metadata array with empty values in abstract Doc class #961

Merged
merged 3 commits into from
Jun 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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