| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package CGI::FCKeditor; | 
| 2 | 1 |  |  | 1 |  | 73966 | use strict; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 42 |  | 
| 3 | 1 |  |  | 1 |  | 5 | use warnings; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 827 |  | 
| 4 |  |  |  |  |  |  |  | 
| 5 |  |  |  |  |  |  | our $VERSION = '0.02'; | 
| 6 |  |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  | sub new { | 
| 8 | 1 |  |  | 1 | 1 | 13 | my $class = shift; | 
| 9 | 1 |  |  |  |  | 9 | 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 |  |  |  |  | 3 | bless($self, $class); | 
| 19 |  |  |  |  |  |  |  | 
| 20 | 1 |  |  |  |  | 5 | my ($name,$base,$set,$value) =@_; | 
| 21 | 1 |  | 50 |  |  | 19 | $self->set_name($name || 'fck'); | 
| 22 | 1 |  | 50 |  |  | 10 | $self->set_base($base || 'FCKeditor'); | 
| 23 | 1 |  | 50 |  |  | 11 | $self->set_set($set || 'Default'); | 
| 24 | 1 |  | 50 |  |  | 8 | $self->set_value($value || ''); | 
| 25 | 1 |  |  |  |  | 3 | return $self; | 
| 26 |  |  |  |  |  |  | } | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  | sub set_name { | 
| 29 | 3 |  |  | 3 | 1 | 911 | my $self = shift; | 
| 30 | 3 | 100 |  |  |  | 10 | if (@_) { $self->{name} = shift } | 
|  | 2 |  |  |  |  | 10 |  | 
| 31 | 3 |  |  |  |  | 9 | return $self->{name}; | 
| 32 |  |  |  |  |  |  | } | 
| 33 |  |  |  |  |  |  |  | 
| 34 |  |  |  |  |  |  | sub set_base { | 
| 35 | 3 |  |  | 3 | 1 | 5 | my $self = shift; | 
| 36 | 3 | 100 |  |  |  | 7 | if (@_) { $self->{base} = shift } | 
|  | 2 |  |  |  |  | 6 |  | 
| 37 | 3 |  |  |  |  | 9 | return $self->{base}; | 
| 38 |  |  |  |  |  |  | } | 
| 39 |  |  |  |  |  |  |  | 
| 40 |  |  |  |  |  |  | sub set_width { | 
| 41 | 2 |  |  | 2 | 1 | 5 | my $self = shift; | 
| 42 | 2 | 100 |  |  |  | 6 | if (@_) { $self->{width} = shift } | 
|  | 1 |  |  |  |  | 2 |  | 
| 43 | 2 |  |  |  |  | 8 | return $self->{width}; | 
| 44 |  |  |  |  |  |  | } | 
| 45 |  |  |  |  |  |  |  | 
| 46 |  |  |  |  |  |  | sub set_height { | 
| 47 | 2 |  |  | 2 | 1 | 5 | my $self = shift; | 
| 48 | 2 | 100 |  |  |  | 6 | if (@_) { $self->{height} = shift } | 
|  | 1 |  |  |  |  | 2 |  | 
| 49 | 2 |  |  |  |  | 7 | return $self->{height}; | 
| 50 |  |  |  |  |  |  | } | 
| 51 |  |  |  |  |  |  |  | 
| 52 |  |  |  |  |  |  | sub set_set { | 
| 53 | 3 |  |  | 3 | 1 | 5 | my $self = shift; | 
| 54 | 3 | 100 |  |  |  | 15 | if (@_) { $self->{set} = shift } | 
|  | 2 |  |  |  |  | 6 |  | 
| 55 | 3 |  |  |  |  | 10 | return $self->{set}; | 
| 56 |  |  |  |  |  |  | } | 
| 57 |  |  |  |  |  |  |  | 
| 58 |  |  |  |  |  |  | sub set_value { | 
| 59 | 3 |  |  | 3 | 1 | 5 | my $self = shift; | 
| 60 | 3 | 100 |  |  |  | 11 | if (@_) { $self->{value} = shift } | 
|  | 2 |  |  |  |  | 4 |  | 
| 61 | 3 |  |  |  |  | 9 | return $self->{value}; | 
| 62 |  |  |  |  |  |  | } | 
| 63 |  |  |  |  |  |  |  | 
| 64 |  |  |  |  |  |  | sub fck { | 
| 65 | 1 |  |  | 1 | 1 | 3 | my $self = shift; | 
| 66 | 1 |  |  |  |  | 3 | my $value = $self->{value}; | 
| 67 |  |  |  |  |  |  |  | 
| 68 |  |  |  |  |  |  | #For HTML Convert | 
| 69 | 1 |  |  |  |  | 9 | $value =~ s/&/&/g;		# & | 
| 70 | 1 |  |  |  |  | 3 | $value =~ s/\"/"/g;	# " | 
| 71 | 1 |  |  |  |  | 3 | $value =~ s/\'/'/g;		# ' | 
| 72 | 1 |  |  |  |  | 2 | $value =~ s/</g;		# < | 
| 73 | 1 |  |  |  |  | 2 | $value =~ s/>/>/g;		# > | 
| 74 |  |  |  |  |  |  |  | 
| 75 |  |  |  |  |  |  | #Browser Check | 
| 76 | 1 | 50 |  |  |  | 5 | unless ($ENV{'HTTP_USER_AGENT'}) { | 
| 77 | 1 |  |  |  |  | 10 | $ENV{'HTTP_USER_AGENT'} = 'test'; | 
| 78 |  |  |  |  |  |  | } | 
| 79 | 1 |  |  |  |  | 3 | my $sAgent = $ENV{'HTTP_USER_AGENT'}; | 
| 80 | 1 |  |  |  |  | 2 | my $iVersion = undef; | 
| 81 | 1 |  |  |  |  | 2 | my $uFlag = 0; | 
| 82 | 1 | 50 | 33 |  |  | 9 | if(($sAgent =~ /MSIE/i) && !($sAgent =~ /mac/i) && !($sAgent =~ /Opera/i)) { | 
|  |  | 50 | 33 |  |  |  |  | 
| 83 | 0 |  |  |  |  | 0 | $iVersion = substr($sAgent,index($sAgent,'MSIE') + 5,3); | 
| 84 | 0 | 0 |  |  |  | 0 | if ($iVersion >= 5.5){ | 
| 85 | 0 |  |  |  |  | 0 | $uFlag++; | 
| 86 |  |  |  |  |  |  | } | 
| 87 |  |  |  |  |  |  | } elsif($sAgent =~ /Gecko\//i) { | 
| 88 | 0 |  |  |  |  | 0 | $iVersion = substr($sAgent,index($sAgent,'Gecko/') + 6,8); | 
| 89 | 0 | 0 |  |  |  | 0 | if ($iVersion >= 20030210){ | 
| 90 | 0 |  |  |  |  | 0 | $uFlag++; | 
| 91 |  |  |  |  |  |  | } | 
| 92 |  |  |  |  |  |  | } | 
| 93 |  |  |  |  |  |  |  | 
| 94 |  |  |  |  |  |  | #Start Form Render | 
| 95 | 1 |  |  |  |  | 2 | my $name = $self->{name}; | 
| 96 | 1 |  |  |  |  | 2 | my $base = $self->{base}; | 
| 97 | 1 |  |  |  |  | 2 | my $width = $self->{width}; | 
| 98 | 1 |  |  |  |  | 3 | my $height = $self->{height}; | 
| 99 | 1 |  |  |  |  | 2 | my $set = $self->{set}; | 
| 100 |  |  |  |  |  |  |  | 
| 101 | 1 |  |  |  |  | 22 | my $Html = ' ';  | 
| 102 | 1 | 50 |  |  |  | 4 | if($uFlag) { | 
| 103 | 0 |  |  |  |  | 0 | my $Link = $base . "editor/fckeditor.html?InstanceName=$name"; | 
| 104 | 0 | 0 |  |  |  | 0 | if($set ne '') { | 
| 105 | 0 |  |  |  |  | 0 | $Link .= "&Toolbar=$set"; | 
| 106 |  |  |  |  |  |  | } | 
| 107 |  |  |  |  |  |  | #// Render the linked hidden field. | 
| 108 | 0 |  |  |  |  | 0 | $Html .= "" ; | 
| 109 |  |  |  |  |  |  |  | 
| 110 |  |  |  |  |  |  | #// Render the configurations hidden field. | 
| 111 | 0 |  |  |  |  | 0 | my $wk = $name."___Config"; | 
| 112 | 0 |  |  |  |  | 0 | $Html .= "" ; | 
| 113 |  |  |  |  |  |  |  | 
| 114 |  |  |  |  |  |  | #// Render the editor IFRAME. | 
| 115 | 0 |  |  |  |  | 0 | $wk = $name."___Frame"; | 
| 116 | 0 |  |  |  |  | 0 | $Html .= ""; | 
| 117 |  |  |  |  |  |  | } else { | 
| 118 | 1 |  |  |  |  | 2 | my $WidthCSS = undef; | 
| 119 | 1 |  |  |  |  | 2 | my $HeightCSS = undef; | 
| 120 |  |  |  |  |  |  |  | 
| 121 | 1 | 50 |  |  |  | 5 | if($width =~ /\%/g){ | 
| 122 | 1 |  |  |  |  | 2 | $WidthCSS = $width; | 
| 123 |  |  |  |  |  |  | } else { | 
| 124 | 0 |  |  |  |  | 0 | $WidthCSS = $width . 'px'; | 
| 125 |  |  |  |  |  |  | } | 
| 126 | 1 | 50 |  |  |  | 5 | if($height =~ /\%/g){ | 
| 127 | 0 |  |  |  |  | 0 | $HeightCSS = $height; | 
| 128 |  |  |  |  |  |  | } else { | 
| 129 | 1 |  |  |  |  | 3 | $HeightCSS = $height . 'px'; | 
| 130 |  |  |  |  |  |  | } | 
| 131 | 1 |  |  |  |  | 5 | $Html .= ""; | 
| 132 |  |  |  |  |  |  | } | 
| 133 | 1 |  |  |  |  | 2 | $Html .= ''; | 
| 134 |  |  |  |  |  |  |  | 
| 135 | 1 |  |  |  |  | 2 | $self->{fck} = $Html; | 
| 136 | 1 |  |  |  |  | 6 | return $self->{fck}; | 
| 137 |  |  |  |  |  |  | } | 
| 138 |  |  |  |  |  |  |  | 
| 139 |  |  |  |  |  |  | 1; | 
| 140 |  |  |  |  |  |  | __END__ |