MediaWiki REL1_34
|
Parser function handlers. More...
Static Public Member Functions | |
static | expr (Parser $parser, $expr='') |
{{#expr: expression }} | |
static | if (Parser $parser, PPFrame $frame, array $args) |
{{if: test string | value if test string is not empty | value if test string is empty }} | |
static | ifeq (Parser $parser, PPFrame $frame, array $args) |
{{#ifeq: string 1 | string 2 | value if identical | value if different }} | |
static | iferror (Parser $parser, PPFrame $frame, array $args) |
{{#iferror: test string | value if error | value if no error }} | |
static | ifexist (Parser $parser, PPFrame $frame, array $args) |
{{#ifexist: page title | value if exists | value if doesn't exist }} | |
static | ifexpr (Parser $parser, PPFrame $frame, array $args) |
{{#ifexpr: expression | value if true | value if false }} | |
static | localTime (Parser $parser, PPFrame $frame, array $args) |
{{#timel: ... }} | |
static | rel2abs (Parser $parser, $to='', $from='') |
{{#rel2abs: path }} or {{#rel2abs: path | base path }} | |
static | runCount (Parser $parser, $inStr='', $inSubStr='') |
{{#count: string | substr }} | |
static | runExplode (Parser $parser, $inStr='', $inDiv='', $inPos=0, $inLim=null) |
{{#explode:string | delimiter | position | limit}} | |
static | runLen (Parser $parser, $inStr='') |
{{#len:string}} | |
static | runPos (Parser $parser, $inStr='', $inNeedle='', $inOffset=0) |
{{#pos: string | needle | offset}} | |
static | runReplace (Parser $parser, $inStr='', $inReplaceFrom='', $inReplaceTo='', $inLimit=-1) |
{{#replace:string | from | to | limit }} | |
static | runRPos (Parser $parser, $inStr='', $inNeedle='') |
{{#rpos: string | needle}} | |
static | runSub (Parser $parser, $inStr='', $inStart=0, $inLength=0) |
{{#sub: string | start | length }} | |
static | runUrlDecode (Parser $parser, $inStr='') |
{{#urldecode:string}} | |
static | switch (Parser $parser, PPFrame $frame, array $args) |
{{#switch: comparison string | case = result | case = result | ... | default result }} | |
static | time (Parser $parser, PPFrame $frame, array $args) |
{{#time: format string }} {{#time: format string | date/time object }} {{#time: format string | date/time object | language code }} | |
static | titleparts (Parser $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 Private Member Functions | |
static | checkLength ( $text) |
Verifies parameter is less than max string length. | |
static | decodeTrimExpand ( $obj, PPFrame $frame, &$trimExpanded=null) |
Take a PPNode (-ish thing), expand it, remove entities, and trim. | |
static & | getExprParser () |
static | ifexistInternal (Parser $parser, PPFrame $frame, $titletext='', $then='', $else='') |
static | registerClearHook () |
Register ParserClearState hook. | |
static | timeCommon (Parser $parser, PPFrame $frame=null, $format='', $date='', $language='', $local=false) |
Used by time() and localTime() | |
static | tooLongError () |
Generates error message. | |
Static Private Attributes | |
static | $mExprParser |
static | $mTimeCache = [] |
static | $mTimeChars = 0 |
Parser function handlers.
https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions
Definition at line 25 of file ParserFunctions.php.
|
staticprivate |
Verifies parameter is less than max string length.
string | $text |
Definition at line 617 of file ParserFunctions.php.
|
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}})
PPNode | string | $obj | Thing to expand |
PPFrame | $frame | |
string | &$trimExpanded | Expanded and trimmed version of PPNode, but with char refs intact |
Definition at line 917 of file ParserFunctions.php.
References Sanitizer\decodeCharReferences(), and PPFrame\expand().
Referenced by MediaWiki\Extensions\ParserFunctions\ParserFunctions\ifeq(), and MediaWiki\Extensions\ParserFunctions\ParserFunctions\switch().
|
static |
{{#expr: expression }}
Parser $parser string $expr string
Definition at line 68 of file ParserFunctions.php.
References MediaWiki\Extensions\ParserFunctions\ParserFunctions\getExprParser(), and MediaWiki\Extensions\ParserFunctions\ExprError\getUserFriendlyMessage().
|
staticprivate |
Definition at line 52 of file ParserFunctions.php.
References MediaWiki\Extensions\ParserFunctions\ParserFunctions\$mExprParser.
Referenced by MediaWiki\Extensions\ParserFunctions\ParserFunctions\expr(), and MediaWiki\Extensions\ParserFunctions\ParserFunctions\ifexpr().
|
static |
{{if: test string | value if test string is not empty | value if test string is empty }}
Parser $parser PPFrame $frame array $args string
Definition at line 118 of file ParserFunctions.php.
References $args, and PPFrame\expand().
|
static |
{{#ifeq: string 1 | string 2 | value if identical | value if different }}
Parser $parser PPFrame $frame array $args string
Definition at line 137 of file ParserFunctions.php.
References $args, MediaWiki\Extensions\ParserFunctions\ParserFunctions\decodeTrimExpand(), and PPFrame\expand().
|
static |
{{#iferror: test string | value if error | value if no error }}
Error is when the input string contains an HTML object with class="error", as generated by other parser functions such as #expr, #time and #rel2abs.
Parser $parser PPFrame $frame array $args string
Definition at line 163 of file ParserFunctions.php.
References $args, and PPFrame\expand().
|
static |
{{#ifexist: page title | value if exists | value if doesn't exist }}
Parser $parser PPFrame $frame array $args string
Definition at line 408 of file ParserFunctions.php.
References $args, $title, PPFrame\expand(), and MediaWiki\Extensions\ParserFunctions\ParserFunctions\ifexistInternal().
|
staticprivate |
Definition at line 339 of file ParserFunctions.php.
References $file, $title, Parser\getContentLanguage(), MediaWiki\MediaWikiServices\getInstance(), Parser\incrementExpensiveFunctionCount(), NS_MEDIA, LinkCache\singleton(), and wfFindFile().
Referenced by MediaWiki\Extensions\ParserFunctions\ParserFunctions\ifexist().
|
static |
{{#ifexpr: expression | value if true | value if false }}
Parser $parser PPFrame $frame array $args string
Definition at line 86 of file ParserFunctions.php.
References $args, PPFrame\expand(), MediaWiki\Extensions\ParserFunctions\ParserFunctions\getExprParser(), and MediaWiki\Extensions\ParserFunctions\ExprError\getUserFriendlyMessage().
|
static |
{{#timel: ... }}
Identical to {{#time: ... }}, except that it uses the local time of the wiki (as set in $wgLocaltimezone) when no date is given.
Parser $parser PPFrame $frame array $args string
Definition at line 569 of file ParserFunctions.php.
References $args, PPFrame\expand(), and MediaWiki\Extensions\ParserFunctions\ParserFunctions\timeCommon().
|
staticprivate |
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 38 of file ParserFunctions.php.
References $wgHooks.
Referenced by MediaWiki\Extensions\ParserFunctions\ParserFunctions\timeCommon().
|
static |
{{#rel2abs: path }} or {{#rel2abs: path | base path }}
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.
Parser $parser string $to string $from string
Definition at line 275 of file ParserFunctions.php.
References Parser\getTitle(), and wfMessage().
|
static |
{{#count: string | substr }}
Returns number of occurrences of "substr" in "string".
Note: If "substr" is empty, a single space is used.
Parser | $parser | |
string | $inStr | |
string | $inSubStr |
Definition at line 759 of file ParserFunctions.php.
References Parser\killMarkers(), and MediaWiki\Extensions\ParserFunctions\ParserFunctions\tooLongError().
|
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.
Parser | $parser | |
string | $inStr | |
string | $inDiv | |
int | $inPos | |
int | null | $inLim |
Definition at line 857 of file ParserFunctions.php.
References $matches, Parser\killMarkers(), and MediaWiki\Extensions\ParserFunctions\ParserFunctions\tooLongError().
|
static |
{{#len:string}}
Reports number of characters in string.
Parser | $parser | |
string | $inStr |
Definition at line 641 of file ParserFunctions.php.
References Parser\killMarkers().
|
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.
Parser | $parser | |
string | $inStr | |
int | string | $inNeedle | |
int | $inOffset |
Definition at line 659 of file ParserFunctions.php.
References Parser\killMarkers(), and MediaWiki\Extensions\ParserFunctions\ParserFunctions\tooLongError().
|
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.
Parser | $parser | |
string | $inStr | |
string | $inReplaceFrom | |
string | $inReplaceTo | |
int | $inLimit |
Definition at line 793 of file ParserFunctions.php.
References StringUtils\escapeRegexReplacement(), Parser\killMarkers(), and MediaWiki\Extensions\ParserFunctions\ParserFunctions\tooLongError().
|
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.
Parser | $parser | |
string | $inStr | |
int | string | $inNeedle |
Definition at line 692 of file ParserFunctions.php.
References Parser\killMarkers(), and MediaWiki\Extensions\ParserFunctions\ParserFunctions\tooLongError().
|
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.
Parser | $parser | |
string | $inStr | |
int | $inStart | |
int | $inLength |
Definition at line 731 of file ParserFunctions.php.
References Parser\killMarkers(), and MediaWiki\Extensions\ParserFunctions\ParserFunctions\tooLongError().
|
static |
{{#urldecode:string}}
Decodes URL-encoded (like%20that) strings.
Parser | $parser | |
string | $inStr |
Definition at line 896 of file ParserFunctions.php.
References Parser\killMarkers(), and MediaWiki\Extensions\ParserFunctions\ParserFunctions\tooLongError().
|
static |
{{#switch: comparison string | case = result | case = result | ... | default result }}
Parser $parser PPFrame $frame array $args string
Definition at line 200 of file ParserFunctions.php.
References $args, MediaWiki\Extensions\ParserFunctions\ParserFunctions\decodeTrimExpand(), PPFrame\expand(), and Parser\getMagicWordFactory().
|
static |
{{#time: format string }} {{#time: format string | date/time object }} {{#time: format string | date/time object | language code }}
Parser $parser PPFrame $frame array $args string
Definition at line 548 of file ParserFunctions.php.
References $args, PPFrame\expand(), and MediaWiki\Extensions\ParserFunctions\ParserFunctions\timeCommon().
|
staticprivate |
Used by time() and localTime()
Parser | $parser | |
PPFrame | null | $frame | |
string | $format | |
string | $date | |
string | $language | |
string | bool | $local |
Definition at line 432 of file ParserFunctions.php.
References $wgLocaltimezone, Language\factory(), Parser\getFunctionLang(), Parser\getOptions(), Language\isValidBuiltInCode(), MediaWiki\Extensions\ParserFunctions\ParserFunctions\registerClearHook(), PPFrame\setTTL(), StubObject\unstub(), and wfMessage().
Referenced by MediaWiki\Extensions\ParserFunctions\ParserFunctions\localTime(), and MediaWiki\Extensions\ParserFunctions\ParserFunctions\time().
|
static |
Obtain a specified number of slash-separated parts of a title, e.g.
{{#titleparts:Hello/World|1}} => "Hello"
Definition at line 588 of file ParserFunctions.php.
References $title.
|
staticprivate |
Generates error message.
Called when string is too long.
Definition at line 626 of file ParserFunctions.php.
References wfMessage().
Referenced by MediaWiki\Extensions\ParserFunctions\ParserFunctions\runCount(), MediaWiki\Extensions\ParserFunctions\ParserFunctions\runExplode(), MediaWiki\Extensions\ParserFunctions\ParserFunctions\runPos(), MediaWiki\Extensions\ParserFunctions\ParserFunctions\runReplace(), MediaWiki\Extensions\ParserFunctions\ParserFunctions\runRPos(), MediaWiki\Extensions\ParserFunctions\ParserFunctions\runSub(), and MediaWiki\Extensions\ParserFunctions\ParserFunctions\runUrlDecode().
|
staticprivate |
Definition at line 26 of file ParserFunctions.php.
Referenced by MediaWiki\Extensions\ParserFunctions\ParserFunctions\getExprParser().
|
staticprivate |
Definition at line 27 of file ParserFunctions.php.
|
staticprivate |
Definition at line 28 of file ParserFunctions.php.
const MediaWiki\Extensions\ParserFunctions\ParserFunctions::MAX_TIME_CHARS = 6000 |
~10 seconds
Definition at line 31 of file ParserFunctions.php.