Add $wgSecondaryGoNamespace, used if an exact match is not found when pressing go...
authorRobert Leverington <roberthl@users.mediawiki.org>
Tue, 21 Jul 2009 14:45:21 +0000 (14:45 +0000)
committerRobert Leverington <roberthl@users.mediawiki.org>
Tue, 21 Jul 2009 14:45:21 +0000 (14:45 +0000)
See bug 19862.

includes/DefaultSettings.php
includes/SearchEngine.php

index ac6a066..740bf2e 100644 (file)
@@ -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;
index daec7ca..533f526 100644 (file)
@@ -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 ) );