From: Aaron Schulz Date: Fri, 5 Dec 2008 18:16:01 +0000 (+0000) Subject: Use boolean searching with '?' char X-Git-Tag: 1.31.0-rc.0~44112 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22auteur_infos%22%2C%20%22id_auteur=%24id%22%29%20.%20%22?a=commitdiff_plain;h=845262071171c5a7f5e712d467e1df9bf77beb4d;p=lhc%2Fweb%2Fwiklou.git Use boolean searching with '?' char --- diff --git a/includes/SearchEngine.php b/includes/SearchEngine.php index 66e8d9bb8a..6aa726c8c2 100644 --- a/includes/SearchEngine.php +++ b/includes/SearchEngine.php @@ -150,7 +150,7 @@ class SearchEngine { } public static function legalSearchChars() { - return "A-Za-z_'0-9\\x80-\\xFF\\-"; + return "A-Za-z_'0-9\\x80-\\xFF\\-\\?"; } /** diff --git a/includes/SearchMySQL.php b/includes/SearchMySQL.php index f9b71c8ecd..6f2b3388a5 100644 --- a/includes/SearchMySQL.php +++ b/includes/SearchMySQL.php @@ -43,12 +43,18 @@ class SearchMySQL extends SearchEngine { # FIXME: This doesn't handle parenthetical expressions. $m = array(); - if( preg_match_all( '/([-+<>~]?)(([' . $lc . ']+)(\*?)|"[^"]*")/', - $filteredText, $m, PREG_SET_ORDER ) ) { + if( preg_match_all( '/([-+<>?~]?)(([' . $lc . ']+)(\*?)|"[^"]*")/', + $filteredText, $m, PREG_SET_ORDER ) ) + { foreach( $m as $terms ) { if( $searchon !== '' ) $searchon .= ' '; - if( $this->strictMatching && ($terms[1] == '') ) { - $terms[1] = '+'; + if( $this->strictMatching ) { + // '' means AND while ? means OR to the user + if( $terms[1] == '' ) { + $terms[1] = '+'; + } else if( $terms[1] == '?' ) { + $terms[1] = ''; + } } $searchon .= $terms[1] . $wgContLang->stripForSearch( $terms[2] ); if( !empty( $terms[3] ) ) {