summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--conf/dokuwiki.php1
-rw-r--r--inc/common.php3
-rw-r--r--inc/fulltext.php13
-rw-r--r--inc/pageutils.php24
-rw-r--r--inc/search.php8
-rw-r--r--inc/template.php2
6 files changed, 47 insertions, 4 deletions
diff --git a/conf/dokuwiki.php b/conf/dokuwiki.php
index 2d89d1cde..65383017c 100644
--- a/conf/dokuwiki.php
+++ b/conf/dokuwiki.php
@@ -79,6 +79,7 @@ $conf['spellchecker']= 0; //enable Spellchecker (needs PHP >= 4.3
$conf['subscribers'] = 0; //enable change notice subscription support
$conf['pluginmanager'] = 0; //enable automated plugin management (requires plugin)
$conf['compress'] = 1; //Strip whitespaces and comments from Styles and JavaScript? 1|0
+$conf['hidepages'] = ''; //Regexp for pages to be skipped from RSS, Search and Recent Changes
$conf['rss_type'] = 'rss1'; //type of RSS feed to provide, by default:
// 'rss' - RSS 0.91
// 'rss1' - RSS 1.0
diff --git a/inc/common.php b/inc/common.php
index 4e8dd1f85..4092eb766 100644
--- a/inc/common.php
+++ b/inc/common.php
@@ -660,6 +660,9 @@ function _handleRecent($line,$ns,$flags){
// remember in seen to skip additional sights
$seen[$id] = 1;
+ // check if it's a hidden page
+ if(isHiddenPage($id)) return false;
+
// filter namespace
if (($ns) && (strpos($id,$ns.':') !== 0)) return false;
diff --git a/inc/fulltext.php b/inc/fulltext.php
index 4d4b8138c..f48250548 100644
--- a/inc/fulltext.php
+++ b/inc/fulltext.php
@@ -44,6 +44,11 @@ function ft_pageSearch($query,&$poswords){
}
if(!count($docs)) return array();
+ // create a list of hidden pages in the result
+ $hidden = array();
+ $hidden = array_filter(array_keys($docs),'isHiddenPage');
+ $not = array_merge($not,$hidden);
+
// remove negative matches
foreach($not as $n){
unset($docs[$n]);
@@ -95,13 +100,14 @@ function ft_backlinks($id){
// quick lookup of the pagename
$page = noNS($id);
$sw = array(); // we don't use stopwords here
- $matches = idx_lookup(idx_tokenizer($page,$sw)); //pagename may contain specials (_ or .)
- $docs = ft_resultCombine(array_values($matches));
+ $matches = idx_lookup(idx_tokenizer($page,$sw)); // pagename may contain specials (_ or .)
+ $docs = array_keys(ft_resultCombine(array_values($matches)));
+ $docs = array_filter($docs,'isVisiblePage'); // discard hidden pages
if(!count($docs)) return $result;
require_once(DOKU_INC.'inc/parserutils.php');
// check instructions for matching links
- foreach(array_keys($docs) as $match){
+ foreach($docs as $match){
$instructions = p_cached_instructions(wikiFN($match),true);
if(is_null($instructions)) continue;
@@ -161,6 +167,7 @@ function ft_pageLookup($id,$pageonly=true){
}
}
+ $pages = array_filter($pages,'isVisiblePage'); // discard hidden pages
if(!count($pages)) return array();
// check ACL permissions
diff --git a/inc/pageutils.php b/inc/pageutils.php
index 1dc66981d..0f9b47e47 100644
--- a/inc/pageutils.php
+++ b/inc/pageutils.php
@@ -301,4 +301,28 @@ function getCacheName($data,$ext=''){
return $file;
}
+/**
+ * Checks a pageid against $conf['hidepages']
+ *
+ * @author Andreas Gohr <gohr@cosmocode.de>
+ */
+function isHiddenPage($id){
+ global $conf;
+ if(empty($conf['hidepages'])) return false;
+
+ if(preg_match('/'.$conf['hidepages'].'/ui',':'.$id)){
+ return true;
+ }
+ return false;
+}
+
+/**
+ * Reverse of isHiddenPage
+ *
+ * @author Andreas Gohr <gohr@cosmocode.de>
+ */
+function isVisiblePage($id){
+ return !isHiddenPage($id);
+}
+
//Setup VIM: ex: et ts=2 enc=utf-8 :
diff --git a/inc/search.php b/inc/search.php
index ffe85adc1..4000c445d 100644
--- a/inc/search.php
+++ b/inc/search.php
@@ -125,8 +125,14 @@ function search_index(&$data,$base,$file,$type,$lvl,$opts){
return false;
}
- //check ACL
$id = pathID($file);
+
+ //check hidden
+ if($type=='f' && isHiddenPage($id)){
+ return false;
+ }
+
+ //check ACL
if($type=='f' && auth_quickaclcheck($id) < AUTH_READ){
return false;
}
diff --git a/inc/template.php b/inc/template.php
index 302d9d1f5..71bb64b4c 100644
--- a/inc/template.php
+++ b/inc/template.php
@@ -905,6 +905,8 @@ function tpl_indexerWebBug(){
global $INFO;
if(!$INFO['exists']) return;
+ if(isHiddenPage($ID)) return; //no need to index hidden pages
+
$p = array();
$p['src'] = DOKU_BASE.'lib/exe/indexer.php?id='.urlencode($ID).
'&'.time();