User Tools

Site Tools

Translations of this page:

plugin:ckeditor

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 for editing messages and templates. It also integrates the KCFinder file manager to provide file uploading and browsing.

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 website path to a custom configuration file.
  • The width and height of the editor window.
  • You can select to generate a full HTML page when editing a template. The template will then include <html>, <head> and <body> elements. This setting defaults to Yes.
  • Similarly you can select to generate a full HTML page when editing a message. This is useful only when you do not use templates, otherwise the template and the message will both contain <html>, <head> and <body> elements. The default value is No. If this field is set to Yes then it is ignored if Allow templates to be edited as full HTML pages is also set to Yes.
  • The website path to KCFinder.
  • 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 of UPLOADIMAGES_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. 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.

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, UPLOADIMAGESDIR, 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 UPLOADIMAGESDIR correctly. So, for example, if the existing image upload directory is /lists/uploadimages then the FCKIMAGESDIR would be uploadimages but the value for UPLOADIMAGESDIR 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.

Only a template or a message can be edited as a full HTML page, not both. This message will use only limited HTML.

By default, CKEditor allows only a limited set of HTML elements to be used. If you want it to generate a full HTML page, including the structural elements (head, body etc), then one of the settings “Allow templates to be edited as full HTML pages” or “Allow messages to be edited as full HTML pages” needs to be enabled in the CKEditor section on the Settings page.

When one of those settings is enabled, CKEditor will ensure that the HTML structural elements are present, even if not entered directly. This means that it is not sensible to edit both templates and messages as full HTML pages because both will include structural elements leading to badly-formed HTML when a template includes a message using the [CONTENT] placeholder.

If both of those settings are enabled then the one for templates takes precedence, and CKEditor will allow only limited HTML when editing a message.

If you want to create only full page HTML messages and do not use templates then set “Allow templates …” to No and “Allow messages …” to Yes.

Support

Please raise any questions or problems in the user forum https://discuss.phplist.org/

plugin/ckeditor.txt · Last modified: 2023/05/14 10:24 by duncanc

Resources
Contact Us

e: info@phplist.com

Boring Bit

phpList is a registered limited company

UK Company No. 07582966

VAT Registration 122 0788 37

© phpList 2016