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 staff intranet, notice you get an console error log message and the background for your staff intranet is now orange ( assuming you've not customized the staff intranet in any way ) Signed-off-by: Owen Leonard <oleonard@myacpl.org> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This commit is contained in:
parent
d74a05d4fe
commit
a37637e303
6 changed files with 76 additions and 1 deletions
|
@ -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;
|
||||
|
|
|
@ -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 %]
|
||||
|
|
|
@ -72,4 +72,5 @@
|
|||
[% jsinclude | $raw # Parse the page template's JavaScript block if necessary %]
|
||||
[% END %]
|
||||
</body>
|
||||
[% KohaPlugins.get_plugins_intranet_js | html %]
|
||||
</html>
|
||||
|
|
|
@ -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' );
|
||||
|
|
|
@ -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('upgrade'), 'Test plugin can upgrade' );
|
||||
|
|
|
@ -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";;
|
||||
|
|
Loading…
Reference in a new issue