protected function &getEditor() { // Only create the editor if it is not already created. if (empty($this->editor)) { // Initialize variables. $editor = null; // Get the editor type attribute. Can be in the form of: editor="desired|alternative". $type = trim((string) $this->element['editor']); if ($type) { // Get the list of editor types. $types = explode('|', $type); // Get the database object. $db = MFactory::getDBO(); // Iterate over teh types looking for an existing editor. foreach ($types as $element) { // Build the query. $query = $db->getQuery(true); $query->select('element'); $query->from('#__extensions'); $query->where('element = ' . $db->quote($element)); $query->where('folder = ' . $db->quote('editors')); $query->where('enabled = 1'); // Check of the editor exists. $db->setQuery($query, 0, 1); $editor = $db->loadResult(); // If an editor was found stop looking. if ($editor) { break; } } } // Create the MEditor instance based on the given editor. $this->editor = MFactory::getEditor($editor ? $editor : null); } return $this->editor; }