r82299 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r82298‎ | r82299 | r82300 >
Date:21:45, 16 February 2011
Author:reedy
Status:reverted
Tags:
Comment:
Followup r82146

Don't use class variables, use function parameters, in combination with array_walk instead of array_map
Modified paths:
  • /trunk/extensions/CodeReview/ui/CodeRevisionView.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/ui/CodeRevisionView.php
@@ -2,9 +2,6 @@
33
44 // Special:Code/MediaWiki/40696
55 class CodeRevisionView extends CodeView {
6 -
7 - protected $showButtonsFormatReference = false, $showButtonsFormatSignoffs = false;
8 -
96 /**
107 * @param string|CodeRepository $repo
118 * @param string|CodeRevision $rev
@@ -51,8 +48,10 @@
5249 $this->mSelectedSignoffs = $wgRequest->getArray( 'wpSignoffs' );
5350 $this->mStrikeSignoffs = $wgRequest->getCheck( 'wpStrikeSignoffs' ) ?
5451 $this->mSelectedSignoffs : array();
 52+
5553 $this->mAddReference = $wgRequest->getCheck( 'wpAddReferenceSubmit' ) ?
5654 $wgRequest->getArray( 'wpAddReference', array() ) : array();
 55+
5756 $this->mRemoveReferences = $wgRequest->getCheck( 'wpRemoveReferences' ) ?
5857 $wgRequest->getIntArray( 'wpReferences', array() ) : array();
5958 }
@@ -457,14 +456,13 @@
458457
459458 /**
460459 * Format the sign-offs table
 460+ * @param $signOffs Array
461461 * @param $showButtons bool Whether the buttons to strike and submit sign-offs should be shown
462462 * @return string HTML
463463 */
464464 protected function formatSignoffs( $signOffs, $showButtons ) {
465 - $this->showButtonsFormatSignoffs = $showButtons;
466 - $signoffs = implode( "\n",
467 - array_map( array( $this, 'formatSignoffInline' ), $signOffs )
468 - );
 465+ array_walk( $signOffs, array( $this, 'formatSignoffInline' ), $showButtons );
 466+ $signoffs = implode( "\n", $signOffs );
469467
470468 $header = '';
471469 if ( $showButtons ) {
@@ -500,11 +498,14 @@
501499 return "<ul class='mw-codereview-changes'>$changes</ul>";
502500 }
503501
 502+ /**
 503+ * @param $references Array
 504+ * @param $showButtons Bool
 505+ * @return string
 506+ */
504507 protected function formatReferences( $references, $showButtons ) {
505 - $this->showButtonsFormatReference = $showButtons;
506 - $refs = implode( "\n",
507 - array_map( array( $this, 'formatReferenceInline' ), $references )
508 - );
 508+ array_walk( $references, array( $this, 'formatReferenceInline' ), $showButtons );
 509+ $refs = implode( "\n", $references );
509510
510511 $header = '';
511512 if ( $showButtons ) {
@@ -521,9 +522,10 @@
522523 /**
523524 * Format a single sign-off row. Helper function for formatSignoffs()
524525 * @param $signoff CodeSignoff
 526+ * @param $showButtons Bool
525527 * @return string HTML
526528 */
527 - protected function formatSignoffInline( $signoff ) {
 529+ protected function formatSignoffInline( $signoff, $showButtons ) {
528530 global $wgLang;
529531 $user = $this->skin->userLink( $signoff->user, $signoff->userText );
530532 $flag = htmlspecialchars( $signoff->flag );
@@ -538,7 +540,7 @@
539541 }
540542
541543 $ret = "<tr class='$class'>";
542 - if ( $this->showButtonsFormatSignoffs ) {
 544+ if ( $showButtons ) {
543545 $checkbox = Html::input( 'wpSignoffs[]', $signoff->getID(), 'checkbox' );
544546 $ret .= "<td>$checkbox</td>";
545547 }
@@ -600,7 +602,7 @@
601603 return "<li>$line</li>";
602604 }
603605
604 - protected function formatReferenceInline( $row ) {
 606+ protected function formatReferenceInline( $row, $showButtons ) {
605607 global $wgLang;
606608 $rev = intval( $row->cr_id );
607609 $repo = $this->mRepo->getName();
@@ -613,7 +615,7 @@
614616 $author = $this->authorLink( $row->cr_author );
615617
616618 $ret = "<tr class='$css'>";
617 - if ( $this->showButtonsFormatReference ) {
 619+ if ( $showButtons ) {
618620 $checkbox = Html::input( 'wpReferences[]', $rev, 'checkbox' );
619621 $ret .= "<td>$checkbox</td>";
620622 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r82302Revert r82299...reedy21:58, 16 February 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r82146* (bug 27407) Hide "Sign offs" section when empty for users without the coder...reedy21:17, 14 February 2011

Status & tagging log