2 // Author: Dongsheng Cai <dongsheng@moodle.com>
5 api: M.cfg.wwwroot+'/files/filebrowser_ajax.php',
6 request: function(url, node, cb) {
7 var api = this.api + '?action=getfiletree';
9 params['contextid'] = this.get_param(url, 'contextid', -1);
10 params['component'] = this.get_param(url, 'component', null);
11 params['filearea'] = this.get_param(url, 'filearea', null);
12 params['itemid'] = this.get_param(url, 'itemid', -1);
13 params['filepath'] = this.get_param(url, 'filepath', null);
14 params['filename'] = this.get_param(url, 'filename', null);
16 params['sesskey']=M.cfg.sesskey;
20 complete: function(id,o,p) {
22 var data = this.y3.JSON.parse(o.responseText);
27 if (data && data.length==0) {
32 label: data[i].filename,
35 var tmp = new YAHOO.widget.TextNode(mynode, node, false);
40 tmp.target = '_blank';
51 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
53 data: build_querystring(params),
59 var tree = new YAHOO.widget.TreeView('course-file-tree-view');
60 tree.setDynamicLoad(this.dynload);
61 tree.subscribe("clickEvent", this.onclick);
62 var root = tree.getRoot();
63 var children = root.children;
65 if (children[i].className == 'file-tree-folder') {
66 children[i].isLeaf = false;
68 children[i].isLeaf = true;
74 dynload: function(node, oncompletecb) {
75 M.core_filetree.request(node.href, node, oncompletecb);
77 onclick: function(e) {
78 YAHOO.util.Event.preventDefault(e);
80 get_param: function(url, name, val) {
81 name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
82 var regexS = "[\\?&]"+name+"=([^&#]*)";
83 var regex = new RegExp( regexS );
84 var results = regex.exec(url);
85 if( results == null ) {
88 return unescape(results[1]);