r74600 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74599‎ | r74600 | r74601 >
Date:15:45, 10 October 2010
Author:platonides
Status:deferred
Tags:
Comment:
Change to use ParserFirstCallInit
Modified paths:
  • /trunk/extensions/StringFunctions/StringFunctions.php (modified) (history)

Diff [purge]

Index: trunk/extensions/StringFunctions/StringFunctions.php
@@ -112,29 +112,26 @@
113113 $dir = dirname( __FILE__ ) . '/';
114114 $wgExtensionMessagesFiles['StringFunctions'] = $dir . 'StringFunctions.i18n.php';
115115
116 -$wgExtensionFunctions[] = 'wfStringFunctions';
 116+$wgHooks['ParserFirstCallInit'][] = 'wfStringFunctions';
117117
118118 $wgHooks['LanguageGetMagic'][] = 'wfStringFunctionsLanguageGetMagic';
119119
120 -function wfStringFunctions() {
121 - global $wgParser;
122 - global $wgStringFunctionsLimitSearch;
123 - global $wgStringFunctionsLimitReplace;
124 - global $wgStringFunctionsLimitPad;
 120+$wgStringFunctionsLimitSearch = 30;
 121+$wgStringFunctionsLimitReplace = 30;
 122+$wgStringFunctionsLimitPad = 100;
125123
126 - $wgStringFunctionsLimitSearch = 30;
127 - $wgStringFunctionsLimitReplace = 30;
128 - $wgStringFunctionsLimitPad = 100;
 124+function wfStringFunctions( &$parser ) {
 125+ $parser->setFunctionHook( 'len', array( 'ExtStringFunctions', 'runLen' ) );
 126+ $parser->setFunctionHook( 'pos', array( 'ExtStringFunctions', 'runPos' ) );
 127+ $parser->setFunctionHook( 'rpos', array( 'ExtStringFunctions', 'runRPos' ) );
 128+ $parser->setFunctionHook( 'sub', array( 'ExtStringFunctions', 'runSub' ) );
 129+ $parser->setFunctionHook( 'pad', array( 'ExtStringFunctions', 'runPad' ) );
 130+ $parser->setFunctionHook( 'replace', array( 'ExtStringFunctions', 'runReplace' ) );
 131+ $parser->setFunctionHook( 'explode', array( 'ExtStringFunctions', 'runExplode' ) );
 132+ $parser->setFunctionHook( 'urlencode', array( 'ExtStringFunctions', 'runUrlEncode' ) );
 133+ $parser->setFunctionHook( 'urldecode', array( 'ExtStringFunctions', 'runUrlDecode' ) );
129134
130 - $wgParser->setFunctionHook( 'len', array( 'ExtStringFunctions', 'runLen' ) );
131 - $wgParser->setFunctionHook( 'pos', array( 'ExtStringFunctions', 'runPos' ) );
132 - $wgParser->setFunctionHook( 'rpos', array( 'ExtStringFunctions', 'runRPos' ) );
133 - $wgParser->setFunctionHook( 'sub', array( 'ExtStringFunctions', 'runSub' ) );
134 - $wgParser->setFunctionHook( 'pad', array( 'ExtStringFunctions', 'runPad' ) );
135 - $wgParser->setFunctionHook( 'replace', array( 'ExtStringFunctions', 'runReplace' ) );
136 - $wgParser->setFunctionHook( 'explode', array( 'ExtStringFunctions', 'runExplode' ) );
137 - $wgParser->setFunctionHook( 'urlencode', array( 'ExtStringFunctions', 'runUrlEncode' ) );
138 - $wgParser->setFunctionHook( 'urldecode', array( 'ExtStringFunctions', 'runUrlDecode' ) );
 135+ return true;
139136 }
140137
141138 function wfStringFunctionsLanguageGetMagic( &$magicWords, $langCode = 'en' ) {

Status & tagging log