From: Frédéric Demians Date: Sun, 2 Nov 2014 07:59:30 +0000 (+0100) Subject: Bug 13170 Remove of prog theme broke the OPAC's "view plain" option for MARC details X-Git-Url: http://git.equinoxoli.org/?p=koha-equinox.git;a=commitdiff_plain;h=3cbf7547023a36166a0dd51d2a778623fc4b6aa0 Bug 13170 Remove of prog theme broke the OPAC's "view plain" option for MARC details In the OPAC if you view the MARC details for a title (and have OPACXSLTDetailsDisplay enabled) there is a "view plain" link which displays the output of opac-showmarc.pl. This is broken in master: fixed by this patch. Test plan: (1) Set OPACXSLTDetailsDisplay to default (2) Do a search on OPAC, then display a specific biblio record (3) Click on MARC view tab. Then click on 'view plain' link. Nothing is displayed. (4) Apply the patch. And refresh the MARC detail page. (5) Click on 'view plain' link. Check that a plain text MARC record is displayed. Signed-off-by: Chris Note: This makes a small change to C4::Templates::themelanguage so that it works with .xsl files too (They live in the xslt dir) Signed-off-by: Katrin Fischer Works as described, passes tests and QA script. Signed-off-by: Tomas Cohen Arazi --- diff --git a/C4/Templates.pm b/C4/Templates.pm index 3a3a65c..d53d1a8 100644 --- a/C4/Templates.pm +++ b/C4/Templates.pm @@ -288,14 +288,15 @@ sub themelanguage { push @themes, $hardcoded_theme; # Try to find first theme for the selected theme/lang, then for fallback/lang + my $where = $tmpl =~ /xsl$/ ? 'xslt' : 'modules'; for my $theme (@themes) { - if ( -e "$htdocs/$theme/$lang/modules/$tmpl" ) { + if ( -e "$htdocs/$theme/$lang/$where/$tmpl" ) { return ( $theme, $lang, uniq( \@themes ) ); } } # Otherwise return theme/'en', last resort fallback/'en' for my $theme (@themes) { - if ( -e "$htdocs/$theme/en/modules/$tmpl" ) { + if ( -e "$htdocs/$theme/en/$where/$tmpl" ) { return ( $theme, 'en', uniq( \@themes ) ); } } diff --git a/opac/opac-showmarc.pl b/opac/opac-showmarc.pl index 702fb1b..86be88f 100755 --- a/opac/opac-showmarc.pl +++ b/opac/opac-showmarc.pl @@ -31,6 +31,7 @@ use C4::Auth; use C4::Biblio; use C4::ImportBatch; use C4::XSLT (); +use C4::Templates; my $input = new CGI; my $biblionumber = $input->param('id'); @@ -52,26 +53,13 @@ if(!ref $record) { } if ($view eq 'card' || $view eq 'html') { - my $xmlrecord= $importid? $record->as_xml(): GetXmlBiblio($biblionumber); - my $xslfile; - my $xslfilename; - my $htdocs = C4::Context->config('opachtdocs'); - my $theme = C4::Context->preference("opacthemes"); - my $lang = C4::Languages::getlanguage($input); - - if ($view eq 'card'){ - $xslfile = "compact.xsl"; - } - else { # must be html - $xslfile = 'plainMARC.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 $newxmlrecord = C4::XSLT::engine->transform($xmlrecord, $xslfilename); - print $input->header(-charset => 'UTF-8'), Encode::encode_utf8($newxmlrecord); + my $xml = $importid ? $record->as_xml(): GetXmlBiblio($biblionumber); + my $xsl = $view eq 'card' ? 'compact.xsl' : 'plainMARC.xsl'; + my $htdocs = C4::Context->config('opachtdocs'); + my ($theme, $lang) = C4::Templates::themelanguage($htdocs, $xsl, 'opac', $input); + $xsl = "$htdocs/$theme/$lang/xslt/$xsl"; + print $input->header(-charset => 'UTF-8'), + Encode::encode_utf8(C4::XSLT::engine->transform($xml, $xsl)); } else { #view eq marc my ( $template, $loggedinuser, $cookie ) = get_template_and_user({