htmleditor and $CFG->defaulthtmleditor and $USER->htmleditor // * function get_preferred_texteditor($format=null) { global $CFG, $USER; if (empty($CFG->texteditors)) { $CFG->texteditors = 'tinymce,textarea'; } $active = explode(',', $CFG->texteditors); // TODO: implement user preferences for text editors // now find some plugin that supports format and is available $editor = false; foreach ($active as $editorname) { if (!$e = get_texteditor($editorname)) { continue; } if (!$e->supported_by_browser()) { // bad luck, this editor is not compatible continue; } if (!$supports = $e->get_supported_formats()) { continue; } if (is_null($format)) { // format does not matter $editor = $e; break; } if (in_array($format, $supports)) { // editor supports this format, yay! $editor = $e; break; } } if (!$editor) { $editor = get_texteditor('textarea'); // must exist and can edit anything } return $editor; } function get_texteditor($editor) { global $CFG; $libfile = "$CFG->libdir/editor/$editor/lib.php"; if (!file_exists($libfile)) { return false; } require_once($libfile); $classname = $editor.'_texteditor'; if (!class_exists($classname)) { return false; } return new $classname(); } /** * Get the list of available editors */ function get_available_editors() { $editors = array(); foreach (get_list_of_plugins('lib/editor') as $editor) { $editors['editor'] = get_string('modulename', 'editor_'.$editor); } return $editors; } /** * Base text editor class */ abstract class texteditor { public abstract function supported_by_browser(); public abstract function get_supported_formats(); public abstract function get_preferred_format(); public abstract function supports_repositories(); public abstract function get_editor_element_class(); public abstract function get_legacy_textarea_class(); public abstract function header_js(); } //=== DEPRECATED ===================== /** * Deprecated... */ function can_use_html_editor() { //TODO: eradicate completely return true; }