Project

General

Profile

Bug #22382 » 14008.diff

Administrator Admin, 2010-04-06 20:14

View differences:

t3lib/class.t3lib_foldertree.php (working copy)
function getFolderTree($files_path, $depth=999, $depthData='', $type='') {
// This generates the directory tree
$dirs = t3lib_div::get_dirs($files_path);
$dirs = t3lib_div::get_dirs($files_path, 1);
$c=0;
if (is_array($dirs)) {
......
$HTML='';
$a=0;
$c=count($dirs);
sort($dirs);
foreach($dirs as $key => $val) {
$a++;
t3lib/class.t3lib_div.php (working copy)
* Usage: 11
*
* @param string Path to list directories from
* @param string $order is sorting: 1= sort alphabetically, 'mtime' = sort by modification time.
* @return array Returns an array with the directory entries as values. If no path, the return value is nothing.
*/
public static function get_dirs($path) {
public static function get_dirs($path, $order='') {
if ($path) {
if (is_dir($path)) {
$dir = scandir($path);
$sortarray = array();
$dirs = array();
foreach ($dir as $entry) {
if (is_dir($path . '/' . $entry) && $entry != '..' && $entry != '.') {
$dirs[] = $entry;
$dirs[$entry] = $entry;
if ($order == 'mtime') {
$sortarray[$entry] = filemtime($path . '/' . $entry);
} elseif ($order) {
$sortarray[$entry] = $entry;
}
}
}
// Sort them:
if ($order) {
natcasesort($sortarray);
$newArr = array();
foreach ($sortarray as $k => $v) {
$newArr[$k] = $dirs[$k];
}
$dirs = $newArr;
}
} else {
$dirs = 'error';
}
......
$path = rtrim($path, '/');
// Find files+directories:
if (@is_dir($path)) {
if (@is_dir($path)) {
$extensionList = strtolower($extensionList);
$d = dir($path);
if (is_object($d)) {
while($entry=$d->read()) {
if (@is_file($path.'/'.$entry)) {
if (is_object($d)) {
while($entry = $d->read()) {
if (@is_file($path . '/' . $entry)) {
$fI = pathinfo($entry);
$key = md5($path.'/'.$entry); // Don't change this ever - extensions may depend on the fact that the hash is an md5 of the path! (import/export extension)
if ((!strlen($extensionList) || self::inList($extensionList,strtolower($fI['extension']))) && (!strlen($excludePattern) || !preg_match('/^'.$excludePattern.'$/',$entry))) {
$filearray[$key]=($prependPath?$path.'/':'').$entry;
if ($order=='mtime') {$sortarray[$key]=filemtime($path.'/'.$entry);}
elseif ($order) {$sortarray[$key]=$entry;}
$key = md5($path . '/' . $entry); // Don't change this ever - extensions may depend on the fact that the hash is an md5 of the path! (import/export extension)
if ((!strlen($extensionList) || self::inList($extensionList,strtolower($fI['extension']))) && (!strlen($excludePattern) || !preg_match('/^' . $excludePattern . '$/', $entry))) {
$filearray[$key] = ($prependPath?$path . '/' : '') . $entry;
if ($order == 'mtime') {
$sortarray[$key] = filemtime($path . '/' . $entry);
} elseif ($order) {
$sortarray[$key] = $entry;
}
}
}
}
$d->close();
} else return 'error opening path: "'.$path.'"';
} else {
return 'error opening path: "' . $path . '"';
}
}
// Sort them:
if ($order) {
asort($sortarray);
$newArr=array();
natcasesort($sortarray);
$newArr = array();
foreach ($sortarray as $k => $v) {
$newArr[$k]=$filearray[$k];
$newArr[$k] = $filearray[$k];
}
$filearray=$newArr;
$filearray = $newArr;
}
// Return result
typo3/class.filelistfoldertree.php (working copy)
function getFolderTree($files_path, $depth=999, $type='') {
// This generates the directory tree
$dirs = t3lib_div::get_dirs($files_path);
$dirs = t3lib_div::get_dirs($files_path, 1);
if (!is_array($dirs)) return 0;
sort($dirs);
$c = count($dirs);
$depth = intval($depth);
(3-3/4)