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-25 22:44] – Added comments. Renamed "decodePica_array" to "decodePicaArray" in class "PicaRecord". rosenke | buechereielektrik:unapi:unapi.inc.php [2010-03-03 17:13] – strols | ||
---|---|---|---|
Line 19: | Line 19: | ||
* | * | ||
| | ||
- | | + | |
| | ||
* | * | ||
| | ||
- | | + | |
*/ | */ | ||
Line 46: | Line 46: | ||
| | ||
* | * | ||
- | | + | |
*/ | */ | ||
Line 52: | Line 52: | ||
| | ||
* | * | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
| | ||
- | | + | * Renamed " |
- | | + | * " |
- | | + | |
- | | + | |
| | ||
- | | + | |
- | | + | |
- | | + | * class " |
| | ||
| | ||
| | ||
- | | + | * "file_get_contents()". |
| | ||
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
+ | | ||
| | ||
- | | + | |
| | ||
| | ||
- | | + | |
| | ||
| | ||
- | | + | |
- | * " | + | |
- | | + | |
- | * class " | + | * " |
| | ||
*/ | */ | ||
Line 97: | Line 107: | ||
// URL-prefix for XML interface | // URL-prefix for XML interface | ||
- | $opac_url = ' | + | $opac_url = ' |
// URL-prefix for Bibsonomy' | // URL-prefix for Bibsonomy' | ||
Line 126: | Line 136: | ||
**/ | **/ | ||
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 143: | Line 157: | ||
/* | /* | ||
| | ||
+ | | ||
| | ||
- | | + | |
**/ | **/ | ||
function decodePica($str) { | function decodePica($str) { | ||
Line 181: | Line 196: | ||
} | } | ||
$res .= "</" | $res .= "</" | ||
+ | |||
+ | // return result | ||
return $res; | return $res; | ||
} | } | ||
Line 186: | Line 203: | ||
/* | /* | ||
| | ||
+ | | ||
| | ||
- | | + | |
**/ | **/ | ||
function decodePicaArray($str) { | function decodePicaArray($str) { | ||
Line 211: | Line 229: | ||
} //switch | } //switch | ||
} | } | ||
+ | |||
+ | // return result | ||
return $res; | return $res; | ||
} | } | ||
Line 216: | Line 236: | ||
/* | /* | ||
| | ||
+ | | ||
| | ||
- | | + | |
**/ | **/ | ||
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-> | + | |
- | $pica_array[$key] = $val; | + | |
- | | + | } 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 | ||
+ | | ||
} | } | ||
/* | /* | ||
| | ||
+ | | ||
| | ||
- | | + | |
**/ | **/ | ||
function getCode($ch) { | function getCode($ch) { | ||
Line 274: | Line 465: | ||
/* | /* | ||
| | ||
+ | | ||
| | ||
| | ||
- | | + | |
**/ | **/ | ||
function getCode2($ch) { | function getCode2($ch) { | ||
Line 295: | Line 487: | ||
/* | /* | ||
| | ||
- | | + | * class PicaRecord |
- | | + | * return simple |
+ | | ||
**/ | **/ | ||
function getDublinCore($str) { | function getDublinCore($str) { | ||
Line 321: | Line 514: | ||
$res .= "< | $res .= "< | ||
$res .="</ | $res .="</ | ||
+ | |||
+ | // return result | ||
return $res; | return $res; | ||
} | } | ||
Line 326: | Line 521: | ||
/* | /* | ||
| | ||
+ | | ||
| | ||
- | | + | |
**/ | **/ | ||
function getPicaPlus($str) { | function getPicaPlus($str) { | ||
$res = $this-> | $res = $this-> | ||
$res = $this-> | $res = $this-> | ||
+ | |||
+ | // return result | ||
return $res; | return $res; | ||
} | } | ||
Line 337: | Line 535: | ||
/* | /* | ||
| | ||
- | | + | * class PicaRecord |
- | | + | * rename numeric tags not allowed in XML |
+ | | ||
**/ | **/ | ||
function getTagName($ch) { | function getTagName($ch) { | ||
Line 350: | Line 549: | ||
/* | /* | ||
| | ||
- | | + | * class PicaRecord |
- | | + | * transform raw PICA data to valid XML |
+ | | ||
+ | | ||
**/ | **/ | ||
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 | ||
+ | | ||
} | } | ||
/* | /* | ||
| | ||
- | | + | * class PicaRecord |
- | | + | * read Dublin Core elements |
+ | | ||
**/ | **/ | ||
function readData($key, | function readData($key, | ||
Line 443: | 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 479: | 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 490: | Line 697: | ||
/* | /* | ||
| | ||
+ | | ||
| | ||
| | ||
Line 495: | Line 703: | ||
**/ | **/ | ||
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 | ||
+ | | ||
} | } | ||
/* | /* | ||
| | ||
+ | | ||
| | ||
| | ||
- | | + | |
**/ | **/ | ||
/* | /* | ||
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 | ||
+ | | ||
} | } | ||
*/ | */ | ||
Line 548: | Line 761: | ||
/* | /* | ||
| | ||
+ | | ||
| | ||
- | | + | |
**/ | **/ | ||
function readTag($val, | function readTag($val, | ||
Line 560: | Line 774: | ||
/* | /* | ||
| | ||
+ | | ||
| | ||
| | ||
Line 584: | Line 799: | ||
/* | /* | ||
| | ||
+ | | ||
| | ||
- | | + | |
**/ | **/ | ||
function transcribe_pica_rec($str) { | function transcribe_pica_rec($str) { | ||
Line 595: | Line 811: | ||
/* | /* | ||
| | ||
+ | | ||
| | ||
- | | + | |
**/ | **/ | ||
function transcribe_pica_utf8($str) { | function transcribe_pica_utf8($str) { | ||
Line 614: | Line 831: | ||
| | ||
| | ||
- | | + | |
- | | + | |
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
**/ | **/ | ||
class Picappn { | class Picappn { | ||
Line 627: | 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 640: | 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 652: | Line 889: | ||
$res = $text.$separator.$array[$category].$suffix; | $res = $text.$separator.$array[$category].$suffix; | ||
} | } | ||
+ | |||
+ | // return result | ||
return $res; | return $res; | ||
} | } | ||
Line 657: | Line 896: | ||
/* | /* | ||
| | ||
+ | | ||
| | ||
- | | + | |
**/ | **/ | ||
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 | ||
+ | | ||
} | } | ||
/* | /* | ||
| | ||
+ | | ||
| | ||
- | | + | |
**/ | **/ | ||
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[' | ||
- | |||
- | // DNB Number | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | |||
- | // OCLC Number | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | $res[' | ||
- | |||
- | // Foreign Data 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[' | ||
// return result | // return result | ||
Line 821: | Line 933: | ||
/* | /* | ||
| | ||
+ | | ||
| | ||
| | ||
Line 845: | Line 958: | ||
/* | /* | ||
| | ||
+ | | ||
| | ||
- | | + | |
**/ | **/ | ||
function getBibTex() { | function getBibTex() { | ||
Line 855: | 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 864: | 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 876: | 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 886: | Line 1021: | ||
} | } | ||
- | // | + | // |
if (isset($res)) { | if (isset($res)) { | ||
+ | // check if last characters of $res are ", | ||
+ | $res = rtrim($res, ", | ||
+ | // trailing element | ||
$res .= " | $res .= " | ||
+ | } | ||
+ | |||
+ | // return result | ||
+ | return $res; | ||
+ | } | ||
+ | |||
+ | /* | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | **/ | ||
+ | function getCsv() { | ||
+ | // check if $this-> | ||
+ | if ($this-> | ||
+ | |||
+ | // 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, " | ||
} | } | ||
Line 897: | Line 1071: | ||
/* | /* | ||
| | ||
+ | | ||
| | ||
- | | + | |
**/ | **/ | ||
function getData($ppn) { | function getData($ppn) { | ||
+ | // get global $use_curl as switch for the following conditional | ||
+ | global $use_curl; | ||
+ | |||
// check whether curl-Module is available, if not available use fallback | // check whether curl-Module is available, if not available use fallback | ||
- | if (function_exists(' | + | if (function_exists(' |
$ch = curl_init(" | $ch = curl_init(" | ||
curl_setopt($ch, | curl_setopt($ch, | ||
Line 913: | Line 1091: | ||
$res = file_get_contents(" | $res = file_get_contents(" | ||
} | } | ||
+ | |||
+ | // return result | ||
return $res; | return $res; | ||
} | } | ||
Line 918: | Line 1098: | ||
/* | /* | ||
| | ||
+ | | ||
| | ||
- | | + | |
**/ | **/ | ||
function getDublinCore() { | function getDublinCore() { | ||
+ | // retrieve data | ||
$res = $this-> | $res = $this-> | ||
+ | |||
+ | // format data | ||
$res = $this-> | $res = $this-> | ||
+ | |||
+ | // return result | ||
return $res; | return $res; | ||
} | } | ||
Line 929: | Line 1115: | ||
/* | /* | ||
| | ||
+ | | ||
| | ||
- | | + | |
**/ | **/ | ||
function getDublinCoreRDF() { | function getDublinCoreRDF() { | ||
+ | // retrieve data | ||
$res = $this-> | $res = $this-> | ||
+ | |||
+ | // put it to some XML structure | ||
$res = $this-> | $res = $this-> | ||
Line 939: | Line 1129: | ||
if (empty($res)) return ""; | if (empty($res)) return ""; | ||
+ | // format | ||
$res = "<? | $res = "<? | ||
$res .= "< | $res .= "< | ||
Line 965: | Line 1156: | ||
$res .= "</ | $res .= "</ | ||
$res .= "</ | $res .= "</ | ||
+ | |||
+ | // return result | ||
return $res; | return $res; | ||
} | } | ||
Line 970: | Line 1163: | ||
/* | /* | ||
| | ||
+ | | ||
| | ||
| | ||
Line 988: | Line 1182: | ||
/* | /* | ||
| | ||
+ | | ||
| | ||
| | ||
Line 998: | 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 1021: | Line 1216: | ||
$keys_nice[' | $keys_nice[' | ||
- | // type | + | // type: book |
$res .= '& | $res .= '& | ||
$res .= '& | $res .= '& | ||
Line 1028: | 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 1038: | 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 1051: | Line 1255: | ||
/* | /* | ||
| | ||
- | | + | * class Picappn |
- | | + | * return |
+ | | ||
**/ | **/ | ||
function getPicaPlus() { | function getPicaPlus() { | ||
Line 1058: | Line 1263: | ||
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; | ||
} | } | ||
Line 1069: | Line 1282: | ||
/* | /* | ||
| | ||
- | | + | * class Picappn |
- | | + | * return |
+ | | ||
**/ | **/ | ||
function getPlain() { | function getPlain() { | ||
Line 1076: | Line 1290: | ||
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 1094: | 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 1102: | 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 1134: | Line 1384: | ||
} | } | ||
} | } | ||
+ | |||
+ | // return result | ||
return $res; | return $res; | ||
} | } | ||
Line 1139: | Line 1391: | ||
/* | /* | ||
| | ||
- | | + | * class Picappn |
- | | + | * return XML formatted |
+ | | ||
**/ | **/ | ||
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 1153: | Line 1413: | ||
//$head .= "< | //$head .= "< | ||
$head .= "< | $head .= "< | ||
+ | |||
+ | // define suffix | ||
$tail = "</ | $tail = "</ | ||
+ | |||
+ | // return result | ||
return $head.$res.$tail; | return $head.$res.$tail; | ||
} | } | ||
/* public | /* public | ||
- | | + | |
- | | + | |
+ | | ||
**/ | **/ | ||
function setOpac($opac) { | function setOpac($opac) { | ||
Line 1166: | Line 1431: | ||
/* public | /* public | ||
- | | + | * class Picappn |
- | | + | * set PPN, the unAPI identifier |
+ | | ||
**/ | **/ | ||
function setPpn($ppn) { | function setPpn($ppn) { | ||
Line 1198: | Line 1464: | ||
**/ | **/ | ||
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 { |