Skip to content
Snippets Groups Projects
Commit 6ea7655e authored by Mathias Maaß's avatar Mathias Maaß Committed by Robert Lange
Browse files

refs #16476 [finc] add interlibrary loan link

* adds a interlibrary loan link to the list of recommendations if search
  result was empty.
* add isil parameter to interlib loan url
* refactor and add docblocks
* add descriptive text to interlibrary loan link
* use a configurable url template
parent c451c38c
No related merge requests found
......@@ -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:
......
......@@ -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"
......
......@@ -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
......
......@@ -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' => [
......
......@@ -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);
}
}
<?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
);
}
}
<?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>
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment