Skip to content
Snippets Groups Projects
Commit f7e3cd7b authored by Dorian Merz's avatar Dorian Merz Committed by Robert Lange
Browse files

refs #20223 [finc] refactor parseDaiaArray()

* adds (configurable) titleHolds logic
parent 5f2cd7e9
Branches
Tags
No related merge requests found
......@@ -136,6 +136,119 @@ class FincLibero extends FincILS implements TranslatorAwareInterface
return preg_quote(substr($this->daiaIdPrefix, 0, strpos($this->daiaIdPrefix, ':')+1));
}
/**
* Parse an array with DAIA status information.
* Copies \VuFind\ILS\Driver\DAIA::parseDaiaArray to enable finc-specific
* titleHoldLogic
*
* @param string $id Record id for the DAIA array.
* @param array $daiaArray Array with raw DAIA status information.
*
* @return array Array with VuFind compatible status information.
*/
protected function parseDaiaArray($id, $daiaArray)
{
$doc_id = null;
$doc_href = null;
if (isset($daiaArray['id'])) {
$doc_id = $daiaArray['id'];
}
if (isset($daiaArray['href'])) {
// url of the document (not needed for VuFind)
$doc_href = $daiaArray['href'];
}
if (isset($daiaArray['message'])) {
// log messages for debugging
$this->logMessages($daiaArray['message'], 'document');
}
// if one or more items exist, iterate and build result-item
if (isset($daiaArray['item']) && is_array($daiaArray['item'])) {
$isTitleHold = null;
$isTitleHoldable = $this->hasTitleHolds();
$number = 0;
foreach ($daiaArray['item'] as $item) {
// if it is a title-holdable record, the first item is a dummy
// that delivers the title hold information and MUST NOT be
// forwarded as an actual piece of availability information
// instead, all following items MUST be marked as title-holdable,
// to enable the frontend to display an adequate link
if ($isTitleHoldable && !$isTitleHold) {
if ($isTitleHold = $this->isTitleHold($item)) {
$titleHoldId = $item['id'];
continue;
}
}
$result_item = [];
$result_item['id'] = $id;
// custom DAIA field
$result_item['doc_id'] = $doc_id;
if (
$isTitleHold
&&
(
!isset($this->noTitleHoldStatuses)
||
empty($this->noTitleHoldStatuses)
||
!in_array($item['localIlsStatus'],$this->noTitleHoldStatuses)
)
) {
$result_item['item_id'] = $titleHoldId;
}
// custom DAIA field used in getHoldLink()
$result_item['ilslink']
= (isset($item['href']) ? $item['href'] : $doc_href);
if ($isTitleHold) {
$result_item['addTitleHoldLink'] = TRUE;
}
// count items
$number++;
$result_item['number'] = $this->getItemNumber($item, $number);
// set default value for barcode
$result_item['barcode'] = $this->getItemBarcode($item);
// set default value for reserve
$result_item['reserve'] = $this->getItemReserveStatus($item);
// get callnumber
$result_item['callnumber'] = $this->getItemCallnumber($item);
// get location
$result_item['location'] = $this->getItemDepartment($item);
// custom DAIA field
$result_item['locationid'] = $this->getItemDepartmentId($item);
// get location link
$result_item['locationhref'] = $this->getItemDepartmentLink($item);
// custom DAIA field
$result_item['storage'] = $this->getItemStorage($item);
// custom DAIA field
$result_item['storageid'] = $this->getItemStorageId($item);
// custom DAIA field
$result_item['storagehref'] = $this->getItemStorageLink($item);
// status and availability will be calculated in own function
$result_item = $this->getItemStatus($item) + $result_item;
// add result_item to the result array
$result[] = $result_item;
} // end iteration on item
}
return $result;
}
/**
* FincLibero specific overrides of PAIA methods
*/
......@@ -826,6 +939,17 @@ class FincLibero extends FincILS implements TranslatorAwareInterface
return null;
}
/**
* May there be Title holdable items in this instance?
* Inherited FincLibero drivers should set see $titleHoldLimitations
* to achieve this
*
* @return bool
*/
public function hasTitleHolds() {
return isset($this->titleHoldLimitations);
}
/**
* Place Title Hold
*
......
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