fix sorting media paths

This commit is contained in:
Garvin Hicking 2006-08-05 21:43:19 +00:00
parent e27065c90b
commit 832ad3eca8
2 changed files with 48 additions and 29 deletions

@ -3,6 +3,8 @@
Version 1.1-alpha7()
------------------------------------------------------------------------
* Properly sort media directories (garvinhicking)
* Better use of "return by references" in some vital areas.
Improves performance. Might introduce glitches. Keep an eye on this!
(garvinhicking)

@ -1380,7 +1380,9 @@ function serendipity_displayImageList($page = 0, $lineBreak = NULL, $manage = fa
}
unset($aResultSet[$sKey]);
}
//sort($paths);
usort($paths, 'serendipity_sortPath');
if ($debug) echo "<p>Got files: <pre>" . print_r($aFilesOnDisk, true) . "</pre></p>";
$serendipity['current_image_hash'] = md5(serialize($aFilesOnDisk));
@ -1714,6 +1716,18 @@ function serendipity_traversePath($basedir, $dir='', $onlyDirs = true, $pattern
return $files;
}
/**
* Custom usort() function that properly sorts a path
*
* @access public
* @param array First array
* @param array Second array
* @return
*/
function serendipity_sortPath($a, $b) {
return strcasecmp($a['relpath'], $b['relpath']);
}
/**
* Delete a directory with all its files
*
@ -3264,5 +3278,8 @@ function &serendipity_getMediaPaths() {
unset($aResultSet[$sKey]);
}
serendipity_directoryACL($paths, 'read');
usort($paths, 'serendipity_sortPath');
return $paths;
}