mirror of
https://github.com/moodle/moodle.git
synced 2025-05-04 15:27:34 +02:00
MDL-13766, tell server side where file picker opened.
This commit is contained in:
parent
6cbb4efbdd
commit
3e515a9f73
@ -207,7 +207,7 @@ echo <<<EOF
|
||||
tinyMCE.execCommand('mceToggleEditor',false,id);
|
||||
}
|
||||
function mce_moodlefilemanager(field_name, url, type, win) {
|
||||
openpicker();
|
||||
openpicker({'env':'editor'});
|
||||
}
|
||||
function mce_saveOnSubmit(id) {
|
||||
var prevOnSubmit = document.getElementById(id).form.onsubmit;
|
||||
|
@ -45,7 +45,7 @@ class MoodleQuickForm_filepicker extends HTML_QuickForm_button
|
||||
return $this->getFrozenHtml();
|
||||
} else {
|
||||
$ret = get_repository_client();
|
||||
return $this->_getTabs() . '<input' . $this->_getAttrString($this->_attributes) . ' onclick=\'openpicker()\' />'.$ret['html'].$ret['js'];
|
||||
return $this->_getTabs() . '<input' . $this->_getAttrString($this->_attributes) . ' onclick=\'openpicker({"env":"form"})\' />'.$ret['html'].$ret['js'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ $ret = get_repository_client();
|
||||
<body class=" yui-skin-sam">
|
||||
<div id='control'>
|
||||
<h1>Open the picker</h1>
|
||||
<input type="button" id="con1" onclick='openpicker()' value="Open File Picker" style="font-size: 24px;padding: 1em" /> <br/>
|
||||
<input type="button" id="con1" onclick='openpicker({"env":"form"})' value="Open File Picker" style="font-size: 24px;padding: 1em" /> <br/>
|
||||
<input type='hidden' id="result">
|
||||
</div>
|
||||
<div>
|
||||
|
@ -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 .= <<<EOD
|
||||
function openpicker() {
|
||||
function openpicker(obj) {
|
||||
if(!repository_client.instance) {
|
||||
repository_client.env = obj.env;
|
||||
repository_client.instance = new repository_client();
|
||||
repository_client.instance.create_picker();
|
||||
} else {
|
||||
|
@ -5,16 +5,18 @@ require_once('../lib/filelib.php');
|
||||
require_once('lib.php');
|
||||
// set one hour here
|
||||
$CFG->repository_cache_expire = 60*60;
|
||||
// repository id
|
||||
$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
|
||||
$file = optional_param('file', '', PARAM_RAW);
|
||||
$title = optional_param('title', '', PARAM_RAW);
|
||||
// page
|
||||
$p = optional_param('p', '', PARAM_RAW);
|
||||
// id of repository
|
||||
$id = optional_param('id', 1, PARAM_INT);
|
||||
// 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);
|
||||
$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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user