Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

case 3993 - Provide the possibility searching with CCL in DDE. #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions lib/AlmaClient/AlmaClient.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

/**
Expand Down