Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
buechereielektrik:unapi:unapi.inc.php [2010-01-31 19:14] – Added (e)Journals to "getBibTex()", "getOpenUrlKev()" and "getText()" in class "Picappn" rosenkebuechereielektrik:unapi:unapi.inc.php [2010-03-03 17:13] strols
Line 52: Line 52:
   Changelog   Changelog
  *  *
 +  20100303: Added check of $use_curl as additional switch for de-
 + * activating curl.
 +  20100219: Added function "getCsv()" to class "Picappn".
 + * Renamend keys "RVK" to "rvk" and "DDC" to "ddc".
   20100131: Added (e)Journals to "getBibTex()", "getOpenUrlKev()" and   20100131: Added (e)Journals to "getBibTex()", "getOpenUrlKev()" and
  * "getText()" in class "Picappn".  * "getText()" in class "Picappn".
Line 103: Line 107:
  
 //  URL-prefix for XML interface //  URL-prefix for XML interface
-$opac_url = 'http://example.com/DB=foo/XML=1.0/PPN?PPN=';+$opac_url = 'http://example.com/DB=1/XML=1.0/PPN?PPN=';
  
 //  URL-prefix for Bibsonomy's BibTeX import //  URL-prefix for Bibsonomy's BibTeX import
Line 264: Line 268:
     class PicaRecord     class PicaRecord
     return bibliographic data in array with speaking keys     return bibliographic data in array with speaking keys
-    Used by Picappn->{getBibTex,getOpenUrlKev,getText}+    Used by Picappn->{getBibTex,getCsv,getOpenUrlKev,getText}
   **/   **/
   function getArrayNice($array_raw) {   function getArrayNice($array_raw) {
Line 406: Line 410:
  
     //  DDC     //  DDC
-    $res['DDC'] = strtr($record['045B']['a'], $filter_nice); +    $res['ddc'] = strtr($record['045B']['a'], $filter_nice); 
-    $res['_bibtex']['DDC'] = ''; +    $res['_bibtex']['ddc'] = ''; 
-    $res['_openurlkev']['DDC'] = ''; +    $res['_openurlkev']['ddc'] = ''; 
-    $res['_text']['DDC'] = 'DDC';+    $res['_text']['ddc'] = 'DDC';
  
     //  RVK     //  RVK
-    $res['RVK'] = strtr($record['045Z']['a'], $filter_nice); +    $res['rvk'] = strtr($record['045Z']['a'], $filter_nice); 
-    $res['_bibtex']['RVK'] = 'keywords'; +    $res['_bibtex']['rvk'] = 'keywords'; 
-    $res['_openurlkev']['RVK'] = ''; +    $res['_openurlkev']['rvk'] = ''; 
-    $res['_text']['RVK'] = 'RVK';+    $res['_text']['rvk'] = 'rvk';
  
     //  EZB link     //  EZB link
Line 830: Line 834:
   - Bibsonomy: Picappn->getBibsonomy   - Bibsonomy: Picappn->getBibsonomy
   - BibTex: Picappn->getBibTex   - BibTex: Picappn->getBibTex
 +  - CSV: Picappn->getCsv
   - Dublin Core: Picappn->getDublinCore   - Dublin Core: Picappn->getDublinCore
   - RDF: Picappn->getDublinCoreRDF   - RDF: Picappn->getDublinCoreRDF
Line 912: Line 917:
     class Picappn     class Picappn
     return record as Array     return record as Array
-    Used by Picappn->{getBibTex,getJson,getOpenUrlKev,getText}+    Used by Picappn->{getBibTex,getCsv,getJson,getOpenUrlKev,getText}
   **/   **/
   function getArray() {   function getArray() {
Line 1022: Line 1027:
       //  trailing element       //  trailing element
       $res .= "\n}";       $res .= "\n}";
 +    }
 +
 +    //  return result
 +    return $res;
 +  }
 +
 +  /*
 +    public
 +    class Picappn
 +    Return CSV record from pica data
 +    Used by unAPI.php
 +  **/
 +  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->getArray($this->ppn);
 +    //  transform raw to nice array
 +    $record_nice = $this->prec->getArrayNice($record_raw);
 +    //  declare $res
 +    $res = '';
 +
 +    //  set categories to used for CSV
 +    $i = array('ppn', 'author', 'editor', 'title', 'address', 'year', 'isbn10',
 +     'isbn13', 'issn', 'dnb_no', 'oclc_no', 'fdin', 'zdb_id', 'rvk');
 +
 +    //  fetch them from array, format and output them
 +    foreach ($i as $j) {
 +      $res .= '"'.$record_nice["$j"].'"|'; 
 +    }
 +
 +    //  stripping et al.
 +    if (isset($res)) {
 +      //  check if last characters of $res are ",\n" and trim them
 +      $res = rtrim($res, "|");
     }     }
  
Line 1035: Line 1076:
   **/   **/
   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('curl_init')) {+    if (function_exists('curl_init'&& $use_curl != 'no') {
       $ch = curl_init("$this->url");       $ch = curl_init("$this->url");
       curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);       curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
Line 1282: Line 1326:
       //  set the field which are fetched: author et al.       //  set the field which are fetched: author et al.
       $i = array('author', 'editor', 'title', 'series', 'address', 'publisher',       $i = array('author', 'editor', 'title', 'series', 'address', 'publisher',
-        'edition', 'year', 'isbn10', 'isbn13', 'pages', 'RVK', 'DDC', 'link',+        'edition', 'year', 'isbn10', 'isbn13', 'pages', 'rvk', 'ddc', 'link',
         'toc', 'ppn', 'dnb_no', 'oclc_no', 'fdin');         'toc', 'ppn', 'dnb_no', 'oclc_no', 'fdin');
  
Line 1313: Line 1357:
  
       //  set the field which are fetched: title et al.       //  set the field which are fetched: title et al.
-      $i = array('title', 'address', 'publisher', 'issn', 'everlauf', 'RVK',+      $i = array('title', 'address', 'publisher', 'issn', 'everlauf', 'rvk',
         'zdb_id', 'ppn', 'ezb_link');         'zdb_id', 'ppn', 'ezb_link');
  
buechereielektrik/unapi/unapi.inc.php.txt · Last modified: 2011-01-20 17:12 by strols
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0