3
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
4
* Copyright (C) 2003-2007 Frederico Caldeira Knabben
8
* Licensed under the terms of any of the following licenses at your
11
* - GNU General Public License Version 2 or later (the "GPL")
12
* http://www.gnu.org/licenses/gpl.html
14
* - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
15
* http://www.gnu.org/licenses/lgpl.html
17
* - Mozilla Public License Version 1.1 or later (the "MPL")
18
* http://www.mozilla.org/MPL/MPL-1.1.html
22
* This is the integration file for PHP 5.
24
* It defines the FCKeditor class that can be used to create editor
25
* instances in PHP pages on server side.
38
// PHP 5 Constructor (by Marcus Bointon <coolbru@users.sourceforge.net>)
39
function __construct( $instanceName )
41
$this->InstanceName = $instanceName ;
42
$this->BasePath = '/fckeditor/' ;
43
$this->Width = '100%' ;
44
$this->Height = '200' ;
45
$this->ToolbarSet = 'Default' ;
48
$this->Config = array() ;
53
echo $this->CreateHtml() ;
58
$HtmlValue = htmlspecialchars( $this->Value ) ;
62
if ( $this->IsCompatible() )
64
if ( isset( $_GET['fcksource'] ) && $_GET['fcksource'] == "true" )
65
$File = 'fckeditor.original.html' ;
67
$File = 'fckeditor.html' ;
69
$Link = "{$this->BasePath}editor/{$File}?InstanceName={$this->InstanceName}" ;
71
if ( $this->ToolbarSet != '' )
72
$Link .= "&Toolbar={$this->ToolbarSet}" ;
74
// Render the linked hidden field.
75
$Html .= "<input type=\"hidden\" id=\"{$this->InstanceName}\" name=\"{$this->InstanceName}\" value=\"{$HtmlValue}\" style=\"display:none\" />" ;
77
// Render the configurations hidden field.
78
$Html .= "<input type=\"hidden\" id=\"{$this->InstanceName}___Config\" value=\"" . $this->GetConfigFieldString() . "\" style=\"display:none\" />" ;
80
// Render the editor IFRAME.
81
$Html .= "<iframe id=\"{$this->InstanceName}___Frame\" src=\"{$Link}\" width=\"{$this->Width}\" height=\"{$this->Height}\" frameborder=\"0\" scrolling=\"no\"></iframe>" ;
85
if ( strpos( $this->Width, '%' ) === false )
86
$WidthCSS = $this->Width . 'px' ;
88
$WidthCSS = $this->Width ;
90
if ( strpos( $this->Height, '%' ) === false )
91
$HeightCSS = $this->Height . 'px' ;
93
$HeightCSS = $this->Height ;
95
$Html .= "<textarea name=\"{$this->InstanceName}\" rows=\"4\" cols=\"40\" style=\"width: {$WidthCSS}; height: {$HeightCSS}\">{$HtmlValue}</textarea>" ;
103
function IsCompatible()
105
global $HTTP_USER_AGENT ;
107
if ( isset( $HTTP_USER_AGENT ) )
108
$sAgent = $HTTP_USER_AGENT ;
110
$sAgent = $_SERVER['HTTP_USER_AGENT'] ;
112
if ( strpos($sAgent, 'MSIE') !== false && strpos($sAgent, 'mac') === false && strpos($sAgent, 'Opera') === false )
114
$iVersion = (float)substr($sAgent, strpos($sAgent, 'MSIE') + 5, 3) ;
115
return ($iVersion >= 5.5) ;
117
else if ( strpos($sAgent, 'Gecko/') !== false )
119
$iVersion = (int)substr($sAgent, strpos($sAgent, 'Gecko/') + 6, 8) ;
120
return ($iVersion >= 20030210) ;
126
function GetConfigFieldString()
131
foreach ( $this->Config as $sKey => $sValue )
133
if ( $bFirst == false )
134
$sParams .= '&' ;
138
if ( $sValue === true )
139
$sParams .= $this->EncodeConfig( $sKey ) . '=true' ;
140
else if ( $sValue === false )
141
$sParams .= $this->EncodeConfig( $sKey ) . '=false' ;
143
$sParams .= $this->EncodeConfig( $sKey ) . '=' . $this->EncodeConfig( $sValue ) ;
149
function EncodeConfig( $valueToEncode )
156
return strtr( $valueToEncode, $chars ) ;
b'\\ No newline at end of file'