View | Details | Raw Unified | Return to bug 21352
Collapse All | Expand All

(-)a/Koha/Template/Plugin/KohaPlugins.pm (+56 lines)
Lines 93-96 sub get_plugins_opac_js { Link Here
93
    return join( "\n", @data );
93
    return join( "\n", @data );
94
}
94
}
95
95
96
=head3 get_plugins_intranet_head
97
98
[% KohaPlugins.get_plugins_intranet_head %]
99
100
This method collects the output of all plugins with an intranet_head method
101
to output to the head section of intranet pages.
102
103
=cut
104
105
sub get_plugins_intranet_head {
106
    return q{}
107
      unless C4::Context->preference('UseKohaPlugins');
108
109
    my $p = Koha::Plugins->new();
110
111
    return q{} unless $p;
112
113
    my @plugins = $p->GetPlugins(
114
        {
115
            method => 'intranet_head',
116
        }
117
    );
118
119
    my @data = map { $_->intranet_head || q{} } @plugins;
120
121
    return join( "\n", @data );
122
}
123
124
=head3 get_plugins_intranet_js
125
126
[% KohaPlugins.get_plugins_intranet_js %]
127
128
This method collects the output of all plugins with an intranet_js method
129
to output to the javascript section of at the bottom of intranet pages.
130
131
=cut
132
133
sub get_plugins_intranet_js {
134
    return q{}
135
      unless C4::Context->preference('UseKohaPlugins');
136
137
    my $p = Koha::Plugins->new();
138
139
    return q{} unless $p;
140
141
    my @plugins = $p->GetPlugins(
142
        {
143
            method => 'intranet_js',
144
        }
145
    );
146
147
    my @data = map { $_->intranet_js || q{} } @plugins;
148
149
    return join( "\n", @data );
150
}
151
96
1;
152
1;
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc (+2 lines)
Lines 25-30 Link Here
25
[% END %]
25
[% END %]
26
[% IF ( IntranetUserCSS ) %]<style type="text/css">[% IntranetUserCSS | $raw %]</style>[% END %]
26
[% IF ( IntranetUserCSS ) %]<style type="text/css">[% IntranetUserCSS | $raw %]</style>[% END %]
27
27
28
[% KohaPlugins.get_plugins_intranet_head | html %]
29
28
[% UNLESS ( footerjs ) %]
30
[% UNLESS ( footerjs ) %]
29
    [% INCLUDE js_includes.inc %]
31
    [% INCLUDE js_includes.inc %]
30
[% END %]
32
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc (+1 lines)
Lines 72-75 Link Here
72
        [% jsinclude | $raw # Parse the page template's JavaScript block if necessary %]
72
        [% jsinclude | $raw # Parse the page template's JavaScript block if necessary %]
73
    [% END %]
73
    [% END %]
74
    </body>
74
    </body>
75
[% KohaPlugins.get_plugins_intranet_js | html %]
75
</html>
76
</html>
(-)a/t/db_dependent/Koha/Template/Plugin/KohaPlugins.t (-1 / +5 lines)
Lines 2-8 Link Here
2
2
3
use Modern::Perl;
3
use Modern::Perl;
4
4
5
use Test::More tests => 10;
5
use Test::More tests => 14;
6
use CGI;
6
use CGI;
7
use File::Basename;
7
use File::Basename;
8
use File::Spec;
8
use File::Spec;
Lines 40-47 t::lib::Mocks::mock_preference('UseKohaPlugins',1); Link Here
40
t::lib::Mocks::mock_config('enable_plugins',1);
40
t::lib::Mocks::mock_config('enable_plugins',1);
41
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' );
41
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' );
42
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' );
42
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' );
43
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' );
44
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' );
43
45
44
t::lib::Mocks::mock_preference('UseKohaPlugins',0);
46
t::lib::Mocks::mock_preference('UseKohaPlugins',0);
45
t::lib::Mocks::mock_config('enable_plugins',0);
47
t::lib::Mocks::mock_config('enable_plugins',0);
46
is( $plugin->get_plugins_opac_js, q{}, 'Test plugin opac_js return value is empty' );
48
is( $plugin->get_plugins_opac_js, q{}, 'Test plugin opac_js return value is empty' );
47
is( $plugin->get_plugins_opac_head, q{}, 'Test plugin opac_head return value is empty' );
49
is( $plugin->get_plugins_opac_head, q{}, 'Test plugin opac_head return value is empty' );
50
is( $plugin->get_plugins_intranet_js, q{}, 'Test plugin intranet_js return value is empty' );
51
is( $plugin->get_plugins_intranet_head, q{}, 'Test plugin intranet_head return value is empty' );
(-)a/t/db_dependent/Plugins.t (+2 lines)
Lines 47-52 ok( $plugin->can('opac_online_payment_begin'), 'Test plugin can opac_online_paym Link Here
47
ok( $plugin->can('opac_online_payment_end'), 'Test plugin can opac_online_payment_end' );
47
ok( $plugin->can('opac_online_payment_end'), 'Test plugin can opac_online_payment_end' );
48
ok( $plugin->can('opac_head'), 'Test plugin can opac_head' );
48
ok( $plugin->can('opac_head'), 'Test plugin can opac_head' );
49
ok( $plugin->can('opac_js'), 'Test plugin can opac_js' );
49
ok( $plugin->can('opac_js'), 'Test plugin can opac_js' );
50
ok( $plugin->can('intranet_head'), 'Test plugin can intranet_head' );
51
ok( $plugin->can('intranet_js'), 'Test plugin can intranet_js' );
50
ok( $plugin->can('configure'), 'Test plugin can configure' );
52
ok( $plugin->can('configure'), 'Test plugin can configure' );
51
ok( $plugin->can('install'), 'Test plugin can install' );
53
ok( $plugin->can('install'), 'Test plugin can install' );
52
ok( $plugin->can('upgrade'), 'Test plugin can upgrade' );
54
ok( $plugin->can('upgrade'), 'Test plugin can upgrade' );
(-)a/t/lib/Koha/Plugin/Test.pm (-1 / +10 lines)
Lines 70-75 sub opac_js { Link Here
70
    return "Koha::Plugin::Test::opac_js";
70
    return "Koha::Plugin::Test::opac_js";
71
}
71
}
72
72
73
sub intranet_head {
74
    my ( $self, $args ) = @_;
75
    return "Koha::Plugin::Test::intranet_head";
76
}
77
78
sub intranet_js {
79
    my ( $self, $args ) = @_;
80
    return "Koha::Plugin::Test::intranet_js";
81
}
82
73
sub configure {
83
sub configure {
74
    my ( $self, $args ) = @_;
84
    my ( $self, $args ) = @_;
75
    return "Koha::Plugin::Test::configure";;
85
    return "Koha::Plugin::Test::configure";;
76
- 

Return to bug 21352