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( [
120 'mediawiki.action.history.styles',
121 'mediawiki.special.changeslist',
123 if ( $config->get( 'UseMediaWikiUIEverywhere' ) ) {
124 $out = $this->getOutput();
125 $out->addModuleStyles( [
126 'mediawiki.ui.input',
127 'mediawiki.ui.checkbox',
131 // Handle atom/RSS feeds.
132 $feedType = $request->getVal( 'feed' );
134 $this->feed( $feedType );
139 $this->addHelpLink( '//meta.wikimedia.org/wiki/Special:MyLanguage/Help:Page_history', true );
141 // Fail nicely if article doesn't exist.
142 if ( !$this->page
->exists() ) {
143 $out->addWikiMsg( 'nohistory' );
144 # show deletion/move log if there is an entry
145 LogEventsList
::showLogExtract(
147 [ 'delete', 'move' ],
151 'conds' => [ "log_action != 'revision'" ],
152 'showIfEmpty' => false,
153 'msgKey' => [ 'moveddeleted-notice' ]
161 * Add date selector to quickly get to a certain time
163 $year = $request->getInt( 'year' );
164 $month = $request->getInt( 'month' );
165 $tagFilter = $request->getVal( 'tagfilter' );
166 $tagSelector = ChangeTags
::buildTagFilterSelector( $tagFilter );
169 * Option to show only revisions that have been (partially) hidden via RevisionDelete
171 if ( $request->getBool( 'deleted' ) ) {
172 $conds = [ 'rev_deleted != 0' ];
176 if ( $this->getUser()->isAllowed( 'deletedhistory' ) ) {
177 $checkDeleted = Xml
::checkLabel( $this->msg( 'history-show-deleted' )->text(),
178 'deleted', 'mw-show-deleted-only', $request->getBool( 'deleted' ) ) . "\n";
183 // Add the general form
184 $action = htmlspecialchars( wfScript() );
186 "<form action=\"$action\" method=\"get\" id=\"mw-history-searchform\">" .
188 $this->msg( 'history-fieldset-title' )->text(),
190 [ 'id' => 'mw-history-search' ]
192 Html
::hidden( 'title', $this->getTitle()->getPrefixedDBkey() ) . "\n" .
193 Html
::hidden( 'action', 'history' ) . "\n" .
195 ( $year == null ? MWTimestamp
::getLocalInstance()->format( 'Y' ) : $year ),
198 ( $tagSelector ?
( implode( ' ', $tagSelector ) . ' ' ) : '' ) .
201 $this->msg( 'historyaction-submit' )->text(),
203 [ 'mw-ui-progressive' ]
208 Hooks
::run( 'PageHistoryBeforeList', [ &$this->page
, $this->getContext() ] );
210 // Create and output the list.
211 $pager = new HistoryPager( $this, $year, $month, $tagFilter, $conds );
213 $pager->getNavigationBar() .
215 $pager->getNavigationBar()
217 $out->preventClickjacking( $pager->getPreventClickjacking() );
222 * Fetch an array of revisions, specified by a given limit, offset and
223 * direction. This is now only used by the feeds. It was previously
224 * used by the main UI but that's now handled by the pager.
226 * @param int $limit The limit number of revisions to get
228 * @param int $direction Either self::DIR_PREV or self::DIR_NEXT
229 * @return ResultWrapper
231 function fetchRevisions( $limit, $offset, $direction ) {
232 // Fail if article doesn't exist.
233 if ( !$this->getTitle()->exists() ) {
234 return new FakeResultWrapper( [] );
237 $dbr = wfGetDB( DB_SLAVE
);
239 if ( $direction === self
::DIR_PREV
) {
240 list( $dirs, $oper ) = [ "ASC", ">=" ];
241 } else { /* $direction === self::DIR_NEXT */
242 list( $dirs, $oper ) = [ "DESC", "<=" ];
246 $offsets = [ "rev_timestamp $oper " . $dbr->addQuotes( $dbr->timestamp( $offset ) ) ];
251 $page_id = $this->page
->getId();
253 return $dbr->select( 'revision',
254 Revision
::selectFields(),
255 array_merge( [ 'rev_page' => $page_id ], $offsets ),
257 [ 'ORDER BY' => "rev_timestamp $dirs",
258 'USE INDEX' => 'page_timestamp', 'LIMIT' => $limit ]
263 * Output a subscription feed listing recent edits to this page.
265 * @param string $type Feed type
267 function feed( $type ) {
268 if ( !FeedUtils
::checkFeedOutput( $type ) ) {
271 $request = $this->getRequest();
273 $feedClasses = $this->context
->getConfig()->get( 'FeedClasses' );
274 /** @var RSSFeed|AtomFeed $feed */
275 $feed = new $feedClasses[$type](
276 $this->getTitle()->getPrefixedText() . ' - ' .
277 $this->msg( 'history-feed-title' )->inContentLanguage()->text(),
278 $this->msg( 'history-feed-description' )->inContentLanguage()->text(),
279 $this->getTitle()->getFullURL( 'action=history' )
282 // Get a limit on number of feed entries. Provide a sane default
283 // of 10 if none is defined (but limit to $wgFeedLimit max)
284 $limit = $request->getInt( 'limit', 10 );
287 $this->context
->getConfig()->get( 'FeedLimit' )
290 $items = $this->fetchRevisions( $limit, 0, self
::DIR_NEXT
);
292 // Generate feed elements enclosed between header and footer.
294 if ( $items->numRows() ) {
295 foreach ( $items as $row ) {
296 $feed->outItem( $this->feedItem( $row ) );
299 $feed->outItem( $this->feedEmpty() );
304 function feedEmpty() {
306 $this->msg( 'nohistory' )->inContentLanguage()->text(),
307 $this->msg( 'history-feed-empty' )->inContentLanguage()->parseAsBlock(),
308 $this->getTitle()->getFullURL(),
309 wfTimestamp( TS_MW
),
311 $this->getTitle()->getTalkPage()->getFullURL()
316 * Generate a FeedItem object from a given revision table row
317 * Borrows Recent Changes' feed generation functions for formatting;
318 * includes a diff to the previous revision (if any).
320 * @param stdClass|array $row Database row
323 function feedItem( $row ) {
324 $rev = new Revision( $row );
325 $rev->setTitle( $this->getTitle() );
326 $text = FeedUtils
::formatDiffRow(
328 $this->getTitle()->getPreviousRevisionID( $rev->getId() ),
330 $rev->getTimestamp(),
333 if ( $rev->getComment() == '' ) {
335 $title = $this->msg( 'history-feed-item-nocomment',
337 $wgContLang->timeanddate( $rev->getTimestamp() ),
338 $wgContLang->date( $rev->getTimestamp() ),
339 $wgContLang->time( $rev->getTimestamp() ) )->inContentLanguage()->text();
341 $title = $rev->getUserText() .
342 $this->msg( 'colon-separator' )->inContentLanguage()->text() .
343 FeedItem
::stripComment( $rev->getComment() );
349 $this->getTitle()->getFullURL( 'diff=' . $rev->getId() . '&oldid=prev' ),
350 $rev->getTimestamp(),
352 $this->getTitle()->getTalkPage()->getFullURL()
361 class HistoryPager
extends ReverseChronologicalPager
{
365 public $lastRow = false;
367 public $counter, $historyPage, $buttons, $conds;
369 protected $oldIdChecked;
371 protected $preventClickjacking = false;
375 protected $parentLens;
377 /** @var bool Whether to show the tag editing UI */
378 protected $showTagEditUI;
381 * @param HistoryAction $historyPage
382 * @param string $year
383 * @param string $month
384 * @param string $tagFilter
385 * @param array $conds
387 function __construct( $historyPage, $year = '', $month = '', $tagFilter = '', $conds = [] ) {
388 parent
::__construct( $historyPage->getContext() );
389 $this->historyPage
= $historyPage;
390 $this->tagFilter
= $tagFilter;
391 $this->getDateCond( $year, $month );
392 $this->conds
= $conds;
393 $this->showTagEditUI
= ChangeTags
::showTagEditingUI( $this->getUser() );
396 // For hook compatibility...
397 function getArticle() {
398 return $this->historyPage
->getArticle();
401 function getSqlComment() {
402 if ( $this->conds
) {
403 return 'history page filtered'; // potentially slow, see CR r58153
405 return 'history page unfiltered';
409 function getQueryInfo() {
411 'tables' => [ 'revision', 'user' ],
412 'fields' => array_merge( Revision
::selectFields(), Revision
::selectUserFields() ),
413 'conds' => array_merge(
414 [ 'rev_page' => $this->getWikiPage()->getId() ],
416 'options' => [ 'USE INDEX' => [ 'revision' => 'page_timestamp' ] ],
417 'join_conds' => [ 'user' => Revision
::userJoinCond() ],
419 ChangeTags
::modifyDisplayQuery(
420 $queryInfo['tables'],
421 $queryInfo['fields'],
423 $queryInfo['join_conds'],
424 $queryInfo['options'],
427 Hooks
::run( 'PageHistoryPager::getQueryInfo', [ &$this, &$queryInfo ] );
432 function getIndexField() {
433 return 'rev_timestamp';
437 * @param stdClass $row
440 function formatRow( $row ) {
441 if ( $this->lastRow
) {
442 $latest = ( $this->counter
== 1 && $this->mIsFirst
);
443 $firstInList = $this->counter
== 1;
446 $notifTimestamp = $this->getConfig()->get( 'ShowUpdatedMarker' )
447 ?
$this->getTitle()->getNotificationTimestamp( $this->getUser() )
450 $s = $this->historyLine(
451 $this->lastRow
, $row, $notifTimestamp, $latest, $firstInList );
455 $this->lastRow
= $row;
460 function doBatchLookups() {
461 if ( !Hooks
::run( 'PageHistoryPager::doBatchLookups', [ $this, $this->mResult
] ) ) {
465 # Do a link batch query
466 $this->mResult
->seek( 0 );
467 $batch = new LinkBatch();
469 foreach ( $this->mResult
as $row ) {
470 if ( $row->rev_parent_id
) {
471 $revIds[] = $row->rev_parent_id
;
473 if ( !is_null( $row->user_name
) ) {
474 $batch->add( NS_USER
, $row->user_name
);
475 $batch->add( NS_USER_TALK
, $row->user_name
);
476 } else { # for anons or usernames of imported revisions
477 $batch->add( NS_USER
, $row->rev_user_text
);
478 $batch->add( NS_USER_TALK
, $row->rev_user_text
);
481 $this->parentLens
= Revision
::getParentLengths( $this->mDb
, $revIds );
483 $this->mResult
->seek( 0 );
487 * Creates begin of history list with a submit button
489 * @return string HTML output
491 function getStartBody() {
492 $this->lastRow
= false;
494 $this->oldIdChecked
= 0;
496 $this->getOutput()->wrapWikiMsg( "<div class='mw-history-legend'>\n$1\n</div>", 'histlegend' );
497 $s = Html
::openElement( 'form', [ 'action' => wfScript(),
498 'id' => 'mw-history-compare' ] ) . "\n";
499 $s .= Html
::hidden( 'title', $this->getTitle()->getPrefixedDBkey() ) . "\n";
500 $s .= Html
::hidden( 'action', 'historysubmit' ) . "\n";
501 $s .= Html
::hidden( 'type', 'revision' ) . "\n";
503 // Button container stored in $this->buttons for re-use in getEndBody()
504 $this->buttons
= '<div>';
505 $className = 'historysubmit mw-history-compareselectedversions-button';
506 $attrs = [ 'class' => $className ]
507 + Linker
::tooltipAndAccesskeyAttribs( 'compareselectedversions' );
508 $this->buttons
.= $this->submitButton( $this->msg( 'compareselectedversions' )->text(),
512 $user = $this->getUser();
514 if ( $user->isAllowed( 'deleterevision' ) ) {
515 $actionButtons .= $this->getRevisionButton( 'revisiondelete', 'showhideselectedversions' );
517 if ( $this->showTagEditUI
) {
518 $actionButtons .= $this->getRevisionButton( 'editchangetags', 'history-edit-tags' );
520 if ( $actionButtons ) {
521 $this->buttons
.= Xml
::tags( 'div', [ 'class' =>
522 'mw-history-revisionactions' ], $actionButtons );
525 if ( $user->isAllowed( 'deleterevision' ) ||
$this->showTagEditUI
) {
526 $this->buttons
.= ( new ListToggle( $this->getOutput() ) )->getHTML();
529 $this->buttons
.= '</div>';
531 $s .= $this->buttons
;
532 $s .= '<ul id="pagehistory">' . "\n";
537 private function getRevisionButton( $name, $msg ) {
538 $this->preventClickjacking();
539 # Note bug #20966, <button> is non-standard in IE<8
540 $element = Html
::element(
546 'class' => "historysubmit mw-history-$name-button",
548 $this->msg( $msg )->text()
553 function getEndBody() {
554 if ( $this->lastRow
) {
555 $latest = $this->counter
== 1 && $this->mIsFirst
;
556 $firstInList = $this->counter
== 1;
557 if ( $this->mIsBackwards
) {
558 # Next row is unknown, but for UI reasons, probably exists if an offset has been specified
559 if ( $this->mOffset
== '' ) {
565 # The next row is the past-the-end row
566 $next = $this->mPastTheEndRow
;
570 $notifTimestamp = $this->getConfig()->get( 'ShowUpdatedMarker' )
571 ?
$this->getTitle()->getNotificationTimestamp( $this->getUser() )
574 $s = $this->historyLine(
575 $this->lastRow
, $next, $notifTimestamp, $latest, $firstInList );
580 # Add second buttons only if there is more than one rev
581 if ( $this->getNumRows() > 2 ) {
582 $s .= $this->buttons
;
590 * Creates a submit button
592 * @param string $message Text of the submit button, will be escaped
593 * @param array $attributes Attributes
594 * @return string HTML output for the submit button
596 function submitButton( $message, $attributes = [] ) {
597 # Disable submit button if history has 1 revision only
598 if ( $this->getNumRows() > 1 ) {
599 return Html
::submitButton( $message, $attributes );
606 * Returns a row from the history printout.
608 * @todo document some more, and maybe clean up the code (some params redundant?)
610 * @param stdClass $row The database row corresponding to the previous line.
611 * @param mixed $next The database row corresponding to the next line
612 * (chronologically previous)
613 * @param bool|string $notificationtimestamp
614 * @param bool $latest Whether this row corresponds to the page's latest revision.
615 * @param bool $firstInList Whether this row corresponds to the first
616 * displayed on this history page.
617 * @return string HTML output for the row
619 function historyLine( $row, $next, $notificationtimestamp = false,
620 $latest = false, $firstInList = false ) {
621 $rev = new Revision( $row );
622 $rev->setTitle( $this->getTitle() );
624 if ( is_object( $next ) ) {
625 $prevRev = new Revision( $next );
626 $prevRev->setTitle( $this->getTitle() );
631 $curlink = $this->curLink( $rev, $latest );
632 $lastlink = $this->lastLink( $rev, $next );
633 $curLastlinks = $curlink . $this->historyPage
->message
['pipe-separator'] . $lastlink;
634 $histLinks = Html
::rawElement(
636 [ 'class' => 'mw-history-histlinks' ],
637 $this->msg( 'parentheses' )->rawParams( $curLastlinks )->escaped()
640 $diffButtons = $this->diffButtons( $rev, $firstInList );
641 $s = $histLinks . $diffButtons;
643 $link = $this->revLink( $rev );
647 $user = $this->getUser();
648 $canRevDelete = $user->isAllowed( 'deleterevision' );
649 // Show checkboxes for each revision, to allow for revision deletion and
651 if ( $canRevDelete ||
$this->showTagEditUI
) {
652 $this->preventClickjacking();
653 // If revision was hidden from sysops and we don't need the checkbox
654 // for anything else, disable it
655 if ( !$this->showTagEditUI
&& !$rev->userCan( Revision
::DELETED_RESTRICTED
, $user ) ) {
656 $del = Xml
::check( 'deleterevisions', false, [ 'disabled' => 'disabled' ] );
657 // Otherwise, enable the checkbox...
659 $del = Xml
::check( 'showhiderevisions', false,
660 [ 'name' => 'ids[' . $rev->getId() . ']' ] );
662 // User can only view deleted revisions...
663 } elseif ( $rev->getVisibility() && $user->isAllowed( 'deletedhistory' ) ) {
664 // If revision was hidden from sysops, disable the link
665 if ( !$rev->userCan( Revision
::DELETED_RESTRICTED
, $user ) ) {
666 $del = Linker
::revDeleteLinkDisabled( false );
667 // Otherwise, show the link...
669 $query = [ 'type' => 'revision',
670 'target' => $this->getTitle()->getPrefixedDBkey(), 'ids' => $rev->getId() ];
671 $del .= Linker
::revDeleteLink( $query,
672 $rev->isDeleted( Revision
::DELETED_RESTRICTED
), false );
679 $lang = $this->getLanguage();
680 $dirmark = $lang->getDirMark();
684 $s .= " <span class='history-user'>" .
685 Linker
::revUserTools( $rev, true ) . "</span>";
688 if ( $rev->isMinor() ) {
689 $s .= ' ' . ChangesList
::flag( 'minor', $this->getContext() );
692 # Sometimes rev_len isn't populated
693 if ( $rev->getSize() !== null ) {
694 # Size is always public data
695 $prevSize = isset( $this->parentLens
[$row->rev_parent_id
] )
696 ?
$this->parentLens
[$row->rev_parent_id
]
698 $sDiff = ChangesList
::showCharacterDifference( $prevSize, $rev->getSize() );
699 $fSize = Linker
::formatRevisionSize( $rev->getSize() );
700 $s .= ' <span class="mw-changeslist-separator">. .</span> ' . "$fSize $sDiff";
703 # Text following the character difference is added just before running hooks
704 $s2 = Linker
::revComment( $rev, false, true );
706 if ( $notificationtimestamp && ( $row->rev_timestamp
>= $notificationtimestamp ) ) {
707 $s2 .= ' <span class="updatedmarker">' . $this->msg( 'updatedmarker' )->escaped() . '</span>';
708 $classes[] = 'mw-history-line-updated';
713 # Rollback and undo links
714 if ( $prevRev && $this->getTitle()->quickUserCan( 'edit', $user ) ) {
715 if ( $latest && $this->getTitle()->quickUserCan( 'rollback', $user ) ) {
716 // Get a rollback link without the brackets
717 $rollbackLink = Linker
::generateRollback(
720 [ 'verify', 'noBrackets' ]
722 if ( $rollbackLink ) {
723 $this->preventClickjacking();
724 $tools[] = $rollbackLink;
728 if ( !$rev->isDeleted( Revision
::DELETED_TEXT
)
729 && !$prevRev->isDeleted( Revision
::DELETED_TEXT
)
731 # Create undo tooltip for the first (=latest) line only
732 $undoTooltip = $latest
733 ?
[ 'title' => $this->msg( 'tooltip-undo' )->text() ]
735 $undolink = Linker
::linkKnown(
737 $this->msg( 'editundo' )->escaped(),
741 'undoafter' => $prevRev->getId(),
742 'undo' => $rev->getId()
745 $tools[] = "<span class=\"mw-history-undo\">{$undolink}</span>";
748 // Allow extension to add their own links here
749 Hooks
::run( 'HistoryRevisionTools', [ $rev, &$tools, $prevRev, $user ] );
752 $s2 .= ' ' . $this->msg( 'parentheses' )->rawParams( $lang->pipeList( $tools ) )->escaped();
756 list( $tagSummary, $newClasses ) = ChangeTags
::formatSummaryRow(
761 $classes = array_merge( $classes, $newClasses );
762 if ( $tagSummary !== '' ) {
763 $s2 .= " $tagSummary";
766 # Include separator between character difference and following text
768 $s .= ' <span class="mw-changeslist-separator">. .</span> ' . $s2;
771 Hooks
::run( 'PageHistoryLineEnding', [ $this, &$row, &$s, &$classes ] );
775 $attribs['class'] = implode( ' ', $classes );
778 return Xml
::tags( 'li', $attribs, $s ) . "\n";
782 * Create a link to view this revision of the page
784 * @param Revision $rev
787 function revLink( $rev ) {
788 $date = $this->getLanguage()->userTimeAndDate( $rev->getTimestamp(), $this->getUser() );
789 $date = htmlspecialchars( $date );
790 if ( $rev->userCan( Revision
::DELETED_TEXT
, $this->getUser() ) ) {
791 $link = Linker
::linkKnown(
794 [ 'class' => 'mw-changeslist-date' ],
795 [ 'oldid' => $rev->getId() ]
800 if ( $rev->isDeleted( Revision
::DELETED_TEXT
) ) {
801 $link = "<span class=\"history-deleted\">$link</span>";
808 * Create a diff-to-current link for this revision for this page
810 * @param Revision $rev
811 * @param bool $latest This is the latest revision of the page?
814 function curLink( $rev, $latest ) {
815 $cur = $this->historyPage
->message
['cur'];
816 if ( $latest ||
!$rev->userCan( Revision
::DELETED_TEXT
, $this->getUser() ) ) {
819 return Linker
::linkKnown(
824 'diff' => $this->getWikiPage()->getLatest(),
825 'oldid' => $rev->getId()
832 * Create a diff-to-previous link for this revision for this page.
834 * @param Revision $prevRev The revision being displayed
835 * @param stdClass|string|null $next The next revision in list (that is
836 * the previous one in chronological order).
837 * May either be a row, "unknown" or null.
840 function lastLink( $prevRev, $next ) {
841 $last = $this->historyPage
->message
['last'];
843 if ( $next === null ) {
844 # Probably no next row
848 if ( $next === 'unknown' ) {
849 # Next row probably exists but is unknown, use an oldid=prev link
850 return Linker
::linkKnown(
855 'diff' => $prevRev->getId(),
861 $nextRev = new Revision( $next );
863 if ( !$prevRev->userCan( Revision
::DELETED_TEXT
, $this->getUser() )
864 ||
!$nextRev->userCan( Revision
::DELETED_TEXT
, $this->getUser() )
869 return Linker
::linkKnown(
874 'diff' => $prevRev->getId(),
875 'oldid' => $next->rev_id
881 * Create radio buttons for page history
883 * @param Revision $rev
884 * @param bool $firstInList Is this version the first one?
886 * @return string HTML output for the radio buttons
888 function diffButtons( $rev, $firstInList ) {
889 if ( $this->getNumRows() > 1 ) {
891 $radio = [ 'type' => 'radio', 'value' => $id ];
892 /** @todo Move title texts to javascript */
893 if ( $firstInList ) {
894 $first = Xml
::element( 'input',
895 array_merge( $radio, [
896 'style' => 'visibility:hidden',
898 'id' => 'mw-oldid-null' ] )
900 $checkmark = [ 'checked' => 'checked' ];
902 # Check visibility of old revisions
903 if ( !$rev->userCan( Revision
::DELETED_TEXT
, $this->getUser() ) ) {
904 $radio['disabled'] = 'disabled';
905 $checkmark = []; // We will check the next possible one
906 } elseif ( !$this->oldIdChecked
) {
907 $checkmark = [ 'checked' => 'checked' ];
908 $this->oldIdChecked
= $id;
912 $first = Xml
::element( 'input',
913 array_merge( $radio, $checkmark, [
915 'id' => "mw-oldid-$id" ] ) );
918 $second = Xml
::element( 'input',
919 array_merge( $radio, $checkmark, [
921 'id' => "mw-diff-$id" ] ) );
923 return $first . $second;
930 * This is called if a write operation is possible from the generated HTML
931 * @param bool $enable
933 function preventClickjacking( $enable = true ) {
934 $this->preventClickjacking
= $enable;
938 * Get the "prevent clickjacking" flag
941 function getPreventClickjacking() {
942 return $this->preventClickjacking
;