~mortenoh/+junk/dhis2-detailed-import-export

« back to all changes in this revision

Viewing changes to dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/FCK/_samples/perl/sample03.cgi

  • Committer: larshelge at gmail
  • Date: 2009-03-03 16:46:36 UTC
  • Revision ID: larshelge@gmail.com-20090303164636-2sjlrquo7ib1gf7r
Initial check-in

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env perl
 
2
 
 
3
#####
 
4
#  FCKeditor - The text editor for Internet - http://www.fckeditor.net
 
5
#  Copyright (C) 2003-2007 Frederico Caldeira Knabben
 
6
#
 
7
#  == BEGIN LICENSE ==
 
8
#
 
9
#  Licensed under the terms of any of the following licenses at your
 
10
#  choice:
 
11
#
 
12
#   - GNU General Public License Version 2 or later (the "GPL")
 
13
#     http://www.gnu.org/licenses/gpl.html
 
14
#
 
15
#   - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
 
16
#     http://www.gnu.org/licenses/lgpl.html
 
17
#
 
18
#   - Mozilla Public License Version 1.1 or later (the "MPL")
 
19
#     http://www.mozilla.org/MPL/MPL-1.1.html
 
20
#
 
21
#  == END LICENSE ==
 
22
#
 
23
#  Sample page.
 
24
#####
 
25
 
 
26
## START: Hack for Windows (Not important to understand the editor code... Perl specific).
 
27
if(Windows_check()) {
 
28
        chdir(GetScriptPath($0));
 
29
}
 
30
 
 
31
sub Windows_check
 
32
{
 
33
        # IIS,PWS(NT/95)
 
34
        $www_server_os = $^O;
 
35
        # Win98 & NT(SP4)
 
36
        if($www_server_os eq "") { $www_server_os= $ENV{'OS'}; }
 
37
        # AnHTTPd/Omni/IIS
 
38
        if($ENV{'SERVER_SOFTWARE'} =~ /AnWeb|Omni|IIS\//i) { $www_server_os= 'win'; }
 
39
        # Win Apache
 
40
        if($ENV{'WINDIR'} ne "") { $www_server_os= 'win'; }
 
41
        if($www_server_os=~ /win/i) { return(1); }
 
42
        return(0);
 
43
}
 
44
 
 
45
sub GetScriptPath {
 
46
        local($path) = @_;
 
47
        if($path =~ /[\:\/\\]/) { $path =~ s/(.*?)[\/\\][^\/\\]+$/$1/; } else { $path = '.'; }
 
48
        $path;
 
49
}
 
50
## END: Hack for IIS
 
51
 
 
52
require '../../fckeditor.pl';
 
53
 
 
54
# When $ENV{'PATH_INFO'} cannot be used by perl.
 
55
# $DefRootPath = "/XXXXX/_samples/perl/sample03.cgi"; Please write in script.
 
56
 
 
57
my $DefServerPath = "";
 
58
my $ServerPath;
 
59
 
 
60
        $ServerPath = &GetServerPath();
 
61
 
 
62
        if($ENV{'REQUEST_METHOD'} eq "POST") {
 
63
                read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
 
64
        } else {
 
65
                $buffer = $ENV{'QUERY_STRING'};
 
66
        }
 
67
        @pairs = split(/&/,$buffer);
 
68
        foreach $pair (@pairs) {
 
69
                ($name,$value) = split(/=/,$pair);
 
70
                $value =~ tr/+/ /;
 
71
                $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
 
72
                $value =~ s/\t//g;
 
73
                $value =~ s/\r\n/\n/g;
 
74
                $FORM{$name} .= "\0"                    if(defined($FORM{$name}));
 
75
                $FORM{$name} .= $value;
 
76
        }
 
77
 
 
78
        print "Content-type: text/html\n\n";
 
79
        print <<"_HTML_TAG_";
 
80
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
 
81
<html>
 
82
        <head>
 
83
                <title>FCKeditor - Sample</title>
 
84
                <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 
85
                <meta name="robots" content="noindex, nofollow">
 
86
                <link href="../sample.css" rel="stylesheet" type="text/css" />
 
87
                <script type="text/javascript">
 
88
 
 
89
function FCKeditor_OnComplete( editorInstance )
 
90
{
 
91
        var oCombo = document.getElementById( 'cmbToolbars' ) ;
 
92
        oCombo.value = editorInstance.ToolbarSet.Name ;
 
93
        oCombo.style.visibility = '' ;
 
94
}
 
95
 
 
96
function ChangeToolbar( toolbarName )
 
97
{
 
98
        window.location.href = window.location.pathname + "?Toolbar=" + toolbarName ;
 
99
}
 
100
 
 
101
                </script>
 
102
        </head>
 
103
        <body>
 
104
                <h1>FCKeditor - Perl - Sample 3</h1>
 
105
                This sample shows how to change the editor toolbar.
 
106
                <hr>
 
107
                <table cellpadding="0" cellspacing="0" border="0">
 
108
                        <tr>
 
109
                                <td>
 
110
                                        Select the toolbar to load:&nbsp;
 
111
                                </td>
 
112
                                <td>
 
113
                                        <select id="cmbToolbars" onchange="ChangeToolbar(this.value);" style="VISIBILITY: hidden">
 
114
                                                <option value="Default" selected>Default</option>
 
115
                                                <option value="Basic">Basic</option>
 
116
                                        </select>
 
117
                                </td>
 
118
                        </tr>
 
119
                </table>
 
120
                <br>
 
121
                <form action="sampleposteddata.cgi" method="post" target="_blank">
 
122
_HTML_TAG_
 
123
 
 
124
        #// Automatically calculates the editor base path based on the _samples directory.
 
125
        #// This is usefull only for these samples. A real application should use something like this:
 
126
        #// $oFCKeditor->BasePath = '/fckeditor/' ;     // '/fckeditor/' is the default value.
 
127
 
 
128
        $sBasePath = $ServerPath;
 
129
        $sBasePath = substr($sBasePath, 0, index( $sBasePath, "_samples" ));
 
130
 
 
131
        &FCKeditor('FCKeditor1') ;
 
132
        $BasePath = $sBasePath ;
 
133
 
 
134
        if($FORM{'Toolbar'} ne "") {
 
135
                $ToolbarSet = &specialchar_cnv( $FORM{'Toolbar'} );
 
136
        }
 
137
        $Value = 'This is some <strong>sample text</strong>. You are using <a href="http://www.fckeditor.net/">FCKeditor</a>.' ;
 
138
        &Create();
 
139
 
 
140
        print <<"_HTML_TAG_";
 
141
                        <br>
 
142
                        <input type="submit" value="Submit">
 
143
                </form>
 
144
        </body>
 
145
</html>
 
146
_HTML_TAG_
 
147
 
 
148
################
 
149
#Please use this function, rewriting it depending on a server's environment.
 
150
################
 
151
sub GetServerPath
 
152
{
 
153
my $dir;
 
154
 
 
155
        if($DefServerPath) {
 
156
                $dir = $DefServerPath;
 
157
        } else {
 
158
                if($ENV{'PATH_INFO'}) {
 
159
                        $dir  = $ENV{'PATH_INFO'};
 
160
                } elsif($ENV{'FILEPATH_INFO'}) {
 
161
                        $dir  = $ENV{'FILEPATH_INFO'};
 
162
                }
 
163
        }
 
164
        return($dir);
 
165
}