From: Robert Leverington Date: Tue, 21 Jul 2009 14:45:21 +0000 (+0000) Subject: Add $wgSecondaryGoNamespace, used if an exact match is not found when pressing go... X-Git-Tag: 1.31.0-rc.0~40785 X-Git-Url: http://git.cyclocoop.org/%22.%24h.%22?a=commitdiff_plain;h=384c79213fa70300b5b013140a937be704699627;p=lhc%2Fweb%2Fwiklou.git Add $wgSecondaryGoNamespace, used if an exact match is not found when pressing go - will try to find a match in a different namespace before performing a search. See bug 19862. --- diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index ac6a066dae..740bf2e08a 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -4085,3 +4085,11 @@ $wgAutocreatePolicy = 'login'; * TODO: Implement message, global. */ $wgAllowPrefChange = array(); + +/** + * If an exact match is not found, try to find a match in a different namespace + * before performing a search. + * + * Integer: Id of namespace to attempt match in. + */ +$wgSecondaryGoNamespace = null; diff --git a/includes/SearchEngine.php b/includes/SearchEngine.php index daec7cad39..533f52689e 100644 --- a/includes/SearchEngine.php +++ b/includes/SearchEngine.php @@ -63,7 +63,7 @@ class SearchEngine { * @return Title */ public static function getNearMatch( $searchterm ) { - global $wgContLang; + global $wgContLang, $wgSecondaryGoNamespace; $allSearchTerms = array($searchterm); @@ -88,6 +88,12 @@ class SearchEngine { return $title; } + # If a match is not found in the main namespace look in secondary go namespace. + if( $wgSecondaryGoNamespace && $title->getNamespace() == NS_MAIN ) { + $title = Title::newFromText( $term, $wgSecondaryGoNamespace ); + if( $title && $title->exists() ) return $title; + } + # Now try all lower case (i.e. first letter capitalized) # $title = Title::newFromText( $wgContLang->lc( $term ) );