r40702 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r40701‎ | r40702 | r40703 >
Date:15:26, 10 September 2008
Author:ialex
Status:old
Tags:
Comment:
Read $wgAllowAnyUserOnlineStatusFunction in the hook/extension function so that the wiki admin can change it :)
Modified paths:
  • /trunk/extensions/OnlineStatus/OnlineStatus.php (modified) (history)

Diff [purge]

Index: trunk/extensions/OnlineStatus/OnlineStatus.php
@@ -33,18 +33,16 @@
3434
3535 static function init(){
3636 global $wgExtensionMessagesFiles, $wgExtensionFunctions, $wgHooks, $wgAjaxExportList;
37 - global $wgAllowAnyUserOnlineStatusFunction;
 37+
3838 // Add messages file
3939 $wgExtensionMessagesFiles['OnlineStatus'] = dirname( __FILE__ ) . '/OnlineStatus.i18n.php';
4040
41 - if( $wgAllowAnyUserOnlineStatusFunction ){
42 - // Hooks for the Parser
43 - // Use ParserFirstCallInit if aviable
44 - if( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) )
45 - $wgHooks['ParserFirstCallInit'][] = 'OnlineStatus::ParserFirstCallInit';
46 - else
47 - $wgExtensionFunctions[] = 'OnlineStatus::Setup';
48 - }
 41+ // Hooks for the Parser
 42+ // Use ParserFirstCallInit if aviable
 43+ if( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) )
 44+ $wgHooks['ParserFirstCallInit'][] = 'OnlineStatus::ParserFirstCallInit';
 45+ else
 46+ $wgExtensionFunctions[] = 'OnlineStatus::Setup';
4947
5048 // Magic words hooks
5149 $wgHooks['MagicWordwgVariableIDs'][] = 'OnlineStatus::MagicWordVariable';
@@ -149,16 +147,17 @@
150148 */
151149 static function Setup() {
152150 global $wgParser;
153 - $wgParser->setFunctionHook( 'anyuseronlinestatus', array( __CLASS__, 'ParserHookCallback' ) );
154 - return true;
 151+ self::ParserFirstCallInit( $wgParser );
155152 }
156153
157154 /**
158155 * Hook for ParserFirstCallInit
159156 * Only called if $wgAllowAnyUserOnlineStatusFunction is true
160157 */
161 - static function ParserFirstCallInit( &$parser ){
162 - $parser->setFunctionHook( 'anyuseronlinestatus', array( __CLASS__, 'ParserHookCallback' ) );
 158+ static function ParserFirstCallInit( $parser ){
 159+ global $wgAllowAnyUserOnlineStatusFunction;
 160+ if( $wgAllowAnyUserOnlineStatusFunction )
 161+ $parser->setFunctionHook( 'anyuseronlinestatus', array( __CLASS__, 'ParserHookCallback' ) );
163162 return true;
164163 }
165164