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. 517
      ebsco/css/ebsco.css
  2. 2
      ebsco/ebsco.info
  3. 1644
      ebsco/ebsco.module
  4. 18
      ebsco/js/ebsco.js
  5. 1249
      ebsco/lib/EBSCOAPI.php
  6. 933
      ebsco/lib/EBSCOConnector.php
  7. 1669
      ebsco/lib/EBSCODocument.php
  8. 738
      ebsco/lib/EBSCORecord.php
  9. 1093
      ebsco/lib/EBSCOResponse.php
  10. 826
      ebsco/lib/sanitizer.class.php
  11. 7
      ebsco/templates/ebsco-advanced-search.tpl.php
  12. 30
      ebsco/templates/ebsco-basic-search.tpl.php
  13. 262
      ebsco/templates/ebsco-result.tpl.php
  14. 651
      ebsco/templates/ebsco-results.tpl.php
  15. 6
      ebsco/templates/ebsco-side-facets.tpl.php

517
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]
* *
@ -9,104 +9,104 @@
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
@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 /* Changes the position of the indicators */
{ #quote-carousel .carousel-indicators {
right: -12px !important; right: 50%;
} top: auto;
/* Changes the position of the indicators */ bottom: 0px;
#quote-carousel .carousel-indicators margin-right: -19px;
{ }
right: 50%; /* Changes the color of the indicators */
top: auto; #quote-carousel .carousel-indicators li {
bottom: 0px; background: #c0c0c0;
margin-right: -19px; }
} #quote-carousel .carousel-indicators .active {
/* Changes the color of the indicators */ background: #333333;
#quote-carousel .carousel-indicators li }
{ #quote-carousel img {
background: #c0c0c0; width: 250px;
} height: 100px
#quote-carousel .carousel-indicators .active }
{ /* End carousel */
background: #333333;
} .item blockquote {
#quote-carousel img border-left: none;
{ margin: 0;
width: 250px; }
height: 100px
} .item blockquote img {
/* End carousel */ margin-bottom: 10px;
}
.item blockquote {
border-left: none; .item blockquote p:before {
margin: 0; content: "\f10d";
} font-family: 'Fontawesome';
float: left;
.item blockquote img { margin-right: 10px;
margin-bottom: 10px; }
}
#relatedInformation img {
.item blockquote p:before { padding-right: 10px;
content: "\f10d"; }
font-family: 'Fontawesome'; .glyphicon {
float: left; position: relative;
margin-right: 10px; top: 1px;
} display: inline-block;
font-family: 'Glyphicons Halflings';
#relatedInformation img { padding-right :10px;} font-style: normal;
font-weight: 400;
.glyphicon { line-height: 1;
position: relative; -webkit-font-smoothing: antialiased;
top: 1px; -moz-osx-font-smoothing: grayscale;
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 { .carousel-control .glyphicon-chevron-right {
position: absolute; position: absolute;
top: 50%; top: 50%;
z-index: 5; z-index: 5;
display: inline-block; display: inline-block;
}
.carousel-control.left span,
.carousel-control.right span {
background-color: #000;
} }
.carousel-control.left span, .carousel-control.right span {
background-color: #000;
}
h3.relatedTitle a{ h3.relatedTitle a {
font-size:24px; font-size: 24px;
} }
/* */ /* */

2
ebsco/ebsco.info

@ -5,4 +5,4 @@ core = 7.x
configure = admin/config/search/ebsco configure = admin/config/search/ebsco
stylesheets[screen][] = css/ebsco.css stylesheets[screen][] = css/ebsco.css
scripts[] = js/ebsco.js scripts[] = js/ebsco.js

1644
ebsco/ebsco.module

File diff suppressed because it is too large Load Diff

18
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]
* *
@ -9,17 +9,16 @@
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
**/ */
(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) {
@ -165,7 +163,7 @@
// Retain search filters checkbox functionality // Retain search filters checkbox functionality
$('#edit-remember').live('click', function (event) { $('#edit-remember').live('click', function (event) {
$("#ebsco-basic-search-form :input[type='checkbox'][name^='filter[']").attr('checked', $(this).attr('checked')); $("#ebsco-basic-search-form :input[type='checkbox'][name^='filter[']").attr('checked', $(this).attr('checked'));
}); });
// Advanced Search : handle 'Date Published from' limiter // Advanced Search : handle 'Date Published from' limiter
// Create the UI slider (if slider function is defined) // Create the UI slider (if slider function is defined)

1249
ebsco/lib/EBSCOAPI.php

File diff suppressed because it is too large Load Diff

933
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]
* *
@ -12,246 +13,257 @@
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
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.
*
* @param array $params
* Retrieve specific parameters.
* @param array $headers
* Authentication and session tokens.
*
* @return object SimpleXml or PEAR_Error
*
* @access public
*/
public function requestRetrieve($params, $headers) {
$url = self::$end_point . '/Retrieve';
$response = $this->request($url, $params, $headers);
return $response;
}
/**
* Request the info data.
*
* @param null $params
* Not used.
* @param array $headers
* Authentication and session tokens.
*
* @return object SimpleXml or PEAR_Error
*
* @access public
*/
public function requestInfo($params, $headers) {
$url = self::$end_point . '/Info';
$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(
* Request a specific record array('Accept-Encoding' => 'gzip,deflate'),
* $headers
* @param array $params Retrieve specific parameters );
* @param array $headers Authentication and session tokens
* $options = array(
* @return object SimpleXml or PEAR_Error 'headers' => $headers,
* @access public 'method' => $method,
*/ 'data' => $data,
public function requestRetrieve($params, $headers) );
{
$url = self::$end_point . '/Retrieve'; // Send the request.
try {
$response = $this->request($url, $params, $headers); $response = drupal_http_request($url, $options);
return $response; // print_r($url);
} // print_r($response);
$code = $response->code;
if (isset($response->headers['content-encoding'])) {
/** if ($response->headers['content-encoding'] == 'gzip') {
* Request the info data $response->data = gzinflate(substr($response->data, 10));
*
* @param null $params Not used
* @param array $headers Authentication and session tokens
*
* @return object SimpleXml or PEAR_Error
* @access public
*/
public function requestInfo($params, $headers)
{
$url = self::$end_point . '/Info';
$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
);
}
} }
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();
}
} }
?>

1669
ebsco/lib/EBSCODocument.php

File diff suppressed because it is too large Load Diff

738
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]
* *
@ -13,7 +13,7 @@
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -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']) &&
/** isset($this->data['FullText']['Links']) &&
* Get the PDF availability of the record. isset($this->data['FullText']['Links']['pdflink']) &&
*
* @return boolean
*/
public function pdf_availability()
{
return isset($this->data['FullText']) &&
isset($this->data['FullText']['Links']) &&
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']) &&
{ isset($this->data['FullText']['Links']) &&
return isset($this->data['FullText']) && isset($this->data['FullText']['Links']['pdflink']) ?
isset($this->data['FullText']['Links']) &&
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'] : '';
} }
} }

1093
ebsco/lib/EBSCOResponse.php

File diff suppressed because it is too large Load Diff

826
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 = '';
}
/**
* Add additional tags to allowed tags
* @param string
* @access public
*/
public function addAdditionalTags( $tags )
{
$this->_additionalTags .= $tags;
}
/** $this->_additionalTags = '';
* Allow iframes }
* @access public
*/
public function allowIframes()
{
$this->addAdditionalTags( '<iframe>' );
}
/** /**
* Allow HTML5 media tags * Add additional tags to allowed tags.
* @access public *
*/ * @param string
public function allowHtml5Media() *
{ * @access public
$this->addAdditionalTags( '<canvas><video><audio>' ); */
} public function addAdditionalTags($tags) {
$this->_additionalTags .= $tags;
}
/** /**
* Allow object, embed, applet and param tags in html * Allow iframes.
* @access public *
*/ * @access public
public function allowObjects() */
{ public function allowIframes() {
$this->_allowObjects = true; $this->addAdditionalTags('<iframe>');
} }
/** /**
* Allow DOM event on DOM elements * Allow HTML5 media tags.
* @access public *
*/ * @access public
public function allowDOMEvents() */
{ public function allowHtml5Media() {
$this->_allowDOMEvents = true; $this->addAdditionalTags('<canvas><video><audio>');
} }
/** /**
* Allow script tags * Allow object, embed, applet and param tags in html.
* @access public *
*/ * @access public
public function allowScript() */
{ public function allowObjects() {
$this->_allowScript = true; $this->_allowObjects = TRUE;
} }
/** /**
* Allow the use of javascript: in urls * Allow DOM event on DOM elements.
* @access public *
*/ * @access public
public function allowJavascriptInUrls() */
{ public function allowDOMEvents() {
$this->_allowJavascriptInUrls = true; $this->_allowDOMEvents = TRUE;
} }
/** /**
* Allow style tags and attributes * Allow script tags.
* @access public *
*/ * @access public
public function allowStyle() */
{ public function allowScript() {
$this->_allowStyle = true; $this->_allowScript = TRUE;
} }
/** /**
* Helper to allow all javascript related tags and attributes * Allow the use of javascript: in urls.
* @access public *
*/ * @access public
public function allowAllJavascript() */
{ public function allowJavascriptInUrls() {
$this->allowDOMEvents(); $this->_allowJavascriptInUrls = TRUE;
$this->allowScript(); }
$this->allowJavascriptInUrls();
} /**
* Allow style tags and attributes.
/** *
* Allow all tags and attributes * @access public
* @access public */
*/ public function allowStyle() {
public function allowAll() $this->_allowStyle = TRUE;
{ }
$this->allowAllJavascript();
$this->allowObjects(); /**
$this->allowStyle(); * Helper to allow all javascript related tags and attributes.
$this->allowIframes(); *
$this->allowHtml5Media(); * @access public
} */
public function allowAllJavascript() {
/** $this->allowDOMEvents();
* Filter URLs to avoid HTTP response splitting attacks $this->allowScript();
* @access public $this->allowJavascriptInUrls();
* @param string url }
* @return string filtered url
*/ /**
public function filterHTTPResponseSplitting( $url ) * Allow all tags and attributes.
{ *
$dangerousCharactersPattern = '~(\r\n|\r|\n|%0a|%0d|%0D|%0A)~'; * @access public
return preg_replace( $dangerousCharactersPattern, '', $url ); */
} public function allowAll() {
$this->allowAllJavascript();
/** $this->allowObjects();
* Remove potential javascript in urls $this->allowStyle();
* @access public $this->allowIframes();
* @param string url $this->allowHtml5Media();
* @return string filtered url }
*/
public function removeJavascriptURL( $str ) /**
{ * Filter URLs to avoid HTTP response splitting attacks.
$HTML_Sanitizer_stripJavascriptURL = 'javascript:[^"]+'; *
* @access public
$str = preg_replace("/$HTML_Sanitizer_stripJavascriptURL/i" * @param string url
, '__forbidden__' *
, $str ); * @return string filtered url
*/
return $str; public function filterHTTPResponseSplitting($url) {
} $dangerousCharactersPattern = '~(\r\n|\r|\n|%0a|%0d|%0D|%0A)~';
return preg_replace($dangerousCharactersPattern, '', $url);
/** }
* Remove potential flaws in urls
* @access private /**
* @param string url * Remove potential javascript in urls.
* @return string filtered url *
*/ * @access public
private function sanitizeURL( $url ) * @param string url
{ *
if ( ! $this->_allowJavascriptInUrls ) * @return string filtered url
{ */
$url = $this->removeJavascriptURL( $url ); public function removeJavascriptURL($str) {
} $HTML_Sanitizer_stripJavascriptURL = 'javascript:[^"]+';
$url = $this->filterHTTPResponseSplitting( $url ); $str = preg_replace("/$HTML_Sanitizer_stripJavascriptURL/i", '__forbidden__', $str);
return $url; return $str;
} }
/** /**
* Callback for PCRE * Remove potential flaws in urls.
* @access private *
* @param matches array * @access private
* @return string * @param string url
* @see sanitizeURL *
*/ * @return string filtered url
private function _sanitizeURLCallback( $matches ) */
{ private function sanitizeURL($url) {
return 'href="'.$this->sanitizeURL( $matches[1] ).'"'; if (!$this->_allowJavascriptInUrls) {
} $url = $this->removeJavascriptURL($url);
/**
* 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] ).'"';
} }
/** $url = $this->filterHTTPResponseSplitting($url);
* Remove potential flaws in href attributes
* @access private return $url;
* @param string html tag }
* @return string filtered html tag
*/ /**
private function sanitizeSrc( $str ) * Callback for PCRE.
{ *
$HTML_Sanitizer_URL = 'src="([^"]+)"'; * @access private
* @param matches array
return preg_replace_callback("/$HTML_Sanitizer_URL/i" *
, array( &$this, '_sanitizeSrcCallback' ) * @return string
, $str ); *
* @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) {
* Remove dangerous attributes from html tags $str = preg_replace_callback('/<(.*?)>/i', array(&$this, '_removeStyleCallback'), $str);
* @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;
} }
/** return $str;
* Remove DOM events attributes from html tags }
* @access private
* @param string html tag /**
* @return string filtered html tag * Remove DOM events attributes from html tags.
*/ *
private function removeDOMEvents( $str ) * @access private
{ * @param string html tag
$str = preg_replace ( '/\s*=\s*/', '=', $str ); *
* @return string filtered html tag
$HTML_Sanitizer_stripAttrib = '(onclick|ondblclick|onmousedown|' */
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" $str = stripslashes(preg_replace("/$HTML_Sanitizer_stripAttrib/i", 'forbidden', $str));
, 'forbidden'
, $str ) );
return $str; return $str;
} }
/** /**
* Callback for PCRE * Callback for PCRE.
* @access private *
* @param matches array * @access private
* @return string * @param matches array
* @see removeDOMEvents *
*/ * @return string
private function _removeDOMEventsCallback( $matches ) *
{ * @see removeDOMEvents
return '<' . $this->removeDOMEvents( $matches[1] ) . '>'; */
} private function _removeDOMEventsCallback($matches) {
return '<' . $this->removeDOMEvents($matches[1]) . '>';
/** }
* Remove style attributes from html tags
* @access private /**
* @param string html tag * Remove style attributes from html tags.
* @return string filtered html tag *
*/ * @access private
private function removeStyle( $str ) * @param string html tag
{ *
$str = preg_replace ( '/\s*=\s*/', '=', $str ); * @return string filtered html tag
*/
$HTML_Sanitizer_stripAttrib = '(style)' private function removeStyle($str) {
; $str = preg_replace('/\s*=\s*/', '=', $str);
$str = stripslashes( preg_replace("/$HTML_Sanitizer_stripAttrib/i" $HTML_Sanitizer_stripAttrib = '(style)';
, 'forbidden'
, $str ) ); $str = stripslashes(preg_replace("/$HTML_Sanitizer_stripAttrib/i", 'forbidden', $str));
return $str; return $str;
} }
/** /**
* Callback for PCRE * Callback for PCRE.
* @access private *
* @param matches array * @access private
* @return string * @param matches array
* @see removeStyle *
*/ * @return string
private function _removeStyleCallback( $matches ) *
{ * @see removeStyle
return '<' . $this->removeStyle( $matches[1] ) . '>'; */
} private function _removeStyleCallback($matches) {
return '<' . $this->removeStyle($matches[1]) . '>';
/** }
* Remove dangerous HTML tags
* @access private /**
* @param string html code * Remove dangerous HTML tags.
* @return string filtered url *
*/ * @access private
private function removeEvilTags( $str ) * @param string html code
{ *
$allowedTags = $this->_allowedTags; * @return string filtered url
*/
if ( $this->_allowScript ) private function removeEvilTags($str) {
{ $allowedTags = $this->_allowedTags;
$allowedTags .= '<script>';
} 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 );
return $str;
} }
/** if ($this->_allowStyle) {
* Sanitize HTML $allowedTags .= '<style>';
* 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->sanitizeSrc( $html );
return $html;
} }
}
function html_sanitize( $str ) if ($this->_allowObjects) {
{ $allowedTags .= '<object><embed><applet><param>';
static $san = null;
if ( empty( $san ) )
{
$san = new HTML_Sanitizer;
} }
return $san->sanitize( $str ); $allowedTags .= $this->_additionalTags;
$str = strip_tags($str, $allowedTags);
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);
$html = $this->sanitizeHref($html);
$html = $this->sanitizeSrc($html);
return $html;
}
} }
function html_loose_sanitize( $str ) /**
{ *
static $san = null; */
function html_sanitize($str) {
if ( empty( $san ) ) static $san = NULL;
{
$san = new HTML_Sanitizer; if (empty($san)) {
$san->allowAll(); $san = new HTML_Sanitizer();
} }
return $san->sanitize( $str );
return $san->sanitize($str);
} }
/**
*
*/
function html_loose_sanitize($str) {
static $san = NULL;
if (empty($san)) {
$san = new HTML_Sanitizer();
$san->allowAll();
}
return $san->sanitize($str);
}

7
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]
* *
@ -14,7 +14,7 @@
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -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">
@ -61,4 +60,4 @@
</div> </div>
</div> </div>
</fieldset> </fieldset>
</div> </div>

30
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]
* *
@ -14,7 +14,7 @@
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -24,17 +24,17 @@
?> ?>
<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>

262
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]
* *
@ -14,7 +14,7 @@
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -23,138 +23,138 @@
*/ */
?> ?>
<?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>

651
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]
* *
@ -14,7 +14,7 @@
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -22,337 +22,338 @@
* limitations under the License. * limitations under the License.
*/ */
if (isset($autoSuggestTerms)) {
if (isset ($autoSuggestTerms) ) { if (count($autoSuggestTerms) > 0) {
if (count($autoSuggestTerms)>0) { $suggestString = "";
$suggestString=""; foreach ($autoSuggestTerms as $term) {
foreach ($autoSuggestTerms as $term ) { $path = url('ebsco/results', array('query' => array('type' => "")));
$path = url('ebsco/results', array('query' => array('type' => ""))); $suggestString .= "<a href=\"{$path}&lookfor=$term\">" . $term . "</a> ";
$suggestString.="<a href=\"{$path}&lookfor=$term\">".$term."</a> "; }
} echo "<p><strong>Did you mean " . $suggestString . "?</strong></p>";
echo "<p><strong>Did you mean ".$suggestString."?</strong></p>"; }
} }
}
if ($records){
if ($records){
echo t('Showing') . " <strong>" . $record_start . "</strong> - <strong> " . $record_end . "</strong> " . t('of') . " <strong>" . $record_count . "</strong> ";
echo t('Showing')." <strong>".$record_start."</strong> - <strong> ".$record_end."</strong> ".t('of')." <strong>".$record_count."</strong> ";
if ($search_view == 'basic') {
if ($search_view == 'basic') { echo t('for search') . " <strong>'" . check_plain($lookfor) . "'</strong> ";
echo t('for search')." <strong>'".check_plain($lookfor)."'</strong> "; }
}
if ($search_time){
if ($search_time){ echo "," . t('query time') . ":" . check_plain(round($search_time, 2)) . " s";
echo "," .t('query time').":".check_plain(round($search_time, 2))." s"; }
}
print $sort_form;
print $sort_form; print $pager;
print $pager;
if (!user_is_logged_in()) {
if (!user_is_logged_in()) { $link = '<a href="' . url('user') . '">' . t('Login') . '</a>';
$link = '<a href="' . url('user') . '">' . t('Login') . '</a>'; echo '<p class="top-login-message">';
echo '<p class="top-login-message">'; echo sprintf(t('Hello, Guest. %s for full access.'), $link);
echo sprintf(t('Hello, Guest. %s for full access.'), $link); echo '</p>';
echo '</p>'; }
}
$tabs = "";
$tabs=""; $tabsContent = "";
$tabsContent="";
$counter = 0;
$counter=0; $rsItem = NULL;
$rsItem=null;
if (isset($relatedContent)) {
if (isset ($relatedContent) ) { foreach ($relatedContent as $item) {
foreach ($relatedContent as $item ) { if (isset($item["RelatedRecord"])) {
if (isset($item["RelatedRecord"])) { $tabs .= '<li data-target="#researchstarters" data-slide-to="' . $counter . '" ' . ($counter == 0 ? ' class="active" ' : ' ') . '></li>';
$tabs.='<li data-target="#researchstarters" data-slide-to="'.$counter.'" '.($counter==0?' class="active" ':' ').'></li>'; $counter++;
$counter++; if (isset($item["RelatedRecord"]["Records"]["Record"][0])) {
if (isset($item["RelatedRecord"]["Records"]["Record"][0])) { $rsItem = $item["RelatedRecord"]["Records"]["Record"][0];
$rsItem=$item["RelatedRecord"]["Records"]["Record"][0]; }
} else
else {
{ if (isset($item["Records"]["Record"])) {
if (isset($item["Records"]["Record"])) { $rsItem = $item["Records"]["Record"];
$rsItem=$item["Records"]["Record"]; }
} }
} if ($rsItem == NULL) {
if ($rsItem==null) { continue;
continue ; }
} // var_dump($rsItem);
//var_dump($rsItem); $rsTitle = "";
$rsTitle=""; $rsSubjects = "";
$rsSubjects=""; $rsAbstract = "";
$rsAbstract=""; $rsSource = "";
$rsSource=""; $rsImage = "";
$rsImage=""; $rsAN = $rsItem["Header"]["An"];
$rsAN=$rsItem["Header"]["An"]; $rsDB = $rsItem["Header"]["DbId"];
$rsDB=$rsItem["Header"]["DbId"]; $rsUrl = url('ebsco/result', array('query' => array('id' => $rsAN . "|" . $rsDB)));
$rsUrl = url('ebsco/result', array('query' => array('id' => $rsAN."|".$rsDB)));
if (isset($rsItem["ImageInfo"]["CoverArt"])) {
if (isset($rsItem["ImageInfo"]["CoverArt"])) { $rsImage = $rsItem["ImageInfo"]["CoverArt"]["Target"];
$rsImage=$rsItem["ImageInfo"]["CoverArt"]["Target"]; }
} foreach($rsItem["Items"]["Item"] as $it) {
foreach($rsItem["Items"]["Item"] as $it) { switch ($it["Group"]) {
switch ($it["Group"]) { case "Ti":
case "Ti": $rsTitle = $it["Data"];
$rsTitle=$it["Data"]; break;
break;
case "Src": case "Src":
$rsSource=$it["Data"]; $rsSource = $it["Data"];
break; break;
case "Su":
$rsSubjects=$it["Data"]; case "Su":
$rsSubjects = $it["Data"];
break;
case "Ab": break;
$rsAbstract=$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">'; $tabsContent .= '<div class="item" ><div class="carousel-caption">';
} if ($rsImage <> "") {
if ($rsTitle<>""){ $tabsContent .= '<img src="' . $rsImage . '" alt="' . $rsTitle . '" style="float:left">';
$tabsContent.='<h3 class="relatedTitle"><a href="'.$rsUrl.'" class="title _record_link">'.$rsTitle.'</a></h3>'; }
} if ($rsTitle <> ""){
if ($rsSubjects<>""){ $tabsContent .= '<h3 class="relatedTitle"><a href="' . $rsUrl . '" class="title _record_link">' . $rsTitle . '</a></h3>';
$path = url('ebsco/results', array('query' => array('type' => "Subject"))); }
$link_xml = '/<searchLink fieldCode="([^\"]*)" term="%22([^\"]*)%22">/'; if ($rsSubjects <> ""){
$link_html = "<a href=\"{$path}&lookfor=$2\">"; $path = url('ebsco/results', array('query' => array('type' => "Subject")));
$rsSubjects = preg_replace($link_xml, $link_html, $rsSubjects); $link_xml = '/<searchLink fieldCode="([^\"]*)" term="%22([^\"]*)%22">/';
$rsSubjects = str_replace('</searchLink>', '</a>', $rsSubjects); $link_html = "<a href=\"{$path}&lookfor=$2\">";
$tabsContent.='<p><strong>'.t('Subjects').'</strong>:<span class="quotestart">'.str_replace(array("<br>","<br />"), ', ', $rsSubjects).'</span></p>'; $rsSubjects = preg_replace($link_xml, $link_html, $rsSubjects);
} $rsSubjects = str_replace('</searchLink>', '</a>', $rsSubjects);
if ($rsSource<>""){ $tabsContent .= '<p><strong>' . t('Subjects') . '</strong>:<span class="quotestart">' . str_replace(array("<br>", "<br />"), ', ', $rsSubjects) . '</span></p>';
$tabsContent.='<p>'.$rsSource.'</p>'; }
} if ($rsSource <> ""){
if ($rsAbstract<>""){ $tabsContent .= '<p>' . $rsSource . '</p>';
$tabsContent.='<p><cite>'.$rsAbstract.'</cite></p>'; }
} if ($rsAbstract <> ""){
$tabsContent .= '<p><cite>' . $rsAbstract . '</cite></p>';
$tabsContent.='</div></div>'; }
}
$tabsContent .= '</div></div>';
// replated publications }
if (isset($item["RelatedPublication"])) {
//var_dump($item); // Replated publications.
$tabs.='<li data-target="#ematchplacard" data-slide-to="'.$counter.'" '.($counter==0?' class="active" ':' ').'></li>'; if (isset($item["RelatedPublication"])) {
$counter++; // var_dump($item);
$tabs .= '<li data-target="#ematchplacard" data-slide-to="' . $counter . '" ' . ($counter == 0 ? ' class="active" ' : ' ') . '></li>';
$tabsContent.='<div class="item" ><div class="carousel-caption">'; $counter++;
$tabsContent.='
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/themes/default/style.min.css" /> $tabsContent .= '<div class="item" ><div class="carousel-caption">';
<script src="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/jstree.min.js"></script> $tabsContent .= '
'; <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/themes/default/style.min.css" />
foreach ($item["RelatedPublication"]["PublicationRecords"] as $pub){ <script src="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/jstree.min.js"></script>
$plink = $pub["PLink"]; ';
foreach($pub["Items"]["Item"] as $item) { foreach ($item["RelatedPublication"]["PublicationRecords"] as $pub){
if ($item["Group"]=="Ti") $plink = $pub["PLink"];
{ foreach($pub["Items"]["Item"] as $item) {
$tabsContent.='<h3 class="relatedTitle"><a href="'.$plink.' target="_blank" >'.$item["Data"].'</a></h3>'; if ($item["Group"] == "Ti")
} {
else $tabsContent .= '<h3 class="relatedTitle"><a href="' . $plink . ' target="_blank" >' . $item["Data"] . '</a></h3>';
{ }
$tabsContent.="<strong>".$item["Label"]."</strong> : ".$item["Data"]."<br/>"; 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"] :""; $tabsContent .= '<div id="publicationList"><ul>';
$hName=isset($itemHoldings["Name"])?$itemHoldings["Name"] :""; foreach($pub["FullTextHoldings"]["FullTextHolding"] as $itemHoldings) {
$hCoverage=isset($itemHoldings["CoverageStatement"])?$itemHoldings["CoverageStatement"] :""; $hURL = isset($itemHoldings["URL"]) ? $itemHoldings["URL"] : "";
$hEmbargo=""; $hName = isset($itemHoldings["Name"]) ? $itemHoldings["Name"] : "";
if (isset($itemHoldings["EmbargoDescription"])) { $hCoverage = isset($itemHoldings["CoverageStatement"]) ? $itemHoldings["CoverageStatement"] : "";
// if no embargo, zero size array $hEmbargo = "";
if (!is_array($itemHoldings["EmbargoDescription"] )) { if (isset($itemHoldings["EmbargoDescription"])) {
$hEmbargo=$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.'; '; $tabsContent .= '<li>
<a href="' . $hURL . '" target="_blank">' . $hName . '</a>;
if ($hEmbargo<>'') { <ul><li>Coverage:' . $hCoverage . '; ';
$tabsContent.='</li><li>Embargo:'.$hEmbargo;
} if ($hEmbargo <> '') {
$tabsContent.='</li></ul></li>'; $tabsContent .= '</li><li>Embargo:' . $hEmbargo;
// Notes }
$tabsContent .= '</li></ul></li>';
} // Notes.
$tabsContent.='</ul></div>'; }
} $tabsContent .= '</ul></div>';
$tabsContent.=' }
<script> $tabsContent .= '
jQuery("#publicationList").jstree().on("changed.jstree", function (e, data) { <script>
var pubURL = data.instance.get_node(data.node, true).children("a").attr("href"); jQuery("#publicationList").jstree().on("changed.jstree", function (e, data) {
if (pubURL!="#") { var pubURL = data.instance.get_node(data.node, true).children("a").attr("href");
window.open(pubURL); if (pubURL!="#") {
} window.open(pubURL);
}); }
</script>'; });
$tabsContent.='</div></div>'; </script>';
break; $tabsContent .= '</div></div>';
} break;
} }
} }
}
if ($tabsContent<>"") {
echo '<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script> 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>
<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 --> <div id="relatedInformation" class="carousel slide" data-ride="carousel" style="display:block;">
<ol class="carousel-indicators">'.$tabs.'</ol>'; <!-- Indicators -->
echo '<div class="carousel-inner" role="listbox" >'.$tabsContent.'</div>'; <ol class="carousel-indicators">' . $tabs . '</ol>';
echo '<!-- Left and right controls --> echo '<div class="carousel-inner" role="listbox" >' . $tabsContent . '</div>';
<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev"> echo '<!-- Left and right controls -->
<span class="glyphicon glyphicon-chevron-left" ></span> <a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
</a> <span class="glyphicon glyphicon-chevron-left" ></span>
<a class="right carousel-control" href="#myCarousel" role="button" data-slide="next"> </a>
<span class="glyphicon glyphicon-chevron-right" ></span> <a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
</a> <span class="glyphicon glyphicon-chevron-right" ></span>
</div> </a>
<script> </div>
jQuery("#relatedInformation").carousel({ <script>
pause: true, jQuery("#relatedInformation").carousel({
interval:4000 pause: true,
}) interval:4000
</script>'; })
</script>';
}
}
?>
?>
<ol class="search-results ebsco"> <ol class="search-results ebsco">
<?php foreach ($records as $record): <?php foreach ($records as $record):
$id = check_plain($record->record_id()); $id = check_plain($record->record_id());
$recordUrl = url('ebsco/result', array('query' => array('id' => $id))); $recordUrl = url('ebsco/result', array('query' => array('id' => $id)));
$fulltextUrl = url('ebsco/fulltext', array('query' => array('id' => $id))); $fulltextUrl = url('ebsco/fulltext', array('query' => array('id' => $id)));
$pdfUrl = url('ebsco/pdf', array('query' => array('id' => $id))); $pdfUrl = url('ebsco/pdf', array('query' => array('id' => $id)));
?>
<li>
<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>
<div class="result floatleft"> <div class="span-9">
<div class="span-2"> <div class="result-line1">
<?php <?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>';
}
?>
</div>
<div class="span-9"> if ($record->access_level == '1'){
<div class="result-line1"> echo '<p>';
<?php $label = '<strong>' . check_plain($record->db_label) . '</strong>';
$link = '<a href="' . url('user') . '">' . t('Login') . '</a>';
if ($record->access_level == '1'){ echo sprintf(t('This result from %s cannot be displayed to guests.'), $label) . "<br /><strong>" . sprintf(t('%s for full access.'), $link) . "</strong>";
echo '<p>'; echo "</p>";
$label = '<strong>' . check_plain($record->db_label) . '</strong>'; }
$link = '<a href="' . url('user') . '">' . t('Login') . '</a>'; elseif ($record->title){
echo sprintf(t('This result from %s cannot be displayed to guests.'), $label)."<br /><strong>".sprintf(t('%s for full access.'), $link)."</strong>"; echo '<a href="' . $recordUrl . '" class="title _record_link">' . $record->title . '</a>';
echo "</p>"; }
} ?>
elseif ($record->title){ </div>
echo '<a href="'.$recordUrl.'" class="title _record_link">'.$record->title.'</a>';
} <div class="result-line2">
?> <?php
</div> if (!empty($record->authors)){
echo "<span>" . t('by') . " " . str_replace(array("<br>", "<br />"), ', ', $record->authors) . " </span>";
<div class="result-line2"> }
<?php
if (!empty($record->authors)){ if (!empty($record->source)){
echo "<span>".t('by'). " ".str_replace(array("<br>","<br />"), ', ', $record->authors)." </span>"; echo '<p>' . t('Published in') . " " . $record->source . '</p>';
} }
if (!empty($record->source)){ ?>
echo '<p>'.t('Published in')." ".$record->source.'</p>'; </div>
}
<div class="result-line3">
?> <?php
</div>
if (!empty($record->summary)){
<div class="result-line3"> echo '<cite>' . $record->summary . '</cite><br />';
<?php }
if (!empty($record->summary)){ if (!empty($record->subjects)){
echo '<cite>'.$record->summary.'</cite><br />'; echo '<strong>' . t('Subjects') . '</strong>:<span class="quotestart">' . str_replace('<br />', ', ', $record->subjects) . '</span>';
} }
if (!empty($record->subjects)){ ?>
echo '<strong>'.t('Subjects').'</strong>:<span class="quotestart">'.str_replace('<br />', ', ', $record->subjects).'</span>'; </div>
}
<?php
?> if (!empty($record->custom_links)){
</div> ?>
<div class="result-line4">
<?php <ul class="custom-links">
if (!empty($record->custom_links)){ <?php
?> foreach ($record->custom_links as $link){ ?>
<div class="result-line4"> <li>
<ul class="custom-links"> <a href="<?php print $link['Url']; ?>" target="_blank" title="<?php print $link['MouseOverText']; ?>" class="external-link">
<?php <?php if ($link['Icon']): ?><img src="<?php print $link['Icon']?>" /><?php
foreach ($record->custom_links as $link){ ?> endif; ?><?php print $link['Name']; ?>
<li> </a>
<a href="<?php print $link['Url']; ?>" target="_blank" title="<?php print $link['MouseOverText']; ?>" class="external-link"> </li>
<?php if ($link['Icon']): ?><img src="<?php print $link['Icon']?>" /><?php endif; ?><?php print $link['Name']; ?> <?php } ?>
</a> </ul>
</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>

6
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()
* *
@ -14,12 +14,12 @@
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
?> ?>

Loading…
Cancel
Save