r48744 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r48743‎ | r48744 | r48745 >
Date:15:35, 24 March 2009
Author:ashley
Status:deferred
Tags:
Comment:
SocialProfile: apply r7166 from wikia codebase (http://trac.wikia-code.com/changeset/7166; don't display blocked users on Special:TopUsers) + spacing + xhtml tweaks + removed unused $wgUser global
Modified paths:
  • /trunk/extensions/SocialProfile/UserStats/TopUsers.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SocialProfile/UserStats/TopUsers.php
@@ -6,7 +6,7 @@
77 * Constructor
88 */
99 public function __construct(){
10 - parent::__construct('TopUsers');
 10+ parent::__construct( 'TopUsers' );
1111 }
1212
1313 /**
@@ -15,7 +15,7 @@
1616 * @param $par Mixed: parameter passed to the page or null
1717 */
1818 public function execute( $par ){
19 - global $wgUser, $wgOut, $wgScriptPath, $wgMemc, $wgUserStatsTrackWeekly, $wgUserStatsTrackMonthly, $wgUserLevels, $wgUploadPath;
 19+ global $wgOut, $wgScriptPath, $wgMemc, $wgUserStatsTrackWeekly, $wgUserStatsTrackMonthly, $wgUserLevels, $wgUploadPath;
2020
2121 // Read in localisation messages
2222 wfLoadExtensionMessages('SocialProfileUserStats');
@@ -23,14 +23,15 @@
2424 // Load CSS
2525 $wgOut->addStyle( '../..' . $wgScriptPath . '/extensions/SocialProfile/UserStats/TopList.css' );
2626
27 - $wgOut->setPagetitle( wfMsg( 'user-stats-alltime-title' ) );
 27+ $wgOut->setPageTitle( wfMsg( 'user-stats-alltime-title' ) );
2828
29 - $count = 50;
 29+ $count = 100;
 30+ $realcount = 50;
3031
3132 $user_list = array();
3233
3334 // Try cache
34 - $key = wfMemcKey( 'user_stats', 'top', 'points', $count );
 35+ $key = wfMemcKey( 'user_stats', 'top', 'points', $realcount );
3536 $data = $wgMemc->get( $key );
3637 if( $data != '' ){
3738 wfDebug("Got top users by points ({$count}) from cache\n");
@@ -42,16 +43,22 @@
4344 $params['LIMIT'] = $count;
4445 $dbr = wfGetDB( DB_SLAVE );
4546 $res = $dbr->select( 'user_stats',
46 - array('stats_user_id','stats_user_name','stats_total_points'),
47 - array('stats_user_id <> 0'), __METHOD__,
 47+ array( 'stats_user_id', 'stats_user_name', 'stats_total_points' ),
 48+ array( 'stats_user_id <> 0' ), __METHOD__,
4849 $params
4950 );
50 - while( $row = $dbr->fetchObject($res) ){
51 - $user_list[] = array(
52 - 'user_id' => $row->stats_user_id,
53 - 'user_name' => $row->stats_user_name,
54 - 'points' => $row->stats_total_points
55 - );
 51+ $loop = 0;
 52+ while( $row = $dbr->fetchObject( $res ) ){
 53+ $user = User::newFromId( $row->stats_user_id );
 54+ if( !$user->isBlocked() ) {
 55+ $user_list[] = array(
 56+ 'user_id' => $row->stats_user_id,
 57+ 'user_name' => $row->stats_user_name,
 58+ 'points' => $row->stats_total_points
 59+ );
 60+ $loop++;
 61+ }
 62+ if( $loop >= 50 ) break;
5663 }
5764 $wgMemc->set( $key, $user_list, 60 * 5 );
5865 }
@@ -59,26 +66,26 @@
6067 $recent_title = Title::makeTitle( NS_SPECIAL, 'TopUsersRecent' );
6168
6269 $out = '<div class="top-fan-nav">
63 - <h1>' . wfMsg('top-fans-by-points-nav-header') . '</h1>
64 - <p><b>' . wfMsg('top-fans-total-points-link') . '</b></p>';
 70+ <h1>' . wfMsg( 'top-fans-by-points-nav-header' ) . '</h1>
 71+ <p><b>' . wfMsg( 'top-fans-total-points-link' ) . '</b></p>';
6572
6673 if( $wgUserStatsTrackWeekly ) {
67 - $out .= '<p><a href="' . $recent_title->escapeFullURL("period=monthly") . '">' . wfMsg('top-fans-monthly-points-link') . '</a><p>';
 74+ $out .= '<p><a href="' . $recent_title->escapeFullURL( 'period=monthly' ) . '">' . wfMsg( 'top-fans-monthly-points-link' ) . '</a></p>';
6875 }
6976
7077 if( $wgUserStatsTrackMonthly ) {
71 - $out .= '<p><a href="' . $recent_title->escapeFullURL("period=weekly") . '">' . wfMsg('top-fans-weekly-points-link') . '</a></p>';
 78+ $out .= '<p><a href="' . $recent_title->escapeFullURL( 'period=weekly' ) . '">' . wfMsg( 'top-fans-weekly-points-link' ) . '</a></p>';
7279 }
7380
7481 // Build nav of stats by category based on MediaWiki:Topfans-by-category
 82+ $by_category_title = Title::makeTitle( NS_SPECIAL, 'TopFansByStatistic' );
7583
 84+ $lines = explode( "\n", wfMsgForContent( 'topfans-by-category' ) );
 85+
7686 if( count( $lines ) > 0 ) {
77 - $out .= '<h1 style="margin-top:15px !important;">' . wfMsg('top-fans-by-category-nav-header') . '</h1>';
 87+ $out .= '<h1 style="margin-top:15px !important;">' . wfMsg( 'top-fans-by-category-nav-header' ) . '</h1>';
7888 }
7989
80 - $by_category_title = Title::makeTitle( NS_SPECIAL, 'TopFansByStatistic' );
81 -
82 - $lines = explode( "\n", wfMsgForContent( 'topfans-by-category' ) );
8390 foreach( $lines as $line ) {
8491
8592 if( strpos($line, '*') !== 0 ){
@@ -105,7 +112,7 @@
106113 if( is_array( $wgUserLevels ) ){
107114 $user_level = new UserLevel( number_format( $user['points'] ) );
108115 if( $user_level->getLevelName() != $last_level ){
109 - $out .= "<div class=\"top-fan-row\"><div class=\"top-fan-level\">
 116+ $out .= "<div class=\"top-fan-row\"><div class=\"top-fan-level\">
110117 {$user_level->getLevelName()}
111118 </div></div>";
112119 }
@@ -114,15 +121,15 @@
115122
116123 $out .= "<div class=\"top-fan-row\">
117124 <span class=\"top-fan-num\">{$x}.</span><span class=\"top-fan\">
118 - <img src='{$wgUploadPath}/avatars/" . $CommentIcon . "' alt='' border=''> <a href='" . $user_title->escapeFullURL() . "' >" . $user["user_name"] . "</a>
 125+ <img src='{$wgUploadPath}/avatars/" . $CommentIcon . "' alt='' border='' /> <a href='" . $user_title->escapeFullURL() . "' >" . $user['user_name'] . "</a>
119126 </span>";
120127
121 - $out .= '<span class="top-fan-points"><b>' . number_format( $user['points'] ) . '</b> ' . wfMsg('top-fans-points') .'</span>';
 128+ $out .= '<span class="top-fan-points"><b>' . number_format( $user['points'] ) . '</b> ' . wfMsg( 'top-fans-points' ) .'</span>';
122129 $out .= '<div class="cleared"></div>';
123130 $out .= '</div>';
124131 $x++;
125132 }
126133 $out .= '</div><div class="cleared"></div>';
127 - $wgOut->addHTML($out);
 134+ $wgOut->addHTML( $out );
128135 }
129136 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r7166draw updatesmagnus_manske15:49, 18 January 2005

Status & tagging log