Bug 11944: Remove all utf8 filter from templates
[koha.git] / Koha / Template / Plugin / AuthorisedValues.pm
blob0198ab42710ccabaaaaa5ccb8d2fdec8742f237b
1 package Koha::Template::Plugin::AuthorisedValues;
3 # Copyright 2012 ByWater Solutions
4 # Copyright 2013-2014 BibLibre
6 # Koha is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
11 # Koha is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with Koha; if not, see <http://www.gnu.org/licenses>.
19 use Modern::Perl;
21 use Template::Plugin;
22 use base qw( Template::Plugin );
24 use Encode qw{encode is_utf8};
26 use C4::Koha;
28 sub GetByCode {
29 my ( $self, $category, $code, $opac ) = @_;
30 return encode( 'UTF-8', GetAuthorisedValueByCode( $category, $code, $opac ) );
33 sub Get {
34 my ( $self, $category, $selected, $opac ) = @_;
35 return GetAuthorisedValues( $category, $selected, $opac );
38 sub GetAuthValueDropbox {
39 my ( $self, $category, $default ) = @_;
40 return C4::Koha::GetAuthvalueDropbox($category, $default);
45 =head1 NAME
47 Koha::Template::Plugin::AuthorisedValues - TT Plugin for authorised values
49 =head1 SYNOPSIS
51 [% USE AuthorisedValues %]
53 [% AuthorisedValues.GetByCode( 'CATEGORY', 'AUTHORISED_VALUE_CODE', 'IS_OPAC' ) %]
55 [% AuthorisedValues.GetAuthValueDropbox( $category, $default ) %]
57 =head1 ROUTINES
59 =head2 GetByCode
61 In a template, you can get the description for an authorised value with
62 the following TT code: [% AuthorisedValues.GetByCode( 'CATEGORY', 'AUTHORISED_VALUE_CODE', 'IS_OPAC' ) %]
64 The parameters are identical to those used by the subroutine C4::Koha::GetAuthorisedValueByCode.
66 sub GetByCode {
67 my ( $self, $category, $code, $opac ) = @_;
68 my $av = GetAuthorisedValueByCode( $category, $code, $opac );
69 return $av;
72 =head2 GetAuthValueDropbox
74 The parameters are identical to those used by the subroutine C4::Koha::GetAuthValueDropbox
76 =head1 AUTHOR
78 Kyle M Hall <kyle@bywatersolutions.com>
80 Jonathan Druart <jonathan.druart@biblibre.com>
82 =cut