1
0
mirror of https://github.com/moodle/moodle.git synced 2025-05-03 14:58:42 +02:00

"FORMSLIB,EDITOR/MDL-16698, add filepicker to editor element"

This commit is contained in:
dongsheng 2009-02-18 02:18:06 +00:00
parent 7c21a62597
commit 159840f02b
3 changed files with 38 additions and 13 deletions

@ -2,7 +2,6 @@
require_once('HTML/QuickForm/element.php'); require_once('HTML/QuickForm/element.php');
//TODO: //TODO:
// * locking // * locking
// * freezing // * freezing
@ -104,7 +103,7 @@ class MoodleQuickForm_editor extends HTML_QuickForm_element {
} }
function toHtml() { function toHtml() {
global $CFG; global $CFG, $COURSE;
if ($this->_flagFrozen) { if ($this->_flagFrozen) {
return $this->getFrozenHtml(); return $this->getFrozenHtml();
@ -178,21 +177,36 @@ class MoodleQuickForm_editor extends HTML_QuickForm_element {
$str .= '<object type="text/html" data="'.$editorurl.'" height="160" width="600" style="border:1px solid #000">Error</object>'; // TODO: localise, fix styles, etc. $str .= '<object type="text/html" data="'.$editorurl.'" height="160" width="600" style="border:1px solid #000">Error</object>'; // TODO: localise, fix styles, etc.
$str .= '</div>'; $str .= '</div>';
/// TODO: somehow pass 'itemid' to tinymce so that image chooser known where to look for and upload files, require_once($CFG->dirroot.'/repository/lib.php');
// also include list of expected file types handled by editor array('image', 'video', 'media') if(empty($COURSE->context)) {
// JS code by Dongsheng goes here - uncomment following block when finished $ctx = get_context_instance(CONTEXT_SYSTEM);
} else {
$ctx = $COURSE->context;
}
$ret = repository_get_client($ctx, array('image', 'video', 'media'), '*');
/// TODO: hide embedded file manager if tinymce used $suffix = $ret['suffix'];
/* if ($editorclass === 'form-textarea-advanced') { $str .= $ret['css'].$ret['js'];
$str .= '<script type="text/javascript"> $str .= <<<EOD
<script type="text/javascript">
id2suffix['$id']='$suffix';
id2itemid['$id']='$draftitemid';
</script>
EOD;
/// TODO: hide embedded file manager if tinymce used
if ($editorclass === 'form-textarea-advanced') {
$str .= <<<EOD
<script type="text/javascript">
//<![CDATA[ //<![CDATA[
var fileman = document.getElementById("'.$id.'_filemanager"); var fileman = document.getElementById("{$id}_filemanager");
fileman.style.visibility = "hidden"; fileman.style.visibility = "hidden";
fileman.style.height = "0"; fileman.style.height = "0";
//]]> //]]>
</script>'; </script>
EOD;
}*/ }
} }

@ -29,6 +29,7 @@ setTimeout('fix_column_widths()', 20);
<script type="text/javascript"> <script type="text/javascript">
//<![CDATA[ //<![CDATA[
var id2suffix = {}; var id2suffix = {};
var id2itemid = {};
<?php <?php
if (!empty($focus)) { if (!empty($focus)) {
if(($pos = strpos($focus, '.')) !== false) { if(($pos = strpos($focus, '.')) !== false) {

@ -491,6 +491,12 @@ _client.viewfiles = function() {
_client.viewthumb(); _client.viewthumb();
} }
} }
_client.print_msg = function(msg) {
_client.print_header();
var panel = new YAHOO.util.Element('panel-$suffix');
panel.get('element').innerHTML += msg;
_client.print_footer();
}
_client.print_header = function() { _client.print_header = function() {
var panel = new YAHOO.util.Element('panel-$suffix'); var panel = new YAHOO.util.Element('panel-$suffix');
var str = '<div id="fp-header-$suffix">'; var str = '<div id="fp-header-$suffix">';
@ -1046,6 +1052,8 @@ success: function(o) {
_client.ds = data; _client.ds = data;
if(!data) { if(!data) {
return; return;
}else if(data.msg){
_client.print_msg(data.msg);
}else if(data.iframe) { }else if(data.iframe) {
_client.viewiframe(); _client.viewiframe();
}else if(data.login) { }else if(data.login) {
@ -1116,6 +1124,8 @@ function openpicker_$suffix(params) {
repository_client_$suffix.target = params.target; repository_client_$suffix.target = params.target;
if(params.itemid){ if(params.itemid){
repository_client_$suffix.itemid = params.itemid; repository_client_$suffix.itemid = params.itemid;
} else if(tinyMCE && id2itemid[tinyMCE.selectedInstance.editorId]){
repository_client_$suffix.itemid = id2itemid[tinyMCE.selectedInstance.editorId];
} }
repository_client_$suffix.instance = new repository_client_$suffix(); repository_client_$suffix.instance = new repository_client_$suffix();
repository_client_$suffix.instance.create_picker(); repository_client_$suffix.instance.create_picker();