# Copyright (c) 2008 bivio Software, Inc. All Rights Reserved. # # Visit http://www.bivio.biz for more info. # # This library is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation; either version 2.1 of the # License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; If not, you may get a copy from: # http://www.opensource.org/licenses/lgpl-license.html # # $Id: MonthYear.pm,v 2.3 2010/06/24 16:13:45 moeller Exp $ package Bivio::UI::HTML::Widget::MonthYear; use strict; use Bivio::Base 'Widget.Join'; use Bivio::UI::ViewLanguageAUTOLOAD; our($VERSION) = sprintf('%d.%02d', q$Revision: 2.3 $ =~ /\d+/g); sub initialize { my($self) = @_; $self->put( values => [ _edit($self, 'month', $self->unsafe_get('want_two_digit_month'), $self->unsafe_get('month_choices')), _edit($self, 'year'), ], join_separator => Join([ vs_blank_cell(2), '/', vs_blank_cell(2), ]), ); return shift->SUPER::initialize(@_); } sub internal_new_args { my($self, $base_field) = @_; return { base_field => $base_field, }; } sub _edit { my($self, $suffix, $want_two_digit_month, $choices) = @_; return vs_edit(join('', $self->ancestral_get('form_class'), '.', $self->get('base_field'), '_', $suffix), { wf_want_select => 1, enum_sort => 'as_int', $want_two_digit_month ? (enum_display => 'get_two_digit_value') : (), $self->unsafe_get('unknown_label') ? (unknown_label => $self->get('unknown_label')) : (), $choices ? (choices => $choices) : (), }); } 1;