Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

getfolder sorting issue #105

Closed
claudep opened this Issue · 3 comments

4 participants

@claudep

The documentation explains that getfolder returns an array of file and folder objects, and that folders should always be returned before files. The example does not show a real array, but an object with paths as keys. The problem is that object keys are not guaranteed to be sorted by the JSON spec (see http://json.org/: An object is an unordered set of name/value pairs.), even if many implementation do keep the sort order.

So either:
1. getfolder returns an array of sorted folders and files [ {...], ...]
2. keep getfolder output as object with paths as keys, and sort files and folders in filemanager.js.

It depends on where you'd like to sort objects, client-side or server-side.

@simogeo
Owner

Actually, there is no special need to return folders before files. This is a documentation outdated mention.

Nowadays, the content is returned (by the server - PHP Connector) in alphabetical order. But it would be great, indeed, to keep that alphabetical order and display folders first.

@santaclaus21

I agree with author. It can be done by option (elfinder do it in this way).

@SManAT

Sorting is easy:
I Have made a new class that extends Filemanager. Also tha i can update my databases via ajax calls if e.g. a file is renamed etc.

within the getfolder() function i'm doing sorting like this
$a = array();$b = array();
foreach ($data as $key=>$item){
if(strcmp($item["File Type"], "dir")==0){
$a[$key]=$item;
}else{
$b[$key]=$item;
}
}
return array_merge($a,$b);

That provides Directorys first, then the files both in alphabeticaly order.

Tried also to implement a plugin, but wasnt working. Let me know if i can support this very COOL project!

@simogeo simogeo referenced this issue from a commit
@simogeo sorting options on configuration file (fixing issue #105), adding
"filemtime" attributes to returned JSON data
a273af0
@simogeo
Owner

@SManAT : thanks for your piece of code, sorting is now part of configuration option, see the following wiki page : https://github.com/simogeo/Filemanager/wiki/How-to-change-files-and-folders-order-in-list%3F and the latest commit : a273af0.

If you want to contribute to the FileManager, you're very welcome : ideas, code, https://github.com/simogeo/Filemanager/wiki, bug fixes/evolution, .... FM is just waiting for you!

@simogeo simogeo closed this
@hammond13 hammond13 referenced this issue from a commit
@simogeo sorting options on configuration file (fixing issue #105), adding
"filemtime" attributes to returned JSON data
41e1229
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.