Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
buechereielektrik:unapi:unapi.inc.php [2010-01-31 19:14] – Added (e)Journals to "getBibTex()", "getOpenUrlKev()" and "getText()" in class "Picappn" rosenke | buechereielektrik:unapi:unapi.inc.php [2011-01-20 17:12] (current) – content moved strols | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | <code php unAPI.inc.php> | + | This content was moved to [[https:// |
- | <?php | + | |
- | /* | ||
- | | ||
- | * | ||
- | | ||
- | | ||
- | | ||
- | * | ||
- | | ||
- | | ||
- | * | ||
- | | ||
- | */ | ||
- | |||
- | /* | ||
- | | ||
- | * | ||
- | | ||
- | | ||
- | | ||
- | * | ||
- | | ||
- | | ||
- | */ | ||
- | |||
- | /* | ||
- | | ||
- | * | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | * | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | * | ||
- | | ||
- | | ||
- | */ | ||
- | |||
- | /* | ||
- | | ||
- | * | ||
- | | ||
- | */ | ||
- | |||
- | /* | ||
- | | ||
- | * | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | */ | ||
- | |||
- | /* | ||
- | | ||
- | * | ||
- | | ||
- | | ||
- | */ | ||
- | |||
- | /* | ||
- | | ||
- | */ | ||
- | |||
- | // URL-prefix for XML interface | ||
- | $opac_url = ' | ||
- | |||
- | // URL-prefix for Bibsonomy' | ||
- | $bibsonomy_url = ' | ||
- | |||
- | // Regex for checking if input is PPN | ||
- | $pattern_ppn = '/ | ||
- | |||
- | // Array for filtering extracted bibliographic data | ||
- | $filter_nice = array( | ||
- | ' | ||
- | ' | ||
- | ); | ||
- | |||
- | // Hostname for generating rfr_id for OpenURL | ||
- | $rfr_id_hostname= ' | ||
- | |||
- | /* | ||
- | | ||
- | | ||
- | | ||
- | */ | ||
- | |||
- | /* | ||
- | | ||
- | | ||
- | | ||
- | **/ | ||
- | class PicaRecord { | ||
- | // 15 dublin core elements http:// | ||
- | var $contributor, | ||
- | var $identifier, | ||
- | var $subject, $title, $type; | ||
- | // 1 for me | ||
- | var $signatur; | ||
- | |||
- | /* | ||
- | | ||
- | | ||
- | | ||
- | **/ | ||
- | function PicaRecord() { | ||
- | // | ||
- | | ||
- | | ||
- | | ||
- | } | ||
- | |||
- | /* | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | **/ | ||
- | function decodePica($str) { | ||
- | $tag = ""; | ||
- | $res = ""; | ||
- | for ($i=0; | ||
- | $ch = substr($str, | ||
- | switch (ord($ch)) { | ||
- | case 31: // | ||
- | $ch = substr($str, | ||
- | if ($tag!="" | ||
- | $res .= "</" | ||
- | $tag = $this-> | ||
- | $res .= "<" | ||
- | } else { | ||
- | $tag = $this-> | ||
- | $res .= "<" | ||
- | } | ||
- | | ||
- | |||
- | case 30: // | ||
- | $res .= "</" | ||
- | $tag = ""; | ||
- | | ||
- | |||
- | case 226: //PICA two byte char accent like " | ||
- | $ch = substr($str, | ||
- | $res .= $this-> | ||
- | | ||
- | |||
- | default: | ||
- | $res .= $this-> | ||
- | | ||
- | } //switch | ||
- | |||
- | } | ||
- | $res .= "</" | ||
- | |||
- | // return result | ||
- | return $res; | ||
- | } | ||
- | |||
- | /* | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | **/ | ||
- | function decodePicaArray($str) { | ||
- | $tag = ""; | ||
- | $res = ""; | ||
- | for ($i=0; | ||
- | $ch = substr($str, | ||
- | switch (ord($ch)) { | ||
- | case 31: // | ||
- | $ch = substr($str, | ||
- | $tag = $this-> | ||
- | | ||
- | | ||
- | case 30: // | ||
- | | ||
- | case 226: //PICA two byte char accent like " | ||
- | $ch = substr($str, | ||
- | | ||
- | | ||
- | default: | ||
- | | ||
- | | ||
- | } //switch | ||
- | } | ||
- | |||
- | // return result | ||
- | return $res; | ||
- | } | ||
- | |||
- | /* | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | **/ | ||
- | function getArray($str) { | ||
- | // PICA record separator is ascii record separator | ||
- | $lines = explode(chr(30), | ||
- | $res = ""; | ||
- | foreach ($lines as $line) { | ||
- | $in1 = ltrim($line); | ||
- | $ch1 = substr($in1, | ||
- | // first char between 0-9 | ||
- | if (ord($ch1) >47 && ord($ch1)< | ||
- | $pos = strpos($in1, | ||
- | $key = substr($in1, | ||
- | $val = substr($in1, | ||
- | $val = $this-> | ||
- | | ||
- | } else { | ||
- | // not valid | ||
- | } | ||
- | } | ||
- | $res = $pica_array; | ||
- | |||
- | // return result | ||
- | return $res; | ||
- | } | ||
- | |||
- | /* | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | **/ | ||
- | function getArrayNice($array_raw) { | ||
- | // if $array_raw is empty just return | ||
- | if (empty($array_raw)) return ""; | ||
- | // make variable name handier | ||
- | $record = $array_raw; | ||
- | |||
- | // get global, user-defineable variable $filter_nice | ||
- | global $filter_nice; | ||
- | |||
- | // type | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | // type w/o kind of record | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | |||
- | // author | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | // editor | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | |||
- | // title | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | |||
- | // series | ||
- | if ((!empty($record[' | ||
- | $res[' | ||
- | | ||
- | } | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | |||
- | // address, especially city | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | // publisher | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | |||
- | // edition | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | // year | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | // Erscheinungsverlauf | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | |||
- | // pages | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | |||
- | // ISBNs | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | |||
- | // ISSN | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | |||
- | // DNB Number | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | |||
- | // OCLC Number | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | |||
- | // Foreign Data Identification Number | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | |||
- | // ZDB identification number | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | |||
- | // PPN | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | |||
- | // Link | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | |||
- | // Table of Contents | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | |||
- | // DDC | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | |||
- | // RVK | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | |||
- | // EZB link | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | |||
- | // return result | ||
- | return $res; | ||
- | } | ||
- | |||
- | /* | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | **/ | ||
- | function getCode($ch) { | ||
- | $xx = ord($ch); | ||
- | | ||
- | // | ||
- | // | ||
- | case 10: return " | ||
- | // case 60: return " | ||
- | case 60: return "& | ||
- | // case 62: return " | ||
- | case 62: return "& | ||
- | case 64: return ""; | ||
- | case 209: return " | ||
- | case 210: return " | ||
- | case 211: return " | ||
- | case 216: return " | ||
- | case 193: return " | ||
- | case 194: return " | ||
- | case 195: return " | ||
- | | ||
- | if ($xx<30 || $xx>128) { | ||
- | | ||
- | } | ||
- | return $ch; | ||
- | } | ||
- | } | ||
- | |||
- | /* | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | **/ | ||
- | function getCode2($ch) { | ||
- | | ||
- | case ' | ||
- | case ' | ||
- | case ' | ||
- | case ' | ||
- | case ' | ||
- | case ' | ||
- | case ' | ||
- | case ' | ||
- | | ||
- | | ||
- | } | ||
- | } | ||
- | |||
- | /* | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | **/ | ||
- | function getDublinCore($str) { | ||
- | $res = $this-> | ||
- | |||
- | if (empty($res)) return ""; | ||
- | |||
- | $res = "<? | ||
- | $res .="< | ||
- | $res .= "< | ||
- | $res .= "< | ||
- | $res .= "< | ||
- | $res .= "< | ||
- | $res .= "< | ||
- | $res .= "< | ||
- | $res .= "< | ||
- | $res .= "< | ||
- | $res .= "< | ||
- | $res .= "< | ||
- | $res .= "< | ||
- | $res .= "< | ||
- | $res .= "< | ||
- | $res .= "< | ||
- | $res .= "< | ||
- | $res .="</ | ||
- | |||
- | // return result | ||
- | return $res; | ||
- | } | ||
- | |||
- | /* | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | **/ | ||
- | function getPicaPlus($str) { | ||
- | $res = $this-> | ||
- | $res = $this-> | ||
- | |||
- | // return result | ||
- | return $res; | ||
- | } | ||
- | |||
- | /* | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | **/ | ||
- | function getTagName($ch) { | ||
- | if (ord($ch) >47 && ord($ch)< | ||
- | return " | ||
- | } else { | ||
- | return $ch; | ||
- | } | ||
- | } | ||
- | |||
- | /* | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | **/ | ||
- | function getXmlData($str) { | ||
- | // PICA record separator is ascii record separator | ||
- | $lines = explode(chr(30), | ||
- | |||
- | // define $res | ||
- | $res = ""; | ||
- | |||
- | // check each element of array | ||
- | foreach ($lines as $line) { | ||
- | $in1 = ltrim($line); | ||
- | $ch1 = substr($in1, | ||
- | // first char between 0-9 | ||
- | if (ord($ch1) >47 && ord($ch1)< | ||
- | $pos = strpos($in1, | ||
- | $key = substr($in1, | ||
- | $val = substr($in1, | ||
- | $val = $this-> | ||
- | // | ||
- | $res .= "< | ||
- | // | ||
- | | ||
- | } else { | ||
- | //not valid | ||
- | } | ||
- | } | ||
- | |||
- | // return result | ||
- | return $res; | ||
- | } | ||
- | |||
- | /* | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | **/ | ||
- | function readData($key, | ||
- | // | ||
- | | ||
- | case ' | ||
- | $this-> | ||
- | break; | ||
- | case ' | ||
- | // The spatial or temporal topic of the resource | ||
- | // $this-> | ||
- | break; | ||
- | case ' | ||
- | //The spatial or temporal topic of the resource | ||
- | $this-> | ||
- | break; | ||
- | case ' | ||
- | $this-> | ||
- | break; | ||
- | case ' | ||
- | // $this-> | ||
- | break; | ||
- | case ' | ||
- | $this-> | ||
- | break; | ||
- | case ' | ||
- | $this-> | ||
- | break; | ||
- | case ' | ||
- | //related : A related resource. | ||
- | $this-> | ||
- | break; | ||
- | case ' | ||
- | //related : A related resource. | ||
- | $this-> | ||
- | break; | ||
- | case ' | ||
- | $this-> | ||
- | break; | ||
- | case ' | ||
- | $this-> | ||
- | break; | ||
- | case ' | ||
- | $this-> | ||
- | break; | ||
- | case ' | ||
- | $this-> | ||
- | break; | ||
- | case ' | ||
- | $this-> | ||
- | break; | ||
- | case ' | ||
- | $pub1 = $this-> | ||
- | $pub2 = $this-> | ||
- | $this-> | ||
- | break; | ||
- | case ' | ||
- | $this-> | ||
- | break; | ||
- | case ' | ||
- | $this-> | ||
- | break; | ||
- | case ' | ||
- | // source : A related resource from which the described is derived. | ||
- | $this-> | ||
- | break; | ||
- | case ' | ||
- | $this-> | ||
- | break; | ||
- | case ' | ||
- | $this-> | ||
- | break; | ||
- | case ' | ||
- | if ($this-> | ||
- | $this-> | ||
- | break; | ||
- | case ' | ||
- | if ($this-> | ||
- | $this-> | ||
- | break; | ||
- | case ' | ||
- | if ($this-> | ||
- | $this-> | ||
- | break; | ||
- | case ' | ||
- | if ($this-> | ||
- | $this-> | ||
- | break; | ||
- | case ' | ||
- | if ($this-> | ||
- | $this-> | ||
- | break; | ||
- | case ' | ||
- | $this-> | ||
- | $subtitle = $this-> | ||
- | if ($subtitle!="" | ||
- | break; | ||
- | case ' | ||
- | // type The nature or genre of the resource. | ||
- | $this-> | ||
- | break; | ||
- | | ||
- | break; | ||
- | } | ||
- | // | ||
- | } | ||
- | |||
- | /* | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | **/ | ||
- | function readDublinCore($str) { | ||
- | $doc = new DomDocument(); | ||
- | $doc -> loadXML($str); | ||
- | $xp = new DomXPath($doc); | ||
- | $this-> | ||
- | $this-> | ||
- | $this-> | ||
- | $this-> | ||
- | $this-> | ||
- | $this-> | ||
- | $this-> | ||
- | $this-> | ||
- | $this-> | ||
- | $this-> | ||
- | $this-> | ||
- | $this-> | ||
- | $this-> | ||
- | $this-> | ||
- | $this-> | ||
- | |||
- | // return result | ||
- | return $res; | ||
- | } | ||
- | |||
- | /* | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | **/ | ||
- | /* | ||
- | function readRDF_DC($str) { | ||
- | $doc = new DomDocument(); | ||
- | $doc -> loadXML($str); | ||
- | $xp = new DomXPath($doc); | ||
- | $this-> | ||
- | $this-> | ||
- | $this-> | ||
- | $this-> | ||
- | $this-> | ||
- | $this-> | ||
- | $this-> | ||
- | $this-> | ||
- | $this-> | ||
- | $this-> | ||
- | $this-> | ||
- | $this-> | ||
- | $this-> | ||
- | $this-> | ||
- | $this-> | ||
- | |||
- | // return result | ||
- | return $res; | ||
- | } | ||
- | */ | ||
- | |||
- | /* | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | **/ | ||
- | function readTag($val, | ||
- | $x = strpos($val,"<" | ||
- | $y = strpos($val,"</" | ||
- | if ($x===FALSE) return ""; | ||
- | | ||
- | } | ||
- | |||
- | /* | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | **/ | ||
- | function readXmlData($str) { | ||
- | | ||
- | // | ||
- | | ||
- | $line = trim($line); | ||
- | if ($line=="" | ||
- | $x = strpos($line, | ||
- | if ($x!==0) continue; | ||
- | $y = strpos($line, | ||
- | $key = substr($line, | ||
- | $z = strpos($line, | ||
- | if ($z===FALSE) continue; | ||
- | $val = substr($line, | ||
- | | ||
- | // | ||
- | } | ||
- | // | ||
- | } | ||
- | |||
- | /* | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | **/ | ||
- | function transcribe_pica_rec($str) { | ||
- | | ||
- | " | ||
- | )); | ||
- | } | ||
- | |||
- | /* | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | **/ | ||
- | function transcribe_pica_utf8($str) { | ||
- | | ||
- | " | ||
- | " | ||
- | )); | ||
- | } | ||
- | } | ||
- | |||
- | /* | ||
- | | ||
- | **/ | ||
- | |||
- | /* | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | **/ | ||
- | class Picappn { | ||
- | // declare some attributes | ||
- | var $opac; | ||
- | var $url; | ||
- | var $ppn; | ||
- | var $myself; | ||
- | |||
- | // a picarecord | ||
- | var $prec; | ||
- | |||
- | /* | ||
- | | ||
- | | ||
- | | ||
- | **/ | ||
- | function Picappn() { | ||
- | // get global user-defineable $opac_url | ||
- | global $opac_url; | ||
- | |||
- | // preset some attributes | ||
- | $this-> | ||
- | $this-> | ||
- | |||
- | // instantiate new PicaRecord() | ||
- | $this-> | ||
- | } | ||
- | |||
- | /* | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | **/ | ||
- | function convOutput($array, | ||
- | // check if $array not empty, otherwise just return | ||
- | if (empty($array)) return ""; | ||
- | |||
- | // check if $subfield is given, otherwise just return category | ||
- | if (!empty($subfield)) { | ||
- | if (empty($array[$category][$subfield])) return ""; | ||
- | $res = $text.$separator.$array[$category][$subfield].$suffix; | ||
- | } else { | ||
- | if (empty($array[$category])) return ""; | ||
- | $res = $text.$separator.$array[$category].$suffix; | ||
- | } | ||
- | |||
- | // return result | ||
- | return $res; | ||
- | } | ||
- | |||
- | /* | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | **/ | ||
- | function convOutputNice($array_nice, | ||
- | // check if $array_nice not empty, otherwise just return | ||
- | if (empty($array_nice)) return ""; | ||
- | // check if $array_nice[$key] not empty, otherwise just return | ||
- | if (empty($array_nice[$key])) return ""; | ||
- | |||
- | // build result | ||
- | $res = $array_text[$key].$prefix.$array_nice[$key].$suffix; | ||
- | |||
- | // return result | ||
- | return $res; | ||
- | } | ||
- | |||
- | /* | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | **/ | ||
- | function getArray() { | ||
- | // check if $this-> | ||
- | if ($this-> | ||
- | |||
- | // build result | ||
- | $res = $this-> | ||
- | $res = $this-> | ||
- | |||
- | // return result | ||
- | return $res; | ||
- | } | ||
- | |||
- | /* | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | **/ | ||
- | function getBibsonomy() { | ||
- | // check if $this-> | ||
- | if ($this-> | ||
- | |||
- | // get BibTeX-Record and URL-encode it | ||
- | $res = $this-> | ||
- | $res = urlencode($res); | ||
- | |||
- | /* | ||
- | | ||
- | | ||
- | **/ | ||
- | global $bibsonomy_url; | ||
- | $res = $bibsonomy_url.$res; | ||
- | |||
- | // return result | ||
- | return $res; | ||
- | } | ||
- | |||
- | /* | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | **/ | ||
- | function getBibTex() { | ||
- | // check if $this-> | ||
- | if ($this-> | ||
- | |||
- | // get pica data as array | ||
- | $record_raw = $this-> | ||
- | // transform raw to nice array | ||
- | $record_nice = $this-> | ||
- | // get keys name from array | ||
- | $keys_nice = $record_nice[' | ||
- | // declare $res | ||
- | $res = ""; | ||
- | |||
- | // make sure there is only one ISBN, prefer isbn13 to isbn10 | ||
- | if (!empty($record_nice[' | ||
- | |||
- | /* | ||
- | | ||
- | | ||
- | **/ | ||
- | if (preg_match('/ | ||
- | // type: book | ||
- | $res = "@book {"; | ||
- | |||
- | // create identifier | ||
- | $res .= $this-> | ||
- | $res .= $this-> | ||
- | |||
- | // set the field which are fetched: author et al. | ||
- | $i = array(' | ||
- | ' | ||
- | |||
- | // fetch them from array, format and output them | ||
- | foreach ($i as $j) { | ||
- | $res .= $this-> | ||
- | } | ||
- | |||
- | // get call number, format and output it | ||
- | $res .= $this-> | ||
- | } elseif (preg_match('/ | ||
- | // type: journal | ||
- | $res = "@misc {"; | ||
- | |||
- | // create identifier | ||
- | $res .= $this-> | ||
- | $res .= $this-> | ||
- | |||
- | // set the field which are fetched: title et al. | ||
- | $i = array(' | ||
- | |||
- | // fetch them from array, format and output them | ||
- | foreach ($i as $j) { | ||
- | $res .= $this-> | ||
- | } | ||
- | |||
- | // get call number, format and output it | ||
- | $res .= $this-> | ||
- | } | ||
- | |||
- | // stripping et al. | ||
- | if (isset($res)) { | ||
- | // check if last characters of $res are ", | ||
- | $res = rtrim($res, ", | ||
- | // trailing element | ||
- | $res .= " | ||
- | } | ||
- | |||
- | // return result | ||
- | return $res; | ||
- | } | ||
- | |||
- | /* | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | **/ | ||
- | function getData($ppn) { | ||
- | // check whether curl-Module is available, if not available use fallback | ||
- | if (function_exists(' | ||
- | $ch = curl_init(" | ||
- | curl_setopt($ch, | ||
- | curl_setopt($ch, | ||
- | // | ||
- | curl_setopt($ch, | ||
- | $res = curl_exec($ch); | ||
- | curl_close($ch); | ||
- | } else { | ||
- | $res = file_get_contents(" | ||
- | } | ||
- | |||
- | // return result | ||
- | return $res; | ||
- | } | ||
- | |||
- | /* | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | **/ | ||
- | function getDublinCore() { | ||
- | // retrieve data | ||
- | $res = $this-> | ||
- | |||
- | // format data | ||
- | $res = $this-> | ||
- | |||
- | // return result | ||
- | return $res; | ||
- | } | ||
- | |||
- | /* | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | **/ | ||
- | function getDublinCoreRDF() { | ||
- | // retrieve data | ||
- | $res = $this-> | ||
- | |||
- | // put it to some XML structure | ||
- | $res = $this-> | ||
- | |||
- | // check if $this-> | ||
- | if (empty($res)) return ""; | ||
- | |||
- | // format | ||
- | $res = "<? | ||
- | $res .= "< | ||
- | $res .= " | ||
- | $res .= " | ||
- | $res .= " | ||
- | $res .= "< | ||
- | | ||
- | $res .= "< | ||
- | .$this-> | ||
- | $res .= "< | ||
- | $res .= "< | ||
- | $res .= "< | ||
- | $res .= "< | ||
- | $res .= "< | ||
- | $res .= "< | ||
- | $res .= "< | ||
- | $res .= "< | ||
- | $res .= "< | ||
- | $res .= "< | ||
- | $res .= "< | ||
- | $res .= "< | ||
- | $res .= "< | ||
- | $res .= "< | ||
- | $res .= "< | ||
- | $res .= "</ | ||
- | $res .= "</ | ||
- | |||
- | // return result | ||
- | return $res; | ||
- | } | ||
- | |||
- | /* | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | **/ | ||
- | function getJson() { | ||
- | // check if $this-> | ||
- | if ($this-> | ||
- | |||
- | // get PICA record as array | ||
- | $res = $this-> | ||
- | // encode array as JSON, requirements: | ||
- | $res = json_encode($res); | ||
- | |||
- | // return result | ||
- | return $res; | ||
- | } | ||
- | |||
- | /* | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | **/ | ||
- | function getOpenUrlKev() { | ||
- | // check if $this-> | ||
- | if ($this-> | ||
- | |||
- | // get pica data as array | ||
- | $record_raw = $this-> | ||
- | // transform raw to nice array | ||
- | $record_nice = $this-> | ||
- | // get keys' name from array | ||
- | $keys_nice = $record_nice[' | ||
- | // declare $res | ||
- | $res = ""; | ||
- | |||
- | // get global, user-defineable variable $rfr_id_hostname | ||
- | global $rfr_id_hostname; | ||
- | |||
- | // set immutable context objects for OpenURL | ||
- | // version of the ContextObject | ||
- | $res .= ' | ||
- | // referrer identifier | ||
- | $res .= '& | ||
- | |||
- | // make sure there is only one ISBN, prefer isbn13 to isbn10 | ||
- | if (!empty($record_nice[' | ||
- | |||
- | // check type and choose right OpenURL-type | ||
- | if (preg_match('/ | ||
- | // make $keys_nice[' | ||
- | $keys_nice[' | ||
- | |||
- | // type: book | ||
- | $res .= '& | ||
- | $res .= '& | ||
- | |||
- | // set the field which are fetched: author et al. | ||
- | $i = array(' | ||
- | ' | ||
- | |||
- | // fetch them from array, format, url-encode and output them | ||
- | foreach ($i as $j) { | ||
- | $record_nice[$j] = urlencode($record_nice[$j]); | ||
- | $res .= $this-> | ||
- | } | ||
- | } elseif (preg_match('/ | ||
- | // type: journal/ | ||
- | $res .= '& | ||
- | $res .= '& | ||
- | |||
- | // set the field which are fetched: author et al. | ||
- | $i = array(' | ||
- | |||
- | // fetch them from array, format, url-encode and output them | ||
- | foreach ($i as $j) { | ||
- | $record_nice[$j] = urlencode($record_nice[$j]); | ||
- | $res .= $this-> | ||
- | } | ||
- | } | ||
- | |||
- | // strip trailing "& | ||
- | if (isset($res)) { | ||
- | $res = rtrim($res, "& | ||
- | } | ||
- | |||
- | // return result | ||
- | return $res; | ||
- | } | ||
- | |||
- | /* | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | **/ | ||
- | function getPicaPlus() { | ||
- | // check if $this-> | ||
- | if ($this-> | ||
- | |||
- | // retrieve record | ||
- | $res = $this-> | ||
- | |||
- | // format | ||
- | $res = $this-> | ||
- | |||
- | // set prefix | ||
- | $head = "<? | ||
- | $head .= "< | ||
- | |||
- | // set suffix | ||
- | $tail = "</ | ||
- | |||
- | // return result | ||
- | return $head.$res.$tail; | ||
- | } | ||
- | |||
- | /* | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | **/ | ||
- | function getPlain() { | ||
- | // check if $this-> | ||
- | if ($this-> | ||
- | |||
- | // retrieve record | ||
- | $res = $this-> | ||
- | |||
- | // put to some XML structure | ||
- | $res = $this-> | ||
- | |||
- | // return result | ||
- | return $res; | ||
- | } | ||
- | |||
- | /* | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | **/ | ||
- | function getText() { | ||
- | // check if $this-> | ||
- | if ($this-> | ||
- | |||
- | // get pica data as array | ||
- | $record_raw = $this-> | ||
- | // transform raw to nice array | ||
- | $record_nice = $this-> | ||
- | // get keys' names from array | ||
- | $keys_nice = $record_nice[' | ||
- | // declare $res | ||
- | $res = ""; | ||
- | |||
- | // check type and choose right type | ||
- | if (preg_match('/ | ||
- | // type: book | ||
- | $res .= $keys_nice[' | ||
- | |||
- | // set the field which are fetched: author et al. | ||
- | $i = array(' | ||
- | ' | ||
- | ' | ||
- | |||
- | // fetch them from array, format and output them | ||
- | foreach ($i as $j) { | ||
- | $res .= $this-> | ||
- | } | ||
- | |||
- | // call number | ||
- | $i = 1; | ||
- | $j = 0; | ||
- | while ( $i <= 99 ) { | ||
- | if (($i <= 9) && ($j == 0)) { | ||
- | $j = " | ||
- | } elseif (($i > 9) && ($j == 0)) { | ||
- | $j = $i; | ||
- | } | ||
- | $res .= $this-> | ||
- | $i++; | ||
- | if ($i <= 9 ) { | ||
- | $j = " | ||
- | } else { | ||
- | $j = $i; | ||
- | } | ||
- | if (empty($record_raw[" | ||
- | } | ||
- | } elseif (preg_match('/ | ||
- | // type: journal | ||
- | $res .= $keys_nice[' | ||
- | |||
- | // set the field which are fetched: title et al. | ||
- | $i = array(' | ||
- | ' | ||
- | |||
- | // fetch them from array, format and output them | ||
- | foreach ($i as $j) { | ||
- | $res .= $this-> | ||
- | } | ||
- | |||
- | // call number | ||
- | $i = 1; | ||
- | $j = 0; | ||
- | while ( $i <= 99 ) { | ||
- | if (($i <= 9) && ($j == 0)) { | ||
- | $j = " | ||
- | } elseif (($i > 9) && ($j == 0)) { | ||
- | $j = $i; | ||
- | } | ||
- | $res .= $this-> | ||
- | $i++; | ||
- | if ($i <= 9 ) { | ||
- | $j = " | ||
- | } else { | ||
- | $j = $i; | ||
- | } | ||
- | if (empty($record_raw[" | ||
- | } | ||
- | } | ||
- | |||
- | // return result | ||
- | return $res; | ||
- | } | ||
- | |||
- | /* | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | **/ | ||
- | function getXmlData() { | ||
- | // check if $this-> | ||
- | if ($this-> | ||
- | |||
- | // retrieve record | ||
- | $res = $this-> | ||
- | |||
- | // put it to some XML structure | ||
- | $res = $this-> | ||
- | |||
- | // define prefix | ||
- | $head = "<? | ||
- | //$head .= "< | ||
- | //$head .= "< | ||
- | //$head .= "< | ||
- | //$head .= "< | ||
- | //$head .= "< | ||
- | $head .= "< | ||
- | |||
- | // define suffix | ||
- | $tail = "</ | ||
- | |||
- | // return result | ||
- | return $head.$res.$tail; | ||
- | } | ||
- | |||
- | /* public | ||
- | | ||
- | | ||
- | | ||
- | **/ | ||
- | function setOpac($opac) { | ||
- | $this-> | ||
- | } | ||
- | |||
- | /* public | ||
- | | ||
- | | ||
- | | ||
- | **/ | ||
- | function setPpn($ppn) { | ||
- | // get global, user-defineable $pattern_ppn | ||
- | global $pattern_ppn; | ||
- | |||
- | / | ||
- | | ||
- | | ||
- | **/ | ||
- | if (preg_match($pattern_ppn, | ||
- | $this-> | ||
- | $this-> | ||
- | } else { | ||
- | // for debugging only | ||
- | //echo foo; | ||
- | } | ||
- | $this-> | ||
- | } | ||
- | } | ||
- | |||
- | /* | ||
- | | ||
- | **/ | ||
- | |||
- | /* | ||
- | | ||
- | | ||
- | | ||
- | **/ | ||
- | function final_result($res, | ||
- | /* if $res is not empty, return it, otherwise act accordingly to unAPI | ||
- | | ||
- | **/ | ||
- | if (!empty($res)) { | ||
- | // send header | ||
- | header(" | ||
- | // return result | ||
- | echo $res; | ||
- | } else { | ||
- | header(' | ||
- | } | ||
- | } | ||
- | |||
- | /* | ||
- | | ||
- | **/ | ||
- | |||
- | ?> | ||
- | </ | ||
- | |||
- | Former name of this file was [[PicaRecord.php]] |