Browse Source

Research Starters, Exact Placard Match, Did you mean, other

- sort the variables on admin interface
- Fixed access to interface when exception existed from wrong API
credentials
- add support for user IP authentication
- add support for GZIP compression in the requests
- clean php code
- prevent site down against network/connection failures
- added more search fields to advanced search
- did you mean / auto suggest terms
- added Research Starters to result list
- Add Exact Placard Match to result list
roblib
Rui Francisco 8 years ago
parent
commit
2c136716a0
  1. 111
      ebsco/css/ebsco.css
  2. 2
      ebsco/ebsco.info
  3. 48
      ebsco/ebsco.module
  4. 3
      ebsco/js/ebsco.js
  5. 50
      ebsco/lib/EBSCOAPI.php
  6. 68
      ebsco/lib/EBSCOConnector.php
  7. 165
      ebsco/lib/EBSCODocument.php
  8. 4
      ebsco/lib/EBSCORecord.php
  9. 118
      ebsco/lib/EBSCOResponse.php
  10. 8
      ebsco/templates/ebsco-advanced-search.tpl.php
  11. 31
      ebsco/templates/ebsco-basic-search.tpl.php
  12. 252
      ebsco/templates/ebsco-result.tpl.php
  13. 369
      ebsco/templates/ebsco-results.tpl.php
  14. 3
      ebsco/templates/ebsco-side-facets.tpl.php

111
ebsco/css/ebsco.css

@ -1,7 +1,8 @@
/* /*
* The styles for EBSCO module * The styles for EBSCO module
* *
* Copyright [2014] [EBSCO Information Services] *
* Copyright [2017] [EBSCO Information Services]
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -397,7 +398,7 @@
/** Icons ***/ /** Icons ***/
.ebsco .icon { .icon {
background: url("../images/sprites_32.png") no-repeat top left; background: url("../images/sprites_32.png") no-repeat top left;
height: 32px; height: 32px;
line-height: 32px; line-height: 32px;
@ -405,15 +406,15 @@
padding: 0 0 0 36px !important; padding: 0 0 0 36px !important;
} }
.ebsco .icon.ebook { .icon.ebook {
background-position: 0 0; background-position: 0 0;
} }
.ebsco .icon.html { .icon.html {
background-position: 0 -42px; background-position: 0 -42px;
} }
.ebsco .icon.pdf { .icon.pdf {
background-position: 0 -84px; background-position: 0 -84px;
} }
@ -443,3 +444,101 @@
.icon16.tick { .icon16.tick {
background-position: 0 -171px; background-position: 0 -171px;
} }
/* RS, EMP carousel */
#quote-carousel
{
padding: 0 10px 30px 10px;
margin-top: 30px;
}
/* Control buttons */
#quote-carousel .carousel-control
{
background: none;
color: #222;
font-size: 2.3em;
text-shadow: none;
margin-top: 30px;
}
/* Previous button */
#quote-carousel .carousel-control.left
{
left: -12px;
}
/* Next button */
#quote-carousel .carousel-control.right
{
right: -12px !important;
}
/* Changes the position of the indicators */
#quote-carousel .carousel-indicators
{
right: 50%;
top: auto;
bottom: 0px;
margin-right: -19px;
}
/* Changes the color of the indicators */
#quote-carousel .carousel-indicators li
{
background: #c0c0c0;
}
#quote-carousel .carousel-indicators .active
{
background: #333333;
}
#quote-carousel img
{
width: 250px;
height: 100px
}
/* End carousel */
.item blockquote {
border-left: none;
margin: 0;
}
.item blockquote img {
margin-bottom: 10px;
}
.item blockquote p:before {
content: "\f10d";
font-family: 'Fontawesome';
float: left;
margin-right: 10px;
}
#relatedInformation img { padding-right :10px;}
.glyphicon {
position: relative;
top: 1px;
display: inline-block;
font-family: 'Glyphicons Halflings';
font-style: normal;
font-weight: 400;
line-height: 1;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.carousel-control .glyphicon-chevron-right {
position: absolute;
top: 50%;
z-index: 5;
display: inline-block;
}
.carousel-control.left span, .carousel-control.right span {
background-color: #000;
}
h3.relatedTitle a{
font-size:24px;
}
/* */

2
ebsco/ebsco.info

@ -1,5 +1,5 @@
name = EBSCO Discovery Service name = EBSCO Discovery Service
description = Full-text articles and eBooks from EBSCOhost Discovery Service description = Full-text articles and eBooks from EBSCO Discovery Service
core = 7.x core = 7.x
configure = admin/config/search/ebsco configure = admin/config/search/ebsco

48
ebsco/ebsco.module

@ -1,8 +1,8 @@
<?php <?php
/* /*
* EBSCO Drupal module
* *
* Copyright [2014] [EBSCO Information Services] *
* Copyright [2017] [EBSCO Information Services]
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,7 +15,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
require_once 'lib/EBSCODocument.php'; require_once 'lib/EBSCODocument.php';
# global variable # global variable
@ -108,6 +108,9 @@ function ebsco_permission() {
'administer ebsco' => array( 'administer ebsco' => array(
'title' => t('Administer EBSCO') 'title' => t('Administer EBSCO')
), ),
'use ebsco' => array(
'title' => t('Use EBSCO')
)
); );
} }
@ -121,15 +124,15 @@ function ebsco_admin() {
$form['ebsco_credentials'] = array( $form['ebsco_credentials'] = array(
'#type' => 'fieldset', '#type' => 'fieldset',
'#title' => t('API credentials') '#title' => t('EDS API credentials')
); );
$form['ebsco_credentials']['ebsco_password'] = array( $form['ebsco_credentials']['ebsco_profile'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Password'), '#title' => t('Profile Id'),
'#default_value' => variable_get('ebsco_password'), '#default_value' => variable_get('ebsco_profile'),
'#size' => 50, '#size' => 50,
'#description' => t("The API password."), '#description' => t("The API Profile Id."),
'#required' => TRUE '#required' => TRUE
); );
@ -142,18 +145,19 @@ function ebsco_admin() {
'#required' => TRUE '#required' => TRUE
); );
$form['ebsco_credentials']['ebsco_profile'] = array( $form['ebsco_credentials']['ebsco_password'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Profile Id'), '#title' => t('Password'),
'#default_value' => variable_get('ebsco_profile'), '#default_value' => variable_get('ebsco_password'),
'#size' => 50, '#size' => 50,
'#description' => t("The API Profile Id."), '#description' => t("The API password."),
'#required' => TRUE '#required' => TRUE
); );
$form['ebsco_credentials']['ebsco_interface'] = array( $form['ebsco_credentials']['ebsco_interface'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Interface Id'), '#title' => t('Interface Id'),
'#default_value' => variable_get('ebsco_interface'),
'#size' => 50, '#size' => 50,
'#description' => t("The API Interface Id."), '#description' => t("The API Interface Id."),
'#required' => FALSE '#required' => FALSE
@ -162,11 +166,21 @@ function ebsco_admin() {
$form['ebsco_credentials']['ebsco_organization'] = array( $form['ebsco_credentials']['ebsco_organization'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Organization Id'), '#title' => t('Organization Id'),
'#default_value' => variable_get('ebsco_organization'),
'#size' => 50, '#size' => 50,
'#description' => t("The API Organization Id."), '#description' => t("The API Organization Id."),
'#required' => FALSE '#required' => FALSE
); );
$form['ebsco_credentials']['ebsco_local_ips'] = array(
'#type' => 'textfield',
'#title' => t('Local IP addresses'),
'#default_value' => variable_get('ebsco_local_ips'),
'#size' => 100,
'#description' => t("Local IP address list for guest detection (ex: 127.0.0.1, 192.168.10.1, 172.18.12)"),
'#required' => FALSE
);
$form['ebsco_credentials']['ebsco_guest'] = array( $form['ebsco_credentials']['ebsco_guest'] = array(
'#type' => 'radios', '#type' => 'radios',
'#title' => t('Guest ?'), '#title' => t('Guest ?'),
@ -202,7 +216,7 @@ function ebsco_admin() {
$form['ebsco_general']['ebsco_default_amount'] = array( $form['ebsco_general']['ebsco_default_amount'] = array(
'#type' => 'select', '#type' => 'select',
'#title' => t('Default detail level'), '#title' => t('Default detail level'),
'#default_value' => variable_get('ebsco_default_amount', 'detailed'), '#default_value' => variable_get('ebsco_default_amount', 'brief'),
'#description' => t("Default level of data detail."), '#description' => t("Default level of data detail."),
'#options' => EBSCODocument::amount_options(), '#options' => EBSCODocument::amount_options(),
'#required' => TRUE '#required' => TRUE
@ -415,7 +429,7 @@ function ebsco_sort_form() {
$options = EBSCODocument::amount_options(); $options = EBSCODocument::amount_options();
$values = array_values($options); $values = array_values($options);
$default_value = isset($params['amount']) ? $params['amount'] : $values[0]; $default_value = isset($params['amount']) ? $params['amount'] : variable_get('ebsco_default_amount', 'brief');
$form['mode'] = array( $form['mode'] = array(
'#id' => 'ebsco-amount', '#id' => 'ebsco-amount',
'#type' => 'select', '#type' => 'select',
@ -886,6 +900,8 @@ function template_preprocess_ebsco_results(&$variables) {
$variables['record_count'] = $Document->record_count(); $variables['record_count'] = $Document->record_count();
$variables['search_view'] = $Document->search_view(); $variables['search_view'] = $Document->search_view();
$variables['search_time'] = $Document->search_time(); $variables['search_time'] = $Document->search_time();
$variables['relatedContent'] = $Document->relatedContent();
$variables['autoSuggestTerms'] = $Document->autoSuggestTerms();
$variables['lookfor'] = ''; $variables['lookfor'] = '';
if (isset($params['lookfor'])) { if (isset($params['lookfor'])) {
$variables['lookfor'] = $params['lookfor']; $variables['lookfor'] = $params['lookfor'];
@ -904,7 +920,7 @@ function template_preprocess_ebsco_results(&$variables) {
$variables['sort_form'] = drupal_render($v1); $variables['sort_form'] = drupal_render($v1);
// Save data needed by scroller in Detailed view page // Save data needed by scroller in Detailed view page
$Document->search_write(); //$Document->search_write();
} }

3
ebsco/js/ebsco.js

@ -1,7 +1,8 @@
/* /*
* The EBSCO module javascript * The EBSCO module javascript
*
* *
* Copyright [2014] [EBSCO Information Services] * Copyright [2017] [EBSCO Information Services]
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

50
ebsco/lib/EBSCOAPI.php

@ -4,9 +4,9 @@
* EBSCO EDS API class * EBSCO EDS API class
* *
* PHP version 5 * PHP version 5
*
* *
* * Copyright [2017] [EBSCO Information Services]
* Copyright [2014] [EBSCO Information Services]
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -19,6 +19,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*
*/ */
require_once 'EBSCOConnector.php'; require_once 'EBSCOConnector.php';
@ -56,7 +57,6 @@ class EBSCOAPI
*/ */
private $config; private $config;
/** /**
* VuFind search types mapped to EBSCO search types * VuFind search types mapped to EBSCO search types
* used for urls in search results / detailed result * used for urls in search results / detailed result
@ -69,7 +69,9 @@ class EBSCOAPI
'Author' => 'AU', 'Author' => 'AU',
'Source' => 'SO', 'Source' => 'SO',
'Subject' => 'SU', 'Subject' => 'SU',
'Title' => 'TI' 'Title' => 'TI',
'ISBN' => 'IB',
'ISSN' => 'IS'
); );
@ -326,7 +328,6 @@ class EBSCOAPI
); );
$response = $this->connector()->requestSessionToken($headers); $response = $this->connector()->requestSessionToken($headers);
// Raise the exception so that any code running this method should exit immediately // Raise the exception so that any code running this method should exit immediately
if ($this->isError($response)) { if ($this->isError($response)) {
return $response; return $response;
@ -384,8 +385,7 @@ class EBSCOAPI
* @access public * @access public
*/ */
public function apiSearch($search, $filters, public function apiSearch($search, $filters,
$start = 1, $limit = 10, $sortBy = 'relevance', $amount = 'detailed', $mode = 'all' $start = 1, $limit = 10, $sortBy = 'relevance', $amount = 'detailed', $mode = 'all', $rs=false, $emp=false,$autosuggest=false) {
) {
$query = array(); $query = array();
// Basic search // Basic search
@ -411,7 +411,8 @@ class EBSCOAPI
} }
// Advanced search // Advanced search
} else if(!empty($search['group'])) { }
else if(!empty($search['group'])) {
$counter = 1; $counter = 1;
foreach ($search['group'] as $group) { foreach ($search['group'] as $group) {
@ -481,6 +482,12 @@ class EBSCOAPI
} }
} }
//2014-03-26 - new action to jump to page
if ($start>1) {
$query['action']="GoToPage(".$start.")";
}
// Add the sort option // Add the sort option
$sortBy = in_array($sortBy, self::$sort_options) ? $sortBy : self::$mapped_sort_options[$sortBy]; $sortBy = in_array($sortBy, self::$sort_options) ? $sortBy : self::$mapped_sort_options[$sortBy];
@ -503,11 +510,33 @@ class EBSCOAPI
/// Specifies whether or not to include facets /// Specifies whether or not to include facets
'includefacets' => 'y', 'includefacets' => 'y',
'resultsperpage' => $limit, 'resultsperpage' => $limit,
'pagenumber' => $start,
//2014-03-26 RF
'pagenumber' => $start,
//'pagenumber' => 1,
// Specifies whether or not to include highlighting in the search results // Specifies whether or not to include highlighting in the search results
'highlight' => 'y' 'highlight' => 'y'
); );
if($autosuggest==true) {
$params["autosuggest"]="y";
}
if ($rs==true){
$params["relatedcontent"]="rs";
}
if ($emp==true){
if (isset($params["relatedcontent"])) {
$params["relatedcontent"].=",emp";
}
else
{
$params["relatedcontent"]="emp";
}
}
$params = array_merge($params, $query); $params = array_merge($params, $query);
$result = $this->request('Search', $params); $result = $this->request('Search', $params);
@ -551,11 +580,12 @@ class EBSCOAPI
if ($result = $this->readSession('info')) { if ($result = $this->readSession('info')) {
return $result; return $result;
} }
$result = $this->request('Info'); $result = $this->request('Info');
if(!$this->isError($result)) { if(!$this->isError($result)) {
$this->writeSession('info', $result); $this->writeSession('info', $result);
} }
return $result; return $result;
} }

68
ebsco/lib/EBSCOConnector.php

@ -3,8 +3,9 @@
/** /**
* EBSCOException class * EBSCOException class
* Used when EBSCO API calls return error messages * Used when EBSCO API calls return error messages
*
* *
* Copyright [2014] [EBSCO Information Services] * Copyright [2017] [EBSCO Information Services]
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -151,6 +152,12 @@ class EBSCOConnector
*/ */
private $isGuest; private $isGuest;
/**
* Contains the list of ip addresses
* @global string
*/
private $local_ip_address;
/* /*
* You can log HTTP_Request requests using this option * You can log HTTP_Request requests using this option
@ -175,6 +182,7 @@ class EBSCOConnector
* *
* @access public * @access public
*/ */
public function __construct($config) public function __construct($config)
{ {
$this->password = $config['password']; $this->password = $config['password'];
@ -182,7 +190,8 @@ class EBSCOConnector
$this->interfaceId = $config['interface']; $this->interfaceId = $config['interface'];
$this->profileId = $config['profile']; $this->profileId = $config['profile'];
$this->orgId = $config['organization']; $this->orgId = $config['organization'];
$this->isGuest = user_is_logged_in() ? 'n' : 'y'; $this->local_ip_address = $config['local_ip_address'];
$this->isGuest = (user_is_logged_in() || $this->isGuestIPAddress($_SERVER["REMOTE_ADDR"]))? 'n' : 'y';
$this->logAPIRequests = ($config['log'] == 1); $this->logAPIRequests = ($config['log'] == 1);
if ($this->logAPIRequests) { if ($this->logAPIRequests) {
$writer = new Zend_Log_Writer_Stream('php://output'); $writer = new Zend_Log_Writer_Stream('php://output');
@ -191,6 +200,30 @@ class EBSCOConnector
} }
/**
* Detects if the user is authorized based on the IP address
*
* @return string
*/
public function isGuestIPAddress($ipUser)
{
$s= $this->local_ip_address;
if (trim($s)=="") {
return false;
}
//break records
$m=explode(",",$s);
foreach($m as $ip) {
if ( strcmp(substr($ipUser,0,strlen(trim($ip))),trim($ip))==0) {
// inside of ip address range of customer
return true;
}
}
return false;
}
/** /**
* Public getter for private isGuest * Public getter for private isGuest
* *
@ -305,10 +338,12 @@ BODY;
$url = self::$end_point . '/Info'; $url = self::$end_point . '/Info';
$response = $this->request($url, $params, $headers); $response = $this->request($url, $params, $headers);
return $response; return $response;
} }
/** /**
* Send an HTTP request and inspect the response * Send an HTTP request and inspect the response
* *
@ -343,6 +378,13 @@ BODY;
} }
} }
//add compression in case its not there
$headers = array_merge(
array('Accept-Encoding' => 'gzip,deflate'),
$headers
);
$options = array( $options = array(
'headers' => $headers, 'headers' => $headers,
'method' => $method, 'method' => $method,
@ -352,12 +394,26 @@ BODY;
// Send the request // Send the request
try { try {
$response = drupal_http_request($url, $options); $response = drupal_http_request($url, $options);
//print_r($url);
//print_r($response); //print_r($response);
$code = $response->code; $code = $response->code;
switch ($code) { if (isset($response->headers['content-encoding'])) {
if ($response->headers['content-encoding'] == 'gzip') {
$response->data = gzinflate(substr($response->data, 10));
}
elseif ($response->headers['content-encoding'] == 'deflate') {
$response->data = gzinflate($response->data);
}
}
switch ($code) {
case self::HTTP_OK: case self::HTTP_OK:
$xml_str = $response->data;
try { $xml_str = $response->data;
try {
// clean EMP namespace
$xml_str=str_replace(array("<a:","</a:"),array("<","</"),$xml_str);
$xml = simplexml_load_string($xml_str); $xml = simplexml_load_string($xml_str);
$return = $xml; $return = $xml;
} catch(Exception $e) { } catch(Exception $e) {
@ -411,6 +467,8 @@ BODY;
break; break;
} }
} catch (Exception $e) { } catch (Exception $e) {
$message = $this->toString($client); // or $this->toString($response)
$this->logger->log($message, Zend_Log::ERR);
$return = new EBSCOException($response); $return = new EBSCOException($response);
} }

165
ebsco/lib/EBSCODocument.php

@ -9,9 +9,9 @@
* - displaying statistics about the search, etc * - displaying statistics about the search, etc
* *
* PHP version 5 * PHP version 5
*
* *
* * Copyright [2017] [EBSCO Information Services]
* Copyright [2014] [EBSCO Information Services]
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -23,7 +23,7 @@
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.*
*/ */
require_once 'EBSCOAPI.php'; require_once 'EBSCOAPI.php';
@ -74,6 +74,14 @@ class EBSCODocument
*/ */
private $records = array(); private $records = array();
/**
* The array of EBSCORecord models returned by a Search API call
* #global array of RelatedRecords
*/
private $relatedContent = array();
private $autoSuggestTerms = array();
/** /**
* The array of filters currently applied * The array of filters currently applied
* @global array * @global array
@ -86,6 +94,12 @@ class EBSCODocument
*/ */
private $limit = 10; private $limit = 10;
/**
* Default level of data detail
* @global string
*/
private $amount = 'brief';
/** /**
* Maximum number of links displayed by the pagination * Maximum number of links displayed by the pagination
* @global integer * @global integer
@ -166,9 +180,14 @@ class EBSCODocument
'AllFields' => 'All Text', 'AllFields' => 'All Text',
'Title' => 'Title', 'Title' => 'Title',
'Author' => 'Author', 'Author' => 'Author',
'Subject' => 'Subject terms' 'Subject' => 'Subject terms',
'Source' => 'Journal Title/Source',
'Abstract' => 'Abstract',
'ISBN' => 'ISBN',
'ISSN' => 'ISSN'
); );
private $local_ips = "";
/** /**
* Constructor. * Constructor.
@ -183,12 +202,14 @@ class EBSCODocument
'profile' => variable_get('ebsco_profile'), 'profile' => variable_get('ebsco_profile'),
'interface' => variable_get('ebsco_interface'), 'interface' => variable_get('ebsco_interface'),
'organization' => variable_get('ebsco_organization'), 'organization' => variable_get('ebsco_organization'),
'local_ip_address' => variable_get('ebsco_local_ips'),
'guest' => variable_get('ebsco_guest'), 'guest' => variable_get('ebsco_guest'),
'log' => variable_get('ebsco_log') 'log' => variable_get('ebsco_log')
)); ));
$this->params = $params ? $params : $_REQUEST; $this->params = $params ? $params : $_REQUEST;
$this->limit = variable_get('ebsco_default_limit') ? variable_get('ebsco_default_limit') : $this->limit; $this->limit = variable_get('ebsco_default_limit') ? variable_get('ebsco_default_limit') : $this->limit;
$this->amount = variable_get('ebsco_default_amount') ? variable_get('ebsco_default_amount') : $this->amount;
} }
@ -242,14 +263,33 @@ class EBSCODocument
$page = isset($this->params['page']) ? $this->params['page'] + 1 : 1; $page = isset($this->params['page']) ? $this->params['page'] + 1 : 1;
$limit = $this->limit; $limit = $this->limit;
$sort = isset($this->params['sort']) ? $this->params['sort'] : 'relevance'; $sort = isset($this->params['sort']) ? $this->params['sort'] : 'relevance';
$amount = isset($this->params['amount']) ? $this->params['amount'] : 'detailed'; $amount = isset($this->params['amount']) ? $this->params['amount'] : 'brief'; //
$mode = isset($this->params['mode']) ? $this->params['mode'] : 'all'; $mode = isset($this->params['mode']) ? $this->params['mode'] : 'all';
$this->results = $this->eds->apiSearch($search, $filter, $page, $limit, $sort, $amount, $mode);
if (isset($this->results['start'])) { //check if research starters , EMP are active
$this->results['start'] = $limit * ($page - 1); $info = $this->info();
} $rs=false;
$emp=false;
if ($info["relatedContent"]){
foreach ($info["relatedContent"] as $related) {
if ( ($related["Type"] == "rs") and ($related["DefaultOn"] == "y")) {
$rs=true;
}
if ( ($related["Type"] == "emp") and ($related["DefaultOn"] == "y")) {
$emp=true;
}
}
}
$autosug=false;
if ($info["didYouMean"]){
if ( $info["didYouMean"][0]["DefaultOn"] == "y") {
$autosug=true;
}
}
$this->results = $this->eds->apiSearch($search, $filter, $page, $limit, $sort, $amount, $mode,$rs,$emp,$autosug);
return $this->results; return $this->results;
} }
@ -277,6 +317,12 @@ class EBSCODocument
*/ */
public function records() public function records()
{ {
if ($this->record instanceof EBSCOException ) {
return null;
}
if ($this->results instanceof EBSCOException ) {
return null;
}
if (empty($this->records) && !(empty($this->results))) { if (empty($this->records) && !(empty($this->results))) {
foreach($this->results['documents'] as $result) { foreach($this->results['documents'] as $result) {
$this->records[] = new EBSCORecord($result); $this->records[] = new EBSCORecord($result);
@ -287,6 +333,26 @@ class EBSCODocument
} }
public function relatedContent()
{
if ($this->results instanceof EBSCOException ) {
return null;
}
$this->relatedContent = isset($this->results['relatedContent']) ? $this->results['relatedContent'] : array();
return $this->relatedContent;
}
public function autoSuggestTerms()
{
$this->autoSuggestTerms = isset($this->results['autoSuggestTerms']) ? $this->results['autoSuggestTerms'] : null;
return $this->autoSuggestTerms;
}
/** /**
* Get the pagination HTML string * Get the pagination HTML string
* *
@ -295,11 +361,19 @@ class EBSCODocument
public function pager() public function pager()
{ {
$pager = null; $pager = null;
if ($this->has_records()) { try
pager_default_initialize($this->record_count() / $this->limit, 1); {
$pager = theme('pager', array('tags' => null, 'quantity' => self::$page_links)); if ($this->has_records()) {
$pager = preg_replace('/<li class="pager-last last">(.*)<\/li>/', '', $pager); pager_default_initialize($this->record_count() / $this->limit, 1);
} $pager = theme('pager', array('tags' => null, 'quantity' => self::$page_links));
$pager = preg_replace('/<li class="pager-last last">(.*)<\/li>/', '', $pager);
}
}
catch(Exception $e)
{
}
return $pager; return $pager;
} }
@ -395,18 +469,31 @@ class EBSCODocument
*/ */
public function expanders() public function expanders()
{ {
$actions = array(); $expanders=array();
$filters = $this->filters(); try
foreach($filters as $filter) { {
$actions[] = $filter['action']; if ($this->info instanceof EBSCOException)
} {
return $expanders;
$expanders = isset($this->info['expanders']) ? $this->info['expanders'] : array(); }
foreach($expanders as $key => $expander) { $actions = array();
if (in_array($expander['Action'], $actions)) { $filters = $this->filters();
$expanders[$key]['selected'] = true; foreach($filters as $filter) {
} $actions[] = $filter['action'];
} }
$expanders = isset($this->info['expanders']) ? $this->info['expanders'] : array();
foreach($expanders as $key => $expander) {
if (in_array($expander['Action'], $actions)) {
$expanders[$key]['selected'] = true;
}
}
}
catch(Exception $e)
{
}
return $expanders; return $expanders;
} }
@ -419,6 +506,10 @@ class EBSCODocument
*/ */
public function facets() public function facets()
{ {
if ($this->results instanceof EBSCOException ) {
return array();
}
$actions = array(); $actions = array();
foreach($this->filters as $filter) { foreach($this->filters as $filter) {
$actions[] = $filter['action']; $actions[] = $filter['action'];
@ -494,6 +585,10 @@ class EBSCODocument
public function limiters() public function limiters()
{ {
$actions = array(); $ids = array(); $actions = array(); $ids = array();
if ($this->info instanceof EBSCOException)
{
return array();
}
$filters = $this->filters(); $filters = $this->filters();
foreach($filters as $filter) { foreach($filters as $filter) {
$actions[] = $filter['action']; $actions[] = $filter['action'];
@ -536,6 +631,9 @@ class EBSCODocument
*/ */
public function record_count() public function record_count()
{ {
if ($this->results instanceof EBSCOException ) {
return 0;
}
return !empty($this->results) ? $this->results['recordCount'] : 0; return !empty($this->results) ? $this->results['recordCount'] : 0;
} }
@ -547,6 +645,9 @@ class EBSCODocument
*/ */
public function record_end() public function record_end()
{ {
if ($this->results instanceof EBSCOException ) {
return -1;
}
$count = !empty($this->results) ? count($this->results['documents']) : 0; $count = !empty($this->results) ? count($this->results['documents']) : 0;
$start = !empty($this->results) ? $this->results['start'] : 0; $start = !empty($this->results) ? $this->results['start'] : 0;
return $start + $count; return $start + $count;
@ -560,6 +661,9 @@ class EBSCODocument
*/ */
public function record_start() public function record_start()
{ {
if ($this->results instanceof EBSCOException ) {
return null;
}
return !empty($this->results) ? $this->results['start'] + 1 : 0; return !empty($this->results) ? $this->results['start'] + 1 : 0;
} }
@ -571,6 +675,9 @@ class EBSCODocument
*/ */
public function search_time() public function search_time()
{ {
if ($this->results instanceof EBSCOException ) {
return 0;
}
return !empty($this->results) && return !empty($this->results) &&
isset($this->results['searchTime']) ? $this->results['searchTime'] : 0; isset($this->results['searchTime']) ? $this->results['searchTime'] : 0;
} }
@ -644,6 +751,9 @@ class EBSCODocument
*/ */
public function has_records() public function has_records()
{ {
if ($this->results instanceof EBSCOException ) {
return false;
}
return !empty($this->results) && !empty($this->results['documents']); return !empty($this->results) && !empty($this->results['documents']);
} }
@ -655,6 +765,9 @@ class EBSCODocument
*/ */
public function search_create($query = null) public function search_create($query = null)
{ {
if ($this->results instanceof EBSCOException ) {
return array();
}
$last_search = array(); $last_search = array();
if (!empty($this->results)) { if (!empty($this->results)) {
$results_identifiers = array(); $results_identifiers = array();

4
ebsco/lib/EBSCORecord.php

@ -4,7 +4,9 @@
* *
* PHP version 5 * PHP version 5
* *
* Copyright [2014] [EBSCO Information Services] *
*
* Copyright [2017] [EBSCO Information Services]
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

118
ebsco/lib/EBSCOResponse.php

@ -7,7 +7,7 @@
* PHP version 5 * PHP version 5
* *
* *
* Copyright [2014] [EBSCO Information Services] * Copyright [2017] [EBSCO Information Services]
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -65,15 +65,20 @@ class EBSCOResponse
{ {
if (!empty($this->response->AuthToken)) { if (!empty($this->response->AuthToken)) {
return $this->buildAuthenticationToken(); return $this->buildAuthenticationToken();
} else if (!empty($this->response->SessionToken)) { }
else if (!empty($this->response->SessionToken)) {
return (string) $this->response->SessionToken; return (string) $this->response->SessionToken;
} else if (!empty($this->response->SearchResult)) { }
else if (!empty($this->response->SearchResult)) {
return $this->buildSearch(); return $this->buildSearch();
} else if(!empty($this->response->Record)) { }
else if(!empty($this->response->Record)) {
return $this->buildRetrieve(); return $this->buildRetrieve();
} else if(!empty($this->response->AvailableSearchCriteria)) { }
else if(!empty($this->response->AvailableSearchCriteria)) {
return $this->buildInfo(); return $this->buildInfo();
} else { // Should not happen, it may be an exception }
else { // Should not happen, it may be an exception
return $this->response; return $this->response;
} }
} }
@ -120,12 +125,28 @@ class EBSCOResponse
$facets = $this->buildFacets(); $facets = $this->buildFacets();
} }
// research Starters & emp
$relatedC=null;
if ($this->response->SearchResult->RelatedContent) {
$result =json_decode(json_encode($this->response->SearchResult->RelatedContent), TRUE);;
$relatedC = $result;
}
//did you mean / auto suggest
$autoSuggestTerms=null;
if ($this->response->SearchResult->AutoSuggestedTerms) {
$result =json_decode(json_encode($this->response->SearchResult->AutoSuggestedTerms), TRUE);;
$autoSuggestTerms = $result;
}
$results = array( $results = array(
'recordCount' => $hits, 'recordCount' => $hits,
'searchTime' => $searchTime, 'searchTime' => $searchTime,
'numFound' => $hits, 'numFound' => $hits,
'start' => 0, 'start' => 0,
'documents' => $records, 'documents' => $records,
'relatedContent' => $relatedC,
'autoSuggestTerms' => $autoSuggestTerms,
'facets' => $facets 'facets' => $facets
); );
@ -149,6 +170,7 @@ class EBSCOResponse
$records = $this->response->SearchResult->Data->Records->Record; $records = $this->response->SearchResult->Data->Records->Record;
foreach ($records as $record) { foreach ($records as $record) {
$result = array(); $result = array();
//var_dump($record);
$result['ResultId'] = $record->ResultId ? (integer) $record->ResultId : ''; $result['ResultId'] = $record->ResultId ? (integer) $record->ResultId : '';
$result['DbId'] = $record->Header->DbId ? (string) $record->Header->DbId : ''; $result['DbId'] = $record->Header->DbId ? (string) $record->Header->DbId : '';
@ -225,9 +247,11 @@ class EBSCOResponse
} }
} }
$results[] = $result; $results[] = $result;
} }
return $results; return $results;
} }
@ -246,30 +270,32 @@ class EBSCOResponse
$results = array(); $results = array();
$facets = $this->response->SearchResult->AvailableFacets->AvailableFacet; $facets = $this->response->SearchResult->AvailableFacets->AvailableFacet;
foreach ($facets as $facet) { if ($facets) {
$values = array(); foreach ($facets as $facet) {
foreach ($facet->AvailableFacetValues->AvailableFacetValue as $value) { $values = array();
$this_value = (string) $value->Value; foreach ($facet->AvailableFacetValues->AvailableFacetValue as $value) {
$this_value = str_replace(array('\(','\)'), array('(', ')'), $this_value); $this_value = (string) $value->Value;
$this_action = (string) $value->AddAction; $this_value = str_replace(array('\(','\)'), array('(', ')'), $this_value);
$this_action = str_replace(array('\(','\)'), array('(', ')'), $this_action); $this_action = (string) $value->AddAction;
$values[] = array( $this_action = str_replace(array('\(','\)'), array('(', ')'), $this_action);
'Value' => $this_value, $values[] = array(
'Action' => $this_action, 'Value' => $this_value,
'Count' => (string) $value->Count 'Action' => $this_action,
); 'Count' => (string) $value->Count
} );
$id = (string) $facet->Id; }
$label = (string) $facet->Label; $id = (string) $facet->Id;
if (!empty($label)) { $label = (string) $facet->Label;
$results[] = array( if (!empty($label)) {
'Id' => $id, $results[] = array(
'Label' => $label, 'Id' => $id,
'Values' => $values, 'Label' => $label,
'isApplied' => false 'Values' => $values,
); 'isApplied' => false
} );
} }
}
}
return $results; return $results;
} }
@ -319,6 +345,29 @@ class EBSCOResponse
); );
} }
// RelatedContent
$elements = $this->response->AvailableSearchCriteria->AvailableRelatedContent->AvailableRelatedContent;
$relatedContent = array();
foreach ($elements as $element) {
$relatedContent[] = array(
'Type' => (string) $element->Type,
'Label' => (string) $element->Label,
'Action' => (string) $element->AddAction,
'DefaultOn' => (string) $element->DefaultOn
);
}
// Did you mean
$elements = $this->response->AvailableSearchCriteria->AvailableDidYouMeanOptions->AvailableDidYouMeanOption;
$didYouMean = array();
foreach ($elements as $element) {
$didYouMean[] = array(
'Id' => (string) $element->Id,
'Label' => (string) $element->Label,
'DefaultOn' => (string) $element->DefaultOn
);
}
// Limiters // Limiters
$elements = $this->response->AvailableSearchCriteria->AvailableLimiters->AvailableLimiter; $elements = $this->response->AvailableSearchCriteria->AvailableLimiters->AvailableLimiter;
$limiters = array(); $limiters = array();
@ -348,7 +397,9 @@ class EBSCOResponse
'sort' => $sort, 'sort' => $sort,
'tags' => $tags, 'tags' => $tags,
'expanders' => $expanders, 'expanders' => $expanders,
'limiters' => $limiters 'limiters' => $limiters,
'relatedContent' => $relatedContent,
'didYouMean' => $didYouMean
); );
return $result; return $result;
@ -385,9 +436,12 @@ class EBSCOResponse
$target = (string) $image->Target; $target = (string) $image->Target;
$result['ImageInfo'][$size] = $target; $result['ImageInfo'][$size] = $target;
} }
} else { }
else
{
$result['ImageInfo'] = ''; $result['ImageInfo'] = '';
} }
if ($record->FullText) { if ($record->FullText) {
$availability = (integer) ($record->FullText->Text->Availability) == 1; $availability = (integer) ($record->FullText->Text->Availability) == 1;
$links = array(); $links = array();

8
ebsco/templates/ebsco-advanced-search.tpl.php

@ -5,8 +5,9 @@
* Displays the advanced search form. * Displays the advanced search form.
* *
* @see template_preprocess_ebsco_advanced_search() * @see template_preprocess_ebsco_advanced_search()
*
* *
* Copyright [2014] [EBSCO Information Services] * Copyright [2017] [EBSCO Information Services]
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -46,6 +47,11 @@
<option value="Title">Title</option> <option value="Title">Title</option>
<option value="Author">Author</option> <option value="Author">Author</option>
<option value="Subject">Subject terms</option> <option value="Subject">Subject terms</option>
<option value="Source">Journal Title/Source</option>
<option value="Abstract">Abstract</option>
<option value="ISBN">ISBN</option>
<option value="ISSN">ISSN</option>
</select> </select>
</div> </div>
<div class="delete-search"> <div class="delete-search">

31
ebsco/templates/ebsco-basic-search.tpl.php

@ -5,8 +5,9 @@
* Displays the basic search form block. * Displays the basic search form block.
* *
* @see template_preprocess_ebsco_basic_search() * @see template_preprocess_ebsco_basic_search()
*
* *
* Copyright [2014] [EBSCO Information Services] * Copyright [2017] [EBSCO Information Services]
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -23,19 +24,17 @@
?> ?>
<div class="container-inline"> <div class="container-inline">
<?php if ($search_view == 'basic'): ?> <?php
<?php print $search_form; ?> if ($search_view == 'basic'){
<?php elseif ($search_view == 'advanced'): ?> echo $search_form;
<a href="<?php print url('ebsco/advanced', array('query' => array('edit' => 1))); ?>" class="small"> }
<?php print t('Edit this Advanced Search'); ?> elseif ($search_view == 'advanced'){
</a> |
<a href="<?php print url('ebsco/advanced'); ?>" class="small"> echo '<a href="'.url('ebsco/advanced', array('query' => array('edit' => 1))).'" class="small">'.t('Edit this Advanced Search')."</a> |";
<?php print t('Start a new Advanced Search'); ?> echo '<a href="'.url('ebsco/advanced').'" class="small">'.t('Start a new Advanced Search').'</a> |';
</a> | echo '<a href="'.url('ebsco/results').'" class="small">'.t('Start a new Basic Search').'</a>';
<a href="<?php print url('ebsco/results'); ?>" class="small"> echo "<br/>";
<?php print t('Start a new Basic Search'); ?> echo t('Your search terms').": <strong>".check_plain($lookfor); "</strong>";
</a> }
<br/> ?>
<?php print t('Your search terms'); ?> : <strong><?php print check_plain($lookfor); ?></strong>
<?php endif; ?>
</div> </div>

252
ebsco/templates/ebsco-result.tpl.php

@ -5,8 +5,9 @@
* Default theme implementation for displaying an EBSCO result. * Default theme implementation for displaying an EBSCO result.
* *
* @see template_preprocess_ebsco_result() * @see template_preprocess_ebsco_result()
*
* *
* Copyright [2014] [EBSCO Information Services] * Copyright [2017] [EBSCO Information Services]
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -22,127 +23,138 @@
*/ */
?> ?>
<?php if ($record): ?>
<?php <?php
$id = check_plain($record->record_id()); if ($record) {
$fulltextUrl = url('ebsco/fulltext', array('query' => array('id' => $id)));
$pdfUrl = url('ebsco/pdf', array('query' => array('id' => $id))); $id = check_plain($record->record_id());
$fulltextUrl = url('ebsco/fulltext', array('query' => array('id' => $id)));
$pdfUrl = url('ebsco/pdf', array('query' => array('id' => $id)));
?> ?>
<div class="ebsco-record"> <div class="ebsco-record">
<h1><?php print $record->title; ?></h1> <h1><?php print $record->title; ?></h1>
<div class="record-toolbar"> <div class="record-toolbar">
<?php if ($last_search): ?> <?php
<div class="floatright"> if ($last_search){
<?php if ($last_search['previous']): ?> ?>
<a href="<?php print url('ebsco/result', array('query' => array('id' => $last_search['previous'], 'op' => 'Previous'))); ?>" class="_record_link"> <div class="floatright">
&laquo; <?php print t('Previous'); ?> <?php
</a> if ($last_search['previous']){
<?php endif; ?> echo '<a href="'.url('ebsco/result', array('query' => array('id' => $last_search['previous'], 'op' => 'Previous'))).'" class="_record_link">&laquo; '.t('Previous').'</a>';
#<?php print $last_search['current_index']; ?> of <?php print $last_search['count']; ?> }
<?php if ($last_search['next']): ?> echo "#";
<a href="<?php print url('ebsco/result', array('query' => array('id' => $last_search['next'], 'op' => 'Next'))); ?>" class="_record_link"> print $last_search['current_index']; ?> of <?php print $last_search['count'];
<?php print t('Next'); ?> &raquo;
</a> if ($last_search['next']){
<?php endif; ?> echo '<a href="'.url('ebsco/result', array('query' => array('id' => $last_search['next'], 'op' => 'Next'))).'" class="_record_link">'.t('Next').' &raquo;</a>';
</div>
<div class="floatleft"> }
<a href="<?php print "?{$last_search['query']}"; ?>"> ?>
&laquo; <?php print t('Back to Results list'); ?> </div>
</a> <div class="floatleft">
</div> <a href="<?php print "?{$last_search['query']}"; ?>">
<div class="clear"></div> &laquo; <?php print t('Back to Results list'); ?>
<?php endif; ?> </a>
</div> </div>
<div class="clear"></div>
<div class="span-5"> <?php
<ul class="external-links"> }
<?php if($record->p_link): ?> ?>
<li> </div>
<a href="<?php print $record->p_link; ?>">
<?php print t('View in EDS'); ?> <div class="span-5">
</a> <ul class="external-links">
</li> <?php
<?php endif; ?> if($record->p_link){
<?php if ($record->pdf_link): ?> echo "<li> <a href='".$record->p_link."'>".t('View in EDS')."</a></li>";
<li> }
<a href="<?php print $pdfUrl; ?>" class="icon pdf fulltext">
<?php print t('PDF full text'); ?> if ($record->pdf_link){
</a> echo '
</li> <li>
<?php endif; ?> <a href="'.$pdfUrl.'" class="icon pdf fulltext">'.t('PDF full text').'</a>
<?php if ($record->full_text_availability): ?> </li>';
<li> }
<a href="<?php if (!user_is_logged_in()) { print $fulltextUrl; } ?>#html" class="icon html fulltext">
<?php print t('HTML full text'); ?> if ($record->full_text_availability){
</a> echo '
</li> <li>
<?php endif; ?> <a href="'.( (!user_is_logged_in())?$fulltextUrl:"").'#html" class="icon html fulltext">'.t('HTML full text').'</a>
<?php if (!empty($record->custom_links)): ?> </li>';
<?php foreach ($record->custom_links as $link): ?> }
<li>
<a href="<?php print $link['Url']; ?>" target="_blank" title="<?php print $link['MouseOverText']; ?>" class="external-link"> if (!empty($record->custom_links)){
<?php if ($link['Icon']): ?><img src="<?php print $link['Icon']?>" /><?php endif; ?><?php print $link['Name']; ?> foreach ($record->custom_links as $link){
</a> echo '
</li> <li>
<?php endforeach; ?> <a href="'.$link['Url'].'" target="_blank" title="'.$link['MouseOverText'].'" class="external-link">'. ($link['Icon'])? '<img src="'.$link['Icon'].'" />':''.$link['Name'].'</a>
<?php endif; ?> </li>';
</ul> }
</div> }
?>
<div class="span-13"> </ul>
<table cellpadding="2" cellspacing="0" border="0" class="citation" summary="<?php print t('Bibliographic Details'); ?>"> </div>
<?php foreach ($record->items as $item): ?>
<?php if (!empty($item['Data'])): ?> <div class="span-13">
<tr valign="top"> <table cellpadding="2" cellspacing="0" border="0" class="citation" summary="<?php print t('Bibliographic Details'); ?>">
<th width="150"><?php print t($item['Label']); ?>:</th> <?php
<td><?php print auto_link($item['Data']); ?></td> foreach ($record->items as $item){
</tr> if (!empty($item['Data'])){
<?php endif; ?> echo '
<?php endforeach; ?> <tr valign="top">
<th width="150">'.t($item['Label']).':</th>
<?php if ($record->db_label): ?> <td>'.auto_link($item['Data']).'</td>
<tr valign="top"> </tr>';
<th width="150"><?php print t('Database'); ?>:</th> }
<td><?php print check_plain($record->db_label); ?></td> }
</tr>
<?php endif; ?> if ($record->db_label){
echo '
<?php if ($record->full_text): ?> <tr valign="top">
<tr id="html" valign="top"> <th width="150">'.t('Database').':</th><td>'.check_plain($record->db_label).'</td>
<td colspan="2" class="html"> </tr>';
<?php print $record->full_text; ?> }
</td>
</tr> if ($record->full_text){
<?php elseif ($record->access_level && !user_is_logged_in()): ?> echo '
<tr id="html" valign="top"> <tr id="html" valign="top">
<td colspan="2" class="html"> <td colspan="2" class="html">'.$record->full_text.'</td>
<p> </tr>';
<?php print t('The full text cannot be displayed to guests.'); ?> }
<br /> elseif ($record->access_level && !user_is_logged_in()){
<?php $link = '<a href="' . url('user') . '">' . t('Login') . '</a>'; ?> echo '
<strong><?php print sprintf(t('%s for full access.'), $link); ?></strong> <tr id="html" valign="top">
</p> <td colspan="2" class="html">
</td> <p>'.t('The full text cannot be displayed to guests.').'<br />.';
</tr> $link = '<a href="' . url('user') . '">' . t('Login') . '</a>';
<?php endif; ?> echo '<strong>'.sprintf(t('%s for full access.'), $link).'</strong>
</table> </p>
</div> </td>
</tr>
<div class="span-4"> ';
<?php if ($record->medium_thumb_link): ?> }
<img src="<?php print check_url($record->medium_thumb_link); ?>" class="book-jacket" alt="<?php print t('Book jacket')?>"/> ?>
<?php endif; ?> </table>
<?php if ($record->publication_type): ?> </div>
<p><?php print check_plain($record->publication_type); ?></p>
<?php endif; ?> <div class="span-4">
</div> <?php
if ($record->medium_thumb_link){
<div class="clear"></div> echo '<img src="'.check_url($record->medium_thumb_link).'" class="book-jacket" alt="'.t('Book jacket').'"/>';
}
</div>
<?php endif; ?> if ($record->publication_type){
echo '<p>'. check_plain($record->publication_type).'</p>';
}
?>
</div>
<div class="clear"></div>
</div>
<?php
}
?>
<div id="spinner" class="spinner"></div> <div id="spinner" class="spinner"></div>

369
ebsco/templates/ebsco-results.tpl.php

@ -5,8 +5,9 @@
* Default theme implementation for displaying EBSCO results. * Default theme implementation for displaying EBSCO results.
* *
* @see template_preprocess_ebsco_results() * @see template_preprocess_ebsco_results()
*
* *
* Copyright [2014] [EBSCO Information Services] * Copyright [2017] [EBSCO Information Services]
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -20,37 +21,219 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
?>
<?php if ($records): ?>
<?php print t('Showing'); ?> if (isset ($autoSuggestTerms) ) {
<strong><?php print $record_start; ?></strong> - <strong><?php print $record_end; ?></strong> if (count($autoSuggestTerms)>0) {
<?php print t('of'); ?> <strong><?php print $record_count; ?></strong> $suggestString="";
<?php if ($search_view == 'basic'): ?> foreach ($autoSuggestTerms as $term ) {
<?php print t('for search')?>: <strong>'<?php print check_plain($lookfor); ?>'</strong> $path = url('ebsco/results', array('query' => array('type' => "")));
<?php endif; ?> $suggestString.="<a href=\"{$path}&lookfor=$term\">".$term."</a> ";
<?php if ($search_time): ?> }
, <?php print t('query time'); ?>: <?php print check_plain(round($search_time, 2)); ?>s echo "<p><strong>Did you mean ".$suggestString."?</strong></p>";
<?php endif; ?> }
}
<?php print $sort_form; ?> if ($records){
<?php print $pager; ?>
echo t('Showing')." <strong>".$record_start."</strong> - <strong> ".$record_end."</strong> ".t('of')." <strong>".$record_count."</strong> ";
if ($search_view == 'basic') {
echo t('for search')." <strong>'".check_plain($lookfor)."'</strong> ";
}
if ($search_time){
echo "," .t('query time').":".check_plain(round($search_time, 2))." s";
}
print $sort_form;
print $pager;
if (!user_is_logged_in()) {
$link = '<a href="' . url('user') . '">' . t('Login') . '</a>';
echo '<p class="top-login-message">';
echo sprintf(t('Hello, Guest. %s for full access.'), $link);
echo '</p>';
}
$tabs="";
$tabsContent="";
$counter=0;
$rsItem=null;
if (isset ($relatedContent) ) {
foreach ($relatedContent as $item ) {
if (isset($item["RelatedRecord"])) {
$tabs.='<li data-target="#researchstarters" data-slide-to="'.$counter.'" '.($counter==0?' class="active" ':' ').'></li>';
$counter++;
if (isset($item["RelatedRecord"]["Records"]["Record"][0])) {
$rsItem=$item["RelatedRecord"]["Records"]["Record"][0];
}
else
{
if (isset($item["Records"]["Record"])) {
$rsItem=$item["Records"]["Record"];
}
}
if ($rsItem==null) {
continue ;
}
//var_dump($rsItem);
$rsTitle="";
$rsSubjects="";
$rsAbstract="";
$rsSource="";
$rsImage="";
$rsAN=$rsItem["Header"]["An"];
$rsDB=$rsItem["Header"]["DbId"];
$rsUrl = url('ebsco/result', array('query' => array('id' => $rsAN."|".$rsDB)));
if (isset($rsItem["ImageInfo"]["CoverArt"])) {
$rsImage=$rsItem["ImageInfo"]["CoverArt"]["Target"];
}
foreach($rsItem["Items"]["Item"] as $it) {
switch ($it["Group"]) {
case "Ti":
$rsTitle=$it["Data"];
break;
case "Src":
$rsSource=$it["Data"];
break;
case "Su":
$rsSubjects=$it["Data"];
break;
case "Ab":
$rsAbstract=$it["Data"];
break;
}
}
$tabsContent.='<div class="item" ><div class="carousel-caption">';
if ($rsImage<>"") {
$tabsContent.='<img src="'.$rsImage.'" alt="'.$rsTitle.'" style="float:left">';
}
if ($rsTitle<>""){
$tabsContent.='<h3 class="relatedTitle"><a href="'.$rsUrl.'" class="title _record_link">'.$rsTitle.'</a></h3>';
}
if ($rsSubjects<>""){
$path = url('ebsco/results', array('query' => array('type' => "Subject")));
$link_xml = '/<searchLink fieldCode="([^\"]*)" term="%22([^\"]*)%22">/';
$link_html = "<a href=\"{$path}&lookfor=$2\">";
$rsSubjects = preg_replace($link_xml, $link_html, $rsSubjects);
$rsSubjects = str_replace('</searchLink>', '</a>', $rsSubjects);
$tabsContent.='<p><strong>'.t('Subjects').'</strong>:<span class="quotestart">'.str_replace(array("<br>","<br />"), ', ', $rsSubjects).'</span></p>';
}
if ($rsSource<>""){
$tabsContent.='<p>'.$rsSource.'</p>';
}
if ($rsAbstract<>""){
$tabsContent.='<p><cite>'.$rsAbstract.'</cite></p>';
}
$tabsContent.='</div></div>';
}
// replated publications
if (isset($item["RelatedPublication"])) {
//var_dump($item);
$tabs.='<li data-target="#ematchplacard" data-slide-to="'.$counter.'" '.($counter==0?' class="active" ':' ').'></li>';
$counter++;
$tabsContent.='<div class="item" ><div class="carousel-caption">';
$tabsContent.='
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/themes/default/style.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/jstree.min.js"></script>
';
foreach ($item["RelatedPublication"]["PublicationRecords"] as $pub){
$plink = $pub["PLink"];
foreach($pub["Items"]["Item"] as $item) {
if ($item["Group"]=="Ti")
{
$tabsContent.='<h3 class="relatedTitle"><a href="'.$plink.' target="_blank" >'.$item["Data"].'</a></h3>';
}
else
{
$tabsContent.="<strong>".$item["Label"]."</strong> : ".$item["Data"]."<br/>";
}
}
$tabsContent.='<div id="publicationList"><ul>';
foreach($pub["FullTextHoldings"]["FullTextHolding"] as $itemHoldings) {
$hURL=isset($itemHoldings["URL"])?$itemHoldings["URL"] :"";
$hName=isset($itemHoldings["Name"])?$itemHoldings["Name"] :"";
$hCoverage=isset($itemHoldings["CoverageStatement"])?$itemHoldings["CoverageStatement"] :"";
$hEmbargo="";
if (isset($itemHoldings["EmbargoDescription"])) {
// if no embargo, zero size array
if (!is_array($itemHoldings["EmbargoDescription"] )) {
$hEmbargo=$itemHoldings["EmbargoDescription"];
}
}
$tabsContent.='<li>
<a href="'.$hURL.'" target="_blank">'.$hName.'</a>;
<ul><li>Coverage:'.$hCoverage.'; ';
if ($hEmbargo<>'') {
$tabsContent.='</li><li>Embargo:'.$hEmbargo;
}
$tabsContent.='</li></ul></li>';
// Notes
}
$tabsContent.='</ul></div>';
}
$tabsContent.='
<script>
jQuery("#publicationList").jstree().on("changed.jstree", function (e, data) {
var pubURL = data.instance.get_node(data.node, true).children("a").attr("href");
if (pubURL!="#") {
window.open(pubURL);
}
});
</script>';
$tabsContent.='</div></div>';
break;
}
}
}
if ($tabsContent<>"") {
echo '<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<?php if (!user_is_logged_in()): ?> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<?php $link = '<a href="' . url('user') . '">' . t('Login') . '</a>'; ?>
<p class="top-login-message"> <div id="relatedInformation" class="carousel slide" data-ride="carousel" style="display:block;">
<?php print sprintf(t('Hello, Guest. %s for full access.'), $link); ?> <!-- Indicators -->
</p> <ol class="carousel-indicators">'.$tabs.'</ol>';
<?php endif; ?> echo '<div class="carousel-inner" role="listbox" >'.$tabsContent.'</div>';
echo '<!-- Left and right controls -->
<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" ></span>
</a>
<a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" ></span>
</a>
</div>
<script>
jQuery("#relatedInformation").carousel({
pause: true,
interval:4000
})
</script>';
}
?>
<ol class="search-results ebsco"> <ol class="search-results ebsco">
<?php foreach ($records as $record): ?> <?php foreach ($records as $record):
<?php
$id = check_plain($record->record_id()); $id = check_plain($record->record_id());
$recordUrl = url('ebsco/result', array('query' => array('id' => $id))); $recordUrl = url('ebsco/result', array('query' => array('id' => $id)));
$fulltextUrl = url('ebsco/fulltext', array('query' => array('id' => $id))); $fulltextUrl = url('ebsco/fulltext', array('query' => array('id' => $id)));
$pdfUrl = url('ebsco/pdf', array('query' => array('id' => $id))); $pdfUrl = url('ebsco/pdf', array('query' => array('id' => $id)));
?> ?>
<li> <li>
<div class="record-number floatleft"> <div class="record-number floatleft">
@ -59,87 +242,92 @@
<div class="result floatleft"> <div class="result floatleft">
<div class="span-2"> <div class="span-2">
<?php if ($record->small_thumb_link): ?> <?php
<a href="<?php print $recordUrl; ?>" class="_record_link"> if ($record->small_thumb_link){
<img src="<?php print $record->small_thumb_link; ?>" class="book-jacket" alt="<?php print t('Book jacket'); ?>"/> echo'
</a> <a href="'.$recordUrl.'" class="_record_link">
<?php endif; ?> <img src="'.$record->small_thumb_link.'" class="book-jacket" alt="'.t('Book jacket').'"/>
</a>';
}
?>
</div> </div>
<div class="span-9"> <div class="span-9">
<div class="result-line1"> <div class="result-line1">
<?php if ($record->access_level == '1'): ?> <?php
<p>
<?php if ($record->access_level == '1'){
$label = '<strong>' . check_plain($record->db_label) . '</strong>'; echo '<p>';
$link = '<a href="' . url('user') . '">' . t('Login') . '</a>'; $label = '<strong>' . check_plain($record->db_label) . '</strong>';
?> $link = '<a href="' . url('user') . '">' . t('Login') . '</a>';
<?php print sprintf(t('This result from %s cannot be displayed to guests.'), $label); ?> echo sprintf(t('This result from %s cannot be displayed to guests.'), $label)."<br /><strong>".sprintf(t('%s for full access.'), $link)."</strong>";
<br /> echo "</p>";
<strong><?php print sprintf(t('%s for full access.'), $link); ?></strong> }
</p> elseif ($record->title){
<?php elseif ($record->title): ?> echo '<a href="'.$recordUrl.'" class="title _record_link">'.$record->title.'</a>';
<a href="<?php print $recordUrl; ?>" class="title _record_link"> }
<?php print $record->title; ?> ?>
</a>
<?php endif; ?>
</div> </div>
<div class="result-line2"> <div class="result-line2">
<?php if (!empty($record->authors)): ?> <?php
<p> if (!empty($record->authors)){
<?php print t('by'); ?> echo "<span>".t('by'). " ".str_replace(array("<br>","<br />"), ', ', $record->authors)." </span>";
<?php print $record->authors; ?> }
</p>
<?php endif; ?> if (!empty($record->source)){
echo '<p>'.t('Published in')." ".$record->source.'</p>';
<?php if (!empty($record->source)): ?> }
<p>
<?php print t('Published in'); ?> ?>
<?php print $record->source; ?>
</p>
<?php endif; ?>
</div> </div>
<div class="result-line3"> <div class="result-line3">
<?php if (!empty($record->summary)): ?> <?php
<cite><?php print $record->summary; ?></cite>
<br /> if (!empty($record->summary)){
<?php endif; ?> echo '<cite>'.$record->summary.'</cite><br />';
}
<?php if (!empty($record->subjects)): ?>
<strong><?php print t('Subjects'); ?></strong>: if (!empty($record->subjects)){
<span class="quotestart"><?php print str_replace('<br />', ', ', $record->subjects); ?></span> echo '<strong>'.t('Subjects').'</strong>:<span class="quotestart">'.str_replace('<br />', ', ', $record->subjects).'</span>';
<?php endif; ?> }
?>
</div> </div>
<?php if (!empty($record->custom_links)): ?> <?php
if (!empty($record->custom_links)){
?>
<div class="result-line4"> <div class="result-line4">
<ul class="custom-links"> <ul class="custom-links">
<?php foreach ($record->custom_links as $link): ?> <?php
foreach ($record->custom_links as $link){ ?>
<li> <li>
<a href="<?php print $link['Url']; ?>" target="_blank" title="<?php print $link['MouseOverText']; ?>" class="external-link"> <a href="<?php print $link['Url']; ?>" target="_blank" title="<?php print $link['MouseOverText']; ?>" class="external-link">
<?php if ($link['Icon']): ?><img src="<?php print $link['Icon']?>" /><?php endif; ?><?php print $link['Name']; ?> <?php if ($link['Icon']): ?><img src="<?php print $link['Icon']?>" /><?php endif; ?><?php print $link['Name']; ?>
</a> </a>
</li> </li>
<?php endforeach; ?> <?php } ?>
</ul> </ul>
</div> </div>
<?php endif; ?> <?php } ?>
<div class="result-line5"> <div class="result-line5">
<?php if ($record->full_text_availability): ?> <?php
<a href="<?php print $fulltextUrl; ?>#html" class="icon html fulltext _record_link"> if ($record->full_text_availability){
<?php print t('HTML full text'); ?> echo '<a href="'.$fulltextUrl.'#html" class="icon html fulltext _record_link">';
</a> echo t('HTML full text');
&nbsp; &nbsp; echo "</a>&nbsp; &nbsp;";
<?php endif; ?> }
<?php if ($record->pdf_availability): ?> if ($record->pdf_availability){
<a href="<?php print $pdfUrl; ?>" class="icon pdf fulltext"> echo ' <a href="'.$pdfUrl.'" class="icon pdf fulltext">';
<?php print t('PDF full text'); ?> echo t('PDF full text');
</a> echo "</a>";
<?php endif; ?> }
?>
</div> </div>
</div> </div>
</div> </div>
@ -149,9 +337,22 @@
</ol> </ol>
<?php print $pager; ?> <?php print $pager; ?>
<?php elseif (!empty($lookfor)) : ?> <?php
<h2><?php print t('Your search did not match any resources.');?></h2> }
<?php print search_help('search#noresults', drupal_help_arg()); ?> elseif (!empty($lookfor)) {
<?php endif; ?> echo "<h2>".t('Your search did not match any resources.')."</h2>";
// check for autocomplete
/*
if (isset ($autoSuggestTerms) ) {
if (count($autoSuggestTerms)>0) {
echo "Did you mean "."?<br/>";
var_dump($autoSuggestTerms);
}
}
*/
echo search_help('search#noresults', drupal_help_arg());
}
?>
<div id="spinner" class="spinner"></div> <div id="spinner" class="spinner"></div>

3
ebsco/templates/ebsco-side-facets.tpl.php

@ -6,7 +6,8 @@
* *
* @see template_preprocess_ebsco_side_facets() * @see template_preprocess_ebsco_side_facets()
* *
* Copyright [2014] [EBSCO Information Services] *
* Copyright [2017] [EBSCO Information Services]
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

Loading…
Cancel
Save