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-27 20:21] – Added link in copyright 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
 + * "getText()" in class "Picappn".
   20100127: Added link in copyright.   20100127: Added link in copyright.
   20100126: Transfered "getArrayNice()" from class "Picappn" to   20100126: Transfered "getArrayNice()" from class "Picappn" to
Line 101: Line 107:
  
 //  URL-prefix for XML interface //  URL-prefix for XML interface
-$opac_url = 'http://pica1l.lhb.tu-darmstadt.de/DB=LHBDA/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 262: 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 322: Line 328:
     $res['_openurlkev']['publisher'] = 'rft.pub';     $res['_openurlkev']['publisher'] = 'rft.pub';
     $res['_text']['publisher'] = 'Verlag';     $res['_text']['publisher'] = 'Verlag';
 +
     //  edition     //  edition
     $res['edition'] = strtr($record['032@']['a'], $filter_nice);     $res['edition'] = strtr($record['032@']['a'], $filter_nice);
Line 332: Line 339:
     $res['_openurlkev']['year'] = 'rft.date';     $res['_openurlkev']['year'] = 'rft.date';
     $res['_text']['year'] = 'Jahr';     $res['_text']['year'] = 'Jahr';
 +    //  Erscheinungsverlauf
 +    $res['everlauf'] = strtr($record['031@']['a'], $filter_nice);
 +    $res['_bibtex']['everlauf'] = '';
 +    $res['_openurlkev']['everlauf'] = '';
 +    $res['_text']['everlauf'] = 'Erscheinungsverlauf';
  
     //  pages     //  pages
Line 348: Line 360:
     $res['_openurlkev']['isbn13'] = 'rft.isbn';     $res['_openurlkev']['isbn13'] = 'rft.isbn';
     $res['_text']['isbn13'] = 'ISBN-13';     $res['_text']['isbn13'] = 'ISBN-13';
 +
 +    //  ISSN
 +    $res['issn'] = strtr($record['005A']['x0'], $filter_nice);
 +    $res['_bibtex']['issn'] = '  issn';
 +    $res['_openurlkev']['issn'] = 'rft.issn';
 +    $res['_text']['issn'] = 'ISSN';
  
     //  DNB Number     //  DNB Number
Line 366: Line 384:
     $res['_openurlkev']['fdin'] = '';     $res['_openurlkev']['fdin'] = '';
     $res['_text']['fdin'] = 'Fremddaten-Identifikationsnummer';     $res['_text']['fdin'] = 'Fremddaten-Identifikationsnummer';
 +
 +    //  ZDB identification number
 +    $res['zdb_id'] = strtr($record['007A']['x0'], $filter_nice);
 +    $res['_bibtex']['zdb_id'] = '';
 +    $res['_openurlkev']['zdb_id'] = '';
 +    $res['_text']['zdb_id'] = 'ZDB-ID';
  
     //  PPN     //  PPN
Line 386: 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 
 +    $res['ezb_link'] = strtr($record['209S/01']['u'], $filter_nice); 
 +    $res['_bibtex']['ezb_link'] = '  url'; 
 +    $res['_openurlkev']['ezb_link'] = ''; 
 +    $res['_text']['ezb_link'] = 'EZB-Link';
  
     //  return result     //  return result
Line 804: 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 886: 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 947: Line 978:
     if (!empty($record_nice['isbn13'])) unset($record_nice['isbn10']);     if (!empty($record_nice['isbn13'])) unset($record_nice['isbn10']);
  
-    / check type and choose right BibTeX-type+    /
 +      check type and choose right BibTeX-type 
 +      "book" works quite well, "journal" not so 
 +    **/
     if (preg_match('/^[AO][aeEfF]$/',$record_nice['twokr'])) {     if (preg_match('/^[AO][aeEfF]$/',$record_nice['twokr'])) {
-      //  type+      //  type: book
       $res = "@book {";       $res = "@book {";
  
Line 959: Line 993:
       $i = array('author', 'editor', 'title', 'series', 'address', 'publisher',       $i = array('author', 'editor', 'title', 'series', 'address', 'publisher',
         'edition', 'year', 'isbn10', 'isbn13', 'link');         'edition', 'year', 'isbn10', 'isbn13', 'link');
 +
 +      //  fetch them from array, format and output them
 +      foreach ($i as $j) {
 +        $res .= $this->convOutputNice($record_nice,$keys_nice,$j," = {","},\n");
 +      }
 +
 +      //  get call number, format and output it
 +      $res .= $this->convOutput($record_raw,"  note"," = {","209A/01",'a',"}");
 +    } elseif (preg_match('/^[AO]b$/',$record_nice['twokr'])) {
 +      //  type: journal
 +      $res = "@misc {";
 +
 +      //  create identifier
 +      $res .= $this->convOutput($record_raw,"","",'003@','x0',"");
 +      $res .= $this->convOutput($record_raw,"","",'011@','a',",\n");
 +
 +      //  set the field which are fetched: title et al.
 +      $i = array('title', 'address', 'publisher', 'issn', 'ezb_link');
  
       //  fetch them from array, format and output them       //  fetch them from array, format and output them
Line 969: Line 1021:
     }     }
  
-    //  trailing element+    //  stripping et al.
     if (isset($res)) {     if (isset($res)) {
 +      //  check if last characters of $res are ",\n" and trim them
 +      $res = rtrim($res, ",\n");
 +      //  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 985: 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 1122: Line 1216:
       $keys_nice['title'] = 'rft.btitle';       $keys_nice['title'] = 'rft.btitle';
  
-      //  type+      //  type: book
       $res .= '&rft_val_fmt='.urlencode('info:ofi/fmt:kev:mtx:book');       $res .= '&rft_val_fmt='.urlencode('info:ofi/fmt:kev:mtx:book');
       $res .= '&rft.genre=book&';       $res .= '&rft.genre=book&';
Line 1129: Line 1223:
       $i = array('author', 'editor', 'title', 'series', 'address', 'publisher',       $i = array('author', 'editor', 'title', 'series', 'address', 'publisher',
         'edition', 'year', 'isbn10', 'isbn13', 'pages');         'edition', 'year', 'isbn10', 'isbn13', 'pages');
 +
 +      //  fetch them from array, format, url-encode and output them
 +      foreach ($i as $j) {
 +        $record_nice[$j] = urlencode($record_nice[$j]);
 +        $res .= $this->convOutputNice($record_nice,$keys_nice,$j,"=","&");
 +      }
 +    } elseif (preg_match('/^[AO]b$/',$record_nice['twokr'])) {
 +      //  type: journal/article
 +      $res .= '&rft_val_fmt='.urlencode('info:ofi/fmt:kev:mtx:journal');
 +      $res .= '&rft.genre=article&';
 +
 +      //  set the field which are fetched: author et al.
 +      $i = array('title', 'address', 'publisher', 'issn');
  
       //  fetch them from array, format, url-encode and output them       //  fetch them from array, format, url-encode and output them
Line 1139: Line 1246:
     //  strip trailing "&" if necessary     //  strip trailing "&" if necessary
     if (isset($res)) {     if (isset($res)) {
-      $length = strlen($res); +      $res = rtrim($res, "&");
-      $last strrpos($res,"&"); +
-      if ( $length == $last+5 ) { +
-        $res = substr($res,0,-5); +
-      }+
     }     }
  
Line 1218: Line 1321:
     //  check type and choose right type     //  check type and choose right type
     if (preg_match('/^[AO][aeEfF]$/',$record_nice['twokr'])) {     if (preg_match('/^[AO][aeEfF]$/',$record_nice['twokr'])) {
-      //  type+      //  type: book
       $res .= $keys_nice['type'].":\t\tMonographie\n";       $res .= $keys_nice['type'].":\t\tMonographie\n";
  
       //  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');
 +
 +      //  fetch them from array, format and output them
 +      foreach ($i as $j) {
 +        $res .= $this->convOutputNice($record_nice,$keys_nice,$j,":\t\t","\n");
 +      }
 +
 +      //  call number
 +      $i = 1;
 +      $j = 0;
 +      while ( $i <= 99 ) {
 +        if (($i <= 9) && ($j == 0)) {
 +          $j = "0".$i;
 +        } elseif (($i > 9) && ($j == 0)) {
 +          $j = $i;
 +        }
 +        $res .= $this->convOutput($record_raw,"Signatur",":\t","209A/$j",'a',"\n");
 +        $i++;
 +        if ($i <= 9 ) {
 +          $j = "0".$i;
 +        } else {
 +          $j = $i;
 +        }
 +        if (empty($record_raw["209A/$j"]['a'])) break;
 +      }
 +    } elseif (preg_match('/^[AO]b$/',$record_nice['twokr'])) {
 +      //  type: journal
 +      $res .= $keys_nice['type'].":\t\tZeitschrift\n";
 +
 +      //  set the field which are fetched: title et al.
 +      $i = array('title', 'address', 'publisher', 'issn', 'everlauf', 'rvk',
 +        'zdb_id', 'ppn', 'ezb_link');
  
       //  fetch them from array, format and output them       //  fetch them from array, format and output them
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