Like many of you who posted on this site, you've struggled with implementing FCKeditor on your XOOPS 2.0.x installation. Here are the instructions and information to get it running for you. It includes the ability to upload images and other files allowed in FCKeditor sitewide as well as for specific modules if you want to have separate locations for separate modules. [Note: This uses the XOOPSeditor v1.10 download. I used this on 2.0.16, but I expect that it will work for most of the 2.0.x versions. Also, since I'm now on PHP5, there may still be some other code in there that doesn't work on PHP4, but I don't have PHP4 servers available for testing anymore, so your mileage may vary. But the one fix I proffer here is a PHP4 & 5 solution.]
If you have questions, post to this topic and I'll answer and clarify. I've also posted instructions formatted in HTML on my website. That may be more readable than what I can accomplish here.
If you want, instead of doing this editing, you may want to just download
my update to FCKeditor.
HOW IT WORKS (DEVELOPER VIEWPOINT)
----------------------------------
In essense, this implementation will build a variable $uploadPath which is tacked onto the XOOPS_UPLOAD_URL which is the XOOPS_ROOT."/uploads" directory. So ALL of your files will be there (unless you do some additional hacking -- not recommended).
This implementation of FCKeditor will look for configuration files in the module directory and use those settings. If it doesn't find the files there, then it uses a default specification (XOOPS_ROOT/uploads/fckeditor unless you change per instructions below).
Under this FCKeditor upload directory, depending upon your usage, it will create the following subdirectories for uploaded content: Image, File, Flash, and Media (yes, case sensitive). You do NOT have to create these yourself, although you may run into permission issues that you may have to fix (more info below)
IMPLEMENTING FCKeditor
----------------------
In short, here are the steps to get FCKeditor (included in XOOPSEditor v1.10) working for your modules (in 2.0.x, where I was using 2.0.16):
- Download XOOPSeditor 1.10 and install per instructions - use the readme.txt file.
- At this point, FCKeditor is in this folder: XOOPSROOT/class/xoopseditor/FCKeditor (don't change this folder name due to some hard-coding)
- Modify any calls from your modules that aren't using this path to point to this location (I realize some specify fckeditor instead of FCKeditor, but due to hardcodings, you'll not want to change that).
At this point, the editor should generally work (except maybe for uploads).
ENABLING FCKeditor UPLOADS
--------------------------
To have uploads work (for images), you will have to edit these files (from FCKeditor folder) due to some error in coding (I couldn't figure out what was trying to be done but I got it to work right):
- /editor/filemanager/browser/default/connectors/php/config.php
- /editor/filemanager/upload/php/config.php
What you want to do is modify two lines:
$fckeditor_root_path = substr($current_path, 0, stripos($current_path, basename(dirname(dirname(__FILE__)))."/editor"));
to be:
$fckeditor_root_path = dirname(substr($current_path, 0, strrpos($current_path, "/editor")));
and (in case you want your upload path to use subdirectories and not strip out the slashes)
if(!defined("XOOPS_FCK_FOLDER") || !$uploadPath = preg_replace("/[^a-z0-9_\-]/i", "", XOOPS_FCK_FOLDER) )
to be:
if(!defined("XOOPS_FCK_FOLDER") || !$uploadPath = preg_replace("/[^a-z0-9_\-\/]/i", "", XOOPS_FCK_FOLDER) )
- if you want, edit the $uploadPath variable (about line 50) in both config.php files as well for the default path (default is fckeditor).
UPLOAD FILE PERMISSIONS
- files are created with 777 permissions unless you change line 206 of editor/filemanager/browser/default/connectors/php/commands.php and line 109 of editor/upload/upload.php to the permissions you want
- folders are created with 777 permissions unless you change line 73 of editor/filemanager/browser/default/connectors/php/io.php to the permissions you want
Notes:
I disabled the Upload tab on the main Image/Flash insert window because these files uploaded into the uploadPath directory and thus weren't browsable later using the Browse Server button on the Image Info, Flash Info or Link tabs. I did this in the editor/filemanager/upload/php/config.php file, line 47, setting $Config['Enabled'] = false;. I was still able to upload using the Browse Server button pop-up. Until we can see the files with the browser, it doesn't make sense to use this upload tab.
I also wanted to use server relative URLs because I make a basic server setup that I replicate to many sites, so then I had to make changes again....
I changed line 55 of editor/filemanager/browser/default/connectors/php/config.php and line 51 of editor\filemanager\upload\php\config.php from:
$Config['UserFilesPath'] = XOOPS_UPLOAD_URL."/".$uploadPath."/" ;
to:
$Config['UserFilesPath'] = str_replace(XOOPS_URL,"",XOOPS_UPLOAD_URL)."/".$uploadPath."/" ;
This just removes the portion with your server name. Relative URLs rule for content!
MODULE SPECIFIC UPLOAD DIRECTORIES
Finally, if you want to enable module specific versions of this, then for each module that you want to have different from the global settings, here is what you do:
- copy the files from the FCKeditor/modules folder to the directory of the module in which you want an upload area named by module.
- edit MODULE/fckeditor.upload.php and ENABLE uploads (if you want), by disabling the FCKUPLOAD_DISABLED variable: define("FCKUPLOAD_DISABLED", 0);
- Note: If you are troubleshooting and make any changes, you will want to clear a cached file in the cache directory for each module, named XOOPS_ROOT/cache/fckeditor.MODULE_NAME.js to have the changes take effect.
Clear as mud? Hope so. But if you still are having problems, then you can use the two test files included to help troubleshoot your installation just like I did:
http://yoursite.com/class/xoopseditor/FCKeditor/editor/filemanager/browser/default/connectors/test.html and
http://yoursite.com/class/xoopseditor/FCKeditor/editor/filemanager/upload/test.htmlThings I would like to see:
- Toolbars. I'd like to offer Users just the basic toolbar and then offer other groups (Admins and privileged content contributors) the ability to use the full toolbar. I see this in the implementation for Drupal, so I'm sure it can be done here. That's left for another day for me. I assume that even though the toolbar isn't there, I can still upload just about any HTML, though, so I'm not sure if it buys any security for the site.
- Options moved to config file. Many of these changes can likely be moved to the configuration file(s). This includes permissions, paths, etc. I expect that is where one would likely want to add the module info, too.
Many thanks to the following posts for helping me to get this going:
XOOPS:
Post 1 |
Post 2 |
Post 3;
XOOPSInfo
Post which also pointed to
this XOOPSforge thread which also pointed me to the test URLs. From all of these pointers, I was able to figure it out. Hope it helps you!