source: companies/celepar/news_admin/templates/celepar/fckeditor/to_delete/fckeditor.pl @ 763

Revision 763, 3.1 KB checked in by niltonneto, 15 years ago (diff)

Importação inicial do Expresso da Celepar

Line 
1#####
2#  FCKeditor - The text editor for internet
3#  Copyright (C) 2003-2006 Frederico Caldeira Knabben
4
5#  Licensed under the terms of the GNU Lesser General Public License:
6#               http://www.opensource.org/licenses/lgpl-license.php
7
8#  For further information visit:
9#               http://www.fckeditor.net/
10
11#  "Support Open Source software. What about a donation today?"
12
13#  File Name: fckeditor.pl
14#       This is the integration file for Perl.
15
16#  File Authors:
17#               Takashi Yamaguchi (jack@omakase.net)
18#####
19
20#my $InstanceName;
21#my $BasePath;
22#my $Width;
23#my $Height;
24#my $ToolbarSet;
25#my $Value;
26#my %Config;
27
28sub FCKeditor
29{
30
31        local($instanceName) = @_;
32        $InstanceName   = $instanceName;
33        $BasePath               = '/fckeditor/';
34        $Width                  = '100%';
35        $Height                 = '200';
36        $ToolbarSet             = 'Default';
37        $Value                  = '';
38}
39
40sub Create
41{
42        print &CreateHtml();
43}
44
45sub specialchar_cnv
46{
47
48        local($ch) = @_;
49
50        $ch =~ s/&/&/g;             # &
51        $ch =~ s/\"/"/g;   #"
52        $ch =~ s/\'/'/g;    # '
53        $ch =~ s/</&lt;/g;              # <
54        $ch =~ s/>/&gt;/g;              # >
55        return($ch);
56}
57
58sub CreateHtml
59{
60
61        $HtmlValue = &specialchar_cnv($Value);
62        $Html = '<div>' ;
63        if(&IsCompatible()) {
64                $Link = $BasePath . "editor/fckeditor.html?InstanceName=$InstanceName";
65                if($ToolbarSet ne '') {
66                        $Link .= "&amp;Toolbar=$ToolbarSet";
67                }
68                #// Render the linked hidden field.
69                $Html .= "<input type=\"hidden\" id=\"$InstanceName\" name=\"$InstanceName\" value=\"$HtmlValue\" style=\"display:none\" />" ;
70
71                #// Render the configurations hidden field.
72                $cfgstr = &GetConfigFieldString();
73                $wk = $InstanceName."___Config";
74                $Html .= "<input type=\"hidden\" id=\"$wk\" value=\"$cfgstr\" style=\"display:none\" />" ;
75
76                #// Render the editor IFRAME.
77                $wk = $InstanceName."___Frame";
78                $Html .= "<iframe id=\"$wk\" src=\"$Link\" width=\"$Width\" height=\"$Height\" frameborder=\"0\" scrolling=\"no\"></iframe>";
79        } else {
80                if($Width =~ /\%/g){
81                        $WidthCSS = $Width;
82                } else {
83                        $WidthCSS = $Width . 'px';
84                }
85                if($Height =~ /\%/g){
86                        $HeightCSS = $Height;
87                } else {
88                        $HeightCSS = $Height . 'px';
89                }
90                $Html .= "<textarea name=\"$InstanceName\" rows=\"4\" cols=\"40\" style=\"width: $WidthCSS; height: $HeightCSS\">$HtmlValue</textarea>";
91        }
92        $Html .= '</div>';
93        return($Html);
94}
95
96sub IsCompatible
97{
98
99        $sAgent = $ENV{'HTTP_USER_AGENT'};
100        if(($sAgent =~ /MSIE/i) && !($sAgent =~ /mac/i) && !($sAgent =~ /Opera/i)) {
101                $iVersion = substr($sAgent,index($sAgent,'MSIE') + 5,3);
102                return($iVersion >= 5.5) ;
103        } elsif($sAgent =~ /Gecko\//i) {
104                $iVersion = substr($sAgent,index($sAgent,'Gecko/') + 6,8);
105                return($iVersion >= 20030210) ;
106        } else {
107                return(0);              # 2.0 PR fix
108        }
109}
110
111sub GetConfigFieldString
112{
113        $sParams = '';
114        $bFirst = 0;
115        foreach $sKey (keys %Config) {
116                $sValue = $Config{$sKey};
117                if($bFirst == 1) {
118                        $sParams .= '&amp;';
119                } else {
120                        $bFirst = 1;
121                }
122                $k = &specialchar_cnv($sKey);
123                $v = &specialchar_cnv($sValue);
124                if($sValue eq "true") {
125                        $sParams .= "$k=true";
126                } elsif($sValue eq "false") {
127                        $sParams .= "$k=false";
128                } else {
129                        $sParams .= "$k=$v";
130                }
131        }
132        return($sParams);
133}
134
1351;
Note: See TracBrowser for help on using the repository browser.