HOWTO to use a server-side spellchecker with FCKeditor

Author: Marc-Aurèle Darche
Revision: $Id$


1   Introduction

The aim of this short documentation is to explain how to use a server-side spellchecker such as aspell in the FCKeditor WYSIWYG HTML editor in a CPS context.

The FCKeditor WYSIWYG HTML editor is used for the CPS text widgets when they are in HTML mode.

2   Setup

2.1   Installing the server-side spellchecker utility

First of all you need to have the aspell program and needed dictionary installed on the host system:

$ apt-get install aspell aspell-en

Of course you could install other dictionaries than the English dictionary. Possible choices are aspell-fr, aspell-es, etc.

Then you have to install a PHP module for your web server, for example:

$ apt-get install libapache2-mod-php4

Then you have to install a file from the FCKeditor Zope product on the web server that will be used to perform the spell checking, that is, on the host system, copying FCKeditor/skins/fckeditor/editor/dialog/fck_spellerpages/spellerpages/server-scripts/spellchecker.php as /var/www/speller/server-scripts/spellchecker.php .

And then you need to modify the spellchecker.php script so that it corresponds to your environment. Since CPS web pages are served as ISO-8859-15 be sure to specify an ISO-8859-15 locale as the lang parameter, otherwise you would receive weird characters (due to encoding problems).

Here is an example for using an English dictionary:

$aspell_prog = 'aspell';
$lang = 'en_US@euro';

Here is an example for using a French dictionary:

$aspell_prog = 'aspell';
$lang = 'fr_FR@euro';

2.2   Enable server-side spellchecking on the client

Then you need to enable the spell checking on the user interface and tell it to use the server-side implementation.

To do so you need to customize the FCKeditor configuration file which is:


The configuration should be:

// Specifying the "SpellerPages" spellchecker server-side implementation
FCKConfig.SpellChecker = 'SpellerPages';

// Adding the "SpellCheck" button on the toolbar that you are currently using.
// "Semantic" is the default toolbar used by CPSSchemas.
FCKConfig.ToolbarSets['Semantic'] = [

2.3   Configuring which spellchecking service to use

Finally you need to configure which spellchecking service should be used by the client.

The actual code of FCKeditor makes it only possible to configure which server-side spellchecker you can/want to use through Apache configuration.

2.3.1   Apache

You can perform the needed configuration through Apache configuration directives.

Apache2 virtualhost configuration:

RewriteCond %{REQUEST_URI} ^(.*)/editor/dialog/fck_spellerpages/spellerpages/server-scripts/spellchecker.php
RewriteRule ^/(.*) /var/www/speller/server-scripts/spellchecker.php [L]

RewriteCond %{HTTP:Authorization}  ^(.*)
RewriteRule ^/(.*) http://localhost:8080/VirtualHostBase/http/%{HTTP_HOST}:80/cps/VirtualHostRoot/$1 [P,L]

2.3.2   Customizing through skins

It would be useful if we could perform the needed configuration through customizing the spellChecker.js FCKeditor file. Unfortunately it doesn't work.

In FCKeditor/skins/fckeditor/editor/dialog/fck_spellerpages/spellerpages/spellChecker.js we would like to just have to modify the following line:

// Original line:
//this.spellCheckScript = 'server-scripts/spellchecker.php';
// New configuration example:
this.spellCheckScript = 'http://spellmachine/speller/server-scripts/spellchecker.php';

Unfortunately it doesn't work.