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
Next revisionBoth sides next revision
buechereielektrik:unapi:picarecord.php [2009-12-15 20:55] – Added function "getJson" to class "Picappn". Made ISBN in getBibTex() unique. Filtered some characters in getArrayNice(). strolsbuechereielektrik:unapi:picarecord.php [2009-12-20 14:51] – Some minor bugfixes. strols
Line 27: Line 27:
 /*  Changelog /*  Changelog
  *  *
 +  20091220: Check whether curl-Module is available, if not use
 +              file_get_contents().
 +              Some minor bugfixes.
   20091215:   Added function "getJson" to class "Picappn".   20091215:   Added function "getJson" to class "Picappn".
               Made ISBN in getBibTex() unique.               Made ISBN in getBibTex() unique.
Line 124: Line 127:
              $ch = substr($str,++$i,1); //new tag ahead              $ch = substr($str,++$i,1); //new tag ahead
              $tag = $this->getTagName($ch);              $tag = $this->getTagName($ch);
 +             $res[$tag] = "";
              break;              break;
- 
           case 30: //information separator two, another field to follow           case 30: //information separator two, another field to follow
              break;              break;
- 
           case 226: //pica two byte char accent like "é";           case 226: //pica two byte char accent like "é";
              $ch = substr($str,++$i,1); // read one char ahead              $ch = substr($str,++$i,1); // read one char ahead
-             $res .= $this->getCode2($ch);+             $res[$tag] .= $this->getCode2($ch);
              break;              break;
- 
           default:           default:
              $res[$tag] .= $this->getCode($ch);              $res[$tag] .= $this->getCode($ch);
              break;              break;
         } //switch         } //switch
- 
     }     }
     return $res;     return $res;
Line 385: Line 385:
             break;             break;
      }      }
-     return $res;+     //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 414: Line 415:
   /** public -- parse dublin core data */   /** public -- parse dublin core data */
   //  experimental, does not work   //  experimental, does not work
 +  /*
   function readRDF_DC($str) {   function readRDF_DC($str) {
      $doc = new DomDocument();      $doc = new DomDocument();
Line 435: Line 437:
      return $res;      return $res;
   }   }
 +  */
  
   /** private -- read tag content from string */   /** private -- read tag content from string */
Line 595: Line 598:
     if (substr($record_nice['type'], 0, 2) == "Aa") {     if (substr($record_nice['type'], 0, 2) == "Aa") {
       //Type       //Type
-      $res .= "@book {";+      $res = "@book {";
  
       //create identifier       //create identifier
Line 618: 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("$this->url"); +    //check whether curl-Module is available, if not available use fallback 
-    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); +    if (function_exists('curl_init')) { 
-    curl_setopt($ch, CURLOPT_COOKIE, session_name().'='.session_id() );  +      $ch = curl_init("$this->url"); 
-    //curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1 );  +      curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); 
-    curl_setopt($ch, CURLOPT_HEADER, 0); +      curl_setopt($ch, CURLOPT_COOKIE, session_name().'='.session_id() );  
-    $res = curl_exec($ch); +      //curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1 );  
-    curl_close($ch);+      curl_setopt($ch, CURLOPT_HEADER, 0); 
 +      $res = curl_exec($ch); 
 +      curl_close($ch); 
 +    } else { 
 +      $res = file_get_contents("$this->url"); 
 +    }
     return $res;     return $res;
   }   }
Line 650: Line 658:
              xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n";              xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n";
     $res .= "<rdf:Description rdf:about=\""     $res .= "<rdf:Description rdf:about=\""
-            .$this->myself."?ppn=$ppn&amp;format=rdf"."\">\n";+            .$this->myself."?ppn=".$this->ppn."&amp;format=rdf"."\">\n";
     $res .= "<dc:contributor>".$this->prec->contributor."</dc:contributor>\n";     $res .= "<dc:contributor>".$this->prec->contributor."</dc:contributor>\n";
     $res .= "<dc:coverage>".$this->prec->coverage."</dc:coverage>\n";     $res .= "<dc:coverage>".$this->prec->coverage."</dc:coverage>\n";
Line 777: Line 785:
     $record_nice = $this->getArrayNice($record_raw);     $record_nice = $this->getArrayNice($record_raw);
     $keys_nice = $this->getKeysText();     $keys_nice = $this->getKeysText();
 +    $res = "";
  
     if (substr($record_nice['type'], 0, 2) == "Aa") {     if (substr($record_nice['type'], 0, 2) == "Aa") {
buechereielektrik/unapi/picarecord.php.txt · Last modified: 2010-01-10 22:28 by rosenke
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0