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