Source for file editor.php
Documentation is available at editor.php
* @package Joomla.Libraries
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
* JEditor class to handle WYSIWYG editors
* @package Joomla.Libraries
* An array of Observer objects to notify
* The state of the observable object
* A multi dimensional array of [function][] = key for observers
* @var array JEditor instances container.
protected static $instances =
array();
* @param string $editor The editor name
* Returns the global Editor object, only creating it
* if it doesn't already exist.
* @param string $editor The editor to use.
* @return JEditor The Editor object.
if (empty(self::$instances[$signature]))
self::$instances[$signature] =
new JEditor($editor);
return self::$instances[$signature];
* Get the state of the JEditor object
* @return mixed The state of the object.
* Attach an observer object
* @param object $observer An observer object to attach
public function attach($observer)
if (!isset
($observer['handler']) ||
!isset
($observer['event']) ||
!is_callable($observer['handler']))
// Make sure we haven't already attached this array as an observer
if (is_array($check) &&
$check['event'] ==
$observer['event'] &&
$check['handler'] ==
$observer['handler'])
$methods =
array($observer['event']);
if (!($observer instanceof
JEditor))
// Make sure we haven't already attached this object as an observer
if ($check instanceof
$class)
foreach ($methods as $method)
* Detach an observer object
* @param object $observer An observer object to detach.
* @return boolean True if the observer object was detached.
public function detach($observer)
// Check if editor is already loaded
$args['event'] =
'onInit';
$results[] =
$this->_editor->update($args);
foreach ($results as $result)
// @todo remove code: $return .= $result;
$document->addCustomTag($return);
* Display the editor area.
* @param string $name The control name.
* @param string $html The contents of the text area.
* @param string $width The width of the text area (px or %).
* @param string $height The height of the text area (px or %).
* @param integer $col The number of columns for the textarea.
* @param integer $row The number of rows for the textarea.
* @param boolean $buttons True and the editor buttons will be displayed.
* @param string $id An optional ID for the textarea (note: since 1.6). If not supplied the name is used.
* @param string $asset The object asset
* @param object $author The author.
* @param array $params Associative array of editor parameters.
public function display($name, $html, $width, $height, $col, $row, $buttons =
true, $id =
null, $asset =
null, $author =
null, $params =
array())
// Check whether editor is already loaded
// Backwards compatibility. Width and height should be passed without a semicolon from now on.
// If editor plugins need a unit like "px" for CSS styling, they need to take care of that
$args['content'] =
$html;
$args['height'] =
$height;
$args['buttons'] =
$buttons;
$args['id'] =
$id ?
$id :
$name;
$args['event'] =
'onDisplay';
$results[] =
$this->_editor->update($args);
foreach ($results as $result)
* Save the editor content
* @param string $editor The name of the editor control
public function save($editor)
// Check whether editor is already loaded
$args['event'] =
'onSave';
$results[] =
$this->_editor->update($args);
foreach ($results as $result)
* Get the editor contents
* @param string $editor The name of the editor control
$args['event'] =
'onGetContent';
$results[] =
$this->_editor->update($args);
foreach ($results as $result)
* Set the editor contents
* @param string $editor The name of the editor control
* @param string $html The contents of the text area
$args['event'] =
'onSetContent';
$results[] =
$this->_editor->update($args);
foreach ($results as $result)
* Get the editor extended buttons (usually from plugins)
* @param string $editor The name of the editor.
* @param mixed $buttons Can be boolean or array, if boolean defines if the buttons are
* displayed, if array defines a list of buttons not to show.
public function getButtons($editor, $buttons =
true)
if (is_bool($buttons) &&
!$buttons)
foreach ($plugins as $plugin)
$className =
'plgButton' .
$plugin->name;
$plugin =
new $className($this, (array)
$plugin);
if ($temp =
$plugin->onDisplay($editor, $this->asset, $this->author))
* @param array $config Associative array of editor config paramaters
// Check whether editor is already loaded
// Build the path to the needed editor plugin
$path =
JPATH_PLUGINS .
'/editors/' .
$name .
'/' .
$name .
'.php';
$params->loadString($plugin->params);
$params->loadArray($config);
$plugin->params =
$params;
// Build editor plugin classname
$name =
'plgEditor' .
$this->_name;
if ($this->_editor =
new $name($this, (array)
$plugin))
// Load plugin parameters
Documentation generated on Tue, 19 Nov 2013 15:02:14 +0100 by phpDocumentor 1.4.3