MediaWiki REL1_32
ParserFunctionsHooks.php
Go to the documentation of this file.
1<?php
2
4
11 public static function onRegistration() {
12 if ( isset( $GLOBALS['wgWikimediaJenkinsCI'] ) && $GLOBALS['wgWikimediaJenkinsCI'] === true ) {
13 $GLOBALS['wgPFEnableStringFunctions'] = true;
14 }
15 }
16
21 public static function onParserFirstCallInit( $parser ) {
22 global $wgPFEnableStringFunctions;
23
24 // These functions accept DOM-style arguments
25 $parser->setFunctionHook( 'if', 'ExtParserFunctions::ifObj', Parser::SFH_OBJECT_ARGS );
26 $parser->setFunctionHook( 'ifeq', 'ExtParserFunctions::ifeqObj', Parser::SFH_OBJECT_ARGS );
27 $parser->setFunctionHook( 'switch', 'ExtParserFunctions::switchObj', Parser::SFH_OBJECT_ARGS );
28 $parser->setFunctionHook( 'ifexist', 'ExtParserFunctions::ifexistObj', Parser::SFH_OBJECT_ARGS );
29 $parser->setFunctionHook( 'ifexpr', 'ExtParserFunctions::ifexprObj', Parser::SFH_OBJECT_ARGS );
30 $parser->setFunctionHook( 'iferror', 'ExtParserFunctions::iferrorObj', Parser::SFH_OBJECT_ARGS );
31 $parser->setFunctionHook( 'time', 'ExtParserFunctions::timeObj', Parser::SFH_OBJECT_ARGS );
32 $parser->setFunctionHook( 'timel', 'ExtParserFunctions::localTimeObj', Parser::SFH_OBJECT_ARGS );
33
34 $parser->setFunctionHook( 'expr', 'ExtParserFunctions::expr' );
35 $parser->setFunctionHook( 'rel2abs', 'ExtParserFunctions::rel2abs' );
36 $parser->setFunctionHook( 'titleparts', 'ExtParserFunctions::titleparts' );
37
38 // String Functions
39 if ( $wgPFEnableStringFunctions ) {
40 $parser->setFunctionHook( 'len', 'ExtParserFunctions::runLen' );
41 $parser->setFunctionHook( 'pos', 'ExtParserFunctions::runPos' );
42 $parser->setFunctionHook( 'rpos', 'ExtParserFunctions::runRPos' );
43 $parser->setFunctionHook( 'sub', 'ExtParserFunctions::runSub' );
44 $parser->setFunctionHook( 'count', 'ExtParserFunctions::runCount' );
45 $parser->setFunctionHook( 'replace', 'ExtParserFunctions::runReplace' );
46 $parser->setFunctionHook( 'explode', 'ExtParserFunctions::runExplode' );
47 $parser->setFunctionHook( 'urldecode', 'ExtParserFunctions::runUrlDecode' );
48 }
49
50 return true;
51 }
52
53 public static function onScribuntoExternalLibraries( $engine, array &$extraLibraries ) {
54 if ( $engine === 'lua' ) {
55 $extraLibraries['mw.ext.ParserFunctions'] = 'Scribunto_LuaParserFunctionsLibrary';
56 }
57 return true;
58 }
59}
$GLOBALS['IP']
static onScribuntoExternalLibraries( $engine, array &$extraLibraries)
static onRegistration()
Enable string functions, when running Wikimedia Jenkins unit tests.
static onParserFirstCallInit( $parser)
see documentation in includes Linker php for Linker::makeImageLink or false for current used if you return false $parser
Definition hooks.txt:1873
the value to return A Title object or null for latest all implement SearchIndexField $engine
Definition hooks.txt:2962
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))