Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion connectors/php/BaseFilemanager.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public function handleRequest()
break;

case 'getfolder':
if($this->getvar('path') && $this->getvard('skip', true, 0)) {
if($this->getvar('path') && $this->getvard('skip', true, 0) && $this->getvard('load', true, 0)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getvard()? Probably should be getvar().

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Take a look for new function getvard which don't throw error if variable wasn't set. 3rd argument is default value which will be used if name not defined in $_GET.


$response = $this->actionGetFolder();
}
Expand Down
5 changes: 4 additions & 1 deletion connectors/php/LocalFilemanager.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ public function actionGetFolder()
$response_data = [];
$target_path = $this->get['path'];
$skipCount = $this->get['skip'];
//$load = 0 - both, 1 - folders, 2 - files
$load = $this->get['load'];
$filesSkipped = 0;
$target_fullpath = $this->getFullPath($target_path, true);
$lazyEnabled = $this->config['options']['lazy'];
Expand All @@ -168,7 +170,8 @@ public function actionGetFolder()
if($file != "." && $file != "..") {
//@todo Skip files not in that dirty way
if ($lazyEnabled && $filesSkipped++ < $skipCount) continue;
array_push($files_list, $file);
if ((is_dir($target_fullpath . $file) && $load != 2) || ($load != 1))
array_push($files_list, $file);
if ($lazyEnabled && count($files_list) >= $lazyLimit) {
$lazyFlag = false;
break;
Expand Down
30 changes: 20 additions & 10 deletions scripts/filemanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,7 @@ $.richFilemanagerPlugin = function(element, pluginOptions)

if (node) {
tree_model.options.expandSpeed = 10;
tree_model.loadNodes(node, false);
tree_model.loadNodes(node, {'refresh': false});
} else {
fullexpandedFolder = null;
tree_model.options.expandSpeed = 200;
Expand Down Expand Up @@ -1024,13 +1024,14 @@ $.richFilemanagerPlugin = function(element, pluginOptions)
return null;
};

this.loadNodes = function(targetNode, refresh) {
//2nd parameter now 'options' array
this.loadNodes = function(targetNode, options) {
var path = targetNode ? targetNode.id : tree_model.treeData.id;
var filesCount = model.treeModel.currentNode() ? model.treeModel.currentNode().children().length : 0;
if(targetNode) {
targetNode.isLoaded(false);
}

if(typeof {} !== typeof options) options = {};
var queryParams = {
mode: 'getfolder',
path: path
Expand All @@ -1042,6 +1043,10 @@ $.richFilemanagerPlugin = function(element, pluginOptions)

var data = {};
if (model.currentPath() === path) data['skip'] = filesCount;
//This parameter is important for lazy loading and split view mode
//It will separate loading for folders (1), files (2) or both (0)
//Default is 0 (both)
if (options.load && config.options.filemanagerMode === 'split') data['load'] = options.load;

$.ajax({
type: 'GET',
Expand All @@ -1056,7 +1061,7 @@ $.richFilemanagerPlugin = function(element, pluginOptions)
fmModel.breadcrumbsModel.splitCurrent();
tree_model.currentNode(targetNode);
if (!targetNode || undefined === targetNode.isDone) {
fmModel.itemsModel.setList(response.data.tree || refresh);
fmModel.itemsModel.setList(response.data.tree || options.refresh);
} else {
fmModel.itemsModel.extendList(response.data.tree);
}
Expand All @@ -1066,7 +1071,7 @@ $.richFilemanagerPlugin = function(element, pluginOptions)
var nodeObject = tree_model.createNode(resourceObject);
nodes.push(nodeObject);
});
if(refresh) {
if(options.refresh) {
targetNode.children([]);
}
tree_model.addNodes(targetNode, nodes);
Expand Down Expand Up @@ -1173,7 +1178,7 @@ $.richFilemanagerPlugin = function(element, pluginOptions)
//@todo: now I'm looking for element by it's name. It's sad, but there's only way I have found
var el = $('span.node_name:contains("' + n + '")');
if (offsetTop >= el.position().top && true !== model.treeModel.currentNode().isDone) {
model.treeModel.loadNodes(model.treeModel.currentNode());
model.treeModel.loadNodes(model.treeModel.currentNode(), {'load': 1});
}
};

Expand Down Expand Up @@ -1245,7 +1250,7 @@ $.richFilemanagerPlugin = function(element, pluginOptions)
this.toggleNode = function(node, forceReload) {
if(node.rdo.type === 'folder') {
if(!node.isExpanded() && (forceReload || !node.isLoaded() || config.options.filemanagerMode === 'split')) {
tree_model.loadNodes(node, true);
tree_model.loadNodes(node, {'refresh': true});
} else {
node.isSliding(true);
}
Expand Down Expand Up @@ -1362,7 +1367,7 @@ $.richFilemanagerPlugin = function(element, pluginOptions)
model.itemsModel.sortObjects();
};

this.loadList = function(path) {
this.loadList = function(path, options) {
model.loadingView(true);
var filesCount = model.itemsModel.objects().length;
//All directories except root has additional element to go back to parent folder
Expand All @@ -1371,12 +1376,17 @@ $.richFilemanagerPlugin = function(element, pluginOptions)
mode: 'getfolder',
path: path
};
if (typeof {} !== typeof options) options = {};
if($.urlParam('type')) {
queryParams.type = $.urlParam('type');
}

var data = {};
if (model.currentPath() === path) data['skip'] = filesCount;
//This parameter is important for lazy loading and split view mode
//It will separate loading for folders (1), files (2) or both (0)
//Default is 0 (both)
if (options.load && config.options.filemanagerMode === 'split') data['load'] = options.load;

$.ajax({
type: 'GET',
Expand Down Expand Up @@ -1646,7 +1656,7 @@ $.richFilemanagerPlugin = function(element, pluginOptions)

this.onCustomScrolling = function(topPct){
if (topPct >= 95 && true !== model.itemsModel.isDone()) {
model.itemsModel.loadList(model.currentPath());
model.itemsModel.loadList(model.currentPath(), {'load': 2});
}
};
};
Expand Down Expand Up @@ -2480,7 +2490,7 @@ $.richFilemanagerPlugin = function(element, pluginOptions)

// Create FileTree and bind events
var createFileTree = function() {
fmModel.treeModel.loadNodes(null, false);
fmModel.treeModel.loadNodes(null, {'refresh': false});
};

// check if plugin instance created inside some context
Expand Down