From 4d3519dffdb54dd6e9d9d701cb0edb0cc724f8dd Mon Sep 17 00:00:00 2001 From: Joshua Ferraro Date: Tue, 8 Apr 2008 09:15:24 -0400 Subject: [PATCH] Partial fixes to enable unapi for non-zebra and non-public-facing sru Signed-off-by: Joshua Ferraro --- C4/Search.pm | 2 +- C4/XSLT.pm | 3 +-- .../prog/en/xslt/MARC21slim2OPACDetail.xsl | 7 +++++-- .../prog/en/xslt/MARC21slim2OPACResults.xsl | 1 + opac/opac-detail.pl | 2 +- opac/unapi | 21 ++++++++++++++++++- 6 files changed, 29 insertions(+), 7 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index cbff21f32d..e72222598e 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -1490,7 +1490,7 @@ s/\[(.?.?.?.?)$tagsubf(.*?)]/$1$subfieldvalue$2\[$1$tagsubf$2]/g; # XSLT processing of some stuff if (C4::Context->preference("XSLTResultsDisplay") ) { - my $newxmlrecord = XSLTParse4Display($oldbiblio->{biblionumber},'Results'); + my $newxmlrecord = XSLTParse4Display($oldbiblio->{biblionumber},C4::Context->config('opachtdocs')."/prog/en/xslt/MARC21slim2OPACResults.xsl"); $oldbiblio->{XSLTResultsRecord} = $newxmlrecord; } diff --git a/C4/XSLT.pm b/C4/XSLT.pm index d6cdcfaef1..4a383fbdbf 100644 --- a/C4/XSLT.pm +++ b/C4/XSLT.pm @@ -101,13 +101,12 @@ sub getAuthorisedValues4MARCSubfields { } sub XSLTParse4Display { - my ($biblionumber,$type) = @_; + my ($biblionumber,$xslfile) = @_; # grab the XML, run it through our stylesheet, push it out to the browser my $record = transformMARCXML4XSLT($biblionumber); my $itemsxml = buildKohaItemsNamespace($biblionumber); my $xmlrecord = $record->as_xml(); $xmlrecord =~ s/\<\/record\>/$itemsxml\<\/record\>/; - my $xslfile = C4::Context->config('opachtdocs')."/prog/en/xslt/MARC21slim2OPAC$type.xsl"; my $parser = XML::LibXML->new(); # don't die when you find &, >, etc $parser->recover_silently(1); diff --git a/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACDetail.xsl b/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACDetail.xsl index dbeffa6918..72182ed25e 100644 --- a/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACDetail.xsl +++ b/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACDetail.xsl @@ -54,6 +54,7 @@ ab + .; @@ -139,7 +140,7 @@

- +

Library of Congress Classification:

@@ -185,8 +186,10 @@

ISBN: + - + + .;

diff --git a/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACResults.xsl b/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACResults.xsl index ee98035455..d8ba11b59e 100644 --- a/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACResults.xsl +++ b/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACResults.xsl @@ -377,6 +377,7 @@ ab + .; diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index f017bcc035..40564726f0 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -51,7 +51,7 @@ my $biblionumber = $query->param('biblionumber') || $query->param('bib'); $template->param( biblionumber => $biblionumber ); # XSLT processing of some stuff if (C4::Context->preference("XSLTResultsDisplay") ) { - my $newxmlrecord = XSLTParse4Display($biblionumber,'Detail'); + my $newxmlrecord = XSLTParse4Display($biblionumber,C4::Context->config('opachtdocs')."/prog/en/xslt/MARC21slim2OPACDetail.xsl"); $template->param('XSLTBloc' => $newxmlrecord); } diff --git a/opac/unapi b/opac/unapi index 1197be5422..b6d03b3369 100755 --- a/opac/unapi +++ b/opac/unapi @@ -17,11 +17,30 @@ 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) my $url = "http://$baseurl:9998/biblios?version=1.1&operation=searchRetrieve&query=$id&startRecord=1&maximumRecords=20&recordSchema=$format"; - my $content = get($url); + 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; } -- 2.39.5