https://www.mediawiki.org/wiki/Special:Code/MediaWiki/115429

Revision: 115429
Author:   petrb
Date:     2012-05-24 22:43:24 +0000 (Thu, 24 May 2012)
Log Message:
-----------
style of code

Modified Paths:
--------------
    trunk/extensions/OnlineStatusBar/OnlineStatusBar.body.php
    trunk/extensions/OnlineStatusBar/OnlineStatusBar.hooks.php
    trunk/extensions/OnlineStatusBar/OnlineStatusBar.status.php

Modified: trunk/extensions/OnlineStatusBar/OnlineStatusBar.body.php
===================================================================
--- trunk/extensions/OnlineStatusBar/OnlineStatusBar.body.php   2012-05-24 
22:24:17 UTC (rev 115428)
+++ trunk/extensions/OnlineStatusBar/OnlineStatusBar.body.php   2012-05-24 
22:43:24 UTC (rev 115429)
@@ -159,7 +159,10 @@
                                        if ( $user === false ) {
                                                $time = 
$wgOnlineStatusBar_AwayTime;
                                        } else {
-                                               $time = $user->getOption( 
'OnlineStatusBar_awaytime', $wgOnlineStatusBar_AwayTime );
+                                               $time = $user->getOption(
+                                                               
'OnlineStatusBar_awaytime',
+                                                               
$wgOnlineStatusBar_AwayTime
+                                                               );
                                        }       
                                        return wfTimestamp( TS_UNIX ) - ( $time 
* 60 );
                        }

Modified: trunk/extensions/OnlineStatusBar/OnlineStatusBar.hooks.php
===================================================================
--- trunk/extensions/OnlineStatusBar/OnlineStatusBar.hooks.php  2012-05-24 
22:24:17 UTC (rev 115428)
+++ trunk/extensions/OnlineStatusBar/OnlineStatusBar.hooks.php  2012-05-24 
22:43:24 UTC (rev 115429)
@@ -16,7 +16,12 @@
         */
        public static function ckSchema( $updater = null ) {
                if ( $updater !== null ) {
-                       $updater->addExtensionUpdate( array( 'addtable', 
'online_status', dirname( __FILE__ ) . '/OnlineStatusBar.sql', true ) );
+                       $updater->addExtensionUpdate( array( 'addtable',
+                                                       'online_status',
+                                                       dirname( __FILE__ ) .
+                                                       '/OnlineStatusBar.sql',
+                                                       true )
+                                               );
                } else {
                        global $wgExtNewTables;
                        $wgExtNewTables[] = array(
@@ -103,20 +108,40 @@
         * @return bool
         */
        public static function preferencesHook( User $user, array &$preferences 
) {
-               global $wgOnlineStatusBarDefaultOnline, 
$wgOnlineStatusBarDefaultEnabled, $wgOnlineStatusBar_AwayTime, 
$wgOnlineStatusBar_LogoutTime, $wgOnlineStatusBarModes;
-               $preferences['OnlineStatusBar_active'] = array( 'type' => 
'toggle', 'label-message' => 'onlinestatusbar-used', 'section' => 
'misc/onlinestatus' );
-               $preferences['OnlineStatusBar_hide'] = array( 'type' => 
'toggle', 'label-message' => 'onlinestatusbar-hide', 'section' => 
'misc/onlinestatus' );
-               $preferences['OnlineStatusBar_away'] = array( 'type' => 
'toggle', 'label-message' => 'onlinestatusbar-away', 'section' => 
'misc/onlinestatus' );
-               $preferences['OnlineStatusBar_autoupdate'] = array( 'type' => 
'toggle', 'label-message' => 'onlinestatusbar-purge', 'section' => 
'misc/onlinestatus' );
-               $preferences['OnlineStatusBar_status'] = array( 'type' => 
'radio', 'label-message' => 'onlinestatusbar-status', 'section' => 
'misc/onlinestatus',
-                       'options' => array(
+               global $wgOnlineStatusBarDefaultOnline, 
$wgOnlineStatusBarDefaultEnabled, $wgOnlineStatusBar_AwayTime,
+                       $wgOnlineStatusBar_LogoutTime, $wgOnlineStatusBarModes;
+               $preferences['OnlineStatusBar_active'] = array( 'type' => 
'toggle',
+                                                       'label-message' => 
'onlinestatusbar-used',
+                                                       'section' => 
'misc/onlinestatus'
+                                                       );
+               $preferences['OnlineStatusBar_hide'] = array( 'type' => 
'toggle',
+                                                       'label-message' => 
'onlinestatusbar-hide',
+                                                       'section' => 
'misc/onlinestatus'
+                                                       );
+               $preferences['OnlineStatusBar_away'] = array( 'type' => 
'toggle',
+                                                       'label-message' => 
'onlinestatusbar-away',
+                                                       'section' => 
'misc/onlinestatus'
+                                                       );
+               $preferences['OnlineStatusBar_autoupdate'] = array( 'type' => 
'toggle',
+                                                               'label-message' 
=> 'onlinestatusbar-purge',
+                                                               'section' => 
'misc/onlinestatus'
+                                                       );
+               $preferences['OnlineStatusBar_status'] = array( 'type' => 
'radio',
+                                                               'label-message' 
=> 'onlinestatusbar-status',
+                                                               'section' => 
'misc/onlinestatus',
+                               'options' => array(
                                wfMessage( 'onlinestatusbar-status-online' 
)->escaped() => 'online',
                                wfMessage( 'onlinestatusbar-status-busy' 
)->escaped() => 'busy',
                                wfMessage( 'onlinestatusbar-status-away' 
)->escaped() => 'away',
                                wfMessage( 'onlinestatusbar-status-hidden' 
)->escaped() => 'hidden'
                        ),
                );
-               $preferences['OnlineStatusBar_awaytime'] = array( 'min' => 2, 
'max' => $wgOnlineStatusBar_LogoutTime, 'type' => 'int', 'label-message' => 
'onlinestatusbar-away-time', 'section' => 'misc/onlinestatus' );
+               $preferences['OnlineStatusBar_awaytime'] = array( 'min' => 2,
+                                                               'max' => 
$wgOnlineStatusBar_LogoutTime,
+                                                               'type' => 'int',
+                                                               'label-message' 
=> 'onlinestatusbar-away-time',
+                                                               'section' => 
'misc/onlinestatus'
+                                                       );
                return true;
        }
 

Modified: trunk/extensions/OnlineStatusBar/OnlineStatusBar.status.php
===================================================================
--- trunk/extensions/OnlineStatusBar/OnlineStatusBar.status.php 2012-05-24 
22:24:17 UTC (rev 115428)
+++ trunk/extensions/OnlineStatusBar/OnlineStatusBar.status.php 2012-05-24 
22:43:24 UTC (rev 115429)
@@ -74,9 +74,14 @@
                        if ( $result == '' ) {
                                $t_time = OnlineStatusBar::getTimeoutDate();
                                $dbr = wfGetDB( DB_SLAVE );
-                               $result = $dbr->selectField( 'online_status', 
'timestamp', array( 'username' => $user->getName(),
-                                       'timestamp > ' . $dbr->addQuotes( 
$dbr->timestamp( $t_time ) ) ),
-                                       __METHOD__, array( 'LIMIT 1', 'ORDER BY 
timestamp DESC' ) );
+                               $result = $dbr->selectField(
+                                               'online_status',
+                                               'timestamp',
+                                               array( 'username' => 
$user->getName(),
+                                               'timestamp > ' .
+                                               $dbr->addQuotes( 
$dbr->timestamp( $t_time ) ) ),
+                                               __METHOD__, array( 'LIMIT 1', 
'ORDER BY timestamp DESC' )
+                                       );
                                // cache it
                                self::setCache( $user->getName(), $result, 
ONLINESTATUSBAR_NORMAL_CACHE );
                        }
@@ -86,8 +91,11 @@
                        $w_time = OnlineStatusBar::getTimeoutDate( 
ONLINESTATUSBAR_CK_DELAYED );
                        if ( $result == '' ) {
                                $dbr = wfGetDB( DB_SLAVE );
-                               $result = $dbr->selectField( 'online_status', 
'timestamp', array( 'username' => $user->getName() ),
-                                       __METHOD__, array( 'LIMIT 1', 'ORDER BY 
timestamp DESC' ) );
+                               $result = $dbr->selectField( 'online_status',
+                                               'timestamp',
+                                               array( 'username' => 
$user->getName() ),
+                                               __METHOD__, array( 'LIMIT 1', 
'ORDER BY timestamp DESC' )
+                                       );
                                // cache it
                                if ( $result !== false && $result > 
wfTimestamp( TS_MW, $w_time ) ) {
                                        self::setCache( $user->getName(), 
$result, ONLINESTATUSBAR_DELAYED_CACHE );
@@ -107,7 +115,10 @@
                                                $status = 'write';
                                        }
                                } else if ( $user->getOption( 
'OnlineStatusBar_away', true ) == true ) {
-                                       if ( $result < wfTimestamp( TS_MW, 
OnlineStatusBar::getTimeoutDate( ONLINESTATUSBAR_CK_AWAY, $user ) ) ) {
+                                       if ( $result < wfTimestamp( TS_MW,
+                                                       
OnlineStatusBar::getTimeoutDate( ONLINESTATUSBAR_CK_AWAY,
+                                                       $user )
+                                               ) ) {
                                                $status = 'away';
                                        }
                                }
@@ -211,8 +222,12 @@
                // Check if we actually need to delete something before we 
write to master
                $dbr = wfGetDB( DB_SLAVE );
                $time = OnlineStatusBar::getTimeoutDate();
-               $result = $dbr->selectField( 'online_status', 'timestamp', 
array( 'timestamp < ' . $dbr->addQuotes( $dbr->timestamp( $time ) ) ),
-                       __METHOD__, array( 'LIMIT 1' ) );
+               $result = $dbr->selectField( 'online_status',
+                               'timestamp',
+                               array( 'timestamp < ' .
+                               $dbr->addQuotes( $dbr->timestamp( $time ) ) ),
+                               __METHOD__, array( 'LIMIT 1' )
+                       );
                if ( $result === false ) {
                        // no need for delete
                        return 0;
@@ -220,8 +235,12 @@
 
                // calculate time and convert it back to mediawiki format
                $dbw = wfGetDB( DB_MASTER );
-               $dbw->delete( 'online_status', array( 'timestamp < ' . 
$dbw->addQuotes( $dbw->timestamp( $time ) ) ), __METHOD__ );
-               self::setCache( 'null', 'true', 'delete', 3600 ); // remember 
we deleted it for 1 hour so that we avoid calling this too many times
+               $dbw->delete( 'online_status',
+                       array( 'timestamp < ' . $dbw->addQuotes( 
$dbw->timestamp( $time ) ) ),
+                       __METHOD__
+               );
+               // remember we deleted it for 1 hour so that we avoid calling 
this too many times
+               self::setCache( 'null', 'true', 'delete', 3600 );
                return 0;
        }
 }


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to