diff --git a/local/config/vufind/searches.ini b/local/config/vufind/searches.ini index d55eda57d759b3414ead0fb607a0c3028421fd3f..b46a0108273171f8bd52b31b9042b6ab25bd9bc8 100644 --- a/local/config/vufind/searches.ini +++ b/local/config/vufind/searches.ini @@ -62,6 +62,8 @@ default_noresults_recommend[] = SwitchQuery ;default_noresults_recommend[] = SwitchQuery:::fuzzy ;default_noresults_recommend[] = SpellingSuggestions default_noresults_recommend[] = RemoveFilters +; InterlibraryLoan: +default_noresults_recommend[] = InterlibraryLoan:"https://fernleihe.boss.bsz-bw.de/Search/Results?lookfor=<QUERY>" ; Set this to true in order to highlight keywords from the search query when they ; appear in fields displayed in search results. @@ -405,6 +407,15 @@ CallNumber = callnumber-sort ; suggesting that the user try switching to [field]. [field description] ; is the human-readable description of [field]. Default values are ; 'AllFields' and 'All Fields' respectively. +; InterlibraryLoan:[URL template] +; Shows a link to an interlibrary loan site. The [URL template] is an URL +; with a placeholder <QUERY> (case sensitive) that gets replaced by the +; user's search query. E.g: +; +; http://example.com/interlibraryloan?q=<QUERY>&foo=bar +; +; The search query will be encoded via `rawurlencode` (RFC 3986) before +; inserted into the url template. ; ; You can build your own recommendations modules if you wish. See the developer's ; guide here: diff --git a/local/languages/de.ini b/local/languages/de.ini index fdd1f1f19490274583186f0cf3db61b74e438e15..3c2577c93378759a286e50d4be6ffc9e0d849894 100644 --- a/local/languages/de.ini +++ b/local/languages/de.ini @@ -338,6 +338,7 @@ Interlibrary loan = "Fernleihe" Interlibraryloans = "Fernleihe" Interlibrary Loans = "Fernleihe" Interlibrary loan information = "Hinweise zur Fernleihe" +Interlibrary loan recommendation = "Sie können mit Ihrer Suchanfrage direkt nach Fernleihen suchen. Folgen Sie hierfür bitte folgendem Link:" Invalid Recipient Email Address = "Ungültige E-Mail-Adresse des Empfängers" Invalid Sender Email Address = "Ungültige E-Mail-Adresse zum Versenden" ISBD Citation = "ISBD Zitierstil" diff --git a/local/languages/en.ini b/local/languages/en.ini index 540e6182b18c8ce04ba1f0f18885bf8466869c00..c1fcba84f3b1b50b43c3650e98c5611acba3dcc2 100644 --- a/local/languages/en.ini +++ b/local/languages/en.ini @@ -442,6 +442,7 @@ Interlibrary loan = "Interlibrary Loan" Interlibrary loan information = "Interlibrary Loan Information" Interlibrary loan - Medicine = "Interlibrary Loan - Medicine" Interlibraryloans = "Interlibrary Loans" +Interlibrary loan recommendation = "You can search for interlibrary loans directly with your search query. Please follow the link:" Invalid Recipient Email Address = "Invalid recipient e-mail address" Invalid Sender Email Address = "Invalid sender e-mail address" # Irish = Gaeilge diff --git a/module/finc/config/module.config.php b/module/finc/config/module.config.php index d126c48273506f933fe89a8c7656250c81d336f8..640b46118ec83cc2de17613d7655ac90d24f3e8d 100644 --- a/module/finc/config/module.config.php +++ b/module/finc/config/module.config.php @@ -137,9 +137,11 @@ $config = [ 'recommend' => [ 'factories' => [ 'finc\Recommend\EbscoResults' => 'finc\Recommend\Factory::getEbscoResults', + 'finc\Recommend\InterlibraryLoan' => 'finc\Recommend\Factory::getInterlibraryLoan', ], 'aliases' => [ 'ebscoresults' => 'finc\Recommend\EbscoResults', + 'interlibraryloan' => 'finc\Recommend\InterlibraryLoan', ] ], 'recorddriver' => [ diff --git a/module/finc/src/finc/Recommend/Factory.php b/module/finc/src/finc/Recommend/Factory.php index cfd2e61ca3df05c24b45e5fd69eaabb086a68625..0ac7101fb807c0a16efe8d4ad509444701e86b42 100644 --- a/module/finc/src/finc/Recommend/Factory.php +++ b/module/finc/src/finc/Recommend/Factory.php @@ -55,4 +55,16 @@ class Factory extends \Vufind\Recommend\Factory { return new EbscoResults(); } + + /** + * Creates InterlibraryLoan + * + * @param ServiceManager $sm Service manager + * + * @return InterlibraryLoan + */ + public static function getInterlibraryLoan(ServiceManager $sm) + { + return new InterlibraryLoan($sm); + } } diff --git a/module/finc/src/finc/Recommend/InterlibraryLoan.php b/module/finc/src/finc/Recommend/InterlibraryLoan.php new file mode 100644 index 0000000000000000000000000000000000000000..55e29021407d554400b3495a816e3d3b93e88e4d --- /dev/null +++ b/module/finc/src/finc/Recommend/InterlibraryLoan.php @@ -0,0 +1,97 @@ +<?php +/** + * Recommendation Module Interlibrary Loan + * + * PHP version 7 + * + * Copyright (C) Villanova University 2014. + * Copyright (C) Leipzig University Library 2022. + * + * 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 Recommendations + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development:plugins:hierarchy_components Wiki + */ +namespace finc\Recommend; + +use VuFind\Recommend\RecommendInterface; + +/** + * Controller for an interlibary loan link to fernleihe.boss.bsz-bw.de + * + * @category VuFind + * @package Recommendations + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development:plugins:hierarchy_components Wiki + */ +class InterlibraryLoan implements RecommendInterface +{ + /** + * Template URL with a "<QUERY>" slot to be replaced by the search query. + * + * @var string + */ + protected $templateUrl; + + /** + * Store the configuration of the recommendation module. + * + * @param string $settings Settings from searches.ini. + * + * @return void + */ + public function setConfig($settings) + { + $this->templateUrl = $settings; + } + + /** + * Called at the end of the Search Params objects' initFromRequest() method. + * This method is responsible for setting search parameters needed by the + * recommendation module and for reading any existing search parameters that may + * be needed. + * + * @param \VuFind\Search\Base\Params $params Search parameter object + * @param \Zend\StdLib\Parameters $request Parameter object representing user + * request. + * + * @return void + */ + public function init($params, $request) + { + } + + /** + * Create the interlibrary loan href. + * + * The href is accessible in the corresponding template via: + * `$this->recommend->href` + * + * @param \VuFind\Search\Base\Results $results Search results object + * + * @return void + */ + public function process($results) + { + $this->href = str_replace( + '<QUERY>', + rawurlencode($results->getParams()->getDisplayQuery()), + $this->templateUrl + ); + } +} diff --git a/themes/finc/templates/Recommend/InterlibraryLoan.phtml b/themes/finc/templates/Recommend/InterlibraryLoan.phtml new file mode 100644 index 0000000000000000000000000000000000000000..ceaff64439537d6a2f470dc85123e2125ba37532 --- /dev/null +++ b/themes/finc/templates/Recommend/InterlibraryLoan.phtml @@ -0,0 +1,12 @@ +<?php + $href = $this->recommend->href; + $text = $this->transEsc('Interlibrary loan recommendation'); +?> +<div class="alert alert-info"> + <p> + <?= $text ?> + </p> + <a href=<?= $href ?>target="_blank"> + <?= $href ?> + </a> +</div>