class HtmlEditorConfig (View source)

A PHP version of TinyMCE's configuration, to allow various parameters to be configured on a site or section basis

There can be multiple HtmlEditorConfig's, which should always be created / accessed using HtmlEditorConfig::get. You can then set the currently active config using set_active. Whichever config is active when HtmlEditorField#Field is called wins.

Properties

protected $settings

Holder for all TinyMCE settings except plugins and buttons

protected $plugins

Holder list of enabled plugins

protected $buttons

Holder list of buttons, organised by line

Methods

public static 
get($identifier = 'default')

Get the HtmlEditorConfig object for the given identifier. This is a correct way to get an HtmlEditorConfig instance - do not call 'new'

public static 
null
set_active($identifier = null)

Set the currently active configuration object

public static 
string
get_active_identifier()

Get the currently active configuration identifier

public static 
get_active()

Get the currently active configuration object

public static 
array
get_available_configs_map()

Get the available configurations as a map of friendly_name to configuration name.

public
mixed
getOption($k)

Get the current value of an option

public
setOption($k, $v)

Set the value of one option

public
setOptions($a)

Set multiple options

public
enablePlugins()

Enable one or several plugins. Will maintain unique list if already enabled plugin is re-passed. If passed in as a map of plugin-name to path, the plugin will be loaded by tinymce.PluginManager.load() instead of through tinyMCE.init().

public
disablePlugins()

Enable one or several plugins. Will properly handle being passed a plugin that is already disabled

public
array
getPlugins()

No description

public
setButtonsForLine()

Totally re-set the buttons on a given line

public
addButtonsToLine()

Add buttons to the end of a line

protected
bool
modifyButtons($name, $offset, $del = 0, $add = null)

Internal function for adding and removing buttons related to another button

public
bool
insertButtonsBefore()

Insert buttons before the first occurance of another button

public
bool
insertButtonsAfter()

Insert buttons after the first occurance of another button

public
null
removeButtons()

Remove the first occurance of buttons

public static 
require_js()

Generate the JavaScript that will set TinyMCE's configuration:

  • Parse all configurations into JSON objects to be used in JavaScript
  • Includes TinyMCE and configurations using the Requirements system

Details

static HtmlEditorConfig get($identifier = 'default')

Get the HtmlEditorConfig object for the given identifier. This is a correct way to get an HtmlEditorConfig instance - do not call 'new'

Parameters

$identifier

string - the identifier for the config set

Return Value

HtmlEditorConfig
  • the configuration object. This will be created if it does not yet exist for that identifier

static null set_active($identifier = null)

Set the currently active configuration object

Parameters

$identifier

string - the identifier for the config set

Return Value

null

static string get_active_identifier()

Get the currently active configuration identifier

Return Value

string
  • the active configuration identifier

static HtmlEditorConfig get_active()

Get the currently active configuration object

Return Value

HtmlEditorConfig
  • the active configuration object

static array get_available_configs_map()

Get the available configurations as a map of friendly_name to configuration name.

Return Value

array

mixed getOption($k)

Get the current value of an option

Parameters

$k

string - The key of the option to get

Return Value

mixed
  • The value of the specified option

HtmlEditorConfig setOption($k, $v)

Set the value of one option

Parameters

$k

string - The key of the option to set

$v

mixed - The value of the option to set

Return Value

HtmlEditorConfig

HtmlEditorConfig setOptions($a)

Set multiple options

Parameters

$a

array - The options to set, as keys and values of the array

Return Value

HtmlEditorConfig

HtmlEditorConfig enablePlugins()

Enable one or several plugins. Will maintain unique list if already enabled plugin is re-passed. If passed in as a map of plugin-name to path, the plugin will be loaded by tinymce.PluginManager.load() instead of through tinyMCE.init().

Keep in mind that these externals plugins require a dash-prefix in their name.

HtmlEditorConfig disablePlugins()

Enable one or several plugins. Will properly handle being passed a plugin that is already disabled

Return Value

HtmlEditorConfig

array getPlugins()

No description

Return Value

array

HtmlEditorConfig setButtonsForLine()

Totally re-set the buttons on a given line

Return Value

HtmlEditorConfig

HtmlEditorConfig addButtonsToLine()

Add buttons to the end of a line

Return Value

HtmlEditorConfig

protected bool modifyButtons($name, $offset, $del = 0, $add = null)

Internal function for adding and removing buttons related to another button

Parameters

$name

string The name of the button to modify

$offset

integer The offset relative to that button to perform an array_splice at - 0 for before $name, 1 for after

$del

integer The number of buttons to remove at the position given by index(string) + offset

$add

mixed An array or single item to insert at the position given by index(string) + offset, or null for no insertion

Return Value

bool

True if $name matched a button, false otherwise

bool insertButtonsBefore()

Insert buttons before the first occurance of another button

Return Value

bool
  • true if insertion occured, false if it did not (because the given button name was not found)

bool insertButtonsAfter()

Insert buttons after the first occurance of another button

Return Value

bool

True if insertion occured, false if it did not (because the given button name was not found)

null removeButtons()

Remove the first occurance of buttons

Return Value

null

static require_js()

Generate the JavaScript that will set TinyMCE's configuration:

  • Parse all configurations into JSON objects to be used in JavaScript
  • Includes TinyMCE and configurations using the Requirements system