diff options
author | chris <chris@jalakai.co.uk> | 2006-01-22 02:12:49 +0100 |
---|---|---|
committer | chris <chris@jalakai.co.uk> | 2006-01-22 02:12:49 +0100 |
commit | b9ac8716a5af742f88887fb9c1315b0e01d244a3 (patch) | |
tree | 033c9ac38ede329565a598bbcb9a1a12edfea4b6 | |
parent | fd7c2db0d17e5b53981fef40fe9e3eca46b34038 (diff) | |
download | rpg-b9ac8716a5af742f88887fb9c1315b0e01d244a3.tar.gz rpg-b9ac8716a5af742f88887fb9c1315b0e01d244a3.tar.bz2 |
adds support for wordblock.local.conf
darcs-hash:20060122011249-9b6ab-fdd9188322e1dc4441562a905ac481f66b703db2.gz
-rw-r--r-- | inc/common.php | 8 | ||||
-rw-r--r-- | inc/confutils.php | 17 |
2 files changed, 22 insertions, 3 deletions
diff --git a/inc/common.php b/inc/common.php index c943ffa3c..b5c29d621 100644 --- a/inc/common.php +++ b/inc/common.php @@ -365,7 +365,7 @@ function checkwordblock(){ if(!$conf['usewordblock']) return false; - $blockfile = file(DOKU_CONF.'wordblock.conf'); + $wordblocks = getWordblocks(); //how many lines to read at once (to work around some PCRE limits) if(version_compare(phpversion(),'4.3.0','<')){ //old versions of PCRE define a maximum of parenthesises even if no @@ -377,7 +377,7 @@ function checkwordblock(){ //MAX_PATTERN_SIZE in modern PCRE $chunksize = 600; } - while($blocks = array_splice($blockfile,0,$chunksize)){ + while($blocks = array_splice($wordblocks,0,$chunksize)){ $re = array(); #build regexp from blocks foreach($blocks as $block){ @@ -386,7 +386,9 @@ function checkwordblock(){ if(empty($block)) continue; $re[] = $block; } - if(preg_match('#('.join('|',$re).')#si',$TEXT)) return true; + if(preg_match('#('.join('|',$re).')#si',$TEXT, $match=array())) { + return true; + } } return false; } diff --git a/inc/confutils.php b/inc/confutils.php index 9432c10d5..cc1d8064a 100644 --- a/inc/confutils.php +++ b/inc/confutils.php @@ -116,6 +116,23 @@ function getInterwiki() { } /** + * returns array of wordblock patterns + * + */ +function getWordblocks() { + static $wordblocks = NULL; + if ( !$wordblocks ) { + $wordblocks = file(DOKU_CONF.'wordblock.conf'); + if (@file_exists(DOKU_CONF.'wordblock.local.conf')) { + $local = file(DOKU_CONF.'wordblock.local.conf'); + $wordblocks = array_merge($wordblocks, $local); + } + } + return $wordblocks; +} + + +/** * Builds a hash from a configfile * * If $lower is set to true all hash keys are converted to |