[ Index ] |
|
Code source de GeekLog 1.4.1 |
1 <?php 2 /* 3 * FCKeditor - The text editor for internet 4 * Copyright (C) 2003-2006 Frederico Caldeira Knabben 5 * 6 * Licensed under the terms of the GNU Lesser General Public License: 7 * http://www.opensource.org/licenses/lgpl-license.php 8 * 9 * For further information visit: 10 * http://www.fckeditor.net/ 11 * 12 * "Support Open Source software. What about a donation today?" 13 * 14 * File Name: fckeditor.php 15 * This is the integration file for PHP. 16 * 17 * It defines the FCKeditor class that can be used to create editor 18 * instances in PHP pages on server side. 19 * 20 * File Authors: 21 * Frederico Caldeira Knabben (fredck@fckeditor.net) 22 */ 23 24 class FCKeditor 25 { 26 var $InstanceName ; 27 var $BasePath ; 28 var $Width ; 29 var $Height ; 30 var $ToolbarSet ; 31 var $Value ; 32 var $Config ; 33 34 // PHP 5 Constructor (by Marcus Bointon <coolbru@users.sourceforge.net>) 35 function __construct( $instanceName ) 36 { 37 $this->InstanceName = $instanceName ; 38 $this->BasePath = '/fckeditor/' ; 39 $this->Width = '100%' ; 40 $this->Height = '200' ; 41 $this->ToolbarSet = 'Default' ; 42 $this->Value = '' ; 43 44 $this->Config = array() ; 45 } 46 47 // PHP 4 Contructor 48 function FCKeditor( $instanceName ) 49 { 50 $this->__construct( $instanceName ) ; 51 } 52 53 function Create() 54 { 55 echo $this->CreateHtml() ; 56 } 57 58 function CreateHtml() 59 { 60 $HtmlValue = htmlspecialchars( $this->Value ) ; 61 62 $Html = '<div>' ; 63 64 if ( $this->IsCompatible() ) 65 { 66 if ( isset( $_GET['fcksource'] ) && $_GET['fcksource'] == "true" ) 67 $File = 'fckeditor.original.html' ; 68 else 69 $File = 'fckeditor.html' ; 70 71 $Link = "{$this->BasePath}editor/{$File}?InstanceName={$this->InstanceName}" ; 72 73 if ( $this->ToolbarSet != '' ) 74 $Link .= "&Toolbar={$this->ToolbarSet}" ; 75 76 // Render the linked hidden field. 77 $Html .= "<input type=\"hidden\" id=\"{$this->InstanceName}\" name=\"{$this->InstanceName}\" value=\"{$HtmlValue}\" style=\"display:none\" />" ; 78 79 // Render the configurations hidden field. 80 $Html .= "<input type=\"hidden\" id=\"{$this->InstanceName}___Config\" value=\"" . $this->GetConfigFieldString() . "\" style=\"display:none\" />" ; 81 82 // Render the editor IFRAME. 83 $Html .= "<iframe id=\"{$this->InstanceName}___Frame\" src=\"{$Link}\" width=\"{$this->Width}\" height=\"{$this->Height}\" frameborder=\"0\" scrolling=\"no\"></iframe>" ; 84 } 85 else 86 { 87 if ( strpos( $this->Width, '%' ) === false ) 88 $WidthCSS = $this->Width . 'px' ; 89 else 90 $WidthCSS = $this->Width ; 91 92 if ( strpos( $this->Height, '%' ) === false ) 93 $HeightCSS = $this->Height . 'px' ; 94 else 95 $HeightCSS = $this->Height ; 96 97 $Html .= "<textarea name=\"{$this->InstanceName}\" rows=\"4\" cols=\"40\" style=\"width: {$WidthCSS}; height: {$HeightCSS}\">{$HtmlValue}</textarea>" ; 98 } 99 100 $Html .= '</div>' ; 101 102 return $Html ; 103 } 104 105 function IsCompatible() 106 { 107 global $HTTP_USER_AGENT ; 108 109 if ( isset( $HTTP_USER_AGENT ) ) 110 $sAgent = $HTTP_USER_AGENT ; 111 else 112 $sAgent = $_SERVER['HTTP_USER_AGENT'] ; 113 114 if ( strpos($sAgent, 'MSIE') !== false && strpos($sAgent, 'mac') === false && strpos($sAgent, 'Opera') === false ) 115 { 116 $iVersion = (float)substr($sAgent, strpos($sAgent, 'MSIE') + 5, 3) ; 117 return ($iVersion >= 5.5) ; 118 } 119 else if ( strpos($sAgent, 'Gecko/') !== false ) 120 { 121 $iVersion = (int)substr($sAgent, strpos($sAgent, 'Gecko/') + 6, 8) ; 122 return ($iVersion >= 20030210) ; 123 } 124 else 125 return false ; 126 } 127 128 function GetConfigFieldString() 129 { 130 $sParams = '' ; 131 $bFirst = true ; 132 133 foreach ( $this->Config as $sKey => $sValue ) 134 { 135 if ( $bFirst == false ) 136 $sParams .= '&' ; 137 else 138 $bFirst = false ; 139 140 if ( $sValue === true ) 141 $sParams .= $this->EncodeConfig( $sKey ) . '=true' ; 142 else if ( $sValue === false ) 143 $sParams .= $this->EncodeConfig( $sKey ) . '=false' ; 144 else 145 $sParams .= $this->EncodeConfig( $sKey ) . '=' . $this->EncodeConfig( $sValue ) ; 146 } 147 148 return $sParams ; 149 } 150 151 function EncodeConfig( $valueToEncode ) 152 { 153 $chars = array( 154 '&' => '%26', 155 '=' => '%3D', 156 '"' => '%22' ) ; 157 158 return strtr( $valueToEncode, $chars ) ; 159 } 160 } 161 162 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Wed Nov 21 12:27:40 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |