meta data for this page
CKEditor
—- plugin —-
description: This plugin provides CKEditor, an HTML text editor, for editing messages and templates. This is for phplist 3.x.
author : Duncan Cameron
type : editor
compatible : 3.x
tags : editor
sourcerepo : https://github.com/bramley/phplist-plugin-ckeditor
This plugin provides CKEditor 4 for editing messages and templates. It also integrates the KCFinder file manager to provide file uploading and browsing.
Both CKEditor 4 and KCFinder are “end of life”, which means they do not receive any code fixes or security updates. The plugin uses the last freely available version of CKEditor 4, version 4.22.1. There is a paid-for version that does have security patches, see https://ckeditor.com/ckeditor-4/download/
Installation
This plugin is now included in phplist, but see the README file on the GitHub page https://github.com/bramley/phplist-plugin-ckeditor for how to install or upgrade the plugin.
Configuration
config.php
The UPLOADIMAGES_DIR value in config.php must be set to the location of a directory where KCFinder can store uploaded images. The directory must be writable by the web server. Note that the value is relative to the web root and must not contain a leading '/'.
define('UPLOADIMAGES_DIR', 'upload');
If the UPLOADIMAGES_DIR value in config.php is set to false
then KCFinder will be disabled and image uploading will not be possible.
The upload directory will be shared by all admins. You can give each admin their own private directory using
define('IMAGE_DIR_PER_ADMIN', true);
KCFinder will use a subdirectory of UPLOADIMAGES_DIR named after the admin login id (1, 2, 3 etc.), creating the subdirectory on first-use. The subdirectory is private to the admin, and there is no sharing of image files.
SELINUX configuration for images dir
To make this work with selinux enforced on centos7 with apache and phplist installed in /var/www/html/lists
Edit config.php adding the following to the end of the file;
define ('UPLOADIMAGES_DIR', 'lists/uploadimages');
cd lists mkdir uploadimages uploadimages/image uploadimages/flash uploadimages/files chown -R apache:apache uploadimages/ semanage fcontext -a -t httpd_sys_rw_content_t /var/www/html/lists/uploadimages chcon -Rv --type=httpd_sys_rw_content_t /var/www/html/lists/uploadimages
Settings page
The Settings page has a CKEditor group where you can configure the plugin.
- The URL of ckeditor.js
- The path to a custom configuration file. This is the path from the web root.
- You can select to generate a full HTML page when editing a message. The message will then include
<html>
,<head>
and<body>
elements. This setting defaults toNo
. The plugin will always enable this setting for CKEditor when editing a template. - Whether to disallow javascript. The default setting is
Yes
in which case<script>
elements,onclick
and similar attributes, and<iframe>
elements will be removed by CKEditor. This helps to reduce the effect of editing malicious HTML. - If using the Dressprow theme, the width and height of the editor window can be specified.
- The path to KCFinder. This is the path from the web root or a relative path from the
admin
directory. - In some web server configurations the plugin will not be able to correctly derive the file system path to the upload image directory from the value of
UPLOADIMAGES_DIR
. The plugin will show a message similar to this
Image browsing is not available because directory “/xxx/xxx” does not exist or is not writeable
.
If the file system path in the message is wrong but the value ofUPLOADIMAGES_DIR
is correct, then you can enter the actual file system path that should be used. - KCFinder will create sub-directories within the image upload directory to store images, flash files and other files. If you need to then you can change the name of a sub-directory from the default value.
Custom configuration
Other settings for the editor can be placed in a custom configuration file. This file needs to be within the web root and its web path specified on the Settings page, e.g. /ckconfig.js
if the file is in the web root. A sample custom configuration file CKEditorPlugin/sample.ckconfig.js
is provided which can be used as the basis for your own settings.
See https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html for how to specify configuration settings.
Styles
Style definitions can be specified in the custom configuration file, and they will then appear in the Styles drop-down list when editing a message. Additionally, a CSS stylesheet file can be parsed to provide the style definitions. The sample custom configuration file has an example of how to define styles.
See https://ckeditor.com/docs/ckeditor4/latest/features/styles.html
Location of CKEditor
Starting in version 2.1.0 of the plugin CKEditor is loaded from its Content Delivery Network. Earlier versions of the plugin included a copy of CKEditor but that is no longer the case.
If you want to customise CKEditor, such as by adding further plugins to it, then you can install a local copy by downloading a version from https://ckeditor.com/ckeditor-4/download/?null-addons=#ckeditor-4
Expand the zip file then copy the ckeditor directory to the root directory of your web site.
You must then enter the URL for ckeditor.js in the CKEditor group on the Settings page. For example, if you installed CKEditor in the directory ckeditor_4.5.6
of your web site then the setting would be /ckeditor_4.5.6/ckeditor.js
.
At present (July 2024) version 4.20.2 is the last one that does not display a pop-up message regarding being insecure and recommending upgrading.
Upgrade CKEditor
The plugin will not automatically upgrade to a new release of the CKEditor package. To see whether there is a later release, or to use either the Basic or the Standard package, visit the CKEditor CDN section https://ckeditor.com/ckeditor-4/download/, then modify the setting “URL of ckeditor.js” on the Settings page.
Upgrade KCFinder
The plugin includes KCFinder 3.20 but the KCFinder package is no longer developed or supported.
Upgrade from phplist 2.10.x with FCKEditor
In phplist 2.10 the FCKIMAGES_DIR value in config.php defines the directory into which images will be uploaded. The value is relative to the phplist root directory.
In phplist 3.x a different value, UPLOADIMAGES_DIR, is used to define the directory. This value is relative to the web root, not to the phplist root directory. To continue using the same upload directory you must set UPLOADIMAGES_DIR correctly. So, for example, if the existing image upload directory is /lists/uploadimages
then the FCKIMAGES_DIR would be uploadimages
but the value for UPLOADIMAGES_DIR would be lists/uploadimages
.
Issues
Image browsing is not available because directory "/xxxx" does not exist or is not writeable
This message means that there is probably an error in the value specified for UPLOADIMAGES_DIR
in the config.php file. The value needs to be the path from the web root (not the full file system path).
For example, on a server using CPanel, using the default value of uploadimages
there needs to be a directory /home/xxx/public_html/uploadimages
that is writeable.
Alternatively, if you want the upload directory to be within the /lists
directory then UPLOADIMAGES_DIR
should be set to lists/uploadimages
and the directory /home/xxx/public_html/lists/uploadimages
must exist and be writeable.
There can be some cases when the plugin displays this message but the directory does exist. This can happen when the web server uses a non-standard DOCUMENT_ROOT or uses symbolic file links. If this is the case then you can specify the actual file system path for the upload directory in the CKEditor group on the Settings page
Warning, Unknown failure
This message can be displayed when a symbolic link is used for the file upload directory, which triggers a bug in the KCFinder file browser. Version 2.1.3 of this plugin has some processing to try to work around this problem, so ensure that you are using version 2.1.3 or later. You can verify this on the Manage Plugins page.
If the error still occurs then you can try setting the file system path for the upload directory explicitly in the CKEditor group on the Settings page
You don’t have permissions to browse server
If you get the message You don’t have permissions to browse server
or You don’t have permissions to upload files
when trying to browse or upload images then there is likely a problem with the php session configuration.
See the KCFinder documentation for an explanation.
To avoid this problem you should use the default session handling with phplist. In particular do not use the phplist option to store sessions in a database table, as the session will not be accessible to KCFinder.
If you cannot resolve the problem then a work-around is to change one line in the KCFinder config file, setting disabled
to false
, as explained in the KCFinder documentation.
Support
Please raise any questions or problems in the user forum https://discuss.phplist.org/