4
# FCKeditor - The text editor for internet
5
# Copyright (C) 2003-2005 Frederico Caldeira Knabben
7
# Licensed under the terms of the GNU Lesser General Public License:
8
# http://www.opensource.org/licenses/lgpl-license.php
10
# For further information visit:
11
# http://www.fckeditor.net/
13
# "Support Open Source software. What about a donation today?"
15
# File Name: sample04.cgi
19
# Takashi Yamaguchi (jack@omakase.net)
22
## START: Hack for Windows (Not important to understand the editor code... Perl specific).
24
chdir(GetScriptPath($0));
32
if($www_server_os eq "") { $www_server_os= $ENV{'OS'}; }
34
if($ENV{'SERVER_SOFTWARE'} =~ /AnWeb|Omni|IIS\//i) { $www_server_os= 'win'; }
36
if($ENV{'WINDIR'} ne "") { $www_server_os= 'win'; }
37
if($www_server_os=~ /win/i) { return(1); }
43
if($path =~ /[\:\/\\]/) { $path =~ s/(.*?)[\/\\][^\/\\]+$/$1/; } else { $path = '.'; }
48
require '../../fckeditor.pl';
50
# When $ENV{'PATH_INFO'} cannot be used by perl.
51
# $DefRootPath = "/XXXXX/_samples/perl/sample04.cgi"; Please write in script.
53
my $DefServerPath = "";
56
$ServerPath = &GetServerPath();
58
if($ENV{'REQUEST_METHOD'} eq "POST") {
59
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
61
$buffer = $ENV{'QUERY_STRING'};
63
@pairs = split(/&/,$buffer);
64
foreach $pair (@pairs) {
65
($name,$value) = split(/=/,$pair);
67
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
69
$value =~ s/\r\n/\n/g;
70
$FORM{$name} .= "\0" if(defined($FORM{$name}));
71
$FORM{$name} .= $value;
74
#!!Caution javascript \ Quart
76
print "Content-type: text/html\n\n";
78
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
81
<title>FCKeditor - Sample</title>
82
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
83
<meta name="robots" content="noindex, nofollow">
84
<link href="../sample.css" rel="stylesheet" type="text/css" />
85
<script type="text/javascript">
87
function FCKeditor_OnComplete( editorInstance )
89
var oCombo = document.getElementById( 'cmbSkins' ) ;
91
// Get the active skin.
92
var sSkin = editorInstance.Config['SkinPath'] ;
93
sSkin = sSkin.match(/[^\\/]+(?=\\/\$)/g) ;
95
oCombo.value = sSkin ;
96
oCombo.style.visibility = '' ;
99
function ChangeSkin( skinName )
101
window.location.href = window.location.pathname + "?Skin=" + skinName ;
107
<h1>FCKeditor - Perl - Sample 4</h1>
108
This sample shows how to change the editor skin.
110
<table cellpadding="0" cellspacing="0" border="0">
113
Select the skin to load:
116
<select id="cmbSkins" onchange="ChangeSkin(this.value);" style="VISIBILITY: hidden">
117
<option value="default" selected>Default</option>
118
<option value="office2003">Office 2003</option>
119
<option value="silver">Silver</option>
125
<form action="sampleposteddata.cgi" method="post" target="_blank">
128
#// Automatically calculates the editor base path based on the _samples directory.
129
#// This is usefull only for these samples. A real application should use something like this:
130
#// $oFCKeditor->BasePath = '/FCKeditor/' ; // '/FCKeditor/' is the default value.
131
$sBasePath = $ServerPath;
132
$sBasePath = substr( $sBasePath, 0, index( $sBasePath, "_samples" ) ) ;
134
&FCKeditor('FCKeditor1');
135
$BasePath = $sBasePath;
137
if($FORM{'Skin'} ne "") {
138
$Config{'SkinPath'} = $sBasePath . 'editor/skins/' . $FORM{'Skin'} . '/' ;
140
$Value = 'This is some <strong>sample text</strong>. You are using <a href="http://www.fckeditor.net/">FCKeditor</a>.' ;
143
print <<"_HTML_TAG_";
145
<input type="submit" value="Submit">
152
#Please use this function, rewriting it depending on a server's environment.
159
$dir = $DefServerPath;
161
if($ENV{'PATH_INFO'}) {
162
$dir = $ENV{'PATH_INFO'};
163
} elsif($ENV{'FILEPATH_INFO'}) {
164
$dir = $ENV{'FILEPATH_INFO'};