summaryrefslogtreecommitdiff
path: root/inc/search.php
diff options
context:
space:
mode:
authorPhilipp A. Hartmann <pah@qo.cx>2013-01-29 19:40:23 +0100
committerPhilipp A. Hartmann <pah@qo.cx>2013-01-29 19:40:23 +0100
commitec24a2df21bc25730b6d807a6930867e09f2aa58 (patch)
tree5575e3ad2f479cf05be5a616d2f299fbac4c5601 /inc/search.php
parent1dc5d48b104c5676df02e6bf0090e13b0e26508b (diff)
downloadrpg-ec24a2df21bc25730b6d807a6930867e09f2aa58.tar.gz
rpg-ec24a2df21bc25730b6d807a6930867e09f2aa58.tar.bz2
search: pass empty $sort to skip sorting
Diffstat (limited to 'inc/search.php')
-rw-r--r--inc/search.php14
1 files changed, 8 insertions, 6 deletions
diff --git a/inc/search.php b/inc/search.php
index 277b17d39..cc3e79006 100644
--- a/inc/search.php
+++ b/inc/search.php
@@ -19,7 +19,7 @@ if(!defined('DOKU_INC')) die('meh.');
* @param callback $func Callback (function name or array with object,method)
* @param string $dir Current directory beyond $base
* @param int $lvl Recursion Level
- * @param mixed $sort 'natural' to use natural order sorting (default); 'date' to sort by filemtime.
+ * @param mixed $sort 'natural' to use natural order sorting (default); 'date' to sort by filemtime; leave empty to skip sorting.
* @author Andreas Gohr <andi@splitbrain.org>
*/
function search(&$data,$base,$func,$opts,$dir='',$lvl=1,$sort='natural'){
@@ -40,12 +40,14 @@ function search(&$data,$base,$func,$opts,$dir='',$lvl=1,$sort='natural'){
$filepaths[] = $base.'/'.$dir.'/'.$file;
}
closedir($dh);
- if ($sort == 'date') {
- @array_multisort(array_map('filemtime', $filepaths), SORT_NUMERIC, SORT_DESC, $files);
- } else /* natural */ {
- natsort($files);
+ if (!empty($sort)) {
+ if ($sort == 'date') {
+ @array_multisort(array_map('filemtime', $filepaths), SORT_NUMERIC, SORT_DESC, $files);
+ } else /* natural */ {
+ natsort($files);
+ }
+ natsort($dirs);
}
- natsort($dirs);
//give directories to userfunction then recurse
foreach($dirs as $dir){