#!/usr/bin/perl use CGI; use strict; use warnings; use C4::Context; use XML::Simple; use LWP::Simple; use LWP::UserAgent; use HTTP::Request::Common; my $cgi = new CGI; binmode(STDOUT, "utf8"); #output as utf8 my $baseurl = C4::Context->preference('OPACBaseURL'); 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://; # 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; } } else { print $cgi->header( -type =>'application/xml' ); print " "; }