Add SearchGetNearMatch hook, have TitleKey provide a case-insensitive exact match...
authorBrion Vibber <brion@users.mediawiki.org>
Thu, 31 Jan 2008 20:51:42 +0000 (20:51 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Thu, 31 Jan 2008 20:51:42 +0000 (20:51 +0000)
docs/hooks.txt
includes/SearchEngine.php

index bca4439..fb9517a 100644 (file)
@@ -844,6 +844,10 @@ $namespace : Page namespace
 $title : Page title
 $text : Current text being indexed
 
+'SearchGetNearMatch': An extra chance for exact-title-matches in "go" searches
+$term : Search term string
+&$title : Outparam; set to $title object and return false for a match
+
 'ShowRawCssJs': Customise the output of raw CSS and JavaScript in page views
 $text: Text being shown
 $title: Title of the custom script/stylesheet page
index 9120da5..c25b9bd 100644 (file)
@@ -51,7 +51,7 @@ class SearchEngine {
                if($wgContLang->hasVariants()){
                        $allSearchTerms = array_merge($allSearchTerms,$wgContLang->convertLinkToAllVariants($searchterm));
                }
-
+               
                foreach($allSearchTerms as $term){
 
                        # Exact match? No need to look further.
@@ -102,6 +102,12 @@ class SearchEngine {
                                        return $title;
                                }
                        }
+
+                       // Give hooks a chance at better match variants
+                       $title = null;
+                       if( !wfRunHooks( 'SearchGetNearMatch', array( $term, &$title ) ) ) {
+                               return $title;
+                       }
                }
 
                $title = Title::newFromText( $searchterm );