|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* Implementation of Roblib search for searching several targets.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements hook_menu().
|
|
|
|
*/
|
|
|
|
function roblib_search_eds_menu() {
|
|
|
|
$items = array();
|
|
|
|
|
|
|
|
$items['admin/roblib_search/eds_search'] = array(
|
|
|
|
'title' => 'EDS search Target configuration',
|
|
|
|
'description' => 'Configuration for the Roblib eds search target',
|
|
|
|
'page callback' => 'drupal_get_form',
|
|
|
|
'page arguments' => array('roblib_search_eds_config_form'),
|
|
|
|
'access arguments' => array('access administration pages'),
|
|
|
|
'type' => MENU_NORMAL_ITEM,
|
|
|
|
);
|
|
|
|
|
|
|
|
$items['roblib_search/eds/ajax/%'] = array(
|
|
|
|
'title' => 'eds ajax',
|
|
|
|
'page callback' => 'roblib_search_eds_ajax',
|
|
|
|
'page arguments' => array(3),
|
|
|
|
'type' => MENU_CALLBACK,
|
|
|
|
'access arguments' => array('search roblib eds'),
|
|
|
|
);
|
|
|
|
$items['roblib_search/eds/articles/%'] = array(
|
|
|
|
'title' => 'eds ajax',
|
|
|
|
'page callback' => 'roblib_search_eds_articles',
|
|
|
|
'page arguments' => array(3),
|
|
|
|
'type' => MENU_CALLBACK,
|
|
|
|
'access arguments' => array('search roblib eds'),
|
|
|
|
);
|
|
|
|
|
|
|
|
$items['roblib_search/eds/info/%'] = array(
|
|
|
|
'title' => 'eds info',
|
|
|
|
'page callback' => 'roblib_search_eds_info',
|
|
|
|
'page arguments' => array(3),
|
|
|
|
'type' => MENU_CALLBACK,
|
|
|
|
'access arguments' => array('search roblib eds'),
|
|
|
|
);
|
|
|
|
|
|
|
|
return $items;
|
|
|
|
}
|
|
|
|
|
|
|
|
function roblib_search_eds_info($type = 'Articles') {
|
|
|
|
$config = roblib_search_eds_build_config_arr($type);
|
|
|
|
$eds_api = new EBSCOAPI($config);
|
|
|
|
$output['type'] = $type;
|
|
|
|
$output['profile'] = $eds_api->getInfo();
|
|
|
|
print json_encode($output);
|
|
|
|
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements hook_permission().
|
|
|
|
*/
|
|
|
|
/*function roblib_search_eds_permission() {
|
|
|
|
return array(
|
|
|
|
'search roblib eds' => array(
|
|
|
|
'title' => t('Search the eds target'),
|
|
|
|
'description' => t('Search Roblib eds target. This permission exposes the search blocks and allows you to see search results.'),
|
|
|
|
),
|
|
|
|
'administer roblib search eds' => array(
|
|
|
|
'title' => t('Administer Roblib Search EDS'),
|
|
|
|
'description' => t('Administer settings for the Roblib eds search client.'),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements hook_theme().
|
|
|
|
*/
|
|
|
|
function roblib_search_eds_theme($existing, $type, $theme, $path) {
|
|
|
|
$modulePath = \Drupal::service('module_handler')->getModule('roblib_search')
|
|
|
|
->getPath();
|
|
|
|
$spinner_path = '/' . $modulePath . "/img/spinner.gif";
|
|
|
|
return [
|
|
|
|
'roblib_search_eds_books' => [
|
|
|
|
'variables' => ['query' => NULL, 'spinner_path' => $spinner_path],
|
|
|
|
],
|
|
|
|
'roblib_search_eds_articles' => [
|
|
|
|
'variables' => ['query' => NULL, 'spinner_path' => $spinner_path],
|
|
|
|
],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*function roblib_search_eds_ajax($query) {
|
|
|
|
print roblib_search_eds_get_results($query, 'Books');
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
function roblib_search_eds_articles($query) {
|
|
|
|
print roblib_search_eds_get_results($query, 'Articles');
|
|
|
|
exit();
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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) {
|
|
|
|
foreach ($output['records'] as &$record) {
|
|
|
|
$db = $record['DbId'];
|
|
|
|
$an = $record['An'];
|
|
|
|
$arr = $eds_api->apiRetrieve($an, $db, $query);
|
|
|
|
$record['DetailedRecord'] = $arr['Items'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements hook_help().
|
|
|
|
*
|
|
|
|
* @param type $path
|
|
|
|
* @param type $arg
|
|
|
|
* @return type
|
|
|
|
*/
|
|
|
|
function roblib_search_eds_help($path, $arg) {
|
|
|
|
switch ($path) {
|
|
|
|
case 'admin/help#roblib_search_eds':
|
|
|
|
return t(
|
|
|
|
'<p>
|
|
|
|
provides a target for the Roblib search module. This target uses javascript
|
|
|
|
to render the results.
|
|
|
|
</p>'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|