- Add some more filter options

- Fix maxdepth option to work
This commit is contained in:
Nathan Gray 2014-09-23 17:46:06 +00:00
parent eefc75369c
commit 47df86be97
2 changed files with 9 additions and 4 deletions

View File

@ -457,6 +457,8 @@ class filemanager_ui
'' => 'Current directory', '' => 'Current directory',
'2' => 'Directories sorted in', '2' => 'Directories sorted in',
'3' => 'Show hidden files', '3' => 'Show hidden files',
'4' => 'All subdirectories',
'5' => 'Files from next subdirectory',
'0' => 'Files from subdirectories', '0' => 'Files from subdirectories',
); );
@ -767,11 +769,14 @@ class filemanager_ui
// Re-map so 'No filters' favorite ('') is depth 1 // Re-map so 'No filters' favorite ('') is depth 1
$filter = $query['filter'] === '' ? 1 : $query['filter']; $filter = $query['filter'] === '' ? 1 : $query['filter'];
$maxdepth = $filter && $filter != 4 ? (int)(boolean)$filter : null;
if($filter == 5) $maxdepth = 2;
foreach(egw_vfs::find(!empty($query['col_filter']['dir']) ? $query['col_filter']['dir'] : $query['path'],array( foreach(egw_vfs::find(!empty($query['col_filter']['dir']) ? $query['col_filter']['dir'] : $query['path'],array(
'mindepth' => 1, 'mindepth' => 1,
'maxdepth' => $filter ? (int)(boolean)$filter : null, 'maxdepth' => $maxdepth,
'dirsontop' => $filter <= 1, 'dirsontop' => $filter <= 1,
'type' => $filter ? null : 'f', 'type' => $filter && $filter != 5 ? ($filter == 4 ? 'd' : null) : 'f',
'order' => $query['order'], 'sort' => $query['sort'], 'order' => $query['order'], 'sort' => $query['sort'],
'limit' => (int)$query['num_rows'].','.(int)$query['start'], 'limit' => (int)$query['num_rows'].','.(int)$query['start'],
'need_mime' => true, 'need_mime' => true,

View File

@ -495,7 +495,7 @@ class egw_vfs extends vfs_stream_wrapper
{ {
self::_check_add($options,$path,$result); self::_check_add($options,$path,$result);
} }
if ($is_dir && (!isset($options['maxdepth']) || $options['maxdepth'] > 0) && ($dir = @opendir($path))) if ($is_dir && (!isset($options['maxdepth']) || ($options['maxdepth'] > 0 && $options['depth'] < $options['maxdepth'])) && ($dir = @opendir($path)))
{ {
while(($file = readdir($dir)) !== false) while(($file = readdir($dir)) !== false)
{ {
@ -514,7 +514,7 @@ class egw_vfs extends vfs_stream_wrapper
{ {
$opts = $options; $opts = $options;
if ($opts['mindepth']) $opts['mindepth']--; if ($opts['mindepth']) $opts['mindepth']--;
if ($opts['maxdepth']) $opts['maxdepth']++; if ($opts['maxdepth']) $opts['depth']++;;
unset($opts['order']); unset($opts['order']);
unset($opts['limit']); unset($opts['limit']);
foreach(self::find($options['url']?$file:parse_url($file,PHP_URL_PATH),$opts,true) as $p => $s) foreach(self::find($options['url']?$file:parse_url($file,PHP_URL_PATH),$opts,true) as $p => $s)