diff --git a/ebsco/css/ebsco.css b/ebsco/css/ebsco.css index 500f88b..2a407e8 100644 --- a/ebsco/css/ebsco.css +++ b/ebsco/css/ebsco.css @@ -1,6 +1,6 @@ -/* -* The styles for EBSCO module - * +/** + * @file + * The EBSCO module styles. * * Copyright [2017] [EBSCO Information Services] * @@ -15,7 +15,7 @@ * 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. -*/ + */ @CHARSET "UTF-8"; /** General ***/ diff --git a/ebsco/ebsco.module b/ebsco/ebsco.module index 0fe3dfa..f3b0abb 100644 --- a/ebsco/ebsco.module +++ b/ebsco/ebsco.module @@ -1,26 +1,28 @@ ' . t("Full-text articles and eBooks from EBSCOhost Discovery Services") . ''; - $output .= '

' . t("EBSCO Discovery Service provides users with an easy, yet powerful means of accessing all of - an institution's information resources through a single search.") . '

'; - $output .= '

' . t("This is achieved by harvesting metadata from both internal (library) and external (database vendors) sources, - and creating a pre-indexed service of unprecedented size and speed.") . '

'; - $output .= '

' . t("Although the resulting collection can be massive in size and scope, the fact that it is indexed locally - (on the EBSCOhost® servers) allows for exceptionally fast search response times.") . '

'; - $output .= '

' . t("As no two institutions are the same, EBSCO Discovery Service offers a vast array of customization options with - regard to both the underlying collection of metadata as well as the front-end delivery of search results. - All of this functionality is based upon the powerful EBSCOhost search experience familiar to researchers worldwide.") . '

'; + $output .= '

' . t("EBSCO Discovery Service provides users with an easy, yet powerful means of accessing all of an institution's information resources through a single search.") . '

'; + $output .= '

' . t("This is achieved by harvesting metadata from both internal (library) and external (database vendors) sources, and creating a pre-indexed service of unprecedented size and speed.") . '

'; + $output .= '

' . t("Although the resulting collection can be massive in size and scope, the fact that it is indexed locally (on the EBSCOhost® servers) allows for exceptionally fast search response times.") . '

'; + $output .= '

' . t("As no two institutions are the same, EBSCO Discovery Service offers a vast array of customization options with regard to both the underlying collection of metadata as well as the front-end delivery of search results. All of this functionality is based upon the powerful EBSCOhost search experience familiar to researchers worldwide.") . '

'; break; } return $output; @@ -305,36 +295,32 @@ function ebsco_block_info() { */ function ebsco_block_view($delta = '') { $params = $_GET; + $block = array(); switch ($delta) { case 'ebsco_main': $reject = isset($params['q']) && strpos('ebsco/advanced', $params['q']) !== FALSE; - return array( - 'content' => $reject ? '' : ebsco_basic_search_block(), - ); - - break; + $block['content'] = $reject ? '' : ebsco_basic_search_block(); + break; case 'ebsco_facets': $reject = isset($params['q']) && strpos('ebsco/advanced', $params['q']) !== FALSE; $reject = $reject || (isset($params['edit']) && strpos('ebsco/results', $params['q']) !== FALSE); $reject = $reject || (isset($params['q']) && strpos('ebsco/result', $params['q']) !== FALSE); - return array( - 'content' => $reject ? '' : ebsco_side_facets_block(), - ); - - break; + $block['content'] = $reject ? '' : ebsco_side_facets_block(); + break; } + return $block; } /** - * Page callbacks. + * EBSCO search results page callback. */ function ebsco_results_page() { return theme('ebsco_results'); } /** - * + * EBSCO search result page callback. */ function ebsco_result_page() { $is_xhr = !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'; @@ -348,7 +334,7 @@ function ebsco_result_page() { } /** - * + * EBSCO fulltext page callback. */ function ebsco_fulltext_page() { $is_xhr = !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'; @@ -374,18 +360,18 @@ function ebsco_fulltext_page() { } /** - * + * EBSCO pdf page callback. */ function ebsco_pdf_page() { - global $Document; + global $_ebsco_document; $params = $_REQUEST; if (user_is_logged_in()) { - if (empty($Document)) { - $Document = new EBSCODocument(); + if (empty($_ebsco_document)) { + $_ebsco_document = new EBSCODocument(); } - $Document->retrieve(); - $record = $Document->record(); + $_ebsco_document->retrieve(); + $record = $_ebsco_document->record(); drupal_goto($record->pdf_link); } else { @@ -395,21 +381,21 @@ function ebsco_pdf_page() { } /** - * + * EBSCO advanced search page callback. */ function ebsco_advanced_search_page() { return theme('ebsco_advanced_search'); } /** - * + * EBSCO basic search page callback. */ function ebsco_basic_search_block() { return theme('ebsco_basic_search'); } /** - * + * EBSCO side facets block callback. */ function ebsco_side_facets_block() { return theme('ebsco_side_facets'); @@ -540,7 +526,7 @@ function ebsco_basic_search_form() { * @ingroup forms */ function ebsco_advanced_search_form() { - global $Document; + global $_ebsco_document; $params = $_REQUEST; if (isset($params['edit']) && !empty($params['edit'])) { @@ -653,8 +639,8 @@ function ebsco_advanced_search_form() { '#options' => EBSCODocument::mode_options(), ); - $expanders = $Document->expanders(); - $limiters = $Document->limiters(); + $expanders = $_ebsco_document->expanders(); + $limiters = $_ebsco_document->limiters(); $options = array('' => TRUE); foreach ($expanders as $key => $expander) { $options[$expander['Action']] = TRUE; @@ -715,7 +701,9 @@ function ebsco_advanced_search_form() { '#title' => $limiter['Label'], '#title_display' => 'after', '#name' => 'filter[]', - '#attributes' => array('value' => str_replace('value', 'y', $limiter['Action'])), + '#attributes' => array( + 'value' => str_replace('value', 'y', $limiter['Action']), + ), '#checked' => $limiter['selected'], ); @@ -757,7 +745,11 @@ function ebsco_advanced_search_form() { '#value' => $displayValue, '#name' => $limiter['Id'], '#autocomplete_path' => NULL, - '#attributes' => array('size' => 4, 'maxlength' => 4, 'class' => array('yearbox')), + '#attributes' => array( + 'size' => 4, + 'maxlength' => 4, + 'class' => array('yearbox'), + ), ); $element['#children'] = theme('textfield', array('element' => $element)); $element['#children'] .= ''; @@ -793,8 +785,9 @@ function ebsco_advanced_search_form() { '#value' => t('Search'), ); + $reset_button_text = t('Clear'); $form['advanced']['clear'] = array( - '#markup' => '', + '#markup' => '', ); return $form; @@ -889,27 +882,27 @@ function ebsco_advanced_search_form_submit($form, &$form_state) { * @see ebsco-results.tpl.php */ function template_preprocess_ebsco_results(&$variables) { - global $Document; + global $_ebsco_document; $params = $_REQUEST; $_SESSION['EBSCO']['redirect'] = drupal_get_destination(); - if (empty($Document)) { - $Document = new EBSCODocument(); + if (empty($_ebsco_document)) { + $_ebsco_document = new EBSCODocument(); } $title = !empty($params['lookfor']) ? ' - ' . $params['lookfor'] : ''; drupal_set_title('Search results' . $title); - $Document->search(); + $_ebsco_document->search(); - $variables['records'] = $Document->records(); - $variables['record_start'] = $Document->record_start(); - $variables['record_end'] = $Document->record_end(); - $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['records'] = $_ebsco_document->records(); + $variables['record_start'] = $_ebsco_document->record_start(); + $variables['record_end'] = $_ebsco_document->record_end(); + $variables['record_count'] = $_ebsco_document->record_count(); + $variables['search_view'] = $_ebsco_document->search_view(); + $variables['search_time'] = $_ebsco_document->search_time(); + $variables['relatedContent'] = $_ebsco_document->relatedContent(); + $variables['autoSuggestTerms'] = $_ebsco_document->autoSuggestTerms(); $variables['lookfor'] = ''; if (isset($params['lookfor'])) { $variables['lookfor'] = $params['lookfor']; @@ -923,13 +916,13 @@ function template_preprocess_ebsco_results(&$variables) { } } } - $variables['pager'] = $Document->pager(); + $variables['pager'] = $_ebsco_document->pager(); $v1 = drupal_get_form('ebsco_sort_form'); $variables['sort_form'] = drupal_render($v1); // Save data needed by scroller in Detailed view page - // $Document->search_write(); + // $_ebsco_document->search_write(); } /** @@ -938,14 +931,14 @@ function template_preprocess_ebsco_results(&$variables) { * @see ebsco-basic-search.tpl.php */ function template_preprocess_ebsco_basic_search(&$variables) { - global $Document; + global $_ebsco_document; $params = $_REQUEST; - if (empty($Document)) { - $Document = new EBSCODocument(); + if (empty($_ebsco_document)) { + $_ebsco_document = new EBSCODocument(); } - $variables['search_view'] = $Document->search_view(); + $variables['search_view'] = $_ebsco_document->search_view(); $variables['lookfor'] = ''; if (isset($params['lookfor'])) { $variables['lookfor'] = $params['lookfor']; @@ -970,13 +963,13 @@ function template_preprocess_ebsco_basic_search(&$variables) { */ function template_preprocess_ebsco_advanced_search(&$variables) { drupal_add_library('system', 'ui.slider'); - global $Document; + global $_ebsco_document; $params = $_REQUEST; - if (empty($Document)) { - $Document = new EBSCODocument(); + if (empty($_ebsco_document)) { + $_ebsco_document = new EBSCODocument(); } - $Document->info(); + $_ebsco_document->info(); $v1 = drupal_get_form('ebsco_advanced_search_form'); $variables['search_form'] = drupal_render($v1); @@ -992,14 +985,14 @@ function template_preprocess_ebsco_result(&$variables) { $params['op'] = isset($params['op']) ? $params['op'] : 'Next'; $_SESSION['EBSCO']['redirect'] = drupal_get_destination(); - if (empty($Document)) { - $Document = new EBSCODocument(); + if (empty($_ebsco_document)) { + $_ebsco_document = new EBSCODocument(); } - $Document->retrieve(); - $record = $Document->record(); + $_ebsco_document->retrieve(); + $record = $_ebsco_document->record(); $variables['record'] = $record; - $lastSearch = isset($params['id']) ? $Document->search_read($params['id'], $params['op']) : ''; + $lastSearch = isset($params['id']) ? $_ebsco_document->search_read($params['id'], $params['op']) : ''; $variables['last_search'] = $lastSearch; drupal_set_title($record->title); @@ -1011,23 +1004,23 @@ function template_preprocess_ebsco_result(&$variables) { * @see ebsco-side-facets.tpl.php */ function template_preprocess_ebsco_side_facets(&$variables) { - global $Document; + global $_ebsco_document; - if (empty($Document)) { - $Document = new EBSCODocument(); + if (empty($_ebsco_document)) { + $_ebsco_document = new EBSCODocument(); } - $Document->info(); + $_ebsco_document->info(); - $variables['record_count'] = $Document->record_count(); - $variables['expanders'] = $Document->expanders(); - $variables['limiters'] = $Document->limiters(); - $variables['facets'] = $Document->facets(); + $variables['record_count'] = $_ebsco_document->record_count(); + $variables['expanders'] = $_ebsco_document->expanders(); + $variables['limiters'] = $_ebsco_document->limiters(); + $variables['facets'] = $_ebsco_document->facets(); // Applied facets, limiters or expanders. - $variables['filters'] = $Document->filters(); + $variables['filters'] = $_ebsco_document->filters(); // Hidden parameters. - $variables['search_params'] = $Document->search_params(); + $variables['search_params'] = $_ebsco_document->search_params(); // Hidden parameters. - $variables['link_search_params'] = $Document->link_search_params(); + $variables['link_search_params'] = $_ebsco_document->link_search_params(); } /****************************************** @@ -1035,9 +1028,10 @@ function template_preprocess_ebsco_side_facets(&$variables) { ******************************************/ /** - * Returns an URL without the given filter parameter. + * Returns the current request's URL without the specified filter parameter. * * @return string + * the filtered request URL */ function remove_filter_link($filter) { $params = $_REQUEST; @@ -1052,18 +1046,22 @@ function remove_filter_link($filter) { } /** - * Performs a regex and replaces any url's with links containing themselves as the text. + * Convert URLs in the given string into HTML link tags. + * + * Performs a regex and replaces any URLs with links containing themselves + * as the text. * * @return string + * the filtered request URL */ function auto_link($string) { $linkedString = preg_replace_callback( - "/\b(https?):\/\/([-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|]*)\b/i", - create_function( - '$matches', - 'return "".($matches[0])."";' - ), - $string - ); + "/\b(https?):\/\/([-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|]*)\b/i", + create_function( + '$matches', + 'return "".($matches[0])."";' + ), + $string + ); return $linkedString; } diff --git a/ebsco/js/ebsco.js b/ebsco/js/ebsco.js index 1d5dada..083466d 100644 --- a/ebsco/js/ebsco.js +++ b/ebsco/js/ebsco.js @@ -1,6 +1,6 @@ -/* - * The EBSCO module javascript - * +/** + * @file + * The EBSCO module javascript. * * Copyright [2017] [EBSCO Information Services] * @@ -9,17 +9,16 @@ * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * 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. - **/ + */ (function ($) { $(document).ready(function () { - // var updatePublishDateSlider = function () { var from = parseInt($('#DT1').val()); var min = 1000; @@ -38,10 +37,9 @@ }); }; - - /* + /** * Self executing function - **/ + */ var onLoad = function () { // EBSCO/Search : Expand limiters $('._more_limiters').live('click', function (event) { @@ -165,7 +163,7 @@ // Retain search filters checkbox functionality $('#edit-remember').live('click', function (event) { $("#ebsco-basic-search-form :input[type='checkbox'][name^='filter[']").attr('checked', $(this).attr('checked')); - }); + }); // Advanced Search : handle 'Date Published from' limiter // Create the UI slider (if slider function is defined) diff --git a/ebsco/lib/EBSCOAPI.php b/ebsco/lib/EBSCOAPI.php index 6bda9a6..bfe7328 100644 --- a/ebsco/lib/EBSCOAPI.php +++ b/ebsco/lib/EBSCOAPI.php @@ -1,7 +1,8 @@ record_id()); - $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))); ?> -
-

title; ?>

- -
- -
- array('id' => $last_search['previous'], 'op' => 'Previous'))) . '" class="_record_link">« ' . t('Previous') . ''; - } - echo "#"; - print $last_search['current_index']; ?> of array('id' => $last_search['next'], 'op' => 'Next'))) . '" class="_record_link">' . t('Next') . ' »'; - - } - ?> -
- -
- +
+

title; ?>

+ +
+ +
+ array('id' => $last_search['previous'], 'op' => 'Previous'))) . '" class="_record_link">« ' . t('Previous') . ''; + } + echo "#"; + print $last_search['current_index']; ?> of array('id' => $last_search['next'], 'op' => 'Next'))) . '" class="_record_link">' . t('Next') . ' »'; + + } + ?>
- -
- -
- -
- - items as $item){ - if (!empty($item['Data'])){ - echo ' - - - - '; - } - } - - if ($record->db_label){ - echo ' - - - '; - } - - if ($record->full_text){ - echo ' - - - '; - } - elseif ($record->access_level && !user_is_logged_in()){ - echo ' - - - - '; - } - ?> -
' . t($item['Label']) . ':' . auto_link($item['Data']) . '
' . t('Database') . ':' . check_plain($record->db_label) . '
' . $record->full_text . '
-

' . t('The full text cannot be displayed to guests.') . '
.'; - $link = '' . t('Login') . ''; - echo '' . sprintf(t('%s for full access.'), $link) . ' -

-
-
- -
- medium_thumb_link){ - echo '' . t('Book jacket') . ''; - } - - if ($record->publication_type){ - echo '

' . check_plain($record->publication_type) . '

'; - } - ?> + -
- -
+ +
+ +
+ +
+ +
+ + items as $item){ + if (!empty($item['Data'])){ + echo ' + + + + '; + } + } + + if ($record->db_label){ + echo ' + + + '; + } + + if ($record->full_text){ + echo ' + + + '; + } + elseif ($record->access_level && !user_is_logged_in()){ + echo ' + + + + '; + } + ?> +
' . t($item['Label']) . ':' . auto_link($item['Data']) . '
' . t('Database') . ':' . check_plain($record->db_label) . '
' . $record->full_text . '
+

' . t('The full text cannot be displayed to guests.') . '
.'; + $link = '' . t('Login') . ''; + echo '' . sprintf(t('%s for full access.'), $link) . ' +

+
+
+ +
+ medium_thumb_link){ + echo '' . t('Book jacket') . ''; + } + + if ($record->publication_type){ + echo '

' . check_plain($record->publication_type) . '

'; + } + ?> +
+ +
+ +