r76699 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76698‎ | r76699 | r76700 >
Date:19:51, 15 November 2010
Author:hashar
Status:ok
Tags:
Comment:
Stylize. Add a couple braces around if/else statements.
Modified paths:
  • /trunk/phase3/includes/HistoryPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/HistoryPage.php
@@ -48,10 +48,10 @@
4949 */
5050 function preCacheMessages() {
5151 // Precache various messages
52 - if( !isset( $this->message ) ) {
 52+ if ( !isset( $this->message ) ) {
5353 $msgs = array( 'cur', 'last', 'pipe-separator' );
54 - foreach( $msgs as $msg ) {
55 - $this->message[$msg] = wfMsgExt( $msg, array( 'escapenoentities') );
 54+ foreach ( $msgs as $msg ) {
 55+ $this->message[$msg] = wfMsgExt( $msg, array( 'escapenoentities' ) );
5656 }
5757 }
5858 }
@@ -66,7 +66,7 @@
6767 /*
6868 * Allow client caching.
6969 */
70 - if( $wgOut->checkLastModified( $this->article->getTouched() ) )
 70+ if ( $wgOut->checkLastModified( $this->article->getTouched() ) )
7171 return; // Client cache fresh and headers sent, nothing more to do.
7272
7373 wfProfileIn( __METHOD__ );
@@ -94,7 +94,7 @@
9595 $wgOut->setSubtitle( $logLink );
9696
9797 $feedType = $wgRequest->getVal( 'feed' );
98 - if( $feedType ) {
 98+ if ( $feedType ) {
9999 wfProfileOut( __METHOD__ );
100100 return $this->feed( $feedType );
101101 }
@@ -102,7 +102,7 @@
103103 /*
104104 * Fail if article doesn't exist.
105105 */
106 - if( !$this->title->exists() ) {
 106+ if ( !$this->title->exists() ) {
107107 $wgOut->addWikiMsg( 'nohistory' );
108108 # show deletion/move log if there is an entry
109109 LogEventsList::showLogExtract(
@@ -131,7 +131,7 @@
132132 * Option to show only revisions that have been (partially) hidden via RevisionDelete
133133 */
134134 if ( $wgRequest->getBool( 'deleted' ) ) {
135 - $conds = array("rev_deleted != '0'");
 135+ $conds = array( "rev_deleted != '0'" );
136136 } else {
137137 $conds = array();
138138 }
@@ -183,24 +183,26 @@
184184 function fetchRevisions( $limit, $offset, $direction ) {
185185 $dbr = wfGetDB( DB_SLAVE );
186186
187 - if( $direction == HistoryPage::DIR_PREV )
188 - list($dirs, $oper) = array("ASC", ">=");
189 - else /* $direction == HistoryPage::DIR_NEXT */
190 - list($dirs, $oper) = array("DESC", "<=");
 187+ if ( $direction == HistoryPage::DIR_PREV ) {
 188+ list( $dirs, $oper ) = array( "ASC", ">=" );
 189+ } else { /* $direction == HistoryPage::DIR_NEXT */
 190+ list( $dirs, $oper ) = array( "DESC", "<=" );
 191+ }
191192
192 - if( $offset )
193 - $offsets = array("rev_timestamp $oper '$offset'");
194 - else
 193+ if ( $offset ) {
 194+ $offsets = array( "rev_timestamp $oper '$offset'" );
 195+ } else {
195196 $offsets = array();
 197+ }
196198
197199 $page_id = $this->title->getArticleID();
198200
199201 return $dbr->select( 'revision',
200202 Revision::selectFields(),
201 - array_merge(array("rev_page=$page_id"), $offsets),
 203+ array_merge( array( "rev_page=$page_id" ), $offsets ),
202204 __METHOD__,
203205 array( 'ORDER BY' => "rev_timestamp $dirs",
204 - 'USE INDEX' => 'page_timestamp', 'LIMIT' => $limit)
 206+ 'USE INDEX' => 'page_timestamp', 'LIMIT' => $limit )
205207 );
206208 }
207209
@@ -211,7 +213,7 @@
212214 */
213215 function feed( $type ) {
214216 global $wgFeedClasses, $wgRequest, $wgFeedLimit;
215 - if( !FeedUtils::checkFeedOutput($type) ) {
 217+ if ( !FeedUtils::checkFeedOutput( $type ) ) {
216218 return;
217219 }
218220
@@ -225,14 +227,14 @@
226228 // Get a limit on number of feed entries. Provide a sane default
227229 // of 10 if none is defined (but limit to $wgFeedLimit max)
228230 $limit = $wgRequest->getInt( 'limit', 10 );
229 - if( $limit > $wgFeedLimit || $limit < 1 ) {
 231+ if ( $limit > $wgFeedLimit || $limit < 1 ) {
230232 $limit = 10;
231233 }
232 - $items = $this->fetchRevisions($limit, 0, HistoryPage::DIR_NEXT);
 234+ $items = $this->fetchRevisions( $limit, 0, HistoryPage::DIR_NEXT );
233235
234236 $feed->outHeader();
235 - if( $items ) {
236 - foreach( $items as $row ) {
 237+ if ( $items ) {
 238+ foreach ( $items as $row ) {
237239 $feed->outItem( $this->feedItem( $row ) );
238240 }
239241 } else {
@@ -271,7 +273,7 @@
272274 $rev->getTimestamp(),
273275 $rev->getComment()
274276 );
275 - if( $rev->getComment() == '' ) {
 277+ if ( $rev->getComment() == '' ) {
276278 global $wgContLang;
277279 $title = wfMsgForContent( 'history-feed-item-nocomment',
278280 $rev->getUserText(),
@@ -302,7 +304,7 @@
303305 public $lastRow = false, $counter, $historyPage, $title, $buttons, $conds;
304306 protected $oldIdChecked;
305307
306 - function __construct( $historyPage, $year='', $month='', $tagFilter = '', $conds = array() ) {
 308+ function __construct( $historyPage, $year = '', $month = '', $tagFilter = '', $conds = array() ) {
307309 parent::__construct();
308310 $this->historyPage = $historyPage;
309311 $this->title = $this->historyPage->title;
@@ -326,12 +328,12 @@
327329
328330 function getQueryInfo() {
329331 $queryInfo = array(
330 - 'tables' => array('revision'),
 332+ 'tables' => array( 'revision' ),
331333 'fields' => Revision::selectFields(),
332334 'conds' => array_merge(
333335 array( 'rev_page' => $this->historyPage->title->getArticleID() ),
334336 $this->conds ),
335 - 'options' => array( 'USE INDEX' => array('revision' => 'page_timestamp') ),
 337+ 'options' => array( 'USE INDEX' => array( 'revision' => 'page_timestamp' ) ),
336338 'join_conds' => array( 'tag_summary' => array( 'LEFT JOIN', 'ts_rev_id=rev_id' ) ),
337339 );
338340 ChangeTags::modifyDisplayQuery(
@@ -351,8 +353,8 @@
352354 }
353355
354356 function formatRow( $row ) {
355 - if( $this->lastRow ) {
356 - $latest = ($this->counter == 1 && $this->mIsFirst);
 357+ if ( $this->lastRow ) {
 358+ $latest = ( $this->counter == 1 && $this->mIsFirst );
357359 $firstInList = $this->counter == 1;
358360 $this->counter++;
359361 $s = $this->historyLine( $this->lastRow, $row,
@@ -381,16 +383,16 @@
382384 $s .= Html::hidden( 'title', $this->title->getPrefixedDbKey() ) . "\n";
383385 $s .= Html::hidden( 'action', 'historysubmit' ) . "\n";
384386
385 - $s .= '<div>' . $this->submitButton( wfMsg( 'compareselectedversions'),
 387+ $s .= '<div>' . $this->submitButton( wfMsg( 'compareselectedversions' ),
386388 array( 'class' => 'historysubmit' ) ) . "\n";
387 -
 389+
388390 $this->buttons = '<div>';
389 - $this->buttons .= $this->submitButton( wfMsg( 'compareselectedversions'),
 391+ $this->buttons .= $this->submitButton( wfMsg( 'compareselectedversions' ),
390392 array( 'class' => 'historysubmit' )
391393 + $wgUser->getSkin()->tooltipAndAccessKeyAttribs( 'compareselectedversions' )
392394 ) . "\n";
393 -
394 - if( $wgUser->isAllowed('deleterevision') ) {
 395+
 396+ if ( $wgUser->isAllowed( 'deleterevision' ) ) {
395397 $float = $wgContLang->alignEnd();
396398 # Note bug #20966, <button> is non-standard in IE<8
397399 $element = Html::element( 'button',
@@ -406,7 +408,7 @@
407409 $s .= $element;
408410 $this->buttons .= $element;
409411 }
410 - if( $wgUser->isAllowed( 'revisionmove' ) ) {
 412+ if ( $wgUser->isAllowed( 'revisionmove' ) ) {
411413 $float = $wgContLang->alignEnd();
412414 # Note bug #20966, <button> is non-standard in IE<8
413415 $element = Html::element( 'button',
@@ -428,12 +430,12 @@
429431 }
430432
431433 function getEndBody() {
432 - if( $this->lastRow ) {
 434+ if ( $this->lastRow ) {
433435 $latest = $this->counter == 1 && $this->mIsFirst;
434436 $firstInList = $this->counter == 1;
435 - if( $this->mIsBackwards ) {
 437+ if ( $this->mIsBackwards ) {
436438 # Next row is unknown, but for UI reasons, probably exists if an offset has been specified
437 - if( $this->mOffset == '' ) {
 439+ if ( $this->mOffset == '' ) {
438440 $next = null;
439441 } else {
440442 $next = 'unknown';
@@ -450,7 +452,7 @@
451453 }
452454 $s .= "</ul>\n";
453455 # Add second buttons only if there is more than one rev
454 - if( $this->getNumRows() > 2 ) {
 456+ if ( $this->getNumRows() > 2 ) {
455457 $s .= $this->buttons;
456458 }
457459 $s .= '</form>';
@@ -466,7 +468,7 @@
467469 */
468470 function submitButton( $message, $attributes = array() ) {
469471 # Disable submit button if history has 1 revision only
470 - if( $this->getNumRows() > 1 ) {
 472+ if ( $this->getNumRows() > 1 ) {
471473 return Xml::submitButton( $message , $attributes );
472474 } else {
473475 return '';
@@ -507,30 +509,30 @@
508510
509511 $del = '';
510512 // Show checkboxes for each revision
511 - if( $wgUser->isAllowed( 'deleterevision' ) || $wgUser->isAllowed( 'revisionmove' ) ) {
 513+ if ( $wgUser->isAllowed( 'deleterevision' ) || $wgUser->isAllowed( 'revisionmove' ) ) {
512514 // If revision was hidden from sysops, disable the checkbox
513515 // However, if the user has revisionmove rights, we cannot disable the checkbox
514 - if( !$rev->userCan( Revision::DELETED_RESTRICTED ) && !$wgUser->isAllowed( 'revisionmove' ) ) {
 516+ if ( !$rev->userCan( Revision::DELETED_RESTRICTED ) && !$wgUser->isAllowed( 'revisionmove' ) ) {
515517 $del = Xml::check( 'deleterevisions', false, array( 'disabled' => 'disabled' ) );
516518 // Otherwise, enable the checkbox...
517519 } else {
518520 $del = Xml::check( 'showhiderevisions', false,
519 - array( 'name' => 'ids['.$rev->getId().']' ) );
 521+ array( 'name' => 'ids[' . $rev->getId() . ']' ) );
520522 }
521523 // User can only view deleted revisions...
522 - } else if( $rev->getVisibility() && $wgUser->isAllowed( 'deletedhistory' ) ) {
 524+ } else if ( $rev->getVisibility() && $wgUser->isAllowed( 'deletedhistory' ) ) {
523525 // If revision was hidden from sysops, disable the link
524 - if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) {
 526+ if ( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) {
525527 $cdel = $this->getSkin()->revDeleteLinkDisabled( false );
526528 // Otherwise, show the link...
527529 } else {
528530 $query = array( 'type' => 'revision',
529 - 'target' => $this->title->getPrefixedDbkey(), 'ids' => $rev->getId() );
 531+ 'target' => $this->title->getPrefixedDbkey(), 'ids' => $rev->getId() );
530532 $del .= $this->getSkin()->revDeleteLink( $query,
531533 $rev->isDeleted( Revision::DELETED_RESTRICTED ), false );
532534 }
533535 }
534 - if( $del ) {
 536+ if ( $del ) {
535537 $s .= " $del ";
536538 }
537539
@@ -538,30 +540,30 @@
539541 $s .= " <span class='history-user'>" .
540542 $this->getSkin()->revUserTools( $rev, true ) . "</span>";
541543
542 - if( $rev->isMinor() ) {
 544+ if ( $rev->isMinor() ) {
543545 $s .= ' ' . ChangesList::flag( 'minor' );
544546 }
545547
546 - if( !is_null( $size = $rev->getSize() ) && !$rev->isDeleted( Revision::DELETED_TEXT ) ) {
 548+ if ( !is_null( $size = $rev->getSize() ) && !$rev->isDeleted( Revision::DELETED_TEXT ) ) {
547549 $s .= ' ' . $this->getSkin()->formatRevisionSize( $size );
548550 }
549551
550552 $s .= $this->getSkin()->revComment( $rev, false, true );
551553
552 - if( $notificationtimestamp && ($row->rev_timestamp >= $notificationtimestamp) ) {
 554+ if ( $notificationtimestamp && ( $row->rev_timestamp >= $notificationtimestamp ) ) {
553555 $s .= ' <span class="updatedmarker">' . wfMsgHtml( 'updatedmarker' ) . '</span>';
554556 }
555557
556558 $tools = array();
557559
558560 # Rollback and undo links
559 - if( !is_null( $next ) && is_object( $next ) ) {
560 - if( $latest && $this->title->userCan( 'rollback' ) && $this->title->userCan( 'edit' ) ) {
561 - $tools[] = '<span class="mw-rollback-link">'.
562 - $this->getSkin()->buildRollbackLink( $rev ).'</span>';
 561+ if ( !is_null( $next ) && is_object( $next ) ) {
 562+ if ( $latest && $this->title->userCan( 'rollback' ) && $this->title->userCan( 'edit' ) ) {
 563+ $tools[] = '<span class="mw-rollback-link">' .
 564+ $this->getSkin()->buildRollbackLink( $rev ) . '</span>';
563565 }
564566
565 - if( $this->title->quickUserCan( 'edit' )
 567+ if ( $this->title->quickUserCan( 'edit' )
566568 && !$rev->isDeleted( Revision::DELETED_TEXT )
567569 && !$next->rev_deleted & Revision::DELETED_TEXT )
568570 {
@@ -584,12 +586,12 @@
585587 }
586588 }
587589
588 - if( $tools ) {
 590+ if ( $tools ) {
589591 $s .= ' (' . $wgLang->pipeList( $tools ) . ')';
590592 }
591593
592594 # Tags
593 - list($tagSummary, $newClasses) = ChangeTags::formatSummaryRow( $row->ts_tags, 'history' );
 595+ list( $tagSummary, $newClasses ) = ChangeTags::formatSummaryRow( $row->ts_tags, 'history' );
594596 $classes = array_merge( $classes, $newClasses );
595597 $s .= " $tagSummary";
596598
@@ -611,7 +613,7 @@
612614 */
613615 function revLink( $rev ) {
614616 global $wgLang;
615 - $date = $wgLang->timeanddate( wfTimestamp(TS_MW, $rev->getTimestamp()), true );
 617+ $date = $wgLang->timeanddate( wfTimestamp( TS_MW, $rev->getTimestamp() ), true );
616618 $date = htmlspecialchars( $date );
617619 if ( $rev->userCan( Revision::DELETED_TEXT ) ) {
618620 $link = $this->getSkin()->link(
@@ -639,7 +641,7 @@
640642 */
641643 function curLink( $rev, $latest ) {
642644 $cur = $this->historyPage->message['cur'];
643 - if( $latest || !$rev->userCan( Revision::DELETED_TEXT ) ) {
 645+ if ( $latest || !$rev->userCan( Revision::DELETED_TEXT ) ) {
644646 return $cur;
645647 } else {
646648 return $this->getSkin()->link(
@@ -665,11 +667,11 @@
666668 function lastLink( $prevRev, $next ) {
667669 $last = $this->historyPage->message['last'];
668670 # $next may either be a Row, null, or "unkown"
669 - $nextRev = is_object($next) ? new Revision( $next ) : $next;
670 - if( is_null($next) ) {
 671+ $nextRev = is_object( $next ) ? new Revision( $next ) : $next;
 672+ if ( is_null( $next ) ) {
671673 # Probably no next row
672674 return $last;
673 - } elseif( $next === 'unknown' ) {
 675+ } elseif ( $next === 'unknown' ) {
674676 # Next row probably exists but is unknown, use an oldid=prev link
675677 return $this->getSkin()->link(
676678 $this->title,
@@ -681,8 +683,8 @@
682684 ),
683685 array( 'known', 'noclasses' )
684686 );
685 - } elseif( !$prevRev->userCan(Revision::DELETED_TEXT)
686 - || !$nextRev->userCan(Revision::DELETED_TEXT) )
 687+ } elseif ( !$prevRev->userCan( Revision::DELETED_TEXT )
 688+ || !$nextRev->userCan( Revision::DELETED_TEXT ) )
687689 {
688690 return $last;
689691 } else {
@@ -708,11 +710,11 @@
709711 * @return String: HTML output for the radio buttons
710712 */
711713 function diffButtons( $rev, $firstInList ) {
712 - if( $this->getNumRows() > 1 ) {
 714+ if ( $this->getNumRows() > 1 ) {
713715 $id = $rev->getId();
714716 $radio = array( 'type' => 'radio', 'value' => $id );
715717 /** @todo: move title texts to javascript */
716 - if( $firstInList ) {
 718+ if ( $firstInList ) {
717719 $first = Xml::element( 'input',
718720 array_merge( $radio, array(
719721 'style' => 'visibility:hidden',
@@ -722,10 +724,10 @@
723725 $checkmark = array( 'checked' => 'checked' );
724726 } else {
725727 # Check visibility of old revisions
726 - if( !$rev->userCan( Revision::DELETED_TEXT ) ) {
 728+ if ( !$rev->userCan( Revision::DELETED_TEXT ) ) {
727729 $radio['disabled'] = 'disabled';
728730 $checkmark = array(); // We will check the next possible one
729 - } else if( !$this->oldIdChecked ) {
 731+ } else if ( !$this->oldIdChecked ) {
730732 $checkmark = array( 'checked' => 'checked' );
731733 $this->oldIdChecked = $id;
732734 } else {

Status & tagging log