From 4a8295aa7b0cf6289315bcfe3fcee6f3d73f47f0 Mon Sep 17 00:00:00 2001 From: Paul Pound Date: Thu, 26 Jun 2014 11:53:09 -0300 Subject: [PATCH] added other source target and code cleanup some experimentation linking back to ebsco --- roblib_search.module | 36 ++++++++++++++----- .../cufts/theme/roblib-search-cufts.tpl.php | 13 +------ targets/eds/js/eds_results.js | 2 ++ targets/eds/js/eds_results_article.js | 3 +- targets/eds/roblib_search_eds.module | 2 +- .../theme/roblib-search-eds-articles.tpl.php | 16 ++++++++- targets/eds/theme/roblib-search-eds.tpl.php | 14 ++------ targets/eds/theme/theme.inc | 1 + .../theme/roblib-search-evergreen.tpl.php | 15 ++------ .../theme/roblib-search-islandscholar.tpl.php | 15 ++------ theme/roblib-search-other-sources.tpl.php | 19 ++++++++++ theme/roblib-search-wrapper.tpl.php | 27 -------------- theme/theme.inc | 13 +++++-- 13 files changed, 85 insertions(+), 91 deletions(-) create mode 100644 theme/roblib-search-other-sources.tpl.php delete mode 100644 theme/roblib-search-wrapper.tpl.php diff --git a/roblib_search.module b/roblib_search.module index ff4c1a2..d8ea0ca 100644 --- a/roblib_search.module +++ b/roblib_search.module @@ -72,17 +72,36 @@ function roblib_search_permission() { function roblib_search_block_info() { $blocks['roblib_search_form'] = array( - // info: The name of the block. 'info' => t('Roblib Global Search Form'), - // Block caching options (per role, per user, etc.) - // Default. + 'cache' => DRUPAL_CACHE_PER_ROLE, + ); + $blocks['roblib_search_other'] = array( + 'info' => t('Roblib Search Other Sources'), 'cache' => DRUPAL_CACHE_PER_ROLE, ); return $blocks; } -function roblib_search_init(){ +/** + * Implements hook_theme(). + */ +function roblib_search_theme() { + // set path + $path = drupal_get_path('module', 'roblib_search'); + $file = 'theme.inc'; + + return array( + 'roblib_search_other_sources' => array( + 'path' => $path . '/theme', + 'file' => $file, + 'template' => 'roblib-search-other-sources', + 'variables' => array('results' => NULL), + ) + ); +} + +function roblib_search_init() { // Make qtip available for all targets js. drupal_add_js(drupal_get_path('module', 'roblib_search') . '/js/jquery.qtip.min.js'); drupal_add_js(drupal_get_path('module', 'roblib_search') . '/js/imagesloaded.pkg.min.js'); @@ -93,14 +112,13 @@ function roblib_search_init(){ function roblib_search_block_view($delta = '') { switch ($delta) { case 'roblib_search_form': - // The subject is displayed at the top of the block. Note that it - // should be passed through t() for translation. The title configured - // for the block using Drupal UI supercedes this one. $block['subject'] = t('Bento Search'); - // The content of the block is typically generated by calling a custom - // function. $block['content'] = drupal_get_form('roblib_search_simple_form'); break; + + case 'roblib_search_other': + $block['subject'] = t('Other Sources'); + $block['content'] = theme('roblib_search_other_sources', array('results' => NULL)); } return $block; } diff --git a/targets/cufts/theme/roblib-search-cufts.tpl.php b/targets/cufts/theme/roblib-search-cufts.tpl.php index 540bacb..384e554 100644 --- a/targets/cufts/theme/roblib-search-cufts.tpl.php +++ b/targets/cufts/theme/roblib-search-cufts.tpl.php @@ -1,19 +1,8 @@
diff --git a/targets/eds/js/eds_results.js b/targets/eds/js/eds_results.js index cb02fc4..6e5029c 100644 --- a/targets/eds/js/eds_results.js +++ b/targets/eds/js/eds_results.js @@ -63,6 +63,8 @@ Drupal.behaviors.roblib_search_eds = { queries.push(query.query); }) 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='; jQuery('#roblib-search-eds-more').empty().append('See all ' + data.recordCount + ' results'); diff --git a/targets/eds/js/eds_results_article.js b/targets/eds/js/eds_results_article.js index c5cac4b..0d005c7 100644 --- a/targets/eds/js/eds_results_article.js +++ b/targets/eds/js/eds_results_article.js @@ -56,7 +56,8 @@ 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=0&custid=uprince&profid=eds&groupid=main&mode=and&cli0=RV&clv0=N&lang=en' + + '&authtype=ip,guest&cli2=FT&clv2=N&cli3=&clv3=(ST+Academic+Journal+or+ST+Conference+Materials+or+ST+News+or+ST+Magazines)&bquery='; jQuery('#roblib-search-eds-article-more').empty().append('See all ' + data.recordCount + ' results'); }); diff --git a/targets/eds/roblib_search_eds.module b/targets/eds/roblib_search_eds.module index 4f440c1..41b729f 100644 --- a/targets/eds/roblib_search_eds.module +++ b/targets/eds/roblib_search_eds.module @@ -242,7 +242,6 @@ function roblib_search_eds_get_results($query = NULL, $type = NULL) { } function roblib_search_eds_get_detailed_result(&$output, $query, &$eds_api) { - $detailed_record = array(); foreach ($output['records'] as &$record) { $db = $record['DbId']; $an = $record['An']; @@ -258,6 +257,7 @@ function roblib_search_eds_get_query_limiters($type) { case 'Articles': $limiters = 'facetfilter=1,SourceType:Magazines,SourceType:News,SourceType:Academic+Journals,SourceType:Conference+Materials'; break; + case 'Books': // $limiters = '+AND+(PT+book)'; $limiters = 'facetfilter=1,SourceType:Books,SourceType:Audio,SourceType:Videos'; diff --git a/targets/eds/theme/roblib-search-eds-articles.tpl.php b/targets/eds/theme/roblib-search-eds-articles.tpl.php index 7ab0440..5936337 100644 --- a/targets/eds/theme/roblib-search-eds-articles.tpl.php +++ b/targets/eds/theme/roblib-search-eds-articles.tpl.php @@ -8,7 +8,6 @@ * - $variables: all array elements of $variables can be used as a variable. e.g. $base_url equals $variables['base_url'] * * - * @see template_preprocess_roblib_search_wrapper() */ ?>
@@ -16,3 +15,18 @@ + + + + +
+ + + +*/ +?> + + diff --git a/targets/eds/theme/roblib-search-eds.tpl.php b/targets/eds/theme/roblib-search-eds.tpl.php index d361837..08c0cce 100644 --- a/targets/eds/theme/roblib-search-eds.tpl.php +++ b/targets/eds/theme/roblib-search-eds.tpl.php @@ -1,19 +1,8 @@
@@ -21,3 +10,4 @@ + diff --git a/targets/eds/theme/theme.inc b/targets/eds/theme/theme.inc index 412a06b..3796459 100644 --- a/targets/eds/theme/theme.inc +++ b/targets/eds/theme/theme.inc @@ -20,6 +20,7 @@ function roblib_search_eds_preprocess_roblib_search_eds(&$variables) { $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'); } diff --git a/targets/evergreen/theme/roblib-search-evergreen.tpl.php b/targets/evergreen/theme/roblib-search-evergreen.tpl.php index a6b2ac4..6922b81 100644 --- a/targets/evergreen/theme/roblib-search-evergreen.tpl.php +++ b/targets/evergreen/theme/roblib-search-evergreen.tpl.php @@ -1,19 +1,8 @@
diff --git a/targets/islandscholar/theme/roblib-search-islandscholar.tpl.php b/targets/islandscholar/theme/roblib-search-islandscholar.tpl.php index 60aafd8..208a523 100644 --- a/targets/islandscholar/theme/roblib-search-islandscholar.tpl.php +++ b/targets/islandscholar/theme/roblib-search-islandscholar.tpl.php @@ -1,19 +1,8 @@
Search all Results
diff --git a/theme/roblib-search-other-sources.tpl.php b/theme/roblib-search-other-sources.tpl.php new file mode 100644 index 0000000..6c93330 --- /dev/null +++ b/theme/roblib-search-other-sources.tpl.php @@ -0,0 +1,19 @@ + + +
+
+ + +
\ No newline at end of file diff --git a/theme/roblib-search-wrapper.tpl.php b/theme/roblib-search-wrapper.tpl.php deleted file mode 100644 index 2aed8bb..0000000 --- a/theme/roblib-search-wrapper.tpl.php +++ /dev/null @@ -1,27 +0,0 @@ - - -
- - -
-
- - -
\ No newline at end of file diff --git a/theme/theme.inc b/theme/theme.inc index 4cf7cd0..c6f45aa 100644 --- a/theme/theme.inc +++ b/theme/theme.inc @@ -5,7 +5,16 @@ * and open the template in the editor. */ -function roblib_search_preprocess_roblib_search_wrapper(&$variables) { - //not yet implemented +function roblib_search_preprocess_roblib_search_other_sources(&$variables) { + global $base_url; + if (!isset($query)) { + if (isset($_GET['roblib_query'])) { + $query = $_GET['roblib_query']; + } + else { + $query = ''; + } + } + $variables['query'] = urlencode($query); } ?>