Yii 1.1: newtinymce

Extension to use TinyMce with Compressor, SpellChecker and FileManager

Almost in every application, i have need in wysiwyg editor for content. In most of them I have used tinymce extension writen by MetaYii(with some ugly changes, added by me, to connect elFinder file manager to it).

Recently I have written my own widget for TinyMce and for elFinder with possibility of integrating them. Also I have written separate actions for TinyMce compessor and for spellchecker plugin. So i think that my code looks more cleaner than something like tinymceelfinder extension, that has similar functionality.

Also I have added less ugly skin for tinyMce(modified version of cirkuitSkin).

TinyMCE Versions

There is two TinyMCE versions - 3.x and new 4.x

Extension has the same interfaces for both of them, but because they are different they will have slightly different settings.

So when configuring it - refer to appropriate documentation version.


  • Tested with Yii 1.1.10, but should work with previous versions too
  • To use with elFinder, requires https://bitbucket.org/z_bodya/yii-elfinder


  1. Checkout source code to ext.tinymce
  2. To use spellchecker and compressor, create controller and add corresponding actions to it
  3. Use it as any other input widget:
  4. More about elFinder extension here: https://bitbucket.org/z_bodya/yii-elfinder
// controller for tinyMce
class TinyMceController extends CController
     public function actions()
          return array(
              'compressor' => array(
                    'class' => 'TinyMceCompressorAction',
                    'settings' => array(
                       'compress' => true,
                            'disk_cache' => true,
                    'spellchecker' => array(
                        'class' => 'TinyMceSpellcheckerAction',
// in view
$this->widget('ext.tinymce.TinyMce', array(
    'model' => $model,
    'attribute' => 'tinyMceArea',
    // Optional config
    'compressorRoute' => 'tinyMce/compressor',
    //'spellcheckerUrl' => array('tinyMce/spellchecker'),
    // or use yandex spell: http://api.yandex.ru/speller/doc/dg/tasks/how-to-spellcheck-tinymce.xml
    'spellcheckerUrl' => 'http://speller.yandex.net/services/tinyspell',
    'fileManager' => array(
        'class' => 'ext.elFinder.TinyMceElFinder',
    'htmlOptions' => array(
        'rows' => 6,
        'cols' => 60,

CSRF token validation problem, for spellchecker requsts

By default Yii validates csrf token for all requsts, but spellchecker has requst content-type "application/json" - so even if we pass csrf token in request, yii will not validate it.

Forum discussion about this

Also there is no need in csrf validation for spellchecker service, so possible solutions is to skip validation for such requests. I order to do so we need to extend CHttpRequst like in sample below:

class HttpRequest extends CHttpRequest
    public function validateCsrfToken($event)
        $contentType = isset($_SERVER["CONTENT_TYPE"]) ? $_SERVER["CONTENT_TYPE"] : null;
        if ($contentType !== 'application/json')

And add it into application configuration:

// application components
'components' => array(
    'request' => array(
       'class' => 'HttpRequest',
       'enableCsrfValidation' => true,


  • March 20, 2014 Updated to 4.0.20
  • February 11, 2014 Updated to 4.0.16
  • December 20, 2013 Updated to 4.0.12
  • December 7, 2013 Updated to 4.0.11
  • November 14, 2013 Updated to 3.5.10, added 4.x verion
  • September 11, 2013 Fixed, bugs in compressor action
  • December 12, 2012 Updated spellchecker(Version - Fixed security issue with google spellchecker)
  • November 24, 2012 Added spellcheckerUrl as replacement for spellcheckerRoute property. Now external spellchecking services can be used(thanks fad comment).
  • Novemner 20, 2012 Upgrade TinyMCE to version 3.5.8
  • September 25, 2012 Upgrade TinyMCE to version 3.5.7
  • August 3, 2012 Replace content.css in circuit skin by default one
  • August 2, 2012 Fixed bug when using attribute with "[]" in name.
  • July 27, 2012 Upgrade TinyMCE to version 3.5.6
  • July 21, 2012 Upgrade TinyMCE to version 3.5.5
  • July 18, 2012 Fixed bug with large compessor response time


Total 15 comments

#19172 report it
Jannis at 2015/04/04 02:14pm
Can not solve the problem alone

I have tried several things now, but I don't find the answer to my last question. Someone else?

#19168 report it
Jannis at 2015/04/02 08:51pm
It works 95%

Thanx with your advice it works with only one problem:

I copied the two files from your hint.

elFinder opens now and I can do everything in it. But one important thing has a problem: Opening an image. I doubleclicked it, used rightclick and "choose file". Nothing happens.

Following error is comming in the firebug-console: TypeError: aWin.document.forms[0].elements[aFieldName] is undefined

Hope you can help me to come to an end.

#19156 report it
Bogdan Savluk at 2015/03/30 07:18am
Re: Full example for integrating elFInder in tinymce

I don't understand the "connectorRoute". What ist 'admin/elfinder/connector'? It looks like controller/action/??? I have tried 'connectorRoute' => 'controller/action',

it is route to ElFinderConnectorAction (from elfinder extension) in your application.

For complete example take a look at this project: https://bitbucket.org/z_bodya/yii-demo-blog

Files: protected/controllers/ApiController.php and protected/views/post/_form.php

#19155 report it
Jannis at 2015/03/30 06:26am
Full example for integrating elFInder in tinymce

Tinymce is running but elFinder gets me cracy ... not a lot of things to find in the internet.

My view:

        $this->widget('ext.tinymce.TinyMce', array(
            'model' => $model,
            'attribute' => 'hilfe',
            // Optional config
            'fileManager' => array(
                'class' => 'ext.elFinder.TinyMceElFinder',
                'connectorRoute' => 'admin/elfinder/connector',

I don't understand the "connectorRoute". What ist 'admin/elfinder/connector'? It looks like controller/action/??? I have tried 'connectorRoute' => 'controller/action',

I tried with one of my Controller/Actions but still got an error: "no valid serverconfiguration".

Can someone give a complete example with needed

  • controller,
  • all actions
  • and view?

I would be very pleased.

#19154 report it
Jannis at 2015/03/30 06:01am
Configure tinymce: settings

Thanx for this extension. Since it is not very well documented it took me hours to find out how to configure it. Next time I look into the code and not into Google ;-)

To save you some time: you have to use an attribute "settings":

// in view
    $this->widget('ext.tinymce.TinyMce', array(
        'model' => $model,
        'attribute' => 'tinyMceArea',
        'settings' => array(
                         'relative_urls' => true, // default is false: absolute urls

Here you can find all the possible settings: Configuration

hope it helps

#15847 report it
mem at 2013/12/22 07:29am
Setup tinyMCE for all textareas on the admin section


1) In order to setup this extensions for ALL textareas on the admin section, how should we proceed? Should we call this widget on admin.php layout, for example?

2) I've already imported this extension under "main.php" configuration file. In order to call the widget, do I still need to provide the path?

3) $model? $attribute? What do they mean? Are they mandatory?

#13875 report it
Andre Lopez at 2013/07/03 10:51am
great extension!

Hello, thanks for this great extension!! Regards

#12934 report it
Jales Monteiro at 2013/04/21 09:13pm
more one thing

I think need one function like 'reinit' to init again with the sames settings than the init :)

#12644 report it
tihanyilaci at 2013/04/03 07:12am
Great extension

Hi Bodya,

nice extension again. I experienced a bootstrap conflict with yii's tinymce extension and I tried this. The conflict has amazingly gone. Excellent work! Grat! So I've tried the galleryManager before and that have been also great like this one again.

Best Regards Laszlo from Hungary

#10617 report it
Bogdan Savluk at 2012/11/08 06:29am
Re: spell/compressor broken with csrf

Compressor will work(it works by get request).

Originally tinymce spellchecker plugin does not support CSRF protection, so, by now, my widget does not support it too. ASAP, I will try to fix this. Thanks for report.

#10611 report it
Cstdenis at 2012/11/08 12:28am
spell/compressor broken with csrf

Spell check (and I think compressor) do not work if you have csrf validation enabled (which everyone should) because it does not send the crsf token.

#9118 report it
Bogdan Savluk at 2012/07/21 05:42pm
Re: connectorRoute

This is part of configuration for fileManager integration. In example above it is for my elFinder extesion. You can read how to configure it on extension page.

#9117 report it
m1m1m1 at 2012/07/21 04:58pm

Please, could you let me know what is this: 'connectorRoute'=>'admin/elfinder/connector', How should I setup it?

#9004 report it
Bogdan Savluk at 2012/07/12 08:20am
Re: settings

Settings are the same as for original script.

About where to set - your can pass them as any other params, when rendering widget. Also you can set some default settings for your application widgets in widgetFactory configuration

#9003 report it
fad at 2012/07/12 07:10am

How-to or where to set $settings declared var in TinyMce.php?

/** @var array Widget settings will override defaultSettings */
    public $settings = array();

Leave a comment

Please to leave your comment.

Create extension