diff --git a/local/config/vufind/searches.ini b/local/config/vufind/searches.ini index 4f829b06c822443d7d31e839d841277f4ce896a3..d56196f77ec6a1625a77e5b80d0ad19b2656a784 100644 --- a/local/config/vufind/searches.ini +++ b/local/config/vufind/searches.ini @@ -55,7 +55,7 @@ default_top_recommend[] = TopFacets:ResultsTop ;default_top_recommend[] = SpellingSuggestions ;default_top_recommend[] = VisualFacets:Visual_Settings default_side_recommend[] = SideFacets:Results:CheckboxFacets -;default_side_recommend[] = EbscoResults:[url]:[namespace] +;default_side_recommend[] = EbscoResults:[namespace]:[url] ;default_noresults_recommend[] = SwitchTab default_noresults_recommend[] = SwitchType default_noresults_recommend[] = SwitchQuery @@ -201,12 +201,13 @@ CallNumber = callnumber-sort ; DPLATerms:[collapsed] ; Display results from the DPLA catalog. Provide a boolean to have the sidebar ; collapsed or open on page load. -; EbscoResults:[url]:[namespace] +; EbscoResults:[namespace]:[url] ; Display searches result of Ebsco databases. Service was developed for ; personal needs of libraries of finc community. [url] is the base search url ; which can contain placeholder %s to inject namespace. [namespace] is a ; defined abbrevation of the service provider to resolve the service for -; a specific instituion. +; a specific instituion. Default [url] is set +; to: www.bibliothek.tu-chemnitz.de/finc/%s/ebsco3.cgi ; EuropeanaResults:[url]:[requestParam]:[limit]:[unwanted data providers] ; Display search results from Europeana.eu API. [url] is the base search URL ; default "api.europeana.eu/api/opensearch.rss" [requestParam] parameter name diff --git a/module/finc/src/finc/Recommend/EbscoResults.php b/module/finc/src/finc/Recommend/EbscoResults.php index 028a9e76389d0bcb6b54353aa471bf27be730115..946ed640161158019855305537c5e6b9fc33d167 100644 --- a/module/finc/src/finc/Recommend/EbscoResults.php +++ b/module/finc/src/finc/Recommend/EbscoResults.php @@ -91,19 +91,10 @@ class EbscoResults implements \VuFind\Recommend\RecommendInterface, /** * Constructor * - * @param array $isils Institution info - * * @access public - * @throws \Exception Service is only available for one generic defined isil. */ - public function __construct($isils = []) + public function __construct() { - if (count($isils) != 1) { - throw new Exception( - 'Service is only available for one generic defined isil.' - . ' Please use full configuration option at searches.ini'); - } - $this->namespace = $isils[0]; } /** @@ -113,15 +104,21 @@ class EbscoResults implements \VuFind\Recommend\RecommendInterface, * * @return void * @access public + * @throws Exception Isil as namespace for service has not been set yet or + * is false. */ public function setConfig($settings) { // Parse out parameters: $params = explode(':', $settings); - $this->baseUrl = (isset($params[0]) && !empty($params[0])) - ? $params[0] : 'www.bibliothek.tu-chemnitz.de/finc/%s/ebsco3.cgi'; - $this->namespace = (isset($params[1]) && !empty($params[1])) - ? $params[1] : $this->namespace; + if (!isset($params[0]) || (0 < preg_match('/\s/g', $params[0]))) { + throw new Exception( + 'Isil as namespace for service has not been set yet or is false.' + ); + } + $this->namespace = $params[0]; + $this->baseUrl = (isset($params[1]) && !empty($params[1])) + ? $params[1] : 'www.bibliothek.tu-chemnitz.de/finc/%s/ebsco3.cgi'; } /** @@ -229,6 +226,10 @@ class EbscoResults implements \VuFind\Recommend\RecommendInterface, */ protected function sortByHits($results, $sortOrder = SORT_DESC) { + if (!is_array($results) && count($results['results']) == 0) { + return $results['results'] = []; + } + $databases = $results['results']; foreach ($databases as $key => $row) { $hits[$key] = $row['hits']; diff --git a/module/finc/src/finc/Recommend/Factory.php b/module/finc/src/finc/Recommend/Factory.php index 0feb9950f705dc0b75de566f9e547d15264ef2f8..b2d00690592524e4c87315f71efceb7f5d2d71f7 100644 --- a/module/finc/src/finc/Recommend/Factory.php +++ b/module/finc/src/finc/Recommend/Factory.php @@ -53,9 +53,6 @@ class Factory extends \Vufind\Recommend\Factory */ public static function getEbscoResults(ServiceManager $sm) { - $config = $sm->getServiceLocator()->get('VuFind\Config')->get('config'); - return new EbscoResults( - $config->InstitutionInfo->isil - ); + return new EbscoResults(); } } \ No newline at end of file diff --git a/themes/finc/templates/Recommend/EbscoResults.phtml b/themes/finc/templates/Recommend/EbscoResults.phtml index e376df29302d0c7efd82dc35361d336769c7ea97..43b06a82e1833e1f5d8de7f43c4fceef101b44b0 100644 --- a/themes/finc/templates/Recommend/EbscoResults.phtml +++ b/themes/finc/templates/Recommend/EbscoResults.phtml @@ -1,6 +1,6 @@ <? $data = $this->recommend->getResult(); -if (is_array($data)): ?> +if (is_array($data) && count($data['results']) > 0): ?> <ul id="side-panel-ebsco" class="accordion" data-accordion=""> <li class="accordion-navigation active"> <a class="title" href="#side-collapse-ebsco" aria-expanded="true">