Index: trunk/phase3/includes/HistoryPage.php |
— | — | @@ -48,10 +48,10 @@ |
49 | 49 | */ |
50 | 50 | function preCacheMessages() { |
51 | 51 | // Precache various messages |
52 | | - if( !isset( $this->message ) ) { |
| 52 | + if ( !isset( $this->message ) ) { |
53 | 53 | $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' ) ); |
56 | 56 | } |
57 | 57 | } |
58 | 58 | } |
— | — | @@ -66,7 +66,7 @@ |
67 | 67 | /* |
68 | 68 | * Allow client caching. |
69 | 69 | */ |
70 | | - if( $wgOut->checkLastModified( $this->article->getTouched() ) ) |
| 70 | + if ( $wgOut->checkLastModified( $this->article->getTouched() ) ) |
71 | 71 | return; // Client cache fresh and headers sent, nothing more to do. |
72 | 72 | |
73 | 73 | wfProfileIn( __METHOD__ ); |
— | — | @@ -94,7 +94,7 @@ |
95 | 95 | $wgOut->setSubtitle( $logLink ); |
96 | 96 | |
97 | 97 | $feedType = $wgRequest->getVal( 'feed' ); |
98 | | - if( $feedType ) { |
| 98 | + if ( $feedType ) { |
99 | 99 | wfProfileOut( __METHOD__ ); |
100 | 100 | return $this->feed( $feedType ); |
101 | 101 | } |
— | — | @@ -102,7 +102,7 @@ |
103 | 103 | /* |
104 | 104 | * Fail if article doesn't exist. |
105 | 105 | */ |
106 | | - if( !$this->title->exists() ) { |
| 106 | + if ( !$this->title->exists() ) { |
107 | 107 | $wgOut->addWikiMsg( 'nohistory' ); |
108 | 108 | # show deletion/move log if there is an entry |
109 | 109 | LogEventsList::showLogExtract( |
— | — | @@ -131,7 +131,7 @@ |
132 | 132 | * Option to show only revisions that have been (partially) hidden via RevisionDelete |
133 | 133 | */ |
134 | 134 | if ( $wgRequest->getBool( 'deleted' ) ) { |
135 | | - $conds = array("rev_deleted != '0'"); |
| 135 | + $conds = array( "rev_deleted != '0'" ); |
136 | 136 | } else { |
137 | 137 | $conds = array(); |
138 | 138 | } |
— | — | @@ -183,24 +183,26 @@ |
184 | 184 | function fetchRevisions( $limit, $offset, $direction ) { |
185 | 185 | $dbr = wfGetDB( DB_SLAVE ); |
186 | 186 | |
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 | + } |
191 | 192 | |
192 | | - if( $offset ) |
193 | | - $offsets = array("rev_timestamp $oper '$offset'"); |
194 | | - else |
| 193 | + if ( $offset ) { |
| 194 | + $offsets = array( "rev_timestamp $oper '$offset'" ); |
| 195 | + } else { |
195 | 196 | $offsets = array(); |
| 197 | + } |
196 | 198 | |
197 | 199 | $page_id = $this->title->getArticleID(); |
198 | 200 | |
199 | 201 | return $dbr->select( 'revision', |
200 | 202 | Revision::selectFields(), |
201 | | - array_merge(array("rev_page=$page_id"), $offsets), |
| 203 | + array_merge( array( "rev_page=$page_id" ), $offsets ), |
202 | 204 | __METHOD__, |
203 | 205 | array( 'ORDER BY' => "rev_timestamp $dirs", |
204 | | - 'USE INDEX' => 'page_timestamp', 'LIMIT' => $limit) |
| 206 | + 'USE INDEX' => 'page_timestamp', 'LIMIT' => $limit ) |
205 | 207 | ); |
206 | 208 | } |
207 | 209 | |
— | — | @@ -211,7 +213,7 @@ |
212 | 214 | */ |
213 | 215 | function feed( $type ) { |
214 | 216 | global $wgFeedClasses, $wgRequest, $wgFeedLimit; |
215 | | - if( !FeedUtils::checkFeedOutput($type) ) { |
| 217 | + if ( !FeedUtils::checkFeedOutput( $type ) ) { |
216 | 218 | return; |
217 | 219 | } |
218 | 220 | |
— | — | @@ -225,14 +227,14 @@ |
226 | 228 | // Get a limit on number of feed entries. Provide a sane default |
227 | 229 | // of 10 if none is defined (but limit to $wgFeedLimit max) |
228 | 230 | $limit = $wgRequest->getInt( 'limit', 10 ); |
229 | | - if( $limit > $wgFeedLimit || $limit < 1 ) { |
| 231 | + if ( $limit > $wgFeedLimit || $limit < 1 ) { |
230 | 232 | $limit = 10; |
231 | 233 | } |
232 | | - $items = $this->fetchRevisions($limit, 0, HistoryPage::DIR_NEXT); |
| 234 | + $items = $this->fetchRevisions( $limit, 0, HistoryPage::DIR_NEXT ); |
233 | 235 | |
234 | 236 | $feed->outHeader(); |
235 | | - if( $items ) { |
236 | | - foreach( $items as $row ) { |
| 237 | + if ( $items ) { |
| 238 | + foreach ( $items as $row ) { |
237 | 239 | $feed->outItem( $this->feedItem( $row ) ); |
238 | 240 | } |
239 | 241 | } else { |
— | — | @@ -271,7 +273,7 @@ |
272 | 274 | $rev->getTimestamp(), |
273 | 275 | $rev->getComment() |
274 | 276 | ); |
275 | | - if( $rev->getComment() == '' ) { |
| 277 | + if ( $rev->getComment() == '' ) { |
276 | 278 | global $wgContLang; |
277 | 279 | $title = wfMsgForContent( 'history-feed-item-nocomment', |
278 | 280 | $rev->getUserText(), |
— | — | @@ -302,7 +304,7 @@ |
303 | 305 | public $lastRow = false, $counter, $historyPage, $title, $buttons, $conds; |
304 | 306 | protected $oldIdChecked; |
305 | 307 | |
306 | | - function __construct( $historyPage, $year='', $month='', $tagFilter = '', $conds = array() ) { |
| 308 | + function __construct( $historyPage, $year = '', $month = '', $tagFilter = '', $conds = array() ) { |
307 | 309 | parent::__construct(); |
308 | 310 | $this->historyPage = $historyPage; |
309 | 311 | $this->title = $this->historyPage->title; |
— | — | @@ -326,12 +328,12 @@ |
327 | 329 | |
328 | 330 | function getQueryInfo() { |
329 | 331 | $queryInfo = array( |
330 | | - 'tables' => array('revision'), |
| 332 | + 'tables' => array( 'revision' ), |
331 | 333 | 'fields' => Revision::selectFields(), |
332 | 334 | 'conds' => array_merge( |
333 | 335 | array( 'rev_page' => $this->historyPage->title->getArticleID() ), |
334 | 336 | $this->conds ), |
335 | | - 'options' => array( 'USE INDEX' => array('revision' => 'page_timestamp') ), |
| 337 | + 'options' => array( 'USE INDEX' => array( 'revision' => 'page_timestamp' ) ), |
336 | 338 | 'join_conds' => array( 'tag_summary' => array( 'LEFT JOIN', 'ts_rev_id=rev_id' ) ), |
337 | 339 | ); |
338 | 340 | ChangeTags::modifyDisplayQuery( |
— | — | @@ -351,8 +353,8 @@ |
352 | 354 | } |
353 | 355 | |
354 | 356 | 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 ); |
357 | 359 | $firstInList = $this->counter == 1; |
358 | 360 | $this->counter++; |
359 | 361 | $s = $this->historyLine( $this->lastRow, $row, |
— | — | @@ -381,16 +383,16 @@ |
382 | 384 | $s .= Html::hidden( 'title', $this->title->getPrefixedDbKey() ) . "\n"; |
383 | 385 | $s .= Html::hidden( 'action', 'historysubmit' ) . "\n"; |
384 | 386 | |
385 | | - $s .= '<div>' . $this->submitButton( wfMsg( 'compareselectedversions'), |
| 387 | + $s .= '<div>' . $this->submitButton( wfMsg( 'compareselectedversions' ), |
386 | 388 | array( 'class' => 'historysubmit' ) ) . "\n"; |
387 | | - |
| 389 | + |
388 | 390 | $this->buttons = '<div>'; |
389 | | - $this->buttons .= $this->submitButton( wfMsg( 'compareselectedversions'), |
| 391 | + $this->buttons .= $this->submitButton( wfMsg( 'compareselectedversions' ), |
390 | 392 | array( 'class' => 'historysubmit' ) |
391 | 393 | + $wgUser->getSkin()->tooltipAndAccessKeyAttribs( 'compareselectedversions' ) |
392 | 394 | ) . "\n"; |
393 | | - |
394 | | - if( $wgUser->isAllowed('deleterevision') ) { |
| 395 | + |
| 396 | + if ( $wgUser->isAllowed( 'deleterevision' ) ) { |
395 | 397 | $float = $wgContLang->alignEnd(); |
396 | 398 | # Note bug #20966, <button> is non-standard in IE<8 |
397 | 399 | $element = Html::element( 'button', |
— | — | @@ -406,7 +408,7 @@ |
407 | 409 | $s .= $element; |
408 | 410 | $this->buttons .= $element; |
409 | 411 | } |
410 | | - if( $wgUser->isAllowed( 'revisionmove' ) ) { |
| 412 | + if ( $wgUser->isAllowed( 'revisionmove' ) ) { |
411 | 413 | $float = $wgContLang->alignEnd(); |
412 | 414 | # Note bug #20966, <button> is non-standard in IE<8 |
413 | 415 | $element = Html::element( 'button', |
— | — | @@ -428,12 +430,12 @@ |
429 | 431 | } |
430 | 432 | |
431 | 433 | function getEndBody() { |
432 | | - if( $this->lastRow ) { |
| 434 | + if ( $this->lastRow ) { |
433 | 435 | $latest = $this->counter == 1 && $this->mIsFirst; |
434 | 436 | $firstInList = $this->counter == 1; |
435 | | - if( $this->mIsBackwards ) { |
| 437 | + if ( $this->mIsBackwards ) { |
436 | 438 | # Next row is unknown, but for UI reasons, probably exists if an offset has been specified |
437 | | - if( $this->mOffset == '' ) { |
| 439 | + if ( $this->mOffset == '' ) { |
438 | 440 | $next = null; |
439 | 441 | } else { |
440 | 442 | $next = 'unknown'; |
— | — | @@ -450,7 +452,7 @@ |
451 | 453 | } |
452 | 454 | $s .= "</ul>\n"; |
453 | 455 | # Add second buttons only if there is more than one rev |
454 | | - if( $this->getNumRows() > 2 ) { |
| 456 | + if ( $this->getNumRows() > 2 ) { |
455 | 457 | $s .= $this->buttons; |
456 | 458 | } |
457 | 459 | $s .= '</form>'; |
— | — | @@ -466,7 +468,7 @@ |
467 | 469 | */ |
468 | 470 | function submitButton( $message, $attributes = array() ) { |
469 | 471 | # Disable submit button if history has 1 revision only |
470 | | - if( $this->getNumRows() > 1 ) { |
| 472 | + if ( $this->getNumRows() > 1 ) { |
471 | 473 | return Xml::submitButton( $message , $attributes ); |
472 | 474 | } else { |
473 | 475 | return ''; |
— | — | @@ -507,30 +509,30 @@ |
508 | 510 | |
509 | 511 | $del = ''; |
510 | 512 | // Show checkboxes for each revision |
511 | | - if( $wgUser->isAllowed( 'deleterevision' ) || $wgUser->isAllowed( 'revisionmove' ) ) { |
| 513 | + if ( $wgUser->isAllowed( 'deleterevision' ) || $wgUser->isAllowed( 'revisionmove' ) ) { |
512 | 514 | // If revision was hidden from sysops, disable the checkbox |
513 | 515 | // 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' ) ) { |
515 | 517 | $del = Xml::check( 'deleterevisions', false, array( 'disabled' => 'disabled' ) ); |
516 | 518 | // Otherwise, enable the checkbox... |
517 | 519 | } else { |
518 | 520 | $del = Xml::check( 'showhiderevisions', false, |
519 | | - array( 'name' => 'ids['.$rev->getId().']' ) ); |
| 521 | + array( 'name' => 'ids[' . $rev->getId() . ']' ) ); |
520 | 522 | } |
521 | 523 | // User can only view deleted revisions... |
522 | | - } else if( $rev->getVisibility() && $wgUser->isAllowed( 'deletedhistory' ) ) { |
| 524 | + } else if ( $rev->getVisibility() && $wgUser->isAllowed( 'deletedhistory' ) ) { |
523 | 525 | // If revision was hidden from sysops, disable the link |
524 | | - if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) { |
| 526 | + if ( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) { |
525 | 527 | $cdel = $this->getSkin()->revDeleteLinkDisabled( false ); |
526 | 528 | // Otherwise, show the link... |
527 | 529 | } else { |
528 | 530 | $query = array( 'type' => 'revision', |
529 | | - 'target' => $this->title->getPrefixedDbkey(), 'ids' => $rev->getId() ); |
| 531 | + 'target' => $this->title->getPrefixedDbkey(), 'ids' => $rev->getId() ); |
530 | 532 | $del .= $this->getSkin()->revDeleteLink( $query, |
531 | 533 | $rev->isDeleted( Revision::DELETED_RESTRICTED ), false ); |
532 | 534 | } |
533 | 535 | } |
534 | | - if( $del ) { |
| 536 | + if ( $del ) { |
535 | 537 | $s .= " $del "; |
536 | 538 | } |
537 | 539 | |
— | — | @@ -538,30 +540,30 @@ |
539 | 541 | $s .= " <span class='history-user'>" . |
540 | 542 | $this->getSkin()->revUserTools( $rev, true ) . "</span>"; |
541 | 543 | |
542 | | - if( $rev->isMinor() ) { |
| 544 | + if ( $rev->isMinor() ) { |
543 | 545 | $s .= ' ' . ChangesList::flag( 'minor' ); |
544 | 546 | } |
545 | 547 | |
546 | | - if( !is_null( $size = $rev->getSize() ) && !$rev->isDeleted( Revision::DELETED_TEXT ) ) { |
| 548 | + if ( !is_null( $size = $rev->getSize() ) && !$rev->isDeleted( Revision::DELETED_TEXT ) ) { |
547 | 549 | $s .= ' ' . $this->getSkin()->formatRevisionSize( $size ); |
548 | 550 | } |
549 | 551 | |
550 | 552 | $s .= $this->getSkin()->revComment( $rev, false, true ); |
551 | 553 | |
552 | | - if( $notificationtimestamp && ($row->rev_timestamp >= $notificationtimestamp) ) { |
| 554 | + if ( $notificationtimestamp && ( $row->rev_timestamp >= $notificationtimestamp ) ) { |
553 | 555 | $s .= ' <span class="updatedmarker">' . wfMsgHtml( 'updatedmarker' ) . '</span>'; |
554 | 556 | } |
555 | 557 | |
556 | 558 | $tools = array(); |
557 | 559 | |
558 | 560 | # 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>'; |
563 | 565 | } |
564 | 566 | |
565 | | - if( $this->title->quickUserCan( 'edit' ) |
| 567 | + if ( $this->title->quickUserCan( 'edit' ) |
566 | 568 | && !$rev->isDeleted( Revision::DELETED_TEXT ) |
567 | 569 | && !$next->rev_deleted & Revision::DELETED_TEXT ) |
568 | 570 | { |
— | — | @@ -584,12 +586,12 @@ |
585 | 587 | } |
586 | 588 | } |
587 | 589 | |
588 | | - if( $tools ) { |
| 590 | + if ( $tools ) { |
589 | 591 | $s .= ' (' . $wgLang->pipeList( $tools ) . ')'; |
590 | 592 | } |
591 | 593 | |
592 | 594 | # Tags |
593 | | - list($tagSummary, $newClasses) = ChangeTags::formatSummaryRow( $row->ts_tags, 'history' ); |
| 595 | + list( $tagSummary, $newClasses ) = ChangeTags::formatSummaryRow( $row->ts_tags, 'history' ); |
594 | 596 | $classes = array_merge( $classes, $newClasses ); |
595 | 597 | $s .= " $tagSummary"; |
596 | 598 | |
— | — | @@ -611,7 +613,7 @@ |
612 | 614 | */ |
613 | 615 | function revLink( $rev ) { |
614 | 616 | global $wgLang; |
615 | | - $date = $wgLang->timeanddate( wfTimestamp(TS_MW, $rev->getTimestamp()), true ); |
| 617 | + $date = $wgLang->timeanddate( wfTimestamp( TS_MW, $rev->getTimestamp() ), true ); |
616 | 618 | $date = htmlspecialchars( $date ); |
617 | 619 | if ( $rev->userCan( Revision::DELETED_TEXT ) ) { |
618 | 620 | $link = $this->getSkin()->link( |
— | — | @@ -639,7 +641,7 @@ |
640 | 642 | */ |
641 | 643 | function curLink( $rev, $latest ) { |
642 | 644 | $cur = $this->historyPage->message['cur']; |
643 | | - if( $latest || !$rev->userCan( Revision::DELETED_TEXT ) ) { |
| 645 | + if ( $latest || !$rev->userCan( Revision::DELETED_TEXT ) ) { |
644 | 646 | return $cur; |
645 | 647 | } else { |
646 | 648 | return $this->getSkin()->link( |
— | — | @@ -665,11 +667,11 @@ |
666 | 668 | function lastLink( $prevRev, $next ) { |
667 | 669 | $last = $this->historyPage->message['last']; |
668 | 670 | # $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 ) ) { |
671 | 673 | # Probably no next row |
672 | 674 | return $last; |
673 | | - } elseif( $next === 'unknown' ) { |
| 675 | + } elseif ( $next === 'unknown' ) { |
674 | 676 | # Next row probably exists but is unknown, use an oldid=prev link |
675 | 677 | return $this->getSkin()->link( |
676 | 678 | $this->title, |
— | — | @@ -681,8 +683,8 @@ |
682 | 684 | ), |
683 | 685 | array( 'known', 'noclasses' ) |
684 | 686 | ); |
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 ) ) |
687 | 689 | { |
688 | 690 | return $last; |
689 | 691 | } else { |
— | — | @@ -708,11 +710,11 @@ |
709 | 711 | * @return String: HTML output for the radio buttons |
710 | 712 | */ |
711 | 713 | function diffButtons( $rev, $firstInList ) { |
712 | | - if( $this->getNumRows() > 1 ) { |
| 714 | + if ( $this->getNumRows() > 1 ) { |
713 | 715 | $id = $rev->getId(); |
714 | 716 | $radio = array( 'type' => 'radio', 'value' => $id ); |
715 | 717 | /** @todo: move title texts to javascript */ |
716 | | - if( $firstInList ) { |
| 718 | + if ( $firstInList ) { |
717 | 719 | $first = Xml::element( 'input', |
718 | 720 | array_merge( $radio, array( |
719 | 721 | 'style' => 'visibility:hidden', |
— | — | @@ -722,10 +724,10 @@ |
723 | 725 | $checkmark = array( 'checked' => 'checked' ); |
724 | 726 | } else { |
725 | 727 | # Check visibility of old revisions |
726 | | - if( !$rev->userCan( Revision::DELETED_TEXT ) ) { |
| 728 | + if ( !$rev->userCan( Revision::DELETED_TEXT ) ) { |
727 | 729 | $radio['disabled'] = 'disabled'; |
728 | 730 | $checkmark = array(); // We will check the next possible one |
729 | | - } else if( !$this->oldIdChecked ) { |
| 731 | + } else if ( !$this->oldIdChecked ) { |
730 | 732 | $checkmark = array( 'checked' => 'checked' ); |
731 | 733 | $this->oldIdChecked = $id; |
732 | 734 | } else { |