Merge pull request #62 from bifek/fixsorting

use SORT_ASC/DESC directly in config. simplifies array_multisort.
This commit is contained in:
Tom.C. 2014-11-24 17:36:55 +01:00
commit 2f0c23019a
2 changed files with 12 additions and 8 deletions

View file

@ -23,8 +23,8 @@ $author = "John Doe";
$folder_color = "black"; // Color of folder icons: blue / black / vista / purple / green / grey $folder_color = "black"; // Color of folder icons: blue / black / vista / purple / green / grey
$sorting_folders = "name"; // Sort folders by: [name][date] $sorting_folders = "name"; // Sort folders by: [name][date]
$sorting_files = "name"; // Sort files by: [name][date][size] $sorting_files = "name"; // Sort files by: [name][date][size]
$sortdir_folders = "ASC"; // Sort direction of folders: [ASC][DESC] $sortdir_folders = SORT_ASC; // Sort direction of folders: SORT_ASC / SORT_DESC
$sortdir_files = "ASC"; // Sort direction of files: [ASC][DESC] $sortdir_files = SORT_ASC; // Sort direction of files: SORT_ASC / SORT_DESC
$lazyload = 1; // 0 is pagination, 1 is display all pictures on one page $lazyload = 1; // 0 is pagination, 1 is display all pictures on one page
$SkipObjects = array('aFolder', 'aFile.ext'); //Those files and folders will not be displayed (affects the page and the RSS feed) $SkipObjects = array('aFolder', 'aFile.ext'); //Those files and folders will not be displayed (affects the page and the RSS feed)

View file

@ -344,24 +344,28 @@ if (sizeof($dirs) > 0)
{ {
foreach ($dirs as $key => $row) foreach ($dirs as $key => $row)
{ {
if($row["name"] == "") unset($dirs[$key]); //Delete empty array entries if($row["name"] == "") {
unset($dirs[$key]); //Delete empty array entries
continue;
}
$name[$key] = strtolower($row['name']); $name[$key] = strtolower($row['name']);
$date[$key] = strtolower($row['date']); $date[$key] = strtolower($row['date']);
} }
if (strtoupper($sortdir_folders) == "DESC") array_multisort($$sorting_folders, SORT_DESC, $name, SORT_DESC, $dirs); @array_multisort($$sorting_folders, $sortdir_folders, $name, $sortdir_folders, $dirs);
else array_multisort($$sorting_folders, SORT_ASC, $name, SORT_ASC, $dirs);
} }
if (sizeof($files) > 0) if (sizeof($files) > 0)
{ {
foreach ($files as $key => $row) foreach ($files as $key => $row)
{ {
if($row["name"] == "") unset($files[$key]); //Delete empty array entries if($row["name"] == "") {
unset($files[$key]); //Delete empty array entries
continue;
}
$name[$key] = strtolower($row['name']); $name[$key] = strtolower($row['name']);
$date[$key] = strtolower($row['date']); $date[$key] = strtolower($row['date']);
$size[$key] = strtolower($row['size']); $size[$key] = strtolower($row['size']);
} }
if (strtoupper($sortdir_files) == "DESC") @array_multisort($$sorting_files, SORT_DESC, $name, SORT_ASC, $files); @array_multisort($$sorting_files, $sortdir_files, $name, SORT_ASC, $files);
else @array_multisort($$sorting_files, SORT_ASC, $name, SORT_ASC, $files);
} }
//----------------------- //-----------------------