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