$editor = get_preferred_texteditor(FORMAT_HTML);
$editorclass = $editor->get_legacy_textarea_class();
+ $editor->use_editor($this->get_id());
return format_admin_setting($this, $this->visiblename,
'<div class="form-textarea"><textarea class="'.$editorclass.'" rows="'. $this->rows .'" cols="'. $this->cols .'" id="'. $this->get_id() .'" name="'. $this->get_full_name() .'">'. s($data) .'</textarea></div>',
return 'form-textarea-legacy';
}
- public function header_js() {
- return '';
+ public function use_editor($elementid=null) {
+ return;
}
}
return 'form-tinymce-legacy';
}
- public function header_js() {
- global $CFG;
-
+ public function use_editor($elementid=null) {
+ global $CFG, $PAGE;
$usehttps = (int)($CFG->httpswwwroot !== $CFG->wwwroot); //hmm, is there a better test?
-
- $js = '<script type="text/javascript" src="'.$CFG->httpswwwroot.'/lib/editor/tinymce/tiny_mce_src.js"></script>'."\n".
- '<script type="text/javascript" src="'.$CFG->httpswwwroot.'/lib/editor/tinymce/extra/tinymce.js.php?elanguage='.current_language().'&etheme='.current_theme().'&eusehttps='.$usehttps.'"></script>'."\n";
- return $js;
+
+ //TODO: requirements manager does not support parameters :-(
+
+ $PAGE->requires->js($CFG->httpswwwroot.'/lib/editor/tinymce/tiny_mce_src.js', true);
+ $PAGE->requires->js($CFG->httpswwwroot.'/lib/editor/tinymce/extra/tinymce.js.php?elanguage='.current_language().'&etheme='.current_theme().'&eusehttps='.$usehttps, true);
}
}
\ No newline at end of file
public abstract function get_legacy_textarea_class();
/**
- * Returns js script statements needed in html head.
- * @return string
+ * Add required JS needed for editor
+ * @return void
*/
- public abstract function header_js();
+ public abstract function use_editor($elementid=null);
}
/// print text area - TODO: add on-the-fly switching, size configuration, etc.
$editorclass = $editor->get_editor_element_class();
+ $editor->use_editor($id);
$str .= '<div><textarea class="'.$editorclass.'" id="'.$id.'" name="'.$elname.'[text]" rows="15" cols="80">';
$str .= s($text);
?>
//]]>
</script>
-<?php
- // editors integrations
- //TODO: optimize loading of editors
- if (empty($CFG->texteditors)) {
- $CFG->texteditors = 'tinymce,textarea';
- }
- $activeeditors = explode(',', $CFG->texteditors);
- foreach ($activeeditors as $editor) {
- if ($editor = get_texteditor($editor)) {
- echo $editor->header_js();
- }
- }
-?>
\ No newline at end of file
if ($usehtmleditor) {
$editor = get_preferred_texteditor(FORMAT_HTML);
$editorclass = $editor->get_legacy_textarea_class();
+ $editor->use_editor($id);
} else {
$editorclass = '';
}