Browse Source

fixed session issues on for eds and minor changes

2.x-ebsco
Paul Pound 12 years ago
parent
commit
86ef54b274
  1. 2
      targets/cufts/theme/roblib-search-cufts.tpl.php
  2. 680
      targets/eds/includes/rest/EBSCOAPI.php
  3. 7
      targets/eds/roblib_search_eds.module
  4. 2
      targets/eds/theme/roblib-search-eds.tpl.php
  5. 14
      targets/evergreen/js/evergreen_results.js
  6. 19
      targets/evergreen/roblib_search_evergreen.module
  7. 2
      targets/evergreen/theme/roblib-search-evergreen.tpl.php

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

@ -18,7 +18,7 @@
?> ?>
<div class ="roblib-search-content cufts" id="roblib-search-content-cufts"> <div class ="roblib-search-content cufts" id="roblib-search-content-cufts">
<img src="<?php print $spinner_path; ?>"/> <img src="<?php print (empty($spinner_path) ? ' ' : $spinner_path); ?>"/>
</div> </div>
<div class ="roblib-search-more">Search all Journals</div> <div class ="roblib-search-more">Search all Journals</div>

680
targets/eds/includes/rest/EBSCOAPI.php

@ -1,6 +1,5 @@
<?php <?php
/** /**
* EBSCO API class * EBSCO API class
* *
@ -8,384 +7,383 @@
* *
*/ */
/** /**
* EBSCO API class * EBSCO API class
*/ */
class EBSCOAPI class EBSCOAPI {
{
/** /**
* The authentication token used for API transactions * The authentication token used for API transactions
* @global string * @global string
*/ */
private $authenticationToken; private $authenticationToken;
/**
/** * The session token for API transactions
* The session token for API transactions * @global string
* @global string */
*/ private $sessionToken;
private $sessionToken;
/**
/** * The EBSCOConnector object used for API transactions
* The EBSCOConnector object used for API transactions * @global object EBSCOConnector
* @global object EBSCOConnector */
*/ private $connector;
private $connector; private $config;
private $config; public function __construct($config) {
$this->config = $config;
public function __construct($config) { $this->connector = new EBSCOConnector($config);
$this->config = $config; }
/**
* Create a new EBSCOConnector object or reuse an existing one
*
* @param none
*
* @return EBSCOConnector object
* @access public
*/
public function connector($config) {
if (empty($this->connector)) {
$this->connector = new EBSCOConnector($config); $this->connector = new EBSCOConnector($config);
} }
/** return $this->connector;
* Create a new EBSCOConnector object or reuse an existing one }
*
* @param none
*
* @return EBSCOConnector object
* @access public
*/
public function connector($config)
{
if (empty($this->connector)) {
$this->connector = new EBSCOConnector($config);
}
return $this->connector; /**
} * Create a new EBSCOResponse object
*
* @param object $response
*
* @return EBSCOResponse object
* @access public
*/
public function response($response) {
$responseObj = new EBSCOResponse($response);
return $responseObj;
}
/**
* Request authentication and session tokens, then send the API request.
* Retry the request if authentication errors occur
*
* @param string $action The EBSCOConnector method name
* @param array $params The parameters for the HTTP request
* @param integer $attempts The number of retries. The default number is 3 but can be increased.
* 3 retries can handle a situation when both autentication and session tokens need to be refreshed + the current API call
*
* @return array An associative array with results.
* @access protected
*/
protected function request($action, $params = null, $attempts = 3) {
try {
/** $authenticationToken = $this->getAuthToken();
* Create a new EBSCOResponse object $sessionToken = $this->getSessionToken($authenticationToken);
*
* @param object $response
*
* @return EBSCOResponse object
* @access public
*/
public function response($response)
{
$responseObj = new EBSCOResponse($response);
return $responseObj;
}
if (empty($authenticationToken)) {
$authenticationToken = $this->getAuthToken();
}
/** if (empty($sessionToken)) {
* Request authentication and session tokens, then send the API request. $sessionToken = $this->getSessionToken($authenticationToken, 'y');
* Retry the request if authentication errors occur }
*
* @param string $action The EBSCOConnector method name $headers = array(
* @param array $params The parameters for the HTTP request 'x-authenticationToken: ' . $authenticationToken,
* @param integer $attempts The number of retries. The default number is 3 but can be increased. 'x-sessionToken: ' . $sessionToken
* 3 retries can handle a situation when both autentication and session tokens need to be refreshed + the current API call );
*
* @return array An associative array with results. $response = call_user_func_array(array($this->connector($this->config), "request{$action}"), array($params, $headers));
* @access protected $result = $this->response($response)->result();
*/ $results = $result;
protected function request($action, $params = null, $attempts = 3) return $results;
{ } catch (EBSCOException $e) {
try { try {
// Retry the request if there were authentication errors
$code = $e->getCode();
switch ($code) {
case EBSCOConnector::EDS_AUTH_TOKEN_INVALID:
$authenticationToken = $this->getAuthToken(); $authenticationToken = $this->getAuthToken();
$sessionToken = $this->getSessionToken($authenticationToken); $sessionToken = $this->getSessionToken($authenticationToken);
if(empty($authenticationToken)){
$authenticationToken = $this -> getAuthToken();
}
if(empty($sessionToken)){
$sessionToken = $this -> getSessionToken($authenticationToken,'y');
}
$headers = array( $headers = array(
'x-authenticationToken: ' . $authenticationToken, 'x-authenticationToken: ' . $authenticationToken,
'x-sessionToken: ' . $sessionToken 'x-sessionToken: ' . $sessionToken
);
$response = call_user_func_array(array($this->connector($this->config), "request{$action}"), array($params, $headers));
$result = $this->response($response)->result();
$results = $result;
return $results;
} catch(EBSCOException $e) {
try {
// Retry the request if there were authentication errors
$code = $e->getCode();
switch ($code) {
case EBSCOConnector::EDS_AUTH_TOKEN_INVALID:
$authenticationToken = $this->getAuthToken();
$sessionToken = $this ->getSessionToken($authenticationToken);
$headers = array(
'x-authenticationToken: ' . $authenticationToken,
'x-sessionToken: ' . $sessionToken
); );
if ($attempts > 0) { if ($attempts > 0) {
return $this->request($action, $params, $headers, --$attempts); return $this->request($action, $params, $headers, --$attempts);
} }
break; break;
case EBSCOConnector::EDS_SESSION_TOKEN_INVALID: case EBSCOConnector::EDS_SESSION_TOKEN_INVALID:
$sessionToken = $this ->getSessionToken($authenticationToken,'y'); $sessionToken = $this->getSessionToken($authenticationToken, 'y');
$headers = array( $headers = array(
'x-authenticationToken: ' . $authenticationToken, 'x-authenticationToken: ' . $authenticationToken,
'x-sessionToken: ' . $sessionToken 'x-sessionToken: ' . $sessionToken
); );
if ($attempts > 0) { if ($attempts > 0) {
return $this->request($action, $params, $headers, --$attempts); return $this->request($action, $params, $headers, --$attempts);
}
break;
default:
$result = array(
'error' => $e->getMessage()
);
return $result;
break;
}
} catch(Exception $e) {
$result = array(
'error' => $e->getMessage()
);
return $result;
} }
} catch(Exception $e) { break;
default:
$result = array( $result = array(
'error' => $e->getMessage() 'error' => $e->getMessage()
); );
return $result; return $result;
break;
}
} catch (Exception $e) {
$result = array(
'error' => $e->getMessage()
);
return $result;
}
} catch (Exception $e) {
$result = array(
'error' => $e->getMessage()
);
return $result;
} }
}
private function writeTokenFile() {
$tokenFile = fopen("edstoken.txt", "w+");
$result = $this->apiAuthenticationToken();
fwrite($tokenFile, $result['authenticationToken'] . "\n");
fwrite($tokenFile, $result['authenticationTimeout'] . "\n");
fwrite($tokenFile, $result['authenticationTimeStamp']);
fclose($tokenFile);
return $result['authenticationToken'];
}
private function writeLockFile() {
$lockFile = fopen("edslock.txt", "w+");
fwrite($lockFile, 'lock');
fclose($lockFile);
}
/*
* Get authentication token from appication scop
* Check authToen's expiration
* if expired get a new authToken and re-new the time stamp
*
* @param none
*
* @access public
*/
public function getAuthToken() {
$lockFile = fopen("edslock.txt", "r");
if (empty($lockFile)) {
$this->writeLockFile();
$lockFile = fopen("edslock.txt", "r");
}
$tokenFile = fopen("edstoken.txt", "r");
if (empty($tokenFile)) {
$this->writetokenFile();
$tokenFile = fopen("edstoken.txt", "r");
} }
while (!feof($tokenFile)) {
private function writeLockFile(){ $authToken = rtrim(fgets($tokenFile), "\n");
$tokenFile = fopen("edstoken.txt","w+"); $timeout = fgets($tokenFile) - 600;
$result = $this->apiAuthenticationToken(); $timestamp = fgets($tokenFile);
fwrite($tokenFile, $result['authenticationToken']."\n");
fwrite($tokenFile, $result['authenticationTimeout']."\n");
fwrite($tokenFile, $result['authenticationTimeStamp']);
fclose($tokenFile);
return $result['authenticationToken'];
} }
fclose($tokenFile);
/* if (time() - $timestamp >= $timeout) {
* Get authentication token from appication scop // Lock check.
* Check authToen's expiration if (flock($lockFile, LOCK_EX)) {
* if expired get a new authToken and re-new the time stamp $tokenFile = fopen("edstoken.txt", "w+");
* $result = $this->apiAuthenticationToken();
* @param none fwrite($tokenFile, $result['authenticationToken'] . "\n");
* fwrite($tokenFile, $result['authenticationTimeout'] . "\n");
* @access public fwrite($tokenFile, $result['authenticationTimeStamp']);
*/
public function getAuthToken(){
$lockFile = fopen("edslock.txt","r");
$tokenFile =fopen("edstoken.txt","r");
if(empty($lockFile) || empty($tokenFile)){
return $this->writeLockFile();
}
while(!feof($tokenFile)){
$authToken = rtrim(fgets($tokenFile),"\n");
$timeout = fgets($tokenFile)-600;
$timestamp = fgets($tokenFile);
}
fclose($tokenFile); fclose($tokenFile);
if(time()-$timestamp>=$timeout){ return $result['authenticationToken'];
// Lock check. }
if(flock($lockFile, LOCK_EX)){ else {
$tokenFile = fopen("edstoken.txt","w+"); return $authToken;
$result = $this->apiAuthenticationToken(); }
fwrite($tokenFile, $result['authenticationToken']."\n");
fwrite($tokenFile, $result['authenticationTimeout']."\n");
fwrite($tokenFile, $result['authenticationTimeStamp']);
fclose($tokenFile);
return $result['authenticationToken'];
}else{
return $authToken;
}
}else{
return $authToken;
}
fclose($lockFile);
} }
else {
/** return $authToken;
* Wrapper for authentication API call
*
* @param none
*
* @access public
*/
public function apiAuthenticationToken()
{
$response = $this->connector->requestAuthenticationToken();
$result = $this->response($response)->result();
return $result;
} }
fclose($lockFile);
}
/**
* Wrapper for authentication API call
*
* @param none
*
* @access public
*/
public function apiAuthenticationToken() {
$response = $this->connector->requestAuthenticationToken();
$result = $this->response($response)->result();
return $result;
}
/** /**
* Get session token for a profile * Get session token for a profile
* If session token is not available * If session token is not available
* a new session token will be generated * a new session token will be generated
* *
* @param Authentication token, Profile * @param Authentication token, Profile
* @access public * @access public
*/ */
public function getSessionToken($authenToken, $invalid='n'){ public function getSessionToken($authenToken, $invalid = 'n') {
$token = ''; $token = '';
// Check user's login status // Check user's login status
if(isset($_COOKIE['login'])){ /* if(isset($_COOKIE['login'])){
if($invalid=='y'){ if($invalid=='y'){
$profile = $_SESSION['sessionToken']['profile']; $profile = $_SESSION['sessionToken']['profile'];
$sessionToken = $this->apiSessionToken($authenToken, $profile,'n'); $sessionToken = $this->apiSessionToken($authenToken, $profile,'n');
$_SESSION['sessionToken']=$sessionToken; $_SESSION['sessionToken']=$sessionToken;
} }
$token = $_SESSION['sessionToken']['sessionToken']; $token = $_SESSION['sessionToken']['sessionToken'];
} */
//else
if (isset($_COOKIE['Guest'])) {
if ($invalid == 'y') {
$profile = $_SESSION['sessionToken']['profile'];
if (empty($profile)) {
$profile = $_COOKIE['Guest'];
} }
else if(isset($_COOKIE['Guest'])){ $sessionToken = $this->apiSessionToken($authenToken, $profile, 'y');
if($invalid=='y'){ $_SESSION['sessionToken'] = $sessionToken;
$profile = $_SESSION['sessionToken']['profile']; }
$sessionToken = $this->apiSessionToken($authenToken, $profile,'y'); $token = $_SESSION['sessionToken']['sessionToken'];
$_SESSION['sessionToken']=$sessionToken;
}
$token = $_SESSION['sessionToken']['sessionToken'];
}else{
//$xml ="Config.xml";
//$dom = new DOMDocument();
//$dom->load($xml);
//$EDSCredentials = $dom ->getElementsByTagName('EDSCredentials')->item(0);
//$users = $EDSCredentials -> getElementsByTagName('User');
$profileId = $this->config['profile'];
//foreach($users as $user){
// $userType = $user->getElementsByTagName('ClientUser')->item(0)->nodeValue;
// if($userType == 'guest'){
// $profileId = $user -> getElementsByTagName('EDSProfile')->item(0)->nodeValue;
// break;
// }
//}
$sessionToken = $this->apiSessionToken($authenToken, $profileId,'y');
$_SESSION['profile'] = $profileId;
$_SESSION['sessionToken']=$sessionToken;
setcookie("Guest", $profileId, 0);
$token = $sessionToken['sessionToken'];
}
return $token;
} }
else {
/** $profileId = $this->config['profile'];
* Wrapper for session API call
*
* @param Authentication token
*
* @access public
*/
public function apiSessionToken($authenToken, $profile, $guest)
{
// Add authentication tokens to headers
$headers = array(
'x-authenticationToken: ' . $authenToken
);
$response = $this->connector($this->config)->requestSessionToken($headers, $profile,$guest); $sessionToken = $this->apiSessionToken($authenToken, $profileId, 'y');
$result = $this->response($response)->result(); $_SESSION['profile'] = $profileId;
$token = array( $_SESSION['sessionToken'] = $sessionToken;
'sessionToken'=>$result, setcookie("Guest", $profileId, 0);
'profile' => $profile $token = $sessionToken['sessionToken'];
);
return $token;
}
/**
* Wrapper for end session API call
*
* @param Authentication token
*
* @access public
*/
public function apiEndSessionToken($authenToken, $sessionToken){
// Add authentication tokens to headers
$headers = array(
'x-authenticationToken: '.$authenToken
);
$this -> connector($this->config)->requestEndSessionToken($headers, $sessionToken);
} }
return $token;
}
/** /**
* Wrapper for search API call * Wrapper for session API call
* *
* @param * @param Authentication token
* *
* @throws object PEAR Error * @access public
* @return array An array of query results */
* @access public public function apiSessionToken($authenToken, $profile, $guest) {
*/ // Add authentication tokens to headers
public function apiSearch($params) { $headers = array(
'x-authenticationToken: ' . $authenToken
$results = $this->request('Search', $params); );
return $results;
}
$response = $this->connector($this->config)->requestSessionToken($headers, $profile, $guest);
$result = $this->response($response)->result();
$token = array(
'sessionToken' => $result,
'profile' => $profile
);
return $token;
}
/** /**
* Wrapper for retrieve API call * Wrapper for end session API call
* *
* @param array $an The accession number * @param Authentication token
* @param string $start The short database name *
* * @access public
* @throws object PEAR Error */
* @return array An associative array of data public function apiEndSessionToken($authenToken, $sessionToken) {
* @access public
*/
public function apiRetrieve($an, $db, $term)
{
// Add the HTTP query params
$params = array(
'an' => $an,
'dbid' => $db,
'highlightterms' => $term // Get currect param name
);
$params = http_build_query($params);
$result = $this->request('Retrieve', $params);
return $result;
}
// Add authentication tokens to headers
$headers = array(
'x-authenticationToken: ' . $authenToken
);
/** $this->connector($this->config)->requestEndSessionToken($headers, $sessionToken);
* Wrapper for info API call }
*
* @return array An associative array of data /**
* @access public * Wrapper for search API call
*/ *
public function getInfo() * @param
{ *
if(isset($_SESSION['info'])){ * @throws object PEAR Error
$InfoArray = $_SESSION['info']; * @return array An array of query results
$timestamp = $InfoArray['timestamp']; * @access public
if(time()-$timestamp>=3600){ */
// Get new Info for the profile public function apiSearch($params) {
$InfoArray = $this->apiInfo();
$_SESSION['info'] = $InfoArray; $results = $this->request('Search', $params);
$info = $InfoArray['Info']; return $results;
}else{ }
$info = $InfoArray['Info'];
} /**
}else{ * Wrapper for retrieve API call
// Get new Info for the profile *
$InfoArray = $this->apiInfo(); * @param array $an The accession number
$_SESSION['info'] = $InfoArray; * @param string $start The short database name
$info = $InfoArray['Info']; *
} * @throws object PEAR Error
return $info; * @return array An associative array of data
* @access public
*/
public function apiRetrieve($an, $db, $term) {
// Add the HTTP query params
$params = array(
'an' => $an,
'dbid' => $db,
'highlightterms' => $term // Get currect param name
);
$params = http_build_query($params);
$result = $this->request('Retrieve', $params);
return $result;
}
/**
* Wrapper for info API call
*
* @return array An associative array of data
* @access public
*/
public function getInfo() {
if (isset($_SESSION['info'])) {
$InfoArray = $_SESSION['info'];
$timestamp = $InfoArray['timestamp'];
if (time() - $timestamp >= 3600) {
// Get new Info for the profile
$InfoArray = $this->apiInfo();
$_SESSION['info'] = $InfoArray;
$info = $InfoArray['Info'];
}
else {
$info = $InfoArray['Info'];
}
} }
else {
public function apiInfo(){ // Get new Info for the profile
$InfoArray = $this->apiInfo();
$response = $this->request('Info',''); $_SESSION['info'] = $InfoArray;
$Info = array( $info = $InfoArray['Info'];
'Info' => $response,
'timestamp'=>time()
);
return $Info;
} }
return $info;
}
public function apiInfo() {
$response = $this->request('Info', '');
$Info = array(
'Info' => $response,
'timestamp' => time()
);
return $Info;
}
} }
?> ?>

7
targets/eds/roblib_search_eds.module

@ -41,7 +41,7 @@ function roblib_search_eds_menu() {
$items['admin/roblib_search/eds_search'] = array( $items['admin/roblib_search/eds_search'] = array(
'title' => 'EDS search Target configuration', 'title' => 'EDS search Target configuration',
'description' => 'Configuration for the Roblib evergreen search target', 'description' => 'Configuration for the Roblib eds search target',
'page callback' => 'drupal_get_form', 'page callback' => 'drupal_get_form',
'page arguments' => array('roblib_search_eds_config_form'), 'page arguments' => array('roblib_search_eds_config_form'),
'access arguments' => array('access administration pages'), 'access arguments' => array('access administration pages'),
@ -216,11 +216,6 @@ function roblib_search_eds_get_results($query = NULL) {
} }
$config = roblib_search_eds_build_config_arr(); $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');*/
$eds_api = new EBSCOAPI($config); $eds_api = new EBSCOAPI($config);
$number_per_page = variable_get('roblib_search_eds_num_results', '5'); $number_per_page = variable_get('roblib_search_eds_num_results', '5');
$query = urlencode($query); $query = urlencode($query);

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

@ -18,7 +18,7 @@
?> ?>
<div class ="roblib-search-content eds" id="roblib-search-content-eds"> <div class ="roblib-search-content eds" id="roblib-search-content-eds">
<img src="<?php print $spinner_path; ?>"/> <img src="<?php print (empty($spinner_path) ? ' ' : $spinner_path); ?>"/>
</div> </div>
<div class ="roblib-search-more" id="roblib-search-eds-more"></div> <div class ="roblib-search-more" id="roblib-search-eds-more"></div>

14
targets/evergreen/js/evergreen_results.js

@ -30,6 +30,13 @@ Drupal.behaviors.roblib_search_evergreen = {
}) })
items.push('</div>') items.push('</div>')
} }
if(typeof val.electronic_holdings !== 'undefined'){
items.push('<div class="evergreen-holdings">');
jQuery.each(val.electronic_holdings, function(key2, val2){
roblibEvergreenAddElectronicHoldings(val2, items);
})
items.push('</div>')
}
items.push('</div>'); items.push('</div>');
}); });
} }
@ -41,9 +48,10 @@ Drupal.behaviors.roblib_search_evergreen = {
} }
function roblibEvergreenAddHoldings(holdings, items){ function roblibEvergreenAddHoldings(holdings, items){
items.push('<div class="evergreen-holdings-item">' + holdings.call_number + ' ' + holdings.availability + '</div>'); items.push('<div class="evergreen-holdings-item">' + holdings.call_number + ' - ' + holdings.location +' (' + holdings.availability + ')</div>');
}
function roblibEvergreenAddElectronicHoldings(holdings, items){
items.push('<div class="evergreen-holdings-item"><a href="' + holdings.url + '">' + holdings.label + '</div>');
} }

19
targets/evergreen/roblib_search_evergreen.module

@ -233,6 +233,7 @@ function roblib_search_evergreen_parse_results($results, $query) {
roblib_search_evergreen_update_array($output, $index, 'date', $record->xpath('marcxml:datafield[@tag="260"]/marcxml:subfield[@code="c"]')); roblib_search_evergreen_update_array($output, $index, 'date', $record->xpath('marcxml:datafield[@tag="260"]/marcxml:subfield[@code="c"]'));
roblib_search_evergreen_update_array($output, $index, 'id', $record->xpath('marcxml:datafield[@tag="901"]/marcxml:subfield[@code="c"]')); roblib_search_evergreen_update_array($output, $index, 'id', $record->xpath('marcxml:datafield[@tag="901"]/marcxml:subfield[@code="c"]'));
roblib_search_evergreen_holdings($output, $index, $record->xpath('marcxml:datafield[@tag="852"]')); roblib_search_evergreen_holdings($output, $index, $record->xpath('marcxml:datafield[@tag="852"]'));
roblib_search_evergreen_electronic_holdings($output, $index, $record->xpath('marcxml:datafield[@tag="856"]'));
$id = $output[$index]['id']; $id = $output[$index]['id'];
$output[$index++]['url'] = variable_get('roblib_search_evergreen_url', 'http://137.149.200.52') $output[$index++]['url'] = variable_get('roblib_search_evergreen_url', 'http://137.149.200.52')
. variable_get('roblib_search_evergreen_detail_suffix', '/opac/en-CA/skin/default/xml/rdetail.xml?r=') . variable_get('roblib_search_evergreen_detail_suffix', '/opac/en-CA/skin/default/xml/rdetail.xml?r=')
@ -249,10 +250,26 @@ function roblib_search_evergreen_holdings(&$arr, $index, $xpath_result){
$call_number = $xml->xpath('marcxml:subfield[@code="c"]'); $call_number = $xml->xpath('marcxml:subfield[@code="c"]');
$arr[$index]['holdings'][$holding_index]['call_number'] = (string)$call_number[0]; $arr[$index]['holdings'][$holding_index]['call_number'] = (string)$call_number[0];
$availability = $xml->xpath('marcxml:subfield[@code="n"]'); $availability = $xml->xpath('marcxml:subfield[@code="n"]');
$arr[$index]['holdings'][$holding_index++]['availability'] = (string)$availability[0]; $arr[$index]['holdings'][$holding_index]['availability'] = (string)$availability[0];
$location = $xml->xpath('marcxml:subfield[@code="a"]');
$arr[$index]['holdings'][$holding_index++]['location'] = (string)$location[0];
} }
} }
function roblib_search_evergreen_electronic_holdings(&$arr, $index, $xpath_result){
$holding_index = 0;
foreach($xpath_result as $xml){
$xml->registerXPathNamespace('marcxml', 'http://www.loc.gov/MARC21/slim');
$label = $xml->xpath('marcxml:subfield[@code="y"]');
$label = (string)$label[0];
$url = $xml->xpath('marcxml:subfield[@code="u"]');
$url = (string)$url[0];
$arr[$index]['electronic_holdings'][$holding_index]['url'] = $url;
$arr[$index]['electronic_holdings'][$holding_index++]['label'] = $label;
}
}
function roblib_search_evergreen_update_array(&$arr, $index, $key, $xpath_result){ function roblib_search_evergreen_update_array(&$arr, $index, $key, $xpath_result){
if(!empty($xpath_result)){ if(!empty($xpath_result)){
$val = (string)$xpath_result[0]; $val = (string)$xpath_result[0];

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

@ -18,7 +18,7 @@
?> ?>
<div class ="roblib-search-content evergreen" id="roblib-search-content-evergreen"> <div class ="roblib-search-content evergreen" id="roblib-search-content-evergreen">
<img src="<?php print $spinner_path; ?>"/> <img src="<?php print (empty($spinner_path) ? ' ' : $spinner_path); ?>"/>
</div> </div>
<div class ="roblib-search-more" id="roblib-search-evergreen-more">Search all Results</div> <div class ="roblib-search-more" id="roblib-search-evergreen-more">Search all Results</div>
Loading…
Cancel
Save