Browse Source

adding

master
Björn 3 years ago
parent
commit
37292ca3e4
1 changed files with 19 additions and 8 deletions
  1. +19
    -8
      app/FileManager.php

+ 19
- 8
app/FileManager.php View File

@ -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]


Loading…
Cancel
Save