Browse Source

read eds profile from database for see all results link

2.x-ebsco
Paul Pound 10 years ago
parent
commit
dbb087970b
  1. 3
      targets/eds/js/eds_results.js
  2. 3
      targets/eds/js/eds_results_article.js
  3. 19
      targets/eds/theme/theme.inc

3
targets/eds/js/eds_results.js

@ -1,6 +1,7 @@
Drupal.behaviors.roblib_search_eds = { Drupal.behaviors.roblib_search_eds = {
attach: function(context, settings) { attach: function(context, settings) {
$url = settings.roblib_search_eds.search_url; $url = settings.roblib_search_eds.search_url;
profile = settings.roblib_search_eds.eds_profile;
jQuery.getJSON($url, function(data) { jQuery.getJSON($url, function(data) {
var items = []; var items = [];
var numberOfDocs = 0; var numberOfDocs = 0;
@ -65,7 +66,7 @@ Drupal.behaviors.roblib_search_eds = {
var query_str = data.queries[0].query; var query_str = data.queries[0].query;
//var host = "http://eds-api.ebscohost.com"; //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 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('<a href="'+href_str+query_str+'" id="see_all_results">See all results</a>'); jQuery('#roblib-search-eds-more').empty().append('<a href="'+href_str+query_str+'" id="see_all_results">See all results</a>');
}); });

3
targets/eds/js/eds_results_article.js

@ -1,6 +1,7 @@
Drupal.behaviors.roblib_search_eds_articles = { Drupal.behaviors.roblib_search_eds_articles = {
attach: function(context, settings) { attach: function(context, settings) {
$url = settings.roblib_search_eds_articles.search_url; $url = settings.roblib_search_eds_articles.search_url;
profile = settings.roblib_search_eds.eds_profile;
jQuery.getJSON($url, function(data) { jQuery.getJSON($url, function(data) {
var items = []; var items = [];
var numberOfDocs = 0; var numberOfDocs = 0;
@ -56,7 +57,7 @@ Drupal.behaviors.roblib_search_eds_articles = {
queries.push(query.query); queries.push(query.query);
}) })
var query_str = data.queries[0].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('<a href="'+href_str+query_str+'" id="eds-article-see-all-results">See all results</a>'); jQuery('#roblib-search-eds-article-more').empty().append('<a href="'+href_str+query_str+'" id="eds-article-see-all-results">See all results</a>');
}); });

19
targets/eds/theme/theme.inc

@ -5,6 +5,8 @@
* loaded async * loaded async
*/ */
// TODO: combine these two functions and call this function from the preprocessor
function roblib_search_eds_preprocess_roblib_search_eds(&$variables) { function roblib_search_eds_preprocess_roblib_search_eds(&$variables) {
global $base_url; global $base_url;
if (!isset($query)) { if (!isset($query)) {
@ -19,8 +21,13 @@ function roblib_search_eds_preprocess_roblib_search_eds(&$variables) {
$variables['spinner_path'] = $spinner_path; $variables['spinner_path'] = $spinner_path;
$search_url = $base_url . '/roblib_search/eds/ajax/' . urlencode($query); $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(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(array(
drupal_add_js("http://supportforms.epnet.com/eit/scripts/ebscohostsearch.js", 'external'); '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; $variables['spinner_path'] = $spinner_path;
$search_url = $base_url . '/roblib_search/eds/articles/' . urlencode($query); $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(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'));
} }

Loading…
Cancel
Save