Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 170 lines (138 sloc) 4.459 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
<?php
/*
Forward user to Relais ILL system via OpenURL

*/

/*
copyright 2011,2012 University of Victoria Libraries

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program 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 General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

*/

include "../includes/contextobject.inc.php";


$ctx_obj = new ContextObject();

$thereisaJtitle=false;
$thereisaBtitle=false;

foreach ($ctx_obj->fieldList as $field) {

if (is_array($ctx_obj->$field)) {
//print $ctx_obj->formatArrayAsString($ctx_obj->$field);
} else {
//print $ctx_obj->$field;
}
}



$urlrelais="https://cabra.comp.uvic.ca:8443/ILL/prelogin.jsp?UT=P";

if($ctx_obj->genre){
$urlrelais.="&genre=".$ctx_obj->genre;
}

if($ctx_obj->fmt){
// commented out because it said a book was a book and that broke relais accepting oclc number

//$urlrelais.="&fmt=".$ctx_obj->fmt;
}

if($ctx_obj->spage){
$urlrelais.="&spage=".$ctx_obj->spage;
}
if($ctx_obj->aulast){
//$urlrelais.="&aulast=".$ctx_obj->aulast;
$urlrelais.="&aulast=".urlencode ($ctx_obj->aulast);
if($ctx_obj->aufirst){
$urlrelais.="&aufirst=".urlencode ($ctx_obj->aufirst);
}
}else{
if($ctx_obj->getAuthors() ){
//$urlrelais.="&aulast=".$ctx_obj->getAuthors();
$urlrelais.="&aulast=".urlencode ($ctx_obj->getAuthors());
//$urlrelais.="&aufirst=".$ctx_obj->getAuthors();
}
}

if($ctx_obj->date){
$urlrelais.="&date=".$ctx_obj->date;
}

if($ctx_obj->volume){
$urlrelais.="&volume=".$ctx_obj->volume;
}

if($ctx_obj->issue){
$urlrelais.="&issue=".$ctx_obj->issue;
}
if($ctx_obj->atitle){
$newtitle = replaceANDsymbol($ctx_obj->atitle);
$urlrelais.="&atitle=".$newtitle;

}
// title of the journal could use jtitle
if($ctx_obj->jtitle){
$thereisaJtitle=true;
$newtitle = replaceANDsymbol($ctx_obj->jtitle);
$urlrelais.="&jtitle=".$newtitle;
}
if($ctx_obj->btitle){
$thereisaBtitle=true;
$newtitle = replaceANDsymbol($ctx_obj->btitle);
$urlrelais.="&btitle=".$newtitle;
}
if($ctx_obj->title){
if(!$thereisaJtitle){
if(!$thereisaBtitle){
$newtitle = replaceANDsymbol($ctx_obj->title);
$urlrelais.="&title=".$newtitle;
}
}
}

if($ctx_obj->issn){
// added by ben feb 10 2012 to add dashes so relais searching works without them manually having to add a dash
$containsdash = strstr($ctx_obj->issn,"-");
if(!$containsdash){
$issndash = substr_replace($ctx_obj->issn, '-', 4,0);
$urlrelais.="&issn=".$issndash;
}else{
$urlrelais.="&issn=".$ctx_obj->issn;
}
}
if($ctx_obj->eissn){
$urlrelais.="&eissn=".$ctx_obj->eissn;
}
if($ctx_obj->isbn){

// added by ben Jan 24 2012 to deal with relais only accepting 13 characters in the isbn field. Therefor remove the dashes
$urlrelais.="&isbn=".str_replace("-", "", $ctx_obj->isbn);
}
if($ctx_obj->rft_id){
// comes in like rft_id=info%3Aoclcnum%2F180923174
// if oclcnum then needs to go out like
//&bibsrc=FirstSearch:WorldCat&verify=180923174
if (is_array($ctx_obj->rft_id)){


$formattedIDField = $ctx_obj->formatArrayAsString($ctx_obj->rft_id);
}else{
$formattedIDField = $ctx_obj->rft_id;
}
$oclcsub = strstr($formattedIDField, 'oclcnum');
if($oclcsub){
// looks like oclcnum/180923174
$oclcNum = substr(strstr($formattedIDField, '/'), 1);
$urlrelais.="&bibsrc=FirstSearch:WorldCat&verify=" . $oclcNum;
}
}
// Feb 10 2012 added by ben to try to include the source of the request rfr_id comes from summon and sid was used by one of the databases I tested
if( isset($_REQUEST['rfr_id']) ){
$urlrelais.="&bibsrc=" . $_REQUEST['rfr_id'];
}
if( isset($_REQUEST['sid']) ){
$urlrelais.="&bibsrc=" . $_REQUEST['sid'];
}

/* testing stuff
echo "\n<!-- ";
print_r($_REQUEST);
echo "-->\n";
echo"<br><a href='$urlrelais'>$urlrelais</a> <br>";
exit;
*/
header("Location: $urlrelais");

// added by ben Feb 10 2012 to deal with & sybmol in titles then going into the url and breakin the title
function replaceANDsymbol($in) {
$out = str_replace("&", "%26", $in);
return $out;
}


?>
Something went wrong with that request. Please try again.