Bug 18309: Add UNIMARC field 214 and its subfields
[koha.git] / Koha / Template / Plugin / KohaPlugins.pm
blob8624504cdbb0cefa26e5fb7f549b649aaec3eda7
1 package Koha::Template::Plugin::KohaPlugins;
3 # This file is part of Koha.
5 # Copyright ByWater Solutions 2018
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 3 of the License, or (at your option) any later
10 # version.
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 use Modern::Perl;
22 use base qw( Template::Plugin );
24 use Koha::Plugins;
26 =head1 NAME
28 Koha::Template::Plugin::KohaPlugins - A module for adding hooks into Koha for plugins
30 =head1 DESCRIPTION
32 This plugin contains functions related to adding plugin hooks into various parts
33 of Koha.
35 To use, include the line '[% USE KohaPlugins %]' at the top of the template
36 to enable the plugin
38 =head2 Methods
40 =head3 get_plugins_opac_head
42 [% KohaPlugins.get_plugins_opac_head %]
44 This method collects the output of all plugins with an opac_head method
45 to output to the head section of opac pages.
47 =cut
49 sub get_plugins_opac_head {
50 return q{}
51 unless C4::Context->preference('UseKohaPlugins');
53 my $p = Koha::Plugins->new();
55 return q{} unless $p;
57 my @plugins = $p->GetPlugins(
59 method => 'opac_head',
63 my @data = map { $_->opac_head || q{} } @plugins;
65 return join( "\n", @data );
68 =head3 get_plugins_opac_js
70 [% KohaPlugins.get_plugins_opac_js %]
72 This method collects the output of all plugins with an opac_js method
73 to output to the javascript section of at the bottom of opac pages.
75 =cut
77 sub get_plugins_opac_js {
78 return q{}
79 unless C4::Context->preference('UseKohaPlugins');
81 my $p = Koha::Plugins->new();
83 return q{} unless $p;
85 my @plugins = $p->GetPlugins(
87 method => 'opac_js',
91 my @data = map { $_->opac_js || q{} } @plugins;
93 return join( "\n", @data );
96 =head3 get_plugins_intranet_head
98 [% KohaPlugins.get_plugins_intranet_head %]
100 This method collects the output of all plugins with an intranet_head method
101 to output to the head section of intranet pages.
103 =cut
105 sub get_plugins_intranet_head {
106 return q{}
107 unless C4::Context->preference('UseKohaPlugins');
109 my $p = Koha::Plugins->new();
111 return q{} unless $p;
113 my @plugins = $p->GetPlugins(
115 method => 'intranet_head',
119 my @data = map { $_->intranet_head || q{} } @plugins;
121 return join( "\n", @data );
124 =head3 get_plugins_intranet_js
126 [% KohaPlugins.get_plugins_intranet_js %]
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.
131 =cut
133 sub get_plugins_intranet_js {
134 return q{}
135 unless C4::Context->preference('UseKohaPlugins');
137 my $p = Koha::Plugins->new();
139 return q{} unless $p;
141 my @plugins = $p->GetPlugins(
143 method => 'intranet_js',
147 my @data = map { $_->intranet_js || q{} } @plugins;
149 return join( "\n", @data );