r102132 MediaWiki - Code Review archive

Repository: MediaWiki
Revision: < r102131‎ | r102132 | r102133 >
Date: 00:17, 6 November 2011
Author: ashley
Status: deferred (Comments)
Tags: socialprofile 
Comment:
SocialProfile: as per Markus' in-depth review:
*move hook registration to the top of the file
*documentation updates
*i18n
*moved inline CSS to the CSS file
*removed some duplicate code
*return an array when we're supposed to return one instead of returning a string
Modified paths:
  • /trunk/extensions/SocialProfile/UserStats/EditCount.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserStats/GenerateTopUsersReport.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserStats/SpecialUpdateEditCounts.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserStats/TopFansByStat.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserStats/TopFansRecent.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserStats/TopList.css (modified) (history)
  • /trunk/extensions/SocialProfile/UserStats/TopUsers.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserStats/UserStats.i18n.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserStats/UserStatsClass.php (modified) (history)

Diff [purge]

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 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r102292 SocialProfile: follow-up to r102132 as per Nikerabbit's code review: use Outp...ashley 15:50, 7 November 2011

Comments

#Comment by Nikerabbit (talk | contribs)   09:43, 6 November 2011

For updateeditcounts-updating and updateeditcounts-updated I suggest $wgOut->addWikiMsg( 'name', 'param1' ); The other messages should be escaped in way or another.

Status & tagging log

  • 01:28, 13 June 2012 Krinkle (talk | contribs) changed the tags for r102132 [removed: nodeploy]
  • 16:08, 27 January 2012 Reedy (talk | contribs) changed the status of r102132 [removed: new added: deferred]
  • 15:25, 19 January 2012 Siebrand (talk | contribs) changed the tags for r102132 [added: nodeploy]
  • 14:24, 15 January 2012 Jack Phoenix (talk | contribs) changed the status of r102132 [removed: deferred added: new]
  • 16:38, 6 January 2012 Reedy (talk | contribs) changed the status of r102132 [removed: new added: deferred]
  • 06:16, 5 January 2012 RobLa-WMF (talk | contribs) changed the tags for r102132 [added: socialprofile]
  • 10:48, 11 December 2011 Jack Phoenix (talk | contribs) changed the status of r102132 [removed: deferred added: new]
  • 09:33, 8 December 2011 Tim Starling (talk | contribs) changed the status of r102132 [removed: new added: deferred]
  • 19:08, 13 November 2011 Jack Phoenix (talk | contribs) changed the status of r102132 [removed: deferred added: new]
  • 13:53, 13 November 2011 Reedy (talk | contribs) changed the status of r102132 [removed: new added: deferred]

AltStyle によって変換されたページ (->オリジナル) /