diff --git a/local/alpha/config/vufind/DAIA.ini b/local/alpha/config/vufind/DAIA.ini index f2b0c6f49ed83319e3d8d6da3e2606d562f06f77..5428ab9655e03e0235236617fc8fbc387e013950 100644 --- a/local/alpha/config/vufind/DAIA.ini +++ b/local/alpha/config/vufind/DAIA.ini @@ -20,10 +20,3 @@ relative_path = ../../../config/vufind/DAIA.ini ; ;##################### DO NOT DELETE THIS HEADER #################### ;#################################################################### - -;[DAIA] -; refer to http://data.ub.uni-leipzig.de/ldinfo for setting up specific DAIA-urls -;baseUrl = http://data.ub.uni-leipzig.de/item/DE-15/finc/ - -; DAIATheca -; http://139.18.19.238:8080/DaiaThecaMssql/ \ No newline at end of file diff --git a/local/config/vufind/DAIA.ini b/local/config/vufind/DAIA.ini index aad984c296a382b231ad5b5b73fcc300acc9bd44..b2f2ab16c944d82164d62a3a8ebd237e63d7691c 100644 --- a/local/config/vufind/DAIA.ini +++ b/local/config/vufind/DAIA.ini @@ -2,16 +2,7 @@ ; http://gbv.github.io/daiaspec/daia.html#query-api ; ; The settings in the [DAIA] section will be used for all DAIA requests. -; The name of this section got refactored with VuFind 2.4, although the old -; configuration using the [Global] section still works, it should be replaced -; with the new [DAIA] section. -; Note: Settings for daiaResponseFormat and daiaIdPrefix are not supported if -; a pre VuFind 2.4 configuration with the [Global] section is used. -; i.e.: -; [Global] -; baseUrl = [your DAIA server base url] -; daiaIdPrefix = [this setting will have no effect] -; daiaResponseFormat = [this setting will have no effect] +; The name of this section got refactored with VuFind 2.4. ; ; A default DAIA call looks like this: ; https://daia.myuniversity.edu/?id=ppn:12345678&format=json @@ -23,6 +14,11 @@ ; daiaResponseFormat = json ; +[DAIA] +; The base URL for the DAIA webservice. +;baseUrl = http://139.18.19.238:9080/daialibero/daia/ +;baseUrl = http://139.18.19.238:9080/daiatheca/daia/ + ; The prefix prepended to the VuFind record Id resulting in the document URI ; used for the DAIA request (default = ppn:) (the prefix usually defines the ; field which the DAIA server uses for the loookup - e.g. ppn: or isbn:). @@ -31,10 +27,21 @@ ; Set the requested DAIA response format: xml (default), json ;daiaResponseFormat = xml -[Global] -; The base URL for the DAIA webservice. -; refer to http://data.ub.uni-leipzig.de/ldinfo for setting up specific DAIA-urls -baseUrl = http://data.ub.uni-leipzig.de/item/ISIL/identifier/ +; Set multiQuery to true if your DAIA webservice supports queries with multiple +; ids (cf. http://gbv.github.io/daiaspec/daia.html#query-api). +; Default is false. +;multiQuery = false + +; If daiaContentTypes are set, the DAIA driver checks the Content-Type +; line in the DAIA response HTTP header for the configured values. If +; daiaContentTypes is not set, Content-Type HTTP header is NOT checked. +; +; expected Content-Types for DAIA XML format: +; (seperate multiple values by commata, for example: +; daiaContentTypes['xml'] = "application/xml, text/xml" +daiaContentTypes['xml'] = "application/xml" -; DAIATheca -; http://139.18.19.238:8080/DaiaThecaMssql/ \ No newline at end of file +; expected Content-Types for DAIA JSON format: +; (seperate multiple values by commata, for example: +; daiaContentTypes['xml'] = "application/json, application/javascript" +daiaContentTypes['json'] = "application/json" diff --git a/local/dev/config/vufind/DAIA.ini.sample b/local/dev/config/vufind/DAIA.ini.sample index c8ae05ca19f1ef2afc15f7f03db88fc8c6c39e6d..01b53f0a6269adda904c4322500ffefd3cdf0895 100644 --- a/local/dev/config/vufind/DAIA.ini.sample +++ b/local/dev/config/vufind/DAIA.ini.sample @@ -20,10 +20,3 @@ relative_path = ../../../config/vufind/DAIA.ini ; ;##################### DO NOT DELETE THIS HEADER #################### ;#################################################################### - -;[DAIA] -; refer to http://data.ub.uni-leipzig.de/ldinfo for setting up specific DAIA-urls -;baseUrl = http://data.ub.uni-leipzig.de/item/DE-15/finc/ - -; DAIATheca -; http://139.18.19.238:8080/DaiaThecaMssql/ \ No newline at end of file diff --git a/module/finc/src/finc/ILS/Driver/DAIA.php b/module/finc/src/finc/ILS/Driver/DAIA.php index cd6c0bb1e39170a741ee45a668e2efab68a4841a..996244e3e88cc21772cc82d65e7ce1845e50026c 100644 --- a/module/finc/src/finc/ILS/Driver/DAIA.php +++ b/module/finc/src/finc/ILS/Driver/DAIA.php @@ -81,12 +81,23 @@ class DAIA extends \VuFind\ILS\Driver\AbstractBase implements protected $multiQuery = false; /** - * DAIA legacySupport flag + * acceptable ContentTypes delivered by DAIA server + * in HTTP header * - * @var boolean - * @deprecated Will be removed in the next driver version + * @var array */ - protected $legacySupport = false; + protected $contentTypesResponse; + + /** + * ContentTypes to use in PAIA HTTP requests + * in HTTP header + * + * @var array + */ + protected $contentTypesRequest = [ + "xml" => "application/xml", + "json" => "application/json", + ]; /** * Initialize the driver. @@ -99,13 +110,6 @@ class DAIA extends \VuFind\ILS\Driver\AbstractBase implements */ public function init() { - // DAIA.ini sections changed, therefore move old [Global] section to - // new [DAIA] section as fallback - if (isset($this->config['Global']) && !isset($this->config['DAIA'])) { - $this->config['DAIA'] = $this->config['Global']; - $this->legacySupport = true; - } - if (isset($this->config['DAIA']['baseUrl'])) { $this->baseUrl = $this->config['DAIA']['baseUrl']; } else { @@ -130,6 +134,11 @@ class DAIA extends \VuFind\ILS\Driver\AbstractBase implements } else { $this->debug("No multiQuery setting found, using default: false"); } + if (isset($this->config['DAIA']['daiaContentTypes'])) { + $this->contentTypesResponse = $this->config['DAIA']['daiaContentTypes']; + } else { + $this->debug("No ContentTypes for response defined. Accepting any."); + } } /** @@ -181,23 +190,20 @@ class DAIA extends \VuFind\ILS\Driver\AbstractBase implements return []; } - if ($this->legacySupport) { - // we are in legacySupport mode, so use the deprecated - // getXMLStatus() method - return $this->getXMLStatus($id); - } else { - // let's retrieve the DAIA document by URI + // let's retrieve the DAIA document by URI + try { $rawResult = $this->doHTTPRequest($this->generateURI($id)); - if ($rawResult != false) { - // extract the DAIA document for the current id from the - // HTTPRequest's result - $doc = $this->extractDaiaDoc($id, $rawResult); - if (!is_null($doc)) { - // parse the extracted DAIA document and return the status info - return $this->parseDaiaDoc($id, $doc); - } + // extract the DAIA document for the current id from the + // HTTPRequest's result + $doc = $this->extractDaiaDoc($id, $rawResult); + if (!is_null($doc)) { + // parse the extracted DAIA document and return the status info + return $this->parseDaiaDoc($id, $doc); } + } catch (ILSException $e) { + $this->debug($e->getMessage()); } + return []; } @@ -208,14 +214,12 @@ class DAIA extends \VuFind\ILS\Driver\AbstractBase implements * collection of records. * As the DAIA Query API supports querying multiple ids simultaneously * (all ids divided by "|") getStatuses(ids) would call getStatus(id) only - * once, id containing the list of ids to be retrieved. Apart from the - * legacySupport this would cause some trouble as the list of ids does not - * necessarily correspond to the VuFind Record-id. Therefore getStatuses(ids) - * has its own logic for multiQuery-support and performs the HTTPRequest - * itself, retrieving one DAIA response for all ids and uses helper - * functions to split this one response into documents corresponding to the - * queried ids. - * If multiQueries are not supported, getStatus(id) is used. + * once, id containing the list of ids to be retrieved. This would cause some + * trouble as the list of ids does not necessarily correspond to the VuFind + * Record-id. Therefore getStatuses(ids) has its own logic for multiQuery-support + * and performs the HTTPRequest itself, retrieving one DAIA response for all ids + * and uses helper functions to split this one response into documents + * corresponding to the queried ids. * * @param array $ids The array of record ids to retrieve the status for * @@ -225,39 +229,41 @@ class DAIA extends \VuFind\ILS\Driver\AbstractBase implements { $status = []; - if ($this->legacySupport) { - // we are in legacySupport mode, so use the deprecated - // getXMLStatus() method for each id - foreach ($ids as $id) { - $status[] = $this->getXMLShortStatus($id); - } - } else { + try { if ($this->multiQuery) { // perform one DAIA query with multiple URIs - $rawResult = $this->doHTTPRequest($this->generateMultiURIs($ids)); - if ($rawResult != false) { - // now we need to reestablish the key-value pair id=>document as - // the id used in VuFind can differ from the document-URI - // (depending on how the URI is generated) - foreach ($ids as $id) { - // it is assumed that each DAIA document has a unique URI, - // so get the document with the corresponding id - $doc = $this->extractDaiaDoc($id, $rawResult); - if (!is_null($doc)) { - // a document with the corresponding id exists, which - // means we got status information for that record - $status[] = $this->parseDaiaDoc($id, $doc); - } - unset($doc); + $rawResult = $this + ->doHTTPRequest($this->generateMultiURIs($ids)); + // the id used in VuFind can differ from the document-URI + // (depending on how the URI is generated) + foreach ($ids as $id) { + // it is assumed that each DAIA document has a unique URI, + // so get the document with the corresponding id + $doc = $this->extractDaiaDoc($id, $rawResult); + if (!is_null($doc)) { + // a document with the corresponding id exists, which + // means we got status information for that record + $status[] = $this->parseDaiaDoc($id, $doc); } + unset($doc); } } else { - // multiQuery is not supported, so retrieve DAIA documents by - // performing getStatus(id) for all ids + // multiQuery is not supported, so retrieve DAIA documents one by + // one foreach ($ids as $id) { - $status[] = $this->getStatus($id); + $rawResult = $this->doHTTPRequest($this->generateURI($id)); + // extract the DAIA document for the current id from the + // HTTPRequest's result + $doc = $this->extractDaiaDoc($id, $rawResult); + if (!is_null($doc)) { + // parse the extracted DAIA document and save the status + // info + $status[] = $this->parseDaiaDoc($id, $doc); + } } } + } catch (ILSException $e) { + $this->debug($e->getMessage()); } return $status; } @@ -306,14 +312,9 @@ class DAIA extends \VuFind\ILS\Driver\AbstractBase implements */ protected function doHTTPRequest($id) { - $contentTypes = [ - "xml" => "application/xml", - "json" => "application/json", - ]; - $http_headers = [ - "Content-type: " . $contentTypes[$this->daiaResponseFormat], - "Accept: " . $contentTypes[$this->daiaResponseFormat], + "Content-type: " . $this->contentTypesRequest[$this->daiaResponseFormat], + "Accept: " . $this->contentTypesRequest[$this->daiaResponseFormat], ]; $params = [ @@ -322,49 +323,48 @@ class DAIA extends \VuFind\ILS\Driver\AbstractBase implements ]; try { - if ($this->legacySupport) { - // HttpRequest for DAIA legacy support as all - // the parameters are contained in the baseUrl - $result = $this->httpService->get( - $this->baseUrl . $id, - [], null, $http_headers - ); - } else { - $result = $this->httpService->get( - $this->baseUrl, - $params, null, $http_headers - ); - } + $result = $this->httpService->get( + $this->baseUrl, + $params, null, $http_headers + ); } catch (\Exception $e) { - throw new ILSException($e->getMessage()); + throw new ILSException( + 'HTTP request exited with Exception ' . $e->getMessage() . + ' for record: ' . $id + ); } if (!$result->isSuccess()) { - // throw ILSException disabled as this will be shown in VuFind-Frontend - //throw new ILSException('HTTP error ' . $result->getStatusCode() . - // ' retrieving status for record: ' . $id); - // write to Debug instead - $this->debug( + throw new ILSException( 'HTTP status ' . $result->getStatusCode() . ' received, retrieving availability information for record: ' . $id ); - // return false as DAIA request failed - return false; } // check if result matches daiaResponseFormat - if (!preg_match( - "/^" . - str_replace("/", "\/", $contentTypes[$this->daiaResponseFormat]) . - "(\s*)(\;.*)?/", - strtolower($result->getHeaders()->get("ContentType")->getFieldValue()) - )) { - throw new ILSException( - "DAIA-ResponseFormat not supported. Received: " . - $result->getHeaders()->get("ContentType")->getFieldValue() . " - " . - "Expected: " . $contentTypes[$this->daiaResponseFormat] - ); + if ($this->contentTypesResponse != null) { + if ($this->contentTypesResponse[$this->daiaResponseFormat]) { + $contentTypesResponse = array_map( + 'trim', + explode( + ",", + $this->contentTypesResponse[$this->daiaResponseFormat] + ) + ); + list($responseMediaType, $responseEncoding) = explode( + ";", + $result->getHeaders()->get("ContentType")->getFieldValue() + ); + if (!in_array(trim($responseMediaType), $contentTypesResponse)) { + throw new ILSException( + "DAIA-ResponseFormat not supported. Received: " . + $responseMediaType . " - " . + "Expected: " . + $this->contentTypesResponse[$this->daiaResponseFormat] + ); + } + } } return ($result->getBody()); @@ -381,11 +381,7 @@ class DAIA extends \VuFind\ILS\Driver\AbstractBase implements */ protected function generateURI($id) { - if ($this->legacySupport) { - return $id; - } else { - return $this->daiaIdPrefix . $id; - } + return $this->daiaIdPrefix . $id; } /** @@ -430,11 +426,9 @@ class DAIA extends \VuFind\ILS\Driver\AbstractBase implements * compatible array of status information. * Supported types are: * - array (for JSON results) - * - DOMNode (for XML results) * * @param string $id Record Id corresponding to the DAIA document - * @param mixed $daiaDoc The DAIA document, supported types are array and - * DOMNode + * @param mixed $daiaDoc The DAIA document, only array is supported * * @return array An array with status information for the record * @throws ILSException @@ -443,8 +437,6 @@ class DAIA extends \VuFind\ILS\Driver\AbstractBase implements { if (is_array($daiaDoc)) { return $this->parseDaiaArray($id, $daiaDoc); - } elseif (is_subclass_of($daiaDoc, "DOMNode")) { - return $this->parseDaiaDom($id, $daiaDoc); } else { throw new ILSException( 'Unsupported document type (did not match Array or DOMNode).' @@ -468,38 +460,18 @@ class DAIA extends \VuFind\ILS\Driver\AbstractBase implements */ protected function extractDaiaDoc($id, $daiaResponse) { - + $docs = []; if ($this->daiaResponseFormat == 'xml') { try { - $docs = new DOMDocument(); - $docs->loadXML($daiaResponse); - // get all the DAIA documents - $doc = $docs->getElementsByTagName("document"); - if (!is_null($doc) && $this->multiQuery) { - // now loop through the found DAIA documents - for ($i = 0; $i < $doc->length; $i++) { - $attr = $doc->item($i)->attributes; - // DAIA documents should use URIs as value for id - $nodeValue = $attr->getNamedItem("id")->nodeValue; - if ($nodeValue == $this->generateURI($id)) { - // we've found the document element with the - // matching URI - return $doc->item($i); - } - } - } elseif (!is_null($doc)) { - // as multiQuery is not enabled we can be sure that the - // DAIA response only contains one document. - return $doc->item(0); - } - // no (id matching) document element found - return null; + $docs = $this->convertDaiaXmlToJson($daiaResponse); } catch (\Exception $e) { throw new ILSException($e->getMessage()); } - } elseif ($this->daiaResponseFormat == 'json') { $docs = json_decode($daiaResponse, true); + } + + if (count($docs)) { // do DAIA documents exist? if (array_key_exists("document", $docs) && $this->multiQuery) { // now loop through the found DAIA documents @@ -524,6 +496,83 @@ class DAIA extends \VuFind\ILS\Driver\AbstractBase implements } } + /** + * Converts a DAIA XML response to an array identical with a DAIA JSON response + * for the sent query. + * + * @param string $daiaResponse Response in XML format from DAIA service + * + * @return mixed + */ + protected function convertDaiaXmlToJson($daiaResponse) + { + $dom = new DOMDocument(); + $dom->loadXML($daiaResponse); + + // prepare DOMDocument as json_encode does not support save attributes if + // elements have values (see http://stackoverflow.com/a/20506281/2115462) + $prepare = function ($domNode) use (&$prepare) { + foreach ($domNode->childNodes as $node) { + if ($node->hasChildNodes()) { + $prepare($node); + } else { + if ($domNode->hasAttributes() && strlen($domNode->nodeValue)) { + if (trim($node->textContent)) { + $domNode->setAttribute("content", $node->textContent); + } + $node->nodeValue = ""; + } + } + } + }; + $prepare($dom); + + // now let json_encode/decode convert XML into an array + $daiaArray = json_decode( + json_encode(simplexml_load_string($dom->saveXML())), + true + ); + + // merge @attributes fields in parent array + $merge = function ($array) use (&$merge) { + foreach ($array as $key => $value) { + if (is_array($value)) { + $value = $merge($value); + } + if ($key === "@attributes") { + $array = array_merge($array, $value); + unset($array[$key]); + } else { + $array[$key] = $value; + } + } + return $array; + }; + $daiaArray = $merge($daiaArray); + + // restructure the array, moving single elements to their parent's index [0] + $restructure = function ($array) use (&$restructure) { + $elements = ["document", "item", "available", "unavailable"]; + foreach ($array as $key => $value) { + if (is_array($value)) { + $value = $restructure($value); + } + if (in_array($key, $elements, true) + && !isset($array[$key][0]) + ) { + unset($array[$key]); + $array[$key][] = $value; + } else { + $array[$key] = $value; + } + } + return $array; + }; + $daiaArray = $restructure($daiaArray); + + return $daiaArray; + } + /** * Parse an array with DAIA status information. * @@ -541,12 +590,12 @@ class DAIA extends \VuFind\ILS\Driver\AbstractBase implements $doc_id = $daiaArray["id"]; } if (array_key_exists("href", $daiaArray)) { - // url of the document + // url of the document (not needed for VuFind) $doc_href = $daiaArray["href"]; } if (array_key_exists("message", $daiaArray)) { - // array of messages with language code and content - $doc_message = $daiaArray["message"]; + // log messages for debugging + $this->logMessages($daiaArray['message'], "document"); } // if one or more items exist, iterate and build result-item if (array_key_exists("item", $daiaArray)) { @@ -555,27 +604,22 @@ class DAIA extends \VuFind\ILS\Driver\AbstractBase implements $result_item = []; $result_item["id"] = $id; $result_item["item_id"] = $item["id"]; - $result_item["ilslink"] = $doc_href; - $number++; // count items - $result_item["number"] = $number; + // custom DAIA field used in getHoldLink() + $result_item["ilslink"] + = (isset($item['href']) ? $item['href'] : $doc_href); + // count items + $number++; + $result_item["number"] = $this->getItemNumber($item, $number); // set default value for barcode - $result_item["barcode"] = "1"; + $result_item["barcode"] = $this->getItemBarcode($item); // set default value for reserve - $result_item["reserve"] = "N"; + $result_item["reserve"] = $this->getItemReserveStatus($item); // get callnumber - if (isset($item["label"])) { - $result_item["callnumber"] = $item["label"]; - } else { - $result_item["callnumber"] = "Unknown"; - } + $result_item["callnumber"] = $this->getItemCallnumber($item); // get location - if (isset($item["storage"]["content"])) { - $result_item["location"] = $item["storage"]["content"]; - } else { - $result_item["location"] = "Unknown"; - } + $result_item["location"] = $this->getItemLocation($item); // status and availability will be calculated in own function - $result_item = $this->calculateStatus($item)+$result_item; + $result_item = $this->getItemStatus($item)+$result_item; // add result_item to the result array $result[] = $result_item; } // end iteration on item @@ -585,299 +629,52 @@ class DAIA extends \VuFind\ILS\Driver\AbstractBase implements } /** - * Parse a DOMNode Object with DAIA status information. + * Returns an array with status information for provided item. * - * @param string $id Record id for the DAIA array. - * @param DOMNode $daiaDom DOMNode object with raw DAIA status information. + * @param array $item Array with DAIA item data * - * @return array Array with VuFind compatible status information. - */ - protected function parseDaiaDom($id, $daiaDom) - { - $itemlist = $daiaDom->getElementsByTagName('item'); - $ilslink = ''; - if ($daiaDom->attributes->getNamedItem('href') !== null) { - $ilslink = $daiaDom->attributes - ->getNamedItem('href')->nodeValue; - } - $emptyResult = [ - 'callnumber' => '-', - 'availability' => '0', - 'number' => 1, - 'reserve' => 'No', - 'duedate' => '', - 'queue' => '', - 'delay' => '', - 'barcode' => 'No samples', - 'status' => '', - 'id' => $id, - 'location' => '', - 'ilslink' => $ilslink, - 'label' => 'No samples' - ]; - for ($c = 0; $itemlist->item($c) !== null; $c++) { - $result = [ - 'callnumber' => '', - 'availability' => '0', - 'number' => ($c+1), - 'reserve' => 'No', - 'duedate' => '', - 'queue' => '', - 'delay' => '', - 'barcode' => 1, - 'status' => '', - 'id' => $id, - 'item_id' => '', - 'recallhref' => '', - 'location' => '', - 'location.id' => '', - 'location.href' => '', - 'label' => '', - 'notes' => [], - ]; - if ($itemlist->item($c)->attributes->getNamedItem('id') !== null) { - $result['item_id'] = $itemlist->item($c)->attributes - ->getNamedItem('id')->nodeValue; - } - if ($itemlist->item($c)->attributes->getNamedItem('href') !== null) { - $result['recallhref'] = $itemlist->item($c)->attributes - ->getNamedItem('href')->nodeValue; - } - $departmentElements = $itemlist->item($c) - ->getElementsByTagName('department'); - if ($departmentElements->length > 0) { - if ($departmentElements->item(0)->nodeValue) { - $result['location'] - = $departmentElements->item(0)->nodeValue; - $result['location.id'] = $departmentElements - ->item(0)->attributes->getNamedItem('id')->nodeValue; - $result['location.href'] = $departmentElements - ->item(0)->attributes->getNamedItem('href')->nodeValue; - } - } - $storageElements - = $itemlist->item($c)->getElementsByTagName('storage'); - if ($storageElements->length > 0) { - if ($storageElements->item(0)->nodeValue) { - $result['location'] = $storageElements->item(0)->nodeValue; - //$result['location.id'] = $storageElements->item(0) - // ->attributes->getNamedItem('id')->nodeValue; - $href = $storageElements->item(0)->attributes - ->getNamedItem('href'); - if ($href !== null) { - //href attribute is recommended but not mandatory - $result['location.href'] = $storageElements->item(0) - ->attributes->getNamedItem('href')->nodeValue; - } - //$result['barcode'] = $result['location.id']; - } - } - $barcodeElements - = $itemlist->item($c)->getElementsByTagName('identifier'); - if ($barcodeElements->length > 0) { - if ($barcodeElements->item(0)->nodeValue) { - $result['barcode'] = $barcodeElements->item(0)->nodeValue; - } - } - $labelElements = $itemlist->item($c)->getElementsByTagName('label'); - if ($labelElements->length > 0) { - if ($labelElements->item(0)->nodeValue) { - $result['label'] = $labelElements->item(0)->nodeValue; - $result['callnumber'] - = urldecode($labelElements->item(0)->nodeValue); - } - } - $messageElements - = $itemlist->item($c)->getElementsByTagName('message'); - if ($messageElements->length > 0) { - for ($m = 0; $messageElements->item($m) !== null; $m++) { - $errno = $messageElements->item($m)->attributes - ->getNamedItem('errno')->nodeValue; - if ($errno === '404') { - $result['status'] = 'missing'; - } else if ($this->logger) { - $lang = $messageElements->item($m)->attributes - ->getNamedItem('lang')->nodeValue; - $logString = "[DAIA] message for {$lang}: " - . $messageElements->item($m)->nodeValue; - $this->debug($logString); - } - } - } - - //$loanAvail = 0; - //$loanExp = 0; - //$presAvail = 0; - //$presExp = 0; - - $unavailableElements = $itemlist->item($c) - ->getElementsByTagName('unavailable'); - if ($unavailableElements->item(0) !== null) { - for ($n = 0; $unavailableElements->item($n) !== null; $n++) { - $service = $unavailableElements->item($n)->attributes - ->getNamedItem('service'); - $expectedNode = $unavailableElements->item($n)->attributes - ->getNamedItem('expected'); - $queueNode = $unavailableElements->item($n)->attributes - ->getNamedItem('queue'); - if ($service !== null) { - $service = $service->nodeValue; - if ($service === 'presentation') { - $result['presentation.availability'] = '0'; - $result['presentation_availability'] = '0'; - if ($expectedNode !== null) { - $result['presentation.duedate'] - = $expectedNode->nodeValue; - } - if ($queueNode !== null) { - $result['presentation.queue'] - = $queueNode->nodeValue; - } - $result['availability'] = '0'; - } elseif ($service === 'loan') { - $result['loan.availability'] = '0'; - $result['loan_availability'] = '0'; - if ($expectedNode !== null) { - $result['loan.duedate'] - = $expectedNode->nodeValue; - } - if ($queueNode !== null) { - $result['loan.queue'] = $queueNode->nodeValue; - } - $result['availability'] = '0'; - } elseif ($service === 'interloan') { - $result['interloan.availability'] = '0'; - if ($expectedNode !== null) { - $result['interloan.duedate'] - = $expectedNode->nodeValue; - } - if ($queueNode !== null) { - $result['interloan.queue'] - = $queueNode->nodeValue; - } - $result['availability'] = '0'; - } elseif ($service === 'openaccess') { - $result['openaccess.availability'] = '0'; - if ($expectedNode !== null) { - $result['openaccess.duedate'] - = $expectedNode->nodeValue; - } - if ($queueNode !== null) { - $result['openaccess.queue'] - = $queueNode->nodeValue; - } - $result['availability'] = '0'; - } - } - // TODO: message/limitation - if ($expectedNode !== null) { - $result['duedate'] = $expectedNode->nodeValue; - } - if ($queueNode !== null) { - $result['queue'] = $queueNode->nodeValue; - } - } - } - - $availableElements = $itemlist->item($c) - ->getElementsByTagName('available'); - if ($availableElements->item(0) !== null) { - for ($n = 0; $availableElements->item($n) !== null; $n++) { - $service = $availableElements->item($n)->attributes - ->getNamedItem('service'); - $delayNode = $availableElements->item($n)->attributes - ->getNamedItem('delay'); - if ($service !== null) { - $service = $service->nodeValue; - if ($service === 'presentation') { - $result['presentation.availability'] = '1'; - $result['presentation_availability'] = '1'; - if ($delayNode !== null) { - $result['presentation.delay'] - = $delayNode->nodeValue; - } - $result['availability'] = '1'; - } elseif ($service === 'loan') { - $result['loan.availability'] = '1'; - $result['loan_availability'] = '1'; - if ($delayNode !== null) { - $result['loan.delay'] = $delayNode->nodeValue; - } - $result['availability'] = '1'; - } elseif ($service === 'interloan') { - $result['interloan.availability'] = '1'; - if ($delayNode !== null) { - $result['interloan.delay'] - = $delayNode->nodeValue; - } - $result['availability'] = '1'; - } elseif ($service === 'openaccess') { - $result['openaccess.availability'] = '1'; - if ($delayNode !== null) { - $result['openaccess.delay'] - = $delayNode->nodeValue; - } - $result['availability'] = '1'; - } - } - // TODO: message/limitation - if ($delayNode !== null) { - $result['delay'] = $delayNode->nodeValue; - } - } - } - // document has no availability elements, so set availability - // and barcode to -1 - if ($availableElements->item(0) === null - && $unavailableElements->item(0) === null - ) { - $result['availability'] = '-1'; - $result['barcode'] = '-1'; - } - $result['ilslink'] = $ilslink; - $status[] = $result; - /* $status = "available"; - if (loanAvail) return 0; - if (presAvail) { - if (loanExp) return 1; - return 2; - } - if (loanExp) return 3; - if (presExp) return 4; - return 5; - */ - } - if (count($status) === 0) { - $status[] = $emptyResult; - } - - return $status; - } - - /** - * Calculate Status and Availability of an item - * - * If availability is false the string of status will be shown in vufind - * - * @param string $item json DAIA item - * - * @return array("status"=>"only for VIPs" ... ) + * @return array */ - protected function calculateStatus($item) + protected function getItemStatus($item) { $availability = false; $status = ''; // status cannot be null as this will crash the translator $duedate = null; + $availableLink = ''; + $queue = ''; if (array_key_exists("available", $item)) { - // check if item is loanable or presentation - foreach ($item["available"] as $available) { - // attribute service can be set once or not - if (isset($available["service"])) { - if ($available["service"] == "loan") { + if (count($item['available']) === 1) { + $availability = true; + } else { + // check if item is loanable or presentation + foreach ($item["available"] as $available) { + // attribute service can be set once or not + if (isset($available["service"]) + && in_array( + $available['service'], + ['loan', 'presentation', 'openaccess'] + ) + ) { + // set item available if service is loan, presentation or + // openaccess $availability = true; + if ($available['service'] == "loan" + && isset($available['service']['href']) + ) { + // save the link to the ils if we have a href for loan + // service + $availableLink = $available['service']['href']; + } } - if ($available["service"] == "presentation") { - $availability = true; + + // use limitation element for status string + if (isset($available['limitation'])) { + $status = $this->getItemLimitation($available['limitation']); + } + + // log messages for debugging + if (isset($available['message'])) { + $this->logMessages($available['message'], "item->available"); } } } @@ -885,456 +682,155 @@ class DAIA extends \VuFind\ILS\Driver\AbstractBase implements if (array_key_exists("unavailable", $item)) { foreach ($item["unavailable"] as $unavailable) { // attribute service can be set once or not - if (isset($unavailable["service"])) { - if ($unavailable["service"] == "loan") { - $status = "dummy text"; + if (isset($unavailable["service"]) + && in_array( + $unavailable['service'], + ['loan', 'presentation', 'openaccess'] + ) + ) { + if ($unavailable['service'] == "loan" + && isset($unavailable['service']['href']) + ) { + //save the link to the ils if we have a href for loan service + } + + // use limitation element for status string + if (isset($unavailable['limitation'])) { + $status = $this + ->getItemLimitation($unavailable['limitation']); } } // attribute expected is mandatory for unavailable element if (isset($unavailable["expected"])) { $duedate = $unavailable["expected"]; } + + // attribute queue can be set + if (isset($unavailable["queue"])) { + $queue = $unavailable["queue"]; + } + + // log messages for debugging + if (isset($unavailable['message'])) { + $this->logMessages($unavailable['message'], 'item->unavailable'); + } } } - return (["status" => $status, - "availability" => $availability, - "duedate" => $duedate]); + + /*'availability' => '0', + 'status' => '', // string - needs to be computed from availability info + 'duedate' => '', // if checked_out else null + 'returnDate' => '', // false if not recently returned(?) + 'requests_placed' => '', // total number of placed holds + 'is_holdable' => false, // place holding possible?*/ + + if (!empty($availableLink)) { + $return['ilslink'] = $availableLink; + } + + $return["status"] = $status; + $return["availability"] = $availability; + $return["duedate"] = $duedate; + $return["requests_placed"] = $queue; + + return $return; } /** - * Flatten a DAIA response to an array of holding information. - * - * @param string $id Document to look up. + * Returns the value for "number" in VuFind getStatus/getHolding array * - * @return array + * @param array $item Array with DAIA item data + * @param int $counter Integer counting items as alternative return value * - * @deprecated Only kept for legacySupport + * @return mixed */ - protected function getXMLStatus($id) + protected function getItemNumber($item, $counter) { - $daia = new DOMDocument(); - $response = $this->doHTTPRequest($id); - if ($response) { - $daia->loadXML($response); - } - // get Availability information from DAIA - $documentlist = $daia->getElementsByTagName('document'); - - // handle empty DAIA response - if ($documentlist->length == 0 - && $daia->getElementsByTagName("message") != null - ) { - // analyse the message for the error handling and debugging - } + return $counter; + } - $status = []; - for ($b = 0; $documentlist->item($b) !== null; $b++) { - $itemlist = $documentlist->item($b)->getElementsByTagName('item'); - $ilslink = ''; - if ($documentlist->item($b)->attributes->getNamedItem('href') !== null) { - $ilslink = $documentlist->item($b)->attributes - ->getNamedItem('href')->nodeValue; - } - $emptyResult = [ - 'callnumber' => '-', - 'availability' => '0', - 'number' => 1, - 'reserve' => 'No', - 'duedate' => '', - 'queue' => '', - 'delay' => '', - 'barcode' => 'No samples', - 'status' => '', - 'id' => $id, - 'location' => '', - 'ilslink' => $ilslink, - 'label' => 'No samples' - ]; - for ($c = 0; $itemlist->item($c) !== null; $c++) { - $result = [ - 'callnumber' => '', - 'availability' => '0', - 'number' => ($c+1), - 'reserve' => 'No', - 'duedate' => '', - 'queue' => '', - 'delay' => '', - 'barcode' => 1, - 'status' => '', - 'id' => $id, - 'item_id' => '', - 'recallhref' => '', - 'location' => '', - 'location.id' => '', - 'location.href' => '', - 'label' => '', - 'notes' => [], - ]; - if ($itemlist->item($c)->attributes->getNamedItem('id') !== null) { - $result['item_id'] = $itemlist->item($c)->attributes - ->getNamedItem('id')->nodeValue; - } - if ($itemlist->item($c)->attributes->getNamedItem('href') !== null) { - $result['recallhref'] = $itemlist->item($c)->attributes - ->getNamedItem('href')->nodeValue; - } - $departmentElements = $itemlist->item($c) - ->getElementsByTagName('department'); - if ($departmentElements->length > 0) { - if ($departmentElements->item(0)->nodeValue) { - $result['location'] - = $departmentElements->item(0)->nodeValue; - $result['location.id'] = $departmentElements - ->item(0)->attributes->getNamedItem('id')->nodeValue; - $result['location.href'] = $departmentElements - ->item(0)->attributes->getNamedItem('href')->nodeValue; - } - } - $storageElements - = $itemlist->item($c)->getElementsByTagName('storage'); - if ($storageElements->length > 0) { - if ($storageElements->item(0)->nodeValue) { - $result['location'] = $storageElements->item(0)->nodeValue; - //$result['location.id'] = $storageElements->item(0) - // ->attributes->getNamedItem('id')->nodeValue; - $href = $storageElements->item(0)->attributes - ->getNamedItem('href'); - if ($href !== null) { - //href attribute is recommended but not mandatory - $result['location.href'] = $storageElements->item(0) - ->attributes->getNamedItem('href')->nodeValue; - } - //$result['barcode'] = $result['location.id']; - } - } - $barcodeElements - = $itemlist->item($c)->getElementsByTagName('identifier'); - if ($barcodeElements->length > 0) { - if ($barcodeElements->item(0)->nodeValue) { - $result['barcode'] = $barcodeElements->item(0)->nodeValue; - } - } - $labelElements = $itemlist->item($c)->getElementsByTagName('label'); - if ($labelElements->length > 0) { - if ($labelElements->item(0)->nodeValue) { - $result['label'] = $labelElements->item(0)->nodeValue; - $result['callnumber'] - = urldecode($labelElements->item(0)->nodeValue); - } - } - $messageElements - = $itemlist->item($c)->getElementsByTagName('message'); - if ($messageElements->length > 0) { - for ($m = 0; $messageElements->item($m) !== null; $m++) { - $errno = $messageElements->item($m)->attributes - ->getNamedItem('errno')->nodeValue; - if ($errno === '404') { - $result['status'] = 'missing'; - } else if ($this->logger) { - $lang = $messageElements->item($m)->attributes - ->getNamedItem('lang')->nodeValue; - $logString = "[DAIA] message for {$lang}: " - . $messageElements->item($m)->nodeValue; - $this->debug($logString); - } - } - } + /** + * Returns the value for "barcode" in VuFind getStatus/getHolding array + * + * @param array $item Array with DAIA item data + * + * @return string + */ + protected function getItemBarcode($item) + { + return "1"; + } - //$loanAvail = 0; - //$loanExp = 0; - //$presAvail = 0; - //$presExp = 0; + /** + * Returns the value for "reserve" in VuFind getStatus/getHolding array + * + * @param array $item Array with DAIA item data + * + * @return string + */ + protected function getItemReserveStatus($item) + { + return "N"; + } - $unavailableElements = $itemlist->item($c) - ->getElementsByTagName('unavailable'); - if ($unavailableElements->item(0) !== null) { - for ($n = 0; $unavailableElements->item($n) !== null; $n++) { - $service = $unavailableElements->item($n)->attributes - ->getNamedItem('service'); - $expectedNode = $unavailableElements->item($n)->attributes - ->getNamedItem('expected'); - $queueNode = $unavailableElements->item($n)->attributes - ->getNamedItem('queue'); - if ($service !== null) { - $service = $service->nodeValue; - if ($service === 'presentation') { - $result['presentation.availability'] = '0'; - $result['presentation_availability'] = '0'; - if ($expectedNode !== null) { - $result['presentation.duedate'] - = $expectedNode->nodeValue; - } - if ($queueNode !== null) { - $result['presentation.queue'] - = $queueNode->nodeValue; - } - $result['availability'] = '0'; - } elseif ($service === 'loan') { - $result['loan.availability'] = '0'; - $result['loan_availability'] = '0'; - if ($expectedNode !== null) { - $result['loan.duedate'] - = $expectedNode->nodeValue; - } - if ($queueNode !== null) { - $result['loan.queue'] = $queueNode->nodeValue; - } - $result['availability'] = '0'; - } elseif ($service === 'interloan') { - $result['interloan.availability'] = '0'; - if ($expectedNode !== null) { - $result['interloan.duedate'] - = $expectedNode->nodeValue; - } - if ($queueNode !== null) { - $result['interloan.queue'] - = $queueNode->nodeValue; - } - $result['availability'] = '0'; - } elseif ($service === 'openaccess') { - $result['openaccess.availability'] = '0'; - if ($expectedNode !== null) { - $result['openaccess.duedate'] - = $expectedNode->nodeValue; - } - if ($queueNode !== null) { - $result['openaccess.queue'] - = $queueNode->nodeValue; - } - $result['availability'] = '0'; - } - } - // TODO: message/limitation - if ($expectedNode !== null) { - $result['duedate'] = $expectedNode->nodeValue; - } - if ($queueNode !== null) { - $result['queue'] = $queueNode->nodeValue; - } - } - } + /** + * Returns the value for "callnumber" in VuFind getStatus/getHolding array + * + * @param array $item Array with DAIA item data + * + * @return string + */ + protected function getItemCallnumber($item) + { + return array_key_exists("label", $item) + ? $item['label'] + : "Unknown"; + } - $availableElements = $itemlist->item($c) - ->getElementsByTagName('available'); - if ($availableElements->item(0) !== null) { - for ($n = 0; $availableElements->item($n) !== null; $n++) { - $service = $availableElements->item($n)->attributes - ->getNamedItem('service'); - $delayNode = $availableElements->item($n)->attributes - ->getNamedItem('delay'); - if ($service !== null) { - $service = $service->nodeValue; - if ($service === 'presentation') { - $result['presentation.availability'] = '1'; - $result['presentation_availability'] = '1'; - if ($delayNode !== null) { - $result['presentation.delay'] - = $delayNode->nodeValue; - } - $result['availability'] = '1'; - } elseif ($service === 'loan') { - $result['loan.availability'] = '1'; - $result['loan_availability'] = '1'; - if ($delayNode !== null) { - $result['loan.delay'] = $delayNode->nodeValue; - } - $result['availability'] = '1'; - } elseif ($service === 'interloan') { - $result['interloan.availability'] = '1'; - if ($delayNode !== null) { - $result['interloan.delay'] - = $delayNode->nodeValue; - } - $result['availability'] = '1'; - } elseif ($service === 'openaccess') { - $result['openaccess.availability'] = '1'; - if ($delayNode !== null) { - $result['openaccess.delay'] - = $delayNode->nodeValue; - } - $result['availability'] = '1'; - } - } - // TODO: message/limitation - if ($delayNode !== null) { - $result['delay'] = $delayNode->nodeValue; - } - } - } - // document has no availability elements, so set availability - // and barcode to -1 - if ($availableElements->item(0) === null - && $unavailableElements->item(0) === null - ) { - $result['availability'] = '-1'; - $result['barcode'] = '-1'; - } - $result['ilslink'] = $ilslink; - $status[] = $result; - /* $status = "available"; - if (loanAvail) return 0; - if (presAvail) { - if (loanExp) return 1; - return 2; - } - if (loanExp) return 3; - if (presExp) return 4; - return 5; - */ - } - if (count($status) === 0) { - $status[] = $emptyResult; - } - } - return $status; + /** + * Returns the value for "location" in VuFind getStatus/getHolding array + * + * @param array $item Array with DAIA item data + * + * @return string + */ + protected function getItemLocation($item) + { + return array_key_exists("content", $item["storage"]) + ? $item['storage']['content'] + : "Unknown"; } /** - * Return an abbreviated set of status information. + * Returns the evaluated value of the provided limitation element * - * @param string $id The record id to retrieve the status for + * @param array $limitation Array with DAIA limitation data * - * @return mixed On success, an associative array with the following keys: - * id, availability (boolean), status, location, reserve, callnumber, duedate, - * number + * @return string + */ + protected function getItemLimitation($limitation) + { + return (isset($limitation['content']) ? $limitation['content'] : ''); + } + + /** + * Logs content of message elements in DAIA response for debugging * - * @deprecated Only kept for legacySupport + * @param array $messages Array with message elements to be logged + * @param string $context Description of current message context + * + * @return void */ - public function getXMLShortStatus($id) + protected function logMessages($messages, $context) { - $daia = new DOMDocument(); - $response = $this->doHTTPRequest($id); - if ($response) { - $daia->loadXML($response); - } - // get Availability information from DAIA - $itemlist = $daia->getElementsByTagName('item'); - $label = "Unknown"; - $storage = "Unknown"; - $presenceOnly = '1'; - $holding = []; - for ($c = 0; $itemlist->item($c) !== null; $c++) { - $earliest_href = ''; - $storageElements = $itemlist->item($c)->getElementsByTagName('storage'); - if ($storageElements->item(0) && $storageElements->item(0)->nodeValue) { - if ($storageElements->item(0)->nodeValue === 'Internet') { - $href = $storageElements->item(0)->attributes - ->getNamedItem('href')->nodeValue; - $storage = '<a href="' . $href . '">' . $href . '</a>'; - } else { - $storage = $storageElements->item(0)->nodeValue; - } - } - $labelElements = $itemlist->item($c)->getElementsByTagName('label'); - if ($labelElements->item(0)->nodeValue) { - $label = $labelElements->item(0)->nodeValue; - } - $availableElements = $itemlist->item($c) - ->getElementsByTagName('available'); - if ($availableElements->item(0) !== null) { - $availability = 1; - $status = 'Available'; - $href = $availableElements->item(0)->attributes - ->getNamedItem('href'); - if ($href !== null) { - $earliest_href = $href->nodeValue; - } - for ($n = 0; $availableElements->item($n) !== null; $n++) { - $svc = $availableElements->item($n)->getAttribute('service'); - if ($svc === 'loan') { - $presenceOnly = '0'; - } - // $status .= ' ' . $svc; - } - } else { - $leanable = 1; - $unavailableElements = $itemlist->item($c) - ->getElementsByTagName('unavailable'); - if ($unavailableElements->item(0) !== null) { - $earliest = []; - $queue = []; - $hrefs = []; - for ($n = 0; $unavailableElements->item($n) !== null; $n++) { - $unavailHref = $unavailableElements->item($n)->attributes - ->getNamedItem('href'); - if ($unavailHref !== null) { - $hrefs['item' . $n] = $unavailHref->nodeValue; - } - $expectedNode = $unavailableElements->item($n)->attributes - ->getNamedItem('expected'); - if ($expectedNode !== null) { - //$duedate = $expectedNode->nodeValue; - //$duedate_arr = explode('-', $duedate); - //$duedate_timestamp = mktime( - // '0', '0', '0', $duedate_arr[1], $duedate_arr[2], - // $duedate_arr[0] - //); - //array_push($earliest, array( - // 'expected' => $expectedNode->nodeValue, - // 'recall' => $unavailHref->nodeValue); - //array_push($earliest, $expectedNode->nodeValue); - $earliest['item' . $n] = $expectedNode->nodeValue; - } else { - array_push($earliest, "0"); - } - $queueNode = $unavailableElements->item($n)->attributes - ->getNamedItem('queue'); - if ($queueNode !== null) { - $queue['item' . $n] = $queueNode->nodeValue; - } else { - array_push($queue, "0"); - } - } - } - if (count($earliest) > 0) { - arsort($earliest); - $earliest_counter = 0; - foreach ($earliest as $earliest_key => $earliest_value) { - if ($earliest_counter === 0) { - $earliest_duedate = $earliest_value; - $earliest_href = isset($hrefs[$earliest_key]) - ? $hrefs[$earliest_key] : ''; - $earliest_queue = isset($queue[$earliest_key]) - ? $queue[$earliest_key] : ''; - } - $earliest_counter = 1; - } - } else { - $leanable = 0; - } - $messageElements = $itemlist->item($c) - ->getElementsByTagName('message'); - if ($messageElements->length > 0) { - $errno = $messageElements->item(0)->attributes - ->getNamedItem('errno')->nodeValue; - if ($errno === '404') { - $status = 'missing'; - } - } - if (!isset($status)) { - $status = 'Unavailable'; - } - $availability = 0; - } - $reserve = 'N'; - if (isset($earliest_queue) && $earliest_queue > 0) { - $reserve = 'Y'; + foreach ($messages as $message) { + if (isset($message['content'])) { + $this->debug( + "Message in DAIA response (" . (string) $context . "): " . + $message['content'] + ); } - $holding[] = [ - 'availability' => $availability, - 'id' => $id, - 'status' => isset($status) ? "$status" : '', - 'location' => isset($storage) ? "$storage" : '', - 'reserve' => isset($reserve) ? $reserve : '', - 'queue' => isset($earliest_queue) ? $earliest_queue : '', - 'callnumber' => isset($label) ? "$label" : '', - 'duedate' => isset($earliest_duedate) ? $earliest_duedate : '', - 'leanable' => isset($leanable) ? $leanable : '', - 'recallhref' => isset($earliest_href) ? $earliest_href : '', - 'number' => ($c+1), - 'presenceOnly' => isset($presenceOnly) ? $presenceOnly : '', - ]; } - return $holding; } -} \ No newline at end of file +} + diff --git a/module/finc/src/finc/ILS/Driver/FincILS.php b/module/finc/src/finc/ILS/Driver/FincILS.php index a0fe764d17789536e41c02166477274734edd56b..9d1a6879b3418ee81fcd1840ce58f3aa207cbedf 100644 --- a/module/finc/src/finc/ILS/Driver/FincILS.php +++ b/module/finc/src/finc/ILS/Driver/FincILS.php @@ -103,49 +103,25 @@ class FincILS extends PAIA implements LoggerAwareInterface { parent::init(); - // due to section naming changes in DAIA.ini switch legacySupport - if ($this->legacySupport) { - // set the ILS-specific recordId for interaction with ILS + // set the ILS-specific recordId for interaction with ILS - // get the ILS-specific identifier - if (!isset($this->config['Global']['ilsIdentifier'])) { - $this->debug( - "No ILS-specific identifier configured, setting ilsIdentifier=default." - ); - $this->ilsIdentifier = "default"; - } else { - $this->ilsIdentifier = $this->config['Global']['ilsIdentifier']; - } - - // get ISIL from config if ILS-specific recordId is barcode for - // interaction with ILS - if (!isset($this->mainConfig['InstitutionInfo']['isil'])) { - $this->debug("No ISIL defined in section InstitutionInfo in config.ini."); - $this->isil = []; - } else { - $this->isil = $this->mainConfig['InstitutionInfo']['isil']->toArray(); - } + // get the ILS-specific identifier + if (!isset($this->config['DAIA']['ilsIdentifier'])) { + $this->debug( + "No ILS-specific identifier configured, setting ilsIdentifier=default." + ); + $this->ilsIdentifier = "default"; } else { - // set the ILS-specific recordId for interaction with ILS - - // get the ILS-specific identifier - if (!isset($this->config['DAIA']['ilsIdentifier'])) { - $this->debug( - "No ILS-specific identifier configured, setting ilsIdentifier=default." - ); - $this->ilsIdentifier = "default"; - } else { - $this->ilsIdentifier = $this->config['DAIA']['ilsIdentifier']; - } + $this->ilsIdentifier = $this->config['DAIA']['ilsIdentifier']; + } - // get ISIL from config if ILS-specific recordId is barcode for - // interaction with ILS - if (!isset($this->mainConfig['InstitutionInfo']['isil'])) { - $this->debug("No ISIL defined in section InstitutionInfo in config.ini."); - $this->isil = []; - } else { - $this->isil = $this->mainConfig['InstitutionInfo']['isil']->toArray(); - } + // get ISIL from config if ILS-specific recordId is barcode for + // interaction with ILS + if (!isset($this->mainConfig['InstitutionInfo']['isil'])) { + $this->debug("No ISIL defined in section InstitutionInfo in config.ini."); + $this->isil = []; + } else { + $this->isil = $this->mainConfig['InstitutionInfo']['isil']->toArray(); } $this->_testILSConnections(); @@ -357,25 +333,19 @@ class FincILS extends PAIA implements LoggerAwareInterface { try { // test DAIA service - $this->httpService->get( - substr( - $this->baseUrl, - 0, - strrpos($this->baseUrl, "/", strrpos($this->baseUrl, "/")) - ) + preg_match( + "/^(http[s:\/0-9\.]*(:[0-9]*)?\/[a-z]*)/", + $this->baseUrl, + $daiaMatches ); + $this->httpService->get($daiaMatches[1]); // test PAIA service - $this->httpService->get( - substr( - $this->paiaURL, - 0, - strrpos( - $this->paiaURL, - "/", - strrpos($this->paiaURL, "/", strrpos($this->paiaURL, "/")) - ) - ) + preg_match( + "/^(http[s:\/0-9\.]*(:[0-9]*)?\/[a-z]*)/", + $this->paiaURL, + $paiaMatches ); + $this->httpService->get($paiaMatches[1]); } catch (\Exception $e) { throw new ILSException($e->getMessage()); } diff --git a/module/finc/src/finc/ILS/Driver/PAIA.php b/module/finc/src/finc/ILS/Driver/PAIA.php index fe6e2ed8e550a60a6228eb14f068dd6c95c34684..b436d6c2ec9d45fa224d889070d1bccd16369b77 100644 --- a/module/finc/src/finc/ILS/Driver/PAIA.php +++ b/module/finc/src/finc/ILS/Driver/PAIA.php @@ -4,7 +4,8 @@ * * PHP version 5 * - * Copyright (C) Oliver Goldschmidt, Magda Roos, Till Kinstler 2013, 2014. + * Copyright (C) Oliver Goldschmidt, Magda Roos, Till Kinstler, André Lahmann 2013, + * 2014, 2015. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2, @@ -73,7 +74,7 @@ class PAIA extends DAIA implements parent::init(); if (!(isset($this->config['PAIA']['baseUrl']))) { - throw new ILSException('PAIA/URL configuration needs to be set.'); + throw new ILSException('PAIA/baseUrl configuration needs to be set.'); } $this->paiaURL = $this->config['PAIA']['baseUrl']; @@ -303,10 +304,10 @@ class PAIA extends DAIA implements ]; } else { $details[$item_id] = [ - 'success' => false, - 'new_date' => $element['endtime'], - 'item_id' => 0, - 'sysMessage' => 'Request rejected' + 'success' => false, + 'new_date' => $element['endtime'], + 'item_id' => 0, + 'sysMessage' => 'Request rejected' ]; } } @@ -835,7 +836,7 @@ class PAIA extends DAIA implements $http_headers = [ 'Authorization' => 'Bearer ' .$access_token, 'Content-type' => 'application/json; charset=UTF-8', - ]; + ]; try { $result = $this->httpService->get( @@ -931,7 +932,6 @@ class PAIA extends DAIA implements "scope" => "read_patron read_fees read_items write_items change_password" ]; $login_response = $this->_postit('/auth/login', $post_data); - $json_start = strpos($login_response, '{'); $json_response = substr($login_response, $json_start); $array_response = json_decode($json_response, true); @@ -984,4 +984,4 @@ class PAIA extends DAIA implements return $this->parseUserDetails($patron, $user_response); } -} \ No newline at end of file +} diff --git a/themes/foundation5/css/default.css b/themes/foundation5/css/default.css index 159b7a27ced256272cb418a1830a1800e97b2a4c..81281f7c24157a95294b118b9dd4c9993b210f08 100644 --- a/themes/foundation5/css/default.css +++ b/themes/foundation5/css/default.css @@ -467,6 +467,9 @@ ul.date-range-slider { #searchForm .columns { padding: 0; } + #searchForm .columns .button, #searchForm .columns button { + padding: 0; + } } @media only screen and (min-width: 45rem) { diff --git a/themes/foundation5/js/foundation.min.js b/themes/foundation5/js/foundation.min.js index e893d901e939c7be2f119cdecb79567cbc86ebaa..e491e10007085fa7e2c9a2fe3f95844c9c6ad9be 100644 --- a/themes/foundation5/js/foundation.min.js +++ b/themes/foundation5/js/foundation.min.js @@ -5117,7 +5117,7 @@ if (!$dropdown.find('.title.back').length) { if (settings.mobile_show_parent_link == true && url) { - $titleLi = $('<li class="title back js-generated"><h5><a href="javascript:void(0)"></a></h5></li><li class="parent-link hide-for-large-up"><a class="parent-link js-generated" href="' + url + '">' + $link.html() +'</a></li>'); + $titleLi = $('<li class="title back js-generated"><h5><a href="javascript:void(0)"></a></h5></li><li class="parent-link hide-for-medium-up"><a class="parent-link js-generated" href="' + url + '">' + $link.html() +'</a></li>'); } else { $titleLi = $('<li class="title back js-generated"><h5><a href="javascript:void(0)"></a></h5>'); } diff --git a/themes/foundation5/js/foundation/foundation.topbar.js b/themes/foundation5/js/foundation/foundation.topbar.js index 30e581dcbe9d65b075fd717e770a19f86f692024..f09dea61f97a8b8cba75bbea7df03054770e94d1 100644 --- a/themes/foundation5/js/foundation/foundation.topbar.js +++ b/themes/foundation5/js/foundation/foundation.topbar.js @@ -372,7 +372,7 @@ if (!$dropdown.find('.title.back').length) { if (settings.mobile_show_parent_link == true && url) { - $titleLi = $('<li class="title back js-generated"><h5><a href="javascript:void(0)"></a></h5></li><li class="parent-link hide-for-large-up"><a class="parent-link js-generated" href="' + url + '">' + $link.html() +'</a></li>'); + $titleLi = $('<li class="title back js-generated"><h5><a href="javascript:void(0)"></a></h5></li><li class="parent-link hide-for-medium-up"><a class="parent-link js-generated" href="' + url + '">' + $link.html() +'</a></li>'); } else { $titleLi = $('<li class="title back js-generated"><h5><a href="javascript:void(0)"></a></h5>'); } diff --git a/themes/foundation5/scss/default.scss b/themes/foundation5/scss/default.scss index 72703ca6ead1502e744e766060ab6c0c25a44d47..bb342ff8cc350852032ba4b1abc9dcd24c597082 100644 --- a/themes/foundation5/scss/default.scss +++ b/themes/foundation5/scss/default.scss @@ -441,6 +441,10 @@ ul.date-range-slider { .columns { @media only screen and (min-width: 20em) { padding: 0; + + .button, button { + padding: 0; + } } @media only screen and (min-width: 45rem) { @include pad-l-r;