[Koha-patches] [PATCH] Bug 9570 - view plain not working in ccsr

Owen Leonard oleonard at myacpl.org
Tue Feb 12 17:14:16 CET 2013


The code in opac-showmarc.pl isn't smart enough to find the xsl files in
the "default" (prog) theme if the ccsr theme is enabled, so the "view
plain" option on opac-MARCdetail.pl fails ever time.

This patch copies some path-handling code from XSLT.pm to improve xsl
file path handling when dealing with a "sub-theme."

To test, view the MARC view in the OPAC and click the "view plain" link.
This should work correctly in prog and ccsr themes and with different
languages enabled (keeping in mind the ccsr theme will fail in general
for languages other than en).
---
 opac/opac-showmarc.pl |   16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/opac/opac-showmarc.pl b/opac/opac-showmarc.pl
index b958485..71fb804 100755
--- a/opac/opac-showmarc.pl
+++ b/opac/opac-showmarc.pl
@@ -58,18 +58,26 @@ else {
 if ($view eq 'card' || $view eq 'html') {
     my $xmlrecord= $importid? $record->as_xml(): GetXmlBiblio($biblionumber);
     my $xslfile;
-    my $themelang = '/' . C4::Context->preference("opacthemes") .  '/' . C4::Templates::_current_language();
+    my $xslfilename;
+    my $htdocs  = C4::Context->config('opachtdocs');
+    my $theme   = C4::Context->preference("opacthemes");
+    my $lang = C4::Templates::_current_language();
 
     if ($view eq 'card'){
-        $xslfile = C4::Context->config('opachtdocs').$themelang."/xslt/compact.xsl";
+        $xslfile = "compact.xsl";
     }
     else { # must be html
-        $xslfile = C4::Context->config('opachtdocs').$themelang."/xslt/MARC21slim2OPACMARCdetail.xsl";
+        $xslfile = C4::Context->preference('marcflavour') . "slim2OPACMARCdetail.xsl";
     }
+    $xslfilename = "$htdocs/$theme/$lang/xslt/$xslfile";
+    $xslfilename = "$htdocs/$theme/en/xslt/$xslfile" unless ( $lang ne 'en' && -f $xslfilename );
+    $xslfilename = "$htdocs/prog/$lang/xslt/$xslfile" unless ( -f $xslfile );
+    $xslfilename = "$htdocs/prog/en/xslt/$xslfile" unless ( $lang ne 'en' && -f $xslfilename );
+
     my $parser = XML::LibXML->new();
     my $xslt   = XML::LibXSLT->new();
     my $source = $parser->parse_string($xmlrecord);
-    my $style_doc = $parser->parse_file($xslfile);
+    my $style_doc = $parser->parse_file($xslfilename);
     my $stylesheet = $xslt->parse_stylesheet($style_doc);
     my $results = $stylesheet->transform($source);
     my $newxmlrecord = $stylesheet->output_string($results);
-- 
1.7.9.5


More information about the Koha-patches mailing list