line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Rose::HTML::Form::Field::Time::Seconds; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
46
|
use strict; |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
224
|
|
4
|
|
|
|
|
|
|
|
5
|
6
|
|
|
6
|
|
45
|
use Rose::HTML::Object::Errors qw(:time); |
|
6
|
|
|
|
|
18
|
|
|
6
|
|
|
|
|
62
|
|
6
|
6
|
|
|
6
|
|
55
|
use Rose::HTML::Object::Messages qw(:time); |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
36
|
|
7
|
|
|
|
|
|
|
|
8
|
6
|
|
|
6
|
|
43
|
use base 'Rose::HTML::Form::Field::Text'; |
|
6
|
|
|
|
|
21
|
|
|
6
|
|
|
|
|
2001
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.606'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
__PACKAGE__->add_required_html_attrs( |
13
|
|
|
|
|
|
|
{ |
14
|
|
|
|
|
|
|
size => 2, |
15
|
|
|
|
|
|
|
}); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub init |
18
|
|
|
|
|
|
|
{ |
19
|
23
|
|
|
23
|
1
|
60
|
my($self) = shift; |
20
|
23
|
|
|
|
|
125
|
$self->label_id(FIELD_LABEL_SECOND); |
21
|
23
|
|
|
|
|
138
|
$self->SUPER::init(@_); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub validate |
25
|
|
|
|
|
|
|
{ |
26
|
0
|
|
|
0
|
1
|
|
my($self) = shift; |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
my $ok = $self->SUPER::validate(@_); |
29
|
0
|
0
|
|
|
|
|
return $ok unless($ok); |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
my $value = $self->internal_value; |
32
|
|
|
|
|
|
|
|
33
|
0
|
0
|
0
|
|
|
|
unless($value =~ /^\d\d?$/ && $value >= 0 && $value <= 59) |
|
|
|
0
|
|
|
|
|
34
|
|
|
|
|
|
|
{ |
35
|
0
|
|
|
|
|
|
$self->add_error_id(TIME_INVALID_SECONDS); |
36
|
0
|
|
|
|
|
|
return 0; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
return 1; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
if(__PACKAGE__->localizer->auto_load_messages) |
43
|
|
|
|
|
|
|
{ |
44
|
|
|
|
|
|
|
__PACKAGE__->localizer->load_all_messages; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
6
|
|
|
6
|
|
73
|
use utf8; # The __DATA__ section contains UTF-8 text |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
37
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
__DATA__ |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
[% LOCALE en %] |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
FIELD_LABEL_SECOND = "Second" |
56
|
|
|
|
|
|
|
FIELD_ERROR_LABEL_SECOND = "second" |
57
|
|
|
|
|
|
|
TIME_INVALID_SECONDS = "Invalid seconds." |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
[% LOCALE de %] |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
TIME_INVALID_SECONDS = "Ungültige Sekunden." |
62
|
|
|
|
|
|
|
FIELD_LABEL_SECOND = "Sekunden" |
63
|
|
|
|
|
|
|
FIELD_ERROR_LABEL_SECOND = "Sekunden" |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
[% LOCALE fr %] |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
TIME_INVALID_SECONDS = "Secondes invalides." |
68
|
|
|
|
|
|
|
FIELD_LABEL_SECOND = "Second" |
69
|
|
|
|
|
|
|
FIELD_ERROR_LABEL_SECOND = "Second" |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
[% LOCALE bg %] |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
FIELD_LABEL_SECOND = "Секунда" |
74
|
|
|
|
|
|
|
FIELD_ERROR_LABEL_SECOND = "секунда" |
75
|
|
|
|
|
|
|
TIME_INVALID_SECONDS = "Невалидни секунди." |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
__END__ |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 NAME |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Rose::HTML::Form::Field::Time::Seconds - Text field that only accepts valid seconds. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 SYNOPSIS |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
$field = |
86
|
|
|
|
|
|
|
Rose::HTML::Form::Field::Time::Seconds->new( |
87
|
|
|
|
|
|
|
label => 'Seconds', |
88
|
|
|
|
|
|
|
name => 'secs'); |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
$field->input_value(99); |
91
|
|
|
|
|
|
|
$field->validate; # 0 |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
$field->input_value(20); |
94
|
|
|
|
|
|
|
$field->validate; # 1 |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
print $field->html; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
... |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 DESCRIPTION |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
L<Rose::HTML::Form::Field::Time::Seconds> is a subclass of L<Rose::HTML::Form::Field::Text> that only accepts valid seconds: numbers between 0 and 59, inclusive, with or without leading zeros. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 AUTHOR |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
John C. Siracusa (siracusa@gmail.com) |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 LICENSE |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Copyright (c) 2010 by John C. Siracusa. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |