PEEL Shopping
Open source ecommerce : PEEL Shopping
fckeditor_php4.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 4.
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 {
91  var $BasePath ;
98  var $Width ;
105  var $Height ;
117  var $Value ;
125  var $Config ;
126 
133  function FCKeditor( $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  function Create()
150  {
151  echo $this->CreateHtml() ;
152  }
153 
159  function CreateHtml()
160  {
161  $HtmlValue = htmlspecialchars( $this->Value ) ;
162 
163  $Html = '' ;
164 
165  if ( !isset( $_GET ) ) {
166  global $HTTP_GET_VARS ;
167  $_GET = $HTTP_GET_VARS ;
168  }
169 
170  if ( $this->IsCompatible() )
171  {
172  if ( isset( $_GET['fcksource'] ) && $_GET['fcksource'] == "true" )
173  $File = 'fckeditor.original.html' ;
174  else
175  $File = 'fckeditor.html' ;
176 
177  $Link = "{$this->BasePath}editor/{$File}?InstanceName={$this->InstanceName}" ;
178 
179  if ( $this->ToolbarSet != '' )
180  $Link .= "&amp;Toolbar={$this->ToolbarSet}" ;
181 
182  // Render the linked hidden field.
183  $Html .= "<input type=\"hidden\" id=\"{$this->InstanceName}\" name=\"{$this->InstanceName}\" value=\"{$HtmlValue}\" style=\"display:none\" />" ;
184 
185  // Render the configurations hidden field.
186  $Html .= "<input type=\"hidden\" id=\"{$this->InstanceName}___Config\" value=\"" . $this->GetConfigFieldString() . "\" style=\"display:none\" />" ;
187 
188  // Render the editor IFRAME.
189  $Html .= "<iframe id=\"{$this->InstanceName}___Frame\" src=\"{$Link}\" width=\"{$this->Width}\" height=\"{$this->Height}\" frameborder=\"0\" scrolling=\"no\"></iframe>" ;
190  }
191  else
192  {
193  if ( strpos( $this->Width, '%' ) === false )
194  $WidthCSS = $this->Width . 'px' ;
195  else
196  $WidthCSS = $this->Width ;
197 
198  if ( strpos( $this->Height, '%' ) === false )
199  $HeightCSS = $this->Height . 'px' ;
200  else
201  $HeightCSS = $this->Height ;
202 
203  $Html .= "<textarea name=\"{$this->InstanceName}\" rows=\"4\" cols=\"40\" style=\"width: {$WidthCSS}; height: {$HeightCSS}\">{$HtmlValue}</textarea>" ;
204  }
205 
206  return $Html ;
207  }
208 
214  function IsCompatible()
215  {
217  }
218 
226  {
227  $sParams = '' ;
228  $bFirst = true ;
229 
230  foreach ( $this->Config as $sKey => $sValue )
231  {
232  if ( $bFirst == false )
233  $sParams .= '&amp;' ;
234  else
235  $bFirst = false ;
236 
237  if ( $sValue === true )
238  $sParams .= $this->EncodeConfig( $sKey ) . '=true' ;
239  else if ( $sValue === false )
240  $sParams .= $this->EncodeConfig( $sKey ) . '=false' ;
241  else
242  $sParams .= $this->EncodeConfig( $sKey ) . '=' . $this->EncodeConfig( $sValue ) ;
243  }
244 
245  return $sParams ;
246  }
247 
256  function EncodeConfig( $valueToEncode )
257  {
258  $chars = array(
259  '&' => '%26',
260  '=' => '%3D',
261  '"' => '%22' ) ;
262 
263  return strtr( $valueToEncode, $chars ) ;
264  }
265 }
EncodeConfig($valueToEncode)
Encode characters that may break the configuration string generated by GetConfigFieldString().
FCKeditor_IsCompatibleBrowser()
Check if browser is compatible with FCKeditor.
GetConfigFieldString()
Get settings from Config array as a single string.
IsCompatible()
Returns true if browser is compatible with FCKeditor.
FCKeditor($instanceName)
Main Constructor.
Create()
Display FCKeditor.
CreateHtml()
Return the HTML code required to run FCKeditor.

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.