Bugzilla – Attachment 122609 Details for
Bug 12561
Remove non-XSLT views
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12561: Change prototype of XSLTParse4Display
Bug-12561-Change-prototype-of-XSLTParse4Display.patch (text/plain), 11.93 KB, created by
Jonathan Druart
on 2021-07-06 09:16:42 UTC
(
hide
)
Description:
Bug 12561: Change prototype of XSLTParse4Display
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2021-07-06 09:16:42 UTC
Size:
11.93 KB
patch
obsolete
>From e7955b150c23d7c8567d71f2d4921258cfbc0172 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Fri, 18 Jun 2021 16:05:34 +0200 >Subject: [PATCH] Bug 12561: Change prototype of XSLTParse4Display > >Use a hash for better readability and reusability. >--- > C4/Search.pm | 22 ++++++++++++++++------ > C4/XSLT.pm | 33 +++++++++++++++++++++++++-------- > catalogue/detail.pl | 17 +++++++++-------- > opac/opac-detail.pl | 20 ++++++++++---------- > opac/opac-shelves.pl | 19 +++++++++---------- > opac/opac-tags.pl | 17 ++++++++--------- > virtualshelves/shelves.pl | 14 ++++++++------ > 7 files changed, 85 insertions(+), 57 deletions(-) > >diff --git a/C4/Search.pm b/C4/Search.pm >index 0da27271169..7d6b6edbf14 100644 >--- a/C4/Search.pm >+++ b/C4/Search.pm >@@ -1648,10 +1648,6 @@ sub searchResults { > my ($bibliotag,$bibliosubf)=GetMarcFromKohaField( 'biblio.biblionumber' ); > > # set stuff for XSLT processing here once, not later again for every record we retrieved >- my $xslsyspref = $is_opac ? 'OPACXSLTResultsDisplay' : 'XSLTResultsDisplay'; >- my $xslfile = C4::Context->preference( $xslsyspref ) || "default"; >- my $lang = C4::Languages::getlanguage(); >- my $sysxml = C4::XSLT::get_xslt_sysprefs(); > > my $userenv = C4::Context->userenv; > my $logged_in_user >@@ -1948,14 +1944,28 @@ sub searchResults { > > # XSLT processing of some stuff > # we fetched the sysprefs already before the loop through all retrieved record! >- if (!$scan && $xslfile) { >+ if (!$scan) { > $record_processor->options({ > frameworkcode => $fw, > interface => $search_context->{'interface'} > }); > > $record_processor->process($marcrecord); >- $oldbiblio->{XSLTResultsRecord} = XSLTParse4Display($oldbiblio->{biblionumber}, $marcrecord, $xslsyspref, 1, \@hiddenitems, $sysxml, $xslfile, $lang, $xslt_variables); >+ >+ $oldbiblio->{XSLTResultsRecord} = XSLTParse4Display( >+ { >+ biblionumber => $oldbiblio->{biblionumber}, >+ record => $marcrecord, >+ xsl_syspref => ( >+ $is_opac >+ ? 'OPACXSLTResultsDisplay' >+ : 'XSLTResultsDisplay' >+ ), >+ fix_amps => 1, >+ hidden_items => \@hiddenitems, >+ xslt_variables => $xslt_variables >+ } >+ ); > } > > # if biblio level itypes are used and itemtype is notforloan, it can't be reserved either >diff --git a/C4/XSLT.pm b/C4/XSLT.pm >index b8ae90e9782..971726ea136 100644 >--- a/C4/XSLT.pm >+++ b/C4/XSLT.pm >@@ -189,17 +189,17 @@ sub get_xslt_sysprefs { > return $sysxml; > } > >-sub XSLTParse4Display { >- my ( $biblionumber, $orig_record, $xslsyspref, $fixamps, $hidden_items, $sysxml, $xslfilename, $lang, $variables, $items_rs ) = @_; >+sub get_xsl_filename { >+ my ( $xslsyspref ) = @_; >+ >+ my $lang = C4::Languages::getlanguage(); > >- $sysxml ||= C4::Context->preference($xslsyspref); >- $xslfilename ||= C4::Context->preference($xslsyspref); >- $lang ||= C4::Languages::getlanguage(); >+ my $xslfilename = C4::Context->preference($xslsyspref) || "default"; > > if ( $xslfilename =~ /^\s*"?default"?\s*$/i ) { >- my $htdocs; >- my $theme; >- my $xslfile; >+ >+ my ( $htdocs, $theme, $xslfile ); >+ > if ($xslsyspref eq "XSLTDetailsDisplay") { > $htdocs = C4::Context->config('intrahtdocs'); > $theme = C4::Context->preference("template"); >@@ -240,6 +240,22 @@ sub XSLTParse4Display { > $xslfilename =~ s/\{langcode\}/$lang/; > } > >+ return $xslfilename; >+} >+ >+sub XSLTParse4Display { >+ my ( $params ) = @_; >+ >+ my $biblionumber = $params->{biblionumber}; >+ my $orig_record = $params->{record}; >+ my $xslsyspref = $params->{xsl_syspref}; >+ my $fixamps = $params->{fix_amps}; >+ my $hidden_items = $params->{hidden_items} || []; >+ my $variables = $params->{xslt_variables}; >+ my $items_rs = $params->{items_rs}; >+ >+ my $xslfilename = get_xsl_filename( $xslsyspref); >+ > # grab the XML, run it through our stylesheet, push it out to the browser > my $record = transformMARCXML4XSLT($biblionumber, $orig_record); > my $itemsxml; >@@ -272,6 +288,7 @@ sub XSLTParse4Display { > } > $varxml .= "</variables>\n"; > >+ my $sysxml = get_xslt_sysprefs(); > $xmlrecord =~ s/\<\/record\>/$itemsxml$sysxml$varxml\<\/record\>/; > if ($fixamps) { # We need to correct the ampersand entities that Zebra outputs > $xmlrecord =~ s/\&amp;/\&/g; >diff --git a/catalogue/detail.pl b/catalogue/detail.pl >index 667f6dce965..752c2bb60d8 100755 >--- a/catalogue/detail.pl >+++ b/catalogue/detail.pl >@@ -119,9 +119,6 @@ my $marcflavour = C4::Context->preference("marcflavour"); > > { > # XSLT processing of some stuff >- my $xslfile = C4::Context->preference('XSLTDetailsDisplay') || "default"; >- my $lang = C4::Languages::getlanguage(); >- my $sysxml = C4::XSLT::get_xslt_sysprefs(); > > my $searcher = Koha::SearchEngine::Search->new( > { index => $Koha::SearchEngine::BIBLIOS_INDEX } >@@ -143,11 +140,15 @@ my $marcflavour = C4::Context->preference("marcflavour"); > > $template->param( > XSLTDetailsDisplay => '1', >- XSLTBloc => XSLTParse4Display( >- $biblionumber, $record, "XSLTDetailsDisplay", 1, >- undef, $sysxml, $xslfile, $lang, >- $variables >- ) >+ XSLTBloc => XSLTParse4Display( >+ { >+ biblionumber => $biblionumber, >+ record => $record, >+ xsl_syspref => "XSLTDetailsDisplay", >+ fix_amps => 1, >+ xslt_variables => $variables >+ } >+ ), > ); > } > >diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl >index 1da80e24a3c..75ef15defdc 100755 >--- a/opac/opac-detail.pl >+++ b/opac/opac-detail.pl >@@ -174,12 +174,6 @@ my $marcflavour = C4::Context->preference("marcflavour"); > my $ean = GetNormalizedEAN( $record, $marcflavour ); > > { >- >- # XSLT processing of some stuff >- my $xslfile = C4::Context->preference('OPACXSLTDetailsDisplay') || "default"; >- my $lang = C4::Languages::getlanguage(); >- my $sysxml = C4::XSLT::get_xslt_sysprefs(); >- > my $searcher = Koha::SearchEngine::Search->new( > { index => $Koha::SearchEngine::BIBLIOS_INDEX } > ); >@@ -192,13 +186,14 @@ my $ean = GetNormalizedEAN( $record, $marcflavour ); > my ( $err, $result, $count ) = $searcher->simple_search_compat( $query, 0, 0 ); > > warn "Warning from simple_search_compat: $err" >- if $err; >+ if $err; > > my $variables = { > anonymous_session => ($borrowernumber) ? 0 : 1, > show_analytics_link => $count > 0 ? 1 : 0 > }; > >+ my $lang = C4::Languages::getlanguage(); > my @plugin_responses = Koha::Plugins->call( > 'opac_detail_xslt_variables', > { >@@ -214,9 +209,14 @@ my $ean = GetNormalizedEAN( $record, $marcflavour ); > > $template->param( > XSLTBloc => XSLTParse4Display( >- $biblionumber, $record, "OPACXSLTDetailsDisplay", 1, undef, >- $sysxml, $xslfile, $lang, $variables >- ) >+ { >+ biblionumber => $biblionumber, >+ record => $record, >+ xsl_syspref => 'OPACXSLTDetailsDisplay', >+ fix_amps => 1, >+ xslt_variables => $variables >+ } >+ ), > ); > } > >diff --git a/opac/opac-shelves.pl b/opac/opac-shelves.pl >index b5ca2abaf0f..58f4d96e601 100755 >--- a/opac/opac-shelves.pl >+++ b/opac/opac-shelves.pl >@@ -294,11 +294,6 @@ if ( $op eq 'view' ) { > $categorycode = $patron ? $patron->categorycode : undef; > } > >- # Lists display falls back to search results configuration >- my $xslfile = C4::Context->preference('OPACXSLTListsDisplay') || "default"; >- my $lang = C4::Languages::getlanguage(); >- my $sysxml = C4::XSLT::get_xslt_sysprefs(); >- > my $record_processor = Koha::RecordProcessor->new({ filters => 'ViewPolicy' }); > > my $art_req_itypes; >@@ -365,13 +360,17 @@ if ( $op eq 'view' ) { > anonymous_session => ($loggedinuser) ? 0 : 1 > }; > $this_item->{XSLTBloc} = XSLTParse4Display( >- $biblionumber, $record, >- "OPACXSLTListsDisplay", 1, >- undef, $sysxml, >- $xslfile, $lang, >- $variables, $items->reset >+ { >+ biblionumber => $biblionumber, >+ record => $record, >+ xsl_syspref => "OPACXSLTListsDisplay", >+ fix_amps => 1, >+ xslt_variables => $variables, >+ items_rs => $items->reset, >+ } > ); > >+ > if ( grep {$_ eq $biblionumber} @cart_list) { > $this_item->{incart} = 1; > } >diff --git a/opac/opac-tags.pl b/opac/opac-tags.pl >index 5b60e2d2262..4437e968ce1 100755 >--- a/opac/opac-tags.pl >+++ b/opac/opac-tags.pl >@@ -280,19 +280,18 @@ if ($loggedinuser) { > # BZ17530: 'Intelligent' guess if result can be article requested > $tag->{artreqpossible} = ( $art_req_itypes->{ $tag->{itemtype} // q{} } || $art_req_itypes->{ '*' } ) ? 1 : q{}; > >- my $xslfile = C4::Context->preference('OPACXSLTResultsDisplay') || "default"; >- my $lang = C4::Languages::getlanguage(); >- my $sysxml = C4::XSLT::get_xslt_sysprefs(); >- > my $variables = { > anonymous_session => ($loggedinuser) ? 0 : 1 > }; > $tag->{XSLTBloc} = XSLTParse4Display( >- $tag->{biblionumber}, $record, >- "OPACXSLTResultsDisplay", 1, >- $hidden_items, $sysxml, >- $xslfile, $lang, >- $variables >+ { >+ biblionumber => $tag->{biblionumber}, >+ record => $record, >+ xsl_filename => 'OPACXSLTResultsDisplay', >+ fix_amps => 1, >+ hidden_items => $hidden_items, >+ xslt_variables => $variables >+ } > ); > > my $date = $tag->{date_created} || ''; >diff --git a/virtualshelves/shelves.pl b/virtualshelves/shelves.pl >index b15ca9cd2df..d1c4ad8ef6a 100755 >--- a/virtualshelves/shelves.pl >+++ b/virtualshelves/shelves.pl >@@ -253,18 +253,20 @@ if ( $op eq 'view' ) { > } > ); > >- my $xslfile = C4::Context->preference('XSLTListsDisplay'); >- my $lang = C4::Languages::getlanguage(); >- my $sysxml = C4::XSLT::get_xslt_sysprefs(); >- > my @items; > while ( my $content = $contents->next ) { > my $this_item; > my $biblionumber = $content->biblionumber; > my $record = GetMarcBiblio({ biblionumber => $biblionumber }); > >- $this_item->{XSLTBloc} = XSLTParse4Display( $biblionumber, $record, "XSLTListsDisplay", >- 1, undef, $sysxml, $xslfile, $lang); >+ $this_item->{XSLTBloc} = XSLTParse4Display( >+ { >+ biblionumber => $biblionumber, >+ record => $record, >+ xsl_filename => "XSLTListsDisplay", >+ fix_amps => 1, >+ } >+ ); > > my $marcflavour = C4::Context->preference("marcflavour"); > my $itemtype = Koha::Biblioitems->search({ biblionumber => $content->biblionumber })->next->itemtype; >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 12561
:
122141
|
122142
|
122143
|
122144
|
122600
|
122601
|
122607
|
122608
|
122609
|
122610
|
123262
|
123263
|
123264
|
123265
|
123267
|
123268
|
123269
|
123270
|
123300
|
123301
|
123302
|
123303
|
123305
|
123306
|
123307
|
123308