Index: trunk/extensions/SocialProfile/UserStats/TopFansRecent.php |
— | — | @@ -23,8 +23,14 @@ |
24 | 24 | |
25 | 25 | // Load CSS |
26 | 26 | $wgOut->addExtensionStyle( $wgScriptPath . '/extensions/SocialProfile/UserStats/TopList.css' ); |
27 | | - $period = $wgRequest->getVal( 'period' ); |
28 | 27 | |
| 28 | + $periodFromRequest = $wgRequest->getVal( 'period' ); |
| 29 | + if ( $periodFromRequest == 'weekly' ) { |
| 30 | + $period = 'weekly'; |
| 31 | + } elseif ( $periodFromRequest == 'monthly' ) { |
| 32 | + $period = 'monthly'; |
| 33 | + } |
| 34 | + |
29 | 35 | if ( !$period ) { |
30 | 36 | $period = 'weekly'; |
31 | 37 | } |
— | — | @@ -52,7 +58,8 @@ |
53 | 59 | $params['LIMIT'] = $count; |
54 | 60 | |
55 | 61 | $dbr = wfGetDB( DB_SLAVE ); |
56 | | - $res = $dbr->select( "user_points_{$period}", |
| 62 | + $res = $dbr->select( |
| 63 | + "user_points_{$period}", |
57 | 64 | array( 'up_user_id', 'up_user_name', 'up_points' ), |
58 | 65 | array( 'up_user_id <> 0' ), |
59 | 66 | __METHOD__, |
— | — | @@ -92,8 +99,8 @@ |
93 | 100 | if ( count( $lines ) > 0 ) { |
94 | 101 | $out .= '<h1 style="margin-top:15px !important;">' . wfMsg( 'top-fans-by-category-nav-header' ) . '</h1>'; |
95 | 102 | } |
| 103 | + |
96 | 104 | foreach ( $lines as $line ) { |
97 | | - |
98 | 105 | if ( strpos( $line, '*' ) !== 0 ) { |
99 | 106 | continue; |
100 | 107 | } else { |
Index: trunk/extensions/SocialProfile/UserStats/UserStats.i18n.php |
— | — | @@ -23,7 +23,20 @@ |
24 | 24 | 'top-fans-weekly-points-link' => 'Points this week', |
25 | 25 | 'top-fans-monthly-points-link' => 'Points this month', |
26 | 26 | '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', |
28 | 41 | 'top-fans-bad-field-title' => 'Oops!', |
29 | 42 | 'top-fans-bad-field-message' => 'The specified stat does not exist.', |
30 | 43 | 'top-fans-stats-vote-count' => '{{PLURAL:$1|Vote|Votes}}', |
— | — | @@ -759,17 +772,31 @@ |
760 | 773 | 'top-fans-points' => 'pistettä', |
761 | 774 | 'top-fans-bad-field-title' => 'Ups!', |
762 | 775 | '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ä}}', |
764 | 791 | 'top-fans-stats-monthly-winner-count' => '{{PLURAL:$1|kuukausittainen voitto|kuukausittaista voittoa}}', |
765 | 792 | 'top-fans-stats-weekly-winner-count' => '{{PLURAL:$1|viikottainen voitto|viikottaista voittoa}}', |
766 | 793 | 'top-fans-stats-edit-count' => '{{PLURAL:$1|muokkaus|muokkausta}}', |
767 | 794 | 'top-fans-stats-comment-count' => '{{PLURAL:$1|kommentti|kommenttia}}', |
768 | 795 | 'top-fans-stats-friends-count' => '{{PLURAL:$1|ystävä|ystävää}}', |
769 | 796 | '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}}', |
774 | 801 | 'top-fans-stats-gifts-rec-count' => '{{PLURAL:$1|saatu lahja|saatua lahjaa}}', |
775 | 802 | 'top-fans-stats-gifts-sent-count' => '{{PLURAL:$1|lähetetty lahja|lähetettyä lahjaa}}', |
776 | 803 | 'right-updatepoints' => 'Päivittää muokkausmääriä', |
Index: trunk/extensions/SocialProfile/UserStats/TopFansByStat.php |
— | — | @@ -24,12 +24,11 @@ |
25 | 25 | // Load CSS |
26 | 26 | $wgOut->addExtensionStyle( $wgScriptPath . '/extensions/SocialProfile/UserStats/TopList.css' ); |
27 | 27 | |
28 | | - $statistic = $wgRequest->getVal( 'stat' ); |
| 28 | + $dbr = wfGetDB( DB_SLAVE ); |
| 29 | + |
| 30 | + $statistic = $dbr->strencode( trim( $wgRequest->getVal( 'stat' ) ) ); |
29 | 31 | $column = "stats_{$statistic}"; |
30 | | - $stat_name_friendly = wfMsg( "top-fans-stats-{$statistic}" ); |
31 | 32 | |
32 | | - $dbr = wfGetDB( DB_SLAVE ); |
33 | | - |
34 | 33 | // Error if the querystring value does not match our stat column |
35 | 34 | if ( !$dbr->fieldExists( 'user_stats', $column ) ) { |
36 | 35 | $wgOut->setPageTitle( wfMsg( 'top-fans-bad-field-title' ) ); |
— | — | @@ -37,8 +36,10 @@ |
38 | 37 | return false; |
39 | 38 | } |
40 | 39 | |
| 40 | + // Fix i18n message key |
| 41 | + $fixedStatistic = str_replace( '_', '-', $statistic ); |
41 | 42 | // 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 ) ); |
43 | 44 | |
44 | 45 | $count = 50; |
45 | 46 | |
— | — | @@ -58,7 +59,8 @@ |
59 | 60 | $params['LIMIT'] = $count; |
60 | 61 | |
61 | 62 | $dbr = wfGetDB( DB_SLAVE ); |
62 | | - $res = $dbr->select( 'user_stats', |
| 63 | + $res = $dbr->select( |
| 64 | + 'user_stats', |
63 | 65 | array( 'stats_user_id', 'stats_user_name', $column ), |
64 | 66 | array( 'stats_user_id <> 0', "{$column} > 0" ), |
65 | 67 | __METHOD__, |
— | — | @@ -112,7 +114,11 @@ |
113 | 115 | $out .= '<div class="top-users">'; |
114 | 116 | |
115 | 117 | 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 | + } |
117 | 123 | $user_title = Title::makeTitle( NS_USER, $user['user_name'] ); |
118 | 124 | $avatar = new wAvatar( $user['user_id'], 'm' ); |
119 | 125 | $commentIcon = $avatar->getAvatarImage(); |
— | — | @@ -123,8 +129,9 @@ |
124 | 130 | $statistics_row = number_format( $row->opinion_average, 2 ); |
125 | 131 | $lowercase_statistics_name = 'percent'; |
126 | 132 | } else { |
| 133 | + global $wgLang; |
127 | 134 | $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'] ) ); |
129 | 136 | } |
130 | 137 | |
131 | 138 | $out .= '<div class="top-fan-row"> |