From 39fa8c4c5796bad164cbb8bf0b880106f058951d Mon Sep 17 00:00:00 2001 From: Paul Pound Date: Fri, 12 Apr 2013 16:14:55 -0300 Subject: [PATCH] updates to eds target --- roblib_search.module | 5 +- targets/eds/css/roblib_search_eds.css | 13 ++++++ targets/eds/includes/rest/Config.xml | 24 ---------- targets/eds/js/eds_results.js | 51 ++++++++++++++++----- targets/eds/roblib_search_eds.info | 2 +- targets/eds/roblib_search_eds.module | 50 +++++++++++++++----- targets/eds/theme/roblib-search-eds.tpl.php | 2 +- 7 files changed, 96 insertions(+), 51 deletions(-) create mode 100644 targets/eds/css/roblib_search_eds.css delete mode 100644 targets/eds/includes/rest/Config.xml diff --git a/roblib_search.module b/roblib_search.module index 027e656..ae2c296 100644 --- a/roblib_search.module +++ b/roblib_search.module @@ -134,10 +134,11 @@ function roblib_search_block_view($delta = '') { * @param array $form_state */ function roblib_search_simple_form_submit($form, &$form_state) { + global $base_url; $form_state['rebuild'] = TRUE; $search_string = $form_state['values']['roblib_search_simple_search_query']; - $redirect_url = variable_get('roblib_search_panel_page','/roblib/panel'); - + $redirect_url = variable_get('roblib_search_panel_page','roblib/panel'); + $redirect_url = $base_url. '/' . $redirect_url; drupal_goto($redirect_url, array('query' => array('roblib_query' => $search_string))); } diff --git a/targets/eds/css/roblib_search_eds.css b/targets/eds/css/roblib_search_eds.css new file mode 100644 index 0000000..f52b497 --- /dev/null +++ b/targets/eds/css/roblib_search_eds.css @@ -0,0 +1,13 @@ +/* + Document : roblib_search_evergreen + Created on : Apr 11, 2013, 2:27:50 PM + Author : ppound + Description: + Purpose of the stylesheet follows. +*/ + + +.highlight {font-weight: bolder; } +.eds-sor, .eds-date, .eds-holdings-item, .eds-db, .eds-src, .eds-pubinfo, .eds-type{ + padding-left: 10px; font-size: smaller; +} diff --git a/targets/eds/includes/rest/Config.xml b/targets/eds/includes/rest/Config.xml deleted file mode 100644 index 507f5f7..0000000 --- a/targets/eds/includes/rest/Config.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - EDS API-PHP Demo 1.4 - - http://eds-api.ebscohost.com/edsapi/rest - https://eds-api.ebscohost.com/Authservice/rest - - 300 - - - insert client side profile - insert client side profile - - - - - - guest - uprince - robertson1 - edsapi - - - diff --git a/targets/eds/js/eds_results.js b/targets/eds/js/eds_results.js index 84373ba..64f5217 100644 --- a/targets/eds/js/eds_results.js +++ b/targets/eds/js/eds_results.js @@ -7,19 +7,48 @@ Drupal.behaviors.roblib_search_eds = { jQuery('#' + 'roblib-search-content-eds').empty().append('No Results'); } else { jQuery.each(data.records, function(key, val) { - items.push('
'); - jQuery.each(val.RecordInfo.BibEntity.Titles, function(key2, val2){ - items.push('
'); - items.push(val2.TitleFull+'
'); - }) - items.push('
'); + + //items.push(''); + //jQuery.each(val.RecordInfo.BibEntity.Titles, function(key2, val2){ + if (typeof val.Items !== 'undefined') { + items.push('
'); + if (typeof val.Items.Ti !== 'undefined') { + jQuery.each(val.Items.Ti, function(key2, val2){ + items.push(''); + }) + } + jQuery.each(val.RecordInfo.BibRelationships.HasContributorRelationships, function(key3, authors){ + items.push('
'+authors.NameFull+'
'); + }) + if (typeof val.Items.Src !== 'undefined') { + jQuery.each(val.Items.Src, function(key4, source){ + items.push('
'+source.Data+'
'); + }) + } + if (typeof val.Items.PubIrInfo !== 'undefined') { + jQuery.each(val.Items.PubIrInfo, function(key5, pubinfo){ + items.push('
'+pubinfo.Data+'
'); + }) + } + if (typeof val.Items.TypPub !== 'undefined') { + jQuery.each(val.Items.TypPub, function(key6, typpub){ + items.push('
'+typpub.Data+'
'); + }) + } + + items.push('
'+val.DbLabel+'
'); + + items.push('
'); + } }); } jQuery('#' + 'roblib-search-content-eds').empty().append(items.join('')); + var queries = []; + jQuery.each(data.queries, function(key7, query){ + queries.push(query.query); + }) + jQuery('#roblib-search-eds-more').empty().append('See all ' + data.recordCount + ' results'); }); - } - + } } - - - diff --git a/targets/eds/roblib_search_eds.info b/targets/eds/roblib_search_eds.info index 4fee8a5..49d8cae 100644 --- a/targets/eds/roblib_search_eds.info +++ b/targets/eds/roblib_search_eds.info @@ -5,7 +5,7 @@ description = implements the Roblib Search modules _roblib_search hook package = Roblib Search version = 7.x-dev core = 7.x -stylesheets[all][] = css/roblib_search_eds.base.css +stylesheets[all][] = css/roblib_search_eds.css files[] = includes/rest/EBSCOAPI.php files[] = includes/rest/EBSCOConnector.php files[] = includes/rest/EBSCOResponse.php \ No newline at end of file diff --git a/targets/eds/roblib_search_eds.module b/targets/eds/roblib_search_eds.module index 010e021..c5ec170 100644 --- a/targets/eds/roblib_search_eds.module +++ b/targets/eds/roblib_search_eds.module @@ -4,10 +4,10 @@ * @file * Implementation of Roblib search for searching several targets. */ - require_once dirname(__FILE__) . '/includes/rest/EBSCOConnector.php'; require_once dirname(__FILE__) . '/includes/rest/EBSCOResponse.php'; require_once dirname(__FILE__) . '/includes/rest/EBSCOConnector.php'; + /** * Implements hook_boot(). * @global type $conf @@ -56,11 +56,26 @@ function roblib_search_eds_menu() { 'access arguments' => array('search roblib eds'), ); + $items['roblib_search/eds/info'] = array( + 'title' => 'eds info', + 'page callback' => 'roblib_search_eds_info', + 'type' => MENU_CALLBACK, + 'access arguments' => array('search roblib eds'), + ); + return $items; } +function roblib_search_eds_info() { + $config = roblib_search_eds_build_config_arr(); + $eds_api = new EBSCOAPI($config); + $output = $eds_api->getInfo(); + print json_encode($output); + exit(); +} + function roblib_search_eds_config_form($form, &$form_state) { - + $form['roblib_search_eds_rest_url'] = array( '#type' => 'textfield', '#title' => t('EDS Rest endpoint'), @@ -75,7 +90,7 @@ function roblib_search_eds_config_form($form, &$form_state) { '#description' => t('The EDS Auth endpoint, for example https://eds-api.ebscohost.com/Authservice/rest'), '#required' => TRUE, ); - + $form['roblib_search_eds_user'] = array( '#type' => 'textfield', '#title' => t('EDS user'), @@ -83,7 +98,7 @@ function roblib_search_eds_config_form($form, &$form_state) { '#description' => t('EDS user, for example username'), '#required' => TRUE, ); - + $form['roblib_search_eds_pass'] = array( '#type' => 'textfield', '#title' => t('EDS password'), @@ -91,15 +106,15 @@ function roblib_search_eds_config_form($form, &$form_state) { '#description' => t('EDS password, for example password'), '#required' => TRUE, ); - - $form['roblib_search_eds_profile'] = array( + + $form['roblib_search_eds_profile'] = array( '#type' => 'textfield', '#title' => t('EDS profile'), '#default_value' => variable_get('roblib_search_eds_profile', 'edsapi'), '#description' => t('EDS profile, for example edsapi'), '#required' => TRUE, ); - + $form['roblib_search_eds_num_results'] = array( '#type' => 'textfield', '#title' => t('Number of results to return'), @@ -180,6 +195,7 @@ function roblib_search_eds_ajax($query) { print roblib_search_eds_get_results($query); exit(); } + /** * * @param string $query @@ -198,21 +214,31 @@ function roblib_search_eds_get_results($query = NULL) { return ''; } } - //TODO move this to drupal variables - $config = array(); - $config['user'] = variable_get('roblib_search_eds_user', 'edsusername'); + + $config = roblib_search_eds_build_config_arr(); + /*$config['user'] = variable_get('roblib_search_eds_user', 'edsusername'); $config['pass'] = variable_get('roblib_search_eds_pass', 'edspassword'); $config['profile'] = variable_get('roblib_search_eds_profile', 'edsapi'); $config['auth_url'] = variable_get('roblib_search_eds_auth_url', 'https://eds-api.ebscohost.com/Authservice/rest'); - $config['rest_url'] = variable_get('roblib_search_eds_rest_url', 'http://eds-api.ebscohost.com/edsapi/rest'); + $config['rest_url'] = variable_get('roblib_search_eds_rest_url', 'http://eds-api.ebscohost.com/edsapi/rest');*/ $eds_api = new EBSCOAPI($config); $number_per_page = variable_get('roblib_search_eds_num_results', '5'); $query = urlencode($query); - $params = "query=$query&includefacets=n&resultsperpage=$number_per_page"; + $params = "query=AND,$query&includefacets=n&resultsperpage=$number_per_page"; $output = $eds_api->apiSearch($params); return json_encode($output); } +function roblib_search_eds_build_config_arr() { + $config = array(); + $config['user'] = variable_get('roblib_search_eds_user', 'edsusername'); + $config['pass'] = variable_get('roblib_search_eds_pass', 'edspassword'); + $config['profile'] = variable_get('roblib_search_eds_profile', 'edsapi'); + $config['auth_url'] = variable_get('roblib_search_eds_auth_url', 'https://eds-api.ebscohost.com/Authservice/rest'); + $config['rest_url'] = variable_get('roblib_search_eds_rest_url', 'http://eds-api.ebscohost.com/edsapi/rest'); + return $config; +} + /** * Implements hook_help(). * diff --git a/targets/eds/theme/roblib-search-eds.tpl.php b/targets/eds/theme/roblib-search-eds.tpl.php index 4661acb..2e244d8 100644 --- a/targets/eds/theme/roblib-search-eds.tpl.php +++ b/targets/eds/theme/roblib-search-eds.tpl.php @@ -21,4 +21,4 @@ -
Search all EDS
\ No newline at end of file +
\ No newline at end of file