r110046 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110045‎ | r110046 | r110047 >
Date:05:55, 26 January 2012
Author:santhosh
Status:ok (Comments)
Tags:aft 
Comment:
Stylize, and whitespace-tab fixes
Modified paths:
  • /trunk/extensions/ArticleFeedbackv5/api/ApiArticleFeedbackv5.php (modified) (history)
  • /trunk/extensions/ArticleFeedbackv5/api/ApiArticleFeedbackv5Utils.php (modified) (history)
  • /trunk/extensions/ArticleFeedbackv5/api/ApiFlagFeedbackArticleFeedbackv5.php (modified) (history)
  • /trunk/extensions/ArticleFeedbackv5/api/ApiViewFeedbackArticleFeedbackv5.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleFeedbackv5/api/ApiFlagFeedbackArticleFeedbackv5.php
@@ -42,70 +42,70 @@
4343 if ( !$record->af_id ) {
4444 // no-op, because this is already broken
4545 $error = 'articlefeedbackv5-invalid-feedback-id';
46 - } elseif( $params['flagtype'] == 'unhide' ) {
 46+ } elseif ( $params['flagtype'] == 'unhide' ) {
4747 // remove the hidden status
4848 $update[] = 'af_hide_count = 0';
49 - } elseif( $params['flagtype'] == 'unoversight' ) {
50 - // remove the oversight flag
 49+ } elseif ( $params['flagtype'] == 'unoversight' ) {
 50+ // remove the oversight flag
5151 $update[] = 'af_needs_oversight = FALSE';
52 - } elseif( $params['flagtype'] == 'undelete' ) {
 52+ } elseif ( $params['flagtype'] == 'undelete' ) {
5353 // remove the deleted status, and clear oversight flag
5454 $update[] = 'af_delete_count = 0';
5555 $update[] = 'af_needs_oversight = FALSE';
56 - } elseif( $params['flagtype'] == 'oversight' ) {
 56+ } elseif ( $params['flagtype'] == 'oversight' ) {
5757 // flag for oversight
5858 $update[] = 'af_needs_oversight = TRUE';
59 - } elseif( in_array( $params['flagtype'], $flags ) ) {
 59+ } elseif ( in_array( $params['flagtype'], $flags ) ) {
6060 // Probably this doesn't need validation, since the API
6161 // will handle it, but if it's getting interpolated into
6262 // the SQL, I'm really wary not re-validating it.
63 - $field = 'af_'.$params['flagtype'].'_count';
 63+ $field = 'af_' . $params['flagtype'] . '_count';
6464 $update[] = "$field = $field + 1";
6565 } else {
6666 $error = 'articlefeedbackv5-invalid-feedback-flag';
6767 }
6868
6969 // Newly abusive record
70 - if( $flag == 'abuse' && $record->af_abuse_count == 0 ) {
 70+ if ( $flag == 'abuse' && $record->af_abuse_count == 0 ) {
7171 $counts['increment'][] = 'abusive';
7272 }
7373
74 - if( $flag == 'oversight' ) {
 74+ if ( $flag == 'oversight' ) {
7575 $counts['increment'][] = 'needsoversight';
7676 }
77 - if( $flag == 'unoversight' ) {
 77+ if ( $flag == 'unoversight' ) {
7878 $counts['decrement'][] = 'needsoversight';
7979 }
8080
8181
8282 // Newly hidden record
83 - if( $flag == 'hide' && $record->af_hide_count == 0 ) {
 83+ if ( $flag == 'hide' && $record->af_hide_count == 0 ) {
8484 $counts['increment'][] = 'invisible';
8585 $counts['decrement'][] = 'visible';
8686 }
8787 // Unhidden record
88 - if( $flag == 'unhide') {
 88+ if ( $flag == 'unhide' ) {
8989 $counts['increment'][] = 'visible';
9090 $counts['decrement'][] = 'invisible';
9191 }
9292
9393 // Newly deleted record
94 - if( $flag == 'delete' && $record->af_delete_count == 0 ) {
 94+ if ( $flag == 'delete' && $record->af_delete_count == 0 ) {
9595 $counts['increment'][] = 'deleted';
9696 $counts['decrement'][] = 'visible';
9797 }
9898 // Undeleted record
99 - if( $flag == 'undelete' ) {
 99+ if ( $flag == 'undelete' ) {
100100 $counts['increment'][] = 'visible';
101101 $counts['decrement'][] = 'deleted';
102102 }
103 -
 103+
104104 // Newly helpful record
105 - if( $flag == 'helpful' && $record->af_helpful_count == 0 ) {
 105+ if ( $flag == 'helpful' && $record->af_helpful_count == 0 ) {
106106 $counts['increment'][] = 'helpful';
107107 }
108108 // Newly unhelpful record (IE, unhelpful has overtaken helpful)
109 - if( $flag == 'unhelpful'
 109+ if ( $flag == 'unhelpful'
110110 && ( ( $record->af_helpful_count - $record->af_unhelpful_count ) == 1 ) ) {
111111 $counts['decrement'][] = 'helpful';
112112 }
@@ -121,15 +121,15 @@
122122
123123 ApiArticleFeedbackv5Utils::incrementFilterCounts( $pageId, $counts['increment'] );
124124 ApiArticleFeedbackv5Utils::decrementFilterCounts( $pageId, $counts['decrement'] );
125 -
126 - // This gets a potentially stale copy from the read
 125+
 126+ // This gets a potentially stale copy from the read
127127 // database assumes it's valid, in the interest
128128 // of staying off of the write database.
129 - // Better stale data than wail on the master, IMO,
 129+ // Better stale data than wail on the master, IMO,
130130 // but I'm open to suggestion on that one.
131131
132132 // Update helpful/unhelpful count after submission
133 - if( $params['flagtype'] == 'helpful' || $params['flagtype'] == 'unhelpful' ) {
 133+ if ( $params['flagtype'] == 'helpful' || $params['flagtype'] == 'unhelpful' ) {
134134 $record = $dbr->selectRow(
135135 'aft_article_feedback',
136136 array( 'af_helpful_count', 'af_unhelpful_count' ),
@@ -140,7 +140,7 @@
141141 $helpful = $record->af_helpful_count;
142142 $unhelpful = $record->af_unhelpful_count;
143143
144 - $helpful = wfMessage( 'articlefeedbackv5-form-helpful-votes',
 144+ $helpful = wfMessage( 'articlefeedbackv5-form-helpful-votes',
145145 ( $helpful + $unhelpful ),
146146 $helpful, $unhelpful
147147 )->escaped();
@@ -160,7 +160,7 @@
161161 'reason' => $reason,
162162 );
163163
164 - if( $helpful ) {
 164+ if ( $helpful ) {
165165 $results['helpful'] = $helpful;
166166 }
167167
Index: trunk/extensions/ArticleFeedbackv5/api/ApiArticleFeedbackv5.php
@@ -34,7 +34,7 @@
3535 $params = $this->extractRequestParams();
3636
3737 // Blocked users are, well, blocked.
38 - if( $wgUser->isBlocked() ) {
 38+ if ( $wgUser->isBlocked() ) {
3939 $this->getResult()->addValue( null, 'error', 'articlefeedbackv5-error-blocked' );
4040 return;
4141 }
@@ -268,15 +268,15 @@
269269
270270 # Does this record have a comment attached?
271271 # Defined as an answer of type 'text'.
272 - foreach( $answers as $a ) {
273 - if( $a['aa_response_text'] !== null ) {
 272+ foreach ( $answers as $a ) {
 273+ if ( $a['aa_response_text'] !== null ) {
274274 $has_comment = true;
275275 }
276276 }
277277
278278 $filters = array( 'all', 'visible' );
279279 # If the feedbackrecord had a comment, update that filter count.
280 - if( $has_comment ) {
 280+ if ( $has_comment ) {
281281 $filters[] = 'comment';
282282 }
283283
Index: trunk/extensions/ArticleFeedbackv5/api/ApiViewFeedbackArticleFeedbackv5.php
@@ -98,12 +98,12 @@
9999 # $sortField = 'rating';
100100 # break;
101101 case 'age':
102 - # Default field, fall through
 102+ # Default field, fall through
103103 default:
104104 $sortField = 'af_id';
105105 $continueSql = "$sortField $continueDirection";
106106 break;
107 - }
 107+ }
108108 $order = "$sortField $direction";
109109
110110 $where['af_page_id'] = $pageId;
@@ -111,7 +111,7 @@
112112 # This join is needed for the comment filter.
113113 $where[] = 'af_id = aa_feedback_id';
114114
115 - if( $continue !== null ) {
 115+ if ( $continue !== null ) {
116116 $where[] = "$continueSql $continue";
117117 }
118118
@@ -122,14 +122,14 @@
123123 sure we get all answers for the exact IDs we want. */
124124 $id_query = $dbr->select(
125125 array(
126 - 'aft_article_feedback',
 126+ 'aft_article_feedback',
127127 'aft_article_answer'
128128 ),
129129 array(
130 - 'DISTINCT af_id',
 130+ 'DISTINCT af_id',
131131 'CONVERT(af_helpful_count, SIGNED) - CONVERT(af_unhelpful_count, SIGNED) AS net_helpfulness'
132132 ),
133 - $where,
 133+ $where,
134134 __METHOD__,
135135 array(
136136 'LIMIT' => $limit,
@@ -156,9 +156,9 @@
157157 'aa_response_rating', 'aa_response_option_id',
158158 'afi_data_type', 'af_created', 'user_name',
159159 'af_user_ip', 'af_hide_count', 'af_abuse_count',
160 - 'af_helpful_count', 'af_unhelpful_count',
 160+ 'af_helpful_count', 'af_unhelpful_count',
161161 'af_delete_count', 'af_needs_oversight',
162 - '(SELECT COUNT(*) FROM '.$dbr->tableName( 'revision' ).' WHERE rev_id > af_revision_id AND rev_page = '.( integer ) $pageId.') AS age',
 162+ '(SELECT COUNT(*) FROM ' . $dbr->tableName( 'revision' ) . ' WHERE rev_id > af_revision_id AND rev_page = ' . ( integer ) $pageId . ') AS age',
163163 'CONVERT(af_helpful_count, SIGNED) - CONVERT(af_unhelpful_count, SIGNED) AS net_helpfulness',
164164 'page_latest', 'af_revision_id', 'page_title'
165165 ),
@@ -202,23 +202,23 @@
203203 $where = array();
204204
205205 // Permissions check: these filters are for admins only.
206 - if(
207 - ( $filter == 'invisible'
 206+ if (
 207+ ( $filter == 'invisible'
208208 && !$wgUser->isAllowed( 'aftv5-see-hidden-feedback' ) )
209 - ||
210 - ( $filter == 'deleted'
 209+ ||
 210+ ( $filter == 'deleted'
211211 && !$wgUser->isAllowed( 'aftv5-see-deleted-feedback' ) )
212212 ) {
213213 $filter = null;
214214 }
215215
216216 // Don't let non-allowed users see these.
217 - if( !$wgUser->isAllowed( 'aftv5-see-hidden-feedback' ) ) {
 217+ if ( !$wgUser->isAllowed( 'aftv5-see-hidden-feedback' ) ) {
218218 $where['af_hide_count'] = 0;
219219 }
220220
221221 // Don't let non-allowed users see these.
222 - if( !$wgUser->isAllowed( 'aftv5-see-deleted-feedback' ) ) {
 222+ if ( !$wgUser->isAllowed( 'aftv5-see-deleted-feedback' ) ) {
223223 $where['af_delete_count'] = 0;
224224 }
225225
@@ -247,7 +247,7 @@
248248 case 'invisible':
249249 $where[] = 'af_hide_count > 0';
250250 break;
251 - case 'abusive':
 251+ case 'abusive':
252252 $where[] = 'af_abuse_count > 0';
253253 break;
254254 case 'helpful':
@@ -294,10 +294,10 @@
295295 ) )
296296 . Html::openElement( 'div', array(
297297 'class' => 'articleFeedbackv5-comment-details-date'
298 - ) )
299 - .Html::element( 'a', array(
 298+ ) )
 299+ . Html::element( 'a', array(
300300 'href' => "#id=$id"
301 - ), date( 'M j, Y H:i', strtotime($record[0]->af_created) ) )
 301+ ), date( 'M j, Y H:i', strtotime( $record[0]->af_created ) ) )
302302 . Html::closeElement( 'div' )
303303 # Remove for now, pending feedback.
304304 # . Html::openElement( 'div', array(
@@ -310,10 +310,10 @@
311311
312312 . Html::openElement( 'div', array(
313313 'class' => 'articleFeedbackv5-comment-details-updates'
314 - ) )
 314+ ) )
315315 . Linker::link(
316316 Title::newFromText( $record[0]->page_title ),
317 - wfMessage( 'articlefeedbackv5-updates-since', $record[0]->age ),
 317+ wfMessage( 'articlefeedbackv5-updates-since', $record[0]->age ),
318318 array(),
319319 array(
320320 'action' => 'historysubmit',
@@ -330,7 +330,7 @@
331331 ) )
332332 . Html::openElement( 'p', array( 'class' => 'articleFeedbackv5-comment-foot' ) );
333333
334 - if( $can_vote ) {
 334+ if ( $can_vote ) {
335335 $footer_links .= Html::element( 'span', array(
336336 'class' => 'articleFeedbackv5-helpful-caption'
337337 ), wfMessage( 'articlefeedbackv5-form-helpful-label', ( $record[0]->af_helpful_count + $record[0]->af_unhelpful_count ) ) )
@@ -338,7 +338,7 @@
339339 'id' => "articleFeedbackv5-helpful-link-$id",
340340 'class' => 'articleFeedbackv5-helpful-link'
341341 ), wfMessage( 'articlefeedbackv5-form-helpful-yes-label', $record[0]->af_helpful_count )->text() )
342 - .Html::element( 'a', array(
 342+ . Html::element( 'a', array(
343343 'id' => "articleFeedbackv5-unhelpful-link-$id",
344344 'class' => 'articleFeedbackv5-unhelpful-link'
345345 ), wfMessage( 'articlefeedbackv5-form-helpful-no-label', $record[0]->af_unhelpful_count )->text() );
@@ -347,7 +347,7 @@
348348 'class' => 'articleFeedbackv5-helpful-votes',
349349 'id' => "articleFeedbackv5-helpful-votes-$id"
350350 ), wfMessage( 'articlefeedbackv5-form-helpful-votes', ( $record[0]->af_helpful_count + $record[0]->af_unhelpful_count ), $record[0]->af_helpful_count, $record[0]->af_unhelpful_count ) );
351 - if( $can_flag ) {
 351+ if ( $can_flag ) {
352352 $footer_links .= Html::element( 'a', array(
353353 'id' => "articleFeedbackv5-abuse-link-$id",
354354 'class' => 'articleFeedbackv5-abuse-link'
@@ -369,22 +369,22 @@
370370
371371 // Don't render the toolbox if they can't do anything with it.
372372 $tools = null;
373 - if( $can_hide || $can_delete ) {
374 - $tools = Html::openElement( 'div', array(
 373+ if ( $can_hide || $can_delete ) {
 374+ $tools = Html::openElement( 'div', array(
375375 'class' => 'articleFeedbackv5-feedback-tools',
376 - 'id' => 'articleFeedbackv5-feedback-tools-'.$id
 376+ 'id' => 'articleFeedbackv5-feedback-tools-' . $id
377377 ) )
378378 . Html::element( 'h3', array(
379 - 'id' => 'articleFeedbackv5-feedback-tools-header-'.$id
 379+ 'id' => 'articleFeedbackv5-feedback-tools-header-' . $id
380380 ), wfMessage( 'articlefeedbackv5-form-tools-label' )->text() )
381381 . Html::openElement( 'ul', array(
382 - 'id' => 'articleFeedbackv5-feedback-tools-list-'.$id
 382+ 'id' => 'articleFeedbackv5-feedback-tools-list-' . $id
383383 ) );
384384
385385
386 - if( $can_hide ) {
 386+ if ( $can_hide ) {
387387 $link = 'hide';
388 - if( $record[0]->af_hide_count > 0 ) {
 388+ if ( $record[0]->af_hide_count > 0 ) {
389389 # unhide
390390 $link = 'unhide';
391391 $tools .= Html::element( 'li', array(), wfMessage( 'articlefeedbackv5-hidden' ) );
@@ -395,10 +395,10 @@
396396 ), wfMessage( "articlefeedbackv5-form-$link", $record[0]->af_hide_count )->text() ) );
397397 }
398398
399 - if( $can_delete ) {
 399+ if ( $can_delete ) {
400400 # delete
401401 $link = 'delete';
402 - if( $record[0]->af_delete_count > 0 ) {
 402+ if ( $record[0]->af_delete_count > 0 ) {
403403 $link = 'undelete';
404404 }
405405 $tools .= Html::rawElement( 'li', array(), Html::element( 'a', array(
@@ -408,18 +408,18 @@
409409 }
410410
411411 $link = null;
412 - if( $record[0]->af_needs_oversight ) {
413 - if( $can_delete ) {
 412+ if ( $record[0]->af_needs_oversight ) {
 413+ if ( $can_delete ) {
414414 $link = 'unoversight';
415415 } else {
416416 $link = 'oversighted';
417417 }
418 - } elseif( $can_hide ) {
 418+ } elseif ( $can_hide ) {
419419 # flag for oversight
420420 $link = 'oversight';
421421 }
422422
423 - if( $link ) {
 423+ if ( $link ) {
424424 $tools .= Html::rawElement( 'li', array(), Html::element( 'a', array(
425425 'id' => "articleFeedbackv5-$link-link-$id",
426426 'class' => "articleFeedbackv5-$link-link"
@@ -479,10 +479,10 @@
480480
481481 private function renderBucket4( $record ) {
482482 return $this->feedbackHead(
483 - 'articlefeedbackv5-form4-header',
484 - 'positive',
485 - $record[0]
486 - );
 483+ 'articlefeedbackv5-form4-header',
 484+ 'positive',
 485+ $record[0]
 486+ );
487487 }
488488
489489 private function renderBucket5( $record ) {
@@ -502,16 +502,16 @@
503503 }
504504 }
505505 $body .= "</ul>";
506 -
 506+
507507 $class = $total / $count >= 3 ? 'positive' : 'negative';
508508
509 - $head = $this->feedbackHead(
510 - 'articlefeedbackv5-form5-header',
511 - $class,
512 - $record[0]
 509+ $head = $this->feedbackHead(
 510+ 'articlefeedbackv5-form5-header',
 511+ $class,
 512+ $record[0]
513513 );
514514
515 - return $head.$body;
 515+ return $head . $body;
516516 }
517517
518518 private function renderBucket0( $record ) {
@@ -520,19 +520,19 @@
521521 }
522522
523523 private function renderNoBucket( $record ) {
524 - return $this->feedbackHead(
 524+ return $this->feedbackHead(
525525 'articlefeedbackv5-form-invalid',
526526 'negative',
527527 $record[0]
528 - );
 528+ );
529529 }
530530
531531 private function renderBucket6( $record ) {
532 - return $this->feedbackHead(
 532+ return $this->feedbackHead(
533533 'articlefeedbackv5-form-not-shown',
534534 'positive',
535535 $record[0]
536 - );
 536+ );
537537 }
538538
539539 private function renderComment( $text, $feedbackId ) {
@@ -548,10 +548,10 @@
549549 . htmlspecialchars( $short )
550550 . Html::closeElement( 'blockquote' );
551551
552 - // If the short string is the same size as the
553 - // original, no truncation happened, so no
 552+ // If the short string is the same size as the
 553+ // original, no truncation happened, so no
554554 // controls are needed.
555 - if( $short != $text ) {
 555+ if ( $short != $text ) {
556556 // Show the short text, with the 'show more' control.
557557 $rv .= Html::openElement( 'blockquote',
558558 array(
@@ -570,18 +570,18 @@
571571 }
572572
573573 private function feedbackHead( $message, $class, $record, $extra = '' ) {
574 - $gender = ''; #?
 574+ $gender = ''; # ?
575575 $name = htmlspecialchars( $record->user_name );
576576 $link = $record->af_user_id ? "User:$name" : "Special:Contributions/$name";
577577
578 - return Html::openElement( 'h3', array(
 578+ return Html::openElement( 'h3', array(
579579 'class' => $class
580580 ) )
581 - . Linker::link( Title::newFromText( $link ), $name )
 581+ . Linker::link( Title::newFromText( $link ), $name )
582582 . Html::element( 'span', array( 'class' => 'icon' ) )
583 - . Html::element( 'span',
584 - array( 'class' => 'result' ),
585 - wfMessage( $message, $gender, $extra )->escaped()
 583+ . Html::element( 'span',
 584+ array( 'class' => 'result' ),
 585+ wfMessage( $message, $gender, $extra )->escaped()
586586 )
587587 . Html::closeElement( 'h3' );
588588 }
Index: trunk/extensions/ArticleFeedbackv5/api/ApiArticleFeedbackv5Utils.php
@@ -153,7 +153,7 @@
154154 /**
155155 * Increments the per-page-per-filter count rollups used on the feedback
156156 * page.
157 - *
 157+ *
158158 * @param $pageId int the ID of the page (page.page_id)
159159 * @param $filterNames array values are names of filters to increment
160160 */
@@ -164,7 +164,7 @@
165165 /**
166166 * decrements the per-page-per-filter count rollups used on the feedback
167167 * page.
168 - *
 168+ *
169169 * @param $pageId int the ID of the page (page.page_id)
170170 * @param $filterNames array values are names of filters to decrement
171171 */
@@ -177,7 +177,7 @@
178178
179179 $dbw->begin();
180180
181 - foreach( $filters as $filter ) {
 181+ foreach ( $filters as $filter ) {
182182 $rows[] = array(
183183 'afc_page_id' => $pageId,
184184 'afc_filter_name' => $filter,
@@ -196,7 +196,7 @@
197197
198198 $value = $decrement ? 'afc_filter_count - 1' : 'afc_filter_count + 1';
199199
200 - foreach( $filters as $filter ) {
 200+ foreach ( $filters as $filter ) {
201201 # Update each row with the new count.
202202 $dbw->update(
203203 'aft_article_filter_count',

Comments

#Comment by Nikerabbit (talk | contribs)   07:23, 26 January 2012
+		. Html::element( 'span',
+			array( 'class' => 'result' ),
+			wfMessage( $message, $gender, $extra )->escaped()

When did that got added? That's double escaping.

#Comment by Reedy (talk | contribs)   15:08, 27 January 2012

Not the fault of this commit then

Status & tagging log