r47774 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r47773‎ | r47774 | r47775 >
Date:00:26, 25 February 2009
Author:aaron
Status:ok
Tags:
Comment:
* Show batch form only as needed
* Other minor cleanup
Modified paths:
  • /trunk/extensions/CodeReview/CodeRevisionListView.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/CodeRevisionListView.php
@@ -24,7 +24,7 @@
2525
2626 // Check for batch change requests.
2727 $editToken = $wgRequest->getVal( 'wpBatchChangeEditToken' );
28 - if ( $wgUser->matchEditToken( $editToken ) ) {
 28+ if( $wgRequest->wasPosted() && $wgUser->matchEditToken( $editToken ) ) {
2929 $this->doBatchChange();
3030 return;
3131 }
@@ -32,8 +32,9 @@
3333 $this->showForm();
3434 $pager = $this->getPager();
3535
36 - // Batch change interface.
37 - $changeInterface = $this->buildBatchInterface( $pager );
 36+ // Build batch change interface as needed
 37+ $this->batchForm = $wgUser->isAllowed('codereview-set-status') ||
 38+ $wgUser->isAllowed('codereview-add-tag');
3839
3940 $wgOut->addHTML(
4041 $pager->getNavigationBar() .
@@ -43,7 +44,7 @@
4445 ) .
4546 $pager->getBody() .
4647 $pager->getNavigationBar() .
47 - $changeInterface .
 48+ ( $this->batchForm ? $this->buildBatchInterface( $pager ) : "" ).
4849 Xml::closeElement( 'form' )
4950 );
5051 }
@@ -94,7 +95,7 @@
9596 $wgOut->redirect( $this->getPager()->getTitle()->getFullURL( $fields ) );
9697 }
9798
98 - function buildBatchInterface( $pager ) {
 99+ protected function buildBatchInterface( $pager ) {
99100 global $wgUser;
100101
101102 $changeInterface = '';
@@ -110,11 +111,12 @@
111112 );
112113 }
113114
114 - if ($wgUser->isAllowed( 'codereview-add-tag' ) ) {
115 - $changeFields['code-batch-tags'] =
116 - CodeRevisionView::addTagForm( '', '' );
 115+ if( $wgUser->isAllowed( 'codereview-add-tag' ) ) {
 116+ $changeFields['code-batch-tags'] = CodeRevisionView::addTagForm( '', '' );
117117 }
118118
 119+ if( !count($changeFields) ) return ''; // nothing to do here
 120+
119121 $changeInterface = Xml::fieldset( wfMsg('codereview-batch-title'),
120122 Xml::buildForm( $changeFields, 'codereview-batch-submit' ) );
121123
@@ -209,8 +211,7 @@
210212 }
211213
212214 function getFieldNames() {
213 - return array(
214 - 'selectforchange' => wfMsg( 'code-field-select' ),
 215+ $fields = array(
215216 $this->getDefaultSort() => wfMsg( 'code-field-id' ),
216217 'cr_status' => wfMsg( 'code-field-status' ),
217218 'comments' => wfMsg( 'code-field-comments' ),
@@ -219,6 +220,11 @@
220221 'cr_author' => wfMsg( 'code-field-author' ),
221222 'cr_timestamp' => wfMsg( 'code-field-timestamp' ),
222223 );
 224+ # Only show checkboxen as needed
 225+ if( !empty($this->mView->batchForm) ) {
 226+ $fields = array('selectforchange' => wfMsg('code-field-select') ) + $fields;
 227+ }
 228+ return $fields;
223229 }
224230
225231 function formatValue( $name, $value ) {} // unused
@@ -228,8 +234,7 @@
229235 switch( $name ) {
230236 case 'selectforchange':
231237 $sort = $this->getDefaultSort();
232 - return Xml::check( "wpRevisionSelected[]", false,
233 - array( 'value' => $row->$sort ) );
 238+ return Xml::check( "wpRevisionSelected[]", false, array( 'value' => $row->$sort ) );
234239 case 'cp_rev_id':
235240 case 'cr_id':
236241 return $this->mView->mSkin->link(

Status & tagging log