line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::FormFu::Filter; |
2
|
|
|
|
|
|
|
|
3
|
400
|
|
|
400
|
|
1789
|
use strict; |
|
400
|
|
|
|
|
486
|
|
|
400
|
|
|
|
|
13945
|
|
4
|
|
|
|
|
|
|
our $VERSION = '2.05'; # VERSION |
5
|
|
|
|
|
|
|
|
6
|
400
|
|
|
400
|
|
1413
|
use Moose; |
|
400
|
|
|
|
|
506
|
|
|
400
|
|
|
|
|
2266
|
|
7
|
400
|
|
|
400
|
|
1692631
|
use MooseX::Attribute::FormFuChained; |
|
400
|
|
|
|
|
582
|
|
|
400
|
|
|
|
|
13393
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
with 'HTML::FormFu::Role::NestedHashUtils', |
10
|
|
|
|
|
|
|
'HTML::FormFu::Role::HasParent', |
11
|
|
|
|
|
|
|
'HTML::FormFu::Role::Populate'; |
12
|
|
|
|
|
|
|
|
13
|
400
|
|
|
400
|
|
1538
|
use HTML::FormFu::Attribute qw( mk_inherited_accessors ); |
|
400
|
|
|
|
|
476
|
|
|
400
|
|
|
|
|
18147
|
|
14
|
400
|
|
|
|
|
87010
|
use HTML::FormFu::ObjectUtil qw( |
15
|
400
|
|
|
400
|
|
1617
|
form name parent nested_name nested_names ); |
|
400
|
|
|
|
|
542
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has type => ( is => 'rw', traits => ['FormFuChained'] ); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has localize_args => ( is => 'rw', traits => ['FormFuChained'] ); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub process { |
22
|
56
|
|
|
56
|
0
|
77
|
my ( $self, $result, $params ) = @_; |
23
|
|
|
|
|
|
|
|
24
|
56
|
|
|
|
|
138
|
my $name = $self->nested_name; |
25
|
56
|
|
|
|
|
282
|
my $value = $self->get_nested_hash_value( $params, $name ); |
26
|
|
|
|
|
|
|
|
27
|
56
|
|
|
|
|
73
|
my $filtered; |
28
|
|
|
|
|
|
|
|
29
|
56
|
50
|
|
|
|
144
|
if ( ref $value eq 'ARRAY' ) { |
30
|
0
|
|
|
|
|
0
|
$filtered = [ map { $self->filter( $_, $params ) } @$value ]; |
|
0
|
|
|
|
|
0
|
|
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
else { |
33
|
56
|
|
|
|
|
197
|
$filtered = $self->filter( $value, $params ); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
56
|
|
|
|
|
676
|
$self->set_nested_hash_value( $params, $name, $filtered ); |
37
|
|
|
|
|
|
|
|
38
|
56
|
|
|
|
|
131
|
return; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub clone { |
42
|
6
|
|
|
6
|
0
|
10
|
my ($self) = @_; |
43
|
|
|
|
|
|
|
|
44
|
6
|
|
|
|
|
22
|
my %new = %$self; |
45
|
|
|
|
|
|
|
|
46
|
6
|
|
|
|
|
188
|
return bless \%new, ref $self; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
__END__ |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 NAME |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
HTML::FormFu::Filter - Filter Base Class |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 VERSION |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
version 2.05 |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 SYNOPSIS |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
--- |
66
|
|
|
|
|
|
|
elements: |
67
|
|
|
|
|
|
|
- type: Text |
68
|
|
|
|
|
|
|
name: foo |
69
|
|
|
|
|
|
|
filters: |
70
|
|
|
|
|
|
|
- type: Encode |
71
|
|
|
|
|
|
|
candidates: |
72
|
|
|
|
|
|
|
- utf8 |
73
|
|
|
|
|
|
|
- Hebrew |
74
|
|
|
|
|
|
|
- type: Text |
75
|
|
|
|
|
|
|
name: bar |
76
|
|
|
|
|
|
|
filters: |
77
|
|
|
|
|
|
|
- LowerCase |
78
|
|
|
|
|
|
|
- Encode |
79
|
|
|
|
|
|
|
filters: |
80
|
|
|
|
|
|
|
- TrimEdges |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 DESCRIPTION |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
C<filters()> and C<filter> can be called on any L<form|HTML::FormFu>, |
85
|
|
|
|
|
|
|
L<block element|HTML::FormFu::Element::Block> (includes fieldsets) or |
86
|
|
|
|
|
|
|
L<field element|HTML::FormFu::Role::Element::Field>. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
If called on a field element, no C<name> argument should be passed. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
If called on a L<form|HTML::FormFu> or |
91
|
|
|
|
|
|
|
L<block element|HTML::FormFu::Element::Block>, if no C<name> argument is |
92
|
|
|
|
|
|
|
provided, a new filter is created for and added to every field on that form |
93
|
|
|
|
|
|
|
or block. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
See L<HTML::FormFu/"FORM LOGIC AND VALIDATION"> for further details. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 METHODS |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head2 type |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Returns the C<type> argument originally used to create the filter. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head2 localise_args |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Provide arguments that should be passed to L<localize|HTML::FormFu/localize> |
106
|
|
|
|
|
|
|
to replace C<[_1]>, C<[_2]>, etc. in the localized string. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head2 parent |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Returns the L<HTML::FormFu::Role::Element::Field> object that the filter is |
111
|
|
|
|
|
|
|
associated with. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head2 get_parent |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Arguments: \%options |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Traverses the parent hierarchy, returning the first parent that matches the |
118
|
|
|
|
|
|
|
supplied options. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head2 form |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Returns the L<HTML::FormFu> object that the filter's field is attached to. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head2 name |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Shorthand for C<< $filter->parent->name >> |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 CORE FILTERS |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=over |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=item L<HTML::FormFu::Filter::Callback> |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=item L<HTML::FormFu::Filter::CompoundJoin> |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=item L<HTML::FormFu::Filter::CompoundSprintf> |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=item L<HTML::FormFu::Filter::CopyValue> |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=item L<HTML::FormFu::Filter::Default> |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=item L<HTML::FormFu::Filter::Encode> |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=item L<HTML::FormFu::Filter::ForceListValue> |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=item L<HTML::FormFu::Filter::FormatNumber> |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=item L<HTML::FormFu::Filter::HTMLEscape> |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=item L<HTML::FormFu::Filter::HTMLScrubber> |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=item L<HTML::FormFu::Filter::LowerCase> |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=item L<HTML::FormFu::Filter::NonNumeric> |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=item L<HTML::FormFu::Filter::Regex> |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=item L<HTML::FormFu::Filter::Split> |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=item L<HTML::FormFu::Filter::TrimEdges> |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=item L<HTML::FormFu::Filter::UpperCase> |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=item L<HTML::FormFu::Filter::Whitespace> |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=back |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head1 FILTER BASE CLASSES |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
The following are base classes for other filters, and generally needn't be |
171
|
|
|
|
|
|
|
used directly. |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=over |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=item L<HTML::FormFu::Filter::_Compound> |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=back |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=head1 AUTHOR |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
Carl Franks, C<cfranks@cpan.org> |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
Based on the original source code of L<HTML::Widget::Filter>, by |
184
|
|
|
|
|
|
|
Sebastian Riedel. |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=head1 LICENSE |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
This library is free software, you can redistribute it and/or modify it under |
189
|
|
|
|
|
|
|
the same terms as Perl itself. |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=cut |