diff --git a/targets/cufts/roblib_search_cufts.module b/targets/cufts/roblib_search_cufts.module
index ab58ccb..0c0194d 100644
--- a/targets/cufts/roblib_search_cufts.module
+++ b/targets/cufts/roblib_search_cufts.module
@@ -139,7 +139,7 @@ function roblib_search_cufts_block_view($delta = '') {
// 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('Cufts Results');
+ $block['subject'] = t('Journals');
// The content of the block is typically generated by calling a custom
// function.
// $block['content'] = roblib_search_cufts_get_results();
diff --git a/targets/eds/js/eds_results_article.js b/targets/eds/js/eds_results_article.js
new file mode 100644
index 0000000..78d0255
--- /dev/null
+++ b/targets/eds/js/eds_results_article.js
@@ -0,0 +1,64 @@
+Drupal.behaviors.roblib_search_eds_articles = {
+ attach: function(context, settings) {
+ $url = settings.roblib_search_eds_articles.search_url;
+ jQuery.getJSON($url, function(data) {
+ var items = [];
+ var numberOfDocs = 0;
+ try {
+ numberOfDocs = data.records.length;
+ } catch (err) {
+ // do nothing leave docLength at 0
+ }
+ if(numberOfDocs < 1){
+ jQuery('#' + 'roblib-search-content-eds').empty().append('No Results');
+ jQuery('.' + 'pane-roblib-search-eds-roblib-search-eds-articles').hide();
+ } else {
+ jQuery.each(data.records, function(key, val) {
+
+ //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-articles').empty().append(items.join(''));
+ var queries = [];
+ jQuery.each(data.queries, function(key7, query){
+ 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=';
+ jQuery('#roblib-search-eds-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 b8298b0..6db5a3a 100644
--- a/targets/eds/roblib_search_eds.module
+++ b/targets/eds/roblib_search_eds.module
@@ -8,30 +8,6 @@ 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
- */
-function roblib_search_eds_boot() {
- /* below is an example from islandora_solr module for internationalization
- * global $conf;
-
- // Allow i18n, by using multilingual variables.
- if (module_exists('i18n')) {
- $vars = array(
- 'islandora_solr_facets',
- 'islandora_solr_result_fields',
- 'islandora_solr_searchterms'
- );
-
- if (isset($conf['i18n_variables']) && is_array($conf['i18n_variables'])) {
- $conf['i18n_variables'] = array_merge($vars, $conf['i18n_variables']);
- }
- else {
- $conf['i18n_variables'] = $vars;
- }
- } */
-}
/**
* Implements hook_menu().
@@ -55,6 +31,13 @@ function roblib_search_eds_menu() {
'type' => MENU_CALLBACK,
'access arguments' => array('search roblib eds'),
);
+ $items['roblib_search/eds/articles/%'] = array(
+ 'title' => 'eds ajax',
+ 'page callback' => 'roblib_search_eds_articles',
+ 'page arguments' => array(3),
+ 'type' => MENU_CALLBACK,
+ 'access arguments' => array('search roblib eds'),
+ );
$items['roblib_search/eds/info'] = array(
'title' => 'eds info',
@@ -68,7 +51,7 @@ function roblib_search_eds_menu() {
function roblib_search_eds_info() {
$config = roblib_search_eds_build_config_arr();
- $eds_api = new EBSCOAPI($config);
+ $eds_api = new EBSCOAPI($config);
$output = $eds_api->getInfo();
print json_encode($output);
exit();
@@ -158,7 +141,13 @@ function roblib_search_eds_theme() {
'file' => $file,
'template' => 'roblib-search-eds',
'variables' => array('results' => NULL),
- )
+ ),
+ 'roblib_search_eds_articles' => array(
+ 'path' => $path . '/theme',
+ 'file' => $file,
+ 'template' => 'roblib-search-eds-articles',
+ 'variables' => array('results' => NULL),
+ ),
);
}
@@ -168,41 +157,54 @@ function roblib_search_eds_block_info() {
// info: The name of the block.
'info' => t('EDS Search Results block'),
// Block caching options (per role, per user, etc.)
- 'cache' => DRUPAL_CACHE_PER_ROLE, // default
+ 'cache' => DRUPAL_CACHE_PER_ROLE,
+ );
+ $blocks['roblib_search_eds_articles'] = array(
+ 'info' => t('EDS Search Results Articles'),
+ 'cache' => DRUPAL_CACHE_PER_ROLE,
);
-
return $blocks;
}
function roblib_search_eds_block_view($delta = '') {
- //The $delta parameter tells us which block is being requested.
switch ($delta) {
case 'roblib_search_eds_results':
// 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('EDS Results');
+ $block['subject'] = t('Books & Media');
// The content of the block is typically generated by calling a custom
// function.
// $block['content'] = roblib_search_eds_get_results();
- $block['content'] = theme('roblib_search_eds', array('results' => NULL)); //we will get the results via javascript
+ $block['content'] = theme('roblib_search_eds', array('results' => NULL));
+ break;
+
+ case 'roblib_search_eds_articles':
+ $block['subject'] = t('Articles');
+ $block['content'] = theme('roblib_search_eds_articles', array('results' => NULL));
break;
+
}
return $block;
}
function roblib_search_eds_ajax($query) {
- print roblib_search_eds_get_results($query);
+ print roblib_search_eds_get_results($query, 'Books');
+ exit();
+}
+
+function roblib_search_eds_articles($query){
+ print roblib_search_eds_get_results($query, 'Articles');
exit();
}
/**
- *
+ *
* @param string $query
* @return string
* json string
*/
-function roblib_search_eds_get_results($query = NULL) {
+function roblib_search_eds_get_results($query = NULL, $type = NULL) {
drupal_add_css(drupal_get_path('module', 'roblib_search_eds') . '/css/roblib_search_eds.theme.css');
// Url parameters.
@@ -214,16 +216,35 @@ function roblib_search_eds_get_results($query = NULL) {
return '';
}
}
-
+ $limiters = '';
+ if($type != NULL){
+ $limiters = roblib_search_eds_get_query_limiters($type);
+ }
$config = roblib_search_eds_build_config_arr();
$eds_api = new EBSCOAPI($config);
$number_per_page = variable_get('roblib_search_eds_num_results', '5');
$query = urlencode($query);
+ $query = trim($query . $limiters);
$params = "query=AND,$query&includefacets=n&resultsperpage=$number_per_page";
$output = $eds_api->apiSearch($params);
return json_encode($output);
}
+function roblib_search_eds_get_query_limiters($type){
+ $limiters = 'n';
+ switch ($type) {
+ case 'Articles':
+ $limiters = '+AND+(ZT+article)';
+ break;
+ case 'Books':
+ $limiters = '+AND+(PT+book)';
+ break;
+
+
+ }
+ return $limiters;
+}
+
function roblib_search_eds_build_config_arr() {
$config = array();
$config['user'] = variable_get('roblib_search_eds_user', 'edsusername');
@@ -245,10 +266,10 @@ function roblib_search_eds_help($path, $arg) {
switch ($path) {
case 'admin/help#roblib_search_eds':
return t(
- '
- provides a target for the Roblib search module. This target uses javascript
- to render the results.
-
'
+ '
+ provides a target for the Roblib search module. This target uses javascript
+ to render the results.
+
'
);
}
}
diff --git a/targets/eds/theme/roblib-search-eds-articles.tpl.php b/targets/eds/theme/roblib-search-eds-articles.tpl.php
new file mode 100644
index 0000000..5fb3cf5
--- /dev/null
+++ b/targets/eds/theme/roblib-search-eds-articles.tpl.php
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/targets/eds/theme/theme.inc b/targets/eds/theme/theme.inc
index f1ac7c4..412a06b 100644
--- a/targets/eds/theme/theme.inc
+++ b/targets/eds/theme/theme.inc
@@ -1,13 +1,13 @@
array('search_url' => $search_url)), array('type' => 'setting'));
-
+
+}
+
+function roblib_search_eds_preprocess_roblib_search_eds_articles(&$variables) {
+ global $base_url;
+ if (!isset($query)) {
+ if (isset($_GET['roblib_query'])) {
+ $query = $_GET['roblib_query'];
+ }
+ else {
+ return '';
+ }
+ }
+ $spinner_path = $base_url . '/' . drupal_get_path('module', 'roblib_search') . '/img/' . 'spinner.gif';
+ $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'));
+
}
+
?>