MediaWiki  REL1_24
SearchHighlighter Class Reference

Highlight bits of wikitext. More...

List of all members.

Public Member Functions

 __construct ($cleanupWikitext=true)
 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.
 highlightNone ($text, $contextlines, $contextchars)
 Returns the first few lines of the text.
 highlightSimple ($text, $terms, $contextlines, $contextchars)
 Simple & fast snippet extraction, but gives completely unrelevant snippets.
 highlightText ($text, $terms, $contextlines, $contextchars)
 Default implementation of wikitext highlighting.
 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.

Protected Attributes

 $mCleanWikitext = true

Detailed Description

Highlight bits of wikitext.

Definition at line 29 of file SearchHighlighter.php.


Constructor & Destructor Documentation

SearchHighlighter::__construct ( cleanupWikitext = true)

Definition at line 32 of file SearchHighlighter.php.


Member Function Documentation

Do manual case conversion for non-ascii chars.

Parameters:
array$matches
Returns:
string

Definition at line 318 of file SearchHighlighter.php.

References $matches, $wgContLang, and global.

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:
string$text
int$start
int$end
int$posStart(out) actual start position
int$posEnd(out) actual end position
Returns:
string

Definition at line 337 of file SearchHighlighter.php.

References position().

Referenced by highlightText(), and process().

SearchHighlighter::highlightNone ( text,
contextlines,
contextchars 
)

Returns the first few lines of the text.

Parameters:
string$text
int$contextlinesMax number of returned lines
int$contextcharsAverage number of characters per line
Returns:
string

Definition at line 567 of file SearchHighlighter.php.

References array().

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

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

Parameters:
string$text
array$terms
int$contextlines
int$contextchars
Returns:
string

Definition at line 513 of file SearchHighlighter.php.

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

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

Default implementation of wikitext highlighting.

Parameters:
string$text
array$termsTerms to highlight (unescaped)
int$contextlines
int$contextchars
Returns:
string

Definition at line 45 of file SearchHighlighter.php.

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

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

Parameters:
array$matches
Returns:
string

Definition at line 488 of file SearchHighlighter.php.

References $matches, $wgContLang, and global.

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

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

Parameters:
string$text
int$point
int$offsetOffset to found index
Returns:
int Nearest nonletter index, or beginning of utf8 char if none

Definition at line 369 of file SearchHighlighter.php.

References $s, and array().

Referenced by extract().

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
int$linesleftNumber of extracts to make
int$contextcharsLength of snippet
array$outMap for highlighted snippets
array$offsetsMap of starting points of snippets
Access:
protected

Definition at line 410 of file SearchHighlighter.php.

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

Referenced by highlightText().

Basic wikitext removal.

Access:
protected
Parameters:
string$text
Returns:
mixed

Definition at line 453 of file SearchHighlighter.php.

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

Referenced by splitAndAdd().

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

Split text into lines and add it to extracts array.

Parameters:
array$extractsIndex -> $line
int$count
string$text

Definition at line 302 of file SearchHighlighter.php.

References $count, as, and removeWiki().

Referenced by highlightText().


Member Data Documentation

SearchHighlighter::$mCleanWikitext = true [protected]

Definition at line 30 of file SearchHighlighter.php.


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