MediaWiki  1.23.2
SearchHighlighter Class Reference

Highlight bits of wikitext. More...

Public Member Functions

 __construct ( $cleanupWikitext=true)
 
 caseCallback ( $matches)
 Do manual case conversion for non-ascii chars. More...
 
 extract ( $text, $start, $end, &$posStart=null, &$posEnd=null)
 Extract part of the text from start to end, but by not chopping up words. More...
 
 highlightSimple ( $text, $terms, $contextlines, $contextchars)
 Simple & fast snippet extraction, but gives completely unrelevant snippets. More...
 
 highlightText ( $text, $terms, $contextlines, $contextchars)
 Default implementation of wikitext highlighting. More...
 
 linkReplace ( $matches)
 callback to replace [[target|caption]] kind of links, if the target is category or image, leave it More...
 
 position ( $text, $point, $offset=0)
 Find a nonletter near a point (index) in the text. More...
 
 process ( $pattern, $extracts, &$linesleft, &$contextchars, &$out, &$offsets)
 Search extracts for a pattern, and return snippets. More...
 
 removeWiki ( $text)
 Basic wikitext removal. More...
 
 splitAndAdd (&$extracts, &$count, $text)
 Split text into lines and add it to extracts array. More...
 

Public Attributes

 $mCleanWikitext = true
 

Detailed Description

Highlight bits of wikitext.

Definition at line 29 of file SearchHighlighter.php.

Constructor & Destructor Documentation

◆ __construct()

SearchHighlighter::__construct (   $cleanupWikitext = true)

Definition at line 32 of file SearchHighlighter.php.

Member Function Documentation

◆ caseCallback()

SearchHighlighter::caseCallback (   $matches)

Do manual case conversion for non-ascii chars.

Parameters
$matchesArray
Returns
string

Definition at line 307 of file SearchHighlighter.php.

References $matches, $wgContLang, and global.

◆ extract()

SearchHighlighter::extract (   $text,
  $start,
  $end,
$posStart = null,
$posEnd = null 
)

Extract part of the text from start to end, but by not chopping up words.

Parameters
$textString
$startInteger
$endInteger
$posStartInteger: (out) actual start position
$posEndInteger: (out) actual end position
Returns
String

Definition at line 326 of file SearchHighlighter.php.

References position().

Referenced by highlightText(), and process().

◆ highlightSimple()

SearchHighlighter::highlightSimple (   $text,
  $terms,
  $contextlines,
  $contextchars 
)

Simple & fast snippet extraction, but gives completely unrelevant snippets.

Parameters
$textString
$termsArray
$contextlinesInteger
$contextcharsInteger
Returns
String

Definition at line 489 of file SearchHighlighter.php.

References $fname, $line, $lines, $pre, $wgContLang, array(), as, global, wfProfileIn(), and wfProfileOut().

◆ highlightText()

SearchHighlighter::highlightText (   $text,
  $terms,
  $contextlines,
  $contextchars 
)

Default implementation of wikitext highlighting.

Parameters
$textString
array$termsterms to highlight (unescaped)
$contextlinesInteger
$contextcharsInteger
Returns
String

Definition at line 45 of file SearchHighlighter.php.

References $count, $fname, $last, $line, $matches, $processed, $term, $wgContLang, array(), as, extract(), global, NS_FILE, process(), splitAndAdd(), wfProfileIn(), and wfProfileOut().

◆ linkReplace()

SearchHighlighter::linkReplace (   $matches)

callback to replace [[target|caption]] kind of links, if the target is category or image, leave it

Parameters
$matchesArray

Definition at line 464 of file SearchHighlighter.php.

References $matches, $wgContLang, global, NS_CATEGORY, and NS_FILE.

◆ position()

SearchHighlighter::position (   $text,
  $point,
  $offset = 0 
)

Find a nonletter near a point (index) in the text.

Parameters
$textString
$pointInteger
$offsetInteger: offset to found index
Returns
Integer: nearest nonletter index, or beginning of utf8 char if none

Definition at line 358 of file SearchHighlighter.php.

References $s, and array().

Referenced by extract().

◆ process()

SearchHighlighter::process (   $pattern,
  $extracts,
$linesleft,
$contextchars,
$out,
$offsets 
)

Search extracts for a pattern, and return snippets.

Parameters
string$patternregexp for matching lines
array$extractsextracts to search
$linesleftInteger: number of extracts to make
$contextcharsInteger: length of snippet
array$outmap for highlighted snippets
array$offsetsmap of starting points of snippets
Access:\n protected

Definition at line 392 of file SearchHighlighter.php.

References $line, $out, array(), as, and extract().

Referenced by highlightText().

◆ removeWiki()

SearchHighlighter::removeWiki (   $text)

Basic wikitext removal.

Access:\n protected
Returns
mixed

Definition at line 434 of file SearchHighlighter.php.

References $fname, array(), wfProfileIn(), and wfProfileOut().

Referenced by splitAndAdd().

◆ splitAndAdd()

SearchHighlighter::splitAndAdd ( $extracts,
$count,
  $text 
)

Split text into lines and add it to extracts array.

Parameters
array$extractsindex -> $line
$countInteger
$textString

Definition at line 291 of file SearchHighlighter.php.

References $count, $line, as, and removeWiki().

Referenced by highlightText().

Member Data Documentation

◆ $mCleanWikitext

SearchHighlighter::$mCleanWikitext = true

Definition at line 30 of file SearchHighlighter.php.


The documentation for this class was generated from the following file: