MediaWiki REL1_37
|
Highlight bits of wikitext. More...
Public Member Functions | |
__construct ( $cleanupWikitext=true) | |
highlightNone ( $text, $contextlines=self::DEFAULT_CONTEXT_LINES, $contextchars=self::DEFAULT_CONTEXT_CHARS) | |
Returns the first few lines of the text. | |
highlightSimple ( $text, $terms, $contextlines=self::DEFAULT_CONTEXT_LINES, $contextchars=self::DEFAULT_CONTEXT_CHARS) | |
Simple & fast snippet extraction, but gives completely irrelevant snippets. | |
highlightText ( $text, $terms, $contextlines=self::DEFAULT_CONTEXT_LINES, $contextchars=self::DEFAULT_CONTEXT_CHARS) | |
Wikitext highlighting when $wgAdvancedSearchHighlighting = true. | |
Public Attributes | |
const | DEFAULT_CONTEXT_CHARS = 75 |
const | DEFAULT_CONTEXT_LINES = 2 |
Protected Attributes | |
$mCleanWikitext = true | |
Private Member Functions | |
caseCallback ( $matches) | |
Do manual case conversion for non-ascii chars. | |
extract ( $text, $start, $end, &$posStart=null, &$posEnd=null) | |
Extract part of the text from start to end, but by not chopping up words. | |
linkReplace ( $matches) | |
callback to replace [[target|caption]] kind of links, if the target is category or image, leave it | |
position ( $text, $point, $offset=0) | |
Find a nonletter near a point (index) in the text. | |
process ( $pattern, $extracts, &$linesleft, &$contextchars, &$out, &$offsets) | |
Search extracts for a pattern, and return snippets. | |
removeWiki ( $text) | |
Basic wikitext removal. | |
splitAndAdd (&$extracts, &$count, $text) | |
Split text into lines and add it to extracts array. | |
Highlight bits of wikitext.
@newable
Definition at line 34 of file SearchHighlighter.php.
SearchHighlighter::__construct | ( | $cleanupWikitext = true | ) |
bool | $cleanupWikitext |
Definition at line 46 of file SearchHighlighter.php.
|
private |
Do manual case conversion for non-ascii chars.
array | $matches |
Definition at line 333 of file SearchHighlighter.php.
References $matches.
|
private |
Extract part of the text from start to end, but by not chopping up words.
string | $text | |
int | $start | |
int | $end | |
int | null | &$posStart | (out) actual start position |
int | null | &$posEnd | (out) actual end position |
Definition at line 353 of file SearchHighlighter.php.
References position().
Referenced by highlightText(), and process().
SearchHighlighter::highlightNone | ( | $text, | |
$contextlines = self::DEFAULT_CONTEXT_LINES , |
|||
$contextchars = self::DEFAULT_CONTEXT_CHARS |
|||
) |
Returns the first few lines of the text.
string | $text | |
int | $contextlines | Max number of returned lines |
int | $contextchars | Average number of characters per line |
Definition at line 577 of file SearchHighlighter.php.
SearchHighlighter::highlightSimple | ( | $text, | |
$terms, | |||
$contextlines = self::DEFAULT_CONTEXT_LINES , |
|||
$contextchars = self::DEFAULT_CONTEXT_CHARS |
|||
) |
Simple & fast snippet extraction, but gives completely irrelevant snippets.
Used when $wgAdvancedSearchHighlighting is false.
string | $text | |
string[] | $terms | Escaped for regex by SearchDatabase::regexTerm() |
int | $contextlines | |
int | $contextchars |
Definition at line 521 of file SearchHighlighter.php.
SearchHighlighter::highlightText | ( | $text, | |
$terms, | |||
$contextlines = self::DEFAULT_CONTEXT_LINES , |
|||
$contextchars = self::DEFAULT_CONTEXT_CHARS |
|||
) |
Wikitext highlighting when $wgAdvancedSearchHighlighting = true.
string | $text | |
string[] | $terms | Terms to highlight (not html escaped but regex escaped via SearchDatabase::regexTerm()) |
int | $contextlines | |
int | $contextchars |
Definition at line 60 of file SearchHighlighter.php.
References $line, $matches, $wgSearchHighlightBoundaries, extract(), NS_FILE, process(), and splitAndAdd().
|
private |
callback to replace [[target|caption]] kind of links, if the target is category or image, leave it
array | $matches |
Definition at line 495 of file SearchHighlighter.php.
References $matches, NS_CATEGORY, and NS_FILE.
|
private |
Find a nonletter near a point (index) in the text.
string | $text | |
int | $point | |
int | $offset | Offset to found index |
Definition at line 385 of file SearchHighlighter.php.
References $s.
Referenced by extract().
|
private |
Search extracts for a pattern, and return snippets.
string | $pattern | Regexp for matching lines |
array | $extracts | Extracts to search |
int | &$linesleft | Number of extracts to make |
int | &$contextchars | Length of snippet |
array | &$out | Map for highlighted snippets |
array | &$offsets | Map of starting points of snippets |
Definition at line 425 of file SearchHighlighter.php.
References $line, and extract().
Referenced by highlightText().
|
private |
Basic wikitext removal.
string | $text |
Definition at line 467 of file SearchHighlighter.php.
Referenced by splitAndAdd().
|
private |
Split text into lines and add it to extracts array.
string[] | &$extracts | Index -> $line |
int | &$count | |
string | $text |
Definition at line 317 of file SearchHighlighter.php.
References $line, and removeWiki().
Referenced by highlightText().
|
protected |
Definition at line 38 of file SearchHighlighter.php.
const SearchHighlighter::DEFAULT_CONTEXT_CHARS = 75 |
Definition at line 36 of file SearchHighlighter.php.
Referenced by SearchEngine\userHighlightPrefs().
const SearchHighlighter::DEFAULT_CONTEXT_LINES = 2 |
Definition at line 35 of file SearchHighlighter.php.
Referenced by SearchEngine\userHighlightPrefs().