[Koha-patches] [PATCH 1/2] Bug 3213 - UNIMARC/MARC21 selection

Frédéric Demians f.demians at tamil.fr
Mon May 11 13:41:49 CEST 2009


Modify how XSLT stylesheet are choosen
depending on 'marcflavour' syspref.

DOCUMENTATION: XSLTResultsDisplay and XSLTDetailsDisplay
sysprefs aren't MARC21-only anymore.
---
 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 f96149f..9aaecf2 100644
--- a/C4/Search.pm
+++ b/C4/Search.pm
@@ -1504,8 +1504,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 8c576b3..60e8496 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 6505741..3e032de 100755
--- a/opac/opac-detail.pl
+++ b/opac/opac-detail.pl
@@ -63,8 +63,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') );
 }
 
 $template->param('OPACShowCheckoutName' => C4::Context->preference("OPACShowCheckoutName") ); 
-- 
1.5.6.5




More information about the Koha-patches mailing list