--- /dev/null
+#####\r
+# FCKeditor - The text editor for Internet - http://www.fckeditor.net\r
+# Copyright (C) 2003-2008 Frederico Caldeira Knabben\r
+#\r
+# == BEGIN LICENSE ==\r
+#\r
+# Licensed under the terms of any of the following licenses at your\r
+# choice:\r
+#\r
+# - GNU General Public License Version 2 or later (the "GPL")\r
+# http://www.gnu.org/licenses/gpl.html\r
+#\r
+# - GNU Lesser General Public License Version 2.1 or later (the "LGPL")\r
+# http://www.gnu.org/licenses/lgpl.html\r
+#\r
+# - Mozilla Public License Version 1.1 or later (the "MPL")\r
+# http://www.mozilla.org/MPL/MPL-1.1.html\r
+#\r
+# == END LICENSE ==\r
+#\r
+# This is the integration file for Perl.\r
+#####\r
+\r
+#my $InstanceName;\r
+#my $BasePath;\r
+#my $Width;\r
+#my $Height;\r
+#my $ToolbarSet;\r
+#my $Value;\r
+#my %Config;\r
+\r
+sub FCKeditor\r
+{\r
+\r
+ local($instanceName) = @_;\r
+ $InstanceName = $instanceName;\r
+ $BasePath = '/fckeditor/';\r
+ $Width = '100%';\r
+ $Height = '200';\r
+ $ToolbarSet = 'Default';\r
+ $Value = '';\r
+}\r
+\r
+sub Create\r
+{\r
+ print &CreateHtml();\r
+}\r
+\r
+sub specialchar_cnv\r
+{\r
+\r
+ local($ch) = @_;\r
+\r
+ $ch =~ s/&/&/g; # &\r
+ $ch =~ s/\"/"/g; #"\r
+ $ch =~ s/\'/'/g; # '\r
+ $ch =~ s/</</g; # <\r
+ $ch =~ s/>/>/g; # >\r
+ return($ch);\r
+}\r
+\r
+sub CreateHtml\r
+{\r
+\r
+ $HtmlValue = &specialchar_cnv($Value);\r
+ $Html = '' ;\r
+ if(&IsCompatible()) {\r
+ $Link = $BasePath . "editor/fckeditor.html?InstanceName=$InstanceName";\r
+ if($ToolbarSet ne '') {\r
+ $Link .= "&Toolbar=$ToolbarSet";\r
+ }\r
+ #// Render the linked hidden field.\r
+ $Html .= "<input type=\"hidden\" id=\"$InstanceName\" name=\"$InstanceName\" value=\"$HtmlValue\" style=\"display:none\" />" ;\r
+\r
+ #// Render the configurations hidden field.\r
+ $cfgstr = &GetConfigFieldString();\r
+ $wk = $InstanceName."___Config";\r
+ $Html .= "<input type=\"hidden\" id=\"$wk\" value=\"$cfgstr\" style=\"display:none\" />" ;\r
+\r
+ #// Render the editor IFRAME.\r
+ $wk = $InstanceName."___Frame";\r
+ $Html .= "<iframe id=\"$wk\" src=\"$Link\" width=\"$Width\" height=\"$Height\" frameborder=\"0\" scrolling=\"no\"></iframe>";\r
+ } else {\r
+ if($Width =~ /\%/g){\r
+ $WidthCSS = $Width;\r
+ } else {\r
+ $WidthCSS = $Width . 'px';\r
+ }\r
+ if($Height =~ /\%/g){\r
+ $HeightCSS = $Height;\r
+ } else {\r
+ $HeightCSS = $Height . 'px';\r
+ }\r
+ $Html .= "<textarea name=\"$InstanceName\" rows=\"4\" cols=\"40\" style=\"width: $WidthCSS; height: $HeightCSS\">$HtmlValue</textarea>";\r
+ }\r
+ return($Html);\r
+}\r
+\r
+sub IsCompatible\r
+{\r
+\r
+ $sAgent = $ENV{'HTTP_USER_AGENT'};\r
+ if(($sAgent =~ /MSIE/i) && !($sAgent =~ /mac/i) && !($sAgent =~ /Opera/i)) {\r
+ $iVersion = substr($sAgent,index($sAgent,'MSIE') + 5,3);\r
+ return($iVersion >= 5.5) ;\r
+ } elsif($sAgent =~ /Gecko\//i) {\r
+ $iVersion = substr($sAgent,index($sAgent,'Gecko/') + 6,8);\r
+ return($iVersion >= 20030210) ;\r
+ } elsif($sAgent =~ /Opera\//i) {\r
+ $iVersion = substr($sAgent,index($sAgent,'Opera/') + 6,4);\r
+ return($iVersion >= 9.5) ;\r
+ } elsif($sAgent =~ /AppleWebKit\/(\d+)/i) {\r
+ return($1 >= 522) ;\r
+ } else {\r
+ return(0); # 2.0 PR fix\r
+ }\r
+}\r
+\r
+sub GetConfigFieldString\r
+{\r
+ $sParams = '';\r
+ $bFirst = 0;\r
+ foreach $sKey (keys %Config) {\r
+ $sValue = $Config{$sKey};\r
+ if($bFirst == 1) {\r
+ $sParams .= '&';\r
+ } else {\r
+ $bFirst = 1;\r
+ }\r
+ $k = &specialchar_cnv($sKey);\r
+ $v = &specialchar_cnv($sValue);\r
+ if($sValue eq "true") {\r
+ $sParams .= "$k=true";\r
+ } elsif($sValue eq "false") {\r
+ $sParams .= "$k=false";\r
+ } else {\r
+ $sParams .= "$k=$v";\r
+ }\r
+ }\r
+ return($sParams);\r
+}\r
+\r
+1;\r