Bug 26922: Regression tests
[koha.git] / Koha / Template / Plugin / Koha.pm
blob5ed58a95ad8b5fde8b1bbb85c6a55c8253cf7e81
1 package Koha::Template::Plugin::Koha;
3 # Copyright ByWater Solutions 2013
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
20 use Modern::Perl;
22 use base qw( Template::Plugin );
24 use C4::Context;
25 use Koha;
27 =head1 NAME
29 Koha::Template::Plugin::Koha - General Koha Template Toolkit plugin
31 =head1 SYNOPSIS
33 This plugin contains various Koha replated Template Toolkit functions
34 to help streamline Koha and to move logic from the Perl code into the
35 Templates when it makes sense to do so.
37 To use, first, include the line '[% USE Koha %]' at the top
38 of the template to enable the plugin.
40 For example: [% IF Koha.Preference( 'MyPreference ) == 'SettingA' %]
41 removes the necessity of setting a template variable in Perl code for
42 each and every system preference, even if no evaluation of the setting
43 is necessary.
45 =cut
47 =head1 API
49 =head2 Class Methods
51 =cut
53 sub Preference {
54 my ( $self, $pref ) = @_;
55 return C4::Context->preference( $pref );
58 sub Version {
59 my $version_string = Koha::version();
60 my ( $major, $minor, $maintenance, $development ) = split( '\.', $version_string );
62 return {
63 major => $major,
64 minor => $minor,
65 release => $major . "." . $minor,
66 maintenance => $major . "." . $minor . "." . $maintenance,
67 development => ( $development ne '000' ) ? $development : undef,
71 =head3 ArePluginsEnabled
73 Returns true if plugins are enabled, false otherwise.
75 =cut
77 sub ArePluginsEnabled {
78 return C4::Context->config('enable_plugins');