diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2009-03-25 18:14:03 +0000 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2009-03-25 18:14:03 +0000 |
commit | ab787233d65f8b20ac081ae78aa8257b363efaa3 (patch) | |
tree | 1e2f21e71fdd362ee1021716c2a4ff88593860cd | |
parent | 944276fdfe813d99c3a7bc2c37c267c68be98ae6 (diff) |
Fix for ticket #184. Sort the output children as DirectoryIterator
does not provide a sort order. Separate the directory and files, sort
them individually and then merge them together so directories are at
the top of the list
-rw-r--r-- | modules/server_add/controllers/server_add.php | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/modules/server_add/controllers/server_add.php b/modules/server_add/controllers/server_add.php index fe511b46..dd6c5d00 100644 --- a/modules/server_add/controllers/server_add.php +++ b/modules/server_add/controllers/server_add.php @@ -133,7 +133,7 @@ class Server_Add_Controller extends Controller { } private function _get_children($path) { - $file_list = array(); + $directory_list = $file_list = array(); $files = new DirectoryIterator($path); foreach ($files as $file) { if ($file->isDot() || $file->isLink()) { @@ -142,7 +142,7 @@ class Server_Add_Controller extends Controller { $filename = $file->getFilename(); if ($filename[0] != ".") { if ($file->isDir()) { - $file_list[$filename] = array("path" => $file->getPathname(), "is_dir" => true); + $directory_list[$filename] = array("path" => $file->getPathname(), "is_dir" => true); } else { $extension = strtolower(substr(strrchr($filename, '.'), 1)); if ($file->isReadable() && @@ -152,6 +152,9 @@ class Server_Add_Controller extends Controller { } } } - return $file_list; + + ksort($directory_list); + ksort($file_list); + return array_merge($directory_list, $file_list); } }
\ No newline at end of file |