mirror of
https://github.com/moodle/moodle.git
synced 2025-04-26 19:03:38 +02:00
"FORMSLIB,EDITOR/MDL-16698, add filepicker to editor element"
This commit is contained in:
parent
7c21a62597
commit
159840f02b
@ -2,7 +2,6 @@
|
||||
|
||||
require_once('HTML/QuickForm/element.php');
|
||||
|
||||
|
||||
//TODO:
|
||||
// * locking
|
||||
// * freezing
|
||||
@ -104,7 +103,7 @@ class MoodleQuickForm_editor extends HTML_QuickForm_element {
|
||||
}
|
||||
|
||||
function toHtml() {
|
||||
global $CFG;
|
||||
global $CFG, $COURSE;
|
||||
|
||||
if ($this->_flagFrozen) {
|
||||
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 .= '</div>';
|
||||
|
||||
/// 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 - uncomment following block when finished
|
||||
require_once($CFG->dirroot.'/repository/lib.php');
|
||||
if(empty($COURSE->context)) {
|
||||
$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
|
||||
/* if ($editorclass === 'form-textarea-advanced') {
|
||||
$str .= '<script type="text/javascript">
|
||||
$suffix = $ret['suffix'];
|
||||
$str .= $ret['css'].$ret['js'];
|
||||
$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[
|
||||
var fileman = document.getElementById("'.$id.'_filemanager");
|
||||
fileman.style.visibility = "hidden";
|
||||
fileman.style.height = "0";
|
||||
var fileman = document.getElementById("{$id}_filemanager");
|
||||
fileman.style.visibility = "hidden";
|
||||
fileman.style.height = "0";
|
||||
//]]>
|
||||
</script>';
|
||||
</script>
|
||||
EOD;
|
||||
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -29,6 +29,7 @@ setTimeout('fix_column_widths()', 20);
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
var id2suffix = {};
|
||||
var id2itemid = {};
|
||||
<?php
|
||||
if (!empty($focus)) {
|
||||
if(($pos = strpos($focus, '.')) !== false) {
|
||||
|
@ -491,6 +491,12 @@ _client.viewfiles = function() {
|
||||
_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() {
|
||||
var panel = new YAHOO.util.Element('panel-$suffix');
|
||||
var str = '<div id="fp-header-$suffix">';
|
||||
@ -1046,6 +1052,8 @@ success: function(o) {
|
||||
_client.ds = data;
|
||||
if(!data) {
|
||||
return;
|
||||
}else if(data.msg){
|
||||
_client.print_msg(data.msg);
|
||||
}else if(data.iframe) {
|
||||
_client.viewiframe();
|
||||
}else if(data.login) {
|
||||
@ -1116,6 +1124,8 @@ function openpicker_$suffix(params) {
|
||||
repository_client_$suffix.target = params.target;
|
||||
if(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.create_picker();
|
||||
|
Loading…
x
Reference in New Issue
Block a user