From: Philip Tzou Date: Tue, 9 Jun 2009 19:19:14 +0000 (+0000) Subject: [[Special:Search]] now could search terms in all variant-forms. ONLY apply on wikis... X-Git-Tag: 1.31.0-rc.0~41431 X-Git-Url: http://git.heureux-cyclage.org/?a=commitdiff_plain;h=282338b31a3f86459db5da2fddca0978ea0436aa;p=lhc%2Fweb%2Fwiklou.git [[Special:Search]] now could search terms in all variant-forms. ONLY apply on wikis with LanguageConverter. --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index eac847a4f3..0882bedda8 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 === diff --git a/includes/SearchIBM_DB2.php b/includes/SearchIBM_DB2.php index 9cad594b30..b94a478236 100644 --- a/includes/SearchIBM_DB2.php +++ b/includes/SearchIBM_DB2.php @@ -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], '/' ); diff --git a/includes/SearchMySQL.php b/includes/SearchMySQL.php index 59e1f0e41b..78aa60fa04 100644 --- a/includes/SearchMySQL.php +++ b/includes/SearchMySQL.php @@ -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 diff --git a/includes/SearchOracle.php b/includes/SearchOracle.php index b54fb859b9..3cd91faab8 100644 --- a/includes/SearchOracle.php +++ b/includes/SearchOracle.php @@ -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], '/' );