From dbb087970ba833fe5b88f026a65767638b89c072 Mon Sep 17 00:00:00 2001 From: Paul Pound Date: Wed, 20 Aug 2014 09:53:13 -0300 Subject: [PATCH] read eds profile from database for see all results link --- targets/eds/js/eds_results.js | 3 ++- targets/eds/js/eds_results_article.js | 3 ++- targets/eds/theme/theme.inc | 19 ++++++++++++++++--- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/targets/eds/js/eds_results.js b/targets/eds/js/eds_results.js index d155d89..8120eac 100644 --- a/targets/eds/js/eds_results.js +++ b/targets/eds/js/eds_results.js @@ -1,6 +1,7 @@ Drupal.behaviors.roblib_search_eds = { attach: function(context, settings) { $url = settings.roblib_search_eds.search_url; + profile = settings.roblib_search_eds.eds_profile; jQuery.getJSON($url, function(data) { var items = []; var numberOfDocs = 0; @@ -65,7 +66,7 @@ Drupal.behaviors.roblib_search_eds = { var query_str = data.queries[0].query; //var host = "http://eds-api.ebscohost.com"; //var get = "/edsapi/rest/Search?query=history&searchmode=all&resultsperpage=20&pagenumber=1&sort=relevance&highlight=y&includefacets=y&facetfilter=1%2cSourceType%3aMagazines%2cSourceType%3aNews%2cSourceType%3aAcademic+Journals%2cSourceType%3aConference+Materials&view=detailed"; - var href_str = 'http://search.ebscohost.com/login.aspx?direct=true&site=ehost-live&scope=site&type=1&custid=uprince&groupid=main&profid=eds&mode=bool&lang=en&bquery='; + var href_str = 'http://search.ebscohost.com/login.aspx?direct=true&site=ehost-live&scope=site&type=1&custid=uprince&groupid=main&profid=' + profile + '&mode=bool&lang=en&bquery='; jQuery('#roblib-search-eds-more').empty().append('See all results'); }); diff --git a/targets/eds/js/eds_results_article.js b/targets/eds/js/eds_results_article.js index 17e490e..a1a0e39 100644 --- a/targets/eds/js/eds_results_article.js +++ b/targets/eds/js/eds_results_article.js @@ -1,6 +1,7 @@ Drupal.behaviors.roblib_search_eds_articles = { attach: function(context, settings) { $url = settings.roblib_search_eds_articles.search_url; + profile = settings.roblib_search_eds.eds_profile; jQuery.getJSON($url, function(data) { var items = []; var numberOfDocs = 0; @@ -56,7 +57,7 @@ Drupal.behaviors.roblib_search_eds_articles = { queries.push(query.query); }) var query_str = data.queries[0].query; - var href_str = 'http://search.ebscohost.com/login.aspx?direct=true&site=ehost-live&scope=site&type=1&custid=uprince&groupid=main&profid=eds&mode=bool&lang=en&bquery='; + var href_str = 'http://search.ebscohost.com/login.aspx?direct=true&site=ehost-live&scope=site&type=1&custid=uprince&groupid=main&profid=' + profile +'&mode=bool&lang=en&bquery='; jQuery('#roblib-search-eds-article-more').empty().append('See all results'); }); diff --git a/targets/eds/theme/theme.inc b/targets/eds/theme/theme.inc index 3796459..0986f67 100644 --- a/targets/eds/theme/theme.inc +++ b/targets/eds/theme/theme.inc @@ -5,6 +5,8 @@ * loaded async */ +// TODO: combine these two functions and call this function from the preprocessor + function roblib_search_eds_preprocess_roblib_search_eds(&$variables) { global $base_url; if (!isset($query)) { @@ -19,8 +21,13 @@ function roblib_search_eds_preprocess_roblib_search_eds(&$variables) { $variables['spinner_path'] = $spinner_path; $search_url = $base_url . '/roblib_search/eds/ajax/' . urlencode($query); drupal_add_js(drupal_get_path('module', 'roblib_search_eds') . '/js/eds_results.js'); - drupal_add_js(array('roblib_search_eds' => array('search_url' => $search_url)), array('type' => 'setting')); - drupal_add_js("http://supportforms.epnet.com/eit/scripts/ebscohostsearch.js", 'external'); + drupal_add_js(array( + 'roblib_search_eds' => array( + 'search_url' => $search_url, + 'eds_profile' => + variable_get('roblib_search_eds_profile', 'edsapi') + ) + ), array('type' => 'setting')); } @@ -38,7 +45,13 @@ function roblib_search_eds_preprocess_roblib_search_eds_articles(&$variables) { $variables['spinner_path'] = $spinner_path; $search_url = $base_url . '/roblib_search/eds/articles/' . urlencode($query); drupal_add_js(drupal_get_path('module', 'roblib_search_eds') . '/js/eds_results_article.js'); - drupal_add_js(array('roblib_search_eds_articles' => array('search_url' => $search_url)), array('type' => 'setting')); + drupal_add_js(array( + 'roblib_search_eds_articles' => array( + 'search_url' => $search_url, + 'eds_profile' => + variable_get('roblib_search_eds_profile', 'edsapi') + ) + ), array('type' => 'setting')); }