Index: trunk/extensions/OnlineStatusBar/OnlineStatusBar.body.php |
— | — | @@ -17,22 +17,22 @@ |
18 | 18 | class OnlineStatusBar { |
19 | 19 | private static function GetNow() |
20 | 20 | { |
21 | | - return gmdate('Ymdhis', time()); |
| 21 | + return gmdate( 'Ymdhis', time() ); |
22 | 22 | } |
23 | | - |
24 | | - public static function Get_Html( $text, $mode) |
| 23 | + |
| 24 | + public static function Get_Html( $text, $mode ) |
25 | 25 | { |
26 | 26 | global $wgOnlineStatusBarModes, $wgOnlineStatusBarIcon, $wgOnlineStatusBarColor, $wgOnlineStatusBarY; |
27 | 27 | $icon = "$wgExtensionAssetsPath/OnlineStatusBar/{$wgOnlineStatusBarModes[$mode]}"; |
28 | 28 | $color = $wgOnlineStatusBarColor[$mode]; |
29 | | - return '<div style="right:0px; margin-top:-10px;" class="metadata topicon" id="status-top"><div style="border: 0px solid black; background: transparent; float: right; position: relative; top:' . $wgOnlineStatusBarY . 'px; padding: 5px"><p><b>' . $text . ': <span style="color: ' . $color . '; font:bold;"><img alt=' . $text . " - " . $mode .' src="' . $wgOnlineStatusBarIcon[$mode] . '" width="20" height="20" />' . $icon . '</span></b></p></div></div>'; |
| 29 | + return '<div style="right:0px; margin-top:-10px;" class="metadata topicon" id="status-top"><div style="border: 0px solid black; background: transparent; float: right; position: relative; top:' . $wgOnlineStatusBarY . 'px; padding: 5px"><p><b>' . $text . ': <span style="color: ' . $color . '; font:bold;"><img alt=' . $text . " - " . $mode . ' src="' . $wgOnlineStatusBarIcon[$mode] . '" width="20" height="20" />' . $icon . '</span></b></p></div></div>'; |
30 | 30 | } |
31 | 31 | |
32 | 32 | static function UpdateDb() |
33 | 33 | { |
34 | 34 | global $wgUser; |
35 | | - //FIXME: GetStatus needs a user id |
36 | | - if ( OnlineStatusBar::GetStatus( $wgUser->getID()) != $OnlineStatusBar->DefaultOnline ) |
| 35 | + // FIXME: GetStatus needs a user id |
| 36 | + if ( OnlineStatusBar::GetStatus( $wgUser->getID() ) != $OnlineStatusBar->DefaultOnline ) |
37 | 37 | { |
38 | 38 | $dbw = wfGetDB( DB_MASTER ); |
39 | 39 | $now = OnlineStatusBar::GetNow(); |
— | — | @@ -43,7 +43,7 @@ |
44 | 44 | ); |
45 | 45 | $dbw->insert( 'online_status', $row, __METHOD__, 'DELAYED' ); |
46 | 46 | } |
47 | | - |
| 47 | + |
48 | 48 | return false; |
49 | 49 | } |
50 | 50 | |
— | — | @@ -51,25 +51,25 @@ |
52 | 52 | { |
53 | 53 | global $wgUser, $wgOnlineStatusBarDefaultOffline; |
54 | 54 | $now = OnlineStatusBar::GetNow(); |
55 | | - //FIXME: GetStatus needs a user id |
56 | | - if (OnlineStatusBar::GetStatus() == $wgOnlineStatusBarDefaultOffline) |
| 55 | + // FIXME: GetStatus needs a user id |
| 56 | + if ( OnlineStatusBar::GetStatus() == $wgOnlineStatusBarDefaultOffline ) |
57 | 57 | { |
58 | 58 | OnlineStatusBar::UpdateDb(); |
59 | 59 | return true; |
60 | 60 | } |
61 | 61 | $dbw = wfGetDB( DB_MASTER ); |
62 | | - $dbw->update('online_status', array ('timestamp' => $now), array ('username' => $wgUser->getName()), __METHOD__ ); |
| 62 | + $dbw->update( 'online_status', array ( 'timestamp' => $now ), array ( 'username' => $wgUser->getName() ), __METHOD__ ); |
63 | 63 | |
64 | 64 | return false; |
65 | | - |
| 65 | + |
66 | 66 | } |
67 | | - |
| 67 | + |
68 | 68 | public static function DeleteOld() |
69 | 69 | { |
70 | 70 | global $wgOnlineStatusBar_LogoutTime, $wgDBname; |
71 | | - $dbw= wfGetDB( DB_MASTER ); |
| 71 | + $dbw = wfGetDB( DB_MASTER ); |
72 | 72 | $time = OnlineStatusBar::GetNow() - $wgOnlineStatusBar_LogoutTime; |
73 | | - $dbw->delete( 'online_status', array( 'timestamp < "' . $time . '"' ) ,__METHOD__ ); |
| 73 | + $dbw->delete( 'online_status', array( 'timestamp < "' . $time . '"' ) , __METHOD__ ); |
74 | 74 | return 0; |
75 | 75 | } |
76 | 76 | |
— | — | @@ -77,19 +77,19 @@ |
78 | 78 | global $wgOnlineStatusBarModes, $wgOnlineStatusBarDefaultOffline, $wgOnlineStatusBarDefaultOnline, $wgDBname; |
79 | 79 | $dbw = wfGetDB( DB_MASTER ); |
80 | 80 | OnlineStatusBar::DeleteOld(); |
81 | | - $result = $dbw->select( 'online_status', array('userid', 'username', 'timestamp'), array('username' => $userID), __METHOD__, array('limit 1', 'order by timestamp desc')); |
82 | | - if ($result->numRows() > 0) |
| 81 | + $result = $dbw->select( 'online_status', array( 'userid', 'username', 'timestamp' ), array( 'username' => $userID ), __METHOD__, array( 'limit 1', 'order by timestamp desc' ) ); |
| 82 | + if ( $result->numRows() > 0 ) |
83 | 83 | { |
84 | 84 | return $wgOnlineStatusBarDefaultOnline; |
85 | 85 | } |
86 | | - |
| 86 | + |
87 | 87 | return $wgOnlineStatusBarDefaultOffline; |
88 | 88 | } |
89 | | - |
| 89 | + |
90 | 90 | static function DeleteStatus( $user ) |
91 | 91 | { |
92 | 92 | $dbw = wfGetDB ( DB_MASTER ); |
93 | | - $dbw->delete( 'online_status', array('username' => $user), __METHOD__ ); // delete user |
| 93 | + $dbw->delete( 'online_status', array( 'username' => $user ), __METHOD__ ); // delete user |
94 | 94 | return true; |
95 | | - } |
| 95 | + } |
96 | 96 | } |
Index: trunk/extensions/OnlineStatusBar/OnlineStatusBar.php |
— | — | @@ -14,7 +14,7 @@ |
15 | 15 | * @link http://www.mediawiki.org/wiki/Extension:OnlineStatusBar Documentation |
16 | 16 | */ |
17 | 17 | |
18 | | -$wgExtensionCredits[version_compare($wgVersion, '1.17', '>=') ? 'userpage tools' : 'other'][] = array( |
| 18 | +$wgExtensionCredits[version_compare( $wgVersion, '1.17', '>=' ) ? 'userpage tools' : 'other'][] = array( |
19 | 19 | 'path' => __FILE__, |
20 | 20 | 'name' => 'Online status bar', |
21 | 21 | 'version' => '1.0.0', |
— | — | @@ -52,23 +52,23 @@ |
53 | 53 | 'offline' => "red", |
54 | 54 | ); |
55 | 55 | |
56 | | -//default for online |
| 56 | +// default for online |
57 | 57 | $wgOnlineStatusBarDefaultOnline = "online"; |
58 | | -//default for offline |
| 58 | +// default for offline |
59 | 59 | $wgOnlineStatusBarDefaultOffline = "offline"; |
60 | | -//if new users have this feature enabled by default (experimental) |
| 60 | +// if new users have this feature enabled by default (experimental) |
61 | 61 | $wgOnlineStatusBarDefaultEnabled = false; |
62 | | -//how long to wait until user is considered as offline |
| 62 | +// how long to wait until user is considered as offline |
63 | 63 | $wgOnlineStatusBar_LogoutTime = 3600; |
64 | | -//position of status bar |
| 64 | +// position of status bar |
65 | 65 | $wgOnlineStatusBarY = "-35"; |
66 | 66 | |
67 | 67 | $wgHooks['LoadExtensionSchemaUpdates'][] = 'wfOnlineStatusBar_CkSchema'; |
68 | | -function wfOnlineStatusBar_CkSchema($updater = null) |
| 68 | +function wfOnlineStatusBar_CkSchema( $updater = null ) |
69 | 69 | { |
70 | | - if ($updater != null) |
| 70 | + if ( $updater != null ) |
71 | 71 | { |
72 | | - $updater->addExtensionUpdate( array ( 'addtable', 'online_status', dirname( __FILE__) . '/OnlineStatusBar.sql', true)); |
| 72 | + $updater->addExtensionUpdate( array ( 'addtable', 'online_status', dirname( __FILE__ ) . '/OnlineStatusBar.sql', true ) ); |
73 | 73 | } |
74 | 74 | else |
75 | 75 | { |
— | — | @@ -80,26 +80,26 @@ |
81 | 81 | } |
82 | 82 | |
83 | 83 | $wgHooks['UserLogoutComplete'][] = 'wfOnlineStatusBar_Logout'; |
84 | | -function wfOnlineStatusBar_Logout(&$user, &$inject_html, $old_name) |
| 84 | +function wfOnlineStatusBar_Logout( &$user, &$inject_html, $old_name ) |
85 | 85 | { |
86 | 86 | global $wgUser; |
87 | | - OnlineStatusBar::DeleteStatus($old_name); |
| 87 | + OnlineStatusBar::DeleteStatus( $old_name ); |
88 | 88 | return true; |
89 | 89 | } |
90 | 90 | |
91 | 91 | $wgHooks['ArticleViewHeader'][] = 'wfOnlineStatusBar_RenderBar'; |
92 | | -function wfOnlineStatusBar_RenderBar(&$article, &$outputDone, &$pcache) |
| 92 | +function wfOnlineStatusBar_RenderBar( &$article, &$outputDone, &$pcache ) |
93 | 93 | { |
94 | 94 | global $wgOnlineStatusBar_Template, $messages, $wgOnlineStatusBarModes, $wgOut; |
95 | 95 | OnlineStatusBar::UpdateStatus(); |
96 | | - $ns=$article->getTitle()->getNamespace(); |
97 | | - if(($ns == NS_USER_TALK) || ($ns == NS_USER)) |
| 96 | + $ns = $article->getTitle()->getNamespace(); |
| 97 | + if ( ( $ns == NS_USER_TALK ) || ( $ns == NS_USER ) ) |
98 | 98 | { |
99 | 99 | // better way to get a username would be great :) |
100 | | - $user = preg_replace('/\/.*/', '', preg_replace('/^.*\:/', "", $article->getTitle())); |
101 | | - $OnlineStatus_Text = $user . language::getMessageFromDB("onlinestatusbar-line"); |
102 | | - $OnlineStatus_Mode = OnlineStatusBar::GetStatus($user); |
103 | | - $wgOut->addHtml(OnlineStatusBar::Get_Html($OnlineStatus_Text, $OnlineStatus_Mode)); |
| 100 | + $user = preg_replace( '/\/.*/', '', preg_replace( '/^.*\:/', "", $article->getTitle() ) ); |
| 101 | + $OnlineStatus_Text = $user . language::getMessageFromDB( "onlinestatusbar-line" ); |
| 102 | + $OnlineStatus_Mode = OnlineStatusBar::GetStatus( $user ); |
| 103 | + $wgOut->addHtml( OnlineStatusBar::Get_Html( $OnlineStatus_Text, $OnlineStatus_Mode ) ); |
104 | 104 | } |
105 | 105 | return true; |
106 | 106 | } |