MediaWiki REL1_33
MediaWiki\Extensions\ParserFunctions\ParserFunctions Class Reference

Static Public Member Functions

static expr ( $parser, $expr='')
 
static & getExprParser ()
 
static ifeqObj ( $parser, $frame, $args)
 
static iferror ( $parser, $test='', $then='', $else=false)
 
static iferrorObj ( $parser, $frame, $args)
 
static ifexistCommon ( $parser, $frame, $titletext='', $then='', $else='')
 
static ifexistObj ( $parser, $frame, $args)
 
static ifexpr ( $parser, $expr='', $then='', $else='')
 
static ifexprObj ( $parser, $frame, $args)
 
static ifObj ( $parser, $frame, $args)
 
static localTime ( $parser, $format='', $date='', $language='')
 
static localTimeObj ( $parser, $frame, $args)
 
static registerClearHook ()
 Register ParserClearState hook.
 
static rel2abs ( $parser, $to='', $from='')
 Returns the absolute path to a subpage, relative to the current article title.
 
static runCount ( $parser, $inStr='', $inSubStr='')
 {{#count: string | substr }}
 
static runExplode ( $parser, $inStr='', $inDiv='', $inPos=0, $inLim=null)
 {{#explode:string | delimiter | position | limit}}
 
static runLen ( $parser, $inStr='')
 {{#len:string}}
 
static runPos ( $parser, $inStr='', $inNeedle='', $inOffset=0)
 {{#pos: string | needle | offset}}
 
static runReplace ( $parser, $inStr='', $inReplaceFrom='', $inReplaceTo='', $inLimit=-1)
 {{replace:string | from | to | limit }}
 
static runRPos ( $parser, $inStr='', $inNeedle='')
 {{#rpos: string | needle}}
 
static runSub ( $parser, $inStr='', $inStart=0, $inLength=0)
 {{#sub: string | start | length }}
 
static runUrlDecode ( $parser, $inStr='')
 {{#urldecode:string}}
 
static switchObj ( $parser, $frame, $args)
 
static time ( $parser, $format='', $date='', $language='', $local=false)
 
static timeCommon ( $parser, $frame=null, $format='', $date='', $language='', $local=false)
 
static timeObj ( $parser, $frame, $args)
 
static titleparts ( $parser, $title='', $parts=0, $offset=0)
 Obtain a specified number of slash-separated parts of a title, e.g.
 

Public Attributes

const MAX_TIME_CHARS = 6000
 ~10 seconds
 

Static Public Attributes

static $mExprParser
 
static $mTimeCache = []
 
static $mTimeChars = 0
 

Static Private Member Functions

static checkLength ( $text)
 Verifies parameter is less than max string length.
 
static decodeTrimExpand ( $obj, $frame, &$trimExpanded=null)
 Take a PPNode (-ish thing), expand it, remove entities, and trim.
 
static tooLongError ()
 Generates error message.
 

Detailed Description

Definition at line 20 of file ParserFunctions.php.

Member Function Documentation

◆ checkLength()

static MediaWiki\Extensions\ParserFunctions\ParserFunctions::checkLength ( $text)
staticprivate

Verifies parameter is less than max string length.

Parameters
string$text
Returns
bool

Definition at line 603 of file ParserFunctions.php.

References and().

◆ decodeTrimExpand()

static MediaWiki\Extensions\ParserFunctions\ParserFunctions::decodeTrimExpand ( $obj,
$frame,
& $trimExpanded = null )
staticprivate

Take a PPNode (-ish thing), expand it, remove entities, and trim.

For use when doing string comparisions, where user expects entities to be equal for what they stand for (e.g. comparisions with {{PAGENAME}})

Parameters
PPNode | string$objThing to expand
PPFrame$frame
string&$trimExpandedExpanded and trimmed version of PPNode, but with char refs intact
Returns
string The trimmed, expanded and entity reference decoded version of the PPNode

Definition at line 898 of file ParserFunctions.php.

References and(), and Sanitizer\decodeCharReferences().

Referenced by MediaWiki\Extensions\ParserFunctions\ParserFunctions\ifeqObj(), and MediaWiki\Extensions\ParserFunctions\ParserFunctions\switchObj().

◆ expr()

static MediaWiki\Extensions\ParserFunctions\ParserFunctions::expr ( $parser,
$expr = '' )
static
Parameters
Parser$parser
string$expr
Returns
string

Definition at line 59 of file ParserFunctions.php.

References $e, and(), and MediaWiki\Extensions\ParserFunctions\ParserFunctions\getExprParser().

◆ getExprParser()

static & MediaWiki\Extensions\ParserFunctions\ParserFunctions::getExprParser ( )
static

◆ ifeqObj()

static MediaWiki\Extensions\ParserFunctions\ParserFunctions::ifeqObj ( $parser,
$frame,
$args )
static
Parameters
Parser$parser
PPFrame$frame
array$args
Returns
string

Definition at line 128 of file ParserFunctions.php.

References $args, and(), and MediaWiki\Extensions\ParserFunctions\ParserFunctions\decodeTrimExpand().

◆ iferror()

static MediaWiki\Extensions\ParserFunctions\ParserFunctions::iferror ( $parser,
$test = '',
$then = '',
$else = false )
static
Parameters
Parser$parser
string$test
string$then
bool$else
Returns
bool|string

Definition at line 148 of file ParserFunctions.php.

References and().

Referenced by MediaWiki\Extensions\ParserFunctions\ParserFunctions\iferrorObj().

◆ iferrorObj()

static MediaWiki\Extensions\ParserFunctions\ParserFunctions::iferrorObj ( $parser,
$frame,
$args )
static
Parameters
Parser$parser
PPFrame$frame
array$args
Returns
string

Definition at line 167 of file ParserFunctions.php.

References $args, $parser, and(), and MediaWiki\Extensions\ParserFunctions\ParserFunctions\iferror().

◆ ifexistCommon()

static MediaWiki\Extensions\ParserFunctions\ParserFunctions::ifexistCommon ( $parser,
$frame,
$titletext = '',
$then = '',
$else = '' )
static
Parameters
Parser$parser
PPFrame$frame
string$titletext
string$then
string$else
Returns
string

Definition at line 320 of file ParserFunctions.php.

References $parser, and(), MediaWiki\MediaWikiServices\getInstance(), Title\newFromText(), NS_MEDIA, LinkCache\singleton(), and wfFindFile().

Referenced by MediaWiki\Extensions\ParserFunctions\ParserFunctions\ifexistObj().

◆ ifexistObj()

static MediaWiki\Extensions\ParserFunctions\ParserFunctions::ifexistObj ( $parser,
$frame,
$args )
static
Parameters
Parser$parser
PPFrame$frame
array$args
Returns
string

Definition at line 385 of file ParserFunctions.php.

References $args, $parser, and(), and MediaWiki\Extensions\ParserFunctions\ParserFunctions\ifexistCommon().

◆ ifexpr()

static MediaWiki\Extensions\ParserFunctions\ParserFunctions::ifexpr ( $parser,
$expr = '',
$then = '',
$else = '' )
static
Parameters
Parser$parser
string$expr
string$then
string$else
Returns
string

Definition at line 74 of file ParserFunctions.php.

References $e, $ret, and(), and MediaWiki\Extensions\ParserFunctions\ParserFunctions\getExprParser().

Referenced by MediaWiki\Extensions\ParserFunctions\ParserFunctions\ifexprObj().

◆ ifexprObj()

static MediaWiki\Extensions\ParserFunctions\ParserFunctions::ifexprObj ( $parser,
$frame,
$args )
static
Parameters
Parser$parser
PPFrame$frame
array$args
Returns
string

Definition at line 96 of file ParserFunctions.php.

References $args, $parser, $result, and(), and MediaWiki\Extensions\ParserFunctions\ParserFunctions\ifexpr().

◆ ifObj()

static MediaWiki\Extensions\ParserFunctions\ParserFunctions::ifObj ( $parser,
$frame,
$args )
static
Parameters
Parser$parser
PPFrame$frame
array$args
Returns
string

Definition at line 113 of file ParserFunctions.php.

References $args, and and().

◆ localTime()

static MediaWiki\Extensions\ParserFunctions\ParserFunctions::localTime ( $parser,
$format = '',
$date = '',
$language = '' )
static
Parameters
Parser$parser
string$format
string$date
string$language
Returns
string

Definition at line 548 of file ParserFunctions.php.

References $parser, and MediaWiki\Extensions\ParserFunctions\ParserFunctions\timeCommon().

◆ localTimeObj()

static MediaWiki\Extensions\ParserFunctions\ParserFunctions::localTimeObj ( $parser,
$frame,
$args )
static
Parameters
Parser$parser
PPFrame$frame
array$args
Returns
string

Definition at line 558 of file ParserFunctions.php.

References $args, $parser, and(), and MediaWiki\Extensions\ParserFunctions\ParserFunctions\timeCommon().

◆ registerClearHook()

static MediaWiki\Extensions\ParserFunctions\ParserFunctions::registerClearHook ( )
static

Register ParserClearState hook.

We defer this until needed to avoid the loading of the code of this file when no parser function is actually called.

Definition at line 33 of file ParserFunctions.php.

References $wgHooks.

Referenced by MediaWiki\Extensions\ParserFunctions\ParserFunctions\timeCommon().

◆ rel2abs()

static MediaWiki\Extensions\ParserFunctions\ParserFunctions::rel2abs ( $parser,
$to = '',
$from = '' )
static

Returns the absolute path to a subpage, relative to the current article title.

Treats titles as slash-separated paths.

Following subpage link syntax instead of standard path syntax, an initial slash is treated as a relative path, and vice versa.

Parameters
Parser$parser
string$to
string$from
Returns
string

Definition at line 256 of file ParserFunctions.php.

References $parser, and(), and wfMessage().

◆ runCount()

static MediaWiki\Extensions\ParserFunctions\ParserFunctions::runCount ( $parser,
$inStr = '',
$inSubStr = '' )
static

{{#count: string | substr }}

Returns number of occurrences of "substr" in "string".

Note: If "substr" is empty, a single space is used.

Parameters
Parser$parser
string$inStr
string$inSubStr
Returns
int|string

Definition at line 743 of file ParserFunctions.php.

References $parser, $result, and(), and MediaWiki\Extensions\ParserFunctions\ParserFunctions\tooLongError().

◆ runExplode()

static MediaWiki\Extensions\ParserFunctions\ParserFunctions::runExplode ( $parser,
$inStr = '',
$inDiv = '',
$inPos = 0,
$inLim = null )
static

{{#explode:string | delimiter | position | limit}}

Breaks "string" into chunks separated by "delimiter" and returns the chunk identified by "position".

Note: Negative position can be used to specify tokens from the end. Note: If the divider is an empty string, single space is used instead. Note: Empty string is returned if there are not enough exploded chunks.

Parameters
Parser$parser
string$inStr
string$inDiv
int$inPos
int | null$inLim
Returns
string

Definition at line 839 of file ParserFunctions.php.

References $matches, $parser, $result, and(), and MediaWiki\Extensions\ParserFunctions\ParserFunctions\tooLongError().

◆ runLen()

static MediaWiki\Extensions\ParserFunctions\ParserFunctions::runLen ( $parser,
$inStr = '' )
static

{{#len:string}}

Reports number of characters in string.

Parameters
Parser$parser
string$inStr
Returns
int

Definition at line 626 of file ParserFunctions.php.

References $parser, and and().

◆ runPos()

static MediaWiki\Extensions\ParserFunctions\ParserFunctions::runPos ( $parser,
$inStr = '',
$inNeedle = '',
$inOffset = 0 )
static

{{#pos: string | needle | offset}}

Finds first occurrence of "needle" in "string" starting at "offset".

Note: If the needle is an empty string, single space is used instead. Note: If the needle is not found, empty string is returned.

Parameters
Parser$parser
string$inStr
int | string$inNeedle
int$inOffset
Returns
int|string

Definition at line 644 of file ParserFunctions.php.

References $parser, and(), and MediaWiki\Extensions\ParserFunctions\ParserFunctions\tooLongError().

◆ runReplace()

static MediaWiki\Extensions\ParserFunctions\ParserFunctions::runReplace ( $parser,
$inStr = '',
$inReplaceFrom = '',
$inReplaceTo = '',
$inLimit = -1 )
static

{{replace:string | from | to | limit }}

Replaces each occurrence of "from" in "string" with "to". At most "limit" replacements are performed.

Note: Armored against replacements that would generate huge strings. Note: If "from" is an empty string, single space is used instead.

Parameters
Parser$parser
string$inStr
string$inReplaceFrom
string$inReplaceTo
int$inLimit
Returns
mixed|string

Definition at line 776 of file ParserFunctions.php.

References $parser, $result, and(), StringUtils\escapeRegexReplacement(), and MediaWiki\Extensions\ParserFunctions\ParserFunctions\tooLongError().

◆ runRPos()

static MediaWiki\Extensions\ParserFunctions\ParserFunctions::runRPos ( $parser,
$inStr = '',
$inNeedle = '' )
static

{{#rpos: string | needle}}

Finds last occurrence of "needle" in "string".

Note: If the needle is an empty string, single space is used instead. Note: If the needle is not found, -1 is returned.

Parameters
Parser$parser
string$inStr
int | string$inNeedle
Returns
int|string

Definition at line 677 of file ParserFunctions.php.

References $parser, and(), and MediaWiki\Extensions\ParserFunctions\ParserFunctions\tooLongError().

◆ runSub()

static MediaWiki\Extensions\ParserFunctions\ParserFunctions::runSub ( $parser,
$inStr = '',
$inStart = 0,
$inLength = 0 )
static

{{#sub: string | start | length }}

Returns substring of "string" starting at "start" and having "length" characters.

Note: If length is zero, the rest of the input is returned. Note: A negative value for "start" operates from the end of the "string". Note: A negative value for "length" returns a string reduced in length by that amount.

Parameters
Parser$parser
string$inStr
int$inStart
int$inLength
Returns
string

Definition at line 716 of file ParserFunctions.php.

References $parser, $result, and(), and MediaWiki\Extensions\ParserFunctions\ParserFunctions\tooLongError().

◆ runUrlDecode()

static MediaWiki\Extensions\ParserFunctions\ParserFunctions::runUrlDecode ( $parser,
$inStr = '' )
static

{{#urldecode:string}}

Decodes URL-encoded (like%20that) strings.

Parameters
Parser$parser
string$inStr
Returns
string

Definition at line 877 of file ParserFunctions.php.

References $parser, and(), and MediaWiki\Extensions\ParserFunctions\ParserFunctions\tooLongError().

◆ switchObj()

static MediaWiki\Extensions\ParserFunctions\ParserFunctions::switchObj ( $parser,
$frame,
$args )
static
Parameters
Parser$parser
PPFrame$frame
array$args
Returns
string

Definition at line 185 of file ParserFunctions.php.

References $args, $parser, and(), and MediaWiki\Extensions\ParserFunctions\ParserFunctions\decodeTrimExpand().

◆ time()

static MediaWiki\Extensions\ParserFunctions\ParserFunctions::time ( $parser,
$format = '',
$date = '',
$language = '',
$local = false )
static
Parameters
Parser$parser
string$format
string$date
string$language
string | bool$local
Returns
string

Definition at line 521 of file ParserFunctions.php.

References $parser, and MediaWiki\Extensions\ParserFunctions\ParserFunctions\timeCommon().

◆ timeCommon()

static MediaWiki\Extensions\ParserFunctions\ParserFunctions::timeCommon ( $parser,
$frame = null,
$format = '',
$date = '',
$language = '',
$local = false )
static

◆ timeObj()

static MediaWiki\Extensions\ParserFunctions\ParserFunctions::timeObj ( $parser,
$frame,
$args )
static
Parameters
Parser$parser
PPFrame$frame
array$args
Returns
string

Definition at line 533 of file ParserFunctions.php.

References $args, $parser, and(), and MediaWiki\Extensions\ParserFunctions\ParserFunctions\timeCommon().

◆ titleparts()

static MediaWiki\Extensions\ParserFunctions\ParserFunctions::titleparts ( $parser,
$title = '',
$parts = 0,
$offset = 0 )
static

Obtain a specified number of slash-separated parts of a title, e.g.

{{#titleparts:Hello/World|1}} => "Hello"

Parameters
Parser$parserParent parser
string$titleTitle to split
int$partsNumber of parts to keep
int$offsetOffset starting at 1
Returns
string

Definition at line 575 of file ParserFunctions.php.

References $title, and(), and Title\newFromText().

◆ tooLongError()

Member Data Documentation

◆ $mExprParser

MediaWiki\Extensions\ParserFunctions\ParserFunctions::$mExprParser
static

◆ $mTimeCache

MediaWiki\Extensions\ParserFunctions\ParserFunctions::$mTimeCache = []
static

Definition at line 22 of file ParserFunctions.php.

◆ $mTimeChars

MediaWiki\Extensions\ParserFunctions\ParserFunctions::$mTimeChars = 0
static

Definition at line 23 of file ParserFunctions.php.

◆ MAX_TIME_CHARS

const MediaWiki\Extensions\ParserFunctions\ParserFunctions::MAX_TIME_CHARS = 6000

~10 seconds

Definition at line 26 of file ParserFunctions.php.


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