Datamanager 2 TinyMCE driven textarea widget

As with all subclasses, the actual initialization is done in the initialize() function, not in the constructor, to allow for error handling.

This widget supports all types which have a simple, plain text representation accessible though their value member. The class will put HTML into those base types.

This type extends the regular textarea type, as this is the fallback for all cases where TinyMCE doesn't run (on Opera f.x.).

Available configuration options:

  • All of the textarea baseclass. The height default has been changed to 25, the width default to 80.
  • string mce_config_snippet: Indicates the name of the snippet which holds the base configuration. This is looked up in the DM2 directory in SG-Config. This defaults to midcom::get('config')->get('midcom_sgconfig_basedir') . '/midcom.helper.datamanager2/tinymce'. Any valid option for midcom_helper_misc::get_snippet_content() is allowed at this point.
  • string local_config: Local configuration options which should overwrite the defaults from the config snippet. This defaults to an empty string.
  • boolean tinymce_use_compressor: TinyMCE's PHP Compressor can help to reduce the page load time. Defaults to false.
  • theme use this to change between a simple and an advanced (i.e. more buttons) configuration of tinymce. Valid values: simple, advanced and tiny. The systemwide default for this value can be set in the tinymce_default_theme DM2 configuration option.
  • boolean use_imagepopup Defaults to yes. Use the imagepopup it the element is attached to an object.

  • string imagepopup_object If you want to override the normal object (f.x. to have a central attachments object). Set that object's guid here. NOTE: NOT IMPLEMENTED YET. MAY CHANGE!

Notes about TinyMCE configuration:

TinyMCE uses a JScript array, outlined in http://tinymce.moxiecode.com/tinymce/docs/reference_configuration.html to configure itself. A different configuration can be used for each textarea, as all of them are initialized individually. If the specified snippet is not used, some default configuration is used (see the private function _get_advanced_configuration).

Configuration is specified in an already JScript compatible way: The main config snippet is included verbatim, as is the information in the local_config option.

The following options must not be specified in any configuration: mode, elements, language

Be aware that this must be valid javascript code to be inserted into the Init function. Especially ensure that all lines end with a comma or the merging with the element-specific startup code will fail. This is important for both the config-snippet and the local config!

Example:

If you add this as the configuration snippet:

theme : "advanced",
cleanup: false,

... we will get this startup code:

tinyMCE.init({
  theme : "advanced",
  cleanup: false,
  mode: "textarea",
  ...
});

In case you have anything in local config, it will be added below the configuration snippet and above the element specific startup code. (Which is important if you specify the same key twice.)

package midcom.helper.datamanager2

 Methods

_add_initscript ($mode)

This helper will construct the TinyMCE initscript based on the specified configuration.

Parameters

$mode

_get_imagepopup_jsstring ()

Returns the string ,imagepopup that is added if we are editing a saved object (and thus can add attachments)

Returns

stringempty or containing ",imagepopup"

_on_configuring ()

This changes the defaults for the textarea size to something more usable for a WYSIWYG editor.

The systemwide defaults for the theme and the mce config snippet will be loaded from the config file at this point.

todo make overrideable.

_on_initialize ()

This is called during intialization the function is used to register the schema to a session key

Returns

booleanalways true

add_elements_to_form ($attributes)

Adds a simple single-line text form element at this time.

Note, that this is a copy of the base class function, as we need another CSS rule here besides the additional initialization code.

Parameters

$attributes

freeze ()

Freeze the tinymce content by replacing textarea form element

_add_external_html_elements ()

Adds the external HTML dependencies, both JS and CSS.

A static flag prevents multiple insertions of these dependencies.

_get_advanced_configuration ()

Returns the "advanced" configuration

_get_configuration ()

Returns the configuration theme based on the local_config_theme.

Returns

string

_get_simple_configuration ()

Returns the default/simple configuration:
theme : "advanced",
button_title_map : false,
apply_source_formatting : true,
plugins : "table,contextmenu,paste,fullscreen",
theme_advanced_buttons2_add : "separator,fullscreen,selectall,pastetext,pasteword,",
theme_advanced_buttons3_add : "separator,tablecontrols",
paste_create_linebreaks : false,

Returns

stringThe default configuration

_get_tiny_configuration ()

Returns the "tiny" configuration

 Properties

 

string $local_config

Local configuration to be added to the config snippet.
 

string $mce_config_snippet

The MCE configuration snippet to use.

Argument must be applicable to use with midcom_helper_misc::get_snippet_content.

 

string $theme

Define some simple configuration themes without having to create a config file.

valid values: simple, advanced or tiny

 

boolean $use_imagepopup

Should the imagepopup button be shown?