Bugzilla – Attachment 78877 Details for
Bug 21352
Allow plugins to add CSS and Javascript to Staff interface
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21352: Allow plugins to add CSS and Javascript to Staff interface
Bug-21352-Allow-plugins-to-add-CSS-and-Javascript-.patch (text/plain), 7.08 KB, created by
Kyle M Hall (khall)
on 2018-09-15 19:12:10 UTC
(
hide
)
Description:
Bug 21352: Allow plugins to add CSS and Javascript to Staff interface
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2018-09-15 19:12:10 UTC
Size:
7.08 KB
patch
obsolete
>From fe42e2bb7cf74fd1c4a8e094679a6e2e59053d0c Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutiosn.com> >Date: Sat, 15 Sep 2018 09:48:49 -0700 >Subject: [PATCH] Bug 21352: Allow plugins to add CSS and Javascript to Staff > interface > >We should have plugin hooks for the staff interface just like we have for the OPAC as detailed on bug 20181. > >Test Plan: >1) Apply this patch >2) Download and install the Kitchen Sink plugin ( v2.1.19 or later ) > https://github.com/bywatersolutions/koha-plugin-kitchen-sink/releases/download/v2.1.19/koha-plugin-kitchen-sink-v2.1.19.kpz >3) Install the plugin >4) Restart all the things if you can ( restart_all if you are using kohadevbox ) > This will ensure the plugin takes effect right away, it should be > necessary but it won't hurt anything! >5) Load the opac, notice you get an alert message and the background > for your opac is now orange ( assuming you've not customized the > opac in any way ) > >https://bugs.koha-community.org/show_bug.cgi?id=13692 >--- > Koha/Template/Plugin/KohaPlugins.pm | 56 ++++++++++++++++++++++ > .../prog/en/includes/doc-head-close.inc | 2 + > .../prog/en/includes/intranet-bottom.inc | 1 + > t/db_dependent/Koha/Template/Plugin/KohaPlugins.t | 6 ++- > t/db_dependent/Plugins.t | 4 +- > t/lib/Koha/Plugin/Test.pm | 10 ++++ > 6 files changed, 77 insertions(+), 2 deletions(-) > >diff --git a/Koha/Template/Plugin/KohaPlugins.pm b/Koha/Template/Plugin/KohaPlugins.pm >index 0148c7f301..8624504cdb 100644 >--- a/Koha/Template/Plugin/KohaPlugins.pm >+++ b/Koha/Template/Plugin/KohaPlugins.pm >@@ -93,4 +93,60 @@ sub get_plugins_opac_js { > return join( "\n", @data ); > } > >+=head3 get_plugins_intranet_head >+ >+[% KohaPlugins.get_plugins_intranet_head %] >+ >+This method collects the output of all plugins with an intranet_head method >+to output to the head section of intranet pages. >+ >+=cut >+ >+sub get_plugins_intranet_head { >+ return q{} >+ unless C4::Context->preference('UseKohaPlugins'); >+ >+ my $p = Koha::Plugins->new(); >+ >+ return q{} unless $p; >+ >+ my @plugins = $p->GetPlugins( >+ { >+ method => 'intranet_head', >+ } >+ ); >+ >+ my @data = map { $_->intranet_head || q{} } @plugins; >+ >+ return join( "\n", @data ); >+} >+ >+=head3 get_plugins_intranet_js >+ >+[% KohaPlugins.get_plugins_intranet_js %] >+ >+This method collects the output of all plugins with an intranet_js method >+to output to the javascript section of at the bottom of intranet pages. >+ >+=cut >+ >+sub get_plugins_intranet_js { >+ return q{} >+ unless C4::Context->preference('UseKohaPlugins'); >+ >+ my $p = Koha::Plugins->new(); >+ >+ return q{} unless $p; >+ >+ my @plugins = $p->GetPlugins( >+ { >+ method => 'intranet_js', >+ } >+ ); >+ >+ my @data = map { $_->intranet_js || q{} } @plugins; >+ >+ return join( "\n", @data ); >+} >+ > 1; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc >index c8d268015e..0cd6b7ea38 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc >@@ -25,6 +25,8 @@ > [% END %] > [% IF ( IntranetUserCSS ) %]<style type="text/css">[% IntranetUserCSS | $raw %]</style>[% END %] > >+[% KohaPlugins.get_plugins_intranet_head | html %] >+ > [% UNLESS ( footerjs ) %] > [% INCLUDE js_includes.inc %] > [% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc >index 022c4e33a2..cfbf362c7a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc >@@ -72,4 +72,5 @@ > [% jsinclude | $raw # Parse the page template's JavaScript block if necessary %] > [% END %] > </body> >+[% KohaPlugins.get_plugins_intranet_js | html %] > </html> >diff --git a/t/db_dependent/Koha/Template/Plugin/KohaPlugins.t b/t/db_dependent/Koha/Template/Plugin/KohaPlugins.t >index 7698bf4686..b0d50e66a0 100755 >--- a/t/db_dependent/Koha/Template/Plugin/KohaPlugins.t >+++ b/t/db_dependent/Koha/Template/Plugin/KohaPlugins.t >@@ -2,7 +2,7 @@ > > use Modern::Perl; > >-use Test::More tests => 10; >+use Test::More tests => 14; > use CGI; > use File::Basename; > use File::Spec; >@@ -40,8 +40,12 @@ t::lib::Mocks::mock_preference('UseKohaPlugins',1); > t::lib::Mocks::mock_config('enable_plugins',1); > ok( index( $plugin->get_plugins_opac_js, 'Koha::Plugin::Test::opac_js' ) != -1, 'Test plugin opac_js return value is part of code returned by get_plugins_opac_js' ); > ok( index( $plugin->get_plugins_opac_head, 'Koha::Plugin::Test::opac_head' ) != -1, 'Test plugin opac_head return value is part of code returned by get_plugins_opac_head' ); >+ok( index( $plugin->get_plugins_intranet_js, 'Koha::Plugin::Test::intranet_js' ) != -1, 'Test plugin intranet_js return value is part of code returned by get_plugins_intranet_js' ); >+ok( index( $plugin->get_plugins_intranet_head, 'Koha::Plugin::Test::intranet_head' ) != -1, 'Test plugin intranet_head return value is part of code returned by get_plugins_intranet_head' ); > > t::lib::Mocks::mock_preference('UseKohaPlugins',0); > t::lib::Mocks::mock_config('enable_plugins',0); > is( $plugin->get_plugins_opac_js, q{}, 'Test plugin opac_js return value is empty' ); > is( $plugin->get_plugins_opac_head, q{}, 'Test plugin opac_head return value is empty' ); >+is( $plugin->get_plugins_intranet_js, q{}, 'Test plugin intranet_js return value is empty' ); >+is( $plugin->get_plugins_intranet_head, q{}, 'Test plugin intranet_head return value is empty' ); >diff --git a/t/db_dependent/Plugins.t b/t/db_dependent/Plugins.t >index f82d3b25be..87ce19affc 100755 >--- a/t/db_dependent/Plugins.t >+++ b/t/db_dependent/Plugins.t >@@ -2,7 +2,7 @@ > > use Modern::Perl; > >-use Test::More tests => 35; >+use Test::More tests => 37; > use CGI; > use File::Basename; > use File::Temp qw( tempdir tempfile ); >@@ -47,6 +47,8 @@ ok( $plugin->can('opac_online_payment_begin'), 'Test plugin can opac_online_paym > ok( $plugin->can('opac_online_payment_end'), 'Test plugin can opac_online_payment_end' ); > ok( $plugin->can('opac_head'), 'Test plugin can opac_head' ); > ok( $plugin->can('opac_js'), 'Test plugin can opac_js' ); >+ok( $plugin->can('intranet_head'), 'Test plugin can intranet_head' ); >+ok( $plugin->can('intranet_js'), 'Test plugin can intranet_js' ); > ok( $plugin->can('configure'), 'Test plugin can configure' ); > ok( $plugin->can('install'), 'Test plugin can install' ); > ok( $plugin->can('uninstall'), 'Test plugin can install' ); >diff --git a/t/lib/Koha/Plugin/Test.pm b/t/lib/Koha/Plugin/Test.pm >index f817438986..2ccefcb3d5 100644 >--- a/t/lib/Koha/Plugin/Test.pm >+++ b/t/lib/Koha/Plugin/Test.pm >@@ -70,6 +70,16 @@ sub opac_js { > return "Koha::Plugin::Test::opac_js"; > } > >+sub intranet_head { >+ my ( $self, $args ) = @_; >+ return "Koha::Plugin::Test::intranet_head"; >+} >+ >+sub intranet_js { >+ my ( $self, $args ) = @_; >+ return "Koha::Plugin::Test::intranet_js"; >+} >+ > sub configure { > my ( $self, $args ) = @_; > return "Koha::Plugin::Test::configure";; >-- >2.11.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 21352
:
78877
|
79185
|
79186
|
79440
|
79441
|
79754
|
79755
|
79756
|
79873
|
79875
|
79876