Bugzilla – Attachment 106667 Details for
Bug 25961
Add hooks for plugins to inject variables to XSLT
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25961: Add hooks for plugins to inject variables to OPAC XSLT
Bug-25961-Add-hooks-for-plugins-to-inject-variable.patch (text/plain), 3.78 KB, created by
Tomás Cohen Arazi (tcohen)
on 2020-07-08 20:20:25 UTC
(
hide
)
Description:
Bug 25961: Add hooks for plugins to inject variables to OPAC XSLT
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2020-07-08 20:20:25 UTC
Size:
3.78 KB
patch
obsolete
>From 09f0a66da0ad4c2b1a308fbb9c1b2f0d14db33f3 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 8 Jul 2020 16:54:51 -0300 >Subject: [PATCH] Bug 25961: Add hooks for plugins to inject variables to OPAC > XSLT > >This patch adds the following plugin hooks: >- opac_results_xslt_variables >- opac_detail_xslt_variables > >This hooks will inject variables returned by the plugin in the form of a >hashref, into the ones that are passed to the XSLT processing code. > >To test: >1. Apply the 'DO NOT PUSH' commit >2. Install the Kitchensink plugin >3. Restart all >4. Search biblios in the OPAC >=> SUCCESS: A text is injected in front of the biblio title >5. Enter the detail page of any of the results >=> SUCCESS: A text is injected in front of the biblio title >6. Sign off :-D > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > opac/opac-detail.pl | 28 ++++++++++++++++++++++++++++ > opac/opac-search.pl | 25 +++++++++++++++++++++++++ > 2 files changed, 53 insertions(+) > >diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl >index 5c1880fbed2..2b238949e11 100755 >--- a/opac/opac-detail.pl >+++ b/opac/opac-detail.pl >@@ -59,9 +59,12 @@ use Koha::ItemTypes; > use Koha::Acquisition::Orders; > use Koha::Virtualshelves; > use Koha::Patrons; >+use Koha::Plugins; > use Koha::Ratings; > use Koha::Reviews; > >+use Try::Tiny; >+ > my $query = CGI->new(); > > my $biblionumber = $query->param('biblionumber') || $query->param('bib') || 0; >@@ -175,6 +178,31 @@ if ( $xslfile ) { > anonymous_session => ($borrowernumber) ? 0 : 1 > }; > >+ if ( C4::Context->config("enable_plugins") ) { >+ >+ my @plugins = Koha::Plugins->new->GetPlugins({ >+ method => 'opac_detail_xslt_variables', >+ }); >+ >+ if (@plugins) { >+ foreach my $plugin ( @plugins ) { >+ try { >+ my $plugin_variables = $plugin->opac_detail_xslt_variables( >+ { >+ biblio_id => $biblionumber, >+ lang => $lang, >+ patron_id => $borrowernumber >+ } >+ ); >+ $variables = { %$variables, %$plugin_variables }; >+ } >+ catch { >+ warn "$_"; >+ }; >+ } >+ } >+ } >+ > $template->param( > XSLTBloc => XSLTParse4Display( > $biblionumber, $record, "OPACXSLTDetailsDisplay", 1, undef, >diff --git a/opac/opac-search.pl b/opac/opac-search.pl >index 2f2043e77cd..3a512f830bc 100755 >--- a/opac/opac-search.pl >+++ b/opac/opac-search.pl >@@ -29,6 +29,7 @@ use Modern::Perl; > ## load Koha modules > use C4::Context; > use List::MoreUtils q/any/; >+use Try::Tiny; > > use Data::Dumper; # TODO remove > >@@ -60,6 +61,7 @@ use Koha::Ratings; > use Koha::Virtualshelves; > use Koha::Library::Groups; > use Koha::Patrons; >+use Koha::Plugins; > use Koha::SearchFields; > > use POSIX qw(ceil floor strftime); >@@ -647,6 +649,29 @@ if (C4::Context->preference('OpacHiddenItemsExceptions')){ > } > > my $variables = { anonymous_session => ($borrowernumber) ? 0 : 1 }; >+if ( C4::Context->config("enable_plugins") ) { >+ >+ my @plugins = Koha::Plugins->new->GetPlugins({ >+ method => 'opac_results_xslt_variables', >+ }); >+ >+ if (@plugins) { >+ foreach my $plugin ( @plugins ) { >+ try { >+ my $plugin_variables = $plugin->opac_results_xslt_variables( >+ { >+ lang => $lang, >+ patron_id => $borrowernumber >+ } >+ ); >+ $variables = { %$variables, %$plugin_variables }; >+ } >+ catch { >+ warn "$_"; >+ }; >+ } >+ } >+} > > for (my $i=0;$i<@servers;$i++) { > my $server = $servers[$i]; >-- >2.27.0
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 25961
:
106666
|
106667
|
106832
|
106833
|
106954
|
106955
|
107477