From 2fa82cdcf944153e5202733edf04fef7114f69ee Mon Sep 17 00:00:00 2001 From: Martin Cording Date: Wed, 4 Jun 2014 10:15:22 +0200 Subject: [PATCH] case 3993 - Provide the possibility searching with CCL in DDE. Signed-off-by: Martin Cording --- lib/AlmaClient/AlmaClient.class.php | 55 +++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/lib/AlmaClient/AlmaClient.class.php b/lib/AlmaClient/AlmaClient.class.php index fd1a1b2..978c3df 100644 --- a/lib/AlmaClient/AlmaClient.class.php +++ b/lib/AlmaClient/AlmaClient.class.php @@ -978,6 +978,61 @@ public function remove_message_service($borr_card, $pin_code, $method, $type) { return TRUE; } + /** + * Runs search across the service. + * + * @param string $query + * Query string. + * @param string $type + * Search type, usually 'native'. + * @param int $start + * The search offset. + * @param int $limit + * Result set limit. + * + * @return Array + * Set of items id's. + */ + public function run_lms_search($query, $type, $start, $limit) { + $params = array( + 'searchText' => $query, + 'searchType' => $type, + 'startNo' => $start, + 'nofRecords' => $limit, + ); + + $doc = $this->request('catalogue/fulltextsearch', $params); + + return $this->process_lms_search($doc); + } + + /** + * Process the search response from WS. + * + * Munge the DOM structure into an array. + * + * @param DOMElement $elem + * WS response in DOM format. + * + * @return Array + * Array of result values. + */ + private function process_lms_search($elem) { + $response = array( + 'status' => $elem->getElementsByTagName('status')->item(0)->getAttribute('value'), + 'numRecords' => $elem->getElementsByTagName('nofRecords')->item(0)->nodeValue, + 'numrecordsTotal' => $elem->getElementsByTagName('nofRecordsTotal')->item(0)->nodeValue, + 'start' => $elem->getElementsByTagName('startNo')->item(0)->nodeValue, + 'limit' => $elem->getElementsByTagName('stopNo')->item(0)->nodeValue, + 'items' => array(), + ); + + foreach ($elem->getElementsByTagName('catalogueRecord') as $record) { + $response['items'][] = $record->getAttribute('id'); + } + + return $response; + } } /**