Use boolean searching with '?' char
authorAaron Schulz <aaron@users.mediawiki.org>
Fri, 5 Dec 2008 18:16:01 +0000 (18:16 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Fri, 5 Dec 2008 18:16:01 +0000 (18:16 +0000)
includes/SearchEngine.php
includes/SearchMySQL.php

index 66e8d9b..6aa726c 100644 (file)
@@ -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\\-\\?";
        }
 
        /**
index f9b71c8..6f2b338 100644 (file)
@@ -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] ) ) {