From 915788ff778113e76b6efff07bb8c4d9a47ba7c8 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 6 Mar 2014 17:07:08 +0100 Subject: [PATCH] Bug 766: Create a plugin routine to build dropdown list On this way, dropdown list could be generated from the templates. Signed-off-by: Bernardo Gonzalez Kriegel Signed-off-by: Katrin Fischer Signed-off-by: Galen Charlton --- Koha/Template/Plugin/AuthorisedValues.pm | 26 ++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Koha/Template/Plugin/AuthorisedValues.pm b/Koha/Template/Plugin/AuthorisedValues.pm index 8f80cb1a52..3013706639 100644 --- a/Koha/Template/Plugin/AuthorisedValues.pm +++ b/Koha/Template/Plugin/AuthorisedValues.pm @@ -25,6 +25,7 @@ use base qw( Template::Plugin ); use Encode qw{encode decode}; use C4::Koha; +use C4::Charset; =pod @@ -43,9 +44,34 @@ sub GetByCode { return encode( 'UTF-8', GetAuthorisedValueByCode( $category, $code, $opac ) ); } + sub Get { my ( $self, $category, $selected, $opac ) = @_; return GetAuthorisedValues( $category, $selected, $opac ); } +sub BuildDropbox { + my ( $self, $name, $category, $default, $params ) = @_; + my $class = $params->{class}; + my $avs = C4::Koha::GetAuthvalueDropbox($category, $default); + my $size = $params->{size} || 20; + my $html; + if ( @$avs ) { + $html = qq||; + } else { + $html .= qq||; + + } + + return encode( 'UTF-8', $html ); +} + 1; -- 2.39.5