source: companies/celepar/news_admin/templates/celepar/fckeditor/to_delete/_samples/perl/sample02.cgi @ 763

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

Importação inicial do Expresso da Celepar

Line 
1#!/usr/bin/env perl
2
3#####
4#  FCKeditor - The text editor for internet
5#  Copyright (C) 2003-2006 Frederico Caldeira Knabben
6
7#  Licensed under the terms of the GNU Lesser General Public License:
8#               http://www.opensource.org/licenses/lgpl-license.php
9
10#  For further information visit:
11#               http://www.fckeditor.net/
12
13#  "Support Open Source software. What about a donation today?"
14
15#  File Name: sample02.cgi
16#       Sample page.
17
18#  File Authors:
19#               Takashi Yamaguchi (jack@omakase.net)
20#####
21
22## START: Hack for Windows (Not important to understand the editor code... Perl specific).
23if(Windows_check()) {
24        chdir(GetScriptPath($0));
25}
26
27sub Windows_check
28{
29        # IIS,PWS(NT/95)
30        $www_server_os = $^O;
31        # Win98 & NT(SP4)
32        if($www_server_os eq "") { $www_server_os= $ENV{'OS'}; }
33        # AnHTTPd/Omni/IIS
34        if($ENV{'SERVER_SOFTWARE'} =~ /AnWeb|Omni|IIS\//i) { $www_server_os= 'win'; }
35        # Win Apache
36        if($ENV{'WINDIR'} ne "") { $www_server_os= 'win'; }
37        if($www_server_os=~ /win/i) { return(1); }
38        return(0);
39}
40
41sub GetScriptPath {
42        local($path) = @_;
43        if($path =~ /[\:\/\\]/) { $path =~ s/(.*?)[\/\\][^\/\\]+$/$1/; } else { $path = '.'; }
44        $path;
45}
46## END: Hack for IIS
47
48require '../../fckeditor.pl';
49
50# When $ENV{'PATH_INFO'} cannot be used by perl.
51# $DefRootPath = "/XXXXX/_samples/perl/sample02.cgi"; Please write in script.
52
53my $DefServerPath = "";
54my $ServerPath;
55
56        $ServerPath = &GetServerPath();
57
58        if($ENV{'REQUEST_METHOD'} eq "POST") {
59                read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
60        } else {
61                $buffer = $ENV{'QUERY_STRING'};
62        }
63        @pairs = split(/&/,$buffer);
64        foreach $pair (@pairs) {
65                ($name,$value) = split(/=/,$pair);
66                $value =~ tr/+/ /;
67                $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
68                $value =~ s/\t//g;
69                $value =~ s/\r\n/\n/g;
70                $FORM{$name} .= "\0"                    if(defined($FORM{$name}));
71                $FORM{$name} .= $value;
72        }
73
74        print "Content-type: text/html\n\n";
75        print <<"_HTML_TAG_";
76<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
77<html>
78        <head>
79                <title>FCKeditor - Sample</title>
80                <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
81                <meta name="robots" content="noindex, nofollow">
82                <link href="../sample.css" rel="stylesheet" type="text/css" />
83                <script type="text/javascript">
84
85function FCKeditor_OnComplete( editorInstance )
86{
87        var oCombo = document.getElementById( 'cmbLanguages' ) ;
88        for ( code in editorInstance.Language.AvailableLanguages )
89        {
90                AddComboOption( oCombo, editorInstance.Language.AvailableLanguages[code] + ' (' + code + ')', code ) ;
91        }
92        oCombo.value = editorInstance.Language.ActiveLanguage.Code ;
93}       
94
95function AddComboOption(combo, optionText, optionValue)
96{
97        var oOption = document.createElement("OPTION") ;
98
99        combo.options.add(oOption) ;
100
101        oOption.innerHTML = optionText ;
102        oOption.value     = optionValue ;
103       
104        return oOption ;
105}
106
107function ChangeLanguage( languageCode )
108{
109        window.location.href = window.location.pathname + "?Lang=" + languageCode ;
110}
111                </script>
112        </head>
113        <body>
114                <h1>FCKeditor - Perl - Sample 2</h1>
115                This sample shows the editor in all its available languages.
116                <hr>
117                <table cellpadding="0" cellspacing="0" border="0">
118                        <tr>
119                                <td>
120                                        Select a language:&nbsp;
121                                </td>
122                                <td>
123                                        <select id="cmbLanguages" onchange="ChangeLanguage(this.value);">
124                                        </select>
125                                </td>
126                        </tr>
127                </table>
128                <br>
129                <form action="sampleposteddata.cgi" method="post" target="_blank">
130_HTML_TAG_
131
132        #// Automatically calculates the editor base path based on the _samples directory.
133        #// This is usefull only for these samples. A real application should use something like this:
134        #// $oFCKeditor->BasePath = '/fckeditor/' ;     // '/fckeditor/' is the default value.
135        $sBasePath = $ServerPath;
136        $sBasePath = substr( $sBasePath, 0, index($sBasePath,"_samples"));
137
138        &FCKeditor('FCKeditor1');
139        $BasePath = $sBasePath;
140
141        if($FORM{'Lang'} ne "") {
142                $Config{'AutoDetectLanguage'}   = "false";
143                $Config{'DefaultLanguage'}              = $FORM{'Lang'};
144        } else {
145                $Config{'AutoDetectLanguage'}   = "true";
146                $Config{'DefaultLanguage'}              = 'en' ;
147        }
148        $Value = 'This is some <strong>sample text</strong>. You are using <a href="http://www.fckeditor.net/">FCKeditor</a>.' ;
149        &Create();
150
151        print <<"_HTML_TAG_";
152                        <br>
153                        <input type="submit" value="Submit">
154                </form>
155        </body>
156</html>
157_HTML_TAG_
158
159################
160#Please use this function, rewriting it depending on a server's environment.
161################
162sub GetServerPath
163{
164my $dir;
165
166        if($DefServerPath) {
167                $dir = $DefServerPath;
168        } else {
169                if($ENV{'PATH_INFO'}) {
170                        $dir  = $ENV{'PATH_INFO'};
171                } elsif($ENV{'FILEPATH_INFO'}) {
172                        $dir  = $ENV{'FILEPATH_INFO'};
173                }
174        }
175        return($dir);
176}
Note: See TracBrowser for help on using the repository browser.