Index: trunk/extensions/CodeReview/ui/CodeRevisionView.php |
— | — | @@ -2,9 +2,6 @@ |
3 | 3 | |
4 | 4 | // Special:Code/MediaWiki/40696 |
5 | 5 | class CodeRevisionView extends CodeView { |
6 | | - |
7 | | - protected $showButtonsFormatReference = false, $showButtonsFormatSignoffs = false; |
8 | | - |
9 | 6 | /** |
10 | 7 | * @param string|CodeRepository $repo |
11 | 8 | * @param string|CodeRevision $rev |
— | — | @@ -51,8 +48,10 @@ |
52 | 49 | $this->mSelectedSignoffs = $wgRequest->getArray( 'wpSignoffs' ); |
53 | 50 | $this->mStrikeSignoffs = $wgRequest->getCheck( 'wpStrikeSignoffs' ) ? |
54 | 51 | $this->mSelectedSignoffs : array(); |
| 52 | + |
55 | 53 | $this->mAddReference = $wgRequest->getCheck( 'wpAddReferenceSubmit' ) ? |
56 | 54 | $wgRequest->getArray( 'wpAddReference', array() ) : array(); |
| 55 | + |
57 | 56 | $this->mRemoveReferences = $wgRequest->getCheck( 'wpRemoveReferences' ) ? |
58 | 57 | $wgRequest->getIntArray( 'wpReferences', array() ) : array(); |
59 | 58 | } |
— | — | @@ -457,14 +456,13 @@ |
458 | 457 | |
459 | 458 | /** |
460 | 459 | * Format the sign-offs table |
| 460 | + * @param $signOffs Array |
461 | 461 | * @param $showButtons bool Whether the buttons to strike and submit sign-offs should be shown |
462 | 462 | * @return string HTML |
463 | 463 | */ |
464 | 464 | 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 ); |
469 | 467 | |
470 | 468 | $header = ''; |
471 | 469 | if ( $showButtons ) { |
— | — | @@ -500,11 +498,14 @@ |
501 | 499 | return "<ul class='mw-codereview-changes'>$changes</ul>"; |
502 | 500 | } |
503 | 501 | |
| 502 | + /** |
| 503 | + * @param $references Array |
| 504 | + * @param $showButtons Bool |
| 505 | + * @return string |
| 506 | + */ |
504 | 507 | 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 ); |
509 | 510 | |
510 | 511 | $header = ''; |
511 | 512 | if ( $showButtons ) { |
— | — | @@ -521,9 +522,10 @@ |
522 | 523 | /** |
523 | 524 | * Format a single sign-off row. Helper function for formatSignoffs() |
524 | 525 | * @param $signoff CodeSignoff |
| 526 | + * @param $showButtons Bool |
525 | 527 | * @return string HTML |
526 | 528 | */ |
527 | | - protected function formatSignoffInline( $signoff ) { |
| 529 | + protected function formatSignoffInline( $signoff, $showButtons ) { |
528 | 530 | global $wgLang; |
529 | 531 | $user = $this->skin->userLink( $signoff->user, $signoff->userText ); |
530 | 532 | $flag = htmlspecialchars( $signoff->flag ); |
— | — | @@ -538,7 +540,7 @@ |
539 | 541 | } |
540 | 542 | |
541 | 543 | $ret = "<tr class='$class'>"; |
542 | | - if ( $this->showButtonsFormatSignoffs ) { |
| 544 | + if ( $showButtons ) { |
543 | 545 | $checkbox = Html::input( 'wpSignoffs[]', $signoff->getID(), 'checkbox' ); |
544 | 546 | $ret .= "<td>$checkbox</td>"; |
545 | 547 | } |
— | — | @@ -600,7 +602,7 @@ |
601 | 603 | return "<li>$line</li>"; |
602 | 604 | } |
603 | 605 | |
604 | | - protected function formatReferenceInline( $row ) { |
| 606 | + protected function formatReferenceInline( $row, $showButtons ) { |
605 | 607 | global $wgLang; |
606 | 608 | $rev = intval( $row->cr_id ); |
607 | 609 | $repo = $this->mRepo->getName(); |
— | — | @@ -613,7 +615,7 @@ |
614 | 616 | $author = $this->authorLink( $row->cr_author ); |
615 | 617 | |
616 | 618 | $ret = "<tr class='$css'>"; |
617 | | - if ( $this->showButtonsFormatReference ) { |
| 619 | + if ( $showButtons ) { |
618 | 620 | $checkbox = Html::input( 'wpReferences[]', $rev, 'checkbox' ); |
619 | 621 | $ret .= "<td>$checkbox</td>"; |
620 | 622 | } |