CKEditor class that can be used to create editor instances in PHP pages on server side. Mehr ...
Öffentliche Methoden | |
CKEditor ($basePath=null) | |
editor ($name, $value="", $config=array(), $events=array()) | |
replace ($id, $config=array(), $events=array()) | |
replaceAll ($className=null) | |
addEventHandler ($event, $javascriptCode) | |
clearEventHandlers ($event=null) | |
addGlobalEventHandler ($event, $javascriptCode) | |
clearGlobalEventHandlers ($event=null) | |
__construct ($basePath=null) | |
editor ($name, $value="", $config=array(), $events=array()) | |
replace ($id, $config=array(), $events=array()) | |
replaceAll ($className=null) | |
addEventHandler ($event, $javascriptCode) | |
clearEventHandlers ($event=null) | |
addGlobalEventHandler ($event, $javascriptCode) | |
clearGlobalEventHandlers ($event=null) | |
Datenfelder | |
$basePath | |
$config = array() | |
$initialized = false | |
$returnOutput = false | |
$textareaAttributes = array( "rows" => 8, "cols" => 60 ) | |
$timestamp = "ABLC4TW" | |
const | version = '3.5' |
const | timestamp = 'ABLC4TW' |
CKEditor class that can be used to create editor instances in PHP pages on server side.
Sample usage:
$CKEditor = new CKEditor(); $CKEditor->editor("editor1", "<p>Initial value.</p>");
__construct | ( | $ | basePath = null |
) |
Main Constructor.
$basePath | (string) URL to the CKEditor installation directory (optional). |
addEventHandler | ( | $ | event, | |
$ | javascriptCode | |||
) |
Adds event listener. Events are fired by CKEditor in various situations.
$event | (string) Event name. | |
$javascriptCode | (string) Javascript anonymous function or function name. |
Example usage:
$CKEditor->addEventHandler('instanceReady', 'function (ev) { alert("Loaded: " + ev.editor.name); }');
addEventHandler | ( | $ | event, | |
$ | javascriptCode | |||
) |
Adds event listener. Events are fired by CKEditor in various situations.
$event | (string) Event name. | |
$javascriptCode | (string) Javascript anonymous function or function name. |
Example usage:
$CKEditor->addEventHandler('instanceReady', 'function (ev) { alert("Loaded: " + ev.editor.name); }');
addGlobalEventHandler | ( | $ | event, | |
$ | javascriptCode | |||
) |
Adds global event listener.
$event | (string) Event name. | |
$javascriptCode | (string) Javascript anonymous function or function name. |
Example usage:
$CKEditor->addGlobalEventHandler('dialogDefinition', 'function (ev) { alert("Loading dialog: " + ev.data.name); }');
addGlobalEventHandler | ( | $ | event, | |
$ | javascriptCode | |||
) |
Adds global event listener.
$event | (string) Event name. | |
$javascriptCode | (string) Javascript anonymous function or function name. |
Example usage:
$CKEditor->addGlobalEventHandler('dialogDefinition', 'function (ev) { alert("Loading dialog: " + ev.data.name); }');
CKEditor | ( | $ | basePath = null |
) |
Main Constructor.
$basePath | (string) URL to the CKEditor installation directory (optional). |
clearEventHandlers | ( | $ | event = null |
) |
Clear registered event handlers. Note: this function will have no effect on already created editor instances.
$event | (string) Event name, if not set all event handlers will be removed (optional). |
clearEventHandlers | ( | $ | event = null |
) |
Clear registered event handlers. Note: this function will have no effect on already created editor instances.
$event | (string) Event name, if not set all event handlers will be removed (optional). |
clearGlobalEventHandlers | ( | $ | event = null |
) |
Clear registered global event handlers. Note: this function will have no effect if the event handler has been already printed/returned.
$event | (string) Event name, if not set all event handlers will be removed (optional). |
clearGlobalEventHandlers | ( | $ | event = null |
) |
Clear registered global event handlers. Note: this function will have no effect if the event handler has been already printed/returned.
$event | (string) Event name, if not set all event handlers will be removed (optional). |
editor | ( | $ | name, | |
$ | value = "" , |
|||
$ | config = array() , |
|||
$ | events = array() | |||
) |
Creates a CKEditor instance. In incompatible browsers CKEditor will downgrade to plain HTML <textarea> element.
$name | (string) Name of the CKEditor instance (this will be also the "name" attribute of textarea element). | |
$value | (string) Initial value (optional). | |
$config | (array) The specific configurations to apply to this editor instance (optional). | |
$events | (array) Event listeners for this editor instance (optional). |
Example usage:
$CKEditor = new CKEditor(); $CKEditor->editor("field1", "<p>Initial value.</p>");
Advanced example:
$CKEditor = new CKEditor(); $config = array(); $config['toolbar'] = array( array( 'Source', '-', 'Bold', 'Italic', 'Underline', 'Strike' ), array( 'Image', 'Link', 'Unlink', 'Anchor' ) ); $events['instanceReady'] = 'function (ev) { alert("Loaded: " + ev.editor.name); }'; $CKEditor->editor("field1", "<p>Initial value.</p>", $config, $events);
editor | ( | $ | name, | |
$ | value = "" , |
|||
$ | config = array() , |
|||
$ | events = array() | |||
) |
Creates a CKEditor instance. In incompatible browsers CKEditor will downgrade to plain HTML <textarea> element.
$name | (string) Name of the CKEditor instance (this will be also the "name" attribute of textarea element). | |
$value | (string) Initial value (optional). | |
$config | (array) The specific configurations to apply to this editor instance (optional). | |
$events | (array) Event listeners for this editor instance (optional). |
Example usage:
$CKEditor = new CKEditor(); $CKEditor->editor("field1", "<p>Initial value.</p>");
Advanced example:
$CKEditor = new CKEditor(); $config = array(); $config['toolbar'] = array( array( 'Source', '-', 'Bold', 'Italic', 'Underline', 'Strike' ), array( 'Image', 'Link', 'Unlink', 'Anchor' ) ); $events['instanceReady'] = 'function (ev) { alert("Loaded: " + ev.editor.name); }'; $CKEditor->editor("field1", "<p>Initial value.</p>", $config, $events);
replace | ( | $ | id, | |
$ | config = array() , |
|||
$ | events = array() | |||
) |
Replaces a <textarea> with a CKEditor instance.
$id | (string) The id or name of textarea element. | |
$config | (array) The specific configurations to apply to this editor instance (optional). | |
$events | (array) Event listeners for this editor instance (optional). |
Example 1: adding CKEditor to <textarea name="article"></textarea> element:
$CKEditor = new CKEditor(); $CKEditor->replace("article");
replace | ( | $ | id, | |
$ | config = array() , |
|||
$ | events = array() | |||
) |
Replaces a <textarea> with a CKEditor instance.
$id | (string) The id or name of textarea element. | |
$config | (array) The specific configurations to apply to this editor instance (optional). | |
$events | (array) Event listeners for this editor instance (optional). |
Example 1: adding CKEditor to <textarea name="article"></textarea> element:
$CKEditor = new CKEditor(); $CKEditor->replace("article");
replaceAll | ( | $ | className = null |
) |
Replace all <textarea> elements available in the document with editor instances.
$className | (string) If set, replace all textareas with class className in the page. |
Example 1: replace all <textarea> elements in the page.
$CKEditor = new CKEditor(); $CKEditor->replaceAll();
Example 2: replace all <textarea class="myClassName"> elements in the page.
$CKEditor = new CKEditor(); $CKEditor->replaceAll( 'myClassName' );
replaceAll | ( | $ | className = null |
) |
Replace all <textarea> elements available in the document with editor instances.
$className | (string) If set, replace all textareas with class className in the page. |
Example 1: replace all <textarea> elements in the page.
$CKEditor = new CKEditor(); $CKEditor->replaceAll();
Example 2: replace all <textarea class="myClassName"> elements in the page.
$CKEditor = new CKEditor(); $CKEditor->replaceAll( 'myClassName' );
$basePath |
URL to the CKEditor installation directory (absolute or relative to document root). If not set, CKEditor will try to guess it's path.
Example usage:
$CKEditor->basePath = '/ckeditor/';
$config = array() |
An array that holds the global CKEditor configuration. For the list of available options, see http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html
Example usage:
$CKEditor->config['height'] = 400; // Use @@ at the beggining of a string to ouput it without surrounding quotes. $CKEditor->config['width'] = '@@screen.width * 0.8';
$initialized = false |
A boolean variable indicating whether CKEditor has been initialized. Set it to true only if you have already included <script> tag loading ckeditor.js in your website.
$returnOutput = false |
Boolean variable indicating whether created code should be printed out or returned by a function.
Example 1: get the code creating CKEditor instance and print it on a page with the "echo" function.
$CKEditor = new CKEditor(); $CKEditor->returnOutput = true; $code = $CKEditor->editor("editor1", "<p>Initial value.</p>"); echo "<p>Editor 1:</p>"; echo $code;
$textareaAttributes = array( "rows" => 8, "cols" => 60 ) |
An array with textarea attributes.
When CKEditor is created with the editor() method, a HTML <textarea> element is created, it will be displayed to anyone with JavaScript disabled or with incompatible browser.
$timestamp = "ABLC4TW" |
A string indicating the creation date of CKEditor. Do not change it unless you want to force browsers to not use previously cached version of CKEditor.
const timestamp = 'ABLC4TW' |
A constant string unique for each release of CKEditor.
const version = '3.5' |
The version of CKEditor.