Pair to previous commit: handle the 'prefix' param - the default backend will just...
authorRobert Stojnić <rainman@users.mediawiki.org>
Wed, 31 Dec 2008 03:33:08 +0000 (03:33 +0000)
committerRobert Stojnić <rainman@users.mediawiki.org>
Wed, 31 Dec 2008 03:33:08 +0000 (03:33 +0000)
includes/SearchEngine.php
includes/specials/SpecialSearch.php

index 9aee994..bf0a722 100644 (file)
@@ -48,6 +48,14 @@ class SearchEngine {
                return true;
        }
        
+       /**
+        * Transform search term in cases when parts of the query came as different GET params (when supported)
+        * e.g. for prefix queries: search=test&prefix=Main_Page/Archive -> test prefix:Main Page/Archive
+        */
+       function transformSearchTerm( $term ) {
+               return $term;
+       }
+       
        /**
         * If an exact title match can be find, or a very slightly close match,
         * return the title. If no match, returns NULL.
index 279f8b7..90cbca5 100644 (file)
@@ -63,6 +63,7 @@ class SpecialSearch {
         */
        function __construct( &$request, &$user ) {
                list( $this->limit, $this->offset ) = $request->getLimitOffset( 20, 'searchlimit' );
+               $this->mPrefix = $request->getVal('prefix', '');
                # Extract requested namespaces
                $this->namespaces = $this->powerSearch( $request );
                if( empty( $this->namespaces ) ) {
@@ -148,6 +149,8 @@ class SpecialSearch {
                $search->setLimitOffset( $this->limit, $this->offset );
                $search->setNamespaces( $this->namespaces );
                $search->showRedirects = $this->searchRedirects;
+               $search->prefix = $this->mPrefix;
+               $term = $search->transformSearchTerm($term);
                $rewritten = $search->replacePrefixes($term);
 
                $titleMatches = $search->searchTitle( $rewritten );