\CKEditor

\brief CKEditor class that can be used to create editor instances in PHP pages on server side.

Summary

Methods
Properties
Constants
CKEditor()
editor()
replace()
replaceAll()
addEventHandler()
clearEventHandlers()
addGlobalEventHandler()
clearGlobalEventHandlers()
script()
configSettings()
returnGlobalEvents()
init()
ckeditorPath()
jsEncode()
$version
$_timestamp
$basePath
$config
$initialized
$returnOutput
$textareaAttributes
$timestamp
$_events
$_globalEvents
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Properties

$version

$version : 

The version of %CKEditor.

\private

Type

$_timestamp

$_timestamp : 

A constant string unique for each release of %CKEditor.

\private

Type

$basePath

$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:

Type

$initialized

$initialized : 

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.

Type

$returnOutput

$returnOutput : 

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.

Type

$textareaAttributes

$textareaAttributes : 

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.

Type

$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.

Type

$_events

$_events : 

An array that holds event listeners.

\private

Type

$_globalEvents

$_globalEvents : 

An array that holds global event listeners.

\private

Type

Methods

CKEditor()

CKEditor(  $basePath = null) 

Main Constructor.

@param $basePath (string) URL to the %CKEditor installation directory (optional).

Parameters

$basePath

editor()

editor(  $name,   $value = "",   $config = array(),   $events = array()) 

Creates a %CKEditor instance.

In incompatible browsers %CKEditor will downgrade to plain HTML <textarea> element.

Parameters

$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:

replace()

replace(  $id,   $config = array(),   $events = array()) 

Replaces a &lt;textarea&gt; with a %CKEditor instance.

Parameters

$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:

replaceAll()

replaceAll(  $className = null) 

Replace all &lt;textarea&gt; elements available in the document with editor instances.

Parameters

$className

(string) If set, replace all textareas with class className in the page.

Example 1: replace all <textarea> elements in the page.

addEventHandler()

addEventHandler(  $event,   $javascriptCode) 

Adds event listener.

Events are fired by %CKEditor in various situations.

Parameters

$event

(string) Event name.

$javascriptCode

(string) Javascript anonymous function or function name.

Example usage:

clearEventHandlers()

clearEventHandlers(  $event = null) 

Clear registered event handlers.

Note: this function will have no effect on already created editor instances.

Parameters

$event

(string) Event name, if not set all event handlers will be removed (optional).

addGlobalEventHandler()

addGlobalEventHandler(  $event,   $javascriptCode) 

Adds global event listener.

Parameters

$event

(string) Event name.

$javascriptCode

(string) Javascript anonymous function or function name.

Example usage:

clearGlobalEventHandlers()

clearGlobalEventHandlers(  $event = null) 

Clear registered global event handlers.

Note: this function will have no effect if the event handler has been already printed/returned.

Parameters

$event

(string) Event name, if not set all event handlers will be removed (optional).

script()

script(string  $js) 

Prints javascript code.

\private

Parameters

string $js

configSettings()

configSettings(  $config = array(),   $events = array()) 

Returns the configuration array (global and instance specific settings are merged into one array).

\private

Parameters

$config

(array) The specific configurations to apply to editor instance.

$events

(array) Event listeners for editor instance.

returnGlobalEvents()

returnGlobalEvents() 

Return global event handlers.

\private

init()

init() 

Initializes CKEditor (executed only once).

\private

ckeditorPath()

ckeditorPath() 

Return path to ckeditor.js.

\private

jsEncode()

jsEncode(mixed  $val) : string

This little function provides a basic JSON support.

\private

Parameters

mixed $val

Returns

string