line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::Shakan::Fields; |
2
|
23
|
|
|
23
|
|
140
|
use strict; |
|
23
|
|
|
|
|
50
|
|
|
23
|
|
|
|
|
628
|
|
3
|
23
|
|
|
23
|
|
113
|
use warnings; |
|
23
|
|
|
|
|
50
|
|
|
23
|
|
|
|
|
556
|
|
4
|
23
|
|
|
23
|
|
134
|
use parent 'Exporter'; |
|
23
|
|
|
|
|
49
|
|
|
23
|
|
|
|
|
126
|
|
5
|
23
|
|
|
23
|
|
1066
|
use Carp (); |
|
23
|
|
|
|
|
63
|
|
|
23
|
|
|
|
|
6903
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our @EXPORT = qw( |
8
|
|
|
|
|
|
|
TextField |
9
|
|
|
|
|
|
|
EmailField |
10
|
|
|
|
|
|
|
URLField |
11
|
|
|
|
|
|
|
UIntField |
12
|
|
|
|
|
|
|
IntField |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
PasswordField |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
FileField |
17
|
|
|
|
|
|
|
ImageField |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
ChoiceField |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
DateField |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Duplication |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# DateTimeField |
27
|
|
|
|
|
|
|
# ImageField |
28
|
|
|
|
|
|
|
# TimeField |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub _input { |
31
|
49
|
|
|
49
|
|
718
|
HTML::Shakan::Field::Input->new( @_ ); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub TextField { |
35
|
46
|
|
|
46
|
1
|
51016
|
_input(type => 'text', @_); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub EmailField { |
39
|
2
|
|
|
2
|
1
|
679
|
TextField(@_)->add_constraint('EMAIL_LOOSE'); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub URLField { |
43
|
2
|
|
|
2
|
1
|
604
|
TextField(@_)->add_constraint('HTTP_URL'); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub UIntField { |
47
|
2
|
|
|
2
|
1
|
602
|
TextField(@_)->add_constraint('UINT'); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub IntField { |
51
|
2
|
|
|
2
|
1
|
628
|
TextField(@_)->add_constraint('INT'); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub PasswordField { |
55
|
3
|
|
|
3
|
1
|
8
|
_input(type => 'password', @_); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub FileField { |
59
|
7
|
|
|
7
|
1
|
14845
|
HTML::Shakan::Field::File->new(@_); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub ImageField { |
63
|
3
|
|
|
3
|
1
|
12994
|
FileField(@_)->add_constraint(['FILE_MIME' => qr{image/.+}]); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub ChoiceField { |
67
|
15
|
|
|
15
|
1
|
6344
|
HTML::Shakan::Field::Choice->new( @_ ); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub DateField { |
71
|
4
|
|
|
4
|
1
|
2705
|
HTML::Shakan::Field::Date->new( @_ ); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub Duplication { |
75
|
2
|
|
|
2
|
1
|
6
|
my ($name, $f1, $f2) = @_; |
76
|
2
|
50
|
|
|
|
7
|
Carp::croak('missing args. Usage: Duplication(name, field1, field2)') unless @_ == 3; |
77
|
2
|
|
|
|
|
17
|
$f1->add_complex_constraint( |
78
|
|
|
|
|
|
|
+{ $name => [ $f1->name(), $f2->name() ] } => [ 'DUPLICATION' ] |
79
|
|
|
|
|
|
|
); |
80
|
2
|
|
|
|
|
16
|
return ($f1, $f2); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; |
84
|
|
|
|
|
|
|
__END__ |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=encoding utf8 |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 NAME |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
HTML::Shakan::Fields - fields |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 DESCRIPTION |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
This module exports some functions, that generates a instance of HTML::Field::*. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
If you want to know the details, please look the source :) |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 FUNCTIONS |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=over 4 |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=item C<< TextField(name => 'foo') >> |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
create a instance of HTML::Shakan::Input. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
This is same as HTML::Shakan::Input->new(name => 'foo', type => 'text', @_); |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=item C<< EmailField(name => 'email') >> |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
TextField() + EMAIL_LOOSE constraint. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=item C<< URLField(name => 'url') >> |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
TextField() + HTTP_URL constraint |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=item C<< UIntField(name => 'i') >> |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
TextField() + UINT constraint |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=item C<< IntField(name => 'i') >> |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
TextField() + INT constraint |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=item C<< PasswordField(name => 'pw') >> |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
define <input type="password" /> field |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=item C<< FileField(name => 'file') >> |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
define <input type="file" /> field |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=item C<< ImageField(name => 'image') >> |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
FileField + FILE_MIME=image/* constraint |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=item C<< ChoiceField(name => 'interest', choices => [1 => 'moose', 2 => 'mouse', 3 => 'exporter']) >> |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
selector field. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=item C<< DateField(name => 'birthdate') >> |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
date input field. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=item C<< Duplication('mail' => EmailField(), EmailField()) >> |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
both field contains same value? |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=back |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 AUTHORS |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Tokuhiro Matsuno(tokuhirom) |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 SEE ALSO |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
L<HTML::Shakan> |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
use Params::Validate ':all'; |