From f6d65e533c62f6deb21342d4901ece24497b433e Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 4 Jun 2015 07:31:04 +0200 Subject: Update to MediaWiki 1.25.1 --- .../ParserFunctions/ParserFunctions.hooks.php | 68 ++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 extensions/ParserFunctions/ParserFunctions.hooks.php (limited to 'extensions/ParserFunctions/ParserFunctions.hooks.php') diff --git a/extensions/ParserFunctions/ParserFunctions.hooks.php b/extensions/ParserFunctions/ParserFunctions.hooks.php new file mode 100644 index 00000000..bac580c0 --- /dev/null +++ b/extensions/ParserFunctions/ParserFunctions.hooks.php @@ -0,0 +1,68 @@ +setFunctionHook( 'if', 'ExtParserFunctions::ifObj', Parser::SFH_OBJECT_ARGS ); + $parser->setFunctionHook( 'ifeq', 'ExtParserFunctions::ifeqObj', Parser::SFH_OBJECT_ARGS ); + $parser->setFunctionHook( 'switch', 'ExtParserFunctions::switchObj', Parser::SFH_OBJECT_ARGS ); + $parser->setFunctionHook( 'ifexist', 'ExtParserFunctions::ifexistObj', Parser::SFH_OBJECT_ARGS ); + $parser->setFunctionHook( 'ifexpr', 'ExtParserFunctions::ifexprObj', Parser::SFH_OBJECT_ARGS ); + $parser->setFunctionHook( 'iferror', 'ExtParserFunctions::iferrorObj', Parser::SFH_OBJECT_ARGS ); + $parser->setFunctionHook( 'time', 'ExtParserFunctions::timeObj', Parser::SFH_OBJECT_ARGS ); + $parser->setFunctionHook( 'timel', 'ExtParserFunctions::localTimeObj', Parser::SFH_OBJECT_ARGS ); + + $parser->setFunctionHook( 'expr', 'ExtParserFunctions::expr' ); + $parser->setFunctionHook( 'rel2abs', 'ExtParserFunctions::rel2abs' ); + $parser->setFunctionHook( 'titleparts', 'ExtParserFunctions::titleparts' ); + + // String Functions + if ( $wgPFEnableStringFunctions ) { + $parser->setFunctionHook( 'len', 'ExtParserFunctions::runLen' ); + $parser->setFunctionHook( 'pos', 'ExtParserFunctions::runPos' ); + $parser->setFunctionHook( 'rpos', 'ExtParserFunctions::runRPos' ); + $parser->setFunctionHook( 'sub', 'ExtParserFunctions::runSub' ); + $parser->setFunctionHook( 'count', 'ExtParserFunctions::runCount' ); + $parser->setFunctionHook( 'replace', 'ExtParserFunctions::runReplace' ); + $parser->setFunctionHook( 'explode', 'ExtParserFunctions::runExplode' ); + $parser->setFunctionHook( 'urldecode', 'ExtParserFunctions::runUrlDecode' ); + } + + return true; + } + + /** + * @param $files array + * @return bool + */ + public static function onUnitTestsList( &$files ) { + $files[] = __DIR__ . '/tests/ExpressionTest.php'; + return true; + } + + public static function onScribuntoExternalLibraries( $engine, array &$extraLibraries ) { + if ( $engine == 'lua' ) { + $extraLibraries['mw.ext.ParserFunctions'] = 'Scribunto_LuaParserFunctionsLibrary'; + } + return true; + } +} -- cgit v1.2.3-54-g00ecf