/** * Parse a table * * @param string $file Input file * @param string $callback Callback routine for parsing * * @return string */ public function parsetable($file, $callback) { $result = array(); $file_handle = fopen($file, "r, ccs=UTF-8"); $rgxp = ""; while (!feof($file_handle)) { $line = fgets($file_handle); $line = chop($line); if (preg_match("/!!/", $line)) { $line = chop($line); $rgxp = AlephTranslator::regexp($line); } if (preg_match("/!.*/", $line) || $rgxp == "" || $line == "") { } else { $line = str_pad($line, 80); $matches = ""; if (preg_match($rgxp, $line, $matches)) { call_user_func($callback, $matches, $result, $this->charset); } } } fclose($file_handle); return $result; }
/** * Get Holding * * This is responsible for retrieving the holding information of a certain * record. * * @param string $id The record id to retrieve the holdings for * @param array $patron Patron data * * @throws \VuFind\Exception\Date * @throws ILSException * @return array On success, an associative array with the following * keys: id, availability (boolean), status, location, reserve, callnumber, * duedate, number, barcode. */ public function getHolding($id, array $patron = null) { $holding = []; list($bib, $sys_no) = $this->parseId($id); $resource = $bib . $sys_no; $params = ['view' => 'full']; if (!empty($patron['id'])) { $params['patron'] = $patron['id']; } else { if (isset($this->defaultPatronId)) { $params['patron'] = $this->defaultPatronId; } } $xml = $this->doRestDLFRequest(['record', $resource, 'items'], $params); foreach ($xml->{'items'}->{'item'} as $item) { $item_status = (string) $item->{'z30-item-status-code'}; // $isc // $ipsc: $item_process_status = (string) $item->{'z30-item-process-status-code'}; $sub_library_code = (string) $item->{'z30-sub-library-code'}; // $slc $z30 = $item->z30; if ($this->translator) { $item_status = $this->translator->tab15Translate($sub_library_code, $item_status, $item_process_status); } else { $item_status = ['opac' => 'Y', 'request' => 'C', 'desc' => (string) $z30->{'z30-item-status'}, 'sub_lib_desc' => (string) $z30->{'z30-sub-library'}]; } if ($item_status['opac'] != 'Y') { continue; } $availability = false; //$reserve = ($item_status['request'] == 'C')?'N':'Y'; $collection = (string) $z30->{'z30-collection'}; $collection_desc = ['desc' => $collection]; if ($this->translator) { $collection_code = (string) $item->{'z30-collection-code'}; $collection_desc = $this->translator->tab40Translate($collection_code, $sub_library_code); } $requested = false; $duedate = ''; $addLink = false; $status = (string) $item->{'status'}; if (in_array($status, $this->available_statuses)) { $availability = true; } if ($item_status['request'] == 'Y' && $availability == false) { $addLink = true; } if (!empty($patron)) { $hold_request = $item->xpath('info[@type="HoldRequest"]/@allowed'); $addLink = $hold_request[0] == 'Y'; } $matches = []; if (preg_match("/([0-9]*\\/[a-zA-Z]*\\/[0-9]*);([a-zA-Z ]*)/", $status, $matches)) { $duedate = $this->parseDate($matches[1]); $requested = trim($matches[2]) == "Requested"; } else { if (preg_match("/([0-9]*\\/[a-zA-Z]*\\/[0-9]*)/", $status, $matches)) { $duedate = $this->parseDate($matches[1]); } else { $duedate = null; } } // process duedate if ($availability) { if ($this->duedates) { foreach ($this->duedates as $key => $value) { if (preg_match($value, $item_status['desc'])) { $duedate = $key; break; } } } else { $duedate = $item_status['desc']; } } else { if ($status == "On Hold" || $status == "Requested") { $duedate = "requested"; } } $item_id = $item->attributes()->href; $item_id = substr($item_id, strrpos($item_id, '/') + 1); $note = (string) $z30->{'z30-note-opac'}; $holding[] = ['id' => $id, 'item_id' => $item_id, 'availability' => $availability, 'status' => (string) $item_status['desc'], 'location' => $sub_library_code, 'reserve' => 'N', 'callnumber' => (string) $z30->{'z30-call-no'}, 'duedate' => (string) $duedate, 'number' => (string) $z30->{'z30-inventory-number'}, 'barcode' => (string) $z30->{'z30-barcode'}, 'description' => (string) $z30->{'z30-description'}, 'notes' => $note == null ? null : [$note], 'is_holdable' => true, 'addLink' => $addLink, 'holdtype' => 'hold', 'collection' => (string) $collection, 'collection_desc' => (string) $collection_desc['desc'], 'callnumber_second' => (string) $z30->{'z30-call-no-2'}, 'sub_lib_desc' => (string) $item_status['sub_lib_desc'], 'no_of_loans' => (string) $z30->{'$no_of_loans'}, 'requested' => (string) $requested]; } return $holding; }
/** * Get Holding * * This is responsible for retrieving the holding information of a certain * record. * * @param string $id The record id to retrieve the holdings for * @param array $patron Patron data * * @throws \VuFind\Exception\Date * @throws ILSException * @return array On success, an associative array with the following * keys: id, availability (boolean), status, location, reserve, callnumber, * duedate, number, barcode. */ public function getHolding($id, array $patron = null, $filters = array()) { $holding = array(); list($bib, $sys_no) = $this->parseId($id); $resource = $bib . $sys_no; $params = array(); if (!empty($filters)) { foreach ($filters as $key => $value) { if ($key == 'hide_loans' && ($value = 'true')) { $params['loaned'] = 'NO'; } else { $params[$key] = $value; } } } $params['view'] = 'full'; if (!empty($patron['id'])) { $params['patron'] = $patron['id']; } else { if (isset($this->defaultPatronId)) { $params['patron'] = $this->defaultPatronId; } } $xml = $this->alephWebService->doRestDLFRequest(array('record', $resource, 'items'), $params); if (!isset($xml->{'items'})) { return $holding; } foreach ($xml->{'items'}->{'item'} as $item) { $item_status = $this->alephTranslator->tab15Translate($item); if ($item_status['opac'] != 'Y') { continue; } $availability = false; $reserve = $item_status['request'] == 'C' ? 'N' : 'Y'; $z30 = $item->z30; $collection = (string) $z30->{'z30-collection'}; $collection_desc = array('desc' => $collection); $collection_desc = $this->alephTranslator->tab40Translate($item); $sub_library_code = (string) $item->{'z30-sub-library-code'}; $requested = false; $duedate = null; $addLink = false; $status = (string) $item->{'status'}; if (in_array($status, $this->available_statuses)) { $availability = true; } if ($item_status['request'] == 'Y' && $availability == false) { $addLink = true; } $holdType = 'hold'; if (!empty($patron) || isset($this->defaultPatronId)) { $hold_request = $item->xpath('info[@type="HoldRequest"]/@allowed'); if ($hold_request[0] == 'N') { $hold_request = $item->xpath('info[@type="ShortLoan"]/@allowed'); if ($hold_request[0] == 'Y') { $holdType = 'shortloan'; } } $addLink = $hold_request[0] == 'Y'; } $matches = array(); if (preg_match("/([0-9]*\\/[a-zA-Z]*\\/[0-9]*);([a-zA-Z ]*)/", $status, $matches)) { $duedate = $this->parseDate($matches[1]); $requested = trim($matches[2]) == "Requested"; } else { if (preg_match("/([0-9]*\\/[a-zA-Z]*\\/[0-9]*)/", $status, $matches)) { $duedate = $this->parseDate($matches[1]); } } // process duedate_status $duedate_status = $item_status['desc']; if ($availability && $this->duedates) { foreach ($this->duedates as $key => $value) { if (preg_match($value, $item_status['desc'])) { $duedate_status = $key; break; } } } else { if (!$availability && ($status == "On Hold" || $status == "Requested")) { $duedate_status = "requested"; } } $item_id = $item->attributes()->href; $item_id = substr($item_id, strrpos($item_id, '/') + 1); $note = (string) $z30->{'z30-note-opac'}; $holding[] = array('id' => $id, 'item_id' => $item_id, 'availability' => $availability, 'status' => (string) $item_status['desc'], 'location' => $sub_library_code, 'reserve' => 'N', 'callnumber' => (string) $z30->{'z30-call-no'}, 'duedate' => (string) $duedate, 'number' => (string) $z30->{'z30-inventory-number'}, 'barcode' => (string) $z30->{'z30-barcode'}, 'description' => (string) $z30->{'z30-description'}, 'notes' => $note == null ? null : array($note), 'is_holdable' => true, 'addLink' => $addLink, 'holdtype' => $holdType, 'duedate_status' => $status, 'collection' => (string) $collection, 'collection_desc' => (string) $collection_desc['desc'], 'callnumber_second' => (string) $z30->{'z30-call-no-2'}, 'sub_lib_desc' => (string) $item_status['sub_lib_desc'], 'no_of_loans' => (string) $z30->{'$no_of_loans'}, 'requested' => (string) $requested); } return $holding; }