r61248 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61247‎ | r61248 | r61249 >
Date:14:05, 19 January 2010
Author:ashley
Status:deferred
Tags:
Comment:
SocialProfile: fixes to UserStats
Modified paths:
  • /trunk/extensions/SocialProfile/UserStats/TopFansByStat.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserStats/TopFansRecent.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserStats/UserStats.i18n.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SocialProfile/UserStats/TopFansRecent.php
@@ -23,8 +23,14 @@
2424
2525 // Load CSS
2626 $wgOut->addExtensionStyle( $wgScriptPath . '/extensions/SocialProfile/UserStats/TopList.css' );
27 - $period = $wgRequest->getVal( 'period' );
2827
 28+ $periodFromRequest = $wgRequest->getVal( 'period' );
 29+ if ( $periodFromRequest == 'weekly' ) {
 30+ $period = 'weekly';
 31+ } elseif ( $periodFromRequest == 'monthly' ) {
 32+ $period = 'monthly';
 33+ }
 34+
2935 if ( !$period ) {
3036 $period = 'weekly';
3137 }
@@ -52,7 +58,8 @@
5359 $params['LIMIT'] = $count;
5460
5561 $dbr = wfGetDB( DB_SLAVE );
56 - $res = $dbr->select( "user_points_{$period}",
 62+ $res = $dbr->select(
 63+ "user_points_{$period}",
5764 array( 'up_user_id', 'up_user_name', 'up_points' ),
5865 array( 'up_user_id <> 0' ),
5966 __METHOD__,
@@ -92,8 +99,8 @@
93100 if ( count( $lines ) > 0 ) {
94101 $out .= '<h1 style="margin-top:15px !important;">' . wfMsg( 'top-fans-by-category-nav-header' ) . '</h1>';
95102 }
 103+
96104 foreach ( $lines as $line ) {
97 -
98105 if ( strpos( $line, '*' ) !== 0 ) {
99106 continue;
100107 } else {
Index: trunk/extensions/SocialProfile/UserStats/UserStats.i18n.php
@@ -23,7 +23,20 @@
2424 'top-fans-weekly-points-link' => 'Points this week',
2525 'top-fans-monthly-points-link' => 'Points this month',
2626 'top-fans-points' => 'points',
27 - 'top-fans-by-category-title' => 'Top overall $1',
 27+ 'top-fans-by-category-title-edit-count' => 'Top overall edits',
 28+ 'top-fans-by-category-title-friends-count' => 'Top overall friends',
 29+ 'top-fans-by-category-title-foe-count' => 'Top overall foes',
 30+ 'top-fans-by-category-title-gifts-rec-count' => 'Top overall gifs received',
 31+ 'top-fans-by-category-title-gifts-sent-count' => 'Top overall gifts sent',
 32+ 'top-fans-by-category-title-vote-count' => 'Top overall votes',
 33+ 'top-fans-by-category-title-comment-count' => 'Top overall comments',
 34+ 'top-fans-by-category-title-referrals-count' => 'Top overall referrals',
 35+ 'top-fans-by-category-title-comment-score-positive-rec' => 'Top overall thumbs up',
 36+ 'top-fans-by-category-title-comment-score-negative-rec' => 'Top overall thumbs down',
 37+ 'top-fans-by-category-title-comment-score-positive-given' => 'Top overall thumbs up given',
 38+ 'top-fans-by-category-title-comment-score-negative-given' => 'Top overall thumbs down given',
 39+ 'top-fans-by-category-title-monthly-winner-count' => 'Top overall monthly wins',
 40+ 'top-fans-by-category-title-weekly-winner-count' => 'Top overall weekly wins',
2841 'top-fans-bad-field-title' => 'Oops!',
2942 'top-fans-bad-field-message' => 'The specified stat does not exist.',
3043 'top-fans-stats-vote-count' => '{{PLURAL:$1|Vote|Votes}}',
@@ -759,17 +772,31 @@
760773 'top-fans-points' => 'pistettä',
761774 'top-fans-bad-field-title' => 'Ups!',
762775 'top-fans-bad-field-message' => 'Määritettyä tilastotietoa ei ole olemassa.',
763 - 'top-fans-stats-vote-count' => '{{PLURAL:$1|Ääni|Ääniä}}',
 776+ 'top-fans-by-category-title-edit-count' => 'Eniten muokkauksia',
 777+ 'top-fans-by-category-title-friends-count' => 'Eniten ystäviä',
 778+ 'top-fans-by-category-title-foe-count' => 'Eniten vihollisia',
 779+ 'top-fans-by-category-title-gifts-rec-count' => 'Eniten saatuja lahjoja',
 780+ 'top-fans-by-category-title-gifts-sent-count' => 'Eniten lähetettyjä lahjoja',
 781+ 'top-fans-by-category-title-vote-count' => 'Eniten ääniä',
 782+ 'top-fans-by-category-title-comment-count' => 'Eniten kommentteja',
 783+ 'top-fans-by-category-title-referrals-count' => 'Eniten lähetettyjä käyttäjiä',
 784+ 'top-fans-by-category-title-comment-score-positive-rec' => 'Eniten peukaloita ylös',
 785+ 'top-fans-by-category-title-comment-score-negative-rec' => 'Eniten peukaloita alas',
 786+ 'top-fans-by-category-title-comment-score-positive-given' => 'Eniten annettuja peukaloita ylös',
 787+ 'top-fans-by-category-title-comment-score-negative-given' => 'Eniten annettuja peukaloita alas',
 788+ 'top-fans-by-category-title-monthly-winner-count' => 'Eniten kuukausittaisia voittoja',
 789+ 'top-fans-by-category-title-weekly-winner-count' => 'Eniten viikottaisia voittoja',
 790+ 'top-fans-stats-vote-count' => '{{PLURAL:$1|ääni|ääniä}}',
764791 'top-fans-stats-monthly-winner-count' => '{{PLURAL:$1|kuukausittainen voitto|kuukausittaista voittoa}}',
765792 'top-fans-stats-weekly-winner-count' => '{{PLURAL:$1|viikottainen voitto|viikottaista voittoa}}',
766793 'top-fans-stats-edit-count' => '{{PLURAL:$1|muokkaus|muokkausta}}',
767794 'top-fans-stats-comment-count' => '{{PLURAL:$1|kommentti|kommenttia}}',
768795 'top-fans-stats-friends-count' => '{{PLURAL:$1|ystävä|ystävää}}',
769796 'top-fans-stats-foe-count' => '{{PLURAL:$1|vihollinen|vihollista}}',
770 - 'top-fans-stats-opinions-published' => '{{PLURAL:$1|Julkaistu mielipide|Julkaistut mielipiteet}}',
771 - 'top-fans-stats-opinions-created' => '{{PLURAL:$1|Mielipide|Mielipiteet}}',
772 - 'top-fans-stats-comment-score-positive-rec' => '{{PLURAL:$1|Peukalo ylös|Peukalot ylös}}',
773 - 'top-fans-stats-comment-score-negative-rec' => '{{PLURAL:$1|Peukalo alas|Peukalot alas}}',
 797+ 'top-fans-stats-opinions-published' => '{{PLURAL:$1|julkaistu mielipide|julkaistua mielipidettä}}',
 798+ 'top-fans-stats-opinions-created' => '{{PLURAL:$1|mielipide|mielipidettä}}',
 799+ 'top-fans-stats-comment-score-positive-rec' => '{{PLURAL:$1|peukalo ylös|peukaloa ylös}}',
 800+ 'top-fans-stats-comment-score-negative-rec' => '{{PLURAL:$1|peukalo alas|peukaloa alas}}',
774801 'top-fans-stats-gifts-rec-count' => '{{PLURAL:$1|saatu lahja|saatua lahjaa}}',
775802 'top-fans-stats-gifts-sent-count' => '{{PLURAL:$1|lähetetty lahja|lähetettyä lahjaa}}',
776803 'right-updatepoints' => 'Päivittää muokkausmääriä',
Index: trunk/extensions/SocialProfile/UserStats/TopFansByStat.php
@@ -24,12 +24,11 @@
2525 // Load CSS
2626 $wgOut->addExtensionStyle( $wgScriptPath . '/extensions/SocialProfile/UserStats/TopList.css' );
2727
28 - $statistic = $wgRequest->getVal( 'stat' );
 28+ $dbr = wfGetDB( DB_SLAVE );
 29+
 30+ $statistic = $dbr->strencode( trim( $wgRequest->getVal( 'stat' ) ) );
2931 $column = "stats_{$statistic}";
30 - $stat_name_friendly = wfMsg( "top-fans-stats-{$statistic}" );
3132
32 - $dbr = wfGetDB( DB_SLAVE );
33 -
3433 // Error if the querystring value does not match our stat column
3534 if ( !$dbr->fieldExists( 'user_stats', $column ) ) {
3635 $wgOut->setPageTitle( wfMsg( 'top-fans-bad-field-title' ) );
@@ -37,8 +36,10 @@
3837 return false;
3938 }
4039
 40+ // Fix i18n message key
 41+ $fixedStatistic = str_replace( '_', '-', $statistic );
4142 // Set page title
42 - $wgOut->setPageTitle( wfMsg( 'top-fans-by-category-title', $stat_name_friendly ) );
 43+ $wgOut->setPageTitle( wfMsg( 'top-fans-by-category-title-' . $fixedStatistic ) );
4344
4445 $count = 50;
4546
@@ -58,7 +59,8 @@
5960 $params['LIMIT'] = $count;
6061
6162 $dbr = wfGetDB( DB_SLAVE );
62 - $res = $dbr->select( 'user_stats',
 63+ $res = $dbr->select(
 64+ 'user_stats',
6365 array( 'stats_user_id', 'stats_user_name', $column ),
6466 array( 'stats_user_id <> 0', "{$column} > 0" ),
6567 __METHOD__,
@@ -112,7 +114,11 @@
113115 $out .= '<div class="top-users">';
114116
115117 foreach ( $user_list as $user ) {
116 - $user_name = ( $user['user_name'] == substr( $user['user_name'] , 0, 22 ) ) ? $user['user_name'] : ( substr( $user['user_name'] , 0, 22 ) . '...' );
 118+ if ( $user['user_name'] == substr( $user['user_name'], 0, 22 ) ) {
 119+ $user_name = $user['user_name'];
 120+ } else {
 121+ $user_name = substr( $user['user_name'], 0, 22 ) . wfMsg( 'ellipsis' );
 122+ }
117123 $user_title = Title::makeTitle( NS_USER, $user['user_name'] );
118124 $avatar = new wAvatar( $user['user_id'], 'm' );
119125 $commentIcon = $avatar->getAvatarImage();
@@ -123,8 +129,9 @@
124130 $statistics_row = number_format( $row->opinion_average, 2 );
125131 $lowercase_statistics_name = 'percent';
126132 } else {
 133+ global $wgLang;
127134 $statistics_row = number_format( $user['stat'] );
128 - $lowercase_statistics_name = strtolower( wfMsgExt( "top-fans-stats-{$statistic}", 'parsemag', $user['stat'] ) );
 135+ $lowercase_statistics_name = $wgLang->lc( wfMsgExt( "top-fans-stats-{$fixedStatistic}", 'parsemag', $user['stat'] ) );
129136 }
130137
131138 $out .= '<div class="top-fan-row">

Status & tagging log