From: skodak Date: Mon, 16 Feb 2009 20:54:30 +0000 (+0000) Subject: MDL-16698 towarsd general editor element X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=7cdee7486dfea2dc64e5e6af93381f332481d742;p=moodle.git MDL-16698 towarsd general editor element --- diff --git a/lib/form/editor.php b/lib/form/editor.php index 2d18a16236..a07c39bffd 100644 --- a/lib/form/editor.php +++ b/lib/form/editor.php @@ -120,7 +120,7 @@ class MoodleQuickForm_editor extends HTML_QuickForm_element { $text = $this->_values['text']; $format = $this->_values['format']; - $itemid = $this->_values['itemid']; + $draftitemid = $this->_values['itemid']; // security - never ever allow guest/not logged in user to upload anything if (isguestuser() or !isloggedin()) { @@ -131,24 +131,29 @@ class MoodleQuickForm_editor extends HTML_QuickForm_element { $str .= '
'; - /// first print text area - TODO: add on-the-fly switching to tinymce, size configuration - $str .= '
'; - /// format option - TODO: ajax conversion and switching $formats = array(FORMAT_MOODLE=>'Moodle', FORMAT_HTML=>'HTML', FORMAT_PLAIN=>'Plaintext', FORMAT_WIKI=>'Wiki'); // TODO: localise & switch to new formats plugins if (!isset($formats[$format])) { - $format = FORMAT_MOODLE; + $format = FORMAT_HTML; // TODO: some user pref } + /// print text area - TODO: add on-the-fly switching to tinymce, size configuration + $editorclass = 'form-textarea'; + if ($format == FORMAT_HTML or $format == FORMAT_MOODLE) { + $editorclass = 'form-textarea-advanced'; + } + + $str .= '
'; + $str .= '
'; if ($changeformat) { $str .= ''; } else { @@ -157,20 +162,36 @@ class MoodleQuickForm_editor extends HTML_QuickForm_element { } $str .= '
'; - /// embedded image files - TODO: hide if tinymce used because it has own image upload/manage dialog if ($maxfiles != 0 ) { // 0 means no files, -1 unlimited if (empty($draftitemid)) { // no existing area info provided - let's use fresh new draft area require_once("$CFG->libdir/filelib.php"); $this->setValue(array('itemid'=>file_get_new_draftitemid())); - $itemid = $this->_values['itemid']; + $draftitemid = $this->_values['itemid']; } + $str .= '
'; - $str .= '
'; - $editorurl = "$CFG->wwwroot/files/draftfiles.php?itemid=$itemid&subdirs=$subdirs&maxbytes=$maxbytes"; - $str .= ''; + /// embedded image files - TODO: hide on the fly when switching editors + $str .= '
'; + $editorurl = "$CFG->wwwroot/files/draftfiles.php?itemid=$draftitemid&subdirs=$subdirs&maxbytes=$maxbytes"; $str .= 'Error'; // TODO: localise, fix styles, etc. $str .= '
'; + + /// TODO: somehow pass 'itemid' to tinymce so that image chooser known where to look for and upload files, + // also include list of expected file types handled by editor array('image', 'video', 'media') + // JS code by Dongsheng goes here + + /// TODO: hide embedded file manager if tinymce used + if ($editorclass === 'form-textarea-advanced') { + $str .= ''; + + } }