From: dongsheng Date: Fri, 1 Aug 2008 04:10:31 +0000 (+0000) Subject: MDL-13766, tell server side where file picker opened. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=3e515a9f734af15f9b08f9d8eecbe67e2e245209;p=moodle.git MDL-13766, tell server side where file picker opened. --- diff --git a/lib/editor/tinymce.js.php b/lib/editor/tinymce.js.php index 003ffbdf1a..4e17b7ef2a 100644 --- a/lib/editor/tinymce.js.php +++ b/lib/editor/tinymce.js.php @@ -207,7 +207,7 @@ echo <<getFrozenHtml(); } else { $ret = get_repository_client(); - return $this->_getTabs() . '_getAttrString($this->_attributes) . ' onclick=\'openpicker()\' />'.$ret['html'].$ret['js']; + return $this->_getTabs() . '_getAttrString($this->_attributes) . ' onclick=\'openpicker({"env":"form"})\' />'.$ret['html'].$ret['js']; } } } diff --git a/repository/ajax.php b/repository/ajax.php index bc433bb024..2e1eb752d5 100644 --- a/repository/ajax.php +++ b/repository/ajax.php @@ -41,7 +41,7 @@ $ret = get_repository_client();

Open the picker

-
+
diff --git a/repository/lib.php b/repository/lib.php index 64ee0b3bd7..33e19ac724 100644 --- a/repository/lib.php +++ b/repository/lib.php @@ -639,7 +639,7 @@ function get_repository_client(){ _client.loading(); var trans = YAHOO.util.Connect.asyncRequest('POST', '$CFG->wwwroot/repository/ws.php?id='+_client.repositoryid+'&action=download', - _client.dlfile, _client.postdata({'file':file, 'title':title})); + _client.dlfile, _client.postdata({'env':_client.env, 'file':file, 'title':title})); } _client.login = function(){ var obj = {}; @@ -653,6 +653,7 @@ function get_repository_client(){ obj[data[k].name] = el.value; } } + obj['env'] = _client.env; _client.loading(); var trans = YAHOO.util.Connect.asyncRequest('POST', '$CFG->wwwroot/repository/ws.php', _client.callback, @@ -704,7 +705,7 @@ function get_repository_client(){ _client.viewbar.set('disabled', false); _client.loading(); _client.repositoryid = id; - var trans = YAHOO.util.Connect.asyncRequest('GET', '$CFG->wwwroot/repository/ws.php?id='+id+'&p='+path+'&reset='+reset, _client.callback); + var trans = YAHOO.util.Connect.asyncRequest('GET', '$CFG->wwwroot/repository/ws.php?id='+id+'&p='+path+'&reset='+reset+'&env='+_client.env, _client.callback); } _client.search = function(id){ var data = window.prompt("What are you searching for?"); @@ -714,7 +715,7 @@ function get_repository_client(){ } _client.viewbar.set('disabled', false); _client.loading(); - var trans = YAHOO.util.Connect.asyncRequest('GET', '$CFG->wwwroot/repository/ws.php?id='+id+'&s='+data, _client.callback); + var trans = YAHOO.util.Connect.asyncRequest('GET', '$CFG->wwwroot/repository/ws.php?id='+id+'&s='+data+'&env='+_client.env, _client.callback); } return _client; })(); @@ -727,8 +728,9 @@ EOD; } $js .= <<repository_cache_expire = 60*60; -// repository id +// page +$p = optional_param('p', '', PARAM_RAW); +// id of repository $id = optional_param('id', 1, PARAM_INT); -// action of client -$action = optional_param('action', '', PARAM_RAW); -// Search text -$search = optional_param('s', '', PARAM_RAW); -// files to be downloaded +// opened in editor or moodleform +$env = optional_param('env', 'form', PARAM_RAW); +// file to download $file = optional_param('file', '', PARAM_RAW); +// rename the file name $title = optional_param('title', '', PARAM_RAW); -$p = optional_param('p', '', PARAM_RAW); +$action = optional_param('action', '', PARAM_RAW); +$search = optional_param('s', '', PARAM_RAW); if(!$repository = $DB->get_record('repository', array('id'=>$id))) { $err = new stdclass; @@ -74,8 +76,14 @@ if($action == 'list') { $entry->userid = $USER->id; $fs = get_file_storage(); if ($file = $fs->create_file_from_pathname($entry, $pathname)) { - //echo json_encode($file->get_content_file_location()); - echo json_encode($file->get_itemid()); + if($env == 'form'){ + // return reference id + echo json_encode($file->get_itemid()); + } elseif($env == 'editor') { + // return url + // echo json_encode($file->get_content_file_location()); + } else { + } } } catch (repository_exception $e){ $err = new stdclass;