Moodle PHP Documentation 4.1
Moodle 4.1.11 (Build: 20240610) (c8c84b4af18)
tinymce_wrap Class Reference
Inheritance diagram for tinymce_wrap:
editor_tinymce_plugin

Public Member Functions

 get_buttons ()
 Returns list of buttons defined by this plugin.
 
 get_config ($name, $default=null)
 Returns plugin config value.
 
 get_name ()
 Returns name of this tinymce plugin.
 
 get_tinymce_file_url ($file='', $absolute=true)
 Returns URL to files in the TinyMCE folder within this plugin, suitable for client-side use such as loading JavaScript files.
 
 set_config ($name, $value)
 Sets plugin config value.
 

Static Public Member Functions

static all_update_init_params (array &$params, context $context, array $options=null)
 Calls all available plugins to adjust the TinyMCE init parameters.
 
static compare_plugins (editor_tinymce_plugin $a, editor_tinymce_plugin $b)
 Compares two plugins.
 
static get ($plugin)
 Gets a named plugin object.
 

Protected Member Functions

 add_button_after (array &$params, $row, $button, $after='', $alwaysadd=true)
 Adds a button to the editor, after another button (or at the end).
 
 add_button_before (array &$params, $row, $button, $before='', $alwaysadd=true)
 Adds a button to the editor.
 
 add_js_plugin (&$params, $pluginname='', $jsfile='editor_plugin.js')
 Adds a JavaScript plugin into TinyMCE.
 
 count_button_rows (array &$params)
 Counts the number of rows in TinyMCE editor (row numbering starts with 1)
 
 find_button (array &$params, $button)
 Tests if button is already present.
 
 get_sort_order ()
 Gets the order in which to run this plugin.
 
 get_version ()
 Obtains version number from version.php for this plugin.
 
 load_config ()
 Makes sure config is loaded and cached.
 
 update_init_params (array &$params, context $context, array $options=null)
 Adjusts TinyMCE init parameters for this plugin.
 

Protected Attributes

array $buttons = array('wrap')
 list of buttons defined by this plugin
 
array $config = null
 Plugin settings.
 
string $plugin
 Plugin folder.
 

Member Function Documentation

◆ add_button_after()

editor_tinymce_plugin::add_button_after ( array & $params,
$row,
$button,
$after = '',
$alwaysadd = true )
protectedinherited

Adds a button to the editor, after another button (or at the end).

Specify the location of this button using the $after variable. If you leave this blank, the button will be added at the end.

If you want to try different possible locations depending on existing plugins you can set $alwaysadd to false and check the return value to see if it succeeded.

Note: button will not be added if it is already present in any row (separator is an exception).

The following example will add the button 'newbutton' after the 'existingbutton' if it exists or in the end of the last row otherwise:

if ($row = $this->find_button($params, 'existingbutton')) {
    $this->add_button_after($params, $row, 'newbutton', 'existingbutton');
} else {
    $this->add_button_after($params, $this->count_button_rows($params), 'newbutton');
}
Parameters
array$paramsTinyMCE init parameters array
int$rowRow to add button to (1 to 3)
string$buttonIdentifier of button/plugin
string$afterAdds button directly after the named plugin
bool$alwaysaddIf specified $after string not found, add at end
Return values
boolTrue if added or button already exists (in any row)

◆ add_button_before()

editor_tinymce_plugin::add_button_before ( array & $params,
$row,
$button,
$before = '',
$alwaysadd = true )
protectedinherited

Adds a button to the editor.

Specify the location of this button using the $before variable. If you leave this blank, the button will be added at the start.

If you want to try different possible locations depending on existing plugins you can set $alwaysadd to false and check the return value to see if it succeeded.

Note: button will not be added if it is already present in any row (separator is an exception).

The following example will add the button 'newbutton' before the 'existingbutton' if it exists or in the end of the last row otherwise:

if ($row = $this->find_button($params, 'existingbutton')) {
    $this->add_button_before($params, $row, 'newbutton', 'existingbutton');
} else {
    $this->add_button_after($params, $this->count_button_rows($params), 'newbutton');
}
Parameters
array$paramsTinyMCE init parameters array
int$rowRow to add button to (1 to 10)
string$buttonIdentifier of button/plugin
string$beforeAdds button directly before the named plugin
bool$alwaysaddIf specified $before string not found, add at start
Return values
boolTrue if added or button already exists (in any row)

◆ add_js_plugin()

editor_tinymce_plugin::add_js_plugin ( & $params,
$pluginname = '',
$jsfile = 'editor_plugin.js' )
protectedinherited

Adds a JavaScript plugin into TinyMCE.

Note that adding a plugin does not by itself add a button; you must do both.

If you leave $pluginname blank (default) it uses the folder name.

Parameters
array$paramsTinyMCE init parameters array
string$pluginnameIdentifier for plugin within TinyMCE
string$jsfileName of JS file (within plugin 'tinymce' directory)

◆ all_update_init_params()

static editor_tinymce_plugin::all_update_init_params ( array & $params,
context $context,
array $options = null )
staticinherited

Calls all available plugins to adjust the TinyMCE init parameters.

Parameters
array$paramsTinyMCE init parameters array
context$contextContext where editor is being shown
array$optionsOptions for this editor

◆ compare_plugins()

static editor_tinymce_plugin::compare_plugins ( editor_tinymce_plugin $a,
editor_tinymce_plugin $b )
staticinherited

Compares two plugins.

Parameters
editor_tinymce_plugin$a
editor_tinymce_plugin$b
Return values
Negativenumber if $a is before $b

◆ count_button_rows()

editor_tinymce_plugin::count_button_rows ( array & $params)
protectedinherited

Counts the number of rows in TinyMCE editor (row numbering starts with 1)

Parameters
array$paramsTinyMCE init parameters array
Return values
intthe maximum existing row number

◆ find_button()

editor_tinymce_plugin::find_button ( array & $params,
$button )
protectedinherited

Tests if button is already present.

Parameters
array$paramsTinyMCE init parameters array
string$buttonbutton name
Return values
false|intfalse if button is not found, row number otherwise (row numbers start from 1)

◆ get()

static editor_tinymce_plugin::get ( $plugin)
staticinherited

Gets a named plugin object.

Will cause fatal error if plugin doesn't exist.

Parameters
string$pluginName of plugin e.g. 'moodleemoticon'
Return values
editor_tinymce_pluginPlugin object

◆ get_buttons()

editor_tinymce_plugin::get_buttons ( )
inherited

Returns list of buttons defined by this plugin.

useful mostly as information when setting custom toolbar.

Return values
array

◆ get_config()

editor_tinymce_plugin::get_config ( $name,
$default = null )
inherited

Returns plugin config value.

Parameters
string$name
string$defaultvalue if config does not exist yet
Return values
stringvalue or default

◆ get_name()

editor_tinymce_plugin::get_name ( )
inherited

Returns name of this tinymce plugin.

Return values
string

◆ get_sort_order()

editor_tinymce_plugin::get_sort_order ( )
protectedinherited

Gets the order in which to run this plugin.

Order usually only matters if (a) the place you add your button might depend on another plugin, or (b) you want to make some changes to layout etc. that should happen last. The default order is 100; within that, plugins are sorted alphabetically. Return a lower number if you want this plugin to run earlier, or a higher number if you want it to run later.

Reimplemented in tinymce_ctrlhelp, tinymce_managefiles, tinymce_moodleimage, tinymce_moodlemedia, and tinymce_pdw.

◆ get_tinymce_file_url()

editor_tinymce_plugin::get_tinymce_file_url ( $file = '',
$absolute = true )
inherited

Returns URL to files in the TinyMCE folder within this plugin, suitable for client-side use such as loading JavaScript files.

(This URL normally goes through loader.php and contains the plugin version to ensure correct and long-term cacheing.)

Parameters
string$fileFilename or path within the folder
bool$absoluteSet false to get relative URL from plugins folder

◆ get_version()

editor_tinymce_plugin::get_version ( )
protectedinherited

Obtains version number from version.php for this plugin.

Return values
stringVersion number

◆ load_config()

editor_tinymce_plugin::load_config ( )
protectedinherited

Makes sure config is loaded and cached.

Return values
void

◆ set_config()

editor_tinymce_plugin::set_config ( $name,
$value )
inherited

Sets plugin config value.

Parameters
string$namename of config
string$valuestring config value, null means delete
Return values
stringvalue

◆ update_init_params()

tinymce_wrap::update_init_params ( array & $params,
context $context,
array $options = null )
protected

Adjusts TinyMCE init parameters for this plugin.

Subclasses must implement this function in order to carry out changes to the TinyMCE settings.

Parameters
array$paramsTinyMCE init parameters array
context$contextContext where editor is being shown
array$optionsOptions for this editor

Reimplemented from editor_tinymce_plugin.


The documentation for this class was generated from the following file: