Bug 3213 - UNIMARC/MARC21 selection
authorFrédéric Demians <f.demians@tamil.fr>
Mon, 11 May 2009 11:41:49 +0000 (13:41 +0200)
committerGalen Charlton <galen.charlton@liblime.com>
Mon, 11 May 2009 12:35:53 +0000 (07:35 -0500)
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 <galen.charlton@liblime.com>
C4/Search.pm
C4/XSLT.pm
opac/opac-detail.pl

index f96149f..9aaecf2 100644 (file)
@@ -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
index 8c576b3..60e8496 100644 (file)
@@ -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);
     }
index 6505741..3e032de 100755 (executable)
@@ -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") );