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 From d971ea8b02ccca4dd879a5db966670e0f3b4f102 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Sat, 30 Jul 2011 20:50:49 +0300 Subject: issue #39 sort by date desc, saved in cookie --- inc/search.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/search.php') diff --git a/inc/search.php b/inc/search.php index c11111efc..a6089c479 100644 --- a/inc/search.php +++ b/inc/search.php @@ -40,7 +40,7 @@ function search(&$data,$base,$func,$opts,$dir='',$lvl=1,$sort=false){ } closedir($dh); if ($sort == 'date') { - @array_multisort(array_map('filemtime', $filepaths), SORT_NUMERIC, SORT_ASC, $files); + @array_multisort(array_map('filemtime', $filepaths), SORT_NUMERIC, SORT_DESC, $files); } else { sort($files); } -- cgit v1.2.3 From 783d2e49b2d8e12ed3bc0693b56c013215099a4c Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Sun, 4 Sep 2011 12:35:38 +0200 Subject: Use search_universal in search_index --- inc/search.php | 49 +++++++++++++------------------------------------ 1 file changed, 13 insertions(+), 36 deletions(-) (limited to 'inc/search.php') diff --git a/inc/search.php b/inc/search.php index 7b53edabe..bc7c35482 100644 --- a/inc/search.php +++ b/inc/search.php @@ -78,8 +78,8 @@ function search_callback($func,&$data,$base,$file,$type,$lvl,$opts){ * return values for files are ignored * * All functions should check the ACL for document READ rights - * namespaces (directories) are NOT checked as this would break - * the recursion (You can have an nonreadable dir over a readable + * namespaces (directories) are NOT checked (when sneaky_index is 0) as this + * would break the recursion (You can have an nonreadable dir over a readable * one deeper nested) also make sure to check the file type (for example * in case of lockfiles). */ @@ -101,45 +101,22 @@ function search_qsearch(&$data,$base,$file,$type,$lvl,$opts){ /** * Build the browsable index of pages * - * $opts['ns'] is the current namespace + * $opts['ns'] is the currently viewed namespace * * @author Andreas Gohr */ function search_index(&$data,$base,$file,$type,$lvl,$opts){ global $conf; - $return = true; - - $item = array(); - - if($type == 'd' && !preg_match('#^'.$file.'(/|$)#','/'.$opts['ns'])){ - //add but don't recurse - $return = false; - }elseif($type == 'f' && ($opts['nofiles'] || substr($file,-4) != '.txt')){ - //don't add - return false; - } - - $id = pathID($file,($type == 'd')); - - if($type=='d' && $conf['sneaky_index'] && auth_quickaclcheck($id.':') < AUTH_READ){ - return false; - } - - //check hidden - if(isHiddenPage($id)){ - return false; - } - - //check ACL - if($type=='f' && auth_quickaclcheck($id) < AUTH_READ){ - return false; - } - - $data[]=array( 'id' => $id, - 'type' => $type, - 'level' => $lvl, - 'open' => $return ); - return $return; + $opts = array( + 'pagesonly' => true, + 'listdirs' => true, + 'listfiles' => !$opts['nofiles'], + 'sneakyacl' => $conf['sneaky_index'], + // Hacky, should rather use recmatch + 'depth' => preg_match('#^'.$file.'(/|$)#','/'.$opts['ns']) ? 0 : -1 + ); + + return search_universal($data, $base, $file, $type, $lvl, $opts); } /** -- cgit v1.2.3 From 923510088dda99cb2790b15308593e47369d4f01 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Sun, 4 Sep 2011 13:52:26 +0200 Subject: tmp: Introduce sneaky2 --- inc/search.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'inc/search.php') diff --git a/inc/search.php b/inc/search.php index bc7c35482..5ba28a1fc 100644 --- a/inc/search.php +++ b/inc/search.php @@ -596,6 +596,25 @@ function search_universal(&$data,$base,$file,$type,$lvl,$opts){ if($opts['firsthead']) $item['title'] = p_get_first_heading($item['id'],METADATA_DONT_RENDER); } + if($type == 'd' && !$opts['skipacl'] && $opts['sneakyacl'] && $item['perm'] < AUTH_READ) { + if ($opts['sneakyacl'] === 2) { + // Perform shy sneaking, i. e. just show the ns if it contains + // something accessible + $old_data_count = count($data); + search($data,$base,'search_universal',$opts,$file,$lvl+1); + if (count($data) > $old_data_count) { + // Contains something visible + array_splice($data, $old_data_count, $return ? 0 : count($data), + array($item)); + } else { + // Contains nothing visible, so hide + $data = array_slice($data, 0, $old_data_count); + } + } + // Stop recursing in any case since we did it ourself + return false; + } + // finally add the item $data[] = $item; return $return; -- cgit v1.2.3 From 1ffc211ddb46bfabe649bbacd1e36bc8e035afa3 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Sun, 4 Sep 2011 15:32:41 +0200 Subject: Revert tmp commits This reverts commit ba6c070edd92ca0fc8a6ee85d51769d64a19ee7c. This reverts commit 923510088dda99cb2790b15308593e47369d4f01. --- inc/search.php | 19 ------------------- 1 file changed, 19 deletions(-) (limited to 'inc/search.php') diff --git a/inc/search.php b/inc/search.php index 5ba28a1fc..bc7c35482 100644 --- a/inc/search.php +++ b/inc/search.php @@ -596,25 +596,6 @@ function search_universal(&$data,$base,$file,$type,$lvl,$opts){ if($opts['firsthead']) $item['title'] = p_get_first_heading($item['id'],METADATA_DONT_RENDER); } - if($type == 'd' && !$opts['skipacl'] && $opts['sneakyacl'] && $item['perm'] < AUTH_READ) { - if ($opts['sneakyacl'] === 2) { - // Perform shy sneaking, i. e. just show the ns if it contains - // something accessible - $old_data_count = count($data); - search($data,$base,'search_universal',$opts,$file,$lvl+1); - if (count($data) > $old_data_count) { - // Contains something visible - array_splice($data, $old_data_count, $return ? 0 : count($data), - array($item)); - } else { - // Contains nothing visible, so hide - $data = array_slice($data, 0, $old_data_count); - } - } - // Stop recursing in any case since we did it ourself - return false; - } - // finally add the item $data[] = $item; return $return; -- cgit v1.2.3