From 9e5428b649960735d5e02823a7c10ca37a78dc4d Mon Sep 17 00:00:00 2001 From: Alexander Purr <purr@ub.uni-leipzig.de> Date: Fri, 28 Aug 2020 13:41:40 +0200 Subject: [PATCH] refs #18227 [finc] adding BK notation for displaying on record details via RecordDataFormatterFactory * adjust marc driver method * add templates (copied and improved from fid_bbi) * add label translation * remove bk notation search link, because search type and solr field missing --- local/languages/de.ini | 2 + local/languages/en.ini | 4 +- .../finc/RecordDriver/SolrMarcFincTrait.php | 55 +++++++++++++------ .../RecordDriver/DefaultRecord/data-bk.phtml | 26 +++++++++ .../RecordDriver/DefaultRecord/link-bk.phtml | 1 + 5 files changed, 71 insertions(+), 17 deletions(-) create mode 100644 themes/finc/templates/RecordDriver/DefaultRecord/data-bk.phtml create mode 100644 themes/finc/templates/RecordDriver/DefaultRecord/link-bk.phtml diff --git a/local/languages/de.ini b/local/languages/de.ini index 33b2bf08b83..a57297d82b6 100644 --- a/local/languages/de.ini +++ b/local/languages/de.ini @@ -2031,3 +2031,5 @@ record_from_cache = "Dieser Datensatz ist nicht mehr im Katalog vorhanden. Event search_cached_record = "Nach "%%title_full%%" suchen." search_cached_record_by_isn = "Per %%type%% suchen" search_cached_record = "Nach "%%title_full%%" suchen." + +BK = "BK-Notation" \ No newline at end of file diff --git a/local/languages/en.ini b/local/languages/en.ini index 2bb335bd894..c9fa86188ee 100644 --- a/local/languages/en.ini +++ b/local/languages/en.ini @@ -2106,4 +2106,6 @@ fine_date_short = "Fine Date" ; #9016, #17375 record_from_cache = "This record is no longer present in the catalogue. Probably it has been replaced by another record." -search_cached_record = "Search for "%%title_full%%."" \ No newline at end of file +search_cached_record = "Search for "%%title_full%%."" + +BK = "BK Notation" \ No newline at end of file diff --git a/module/finc/src/finc/RecordDriver/SolrMarcFincTrait.php b/module/finc/src/finc/RecordDriver/SolrMarcFincTrait.php index 74fc5a99320..b30d58822ae 100644 --- a/module/finc/src/finc/RecordDriver/SolrMarcFincTrait.php +++ b/module/finc/src/finc/RecordDriver/SolrMarcFincTrait.php @@ -2153,22 +2153,45 @@ trait SolrMarcFincTrait { $array = []; - $bkl = $this->getMarcRecord()->getFields('084'); - // if not return void value - if (!$bkl) { - return $array; - } // end if - foreach ($bkl as $key => $line) { - // if subfield with bkl exists - if ($line->getSubfield('2') - && ($line->getSubfield('2')->getData() == 'bkl') - ) { - // get bkl - if ($line->getSubfield('a')) { - $array[] = $line->getSubfield('a')->getData(); - } // end if subfield a - } // end if subfield 2 - } // end foreach + // getting contens from marc 936 + $fields = $this->getMarcRecord()->getFields('936'); + if ($fields) { + foreach ($fields as $line) { + if ($line->getIndicator('1') == 'b' && + $line->getIndicator('2') == 'k') { + if ($bkl = $line->getSubfield('a')) { + $subarray = []; + // get bkl + $subarray['bk'] = $bkl->getData(); + // get bkl nomination + if ($names = $line->getSubfields('j')) { + foreach ($names as $i => $name) + $subarray['names'][] = $name->getData(); + } + $array[] = $subarray; + } + } + } + } + + // getting contens from marc 084 if array is still empty + if (empty($array)) { + $fields = $this->getMarcRecord()->getFields('084'); + if ($fields) { + foreach ($fields as $line) { + // if subfield with bkl exists + if ($line->getSubfield('2') + && ($line->getSubfield('2')->getData() == 'bkl') + ) { + // get bkl + if ($bkl = $line->getSubfield('a')) { + $array[]['bk'] = $bkl->getData(); + } + } + } + } + } + return $array; } diff --git a/themes/finc/templates/RecordDriver/DefaultRecord/data-bk.phtml b/themes/finc/templates/RecordDriver/DefaultRecord/data-bk.phtml new file mode 100644 index 00000000000..d7b19e2baab --- /dev/null +++ b/themes/finc/templates/RecordDriver/DefaultRecord/data-bk.phtml @@ -0,0 +1,26 @@ +<!-- finc: RecordDriver - SolrMarc - data-bk --> +<? if (!(empty($data))): ?> +<? $i = 0; foreach ($data as $item): ?> + <?= ($i++ == 0) ? '' : '<br>'; ?> + <?php //ToDo: add link to embed bk notation search via search type on upcoming solr field + /* + <a title="<?=$this->escapeHtmlAttr($item["bk"])?>" href="<?=$this->record($this->driver)->getLink('bk', $item["bk"])?>" rel="nofollow"> + <?=trim($this->escapeHtml($item["bk"]))?> + </a> + */ ?> + <?php //ToDo: remove after adding search link ↑ ?> + <?=trim($this->escapeHtml($item["bk"]))?> + <?php + if (isset($item["names"])) { + $output = ''; + $j = 0; + foreach ($item["names"] as $name) { + $output .= ($j++ == 0) ? '' : ', '; + $output .= $this->escapeHtml($name); + } + echo $output; + } + ?> +<? endforeach; ?> +<? endif; ?> +<!-- finc: RecordDriver - SolrMarc - data-bk - END --> \ No newline at end of file diff --git a/themes/finc/templates/RecordDriver/DefaultRecord/link-bk.phtml b/themes/finc/templates/RecordDriver/DefaultRecord/link-bk.phtml new file mode 100644 index 00000000000..178be2e908f --- /dev/null +++ b/themes/finc/templates/RecordDriver/DefaultRecord/link-bk.phtml @@ -0,0 +1 @@ +<?=$this->url('search-results')?>?lookfor=%22<?=urlencode($this->lookfor)?>%22&type=bk \ No newline at end of file -- GitLab