line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DTL::Fast::Filter::Urlizetrunc; |
2
|
2
|
|
|
2
|
|
928
|
use strict; use utf8; use warnings FATAL => 'all'; |
|
2
|
|
|
2
|
|
3
|
|
|
2
|
|
|
2
|
|
46
|
|
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
50
|
|
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
79
|
|
3
|
2
|
|
|
2
|
|
7
|
use parent 'DTL::Fast::Filter::Urlize'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
13
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
$DTL::Fast::FILTER_HANDLERS{'urlizetrunc'} = __PACKAGE__; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
#@Override |
8
|
|
|
|
|
|
|
sub parse_parameters |
9
|
|
|
|
|
|
|
{ |
10
|
9
|
|
|
9
|
0
|
6
|
my $self = shift; |
11
|
|
|
|
|
|
|
die $self->get_parse_error("no max size specified") |
12
|
9
|
50
|
|
|
|
8
|
if not scalar @{$self->{'parameter'}}; |
|
9
|
|
|
|
|
20
|
|
13
|
9
|
|
|
|
|
11
|
$self->{'maxsize'} = $self->{'parameter'}->[0]; |
14
|
9
|
|
|
|
|
19
|
return $self; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
#@Override |
18
|
|
|
|
|
|
|
sub filter |
19
|
|
|
|
|
|
|
{ |
20
|
9
|
|
|
9
|
0
|
9
|
my($self, $filter_manager, $value, $context ) = @_; |
21
|
|
|
|
|
|
|
|
22
|
9
|
|
|
|
|
19
|
$self->{'size'} = $self->{'maxsize'}->render($context); |
23
|
9
|
|
|
|
|
25
|
return $self->SUPER::filter($filter_manager, $value, $context); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
#@Override |
27
|
|
|
|
|
|
|
sub normalize_text |
28
|
|
|
|
|
|
|
{ |
29
|
10
|
|
|
10
|
0
|
11
|
my ($self, $text) = @_; |
30
|
|
|
|
|
|
|
|
31
|
10
|
50
|
|
|
|
25
|
if( length $text > $self->{'size'} ) |
32
|
|
|
|
|
|
|
{ |
33
|
10
|
|
|
|
|
12
|
$text = substr $text, 0, $self->{'size'}; |
34
|
10
|
|
|
|
|
36
|
$text =~ s/\s*$/.../s; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
10
|
|
|
|
|
112
|
return $text; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |