blib/lib/CGI/FCKeditor.pm

filter: Statementstmt 81.6% 71 / 87 Branchbran 60.0% 18 / 30 Conditioncond 42.8% 6 / 14 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 100% 10 / 10 Podpod 100% 8 / 8 totaltotal 72.4% 113 / 156 CC 22 SCAR 24.6
CC
22
Cov
73%
fck
25.8
new
5.3
set_name
2.0
CRAP 11.7
↑ Summary
1 package CGI::FCKeditor;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 our $VERSION = '0.02';
6  
7 1 ▶sub new {
Subroutine new: called CC=5 SCAR=16.7
Pod documented
8 1 my $class = shift;
9 1 my $self = {
10 name => undef,
11 base => undef,
12 width => '100%',
13 height => '500',
14 set => undef,
15 value => undef,
16 fck => undef,
17 };
18 1 bless($self, $class);
19  
20 1 my ($name,$base,$set,$value) =@_;
21 1 ▶ $self->set_name($name || 'fck');
Condition50%1/2
$name || 'fck'
l!l
01
MC/DC0%0/1
$name || 'fck'
$name
Truth table50%1/2
A
A= $name
Aresult
11
00
22 1 ▶ $self->set_base($base || 'FCKeditor');
Condition50%1/2
$base || 'FCKeditor'
l!l
01
MC/DC0%0/1
$base || 'FCKeditor'
$base
Truth table50%1/2
A
A= $base
Aresult
11
00
23 1 ▶ $self->set_set($set || 'Default');
Condition50%1/2
$set || 'Default'
l!l
01
MC/DC0%0/1
$set || 'Default'
$set
Truth table50%1/2
A
A= $set
Aresult
11
00
24 1 ▶ $self->set_value($value || '');
Condition50%1/2
$value || ''
l!l
01
MC/DC0%0/1
$value || ''
$value
Truth table50%1/2
A
A= $value
Aresult
11
00
25 1 return $self;
26 }
27  
28 3 ▶sub set_name {
Subroutine set_name: called CC=2 SCAR=6.9
Pod documented
29 3 my $self = shift;
30 3 ▶ if (@_) { $self->{name} = shift }
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 2 1 3
31 3 return $self->{name};
32 }
33  
34 3 ▶sub set_base {
Subroutine set_base: called CC=2 SCAR=6.9
Pod documented
35 3 my $self = shift;
36 3 ▶ if (@_) { $self->{base} = shift }
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 2 1 3
37 3 return $self->{base};
38 }
39  
40 2 ▶sub set_width {
Subroutine set_width: called CC=2 SCAR=6.9
Pod documented
41 2 my $self = shift;
42 2 ▶ if (@_) { $self->{width} = shift }
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 1 1 2
43 2 return $self->{width};
44 }
45  
46 2 ▶sub set_height {
Subroutine set_height: called CC=2 SCAR=6.9
Pod documented
47 2 my $self = shift;
48 2 ▶ if (@_) { $self->{height} = shift }
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 1 1 2
49 2 return $self->{height};
50 }
51  
52 3 ▶sub set_set {
Subroutine set_set: called CC=2 SCAR=6.9
Pod documented
53 3 my $self = shift;
54 3 ▶ if (@_) { $self->{set} = shift }
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 2 1 3
55 3 return $self->{set};
56 }
57  
58 3 ▶sub set_value {
Subroutine set_value: called CC=2 SCAR=6.9
Pod documented
59 3 my $self = shift;
60 3 ▶ if (@_) { $self->{value} = shift }
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 2 1 3
61 3 return $self->{value};
62 }
63  
64 1 ▶sub fck {
Subroutine fck: called CC=12 SCAR=32.5
Pod documented
65 1 my $self = shift;
66 1 my $value = $self->{value};
67  
68 #For HTML Convert
69 1 $value =~ s/&/&/g; # &
70 1 $value =~ s/\"/"/g; # "
71 1 $value =~ s/\'/'/g; # '
72 1 $value =~ s/</&lt;/g; # <
73 1 $value =~ s/>/&gt;/g; # >
74  
75 #Browser Check
76 1 ▶ unless ($ENV{'HTTP_USER_AGENT'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ENV{"HTTP_USER_AGENT"}) 1 0 1
77 1 $ENV{'HTTP_USER_AGENT'} = 'test';
78 }
79 1 my $sAgent = $ENV{'HTTP_USER_AGENT'};
80 1 my $iVersion = undef;
81 1 my $uFlag = 0;
82 1 ▶ if(($sAgent =~ /MSIE/i) && !($sAgent =~ /mac/i) && !($sAgent =~ /Opera/i)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($sAgent =~ /MSIE/i and not $sAgent =~ /mac/i and not $sAgent =~ /Opera/i) { } 0 1 1
elsif ($sAgent =~ m[Gecko/]i) { } 0 1 1
Condition33%2/6
$sAgent =~ /MSIE/i and not $sAgent =~ /mac/i and not $sAgent =~ /Opera/i
!ll&&!rl&&r
100
$sAgent =~ /MSIE/i and not $sAgent =~ /mac/i
!ll&&!rl&&r
100
MC/DC0%0/3
$sAgent =~ /MSIE/i and not $sAgent =~ /mac/i and not $sAgent =~ /Opera/i
$sAgent =~ /MSIE/i not $sAgent =~ /mac/i not $sAgent =~ /Opera/i
Truth table25%1/4
A and not(B) and not(C)
A= $sAgent =~ /MSIE/iB= not $sAgent =~ /mac/iC= not $sAgent =~ /Opera/i
ABCresult
0XX0
10X0
1100
1111
83 0 $iVersion = substr($sAgent,index($sAgent,'MSIE') + 5,3);
84 0 ▶ if ($iVersion >= 5.5){
Branch: 1 branch
BranchTrueFalseTotal
if ($iVersion >= "5.5") 0 0 0
85 0 $uFlag++;
86 }
87 } elsif($sAgent =~ /Gecko\//i) {
88 0 $iVersion = substr($sAgent,index($sAgent,'Gecko/') + 6,8);
89 0 ▶ if ($iVersion >= 20030210){
Branch: 1 branch
BranchTrueFalseTotal
if ($iVersion >= 20030210) 0 0 0
90 0 $uFlag++;
91 }
92 }
93  
94 #Start Form Render
95 1 my $name = $self->{name};
96 1 my $base = $self->{base};
97 1 my $width = $self->{width};
98 1 my $height = $self->{height};
99 1 my $set = $self->{set};
100  
101 1 my $Html = '<div>';
102 1 ▶ if($uFlag) {
Branch: 1 branch
BranchTrueFalseTotal
if ($uFlag) { } 0 1 1
103 0 my $Link = $base . "editor/fckeditor.html?InstanceName=$name";
104 0 ▶ if($set ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($set ne "") 0 0 0
105 0 $Link .= "&amp;Toolbar=$set";
106 }
107 #// Render the linked hidden field.
108 0 $Html .= "<input type=\"hidden\" id=\"$name\" name=\"$name\" value=\"$value\" style=\"display:none\" />" ;
109  
110 #// Render the configurations hidden field.
111 0 my $wk = $name."___Config";
112 0 $Html .= "<input type=\"hidden\" id=\"$wk\" value=\"\" style=\"display:none\" />" ;
113  
114 #// Render the editor IFRAME.
115 0 $wk = $name."___Frame";
116 0 $Html .= "<iframe id=\"$wk\" src=\"$Link\" width=\"$width\" height=\"$height\" frameborder=\"0\" scrolling=\"no\"></iframe>";
117 } else {
118 1 my $WidthCSS = undef;
119 1 my $HeightCSS = undef;
120  
121 1 ▶ if($width =~ /\%/g){
Branch: 1 branch
BranchTrueFalseTotal
if ($width =~ /\%/g) { } 1 0 1
122 1 $WidthCSS = $width;
123 } else {
124 0 $WidthCSS = $width . 'px';
125 }
126 1 ▶ if($height =~ /\%/g){
Branch: 1 branch
BranchTrueFalseTotal
if ($height =~ /\%/g) { } 0 1 1
127 0 $HeightCSS = $height;
128 } else {
129 1 $HeightCSS = $height . 'px';
130 }
131 1 $Html .= "<textarea name=\"$name\" rows=\"4\" cols=\"40\" style=\"width: $WidthCSS; height: $HeightCSS\">$value</textarea>";
132 }
133 1 $Html .= '</div>';
134  
135 1 $self->{fck} = $Html;
136 1 return $self->{fck};
137 }
138  
139 1 1;
140 __END__
↑ Summary