[[Special:Search]] now could search terms in all variant-forms. ONLY apply on wikis...
authorPhilip Tzou <philip@users.mediawiki.org>
Tue, 9 Jun 2009 19:19:14 +0000 (19:19 +0000)
committerPhilip Tzou <philip@users.mediawiki.org>
Tue, 9 Jun 2009 19:19:14 +0000 (19:19 +0000)
RELEASE-NOTES
includes/SearchIBM_DB2.php
includes/SearchMySQL.php
includes/SearchOracle.php

index eac847a..0882bed 100644 (file)
@@ -81,6 +81,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   'recentchangeslinked-toolbox' were added to allow more fine grained
   customisation of the user interface
 * DISPLAYTITLE now accepts a limited amount of wiki markup (the single-quote items)
+* Special:Search now could search terms in all variant-forms. ONLY apply on
+  wikis with LanguageConverter
 
 === Bug fixes in 1.16 ===
 
index 9cad594..b94a478 100644 (file)
@@ -151,7 +151,17 @@ class SearchIBM_DB2 extends SearchEngine {
                if (preg_match_all('/([-+<>~]?)(([' . $lc . ']+)(\*?)|"[^"]*")/',
                          $filteredText, $m, PREG_SET_ORDER)) {
                        foreach($m as $terms) {
-                               $q[] = $terms[1] . $wgContLang->stripForSearch($terms[2]);
+
+                               // Search terms in all variant forms, only
+                               // apply on wiki with LanguageConverter
+                               $temp_terms = $wgContLang->autoConvertToAllVariants( $terms[2] );
+                               if( is_array( $temp_terms )) {
+                                       $temp_terms = array_unique( array_values( $temp_terms ));
+                                       foreach( $temp_terms as $t )
+                                               $q[] = $terms[1] . $wgContLang->stripForSearch( $t );
+                               }
+                               else
+                                       $q[] = $terms[1] . $wgContLang->stripForSearch( $terms[2] );
 
                                if (!empty($terms[3])) {
                                        $regexp = preg_quote( $terms[3], '/' );
index 59e1f0e..78aa60f 100644 (file)
@@ -53,7 +53,16 @@ class SearchMySQL extends SearchEngine {
                                if( $this->strictMatching && ($terms[1] == '') ) {
                                        $terms[1] = '+';
                                }
-                               $searchon .= $terms[1] . $wgContLang->stripForSearch( $terms[2] );
+                               // Search terms in all variant forms, only
+                               // apply on wiki with LanguageConverter
+                               $temp_terms = $wgContLang->autoConvertToAllVariants( $terms[2] );
+                               if( is_array( $temp_terms )) {
+                                       $temp_terms = array_unique( array_values( $temp_terms ));
+                                       foreach( $temp_terms as $t )
+                                               $searchon .= $terms[1] . $wgContLang->stripForSearch( $t ) . ' ';
+                               }
+                               else
+                                       $searchon .= $terms[1] . $wgContLang->stripForSearch( $terms[2] );
                                if( !empty( $terms[3] ) ) {
                                        // Match individual terms in result highlighting...
                                        $regexp = preg_quote( $terms[3], '/' );
@@ -259,4 +268,4 @@ class MySQLSearchResultSet extends SearchResultSet {
        function free() {
                $this->mResultSet->free();
        }
-}
+}
\ No newline at end of file
index b54fb85..3cd91fa 100644 (file)
@@ -159,7 +159,17 @@ class SearchOracle extends SearchEngine {
                if (preg_match_all('/([-+<>~]?)(([' . $lc . ']+)(\*?)|"[^"]*")/',
                          $filteredText, $m, PREG_SET_ORDER)) {
                        foreach($m as $terms) {
-                               $q[] = $terms[1] . $wgContLang->stripForSearch($terms[2]);
+                               
+                               // Search terms in all variant forms, only
+                               // apply on wiki with LanguageConverter
+                               $temp_terms = $wgContLang->autoConvertToAllVariants( $terms[2] );
+                               if( is_array( $temp_terms )) {
+                                       $temp_terms = array_unique( array_values( $temp_terms ));
+                                       foreach( $temp_terms as $t )
+                                               $q[] = $terms[1] . $wgContLang->stripForSearch( $t );
+                               }
+                               else
+                                       $q[] = $terms[1] . $wgContLang->stripForSearch( $terms[2] );
 
                                if (!empty($terms[3])) {
                                        $regexp = preg_quote( $terms[3], '/' );