MDL-22982, fixed file browser renderer component
This commit is contained in:
@@ -34,7 +34,6 @@ $action = optional_param('action', 'list', PARAM_ALPHA);
|
||||
require_login();
|
||||
|
||||
$err = new stdclass;
|
||||
|
||||
if (isguestuser()) {
|
||||
$err->error = get_string('noguest');
|
||||
die(json_encode($err));
|
||||
@@ -43,7 +42,6 @@ if (isguestuser()) {
|
||||
switch ($action) {
|
||||
// used by course file tree viewer
|
||||
case 'getfiletree':
|
||||
|
||||
$contextid = required_param('contextid', PARAM_INT);
|
||||
$component = required_param('component', PARAM_ALPHAEXT);
|
||||
$filearea = required_param('filearea', PARAM_ALPHAEXT);
|
||||
@@ -51,13 +49,6 @@ switch ($action) {
|
||||
$filepath = required_param('filepath', PARAM_PATH);
|
||||
|
||||
$browser = get_file_browser();
|
||||
$params = $url->params();
|
||||
// fix empty value
|
||||
foreach ($params as $key=>$value) {
|
||||
if ($value==='') {
|
||||
$params[$key] = null;
|
||||
}
|
||||
}
|
||||
$fileinfo = $browser->get_file_info(get_context_instance_by_id($contextid), $component, $filearea, $itemid, $filepath);
|
||||
$children = $fileinfo->get_children();
|
||||
$tree = array();
|
||||
@@ -75,14 +66,13 @@ switch ($action) {
|
||||
);
|
||||
if ($child->is_directory()) {
|
||||
$fileitem['isdir'] = true;
|
||||
$fileitem['url'] = $url->out();
|
||||
$fileitem['url'] = $url->out(false);
|
||||
} else {
|
||||
$fileitem['url'] = $child->get_url();
|
||||
}
|
||||
$tree[] = $fileitem;
|
||||
}
|
||||
echo json_encode($tree);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
+18
-2
@@ -6,7 +6,12 @@ M.core_filetree = {
|
||||
request: function(url, node, cb) {
|
||||
var api = this.api + '?action=getfiletree';
|
||||
var params = [];
|
||||
params['fileurl'] = url;
|
||||
params['contextid'] = this.get_param(url, 'contextid', -1);
|
||||
params['component'] = this.get_param(url, 'component', null);
|
||||
params['filearea'] = this.get_param(url, 'filearea', null);
|
||||
params['itemid'] = this.get_param(url, 'itemid', -1);
|
||||
params['filepath'] = this.get_param(url, 'filepath', null);
|
||||
params['filename'] = this.get_param(url, 'filename', null);
|
||||
var scope = this;
|
||||
params['sesskey']=M.cfg.sesskey;
|
||||
var cfg = {
|
||||
@@ -50,7 +55,7 @@ M.core_filetree = {
|
||||
};
|
||||
this.y3.io(api, cfg);
|
||||
},
|
||||
init : function(Y, options){
|
||||
init : function(Y){
|
||||
var tree = new YAHOO.widget.TreeView('course-file-tree-view');
|
||||
tree.setDynamicLoad(this.dynload);
|
||||
tree.subscribe("clickEvent", this.onclick);
|
||||
@@ -71,5 +76,16 @@ M.core_filetree = {
|
||||
},
|
||||
onclick: function(e) {
|
||||
YAHOO.util.Event.preventDefault(e);
|
||||
},
|
||||
get_param: function(url, name, val) {
|
||||
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
|
||||
var regexS = "[\\?&]"+name+"=([^&#]*)";
|
||||
var regex = new RegExp( regexS );
|
||||
var results = regex.exec(url);
|
||||
if( results == null ) {
|
||||
return val;
|
||||
} else {
|
||||
return unescape(results[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user