* @ingroup Search
*/
+use MediaWiki\MediaWikiServices;
+
/**
* @todo FIXME: This class is horribly factored. It would probably be better to
* have a useful base class to which you pass some standard information, then
*/
protected $mText;
+ /**
+ * @var SearchEngine
+ */
+ protected $searchEngine;
+
/**
* Return a new SearchResult and initializes it with a title.
*
* @return SearchResult
*/
public static function newFromTitle( $title ) {
- $result = new self();
+ $result = new static();
$result->initFromTitle( $title );
return $result;
}
$this->mImage = wfFindFile( $this->mTitle );
}
}
+ $this->searchEngine = MediaWikiServices::getInstance()->newSearchEngine();
}
/**
protected function initText() {
if ( !isset( $this->mText ) ) {
if ( $this->mRevision != null ) {
- $this->mText = SearchEngine::create()
- ->getTextFromContent( $this->mTitle, $this->mRevision->getContent() );
+ $this->mText = $this->searchEngine->getTextFromContent(
+ $this->mTitle, $this->mRevision->getContent() );
} else { // TODO: can we fetch raw wikitext for commons images?
$this->mText = '';
}
$this->initText();
// TODO: make highliter take a content object. Make ContentHandler a factory for SearchHighliter.
- list( $contextlines, $contextchars ) = SearchEngine::userHighlightPrefs();
+ list( $contextlines, $contextchars ) = $this->searchEngine->userHighlightPrefs();
$h = new SearchHighlighter();
if ( count( $terms ) > 0 ) {