PHP API Events
PHP API events will trigger functions within a PHP API plugin when an event occurs within the construction or display of the editor. Functions inside a PHP API plugin that have the same name as an event will be triggered when that event is fired. The functions are passed the current editor object which should be accepted by reference and optionally an associative array of data pertaining to the event. The function can then set properties and call methods of the editor object to alter its configuration and do something with any data passed to it in the array.
You can trigger an event by calling $editor->triggerEvent($name, $data); where $name is the name of the event you would like to trigger and $data is an associative array of data pertaining to the event.
Example:Lets image you want to create a PHP API plugin called 'myPlugin'
First create the plugin file:
wysiwygPro/plugins/myPlugin/plugin.php
<?php
if (!defined('IN_WPRO')) exit;
class wproPlugin_myPlugin {
// place functions here for all the events you want
// Here are some examples:
// this event function will fire when the plugin is loaded
function init(&$editor) {
// ensure that the snippets button is shown on the toolbar.
$editor->snippets = true;
}
// this event function will fire before the links dialog looks for links
function onBeforeGetLinks(&$editor) {
// Add some links that you can choose from when inserting a hyperlink:
$editor->links = array(
array('title'=>'Home', 'URL'=>'/'),
array('title'=>'About Us','URL'=>'/about/', 'children'=>array(
array('title'=>'Company History','URL'=>'/about/history.php'),
array('title'=>'Franchise Information','URL'=>'/about/franchise.php'),
array('title'=>'Shareholders Information','URL'=>'/about/shareholders.php'),
)),
array('title'=>'Services', 'URL'=>'/services/'),
array('title'=>'Contact Us', 'URL'=>'/contact/'),
);
}
// this event function will fire before the snippets dialog loads snippets:
function onBeforeGetSnippets(&$editor) {
// Add some snippets:
$editor->snippets = array(
'Company Logo' => '<img src="logo.gif">',
'Company Address' => '2/99 Nowhere Sreet, Nowhereville',
);
}
}
?>
To load the plugin named 'myPlugin' you would use the loadPlugin function:
$editor->loadPlugin('myPlugin');
PHP API Events
The following table lists available events:
|
Event Name |
Array Keys |
Description |
|---|---|---|
|
onLoadDialog |
empty |
Fires when a dialog window is opened just before the dialog plugin is loaded. |
|
onBeforeDisplayDialog |
empty |
Fires just before the dialog template is parsed. |
|
onAfterDisplayDialog |
empty |
Fires just after the dialog template is parsed and displayed. |
|
onBeforeMakeEditorProcess |
empty |
Called when display or fetch is called, before any of the editor's configuration is processed. |
|
onAfterFixHTML |
empty |
|
|
onBeforeMakeEditor |
empty |
Called after the editor configuration has been processed and just before the editor template is parsed. |
|
onAfterMakeEditor |
empty |
Called after the editor template has been parsed. |
|
onFileChooserButtonJS |
type field |
Can be used to change the file browser to one of your design. Any other required JavaScript tags can be output directly using an echo statement. |
|
onBeforeGetLinks |
empty |
Called before the links dialog loads the links property. See links for an example. |
|
onFileDelete |
directory directoryURL |
|
|
onEditImage |
directory directoryURL tempFile task options
|
|
|
onFileMove |
srcDirectory |
|
|
onFileCopy |
srcDirectory |
|
|
onNewFolder |
directory directoryURL
|
|
|
onFileRename |
directory directoryURL
|
|
|
onUpload |
directory directoryURL
|
|
|
onBeforeGetSnippets |
empty |
Called just before the snippet dialog loads the snippets. See snippets for an example. |
Contents
This online documentation specifically covers version 3.0 and above, developers using earlier versions should refer to their PDF or MS-Word manual that was included in the product download.
