Skip to content
Snippets Groups Projects
Commit a0c98cfc authored by Vaclav Rosecky's avatar Vaclav Rosecky Committed by Demian Katz
Browse files

cleanup in getHolding method (avoid use of xpath for simple cases)

parent 3af29794
Branches
Tags
No related merge requests found
...@@ -780,63 +780,49 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, ...@@ -780,63 +780,49 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface,
} catch (\Exception $ex) { } catch (\Exception $ex) {
return array(); return array();
} }
foreach ($xml->xpath('//items/item') as $item) { foreach ($xml->{'items'}->{'item'} as $item) {
$item_id = $item->xpath('@href'); $item_status = (string) $item->{'z30-item-status-code'}; // $isc
$item_id = substr($item_id[0], strrpos($item_id[0], '/') + 1); $item_process_status = (string) $item->{'z30-item-process-status-code'}; // $ipsc
$item_status = $item->xpath('z30-item-status-code/text()'); // $isc $sub_library_code = (string) $item->{'z30-sub-library-code'}; // $slc
$item_process_status $z30 = $item->z30;
= $item->xpath('z30-item-process-status-code/text()'); // $ipsc
$sub_library = $item->xpath('z30-sub-library-code/text()'); // $slc
if ($this->translator) { if ($this->translator) {
$item_status = $this->translator->tab15Translate( $item_status = $this->translator->tab15Translate($sub_library_code,
(string) $sub_library[0], (string) $item_status[0], $item_status, $item_process_status
(string) $item_process_status[0]
); );
} else { } else {
$z30_item_status = $item->xpath('z30/z30-item-status/text()');
$z30_sub_library = $item->xpath('z30/z30-sub-library/text()');
$item_status = array( $item_status = array(
'opac' => 'Y', 'request' => 'C', 'desc' => $z30_item_status[0], 'opac' => 'Y',
'sub_lib_desc' => $z30_sub_library[0] 'request' => 'C',
'desc' => (string) $z30->{'z30-item-status'},
'sub_lib_desc' => (string) $z30->{'z30-sub-library'}
); );
} }
if ($item_status['opac'] != 'Y') { if ($item_status['opac'] != 'Y') {
continue; continue;
} }
$status = $item->xpath('status/text()');
$availability = false; $availability = false;
$location = $item->xpath('z30-sub-library-code/text()');
$reserve = ($item_status['request'] == 'C')?'N':'Y'; $reserve = ($item_status['request'] == 'C')?'N':'Y';
$callnumber = $item->xpath('z30/z30-call-no/text()'); $collection = (string) $z30->{'z30-collection'};
$barcode = $item->xpath('z30/z30-barcode/text()'); $collection_desc = array('desc' => $collection);
$number = $item->xpath('z30/z30-inventory-number/text()');
$collection = $item->xpath('z30/z30-collection/text()');
$collection_code = $item->xpath('z30-collection-code/text()');
if ($this->translator) { if ($this->translator) {
$collection_code = (string) $item->{'z30-collection-code'};
$collection_desc = $this->translator->tab40Translate( $collection_desc = $this->translator->tab40Translate(
(string) $collection_code[0], (string) $location[0] $collection_code, $sub_library_code
); );
} else {
$z30_collection = $item->xpath('z30/z30-collection/text()');
$collection_desc = array('desc' => $z30_collection[0]);
} }
$sig1 = $item->xpath('z30/z30-call-no/text()');
$sig2 = $item->xpath('z30/z30-call-no-2/text()');
$desc = $item->xpath('z30/z30-description/text()');
$note = $item->xpath('z30/z30-note-opac/text()');
$no_of_loans = $item->xpath('z30/z30-no-loans/text()');
$requested = false; $requested = false;
$duedate = ''; $duedate = '';
$status = $status[0]; $addLink = false;
$status = (string) $item->{'status'};
if (in_array($status, $this->available_statuses)) { if (in_array($status, $this->available_statuses)) {
$availability = true; $availability = true;
} }
if ($item_status['request'] == 'Y' && $availability == false) { if ($item_status['request'] == 'Y' && $availability == false) {
$reserve = 'N'; $addLink = true;
} }
if ($patron) { if ($patron) {
$hold_request = $item->xpath('info[@type="HoldRequest"]/@allowed'); $hold_request = $item->xpath('info[@type="HoldRequest"]/@allowed');
$reserve = ($hold_request[0] == 'Y')?'N':'Y'; $addLink = ($hold_request[0] == 'Y');
} }
$matches = array(); $matches = array();
if (preg_match( if (preg_match(
...@@ -868,29 +854,32 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, ...@@ -868,29 +854,32 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface,
$duedate = "requested"; $duedate = "requested";
} }
} }
$item_id = $item->attributes()->href;
$item_id = substr($item_id, strrpos($item_id, '/') + 1);
$note = (string) $z30->{'z30-note-opac'};
$holding[] = array( $holding[] = array(
'id' => $id, 'id' => $id,
'item_id' => $item_id, 'item_id' => $item_id,
'availability' => $availability, // was true 'availability' => $availability,
'status' => (string) $item_status['desc'], 'status' => (string) $item_status['desc'],
'location' => (string) $location[0], 'location' => $sub_library_code,
'reserve' => $reserve, // was 'reserve' => 'N' 'reserve' => 'N',
'callnumber' => (string) $callnumber[0], 'callnumber' => (string) $z30->{'z30-call-no'},
'duedate' => (string) $duedate, 'duedate' => (string) $duedate,
'number' => isset($number[0])?((string) $number[0]):null, 'number' => (string) $z30->{'z30-inventory-number'},
'collection' => (string) $collection[0], 'barcode' => (string) $z30->{'z30-barcode'},
'collection_desc' => (string) $collection_desc['desc'], 'description' => (string) $z30->{'z30-description'},
'barcode' => (string) $barcode[0], 'notes' => ($note == null) ? null : array($note),
'description' => isset($desc[0])?((string) $desc[0]):null, 'is_holdable' => true,
'note' => isset($note[0])?((string) $note[0]):null, 'addLink' => $addLink,
'is_holdable' => true, // ($reserve == 'Y')?true:false, 'holdtype' => 'hold',
'holdtype' => 'hold',
/* below are optional attributes*/ /* below are optional attributes*/
'sig1' => (string) $sig1[0], 'collection' => (string) $collection,
'sig2' => isset($sig2[0])?((string) $sig2[0]):null, 'collection_desc' => (string) $collection_desc['desc'],
'sub_lib_desc' => (string) $item_status['sub_lib_desc'], 'callnumber_second' => (string) $z30->{'z30-call-no-2'},
'no_of_loans' => (integer) $no_of_loans[0], 'sub_lib_desc' => (string) $item_status['sub_lib_desc'],
'requested' => (string) $requested 'no_of_loans' => (string) $z30->{'$no_of_loans'},
'requested' => (string) $requested
); );
} }
return $holding; return $holding;
......
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