MediaWiki  1.34.0
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 ) {
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 }
SqlSearchResult
Definition: SqlSearchResult.php:25
SqlSearchResult\$terms
string[] $terms
Definition: SqlSearchResult.php:27
SqlSearchResult\__construct
__construct(Title $title, array $terms)
SqlSearchResult constructor.
Definition: SqlSearchResult.php:34
RevisionSearchResult
SearchResult class based on the Revision information.
Definition: RevisionSearchResult.php:8
$title
$title
Definition: testCompression.php:34
$wgAdvancedSearchHighlighting
$wgAdvancedSearchHighlighting
Set to true to have nicer highlighted text in search results, by default off due to execution overhea...
Definition: DefaultSettings.php:6528
SearchHighlighter
Highlight bits of wikitext.
Definition: SearchHighlighter.php:31
SqlSearchResult\getTermMatches
getTermMatches()
return string[]
Definition: SqlSearchResult.php:42
Title
Represents a title within MediaWiki.
Definition: Title.php:42
initText
initText()
Lazy initialization of article text from DB.
Definition: RevisionSearchResultTrait.php:89
SqlSearchResult\getTextSnippet
getTextSnippet( $terms=[])
Definition: SqlSearchResult.php:50