MediaWiki  1.32.5
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 }
SFH_OBJECT_ARGS
const SFH_OBJECT_ARGS
Definition: Defines.php:198
ParserFunctionsHooks\onParserFirstCallInit
static onParserFirstCallInit( $parser)
Definition: ParserFunctionsHooks.php:21
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
$parser
see documentation in includes Linker php for Linker::makeImageLink or false for current used if you return false $parser
Definition: hooks.txt:1841
ParserFunctionsHooks\onRegistration
static onRegistration()
Enable string functions, when running Wikimedia Jenkins unit tests.
Definition: ParserFunctionsHooks.php:11
$engine
the value to return A Title object or null for latest all implement SearchIndexField $engine
Definition: hooks.txt:2946
ParserFunctionsHooks
Definition: ParserFunctionsHooks.php:3
array
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))
ParserFunctionsHooks\onScribuntoExternalLibraries
static onScribuntoExternalLibraries( $engine, array &$extraLibraries)
Definition: ParserFunctionsHooks.php:53
$GLOBALS
$GLOBALS['IP']
Definition: ComposerHookHandler.php:6