rework FileDir::makePathfield() is mode is 'dropdown' to show all directories correctly (depth limited); fixes #1044
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Froxlor;
|
namespace Froxlor;
|
||||||
|
|
||||||
use Froxlor\Database\Database;
|
use Froxlor\Database\Database;
|
||||||
@@ -408,7 +409,6 @@ class FileDir
|
|||||||
natcasesort($dirList);
|
natcasesort($dirList);
|
||||||
|
|
||||||
if (sizeof($dirList) > 0) {
|
if (sizeof($dirList) > 0) {
|
||||||
if (sizeof($dirList) <= 100) {
|
|
||||||
$_field = '';
|
$_field = '';
|
||||||
foreach ($dirList as $dir) {
|
foreach ($dirList as $dir) {
|
||||||
if (strpos($dir, $path) === 0) {
|
if (strpos($dir, $path) === 0) {
|
||||||
@@ -425,17 +425,6 @@ class FileDir
|
|||||||
'type' => 'select',
|
'type' => 'select',
|
||||||
'value' => $_field
|
'value' => $_field
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
// remove starting slash we added
|
|
||||||
// for the Dropdown, #225
|
|
||||||
$value = substr($value, 1);
|
|
||||||
// $field = $lng['panel']['toomanydirs'];
|
|
||||||
$field = array(
|
|
||||||
'type' => 'text',
|
|
||||||
'value' => htmlspecialchars($value),
|
|
||||||
'note' => $lng['panel']['toomanydirs']
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// $field = $lng['panel']['dirsmissing'];
|
// $field = $lng['panel']['dirsmissing'];
|
||||||
// $field = '<input type="hidden" name="path" value="/" />';
|
// $field = '<input type="hidden" name="path" value="/" />';
|
||||||
@@ -489,22 +478,31 @@ class FileDir
|
|||||||
$filter = function ($file, $key, $iterator) use ($exclude) {
|
$filter = function ($file, $key, $iterator) use ($exclude) {
|
||||||
if (in_array($file->getFilename(), $exclude)) {
|
if (in_array($file->getFilename(), $exclude)) {
|
||||||
return false;
|
return false;
|
||||||
|
} elseif (substr($file->getFilename(), 0, 1) == '.') {
|
||||||
|
// also hide hidden folders
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
// create RecursiveIteratorIterator
|
// create RecursiveIteratorIterator
|
||||||
$its = new \RecursiveIteratorIterator(new \RecursiveCallbackFilterIterator(new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS), $filter));
|
$its = new \RecursiveIteratorIterator(
|
||||||
|
new \RecursiveCallbackFilterIterator(
|
||||||
|
new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS),
|
||||||
|
$filter
|
||||||
|
),
|
||||||
|
\RecursiveIteratorIterator::LEAVES_ONLY,
|
||||||
|
\RecursiveIteratorIterator::CATCH_GET_CHILD
|
||||||
|
);
|
||||||
// we can limit the recursion-depth, but will it be helpful or
|
// we can limit the recursion-depth, but will it be helpful or
|
||||||
// will people start asking "why do I only see 2 subdirectories, i want to use /a/b/c"
|
// will people start asking "why do I only see 2 subdirectories, i want to use /a/b/c"
|
||||||
// let's keep this in mind and see whether it will be useful
|
// let's keep this in mind and see whether it will be useful
|
||||||
// @TODO
|
$its->setMaxDepth(2);
|
||||||
// $its->setMaxDepth(2);
|
|
||||||
|
|
||||||
// check every file
|
// check every file
|
||||||
foreach ($its as $fullFileName => $it) {
|
foreach ($its as $fullFileName => $it) {
|
||||||
if ($it->isDir() && (fileowner($fullFileName) == $uid || filegroup($fullFileName) == $gid)) {
|
if ($it->isDir() && (fileowner($fullFileName) == $uid || filegroup($fullFileName) == $gid)) {
|
||||||
$_fileList[] = self::makeCorrectDir(dirname($fullFileName));
|
$_fileList[] = self::makeCorrectDir($fullFileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$_fileList[] = $path;
|
$_fileList[] = $path;
|
||||||
|
|||||||
Reference in New Issue
Block a user