@ -198,13 +198,7 @@ function roblib_search_eds_block_info() {
function roblib_search_eds_block_view($delta = '') {
function roblib_search_eds_block_view($delta = '') {
switch ($delta) {
switch ($delta) {
case 'roblib_search_eds_results':
case 'roblib_search_eds_results':
// The subject is displayed at the top of the block. Note that it
// should be passed through t() for translation. The title configured
// for the block using Drupal UI supercedes this one.
$block['subject'] = t('Books & Media');
$block['subject'] = t('Books & Media');
// The content of the block is typically generated by calling a custom
// function.
// $block['content'] = roblib_search_eds_get_results();
$block['content'] = theme('roblib_search_eds', array('results' => NULL));
$block['content'] = theme('roblib_search_eds', array('results' => NULL));
break;
break;
@ -257,10 +251,23 @@ function roblib_search_eds_get_results($query = NULL, $type = NULL) {
//$params = "query=AND,$query&view=detailed&includefacets=n&$limiters&resultsperpage=$number_per_page";
//$params = "query=AND,$query&view=detailed&includefacets=n&$limiters&resultsperpage=$number_per_page";
$params = "query=AND,$query&view=detailed&includefacets=n&resultsperpage=$number_per_page";
$params = "query=AND,$query&view=detailed&includefacets=n&resultsperpage=$number_per_page";
$output = $eds_api->apiSearch($params);
$output = $eds_api->apiSearch($params);
$output = roblib_search_eds_get_detailed_result($output, $query, $eds_api);
roblib_search_eds_get_detailed_result($output, $query, $eds_api);
return json_encode($output);
return json_encode($output);
}
}
/**
* For each result query ebsco again to get the detailed record.
*
* and insert a new DetailedRecord element in each record.
*
* @param array $output
* The orginal search results array
* @param string $query
* The orginal query
* @param object $eds_api
* an ebco API PHP object
*/
function roblib_search_eds_get_detailed_result(&$output, $query, &$eds_api) {
function roblib_search_eds_get_detailed_result(&$output, $query, &$eds_api) {
foreach ($output['records'] as &$record) {
foreach ($output['records'] as &$record) {
$db = $record['DbId'];
$db = $record['DbId'];
@ -268,9 +275,17 @@ function roblib_search_eds_get_detailed_result(&$output, $query, &$eds_api) {
$arr = $eds_api->apiRetrieve($an, $db, $query);
$arr = $eds_api->apiRetrieve($an, $db, $query);
$record['DetailedRecord'] = $arr['Items'];
$record['DetailedRecord'] = $arr['Items'];
}
}
return $output;
}
}
/**
* Creates the limiter string to append to the end of a query.
*
* @param string $type
* The type of search we want (Articles or Books)
*
* @return string
* The limiters to append to the query.
*/
function roblib_search_eds_get_query_limiters($type) {
function roblib_search_eds_get_query_limiters($type) {
$limiters = 'n';
$limiters = 'n';
switch ($type) {
switch ($type) {