From c0e70cbda9433252ec2b372940916475c843bbbb Mon Sep 17 00:00:00 2001 From: Robert Lange <robert.lange@uni-leipzig.de> Date: Thu, 17 Dec 2020 15:42:24 +0100 Subject: [PATCH] refs #18657 [finc] add Marc 533 - Reproduction Note to Publication Details * prepend type of reproduction if set * eventually outsource new helper method $getSubfieldLinesConcat to SolrMarcFinc later --- .../finc/RecordDriver/SolrMarcFincTrait.php | 41 +++++++++++-------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/module/finc/src/finc/RecordDriver/SolrMarcFincTrait.php b/module/finc/src/finc/RecordDriver/SolrMarcFincTrait.php index ae53d4e3012..0d2d75d3d67 100644 --- a/module/finc/src/finc/RecordDriver/SolrMarcFincTrait.php +++ b/module/finc/src/finc/RecordDriver/SolrMarcFincTrait.php @@ -2319,14 +2319,22 @@ trait SolrMarcFincTrait } /** + * Get an array of publication detail lines combining information from Marc 260, 264, 533 * + * @return array */ public function getPublicationDetails() { $places = $names = $dates = []; - foreach (array('260','264') as $pos => $field_name) { + + $getSubfieldLinesConcat = function ($field, $code, $separator) { + return implode($separator, array_map(function ($elem) {return $elem->getData();}, $field->getSubfields($code) ?? [])); + }; + + // getting contents from marc 260 and 264 + foreach (['260','264'] as $pos => $field_name) { if ($fields = $this->getMarcRecord()->getFields($field_name)) { foreach ($fields as $field) { // for MARC $264 if indicator2 equals 1 we have publication details @@ -2334,29 +2342,30 @@ trait SolrMarcFincTrait if ($pos === '264' && $field->getIndicator('2') !== '1') { continue; } - foreach (array( + foreach ([ 'places' => 'a', 'names' => 'b', 'dates' => 'c' - ) as $key => $sub_name) { - if ($lines = $field->getSubfields($sub_name)) { - ${$key}[] = implode( - ', ', - array_map( - function ($elem) { - return $elem->getData(); - }, - $lines - ) - ); - } else { - ${$key}[] = ''; - } + ] as $key => $sub_name) { + ${$key}[] = $getSubfieldLinesConcat($field, $sub_name, ', '); } } } } + // getting (additional) contents from marc 533 - Reproduction Note (https://www.loc.gov/marc/bibliographic/bd533.html) + if ($fields = $this->getMarcRecord()->getFields('533')) { + $mapping = ['type' => 'a', 'place' => 'b', 'name' => 'c', 'date' => 'd']; + foreach ($fields as $field) { + foreach ($mapping as $key => $sub_name) { + ${$key} = $getSubfieldLinesConcat($field, $sub_name, ', '); + } + $places[] = (empty($type) ? '' : $type . '. ') . $place ?? ''; + $names[] = $name ?? ''; + $dates[] = $date ?? ''; + } + } + $i = 0; $retval = []; while (isset($places[$i]) || isset($names[$i]) || isset($dates[$i])) { -- GitLab