|
|
@ -47,25 +47,23 @@ class FileManager |
|
|
|
]; |
|
|
|
|
|
|
|
if ($result['is_file']) { |
|
|
|
$result['size'] = $this->formatBytes($meta['size']); |
|
|
|
$result['meta']['size'] = $this->formatBytes($meta['size']); |
|
|
|
$files[] = $result; |
|
|
|
} else { |
|
|
|
$directories[] = $result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
usort($directories, function($a, $b) { |
|
|
|
if (strtolower($a['filename']) < strtolower($b['filename'])) { |
|
|
|
return 0; |
|
|
|
} else { |
|
|
|
return 1; |
|
|
|
} |
|
|
|
}); |
|
|
|
// sorting by filename
|
|
|
|
usort($directories, [$this, 'sortByFilename']); |
|
|
|
usort($files, [$this, 'sortByFilename']); |
|
|
|
|
|
|
|
// adding directories
|
|
|
|
foreach($directories as $directory) { |
|
|
|
$results[] = $directory; |
|
|
|
} |
|
|
|
|
|
|
|
// adding files
|
|
|
|
foreach($files as $file) { |
|
|
|
$results[] = $file; |
|
|
|
} |
|
|
@ -73,6 +71,19 @@ class FileManager |
|
|
|
return $results; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* sorting by filename, function for usort |
|
|
|
* |
|
|
|
*/ |
|
|
|
private function sortByFilename($a, $b) |
|
|
|
{ |
|
|
|
if (strtolower($a['filename']) < strtolower($b['filename'])) { |
|
|
|
return 0; |
|
|
|
} else { |
|
|
|
return 1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
* @param [type] $size [description] |
|
|
|