Handle space in namespace prefixed searches
[lhc/web/wiklou.git] / includes / search / SearchEngine.php
index 94d39a5..51cc539 100644 (file)
@@ -41,19 +41,6 @@ class SearchEngine {
        /// Feature values
        protected $features = array();
 
-       /**
-        * @var DatabaseBase
-        */
-       protected $db;
-
-       function __construct( $db = null ) {
-               if ( $db ) {
-                       $this->db = $db;
-               } else {
-                       $this->db = wfGetDB( DB_SLAVE );
-               }
-       }
-
        /**
         * Perform a full text search query and return a result set.
         * If title searches are not supported or disabled, return null.
@@ -78,16 +65,6 @@ class SearchEngine {
                return null;
        }
 
-       /**
-        * If this search backend can list/unlist redirects
-        * @deprecated since 1.18 Call supports( 'list-redirects' );
-        * @return bool
-        */
-       function acceptListRedirects() {
-               wfDeprecated( __METHOD__, '1.18' );
-               return $this->supports( 'list-redirects' );
-       }
-
        /**
         * @since 1.18
         * @param $feature String
@@ -337,7 +314,7 @@ class SearchEngine {
                        $this->namespaces = null;
                        $parsed = substr( $query, strlen( $allkeyword ) );
                } elseif ( strpos( $query, ':' ) !== false ) {
-                       $prefix = substr( $query, 0, strpos( $query, ':' ) );
+                       $prefix = str_replace( ' ', '_', substr( $query, 0, strpos( $query, ':' ) ) );
                        $index = $wgContLang->getNsIndex( $prefix );
                        if ( $index !== false ) {
                                $this->namespaces = array( $index );
@@ -485,7 +462,6 @@ class SearchEngine {
                }
 
                $search = new $class( $dbr );
-               $search->setLimitOffset( 0, 0 );
                return $search;
        }
 
@@ -762,18 +738,22 @@ class SearchResult {
        /**
         * @var Revision
         */
-       var $mRevision = null;
-       var $mImage = null;
+       protected $mRevision = null;
+
+       /**
+        * @var File
+        */
+       protected $mImage = null;
 
        /**
         * @var Title
         */
-       var $mTitle;
+       protected $mTitle;
 
        /**
         * @var String
         */
-       var $mText;
+       protected $mText;
 
        /**
         * Return a new SearchResult and initializes it with a title.
@@ -840,10 +820,7 @@ class SearchResult {
         * @return Boolean
         */
        function isBrokenTitle() {
-               if ( is_null( $this->mTitle ) ) {
-                       return true;
-               }
-               return false;
+               return is_null( $this->mTitle );
        }
 
        /**
@@ -862,6 +839,14 @@ class SearchResult {
                return $this->mTitle;
        }
 
+       /**
+        * Get the file for this page, if one exists
+        * @return File|null
+        */
+       function getFile() {
+               return $this->mImage;
+       }
+
        /**
         * @return float|null if not supported
         */
@@ -979,6 +964,13 @@ class SearchResult {
        function getInterwikiPrefix() {
                return '';
        }
+
+       /**
+        * Did this match file contents (eg: PDF/DJVU)?
+        */
+       function isFileMatch() {
+               return false;
+       }
 }
 /**
  * A SearchResultSet wrapper for SearchEngine::getNearMatch