diff --git a/fid/languages/fid/de.ini b/fid/languages/fid/de.ini index 0dfa316adca32c7b5acd0348608cd319079fe8d5..34a6e70fbe19b7db84532d1b9be522bcf04641b0 100644 --- a/fid/languages/fid/de.ini +++ b/fid/languages/fid/de.ini @@ -228,3 +228,13 @@ export_orders = "Bestellungen" required_fields_note = Mit einem * markierte Felder müssen ausgefüllt werden. user_list_empty = Die Nutzerliste ist leer. + +#24276 +fern_url_swb = https://fernleihe.boss.bsz-bw.de/Record/%%gvi%%#interlibraryloan +fern_url_bvb = https://sfx.bib-bvb.de/sfx_bvb?ctx_enc=info:ofi/enc:UTF-8&ctx_ver=Z39.88-2004&url_ctx_fmt=info:ofi/fmt:kev:Amtx:ctx&rft_id=info:gvi/%%gvi%%&rft.isbn=%%isbn%%&req_dat=%%isil%%&svc.ill=yes +fern_url_kobv = https://flbs.kobv.de/flbk/login?k2_doc_nr=%%gvi%%&isil=%%isil%% +fern_url_gbv = https://kxpt.k10plus.de/DB=2.1/FIDILL?FID-ID=%%gvi%% +fern_url_hebis = https://portal.hebis.de/fidfl/%%gvi%%/%%isil%% +fern_url_hbz = https://openurlgw.hbz-nrw.de/gw?ctx_enc=info:ofi/enc:UTF-8&ctx_ver=Z39.88-2004&url_ctx_fmt=info:ofi/fmt:kev:Amtx:ctx&rft_id=info:gvi/%%gvi%%&rft.isbn=%%isbn%%&req_dat=%%isil%%&svc.ill=yes +fern_url_gen = https://primogvi.kobv.de/fidfl?ctx_ver=Z39.88-2004&svc.ill=yes&rft_id=info:gvi/%%gvi%% +fern_txt_button = Fernleihe ihres Verbundes diff --git a/fid/languages/fid/en.ini b/fid/languages/fid/en.ini index 1024910e03f8a36a156d5de5e312e5d5461f7979..5e57bcce8ebe173ee5e8c1a3a67d2fa2b1c18146 100644 --- a/fid/languages/fid/en.ini +++ b/fid/languages/fid/en.ini @@ -223,4 +223,7 @@ export_data = "additional Data" export_orders = "Orders" required_fields_note = All fields marked with an asterisk * are required. -user_list_empty = The user list is empty. \ No newline at end of file +user_list_empty = The user list is empty. + +#24276 +fern_txt_button = Interlibrary loan of your network diff --git a/module/finc/src/finc/Controller/CustomTraits/GviRecordTrait.php b/module/finc/src/finc/Controller/CustomTraits/GviRecordTrait.php new file mode 100644 index 0000000000000000000000000000000000000000..c09d8d5c65b3bce56d762ae5ac09c9ffa33187d6 --- /dev/null +++ b/module/finc/src/finc/Controller/CustomTraits/GviRecordTrait.php @@ -0,0 +1,104 @@ +<?php +/** + * finc specific model for MARC records with a fullrecord in Solr. + * + * PHP version 7 + * + * Copyright (C) Leipzig University Library 2023. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * @category VuFind + * @package RecordDrivers + * @author JP Kanter <kanter@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/vufind2:record_drivers Wiki + */ +namespace finc\Controller\CustomTraits; + +/** + * fid specific model for MARC records with a fullrecord in Solr. + * + * @category VuFind + * @package Controller + * @author JP Kanter <kanter@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/vufind2:record_drivers Wiki + */ +trait GviRecordTrait +{ + /** + * returns all ctrlnums from either the solr field or marc data + * + * @return array might be an empty array if nothing can be found + * @throws \File_MARC_Exception + */ + public function getCtrlnum()//php_8//: array + { + $ctrls = []; + // trying to source ctrlnums from either direct solr fields or the corresponding marc set + if (isset($this->fields['ctrlnum'])) { + $ctrls = $this->fields['ctrlnum']; + } elseif ($field = $this->getMarcRecord()->getFields('35')) { + foreach ($field as $item) { + if ($subfield = $item->getSubfield('a')) { + $ctrls[] = $subfield->getData(); + } + } + } + return $ctrls; + } + + /** + * Extracts a GVI-ID from the data we got, there might be none available or even more than one, in case of + * multiple instances, the most fitting one gets chosen + * + * @param string $isil ISIL of the Network the user is residing in, can be empty + * + * @return false|string complete GVI ID, eg. (DE-627)452235435 + */ + public function getGviId($isil="")//php_8//: false|string + { + if (empty($ctrls = $this->getCtrlnum())) { //abort misssion without ctrlnum + return false; + } + + // extracts all possible GVI ids out of the ctrlnum field, it's nothing more than creating a dictionary + $ctrl_arr = []; + foreach ($ctrls as $row) { + if (preg_match('{(\(.+\))(.+)}', $row, $re)) { + $ctrl_arr[$re[1]] = $re[0]; # '(DE-602)' => "(DE-602)452235435" + } + } + + // Special Case for 604 because those BV-Numbers seem to work a bit + foreach ($ctrl_arr as $value) { + if (preg_match('{(\(DE-604\)BV)(\d+)}', $value, $re)) { + if ($isil == "bvb") { + return $re[0]; + } + } + if (preg_match('{(\(DE-605\)HT)(\d+)}', $value, $re)) { + if ($isil == "hbz") { + return $re[0]; + } + } + } + if (isset($ctrl_arr['(DE-627)'])) { + return $ctrl_arr['(DE-627)']; + } + + return false; // default false in case we get here + } +} diff --git a/themes/fid/templates/get-it-box/interlibraryloan.phtml b/themes/fid/templates/get-it-box/interlibraryloan.phtml new file mode 100644 index 0000000000000000000000000000000000000000..71878b1a4c4e17f7377cf1215ee3109eb0d3abd8 --- /dev/null +++ b/themes/fid/templates/get-it-box/interlibraryloan.phtml @@ -0,0 +1,36 @@ +<!-- fid: get-it-box - interlibraryloan --> +<?php +/** + * origin: -- + * + * called by view helper/controller: HoldingsILS->getTemplate() (RecordTab) + * enriched by GetIt.php, implemented by get-it-box/notice.phtml + * + * usage: + * - displays, if available, inter library loan links in logged in status + * - url: /Record/[id] + * + * parent template: -- + * + * configured in: getitbox.yaml + */ +?> +<?php if (isset($getitConfig['showFernleihe']) && $getitConfig['showFernleihe']): ?> + <?php + $userDetails = $getitConfig['client']->requestUserDetails(); + $libdDetails = $getitConfig['client']->requestLibraryById($userDetails->getHomeLibrary()); + + $isil = $libdDetails->getIsil(); + $isbn = implode($this->driver->getISBNs()); + $net = $libdDetails->getNetwork(); + $gvi = $this->driver->tryMethod('getGviId', [$net]); + ?> + <?php if ($gvi): ?> + <h3><?=$this->translate("Interlibrary Loans")?></h3> + <a href="<?=$this->translate("fid::fern_url_{$net}", ['%%isbn%%' => $isbn, '%%gvi%%' => $gvi, '%%isil%%' => $isil]);?>"> + <?=$this->translate('fid::fern_txt_button')?> + </a> + <br> + <?php endif; ?> +<?php endif; ?> +<!-- fid: get-it-box - interlibraryloan - END -->