Reorder SpecialRecentChanges::webOutput
[lhc/web/wiklou.git] / includes / search / SearchEngine.php
index a975b03..4f4e31d 100644 (file)
@@ -494,6 +494,18 @@ class SearchEngine {
                // no-op
        }
 
+       /**
+        * Delete an indexed page
+        * Title should be pre-processed.
+        * STUB
+        *
+        * @param Integer $id Page id that was deleted
+        * @param String $title Title of page that was deleted
+        */
+       function delete( $id, $title ) {
+               // no-op
+       }
+
        /**
         * Get OpenSearch suggestion template
         *
@@ -511,6 +523,20 @@ class SearchEngine {
                        return $wgCanonicalServer . wfScript( 'api' ) . '?action=opensearch&search={searchTerms}&namespace=' . $ns;
                }
        }
+
+       /**
+        * Get the raw text for updating the index from a content object
+        * Nicer search backends could possibly do something cooler than
+        * just returning raw text
+        *
+        * @todo This isn't ideal, we'd really like to have content-specific handling here
+        * @param Title $t Title we're indexing
+        * @param Content $c Content of the page to index
+        * @return string
+        */
+       public function getTextFromContent( Title $t, Content $c = null ) {
+               return $c ? $c->getTextForSearchIndex() : '';
+       }
 }
 
 /**
@@ -803,10 +829,8 @@ class SearchResult {
        protected function initText() {
                if ( !isset( $this->mText ) ) {
                        if ( $this->mRevision != null ) {
-                               //TODO: if we could plug in some code that knows about special content models *and* about
-                               //      special features of the search engine, the search could benefit.
-                               $content = $this->mRevision->getContent();
-                               $this->mText = $content ? $content->getTextForSearchIndex() : '';
+                               $this->mText = SearchEngine::create()
+                                       ->getTextFromContent( $this->mTitle, $this->mRevision->getContent() );
                        } else { // TODO: can we fetch raw wikitext for commons images?
                                $this->mText = '';
                        }