r100544 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100543‎ | r100544 | r100545 >
Date:13:58, 23 October 2011
Author:nikerabbit
Status:deferred
Tags:
Comment:
Stylized
Modified paths:
  • /trunk/extensions/OnlineStatusBar/OnlineStatusBar.body.php (modified) (history)
  • /trunk/extensions/OnlineStatusBar/OnlineStatusBar.php (modified) (history)

Diff [purge]

Index: trunk/extensions/OnlineStatusBar/OnlineStatusBar.body.php
@@ -17,22 +17,22 @@
1818 class OnlineStatusBar {
1919 private static function GetNow()
2020 {
21 - return gmdate('Ymdhis', time());
 21+ return gmdate( 'Ymdhis', time() );
2222 }
23 -
24 - public static function Get_Html( $text, $mode)
 23+
 24+ public static function Get_Html( $text, $mode )
2525 {
2626 global $wgOnlineStatusBarModes, $wgOnlineStatusBarIcon, $wgOnlineStatusBarColor, $wgOnlineStatusBarY;
2727 $icon = "$wgExtensionAssetsPath/OnlineStatusBar/{$wgOnlineStatusBarModes[$mode]}";
2828 $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>';
3030 }
3131
3232 static function UpdateDb()
3333 {
3434 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 )
3737 {
3838 $dbw = wfGetDB( DB_MASTER );
3939 $now = OnlineStatusBar::GetNow();
@@ -43,7 +43,7 @@
4444 );
4545 $dbw->insert( 'online_status', $row, __METHOD__, 'DELAYED' );
4646 }
47 -
 47+
4848 return false;
4949 }
5050
@@ -51,25 +51,25 @@
5252 {
5353 global $wgUser, $wgOnlineStatusBarDefaultOffline;
5454 $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 )
5757 {
5858 OnlineStatusBar::UpdateDb();
5959 return true;
6060 }
6161 $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__ );
6363
6464 return false;
65 -
 65+
6666 }
67 -
 67+
6868 public static function DeleteOld()
6969 {
7070 global $wgOnlineStatusBar_LogoutTime, $wgDBname;
71 - $dbw= wfGetDB( DB_MASTER );
 71+ $dbw = wfGetDB( DB_MASTER );
7272 $time = OnlineStatusBar::GetNow() - $wgOnlineStatusBar_LogoutTime;
73 - $dbw->delete( 'online_status', array( 'timestamp < "' . $time . '"' ) ,__METHOD__ );
 73+ $dbw->delete( 'online_status', array( 'timestamp < "' . $time . '"' ) , __METHOD__ );
7474 return 0;
7575 }
7676
@@ -77,19 +77,19 @@
7878 global $wgOnlineStatusBarModes, $wgOnlineStatusBarDefaultOffline, $wgOnlineStatusBarDefaultOnline, $wgDBname;
7979 $dbw = wfGetDB( DB_MASTER );
8080 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 )
8383 {
8484 return $wgOnlineStatusBarDefaultOnline;
8585 }
86 -
 86+
8787 return $wgOnlineStatusBarDefaultOffline;
8888 }
89 -
 89+
9090 static function DeleteStatus( $user )
9191 {
9292 $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
9494 return true;
95 - }
 95+ }
9696 }
Index: trunk/extensions/OnlineStatusBar/OnlineStatusBar.php
@@ -14,7 +14,7 @@
1515 * @link http://www.mediawiki.org/wiki/Extension:OnlineStatusBar Documentation
1616 */
1717
18 -$wgExtensionCredits[version_compare($wgVersion, '1.17', '>=') ? 'userpage tools' : 'other'][] = array(
 18+$wgExtensionCredits[version_compare( $wgVersion, '1.17', '>=' ) ? 'userpage tools' : 'other'][] = array(
1919 'path' => __FILE__,
2020 'name' => 'Online status bar',
2121 'version' => '1.0.0',
@@ -52,23 +52,23 @@
5353 'offline' => "red",
5454 );
5555
56 -//default for online
 56+// default for online
5757 $wgOnlineStatusBarDefaultOnline = "online";
58 -//default for offline
 58+// default for offline
5959 $wgOnlineStatusBarDefaultOffline = "offline";
60 -//if new users have this feature enabled by default (experimental)
 60+// if new users have this feature enabled by default (experimental)
6161 $wgOnlineStatusBarDefaultEnabled = false;
62 -//how long to wait until user is considered as offline
 62+// how long to wait until user is considered as offline
6363 $wgOnlineStatusBar_LogoutTime = 3600;
64 -//position of status bar
 64+// position of status bar
6565 $wgOnlineStatusBarY = "-35";
6666
6767 $wgHooks['LoadExtensionSchemaUpdates'][] = 'wfOnlineStatusBar_CkSchema';
68 -function wfOnlineStatusBar_CkSchema($updater = null)
 68+function wfOnlineStatusBar_CkSchema( $updater = null )
6969 {
70 - if ($updater != null)
 70+ if ( $updater != null )
7171 {
72 - $updater->addExtensionUpdate( array ( 'addtable', 'online_status', dirname( __FILE__) . '/OnlineStatusBar.sql', true));
 72+ $updater->addExtensionUpdate( array ( 'addtable', 'online_status', dirname( __FILE__ ) . '/OnlineStatusBar.sql', true ) );
7373 }
7474 else
7575 {
@@ -80,26 +80,26 @@
8181 }
8282
8383 $wgHooks['UserLogoutComplete'][] = 'wfOnlineStatusBar_Logout';
84 -function wfOnlineStatusBar_Logout(&$user, &$inject_html, $old_name)
 84+function wfOnlineStatusBar_Logout( &$user, &$inject_html, $old_name )
8585 {
8686 global $wgUser;
87 - OnlineStatusBar::DeleteStatus($old_name);
 87+ OnlineStatusBar::DeleteStatus( $old_name );
8888 return true;
8989 }
9090
9191 $wgHooks['ArticleViewHeader'][] = 'wfOnlineStatusBar_RenderBar';
92 -function wfOnlineStatusBar_RenderBar(&$article, &$outputDone, &$pcache)
 92+function wfOnlineStatusBar_RenderBar( &$article, &$outputDone, &$pcache )
9393 {
9494 global $wgOnlineStatusBar_Template, $messages, $wgOnlineStatusBarModes, $wgOut;
9595 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 ) )
9898 {
9999 // 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 ) );
104104 }
105105 return true;
106106 }

Status & tagging log