* sorting fileselection popup always by directory on top and then name

This commit is contained in:
Ralf Becker 2010-11-09 12:59:27 +00:00
parent 27abf5f015
commit 65813764ed

View File

@ -220,7 +220,11 @@ class filemanager_select
{ {
$content['path'] = filemanager_ui::get_home_dir(); $content['path'] = filemanager_ui::get_home_dir();
} }
if (!($d = egw_vfs::opendir($content['path']))) if (!($files = egw_vfs::find($content['path'],array(
'order' => 'name',
'sort' => 'ASC',
'maxdepth' => 1,
))))
{ {
$content['msg'] = lang("Can't open directory %1!",$content['path']); $content['msg'] = lang("Can't open directory %1!",$content['path']);
} }
@ -228,10 +232,10 @@ class filemanager_select
{ {
$n = 0; $n = 0;
$content['dir'] = array('mode' => $content['mode']); $content['dir'] = array('mode' => $content['mode']);
while (($name = readdir($d))) array_shift($files); // remove directory itself
foreach($files as $path)
{ {
if ($name[0] == '.' || $name == 'Thumbs.db') continue; // ignore hidden files $name = egw_vfs::basename($path);
$path = egw_vfs::concat($content['path'],$name);
$is_dir = egw_vfs::is_dir($path); $is_dir = egw_vfs::is_dir($path);
if ($content['mime'] && !$is_dir && egw_vfs::mime_content_type($path) != $content['mime']) if ($content['mime'] && !$is_dir && egw_vfs::mime_content_type($path) != $content['mime'])
{ {
@ -251,7 +255,6 @@ class filemanager_select
++$n; ++$n;
} }
if (!$n) $readonlys['selected[]'] = true; // remove checkbox from empty line if (!$n) $readonlys['selected[]'] = true; // remove checkbox from empty line
closedir($d);
} }
$content['js'] = '<script type="text/javascript"> $content['js'] = '<script type="text/javascript">