Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
buechereielektrik:unapi:unapi.inc.php [2010-01-12 20:56] – Added further mappings in getArrayNice. Extended types for monographies. strols | buechereielektrik:unapi:unapi.inc.php [2010-03-03 17:13] – strols | ||
---|---|---|---|
Line 9: | Line 9: | ||
| | ||
* | * | ||
- | | + | |
| | ||
* | * | ||
Line 19: | Line 19: | ||
* | * | ||
| | ||
- | | + | |
| | ||
* | * | ||
| | ||
- | | + | |
*/ | */ | ||
Line 46: | Line 46: | ||
| | ||
* | * | ||
- | | + | |
*/ | */ | ||
Line 52: | Line 52: | ||
| | ||
* | * | ||
- | | + | * 20100303: |
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | * 20100112: | ||
| | ||
- | | + | |
- | | + | |
- | | + | * class " |
| | ||
| | ||
| | ||
- | | + | * "file_get_contents()". |
| | ||
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
+ | | ||
| | ||
- | | + | |
| | ||
| | ||
- | | + | |
| | ||
| | ||
- | | + | |
- | * " | + | |
- | | + | |
- | * class " | + | * " |
| | ||
*/ | */ | ||
Line 92: | Line 106: | ||
*/ | */ | ||
- | // URL-prefix for XML-interface | + | // URL-prefix for XML interface |
- | $opac_url = ' | + | $opac_url = ' |
- | // URL-prefix for Bibsonomy' | + | // URL-prefix for Bibsonomy' |
$bibsonomy_url = ' | $bibsonomy_url = ' | ||
Line 111: | Line 125: | ||
/* | /* | ||
- | * | + | ******************************************************************************* |
- | | + | |
- | * | + | ******************************************************************************* |
*/ | */ | ||
/* | /* | ||
| | ||
- | | + | |
- | */ | + | * XML structure or an array |
+ | **/ | ||
class PicaRecord { | class PicaRecord { | ||
- | // 15 dublin core elements http:// | + | // 15 dublin core elements http:// |
var $contributor, | var $contributor, | ||
var $identifier, | var $identifier, | ||
var $subject, $title, $type; | var $subject, $title, $type; | ||
- | // 1 for me | + | // 1 for me |
var $signatur; | var $signatur; | ||
+ | /* | ||
+ | | ||
+ | | ||
+ | | ||
+ | **/ | ||
function PicaRecord() { | function PicaRecord() { | ||
// | // | ||
Line 135: | Line 155: | ||
} | } | ||
- | /** private | + | /* |
+ | * private | ||
+ | | ||
+ | | ||
+ | | ||
+ | **/ | ||
function decodePica($str) { | function decodePica($str) { | ||
$tag = ""; | $tag = ""; | ||
Line 159: | Line 184: | ||
| | ||
- | case 226: //pica two byte char accent like " | + | case 226: //PICA two byte char accent like " |
$ch = substr($str, | $ch = substr($str, | ||
$res .= $this-> | $res .= $this-> | ||
Line 171: | Line 196: | ||
} | } | ||
$res .= "</" | $res .= "</" | ||
+ | |||
+ | // return result | ||
return $res; | return $res; | ||
} | } | ||
- | /** private | + | /* |
- | function | + | * private |
+ | | ||
+ | | ||
+ | | ||
+ | **/ | ||
+ | function | ||
$tag = ""; | $tag = ""; | ||
$res = ""; | $res = ""; | ||
Line 188: | Line 220: | ||
case 30: // | case 30: // | ||
| | ||
- | case 226: //pica two byte char accent like " | + | case 226: //PICA two byte char accent like " |
$ch = substr($str, | $ch = substr($str, | ||
| | ||
Line 197: | Line 229: | ||
} //switch | } //switch | ||
} | } | ||
+ | |||
+ | // return result | ||
return $res; | return $res; | ||
} | } | ||
- | /** public | + | /* |
+ | * public | ||
+ | | ||
+ | | ||
+ | | ||
+ | **/ | ||
function getArray($str) { | 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->decodePica_array($val); | + | |
- | $pica_array[$key] = $val; | + | |
- | | + | } else { |
- | | + | // not valid |
- | | + | } |
- | | + | } |
- | | + | $res = $pica_array; |
- | | + | |
+ | // return result | ||
+ | | ||
} | } | ||
- | /** private | + | /* |
+ | * | ||
+ | | ||
+ | | ||
+ | | ||
+ | **/ | ||
+ | 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) { | function getCode($ch) { | ||
$xx = ord($ch); | $xx = ord($ch); | ||
Line 234: | Line 447: | ||
// case 62: return " | // case 62: return " | ||
case 62: return "& | case 62: return "& | ||
- | case 64: return ""; | + | case 64: return ""; |
case 209: return " | case 209: return " | ||
case 210: return " | case 210: return " | ||
Line 250: | Line 463: | ||
} | } | ||
- | /** private | + | /* |
- | an accent sign */ | + | * private |
+ | | ||
+ | | ||
+ | * | ||
+ | | ||
+ | **/ | ||
function getCode2($ch) { | function getCode2($ch) { | ||
| | ||
Line 267: | Line 485: | ||
} | } | ||
- | /** public | + | /* |
- | //used by unapi | + | * public |
+ | | ||
+ | | ||
+ | * Used by Picappn-> | ||
+ | | ||
function getDublinCore($str) { | function getDublinCore($str) { | ||
$res = $this-> | $res = $this-> | ||
Line 292: | Line 514: | ||
$res .= "< | $res .= "< | ||
$res .="</ | $res .="</ | ||
+ | |||
+ | // return result | ||
return $res; | return $res; | ||
} | } | ||
- | /** public | + | /* |
- | //used by unapi | + | * public |
+ | | ||
+ | | ||
+ | * Used by Picappn-> | ||
+ | | ||
function getPicaPlus($str) { | function getPicaPlus($str) { | ||
$res = $this-> | $res = $this-> | ||
$res = $this-> | $res = $this-> | ||
+ | |||
+ | // return result | ||
return $res; | return $res; | ||
} | } | ||
- | /** private | + | /* |
+ | * private | ||
+ | | ||
+ | | ||
+ | | ||
+ | **/ | ||
function getTagName($ch) { | function getTagName($ch) { | ||
if (ord($ch) >47 && ord($ch)< | if (ord($ch) >47 && ord($ch)< | ||
Line 312: | Line 547: | ||
} | } | ||
- | /** public | + | /* |
- | //used by unapi | + | * public |
+ | | ||
+ | | ||
+ | * Used by PicaRecord-> | ||
+ | * Picappn-> | ||
+ | **/ | ||
function getXmlData($str) { | function getXmlData($str) { | ||
- | // pica record separator is ascii record separator | + | |
- | | + | $lines = explode(chr(30), |
- | | + | |
- | | + | // define $res |
- | | + | |
- | | + | |
- | | + | // check each element of array |
- | | + | |
- | $pos = strpos($in1, | + | $in1 = ltrim($line); |
- | $key = substr($in1, | + | $ch1 = substr($in1, |
- | $val = substr($in1, | + | // first char between 0-9 |
- | $val = $this-> | + | if (ord($ch1) >47 && ord($ch1)< |
- | //$res .= " | + | |
- | $res .= "< | + | |
- | //side effect to scan dublin core elements | + | |
- | $this-> | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | } else { |
+ | //not valid | ||
+ | } | ||
+ | } | ||
+ | |||
+ | // return result | ||
+ | | ||
} | } | ||
- | /** private | + | /* |
+ | * private | ||
+ | | ||
+ | | ||
+ | | ||
+ | **/ | ||
function readData($key, | function readData($key, | ||
// | // | ||
Line 400: | Line 651: | ||
break; | break; | ||
case ' | case ' | ||
- | //source : A related resource from which the described is derived. | + | // source : A related resource from which the described is derived. |
$this-> | $this-> | ||
- | // | ||
break; | break; | ||
case ' | case ' | ||
Line 436: | Line 686: | ||
break; | break; | ||
case ' | case ' | ||
- | //type The nature or genre of the resource. | + | // type The nature or genre of the resource. |
$this-> | $this-> | ||
break; | break; | ||
Line 447: | Line 697: | ||
/* | /* | ||
| | ||
+ | | ||
| | ||
| | ||
| | ||
- | */ | + | **/ |
function readDublinCore($str) { | 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 | ||
+ | | ||
} | } | ||
/* | /* | ||
| | ||
+ | | ||
| | ||
| | ||
- | */ | + | * Used by n/a |
+ | **/ | ||
/* | /* | ||
function readRDF_DC($str) { | 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 | ||
+ | | ||
} | } | ||
*/ | */ | ||
- | /** private | + | /* |
+ | * private | ||
+ | | ||
+ | | ||
+ | | ||
+ | **/ | ||
function readTag($val, | function readTag($val, | ||
$x = strpos($val,"<" | $x = strpos($val,"<" | ||
Line 512: | Line 774: | ||
/* | /* | ||
| | ||
+ | | ||
| | ||
| | ||
- | */ | + | **/ |
function readXmlData($str) { | function readXmlData($str) { | ||
| | ||
Line 534: | Line 797: | ||
} | } | ||
- | /** private | + | /* |
+ | * private | ||
+ | | ||
+ | | ||
+ | | ||
+ | **/ | ||
function transcribe_pica_rec($str) { | function transcribe_pica_rec($str) { | ||
| | ||
Line 541: | Line 809: | ||
} | } | ||
- | /** private | + | /* |
+ | * private | ||
+ | | ||
+ | | ||
+ | | ||
+ | **/ | ||
function transcribe_pica_utf8($str) { | function transcribe_pica_utf8($str) { | ||
| | ||
Line 551: | Line 824: | ||
/* | /* | ||
- | * end class PicaRecord | + | |
- | */ | + | **/ |
/* | /* | ||
| | ||
- | | + | |
- | */ | + | * Supported formats: |
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | **/ | ||
class Picappn { | class Picappn { | ||
// declare some attributes | // declare some attributes | ||
Line 568: | Line 854: | ||
var $prec; | var $prec; | ||
- | // | + | /* |
+ | | ||
+ | | ||
+ | | ||
+ | **/ | ||
function Picappn() { | function Picappn() { | ||
// get global user-defineable $opac_url | // get global user-defineable $opac_url | ||
global $opac_url; | global $opac_url; | ||
+ | |||
// preset some attributes | // preset some attributes | ||
$this-> | $this-> | ||
$this-> | $this-> | ||
+ | |||
// instantiate new PicaRecord() | // instantiate new PicaRecord() | ||
$this-> | $this-> | ||
Line 581: | Line 873: | ||
/* | /* | ||
| | ||
+ | | ||
| | ||
- | | + | |
- | | + | **/ |
function convOutput($array, | function convOutput($array, | ||
+ | // check if $array not empty, otherwise just return | ||
if (empty($array)) return ""; | if (empty($array)) return ""; | ||
+ | |||
+ | // check if $subfield is given, otherwise just return category | ||
if (!empty($subfield)) { | if (!empty($subfield)) { | ||
if (empty($array[$category][$subfield])) return ""; | if (empty($array[$category][$subfield])) return ""; | ||
Line 593: | Line 889: | ||
$res = $text.$separator.$array[$category].$suffix; | $res = $text.$separator.$array[$category].$suffix; | ||
} | } | ||
+ | |||
+ | // return result | ||
return $res; | return $res; | ||
} | } | ||
Line 598: | Line 896: | ||
/* | /* | ||
| | ||
+ | | ||
| | ||
- | */ | + | * Used by Picappn-> |
+ | **/ | ||
function convOutputNice($array_nice, | function convOutputNice($array_nice, | ||
+ | // check if $array_nice not empty, otherwise just return | ||
if (empty($array_nice)) return ""; | if (empty($array_nice)) return ""; | ||
+ | // check if $array_nice[$key] not empty, otherwise just return | ||
if (empty($array_nice[$key])) return ""; | if (empty($array_nice[$key])) return ""; | ||
+ | |||
+ | // build result | ||
$res = $array_text[$key].$prefix.$array_nice[$key].$suffix; | $res = $array_text[$key].$prefix.$array_nice[$key].$suffix; | ||
- | | + | |
+ | // return result | ||
+ | | ||
} | } | ||
/* | /* | ||
| | ||
+ | | ||
| | ||
- | */ | + | * Used by Picappn-> |
+ | **/ | ||
function getArray() { | function getArray() { | ||
+ | // check if $this-> | ||
if ($this-> | if ($this-> | ||
+ | |||
+ | // build result | ||
$res = $this-> | $res = $this-> | ||
$res = $this-> | $res = $this-> | ||
- | return $res; | ||
- | } | ||
- | |||
- | /* | ||
- | | ||
- | | ||
- | | ||
- | */ | ||
- | function getArrayNice($array_raw) { | ||
- | if (empty($array_raw)) return ""; | ||
- | $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[' | ||
- | |||
- | // pages | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | |||
- | // ISBNs | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | $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[' | ||
// return result | // return result | ||
Line 742: | Line 933: | ||
/* | /* | ||
| | ||
- | | + | * class Picappn |
+ | * return BibTeX record prefixed with $bibsonomy_url from PICA data. | ||
| | ||
**/ | **/ | ||
Line 765: | Line 957: | ||
/* | /* | ||
- | * public | + | |
- | * Return BibTex record from pica data | + | |
- | * Used by unAPI.php and Bibsonomy.php | + | |
+ | | ||
**/ | **/ | ||
function getBibTex() { | function getBibTex() { | ||
Line 776: | Line 969: | ||
$record_raw = $this-> | $record_raw = $this-> | ||
// transform raw to nice array | // transform raw to nice array | ||
- | $record_nice = $this-> | + | $record_nice = $this->prec-> |
// get keys name from array | // get keys name from array | ||
$keys_nice = $record_nice[' | $keys_nice = $record_nice[' | ||
Line 785: | Line 978: | ||
if (!empty($record_nice[' | if (!empty($record_nice[' | ||
- | // check type and choose right BibTeX-type | + | /* |
+ | | ||
+ | | ||
+ | **/ | ||
if (preg_match('/ | if (preg_match('/ | ||
- | // type | + | // type: book |
$res = "@book {"; | $res = "@book {"; | ||
Line 797: | Line 993: | ||
$i = array(' | $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 | // fetch them from array, format and output them | ||
Line 807: | Line 1021: | ||
} | } | ||
- | // | + | // |
if (isset($res)) { | if (isset($res)) { | ||
+ | // check if last characters of $res are ", | ||
+ | $res = rtrim($res, ", | ||
+ | // trailing element | ||
$res .= " | $res .= " | ||
} | } | ||
Line 816: | Line 1033: | ||
} | } | ||
- | /** private | + | /* |
+ | * | ||
+ | | ||
+ | | ||
+ | | ||
+ | **/ | ||
+ | function getCsv() { | ||
+ | // check if $this->ppn is not the preset value else return emptily | ||
+ | if ($this->ppn == 0) return ""; | ||
+ | |||
+ | // get pica data as array | ||
+ | $record_raw = $this-> | ||
+ | // transform raw to nice array | ||
+ | $record_nice = $this-> | ||
+ | // declare $res | ||
+ | $res = ''; | ||
+ | |||
+ | // set categories to used for CSV | ||
+ | $i = array(' | ||
+ | ' | ||
+ | |||
+ | // fetch them from array, format and output them | ||
+ | foreach ($i as $j) { | ||
+ | $res .= '"' | ||
+ | } | ||
+ | |||
+ | // stripping et al. | ||
+ | if (isset($res)) { | ||
+ | // check if last characters of $res are ", | ||
+ | $res = rtrim($res, " | ||
+ | } | ||
+ | |||
+ | // return result | ||
+ | return $res; | ||
+ | } | ||
+ | |||
+ | /* | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | **/ | ||
function getData($ppn) { | function getData($ppn) { | ||
- | //check whether curl-Module is available, if not available use fallback | + | // get global $use_curl as switch for the following conditional |
- | if (function_exists(' | + | global $use_curl; |
+ | |||
+ | // | ||
+ | if (function_exists(' | ||
$ch = curl_init(" | $ch = curl_init(" | ||
curl_setopt($ch, | curl_setopt($ch, | ||
Line 830: | Line 1091: | ||
$res = file_get_contents(" | $res = file_get_contents(" | ||
} | } | ||
+ | |||
+ | // return result | ||
return $res; | return $res; | ||
} | } | ||
- | /** public | + | /* |
+ | * public | ||
+ | | ||
+ | | ||
+ | | ||
+ | **/ | ||
function getDublinCore() { | function getDublinCore() { | ||
+ | // retrieve data | ||
$res = $this-> | $res = $this-> | ||
+ | |||
+ | // format data | ||
$res = $this-> | $res = $this-> | ||
+ | |||
+ | // return result | ||
return $res; | return $res; | ||
} | } | ||
- | /** public | + | /* |
+ | * public | ||
+ | | ||
+ | | ||
+ | | ||
+ | **/ | ||
function getDublinCoreRDF() { | function getDublinCoreRDF() { | ||
+ | // retrieve data | ||
$res = $this-> | $res = $this-> | ||
+ | |||
+ | // put it to some XML structure | ||
$res = $this-> | $res = $this-> | ||
+ | // check if $this-> | ||
if (empty($res)) return ""; | if (empty($res)) return ""; | ||
+ | // format | ||
$res = "<? | $res = "<? | ||
$res .= "< | $res .= "< | ||
Line 873: | Line 1156: | ||
$res .= "</ | $res .= "</ | ||
$res .= "</ | $res .= "</ | ||
+ | |||
+ | // return result | ||
return $res; | return $res; | ||
} | } | ||
- | /** public | + | /* |
- | //used by unapi | + | * public |
+ | | ||
+ | | ||
+ | * Used by unAPI.php | ||
+ | | ||
function getJson() { | function getJson() { | ||
+ | // check if $this-> | ||
if ($this-> | if ($this-> | ||
+ | // get PICA record as array | ||
$res = $this-> | $res = $this-> | ||
- | //(PHP 5 >= 5.2.0, PECL json >= 1.2.0) | + | // |
$res = json_encode($res); | $res = json_encode($res); | ||
+ | // return result | ||
return $res; | return $res; | ||
} | } | ||
/* | /* | ||
- | * public | + | |
- | * return OpenURL KEV record from pica data | + | |
- | * Used by unAPI.php and Coins.php | + | |
+ | | ||
**/ | **/ | ||
function getOpenUrlKev() { | function getOpenUrlKev() { | ||
Line 900: | Line 1193: | ||
$record_raw = $this-> | $record_raw = $this-> | ||
// transform raw to nice array | // transform raw to nice array | ||
- | $record_nice = $this-> | + | $record_nice = $this->prec-> |
// get keys' name from array | // get keys' name from array | ||
$keys_nice = $record_nice[' | $keys_nice = $record_nice[' | ||
Line 923: | Line 1216: | ||
$keys_nice[' | $keys_nice[' | ||
- | // type | + | // type: book |
$res .= '& | $res .= '& | ||
$res .= '& | $res .= '& | ||
Line 930: | Line 1223: | ||
$i = array(' | $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 | // fetch them from array, format, url-encode and output them | ||
Line 940: | Line 1246: | ||
// strip trailing "& | // strip trailing "& | ||
if (isset($res)) { | if (isset($res)) { | ||
- | | + | $res = rtrim($res, "& |
- | $last = strrpos($res,"& | + | |
- | if ( $length == $last+5 ) { | + | |
- | $res = substr($res, | + | |
- | } | + | |
} | } | ||
Line 951: | Line 1253: | ||
} | } | ||
- | /** public | + | /* |
+ | * public | ||
+ | | ||
+ | | ||
+ | | ||
+ | **/ | ||
function getPicaPlus() { | function getPicaPlus() { | ||
+ | // check if $this-> | ||
if ($this-> | if ($this-> | ||
+ | |||
+ | // retrieve record | ||
$res = $this-> | $res = $this-> | ||
+ | |||
+ | // format | ||
$res = $this-> | $res = $this-> | ||
+ | |||
+ | // set prefix | ||
$head = "<? | $head = "<? | ||
$head .= "< | $head .= "< | ||
+ | |||
+ | // set suffix | ||
$tail = "</ | $tail = "</ | ||
+ | |||
+ | // return result | ||
return $head.$res.$tail; | return $head.$res.$tail; | ||
} | } | ||
- | /** public | + | /* |
+ | * public | ||
+ | | ||
+ | | ||
+ | | ||
+ | **/ | ||
function getPlain() { | function getPlain() { | ||
+ | // check if $this-> | ||
if ($this-> | if ($this-> | ||
+ | |||
+ | // retrieve record | ||
$res = $this-> | $res = $this-> | ||
+ | |||
+ | // put to some XML structure | ||
$res = $this-> | $res = $this-> | ||
+ | |||
+ | // return result | ||
return $res; | return $res; | ||
} | } | ||
/* | /* | ||
- | * public | + | |
- | * Return simple text record from pica data | + | |
- | * Used by unAPI.php | + | |
+ | | ||
**/ | **/ | ||
function getText() { | function getText() { | ||
Line 982: | Line 1313: | ||
$record_raw = $this-> | $record_raw = $this-> | ||
// transform raw to nice array | // transform raw to nice array | ||
- | $record_nice = $this-> | + | $record_nice = $this->prec-> |
// get keys' names from array | // get keys' names from array | ||
$keys_nice = $record_nice[' | $keys_nice = $record_nice[' | ||
Line 990: | Line 1321: | ||
// check type and choose right type | // check type and choose right type | ||
if (preg_match('/ | if (preg_match('/ | ||
- | // type | + | // type: book |
$res .= $keys_nice[' | $res .= $keys_nice[' | ||
// set the field which are fetched: author et al. | // set the field which are fetched: author et al. | ||
$i = array(' | $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 | // fetch them from array, format and output them | ||
Line 1022: | Line 1384: | ||
} | } | ||
} | } | ||
+ | |||
+ | // return result | ||
return $res; | return $res; | ||
} | } | ||
- | /** public | + | /* |
+ | * public | ||
+ | | ||
+ | | ||
+ | | ||
+ | **/ | ||
function getXmlData() { | function getXmlData() { | ||
+ | // check if $this-> | ||
if ($this-> | if ($this-> | ||
+ | |||
+ | // retrieve record | ||
$res = $this-> | $res = $this-> | ||
- | | + | |
+ | // put it to some XML structure | ||
+ | | ||
+ | |||
+ | // define prefix | ||
$head = "<? | $head = "<? | ||
//$head .= "< | //$head .= "< | ||
Line 1037: | Line 1413: | ||
//$head .= "< | //$head .= "< | ||
$head .= "< | $head .= "< | ||
+ | |||
+ | // define suffix | ||
$tail = "</ | $tail = "</ | ||
+ | |||
+ | // return result | ||
return $head.$res.$tail; | return $head.$res.$tail; | ||
} | } | ||
- | // | + | /* |
+ | | ||
+ | | ||
+ | | ||
+ | **/ | ||
function setOpac($opac) { | function setOpac($opac) { | ||
$this-> | $this-> | ||
} | } | ||
- | // | + | /* |
+ | | ||
+ | | ||
+ | | ||
+ | **/ | ||
function setPpn($ppn) { | function setPpn($ppn) { | ||
// get global, user-defineable $pattern_ppn | // get global, user-defineable $pattern_ppn | ||
Line 1053: | Line 1441: | ||
/ | / | ||
| | ||
- | | + | |
- | | + | **/ |
if (preg_match($pattern_ppn, | if (preg_match($pattern_ppn, | ||
$this-> | $this-> | ||
Line 1068: | Line 1456: | ||
/* | /* | ||
| | ||
- | */ | + | **/ |
/* | /* | ||
Line 1074: | Line 1462: | ||
| | ||
| | ||
- | */ | + | **/ |
function final_result($res, | function final_result($res, | ||
+ | /* if $res is not empty, return it, otherwise act accordingly to unAPI | ||
+ | | ||
+ | **/ | ||
if (!empty($res)) { | if (!empty($res)) { | ||
+ | // send header | ||
header(" | header(" | ||
+ | // return result | ||
echo $res; | echo $res; | ||
} else { | } else { | ||
Line 1085: | Line 1478: | ||
/* | /* | ||
- | * end function final_result | + | |
- | */ | + | **/ |
?> | ?> | ||
</ | </ | ||
+ | Former name of this file was [[PicaRecord.php]] |