Browse Source

updates to eds target

2.x-ebsco
Paul Pound 12 years ago
parent
commit
39fa8c4c57
  1. 5
      roblib_search.module
  2. 13
      targets/eds/css/roblib_search_eds.css
  3. 24
      targets/eds/includes/rest/Config.xml
  4. 51
      targets/eds/js/eds_results.js
  5. 2
      targets/eds/roblib_search_eds.info
  6. 50
      targets/eds/roblib_search_eds.module
  7. 2
      targets/eds/theme/roblib-search-eds.tpl.php

5
roblib_search.module

@ -134,10 +134,11 @@ function roblib_search_block_view($delta = '') {
* @param array $form_state
*/
function roblib_search_simple_form_submit($form, &$form_state) {
global $base_url;
$form_state['rebuild'] = TRUE;
$search_string = $form_state['values']['roblib_search_simple_search_query'];
$redirect_url = variable_get('roblib_search_panel_page','/roblib/panel');
$redirect_url = variable_get('roblib_search_panel_page','roblib/panel');
$redirect_url = $base_url. '/' . $redirect_url;
drupal_goto($redirect_url, array('query' => array('roblib_query' => $search_string)));
}

13
targets/eds/css/roblib_search_eds.css

@ -0,0 +1,13 @@
/*
Document : roblib_search_evergreen
Created on : Apr 11, 2013, 2:27:50 PM
Author : ppound
Description:
Purpose of the stylesheet follows.
*/
.highlight {font-weight: bolder; }
.eds-sor, .eds-date, .eds-holdings-item, .eds-db, .eds-src, .eds-pubinfo, .eds-type{
padding-left: 10px; font-size: smaller;
}

24
targets/eds/includes/rest/Config.xml

@ -1,24 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Config>
<Version>EDS API-PHP Demo 1.4</Version>
<EndPoints>
<EndPoint>http://eds-api.ebscohost.com/edsapi/rest</EndPoint>
<AuthenticationEndPoint>https://eds-api.ebscohost.com/Authservice/rest</AuthenticationEndPoint>
</EndPoints>
<AbstractLength>300</AbstractLength>
<ClientCredentials>
<User>
<UserId>insert client side profile</UserId>
<Password>insert client side profile</Password>
</User>
</ClientCredentials>
<EDSCredentials>
<User>
<ClientUser>guest</ClientUser>
<EDSUserID>uprince</EDSUserID>
<EDSPassword>robertson1</EDSPassword>
<EDSProfile>edsapi</EDSProfile>
</User>
</EDSCredentials>
</Config>

51
targets/eds/js/eds_results.js

@ -7,19 +7,48 @@ Drupal.behaviors.roblib_search_eds = {
jQuery('#' + 'roblib-search-content-eds').empty().append('No Results');
} else {
jQuery.each(data.records, function(key, val) {
items.push('<div class ="roblib-search-row">');
jQuery.each(val.RecordInfo.BibEntity.Titles, function(key2, val2){
items.push('<div class="roblib-title eds">');
items.push(val2.TitleFull+'</div>');
})
items.push('</div>');
//items.push('<a class="roblib-search-eds-tn" href="'+val.ImageInfo.thumb+'"/>');
//jQuery.each(val.RecordInfo.BibEntity.Titles, function(key2, val2){
if (typeof val.Items !== 'undefined') {
items.push('<div class ="roblib-search-row">');
if (typeof val.Items.Ti !== 'undefined') {
jQuery.each(val.Items.Ti, function(key2, val2){
items.push('<div class="roblib-title eds">');
items.push('<a href="'+val.PLink+'">'+val2.Data+'</a></div>');
})
}
jQuery.each(val.RecordInfo.BibRelationships.HasContributorRelationships, function(key3, authors){
items.push('<div class="eds-sor">'+authors.NameFull+'</div>');
})
if (typeof val.Items.Src !== 'undefined') {
jQuery.each(val.Items.Src, function(key4, source){
items.push('<div class="eds-src">'+source.Data+'</div>');
})
}
if (typeof val.Items.PubIrInfo !== 'undefined') {
jQuery.each(val.Items.PubIrInfo, function(key5, pubinfo){
items.push('<div class="eds-pubinfo">'+pubinfo.Data+'</div>');
})
}
if (typeof val.Items.TypPub !== 'undefined') {
jQuery.each(val.Items.TypPub, function(key6, typpub){
items.push('<div class="eds-type">'+typpub.Data+'</div>');
})
}
items.push('<div class="eds-db">'+val.DbLabel+'</div>');
items.push('</div>');
}
});
}
jQuery('#' + 'roblib-search-content-eds').empty().append(items.join(''));
var queries = [];
jQuery.each(data.queries, function(key7, query){
queries.push(query.query);
})
jQuery('#roblib-search-eds-more').empty().append('See all ' + data.recordCount + ' results');
});
}
}
}

2
targets/eds/roblib_search_eds.info

@ -5,7 +5,7 @@ description = implements the Roblib Search modules _roblib_search hook
package = Roblib Search
version = 7.x-dev
core = 7.x
stylesheets[all][] = css/roblib_search_eds.base.css
stylesheets[all][] = css/roblib_search_eds.css
files[] = includes/rest/EBSCOAPI.php
files[] = includes/rest/EBSCOConnector.php
files[] = includes/rest/EBSCOResponse.php

50
targets/eds/roblib_search_eds.module

@ -4,10 +4,10 @@
* @file
* Implementation of Roblib search for searching several targets.
*/
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
@ -56,11 +56,26 @@ function roblib_search_eds_menu() {
'access arguments' => array('search roblib eds'),
);
$items['roblib_search/eds/info'] = array(
'title' => 'eds info',
'page callback' => 'roblib_search_eds_info',
'type' => MENU_CALLBACK,
'access arguments' => array('search roblib eds'),
);
return $items;
}
function roblib_search_eds_info() {
$config = roblib_search_eds_build_config_arr();
$eds_api = new EBSCOAPI($config);
$output = $eds_api->getInfo();
print json_encode($output);
exit();
}
function roblib_search_eds_config_form($form, &$form_state) {
$form['roblib_search_eds_rest_url'] = array(
'#type' => 'textfield',
'#title' => t('EDS Rest endpoint'),
@ -75,7 +90,7 @@ function roblib_search_eds_config_form($form, &$form_state) {
'#description' => t('The EDS Auth endpoint, for example https://eds-api.ebscohost.com/Authservice/rest'),
'#required' => TRUE,
);
$form['roblib_search_eds_user'] = array(
'#type' => 'textfield',
'#title' => t('EDS user'),
@ -83,7 +98,7 @@ function roblib_search_eds_config_form($form, &$form_state) {
'#description' => t('EDS user, for example username'),
'#required' => TRUE,
);
$form['roblib_search_eds_pass'] = array(
'#type' => 'textfield',
'#title' => t('EDS password'),
@ -91,15 +106,15 @@ function roblib_search_eds_config_form($form, &$form_state) {
'#description' => t('EDS password, for example password'),
'#required' => TRUE,
);
$form['roblib_search_eds_profile'] = array(
$form['roblib_search_eds_profile'] = array(
'#type' => 'textfield',
'#title' => t('EDS profile'),
'#default_value' => variable_get('roblib_search_eds_profile', 'edsapi'),
'#description' => t('EDS profile, for example edsapi'),
'#required' => TRUE,
);
$form['roblib_search_eds_num_results'] = array(
'#type' => 'textfield',
'#title' => t('Number of results to return'),
@ -180,6 +195,7 @@ function roblib_search_eds_ajax($query) {
print roblib_search_eds_get_results($query);
exit();
}
/**
*
* @param string $query
@ -198,21 +214,31 @@ function roblib_search_eds_get_results($query = NULL) {
return '';
}
}
//TODO move this to drupal variables
$config = array();
$config['user'] = variable_get('roblib_search_eds_user', 'edsusername');
$config = roblib_search_eds_build_config_arr();
/*$config['user'] = variable_get('roblib_search_eds_user', 'edsusername');
$config['pass'] = variable_get('roblib_search_eds_pass', 'edspassword');
$config['profile'] = variable_get('roblib_search_eds_profile', 'edsapi');
$config['auth_url'] = variable_get('roblib_search_eds_auth_url', 'https://eds-api.ebscohost.com/Authservice/rest');
$config['rest_url'] = variable_get('roblib_search_eds_rest_url', 'http://eds-api.ebscohost.com/edsapi/rest');
$config['rest_url'] = variable_get('roblib_search_eds_rest_url', 'http://eds-api.ebscohost.com/edsapi/rest');*/
$eds_api = new EBSCOAPI($config);
$number_per_page = variable_get('roblib_search_eds_num_results', '5');
$query = urlencode($query);
$params = "query=$query&includefacets=n&resultsperpage=$number_per_page";
$params = "query=AND,$query&includefacets=n&resultsperpage=$number_per_page";
$output = $eds_api->apiSearch($params);
return json_encode($output);
}
function roblib_search_eds_build_config_arr() {
$config = array();
$config['user'] = variable_get('roblib_search_eds_user', 'edsusername');
$config['pass'] = variable_get('roblib_search_eds_pass', 'edspassword');
$config['profile'] = variable_get('roblib_search_eds_profile', 'edsapi');
$config['auth_url'] = variable_get('roblib_search_eds_auth_url', 'https://eds-api.ebscohost.com/Authservice/rest');
$config['rest_url'] = variable_get('roblib_search_eds_rest_url', 'http://eds-api.ebscohost.com/edsapi/rest');
return $config;
}
/**
* Implements hook_help().
*

2
targets/eds/theme/roblib-search-eds.tpl.php

@ -21,4 +21,4 @@
<img src="<?php print $spinner_path; ?>"/>
</div>
<div class ="roblib-search-more">Search all EDS</div>
<div class ="roblib-search-more" id="roblib-search-eds-more"></div>
Loading…
Cancel
Save