From 1fcfad4dd1ab7443fa9dea7b8c062f59e6efd1fa Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Thu, 19 Feb 2009 22:43:45 +0100 Subject: more flexible page listing method in search.php darcs-hash:20090219214345-7ad00-2597a205c5dfae869defebe5f57d34a5f2fa3baf.gz --- inc/search.php | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'inc') diff --git a/inc/search.php b/inc/search.php index e8af8f64a..a5637fff0 100644 --- a/inc/search.php +++ b/inc/search.php @@ -269,16 +269,36 @@ function search_pagename(&$data,$base,$file,$type,$lvl,$opts){ /** * Just lists all documents * + * $opts['depth'] recursion level, 0 for all + * $opts['hash'] do md5 sum of content? + * * @author Andreas Gohr */ function search_allpages(&$data,$base,$file,$type,$lvl,$opts){ - //we do nothing with directories - if($type == 'd') return true; - //only search txt files - if(substr($file,-4) != '.txt') return true; + //we do nothing with directories + if($type == 'd'){ + if(!$opts['depth']) return true; // recurse forever + $parts = explode('/',$file); + if(count($parts) == $opts['depth']) return false; // depth reached + return true; + } - $data[]['id'] = pathID($file); - return true; + //only search txt files + if(substr($file,-4) != '.txt') return true; + + $item['id'] = pathID($file); + if(!$opts['skipacl'] && auth_quickaclcheck($id) < AUTH_READ){ + return false; + } + + $item['rev'] = filemtime($base.'/'.$file); + $item['size'] = filesize($base.'/'.$file); + if($opts['hash']){ + $item['hash'] = md5(trim(rawWiki($item['id']))); + } + + $data[] = $item; + return true; } /** -- cgit v1.2.3