Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
|
Public Member Functions | |
__construct ($plugin) | |
get_buttons () | |
Returns list of buttons defined by this plugin. More... | |
get_config ($name, $default=null) | |
Returns plugin config value. More... | |
get_name () | |
Returns name of this tinymce plugin. More... | |
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. More... | |
set_config ($name, $value) | |
Sets plugin config value. More... | |
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. More... | |
static | compare_plugins (editor_tinymce_plugin $a, editor_tinymce_plugin $b) |
Compares two plugins. More... | |
static | get ($plugin) |
Gets a named plugin object. More... | |
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). More... | |
add_button_before (array &$params, $row, $button, $before='', $alwaysadd=true) | |
Adds a button to the editor. More... | |
add_js_plugin (&$params, $pluginname='', $jsfile='editor_plugin.js') | |
Adds a JavaScript plugin into TinyMCE. More... | |
count_button_rows (array &$params) | |
Counts the number of rows in TinyMCE editor (row numbering starts with 1) More... | |
find_button (array &$params, $button) | |
Tests if button is already present. More... | |
get_sort_order () | |
Gets the order in which to run this plugin. More... | |
get_version () | |
Obtains version number from version.php for this plugin. More... | |
load_config () | |
Makes sure config is loaded and cached. More... | |
update_init_params (array &$params, context $context, array $options=null) | |
Adjusts TinyMCE init parameters for this plugin. More... | |
Protected Attributes | |
array | $buttons = array() |
list of buttons defined by this plugin | |
array | $config = null |
Plugin settings. | |
string | $plugin |
Plugin folder. | |
editor_tinymce_plugin::__construct | ( | $plugin | ) |
string | $plugin | Name of folder |
|
protected |
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'); }
array | $params | TinyMCE init parameters array |
int | $row | Row to add button to (1 to 3) |
string | $button | Identifier of button/plugin |
string | $after | Adds button directly after the named plugin |
bool | $alwaysadd | If specified $after string not found, add at end |
bool | True if added or button already exists (in any row) |
|
protected |
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'); }
array | $params | TinyMCE init parameters array |
int | $row | Row to add button to (1 to 10) |
string | $button | Identifier of button/plugin |
string | $before | Adds button directly before the named plugin |
bool | $alwaysadd | If specified $before string not found, add at start |
bool | True if added or button already exists (in any row) |
|
protected |
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.
array | $params | TinyMCE init parameters array |
string | $pluginname | Identifier for plugin within TinyMCE |
string | $jsfile | Name of JS file (within plugin 'tinymce' directory) |
|
static |
Calls all available plugins to adjust the TinyMCE init parameters.
array | $params | TinyMCE init parameters array |
context | $context | Context where editor is being shown |
array | $options | Options for this editor |
|
static |
Compares two plugins.
editor_tinymce_plugin | $a | |
editor_tinymce_plugin | $b |
Negative | number if $a is before $b |
|
protected |
Counts the number of rows in TinyMCE editor (row numbering starts with 1)
array | $params | TinyMCE init parameters array |
int | the maximum existing row number |
|
protected |
Tests if button is already present.
array | $params | TinyMCE init parameters array |
string | $button | button name |
false|int | false if button is not found, row number otherwise (row numbers start from 1) |
|
static |
Gets a named plugin object.
Will cause fatal error if plugin doesn't exist.
string | $plugin | Name of plugin e.g. 'moodleemoticon' |
editor_tinymce_plugin | Plugin object |
editor_tinymce_plugin::get_buttons | ( | ) |
Returns list of buttons defined by this plugin.
useful mostly as information when setting custom toolbar.
array |
editor_tinymce_plugin::get_config | ( | $name, | |
$default = null |
|||
) |
Returns plugin config value.
string | $name | |
string | $default | value if config does not exist yet |
string | value or default |
editor_tinymce_plugin::get_name | ( | ) |
Returns name of this tinymce plugin.
string |
|
protected |
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.
editor_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.
(This URL normally goes through loader.php and contains the plugin version to ensure correct and long-term cacheing.)
string | $file | Filename or path within the folder |
bool | $absolute | Set false to get relative URL from plugins folder |
|
protected |
Obtains version number from version.php for this plugin.
string | Version number |
|
protected |
Makes sure config is loaded and cached.
void |
editor_tinymce_plugin::set_config | ( | $name, | |
$value | |||
) |
Sets plugin config value.
string | $name | name of config |
string | $value | string config value, null means delete |
string | value |
|
abstractprotected |
Adjusts TinyMCE init parameters for this plugin.
Subclasses must implement this function in order to carry out changes to the TinyMCE settings.
array | $params | TinyMCE init parameters array |
context | $context | Context where editor is being shown |
array | $options | Options for this editor |