Browse Source

Merge pull request #6 from BluesparkLabs/drupal7-coding-standards

Drupal7 coding standards
roblib
Rui Francisco 8 years ago committed by GitHub
parent
commit
dac99c4004
  1. 513
      ebsco/css/ebsco.css
  2. 1640
      ebsco/ebsco.module
  3. 14
      ebsco/js/ebsco.js
  4. 1247
      ebsco/lib/EBSCOAPI.php
  5. 931
      ebsco/lib/EBSCOConnector.php
  6. 1663
      ebsco/lib/EBSCODocument.php
  7. 728
      ebsco/lib/EBSCORecord.php
  8. 1091
      ebsco/lib/EBSCOResponse.php
  9. 800
      ebsco/lib/sanitizer.class.php
  10. 3
      ebsco/templates/ebsco-advanced-search.tpl.php
  11. 24
      ebsco/templates/ebsco-basic-search.tpl.php
  12. 256
      ebsco/templates/ebsco-result.tpl.php
  13. 643
      ebsco/templates/ebsco-results.tpl.php
  14. 2
      ebsco/templates/ebsco-side-facets.tpl.php

513
ebsco/css/ebsco.css

@ -1,6 +1,6 @@
/* /**
* The styles for EBSCO module * @file
* * The EBSCO module styles.
* *
* Copyright [2017] [EBSCO Information Services] * Copyright [2017] [EBSCO Information Services]
* *
@ -15,98 +15,98 @@
* 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.
*/ */
@CHARSET "UTF-8"; @CHARSET "UTF-8";
/** General ***/ /** General ***/
.floatleft { .floatleft {
float: left; float: left;
} }
.floatright { .floatright {
float: right; float: right;
} }
.clear { .clear {
clear: both; clear: both;
} }
.offscreen { .offscreen {
display: none; display: none;
} }
.spinner { .spinner {
width: 16px; width: 16px;
height: 16px; height: 16px;
background: url("../images/ajax_loading.gif") no-repeat left top; background: url("../images/ajax_loading.gif") no-repeat left top;
display: none; display: none;
} }
.highlight { .highlight {
font-weight: bold; font-weight: bold;
} }
/** Search list ***/ /** Search list ***/
.ebsco .result { .ebsco .result {
width: 650px; width: 650px;
} }
.ebsco .record-number { .ebsco .record-number {
margin-right: 10px; margin-right: 10px;
min-width: 10px; min-width: 10px;
} }
.ebsco .span-2 { .ebsco .span-2 {
width: auto; width: auto;
max-width: 70px; max-width: 70px;
margin-right: 10px; margin-right: 10px;
float: left; float: left;
} }
.ebsco .span-9 { .ebsco .span-9 {
float: none; float: none;
overflow: auto; overflow: auto;
width: auto; width: auto;
margin-right: 0; margin-right: 0;
} }
.ebsco .pagination { .ebsco .pagination {
margin-bottom: 0; margin-bottom: 0;
padding: 0.2em padding: 0.2em
} }
.ebsco p.submit { .ebsco p.submit {
padding: 10px 0; padding: 10px 0;
} }
.ebsco .jumpMenu { .ebsco .jumpMenu {
max-width: 130px; max-width: 130px;
} }
.ebsco ul.custom-links { .ebsco ul.custom-links {
list-style-type: none; list-style-type: none;
margin: 0; margin: 0;
padding: 0; padding: 0;
} }
.ebsco ul.custom-links li { .ebsco ul.custom-links li {
display: inline-block; display: inline-block;
padding-left: 0; padding-left: 0;
padding-right: 10px; padding-right: 10px;
margin-left: 10px; margin-left: 10px;
border-right: 1px solid #CCCCCC; border-right: 1px solid #cccccc;
} }
.ebsco ul.custom-links li:first-child { .ebsco ul.custom-links li:first-child {
margin-left: 0; margin-left: 0;
} }
.ebsco ul.custom-links li:last-child { .ebsco ul.custom-links li:last-child {
padding-right: 0; padding-right: 0;
border-right: 0 none; border-right: 0 none;
} }
@ -114,63 +114,63 @@
/** Side facets **/ /** Side facets **/
#block-ebsco-ebsco-facets h2 { #block-ebsco-ebsco-facets h2 {
font-weight: bold; font-weight: bold;
} }
#block-ebsco-ebsco-facets { #block-ebsco-ebsco-facets {
padding: 5px !important; padding: 5px !important;
} }
#block-ebsco-ebsco-facets dl { #block-ebsco-ebsco-facets dl {
margin: 5px 0; margin: 5px 0;
padding: 0; padding: 0;
} }
#block-ebsco-ebsco-facets dl dt { #block-ebsco-ebsco-facets dl dt {
font-size: 115%; font-size: 115%;
padding: 5px; padding: 5px;
background-color: #eeeeee; background-color: #eeeeee;
} }
#block-ebsco-ebsco-facets dd { #block-ebsco-ebsco-facets dd {
font-weight: normal !important; font-weight: normal !important;
margin: 0; margin: 0;
padding: 5px !important; padding: 5px !important;
border-bottom: 1px solid #dddddd; border-bottom: 1px solid #dddddd;
} }
#block-ebsco-ebsco-facets dd.submit input { #block-ebsco-ebsco-facets dd.submit input {
margin: 0; margin: 0;
} }
#block-ebsco-ebsco-facets dl dd:last-child { #block-ebsco-ebsco-facets dl dd:last-child {
border-bottom: none; border-bottom: none;
} }
#block-ebsco-ebsco-facets dd label { #block-ebsco-ebsco-facets dd label {
font-weight: normal; font-weight: normal;
font-family: Arial; font-family: Arial;
padding: 0 3px; padding: 0 3px;
} }
#block-ebsco-ebsco-facets dd label { #block-ebsco-ebsco-facets dd label {
display: inline; display: inline;
} }
#block-ebsco-ebsco-facets dl.expandable:hover { #block-ebsco-ebsco-facets dl.expandable:hover {
cursor: pointer; cursor: pointer;
} }
#block-ebsco-ebsco-facets dl.expandable:hover dt span { #block-ebsco-ebsco-facets dl.expandable:hover dt span {
color: #444444; color: #444444;
} }
#block-ebsco-ebsco-facets .narrow-list.filters { #block-ebsco-ebsco-facets .narrow-list.filters {
background-color: orange; background-color: orange;
} }
#block-ebsco-ebsco-facets .narrow-list.filters a { #block-ebsco-ebsco-facets .narrow-list.filters a {
color: white; color: white;
} }
@ -178,85 +178,85 @@
/** Detailed view ***/ /** Detailed view ***/
.ebsco-record .toolbar { .ebsco-record .toolbar {
border-bottom: 1px solid #EEEEEE; border-bottom: 1px solid #eeeeee;
margin-bottom: 1em; margin-bottom: 1em;
min-height: 2em; min-height: 2em;
padding-left: 1em; padding-left: 1em;
} }
.ebsco-record.push-5 { .ebsco-record.push-5 {
margin: 0; margin: 0;
} }
.ebsco-record .span-13 { .ebsco-record .span-13 {
min-width: 540px; min-width: 540px;
max-width: 690px; max-width: 690px;
width: auto; width: auto;
float: left; float: left;
} }
.ebsco-record .span-13 table { .ebsco-record .span-13 table {
margin-top: 0; margin-top: 0;
} }
.ebsco-record .span-13 table tr td { .ebsco-record .span-13 table tr td {
word-break: break-all; word-break: break-all;
} }
.ebsco-record .span-4 { .ebsco-record .span-4 {
max-width: 150px; max-width: 150px;
min-width: 80px; min-width: 80px;
width: auto; width: auto;
margin: 0 0 0 10px; margin: 0 0 0 10px;
text-align: center; text-align: center;
float: left; float: left;
} }
.ebsco-record .external-links { .ebsco-record .external-links {
border: 1px solid #eeeeee; border: 1px solid #eeeeee;
list-style-type: none; list-style-type: none;
margin: 10px 0; margin: 10px 0;
padding: 0; padding: 0;
} }
.ebsco-record .external-links li { .ebsco-record .external-links li {
display: inline-block; display: inline-block;
padding-left: 0; padding-left: 0;
padding-right: 10px; padding-right: 10px;
margin-left: 10px; margin-left: 10px;
border-right: 1px solid #CCCCCC; border-right: 1px solid #cccccc;
line-height: 32px; line-height: 32px;
margin: 5px; margin: 5px;
} }
.ebsco-record .external-links li:last-child { .ebsco-record .external-links li:last-child {
border-right: 0 none; border-right: 0 none;
} }
.external-link img { .external-link img {
vertical-align: middle; vertical-align: middle;
padding-right: 5px; padding-right: 5px;
} }
.top-login-message { .top-login-message {
margin-top:10px; margin-top: 10px;
width: 100%; width: 100%;
text-align: center; text-align: center;
} }
.ebsco-record .record { .ebsco-record .record {
width: 100%; width: 100%;
padding: 0; padding: 0;
} }
.ebsco-record .book-jacket { .ebsco-record .book-jacket {
max-width: 150px; max-width: 150px;
} }
.ebsco-record .html { .ebsco-record .html {
background-color: white; background-color: white;
padding:10px 0; padding: 10px 0;
border: 0; border: 0;
} }
@ -264,281 +264,274 @@
#ebsco-basic-search-form .form-item-lookfor, #ebsco-basic-search-form .form-item-lookfor,
#ebsco-basic-search-form .form-item-type { #ebsco-basic-search-form .form-item-type {
display: inline !important; display: inline !important;
} }
#ebsco-basic-search-form #edit-links { #ebsco-basic-search-form #edit-links {
display: inline; display: inline;
margin: 0; margin: 0;
padding: 0; padding: 0;
border: none 0; border: none 0;
position: static; position: static;
} }
#ebsco-basic-search-form #edit-offscreen { #ebsco-basic-search-form #edit-offscreen {
display: none; display: none;
} }
#ebsco-basic-search-form .form-item-remember label { #ebsco-basic-search-form .form-item-remember label {
font-weight: bold; font-weight: bold;
} }
#ebsco-sort-form { #ebsco-sort-form {
margin : 10px 0; margin: 10px 0;
} }
#ebsco-sort-form > div { #ebsco-sort-form > div {
border-bottom: 1px solid #CCCCCC; border-bottom: 1px solid #cccccc;
} }
#ebsco-sort-form label, #ebsco-sort-form label,
#ebsco-sort-form .form-item { #ebsco-sort-form .form-item {
display: inline-block !important; display: inline-block !important;
} }
#ebsco-sort-form .form-item:first-child { #ebsco-sort-form .form-item:first-child {
float: right; float: right;
} }
#ebsco-sort-form .form-item:last-child { #ebsco-sort-form .form-item:last-child {
float: left; float: left;
} }
/** Advanced search form ***/ /** Advanced search form ***/
.ebsco-advanced ._advanced-row { .ebsco-advanced ._advanced-row {
border: 0 none; border: 0 none;
padding: 0; padding: 0;
margin: 10px; margin: 10px;
top: 5px; top: 5px;
} }
.ebsco-advanced #edit-rows { .ebsco-advanced #edit-rows {
margin-bottom: 20px; margin-bottom: 20px;
} }
.ebsco-advanced ._advanced-row .fieldset-wrapper { .ebsco-advanced ._advanced-row .fieldset-wrapper {
margin: 0 !important; margin: 0 !important;
padding: 0; padding: 0;
} }
.ebsco-advanced .form-item-group0-lookfor label { .ebsco-advanced .form-item-group0-lookfor label {
display: inline-block; display: inline-block;
text-align: right; text-align: right;
width: 100px; width: 100px;
} }
.ebsco-advanced .form-type-radio label { .ebsco-advanced .form-type-radio label {
display: inline-block; display: inline-block;
text-align: left; text-align: left;
width: 90%; width: 90%;
} }
.ebsco-advanced #edit-add-row { .ebsco-advanced #edit-add-row {
border: 0 none; border: 0 none;
padding: 0; padding: 0;
margin: 10px; margin: 10px;
top: 5px; top: 5px;
} }
.ebsco-advanced #edit-add-row .fieldset-wrapper { .ebsco-advanced #edit-add-row .fieldset-wrapper {
margin-top: 5px; margin-top: 5px;
} }
.ebsco-advanced #edit-links { .ebsco-advanced #edit-links {
margin-bottom: 20px; margin-bottom: 20px;
text-align: center; text-align: center;
} }
.ebsco-advanced #edit-links .fieldset-wrapper { .ebsco-advanced #edit-links .fieldset-wrapper {
margin-top: 10px; margin-top: 10px;
} }
.ebsco-advanced #edit-limiters { .ebsco-advanced #edit-limiters {
width: 99%; width: 99%;
} }
.ebsco-advanced #edit-modes { .ebsco-advanced #edit-modes {
width: 49%; width: 49%;
float: left; float: left;
} }
.ebsco-advanced #edit-modes { .ebsco-advanced #edit-modes {
width: 49%; width: 49%;
float: left; float: left;
} }
.ebsco-advanced #edit-expanders { .ebsco-advanced #edit-expanders {
width: 49%; width: 49%;
float: right; float: right;
} }
.ebsco-advanced #edit-limiters label { .ebsco-advanced #edit-limiters label {
font-weight: normal; font-weight: normal;
} }
.ebsco-advanced #edit-limiters .form-type-select label { .ebsco-advanced #edit-limiters .form-type-select label {
display: block; display: block;
} }
.ebsco-advanced #edit-limiters hr { .ebsco-advanced #edit-limiters hr {
margin: 15px 0; margin: 15px 0;
height: 1px; height: 1px;
background-color: #CCCCCC; background-color: #cccccc;
color: #CCCCCC; color: #cccccc;
border: 0 none; border: 0 none;
} }
.dateSlider { .dateSlider {
width: 150px; width: 150px;
display: inline-block !important; display: inline-block !important;
margin: 0 10px; margin: 0 10px;
} }
/** Icons ***/ /** Icons ***/
.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;
display: inline-block; display: inline-block;
padding: 0 0 0 36px !important; padding: 0 0 0 36px !important;
} }
.icon.ebook { .icon.ebook {
background-position: 0 0; background-position: 0 0;
} }
.icon.html { .icon.html {
background-position: 0 -42px; background-position: 0 -42px;
} }
.icon.pdf { .icon.pdf {
background-position: 0 -84px; background-position: 0 -84px;
} }
.icon13 { .icon13 {
background: url("../images/sprites_32.png") no-repeat top left; background: url("../images/sprites_32.png") no-repeat top left;
padding-left: 18px !important; padding-left: 18px !important;
width: 13px; width: 13px;
height: 13px; height: 13px;
} }
.icon13.collapsed { .icon13.collapsed {
background-position: 0 -126px; background-position: 0 -126px;
} }
.icon13.expanded { .icon13.expanded {
background-position: 0 -149px; background-position: 0 -149px;
} }
.icon16 { .icon16 {
background: url("../images/sprites_32.png") no-repeat top left; background: url("../images/sprites_32.png") no-repeat top left;
padding-left: 21px !important; padding-left: 21px !important;
width: 16px; width: 16px;
height: 16px; height: 16px;
display: inline-block; display: inline-block;
} }
.icon16.tick { .icon16.tick {
background-position: 0 -171px; background-position: 0 -171px;
} }
/* RS, EMP carousel */ /* RS, EMP carousel */
#quote-carousel #quote-carousel {
{ padding: 0 10px 30px 10px;
padding: 0 10px 30px 10px; margin-top: 30px;
margin-top: 30px; }
}
/* Control buttons */
/* Control buttons */ #quote-carousel .carousel-control {
#quote-carousel .carousel-control background: none;
{ color: #222;
background: none; font-size: 2.3em;
color: #222; text-shadow: none;
font-size: 2.3em; margin-top: 30px;
text-shadow: none; }
margin-top: 30px; /* Previous button */
} #quote-carousel .carousel-control.left {
/* Previous button */ left: -12px;
#quote-carousel .carousel-control.left }
{ /* Next button */
left: -12px; #quote-carousel .carousel-control.right {
} right: -12px !important;
/* 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 { /* Changes the position of the indicators */
background-color: #000; #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;
}
h3.relatedTitle a{ .item blockquote img {
font-size:24px; 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;
}
/* */ /* */

1640
ebsco/ebsco.module

File diff suppressed because it is too large Load Diff

14
ebsco/js/ebsco.js

@ -1,6 +1,6 @@
/* /**
* The EBSCO module javascript * @file
* * The EBSCO module javascript.
* *
* Copyright [2017] [EBSCO Information Services] * Copyright [2017] [EBSCO Information Services]
* *
@ -15,11 +15,10 @@
* 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.
**/ */
(function ($) { (function ($) {
$(document).ready(function () { $(document).ready(function () {
//
var updatePublishDateSlider = function () { var updatePublishDateSlider = function () {
var from = parseInt($('#DT1').val()); var from = parseInt($('#DT1').val());
var min = 1000; var min = 1000;
@ -38,10 +37,9 @@
}); });
}; };
/**
/*
* Self executing function * Self executing function
**/ */
var onLoad = function () { var onLoad = function () {
// EBSCO/Search : Expand limiters // EBSCO/Search : Expand limiters
$('._more_limiters').live('click', function (event) { $('._more_limiters').live('click', function (event) {

1247
ebsco/lib/EBSCOAPI.php

File diff suppressed because it is too large Load Diff

931
ebsco/lib/EBSCOConnector.php

@ -1,9 +1,10 @@
<?php <?php
/** /**
* EBSCOException class * @file
* Used when EBSCO API calls return error messages * The EBSCO Connector and Exception classes.
* *
* Used when EBSCO API calls return error messages.
* *
* Copyright [2017] [EBSCO Information Services] * Copyright [2017] [EBSCO Information Services]
* *
@ -19,239 +20,250 @@
* 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.
*/ */
class EBSCOException extends Exception
{
const CRITICAL_ERROR = 1;
// Make message argument mandatory
public function __construct($message, $code = self::CRITICAL_ERROR, Exception $previous = null) {
parent::__construct($message, $code, $previous);
}
}
/**
* EBSCOException class.
*/
class EBSCOException extends Exception {
const CRITICAL_ERROR = 1;
/**
* Make message argument mandatory.
*/
public function __construct($message, $code = self::CRITICAL_ERROR, Exception $previous = NULL) {
parent::__construct($message, $code, $previous);
}
class EBSCOConnector }
{
/** /**
* Error codes defined by EDS API * EBSCOConnector class.
*/
class EBSCOConnector {
/**
* Error codes defined by EDS API.
*/ */
const EDS_UNKNOWN_PARAMETER = 100; const EDS_UNKNOWN_PARAMETER = 100;
const EDS_INCORRECT_PARAMETER_FORMAT = 101; const EDS_INCORRECT_PARAMETER_FORMAT = 101;
const EDS_INVALID_PARAMETER_INDEX = 102; const EDS_INVALID_PARAMETER_INDEX = 102;
const EDS_MISSING_PARAMETER = 103; const EDS_MISSING_PARAMETER = 103;
const EDS_AUTH_TOKEN_INVALID = 104; const EDS_AUTH_TOKEN_INVALID = 104;
const EDS_INCORRECT_ARGUMENTS_NUMBER = 105; const EDS_INCORRECT_ARGUMENTS_NUMBER = 105;
const EDS_UNKNOWN_ERROR = 106; const EDS_UNKNOWN_ERROR = 106;
const EDS_AUTH_TOKEN_MISSING = 107; const EDS_AUTH_TOKEN_MISSING = 107;
const EDS_SESSION_TOKEN_MISSING = 108; const EDS_SESSION_TOKEN_MISSING = 108;
const EDS_SESSION_TOKEN_INVALID = 109; const EDS_SESSION_TOKEN_INVALID = 109;
const EDS_INVALID_RECORD_FORMAT = 110; const EDS_INVALID_RECORD_FORMAT = 110;
const EDS_UNKNOWN_ACTION = 111; const EDS_UNKNOWN_ACTION = 111;
const EDS_INVALID_ARGUMENT_VALUE = 112; const EDS_INVALID_ARGUMENT_VALUE = 112;
const EDS_CREATE_SESSION_ERROR = 113; const EDS_CREATE_SESSION_ERROR = 113;
const EDS_REQUIRED_DATA_MISSING = 114; const EDS_REQUIRED_DATA_MISSING = 114;
const EDS_TRANSACTION_LOGGING_ERROR = 115; const EDS_TRANSACTION_LOGGING_ERROR = 115;
const EDS_DUPLICATE_PARAMETER = 116; const EDS_DUPLICATE_PARAMETER = 116;
const EDS_UNABLE_TO_AUTHENTICATE = 117; const EDS_UNABLE_TO_AUTHENTICATE = 117;
const EDS_SEARCH_ERROR = 118; const EDS_SEARCH_ERROR = 118;
const EDS_INVALID_PAGE_SIZE = 119; const EDS_INVALID_PAGE_SIZE = 119;
const EDS_SESSION_SAVE_ERROR = 120; const EDS_SESSION_SAVE_ERROR = 120;
const EDS_SESSION_ENDING_ERROR = 121; const EDS_SESSION_ENDING_ERROR = 121;
const EDS_CACHING_RESULTSET_ERROR = 122; const EDS_CACHING_RESULTSET_ERROR = 122;
const EDS_INVALID_EXPANDER_ERROR = 123; const EDS_INVALID_EXPANDER_ERROR = 123;
const EDS_INVALID_SEARCH_MODE_ERROR = 124; const EDS_INVALID_SEARCH_MODE_ERROR = 124;
const EDS_INVALID_LIMITER_ERROR = 125; const EDS_INVALID_LIMITER_ERROR = 125;
const EDS_INVALID_LIMITER_VALUE_ERROR = 126; const EDS_INVALID_LIMITER_VALUE_ERROR = 126;
const EDS_UNSUPPORTED_PROFILE_ERROR = 127; const EDS_UNSUPPORTED_PROFILE_ERROR = 127;
const EDS_PROFILE_NOT_SUPPORTED_ERROR = 128; const EDS_PROFILE_NOT_SUPPORTED_ERROR = 128;
const EDS_INVALID_CONTENT_PROVIDER_ERROR = 129; const EDS_INVALID_CONTENT_PROVIDER_ERROR = 129;
const EDS_INVALID_SOURCE_TYPE_ERROR = 130; const EDS_INVALID_SOURCE_TYPE_ERROR = 130;
const EDS_XSLT_ERROR = 131; const EDS_XSLT_ERROR = 131;
const EDS_RECORD_NOT_FOUND_ERROR = 132; const EDS_RECORD_NOT_FOUND_ERROR = 132;
const EDS_SIMULTANEOUS_USER_LIMIT_ERROR = 133; const EDS_SIMULTANEOUS_USER_LIMIT_ERROR = 133;
const EDS_NO_GUEST_ACCESS_ERROR = 134; const EDS_NO_GUEST_ACCESS_ERROR = 134;
const EDS_DBID_NOT_IN_PROFILE_ERROR = 135; const EDS_DBID_NOT_IN_PROFILE_ERROR = 135;
const EDS_INVALID_SEARCH_VIEW_ERROR = 136; const EDS_INVALID_SEARCH_VIEW_ERROR = 136;
const EDS_RETRIEVING_FULL_TEXT_ERROR = 137; const EDS_RETRIEVING_FULL_TEXT_ERROR = 137;
/** /**
* HTTP status codes constants * HTTP status codes constants
* http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html * http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html.
* *
* @global integer HTTP_OK The request has succeeded * @global integer HTTP_OK The request has succeeded
* @global integer HTTP_NOT_FOUND The server has not found anything matching the Request-URI * @global integer HTTP_NOT_FOUND The server has not found anything matching the Request-URI
*/ */
const HTTP_OK = 200; const HTTP_OK = 200;
const HTTP_BAD_REQUEST = 400; const HTTP_BAD_REQUEST = 400;
const HTTP_NOT_FOUND = 404; const HTTP_NOT_FOUND = 404;
const HTTP_INTERNAL_SERVER_ERROR = 500; const HTTP_INTERNAL_SERVER_ERROR = 500;
/** /**
* The HTTP_Request object used for API transactions * The HTTP_Request object used for API transactions.
* @global object HTTP_Request *
*/ * @global object HTTP_Request
private $client; */
private $client;
/**
* The URL of the EBSCO API server /**
* @global string * The URL of the EBSCO API server.
*/ *
private static $end_point = 'http://eds-api.ebscohost.com/EDSAPI/rest'; * @global string
*/
private static $end_point = 'http://eds-api.ebscohost.com/EDSAPI/rest';
/**
* The URL of the EBSCO API server
* @global string /**
*/ * The URL of the EBSCO API server.
private static $authentication_end_point = 'https://eds-api.ebscohost.com/AuthService/rest'; *
* @global string
*/
/** private static $authentication_end_point = 'https://eds-api.ebscohost.com/AuthService/rest';
* The password used for API transactions
* @global string
*/ /**
private $password; * The password used for API transactions.
*
* @global string
/** */
* The user id used for API transactions private $password;
* @global string
*/
private $userId; /**
* The user id used for API transactions.
*
/** * @global string
* The profile ID used for API transactions */
* @global string private $userId;
*/
private $profileId;
/**
* The profile ID used for API transactions.
/** *
* The interface ID used for API transactions * @global string
* @global string */
*/ private $profileId;
private $interfaceId;
/**
/** * The interface ID used for API transactions.
* The customer ID used for API transactions *
* @global string * @global string
*/ */
private $orgId; private $interfaceId;
/** /**
* The isGuest used for API transactions * The customer ID used for API transactions.
* @global string 'y' or 'n' *
*/ * @global string
private $isGuest; */
private $orgId;
/**
* Contains the list of ip addresses
* @global string /**
*/ * The isGuest used for API transactions.
private $local_ip_address; *
* @global string 'y' or 'n'
*/
/* private $isGuest;
* You can log HTTP_Request requests using this option
* @global bool logAPIRequests /**
*/ * Contains the list of ip addresses.
private $logAPIRequests; *
* @global string
*/
/** private $local_ip_address;
* The logger object
* @global object Logger
*/ /**
private $logger; * You can log HTTP_Request requests using this option.
*
* @global bool logAPIRequests
/** */
* Constructor
* private $logAPIRequests;
* Sets up the EBSCO API settings
*
* @param none /**
* * The logger object.
* @access public *
*/ * @global object Logger
*/
public function __construct($config) private $logger;
{
$this->password = $config['password']; /**
$this->userId = $config['user']; * Constructor.
$this->interfaceId = $config['interface']; *
$this->profileId = $config['profile']; * Sets up the EBSCO API settings.
$this->orgId = $config['organization']; *
$this->local_ip_address = $config['local_ip_address']; * @param none
$this->isGuest = (user_is_logged_in() || $this->isGuestIPAddress($_SERVER["REMOTE_ADDR"]))? 'n' : 'y'; *
$this->logAPIRequests = ($config['log'] == 1); * @access public
if ($this->logAPIRequests) { */
$writer = new Zend_Log_Writer_Stream('php://output'); public function __construct($config) {
$this->logger = new Zend_Log($writer); $this->password = $config['password'];
} $this->userId = $config['user'];
$this->interfaceId = $config['interface'];
$this->profileId = $config['profile'];
$this->orgId = $config['organization'];
$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');
$this->logger = new Zend_Log($writer);
} }
}
/** /**
* Detects if the user is authorized based on the IP address * Detects if the user is authorized based on the IP address.
* *
* @return string * @return string
*/ */
public function isGuestIPAddress($ipUser) public function isGuestIPAddress($ipUser) {
{ $s = $this->local_ip_address;
$s= $this->local_ip_address;
if (trim($s) == "") {
if (trim($s)=="") { return FALSE;
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;
} }
// Break records.
/** $m = explode(",", $s);
* Public getter for private isGuest
* foreach ($m as $ip) {
* @param none if (strcmp(substr($ipUser, 0, strlen(trim($ip))), trim($ip)) == 0) {
* // Inside of ip address range of customer.
* @return string isGuest return TRUE;
* @access public }
*/
public function isGuest()
{
return $this->isGuest;
} }
return FALSE;
}
/**
* Request the authentication token /**
* * Public getter for private isGuest .
* @param none *
* * @param none
* @return object SimpleXml or PEAR_Error *
* @access public * @return string isGuest
*/ *
public function requestAuthenticationToken() * @access public
{ */
$url = self::$authentication_end_point . '/UIDAuth'; public function isGuest() {
return $this->isGuest;
// Add the body of the request }
$params =<<<BODY
/**
* Request the authentication token.
*
* @param none
*
* @return object SimpleXml or PEAR_Error
*
* @access public
*/
public function requestAuthenticationToken() {
$url = self::$authentication_end_point . '/UIDAuth';
// Add the body of the request.
$params = <<<BODY
<UIDAuthRequestMessage xmlns="http://www.ebscohost.com/services/public/AuthService/Response/2012/06/01"> <UIDAuthRequestMessage xmlns="http://www.ebscohost.com/services/public/AuthService/Response/2012/06/01">
<UserId>{$this->userId}</UserId> <UserId>{$this->userId}</UserId>
<Password>{$this->password}</Password> <Password>{$this->password}</Password>
@ -259,246 +271,251 @@ class EBSCOConnector
</UIDAuthRequestMessage> </UIDAuthRequestMessage>
BODY; BODY;
$response = $this->request($url, $params, array(), 'POST'); $response = $this->request($url, $params, array(), 'POST');
return $response; return $response;
} }
/**
/** * Request the session token.
* Request the session token *
* * @param array $headers
* @param array $headers Authentication token * Authentication token.
* *
* @return object SimpleXml or PEAR_Error * @return object SimpleXml or PEAR_Error
* @access public *
*/ * @access public
public function requestSessionToken($headers) */
{ public function requestSessionToken($headers) {
$url = self::$end_point . '/CreateSession'; $url = self::$end_point . '/CreateSession';
// Add the HTTP query params // Add the HTTP query params.
$params = array( $params = array(
'profile' => $this->profileId, 'profile' => $this->profileId,
'org' => $this->orgId, 'org' => $this->orgId,
'guest' => $this->isGuest 'guest' => $this->isGuest,
); );
$response = $this->request($url, $params, $headers); $response = $this->request($url, $params, $headers);
return $response; return $response;
} }
/**
/** * Request the search records.
* Request the search records *
* * @param array $params
* @param array $params Search specific parameters * Search specific parameters.
* @param array $headers Authentication and session tokens * @param array $headers
* * Authentication and session tokens.
* @return object SimpleXml or PEAR_Error *
* @access public * @return object SimpleXml or PEAR_Error
*/ *
public function requestSearch($params, $headers) * @access public
{ */
$url = self::$end_point . '/Search'; public function requestSearch($params, $headers) {
$url = self::$end_point . '/Search';
$response = $this->request($url, $params, $headers);
return $response; $response = $this->request($url, $params, $headers);
} return $response;
}
/** /**
* Request a specific record * Request a specific record.
* *
* @param array $params Retrieve specific parameters * @param array $params
* @param array $headers Authentication and session tokens * Retrieve specific parameters.
* * @param array $headers
* @return object SimpleXml or PEAR_Error * Authentication and session tokens.
* @access public *
*/ * @return object SimpleXml or PEAR_Error
public function requestRetrieve($params, $headers) *
{ * @access public
$url = self::$end_point . '/Retrieve'; */
public function requestRetrieve($params, $headers) {
$response = $this->request($url, $params, $headers); $url = self::$end_point . '/Retrieve';
return $response;
} $response = $this->request($url, $params, $headers);
return $response;
}
/**
* Request the info data /**
* * Request the info data.
* @param null $params Not used *
* @param array $headers Authentication and session tokens * @param null $params
* * Not used.
* @return object SimpleXml or PEAR_Error * @param array $headers
* @access public * Authentication and session tokens.
*/ *
public function requestInfo($params, $headers) * @return object SimpleXml or PEAR_Error
{ *
$url = self::$end_point . '/Info'; * @access public
*/
$response = $this->request($url, $params, $headers); public function requestInfo($params, $headers) {
$url = self::$end_point . '/Info';
return $response;
$response = $this->request($url, $params, $headers);
return $response;
}
/**
* Send an HTTP request and inspect the response.
*
* @param string $url
* The url of the HTTP request.
* @param array $params
* The parameters of the HTTP request.
* @param array $headers
* The headers of the HTTP request.
* @param array $body
* The body of the HTTP request.
* @param string $method
* The HTTP method, default is 'GET'.
*
* @return object SimpleXml or PEAR_Error
*
* @access protected
*/
protected function request($url, $params, $headers = array(), $method = 'GET') {
$xml = FALSE;
$return = FALSE;
$data = NULL;
if (!empty($params)) {
// Arrays of parameters are used only for GET requests.
if (is_array($params)) {
$query = http_build_query($params, '', '&');
$query = preg_replace('/\%5B\d+\%5D/', '', $query);
$url = $url . '?' . $query;
// String parameters are used only for POST requests.
}
else {
$data = $params;
$headers = array_merge(
array('content-type' => 'text/xml'),
$headers
);
}
} }
// Add compression in case its not there.
$headers = array_merge(
/** array('Accept-Encoding' => 'gzip,deflate'),
* Send an HTTP request and inspect the response $headers
* );
* @param string $url The url of the HTTP request
* @param array $params The parameters of the HTTP request $options = array(
* @param array $headers The headers of the HTTP request 'headers' => $headers,
* @param array $body The body of the HTTP request 'method' => $method,
* @param string $method The HTTP method, default is 'GET' 'data' => $data,
* );
* @return object SimpleXml or PEAR_Error
* @access protected // Send the request.
*/ try {
protected function request($url, $params, $headers = array(), $method = 'GET') $response = drupal_http_request($url, $options);
{ // print_r($url);
$xml = false; // print_r($response);
$return = false; $code = $response->code;
$data = null; if (isset($response->headers['content-encoding'])) {
if ($response->headers['content-encoding'] == 'gzip') {
if (!empty($params)) { $response->data = gzinflate(substr($response->data, 10));
// Arrays of parameters are used only for GET requests
if (is_array($params)) {
$query = http_build_query($params, '', '&');
$query = preg_replace('/\%5B\d+\%5D/', '', $query);
$url = $url . '?' . $query;
// String parameters are used only for POST requests
} else {
$data = $params;
$headers = array_merge(
array('content-type' => 'text/xml'),
$headers
);
}
} }
elseif ($response->headers['content-encoding'] == 'deflate') {
//add compression in case its not there $response->data = gzinflate($response->data);
$headers = array_merge(
array('Accept-Encoding' => 'gzip,deflate'),
$headers
);
$options = array(
'headers' => $headers,
'method' => $method,
'data' => $data
);
// Send the request
try {
$response = drupal_http_request($url, $options);
//print_r($url);
//print_r($response);
$code = $response->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 {
// clean EMP namespace
$xml_str=str_replace(array("<a:","</a:"),array("<","</"),$xml_str);
$xml = simplexml_load_string($xml_str);
$return = $xml;
} catch(Exception $e) {
$return = new EBSCOException($xml);
}
break;
case self::HTTP_BAD_REQUEST:
$xml_str = $response->data;
try {
$xml = simplexml_load_string($xml_str);
// If the response is an API error
$isError = isset($xml->ErrorNumber) || isset($xml->ErrorCode);
if ($isError) {
$error = ''; $code = 0;
if (isset($xml->DetailedErrorDescription) && !empty($xml->DetailedErrorDescription)) {
$error = (string) $xml->DetailedErrorDescription;
} else if (isset($xml->ErrorDescription)) {
$error = (string) $xml->ErrorDescription;
} else if (isset($xml->Reason)) {
$error = (string) $xml->Reason;
}
if (isset($xml->ErrorNumber)) {
$code = (integer) $xml->ErrorNumber;
} else if (isset($xml->ErrorCode)) {
$code = (integer) $xml->ErrorCode;
}
$return = new EBSCOException($error, $code);
} else {
$return = new EBSCOException("HTTP {$code} : The request could not be understood
by the server due to malformed syntax. Modify your search before retrying.");
}
} catch (Exception $e) {
$return = new EBSCOException($xml);
}
break;
case self::HTTP_NOT_FOUND:
$return = new EBSCOException("HTTP {$code} : The resource you are looking for might
have been removed, had its name changed, or is temporarily unavailable.");
break;
case self::HTTP_INTERNAL_SERVER_ERROR:
$return = new EBSCOException("HTTP {$code} : The server encountered an unexpected condition
which prevented it from fulfilling the request.");
break;
default:
$return = new EBSCOException("HTTP {$code} : Unexpected HTTP error.");
break;
}
} catch (Exception $e) {
$message = $this->toString($client); // or $this->toString($response)
$this->logger->log($message, Zend_Log::ERR);
$return = new EBSCOException($response);
} }
}
// Log any error switch ($code) {
/*if ($this->logAPIRequests) { case self::HTTP_OK:
// $client = both the HTTP request and response
// $response = only the HTTP response $xml_str = $response->data;
$message = $this->toString($client); // or $this->toString($response)
$this->logger->log($message, Zend_Log::ERR); try {
}*/ // Clean EMP namespace.
$xml_str = str_replace(array("<a:", "</a:"), array("<", "</"), $xml_str);
return $return; $xml = simplexml_load_string($xml_str);
$return = $xml;
}
catch (Exception $e) {
$return = new EBSCOException($xml);
}
break;
case self::HTTP_BAD_REQUEST:
$xml_str = $response->data;
try {
$xml = simplexml_load_string($xml_str);
// If the response is an API error.
$isError = isset($xml->ErrorNumber) || isset($xml->ErrorCode);
if ($isError) {
$error = ''; $code = 0;
if (isset($xml->DetailedErrorDescription) && !empty($xml->DetailedErrorDescription)) {
$error = (string) $xml->DetailedErrorDescription;
}
elseif (isset($xml->ErrorDescription)) {
$error = (string) $xml->ErrorDescription;
}
elseif (isset($xml->Reason)) {
$error = (string) $xml->Reason;
}
if (isset($xml->ErrorNumber)) {
$code = (integer) $xml->ErrorNumber;
}
elseif (isset($xml->ErrorCode)) {
$code = (integer) $xml->ErrorCode;
}
$return = new EBSCOException($error, $code);
}
else {
$return = new EBSCOException("HTTP {$code} : The request could not be understood by the server due to malformed syntax. Modify your search before retrying.");
}
}
catch (Exception $e) {
$return = new EBSCOException($xml);
}
break;
case self::HTTP_NOT_FOUND:
$return = new EBSCOException("HTTP {$code} : The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.");
break;
case self::HTTP_INTERNAL_SERVER_ERROR:
$return = new EBSCOException("HTTP {$code} : The server encountered an unexpected condition which prevented it from fulfilling the request.");
break;
default:
$return = new EBSCOException("HTTP {$code} : Unexpected HTTP error.");
break;
}
} }
catch (Exception $e) {
// Or $this->toString($response)
/* $message = $this->toString($client);
* Capture the output of print_r into a string $this->logger->log($message, Zend_Log::ERR);
* $return = new EBSCOException($response);
* @param object Any object
* @access private
*/
private function toString($object)
{
ob_start();
print_r($object);
return ob_get_clean();
} }
// Log any error
/*if ($this->logAPIRequests) {
// $client = both the HTTP request and response
// $response = only the HTTP response
$message = $this->toString($client); // or $this->toString($response)
$this->logger->log($message, Zend_Log::ERR);
}*/
return $return;
}
/**
* Capture the output of print_r into a string.
*
* @param object Any object
*
* @access private
*/
private function toString($object) {
ob_start();
print_r($object);
return ob_get_clean();
}
} }
?>

1663
ebsco/lib/EBSCODocument.php

File diff suppressed because it is too large Load Diff

728
ebsco/lib/EBSCORecord.php

@ -1,10 +1,10 @@
<?php <?php
/** /**
* The EBSCO record object * @file
* The EBSCO record object.
* *
* PHP version 5 * PHP version 5
*
*
* *
* Copyright [2017] [EBSCO Information Services] * Copyright [2017] [EBSCO Information Services]
* *
@ -21,393 +21,379 @@
* limitations under the License. * limitations under the License.
*/ */
class EBSCORecord /**
{ * EBSCORecord class.
/** */
* The array of data class EBSCORecord {
* @global array /**
*/ * The array of data.
private $data = array(); *
* @global array
/** */
* The result id (the EBSCO counter) of the record private $data = array();
* @global integer
*/ /**
public $result_id = null; * The result id (the EBSCO counter) of the record.
*
/** * @global integer
* The id of the record */
* @global integer public $result_id = NULL;
*/
public $record_id = null; /**
* The id of the record.
/** *
* The summary of the record. * @global integer
* @global string */
*/ public $record_id = NULL;
public $summary = null;
/**
/** * The summary of the record.
* The authors of the record. *
* @global string * @global string
*/ */
public $authors = null; public $summary = NULL;
/** /**
* The subjects of the record. * The authors of the record.
* @global string *
*/ * @global string
public $subjects = null; */
public $authors = NULL;
/**
* The custom links provided for the record. /**
* @global array * The subjects of the record.
*/ *
public $custom_links = array(); * @global string
*/
/** public $subjects = NULL;
* The database label of the record.
* @global string /**
*/ * The custom links provided for the record.
public $db_label = null; *
* @global array
/** */
* The full-text availability of the record. public $custom_links = array();
* @global boolean
*/ /**
public $full_text_availability = null; * The database label of the record.
*
/** * @global string
* The full text of the record. */
* @global string public $db_label = NULL;
*/
public $full_text = null; /**
* The full-text availability of the record.
/** *
* The PDF availability of the record. * @global boolean
* @global boolean */
*/ public $full_text_availability = NULL;
public $pdf_availability = null;
/**
/** * The full text of the record.
* The items of the record. *
* @global array * @global string
*/ */
public $items = array(); public $full_text = NULL;
/** /**
* The external link of the record. * The PDF availability of the record.
* @global string *
*/ * @global boolean
public $p_link = null; */
public $pdf_availability = NULL;
/**
* The external link to the PDF version of the record. /**
* @global string * The items of the record.
*/ *
public $pdf_link = null; * @global array
*/
/** public $items = array();
* The publication type link of the record.
* @global string /**
*/ * The external link of the record.
public $publication_type = null; *
* @global string
/** */
* The external thumbnails links of the record. public $p_link = NULL;
* @global string
*/ /**
public $small_thumb_link = null; * The external link to the PDF version of the record.
public $medium_thumb_link = null; *
* @global string
/** */
* The title of the record. public $pdf_link = NULL;
* @global string
*/ /**
public $title = null; * The publication type link of the record.
*
/** * @global string
* The source of the record. */
* @global string public $publication_type = NULL;
*/
public $source = null; /**
* The external thumbnails links of the record.
/** *
* The access level of the record. * @global string
* @global string */
*/ public $small_thumb_link = NULL;
public $access_level = null; public $medium_thumb_link = NULL;
/**
/** * The title of the record.
* Constructor. *
* * @global string
* @param array $data Raw data from the EBSCO search representing the record. */
*/ public $title = NULL;
public function __construct($data = array())
{ /**
$this->data = $data; * The source of the record.
$this->record_id = $this->record_id(); *
$this->result_id = $this->result_id(); * @global string
$this->title = $this->title(); */
$this->summary = $this->summary(); public $source = NULL;
$this->authors = $this->authors();
$this->subjects = $this->subjects(); /**
$this->custom_links = $this->custom_links(); * The access level of the record.
$this->db_label = $this->db_label(); *
$this->full_text_availability = $this->full_text_availability(); * @global string
$this->full_text = $this->full_text(); */
$this->items = $this->items(); public $access_level = NULL;
$this->p_link = $this->p_link();
$this->publication_type = $this->publication_type(); /**
$this->pdf_availability = $this->pdf_availability(); * Constructor.
$this->pdf_link = $this->pdf_link(); *
$this->small_thumb_link = $this->thumb_link(); * @param array $data
$this->medium_thumb_link = $this->thumb_link('medium'); * Raw data from the EBSCO search representing the record.
$this->source = $this->source(); */
$this->access_level = $this->access_level(); public function __construct($data = array()) {
} $this->data = $data;
$this->record_id = $this->record_id();
$this->result_id = $this->result_id();
/******************************************************** $this->title = $this->title();
* $this->summary = $this->summary();
* Getters $this->authors = $this->authors();
* $this->subjects = $this->subjects();
********************************************************/ $this->custom_links = $this->custom_links();
$this->db_label = $this->db_label();
$this->full_text_availability = $this->full_text_availability();
/** $this->full_text = $this->full_text();
* Get the summary of the record. $this->items = $this->items();
* $this->p_link = $this->p_link();
* @return string $this->publication_type = $this->publication_type();
*/ $this->pdf_availability = $this->pdf_availability();
public function access_level() $this->pdf_link = $this->pdf_link();
{ $this->small_thumb_link = $this->thumb_link();
return isset($this->data['AccessLevel']) ? $this->medium_thumb_link = $this->thumb_link('medium');
$this->source = $this->source();
$this->access_level = $this->access_level();
}
/********************************************************
*
* Getters
*
********************************************************/
/**
* Get the summary of the record.
*
* @return string
*/
public function access_level() {
return isset($this->data['AccessLevel']) ?
$this->data['AccessLevel'] : ''; $this->data['AccessLevel'] : '';
} }
/**
/** * Get the summary of the record.
* Get the summary of the record. *
* * @return string
* @return string */
*/ public function summary() {
public function summary() return isset($this->data['Items']['Abstract']) ?
{
return isset($this->data['Items']['Abstract']) ?
$this->data['Items']['Abstract']['Data'] : ''; $this->data['Items']['Abstract']['Data'] : '';
} }
/**
/** * Get the authors of the record.
* Get the authors of the record. *
* * @return string
* @return string */
*/ public function authors() {
public function authors() return isset($this->data['Items']['Author']) ?
{
return isset($this->data['Items']['Author']) ?
$this->data['Items']['Author']['Data'] : ''; $this->data['Items']['Author']['Data'] : '';
} }
/**
/** * Get the custom links of the record.
* Get the custom links of the record. *
* * @return array
* @return array */
*/ public function custom_links() {
public function custom_links() return isset($this->data['CustomLinks']) ?
{
return isset($this->data['CustomLinks']) ?
$this->data['CustomLinks'] : array(); $this->data['CustomLinks'] : array();
} }
/**
/** * Get the database label of the record.
* Get the database label of the record. *
* * @return string
* @return string */
*/ public function db_label() {
public function db_label() return isset($this->data['DbLabel']) ?
{
return isset($this->data['DbLabel']) ?
$this->data['DbLabel'] : ''; $this->data['DbLabel'] : '';
} }
/**
/** * Get the full text availability of the record.
* Get the full text availability of the record. *
* * @return bool
* @return boolean */
*/ public function full_text() {
public function full_text() return isset($this->data['FullText']) &&
{
return isset($this->data['FullText']) &&
isset($this->data['FullText']['Value']) ? $this->data['FullText']['Value'] : ''; isset($this->data['FullText']['Value']) ? $this->data['FullText']['Value'] : '';
} }
/**
/** * Get the full text availability of the record.
* Get the full text availability of the record. *
* * @return bool
* @return boolean */
*/ public function full_text_availability() {
public function full_text_availability() return isset($this->data['FullText']) &&
{
return isset($this->data['FullText']) &&
$this->data['FullText']['Availability']; $this->data['FullText']['Availability'];
} }
/**
/** * Get the items of the record.
* Get the items of the record. *
* * @return array
* @return array */
*/ public function items() {
public function items() return isset($this->data['Items']) ? $this->data['Items'] : array();
{ }
return isset($this->data['Items']) ? $this->data['Items'] : array();
} /**
* Get the external url of the record.
*
/** * @return string
* Get the external url of the record. */
* public function p_link() {
* @return string return isset($this->data['PLink']) ? $this->data['PLink'] : '';
*/ }
public function p_link()
{ /**
return isset($this->data['PLink']) ? $this->data['PLink'] : ''; * Get the publication type of the record.
} *
* @return string
*/
/** public function publication_type() {
* Get the publication type of the record. return isset($this->data['PubType']) ? $this->data['PubType'] : '';
* }
* @return string
*/ /**
public function publication_type() * Get the PDF availability of the record.
{ *
return isset($this->data['PubType']) ? $this->data['PubType'] : ''; * @return bool
} */
public function pdf_availability() {
return isset($this->data['FullText']) &&
/**
* Get the PDF availability of the record.
*
* @return boolean
*/
public function pdf_availability()
{
return isset($this->data['FullText']) &&
isset($this->data['FullText']['Links']) && isset($this->data['FullText']['Links']) &&
isset($this->data['FullText']['Links']['pdflink']) && isset($this->data['FullText']['Links']['pdflink']) &&
$this->data['FullText']['Links']['pdflink']; $this->data['FullText']['Links']['pdflink'];
} }
/**
/** * Get the PDF url of the record.
* Get the PDF url of the record. *
* * @return string
* @return string */
*/ public function pdf_link() {
public function pdf_link() return isset($this->data['FullText']) &&
{
return isset($this->data['FullText']) &&
isset($this->data['FullText']['Links']) && isset($this->data['FullText']['Links']) &&
isset($this->data['FullText']['Links']['pdflink']) ? isset($this->data['FullText']['Links']['pdflink']) ?
$this->data['FullText']['Links']['pdflink'] : $this->data['FullText']['Links']['pdflink'] :
''; '';
} }
/**
/** * Get the result id of the record.
* Get the result id of the record. *
* * @return int
* @return integer */
*/ public function result_id() {
public function result_id() return isset($this->data['ResultId']) ?
{
return isset($this->data['ResultId']) ?
$this->data['ResultId'] : ''; $this->data['ResultId'] : '';
} }
/**
/** * Get the subject data of the record.
* Get the subject data of the record. *
* * @return string
* @return string */
*/ public function subjects() {
public function subjects() return isset($this->data['Items']['Subject']) ?
{
return isset($this->data['Items']['Subject']) ?
$this->data['Items']['Subject']['Data'] : ''; $this->data['Items']['Subject']['Data'] : '';
}
/**
* Return a URL to a thumbnail preview of the record, if available; false
* otherwise.
*
* @param string $size
* Size of thumbnail (small, medium or large -- small is
* default).
*
* @return string
*/
public function thumb_link($size = 'small') {
$imageInfo = isset($this->data['ImageInfo']) ? $this->data['ImageInfo'] : '';
if ($imageInfo && isset($imageInfo['thumb'])) {
switch ($size) {
case 'large':
case 'medium':
return $imageInfo['medium'];
break;
case 'small':
default:
return $imageInfo['thumb'];
break;
}
} }
return FALSE;
}
/**
* Return a URL to a thumbnail preview of the record, if available; false /**
* otherwise. * Get the title of the record.
* *
* @param string $size Size of thumbnail (small, medium or large -- small is * @return string
* default). */
* public function title() {
* @return string return isset($this->data['Items']['Title']) ?
*/
public function thumb_link($size = 'small')
{
$imageInfo = isset($this->data['ImageInfo']) ? $this->data['ImageInfo'] : '';
if ($imageInfo && isset($imageInfo['thumb'])) {
switch ($size) {
case 'large':
case 'medium':
return $imageInfo['medium'];
break;
case 'small':
default:
return $imageInfo['thumb'];
break;
}
}
return false;
}
/**
* Get the title of the record.
*
* @return string
*/
public function title()
{
return isset($this->data['Items']['Title']) ?
$this->data['Items']['Title']['Data'] : ''; $this->data['Items']['Title']['Data'] : '';
} }
/**
/** * Get the source of the record.
* Get the source of the record. *
* * @return string
* @return string */
*/ public function source() {
public function source() return isset($this->data['Items']['TitleSource']) ?
{
return isset($this->data['Items']['TitleSource']) ?
$this->data['Items']['TitleSource']['Data'] : ''; $this->data['Items']['TitleSource']['Data'] : '';
} }
/**
/** * Return the identifier of this record within the EBSCO databases.
* Return the identifier of this record within the EBSCO databases *
* * @return string Unique identifier.
* @return string Unique identifier. */
*/ public function record_id() {
public function record_id() return isset($this->data['id']) ?
{
return isset($this->data['id']) ?
$this->data['id'] : ''; $this->data['id'] : '';
} }
} }

1091
ebsco/lib/EBSCOResponse.php

File diff suppressed because it is too large Load Diff

800
ebsco/lib/sanitizer.class.php

@ -1,444 +1,444 @@
<?php // $Id$ <?php
// vim: expandtab sw=4 ts=4 sts=4: /**
* @file
# ***** BEGIN LICENSE BLOCK ***** * $Id$.
# This file is part of HTML Sanitizer. */
# Copyright (c) 2005-2011 Frederic Minne <zefredz@gmail.com>.
# All rights reserved.
#
# HTML Sanitizer is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# HTML Sanitizer is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with HTML Sanitizer; if not, see <http://www.gnu.org/licenses/>.
#
# ***** END LICENSE BLOCK *****
// vim: expandtab sw=4 ts=4 sts=4:
// ***** BEGIN LICENSE BLOCK *****
// This file is part of HTML Sanitizer.
// Copyright (c) 2005-2011 Frederic Minne <zefredz@gmail.com>.
// All rights reserved.
//
// HTML Sanitizer is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// HTML Sanitizer is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with HTML Sanitizer; if not, see <http://www.gnu.org/licenses/>.
//
// ***** END LICENSE BLOCK *****.
/** /**
* Sanitize HTML contents : * Sanitize HTML contents :
* Remove dangerous tags and attributes that can lead to security issues like * Remove dangerous tags and attributes that can lead to security issues like
* XSS or HTTP response splitting * XSS or HTTP response splitting.
* *
* @author Frederic Minne <zefredz@gmail.com> * @author Frederic Minne <zefredz@gmail.com>
* @copyright Copyright &copy; 2005-2011, Frederic Minne * @copyright Copyright &copy; 2005-2011, Frederic Minne
* @license http://www.gnu.org/licenses/lgpl.txt GNU Lesser General Public License version 3 or later * @license http://www.gnu.org/licenses/lgpl.txt GNU Lesser General Public License version 3 or later
* @version 1.1 * @version 1.1
*/ */
class HTML_Sanitizer class HTML_Sanitizer {
{ /**
// Private fields * Private fields.
private $_allowedTags; */
private $_allowJavascriptEvents; private $_allowedTags;
private $_allowJavascriptInUrls; private $_allowJavascriptEvents;
private $_allowObjects; private $_allowJavascriptInUrls;
private $_allowScript; private $_allowObjects;
private $_allowStyle; private $_allowScript;
private $_additionalTags; private $_allowStyle;
private $_additionalTags;
/**
* Constructor /**
*/ * Constructor.
public function __construct() */
{ public function __construct() {
$this->resetAll(); $this->resetAll();
} }
/** /**
* (re)set all options to default value * (re)set all options to default value.
*/ */
public function resetAll() public function resetAll() {
{ $this->_allowDOMEvents = FALSE;
$this->_allowDOMEvents = false; $this->_allowJavascriptInUrls = FALSE;
$this->_allowJavascriptInUrls = false; $this->_allowStyle = FALSE;
$this->_allowStyle = false; $this->_allowScript = FALSE;
$this->_allowScript = false; $this->_allowObjects = FALSE;
$this->_allowObjects = false; $this->_allowStyle = FALSE;
$this->_allowStyle = false;
$this->_allowedTags = '<a><br><b><h1><h2><h3><h4><h5><h6>'
$this->_allowedTags = '<a><br><b><h1><h2><h3><h4><h5><h6>'
. '<img><li><ol><p><strong><table><tr><td><th><u><ul><thead>' . '<img><li><ol><p><strong><table><tr><td><th><u><ul><thead>'
. '<tbody><tfoot><em><dd><dt><dl><span><div><del><add><i><hr>' . '<tbody><tfoot><em><dd><dt><dl><span><div><del><add><i><hr>'
. '<pre><br><blockquote><address><code><caption><abbr><acronym>' . '<pre><br><blockquote><address><code><caption><abbr><acronym>'
. '<cite><dfn><q><ins><sup><sub><kbd><samp><var><tt><small><big>' . '<cite><dfn><q><ins><sup><sub><kbd><samp><var><tt><small><big>';
;
$this->_additionalTags = '';
$this->_additionalTags = ''; }
}
/**
/** * Add additional tags to allowed tags.
* Add additional tags to allowed tags *
* @param string * @param string
* @access public *
*/ * @access public
public function addAdditionalTags( $tags ) */
{ public function addAdditionalTags($tags) {
$this->_additionalTags .= $tags; $this->_additionalTags .= $tags;
} }
/** /**
* Allow iframes * Allow iframes.
* @access public *
*/ * @access public
public function allowIframes() */
{ public function allowIframes() {
$this->addAdditionalTags( '<iframe>' ); $this->addAdditionalTags('<iframe>');
} }
/** /**
* Allow HTML5 media tags * Allow HTML5 media tags.
* @access public *
*/ * @access public
public function allowHtml5Media() */
{ public function allowHtml5Media() {
$this->addAdditionalTags( '<canvas><video><audio>' ); $this->addAdditionalTags('<canvas><video><audio>');
} }
/** /**
* Allow object, embed, applet and param tags in html * Allow object, embed, applet and param tags in html.
* @access public *
*/ * @access public
public function allowObjects() */
{ public function allowObjects() {
$this->_allowObjects = true; $this->_allowObjects = TRUE;
}
/**
* Allow DOM event on DOM elements.
*
* @access public
*/
public function allowDOMEvents() {
$this->_allowDOMEvents = TRUE;
}
/**
* Allow script tags.
*
* @access public
*/
public function allowScript() {
$this->_allowScript = TRUE;
}
/**
* Allow the use of javascript: in urls.
*
* @access public
*/
public function allowJavascriptInUrls() {
$this->_allowJavascriptInUrls = TRUE;
}
/**
* Allow style tags and attributes.
*
* @access public
*/
public function allowStyle() {
$this->_allowStyle = TRUE;
}
/**
* Helper to allow all javascript related tags and attributes.
*
* @access public
*/
public function allowAllJavascript() {
$this->allowDOMEvents();
$this->allowScript();
$this->allowJavascriptInUrls();
}
/**
* Allow all tags and attributes.
*
* @access public
*/
public function allowAll() {
$this->allowAllJavascript();
$this->allowObjects();
$this->allowStyle();
$this->allowIframes();
$this->allowHtml5Media();
}
/**
* Filter URLs to avoid HTTP response splitting attacks.
*
* @access public
* @param string url
*
* @return string filtered url
*/
public function filterHTTPResponseSplitting($url) {
$dangerousCharactersPattern = '~(\r\n|\r|\n|%0a|%0d|%0D|%0A)~';
return preg_replace($dangerousCharactersPattern, '', $url);
}
/**
* Remove potential javascript in urls.
*
* @access public
* @param string url
*
* @return string filtered url
*/
public function removeJavascriptURL($str) {
$HTML_Sanitizer_stripJavascriptURL = 'javascript:[^"]+';
$str = preg_replace("/$HTML_Sanitizer_stripJavascriptURL/i", '__forbidden__', $str);
return $str;
}
/**
* Remove potential flaws in urls.
*
* @access private
* @param string url
*
* @return string filtered url
*/
private function sanitizeURL($url) {
if (!$this->_allowJavascriptInUrls) {
$url = $this->removeJavascriptURL($url);
} }
/** $url = $this->filterHTTPResponseSplitting($url);
* Allow DOM event on DOM elements
* @access public return $url;
*/ }
public function allowDOMEvents()
{ /**
$this->_allowDOMEvents = true; * Callback for PCRE.
*
* @access private
* @param matches array
*
* @return string
*
* @see sanitizeURL
*/
private function _sanitizeURLCallback($matches) {
return 'href="' . $this->sanitizeURL($matches[1]) . '"';
}
/**
* Remove potential flaws in href attributes.
*
* @access private
* @param string html tag
*
* @return string filtered html tag
*/
private function sanitizeHref($str) {
$HTML_Sanitizer_URL = 'href="([^"]+)"';
return preg_replace_callback("/$HTML_Sanitizer_URL/i", array(&$this, '_sanitizeURLCallback'), $str);
}
/**
* Callback for PCRE.
*
* @access private
* @param matches array
*
* @return string
*
* @see sanitizeURL
*/
private function _sanitizeSrcCallback($matches) {
return 'src="' . $this->sanitizeURL($matches[1]) . '"';
}
/**
* Remove potential flaws in href attributes.
*
* @access private
* @param string html tag
*
* @return string filtered html tag
*/
private function sanitizeSrc($str) {
$HTML_Sanitizer_URL = 'src="([^"]+)"';
return preg_replace_callback("/$HTML_Sanitizer_URL/i", array(&$this, '_sanitizeSrcCallback'), $str);
}
/**
* Remove dangerous attributes from html tags.
*
* @access private
* @param string html tag
*
* @return string filtered html tag
*/
private function removeEvilAttributes($str) {
if (!$this->_allowDOMEvents) {
$str = preg_replace_callback('/<(.*?)>/i', array(&$this, '_removeDOMEventsCallback'), $str);
} }
/** if (!$this->_allowStyle) {
* Allow script tags $str = preg_replace_callback('/<(.*?)>/i', array(&$this, '_removeStyleCallback'), $str);
* @access public
*/
public function allowScript()
{
$this->_allowScript = true;
} }
/** return $str;
* Allow the use of javascript: in urls }
* @access public
*/ /**
public function allowJavascriptInUrls() * Remove DOM events attributes from html tags.
{ *
$this->_allowJavascriptInUrls = true; * @access private
} * @param string html tag
*
/** * @return string filtered html tag
* Allow style tags and attributes */
* @access public private function removeDOMEvents($str) {
*/ $str = preg_replace('/\s*=\s*/', '=', $str);
public function allowStyle()
{ $HTML_Sanitizer_stripAttrib = '(onclick|ondblclick|onmousedown|'
$this->_allowStyle = true;
}
/**
* Helper to allow all javascript related tags and attributes
* @access public
*/
public function allowAllJavascript()
{
$this->allowDOMEvents();
$this->allowScript();
$this->allowJavascriptInUrls();
}
/**
* Allow all tags and attributes
* @access public
*/
public function allowAll()
{
$this->allowAllJavascript();
$this->allowObjects();
$this->allowStyle();
$this->allowIframes();
$this->allowHtml5Media();
}
/**
* Filter URLs to avoid HTTP response splitting attacks
* @access public
* @param string url
* @return string filtered url
*/
public function filterHTTPResponseSplitting( $url )
{
$dangerousCharactersPattern = '~(\r\n|\r|\n|%0a|%0d|%0D|%0A)~';
return preg_replace( $dangerousCharactersPattern, '', $url );
}
/**
* Remove potential javascript in urls
* @access public
* @param string url
* @return string filtered url
*/
public function removeJavascriptURL( $str )
{
$HTML_Sanitizer_stripJavascriptURL = 'javascript:[^"]+';
$str = preg_replace("/$HTML_Sanitizer_stripJavascriptURL/i"
, '__forbidden__'
, $str );
return $str;
}
/**
* Remove potential flaws in urls
* @access private
* @param string url
* @return string filtered url
*/
private function sanitizeURL( $url )
{
if ( ! $this->_allowJavascriptInUrls )
{
$url = $this->removeJavascriptURL( $url );
}
$url = $this->filterHTTPResponseSplitting( $url );
return $url;
}
/**
* Callback for PCRE
* @access private
* @param matches array
* @return string
* @see sanitizeURL
*/
private function _sanitizeURLCallback( $matches )
{
return 'href="'.$this->sanitizeURL( $matches[1] ).'"';
}
/**
* Remove potential flaws in href attributes
* @access private
* @param string html tag
* @return string filtered html tag
*/
private function sanitizeHref( $str )
{
$HTML_Sanitizer_URL = 'href="([^"]+)"';
return preg_replace_callback("/$HTML_Sanitizer_URL/i"
, array( &$this, '_sanitizeURLCallback' )
, $str );
}
/**
* Callback for PCRE
* @access private
* @param matches array
* @return string
* @see sanitizeURL
*/
private function _sanitizeSrcCallback( $matches )
{
return 'src="'.$this->sanitizeURL( $matches[1] ).'"';
}
/**
* Remove potential flaws in href attributes
* @access private
* @param string html tag
* @return string filtered html tag
*/
private function sanitizeSrc( $str )
{
$HTML_Sanitizer_URL = 'src="([^"]+)"';
return preg_replace_callback("/$HTML_Sanitizer_URL/i"
, array( &$this, '_sanitizeSrcCallback' )
, $str );
}
/**
* Remove dangerous attributes from html tags
* @access private
* @param string html tag
* @return string filtered html tag
*/
private function removeEvilAttributes( $str )
{
if ( ! $this->_allowDOMEvents )
{
$str = preg_replace_callback('/<(.*?)>/i'
, array( &$this, '_removeDOMEventsCallback' )
, $str );
}
if ( ! $this->_allowStyle )
{
$str = preg_replace_callback('/<(.*?)>/i'
, array( &$this, '_removeStyleCallback' )
, $str );
}
return $str;
}
/**
* Remove DOM events attributes from html tags
* @access private
* @param string html tag
* @return string filtered html tag
*/
private function removeDOMEvents( $str )
{
$str = preg_replace ( '/\s*=\s*/', '=', $str );
$HTML_Sanitizer_stripAttrib = '(onclick|ondblclick|onmousedown|'
. 'onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|' . 'onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|'
. 'onkeyup|onfocus|onblur|onabort|onerror|onload)' . 'onkeyup|onfocus|onblur|onabort|onerror|onload)';
;
$str = stripslashes(preg_replace("/$HTML_Sanitizer_stripAttrib/i", 'forbidden', $str));
$str = stripslashes( preg_replace("/$HTML_Sanitizer_stripAttrib/i"
, 'forbidden' return $str;
, $str ) ); }
return $str; /**
* Callback for PCRE.
*
* @access private
* @param matches array
*
* @return string
*
* @see removeDOMEvents
*/
private function _removeDOMEventsCallback($matches) {
return '<' . $this->removeDOMEvents($matches[1]) . '>';
}
/**
* Remove style attributes from html tags.
*
* @access private
* @param string html tag
*
* @return string filtered html tag
*/
private function removeStyle($str) {
$str = preg_replace('/\s*=\s*/', '=', $str);
$HTML_Sanitizer_stripAttrib = '(style)';
$str = stripslashes(preg_replace("/$HTML_Sanitizer_stripAttrib/i", 'forbidden', $str));
return $str;
}
/**
* Callback for PCRE.
*
* @access private
* @param matches array
*
* @return string
*
* @see removeStyle
*/
private function _removeStyleCallback($matches) {
return '<' . $this->removeStyle($matches[1]) . '>';
}
/**
* Remove dangerous HTML tags.
*
* @access private
* @param string html code
*
* @return string filtered url
*/
private function removeEvilTags($str) {
$allowedTags = $this->_allowedTags;
if ($this->_allowScript) {
$allowedTags .= '<script>';
} }
/** if ($this->_allowStyle) {
* Callback for PCRE $allowedTags .= '<style>';
* @access private
* @param matches array
* @return string
* @see removeDOMEvents
*/
private function _removeDOMEventsCallback( $matches )
{
return '<' . $this->removeDOMEvents( $matches[1] ) . '>';
}
/**
* Remove style attributes from html tags
* @access private
* @param string html tag
* @return string filtered html tag
*/
private function removeStyle( $str )
{
$str = preg_replace ( '/\s*=\s*/', '=', $str );
$HTML_Sanitizer_stripAttrib = '(style)'
;
$str = stripslashes( preg_replace("/$HTML_Sanitizer_stripAttrib/i"
, 'forbidden'
, $str ) );
return $str;
} }
/** if ($this->_allowObjects) {
* Callback for PCRE $allowedTags .= '<object><embed><applet><param>';
* @access private
* @param matches array
* @return string
* @see removeStyle
*/
private function _removeStyleCallback( $matches )
{
return '<' . $this->removeStyle( $matches[1] ) . '>';
} }
/** $allowedTags .= $this->_additionalTags;
* Remove dangerous HTML tags
* @access private
* @param string html code
* @return string filtered url
*/
private function removeEvilTags( $str )
{
$allowedTags = $this->_allowedTags;
if ( $this->_allowScript )
{
$allowedTags .= '<script>';
}
if ( $this->_allowStyle )
{
$allowedTags .= '<style>';
}
if ( $this->_allowObjects )
{
$allowedTags .= '<object><embed><applet><param>';
}
$allowedTags .= $this->_additionalTags; $str = strip_tags($str, $allowedTags);
$str = strip_tags($str, $allowedTags ); return $str;
}
return $str; /**
} * Sanitize HTML
* remove dangerous tags and attributes
* clean urls.
*
* @access public
* @param string html code
*
* @return string sanitized html code
*/
public function sanitize($html) {
$html = $this->removeEvilTags($html);
/** $html = $this->removeEvilAttributes($html);
* Sanitize HTML
* remove dangerous tags and attributes
* clean urls
* @access public
* @param string html code
* @return string sanitized html code
*/
public function sanitize( $html )
{
$html = $this->removeEvilTags( $html );
$html = $this->removeEvilAttributes( $html ); $html = $this->sanitizeHref($html);
$html = $this->sanitizeHref( $html ); $html = $this->sanitizeSrc($html);
$html = $this->sanitizeSrc( $html ); return $html;
}
return $html;
}
} }
function html_sanitize( $str ) /**
{ *
static $san = null; */
function html_sanitize($str) {
static $san = NULL;
if ( empty( $san ) ) if (empty($san)) {
{ $san = new HTML_Sanitizer();
$san = new HTML_Sanitizer; }
}
return $san->sanitize( $str ); return $san->sanitize($str);
} }
function html_loose_sanitize( $str ) /**
{ *
static $san = null; */
function html_loose_sanitize($str) {
static $san = NULL;
if ( empty( $san ) ) if (empty($san)) {
{ $san = new HTML_Sanitizer();
$san = new HTML_Sanitizer; $san->allowAll();
$san->allowAll(); }
}
return $san->sanitize( $str ); return $san->sanitize($str);
} }

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

@ -5,7 +5,7 @@
* Displays the advanced search form. * Displays the advanced search form.
* *
* @see template_preprocess_ebsco_advanced_search() * @see template_preprocess_ebsco_advanced_search()
* *
* *
* Copyright [2017] [EBSCO Information Services] * Copyright [2017] [EBSCO Information Services]
* *
@ -51,7 +51,6 @@
<option value="Abstract">Abstract</option> <option value="Abstract">Abstract</option>
<option value="ISBN">ISBN</option> <option value="ISBN">ISBN</option>
<option value="ISSN">ISSN</option> <option value="ISSN">ISSN</option>
</select> </select>
</div> </div>
<div class="delete-search"> <div class="delete-search">

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

@ -5,7 +5,7 @@
* 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 [2017] [EBSCO Information Services] * Copyright [2017] [EBSCO Information Services]
* *
@ -25,16 +25,16 @@
<div class="container-inline"> <div class="container-inline">
<?php <?php
if ($search_view == 'basic'){ if ($search_view == 'basic'){
echo $search_form; echo $search_form;
} }
elseif ($search_view == 'advanced'){ elseif ($search_view == 'advanced'){
echo '<a href="'.url('ebsco/advanced', array('query' => array('edit' => 1))).'" class="small">'.t('Edit this Advanced Search')."</a> |"; echo '<a href="' . url('ebsco/advanced', array('query' => array('edit' => 1))) . '" class="small">' . t('Edit this Advanced Search') . "</a> |";
echo '<a href="'.url('ebsco/advanced').'" class="small">'.t('Start a new Advanced Search').'</a> |'; echo '<a href="' . url('ebsco/advanced') . '" class="small">' . t('Start a new Advanced Search') . '</a> |';
echo '<a href="'.url('ebsco/results').'" class="small">'.t('Start a new Basic Search').'</a>'; echo '<a href="' . url('ebsco/results') . '" class="small">' . t('Start a new Basic Search') . '</a>';
echo "<br/>"; echo "<br/>";
echo t('Your search terms').": <strong>".check_plain($lookfor); "</strong>"; echo t('Your search terms') . ": <strong>" . check_plain($lookfor); "</strong>";
} }
?> ?>
</div> </div>

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

@ -5,7 +5,7 @@
* 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 [2017] [EBSCO Information Services] * Copyright [2017] [EBSCO Information Services]
* *
@ -24,137 +24,137 @@
?> ?>
<?php <?php
if ($record) { if ($record) {
$id = check_plain($record->record_id()); $id = check_plain($record->record_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)));
?> ?>
<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 <?php
if ($last_search){ if ($last_search){
?> ?>
<div class="floatright"> <div class="floatright">
<?php <?php
if ($last_search['previous']){ if ($last_search['previous']){
echo '<a href="'.url('ebsco/result', array('query' => array('id' => $last_search['previous'], 'op' => 'Previous'))).'" class="_record_link">&laquo; '.t('Previous').'</a>'; echo '<a href="' . url('ebsco/result', array('query' => array('id' => $last_search['previous'], 'op' => 'Previous'))) . '" class="_record_link">&laquo; ' . t('Previous') . '</a>';
} }
echo "#"; echo "#";
print $last_search['current_index']; ?> of <?php print $last_search['count']; print $last_search['current_index']; ?> of <?php print $last_search['count'];
if ($last_search['next']){ if ($last_search['next']){
echo '<a href="'.url('ebsco/result', array('query' => array('id' => $last_search['next'], 'op' => 'Next'))).'" class="_record_link">'.t('Next').' &raquo;</a>'; echo '<a href="' . url('ebsco/result', array('query' => array('id' => $last_search['next'], 'op' => 'Next'))) . '" class="_record_link">' . t('Next') . ' &raquo;</a>';
} }
?> ?>
</div> </div>
<div class="floatleft"> <div class="floatleft">
<a href="<?php print "?{$last_search['query']}"; ?>"> <a href="<?php print "?{$last_search['query']}"; ?>">
&laquo; <?php print t('Back to Results list'); ?> &laquo; <?php print t('Back to Results list'); ?>
</a> </a>
</div> </div>
<div class="clear"></div> <div class="clear"></div>
<?php <?php
} }
?> ?>
</div> </div>
<div class="span-5"> <div class="span-5">
<ul class="external-links"> <ul class="external-links">
<?php <?php
if($record->p_link){ if($record->p_link){
echo "<li> <a href='".$record->p_link."'>".t('View in EDS')."</a></li>"; echo "<li> <a href='" . $record->p_link . "'>" . t('View in EDS') . "</a></li>";
} }
if ($record->pdf_link){ if ($record->pdf_link){
echo ' echo '
<li> <li>
<a href="'.$pdfUrl.'" class="icon pdf fulltext">'.t('PDF full text').'</a> <a href="' . $pdfUrl . '" class="icon pdf fulltext">' . t('PDF full text') . '</a>
</li>'; </li>';
} }
if ($record->full_text_availability){ if ($record->full_text_availability){
echo ' echo '
<li> <li>
<a href="'.( (!user_is_logged_in())?$fulltextUrl:"").'#html" class="icon html fulltext">'.t('HTML full text').'</a> <a href="' . ((!user_is_logged_in()) ? $fulltextUrl : "") . '#html" class="icon html fulltext">' . t('HTML full text') . '</a>
</li>'; </li>';
} }
if (!empty($record->custom_links)){ if (!empty($record->custom_links)){
foreach ($record->custom_links as $link){ foreach ($record->custom_links as $link){
echo ' echo '
<li> <li>
<a href="'.$link['Url'].'" target="_blank" title="'.$link['MouseOverText'].'" class="external-link">'. ($link['Icon'])? '<img src="'.$link['Icon'].'" />':''.$link['Name'].'</a> <a href="' . $link['Url'] . '" target="_blank" title="' . $link['MouseOverText'] . '" class="external-link">' . ($link['Icon']) ? '<img src="' . $link['Icon'] . '" />' : '' . $link['Name'] . '</a>
</li>'; </li>';
} }
} }
?> ?>
</ul> </ul>
</div> </div>
<div class="span-13"> <div class="span-13">
<table cellpadding="2" cellspacing="0" border="0" class="citation" summary="<?php print t('Bibliographic Details'); ?>"> <table cellpadding="2" cellspacing="0" border="0" class="citation" summary="<?php print t('Bibliographic Details'); ?>">
<?php <?php
foreach ($record->items as $item){ foreach ($record->items as $item){
if (!empty($item['Data'])){ if (!empty($item['Data'])){
echo ' echo '
<tr valign="top"> <tr valign="top">
<th width="150">'.t($item['Label']).':</th> <th width="150">' . t($item['Label']) . ':</th>
<td>'.auto_link($item['Data']).'</td> <td>' . auto_link($item['Data']) . '</td>
</tr>'; </tr>';
} }
} }
if ($record->db_label){ if ($record->db_label){
echo ' echo '
<tr valign="top"> <tr valign="top">
<th width="150">'.t('Database').':</th><td>'.check_plain($record->db_label).'</td> <th width="150">' . t('Database') . ':</th><td>' . check_plain($record->db_label) . '</td>
</tr>'; </tr>';
} }
if ($record->full_text){ if ($record->full_text){
echo ' echo '
<tr id="html" valign="top"> <tr id="html" valign="top">
<td colspan="2" class="html">'.$record->full_text.'</td> <td colspan="2" class="html">' . $record->full_text . '</td>
</tr>'; </tr>';
} }
elseif ($record->access_level && !user_is_logged_in()){ elseif ($record->access_level && !user_is_logged_in()){
echo ' echo '
<tr id="html" valign="top"> <tr id="html" valign="top">
<td colspan="2" class="html"> <td colspan="2" class="html">
<p>'.t('The full text cannot be displayed to guests.').'<br />.'; <p>' . t('The full text cannot be displayed to guests.') . '<br />.';
$link = '<a href="' . url('user') . '">' . t('Login') . '</a>'; $link = '<a href="' . url('user') . '">' . t('Login') . '</a>';
echo '<strong>'.sprintf(t('%s for full access.'), $link).'</strong> echo '<strong>' . sprintf(t('%s for full access.'), $link) . '</strong>
</p> </p>
</td> </td>
</tr> </tr>
'; ';
} }
?> ?>
</table> </table>
</div> </div>
<div class="span-4"> <div class="span-4">
<?php <?php
if ($record->medium_thumb_link){ if ($record->medium_thumb_link){
echo '<img src="'.check_url($record->medium_thumb_link).'" class="book-jacket" alt="'.t('Book jacket').'"/>'; echo '<img src="' . check_url($record->medium_thumb_link) . '" class="book-jacket" alt="' . t('Book jacket') . '"/>';
} }
if ($record->publication_type){ if ($record->publication_type){
echo '<p>'. check_plain($record->publication_type).'</p>'; echo '<p>' . check_plain($record->publication_type) . '</p>';
} }
?> ?>
</div> </div>
<div class="clear"></div> <div class="clear"></div>
</div> </div>
<?php <?php
} }
?> ?>
<div id="spinner" class="spinner"></div> <div id="spinner" class="spinner"></div>

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

@ -5,7 +5,7 @@
* 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 [2017] [EBSCO Information Services] * Copyright [2017] [EBSCO Information Services]
* *
@ -22,337 +22,338 @@
* limitations under the License. * limitations under the License.
*/ */
if (isset($autoSuggestTerms)) {
if (count($autoSuggestTerms) > 0) {
$suggestString = "";
foreach ($autoSuggestTerms as $term) {
$path = url('ebsco/results', array('query' => array('type' => "")));
$suggestString .= "<a href=\"{$path}&lookfor=$term\">" . $term . "</a> ";
}
echo "<p><strong>Did you mean " . $suggestString . "?</strong></p>";
}
}
if ($records){
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>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<div id="relatedInformation" class="carousel slide" data-ride="carousel" style="display:block;">
<!-- Indicators -->
<ol class="carousel-indicators">' . $tabs . '</ol>';
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>';
if (isset ($autoSuggestTerms) ) { }
if (count($autoSuggestTerms)>0) {
$suggestString="";
foreach ($autoSuggestTerms as $term ) {
$path = url('ebsco/results', array('query' => array('type' => "")));
$suggestString.="<a href=\"{$path}&lookfor=$term\">".$term."</a> ";
}
echo "<p><strong>Did you mean ".$suggestString."?</strong></p>";
}
}
if ($records){
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>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<div id="relatedInformation" class="carousel slide" data-ride="carousel" style="display:block;">
<!-- Indicators -->
<ol class="carousel-indicators">'.$tabs.'</ol>';
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">
<?php foreach ($records as $record):
$id = check_plain($record->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)));
<ol class="search-results ebsco">
<?php foreach ($records as $record):
$id = check_plain($record->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)));
?>
<li>
<div class="record-number floatleft">
<?php print $record->result_id; ?>
</div>
<div class="result floatleft">
<div class="span-2">
<?php
if ($record->small_thumb_link){
echo '
<a href="' . $recordUrl . '" class="_record_link">
<img src="' . $record->small_thumb_link . '" class="book-jacket" alt="' . t('Book jacket') . '"/>
</a>';
}
?> ?>
<li> </div>
<div class="record-number floatleft">
<?php print $record->result_id; ?> <div class="span-9">
</div> <div class="result-line1">
<?php
<div class="result floatleft">
<div class="span-2"> if ($record->access_level == '1'){
<?php echo '<p>';
if ($record->small_thumb_link){ $label = '<strong>' . check_plain($record->db_label) . '</strong>';
echo' $link = '<a href="' . url('user') . '">' . t('Login') . '</a>';
<a href="'.$recordUrl.'" class="_record_link"> echo sprintf(t('This result from %s cannot be displayed to guests.'), $label) . "<br /><strong>" . sprintf(t('%s for full access.'), $link) . "</strong>";
<img src="'.$record->small_thumb_link.'" class="book-jacket" alt="'.t('Book jacket').'"/> echo "</p>";
</a>'; }
} elseif ($record->title){
?> echo '<a href="' . $recordUrl . '" class="title _record_link">' . $record->title . '</a>';
</div> }
?>
<div class="span-9"> </div>
<div class="result-line1">
<?php <div class="result-line2">
<?php
if ($record->access_level == '1'){ if (!empty($record->authors)){
echo '<p>'; echo "<span>" . t('by') . " " . str_replace(array("<br>", "<br />"), ', ', $record->authors) . " </span>";
$label = '<strong>' . check_plain($record->db_label) . '</strong>'; }
$link = '<a href="' . url('user') . '">' . t('Login') . '</a>';
echo sprintf(t('This result from %s cannot be displayed to guests.'), $label)."<br /><strong>".sprintf(t('%s for full access.'), $link)."</strong>"; if (!empty($record->source)){
echo "</p>"; echo '<p>' . t('Published in') . " " . $record->source . '</p>';
} }
elseif ($record->title){
echo '<a href="'.$recordUrl.'" class="title _record_link">'.$record->title.'</a>'; ?>
} </div>
?>
</div> <div class="result-line3">
<?php
<div class="result-line2">
<?php if (!empty($record->summary)){
if (!empty($record->authors)){ echo '<cite>' . $record->summary . '</cite><br />';
echo "<span>".t('by'). " ".str_replace(array("<br>","<br />"), ', ', $record->authors)." </span>"; }
}
if (!empty($record->subjects)){
if (!empty($record->source)){ echo '<strong>' . t('Subjects') . '</strong>:<span class="quotestart">' . str_replace('<br />', ', ', $record->subjects) . '</span>';
echo '<p>'.t('Published in')." ".$record->source.'</p>'; }
}
?>
?> </div>
</div>
<?php
<div class="result-line3"> if (!empty($record->custom_links)){
<?php ?>
<div class="result-line4">
if (!empty($record->summary)){ <ul class="custom-links">
echo '<cite>'.$record->summary.'</cite><br />'; <?php
} foreach ($record->custom_links as $link){ ?>
<li>
if (!empty($record->subjects)){ <a href="<?php print $link['Url']; ?>" target="_blank" title="<?php print $link['MouseOverText']; ?>" class="external-link">
echo '<strong>'.t('Subjects').'</strong>:<span class="quotestart">'.str_replace('<br />', ', ', $record->subjects).'</span>'; <?php if ($link['Icon']): ?><img src="<?php print $link['Icon']?>" /><?php
} endif; ?><?php print $link['Name']; ?>
</a>
?> </li>
</div> <?php } ?>
</ul>
<?php
if (!empty($record->custom_links)){
?>
<div class="result-line4">
<ul class="custom-links">
<?php
foreach ($record->custom_links as $link){ ?>
<li>
<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']; ?>
</a>
</li>
<?php } ?>
</ul>
</div>
<?php } ?>
<div class="result-line5">
<?php
if ($record->full_text_availability){
echo '<a href="'.$fulltextUrl.'#html" class="icon html fulltext _record_link">';
echo t('HTML full text');
echo "</a>&nbsp; &nbsp;";
}
if ($record->pdf_availability){
echo ' <a href="'.$pdfUrl.'" class="icon pdf fulltext">';
echo t('PDF full text');
echo "</a>";
}
?>
</div>
</div>
</div> </div>
<div class="clear"></div> <?php } ?>
</li>
<?php endforeach; ?> <div class="result-line5">
<?php
if ($record->full_text_availability){
echo '<a href="' . $fulltextUrl . '#html" class="icon html fulltext _record_link">';
echo t('HTML full text');
echo "</a>&nbsp; &nbsp;";
}
if ($record->pdf_availability){
echo ' <a href="' . $pdfUrl . '" class="icon pdf fulltext">';
echo t('PDF full text');
echo "</a>";
}
?>
</div>
</div>
</div>
<div class="clear"></div>
</li>
<?php endforeach; ?>
</ol> </ol>
<?php print $pager; ?> <?php print $pager; ?>
<?php <?php
} }
elseif (!empty($lookfor)) { elseif (!empty($lookfor)) {
echo "<h2>".t('Your search did not match any resources.')."</h2>"; echo "<h2>" . t('Your search did not match any resources.') . "</h2>";
// check for autocomplete // Check for autocomplete.
/* /*
if (isset ($autoSuggestTerms) ) { if (isset ($autoSuggestTerms) ) {
if (count($autoSuggestTerms)>0) { if (count($autoSuggestTerms)>0) {
echo "Did you mean "."?<br/>"; echo "Did you mean "."?<br/>";
var_dump($autoSuggestTerms); var_dump($autoSuggestTerms);
} }
} }
*/ */
echo search_help('search#noresults', drupal_help_arg()); echo search_help('search#noresults', drupal_help_arg());
} }
?> ?>
<div id="spinner" class="spinner"></div> <div id="spinner" class="spinner"></div>

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

@ -2,7 +2,7 @@
/** /**
* @file * @file
* Display the sidebar block with facets filters * Display the sidebar block with facets filters.
* *
* @see template_preprocess_ebsco_side_facets() * @see template_preprocess_ebsco_side_facets()
* *

Loading…
Cancel
Save