source: sandbox/filemanager/tp/fckeditor/fckeditor.pl @ 1575

Revision 1575, 3.4 KB checked in by amuller, 14 years ago (diff)

Ticket #597 - Implentação, melhorias do modulo gerenciador de arquivos

  • Property svn:executable set to *
Line 
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
32sub 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
44sub Create
45{
46        print &CreateHtml();
47}
48
49sub 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
62sub 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
99sub 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
119sub 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
1431;
Note: See TracBrowser for help on using the repository browser.