Followup r61181, put @return nothing back on history(). Some people like it.
[lhc/web/wiklou.git] / includes / HistoryPage.php
1 <?php
2 /**
3 * Page history
4 *
5 * Split off from Article.php and Skin.php, 2003-12-22
6 * @file
7 */
8
9 /**
10 * This class handles printing the history page for an article. In order to
11 * be efficient, it uses timestamps rather than offsets for paging, to avoid
12 * costly LIMIT,offset queries.
13 *
14 * Construct it by passing in an Article, and call $h->history() to print the
15 * history.
16 *
17 */
18 class HistoryPage {
19 const DIR_PREV = 0;
20 const DIR_NEXT = 1;
21
22 var $article, $title, $skin;
23
24 /**
25 * Construct a new HistoryPage.
26 *
27 * @param $article Article
28 */
29 function __construct( $article ) {
30 global $wgUser;
31 $this->article = $article;
32 $this->title = $article->getTitle();
33 $this->skin = $wgUser->getSkin();
34 $this->preCacheMessages();
35 }
36
37 function getArticle() {
38 return $this->article;
39 }
40
41 function getTitle() {
42 return $this->title;
43 }
44
45 /**
46 * As we use the same small set of messages in various methods and that
47 * they are called often, we call them once and save them in $this->message
48 */
49 function preCacheMessages() {
50 // Precache various messages
51 if( !isset( $this->message ) ) {
52 $msgs = array( 'cur', 'last', 'pipe-separator' );
53 foreach( $msgs as $msg ) {
54 $this->message[$msg] = wfMsgExt( $msg, array( 'escapenoentities') );
55 }
56 }
57 }
58
59 /**
60 * Print the history page for an article.
61 * @return nothing
62 */
63 function history() {
64 global $wgOut, $wgRequest, $wgScript;
65
66 /*
67 * Allow client caching.
68 */
69 if( $wgOut->checkLastModified( $this->article->getTouched() ) )
70 return; // Client cache fresh and headers sent, nothing more to do.
71
72 wfProfileIn( __METHOD__ );
73
74 /*
75 * Setup page variables.
76 */
77 $wgOut->setPageTitle( wfMsg( 'history-title', $this->title->getPrefixedText() ) );
78 $wgOut->setPageTitleActionText( wfMsg( 'history_short' ) );
79 $wgOut->setArticleFlag( false );
80 $wgOut->setArticleRelated( true );
81 $wgOut->setRobotPolicy( 'noindex,nofollow' );
82 $wgOut->setSyndicated( true );
83 $wgOut->setFeedAppendQuery( 'action=history' );
84 $wgOut->addScriptFile( 'history.js' );
85
86 $logPage = SpecialPage::getTitleFor( 'Log' );
87 $logLink = $this->skin->link(
88 $logPage,
89 wfMsgHtml( 'viewpagelogs' ),
90 array(),
91 array( 'page' => $this->title->getPrefixedText() ),
92 array( 'known', 'noclasses' )
93 );
94 $wgOut->setSubtitle( $logLink );
95
96 $feedType = $wgRequest->getVal( 'feed' );
97 if( $feedType ) {
98 wfProfileOut( __METHOD__ );
99 return $this->feed( $feedType );
100 }
101
102 /*
103 * Fail if article doesn't exist.
104 */
105 if( !$this->title->exists() ) {
106 $wgOut->addWikiMsg( 'nohistory' );
107 # show deletion/move log if there is an entry
108 LogEventsList::showLogExtract(
109 $wgOut,
110 array( 'delete', 'move' ),
111 $this->title->getPrefixedText(),
112 '',
113 array( 'lim' => 10,
114 'conds' => array( "log_action != 'revision'" ),
115 'showIfEmpty' => false,
116 'msgKey' => array( 'moveddeleted-notice' )
117 )
118 );
119 wfProfileOut( __METHOD__ );
120 return;
121 }
122
123 /**
124 * Add date selector to quickly get to a certain time
125 */
126 $year = $wgRequest->getInt( 'year' );
127 $month = $wgRequest->getInt( 'month' );
128 $tagFilter = $wgRequest->getVal( 'tagfilter' );
129 $tagSelector = ChangeTags::buildTagFilterSelector( $tagFilter );
130 /**
131 * Option to show only revisions that have been (partially) hidden via RevisionDelete
132 * Note that this can run a *long* time if there are many revisions to look at.
133 * We use "isBigDeletion" to determine if the history is too big to go through.
134 * Additionally, only users with 'deleterevision' right can filter for deleted edits.
135 */
136 if ( $this->title->userCan( 'deleterevision' ) && ( !$this->article->isBigDeletion() || $this->title->userCan( 'bigdelete' ) ) ) {
137 $conds = ( $wgRequest->getBool( 'deleted' ) ) ? array("rev_deleted != '0'") : array();
138 $checkDeleted = Xml::checkLabel( wfMsg( 'history-show-deleted' ), 'deleted', '', $wgRequest->getBool( 'deleted' ) ) . "\n";
139 }
140 else { # Don't filter and don't add the checkbox for filtering
141 $conds = array();
142 $checkDeleted = '';
143 }
144
145 $action = htmlspecialchars( $wgScript );
146 $wgOut->addHTML(
147 "<form action=\"$action\" method=\"get\" id=\"mw-history-searchform\">" .
148 Xml::fieldset(
149 wfMsg( 'history-fieldset-title' ),
150 false,
151 array( 'id' => 'mw-history-search' )
152 ) .
153 Xml::hidden( 'title', $this->title->getPrefixedDBKey() ) . "\n" .
154 Xml::hidden( 'action', 'history' ) . "\n" .
155 Xml::dateMenu( $year, $month ) . '&nbsp;' .
156 ( $tagSelector ? ( implode( '&nbsp;', $tagSelector ) . '&nbsp;' ) : '' ) .
157 $checkDeleted .
158 Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "\n" .
159 '</fieldset></form>'
160 );
161
162 wfRunHooks( 'PageHistoryBeforeList', array( &$this->article ) );
163
164 /**
165 * Do the list
166 */
167 $pager = new HistoryPager( $this, $year, $month, $tagFilter, $conds );
168 $wgOut->addHTML(
169 $pager->getNavigationBar() .
170 $pager->getBody() .
171 $pager->getNavigationBar()
172 );
173
174 wfProfileOut( __METHOD__ );
175 }
176
177 /**
178 * Fetch an array of revisions, specified by a given limit, offset and
179 * direction. This is now only used by the feeds. It was previously
180 * used by the main UI but that's now handled by the pager.
181 *
182 * @param $limit Integer: the limit number of revisions to get
183 * @param $offset Integer
184 * @param $direction Integer: either HistoryPage::DIR_PREV or HistoryPage::DIR_NEXT
185 * @return ResultWrapper
186 */
187 function fetchRevisions( $limit, $offset, $direction ) {
188 $dbr = wfGetDB( DB_SLAVE );
189
190 if( $direction == HistoryPage::DIR_PREV )
191 list($dirs, $oper) = array("ASC", ">=");
192 else /* $direction == HistoryPage::DIR_NEXT */
193 list($dirs, $oper) = array("DESC", "<=");
194
195 if( $offset )
196 $offsets = array("rev_timestamp $oper '$offset'");
197 else
198 $offsets = array();
199
200 $page_id = $this->title->getArticleID();
201
202 return $dbr->select( 'revision',
203 Revision::selectFields(),
204 array_merge(array("rev_page=$page_id"), $offsets),
205 __METHOD__,
206 array( 'ORDER BY' => "rev_timestamp $dirs",
207 'USE INDEX' => 'page_timestamp', 'LIMIT' => $limit)
208 );
209 }
210
211 /**
212 * Output a subscription feed listing recent edits to this page.
213 *
214 * @param $type String: feed type
215 */
216 function feed( $type ) {
217 global $wgFeedClasses, $wgRequest, $wgFeedLimit;
218 if( !FeedUtils::checkFeedOutput($type) ) {
219 return;
220 }
221
222 $feed = new $wgFeedClasses[$type](
223 $this->title->getPrefixedText() . ' - ' .
224 wfMsgForContent( 'history-feed-title' ),
225 wfMsgForContent( 'history-feed-description' ),
226 $this->title->getFullUrl( 'action=history' )
227 );
228
229 // Get a limit on number of feed entries. Provide a sane default
230 // of 10 if none is defined (but limit to $wgFeedLimit max)
231 $limit = $wgRequest->getInt( 'limit', 10 );
232 if( $limit > $wgFeedLimit || $limit < 1 ) {
233 $limit = 10;
234 }
235 $items = $this->fetchRevisions($limit, 0, HistoryPage::DIR_NEXT);
236
237 $feed->outHeader();
238 if( $items ) {
239 foreach( $items as $row ) {
240 $feed->outItem( $this->feedItem( $row ) );
241 }
242 } else {
243 $feed->outItem( $this->feedEmpty() );
244 }
245 $feed->outFooter();
246 }
247
248 function feedEmpty() {
249 global $wgOut;
250 return new FeedItem(
251 wfMsgForContent( 'nohistory' ),
252 $wgOut->parse( wfMsgForContent( 'history-feed-empty' ) ),
253 $this->title->getFullUrl(),
254 wfTimestamp( TS_MW ),
255 '',
256 $this->title->getTalkPage()->getFullUrl()
257 );
258 }
259
260 /**
261 * Generate a FeedItem object from a given revision table row
262 * Borrows Recent Changes' feed generation functions for formatting;
263 * includes a diff to the previous revision (if any).
264 *
265 * @param $row Object: database row
266 * @return FeedItem
267 */
268 function feedItem( $row ) {
269 $rev = new Revision( $row );
270 $rev->setTitle( $this->title );
271 $text = FeedUtils::formatDiffRow(
272 $this->title,
273 $this->title->getPreviousRevisionID( $rev->getId() ),
274 $rev->getId(),
275 $rev->getTimestamp(),
276 $rev->getComment()
277 );
278 if( $rev->getComment() == '' ) {
279 global $wgContLang;
280 $title = wfMsgForContent( 'history-feed-item-nocomment',
281 $rev->getUserText(),
282 $wgContLang->timeanddate( $rev->getTimestamp() ),
283 $wgContLang->date( $rev->getTimestamp() ),
284 $wgContLang->time( $rev->getTimestamp() )
285 );
286 } else {
287 $title = $rev->getUserText() .
288 wfMsgForContent( 'colon-separator' ) .
289 FeedItem::stripComment( $rev->getComment() );
290 }
291 return new FeedItem(
292 $title,
293 $text,
294 $this->title->getFullUrl( 'diff=' . $rev->getId() . '&oldid=prev' ),
295 $rev->getTimestamp(),
296 $rev->getUserText(),
297 $this->title->getTalkPage()->getFullUrl()
298 );
299 }
300 }
301
302 /**
303 * @ingroup Pager
304 */
305 class HistoryPager extends ReverseChronologicalPager {
306 public $lastRow = false, $counter, $historyPage, $title, $buttons, $conds;
307 protected $oldIdChecked;
308
309 function __construct( $historyPage, $year='', $month='', $tagFilter = '', $conds = array() ) {
310 parent::__construct();
311 $this->historyPage = $historyPage;
312 $this->title = $this->historyPage->title;
313 $this->tagFilter = $tagFilter;
314 $this->getDateCond( $year, $month );
315 $this->conds = $conds;
316 }
317
318 // For hook compatibility...
319 function getArticle() {
320 return $this->historyPage->getArticle();
321 }
322
323 function getQueryInfo() {
324 $queryInfo = array(
325 'tables' => array('revision'),
326 'fields' => Revision::selectFields(),
327 'conds' => array_merge( array('rev_page' => $this->historyPage->title->getArticleID() ), $this->conds ),
328 'options' => array( 'USE INDEX' => array('revision' => 'page_timestamp') ),
329 'join_conds' => array( 'tag_summary' => array( 'LEFT JOIN', 'ts_rev_id=rev_id' ) ),
330 );
331 ChangeTags::modifyDisplayQuery(
332 $queryInfo['tables'],
333 $queryInfo['fields'],
334 $queryInfo['conds'],
335 $queryInfo['join_conds'],
336 $queryInfo['options'],
337 $this->tagFilter
338 );
339 wfRunHooks( 'PageHistoryPager::getQueryInfo', array( &$this, &$queryInfo ) );
340 return $queryInfo;
341 }
342
343 function getIndexField() {
344 return 'rev_timestamp';
345 }
346
347 function formatRow( $row ) {
348 if( $this->lastRow ) {
349 $latest = ($this->counter == 1 && $this->mIsFirst);
350 $firstInList = $this->counter == 1;
351 $s = $this->historyLine( $this->lastRow, $row, $this->counter++,
352 $this->title->getNotificationTimestamp(), $latest, $firstInList );
353 } else {
354 $s = '';
355 }
356 $this->lastRow = $row;
357 return $s;
358 }
359
360 /**
361 * Creates begin of history list with a submit button
362 *
363 * @return string HTML output
364 */
365 function getStartBody() {
366 global $wgScript, $wgUser, $wgOut, $wgContLang;
367 $this->lastRow = false;
368 $this->counter = 1;
369 $this->oldIdChecked = 0;
370
371 $wgOut->wrapWikiMsg( "<div class='mw-history-legend'>\n$1</div>", 'histlegend' );
372 $s = Xml::openElement( 'form', array( 'action' => $wgScript,
373 'id' => 'mw-history-compare' ) ) . "\n";
374 $s .= Xml::hidden( 'title', $this->title->getPrefixedDbKey() ) . "\n";
375 $s .= Xml::hidden( 'action', 'historysubmit' ) . "\n";
376
377 $this->buttons = '<div>';
378 if( $wgUser->isAllowed('deleterevision') ) {
379 $float = $wgContLang->alignEnd();
380 # Note bug #20966, <button> is non-standard in IE<8
381 $this->buttons .= Xml::element( 'button',
382 array(
383 'type' => 'submit',
384 'name' => 'revisiondelete',
385 'value' => '1',
386 'style' => "float: $float;",
387 'class' => 'mw-history-revisiondelete-button',
388 ),
389 wfMsg( 'showhideselectedversions' )
390 ) . "\n";
391 }
392 $this->buttons .= $this->submitButton( wfMsg( 'compareselectedversions'),
393 array(
394 'class' => 'historysubmit',
395 'accesskey' => wfMsg( 'accesskey-compareselectedversions' ),
396 'title' => wfMsg( 'tooltip-compareselectedversions' ),
397 )
398 ) . "\n";
399 $this->buttons .= '</div>';
400 $s .= $this->buttons . '<ul id="pagehistory">' . "\n";
401 return $s;
402 }
403
404 function getEndBody() {
405 if( $this->lastRow ) {
406 $latest = $this->counter == 1 && $this->mIsFirst;
407 $firstInList = $this->counter == 1;
408 if( $this->mIsBackwards ) {
409 # Next row is unknown, but for UI reasons, probably exists if an offset has been specified
410 if( $this->mOffset == '' ) {
411 $next = null;
412 } else {
413 $next = 'unknown';
414 }
415 } else {
416 # The next row is the past-the-end row
417 $next = $this->mPastTheEndRow;
418 }
419 $s = $this->historyLine( $this->lastRow, $next, $this->counter++,
420 $this->title->getNotificationTimestamp(), $latest, $firstInList );
421 } else {
422 $s = '';
423 }
424 $s .= "</ul>\n";
425 # Add second buttons only if there is more than one rev
426 if( $this->getNumRows() > 2 ) {
427 $s .= $this->buttons;
428 }
429 $s .= '</form>';
430 return $s;
431 }
432
433 /**
434 * Creates a submit button
435 *
436 * @param $message String: text of the submit button, will be escaped
437 * @param $attributes Array: attributes
438 * @return String: HTML output for the submit button
439 */
440 function submitButton( $message, $attributes = array() ) {
441 # Disable submit button if history has 1 revision only
442 if( $this->getNumRows() > 1 ) {
443 return Xml::submitButton( $message , $attributes );
444 } else {
445 return '';
446 }
447 }
448
449 /**
450 * Returns a row from the history printout.
451 *
452 * @todo document some more, and maybe clean up the code (some params redundant?)
453 *
454 * @param $row Object: the database row corresponding to the previous line.
455 * @param $next Mixed: the database row corresponding to the next line.
456 * @param $counter Integer: apparently a counter of what row number we're at, counted from the top row = 1.
457 * @param $notificationtimestamp
458 * @param $latest Boolean: whether this row corresponds to the page's latest revision.
459 * @param $firstInList Boolean: whether this row corresponds to the first displayed on this history page.
460 * @return String: HTML output for the row
461 */
462 function historyLine( $row, $next, $counter = '', $notificationtimestamp = false,
463 $latest = false, $firstInList = false )
464 {
465 global $wgUser, $wgLang;
466 $rev = new Revision( $row );
467 $rev->setTitle( $this->title );
468
469 $curlink = $this->curLink( $rev, $latest );
470 $lastlink = $this->lastLink( $rev, $next, $counter );
471 $diffButtons = $this->diffButtons( $rev, $firstInList, $counter );
472 $histLinks = Html::rawElement(
473 'span',
474 array( 'class' => 'mw-history-histlinks' ),
475 '(' . $curlink . $this->historyPage->message['pipe-separator'] . $lastlink . ') '
476 );
477 $s = $histLinks . $diffButtons;
478
479 $link = $this->revLink( $rev );
480 $classes = array();
481
482 $del = '';
483 // User can delete revisions...
484 if( $wgUser->isAllowed( 'deleterevision' ) ) {
485 // If revision was hidden from sysops, disable the checkbox
486 if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) {
487 $del = Xml::check( 'deleterevisions', false, array( 'disabled' => 'disabled' ) );
488 // Otherwise, enable the checkbox...
489 } else {
490 $del = Xml::check( 'showhiderevisions', false, array( 'name' => 'ids['.$rev->getId().']' ) );
491 }
492 // User can only view deleted revisions...
493 } else if( $rev->getVisibility() && $wgUser->isAllowed( 'deletedhistory' ) ) {
494 // If revision was hidden from sysops, disable the link
495 if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) {
496 $cdel = $this->getSkin()->revDeleteLinkDisabled( false );
497 // Otherwise, show the link...
498 } else {
499 $query = array( 'type' => 'revision',
500 'target' => $this->title->getPrefixedDbkey(), 'ids' => $rev->getId() );
501 $del .= $this->getSkin()->revDeleteLink( $query,
502 $rev->isDeleted( Revision::DELETED_RESTRICTED ), false );
503 }
504 }
505 if( $del ) $s .= " $del ";
506
507 $s .= " $link";
508 $s .= " <span class='history-user'>" . $this->getSkin()->revUserTools( $rev, true ) . "</span>";
509
510 if( $rev->isMinor() ) {
511 $s .= ' ' . ChangesList::flag( 'minor' );
512 }
513
514 if( !is_null( $size = $rev->getSize() ) && !$rev->isDeleted( Revision::DELETED_TEXT ) ) {
515 $s .= ' ' . $this->getSkin()->formatRevisionSize( $size );
516 }
517
518 $s .= $this->getSkin()->revComment( $rev, false, true );
519
520 if( $notificationtimestamp && ($row->rev_timestamp >= $notificationtimestamp) ) {
521 $s .= ' <span class="updatedmarker">' . wfMsgHtml( 'updatedmarker' ) . '</span>';
522 }
523
524 $tools = array();
525
526 # Rollback and undo links
527 if( !is_null( $next ) && is_object( $next ) ) {
528 if( $latest && $this->title->userCan( 'rollback' ) && $this->title->userCan( 'edit' ) ) {
529 $tools[] = '<span class="mw-rollback-link">'.
530 $this->getSkin()->buildRollbackLink( $rev ).'</span>';
531 }
532
533 if( $this->title->quickUserCan( 'edit' )
534 && !$rev->isDeleted( Revision::DELETED_TEXT )
535 && !$next->rev_deleted & Revision::DELETED_TEXT )
536 {
537 # Create undo tooltip for the first (=latest) line only
538 $undoTooltip = $latest
539 ? array( 'title' => wfMsg( 'tooltip-undo' ) )
540 : array();
541 $undolink = $this->getSkin()->link(
542 $this->title,
543 wfMsgHtml( 'editundo' ),
544 $undoTooltip,
545 array(
546 'action' => 'edit',
547 'undoafter' => $next->rev_id,
548 'undo' => $rev->getId()
549 ),
550 array( 'known', 'noclasses' )
551 );
552 $tools[] = "<span class=\"mw-history-undo\">{$undolink}</span>";
553 }
554 }
555
556 if( $tools ) {
557 $s .= ' (' . $wgLang->pipeList( $tools ) . ')';
558 }
559
560 # Tags
561 list($tagSummary, $newClasses) = ChangeTags::formatSummaryRow( $row->ts_tags, 'history' );
562 $classes = array_merge( $classes, $newClasses );
563 $s .= " $tagSummary";
564
565 wfRunHooks( 'PageHistoryLineEnding', array( $this, &$row , &$s, &$classes ) );
566
567 $attribs = array();
568 if ( $classes ) {
569 $attribs['class'] = implode( ' ', $classes );
570 }
571
572 return Xml::tags( 'li', $attribs, $s ) . "\n";
573 }
574
575 /**
576 * Create a link to view this revision of the page
577 *
578 * @param $rev Revision
579 * @return String
580 */
581 function revLink( $rev ) {
582 global $wgLang;
583 $date = $wgLang->timeanddate( wfTimestamp(TS_MW, $rev->getTimestamp()), true );
584 $date = htmlspecialchars( $date );
585 if( !$rev->isDeleted( Revision::DELETED_TEXT ) ) {
586 $link = $this->getSkin()->link(
587 $this->title,
588 $date,
589 array(),
590 array( 'oldid' => $rev->getId() ),
591 array( 'known', 'noclasses' )
592 );
593 } else {
594 $link = "<span class=\"history-deleted\">$date</span>";
595 }
596 return $link;
597 }
598
599 /**
600 * Create a diff-to-current link for this revision for this page
601 *
602 * @param $rev Revision
603 * @param $latest Boolean: this is the latest revision of the page?
604 * @return String
605 */
606 function curLink( $rev, $latest ) {
607 $cur = $this->historyPage->message['cur'];
608 if( $latest || !$rev->userCan( Revision::DELETED_TEXT ) ) {
609 return $cur;
610 } else {
611 return $this->getSkin()->link(
612 $this->title,
613 $cur,
614 array(),
615 array(
616 'diff' => $this->title->getLatestRevID(),
617 'oldid' => $rev->getId()
618 ),
619 array( 'known', 'noclasses' )
620 );
621 }
622 }
623
624 /**
625 * Create a diff-to-previous link for this revision for this page.
626 *
627 * @param $prevRev Revision: the previous revision
628 * @param $next Mixed: the newer revision
629 * @param $counter Integer: what row on the history list this is
630 * @return String
631 */
632 function lastLink( $prevRev, $next, $counter ) {
633 $last = $this->historyPage->message['last'];
634 # $next may either be a Row, null, or "unkown"
635 $nextRev = is_object($next) ? new Revision( $next ) : $next;
636 if( is_null($next) ) {
637 # Probably no next row
638 return $last;
639 } elseif( $next === 'unknown' ) {
640 # Next row probably exists but is unknown, use an oldid=prev link
641 return $this->getSkin()->link(
642 $this->title,
643 $last,
644 array(),
645 array(
646 'diff' => $prevRev->getId(),
647 'oldid' => 'prev'
648 ),
649 array( 'known', 'noclasses' )
650 );
651 } elseif( !$prevRev->userCan(Revision::DELETED_TEXT) || !$nextRev->userCan(Revision::DELETED_TEXT) ) {
652 return $last;
653 } else {
654 return $this->getSkin()->link(
655 $this->title,
656 $last,
657 array(),
658 array(
659 'diff' => $prevRev->getId(),
660 'oldid' => $next->rev_id
661 ),
662 array( 'known', 'noclasses' )
663 );
664 }
665 }
666
667 /**
668 * Create radio buttons for page history
669 *
670 * @param $rev Revision object
671 * @param $firstInList Boolean: is this version the first one?
672 * @param $counter Integer: a counter of what row number we're at, counted from the top row = 1.
673 * @return String: HTML output for the radio buttons
674 */
675 function diffButtons( $rev, $firstInList, $counter ) {
676 if( $this->getNumRows() > 1 ) {
677 $id = $rev->getId();
678 $radio = array( 'type' => 'radio', 'value' => $id );
679 /** @todo: move title texts to javascript */
680 if( $firstInList ) {
681 $first = Xml::element( 'input',
682 array_merge( $radio, array(
683 'style' => 'visibility:hidden',
684 'name' => 'oldid',
685 'id' => 'mw-oldid-null' ) )
686 );
687 $checkmark = array( 'checked' => 'checked' );
688 } else {
689 # Check visibility of old revisions
690 if( !$rev->userCan( Revision::DELETED_TEXT ) ) {
691 $radio['disabled'] = 'disabled';
692 $checkmark = array(); // We will check the next possible one
693 } else if( $counter == 2 || !$this->oldIdChecked ) {
694 $checkmark = array( 'checked' => 'checked' );
695 $this->oldIdChecked = $id;
696 } else {
697 $checkmark = array();
698 }
699 $first = Xml::element( 'input',
700 array_merge( $radio, $checkmark, array(
701 'name' => 'oldid',
702 'id' => "mw-oldid-$id" ) ) );
703 $checkmark = array();
704 }
705 $second = Xml::element( 'input',
706 array_merge( $radio, $checkmark, array(
707 'name' => 'diff',
708 'id' => "mw-diff-$id" ) ) );
709 return $first . $second;
710 } else {
711 return '';
712 }
713 }
714 }
715
716 /**
717 * Backwards-compatibility aliases
718 */
719 class PageHistory extends HistoryPage {}
720 class PageHistoryPager extends HistoryPager {}