Index: trunk/extensions/SocialProfile/UserStats/GenerateTopUsersReport.php |
— | — | @@ -79,6 +79,8 @@ |
80 | 80 | // Add CSS |
81 | 81 | $wgOut->addExtensionStyle( $wgScriptPath . '/extensions/SocialProfile/UserStats/TopList.css' ); |
82 | 82 | |
| 83 | + // Used as the LIMIT for SQL queries; basically, show this many users |
| 84 | + // in the generated reports. |
83 | 85 | $user_count = $wgRequest->getInt( 'user_count', 10 ); |
84 | 86 | |
85 | 87 | if( $period == 'weekly' ) { |
— | — | @@ -101,7 +103,11 @@ |
102 | 104 | ); |
103 | 105 | |
104 | 106 | $last_rank = 0; |
| 107 | + $last_total = 0; |
| 108 | + $x = 1; |
105 | 109 | |
| 110 | + $users = array(); |
| 111 | + |
106 | 112 | // Initial run is a special case |
107 | 113 | if ( $dbw->numRows( $res ) <= 0 ) { |
108 | 114 | // For the initial run, everybody's a winner! |
— | — | @@ -122,11 +128,6 @@ |
123 | 129 | |
124 | 130 | $out = '<div class="top-users">'; |
125 | 131 | |
126 | | - $last_total = 0; |
127 | | - $x = 1; |
128 | | - |
129 | | - $users = array(); |
130 | | - |
131 | 132 | foreach( $res as $row ) { |
132 | 133 | if( $row->stats_total_points == $last_total ) { |
133 | 134 | $rank = $last_rank; |
— | — | @@ -146,11 +147,6 @@ |
147 | 148 | } else { |
148 | 149 | $out = '<div class="top-users">'; |
149 | 150 | |
150 | | - $last_total = 0; |
151 | | - $x = 1; |
152 | | - |
153 | | - $users = array(); |
154 | | - |
155 | 151 | foreach( $res as $row ) { |
156 | 152 | if( $row->up_points == $last_total ) { |
157 | 153 | $rank = $last_rank; |
Index: trunk/extensions/SocialProfile/UserStats/TopFansRecent.php |
— | — | @@ -95,7 +95,7 @@ |
96 | 96 | $message = wfMsgForContent( 'topfans-by-category' ); |
97 | 97 | |
98 | 98 | if ( !wfEmptyMsg( 'topfans-by-category', $message ) ) { |
99 | | - $out .= '<h1 style="margin-top:15px !important;">' . |
| 99 | + $out .= '<h1 class="top-title">' . |
100 | 100 | wfMsg( 'top-fans-by-category-nav-header' ) . '</h1>'; |
101 | 101 | |
102 | 102 | $lines = explode( "\n", $message ); |
Index: trunk/extensions/SocialProfile/UserStats/UserStats.i18n.php |
— | — | @@ -72,6 +72,10 @@ |
73 | 73 | |
74 | 74 | Click $3 |
75 | 75 | and change your settings to disable e-mail notifications.', |
| 76 | + // Special:UpdateEditCounts |
| 77 | + 'updateeditcounts' => 'Update Edit Counts', |
| 78 | + 'updateeditcounts-updated' => "Updated stats for '''$1''' {{PLURAL:$1|user|users}}", |
| 79 | + 'updateeditcounts-updating' => 'Updating $1 with $2 {{PLURAL:$2|edit|edits}}', |
76 | 80 | // Special:GenerateTopUsersReport |
77 | 81 | 'generatetopusersreport' => 'Generate Top Users Report', |
78 | 82 | 'user-stats-weekly-winners' => 'Weekly {{PLURAL:$1|Winner|Winners}}', |
Index: trunk/extensions/SocialProfile/UserStats/EditCount.php |
— | — | @@ -7,8 +7,19 @@ |
8 | 8 | die( "This is not a valid entry point.\n" ); |
9 | 9 | } |
10 | 10 | |
| 11 | +/** |
| 12 | + * For the UserLevels (points) functionality to work, you will need to |
| 13 | + * define $wgUserLevels and require_once() this file in your wiki's |
| 14 | + * LocalSettings.php file. |
| 15 | + */ |
11 | 16 | $wgHooks['NewRevisionFromEditComplete'][] = 'incEditCount'; |
| 17 | +$wgHooks['ArticleDelete'][] = 'removeDeletedEdits'; |
| 18 | +$wgHooks['ArticleUndelete'][] = 'restoreDeletedEdits'; |
12 | 19 | |
| 20 | +/** |
| 21 | + * Updates user's points after they've made an edit in a namespace that is |
| 22 | + * listed in the $wgNamespacesForEditPoints array. |
| 23 | + */ |
13 | 24 | function incEditCount( $article, $revision, $baseRevId ) { |
14 | 25 | global $wgUser, $wgNamespacesForEditPoints; |
15 | 26 | |
— | — | @@ -24,8 +35,10 @@ |
25 | 36 | return true; |
26 | 37 | } |
27 | 38 | |
28 | | -$wgHooks['ArticleDelete'][] = 'removeDeletedEdits'; |
29 | | - |
| 39 | +/** |
| 40 | + * Updates user's points after a page in a namespace that is listed in the |
| 41 | + * $wgNamespacesForEditPoints array that they've edited has been deleted. |
| 42 | + */ |
30 | 43 | function removeDeletedEdits( &$article, &$user, &$reason ) { |
31 | 44 | global $wgNamespacesForEditPoints; |
32 | 45 | |
— | — | @@ -51,8 +64,11 @@ |
52 | 65 | return true; |
53 | 66 | } |
54 | 67 | |
55 | | -$wgHooks['ArticleUndelete'][] = 'restoreDeletedEdits'; |
56 | | - |
| 68 | +/** |
| 69 | + * Updates user's points after a page in a namespace that is listed in the |
| 70 | + * $wgNamespacesForEditPoints array that they've edited has been restored after |
| 71 | + * it was originally deleted. |
| 72 | + */ |
57 | 73 | function restoreDeletedEdits( &$title, $new ) { |
58 | 74 | global $wgNamespacesForEditPoints; |
59 | 75 | |
Index: trunk/extensions/SocialProfile/UserStats/TopList.css |
— | — | @@ -73,7 +73,13 @@ |
74 | 74 | width: 200px; |
75 | 75 | padding: 5px; |
76 | 76 | } |
| 77 | + |
77 | 78 | .top-fan-nav a { |
78 | 79 | font-weight: bold; |
79 | 80 | text-decoration: none; |
80 | 81 | } |
| 82 | + |
| 83 | +/* A "Top users by category" <h1> on Special:TopFansByStatistics and Special:TopUsersRecent */ |
| 84 | +.top-title { |
| 85 | + margin-top: 15px !important; |
| 86 | +} |
\ No newline at end of file |
Index: trunk/extensions/SocialProfile/UserStats/TopFansByStat.php |
— | — | @@ -56,7 +56,6 @@ |
57 | 57 | $params['ORDER BY'] = "{$column} DESC"; |
58 | 58 | $params['LIMIT'] = $count; |
59 | 59 | |
60 | | - $dbr = wfGetDB( DB_SLAVE ); |
61 | 60 | $res = $dbr->select( |
62 | 61 | 'user_stats', |
63 | 62 | array( 'stats_user_id', 'stats_user_name', $column ), |
— | — | @@ -96,7 +95,7 @@ |
97 | 96 | $message = wfMsgForContent( 'topfans-by-category' ); |
98 | 97 | |
99 | 98 | if ( !wfEmptyMsg( 'topfans-by-category', $message ) ) { |
100 | | - $out .= '<h1 style="margin-top:15px !important;">' . |
| 99 | + $out .= '<h1 class="top-title">' . |
101 | 100 | wfMsg( 'top-fans-by-category-nav-header' ) . '</h1>'; |
102 | 101 | |
103 | 102 | $lines = explode( "\n", $message ); |
Index: trunk/extensions/SocialProfile/UserStats/UserStatsClass.php |
— | — | @@ -581,7 +581,7 @@ |
582 | 582 | global $wgEnableFacebook, $wgUserLevels; |
583 | 583 | |
584 | 584 | if ( $this->user_id == 0 ) { |
585 | | - return ''; |
| 585 | + return array(); |
586 | 586 | } |
587 | 587 | |
588 | 588 | $stats_data = array(); |
— | — | @@ -775,7 +775,7 @@ |
776 | 776 | * amount of points the user has |
777 | 777 | */ |
778 | 778 | static function getTopFansList( $limit = 10 ) { |
779 | | - $dbr = wfGetDB( DB_MASTER ); |
| 779 | + $dbr = wfGetDB( DB_SLAVE ); |
780 | 780 | |
781 | 781 | $res = $dbr->select( |
782 | 782 | 'user_stats', |
Index: trunk/extensions/SocialProfile/UserStats/TopUsers.php |
— | — | @@ -57,7 +57,7 @@ |
58 | 58 | ); |
59 | 59 | $loop++; |
60 | 60 | } |
61 | | - if ( $loop >= 50 ) { |
| 61 | + if ( $loop >= $realcount ) { |
62 | 62 | break; |
63 | 63 | } |
64 | 64 | } |
Index: trunk/extensions/SocialProfile/UserStats/SpecialUpdateEditCounts.php |
— | — | @@ -73,7 +73,14 @@ |
74 | 74 | __METHOD__ |
75 | 75 | ); |
76 | 76 | } |
77 | | - $wgOut->addHTML( "<p>Updating {$row->rev_user_text} with {$editCount} edits</p>" ); |
| 77 | + $wgOut->addHTML( |
| 78 | + wfMsgExt( |
| 79 | + 'updateeditcounts-updating', |
| 80 | + 'parsemag', |
| 81 | + $row->rev_user_text, |
| 82 | + $editCount |
| 83 | + ) |
| 84 | + ); |
78 | 85 | |
79 | 86 | $dbw->update( |
80 | 87 | 'user_stats', |
— | — | @@ -97,8 +104,6 @@ |
98 | 105 | public function execute( $par ) { |
99 | 106 | global $wgOut, $wgUser; |
100 | 107 | |
101 | | - $wgOut->setPageTitle( 'Update Edit Counts' ); |
102 | | - |
103 | 108 | // Check permissions -- we must be allowed to access this special page |
104 | 109 | // before we can run any database queries |
105 | 110 | if ( !$wgUser->isAllowed( 'updatepoints' ) ) { |
— | — | @@ -112,6 +117,9 @@ |
113 | 118 | return; |
114 | 119 | } |
115 | 120 | |
| 121 | + // Set the page title, robot policies, etc. |
| 122 | + $this->setHeaders(); |
| 123 | + |
116 | 124 | $dbw = wfGetDB( DB_MASTER ); |
117 | 125 | $this->updateMainEditsCount(); |
118 | 126 | |
— | — | @@ -125,7 +133,7 @@ |
126 | 134 | __METHOD__, |
127 | 135 | array( 'ORDER BY' => 'stats_user_name' ) |
128 | 136 | ); |
129 | | - $out = ''; |
| 137 | + |
130 | 138 | $x = 0; |
131 | 139 | foreach ( $res as $row ) { |
132 | 140 | $x++; |
— | — | @@ -135,7 +143,7 @@ |
136 | 144 | ); |
137 | 145 | $stats->updateTotalPoints(); |
138 | 146 | } |
139 | | - $out = "Updated stats for <b>{$x}</b> users"; |
140 | | - $wgOut->addHTML( $out ); |
| 147 | + |
| 148 | + $wgOut->addHTML( wfMsgExt( 'updateeditcounts-updated', 'parsemag', $x ) ); |
141 | 149 | } |
142 | 150 | } |