Index: trunk/extensions/SocialProfile/UserStats/TopFansRecent.php |
— | — | @@ -15,8 +15,7 @@ |
16 | 16 | * @param $par Mixed: parameter passed to the page or null |
17 | 17 | */ |
18 | 18 | public function execute( $par ) { |
19 | | - global $wgRequest, $wgUser, $wgOut, $wgMemc, $wgUserStatsTrackWeekly, $wgUserStatsTrackMonthly, |
20 | | - $wgUserLevels, $wgUploadPath, $wgScriptPath; |
| 19 | + global $wgRequest, $wgUser, $wgOut, $wgMemc, $wgUploadPath, $wgScriptPath; |
21 | 20 | |
22 | 21 | // Load CSS |
23 | 22 | $wgOut->addExtensionStyle( $wgScriptPath . '/extensions/SocialProfile/UserStats/TopList.css' ); |
— | — | @@ -78,35 +77,41 @@ |
79 | 78 | |
80 | 79 | $out = '<div class="top-fan-nav"> |
81 | 80 | <h1>' . wfMsg( 'top-fans-by-points-nav-header' ) . '</h1> |
82 | | - <p><a href="' . $top_title->escapeFullURL() . '">' . wfMsg( 'top-fans-total-points-link' ) . '</a></p>'; |
| 81 | + <p><a href="' . $top_title->escapeFullURL() . '">' . |
| 82 | + wfMsg( 'top-fans-total-points-link' ) . '</a></p>'; |
83 | 83 | |
84 | 84 | if ( $period == 'weekly' ) { |
85 | | - $out .= '<p><a href="' . $recent_title->escapeFullURL( 'period=monthly' ) . '">' . wfMsg( 'top-fans-monthly-points-link' ) . '</a><p> |
| 85 | + $out .= '<p><a href="' . $recent_title->escapeFullURL( 'period=monthly' ) . '">' . |
| 86 | + wfMsg( 'top-fans-monthly-points-link' ) . '</a><p> |
86 | 87 | <p><b>' . wfMsg( 'top-fans-weekly-points-link' ) . '</b></p>'; |
87 | 88 | } else { |
88 | 89 | $out .= '<p><b>' . wfMsg( 'top-fans-monthly-points-link' ) . '</b><p> |
89 | | - <p><a href="' . $recent_title->escapeFullURL( 'period=weekly' ) . '">' . wfMsg( 'top-fans-weekly-points-link' ) . '</a></p>'; |
| 90 | + <p><a href="' . $recent_title->escapeFullURL( 'period=weekly' ) . '">' . |
| 91 | + wfMsg( 'top-fans-weekly-points-link' ) . '</a></p>'; |
90 | 92 | } |
91 | 93 | |
92 | 94 | // Build nav of stats by category based on MediaWiki:Topfans-by-category |
93 | 95 | $by_category_title = SpecialPage::getTitleFor( 'TopFansByStatistic' ); |
94 | | - $nav = array(); |
| 96 | + $message = wfMsgForContent( 'topfans-by-category' ); |
95 | 97 | |
96 | | - $lines = explode( "\n", wfMsgForContent( 'topfans-by-category' ) ); |
97 | | - if ( count( $lines ) > 0 ) { |
98 | | - $out .= '<h1 style="margin-top:15px !important;">' . wfMsg( 'top-fans-by-category-nav-header' ) . '</h1>'; |
99 | | - } |
| 98 | + if ( !wfEmptyMsg( 'topfans-by-category', $message ) ) { |
| 99 | + $out .= '<h1 style="margin-top:15px !important;">' . |
| 100 | + wfMsg( 'top-fans-by-category-nav-header' ) . '</h1>'; |
100 | 101 | |
101 | | - foreach ( $lines as $line ) { |
102 | | - if ( strpos( $line, '*' ) !== 0 ) { |
103 | | - continue; |
104 | | - } else { |
105 | | - $line = explode( '|', trim( $line, '* ' ), 2 ); |
106 | | - $stat = $line[0]; |
107 | | - $link_text = $line[1]; |
108 | | - $out .= '<p><a href="' . $by_category_title->escapeFullURL( "stat={$stat}" ) . '">' . $link_text . '</a></p>'; |
| 102 | + $lines = explode( "\n", $message ); |
| 103 | + foreach ( $lines as $line ) { |
| 104 | + if ( strpos( $line, '*' ) !== 0 ) { |
| 105 | + continue; |
| 106 | + } else { |
| 107 | + $line = explode( '|', trim( $line, '* ' ), 2 ); |
| 108 | + $stat = $line[0]; |
| 109 | + $link_text = $line[1]; |
| 110 | + $statURL = $by_category_title->escapeFullURL( "stat={$stat}" ); |
| 111 | + $out .= '<p><a href="' . $statURL . '">' . $link_text . '</a></p>'; |
| 112 | + } |
109 | 113 | } |
110 | 114 | } |
| 115 | + |
111 | 116 | $out .= '</div>'; |
112 | 117 | |
113 | 118 | $x = 1; |
— | — | @@ -115,20 +120,23 @@ |
116 | 121 | foreach ( $user_list as $user ) { |
117 | 122 | $user_title = Title::makeTitle( NS_USER, $user['user_name'] ); |
118 | 123 | $avatar = new wAvatar( $user['user_id'], 'm' ); |
119 | | - $commentIcon = $avatar->getAvatarImage(); |
| 124 | + $avatarImage = $avatar->getAvatarImage(); |
120 | 125 | |
121 | 126 | $out .= '<div class="top-fan-row"> |
122 | 127 | <span class="top-fan-num">' . $x . '.</span> |
123 | 128 | <span class="top-fan"> |
124 | | - <img src="' . $wgUploadPath . '/avatars/' . $commentIcon . '" alt="" border="" /> |
| 129 | + <img src="' . $wgUploadPath . '/avatars/' . $avatarImage . '" alt="" border="" /> |
125 | 130 | <a href="' . $user_title->escapeFullURL() . '" >' . $user['user_name'] . '</a> |
126 | 131 | </span>'; |
127 | 132 | |
128 | | - $out .= '<span class="top-fan-points"><b>' . number_format( $user['points'] ) . '</b> ' . wfMsg( 'top-fans-points' ) . '</span>'; |
| 133 | + $out .= '<span class="top-fan-points"><b>' . |
| 134 | + number_format( $user['points'] ) . '</b> ' . |
| 135 | + wfMsg( 'top-fans-points' ) . '</span>'; |
129 | 136 | $out .= '<div class="cleared"></div>'; |
130 | 137 | $out .= '</div>'; |
131 | 138 | $x++; |
132 | 139 | } |
| 140 | + |
133 | 141 | $out .= '</div><div class="cleared"></div>'; |
134 | 142 | $wgOut->addHTML( $out ); |
135 | 143 | } |
Index: trunk/extensions/SocialProfile/UserStats/TopFansByStat.php |
— | — | @@ -15,8 +15,8 @@ |
16 | 16 | * @param $par Mixed: parameter passed to the page or null |
17 | 17 | */ |
18 | 18 | public function execute( $par ) { |
19 | | - global $wgRequest, $wgUser, $wgOut, $wgMemc, $wgUserStatsTrackWeekly, $wgUserStatsTrackMonthly, |
20 | | - $wgUserLevels, $wgUploadPath, $wgScriptPath; |
| 19 | + global $wgRequest, $wgUser, $wgOut, $wgMemc, $wgUploadPath, $wgScriptPath; |
| 20 | + global $wgUserStatsTrackWeekly, $wgUserStatsTrackMonthly; |
21 | 21 | |
22 | 22 | // Load CSS |
23 | 23 | $wgOut->addExtensionStyle( $wgScriptPath . '/extensions/SocialProfile/UserStats/TopList.css' ); |
— | — | @@ -26,7 +26,7 @@ |
27 | 27 | $statistic = $dbr->strencode( trim( $wgRequest->getVal( 'stat' ) ) ); |
28 | 28 | $column = "stats_{$statistic}"; |
29 | 29 | |
30 | | - // Error if the querystring value does not match our stat column |
| 30 | + // Error if the query string value does not match our stat column |
31 | 31 | if ( !$dbr->fieldExists( 'user_stats', $column ) ) { |
32 | 32 | $wgOut->setPageTitle( wfMsg( 'top-fans-bad-field-title' ) ); |
33 | 33 | $wgOut->addHTML( wfMsg( 'top-fans-bad-field-message' ) ); |
— | — | @@ -35,6 +35,7 @@ |
36 | 36 | |
37 | 37 | // Fix i18n message key |
38 | 38 | $fixedStatistic = str_replace( '_', '-', $statistic ); |
| 39 | + |
39 | 40 | // Set page title |
40 | 41 | $wgOut->setPageTitle( wfMsg( 'top-fans-by-category-title-' . $fixedStatistic ) ); |
41 | 42 | |
— | — | @@ -79,34 +80,40 @@ |
80 | 81 | |
81 | 82 | $out = '<div class="top-fan-nav"> |
82 | 83 | <h1>' . wfMsg( 'top-fans-by-points-nav-header' ) . '</h1> |
83 | | - <p><a href="' . $top_title->escapeFullURL() . '">' . wfMsg( 'top-fans-total-points-link' ) . '</a></p>'; |
| 84 | + <p><a href="' . $top_title->escapeFullURL() . '">' . |
| 85 | + wfMsg( 'top-fans-total-points-link' ) . '</a></p>'; |
84 | 86 | |
85 | 87 | if ( $wgUserStatsTrackWeekly ) { |
86 | | - $out .= '<p><a href="' . $recent_title->escapeFullURL( 'period=monthly' ) . '">' . wfMsg( 'top-fans-monthly-points-link' ) . '</a><p>'; |
| 88 | + $out .= '<p><a href="' . $recent_title->escapeFullURL( 'period=monthly' ) . '">' . |
| 89 | + wfMsg( 'top-fans-monthly-points-link' ) . '</a><p>'; |
87 | 90 | } |
88 | 91 | if ( $wgUserStatsTrackMonthly ) { |
89 | | - $out .= '<p><a href="' . $recent_title->escapeFullURL( 'period=weekly' ) . '">' . wfMsg( 'top-fans-weekly-points-link' ) . '</a></p>'; |
| 92 | + $out .= '<p><a href="' . $recent_title->escapeFullURL( 'period=weekly' ) . '">' . |
| 93 | + wfMsg( 'top-fans-weekly-points-link' ) . '</a></p>'; |
90 | 94 | } |
91 | 95 | |
92 | 96 | // Build nav of stats by category based on MediaWiki:Topfans-by-category |
93 | | - $out .= '<h1 style="margin-top:15px !important;">' . wfMsg( 'top-fans-by-category-nav-header' ) . '</h1>'; |
| 97 | + $message = wfMsgForContent( 'topfans-by-category' ); |
94 | 98 | |
95 | | - $by_category_title = SpecialPage::getTitleFor( 'TopFansByStatistic' ); |
96 | | - $nav = array(); |
| 99 | + if ( !wfEmptyMsg( 'topfans-by-category', $message ) ) { |
| 100 | + $out .= '<h1 style="margin-top:15px !important;">' . |
| 101 | + wfMsg( 'top-fans-by-category-nav-header' ) . '</h1>'; |
97 | 102 | |
98 | | - $lines = explode( "\n", wfMsgForContent( 'topfans-by-category' ) ); |
99 | | - foreach ( $lines as $line ) { |
100 | | - if ( strpos( $line, '*' ) !== 0 ) { |
101 | | - continue; |
102 | | - } else { |
103 | | - $line = explode( '|', trim( $line, '* ' ), 2 ); |
104 | | - $stat = $line[0]; |
105 | | - $link_text = $line[1]; |
106 | | - $out .= '<p><a href="' . $by_category_title->escapeFullURL( "stat={$stat}" ) . '">' . $link_text . '</a></p>'; |
| 103 | + $lines = explode( "\n", $message ); |
| 104 | + foreach ( $lines as $line ) { |
| 105 | + if ( strpos( $line, '*' ) !== 0 ) { |
| 106 | + continue; |
| 107 | + } else { |
| 108 | + $line = explode( '|', trim( $line, '* ' ), 2 ); |
| 109 | + $stat = $line[0]; |
| 110 | + $link_text = $line[1]; |
| 111 | + $statURL = $this->getTitle()->escapeFullURL( "stat={$stat}" ); |
| 112 | + $out .= '<p><a href="' . $statURL . '">' . $link_text . '</a></p>'; |
| 113 | + } |
107 | 114 | } |
108 | 115 | } |
| 116 | + |
109 | 117 | $out .= '</div>'; |
110 | | - |
111 | 118 | $x = 1; |
112 | 119 | $out .= '<div class="top-users">'; |
113 | 120 | |
— | — | @@ -128,7 +135,11 @@ |
129 | 136 | } else { |
130 | 137 | global $wgLang; |
131 | 138 | $statistics_row = number_format( $user['stat'] ); |
132 | | - $lowercase_statistics_name = $wgLang->lc( wfMsgExt( "top-fans-stats-{$fixedStatistic}", 'parsemag', $user['stat'] ) ); |
| 139 | + $lowercase_statistics_name = $wgLang->lc( wfMsgExt( |
| 140 | + "top-fans-stats-{$fixedStatistic}", |
| 141 | + 'parsemag', |
| 142 | + $user['stat'] |
| 143 | + ) ); |
133 | 144 | } |
134 | 145 | |
135 | 146 | $out .= '<div class="top-fan-row"> |
— | — | @@ -142,6 +153,7 @@ |
143 | 154 | </div>'; |
144 | 155 | $x++; |
145 | 156 | } |
| 157 | + |
146 | 158 | $out .= '</div><div class="cleared"></div>'; |
147 | 159 | $wgOut->addHTML( $out ); |
148 | 160 | } |
Index: trunk/extensions/SocialProfile/UserStats/TopUsers.php |
— | — | @@ -71,36 +71,35 @@ |
72 | 72 | <p><b>' . wfMsg( 'top-fans-total-points-link' ) . '</b></p>'; |
73 | 73 | |
74 | 74 | if ( $wgUserStatsTrackWeekly ) { |
75 | | - $out .= '<p><a href="' . $recent_title->escapeFullURL( 'period=monthly' ) . '">' . wfMsg( 'top-fans-monthly-points-link' ) . '</a></p>'; |
| 75 | + $out .= '<p><a href="' . $recent_title->escapeFullURL( 'period=monthly' ) . '">' . |
| 76 | + wfMsg( 'top-fans-monthly-points-link' ) . '</a></p>'; |
76 | 77 | } |
77 | 78 | |
78 | 79 | if ( $wgUserStatsTrackMonthly ) { |
79 | | - $out .= '<p><a href="' . $recent_title->escapeFullURL( 'period=weekly' ) . '">' . wfMsg( 'top-fans-weekly-points-link' ) . '</a></p>'; |
| 80 | + $out .= '<p><a href="' . $recent_title->escapeFullURL( 'period=weekly' ) . '">' . |
| 81 | + wfMsg( 'top-fans-weekly-points-link' ) . '</a></p>'; |
80 | 82 | } |
81 | 83 | |
82 | 84 | // Build nav of stats by category based on MediaWiki:Topfans-by-category |
83 | 85 | $by_category_title = SpecialPage::getTitleFor( 'TopFansByStatistic' ); |
84 | 86 | |
85 | 87 | $byCategoryMessage = wfMsgForContent( 'topfans-by-category' ); |
86 | | - $lines = explode( "\n", $byCategoryMessage ); |
87 | 88 | |
88 | | - if ( |
89 | | - count( $lines ) > 0 && |
90 | | - !wfEmptyMsg( 'topfans-by-category', $byCategoryMessage ) |
91 | | - ) |
92 | | - { |
| 89 | + if ( !wfEmptyMsg( 'topfans-by-category', $byCategoryMessage ) ) { |
93 | 90 | $out .= '<h1 style="margin-top:15px !important;">' . |
94 | 91 | wfMsg( 'top-fans-by-category-nav-header' ) . '</h1>'; |
95 | | - } |
96 | 92 | |
97 | | - foreach ( $lines as $line ) { |
98 | | - if ( strpos( $line, '*' ) !== 0 ) { |
99 | | - continue; |
100 | | - } else { |
101 | | - $line = explode( '|' , trim( $line, '* ' ), 2 ); |
102 | | - $stat = $line[0]; |
103 | | - $link_text = $line[1]; |
104 | | - $out .= '<p> <a href="' . $by_category_title->escapeFullURL( "stat={$stat}" ) . "\">{$link_text}</a></p>"; |
| 93 | + $lines = explode( "\n", $byCategoryMessage ); |
| 94 | + foreach ( $lines as $line ) { |
| 95 | + if ( strpos( $line, '*' ) !== 0 ) { |
| 96 | + continue; |
| 97 | + } else { |
| 98 | + $line = explode( '|' , trim( $line, '* ' ), 2 ); |
| 99 | + $stat = $line[0]; |
| 100 | + $link_text = $line[1]; |
| 101 | + $statURL = $by_category_title->escapeFullURL( "stat={$stat}" ); |
| 102 | + $out .= '<p> <a href="' . $statURL . "\">{$link_text}</a></p>"; |
| 103 | + } |
105 | 104 | } |
106 | 105 | } |
107 | 106 | |