Index: trunk/extensions/SocialProfile/UserStats/TopFansRecent.php |
— | — | @@ -6,7 +6,7 @@ |
7 | 7 | * Constructor |
8 | 8 | */ |
9 | 9 | public function __construct(){ |
10 | | - parent::__construct('TopUsersRecent'); |
| 10 | + parent::__construct( 'TopUsersRecent' ); |
11 | 11 | } |
12 | 12 | |
13 | 13 | /** |
— | — | @@ -19,18 +19,18 @@ |
20 | 20 | $wgUserLevels, $wgUploadPath, $wgScriptPath; |
21 | 21 | |
22 | 22 | // Read in localisation messages |
23 | | - wfLoadExtensionMessages('SocialProfileUserStats'); |
| 23 | + wfLoadExtensionMessages( 'SocialProfileUserStats' ); |
24 | 24 | |
25 | 25 | // Load CSS |
26 | | - $wgOut->addStyle( '../..' . $wgScriptPath . '/extensions/SocialProfile/UserStats/TopList.css' ); |
| 26 | + $wgOut->addExtensionStyle( $wgScriptPath . '/extensions/SocialProfile/UserStats/TopList.css' ); |
27 | 27 | $period = $wgRequest->getVal( 'period' ); |
28 | 28 | |
29 | 29 | if( !$period ) $period = 'weekly'; |
30 | 30 | |
31 | 31 | if( $period == 'weekly' ){ |
32 | | - $wgOut->setPagetitle( wfMsg('user-stats-weekly-title') ); |
| 32 | + $wgOut->setPageTitle( wfMsg( 'user-stats-weekly-title' ) ); |
33 | 33 | } else { |
34 | | - $wgOut->setPagetitle( wfMsg('user-stats-monthly-title') ); |
| 34 | + $wgOut->setPageTitle( wfMsg( 'user-stats-monthly-title' ) ); |
35 | 35 | } |
36 | 36 | |
37 | 37 | $count = 50; |
— | — | @@ -51,18 +51,19 @@ |
52 | 52 | |
53 | 53 | $dbr = wfGetDB( DB_SLAVE ); |
54 | 54 | $res = $dbr->select( "user_points_{$period}", |
55 | | - array('up_user_id','up_user_name','up_points'), |
56 | | - array('up_user_id <> 0'), __METHOD__, |
| 55 | + array( 'up_user_id', 'up_user_name', 'up_points' ), |
| 56 | + array( 'up_user_id <> 0' ), |
| 57 | + __METHOD__, |
57 | 58 | $params |
58 | 59 | ); |
59 | | - while( $row = $dbr->fetchObject($res) ){ |
| 60 | + while( $row = $dbr->fetchObject( $res ) ){ |
60 | 61 | $user_list[] = array( |
61 | 62 | 'user_id' => $row->up_user_id, |
62 | 63 | 'user_name' => $row->up_user_name, |
63 | 64 | 'points' => $row->up_points |
64 | 65 | ); |
65 | 66 | } |
66 | | - $wgMemc->set( $key, $user_list, 60 * 5); |
| 67 | + $wgMemc->set( $key, $user_list, 60 * 5 ); |
67 | 68 | } |
68 | 69 | |
69 | 70 | // Top nav bar |
— | — | @@ -70,35 +71,34 @@ |
71 | 72 | $recent_title = Title::makeTitle( NS_SPECIAL, 'TopUsersRecent' ); |
72 | 73 | |
73 | 74 | $out .= '<div class="top-fan-nav"> |
74 | | - <h1>' . wfMsg('top-fans-by-points-nav-header') . '</h1> |
75 | | - <p><a href="'.$top_title->escapeFullURL().'">' . wfMsg('top-fans-total-points-link') . '</a></p>'; |
| 75 | + <h1>' . wfMsg( 'top-fans-by-points-nav-header' ) . '</h1> |
| 76 | + <p><a href="' . $top_title->escapeFullURL() . '">' . wfMsg( 'top-fans-total-points-link' ) . '</a></p>'; |
76 | 77 | |
77 | 78 | if( $period == 'weekly' ) { |
78 | | - $out .= '<p><a href="' . $recent_title->escapeFullURL("period=monthly") . '">' .wfMsg('top-fans-monthly-points-link') . '</a><p> |
79 | | - <p><b>' . wfMsg('top-fans-weekly-points-link') . '</b></p>'; |
| 79 | + $out .= '<p><a href="' . $recent_title->escapeFullURL( 'period=monthly' ) . '">' . wfMsg( 'top-fans-monthly-points-link' ) . '</a><p> |
| 80 | + <p><b>' . wfMsg( 'top-fans-weekly-points-link' ) . '</b></p>'; |
80 | 81 | } else { |
81 | | - $out .= '<p><b>' .wfMsg('top-fans-monthly-points-link') . '</b><p> |
82 | | - <p><a href="' . $recent_title->escapeFullURL("period=weekly") . '">' .wfMsg('top-fans-weekly-points-link') . '</a></p>'; |
| 82 | + $out .= '<p><b>' . wfMsg( 'top-fans-monthly-points-link' ) . '</b><p> |
| 83 | + <p><a href="' . $recent_title->escapeFullURL( 'period=weekly' ) . '">' . wfMsg( 'top-fans-weekly-points-link' ) . '</a></p>'; |
83 | 84 | } |
84 | 85 | |
85 | 86 | // Build nav of stats by category based on MediaWiki:Topfans-by-category |
86 | | - if( count( $lines ) > 0 ) { |
87 | | - $out .= '<h1 style="margin-top:15px !important;">' . wfMsg('top-fans-by-category-nav-header') . '</h1>'; |
88 | | - } |
89 | | - |
90 | | - $by_category_title = Title::makeTitle( NS_SPECIAL, 'TopFansByStatistic' ); |
| 87 | + $by_category_title = SpecialPage::getTitleFor( 'TopFansByStatistic' ); |
91 | 88 | $nav = array(); |
92 | 89 | |
93 | 90 | $lines = explode( "\n", wfMsgForContent( 'topfans-by-category' ) ); |
| 91 | + if( count( $lines ) > 0 ) { |
| 92 | + $out .= '<h1 style="margin-top:15px !important;">' . wfMsg( 'top-fans-by-category-nav-header' ) . '</h1>'; |
| 93 | + } |
94 | 94 | foreach( $lines as $line ) { |
95 | 95 | |
96 | | - if( strpos($line, '*') !== 0 ){ |
| 96 | + if( strpos( $line, '*' ) !== 0 ){ |
97 | 97 | continue; |
98 | 98 | } else { |
99 | | - $line = explode( '|' , trim($line, '* '), 2 ); |
| 99 | + $line = explode( '|', trim( $line, '* ' ), 2 ); |
100 | 100 | $stat = $line[0]; |
101 | 101 | $link_text = $line[1]; |
102 | | - $out .= '<p><a href="' . $by_category_title->escapeFullURL("stat={$stat}") . '">'.$link_text.'</a></p>'; |
| 102 | + $out .= '<p><a href="' . $by_category_title->escapeFullURL( "stat={$stat}" ) . '">' . $link_text . '</a></p>'; |
103 | 103 | } |
104 | 104 | } |
105 | 105 | $out .= '</div>'; |
— | — | @@ -109,21 +109,21 @@ |
110 | 110 | foreach( $user_list as $user ){ |
111 | 111 | $user_title = Title::makeTitle( NS_USER, $user['user_name'] ); |
112 | 112 | $avatar = new wAvatar( $user['user_id'], 'm' ); |
113 | | - $CommentIcon = $avatar->getAvatarImage(); |
| 113 | + $commentIcon = $avatar->getAvatarImage(); |
114 | 114 | |
115 | 115 | $out .= '<div class="top-fan-row"> |
116 | | - <span class="top-fan-num">'.$x.'.</span> |
| 116 | + <span class="top-fan-num">' . $x . '.</span> |
117 | 117 | <span class="top-fan"> |
118 | | - <img src="'.$wgUploadPath.'/avatars/' . $CommentIcon . '" alt="" border=""> |
| 118 | + <img src="' . $wgUploadPath . '/avatars/' . $commentIcon . '" alt="" border="" /> |
119 | 119 | <a href="' . $user_title->escapeFullURL() . '" >' . $user['user_name'] . '</a> |
120 | 120 | </span>'; |
121 | 121 | |
122 | | - $out .= '<span class="top-fan-points"><b>' . number_format( $user['points'] ) . '</b> ' . wfMsg('top-fans-points') . '</span>'; |
| 122 | + $out .= '<span class="top-fan-points"><b>' . number_format( $user['points'] ) . '</b> ' . wfMsg( 'top-fans-points' ) . '</span>'; |
123 | 123 | $out .= '<div class="cleared"></div>'; |
124 | 124 | $out .= '</div>'; |
125 | 125 | $x++; |
126 | 126 | } |
127 | 127 | $out .= '</div><div class="cleared"></div>'; |
128 | | - $wgOut->addHTML($out); |
| 128 | + $wgOut->addHTML( $out ); |
129 | 129 | } |
130 | 130 | } |
\ No newline at end of file |
Index: trunk/extensions/SocialProfile/UserStats/TopFansByStat.php |
— | — | @@ -6,7 +6,7 @@ |
7 | 7 | * Constructor |
8 | 8 | */ |
9 | 9 | public function __construct(){ |
10 | | - parent::__construct('TopFansByStatistic'); |
| 10 | + parent::__construct( 'TopFansByStatistic' ); |
11 | 11 | } |
12 | 12 | |
13 | 13 | /** |
— | — | @@ -16,13 +16,13 @@ |
17 | 17 | */ |
18 | 18 | public function execute( $par ){ |
19 | 19 | global $wgRequest, $wgUser, $wgOut, $wgMemc, $wgUserStatsTrackWeekly, $wgUserStatsTrackMonthly, |
20 | | - $wgUserLevels, $wgOut, $wgUploadPath, $wgScriptPath; |
| 20 | + $wgUserLevels, $wgUploadPath, $wgScriptPath; |
21 | 21 | |
22 | 22 | // Read in localisation messages |
23 | | - wfLoadExtensionMessages('SocialProfileUserStats'); |
| 23 | + wfLoadExtensionMessages( 'SocialProfileUserStats' ); |
24 | 24 | |
25 | 25 | // Load CSS |
26 | | - $wgOut->addStyle( '../..' . $wgScriptPath . '/extensions/SocialProfile/UserStats/TopList.css' ); |
| 26 | + $wgOut->addExtensionStyle( $wgScriptPath . '/extensions/SocialProfile/UserStats/TopList.css' ); |
27 | 27 | |
28 | 28 | $statistic = $wgRequest->getVal( 'stat' ); |
29 | 29 | $column = "stats_{$statistic}"; |
— | — | @@ -32,13 +32,13 @@ |
33 | 33 | |
34 | 34 | // Error if the querystring value does not match our stat column |
35 | 35 | if( !$dbr->fieldExists( 'user_stats', $column ) ){ |
36 | | - $wgOut->setPagetitle( wfMsg('top-fans-bad-field-title') ); |
37 | | - $wgOut->addHTML( wfMsg('top-fans-bad-field-message') ); |
| 36 | + $wgOut->setPageTitle( wfMsg( 'top-fans-bad-field-title' ) ); |
| 37 | + $wgOut->addHTML( wfMsg( 'top-fans-bad-field-message' ) ); |
38 | 38 | return false; |
39 | 39 | } |
40 | 40 | |
41 | 41 | // Set page title |
42 | | - $wgOut->setPagetitle( wfMsg( 'top-fans-by-category-title', $stat_name_friendly ) ); |
| 42 | + $wgOut->setPageTitle( wfMsg( 'top-fans-by-category-title', $stat_name_friendly ) ); |
43 | 43 | |
44 | 44 | $count = 50; |
45 | 45 | |
— | — | @@ -59,11 +59,12 @@ |
60 | 60 | |
61 | 61 | $dbr = wfGetDB( DB_SLAVE ); |
62 | 62 | $res = $dbr->select( 'user_stats', |
63 | | - array('stats_user_id', 'stats_user_name', $column), |
64 | | - array('stats_user_id <> 0', "{$column} > 0" ), __METHOD__, |
| 63 | + array( 'stats_user_id', 'stats_user_name', $column ), |
| 64 | + array( 'stats_user_id <> 0', "{$column} > 0" ), |
| 65 | + __METHOD__, |
65 | 66 | $params |
66 | 67 | ); |
67 | | - while( $row = $dbr->fetchObject($res) ){ |
| 68 | + while( $row = $dbr->fetchObject( $res ) ){ |
68 | 69 | $user_list[] = array( |
69 | 70 | 'user_id' => $row->stats_user_id, |
70 | 71 | 'user_name' => $row->stats_user_name, |
— | — | @@ -74,35 +75,35 @@ |
75 | 76 | } |
76 | 77 | |
77 | 78 | // Top nav bar |
78 | | - $top_title = Title::makeTitle( NS_SPECIAL, 'TopFans' ); |
79 | | - $recent_title = Title::makeTitle( NS_SPECIAL, 'TopFansRecent' ); |
| 79 | + $top_title = SpecialPage::getTitleFor( 'TopUsers' ); |
| 80 | + $recent_title = SpecialPage::getTitleFor( 'TopUsersRecent' ); |
80 | 81 | |
81 | | - $out .= '<div class="top-fan-nav"> |
82 | | - <h1>' . wfMsg('top-fans-by-points-nav-header') . '</h1> |
83 | | - <p><a href="'.$top_title->escapeFullURL().'">' . wfMsg('top-fans-total-points-link') . '</a></p>'; |
| 82 | + $out = '<div class="top-fan-nav"> |
| 83 | + <h1>' . wfMsg( 'top-fans-by-points-nav-header' ) . '</h1> |
| 84 | + <p><a href="' . $top_title->escapeFullURL() . '">' . wfMsg( 'top-fans-total-points-link' ) . '</a></p>'; |
84 | 85 | |
85 | 86 | if( $wgUserStatsTrackWeekly ){ |
86 | | - $out .= '<p><a href="' . $recent_title->escapeFullURL("period=monthly") . '">' . wfMsg('top-fans-monthly-points-link') . '</a><p>'; |
| 87 | + $out .= '<p><a href="' . $recent_title->escapeFullURL( 'period=monthly' ) . '">' . wfMsg( 'top-fans-monthly-points-link' ) . '</a><p>'; |
87 | 88 | } |
88 | 89 | if( $wgUserStatsTrackMonthly ){ |
89 | | - $out .= '<p><a href="' . $recent_title->escapeFullURL("period=weekly") . '">' . wfMsg('top-fans-weekly-points-link') . '</a></p>'; |
| 90 | + $out .= '<p><a href="' . $recent_title->escapeFullURL( 'period=weekly' ) . '">' . wfMsg( 'top-fans-weekly-points-link' ) . '</a></p>'; |
90 | 91 | } |
91 | 92 | |
92 | 93 | // 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>'; |
| 94 | + $out .= '<h1 style="margin-top:15px !important;">' . wfMsg( 'top-fans-by-category-nav-header' ) . '</h1>'; |
94 | 95 | |
95 | | - $by_category_title = Title::makeTitle( NS_SPECIAL, 'TopFansByStatistic' ); |
| 96 | + $by_category_title = SpecialPage::getTitleFor( 'TopFansByStatistic' ); |
96 | 97 | $nav = array(); |
97 | 98 | |
98 | 99 | $lines = explode( "\n", wfMsgForContent( 'topfans-by-category' ) ); |
99 | 100 | foreach( $lines as $line ) { |
100 | | - if( strpos($line, '*') !== 0 ){ |
| 101 | + if( strpos( $line, '*' ) !== 0 ){ |
101 | 102 | continue; |
102 | 103 | } else { |
103 | | - $line = explode( '|' , trim($line, '* '), 2 ); |
| 104 | + $line = explode( '|', trim( $line, '* ' ), 2 ); |
104 | 105 | $stat = $line[0]; |
105 | 106 | $link_text = $line[1]; |
106 | | - $out .= '<p><a href="' . $by_category_title->escapeFullURL("stat={$stat}") . '">'.$link_text.'</a></p>'; |
| 107 | + $out .= '<p><a href="' . $by_category_title->escapeFullURL( "stat={$stat}" ) . '">' . $link_text . '</a></p>'; |
107 | 108 | } |
108 | 109 | } |
109 | 110 | $out .= '</div>'; |
— | — | @@ -111,15 +112,15 @@ |
112 | 113 | $out .= '<div class="top-users">'; |
113 | 114 | |
114 | 115 | foreach( $user_list as $user ){ |
115 | | - $user_name = ( $user['user_name'] == substr( $user['user_name'] , 0, 22) ) ? $user['user_name'] : ( substr( $user['user_name'] , 0, 22) . "..."); |
| 116 | + $user_name = ( $user['user_name'] == substr( $user['user_name'] , 0, 22) ) ? $user['user_name'] : ( substr( $user['user_name'] , 0, 22 ) . '...' ); |
116 | 117 | $user_title = Title::makeTitle( NS_USER, $user['user_name'] ); |
117 | 118 | $avatar = new wAvatar( $user['user_id'], 'm' ); |
118 | | - $CommentIcon = $avatar->getAvatarImage(); |
| 119 | + $commentIcon = $avatar->getAvatarImage(); |
119 | 120 | |
120 | 121 | // Stats row |
121 | | - // TODO: opinion_average isn't currently working, so its not enabled in menus |
122 | | - if( $statistic == "opinion_average" ) { |
123 | | - $statistics_row = number_format($row->opinion_average, 2); |
| 122 | + // TODO: opinion_average isn't currently working, so it's not enabled in menus |
| 123 | + if( $statistic == 'opinion_average' ) { |
| 124 | + $statistics_row = number_format( $row->opinion_average, 2 ); |
124 | 125 | $lowercase_statistics_name = 'percent'; |
125 | 126 | } else { |
126 | 127 | $statistics_row = number_format( $user['stat'] ); |
— | — | @@ -127,17 +128,17 @@ |
128 | 129 | } |
129 | 130 | |
130 | 131 | $out .= '<div class="top-fan-row"> |
131 | | - <span class="top-fan-num">'.$x.'.</span> |
| 132 | + <span class="top-fan-num">' . $x . '.</span> |
132 | 133 | <span class="top-fan"> |
133 | | - <img src="'.$wgUploadPath.'/avatars/' . $CommentIcon . '" alt="" border=""> |
134 | | - <a href="' . $user_title->escapeFullURL() . '" >'.$user_name.'</a> |
| 134 | + <img src="' . $wgUploadPath . '/avatars/' . $commentIcon . '" alt="" border="" /> |
| 135 | + <a href="' . $user_title->escapeFullURL() . '">' . $user_name . '</a> |
135 | 136 | </span> |
136 | | - <span class="top-fan-points"><b>' . $statistics_row . '</b> '.$lowercase_statistics_name.'</span>'; |
| 137 | + <span class="top-fan-points"><b>' . $statistics_row . '</b> ' . $lowercase_statistics_name . '</span>'; |
137 | 138 | $out .= '<div class="cleared"></div>'; |
138 | 139 | $out .= '</div>'; |
139 | 140 | $x++; |
140 | 141 | } |
141 | 142 | $out .= '</div><div class="cleared"></div>'; |
142 | | - $wgOut->addHTML($out); |
| 143 | + $wgOut->addHTML( $out ); |
143 | 144 | } |
144 | 145 | } |
\ No newline at end of file |