CKEditor class that can be used to create editor instances in PHP pages on server side. More...
Public Member Functions | |
__construct ($basePath=null) | |
textarea ($name, $value="", $attributes=array(), $config=array(), $events=array()) | |
replace ($id, $config=array(), $events=array()) | |
replaceAll ($className=null) | |
Data Fields | |
const | version = '%VERSION%' |
const | timestamp = '%TIMESTAMP%' |
$basePath | |
$timestamp = "%TIMESTAMP%" | |
$config = array() | |
$events = array() | |
$initialized = false |
CKEditor class that can be used to create editor instances in PHP pages on server side.
Sample usage:
$CKEditor = new CKEditor(); echo $CKEditor->textarea("editor1", "<p>Initial value.</p>");
__construct | ( | $ | basePath = null |
) |
Main Constructor.
$basePath | (string) URL to the CKEditor installation directory (optional). |
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(); echo $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(); echo $CKEditor->replaceAll();
Example 2: replace all <textarea class="myClassName"> elements in the page.
$CKEditor = new CKEditor(); echo $CKEditor->replaceAll( 'myClassName' );
textarea | ( | $ | name, | |
$ | value = "" , |
|||
$ | attributes = array() , |
|||
$ | config = array() , |
|||
$ | events = array() | |||
) |
Creates a <textarea> element with CKEditor enabled on it.
$name | (string) Name of the CKEditor instance (this will be also the "name" attribute of textarea element). | |
$value | (string) Initial value (optional). | |
$attributes | (array) An array with textarea attributes (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(); echo $CKEditor->textarea("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 (evt) { alert("Loaded: " + evt.editor.name); }'; echo $CKEditor->textarea("field1", "<p>Initial value.</p>", array("cols" => 60, "rows" => 8), $config, $events);
$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';
$events = array() |
An array that holds event listeners. Events are fired by CKEditor in various situations.
Example usage:
$CKEditor->events['dialogDefinition'] = 'function (evt) { alert("Loading dialog: " + ev.data.name); }';
$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.
$timestamp = "%TIMESTAMP%" |
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 = '%TIMESTAMP%' |
A constant string unique for each release of CKEditor.
const version = '%VERSION%' |
The version of CKEditor.