FCKeditor is an excellent tool for providing rich text editing experience on web. Best part is that it works almost out of the box, there is very little to configure. Spelling checking is an exception here. Though spell checking also works out of the box, but with Internet Explorer only, which is not the only browser out there. Recently I used FCKeditor in a Java web application and had to integrate the spell check functionality as well. The spellar pages + aspell + PHP combination works pretty well for this task. FCKeditor comes with perl, PHP and Cold Fusion scripts for spell checking, I used PHP. In this post I will try to outline the steps required to make spell check working in FCKeditor.
1. Install PHP
PHP installation (I did it on Fedora) is pretty simple, just download the source and execute following command sequence-
tar –xvzf php-5.2.9.tar.gz
cd php-5.2.9
./configure --prefix=/path_to_install \
--with-apxs2=/apache_install_dir/bin/apxs \
--disable-cli \
--disable-cgi
make
make install
For more details about PHP installation see
PHP documentation.
2. Integrate PHP with ApacheApache needs to be instructed to invoke PHP interpreter for all requests for PHP files ('
.php' extension). First we need to include PHP module by adding following line in
/apache_install_dir/conf/httpd.conf-
LoadModule php5_module modules/libphp5.so
In same configuration file add PHP handler-
<Directory "/apache_install_dir/htdocs">
. . . .
. . . .
<FilesMatch \.php$ >
SetHandler application/x-httpd-php
</FilesMatch>
</Directory>
3. Install aspell and dictionariesAspell provides dictionaries for all major world languages. Installation of aspell and its dictionaries is fairly straightforward. After downloading aspell and dictionaries execute following command sequence for each of the downloaded archive-
tar –xvzf archive_name.tar.gz
cd archive_name
./configure
make
make install
4. FCKeditor ConfigurationBy default FCKeditor is configured to use 'ieSpell', change it to use 'SpellarPages' instead. Also make sure it uses PHP and does spell checking in FireFox. Following properties needs to be changed in 'fckconfig.js'-
FCKConfig.SpellChecker = 'SpellerPages' ;
FCKConfig.SpellerPagesServerScript = 'server-scripts/spellchecker.php' ;
FCKConfig.FirefoxSpellChecker = true ;
Now configure the language and 'aspell' path in 'spellchecker.php'-
$aspell_prog = 'aspell';
$lang = 'en_US';
Now we are ready to test the application and see spell check in action. All software versions being used for this post are outlined below-
- Apache 2.2.11
- PHP 5.2.9
- FCKeditor 2.6.4 (with bundled Spellar Pages)
- Aspell 0.60.6
- Tomcat 6.0.18
- Java 6 update 13
- Fedora 9
To know more about using Apache to serve Java application see
Apache in from of Tomcat and JBoss.