PEEL Shopping
Open source ecommerce : PEEL Shopping
fckeditor_php5.php
Go to the documentation of this file.
1 <?php
2 /*
3  * FCKeditor - The text editor for Internet - http://www.fckeditor.net
4  * Copyright (C) 2003-2010 Frederico Caldeira Knabben
5  *
6  * == BEGIN LICENSE ==
7  *
8  * Licensed under the terms of any of the following licenses at your
9  * choice:
10  *
11  * - GNU General Public License Version 2 or later (the "GPL")
12  * http://www.gnu.org/licenses/gpl.html
13  *
14  * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
15  * http://www.gnu.org/licenses/lgpl.html
16  *
17  * - Mozilla Public License Version 1.1 or later (the "MPL")
18  * http://www.mozilla.org/MPL/MPL-1.1.html
19  *
20  * == END LICENSE ==
21  *
22  * This is the integration file for PHP 5.
23  *
24  * It defines the FCKeditor class that can be used to create editor
25  * instances in PHP pages on server side.
26  */
27 
35 {
36  if ( isset( $_SERVER ) ) {
37  $sAgent = $_SERVER['HTTP_USER_AGENT'] ;
38  }
39  else {
40  global $HTTP_SERVER_VARS ;
41  if ( isset( $HTTP_SERVER_VARS ) ) {
42  $sAgent = $HTTP_SERVER_VARS['HTTP_USER_AGENT'] ;
43  }
44  else {
45  global $HTTP_USER_AGENT ;
46  $sAgent = $HTTP_USER_AGENT ;
47  }
48  }
49 
50  if ( strpos($sAgent, 'MSIE') !== false && strpos($sAgent, 'mac') === false && strpos($sAgent, 'Opera') === false )
51  {
52  $iVersion = (float)substr($sAgent, strpos($sAgent, 'MSIE') + 5, 3) ;
53  return ($iVersion >= 5.5) ;
54  }
55  else if ( strpos($sAgent, 'Gecko/') !== false )
56  {
57  // Firefox 17+
58  if (preg_match("|Gecko/\d+\.\d+|", $sAgent))
59  return true;
60  $iVersion = (int)substr($sAgent, strpos($sAgent, 'Gecko/') + 6, 8) ;
61  return ($iVersion >= 20030210) ;
62  }
63  else if ( strpos($sAgent, 'Opera/') !== false )
64  {
65  $fVersion = (float)substr($sAgent, strpos($sAgent, 'Opera/') + 6, 4) ;
66  return ($fVersion >= 9.5) ;
67  }
68  else if ( preg_match( "|AppleWebKit/(\d+)|i", $sAgent, $matches ) )
69  {
70  $iVersion = $matches[1] ;
71  return ( $matches[1] >= 522 ) ;
72  }
73  else
74  return false ;
75 }
76 
77 class FCKeditor
78 {
85  public $InstanceName ;
91  public $BasePath ;
98  public $Width ;
105  public $Height ;
111  public $ToolbarSet ;
117  public $Value ;
125  public $Config ;
126 
133  public function __construct( $instanceName )
134  {
135  $this->InstanceName = $instanceName ;
136  $this->BasePath = '/fckeditor/' ;
137  $this->Width = '100%' ;
138  $this->Height = '200' ;
139  $this->ToolbarSet = 'Default' ;
140  $this->Value = '' ;
141 
142  $this->Config = array() ;
143  }
144 
149  public function Create()
150  {
151  echo $this->CreateHtml() ;
152  }
153 
159  public function CreateHtml()
160  {
161  $HtmlValue = htmlspecialchars( $this->Value ) ;
162 
163  $Html = '' ;
164 
165  if ( $this->IsCompatible() )
166  {
167  if ( isset( $_GET['fcksource'] ) && $_GET['fcksource'] == "true" )
168  $File = 'fckeditor.original.html' ;
169  else
170  $File = 'fckeditor.html' ;
171 
172  $Link = "{$this->BasePath}editor/{$File}?InstanceName={$this->InstanceName}" ;
173 
174  if ( $this->ToolbarSet != '' )
175  $Link .= "&amp;Toolbar={$this->ToolbarSet}" ;
176 
177  // Render the linked hidden field.
178  $Html .= "<input type=\"hidden\" id=\"{$this->InstanceName}\" name=\"{$this->InstanceName}\" value=\"{$HtmlValue}\" style=\"display:none\" />" ;
179 
180  // Render the configurations hidden field.
181  $Html .= "<input type=\"hidden\" id=\"{$this->InstanceName}___Config\" value=\"" . $this->GetConfigFieldString() . "\" style=\"display:none\" />" ;
182 
183  // Render the editor IFRAME.
184  $Html .= "<iframe id=\"{$this->InstanceName}___Frame\" src=\"{$Link}\" width=\"{$this->Width}\" height=\"{$this->Height}\" frameborder=\"0\" scrolling=\"no\"></iframe>" ;
185  }
186  else
187  {
188  if ( strpos( $this->Width, '%' ) === false )
189  $WidthCSS = $this->Width . 'px' ;
190  else
191  $WidthCSS = $this->Width ;
192 
193  if ( strpos( $this->Height, '%' ) === false )
194  $HeightCSS = $this->Height . 'px' ;
195  else
196  $HeightCSS = $this->Height ;
197 
198  $Html .= "<textarea name=\"{$this->InstanceName}\" rows=\"4\" cols=\"40\" style=\"width: {$WidthCSS}; height: {$HeightCSS}\">{$HtmlValue}</textarea>" ;
199  }
200 
201  return $Html ;
202  }
203 
209  public function IsCompatible()
210  {
212  }
213 
220  public function GetConfigFieldString()
221  {
222  $sParams = '' ;
223  $bFirst = true ;
224 
225  foreach ( $this->Config as $sKey => $sValue )
226  {
227  if ( $bFirst == false )
228  $sParams .= '&amp;' ;
229  else
230  $bFirst = false ;
231 
232  if ( $sValue === true )
233  $sParams .= $this->EncodeConfig( $sKey ) . '=true' ;
234  else if ( $sValue === false )
235  $sParams .= $this->EncodeConfig( $sKey ) . '=false' ;
236  else
237  $sParams .= $this->EncodeConfig( $sKey ) . '=' . $this->EncodeConfig( $sValue ) ;
238  }
239 
240  return $sParams ;
241  }
242 
251  public function EncodeConfig( $valueToEncode )
252  {
253  $chars = array(
254  '&' => '%26',
255  '=' => '%3D',
256  '"' => '%22' ) ;
257 
258  return strtr( $valueToEncode, $chars ) ;
259  }
260 }
EncodeConfig($valueToEncode)
Encode characters that may break the configuration string generated by GetConfigFieldString().
GetConfigFieldString()
Get settings from Config array as a single string.
FCKeditor_IsCompatibleBrowser()
Check if browser is compatible with FCKeditor.
IsCompatible()
Returns true if browser is compatible with FCKeditor.
Create()
Display FCKeditor.
CreateHtml()
Return the HTML code required to run FCKeditor.
__construct($instanceName)
Main Constructor.

This documentation for Open ecommerce PEEL Shopping and PEEL.fr has been generated by Doxygen on Thu Oct 15 2015 14:30:08 - Peel ecommerce is a product of Agence web Advisto SAS. All rights reserved.