fixing long lines
[lhc/web/wiklou.git] / includes / search / SearchEngine.php
index a8e0437..59dd7ab 100644 (file)
@@ -315,7 +315,7 @@ class SearchEngine {
                        return $parsed;
                }
 
-               $allkeyword = wfMsgForContent( 'searchall' ) . ":";
+               $allkeyword = wfMessage( 'searchall' )->inContentLanguage()->text() . ":";
                if ( strncmp( $query, $allkeyword, strlen( $allkeyword ) ) == 0 ) {
                        $this->namespaces = null;
                        $parsed = substr( $query, strlen( $allkeyword ) );
@@ -417,7 +417,7 @@ class SearchEngine {
                $formatted = array_map( array( $wgContLang, 'getFormattedNsText' ), $namespaces );
                foreach ( $formatted as $key => $ns ) {
                        if ( empty( $ns ) )
-                               $formatted[$key] = wfMsg( 'blanknamespace' );
+                               $formatted[$key] = wfMessage( 'blanknamespace' )->text();
                }
                return $formatted;
        }
@@ -757,7 +757,7 @@ class SearchResult {
                $this->mTitle = $title;
                if ( !is_null( $this->mTitle ) ) {
                        $this->mRevision = Revision::newFromTitle(
-                               $this->mTitle, false, Revision::AVOID_MASTER );
+                               $this->mTitle, false, Revision::READ_NORMAL );
                        if ( $this->mTitle->getNamespace() === NS_FILE )
                                $this->mImage = wfFindFile( $this->mTitle );
                }
@@ -802,11 +802,13 @@ class SearchResult {
         */
        protected function initText() {
                if ( !isset( $this->mText ) ) {
-                       if ( $this->mRevision != null )
-                               $this->mText = $this->mRevision->getText();
-                       else // TODO: can we fetch raw wikitext for commons images?
+                       if ( $this->mRevision != null ) {
+                               //TODO: don't use the text, but the content object!
+                               $content = $this->mRevision->getContent();
+                               $this->mText = $content->getTextForSearchIndex();
+                       } else { // TODO: can we fetch raw wikitext for commons images?
                                $this->mText = '';
-
+                       }
                }
        }
 
@@ -817,6 +819,8 @@ class SearchResult {
        function getTextSnippet( $terms ) {
                global $wgUser, $wgAdvancedSearchHighlighting;
                $this->initText();
+
+               // TODO: make highliter take a content object. Make ContentHandler a factory for SearchHighliter.
                list( $contextlines, $contextchars ) = SearchEngine::userHighlightPrefs( $wgUser );
                $h = new SearchHighlighter();
                if ( $wgAdvancedSearchHighlighting )