splittingred / TinyMCE

TinyMCE integration for MODx Revolution.
http://svn.modxcms.com/docs/display/ADDON/TinyMCE
35 stars 19 forks source link

Feature: Setting for "blockformats" (determines which HTML block elements can be chosen) #14

Closed enigmatic-user closed 14 years ago

enigmatic-user commented 14 years ago

I'd really like to be able to limit the HTML block elements that can be chosen (p, h1-h6, div, blockquote etc.) for some of my clients to prevent them from misusing these options (see http://bugs.modx.com/browse/TINYMCE-77, too - I'm not sure if the project is still maintained in that issue tracker).

To accomplish this, I modified the following files:

/core/components/tinymce/tinymce.class.php

public function setProperties(array $properties = array()) {
    $browserAction = $this->_getBrowserAction();
    $this->properties = array_merge(array(

[...]

        // This line has been changed:
        'theme_advanced_blockformats' => $this->modx->getOption('tiny.blockformats',null,'p,h1,h2,h3,h4,h5,h6,div,blockquote,code,pre,address'),

[...]

    ),$properties);

    /* now do user/context/system setting overrides - these must override properties */
    $this->properties = array_merge($this->properties,array(

[...]

        // This line has been added:
        'theme_advanced_blockformats' => $this->modx->getOption('tiny.blockformats',$this->properties,'p,h1,h2,h3,h4,h5,h6,div,blockquote,code,pre,address'),

[...]

    ));
}

/assets/components/tinymce/tinymce.panel.js

Tiny.Editor = function(config) {
    config = config || {};
    config.tinyConfig = config.tinyConfig || Tiny.config;
    config.tinyConfig = config.tinyConfig || {};
    Ext.applyIf(config.tinyConfig,{
        setup: (function(ed) {
            ed.onInit.add(this.onLoad);
            ed.onKeyUp.add(this.onChange);
        }).createDelegate(this)
        ,apply_source_formatting: true

[...]

        // This line has been changed:
        ,theme_advanced_blockformats: MODx.config['tiny.blockformats']

[...]

    });

/core/components/tinymce/lexicon/en/default.inc.php

// These lines have been added:
$_lang['setting_tiny.blockformats'] = 'HTML block elements';
$_lang['setting_tiny.blockformats_desc'] = 'A comma separated list of HTML block elements. Possible values are: p, h1, h2, h3, h4, h5, h6, div, blockquote, code, pre, address.';

/core/components/tinymce/lexicon/de/default.inc.php

// These lines have been added:
$_lang['setting_tiny.blockformats'] = 'HTML-Blockelemente';
$_lang['setting_tiny.blockformats_desc'] = 'Eine kommaseparierte Liste von HTML-Blockelementen. Mögliche Werte sind: p, h1, h2, h3, h4, h5, h6, div, blockquote, code, pre, address.';

This has to be done for the other languages, too, of course. ;)

Finally I added the system setting for this to the system_settings database table:

Database entry in table system_settings

key:       tiny.blockformats
value:     p,h1,h2,h3,h4,h5,h6,div,blockquote,code,pre,address
xtype:     textfield
namespace: tinymce
area:      tinymce

I'd be happy if this could be taken over into the official TinyMCE package. ;)