MediaWiki  1.30.0
ExtParserFunctions Class Reference

Static Public Member Functions

static clearState ( $parser)
 
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. More...
 
static rel2abs ( $parser, $to='', $from='')
 Returns the absolute path to a subpage, relative to the current article title. More...
 
static runCount ( $parser, $inStr='', $inSubStr='')
 {{#count: string | substr }} More...
 
static runExplode ( $parser, $inStr='', $inDiv='', $inPos=0, $inLim=null)
 {{#explode:string | delimiter | position | limit}} More...
 
static runLen ( $parser, $inStr='')
 {{#len:string}} More...
 
static runPos ( $parser, $inStr='', $inNeedle='', $inOffset=0)
 {{#pos: string | needle | offset}} More...
 
static runReplace ( $parser, $inStr='', $inReplaceFrom='', $inReplaceTo='', $inLimit=-1)
 {{replace:string | from | to | limit }} More...
 
static runRPos ( $parser, $inStr='', $inNeedle='')
 {{#rpos: string | needle}} More...
 
static runSub ( $parser, $inStr='', $inStart=0, $inLength=0)
 {{#sub: string | start | length }} More...
 
static runUrlDecode ( $parser, $inStr='')
 {{#urldecode:string}} More...
 
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. More...
 

Static Public Attributes

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

Static Private Member Functions

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

Detailed Description

Definition at line 3 of file ParserFunctions_body.php.

Member Function Documentation

◆ checkLength()

static ExtParserFunctions::checkLength (   $text)
staticprivate

Verifies parameter is less than max string length.

Parameters
$text
Returns
bool

Definition at line 591 of file ParserFunctions_body.php.

References global.

◆ clearState()

static ExtParserFunctions::clearState (   $parser)
static
Parameters
$parserParser
Returns
bool

Definition at line 13 of file ParserFunctions_body.php.

◆ decodeTrimExpand()

static ExtParserFunctions::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
$objPPNode|string Thing to expand
$framePPFrame
&$trimExpandedString Expanded 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 886 of file ParserFunctions_body.php.

Referenced by ifeqObj(), and switchObj().

◆ expr()

static ExtParserFunctions::expr (   $parser,
  $expr = '' 
)
static
Parameters
$parserParser
$exprstring
Returns
string

Definition at line 47 of file ParserFunctions_body.php.

References $e, and getExprParser().

◆ getExprParser()

static& ExtParserFunctions::getExprParser ( )
static
Returns
ExprParser

Definition at line 35 of file ParserFunctions_body.php.

References $mExprParser.

Referenced by Scribunto_LuaParserFunctionsLibrary\expr(), expr(), and ifexpr().

◆ ifeqObj()

static ExtParserFunctions::ifeqObj (   $parser,
  $frame,
  $args 
)
static
Parameters
$parserParser
$framePPFrame
$argsarray
Returns
string

Definition at line 116 of file ParserFunctions_body.php.

References $args, and decodeTrimExpand().

◆ iferror()

static ExtParserFunctions::iferror (   $parser,
  $test = '',
  $then = '',
  $else = false 
)
static
Parameters
$parserParser
$teststring
$thenstring
$elsebool
Returns
bool|string

Definition at line 136 of file ParserFunctions_body.php.

Referenced by iferrorObj().

◆ iferrorObj()

static ExtParserFunctions::iferrorObj (   $parser,
  $frame,
  $args 
)
static
Parameters
$parserParser
$framePPFrame
$argsarray
Returns
string

Definition at line 155 of file ParserFunctions_body.php.

References $args, $parser, and iferror().

◆ ifexistCommon()

static ExtParserFunctions::ifexistCommon (   $parser,
  $frame,
  $titletext = '',
  $then = '',
  $else = '' 
)
static
Parameters
$parserParser
$framePPFrame
$titletextstring
$thenstring
$elsestring
Returns
string

Definition at line 308 of file ParserFunctions_body.php.

References $parser, $title, $wgContLang, SpecialPageFactory\exists(), global, Title\newFromText(), NS_MEDIA, NS_SPECIAL, LinkCache\singleton(), and wfFindFile().

Referenced by ifexistObj().

◆ ifexistObj()

static ExtParserFunctions::ifexistObj (   $parser,
  $frame,
  $args 
)
static
Parameters
$parserParser
$framePPFrame
$argsarray
Returns
string

Definition at line 373 of file ParserFunctions_body.php.

References $args, $parser, $title, and ifexistCommon().

◆ ifexpr()

static ExtParserFunctions::ifexpr (   $parser,
  $expr = '',
  $then = '',
  $else = '' 
)
static
Parameters
$parserParser
$exprstring
$thenstring
$elsestring
Returns
string

Definition at line 62 of file ParserFunctions_body.php.

References $e, $ret, and getExprParser().

Referenced by ifexprObj().

◆ ifexprObj()

static ExtParserFunctions::ifexprObj (   $parser,
  $frame,
  $args 
)
static
Parameters
$parserParser
$framePPFrame
$argsarray
Returns
string

Definition at line 84 of file ParserFunctions_body.php.

References $args, $parser, and ifexpr().

◆ ifObj()

static ExtParserFunctions::ifObj (   $parser,
  $frame,
  $args 
)
static
Parameters
$parserParser
$framePPFrame
$argsarray
Returns
string

Definition at line 101 of file ParserFunctions_body.php.

References $args.

◆ localTime()

static ExtParserFunctions::localTime (   $parser,
  $format = '',
  $date = '',
  $language = '' 
)
static
Parameters
$parserParser
$formatstring
$datestring
$languagestring
Returns
string

Definition at line 536 of file ParserFunctions_body.php.

References $parser, and timeCommon().

◆ localTimeObj()

static ExtParserFunctions::localTimeObj (   $parser,
  $frame,
  $args 
)
static
Parameters
$parserParser
$framePPFrame
$argsarray
Returns
string

Definition at line 546 of file ParserFunctions_body.php.

References $args, $parser, and timeCommon().

◆ registerClearHook()

static ExtParserFunctions::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 23 of file ParserFunctions_body.php.

References $wgHooks, and global.

Referenced by timeCommon().

◆ rel2abs()

static ExtParserFunctions::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
$parserParser
$tostring
$fromstring
Returns
string

Definition at line 244 of file ParserFunctions_body.php.

References $parser, as, captcha-old\count, and wfMessage().

◆ runCount()

static ExtParserFunctions::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
$parserParser
$inStrstring
$inSubStrstring
Returns
int|string

Definition at line 731 of file ParserFunctions_body.php.

References $parser, and tooLongError().

◆ runExplode()

static ExtParserFunctions::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
$parserParser
$inStrstring
$inDivstring
$inPosint
$inLimint|null
Returns
string

Definition at line 827 of file ParserFunctions_body.php.

References $matches, $parser, captcha-old\count, and tooLongError().

◆ runLen()

static ExtParserFunctions::runLen (   $parser,
  $inStr = '' 
)
static

{{#len:string}}

Reports number of characters in string.

Parameters
$parserParser
$inStrstring
Returns
int

Definition at line 614 of file ParserFunctions_body.php.

References $parser.

◆ runPos()

static ExtParserFunctions::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
$parserParser
$inStrstring
$inNeedleint|string
$inOffsetint
Returns
int|string

Definition at line 632 of file ParserFunctions_body.php.

References $parser, and tooLongError().

◆ runReplace()

static ExtParserFunctions::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
$parserParser
$inStrstring
$inReplaceFromstring
$inReplaceTostring
$inLimitint
Returns
mixed|string

Definition at line 764 of file ParserFunctions_body.php.

References $parser, StringUtils\escapeRegexReplacement(), global, and tooLongError().

◆ runRPos()

static ExtParserFunctions::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
$parserParser
$inStrstring
$inNeedleint|string
Returns
int|string

Definition at line 665 of file ParserFunctions_body.php.

References $parser, and tooLongError().

◆ runSub()

static ExtParserFunctions::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
$parserParser
$inStrstring
$inStartint
$inLengthint
Returns
string

Definition at line 704 of file ParserFunctions_body.php.

References $parser, and tooLongError().

◆ runUrlDecode()

static ExtParserFunctions::runUrlDecode (   $parser,
  $inStr = '' 
)
static

{{#urldecode:string}}

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

Parameters
$parserParser
$inStrstring
Returns
string

Definition at line 865 of file ParserFunctions_body.php.

References $parser, and tooLongError().

◆ switchObj()

static ExtParserFunctions::switchObj (   $parser,
  $frame,
  $args 
)
static
Parameters
$parserParser
$framePPFrame
$args
Returns
string

Definition at line 173 of file ParserFunctions_body.php.

References $args, as, captcha-old\count, decodeTrimExpand(), and MagicWord\get().

◆ time()

static ExtParserFunctions::time (   $parser,
  $format = '',
  $date = '',
  $language = '',
  $local = false 
)
static
Parameters
$parserParser
$formatstring
$datestring
$languagestring
$localstring|bool
Returns
string

Definition at line 509 of file ParserFunctions_body.php.

References $parser, and timeCommon().

◆ timeCommon()

static ExtParserFunctions::timeCommon (   $parser,
  $frame = null,
  $format = '',
  $date = '',
  $language = '',
  $local = false 
)
static
Parameters
$parserParser
$framePPFrame
$formatstring
$datestring
$languagestring
$localstring|bool
Returns
string

Definition at line 395 of file ParserFunctions_body.php.

References $parser, $wgLocaltimezone, Language\factory(), global, Language\isValidBuiltInCode(), registerClearHook(), StubObject\unstub(), and wfMessage().

Referenced by localTime(), localTimeObj(), time(), and timeObj().

◆ timeObj()

static ExtParserFunctions::timeObj (   $parser,
  $frame,
  $args 
)
static
Parameters
$parserParser
$framePPFrame
$argsarray
Returns
string

Definition at line 521 of file ParserFunctions_body.php.

References $args, $parser, and timeCommon().

◆ titleparts()

static ExtParserFunctions::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
$parserParser Parent parser
$titlestring Title to split
$partsint Number of parts to keep
$offsetint Offset starting at 1
Returns
string

Definition at line 563 of file ParserFunctions_body.php.

References $title, captcha-old\count, and Title\newFromText().

◆ tooLongError()

static ExtParserFunctions::tooLongError ( )
staticprivate

Generates error message.

Called when string is too long.

Returns
string

Definition at line 600 of file ParserFunctions_body.php.

References global, and wfMessage().

Referenced by runCount(), runExplode(), runPos(), runReplace(), runRPos(), runSub(), and runUrlDecode().

Member Data Documentation

◆ $mExprParser

ExtParserFunctions::$mExprParser
static

Definition at line 4 of file ParserFunctions_body.php.

Referenced by getExprParser().

◆ $mMaxTimeChars

ExtParserFunctions::$mMaxTimeChars = 6000
static

Definition at line 7 of file ParserFunctions_body.php.

◆ $mTimeCache

ExtParserFunctions::$mTimeCache = []
static

Definition at line 5 of file ParserFunctions_body.php.

◆ $mTimeChars

ExtParserFunctions::$mTimeChars = 0
static

Definition at line 6 of file ParserFunctions_body.php.


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