Example #1
0
 /**
  * Get the editor object.
  *
  * @return  object
  */
 public function instance()
 {
     try {
         $editor = App::get('editor');
     } catch (Exception $e) {
         $editor = \Hubzero\Html\Editor::getInstance('none');
     }
     return $editor;
 }
Example #2
0
 /**
  * Method to get a Editor object based on the form field.
  *
  * @return  object  The Editor object.
  */
 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 = App::get('db');
             // 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 JEditor instance based on the given editor.
         $this->editor = Wysiwyg::getInstance($editor ? $editor : App::get('config')->get('editor', 'none'));
     }
     return $this->editor;
 }