diff --git a/config/vufind/WorldCat.ini b/config/vufind/WorldCat.ini index d8fce1f8e448e3471a8ee6405af189b8bd0be1fb..d78e36b365bc9b322dea05aeed06e5b5fda7b079 100644 --- a/config/vufind/WorldCat.ini +++ b/config/vufind/WorldCat.ini @@ -69,3 +69,10 @@ related[] = "WorldCatSimilar" ; regular Syndetics if necessary. [List] view=full + +; This section contains additional settings to pass to the WorldCat connector +; code. +[Connector] +; When looking up holdings at other libraries, should we retrieve holdings for +; any record matching the FRBR group (true) or only for exact matches (false)? +;useFrbrGroupingForHoldings = false \ No newline at end of file diff --git a/module/VuFind/src/VuFind/Search/Factory/WorldCatBackendFactory.php b/module/VuFind/src/VuFind/Search/Factory/WorldCatBackendFactory.php index b904866bab0816a05a87777f90bbf532c9e3e93c..d39d468a09e3fa01d7dd2d27c35adb3e3ce0d060 100644 --- a/module/VuFind/src/VuFind/Search/Factory/WorldCatBackendFactory.php +++ b/module/VuFind/src/VuFind/Search/Factory/WorldCatBackendFactory.php @@ -69,6 +69,13 @@ class WorldCatBackendFactory implements FactoryInterface */ protected $config; + /** + * WorldCat configuration + * + * @var \Zend\Config\Config + */ + protected $wcConfig; + /** * Create the backend. * @@ -80,6 +87,8 @@ class WorldCatBackendFactory implements FactoryInterface { $this->serviceLocator = $serviceLocator; $this->config = $this->serviceLocator->get('VuFind\Config')->get('config'); + $this->wcConfig = $this->serviceLocator + ->get('VuFind\Config')->get('WorldCat'); if ($this->serviceLocator->has('VuFind\Logger')) { $this->logger = $this->serviceLocator->get('VuFind\Logger'); } @@ -112,8 +121,11 @@ class WorldCatBackendFactory implements FactoryInterface { $wsKey = isset($this->config->WorldCat->apiKey) ? $this->config->WorldCat->apiKey : null; + $connectorOptions = isset($this->wcConfig->Connector) + ? $this->wcConfig->Connector->toArray() : []; $connector = new Connector( - $wsKey, $this->serviceLocator->get('VuFind\Http')->createClient() + $wsKey, $this->serviceLocator->get('VuFind\Http')->createClient(), + $connectorOptions ); $connector->setLogger($this->logger); return $connector; diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/WorldCat/Connector.php b/module/VuFindSearch/src/VuFindSearch/Backend/WorldCat/Connector.php index 207baa86840de28daa1c6e65490191f258d07c6f..056dfe3f8debca9b77899b68d051890eb8656f40 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/WorldCat/Connector.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/WorldCat/Connector.php @@ -47,18 +47,28 @@ class Connector extends \VuFindSearch\Backend\SRU\Connector */ protected $wskey; + /** + * Additional options + * + * @var array + */ + protected $options; + /** * Constructor * - * @param string $wsKey Web services key - * @param \Zend\Http\Client $client An HTTP client object + * @param string $wsKey Web services key + * @param \Zend\Http\Client $client An HTTP client object + * @param array $options Additional config settings */ - public function __construct($wsKey, \Zend\Http\Client $client) - { + public function __construct($wsKey, \Zend\Http\Client $client, + array $options = [] + ) { parent::__construct( 'http://www.worldcat.org/webservices/catalog/search/sru', $client ); $this->wskey = $wsKey; + $this->options = $options; } /** @@ -72,8 +82,13 @@ class Connector extends \VuFindSearch\Backend\SRU\Connector public function getHoldings($id) { $this->client->resetParameters(); - $uri = "http://www.worldcat.org/webservices/catalog/content/libraries/{$id}"; - $uri .= "?wskey={$this->wskey}&servicelevel=full"; + if (!isset($this->options['useFrbrGroupingForHoldings'])) { + $grouping = 'on'; // default to "on" for backward compatibility + } else { + $grouping = $this->options['useFrbrGroupingForHoldings'] ? 'on' : 'off'; + } + $uri = "http://www.worldcat.org/webservices/catalog/content/libraries/{$id}" + . "?wskey={$this->wskey}&servicelevel=full&frbrGrouping=$grouping"; $this->client->setUri($uri); $this->debug('Connect: ' . $uri); $result = $this->client->setMethod('POST')->send();