1
mboyden
FCKeditor for XOOPS
  • 2010/10/7 16:43

  • mboyden

  • Moderator

  • Posts: 484

  • Since: 2005/3/9 1


Notes on FCKeditor 2.6.6 (the latest as of this writing) integration in XOOPS as based on that released in the extra editors release of 2009-10. Feel free to see my notes on FCKeditor for XOOPS on my website for better formatting (and where I will make any updates). I also last wrote about FCKeditor using 2.6.3 for XOOPS 2.3.x and previously 2.0.x.

Latest XOOPSified Version: 2.6.4.1 (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 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, deleting 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.

------------
Installation
------------
New
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 in the XOOPS version) on top and then made these edits/changes below.

Upgrades
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.

-------------
Configuration
-------------
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 ONLY works for the filemanager and NOT 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.

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

Files
The list of files I've modified/added:
- fckconfig-xoops.js (custom FCKeditor configs)
- fckeditor/editor
- o dialog/fck_paste.html (Paste from Word Remove Styles checkbox checked by default)
- o filemanager/connectors/php
- o + commands.php (custom directory/filename code)
- o + config.php (default upload directory, enable Subdirectories, disable QuickUpload, enable ProtectedSource, directory/file permissions, custom directories/filenames, reg user check)
- o + upload.php (disable upload code)
- o lang/en.js (per my desires)
- o 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)
- modules
- o fckeditor.config.js (cleared customizations)
- o 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( /<?[sS]*??>/) ; // 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__);
if ( 
DIRECTORY_SEPARATOR != "/" ) {
    
$current_path str_replaceDIRECTORY_SEPARATOR"/"$current_path);
}
$xoops_root_path substr($current_path0strpos(strtolower($current_path), "/class/xoopseditor/fckeditor/"));
include_once 
$xoops_root_path "/mainfile.php";
if (!
defined("XOOPS_ROOT_PATH") || !$xoopsUser) exit();

$xoopsLogger->activated false;

if (
$_SESSION['module_dir'] != "system") {
    
$uploadPath $_SESSION['module_dir'];
} else {
    
$uploadPath "content";
}
Note that code checks to make sure the user is a registered user (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.'/' ;
Using this, 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 ( defined("FCKUPLOAD_DISABLED") && FCKUPLOAD_DISABLED ) {
SendUploadResults'1''''''ERROR: file uploader is disabled' ) ; // this should be "languaged"
exit();
}

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 example: date|time|uid
// - 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");
                break;
            case 
"time":
                
$name_pattern .= $delimiter strval(time());
                break;
            case 
"uid":
                
$name_pattern .= $delimiter . ( is_object($GLOBALS["xoopsUser"]) ? str_pad($GLOBALS["xoopsUser"]->getVar("uid"), 10"0"STR_PAD_LEFT) : "0" );
                break;
        }
        
$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.

Certainly post here if you have questions or issues; I'll be monitoring this thread.
Pessimists see difficulty in opportunity; Optimists see opportunity in difficulty. --W Churchill

XOOPS: Latest | Debug | Hosting and Web Development

2
Burning
Re: FCKeditor for XOOPS
  • 2010/10/7 18:14

  • Burning

  • Theme Designer

  • Posts: 1163

  • Since: 2006/8/22


hi'

Many thanks, that's great !



ps : I have two plugins to manage video, do you want to add it ?
Still learning CSS and... english

3
mboyden
Re: FCKeditor for XOOPS
  • 2010/10/7 18:40

  • mboyden

  • Moderator

  • Posts: 484

  • Since: 2005/3/9 1


I have what you sent me in May 2009, (for XOOPS 2.3.2b with FCKeditor 2.6.4) still sitting waiting on me. Any changes since then? It hasn't been on my hotlist because no one I work with has needed them -- yet. Most use YouTube instead which FCKeditor already does. But it could be added, I suppose. Do they use the custom module configurations?

My email address is in my profile if you have an update.

I could package it all up and hand it back to phppp to incorporate.
Pessimists see difficulty in opportunity; Optimists see opportunity in difficulty. --W Churchill

XOOPS: Latest | Debug | Hosting and Web Development

4
Burning
Re: FCKeditor for XOOPS
  • 2010/10/7 23:57

  • Burning

  • Theme Designer

  • Posts: 1163

  • Since: 2006/8/22


hi'

Plugins are the same, nothing changed. It worked with FCKEditor 2.6.3

Here instructions to install :
Quote:

a. Modiy fckeditor/fckeditor/fckcongifs.js (around line 55)

// Youtube plugin
FCKConfig.Plugins.Add( 'youtube', 'en' ) ;

// EmbedMovies plugin
FCKConfig.Plugins.Add( 'embedmovies', 'en' ) ;

// flvPlayer plugin
FCKConfig.Plugins.Add( 'flvPlayer', 'en' ) ;

b. Modify toolbar into fckeditor/fckeditor/fckconfigs.js (around line 162)

['EmbedMovies','YouTube','flvPlayer'],

c. Modify toolbar into fckeditor/fckconfig-xoops.js (line 16)

['Image','Flash','Table','Rule','SpecialChar','EmbedMovies','YouTube','flvPlayer'],


d. Add plugins into fckeditor/fckeditor/editor/plugins/youtube/
- /fckeditor/editor/plugins/embedmovies/
- /fckeditor/editor/plugins/youtube/
- /fckeditor/editor/plugins/flvPlayer/


To make plugin flvPlayer works :
1. In flvPlayer.js, replace MediaBrowserURL by FlashBrowserWindow
2. In flvPlayer.js, delete background-image: ***

(*** sorry, my notes seems incomplete here)


Tell me if you have enough free time ... I hope so


---

Here the download link :http://tutos.xoofoo.org/modules/mydownloads/viewcat.php?cid=48
Still learning CSS and... english

5
kris_fr
Re: FCKeditor for XOOPS
  • 2010/10/8 9:14

  • kris_fr

  • Theme Designer

  • Posts: 1009

  • Since: 2005/12/31


Thanks

SVN updated to FCKeditor 2.6.6

6
mboyden
Re: FCKeditor for XOOPS
  • 2010/10/8 14:34

  • mboyden

  • Moderator

  • Posts: 484

  • Since: 2005/3/9 1


@kris_fr:

Should I assume that means it was just FCKeditor 2.6.6 updated, but not any of the other aspects I've noted? Just curious. I think that it should support theme CSS out of the box, and the PHP protection should be turned on, and the FCKUPLOAD_DISABLED should be in there, HTML Special Characters, and maybe a few others things (for instance the image manager is available to anonymous users out of the box, a security problem IMHO).

Anyhoos, would be happy to work with you on getting the right things for others to use. I'll be applying these similar things to CKeditor when I head that direction, but it's all j-script, so will need some additional time to go through it all and get it set right and to find and configure the right image/file managers (and maybe others as well from Burning).
Pessimists see difficulty in opportunity; Optimists see opportunity in difficulty. --W Churchill

XOOPS: Latest | Debug | Hosting and Web Development

7
kris_fr
Re: FCKeditor for XOOPS
  • 2010/10/8 15:10

  • kris_fr

  • Theme Designer

  • Posts: 1009

  • Since: 2005/12/31


@ Mark :
I applied your changes and those of burning, if there are errors, I think you can fix on the svn or send me files and I make the correction.

Otherwise I watch also the editor "elrle (http://elrte.org)" - which I had the very good. I started the integration for Xoops, but my skills will soon be limited - so a little help is requested

Login

Who's Online

177 user(s) are online (119 user(s) are browsing Support Forums)


Members: 0


Guests: 177


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits