[ Index ] |
|
Code source de FCKeditor 2.4 |
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 # File Name: sample04.cgi 24 # Sample page. 25 # 26 # File Authors: 27 # Takashi Yamaguchi (jack@omakase.net) 28 ##### 29 30 ## START: Hack for Windows (Not important to understand the editor code... Perl specific). 31 if(Windows_check()) { 32 chdir(GetScriptPath($0)); 33 } 34 35 sub Windows_check 36 { 37 # IIS,PWS(NT/95) 38 $www_server_os = $^O; 39 # Win98 & NT(SP4) 40 if($www_server_os eq "") { $www_server_os= $ENV{'OS'}; } 41 # AnHTTPd/Omni/IIS 42 if($ENV{'SERVER_SOFTWARE'} =~ /AnWeb|Omni|IIS\//i) { $www_server_os= 'win'; } 43 # Win Apache 44 if($ENV{'WINDIR'} ne "") { $www_server_os= 'win'; } 45 if($www_server_os=~ /win/i) { return(1); } 46 return(0); 47 } 48 49 sub GetScriptPath { 50 local($path) = @_; 51 if($path =~ /[\:\/\\]/) { $path =~ s/(.*?)[\/\\][^\/\\]+$/$1/; } else { $path = '.'; } 52 $path; 53 } 54 ## END: Hack for IIS 55 56 require '../../fckeditor.pl'; 57 58 # When $ENV{'PATH_INFO'} cannot be used by perl. 59 # $DefRootPath = "/XXXXX/_samples/perl/sample04.cgi"; Please write in script. 60 61 my $DefServerPath = ""; 62 my $ServerPath; 63 64 $ServerPath = &GetServerPath(); 65 66 if($ENV{'REQUEST_METHOD'} eq "POST") { 67 read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); 68 } else { 69 $buffer = $ENV{'QUERY_STRING'}; 70 } 71 @pairs = split(/&/,$buffer); 72 foreach $pair (@pairs) { 73 ($name,$value) = split(/=/,$pair); 74 $value =~ tr/+/ /; 75 $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; 76 $value =~ s/\t//g; 77 $value =~ s/\r\n/\n/g; 78 $FORM{$name} .= "\0" if(defined($FORM{$name})); 79 $FORM{$name} .= $value; 80 } 81 82 #!!Caution javascript \ Quart 83 84 print "Content-type: text/html\n\n"; 85 print <<"_HTML_TAG_"; 86 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 87 <html> 88 <head> 89 <title>FCKeditor - Sample</title> 90 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 91 <meta name="robots" content="noindex, nofollow"> 92 <link href="../sample.css" rel="stylesheet" type="text/css" /> 93 <script type="text/javascript"> 94 95 function FCKeditor_OnComplete( editorInstance ) 96 { 97 var oCombo = document.getElementById( 'cmbSkins' ) ; 98 99 // Get the active skin. 100 var sSkin = editorInstance.Config['SkinPath'] ; 101 sSkin = sSkin.match(/[^\\/]+(?=\\/\$)/g) ; 102 103 oCombo.value = sSkin ; 104 oCombo.style.visibility = '' ; 105 } 106 107 function ChangeSkin( skinName ) 108 { 109 window.location.href = window.location.pathname + "?Skin=" + skinName ; 110 } 111 112 </script> 113 </head> 114 <body> 115 <h1>FCKeditor - Perl - Sample 4</h1> 116 This sample shows how to change the editor skin. 117 <hr> 118 <table cellpadding="0" cellspacing="0" border="0"> 119 <tr> 120 <td> 121 Select the skin to load: 122 </td> 123 <td> 124 <select id="cmbSkins" onchange="ChangeSkin(this.value);" style="VISIBILITY: hidden"> 125 <option value="default" selected>Default</option> 126 <option value="office2003">Office 2003</option> 127 <option value="silver">Silver</option> 128 </select> 129 </td> 130 </tr> 131 </table> 132 <br> 133 <form action="sampleposteddata.cgi" method="post" target="_blank"> 134 _HTML_TAG_ 135 136 #// Automatically calculates the editor base path based on the _samples directory. 137 #// This is usefull only for these samples. A real application should use something like this: 138 #// $oFCKeditor->BasePath = '/fckeditor/' ; // '/fckeditor/' is the default value. 139 $sBasePath = $ServerPath; 140 $sBasePath = substr( $sBasePath, 0, index( $sBasePath, "_samples" ) ) ; 141 142 &FCKeditor('FCKeditor1'); 143 $BasePath = $sBasePath; 144 145 if($FORM{'Skin'} ne "") { 146 $Config{'SkinPath'} = $sBasePath . 'editor/skins/' . &specialchar_cnv( $FORM{'Skin'} ) . '/' ; 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 ################ 162 sub GetServerPath 163 { 164 my $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 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 15:28:05 2007 | par Balluche grâce à PHPXref 0.7 |