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:picarecord.php [2009-12-14 14:14] – Added function "convOutputNice", "getArrayNice", "getBibsonomy", "getKeysText" and "getKeysBibTex" to class "Picappn" strols | buechereielektrik:unapi:picarecord.php [2009-12-26 14:44] – rosenke | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | < | + | < |
<?php | <?php | ||
Line 27: | Line 27: | ||
/* Changelog | /* Changelog | ||
* | * | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
| | ||
| | ||
+ | | ||
| | ||
| | ||
Line 48: | Line 55: | ||
$bibsonomy_url = " | $bibsonomy_url = " | ||
+ | |||
+ | $filter_nice = array( | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
/** represents a bibliographic data record from oclc/pica LBS | /** represents a bibliographic data record from oclc/pica LBS | ||
Line 115: | Line 127: | ||
$ch = substr($str, | $ch = substr($str, | ||
$tag = $this-> | $tag = $this-> | ||
+ | | ||
| | ||
- | |||
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, | ||
- | $res .= $this-> | + | $res[$tag] |
| | ||
- | |||
default: | default: | ||
| | ||
| | ||
} //switch | } //switch | ||
- | |||
} | } | ||
return $res; | return $res; | ||
Line 205: | Line 214: | ||
function getDublinCore($str) { | function getDublinCore($str) { | ||
$res = $this-> | $res = $this-> | ||
+ | |||
+ | if (empty($res)) return ""; | ||
$res = "<? | $res = "<? | ||
Line 374: | Line 385: | ||
break; | break; | ||
} | } | ||
- | | + | //return $res; |
} | } | ||
/** public -- parse dublin core data */ | /** public -- parse dublin core data */ | ||
//client functionality | //client functionality | ||
+ | // comment out if using PHP4 | ||
function readDublinCore($str) { | function readDublinCore($str) { | ||
$doc = new DomDocument(); | $doc = new DomDocument(); | ||
Line 403: | Line 415: | ||
/** public -- parse dublin core data */ | /** public -- parse dublin core data */ | ||
// experimental, | // experimental, | ||
+ | /* | ||
function readRDF_DC($str) { | function readRDF_DC($str) { | ||
$doc = new DomDocument(); | $doc = new DomDocument(); | ||
Line 424: | Line 437: | ||
| | ||
} | } | ||
+ | */ | ||
/** private -- read tag content from string */ | /** private -- read tag content from string */ | ||
Line 522: | Line 536: | ||
if (empty($array_raw)) return ""; | if (empty($array_raw)) return ""; | ||
$record = $array_raw; | $record = $array_raw; | ||
+ | |||
+ | global $filter_nice; | ||
//Type | //Type | ||
- | $res[' | + | $res[' |
//Author | //Author | ||
- | $res[' | + | $res[' |
//Editor | //Editor | ||
- | $res[' | + | $res[' |
//Title | //Title | ||
- | $res[' | + | $res[' |
//Series | //Series | ||
- | $res[' | + | $res[' |
//Address, especially city | //Address, especially city | ||
- | $res[' | + | $res[' |
//Publisher | //Publisher | ||
- | $res[' | + | $res[' |
//Edition | //Edition | ||
- | $res[' | + | $res[' |
//Year | //Year | ||
- | $res[' | + | $res[' |
//ISBNs | //ISBNs | ||
- | $res[' | + | $res[' |
- | $res[' | + | $res[' |
//PPN | //PPN | ||
- | $res[' | + | $res[' |
return $res; | return $res; | ||
} | } | ||
Line 559: | Line 575: | ||
function getBibsonomy() { | function getBibsonomy() { | ||
if ($this-> | if ($this-> | ||
- | $record_raw = $this-> | ||
- | $record_nice = $this-> | ||
- | $keys_nice = $this-> | ||
- | |||
- | if (substr($record_nice[' | ||
- | //Type | ||
- | $res .= "@book {"; | ||
- | |||
- | //create identifier | ||
- | $res .= $this-> | ||
- | $res .= $this-> | ||
- | |||
- | //Author et al. | ||
- | $i = array(' | ||
- | ' | ||
- | foreach ($i as $j) { | ||
- | $res .= $this-> | ||
- | } | ||
- | |||
- | //Call Number | ||
- | $res .= $this-> | ||
- | } | ||
- | $res .= " | ||
+ | $res = $this-> | ||
$res = urlencode($res); | $res = urlencode($res); | ||
Line 598: | Line 592: | ||
$record_nice = $this-> | $record_nice = $this-> | ||
$keys_nice = $this-> | $keys_nice = $this-> | ||
+ | |||
+ | //make sure there is only one ISBN | ||
+ | if (!empty($record_nice[' | ||
if (substr($record_nice[' | if (substr($record_nice[' | ||
//Type | //Type | ||
- | $res .= "@book {"; | + | $res = "@book {"; |
//create identifier | //create identifier | ||
Line 610: | Line 607: | ||
$i = array(' | $i = array(' | ||
' | ' | ||
+ | |||
foreach ($i as $j) { | foreach ($i as $j) { | ||
$res .= $this-> | $res .= $this-> | ||
Line 623: | Line 621: | ||
/** private -- get data via pica xml interface */ | /** private -- get data via pica xml interface */ | ||
function getData($ppn) { | function getData($ppn) { | ||
- | $ch = curl_init(" | + | |
- | curl_setopt($ch, | + | if (function_exists(' |
- | curl_setopt($ch, | + | |
- | // | + | curl_setopt($ch, |
- | curl_setopt($ch, | + | curl_setopt($ch, |
- | $res = curl_exec($ch); | + | // |
- | curl_close($ch); | + | curl_setopt($ch, |
+ | $res = curl_exec($ch); | ||
+ | curl_close($ch); | ||
+ | } else { | ||
+ | $res = file_get_contents(" | ||
+ | } | ||
return $res; | return $res; | ||
} | } | ||
Line 644: | Line 647: | ||
$res = $this-> | $res = $this-> | ||
$res = $this-> | $res = $this-> | ||
+ | |||
+ | if (empty($res)) return ""; | ||
$res = "<? | $res = "<? | ||
Line 653: | Line 658: | ||
| | ||
$res .= "< | $res .= "< | ||
- | .$this-> | + | .$this-> |
$res .= "< | $res .= "< | ||
$res .= "< | $res .= "< | ||
Line 671: | Line 676: | ||
$res .= "</ | $res .= "</ | ||
$res .= "</ | $res .= "</ | ||
+ | return $res; | ||
+ | } | ||
+ | |||
+ | /** public -- return JSON record from pica data */ | ||
+ | //used by unapi | ||
+ | function getJson() { | ||
+ | if ($this-> | ||
+ | |||
+ | $res = $this-> | ||
+ | //(PHP 5 >= 5.2.0, PECL json >= 1.2.0) | ||
+ | $res = json_encode($res); | ||
+ | |||
return $res; | return $res; | ||
} | } | ||
Line 768: | Line 785: | ||
$record_nice = $this-> | $record_nice = $this-> | ||
$keys_nice = $this-> | $keys_nice = $this-> | ||
+ | $res = ""; | ||
if (substr($record_nice[' | if (substr($record_nice[' |