diff options
author | Kate Arzamastseva <pshns@ukr.net> | 2011-07-25 16:23:24 +0300 |
---|---|---|
committer | Kate Arzamastseva <pshns@ukr.net> | 2011-07-25 16:23:24 +0300 |
commit | abc306f45f2ace038967bf7c51abd6ea53f56170 (patch) | |
tree | e032b59bb6e8cc9645561f3d1176926a025a2a9a /inc/search.php | |
parent | b5941dfab8516bd445afebc91d6a4942cab4d5f0 (diff) | |
download | rpg-abc306f45f2ace038967bf7c51abd6ea53f56170.tar.gz rpg-abc306f45f2ace038967bf7c51abd6ea53f56170.tar.bz2 |
mediamanager sort button
Diffstat (limited to 'inc/search.php')
-rw-r--r-- | inc/search.php | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/inc/search.php b/inc/search.php index 7b53edabe..c11111efc 100644 --- a/inc/search.php +++ b/inc/search.php @@ -21,9 +21,10 @@ if(!defined('DOKU_INC')) die('meh.'); * @param int $lvl Recursion Level * @author Andreas Gohr <andi@splitbrain.org> */ -function search(&$data,$base,$func,$opts,$dir='',$lvl=1){ +function search(&$data,$base,$func,$opts,$dir='',$lvl=1,$sort=false){ $dirs = array(); $files = array(); + $filepaths = array(); //read in directories and files $dh = @opendir($base.'/'.$dir); @@ -35,9 +36,14 @@ function search(&$data,$base,$func,$opts,$dir='',$lvl=1){ continue; } $files[] = $dir.'/'.$file; + $filepaths[] = $base.'/'.$dir.'/'.$file; } closedir($dh); - sort($files); + if ($sort == 'date') { + @array_multisort(array_map('filemtime', $filepaths), SORT_NUMERIC, SORT_ASC, $files); + } else { + sort($files); + } sort($dirs); //give directories to userfunction then recurse |