5 * Split off from Article.php and Skin.php, 2003-12-22
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * http://www.gnu.org/copyleft/gpl.html
27 * This class handles printing the history page for an article. In order to
28 * be efficient, it uses timestamps rather than offsets for paging, to avoid
29 * costly LIMIT,offset queries.
31 * Construct it by passing in an Article, and call $h->history() to print the
36 class HistoryAction
extends FormlessAction
{
40 /** @var array Array of message keys and strings */
43 public function getName() {
47 public function requiresWrite() {
51 public function requiresUnblock() {
55 protected function getPageTitle() {
56 return $this->msg( 'history-title', $this->getTitle()->getPrefixedText() )->text();
59 protected function getDescription() {
60 // Creation of a subtitle link pointing to [[Special:Log]]
61 return Linker
::linkKnown(
62 SpecialPage
::getTitleFor( 'Log' ),
63 $this->msg( 'viewpagelogs' )->escaped(),
65 [ 'page' => $this->getTitle()->getPrefixedText() ]
70 * @return WikiPage|Article|ImagePage|CategoryPage|Page The Article object we are working on.
72 public function getArticle() {
77 * As we use the same small set of messages in various methods and that
78 * they are called often, we call them once and save them in $this->message
80 private function preCacheMessages() {
81 // Precache various messages
82 if ( !isset( $this->message
) ) {
83 $msgs = [ 'cur', 'last', 'pipe-separator' ];
84 foreach ( $msgs as $msg ) {
85 $this->message
[$msg] = $this->msg( $msg )->escaped();
91 * Print the history page for an article.
94 $out = $this->getOutput();
95 $request = $this->getRequest();
98 * Allow client caching.
100 if ( $out->checkLastModified( $this->page
->getTouched() ) ) {
101 return; // Client cache fresh and headers sent, nothing more to do.
104 $this->preCacheMessages();
105 $config = $this->context
->getConfig();
107 # Fill in the file cache if not set already
108 $useFileCache = $config->get( 'UseFileCache' );
109 if ( $useFileCache && HTMLFileCache
::useFileCache( $this->getContext() ) ) {
110 $cache = new HTMLFileCache( $this->getTitle(), 'history' );
111 if ( !$cache->isCacheGood( /* Assume up to date */ ) ) {
112 ob_start( [ &$cache, 'saveToFileCache' ] );
116 // Setup page variables.
117 $out->setFeedAppendQuery( 'action=history' );
118 $out->addModules( 'mediawiki.action.history' );
119 $out->addModuleStyles( 'mediawiki.action.history.styles' );
120 if ( $config->get( 'UseMediaWikiUIEverywhere' ) ) {
121 $out = $this->getOutput();
122 $out->addModuleStyles( [
123 'mediawiki.ui.input',
124 'mediawiki.ui.checkbox',
128 // Handle atom/RSS feeds.
129 $feedType = $request->getVal( 'feed' );
131 $this->feed( $feedType );
136 $this->addHelpLink( '//meta.wikimedia.org/wiki/Special:MyLanguage/Help:Page_history', true );
138 // Fail nicely if article doesn't exist.
139 if ( !$this->page
->exists() ) {
140 $out->addWikiMsg( 'nohistory' );
141 # show deletion/move log if there is an entry
142 LogEventsList
::showLogExtract(
144 [ 'delete', 'move' ],
148 'conds' => [ "log_action != 'revision'" ],
149 'showIfEmpty' => false,
150 'msgKey' => [ 'moveddeleted-notice' ]
158 * Add date selector to quickly get to a certain time
160 $year = $request->getInt( 'year' );
161 $month = $request->getInt( 'month' );
162 $tagFilter = $request->getVal( 'tagfilter' );
163 $tagSelector = ChangeTags
::buildTagFilterSelector( $tagFilter );
166 * Option to show only revisions that have been (partially) hidden via RevisionDelete
168 if ( $request->getBool( 'deleted' ) ) {
169 $conds = [ 'rev_deleted != 0' ];
173 if ( $this->getUser()->isAllowed( 'deletedhistory' ) ) {
174 $checkDeleted = Xml
::checkLabel( $this->msg( 'history-show-deleted' )->text(),
175 'deleted', 'mw-show-deleted-only', $request->getBool( 'deleted' ) ) . "\n";
180 // Add the general form
181 $action = htmlspecialchars( wfScript() );
183 "<form action=\"$action\" method=\"get\" id=\"mw-history-searchform\">" .
185 $this->msg( 'history-fieldset-title' )->text(),
187 [ 'id' => 'mw-history-search' ]
189 Html
::hidden( 'title', $this->getTitle()->getPrefixedDBkey() ) . "\n" .
190 Html
::hidden( 'action', 'history' ) . "\n" .
192 ( $year == null ? MWTimestamp
::getLocalInstance()->format( 'Y' ) : $year ),
195 ( $tagSelector ?
( implode( ' ', $tagSelector ) . ' ' ) : '' ) .
198 $this->msg( 'historyaction-submit' )->text(),
200 [ 'mw-ui-progressive' ]
205 Hooks
::run( 'PageHistoryBeforeList', [ &$this->page
, $this->getContext() ] );
207 // Create and output the list.
208 $pager = new HistoryPager( $this, $year, $month, $tagFilter, $conds );
210 $pager->getNavigationBar() .
212 $pager->getNavigationBar()
214 $out->preventClickjacking( $pager->getPreventClickjacking() );
219 * Fetch an array of revisions, specified by a given limit, offset and
220 * direction. This is now only used by the feeds. It was previously
221 * used by the main UI but that's now handled by the pager.
223 * @param int $limit The limit number of revisions to get
225 * @param int $direction Either self::DIR_PREV or self::DIR_NEXT
226 * @return ResultWrapper
228 function fetchRevisions( $limit, $offset, $direction ) {
229 // Fail if article doesn't exist.
230 if ( !$this->getTitle()->exists() ) {
231 return new FakeResultWrapper( [] );
234 $dbr = wfGetDB( DB_SLAVE
);
236 if ( $direction === self
::DIR_PREV
) {
237 list( $dirs, $oper ) = [ "ASC", ">=" ];
238 } else { /* $direction === self::DIR_NEXT */
239 list( $dirs, $oper ) = [ "DESC", "<=" ];
243 $offsets = [ "rev_timestamp $oper " . $dbr->addQuotes( $dbr->timestamp( $offset ) ) ];
248 $page_id = $this->page
->getId();
250 return $dbr->select( 'revision',
251 Revision
::selectFields(),
252 array_merge( [ 'rev_page' => $page_id ], $offsets ),
254 [ 'ORDER BY' => "rev_timestamp $dirs",
255 'USE INDEX' => 'page_timestamp', 'LIMIT' => $limit ]
260 * Output a subscription feed listing recent edits to this page.
262 * @param string $type Feed type
264 function feed( $type ) {
265 if ( !FeedUtils
::checkFeedOutput( $type ) ) {
268 $request = $this->getRequest();
270 $feedClasses = $this->context
->getConfig()->get( 'FeedClasses' );
271 /** @var RSSFeed|AtomFeed $feed */
272 $feed = new $feedClasses[$type](
273 $this->getTitle()->getPrefixedText() . ' - ' .
274 $this->msg( 'history-feed-title' )->inContentLanguage()->text(),
275 $this->msg( 'history-feed-description' )->inContentLanguage()->text(),
276 $this->getTitle()->getFullURL( 'action=history' )
279 // Get a limit on number of feed entries. Provide a sane default
280 // of 10 if none is defined (but limit to $wgFeedLimit max)
281 $limit = $request->getInt( 'limit', 10 );
284 $this->context
->getConfig()->get( 'FeedLimit' )
287 $items = $this->fetchRevisions( $limit, 0, self
::DIR_NEXT
);
289 // Generate feed elements enclosed between header and footer.
291 if ( $items->numRows() ) {
292 foreach ( $items as $row ) {
293 $feed->outItem( $this->feedItem( $row ) );
296 $feed->outItem( $this->feedEmpty() );
301 function feedEmpty() {
303 $this->msg( 'nohistory' )->inContentLanguage()->text(),
304 $this->msg( 'history-feed-empty' )->inContentLanguage()->parseAsBlock(),
305 $this->getTitle()->getFullURL(),
306 wfTimestamp( TS_MW
),
308 $this->getTitle()->getTalkPage()->getFullURL()
313 * Generate a FeedItem object from a given revision table row
314 * Borrows Recent Changes' feed generation functions for formatting;
315 * includes a diff to the previous revision (if any).
317 * @param stdClass|array $row Database row
320 function feedItem( $row ) {
321 $rev = new Revision( $row );
322 $rev->setTitle( $this->getTitle() );
323 $text = FeedUtils
::formatDiffRow(
325 $this->getTitle()->getPreviousRevisionID( $rev->getId() ),
327 $rev->getTimestamp(),
330 if ( $rev->getComment() == '' ) {
332 $title = $this->msg( 'history-feed-item-nocomment',
334 $wgContLang->timeanddate( $rev->getTimestamp() ),
335 $wgContLang->date( $rev->getTimestamp() ),
336 $wgContLang->time( $rev->getTimestamp() ) )->inContentLanguage()->text();
338 $title = $rev->getUserText() .
339 $this->msg( 'colon-separator' )->inContentLanguage()->text() .
340 FeedItem
::stripComment( $rev->getComment() );
346 $this->getTitle()->getFullURL( 'diff=' . $rev->getId() . '&oldid=prev' ),
347 $rev->getTimestamp(),
349 $this->getTitle()->getTalkPage()->getFullURL()
358 class HistoryPager
extends ReverseChronologicalPager
{
362 public $lastRow = false;
364 public $counter, $historyPage, $buttons, $conds;
366 protected $oldIdChecked;
368 protected $preventClickjacking = false;
372 protected $parentLens;
374 /** @var bool Whether to show the tag editing UI */
375 protected $showTagEditUI;
378 * @param HistoryAction $historyPage
379 * @param string $year
380 * @param string $month
381 * @param string $tagFilter
382 * @param array $conds
384 function __construct( $historyPage, $year = '', $month = '', $tagFilter = '', $conds = [] ) {
385 parent
::__construct( $historyPage->getContext() );
386 $this->historyPage
= $historyPage;
387 $this->tagFilter
= $tagFilter;
388 $this->getDateCond( $year, $month );
389 $this->conds
= $conds;
390 $this->showTagEditUI
= ChangeTags
::showTagEditingUI( $this->getUser() );
393 // For hook compatibility...
394 function getArticle() {
395 return $this->historyPage
->getArticle();
398 function getSqlComment() {
399 if ( $this->conds
) {
400 return 'history page filtered'; // potentially slow, see CR r58153
402 return 'history page unfiltered';
406 function getQueryInfo() {
408 'tables' => [ 'revision', 'user' ],
409 'fields' => array_merge( Revision
::selectFields(), Revision
::selectUserFields() ),
410 'conds' => array_merge(
411 [ 'rev_page' => $this->getWikiPage()->getId() ],
413 'options' => [ 'USE INDEX' => [ 'revision' => 'page_timestamp' ] ],
414 'join_conds' => [ 'user' => Revision
::userJoinCond() ],
416 ChangeTags
::modifyDisplayQuery(
417 $queryInfo['tables'],
418 $queryInfo['fields'],
420 $queryInfo['join_conds'],
421 $queryInfo['options'],
424 Hooks
::run( 'PageHistoryPager::getQueryInfo', [ &$this, &$queryInfo ] );
429 function getIndexField() {
430 return 'rev_timestamp';
434 * @param stdClass $row
437 function formatRow( $row ) {
438 if ( $this->lastRow
) {
439 $latest = ( $this->counter
== 1 && $this->mIsFirst
);
440 $firstInList = $this->counter
== 1;
443 $notifTimestamp = $this->getConfig()->get( 'ShowUpdatedMarker' )
444 ?
$this->getTitle()->getNotificationTimestamp( $this->getUser() )
447 $s = $this->historyLine(
448 $this->lastRow
, $row, $notifTimestamp, $latest, $firstInList );
452 $this->lastRow
= $row;
457 function doBatchLookups() {
458 if ( !Hooks
::run( 'PageHistoryPager::doBatchLookups', [ $this, $this->mResult
] ) ) {
462 # Do a link batch query
463 $this->mResult
->seek( 0 );
464 $batch = new LinkBatch();
466 foreach ( $this->mResult
as $row ) {
467 if ( $row->rev_parent_id
) {
468 $revIds[] = $row->rev_parent_id
;
470 if ( !is_null( $row->user_name
) ) {
471 $batch->add( NS_USER
, $row->user_name
);
472 $batch->add( NS_USER_TALK
, $row->user_name
);
473 } else { # for anons or usernames of imported revisions
474 $batch->add( NS_USER
, $row->rev_user_text
);
475 $batch->add( NS_USER_TALK
, $row->rev_user_text
);
478 $this->parentLens
= Revision
::getParentLengths( $this->mDb
, $revIds );
480 $this->mResult
->seek( 0 );
484 * Creates begin of history list with a submit button
486 * @return string HTML output
488 function getStartBody() {
489 $this->lastRow
= false;
491 $this->oldIdChecked
= 0;
493 $this->getOutput()->wrapWikiMsg( "<div class='mw-history-legend'>\n$1\n</div>", 'histlegend' );
494 $s = Html
::openElement( 'form', [ 'action' => wfScript(),
495 'id' => 'mw-history-compare' ] ) . "\n";
496 $s .= Html
::hidden( 'title', $this->getTitle()->getPrefixedDBkey() ) . "\n";
497 $s .= Html
::hidden( 'action', 'historysubmit' ) . "\n";
498 $s .= Html
::hidden( 'type', 'revision' ) . "\n";
500 // Button container stored in $this->buttons for re-use in getEndBody()
501 $this->buttons
= '<div>';
502 $className = 'historysubmit mw-history-compareselectedversions-button';
503 $attrs = [ 'class' => $className ]
504 + Linker
::tooltipAndAccesskeyAttribs( 'compareselectedversions' );
505 $this->buttons
.= $this->submitButton( $this->msg( 'compareselectedversions' )->text(),
509 $user = $this->getUser();
511 if ( $user->isAllowed( 'deleterevision' ) ) {
512 $actionButtons .= $this->getRevisionButton( 'revisiondelete', 'showhideselectedversions' );
514 if ( $this->showTagEditUI
) {
515 $actionButtons .= $this->getRevisionButton( 'editchangetags', 'history-edit-tags' );
517 if ( $actionButtons ) {
518 $this->buttons
.= Xml
::tags( 'div', [ 'class' =>
519 'mw-history-revisionactions' ], $actionButtons );
522 if ( $user->isAllowed( 'deleterevision' ) ||
$this->showTagEditUI
) {
523 $this->buttons
.= ( new ListToggle( $this->getOutput() ) )->getHTML();
526 $this->buttons
.= '</div>';
528 $s .= $this->buttons
;
529 $s .= '<ul id="pagehistory">' . "\n";
534 private function getRevisionButton( $name, $msg ) {
535 $this->preventClickjacking();
536 # Note bug #20966, <button> is non-standard in IE<8
537 $element = Html
::element(
543 'class' => "historysubmit mw-history-$name-button",
545 $this->msg( $msg )->text()
550 function getEndBody() {
551 if ( $this->lastRow
) {
552 $latest = $this->counter
== 1 && $this->mIsFirst
;
553 $firstInList = $this->counter
== 1;
554 if ( $this->mIsBackwards
) {
555 # Next row is unknown, but for UI reasons, probably exists if an offset has been specified
556 if ( $this->mOffset
== '' ) {
562 # The next row is the past-the-end row
563 $next = $this->mPastTheEndRow
;
567 $notifTimestamp = $this->getConfig()->get( 'ShowUpdatedMarker' )
568 ?
$this->getTitle()->getNotificationTimestamp( $this->getUser() )
571 $s = $this->historyLine(
572 $this->lastRow
, $next, $notifTimestamp, $latest, $firstInList );
577 # Add second buttons only if there is more than one rev
578 if ( $this->getNumRows() > 2 ) {
579 $s .= $this->buttons
;
587 * Creates a submit button
589 * @param string $message Text of the submit button, will be escaped
590 * @param array $attributes Attributes
591 * @return string HTML output for the submit button
593 function submitButton( $message, $attributes = [] ) {
594 # Disable submit button if history has 1 revision only
595 if ( $this->getNumRows() > 1 ) {
596 return Html
::submitButton( $message, $attributes );
603 * Returns a row from the history printout.
605 * @todo document some more, and maybe clean up the code (some params redundant?)
607 * @param stdClass $row The database row corresponding to the previous line.
608 * @param mixed $next The database row corresponding to the next line
609 * (chronologically previous)
610 * @param bool|string $notificationtimestamp
611 * @param bool $latest Whether this row corresponds to the page's latest revision.
612 * @param bool $firstInList Whether this row corresponds to the first
613 * displayed on this history page.
614 * @return string HTML output for the row
616 function historyLine( $row, $next, $notificationtimestamp = false,
617 $latest = false, $firstInList = false ) {
618 $rev = new Revision( $row );
619 $rev->setTitle( $this->getTitle() );
621 if ( is_object( $next ) ) {
622 $prevRev = new Revision( $next );
623 $prevRev->setTitle( $this->getTitle() );
628 $curlink = $this->curLink( $rev, $latest );
629 $lastlink = $this->lastLink( $rev, $next );
630 $curLastlinks = $curlink . $this->historyPage
->message
['pipe-separator'] . $lastlink;
631 $histLinks = Html
::rawElement(
633 [ 'class' => 'mw-history-histlinks' ],
634 $this->msg( 'parentheses' )->rawParams( $curLastlinks )->escaped()
637 $diffButtons = $this->diffButtons( $rev, $firstInList );
638 $s = $histLinks . $diffButtons;
640 $link = $this->revLink( $rev );
644 $user = $this->getUser();
645 $canRevDelete = $user->isAllowed( 'deleterevision' );
646 // Show checkboxes for each revision, to allow for revision deletion and
648 if ( $canRevDelete ||
$this->showTagEditUI
) {
649 $this->preventClickjacking();
650 // If revision was hidden from sysops and we don't need the checkbox
651 // for anything else, disable it
652 if ( !$this->showTagEditUI
&& !$rev->userCan( Revision
::DELETED_RESTRICTED
, $user ) ) {
653 $del = Xml
::check( 'deleterevisions', false, [ 'disabled' => 'disabled' ] );
654 // Otherwise, enable the checkbox...
656 $del = Xml
::check( 'showhiderevisions', false,
657 [ 'name' => 'ids[' . $rev->getId() . ']' ] );
659 // User can only view deleted revisions...
660 } elseif ( $rev->getVisibility() && $user->isAllowed( 'deletedhistory' ) ) {
661 // If revision was hidden from sysops, disable the link
662 if ( !$rev->userCan( Revision
::DELETED_RESTRICTED
, $user ) ) {
663 $del = Linker
::revDeleteLinkDisabled( false );
664 // Otherwise, show the link...
666 $query = [ 'type' => 'revision',
667 'target' => $this->getTitle()->getPrefixedDBkey(), 'ids' => $rev->getId() ];
668 $del .= Linker
::revDeleteLink( $query,
669 $rev->isDeleted( Revision
::DELETED_RESTRICTED
), false );
676 $lang = $this->getLanguage();
677 $dirmark = $lang->getDirMark();
681 $s .= " <span class='history-user'>" .
682 Linker
::revUserTools( $rev, true ) . "</span>";
685 if ( $rev->isMinor() ) {
686 $s .= ' ' . ChangesList
::flag( 'minor', $this->getContext() );
689 # Sometimes rev_len isn't populated
690 if ( $rev->getSize() !== null ) {
691 # Size is always public data
692 $prevSize = isset( $this->parentLens
[$row->rev_parent_id
] )
693 ?
$this->parentLens
[$row->rev_parent_id
]
695 $sDiff = ChangesList
::showCharacterDifference( $prevSize, $rev->getSize() );
696 $fSize = Linker
::formatRevisionSize( $rev->getSize() );
697 $s .= ' <span class="mw-changeslist-separator">. .</span> ' . "$fSize $sDiff";
700 # Text following the character difference is added just before running hooks
701 $s2 = Linker
::revComment( $rev, false, true );
703 if ( $notificationtimestamp && ( $row->rev_timestamp
>= $notificationtimestamp ) ) {
704 $s2 .= ' <span class="updatedmarker">' . $this->msg( 'updatedmarker' )->escaped() . '</span>';
705 $classes[] = 'mw-history-line-updated';
710 # Rollback and undo links
711 if ( $prevRev && $this->getTitle()->quickUserCan( 'edit', $user ) ) {
712 if ( $latest && $this->getTitle()->quickUserCan( 'rollback', $user ) ) {
713 // Get a rollback link without the brackets
714 $rollbackLink = Linker
::generateRollback(
717 [ 'verify', 'noBrackets' ]
719 if ( $rollbackLink ) {
720 $this->preventClickjacking();
721 $tools[] = $rollbackLink;
725 if ( !$rev->isDeleted( Revision
::DELETED_TEXT
)
726 && !$prevRev->isDeleted( Revision
::DELETED_TEXT
)
728 # Create undo tooltip for the first (=latest) line only
729 $undoTooltip = $latest
730 ?
[ 'title' => $this->msg( 'tooltip-undo' )->text() ]
732 $undolink = Linker
::linkKnown(
734 $this->msg( 'editundo' )->escaped(),
738 'undoafter' => $prevRev->getId(),
739 'undo' => $rev->getId()
742 $tools[] = "<span class=\"mw-history-undo\">{$undolink}</span>";
745 // Allow extension to add their own links here
746 Hooks
::run( 'HistoryRevisionTools', [ $rev, &$tools, $prevRev, $user ] );
749 $s2 .= ' ' . $this->msg( 'parentheses' )->rawParams( $lang->pipeList( $tools ) )->escaped();
753 list( $tagSummary, $newClasses ) = ChangeTags
::formatSummaryRow(
758 $classes = array_merge( $classes, $newClasses );
759 if ( $tagSummary !== '' ) {
760 $s2 .= " $tagSummary";
763 # Include separator between character difference and following text
765 $s .= ' <span class="mw-changeslist-separator">. .</span> ' . $s2;
768 Hooks
::run( 'PageHistoryLineEnding', [ $this, &$row, &$s, &$classes ] );
772 $attribs['class'] = implode( ' ', $classes );
775 return Xml
::tags( 'li', $attribs, $s ) . "\n";
779 * Create a link to view this revision of the page
781 * @param Revision $rev
784 function revLink( $rev ) {
785 $date = $this->getLanguage()->userTimeAndDate( $rev->getTimestamp(), $this->getUser() );
786 $date = htmlspecialchars( $date );
787 if ( $rev->userCan( Revision
::DELETED_TEXT
, $this->getUser() ) ) {
788 $link = Linker
::linkKnown(
791 [ 'class' => 'mw-changeslist-date' ],
792 [ 'oldid' => $rev->getId() ]
797 if ( $rev->isDeleted( Revision
::DELETED_TEXT
) ) {
798 $link = "<span class=\"history-deleted\">$link</span>";
805 * Create a diff-to-current link for this revision for this page
807 * @param Revision $rev
808 * @param bool $latest This is the latest revision of the page?
811 function curLink( $rev, $latest ) {
812 $cur = $this->historyPage
->message
['cur'];
813 if ( $latest ||
!$rev->userCan( Revision
::DELETED_TEXT
, $this->getUser() ) ) {
816 return Linker
::linkKnown(
821 'diff' => $this->getWikiPage()->getLatest(),
822 'oldid' => $rev->getId()
829 * Create a diff-to-previous link for this revision for this page.
831 * @param Revision $prevRev The revision being displayed
832 * @param stdClass|string|null $next The next revision in list (that is
833 * the previous one in chronological order).
834 * May either be a row, "unknown" or null.
837 function lastLink( $prevRev, $next ) {
838 $last = $this->historyPage
->message
['last'];
840 if ( $next === null ) {
841 # Probably no next row
845 if ( $next === 'unknown' ) {
846 # Next row probably exists but is unknown, use an oldid=prev link
847 return Linker
::linkKnown(
852 'diff' => $prevRev->getId(),
858 $nextRev = new Revision( $next );
860 if ( !$prevRev->userCan( Revision
::DELETED_TEXT
, $this->getUser() )
861 ||
!$nextRev->userCan( Revision
::DELETED_TEXT
, $this->getUser() )
866 return Linker
::linkKnown(
871 'diff' => $prevRev->getId(),
872 'oldid' => $next->rev_id
878 * Create radio buttons for page history
880 * @param Revision $rev
881 * @param bool $firstInList Is this version the first one?
883 * @return string HTML output for the radio buttons
885 function diffButtons( $rev, $firstInList ) {
886 if ( $this->getNumRows() > 1 ) {
888 $radio = [ 'type' => 'radio', 'value' => $id ];
889 /** @todo Move title texts to javascript */
890 if ( $firstInList ) {
891 $first = Xml
::element( 'input',
892 array_merge( $radio, [
893 'style' => 'visibility:hidden',
895 'id' => 'mw-oldid-null' ] )
897 $checkmark = [ 'checked' => 'checked' ];
899 # Check visibility of old revisions
900 if ( !$rev->userCan( Revision
::DELETED_TEXT
, $this->getUser() ) ) {
901 $radio['disabled'] = 'disabled';
902 $checkmark = []; // We will check the next possible one
903 } elseif ( !$this->oldIdChecked
) {
904 $checkmark = [ 'checked' => 'checked' ];
905 $this->oldIdChecked
= $id;
909 $first = Xml
::element( 'input',
910 array_merge( $radio, $checkmark, [
912 'id' => "mw-oldid-$id" ] ) );
915 $second = Xml
::element( 'input',
916 array_merge( $radio, $checkmark, [
918 'id' => "mw-diff-$id" ] ) );
920 return $first . $second;
927 * This is called if a write operation is possible from the generated HTML
928 * @param bool $enable
930 function preventClickjacking( $enable = true ) {
931 $this->preventClickjacking
= $enable;
935 * Get the "prevent clickjacking" flag
938 function getPreventClickjacking() {
939 return $this->preventClickjacking
;