From 929f205ee37da0e6db2e886680a055d2e0e78ccd Mon Sep 17 00:00:00 2001 From: Dorian Merz <merz@ub.uni-leipzig.de> Date: Fri, 17 Aug 2018 14:29:01 +0200 Subject: [PATCH] refs #13469 CHANGES on MASTER * adds getSetMultipart method * adds parent function to SolrDefaultFincTrait * translates captions of additionals --- .../RecordDriver/SolrDefaultFincTrait.php | 18 ++++ .../finc/RecordDriver/SolrMarcFincTrait.php | 100 ++++++++++++++++++ .../SolrDefault/data-additionals.phtml | 2 +- 3 files changed, 119 insertions(+), 1 deletion(-) diff --git a/module/finc/src/finc/RecordDriver/SolrDefaultFincTrait.php b/module/finc/src/finc/RecordDriver/SolrDefaultFincTrait.php index 295aa97e3cc..48e1d708447 100644 --- a/module/finc/src/finc/RecordDriver/SolrDefaultFincTrait.php +++ b/module/finc/src/finc/RecordDriver/SolrDefaultFincTrait.php @@ -292,6 +292,24 @@ trait SolrDefaultFincTrait return $params; } + public function getSetMultiPart() { + + $ids = $this->getHierarchyParentID(); + if (empty($ids)) return []; + $titles = $this->getHierarchyParentTitle(); + $result = []; + if (count($ids) === count($titles)) { + foreach ($ids as $key => $id) { + $result[] = [ + 'text' => $titles[$key], + 'id' => $id, + 'identifier' => 'Set Multipart' + ]; + } + } + return $result; + } + /** * Get the hierarchy_parent_id(s) associated with this item (empty if none). * diff --git a/module/finc/src/finc/RecordDriver/SolrMarcFincTrait.php b/module/finc/src/finc/RecordDriver/SolrMarcFincTrait.php index 1b9ca280fa9..e6b24812471 100644 --- a/module/finc/src/finc/RecordDriver/SolrMarcFincTrait.php +++ b/module/finc/src/finc/RecordDriver/SolrMarcFincTrait.php @@ -1531,6 +1531,106 @@ trait SolrMarcFincTrait return $this->addFincIDToRecord($array); } + /** + * Get specific marc information about containing items. Unflexible solution + * for UBL only implemented. + * + * @return array + * @link https://intern.finc.info/fincproject/issues/1315 + */ + public function getSetMultiPart() + { + $array = []; + $fields = [ + '773' => ['a'=>['',''], 't'=>[': ',''], 'g'=>[' ; ','']], + '490' => ['a'=>['','']], + '800' => ['a'=>['',': '], 't'=>['',''], 'v'=>[' ; ',''] ,'g'=>[' ; ','']], + '810' => ['a'=>['',': '], 't'=>['',''], 'v'=>[' ; ',''] ,'g'=>[' ; ','']], + '811' => ['a'=>['',': '], 't'=>['',''], 'v'=>[' ; ',''] ,'g'=>[' ; ','']], + '830' => ['a'=>['',''], 'v'=>[' ; ','']] + ]; + $i = 0; + + foreach ($fields as $field => $subfields) { + $related = $this->getMarcRecord()->getFields($field); + // if no entry stop + if ($related) { + // loop through all found fields + foreach ($related as $key => $line) { + // first lets look for identifiers - identifiers are vital as + // those are used to identify the text in the frontend (e.g. as + // table headers) + // so, proceed only if we have an identifier + + // lets collect the text + // https://intern.finc.info/issues/6896#note-7 + $text = []; + foreach ($subfields as $subfield => list($l_delim,$r_delim)) { + $val = $line->getSubfield($subfield); + if ($field == '773' && $subfield == 'a') { + if ($line->getIndicator(1) == 1) { + $field245 = $this->getMarcRecord()->getField('245'); + if ($sub245a = $field245->getSubfield('a')) { + $text[] = $sub245a->getData(); + } + unset($subfields['t']); + } elseif (empty($val)) { + continue; + } else { + $text[] = $l_delim.$val->getData().$r_delim; + } + } else { + if (empty($val)) continue; + if ($field == '490') { + if ($line->getIndicator(1) == 0) { + $text[] = $l_delim.$val->getData().$r_delim; + } + } elseif ($subfield == 'v' && in_array($field, ['800', '810', '811'])) { + if (!empty($val)) { + $text[] = $l_delim.$val->getData().$r_delim; + // do not use the next (and last) subfield $g, + // if $v is already set + break; + } + } else { + $text[] = $l_delim.$val->getData().$r_delim; + } + } + } + + // we can have text without links but no links without text, so + // only proceed if we actually have a value for the text + if (count($text) > 0) { + $array[$i] = [ + 'text' => implode('', $text), + 'identifier' => ($line->getSubfield('i')) + ? $line->getSubfield('i')->getData() : 'Set Multipart' + ]; + + // finally we can try to use given PPNs (from the BSZ) to + // link the record + if ($linkFields = $line->getSubfields('w')) { + foreach ($linkFields as $current) { + $text = $current->getData(); + // Extract parenthetical prefixes: + if (preg_match(self::BSZ_PATTERN, $text, $matches)) { + $array[$i]['record_id'] + = $matches[2] . $matches[3]; + if (null != ($sid = $this->getSourceID())) { + $array[$i]['source_id'] = $sid; + } + } + } + } + // at least we found some identifier and text so increment + $i++; + } + } + } + } + return $this->addFincIDToRecord($array); + } + /** * Returns notes and additional information stored in Marc 546$a. * Refs. #8509 diff --git a/themes/finc/templates/RecordDriver/SolrDefault/data-additionals.phtml b/themes/finc/templates/RecordDriver/SolrDefault/data-additionals.phtml index 8619aa16586..1e9a782ea13 100644 --- a/themes/finc/templates/RecordDriver/SolrDefault/data-additionals.phtml +++ b/themes/finc/templates/RecordDriver/SolrDefault/data-additionals.phtml @@ -4,7 +4,7 @@ <? if (isset($additional['identifier'])): ?> <tr> <th> - <?=$this->escapeHtml($additional['identifier'])?>: + <?=$this->transEsc($additional['identifier'])?>: </th> <td> <? if(isset($additional['id'])): ?> -- GitLab