Bugzilla – Attachment 119429 Details for
Bug 27114
Use Template Toolkit plugin for Koha plugins hook 'intranet_catalog_biblio_tab'
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27114: Use Template Toolkit plugin for Koha plugins hook 'intranet_catalog_biblio_tab'
Bug-27114-Use-Template-Toolkit-plugin-for-Koha-plu.patch (text/plain), 5.51 KB, created by
Kyle M Hall (khall)
on 2021-04-09 18:24:30 UTC
(
hide
)
Description:
Bug 27114: Use Template Toolkit plugin for Koha plugins hook 'intranet_catalog_biblio_tab'
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2021-04-09 18:24:30 UTC
Size:
5.51 KB
patch
obsolete
>From cfe5d53c757ab598401b1dbf7481a9d693a882fd Mon Sep 17 00:00:00 2001 >From: Fridolin Somers <fridolin.somers@biblibre.com> >Date: Mon, 30 Nov 2020 08:39:41 +0100 >Subject: [PATCH] Bug 27114: Use Template Toolkit plugin for Koha plugins hook > 'intranet_catalog_biblio_tab' > >Koha plugins hook 'intranet_catalog_biblio_tab' is for a template, >it will be better it uses Template Toolkit plugin like intranet_js, ... >It will allow using it in other places like MARC details page for example. > >Test plan uses a plugin from git.biblibre.com because this hook is not >yet in KitchenSink. > >Test plan : >1) Enable Koha plugins >2) Download and install the latest version of this plugin >https://git.biblibre.com/biblibre/koha-plugin-intranet-detail-hook >3) Browse to catalogue/detail.pl for a record >4) Note you see two new tabs with content > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > Koha/Template/Plugin/KohaPlugins.pm | 37 +++++++++++++++++++ > catalogue/detail.pl | 23 ------------ > .../prog/en/modules/catalogue/detail.tt | 13 ++++--- > 3 files changed, 45 insertions(+), 28 deletions(-) > >diff --git a/Koha/Template/Plugin/KohaPlugins.pm b/Koha/Template/Plugin/KohaPlugins.pm >index 798e648a17..157d6bca0b 100644 >--- a/Koha/Template/Plugin/KohaPlugins.pm >+++ b/Koha/Template/Plugin/KohaPlugins.pm >@@ -21,6 +21,8 @@ use Modern::Perl; > > use base qw( Template::Plugin ); > >+use Try::Tiny; >+ > use Koha::Plugins; > > =head1 NAME >@@ -145,4 +147,39 @@ sub get_plugins_intranet_js { > return join( "\n", @data ); > } > >+sub get_plugins_intranet_catalog_biblio_tab { >+ >+ my $tabs = []; >+ >+ return $tabs unless C4::Context->config("enable_plugins"); >+ >+ my $p = Koha::Plugins->new(); >+ return $tabs unless $p; >+ >+ my @plugins = $p->GetPlugins( >+ { >+ method => 'intranet_catalog_biblio_tab', >+ } >+ ); >+ >+ foreach my $plugin (@plugins) { >+ try { >+ my @newtabs = $plugin->intranet_catalog_biblio_tab(); >+ foreach my $newtab (@newtabs) { >+ # Add a unique HTML id >+ my $html_id = 'tab-'. $plugin->{class} . '-' . $newtab->title; >+ # Using characters except ASCII letters, digits, '_', '-' and '.' may cause compatibility problems >+ $html_id =~ s/[^0-9A-Za-z]+/-/g; >+ $newtab->id($html_id); >+ } >+ push @$tabs, @newtabs; >+ } >+ catch { >+ warn "Error calling 'intranet_catalog_biblio_tab' on the " . $plugin->{class} . "plugin ($_)"; >+ }; >+ } >+ >+ return $tabs; >+} >+ > 1; >diff --git a/catalogue/detail.pl b/catalogue/detail.pl >index 7e8d05d48d..eca8c718af 100755 >--- a/catalogue/detail.pl >+++ b/catalogue/detail.pl >@@ -70,31 +70,8 @@ if ( C4::Context->config('enable_plugins') ) { > my @plugins = Koha::Plugins->new()->GetPlugins({ > method => 'intranet_catalog_biblio_enhancements_toolbar_button' > }); >- >- my @tab_plugins = Koha::Plugins->new()->GetPlugins({ >- method => 'intranet_catalog_biblio_tab', >- }); >- my @tabs; >- foreach my $tab_plugin (@tab_plugins) { >- my @biblio_tabs; >- >- try { >- @biblio_tabs = $tab_plugin->intranet_catalog_biblio_tab(); >- foreach my $tab (@biblio_tabs) { >- my $tab_id = 'tab-' . $tab->title; >- $tab_id =~ s/[^0-9A-Za-z]+/-/g; >- $tab->id( $tab_id ); >- push @tabs, $tab, >- } >- } >- catch { >- warn "Error calling 'intranet_catalog_biblio_tab' on the " . $tab_plugin->{class} . "plugin ($_)"; >- }; >- } >- > $template->param( > plugins => \@plugins, >- tabs => \@tabs, > ); > } > >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 90000082c5..56e5fd7448 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >@@ -2,6 +2,7 @@ > [% USE Asset %] > [% USE Koha %] > [% USE KohaDates %] >+[% USE KohaPlugins %] > [% USE AuthorisedValues %] > [% USE Branches %] > [% USE Biblio %] >@@ -30,6 +31,8 @@ > [% END %] > [% END %] > >+[% SET plugins_intranet_catalog_biblio_tabs = KohaPlugins.get_plugins_intranet_catalog_biblio_tab %] >+ > [% SET footerjs = 1 %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Catalog › >@@ -280,8 +283,8 @@ > [% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && Koha.Preference('NovelistSelectStaffView') == 'tab' ) %] > <li class="NovelistSelect" style="display:none;"><a href="#NovelistSelect">NoveList Select</a></li> > [% END %] >-[% FOREACH tab IN tabs %] >- <li><a href="#[% tab.id | uri %]">[% tab.title | html %]</a></li> >+[% FOREACH plugins_intranet_catalog_biblio_tab IN plugins_intranet_catalog_biblio_tabs %] >+ <li><a href="#[% plugins_intranet_catalog_biblio_tab.id | uri %]">[% plugins_intranet_catalog_biblio_tab.title | html %]</a></li> > [% END %] > </ul> > >@@ -951,9 +954,9 @@ Note that permanent location is a code, and location may be an authval. > </div> > [% END %] > >-[% FOREACH tab IN tabs %] >- <div id="[% tab.id | html %]"> >- [% tab.content | $raw %] >+[% FOREACH plugins_intranet_catalog_biblio_tab IN plugins_intranet_catalog_biblio_tabs %] >+ <div id="[% plugins_intranet_catalog_biblio_tab.id | html %]"> >+ [% plugins_intranet_catalog_biblio_tab.content | $raw %] > </div> > [% END %] > >-- >2.24.3 (Apple Git-128)
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 27114
:
114054
|
117995
|
117996
| 119429 |
119430