Source code for file /joomla/html/editor.php
Documentation is available at editor.php
* @version $Id: editor.php 13376 2009-10-29 01:44:22Z ian $
* @package Joomla.Framework
* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
// Check to ensure this file is within the rest of the framework
jimport('joomla.event.dispatcher');
* JEditor class to handle WYSIWYG editors
* @package Joomla.Framework
* Editor start and end tag
* Used to tell SEF plugin not to process editor contents
var $_tagForSEF =
array('start' =>
'<!-- Start Editor -->', 'end' =>
'<!-- End Editor -->');
* @param string The editor name
* Returns a reference to a global Editor object, only creating it
* if it doesn't already exist.
* This method must be invoked as:
* <pre> $editor = &JEditor::getInstance([$editor);</pre>
* @param string $editor The editor to use.
* @return JEditor The Editor object.
if (!isset
($instances)) {
if (empty ($instances[$signature])) {
$instances[$signature] =
new JEditor($editor);
return $instances[$signature];
//check if editor is already loaded
$args['event'] =
'onInit';
$results[] =
$this->_editor->update($args);
foreach ($results as $result) {
$document->addCustomTag($return);
* @param string The control name
* @param string The contents of the text area
* @param string The width of the text area (px or %)
* @param string The height of the text area (px or %)
* @param int The number of columns for the textarea
* @param int The number of rows for the textarea
* @param boolean True and the editor buttons will be displayed
* @param array Associative array of editor parameters
function display($name, $html, $width, $height, $col, $row, $buttons =
true, $params =
array())
$this->_loadEditor($params);
//check if 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['event'] =
'onDisplay';
$results[] =
$this->_editor->update($args);
foreach ($results as $result)
* Save the editor content
* @param string The name of the editor control
//check if editor is already loaded
$args['event'] =
'onSave';
$results[] =
$this->_editor->update($args);
foreach ($results as $result) {
* Get the editor contents
* @param string The name of the editor control
$args['event'] =
'onGetContent';
$results[] =
$this->_editor->update($args);
foreach ($results as $result) {
* Set the editor contents
* @param string The name of the editor control
* @param string The contents of the text area
$args['event'] =
'onSetContent';
$results[] =
$this->_editor->update($args);
foreach ($results as $result) {
* @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.
if(is_bool($buttons) &&
!$buttons) {
foreach($plugins as $plugin)
$className =
'plgButton'.
$plugin->name;
$plugin =
new $className($this, (array)
$plugin);
// Try to authenticate -- only add to array if authentication is successful
$resultTest =
$plugin->onDisplay($editor);
if ($resultTest) $result[] =
$resultTest;
* @param array Associative array of editor config paramaters
function _loadEditor($config =
array())
//check if editor is already loaded
// Build the path to the needed editor plugin
$path =
JPATH_SITE.
DS.
'plugins'.
DS.
'editors'.
DS.
$name.
'.php';
$message =
JText::_('Cannot load the editor');
$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