Opened 18 years ago
Closed 12 years ago
#232 closed New Feature (wontfix)
New code for PHP classe of FCKeditor
Reported by: | Joly, Alexandre | Owned by: | |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | Server : PHP | Version: | FCKeditor 2.4 |
Keywords: | HasPatch | Cc: |
Description
Hello,
This ticket is here, for propose a new version of classe for PHP 5.x. This new classe using singleton, less ressource asked, and an implementation more easy in our script file.
We can to speak about it with that ticket and check how to ameliorate it.
The new code :
<?php /* * FCKeditor - The text editor for internet * Copyright (C) 2003-2006 Frederico Caldeira Knabben * * Licensed under the terms of the GNU Lesser General Public License: * http://www.opensource.org/licenses/lgpl-license.php * * For further information visit: * http://www.fckeditor.net/ * * "Support Open Source software. What about a donation today?" * * File Name: fckeditor.php * This is the integration file for PHP. * * It defines the FCKeditor class that can be used to create editor * instances in PHP pages on server side. * * File Authors: * Frederico Caldeira Knabben (fredck@fckeditor.net) * Modification Authors : * Alexandre Joly (webmaster@game-anime.com) * Modification description : Using Singleton * For PHP > 5.x */ class FCKeditor { private static $Config ; private function __construct(){} static function CreateHtml($InstanceName, $BasePath='/fckeditor/', $ToolbarSet = 'Default', $Value = '', $Width = '100%', $Height = '200') { self::$Config = array(); $HtmlValue = htmlspecialchars( $Value ) ; $Html = '<div>' ; if ( self::IsCompatible() ) { if ( isset( $_GET['fcksource'] ) && $_GET['fcksource'] == "true" ) $File = 'fckeditor.original.html' ; else $File = 'fckeditor.html' ; $Link = $BasePath.'editor/'.$File.'?InstanceName='.$InstanceName; if ( $ToolbarSet != '' ) $Link .= '&Toolbar='.$ToolbarSet; /* * First field : Render the linked hidden field. * Seconde field : Render the configurations hidden field. * Third field : Render the editor IFRAME. */ $Html .= '<input type="hidden" id="'.$InstanceName.'" name="'.$InstanceName.'" value="'.$HtmlValue.'" style="display:none" /> <input type="hidden" id="'.$InstanceName.'___Config" value="" '.self::GetConfigFieldString().' style="display:none" /> <iframe id="'.$InstanceName.'___Frame" src="'.$Link.'" width="'.$Width.'" height="'.$Height.'" frameborder="0" scrolling="no"></iframe>'; } else { if ( strpos( $Width, '%' ) === false ) $WidthCSS = $Width . 'px' ; else $WidthCSS = $Width ; if ( strpos( $Height, '%' ) === false ) $HeightCSS = $Height . 'px' ; else $HeightCSS = $Height ; $Html .= '<textarea name="'.$InstanceName.'" rows="4" cols="40" style="width: '.$WidthCSS.'; height: '.$HeightCSS.';">'.$HtmlValue.'</textarea>'; } $Html .= '</div>' ; return $Html ; } private static function IsCompatible() { $sAgent = $_SERVER['HTTP_USER_AGENT'] ; if ( strpos($sAgent, 'MSIE') !== false && strpos($sAgent, 'mac') === false && strpos($sAgent, 'Opera') === false ) { $iVersion = (float)substr($sAgent, strpos($sAgent, 'MSIE') + 5, 3) ; return ($iVersion >= 5.5) ; } else if ( strpos($sAgent, 'Gecko/') !== false ) { $iVersion = (int)substr($sAgent, strpos($sAgent, 'Gecko/') + 6, 8) ; return ($iVersion >= 20030210) ; } else return false ; } private static function GetConfigFieldString() { $sParams = '' ; $bFirst = true ; foreach ( self::$Config as $sKey => $sValue ) { if ( $bFirst == false ) $sParams .= '&' ; else $bFirst = false ; if ( $sValue === true ) $sParams .= self::EncodeConfig( $sKey ) . '=true' ; else if ( $sValue === false ) $sParams .= self::EncodeConfig( $sKey ) . '=false' ; else $sParams .= self::EncodeConfig( $sKey ) . '=' . self::EncodeConfig( $sValue ) ; } return $sParams ; } private static function EncodeConfig( $valueToEncode ) { $chars = array( '&' => '%26', '=' => '%3D', '"' => '%22' ) ; return strtr( $valueToEncode, $chars ) ; } } ?>
Change History (5)
comment:1 Changed 18 years ago by
Keywords: | Classe SIngleton PHP 5 removed |
---|
comment:2 Changed 17 years ago by
comment:3 Changed 17 years ago by
Owner: | Frederico Caldeira Knabben deleted |
---|
comment:4 Changed 17 years ago by
Keywords: | Confirmed HasPatch added |
---|
comment:5 Changed 12 years ago by
Resolution: | → wontfix |
---|---|
Status: | confirmed → closed |
FCKeditor was retired and is no longer supported. All active development was moved to its successor, CKEditor 3.x, that is a fully mature and far superior product. We recommend you upgrade as soon as possible.
Another proposed version was in https://sourceforge.net/tracker/index.php?func=detail&aid=1109049&group_id=75348&atid=543655
Introduced visibility specifiers (private, public) for member variables and methods.
Fixed XHTML validity (slash at the end of input tag).
Code style (indenting, one-true brackets etc.) adjusted to PEAR coding standards, as well as naming of variables and methods (first char in lowercase).