PluginProbe
Wp-Insert / 1.6.2
Wp-Insert v1.6.2
trunk 1.0 1.1 1.2 1.2.1 1.2.2 1.3.0 1.3.1 1.3.3 1.4 1.5.0 1.5.1 1.5.2 1.5.3 1.6.0 1.6.1 1.6.2 1.7 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 2.0 All 63 releases
wp-insert / fckeditor / fckeditor.pl

fckeditor.pl in Wp-Insert 1.6.2, at fckeditor/fckeditor.pl

144 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 #####
2 # FCKeditor - The text editor for Internet - http://www.fckeditor.net
3 # Copyright (C) 2003-2009 Frederico Caldeira Knabben
4 #
5 # == BEGIN LICENSE ==
6 #
7 # Licensed under the terms of any of the following licenses at your
8 # choice:
9 #
10 # - GNU General Public License Version 2 or later (the "GPL")
11 # http://www.gnu.org/licenses/gpl.html
12 #
13 # - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
14 # http://www.gnu.org/licenses/lgpl.html
15 #
16 # - Mozilla Public License Version 1.1 or later (the "MPL")
17 # http://www.mozilla.org/MPL/MPL-1.1.html
18 #
19 # == END LICENSE ==
20 #
21 # This is the integration file for Perl.
22 #####
23
24 #my $InstanceName;
25 #my $BasePath;
26 #my $Width;
27 #my $Height;
28 #my $ToolbarSet;
29 #my $Value;
30 #my %Config;
31
32 sub FCKeditor
33 {
34
35 local($instanceName) = @_;
36 $InstanceName = $instanceName;
37 $BasePath = '/fckeditor/';
38 $Width = '100%';
39 $Height = '200';
40 $ToolbarSet = 'Default';
41 $Value = '';
42 }
43
44 sub Create
45 {
46 print &CreateHtml();
47 }
48
49 sub specialchar_cnv
50 {
51
52 local($ch) = @_;
53
54 $ch =~ s/&/&/g; # &
55 $ch =~ s/\"/"/g; #"
56 $ch =~ s/\'/'/g; # '
57 $ch =~ s/</&lt;/g; # <
58 $ch =~ s/>/&gt;/g; # >
59 return($ch);
60 }
61
62 sub CreateHtml
63 {
64
65 $HtmlValue = &specialchar_cnv($Value);
66 $Html = '' ;
67 if(&IsCompatible()) {
68 $Link = $BasePath . "editor/fckeditor.html?InstanceName=$InstanceName";
69 if($ToolbarSet ne '') {
70 $Link .= "&amp;Toolbar=$ToolbarSet";
71 }
72 #// Render the linked hidden field.
73 $Html .= "<input type=\"hidden\" id=\"$InstanceName\" name=\"$InstanceName\" value=\"$HtmlValue\" style=\"display:none\" />" ;
74
75 #// Render the configurations hidden field.
76 $cfgstr = &GetConfigFieldString();
77 $wk = $InstanceName."___Config";
78 $Html .= "<input type=\"hidden\" id=\"$wk\" value=\"$cfgstr\" style=\"display:none\" />" ;
79
80 #// Render the editor IFRAME.
81 $wk = $InstanceName."___Frame";
82 $Html .= "<iframe id=\"$wk\" src=\"$Link\" width=\"$Width\" height=\"$Height\" frameborder=\"0\" scrolling=\"no\"></iframe>";
83 } else {
84 if($Width =~ /\%/g){
85 $WidthCSS = $Width;
86 } else {
87 $WidthCSS = $Width . 'px';
88 }
89 if($Height =~ /\%/g){
90 $HeightCSS = $Height;
91 } else {
92 $HeightCSS = $Height . 'px';
93 }
94 $Html .= "<textarea name=\"$InstanceName\" rows=\"4\" cols=\"40\" style=\"width: $WidthCSS; height: $HeightCSS\">$HtmlValue</textarea>";
95 }
96 return($Html);
97 }
98
99 sub IsCompatible
100 {
101
102 $sAgent = $ENV{'HTTP_USER_AGENT'};
103 if(($sAgent =~ /MSIE/i) && !($sAgent =~ /mac/i) && !($sAgent =~ /Opera/i)) {
104 $iVersion = substr($sAgent,index($sAgent,'MSIE') + 5,3);
105 return($iVersion >= 5.5) ;
106 } elsif($sAgent =~ /Gecko\//i) {
107 $iVersion = substr($sAgent,index($sAgent,'Gecko/') + 6,8);
108 return($iVersion >= 20030210) ;
109 } elsif($sAgent =~ /Opera\//i) {
110 $iVersion = substr($sAgent,index($sAgent,'Opera/') + 6,4);
111 return($iVersion >= 9.5) ;
112 } elsif($sAgent =~ /AppleWebKit\/(\d+)/i) {
113 return($1 >= 522) ;
114 } else {
115 return(0); # 2.0 PR fix
116 }
117 }
118
119 sub GetConfigFieldString
120 {
121 $sParams = '';
122 $bFirst = 0;
123 foreach $sKey (keys %Config) {
124 $sValue = $Config{$sKey};
125 if($bFirst == 1) {
126 $sParams .= '&amp;';
127 } else {
128 $bFirst = 1;
129 }
130 $k = &specialchar_cnv($sKey);
131 $v = &specialchar_cnv($sValue);
132 if($sValue eq "true") {
133 $sParams .= "$k=true";
134 } elsif($sValue eq "false") {
135 $sParams .= "$k=false";
136 } else {
137 $sParams .= "$k=$v";
138 }
139 }
140 return($sParams);
141 }
142
143 1;
144