http://www.mediawiki.org/wiki/Special:Code/MediaWiki/61248

Revision: 61248
Author:   ashley
Date:     2010-01-19 14:05:19 +0000 (Tue, 19 Jan 2010)

Log Message:
-----------
SocialProfile: fixes to UserStats

Modified Paths:
--------------
    trunk/extensions/SocialProfile/UserStats/TopFansByStat.php
    trunk/extensions/SocialProfile/UserStats/TopFansRecent.php
    trunk/extensions/SocialProfile/UserStats/UserStats.i18n.php

Modified: trunk/extensions/SocialProfile/UserStats/TopFansByStat.php
===================================================================
--- trunk/extensions/SocialProfile/UserStats/TopFansByStat.php  2010-01-19 
13:53:34 UTC (rev 61247)
+++ trunk/extensions/SocialProfile/UserStats/TopFansByStat.php  2010-01-19 
14:05:19 UTC (rev 61248)
@@ -24,12 +24,11 @@
                // Load CSS
                $wgOut->addExtensionStyle( $wgScriptPath . 
'/extensions/SocialProfile/UserStats/TopList.css' );
 
-               $statistic = $wgRequest->getVal( 'stat' );
+               $dbr = wfGetDB( DB_SLAVE );
+
+               $statistic = $dbr->strencode( trim( $wgRequest->getVal( 'stat' 
) ) );
                $column = "stats_{$statistic}";
-               $stat_name_friendly = wfMsg( "top-fans-stats-{$statistic}" );
 
-               $dbr = wfGetDB( DB_SLAVE );
-
                // Error if the querystring value does not match our stat column
                if ( !$dbr->fieldExists( 'user_stats', $column ) ) {
                        $wgOut->setPageTitle( wfMsg( 'top-fans-bad-field-title' 
) );
@@ -37,8 +36,10 @@
                        return false;
                }
 
+               // Fix i18n message key
+               $fixedStatistic = str_replace( '_', '-', $statistic );
                // Set page title
-               $wgOut->setPageTitle( wfMsg( 'top-fans-by-category-title', 
$stat_name_friendly ) );
+               $wgOut->setPageTitle( wfMsg( 'top-fans-by-category-title-' . 
$fixedStatistic ) );
 
                $count = 50;
 
@@ -58,7 +59,8 @@
                        $params['LIMIT'] = $count;
 
                        $dbr = wfGetDB( DB_SLAVE );
-                       $res = $dbr->select( 'user_stats',
+                       $res = $dbr->select(
+                               'user_stats',
                                array( 'stats_user_id', 'stats_user_name', 
$column ),
                                array( 'stats_user_id <> 0', "{$column} > 0" ),
                                __METHOD__,
@@ -112,7 +114,11 @@
                $out .= '<div class="top-users">';
 
                foreach ( $user_list as $user ) {
-                       $user_name = ( $user['user_name'] == substr( 
$user['user_name'] , 0, 22 ) ) ? $user['user_name'] : ( substr( 
$user['user_name'] , 0, 22 ) . '...' );
+                       if ( $user['user_name'] == substr( $user['user_name'], 
0, 22 ) ) {
+                               $user_name = $user['user_name'];
+                       } else {
+                               $user_name = substr( $user['user_name'], 0, 22 
) . wfMsg( 'ellipsis' );
+                       }
                        $user_title = Title::makeTitle( NS_USER, 
$user['user_name'] );
                        $avatar = new wAvatar( $user['user_id'], 'm' );
                        $commentIcon = $avatar->getAvatarImage();
@@ -123,8 +129,9 @@
                                $statistics_row = number_format( 
$row->opinion_average, 2 );
                                $lowercase_statistics_name = 'percent';
                        } else {
+                               global $wgLang;
                                $statistics_row = number_format( $user['stat'] 
);
-                               $lowercase_statistics_name = strtolower( 
wfMsgExt( "top-fans-stats-{$statistic}", 'parsemag', $user['stat'] ) );
+                               $lowercase_statistics_name = $wgLang->lc( 
wfMsgExt( "top-fans-stats-{$fixedStatistic}", 'parsemag', $user['stat'] ) );
                        }
 
                        $out .= '<div class="top-fan-row">

Modified: trunk/extensions/SocialProfile/UserStats/TopFansRecent.php
===================================================================
--- trunk/extensions/SocialProfile/UserStats/TopFansRecent.php  2010-01-19 
13:53:34 UTC (rev 61247)
+++ trunk/extensions/SocialProfile/UserStats/TopFansRecent.php  2010-01-19 
14:05:19 UTC (rev 61248)
@@ -23,8 +23,14 @@
 
                // Load CSS
                $wgOut->addExtensionStyle( $wgScriptPath . 
'/extensions/SocialProfile/UserStats/TopList.css' );
-               $period = $wgRequest->getVal( 'period' );
 
+               $periodFromRequest = $wgRequest->getVal( 'period' );
+               if ( $periodFromRequest == 'weekly' ) {
+                       $period = 'weekly';
+               } elseif ( $periodFromRequest == 'monthly' ) {
+                       $period = 'monthly';
+               }
+
                if ( !$period ) {
                        $period = 'weekly';
                }
@@ -52,7 +58,8 @@
                        $params['LIMIT'] = $count;
 
                        $dbr = wfGetDB( DB_SLAVE );
-                       $res = $dbr->select( "user_points_{$period}",
+                       $res = $dbr->select(
+                               "user_points_{$period}",
                                array( 'up_user_id', 'up_user_name', 
'up_points' ),
                                array( 'up_user_id <> 0' ),
                                __METHOD__,
@@ -92,8 +99,8 @@
                if ( count( $lines ) > 0 ) {
                        $out .= '<h1 style="margin-top:15px !important;">' . 
wfMsg( 'top-fans-by-category-nav-header' ) . '</h1>';
                }
+
                foreach ( $lines as $line ) {
-
                        if ( strpos( $line, '*' ) !== 0 ) {
                                continue;
                        } else {

Modified: trunk/extensions/SocialProfile/UserStats/UserStats.i18n.php
===================================================================
--- trunk/extensions/SocialProfile/UserStats/UserStats.i18n.php 2010-01-19 
13:53:34 UTC (rev 61247)
+++ trunk/extensions/SocialProfile/UserStats/UserStats.i18n.php 2010-01-19 
14:05:19 UTC (rev 61248)
@@ -23,7 +23,20 @@
        'top-fans-weekly-points-link' => 'Points this week',
        'top-fans-monthly-points-link' => 'Points this month',
        'top-fans-points' => 'points',
-       'top-fans-by-category-title' => 'Top overall $1',
+       'top-fans-by-category-title-edit-count' => 'Top overall edits',
+       'top-fans-by-category-title-friends-count' => 'Top overall friends',
+       'top-fans-by-category-title-foe-count' => 'Top overall foes',
+       'top-fans-by-category-title-gifts-rec-count' => 'Top overall gifs 
received',
+       'top-fans-by-category-title-gifts-sent-count' => 'Top overall gifts 
sent',
+       'top-fans-by-category-title-vote-count' => 'Top overall votes',
+       'top-fans-by-category-title-comment-count' => 'Top overall comments',
+       'top-fans-by-category-title-referrals-count' => 'Top overall referrals',
+       'top-fans-by-category-title-comment-score-positive-rec' => 'Top overall 
thumbs up',
+       'top-fans-by-category-title-comment-score-negative-rec' => 'Top overall 
thumbs down',
+       'top-fans-by-category-title-comment-score-positive-given' => 'Top 
overall thumbs up given',
+       'top-fans-by-category-title-comment-score-negative-given' => 'Top 
overall thumbs down given',
+       'top-fans-by-category-title-monthly-winner-count' => 'Top overall 
monthly wins',
+       'top-fans-by-category-title-weekly-winner-count' => 'Top overall weekly 
wins',
        'top-fans-bad-field-title' => 'Oops!',
        'top-fans-bad-field-message' => 'The specified stat does not exist.',
        'top-fans-stats-vote-count' => '{{PLURAL:$1|Vote|Votes}}',
@@ -759,17 +772,31 @@
        'top-fans-points' => 'pistettä',
        'top-fans-bad-field-title' => 'Ups!',
        'top-fans-bad-field-message' => 'Määritettyä tilastotietoa ei ole 
olemassa.',
-       'top-fans-stats-vote-count' => '{{PLURAL:$1|Ääni|Ääniä}}',
+       'top-fans-by-category-title-edit-count' => 'Eniten muokkauksia',
+       'top-fans-by-category-title-friends-count' => 'Eniten ystäviä',
+       'top-fans-by-category-title-foe-count' => 'Eniten vihollisia',
+       'top-fans-by-category-title-gifts-rec-count' => 'Eniten saatuja 
lahjoja',
+       'top-fans-by-category-title-gifts-sent-count' => 'Eniten lähetettyjä 
lahjoja',
+       'top-fans-by-category-title-vote-count' => 'Eniten ääniä',
+       'top-fans-by-category-title-comment-count' => 'Eniten kommentteja',
+       'top-fans-by-category-title-referrals-count' => 'Eniten lähetettyjä 
käyttäjiä',
+       'top-fans-by-category-title-comment-score-positive-rec' => 'Eniten 
peukaloita ylös',
+       'top-fans-by-category-title-comment-score-negative-rec' => 'Eniten 
peukaloita alas',
+       'top-fans-by-category-title-comment-score-positive-given' => 'Eniten 
annettuja peukaloita ylös',
+       'top-fans-by-category-title-comment-score-negative-given' => 'Eniten 
annettuja peukaloita alas',
+       'top-fans-by-category-title-monthly-winner-count' => 'Eniten 
kuukausittaisia voittoja',
+       'top-fans-by-category-title-weekly-winner-count' => 'Eniten 
viikottaisia voittoja',
+       'top-fans-stats-vote-count' => '{{PLURAL:$1|ääni|ääniä}}',
        'top-fans-stats-monthly-winner-count' => '{{PLURAL:$1|kuukausittainen 
voitto|kuukausittaista voittoa}}',
        'top-fans-stats-weekly-winner-count' => '{{PLURAL:$1|viikottainen 
voitto|viikottaista voittoa}}',
        'top-fans-stats-edit-count' => '{{PLURAL:$1|muokkaus|muokkausta}}',
        'top-fans-stats-comment-count' => '{{PLURAL:$1|kommentti|kommenttia}}',
        'top-fans-stats-friends-count' => '{{PLURAL:$1|ystävä|ystävää}}',
        'top-fans-stats-foe-count' => '{{PLURAL:$1|vihollinen|vihollista}}',
-       'top-fans-stats-opinions-published' => '{{PLURAL:$1|Julkaistu 
mielipide|Julkaistut mielipiteet}}',
-       'top-fans-stats-opinions-created' => 
'{{PLURAL:$1|Mielipide|Mielipiteet}}',
-       'top-fans-stats-comment-score-positive-rec' => '{{PLURAL:$1|Peukalo 
ylös|Peukalot ylös}}',
-       'top-fans-stats-comment-score-negative-rec' => '{{PLURAL:$1|Peukalo 
alas|Peukalot alas}}',
+       'top-fans-stats-opinions-published' => '{{PLURAL:$1|julkaistu 
mielipide|julkaistua mielipidettä}}',
+       'top-fans-stats-opinions-created' => 
'{{PLURAL:$1|mielipide|mielipidettä}}',
+       'top-fans-stats-comment-score-positive-rec' => '{{PLURAL:$1|peukalo 
ylös|peukaloa ylös}}',
+       'top-fans-stats-comment-score-negative-rec' => '{{PLURAL:$1|peukalo 
alas|peukaloa alas}}',
        'top-fans-stats-gifts-rec-count' => '{{PLURAL:$1|saatu lahja|saatua 
lahjaa}}',
        'top-fans-stats-gifts-sent-count' => '{{PLURAL:$1|lähetetty 
lahja|lähetettyä lahjaa}}',
        'right-updatepoints' => 'Päivittää muokkausmääriä',



_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to