Jump to Main Content
Content > XOOPS > FCKeditor for XOOPS
FCKeditor for XOOPS

Notes on FCKeditor 2.6.6 integration in XOOPS as released in the extra editors release of 2009-10.

Latest XOOPSified Version: (Included in extra XOOPSeditors release date 2009-10-26)

Latest FCKeditor Release: 2.6.6

This release of the FCKeditor for XOOPS is much better than before (see previous FCKeditor notes for XOOPS 2.3.x and before) generally making upgrades of FCKeditor much easier (some mods still needed, see below). And some integration issues and bugs were fixed and others not. Finally, note that FCKeditor's lifespan is limited and CKeditor is the future direction and I'll be focusing on that shortly for my projects, but there are a bit of changes that must be handled to dial it in for my projects and not all modules are fully supporting it yet.

This edition integrates the ImageManager plugin to replace the built-in version using File Manager, a more robust toolset with thumbnail images and such. However, you can't disable it on a module-by-module basis as you could before, so you may need to disable it altogether. Because the future direction is with CKeditor, I'll be focusing there generally in the future, but CKeditor requires a plugin for any uploadable aspects and/or the for-pay CKfinder.

Note: all path/file references in this article, generally, will be from xRoot/class/xoopseditors/fckeditor directory.



Extract the FCKeditor from the extra XOOPSeditors release and place it in xRoot/class/xoopseditors/ directory. Feel free to use as is, or customize as I've outlined below. I did that, uploaded the latest FCKeditor release (keeping the ImageManager plugin) on top and then made these edits/changes.


It's always best before upgrading to save your configuration, style, and template files:

  • FCKeditor Configurations, Styles and Templates
    • If you made customizations per my notes, you will need to merge these files: fckconfig-xoops.js, fckstyles-xoops.xml, and fcktemplates-xoops.xml (older versions of XOOPS FCKeditor may require a move of these files)
  • FCKeditor Connector Configs
    • save the config.php file (in ./fckeditor/editor/filemanager/connectors/php directory) to refer to when updating your configs there
    • Make appropriate configuration changes as described in my modifications below (or use my latest release)

Note: upgrades from FCKeditor 2.4.x and prior will require making all configuration changes again as described below due to the changes in file structure to FCKeditor.


Make the following changes as desired:

  • Custom Configurations
    This installation automatically uses the fckconfig-xoops.js custom configuration file (if it exists, it should). Make site-wide configuration changes there as desired. Note: when making configuration file modifications you will have to clear the XOOPS cache to see it because XOOPS/FCKeditor writes a cached configuration file (module by module) there.
  • FileManager (PHP-based) Modifications
    The integrators setup image management (using the Image Manager plugin), but not file management (such as Flash, Media, Files as well as Images). You'll have to edit some files to make that work correctly. See below for other useful modifications (apply as desired)
  • Module Specific Customizations
    Copy the files from the modules directory into the directory of the module you want to modify its storage. This works for the filemanager and for the Image Manager plugin (it's handled differently). It also requires different code in the connector configuration: if (!defined("XOOPS_FCK_FOLDER") || !$uploadPath = preg_replace("/[^a-z0-9_\-\/]/i", "", XOOPS_FCK_FOLDER) ) { $uploadPath = "content"; } for it to work.


These are the modifications I've made based on the XOOPS FCKeditor release (includes Image Manager plugin).


The list of files I've modified/added:

  • fckconfig-xoops.js (custom FCKeditor configs)
  • fckeditor/editor
    • dialog/fck_paste.html (Paste from Word Remove Styles checkbox checked by default)
    • filemanager/connectors/php
      • commands.php (custom directory/filename code)
      • config.php (default upload directory, enable Subdirectories, disable QuickUpload, enable ProtectedSource, directory/file permissions, custom directories/filenames, reg user check)
      • upload.php (disable upload code)
    • lang/en.js (per my desires)
    • plugins/ImageManager/config.inc.php (reg user check)
  • fckstyles-xoops.xml (custom css styles for dropdowns -- styles specified in theme css)
  • fcktemplates-xoops.xml (custom site templates -- styles specified in theme css)
  • formfckeditor.php (use theme stylesheets in editor, custom directory)
  • modules
    • fckeditor.config.js (cleared customizations)
    • readme.txt (clearer instructions)

Use Theme Stylesheets in Editor

This allows your editors to see what it will actually look like while editing. In ./formfckeditor.php add after line 86:

$oFCKeditor->Config['EditorAreaCSS'] = xoops_getcss();

Enable ProtectedSource

This security issue should have been done by the development team IMHO since this configuration depends upon which server-side application language is in use (php for XOOPS), so, to stop having to worry about this, put in in fckconfig-xoops.js (at least until this gets fixed):

FCKConfig.ProtectedSource.Add( /<\?[\s\S]*?\?>/g ) ; // PHP style server side code

Allow File Manager Browse / Uploads

The default installation has a new Image Manager integrated, but that doesn't deal with files, flash and such. Edit ./fckeditor/editor/filemanager/connectors/php/config.php:

after the global $Config statement add this code (comes from the XOOPS 1.2.1 editors release (circa 2005) with a couple of modifications (relative URLs, sub-directories, registered user):

$current_path = dirname(__FILE__);
    $current_path = str_replace( DIRECTORY_SEPARATOR, "/", $current_path);
$xoops_root_path = substr($current_path, 0, strpos(strtolower($current_path), "/class/xoopseditor/fckeditor/"));
include_once $xoops_root_path . "/mainfile.php";
if (!defined("XOOPS_ROOT_PATH") || !$xoopsUser) exit();

$xoopsLogger->activated = false;

if (!defined("XOOPS_FCK_FOLDER") || !$uploadPath = preg_replace("/[^a-z0-9_\-\/]/i", "", XOOPS_FCK_FOLDER) ) {
    if ($_SESSION['module_dir'] != "system") {
        $uploadPath = $_SESSION['module_dir'];
    } else {
        $uploadPath = "content";

Note that the above code checks for logged in users (no anonymous users). Also edit these lines:

$Config['Enabled'] = true ;
$Config['UserFilesPath'] = str_replace(XOOPS_URL,'',XOOPS_UPLOAD_URL).'/'.$uploadPath.'/' ;
$Config['UserFilesAbsolutePath'] = XOOPS_UPLOAD_PATH.'/'.$uploadPath.'/' ;

The default upload directory is thus /uploads/dirname. To change the second part, change 'content' to the directory name of your choice (like 'mynewdirname'). Whatever you name this, it remains a subdirectory in the uploads directory.

HTML Special Characters Issue

For whatever reason, this error still persists. XoopsEditor 1.21 solved it by getting rid of the undoHtmlSpecialChars call in formfckeditor.php (as introduced in the XoopsEditor 1.10 release). However, it was re-introduced. I expect there is a reason that this call is made by FCKeditor for some sort of protection in case someone adds a special character in the source side - ::shrug::

Using any special characters cause an unintended cascading effect of ampersand conversion. For instance, a quote " will become &quot; in the code — as it should be. However, after FCKeditor retrieves it from the database and displays it, it becomes &quot; in the WYSIWYG instead of ". The next time it becomes &amp;quot; and then &amp;amp;quot; ad infinitum. What I had to do was change fckeditor_php4.php and fckeditor_php5.php, approximately line 158 to (in function CreateHtml):

// $HtmlValue = htmlspecialchars( $this->Value ) ;
$myts =& MyTextSanitizer::getInstance();
$HtmlValue = $myts->htmlSpecialChars( $this->Value ) ;

This is because this XOOPS implementation uses the $myts->undoHtmlSpecialChars function before throwing it back into the database so we need to use the XOOPS version of the htmlspecialchars function.

Upload File Permissions

Files and folders will be created with 777 permissions unless you change it in the configurations file, change in fckeditor/editor/filemanager/connectors/php/config.php:

  • Files: line 100 (recommend 644)
  • Folders: line 104 (recommend 755)

File Uploader Doesn't Check if Disabled in Module Configurations

Interestingly, in the module-specific configuration code, there is ability to disable file uploads for that module alone, but the code doesn't exist to actually disable upload ability in the php connector. To do so, add these lines to fckeditor/editor/filemanager/connectors/php/config.php (before enabling -- i did it starting at line 62):

if ( !$Config['Enabled'] || ( defined("FCKUPLOAD_DISABLED") && FCKUPLOAD_DISABLED ) ) ...

Paste from Word Remove Styles Checkbox

I want the remove styles checkbox checked by default for the Paste from Word function, so made this change to line 339 of fckeditor/editor/dialog/fck_paste.html:

<input id="chkRemoveStyles" type="checkbox" checked="checked" />

Require Registered User

Both the Image Manager and File Manager should require at least registered user access. yeah, that means anonymous users can't browse the files. So what. Do you really want them having access to this? Because if they can upload files using this, then you're in trouble. To fix that in Image Manager, change line 26 to (Filemanager is fixed in the code above):

if (!defined("XOOPS_ROOT_PATH") || !$xoopsUser) exit();

User Directory and Filename Patterns

The directory (by month/year or year) and filename (various options) patterns was introduced in XOOPSeditor 1.2.1 but dropped in this implementation for some reason (I'm assuming to touch as little of the connector code as possible for future updates). Some of my community sites liked it, so I've added it back in. To add it back in, follow these instructions.

Add to fckeditor/editor/filemanager/connectors/php/config.php the following lines:

// Directory Pattern (UserFiles path based on month and/or year)
// Possible values:
// - Ym: new subdirectory each month
// - Y: new subdirectory each year
// - empty: inside same directory
$Config['UserFilesPathPattern'] = "" ;

// Filename Pattern (filename adds this info)
// Possible values:
// - date: YmdHis
// - time: unixtime
// - uid: userid (prepad with 0)
// - |: combination
// - empty: original name
$Config['UserFilesNamePattern'] = "" ;

and then make configuration changes based upon the pattern(s) you want to use.

In fckeditor/editor/filemanager/connectors/php/commands.php remove lines 177-179:

$sFileName = SanitizeFileName( $sFileName ) ;

$sOriginalFileName = $sFileName ;

then, add starting at (before) new line 182

$name_pattern = "";
if (!empty($Config['UserFilesNamePattern'])) {
$patterns = explode("|", $Config['UserFilesNamePattern']);
$delimiter = "";
foreach ($patterns as $pattern) {
switch($pattern) {
case "date":
$name_pattern .= $delimiter . date("YmdHis");
case "time":
$name_pattern .= $delimiter . strval(time());
case "uid":
$name_pattern .= $delimiter . ( is_object($GLOBALS["xoopsUser"]) ? str_pad($GLOBALS["xoopsUser"]->getVar("uid"), 10, "0", STR_PAD_LEFT) : "0" );
$delimiter = "-";
if (!empty($name_pattern)) {
$sFileName = $name_pattern . "." . $sExtension;
} else {
$sFileName = SanitizeFileName( $sFileName ) ;

$sOriginalFileName = $sFileName ;

Other Notes

Image Manager Not Disabled

This installation doesn't allow for the disabling of the Image Manager if it's specified in the configuration file. It might be best to setup module specific configurations in the fckeditor/modules directory and control it from there. That may be a future direction, but for now you'll just have to remove it from the editor configs.

Safe Mode / Image Manager

If you are using safe_mode = On, then you will need to edit the Image Manager plugin configuration file for safe mode.

ImageMagick or NetPBM

Image Manager uses GD by default, but if you want to use ImageMagick or NetPBM, edit the Image Manager plugin configuration file.

Other Pages
Previous Page Meeting Room Booking System (MRBS) Publisher Module for XOOPS Next Page
Comments are solely the opionion of the author and not to be construed as the opinion of anyone else.


Remember me

Lost Password?

Register now!



(c) 2006-2007 - Mark Boyden
Privacy - Legal Stuff - Contacts