From abc306f45f2ace038967bf7c51abd6ea53f56170 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Mon, 25 Jul 2011 16:23:24 +0300 Subject: mediamanager sort button --- inc/search.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'inc/search.php') 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 */ -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 -- cgit v1.2.3