Index: trunk/extensions/OnlineStatus/OnlineStatus.php |
— | — | @@ -4,7 +4,7 @@ |
5 | 5 | * Extension that adds a new toggle in user preferences to show if the user is |
6 | 6 | * aviabled or not. See http://mediawiki.org/wiki/Extension:OnlineStatus for |
7 | 7 | * more informations. |
8 | | - * Require MediaWiki 1.16 alpha r52503 or higher to work. |
| 8 | + * Require MediaWiki 1.17 r77011 or higher to work. |
9 | 9 | * |
10 | 10 | * @file |
11 | 11 | * @ingroup Extensions |
— | — | @@ -41,34 +41,34 @@ |
42 | 42 | $wgExtensionMessagesFiles['OnlineStatus'] = dirname( __FILE__ ) . '/OnlineStatus.i18n.php'; |
43 | 43 | $wgExtensionMessagesFiles['OnlineStatusMagic'] = dirname( __FILE__ ) . '/OnlineStatus.i18n.magic.php'; |
44 | 44 | |
45 | | -// FIXME: Should be a separate class file |
46 | | -class OnlineStatus { |
47 | | - // FIXME: Can't this just be in the core bit instead of the class? The init() will not have to be called |
48 | | - static function init(){ |
49 | | - global $wgExtensionFunctions, $wgHooks, $wgAjaxExportList; |
| 45 | +// Hooks for the Parser |
| 46 | +$wgHooks['ParserFirstCallInit'][] = 'OnlineStatus::ParserFirstCallInit'; |
50 | 47 | |
51 | | - // Hooks for the Parser |
52 | | - $wgHooks['ParserFirstCallInit'][] = 'OnlineStatus::ParserFirstCallInit'; |
| 48 | +// Magic words hooks |
| 49 | +$wgHooks['MagicWordwgVariableIDs'][] = 'OnlineStatus::MagicWordVariable'; |
| 50 | +$wgHooks['ParserGetVariableValueSwitch'][] = 'OnlineStatus::ParserGetVariable'; |
53 | 51 | |
54 | | - // Magic words hooks |
55 | | - $wgHooks['MagicWordwgVariableIDs'][] = 'OnlineStatus::MagicWordVariable'; |
56 | | - $wgHooks['ParserGetVariableValueSwitch'][] = 'OnlineStatus::ParserGetVariable'; |
| 52 | +// Hooks for Special:Preferences |
| 53 | +$wgHooks['GetPreferences'][] = 'OnlineStatus::GetPreferences'; |
57 | 54 | |
58 | | - // Hooks for Special:Preferences |
59 | | - $wgHooks['GetPreferences'][] = 'OnlineStatus::GetPreferences'; |
| 55 | +// User hook |
| 56 | +$wgHooks['UserLoginComplete'][] = 'OnlineStatus::UserLoginComplete'; |
| 57 | +$wgHooks['UserLogoutComplete'][] = 'OnlineStatus::UserLogoutComplete'; |
60 | 58 | |
61 | | - // User hook |
62 | | - $wgHooks['UserLoginComplete'][] = 'OnlineStatus::UserLoginComplete'; |
63 | | - $wgHooks['UserLogoutComplete'][] = 'OnlineStatus::UserLogoutComplete'; |
| 59 | +// User page |
| 60 | +$wgHooks['BeforePageDisplay'][] = 'OnlineStatus::BeforePageDisplay'; |
| 61 | +$wgHooks['PersonalUrls'][] = 'OnlineStatus::PersonalUrls'; |
64 | 62 | |
65 | | - // User page |
66 | | - $wgHooks['BeforePageDisplay'][] = 'OnlineStatus::BeforePageDisplay'; |
67 | | - $wgHooks['PersonalUrls'][] = 'OnlineStatus::PersonalUrls'; |
| 63 | +// Ajax stuff |
| 64 | +$wgAjaxExportList[] = 'OnlineStatus::Ajax'; |
68 | 65 | |
69 | | - // Ajax stuff |
70 | | - $wgAjaxExportList[] = 'OnlineStatus::Ajax'; |
71 | | - } |
| 66 | +$wgResourceModules['ext.onlineStatus'] = array( |
| 67 | + 'scripts' => 'extensions/OnlineStatus/OnlineStatus.js', |
| 68 | + 'styles' => 'extensions/OnlineStatus/OnlineStatus.css', |
| 69 | +); |
72 | 70 | |
| 71 | +// FIXME: Should be a separate class file |
| 72 | +class OnlineStatus { |
73 | 73 | /** |
74 | 74 | * Get the user online status |
75 | 75 | * |
— | — | @@ -274,18 +274,16 @@ |
275 | 275 | * Hook function for BeforePageDisplay |
276 | 276 | */ |
277 | 277 | static function BeforePageDisplay( &$out ){ |
278 | | - global $wgTitle, $wgRequest, $wgUser; |
| 278 | + global $wgRequest, $wgUser; |
279 | 279 | global $wgUseAjax; |
280 | 280 | |
281 | 281 | if( $wgUser->isLoggedIn() && $wgUseAjax ){ |
282 | | - global $wgScriptPath; |
283 | | - $out->addScriptFile( "{$wgScriptPath}/extensions/OnlineStatus/OnlineStatus.js" ); |
284 | | - $out->addExtensionStyle( "{$wgScriptPath}/extensions/OnlineStatus/OnlineStatus.css" ); |
| 282 | + $out->addModules( 'ext.onlineStatus' ); |
285 | 283 | } |
286 | 284 | |
287 | 285 | if( !in_array( $wgRequest->getVal( 'action', 'view' ), array( 'view', 'purge' ) ) ) |
288 | 286 | return true; |
289 | | - $status = self::GetUserStatus( $wgTitle, true ); |
| 287 | + $status = self::GetUserStatus( $out->getTitle(), true ); |
290 | 288 | if( $status === null ) |
291 | 289 | return true; |
292 | 290 | $out->setSubtitle( wfMsgExt( 'onlinestatus-subtitle-' . $status, array( 'parse' ) ) ); |
— | — | @@ -316,5 +314,3 @@ |
317 | 315 | return true; |
318 | 316 | } |
319 | 317 | } |
320 | | - |
321 | | -OnlineStatus::init(); |