aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/search
diff options
context:
space:
mode:
authorNils Adermann <naderman@naderman.de>2007-01-05 21:17:28 +0000
committerNils Adermann <naderman@naderman.de>2007-01-05 21:17:28 +0000
commitce13b9b9963b2d11bae2eca26560b1f74bd5505f (patch)
treeb0ff589bf29acf71ef4c953531af1ee385f8b089 /phpBB/includes/search
parent77335d94e4258112a69b5484a3006233c7550630 (diff)
downloadforums-ce13b9b9963b2d11bae2eca26560b1f74bd5505f.tar
forums-ce13b9b9963b2d11bae2eca26560b1f74bd5505f.tar.gz
forums-ce13b9b9963b2d11bae2eca26560b1f74bd5505f.tar.bz2
forums-ce13b9b9963b2d11bae2eca26560b1f74bd5505f.tar.xz
forums-ce13b9b9963b2d11bae2eca26560b1f74bd5505f.zip
- use constants no weird numbers ;-)
- solved problem with \w using UTF-8 search (fulltext_mysql) by using PCRE unicode character properties if available [Bug #5768] git-svn-id: file:///svn/phpbb/trunk@6843 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/search')
-rw-r--r--phpBB/includes/search/fulltext_mysql.php14
1 files changed, 10 insertions, 4 deletions
diff --git a/phpBB/includes/search/fulltext_mysql.php b/phpBB/includes/search/fulltext_mysql.php
index f20962d11d..e475e012f0 100644
--- a/phpBB/includes/search/fulltext_mysql.php
+++ b/phpBB/includes/search/fulltext_mysql.php
@@ -32,6 +32,7 @@ class fulltext_mysql extends search_backend
var $split_words = array();
var $search_query;
var $common_words = array();
+ var $pcre_properties = false;
function fulltext_mysql(&$error)
{
@@ -39,6 +40,11 @@ class fulltext_mysql extends search_backend
$this->word_length = array('min' => $config['fulltext_mysql_min_word_len'], 'max' => $config['fulltext_mysql_max_word_len']);
+ if (version_compare(PHP_VERSION, '5.1.0', '>=') || (version_compare(PHP_VERSION, '5.0.0-dev', '<=') && version_compare(PHP_VERSION, '4.4.0', '>=')))
+ {
+ $this->pcre_properties = true;
+ }
+
$error = false;
}
@@ -123,9 +129,9 @@ class fulltext_mysql extends search_backend
$keywords = preg_replace($match, ' ', trim($keywords));
// Split words
- $split_keywords = preg_replace('#([^\w\'*])#', '$1$1', str_replace('\'\'', '\' \'', trim($keywords)));
+ $split_keywords = preg_replace(($this->pcre_properties) ? '#([^\p{L}\p{N}\'*])#u' : '#([^\w\'*])#u', '$1$1', str_replace('\'\'', '\' \'', trim($keywords)));
$matches = array();
- preg_match_all('#(?:[^\w*]|^)([+\-|]?(?:[\w*]+\'?)*[\w*])(?:[^\w*]|$)#', $split_keywords, $matches);
+ preg_match_all(($this->pcre_properties) ? '#(?:[^\p{L}\p{N}*]|^)([+\-|]?(?:[\p{L}\p{N}*]+\'?)*[\p{L}\p{N}*])(?:[^\p{L}\p{N}*]|$)#u' : '#(?:[^\w*]|^)([+\-|]?(?:[\w*]+\'?)*[\w*])(?:[^\w*]|$)#u', $split_keywords, $matches);
$this->split_words = $matches[1];
if (sizeof($this->ignore_words))
@@ -174,9 +180,9 @@ class fulltext_mysql extends search_backend
$this->get_synonyms();
// Split words
- $text = preg_replace('#([^\w\'*])#', '$1$1', str_replace('\'\'', '\' \'', trim($text)));
+ $text = preg_replace(($this->pcre_properties) ? '#([^\p{L}\p{N}\'*])#u' : '#([^\w\'*])#u', '$1$1', str_replace('\'\'', '\' \'', trim($text)));
$matches = array();
- preg_match_all('#(?:[^\w*]|^)([+\-|]?(?:[\w*]+\'?)*[\w*])(?:[^\w*]|$)#', $text, $matches);
+ preg_match_all(($this->pcre_properties) ? '#(?:[^\p{L}\p{N}*]|^)([+\-|]?(?:[\p{L}\p{N}*]+\'?)*[\p{L}\p{N}*])(?:[^\p{L}\p{N}*]|$)#u' : '#(?:[^\w*]|^)([+\-|]?(?:[\w*]+\'?)*[\w*])(?:[^\w*]|$)#u', $text, $matches);
$text = $matches[1];
if (sizeof($this->ignore_words))