Strip # from IDs, IE doesn't seem to like them
[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' )
137 && ( !$this->article->isBigDeletion() || $this->title->userCan( 'bigdelete' ) ) )
138 {
139 $conds = ( $wgRequest->getBool( 'deleted' ) )
140 ? array("rev_deleted != '0'")
141 : array();
142 $checkDeleted = Xml::checkLabel( wfMsg( 'history-show-deleted' ),
143 'deleted', 'mw-show-deleted-only', $wgRequest->getBool( 'deleted' ) ) . "\n";
144 }
145 else { # Don't filter and don't add the checkbox for filtering
146 $conds = array();
147 $checkDeleted = '';
148 }
149
150 $action = htmlspecialchars( $wgScript );
151 $wgOut->addHTML(
152 "<form action=\"$action\" method=\"get\" id=\"mw-history-searchform\">" .
153 Xml::fieldset(
154 wfMsg( 'history-fieldset-title' ),
155 false,
156 array( 'id' => 'mw-history-search' )
157 ) .
158 Xml::hidden( 'title', $this->title->getPrefixedDBKey() ) . "\n" .
159 Xml::hidden( 'action', 'history' ) . "\n" .
160 Xml::dateMenu( $year, $month ) . '&nbsp;' .
161 ( $tagSelector ? ( implode( '&nbsp;', $tagSelector ) . '&nbsp;' ) : '' ) .
162 $checkDeleted .
163 Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "\n" .
164 '</fieldset></form>'
165 );
166
167 wfRunHooks( 'PageHistoryBeforeList', array( &$this->article ) );
168
169 /**
170 * Do the list
171 */
172 $pager = new HistoryPager( $this, $year, $month, $tagFilter, $conds );
173 $wgOut->addHTML(
174 $pager->getNavigationBar() .
175 $pager->getBody() .
176 $pager->getNavigationBar()
177 );
178
179 wfProfileOut( __METHOD__ );
180 }
181
182 /**
183 * Fetch an array of revisions, specified by a given limit, offset and
184 * direction. This is now only used by the feeds. It was previously
185 * used by the main UI but that's now handled by the pager.
186 *
187 * @param $limit Integer: the limit number of revisions to get
188 * @param $offset Integer
189 * @param $direction Integer: either HistoryPage::DIR_PREV or HistoryPage::DIR_NEXT
190 * @return ResultWrapper
191 */
192 function fetchRevisions( $limit, $offset, $direction ) {
193 $dbr = wfGetDB( DB_SLAVE );
194
195 if( $direction == HistoryPage::DIR_PREV )
196 list($dirs, $oper) = array("ASC", ">=");
197 else /* $direction == HistoryPage::DIR_NEXT */
198 list($dirs, $oper) = array("DESC", "<=");
199
200 if( $offset )
201 $offsets = array("rev_timestamp $oper '$offset'");
202 else
203 $offsets = array();
204
205 $page_id = $this->title->getArticleID();
206
207 return $dbr->select( 'revision',
208 Revision::selectFields(),
209 array_merge(array("rev_page=$page_id"), $offsets),
210 __METHOD__,
211 array( 'ORDER BY' => "rev_timestamp $dirs",
212 'USE INDEX' => 'page_timestamp', 'LIMIT' => $limit)
213 );
214 }
215
216 /**
217 * Output a subscription feed listing recent edits to this page.
218 *
219 * @param $type String: feed type
220 */
221 function feed( $type ) {
222 global $wgFeedClasses, $wgRequest, $wgFeedLimit;
223 if( !FeedUtils::checkFeedOutput($type) ) {
224 return;
225 }
226
227 $feed = new $wgFeedClasses[$type](
228 $this->title->getPrefixedText() . ' - ' .
229 wfMsgForContent( 'history-feed-title' ),
230 wfMsgForContent( 'history-feed-description' ),
231 $this->title->getFullUrl( 'action=history' )
232 );
233
234 // Get a limit on number of feed entries. Provide a sane default
235 // of 10 if none is defined (but limit to $wgFeedLimit max)
236 $limit = $wgRequest->getInt( 'limit', 10 );
237 if( $limit > $wgFeedLimit || $limit < 1 ) {
238 $limit = 10;
239 }
240 $items = $this->fetchRevisions($limit, 0, HistoryPage::DIR_NEXT);
241
242 $feed->outHeader();
243 if( $items ) {
244 foreach( $items as $row ) {
245 $feed->outItem( $this->feedItem( $row ) );
246 }
247 } else {
248 $feed->outItem( $this->feedEmpty() );
249 }
250 $feed->outFooter();
251 }
252
253 function feedEmpty() {
254 global $wgOut;
255 return new FeedItem(
256 wfMsgForContent( 'nohistory' ),
257 $wgOut->parse( wfMsgForContent( 'history-feed-empty' ) ),
258 $this->title->getFullUrl(),
259 wfTimestamp( TS_MW ),
260 '',
261 $this->title->getTalkPage()->getFullUrl()
262 );
263 }
264
265 /**
266 * Generate a FeedItem object from a given revision table row
267 * Borrows Recent Changes' feed generation functions for formatting;
268 * includes a diff to the previous revision (if any).
269 *
270 * @param $row Object: database row
271 * @return FeedItem
272 */
273 function feedItem( $row ) {
274 $rev = new Revision( $row );
275 $rev->setTitle( $this->title );
276 $text = FeedUtils::formatDiffRow(
277 $this->title,
278 $this->title->getPreviousRevisionID( $rev->getId() ),
279 $rev->getId(),
280 $rev->getTimestamp(),
281 $rev->getComment()
282 );
283 if( $rev->getComment() == '' ) {
284 global $wgContLang;
285 $title = wfMsgForContent( 'history-feed-item-nocomment',
286 $rev->getUserText(),
287 $wgContLang->timeanddate( $rev->getTimestamp() ),
288 $wgContLang->date( $rev->getTimestamp() ),
289 $wgContLang->time( $rev->getTimestamp() )
290 );
291 } else {
292 $title = $rev->getUserText() .
293 wfMsgForContent( 'colon-separator' ) .
294 FeedItem::stripComment( $rev->getComment() );
295 }
296 return new FeedItem(
297 $title,
298 $text,
299 $this->title->getFullUrl( 'diff=' . $rev->getId() . '&oldid=prev' ),
300 $rev->getTimestamp(),
301 $rev->getUserText(),
302 $this->title->getTalkPage()->getFullUrl()
303 );
304 }
305 }
306
307 /**
308 * @ingroup Pager
309 */
310 class HistoryPager extends ReverseChronologicalPager {
311 public $lastRow = false, $counter, $historyPage, $title, $buttons, $conds;
312 protected $oldIdChecked;
313
314 function __construct( $historyPage, $year='', $month='', $tagFilter = '', $conds = array() ) {
315 parent::__construct();
316 $this->historyPage = $historyPage;
317 $this->title = $this->historyPage->title;
318 $this->tagFilter = $tagFilter;
319 $this->getDateCond( $year, $month );
320 $this->conds = $conds;
321 }
322
323 // For hook compatibility...
324 function getArticle() {
325 return $this->historyPage->getArticle();
326 }
327
328 function getQueryInfo() {
329 $queryInfo = array(
330 'tables' => array('revision'),
331 'fields' => Revision::selectFields(),
332 'conds' => array_merge(
333 array( 'rev_page' => $this->historyPage->title->getArticleID() ),
334 $this->conds ),
335 'options' => array( 'USE INDEX' => array('revision' => 'page_timestamp') ),
336 'join_conds' => array( 'tag_summary' => array( 'LEFT JOIN', 'ts_rev_id=rev_id' ) ),
337 );
338 ChangeTags::modifyDisplayQuery(
339 $queryInfo['tables'],
340 $queryInfo['fields'],
341 $queryInfo['conds'],
342 $queryInfo['join_conds'],
343 $queryInfo['options'],
344 $this->tagFilter
345 );
346 wfRunHooks( 'PageHistoryPager::getQueryInfo', array( &$this, &$queryInfo ) );
347 return $queryInfo;
348 }
349
350 function getIndexField() {
351 return 'rev_timestamp';
352 }
353
354 function formatRow( $row ) {
355 if( $this->lastRow ) {
356 $latest = ($this->counter == 1 && $this->mIsFirst);
357 $firstInList = $this->counter == 1;
358 $s = $this->historyLine( $this->lastRow, $row, $this->counter++,
359 $this->title->getNotificationTimestamp(), $latest, $firstInList );
360 } else {
361 $s = '';
362 }
363 $this->lastRow = $row;
364 return $s;
365 }
366
367 /**
368 * Creates begin of history list with a submit button
369 *
370 * @return string HTML output
371 */
372 function getStartBody() {
373 global $wgScript, $wgUser, $wgOut, $wgContLang;
374 $this->lastRow = false;
375 $this->counter = 1;
376 $this->oldIdChecked = 0;
377
378 $wgOut->wrapWikiMsg( "<div class='mw-history-legend'>\n$1</div>", 'histlegend' );
379 $s = Xml::openElement( 'form', array( 'action' => $wgScript,
380 'id' => 'mw-history-compare' ) ) . "\n";
381 $s .= Xml::hidden( 'title', $this->title->getPrefixedDbKey() ) . "\n";
382 $s .= Xml::hidden( 'action', 'historysubmit' ) . "\n";
383
384 $this->buttons = '<div>';
385 if( $wgUser->isAllowed('deleterevision') ) {
386 $float = $wgContLang->alignEnd();
387 # Note bug #20966, <button> is non-standard in IE<8
388 $this->buttons .= Xml::element( 'button',
389 array(
390 'type' => 'submit',
391 'name' => 'revisiondelete',
392 'value' => '1',
393 'style' => "float: $float;",
394 'class' => 'mw-history-revisiondelete-button',
395 ),
396 wfMsg( 'showhideselectedversions' )
397 ) . "\n";
398 }
399 $this->buttons .= $this->submitButton( wfMsg( 'compareselectedversions'),
400 array(
401 'class' => 'historysubmit',
402 'accesskey' => wfMsg( 'accesskey-compareselectedversions' ),
403 'title' => wfMsg( 'tooltip-compareselectedversions' ),
404 )
405 ) . "\n";
406 $this->buttons .= '</div>';
407 $s .= $this->buttons . '<ul id="pagehistory">' . "\n";
408 return $s;
409 }
410
411 function getEndBody() {
412 if( $this->lastRow ) {
413 $latest = $this->counter == 1 && $this->mIsFirst;
414 $firstInList = $this->counter == 1;
415 if( $this->mIsBackwards ) {
416 # Next row is unknown, but for UI reasons, probably exists if an offset has been specified
417 if( $this->mOffset == '' ) {
418 $next = null;
419 } else {
420 $next = 'unknown';
421 }
422 } else {
423 # The next row is the past-the-end row
424 $next = $this->mPastTheEndRow;
425 }
426 $s = $this->historyLine( $this->lastRow, $next, $this->counter++,
427 $this->title->getNotificationTimestamp(), $latest, $firstInList );
428 } else {
429 $s = '';
430 }
431 $s .= "</ul>\n";
432 # Add second buttons only if there is more than one rev
433 if( $this->getNumRows() > 2 ) {
434 $s .= $this->buttons;
435 }
436 $s .= '</form>';
437 return $s;
438 }
439
440 /**
441 * Creates a submit button
442 *
443 * @param $message String: text of the submit button, will be escaped
444 * @param $attributes Array: attributes
445 * @return String: HTML output for the submit button
446 */
447 function submitButton( $message, $attributes = array() ) {
448 # Disable submit button if history has 1 revision only
449 if( $this->getNumRows() > 1 ) {
450 return Xml::submitButton( $message , $attributes );
451 } else {
452 return '';
453 }
454 }
455
456 /**
457 * Returns a row from the history printout.
458 *
459 * @todo document some more, and maybe clean up the code (some params redundant?)
460 *
461 * @param $row Object: the database row corresponding to the previous line.
462 * @param $next Mixed: the database row corresponding to the next line.
463 * @param $counter Integer: apparently a counter of what row number we're at, counted from the top row = 1.
464 * @param $notificationtimestamp
465 * @param $latest Boolean: whether this row corresponds to the page's latest revision.
466 * @param $firstInList Boolean: whether this row corresponds to the first displayed on this history page.
467 * @return String: HTML output for the row
468 */
469 function historyLine( $row, $next, $counter = '', $notificationtimestamp = false,
470 $latest = false, $firstInList = false )
471 {
472 global $wgUser, $wgLang;
473 $rev = new Revision( $row );
474 $rev->setTitle( $this->title );
475
476 $curlink = $this->curLink( $rev, $latest );
477 $lastlink = $this->lastLink( $rev, $next, $counter );
478 $diffButtons = $this->diffButtons( $rev, $firstInList, $counter );
479 $histLinks = Html::rawElement(
480 'span',
481 array( 'class' => 'mw-history-histlinks' ),
482 '(' . $curlink . $this->historyPage->message['pipe-separator'] . $lastlink . ') '
483 );
484 $s = $histLinks . $diffButtons;
485
486 $link = $this->revLink( $rev );
487 $classes = array();
488
489 $del = '';
490 // User can delete revisions...
491 if( $wgUser->isAllowed( 'deleterevision' ) ) {
492 // If revision was hidden from sysops, disable the checkbox
493 if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) {
494 $del = Xml::check( 'deleterevisions', false, array( 'disabled' => 'disabled' ) );
495 // Otherwise, enable the checkbox...
496 } else {
497 $del = Xml::check( 'showhiderevisions', false,
498 array( 'name' => 'ids['.$rev->getId().']' ) );
499 }
500 // User can only view deleted revisions...
501 } else if( $rev->getVisibility() && $wgUser->isAllowed( 'deletedhistory' ) ) {
502 // If revision was hidden from sysops, disable the link
503 if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) {
504 $cdel = $this->getSkin()->revDeleteLinkDisabled( false );
505 // Otherwise, show the link...
506 } else {
507 $query = array( 'type' => 'revision',
508 'target' => $this->title->getPrefixedDbkey(), 'ids' => $rev->getId() );
509 $del .= $this->getSkin()->revDeleteLink( $query,
510 $rev->isDeleted( Revision::DELETED_RESTRICTED ), false );
511 }
512 }
513 if( $del ) $s .= " $del ";
514
515 $s .= " $link";
516 $s .= " <span class='history-user'>" .
517 $this->getSkin()->revUserTools( $rev, true ) . "</span>";
518
519 if( $rev->isMinor() ) {
520 $s .= ' ' . ChangesList::flag( 'minor' );
521 }
522
523 if( !is_null( $size = $rev->getSize() ) && !$rev->isDeleted( Revision::DELETED_TEXT ) ) {
524 $s .= ' ' . $this->getSkin()->formatRevisionSize( $size );
525 }
526
527 $s .= $this->getSkin()->revComment( $rev, false, true );
528
529 if( $notificationtimestamp && ($row->rev_timestamp >= $notificationtimestamp) ) {
530 $s .= ' <span class="updatedmarker">' . wfMsgHtml( 'updatedmarker' ) . '</span>';
531 }
532
533 $tools = array();
534
535 # Rollback and undo links
536 if( !is_null( $next ) && is_object( $next ) ) {
537 if( $latest && $this->title->userCan( 'rollback' ) && $this->title->userCan( 'edit' ) ) {
538 $tools[] = '<span class="mw-rollback-link">'.
539 $this->getSkin()->buildRollbackLink( $rev ).'</span>';
540 }
541
542 if( $this->title->quickUserCan( 'edit' )
543 && !$rev->isDeleted( Revision::DELETED_TEXT )
544 && !$next->rev_deleted & Revision::DELETED_TEXT )
545 {
546 # Create undo tooltip for the first (=latest) line only
547 $undoTooltip = $latest
548 ? array( 'title' => wfMsg( 'tooltip-undo' ) )
549 : array();
550 $undolink = $this->getSkin()->link(
551 $this->title,
552 wfMsgHtml( 'editundo' ),
553 $undoTooltip,
554 array(
555 'action' => 'edit',
556 'undoafter' => $next->rev_id,
557 'undo' => $rev->getId()
558 ),
559 array( 'known', 'noclasses' )
560 );
561 $tools[] = "<span class=\"mw-history-undo\">{$undolink}</span>";
562 }
563 }
564
565 if( $tools ) {
566 $s .= ' (' . $wgLang->pipeList( $tools ) . ')';
567 }
568
569 # Tags
570 list($tagSummary, $newClasses) = ChangeTags::formatSummaryRow( $row->ts_tags, 'history' );
571 $classes = array_merge( $classes, $newClasses );
572 $s .= " $tagSummary";
573
574 wfRunHooks( 'PageHistoryLineEnding', array( $this, &$row , &$s, &$classes ) );
575
576 $attribs = array();
577 if ( $classes ) {
578 $attribs['class'] = implode( ' ', $classes );
579 }
580
581 return Xml::tags( 'li', $attribs, $s ) . "\n";
582 }
583
584 /**
585 * Create a link to view this revision of the page
586 *
587 * @param $rev Revision
588 * @return String
589 */
590 function revLink( $rev ) {
591 global $wgLang;
592 $date = $wgLang->timeanddate( wfTimestamp(TS_MW, $rev->getTimestamp()), true );
593 $date = htmlspecialchars( $date );
594 if( !$rev->isDeleted( Revision::DELETED_TEXT ) ) {
595 $link = $this->getSkin()->link(
596 $this->title,
597 $date,
598 array(),
599 array( 'oldid' => $rev->getId() ),
600 array( 'known', 'noclasses' )
601 );
602 } else {
603 $link = "<span class=\"history-deleted\">$date</span>";
604 }
605 return $link;
606 }
607
608 /**
609 * Create a diff-to-current link for this revision for this page
610 *
611 * @param $rev Revision
612 * @param $latest Boolean: this is the latest revision of the page?
613 * @return String
614 */
615 function curLink( $rev, $latest ) {
616 $cur = $this->historyPage->message['cur'];
617 if( $latest || !$rev->userCan( Revision::DELETED_TEXT ) ) {
618 return $cur;
619 } else {
620 return $this->getSkin()->link(
621 $this->title,
622 $cur,
623 array(),
624 array(
625 'diff' => $this->title->getLatestRevID(),
626 'oldid' => $rev->getId()
627 ),
628 array( 'known', 'noclasses' )
629 );
630 }
631 }
632
633 /**
634 * Create a diff-to-previous link for this revision for this page.
635 *
636 * @param $prevRev Revision: the previous revision
637 * @param $next Mixed: the newer revision
638 * @param $counter Integer: what row on the history list this is
639 * @return String
640 */
641 function lastLink( $prevRev, $next, $counter ) {
642 $last = $this->historyPage->message['last'];
643 # $next may either be a Row, null, or "unkown"
644 $nextRev = is_object($next) ? new Revision( $next ) : $next;
645 if( is_null($next) ) {
646 # Probably no next row
647 return $last;
648 } elseif( $next === 'unknown' ) {
649 # Next row probably exists but is unknown, use an oldid=prev link
650 return $this->getSkin()->link(
651 $this->title,
652 $last,
653 array(),
654 array(
655 'diff' => $prevRev->getId(),
656 'oldid' => 'prev'
657 ),
658 array( 'known', 'noclasses' )
659 );
660 } elseif( !$prevRev->userCan(Revision::DELETED_TEXT)
661 || !$nextRev->userCan(Revision::DELETED_TEXT) )
662 {
663 return $last;
664 } else {
665 return $this->getSkin()->link(
666 $this->title,
667 $last,
668 array(),
669 array(
670 'diff' => $prevRev->getId(),
671 'oldid' => $next->rev_id
672 ),
673 array( 'known', 'noclasses' )
674 );
675 }
676 }
677
678 /**
679 * Create radio buttons for page history
680 *
681 * @param $rev Revision object
682 * @param $firstInList Boolean: is this version the first one?
683 * @param $counter Integer: a counter of what row number we're at, counted from the top row = 1.
684 * @return String: HTML output for the radio buttons
685 */
686 function diffButtons( $rev, $firstInList, $counter ) {
687 if( $this->getNumRows() > 1 ) {
688 $id = $rev->getId();
689 $radio = array( 'type' => 'radio', 'value' => $id );
690 /** @todo: move title texts to javascript */
691 if( $firstInList ) {
692 $first = Xml::element( 'input',
693 array_merge( $radio, array(
694 'style' => 'visibility:hidden',
695 'name' => 'oldid',
696 'id' => 'mw-oldid-null' ) )
697 );
698 $checkmark = array( 'checked' => 'checked' );
699 } else {
700 # Check visibility of old revisions
701 if( !$rev->userCan( Revision::DELETED_TEXT ) ) {
702 $radio['disabled'] = 'disabled';
703 $checkmark = array(); // We will check the next possible one
704 } else if( $counter == 2 || !$this->oldIdChecked ) {
705 $checkmark = array( 'checked' => 'checked' );
706 $this->oldIdChecked = $id;
707 } else {
708 $checkmark = array();
709 }
710 $first = Xml::element( 'input',
711 array_merge( $radio, $checkmark, array(
712 'name' => 'oldid',
713 'id' => "mw-oldid-$id" ) ) );
714 $checkmark = array();
715 }
716 $second = Xml::element( 'input',
717 array_merge( $radio, $checkmark, array(
718 'name' => 'diff',
719 'id' => "mw-diff-$id" ) ) );
720 return $first . $second;
721 } else {
722 return '';
723 }
724 }
725 }
726
727 /**
728 * Backwards-compatibility aliases
729 */
730 class PageHistory extends HistoryPage {}
731 class PageHistoryPager extends HistoryPager {}