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