Index: trunk/extensions/SocialProfile/UserStats/TopUsers.php |
— | — | @@ -6,7 +6,7 @@ |
7 | 7 | * Constructor |
8 | 8 | */ |
9 | 9 | public function __construct(){ |
10 | | - parent::__construct('TopUsers'); |
| 10 | + parent::__construct( 'TopUsers' ); |
11 | 11 | } |
12 | 12 | |
13 | 13 | /** |
— | — | @@ -15,7 +15,7 @@ |
16 | 16 | * @param $par Mixed: parameter passed to the page or null |
17 | 17 | */ |
18 | 18 | public function execute( $par ){ |
19 | | - global $wgUser, $wgOut, $wgScriptPath, $wgMemc, $wgUserStatsTrackWeekly, $wgUserStatsTrackMonthly, $wgUserLevels, $wgUploadPath; |
| 19 | + global $wgOut, $wgScriptPath, $wgMemc, $wgUserStatsTrackWeekly, $wgUserStatsTrackMonthly, $wgUserLevels, $wgUploadPath; |
20 | 20 | |
21 | 21 | // Read in localisation messages |
22 | 22 | wfLoadExtensionMessages('SocialProfileUserStats'); |
— | — | @@ -23,14 +23,15 @@ |
24 | 24 | // Load CSS |
25 | 25 | $wgOut->addStyle( '../..' . $wgScriptPath . '/extensions/SocialProfile/UserStats/TopList.css' ); |
26 | 26 | |
27 | | - $wgOut->setPagetitle( wfMsg( 'user-stats-alltime-title' ) ); |
| 27 | + $wgOut->setPageTitle( wfMsg( 'user-stats-alltime-title' ) ); |
28 | 28 | |
29 | | - $count = 50; |
| 29 | + $count = 100; |
| 30 | + $realcount = 50; |
30 | 31 | |
31 | 32 | $user_list = array(); |
32 | 33 | |
33 | 34 | // Try cache |
34 | | - $key = wfMemcKey( 'user_stats', 'top', 'points', $count ); |
| 35 | + $key = wfMemcKey( 'user_stats', 'top', 'points', $realcount ); |
35 | 36 | $data = $wgMemc->get( $key ); |
36 | 37 | if( $data != '' ){ |
37 | 38 | wfDebug("Got top users by points ({$count}) from cache\n"); |
— | — | @@ -42,16 +43,22 @@ |
43 | 44 | $params['LIMIT'] = $count; |
44 | 45 | $dbr = wfGetDB( DB_SLAVE ); |
45 | 46 | $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__, |
48 | 49 | $params |
49 | 50 | ); |
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; |
56 | 63 | } |
57 | 64 | $wgMemc->set( $key, $user_list, 60 * 5 ); |
58 | 65 | } |
— | — | @@ -59,26 +66,26 @@ |
60 | 67 | $recent_title = Title::makeTitle( NS_SPECIAL, 'TopUsersRecent' ); |
61 | 68 | |
62 | 69 | $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>'; |
65 | 72 | |
66 | 73 | 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>'; |
68 | 75 | } |
69 | 76 | |
70 | 77 | 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>'; |
72 | 79 | } |
73 | 80 | |
74 | 81 | // Build nav of stats by category based on MediaWiki:Topfans-by-category |
| 82 | + $by_category_title = Title::makeTitle( NS_SPECIAL, 'TopFansByStatistic' ); |
75 | 83 | |
| 84 | + $lines = explode( "\n", wfMsgForContent( 'topfans-by-category' ) ); |
| 85 | + |
76 | 86 | 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>'; |
78 | 88 | } |
79 | 89 | |
80 | | - $by_category_title = Title::makeTitle( NS_SPECIAL, 'TopFansByStatistic' ); |
81 | | - |
82 | | - $lines = explode( "\n", wfMsgForContent( 'topfans-by-category' ) ); |
83 | 90 | foreach( $lines as $line ) { |
84 | 91 | |
85 | 92 | if( strpos($line, '*') !== 0 ){ |
— | — | @@ -105,7 +112,7 @@ |
106 | 113 | if( is_array( $wgUserLevels ) ){ |
107 | 114 | $user_level = new UserLevel( number_format( $user['points'] ) ); |
108 | 115 | 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\"> |
110 | 117 | {$user_level->getLevelName()} |
111 | 118 | </div></div>"; |
112 | 119 | } |
— | — | @@ -114,15 +121,15 @@ |
115 | 122 | |
116 | 123 | $out .= "<div class=\"top-fan-row\"> |
117 | 124 | <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> |
119 | 126 | </span>"; |
120 | 127 | |
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>'; |
122 | 129 | $out .= '<div class="cleared"></div>'; |
123 | 130 | $out .= '</div>'; |
124 | 131 | $x++; |
125 | 132 | } |
126 | 133 | $out .= '</div><div class="cleared"></div>'; |
127 | | - $wgOut->addHTML($out); |
| 134 | + $wgOut->addHTML( $out ); |
128 | 135 | } |
129 | 136 | } |