MediaWiki  master
SqlSearchResult.php
Go to the documentation of this file.
1 <?php
2 
27  private $terms;
28 
34  public function __construct( Title $title, array $terms ) {
35  parent::__construct( $title );
36  $this->terms = $terms;
37  }
38 
42  public function getTermMatches(): array {
43  return $this->terms;
44  }
45 
50  function getTextSnippet( $terms = [] ) {
52  $this->initText();
53 
54  $h = new SearchHighlighter();
55  if ( count( $this->terms ) > 0 ) {
56  if ( $wgAdvancedSearchHighlighting ) {
57  return $h->highlightText( $this->mText, $this->terms );
58  } else {
59  return $h->highlightSimple( $this->mText, $this->terms );
60  }
61  } else {
62  return $h->highlightNone( $this->mText );
63  }
64  }
65 
66 }
SearchResult class based on the Revision information.
getTermMatches()
return string[]
Highlight bits of wikitext.
initText()
Lazy initialization of article text from DB.
__construct(Title $title, array $terms)
SqlSearchResult constructor.
getTextSnippet( $terms=[])
$wgAdvancedSearchHighlighting
Set to true to have nicer highlighted text in search results, by default off due to execution overhea...