From e7f8b610852cb532f7320078643163570bf1fa14 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20Demians?= Date: Mon, 11 May 2009 13:41:49 +0200 Subject: [PATCH] Bug 3213 - UNIMARC/MARC21 selection Modify how XSLT stylesheet are choosen depending on 'marcflavour' syspref. DOCUMENTATION: XSLTResultsDisplay and XSLTDetailsDisplay sysprefs aren't MARC21-only anymore. Signed-off-by: Galen Charlton Signed-off-by: Henri-Damien LAURENT --- C4/Search.pm | 4 ++-- C4/XSLT.pm | 9 ++++++--- opac/opac-detail.pl | 4 ++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index 6edf8ddd3e..bef20e6017 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -1528,8 +1528,8 @@ s/\[(.?.?.?.?)$tagsubf(.*?)]/$1$subfieldvalue$2\[$1$tagsubf$2]/g; # XSLT processing of some stuff if (C4::Context->preference("XSLTResultsDisplay") && !$scan) { - my $newxmlrecord = XSLTParse4Display($oldbiblio->{biblionumber}, $marcrecord, C4::Context->config('opachtdocs')."/prog/en/xslt/MARC21slim2OPACResults.xsl"); - $oldbiblio->{XSLTResultsRecord} = $newxmlrecord; + $oldbiblio->{XSLTResultsRecord} = XSLTParse4Display( + $oldbiblio->{biblionumber}, $marcrecord, 'Results' ); } # last check for norequest : if itemtype is notforloan, it can't be reserved either, whatever the items diff --git a/C4/XSLT.pm b/C4/XSLT.pm index 8c576b338c..60e8496267 100644 --- a/C4/XSLT.pm +++ b/C4/XSLT.pm @@ -54,7 +54,6 @@ C4::XSLT - Functions for displaying XSLT-generated content sub transformMARCXML4XSLT { my ($biblionumber, $orig_record) = @_; my $record = $orig_record->clone(); # not updating original record; this may be unnecessarily paranoid - my $biblio = GetBiblioData($biblionumber); my $frameworkcode = GetFrameworkCode($biblionumber); my $tagslib = &GetMarcStructure(1,$frameworkcode); my @fields; @@ -80,7 +79,7 @@ sub transformMARCXML4XSLT { $authvalue->{tagfield}, $field->indicator(1), $field->indicator(2), - $authvalue->{tagsubfield} => @newSubfields + @newSubfields ); $field->replace_with($newField); } @@ -120,7 +119,7 @@ sub getAuthorisedValues4MARCSubfields { my $stylesheet; sub XSLTParse4Display { - my ($biblionumber, $orig_record, $xslfile) = @_; + my ( $biblionumber, $orig_record, $xsl_suffix ) = @_; # grab the XML, run it through our stylesheet, push it out to the browser my $record = transformMARCXML4XSLT($biblionumber, $orig_record); my $itemsxml = buildKohaItemsNamespace($biblionumber); @@ -132,6 +131,10 @@ sub XSLTParse4Display { my $source = $parser->parse_string($xmlrecord); unless ( $stylesheet ) { my $xslt = XML::LibXSLT->new(); + my $xslfile = C4::Context->config('opachtdocs') . + "/prog/en/xslt/" . + C4::Context->preference('marcflavour') . + "slim2OPAC$xsl_suffix.xsl"; my $style_doc = $parser->parse_file($xslfile); $stylesheet = $xslt->parse_stylesheet($style_doc); } diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index 8100886966..beb695f718 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -62,8 +62,8 @@ my $record = GetMarcBiblio($biblionumber); $template->param( biblionumber => $biblionumber ); # XSLT processing of some stuff if (C4::Context->preference("XSLTDetailsDisplay") ) { - my $newxmlrecord = XSLTParse4Display($biblionumber, $record, C4::Context->config('opachtdocs')."/prog/en/xslt/MARC21slim2OPACDetail.xsl"); - $template->param('XSLTBloc' => $newxmlrecord); + $template->param( + 'XSLTBloc' => XSLTParse4Display($biblionumber, $record, 'Detail') ); } # change back when ive fixed request.pl -- 2.39.5