(bug #4051) add due date in overdue.tmpl
[koha.git] / opac / unapi
index 1197be5..cd17881 100755 (executable)
@@ -17,11 +17,32 @@ warn "Warning: OPACBaseURL not set in system preferences" unless $baseurl;
 my $id = $cgi->param('id');
 my $format = $cgi->param('format');
 if ($id && $format) {
+
     # koha:isbn:0152018484
     if ($id =~ /isbn/) {
         $id =~ s/koha:isbn://;
-        my $url = "http://$baseurl:9998/biblios?version=1.1&operation=searchRetrieve&query=$id&startRecord=1&maximumRecords=20&recordSchema=$format";
-        my $content = get($url);
+
+        # two ways to do this, one via the SRU Zebra server (fast)
+        # FIXME - getting the SRU URL this way is purely guesswork
+        $baseurl =~ s/:\d+$//; # parse off OPAC port
+        my $url = "$baseurl:9998/biblios?version=1.1&operation=searchRetrieve&query=$id&startRecord=1&maximumRecords=20&recordSchema=$format";
+        my $content= get($url);
+
+        # the other via XSL parsing (not as fast)
+        unless ($content) {
+            
+        eval {
+            my $conn = C4::Context->Zconn('biblioserver');
+            $conn->option(preferredRecordSyntax => $format);
+            my $rs = $conn->search_pqf('@attr 1=7 '.$id);
+            my $n = $rs->size();
+            $content = $rs->record(0)->raw();
+        };
+        if ($@) {
+            print "Error ", $@->code(), ": ", $@->message(), "\n";
+        }
+
+        }
         print $cgi->header( -type =>'application/xml' );
         print $content;
     }