diff --git a/ebsco/css/ebsco.css b/ebsco/css/ebsco.css index 4e867a1..b1176cb 100644 --- a/ebsco/css/ebsco.css +++ b/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"); * you may not use this file except in compliance with the License. @@ -397,7 +398,7 @@ /** Icons ***/ -.ebsco .icon { +.icon { background: url("../images/sprites_32.png") no-repeat top left; height: 32px; line-height: 32px; @@ -405,15 +406,15 @@ padding: 0 0 0 36px !important; } -.ebsco .icon.ebook { +.icon.ebook { background-position: 0 0; } -.ebsco .icon.html { +.icon.html { background-position: 0 -42px; } -.ebsco .icon.pdf { +.icon.pdf { background-position: 0 -84px; } @@ -443,3 +444,101 @@ .icon16.tick { 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; + } + + + /* */ \ No newline at end of file diff --git a/ebsco/ebsco.info b/ebsco/ebsco.info index 5dd95e0..e5799c3 100644 --- a/ebsco/ebsco.info +++ b/ebsco/ebsco.info @@ -1,5 +1,5 @@ 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 configure = admin/config/search/ebsco diff --git a/ebsco/ebsco.module b/ebsco/ebsco.module index ad2416a..0e6f907 100644 --- a/ebsco/ebsco.module +++ b/ebsco/ebsco.module @@ -1,8 +1,8 @@ array( 'title' => t('Administer EBSCO') ), + 'use ebsco' => array( + 'title' => t('Use EBSCO') + ) ); } @@ -121,15 +124,15 @@ function ebsco_admin() { $form['ebsco_credentials'] = array( '#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', - '#title' => t('Password'), - '#default_value' => variable_get('ebsco_password'), + '#title' => t('Profile Id'), + '#default_value' => variable_get('ebsco_profile'), '#size' => 50, - '#description' => t("The API password."), + '#description' => t("The API Profile Id."), '#required' => TRUE ); @@ -142,18 +145,19 @@ function ebsco_admin() { '#required' => TRUE ); - $form['ebsco_credentials']['ebsco_profile'] = array( + $form['ebsco_credentials']['ebsco_password'] = array( '#type' => 'textfield', - '#title' => t('Profile Id'), - '#default_value' => variable_get('ebsco_profile'), + '#title' => t('Password'), + '#default_value' => variable_get('ebsco_password'), '#size' => 50, - '#description' => t("The API Profile Id."), + '#description' => t("The API password."), '#required' => TRUE ); $form['ebsco_credentials']['ebsco_interface'] = array( '#type' => 'textfield', '#title' => t('Interface Id'), + '#default_value' => variable_get('ebsco_interface'), '#size' => 50, '#description' => t("The API Interface Id."), '#required' => FALSE @@ -162,11 +166,21 @@ function ebsco_admin() { $form['ebsco_credentials']['ebsco_organization'] = array( '#type' => 'textfield', '#title' => t('Organization Id'), + '#default_value' => variable_get('ebsco_organization'), '#size' => 50, '#description' => t("The API Organization Id."), '#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( '#type' => 'radios', '#title' => t('Guest ?'), @@ -202,7 +216,7 @@ function ebsco_admin() { $form['ebsco_general']['ebsco_default_amount'] = array( '#type' => 'select', '#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."), '#options' => EBSCODocument::amount_options(), '#required' => TRUE @@ -415,7 +429,7 @@ function ebsco_sort_form() { $options = EBSCODocument::amount_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( '#id' => 'ebsco-amount', '#type' => 'select', @@ -886,6 +900,8 @@ function template_preprocess_ebsco_results(&$variables) { $variables['record_count'] = $Document->record_count(); $variables['search_view'] = $Document->search_view(); $variables['search_time'] = $Document->search_time(); + $variables['relatedContent'] = $Document->relatedContent(); + $variables['autoSuggestTerms'] = $Document->autoSuggestTerms(); $variables['lookfor'] = ''; if (isset($params['lookfor'])) { $variables['lookfor'] = $params['lookfor']; @@ -904,7 +920,7 @@ function template_preprocess_ebsco_results(&$variables) { $variables['sort_form'] = drupal_render($v1); // Save data needed by scroller in Detailed view page - $Document->search_write(); + //$Document->search_write(); } @@ -1046,4 +1062,4 @@ function auto_link($string) $string ); return $linkedString; -} +} \ No newline at end of file diff --git a/ebsco/js/ebsco.js b/ebsco/js/ebsco.js index 5d9c7f2..1d5dada 100644 --- a/ebsco/js/ebsco.js +++ b/ebsco/js/ebsco.js @@ -1,7 +1,8 @@ /* * The EBSCO module javascript + * * - * Copyright [2014] [EBSCO Information Services] + * Copyright [2017] [EBSCO Information Services] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/ebsco/lib/EBSCOAPI.php b/ebsco/lib/EBSCOAPI.php index 44c6b4a..9ec33f4 100644 --- a/ebsco/lib/EBSCOAPI.php +++ b/ebsco/lib/EBSCOAPI.php @@ -4,9 +4,9 @@ * EBSCO EDS API class * * PHP version 5 + * * - * - * Copyright [2014] [EBSCO Information Services] + * Copyright [2017] [EBSCO Information Services] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,8 @@ * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and - * limitations under the License. + * limitations under the License. + * */ require_once 'EBSCOConnector.php'; @@ -56,7 +57,6 @@ class EBSCOAPI */ private $config; - /** * VuFind search types mapped to EBSCO search types * used for urls in search results / detailed result @@ -69,7 +69,9 @@ class EBSCOAPI 'Author' => 'AU', 'Source' => 'SO', 'Subject' => 'SU', - 'Title' => 'TI' + 'Title' => 'TI', + 'ISBN' => 'IB', + 'ISSN' => 'IS' ); @@ -326,7 +328,6 @@ class EBSCOAPI ); $response = $this->connector()->requestSessionToken($headers); - // Raise the exception so that any code running this method should exit immediately if ($this->isError($response)) { return $response; @@ -384,8 +385,7 @@ class EBSCOAPI * @access public */ 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(); // Basic search @@ -411,7 +411,8 @@ class EBSCOAPI } // Advanced search - } else if(!empty($search['group'])) { + } + else if(!empty($search['group'])) { $counter = 1; foreach ($search['group'] as $group) { @@ -480,7 +481,13 @@ class EBSCOAPI $groupId += 1; } } + + //2014-03-26 - new action to jump to page + if ($start>1) { + $query['action']="GoToPage(".$start.")"; + } + // Add the sort option $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 'includefacets' => 'y', 'resultsperpage' => $limit, - 'pagenumber' => $start, + + //2014-03-26 RF + 'pagenumber' => $start, + //'pagenumber' => 1, // Specifies whether or not to include highlighting in the search results '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); $result = $this->request('Search', $params); @@ -551,11 +580,12 @@ class EBSCOAPI if ($result = $this->readSession('info')) { return $result; } - $result = $this->request('Info'); + if(!$this->isError($result)) { $this->writeSession('info', $result); } + return $result; } diff --git a/ebsco/lib/EBSCOConnector.php b/ebsco/lib/EBSCOConnector.php index baa872b..a683181 100644 --- a/ebsco/lib/EBSCOConnector.php +++ b/ebsco/lib/EBSCOConnector.php @@ -3,8 +3,9 @@ /** * EBSCOException class * 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"); * you may not use this file except in compliance with the License. @@ -16,7 +17,7 @@ * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and - * limitations under the License. + * limitations under the License. */ class EBSCOException extends Exception { @@ -151,6 +152,12 @@ class EBSCOConnector */ private $isGuest; + /** + * Contains the list of ip addresses + * @global string + */ + private $local_ip_address; + /* * You can log HTTP_Request requests using this option @@ -175,6 +182,7 @@ class EBSCOConnector * * @access public */ + public function __construct($config) { $this->password = $config['password']; @@ -182,7 +190,8 @@ class EBSCOConnector $this->interfaceId = $config['interface']; $this->profileId = $config['profile']; $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); if ($this->logAPIRequests) { $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 * @@ -305,10 +338,12 @@ BODY; $url = self::$end_point . '/Info'; $response = $this->request($url, $params, $headers); + return $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( 'headers' => $headers, 'method' => $method, @@ -352,12 +394,26 @@ BODY; // Send the request try { $response = drupal_http_request($url, $options); +//print_r($url); //print_r($response); + $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: - $xml_str = $response->data; - try { + + $xml_str = $response->data; + + try { + // clean EMP namespace + $xml_str=str_replace(array("toString($client); // or $this->toString($response) + $this->logger->log($message, Zend_Log::ERR); $return = new EBSCOException($response); } diff --git a/ebsco/lib/EBSCODocument.php b/ebsco/lib/EBSCODocument.php index 7b4ebc5..7f04d83 100644 --- a/ebsco/lib/EBSCODocument.php +++ b/ebsco/lib/EBSCODocument.php @@ -9,9 +9,9 @@ * - displaying statistics about the search, etc * * PHP version 5 + * * - * - * Copyright [2014] [EBSCO Information Services] + * Copyright [2017] [EBSCO Information Services] * * Licensed under the Apache License, Version 2.0 (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, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and - * limitations under the License. + * limitations under the License.* */ require_once 'EBSCOAPI.php'; @@ -73,6 +73,14 @@ class EBSCODocument * #global array of EBSCORecord objects */ 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 @@ -85,6 +93,12 @@ class EBSCODocument * @global integer */ private $limit = 10; + + /** + * Default level of data detail + * @global string + */ + private $amount = 'brief'; /** * Maximum number of links displayed by the pagination @@ -166,9 +180,14 @@ class EBSCODocument 'AllFields' => 'All Text', 'Title' => 'Title', 'Author' => 'Author', - 'Subject' => 'Subject terms' + 'Subject' => 'Subject terms', + 'Source' => 'Journal Title/Source', + 'Abstract' => 'Abstract', + 'ISBN' => 'ISBN', + 'ISSN' => 'ISSN' ); + private $local_ips = ""; /** * Constructor. @@ -183,12 +202,14 @@ class EBSCODocument 'profile' => variable_get('ebsco_profile'), 'interface' => variable_get('ebsco_interface'), 'organization' => variable_get('ebsco_organization'), + 'local_ip_address' => variable_get('ebsco_local_ips'), 'guest' => variable_get('ebsco_guest'), 'log' => variable_get('ebsco_log') )); $this->params = $params ? $params : $_REQUEST; $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; } @@ -226,7 +247,7 @@ class EBSCODocument public function search() { $search = array(); - + if (isset($this->params['lookfor']) && isset($this->params['type'])) { $search = array( 'lookfor' => $this->params['lookfor'], @@ -242,15 +263,34 @@ class EBSCODocument $page = isset($this->params['page']) ? $this->params['page'] + 1 : 1; $limit = $this->limit; $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'; - $this->results = $this->eds->apiSearch($search, $filter, $page, $limit, $sort, $amount, $mode); - - if (isset($this->results['start'])) { - $this->results['start'] = $limit * ($page - 1); - } - + + //check if research starters , EMP are active + $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; } @@ -277,6 +317,12 @@ class EBSCODocument */ public function records() { + if ($this->record instanceof EBSCOException ) { + return null; + } + if ($this->results instanceof EBSCOException ) { + return null; + } if (empty($this->records) && !(empty($this->results))) { foreach($this->results['documents'] as $result) { $this->records[] = new EBSCORecord($result); @@ -285,6 +331,26 @@ class EBSCODocument return $this->records; } + + + 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; + } /** @@ -295,11 +361,19 @@ class EBSCODocument public function pager() { $pager = null; - if ($this->has_records()) { - pager_default_initialize($this->record_count() / $this->limit, 1); - $pager = theme('pager', array('tags' => null, 'quantity' => self::$page_links)); - $pager = preg_replace('/
  • (.*)<\/li>/', '', $pager); - } + try + { + if ($this->has_records()) { + pager_default_initialize($this->record_count() / $this->limit, 1); + $pager = theme('pager', array('tags' => null, 'quantity' => self::$page_links)); + $pager = preg_replace('/
  • (.*)<\/li>/', '', $pager); + } + + } + catch(Exception $e) + { + + } return $pager; } @@ -395,18 +469,31 @@ class EBSCODocument */ public function expanders() { - $actions = array(); - $filters = $this->filters(); - 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; - } - } + $expanders=array(); + try + { + if ($this->info instanceof EBSCOException) + { + return $expanders; + } + $actions = array(); + $filters = $this->filters(); + 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; } @@ -419,6 +506,10 @@ class EBSCODocument */ public function facets() { + if ($this->results instanceof EBSCOException ) { + return array(); + } + $actions = array(); foreach($this->filters as $filter) { $actions[] = $filter['action']; @@ -494,6 +585,10 @@ class EBSCODocument public function limiters() { $actions = array(); $ids = array(); + if ($this->info instanceof EBSCOException) + { + return array(); + } $filters = $this->filters(); foreach($filters as $filter) { $actions[] = $filter['action']; @@ -536,6 +631,9 @@ class EBSCODocument */ public function record_count() { + if ($this->results instanceof EBSCOException ) { + return 0; + } return !empty($this->results) ? $this->results['recordCount'] : 0; } @@ -547,6 +645,9 @@ class EBSCODocument */ public function record_end() { + if ($this->results instanceof EBSCOException ) { + return -1; + } $count = !empty($this->results) ? count($this->results['documents']) : 0; $start = !empty($this->results) ? $this->results['start'] : 0; return $start + $count; @@ -560,6 +661,9 @@ class EBSCODocument */ public function record_start() { + if ($this->results instanceof EBSCOException ) { + return null; + } return !empty($this->results) ? $this->results['start'] + 1 : 0; } @@ -571,6 +675,9 @@ class EBSCODocument */ public function search_time() { + if ($this->results instanceof EBSCOException ) { + return 0; + } return !empty($this->results) && isset($this->results['searchTime']) ? $this->results['searchTime'] : 0; } @@ -644,6 +751,9 @@ class EBSCODocument */ public function has_records() { + if ($this->results instanceof EBSCOException ) { + return false; + } return !empty($this->results) && !empty($this->results['documents']); } @@ -655,6 +765,9 @@ class EBSCODocument */ public function search_create($query = null) { + if ($this->results instanceof EBSCOException ) { + return array(); + } $last_search = array(); if (!empty($this->results)) { $results_identifiers = array(); diff --git a/ebsco/lib/EBSCORecord.php b/ebsco/lib/EBSCORecord.php index 7ff11df..e9cfea4 100644 --- a/ebsco/lib/EBSCORecord.php +++ b/ebsco/lib/EBSCORecord.php @@ -4,7 +4,9 @@ * * PHP version 5 * - * Copyright [2014] [EBSCO Information Services] + * + * + * Copyright [2017] [EBSCO Information Services] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/ebsco/lib/EBSCOResponse.php b/ebsco/lib/EBSCOResponse.php index 3c44ff1..4775682 100644 --- a/ebsco/lib/EBSCOResponse.php +++ b/ebsco/lib/EBSCOResponse.php @@ -7,7 +7,7 @@ * PHP version 5 * * - * Copyright [2014] [EBSCO Information Services] + * Copyright [2017] [EBSCO Information Services] * * Licensed under the Apache License, Version 2.0 (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)) { return $this->buildAuthenticationToken(); - } else if (!empty($this->response->SessionToken)) { + } + else if (!empty($this->response->SessionToken)) { return (string) $this->response->SessionToken; - } else if (!empty($this->response->SearchResult)) { + } + else if (!empty($this->response->SearchResult)) { return $this->buildSearch(); - } else if(!empty($this->response->Record)) { + } + else if(!empty($this->response->Record)) { return $this->buildRetrieve(); - } else if(!empty($this->response->AvailableSearchCriteria)) { + } + else if(!empty($this->response->AvailableSearchCriteria)) { return $this->buildInfo(); - } else { // Should not happen, it may be an exception + } + else { // Should not happen, it may be an exception return $this->response; } } @@ -119,13 +124,29 @@ class EBSCOResponse $records = $this->buildRecords(); $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( 'recordCount' => $hits, 'searchTime' => $searchTime, 'numFound' => $hits, 'start' => 0, 'documents' => $records, + 'relatedContent' => $relatedC, + 'autoSuggestTerms' => $autoSuggestTerms, 'facets' => $facets ); @@ -149,7 +170,8 @@ class EBSCOResponse $records = $this->response->SearchResult->Data->Records->Record; foreach ($records as $record) { $result = array(); - + //var_dump($record); + $result['ResultId'] = $record->ResultId ? (integer) $record->ResultId : ''; $result['DbId'] = $record->Header->DbId ? (string) $record->Header->DbId : ''; $result['DbLabel'] = $record->Header->DbLabel ? (string) $record->Header->DbLabel : ''; @@ -225,9 +247,11 @@ class EBSCOResponse } } + $results[] = $result; } + return $results; } @@ -246,30 +270,32 @@ class EBSCOResponse $results = array(); $facets = $this->response->SearchResult->AvailableFacets->AvailableFacet; - foreach ($facets as $facet) { - $values = array(); - foreach ($facet->AvailableFacetValues->AvailableFacetValue as $value) { - $this_value = (string) $value->Value; - $this_value = str_replace(array('\(','\)'), array('(', ')'), $this_value); - $this_action = (string) $value->AddAction; - $this_action = str_replace(array('\(','\)'), array('(', ')'), $this_action); - $values[] = array( - 'Value' => $this_value, - 'Action' => $this_action, - 'Count' => (string) $value->Count - ); - } - $id = (string) $facet->Id; - $label = (string) $facet->Label; - if (!empty($label)) { - $results[] = array( - 'Id' => $id, - 'Label' => $label, - 'Values' => $values, - 'isApplied' => false - ); - } - } + if ($facets) { + foreach ($facets as $facet) { + $values = array(); + foreach ($facet->AvailableFacetValues->AvailableFacetValue as $value) { + $this_value = (string) $value->Value; + $this_value = str_replace(array('\(','\)'), array('(', ')'), $this_value); + $this_action = (string) $value->AddAction; + $this_action = str_replace(array('\(','\)'), array('(', ')'), $this_action); + $values[] = array( + 'Value' => $this_value, + 'Action' => $this_action, + 'Count' => (string) $value->Count + ); + } + $id = (string) $facet->Id; + $label = (string) $facet->Label; + if (!empty($label)) { + $results[] = array( + 'Id' => $id, + 'Label' => $label, + 'Values' => $values, + 'isApplied' => false + ); + } + } + } 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 $elements = $this->response->AvailableSearchCriteria->AvailableLimiters->AvailableLimiter; $limiters = array(); @@ -348,7 +397,9 @@ class EBSCOResponse 'sort' => $sort, 'tags' => $tags, 'expanders' => $expanders, - 'limiters' => $limiters + 'limiters' => $limiters, + 'relatedContent' => $relatedContent, + 'didYouMean' => $didYouMean ); return $result; @@ -385,9 +436,12 @@ class EBSCOResponse $target = (string) $image->Target; $result['ImageInfo'][$size] = $target; } - } else { + } + else + { $result['ImageInfo'] = ''; } + if ($record->FullText) { $availability = (integer) ($record->FullText->Text->Availability) == 1; $links = array(); diff --git a/ebsco/templates/ebsco-advanced-search.tpl.php b/ebsco/templates/ebsco-advanced-search.tpl.php index 41ab309..0f656ed 100644 --- a/ebsco/templates/ebsco-advanced-search.tpl.php +++ b/ebsco/templates/ebsco-advanced-search.tpl.php @@ -5,8 +5,9 @@ * Displays the advanced search form. * * @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"); * you may not use this file except in compliance with the License. @@ -18,7 +19,7 @@ * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and - * limitations under the License. + * limitations under the License. */ ?> @@ -46,6 +47,11 @@ + + + + +
  • '; + $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.='
    '; + } + + // replated publications + if (isset($item["RelatedPublication"])) { + //var_dump($item); + $tabs.='
  • '; + $counter++; + + $tabsContent.='
    '; + break; + } + } + } + + if ($tabsContent<>"") { + echo ' + + - - ' . t('Login') . ''; ?> -

    - -

    - + + '; + + } + + ?>
      - - record_id()); $recordUrl = url('ebsco/result', array('query' => array('id' => $id))); $fulltextUrl = url('ebsco/fulltext', array('query' => array('id' => $id))); $pdfUrl = url('ebsco/pdf', array('query' => array('id' => $id))); + ?>
    1. @@ -59,87 +242,92 @@
      - small_thumb_link): ?> - - <?php print t('Book jacket'); ?> - - + small_thumb_link){ + echo' + + '.t('Book jacket').' + '; + } + ?>
      - access_level == '1'): ?> -

      - ' . check_plain($record->db_label) . ''; - $link = '' . t('Login') . ''; - ?> - -
      - -

      - title): ?> - - title; ?> - - + access_level == '1'){ + echo '

      '; + $label = '' . check_plain($record->db_label) . ''; + $link = '' . t('Login') . ''; + echo sprintf(t('This result from %s cannot be displayed to guests.'), $label)."
      ".sprintf(t('%s for full access.'), $link).""; + echo "

      "; + } + elseif ($record->title){ + echo ''.$record->title.''; + } + ?>
      - authors)): ?> -

      - - authors; ?> -

      - - - source)): ?> -

      - - source; ?> -

      - + authors)){ + echo "".t('by'). " ".str_replace(array("
      ","
      "), ', ', $record->authors)."
      "; + } + + if (!empty($record->source)){ + echo '

      '.t('Published in')." ".$record->source.'

      '; + } + + ?>
      - summary)): ?> - summary; ?> -
      - - - subjects)): ?> - : - ', ', ', $record->subjects); ?> - + summary)){ + echo ''.$record->summary.'
      '; + } + + if (!empty($record->subjects)){ + echo ''.t('Subjects').':'.str_replace('
      ', ', ', $record->subjects).'
      '; + } + + ?>
      - custom_links)): ?> + custom_links)){ + ?>
      - +
      - full_text_availability): ?> - - - -     - - - pdf_availability): ?> - - - - + full_text_availability){ + echo ''; + echo t('HTML full text'); + echo "   "; + } + + if ($record->pdf_availability){ + echo ' '; + echo t('PDF full text'); + echo ""; + } + ?> +
      @@ -149,9 +337,22 @@
    - -

    - - +".t('Your search did not match any resources.').""; + // check for autocomplete + +/* + if (isset ($autoSuggestTerms) ) { + if (count($autoSuggestTerms)>0) { + echo "Did you mean "."?
    "; + var_dump($autoSuggestTerms); + } + } +*/ + echo search_help('search#noresults', drupal_help_arg()); + } +?>
    \ No newline at end of file diff --git a/ebsco/templates/ebsco-side-facets.tpl.php b/ebsco/templates/ebsco-side-facets.tpl.php index bd2b40a..f55156e 100644 --- a/ebsco/templates/ebsco-side-facets.tpl.php +++ b/ebsco/templates/ebsco-side-facets.tpl.php @@ -6,7 +6,8 @@ * * @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"); * you may not use this file except in compliance with the License.