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