line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: FONT.pm 284 2006-12-01 07:51:49Z chronos $ |
2
|
|
|
|
|
|
|
package BBCode::Tag::FONT; |
3
|
2
|
|
|
2
|
|
15
|
use base qw(BBCode::Tag::Inline); |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
214
|
|
4
|
2
|
|
|
2
|
|
13
|
use BBCode::Util qw(:parse encodeHTML multilineText); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
505
|
|
5
|
2
|
|
|
2
|
|
15
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
81
|
|
6
|
2
|
|
|
2
|
|
13
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1062
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.34'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub BodyPermitted($):method { |
10
|
40
|
|
|
40
|
1
|
163
|
return 1; |
11
|
|
|
|
|
|
|
} |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub NamedParams($):method { |
14
|
22
|
|
|
22
|
1
|
85
|
return qw(FACE SIZE COLOR); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub RequiredParams($):method { |
18
|
0
|
|
|
0
|
1
|
0
|
return (); |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub DefaultParam($):method { |
22
|
15
|
|
|
15
|
1
|
44
|
return 'FACE'; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub validateParam($$$):method { |
26
|
15
|
|
|
15
|
1
|
34
|
my($this,$param,$val) = @_; |
27
|
|
|
|
|
|
|
|
28
|
15
|
100
|
|
|
|
43
|
if($param eq 'SIZE') { |
29
|
4
|
|
|
|
|
20
|
my $size = parseFontSize($val); |
30
|
4
|
50
|
|
|
|
12
|
if(defined $size) { |
31
|
4
|
|
|
|
|
18
|
return $size; |
32
|
|
|
|
|
|
|
} else { |
33
|
0
|
|
|
|
|
0
|
die qq(Invalid value [FONT SIZE="$val"]); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
} |
36
|
11
|
100
|
|
|
|
32
|
if($param eq 'COLOR') { |
37
|
6
|
|
|
|
|
25
|
my $color = parseColor($val); |
38
|
6
|
50
|
|
|
|
18
|
if(defined $color) { |
39
|
6
|
|
|
|
|
22
|
return $color; |
40
|
|
|
|
|
|
|
} else { |
41
|
0
|
|
|
|
|
0
|
die qq(Invalid value [FONT COLOR="$val"]); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} |
44
|
5
|
|
|
|
|
31
|
return $this->SUPER::validateParam($param,$val); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub toHTML($):method { |
48
|
11
|
|
|
11
|
1
|
43
|
my $this = shift->replace; |
49
|
11
|
|
|
|
|
55
|
my $ret = $this->bodyHTML; |
50
|
11
|
|
|
|
|
44
|
my $face = $this->param('FACE'); |
51
|
11
|
|
|
|
|
41
|
my $size = $this->param('SIZE'); |
52
|
11
|
|
|
|
|
39
|
my $color = $this->param('COLOR'); |
53
|
11
|
|
|
|
|
17
|
my @css; |
54
|
11
|
100
|
|
|
|
42
|
push @css, sprintf "font-family: '%s'", encodeHTML($face) if defined $face; |
55
|
11
|
100
|
|
|
|
48
|
push @css, sprintf "font-size: %s", encodeHTML($size) if defined $size; |
56
|
11
|
100
|
|
|
|
45
|
push @css, sprintf "color: %s", encodeHTML($color) if defined $color; |
57
|
11
|
50
|
|
|
|
33
|
return $ret unless @css; |
58
|
11
|
|
|
|
|
68
|
return multilineText ''.$ret.''; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |