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