From 4b86b2b19c74dc29ca72b2948a8d7b52b3f6c0e4 Mon Sep 17 00:00:00 2001 From: Paul Pound Date: Mon, 11 Dec 2017 10:28:53 -0400 Subject: [PATCH] added NON UPEI links to ebsco results added is local ip to javascript for link generation --- targets/eds/js/eds_results.js | 13 +++++++++---- targets/eds/js/eds_results_article.js | 13 +++++++++---- targets/eds/roblib_search_eds.module | 6 +++++- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/targets/eds/js/eds_results.js b/targets/eds/js/eds_results.js index 4a6bdbe..901ee37 100644 --- a/targets/eds/js/eds_results.js +++ b/targets/eds/js/eds_results.js @@ -71,10 +71,15 @@ Drupal.behaviors.roblib_search_eds = { }); jQuery('#' + 'roblib-search-content-eds').empty().append(items.join('')); } - - jQuery('#roblib-search-eds-more').empty().append('See all results (' + data.recordCount + ')'); - jQuery('#roblib-eds-books-more-results').empty().append('See all results (' + data.recordCount + ')'); - jQuery('#roblib-eds-books-toc').empty().append('Books (' + data.recordCount + ')'); + var non_upei_link = ''; + var upei_link = 'SEE ALL (' + data.recordCount + ') '; + if(!data.is_local_ip) { + non_upei_link = '[Non-UPEI]'; + upei_link = 'SEE ALL (' + data.recordCount + ') ' + non_upei_link; + } + jQuery('#roblib-search-eds-more').empty().append(upei_link); + jQuery('#roblib-eds-books-more-results').empty().append(upei_link); + jQuery('#roblib-eds-books-toc').empty().append('Articles (' + data.recordCount + ')'); }); } diff --git a/targets/eds/js/eds_results_article.js b/targets/eds/js/eds_results_article.js index e21b66d..8b4b265 100644 --- a/targets/eds/js/eds_results_article.js +++ b/targets/eds/js/eds_results_article.js @@ -68,10 +68,15 @@ Drupal.behaviors.roblib_search_eds_articles = { }); jQuery('#' + 'roblib-search-content-eds-articles').empty().append(items.join('')); } - - jQuery('#roblib-search-eds-article-more').empty().append('See all results (' + data.recordCount + ')'); - jQuery('#roblib-eds-articles-more-results').empty().append('See all results (' + data.recordCount + ')'); - jQuery('#roblib-eds-articles-toc').empty().append('Articles (' + data.recordCount + ')'); + var non_upei_link = ''; + var upei_link = 'SEE ALL (' + data.recordCount + ') '; + if(!data.is_local_ip) { + non_upei_link = '[Non-UPEI]'; + upei_link = 'SEE ALL (' + data.recordCount + ') ' + non_upei_link; + } + jQuery('#roblib-search-eds-article-more').empty().append(upei_link); + jQuery('#roblib-eds-articles-more-results').empty().append(upei_link); + jQuery('#roblib-eds-articles-toc').empty().append('Articles (' + data.recordCount + ')'); }); } diff --git a/targets/eds/roblib_search_eds.module b/targets/eds/roblib_search_eds.module index 60ddbfc..eb24b67 100644 --- a/targets/eds/roblib_search_eds.module +++ b/targets/eds/roblib_search_eds.module @@ -270,8 +270,12 @@ function roblib_search_eds_get_results($query = NULL, $type = 'Articles') { $query .= $limiters; $search = array('lookfor' => $query, 'type' => 'ALLFields', 'index' => 'AllFields', 'q' => 'ebsco/results', 'op' => 'Search'); $eds_api = new EBSCOAPI($config); - $eds_api->isGuest(boolval(variable_get('roblib_search_eds_guest','y'))); + $is_local_ip = $eds_api->connector()->isGuestIPAddress($_SERVER["REMOTE_ADDR"]); + //$eds_api->isGuest(boolval(variable_get('roblib_search_eds_guest','y'))); + $eds_api->isGuest(!$is_local_ip); + $output = $eds_api->apiSearch($search, $filters, 1, $number_per_page); + $output['is_local_ip'] = $is_local_ip; return json_encode($output); }