Script adapting: FCKeditor
From phpCMS
In the phpCMS support forum, Nick ("nick77") explained how to include the free WYSIWYG editor FCKeditor in phpCMS. The original version of this article is taken from this forum article.
The FCKEditor is obsolete and was replaced by the CKEditor. The installation instructions for the CKEditor can be found in Installation of the CKEditor.
Documentation for phpCMS 1.2.2 and FCKEditor 2.4.2
Contents |
[edit] History and Features of FCKeditor
Within a short time, FCKeditor evolved from a IE-only Editor to a mature, feature-rich, cross-browser (i.e. Mozilla and IE so far) and cross-platform solution - even big companies like Adobe or Oracle use the editor in their products.
The features are (from fckeditor.net):
- Internet Explorer 5.5+ and Gecko browser (Mozilla / Firefox / Netscape) compatibility
- XHTML 1.0 support
- Font formatting: type, size, color, style, bold, italic, etc
- Text formatting: alignment, indentation, bullets list, etc
- Cut, Paste and Paste as Plain Text, Undo and Redo
- Paste from Word cleanup with auto detection
- Link creation
- Anchors support
- Image insertion, with upload and server browsing support
- Table creation and editing (add, delete rows, etc) - one of the best systems in the market.
- Table cells editing (size, colors, etc)
- Form fields
- Right click context menus support
- Complete toolbar customization
- Skins support.
- Plugins support.
- Spell checker
- CSS support for better integration with your web site
- Multi-language support with automatic user language detection. Including Right to Left scripting.
To see a working demo have a look at the FCKeditor homepage or at the example integration with phpCMS I set up.
[edit] Prerequisites
- installed and working phpCMS 1.2.2
- online editing enabled in phpCMS GUI and editor password set in the project (.ini) file.
[edit] Installation
- download the FCKeditor package from: http://www.fckeditor.net/download/default.html
- unpack the archive and put its content into /parser/fckeditor (it is advisable to rename the folder FCKeditor to fckeditor so that you don't have to remember which letters are capital).
[edit] File Edits
[edit] Changes in FCKeditor files
You should now have the folder fckeditor in your parsers folder. Edit the following files:
[edit] /parser/fckeditor/editor/filemanager/browser/default/connectors/php/config.php
Adjust the following fields here:
$Config['Enabled'] = false ;
Replace false with true to enable the PHP-Connector
$Config['UserFilesPath'] = '/userfiles/' ;
You can set the folder where files can be uploaded the users. The path is relative to Document Root. (i.e. if you want the files to be in /parser/fckeditor/userfiles/ you would have to enter /parser/fckeditor/userfiles/). Depending on your php installation you might have to create this folder manually and set its permissions to 0666 (-rw-rw-rw). You have to add all allowed file extensions manually for security reasons.
$Config['AllowedExtensions']['File'] = array() ;
$Config['DeniedExtensions']['File'] = array('php','php3','php5'.....
Here you can add and remove allowed extensions for different file types. For example if you want the users to allow to upload PDFs, and ZIPs as Files you change the first line to:
$Config['AllowedExtensions']['File'] = array('pdf','zip') ;
[edit] /parser/fckeditor/fckconfig.js
Try adjusting the following fields if the default installation should turn out not to work
FCKConfig.BaseHref = '' ;
Put the URL of you domain here for example:
FCKConfig.BaseHref = 'http://www.domain.de' ;
On line 134,145 change "asp" to "php". The modified block looks like that:
var _FileBrowserLanguage = 'php' ; // asp | aspx | cfm | lasso | perl | php | py var _QuickUploadLanguage = 'php' ; // asp | aspx | cfm | lasso | php
It is recommended to use an externmal configuration file in order to ovveride the default settings in fckconfig.js. This way after an update of FCKEditor you only have to change the include line for the override file and not the whole fckconfig.js. The override file is set here:
FCKConfig.CustomConfigurationsPath = 'path/to/your/config.js' ;
[edit] Add necessary phpCMS file
You only need to add the 'class.edit_wysiwyg_phpcms.php' file (c.f. below), no changes are needed in any phpCMS - files anymore:
[edit] Create class.edit_wysiwyg_phpcms.php
This file does not exist yet so add it with the following content to /parser/include/class.edit_wysiwyg_phpcms.php:
<?php
if (!defined('FCKEDITOR_ROOT'))
{
define('FCKEDITOR_ROOT', $DEFAULTS->DOCUMENT_ROOT.$DEFAULTS->SCRIPT_PATH.'/fckeditor/');
include_once (FCKEDITOR_ROOT.'fckeditor.php');
}
$oFCKeditor = new FCKeditor($FIELD) ;
// $oFCKeditor->ToolbarSet = '' ; you can choose a toolbar set other than the default here
$oFCKeditor->BasePath = $DEFAULTS->SCRIPT_PATH.'/fckeditor/';
$oFCKeditor->Value = $buffer ;
$oFCKeditor->Create() ;
?>
Remember: no spaces or blanks after the closing "?>".
[edit] Adjust your phpCMS template files
You need to adjust your template files:
- make sure you provide your editable content inbetween <START_EDIT> and <END_EDIT> tags
- make sure, tags are written on a separate line in the template as they might not get replaced if they don't!
- make sure you extend the placeholders for your content like this:{CONTENT EDITTYPE="WYSIWYG"}
[edit] Check your default FCKeditor installation
- call http://www.YOURSERVER.TLD/parser/fckeditor/_samples/default.html
- choose one of the samples (f.e. http://www.YOURSERVER.TLD/parser/fckeditor/_samples/php/sample01.php)
- check the configuration of the PHP file browser connector (only needed if you need image/file browsing/uploading ability) by calling http://www.YOURSERVER.TLD/parser/fckeditor/editor/filemanager/browser/default/connectors/test.html
- choose/adjust the values for your environment
You should now be ready to call your site with http://www.YOURSERVER.TLD/index.htm?phpcmsaction=edit
[edit] Additional configuration
- If you want to use the filemanager function, you first have to enable it by setting 'true' in /parser/fckeditor/editor/filemanager/browser/default/connectors/php/config.php
//SECURITY: You must explicitelly enable this "connector". (Set it to "true"). $Config['Enabled'] = false ;
- If you want to use the upload function, you first have to enable it by setting 'true' in /parser/fckeditor/editor/filemanager/upload/php/config.php
// SECURITY: You must explicitelly enable this "uploader". $Config['Enabled'] = false ;
- You can change the size of the iframe (the size of the editor window) in ../parser/fckeditor/fckeditor.php at line 39,40
$this->Width = '100%' ; $this->Height = '200' ;
You can either give absolute pixel dimensions or relative percentage values. It is better to use absolute values since the iframe stays very small with relative values. 700px*700px is pretty usable.
- Design your own toolbar in /parser/fckeditor/fckconfig.js and call it by adding it's name in /parser/include/class.edit_wysiwyg_phpcms.php line 3:
$oFCKeditor->ToolbarSet = 'YOUR_TOOLBAR' ;
- You could save some bytes of storing space on your server by removing the directories starting with underscore ("_") in /parser/fckeditor/.
[edit] Troubleshooting
- Images are shown as dead links in edit mode but are displayed correctly when page is saved
-> Check your /parser/fckeditor/fckconfig.js for the correct server path.
- Jumping around in the text with the Cursors, HOME-Button, END-Button doesn't work.
-> rename /parser/fckeditor/htaccess.txt to /parser/fckeditor/.htaccess in order for the apache directives in this file to be applied
- Klicking the EDIT-Button runs into a login-loop
-> Add a .htaccess file to the subdirectory where you have installed the fckeditor in (for example parser/fckeditor) with the following single line as content:
AddType text/html .html
The problem is, that the fckeditor has to load a (static) html-page via an IFRAME. As apache was set via .htaccess file to parse all *.html files with the phpCMS parser, it loads now this static html-page, recognizes that it's in edit mode, but of course can't find a password in the static html page. This results in phpCMS asking again for a password.
The line above tells Apache not to send the *.html-files in the fckeditor subdirectory to phpCMS and therefore solves this problem.
[edit] Known issues and limitations
- It seems the editor won't get loaded in certain environments, i.e. heavy firewalled company computers.
- Concerning the first issue there might be server related issues too that have never become very transparent but which look like malfunctions you sometimes run into with different Apache/PHP configurations.
- I never tried to use more than one instance of FCKeditor on one page; possibly it works, probably it doesn't ...
- On older machines, loading the editor in Firefox might raise the CPU load to 100% for quite some time. Though functionality shouldn't be an issue, speed might be one.
- Poorly designed Firefox extensions might break your editor (this happened with "TabBrowser Extensions"). If you get errors loading certain editor windows (i.e. "undefined" messages) check your extensions for unofficial ones, i.e. not downloaded form update.mozilla.org.
- The editor doesn't work with Opera, Konqueror and Safari due to it's lack of DOM support. The developer of FCKeditor is working on an implementation for Safari. The above implementation of the Editor shows a simple Textfield with the source code in using these browsers so you can edit the text anyway, although with less convenience.
Main Page: Main Page | Top Page: Tutorials MainPage

