From 495315d9992363d022c8a1e59bf7630179060ae3 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 1 Nov 2016 10:25:26 +0000 Subject: [PATCH] Bug 17527: Hide hidden fields for XSLT blocks --- C4/Search.pm | 2 +- C4/XSLT.pm | 15 ++++++++++++++- catalogue/detail.pl | 2 +- .../intranet-tmpl/prog/en/modules/catalogue/detail.tt | 2 +- opac/opac-detail.pl | 2 +- opac/opac-shelves.pl | 2 +- opac/opac-tags.pl | 2 +- virtualshelves/shelves.pl | 2 +- 8 files changed, 21 insertions(+), 8 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index 9379eeb..c6fc743 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -2222,7 +2222,7 @@ sub searchResults { # XSLT processing of some stuff # we fetched the sysprefs already before the loop through all retrieved record! if (!$scan && $xslfile) { - $oldbiblio->{XSLTResultsRecord} = XSLTParse4Display($oldbiblio->{biblionumber}, $marcrecord, $xslsyspref, 1, \@hiddenitems, $sysxml, $xslfile, $lang); + $oldbiblio->{XSLTResultsRecord} = XSLTParse4Display($oldbiblio->{biblionumber}, $marcrecord, $xslsyspref, 1, \@hiddenitems, $sysxml, $xslfile, $lang, $interface); # the last parameter tells Koha to clean up the problematic ampersand entities that Zebra outputs } diff --git a/C4/XSLT.pm b/C4/XSLT.pm index 50ab8e6..4b92cb5 100644 --- a/C4/XSLT.pm +++ b/C4/XSLT.pm @@ -32,6 +32,7 @@ use C4::Reserves; use Koha::AuthorisedValues; use Koha::XSLT_Handler; use Koha::Libraries; +use Koha::RecordProcessor; use Encode; @@ -187,11 +188,12 @@ sub get_xslt_sysprefs { } sub XSLTParse4Display { - my ( $biblionumber, $orig_record, $xslsyspref, $fixamps, $hidden_items, $sysxml, $xslfilename, $lang ) = @_; + my ( $biblionumber, $orig_record, $xslsyspref, $fixamps, $hidden_items, $sysxml, $xslfilename, $lang, $interface ) = @_; $sysxml ||= C4::Context->preference($xslsyspref); $xslfilename ||= C4::Context->preference($xslsyspref); $lang ||= C4::Languages::getlanguage(); + $interface ||= 'opac'; if ( $xslfilename =~ /^\s*"?default"?\s*$/i ) { my $htdocs; @@ -239,6 +241,17 @@ sub XSLTParse4Display { # grab the XML, run it through our stylesheet, push it out to the browser my $record = transformMARCXML4XSLT($biblionumber, $orig_record); + + my $framework = C4::Biblio::GetFrameworkCode( $biblionumber ); + my $record_processor = Koha::RecordProcessor->new({ + filters => 'ViewPolicy', + options => { + interface => $interface, + frameworkcode => $framework + } + }); + $record_processor->process($record); + my $itemsxml = buildKohaItemsNamespace($biblionumber, $hidden_items); my $xmlrecord = $record->as_xml(C4::Context->preference('marcflavour')); diff --git a/catalogue/detail.pl b/catalogue/detail.pl index 09aa55c..3732651 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -94,7 +94,7 @@ if ( $xslfile ) { XSLTDetailsDisplay => '1', XSLTBloc => XSLTParse4Display( $biblionumber, $record, "XSLTDetailsDisplay", - 1, undef, $sysxml, $xslfile, $lang + 1, undef, $sysxml, $xslfile, $lang, 'intranet' ) ); } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt index 2b6583b..880919d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -347,7 +347,7 @@ function verify_images() { [% IF ( unknownbiblionumber ) %] Unknown record [% ELSE %] - Details for [% title |html %] [% FOREACH subtitl IN subtitle %] [% subtitl.subfield | html %][% END %] +/ Details for [% title |html %] [% FOREACH subtitl IN subtitle %] [% subtitl.subfield | html %][% END %] [% END %] diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index 41c1d22..9087118 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -157,7 +157,7 @@ if ( $xslfile ) { $template->param( XSLTBloc => XSLTParse4Display( $biblionumber, $record, "OPACXSLTDetailsDisplay", - 1, undef, $sysxml, $xslfile, $lang + 1, undef, $sysxml, $xslfile, $lang, 'opac' ) ); } diff --git a/opac/opac-shelves.pl b/opac/opac-shelves.pl index b29ade6..52954fd 100755 --- a/opac/opac-shelves.pl +++ b/opac/opac-shelves.pl @@ -272,7 +272,7 @@ if ( $op eq 'view' ) { if ( $xslfile ) { $this_item->{XSLTBloc} = XSLTParse4Display( $biblionumber, $record, "OPACXSLTListsDisplay", - 1, undef, $sysxml, $xslfile, $lang); + 1, undef, $sysxml, $xslfile, $lang, 'opac'); } my $marcflavour = C4::Context->preference("marcflavour"); diff --git a/opac/opac-tags.pl b/opac/opac-tags.pl index 665d6b6..dc14315 100755 --- a/opac/opac-tags.pl +++ b/opac/opac-tags.pl @@ -242,7 +242,7 @@ if ($loggedinuser) { if ( $xslfile ) { $tag->{XSLTBloc} = XSLTParse4Display( $tag->{ biblionumber }, $record, "OPACXSLTResultsDisplay", - 1, undef, $sysxml, $xslfile, $lang + 1, undef, $sysxml, $xslfile, $lang, 'opac' ); } diff --git a/virtualshelves/shelves.pl b/virtualshelves/shelves.pl index 691e215..e9c1900 100755 --- a/virtualshelves/shelves.pl +++ b/virtualshelves/shelves.pl @@ -230,7 +230,7 @@ if ( $op eq 'view' ) { if ( $xslfile ) { $this_item->{XSLTBloc} = XSLTParse4Display( $biblionumber, $record, "XSLTListsDisplay", - 1, undef, $sysxml, $xslfile, $lang); + 1, undef, $sysxml, $xslfile, $lang, 'intranet'); } my $marcflavour = C4::Context->preference("marcflavour"); -- 2.1.4