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 $out->addModuleStyles( 'mediawiki.special.changeslist' );
121 if ( $config->get( 'UseMediaWikiUIEverywhere' ) ) {
122 $out = $this->getOutput();
123 $out->addModuleStyles( [
124 'mediawiki.ui.input',
125 'mediawiki.ui.checkbox',
129 // Handle atom/RSS feeds.
130 $feedType = $request->getVal( 'feed' );
132 $this->feed( $feedType );
137 $this->addHelpLink( '//meta.wikimedia.org/wiki/Special:MyLanguage/Help:Page_history', true );
139 // Fail nicely if article doesn't exist.
140 if ( !$this->page
->exists() ) {
141 $out->addWikiMsg( 'nohistory' );
142 # show deletion/move log if there is an entry
143 LogEventsList
::showLogExtract(
145 [ 'delete', 'move' ],
149 'conds' => [ "log_action != 'revision'" ],
150 'showIfEmpty' => false,
151 'msgKey' => [ 'moveddeleted-notice' ]
159 * Add date selector to quickly get to a certain time
161 $year = $request->getInt( 'year' );
162 $month = $request->getInt( 'month' );
163 $tagFilter = $request->getVal( 'tagfilter' );
164 $tagSelector = ChangeTags
::buildTagFilterSelector( $tagFilter );
167 * Option to show only revisions that have been (partially) hidden via RevisionDelete
169 if ( $request->getBool( 'deleted' ) ) {
170 $conds = [ 'rev_deleted != 0' ];
174 if ( $this->getUser()->isAllowed( 'deletedhistory' ) ) {
175 $checkDeleted = Xml
::checkLabel( $this->msg( 'history-show-deleted' )->text(),
176 'deleted', 'mw-show-deleted-only', $request->getBool( 'deleted' ) ) . "\n";
181 // Add the general form
182 $action = htmlspecialchars( wfScript() );
184 "<form action=\"$action\" method=\"get\" id=\"mw-history-searchform\">" .
186 $this->msg( 'history-fieldset-title' )->text(),
188 [ 'id' => 'mw-history-search' ]
190 Html
::hidden( 'title', $this->getTitle()->getPrefixedDBkey() ) . "\n" .
191 Html
::hidden( 'action', 'history' ) . "\n" .
193 ( $year == null ? MWTimestamp
::getLocalInstance()->format( 'Y' ) : $year ),
196 ( $tagSelector ?
( implode( ' ', $tagSelector ) . ' ' ) : '' ) .
199 $this->msg( 'historyaction-submit' )->text(),
201 [ 'mw-ui-progressive' ]
206 Hooks
::run( 'PageHistoryBeforeList', [ &$this->page
, $this->getContext() ] );
208 // Create and output the list.
209 $pager = new HistoryPager( $this, $year, $month, $tagFilter, $conds );
211 $pager->getNavigationBar() .
213 $pager->getNavigationBar()
215 $out->preventClickjacking( $pager->getPreventClickjacking() );
220 * Fetch an array of revisions, specified by a given limit, offset and
221 * direction. This is now only used by the feeds. It was previously
222 * used by the main UI but that's now handled by the pager.
224 * @param int $limit The limit number of revisions to get
226 * @param int $direction Either self::DIR_PREV or self::DIR_NEXT
227 * @return ResultWrapper
229 function fetchRevisions( $limit, $offset, $direction ) {
230 // Fail if article doesn't exist.
231 if ( !$this->getTitle()->exists() ) {
232 return new FakeResultWrapper( [] );
235 $dbr = wfGetDB( DB_SLAVE
);
237 if ( $direction === self
::DIR_PREV
) {
238 list( $dirs, $oper ) = [ "ASC", ">=" ];
239 } else { /* $direction === self::DIR_NEXT */
240 list( $dirs, $oper ) = [ "DESC", "<=" ];
244 $offsets = [ "rev_timestamp $oper " . $dbr->addQuotes( $dbr->timestamp( $offset ) ) ];
249 $page_id = $this->page
->getId();
251 return $dbr->select( 'revision',
252 Revision
::selectFields(),
253 array_merge( [ 'rev_page' => $page_id ], $offsets ),
255 [ 'ORDER BY' => "rev_timestamp $dirs",
256 'USE INDEX' => 'page_timestamp', 'LIMIT' => $limit ]
261 * Output a subscription feed listing recent edits to this page.
263 * @param string $type Feed type
265 function feed( $type ) {
266 if ( !FeedUtils
::checkFeedOutput( $type ) ) {
269 $request = $this->getRequest();
271 $feedClasses = $this->context
->getConfig()->get( 'FeedClasses' );
272 /** @var RSSFeed|AtomFeed $feed */
273 $feed = new $feedClasses[$type](
274 $this->getTitle()->getPrefixedText() . ' - ' .
275 $this->msg( 'history-feed-title' )->inContentLanguage()->text(),
276 $this->msg( 'history-feed-description' )->inContentLanguage()->text(),
277 $this->getTitle()->getFullURL( 'action=history' )
280 // Get a limit on number of feed entries. Provide a sane default
281 // of 10 if none is defined (but limit to $wgFeedLimit max)
282 $limit = $request->getInt( 'limit', 10 );
285 $this->context
->getConfig()->get( 'FeedLimit' )
288 $items = $this->fetchRevisions( $limit, 0, self
::DIR_NEXT
);
290 // Generate feed elements enclosed between header and footer.
292 if ( $items->numRows() ) {
293 foreach ( $items as $row ) {
294 $feed->outItem( $this->feedItem( $row ) );
297 $feed->outItem( $this->feedEmpty() );
302 function feedEmpty() {
304 $this->msg( 'nohistory' )->inContentLanguage()->text(),
305 $this->msg( 'history-feed-empty' )->inContentLanguage()->parseAsBlock(),
306 $this->getTitle()->getFullURL(),
307 wfTimestamp( TS_MW
),
309 $this->getTitle()->getTalkPage()->getFullURL()
314 * Generate a FeedItem object from a given revision table row
315 * Borrows Recent Changes' feed generation functions for formatting;
316 * includes a diff to the previous revision (if any).
318 * @param stdClass|array $row Database row
321 function feedItem( $row ) {
322 $rev = new Revision( $row );
323 $rev->setTitle( $this->getTitle() );
324 $text = FeedUtils
::formatDiffRow(
326 $this->getTitle()->getPreviousRevisionID( $rev->getId() ),
328 $rev->getTimestamp(),
331 if ( $rev->getComment() == '' ) {
333 $title = $this->msg( 'history-feed-item-nocomment',
335 $wgContLang->timeanddate( $rev->getTimestamp() ),
336 $wgContLang->date( $rev->getTimestamp() ),
337 $wgContLang->time( $rev->getTimestamp() ) )->inContentLanguage()->text();
339 $title = $rev->getUserText() .
340 $this->msg( 'colon-separator' )->inContentLanguage()->text() .
341 FeedItem
::stripComment( $rev->getComment() );
347 $this->getTitle()->getFullURL( 'diff=' . $rev->getId() . '&oldid=prev' ),
348 $rev->getTimestamp(),
350 $this->getTitle()->getTalkPage()->getFullURL()
359 class HistoryPager
extends ReverseChronologicalPager
{
363 public $lastRow = false;
365 public $counter, $historyPage, $buttons, $conds;
367 protected $oldIdChecked;
369 protected $preventClickjacking = false;
373 protected $parentLens;
375 /** @var bool Whether to show the tag editing UI */
376 protected $showTagEditUI;
379 * @param HistoryAction $historyPage
380 * @param string $year
381 * @param string $month
382 * @param string $tagFilter
383 * @param array $conds
385 function __construct( $historyPage, $year = '', $month = '', $tagFilter = '', $conds = [] ) {
386 parent
::__construct( $historyPage->getContext() );
387 $this->historyPage
= $historyPage;
388 $this->tagFilter
= $tagFilter;
389 $this->getDateCond( $year, $month );
390 $this->conds
= $conds;
391 $this->showTagEditUI
= ChangeTags
::showTagEditingUI( $this->getUser() );
394 // For hook compatibility...
395 function getArticle() {
396 return $this->historyPage
->getArticle();
399 function getSqlComment() {
400 if ( $this->conds
) {
401 return 'history page filtered'; // potentially slow, see CR r58153
403 return 'history page unfiltered';
407 function getQueryInfo() {
409 'tables' => [ 'revision', 'user' ],
410 'fields' => array_merge( Revision
::selectFields(), Revision
::selectUserFields() ),
411 'conds' => array_merge(
412 [ 'rev_page' => $this->getWikiPage()->getId() ],
414 'options' => [ 'USE INDEX' => [ 'revision' => 'page_timestamp' ] ],
415 'join_conds' => [ 'user' => Revision
::userJoinCond() ],
417 ChangeTags
::modifyDisplayQuery(
418 $queryInfo['tables'],
419 $queryInfo['fields'],
421 $queryInfo['join_conds'],
422 $queryInfo['options'],
425 Hooks
::run( 'PageHistoryPager::getQueryInfo', [ &$this, &$queryInfo ] );
430 function getIndexField() {
431 return 'rev_timestamp';
435 * @param stdClass $row
438 function formatRow( $row ) {
439 if ( $this->lastRow
) {
440 $latest = ( $this->counter
== 1 && $this->mIsFirst
);
441 $firstInList = $this->counter
== 1;
444 $notifTimestamp = $this->getConfig()->get( 'ShowUpdatedMarker' )
445 ?
$this->getTitle()->getNotificationTimestamp( $this->getUser() )
448 $s = $this->historyLine(
449 $this->lastRow
, $row, $notifTimestamp, $latest, $firstInList );
453 $this->lastRow
= $row;
458 function doBatchLookups() {
459 if ( !Hooks
::run( 'PageHistoryPager::doBatchLookups', [ $this, $this->mResult
] ) ) {
463 # Do a link batch query
464 $this->mResult
->seek( 0 );
465 $batch = new LinkBatch();
467 foreach ( $this->mResult
as $row ) {
468 if ( $row->rev_parent_id
) {
469 $revIds[] = $row->rev_parent_id
;
471 if ( !is_null( $row->user_name
) ) {
472 $batch->add( NS_USER
, $row->user_name
);
473 $batch->add( NS_USER_TALK
, $row->user_name
);
474 } else { # for anons or usernames of imported revisions
475 $batch->add( NS_USER
, $row->rev_user_text
);
476 $batch->add( NS_USER_TALK
, $row->rev_user_text
);
479 $this->parentLens
= Revision
::getParentLengths( $this->mDb
, $revIds );
481 $this->mResult
->seek( 0 );
485 * Creates begin of history list with a submit button
487 * @return string HTML output
489 function getStartBody() {
490 $this->lastRow
= false;
492 $this->oldIdChecked
= 0;
494 $this->getOutput()->wrapWikiMsg( "<div class='mw-history-legend'>\n$1\n</div>", 'histlegend' );
495 $s = Html
::openElement( 'form', [ 'action' => wfScript(),
496 'id' => 'mw-history-compare' ] ) . "\n";
497 $s .= Html
::hidden( 'title', $this->getTitle()->getPrefixedDBkey() ) . "\n";
498 $s .= Html
::hidden( 'action', 'historysubmit' ) . "\n";
499 $s .= Html
::hidden( 'type', 'revision' ) . "\n";
501 // Button container stored in $this->buttons for re-use in getEndBody()
502 $this->buttons
= '<div>';
503 $className = 'historysubmit mw-history-compareselectedversions-button';
504 $attrs = [ 'class' => $className ]
505 + Linker
::tooltipAndAccesskeyAttribs( 'compareselectedversions' );
506 $this->buttons
.= $this->submitButton( $this->msg( 'compareselectedversions' )->text(),
510 $user = $this->getUser();
512 if ( $user->isAllowed( 'deleterevision' ) ) {
513 $actionButtons .= $this->getRevisionButton( 'revisiondelete', 'showhideselectedversions' );
515 if ( $this->showTagEditUI
) {
516 $actionButtons .= $this->getRevisionButton( 'editchangetags', 'history-edit-tags' );
518 if ( $actionButtons ) {
519 $this->buttons
.= Xml
::tags( 'div', [ 'class' =>
520 'mw-history-revisionactions' ], $actionButtons );
523 if ( $user->isAllowed( 'deleterevision' ) ||
$this->showTagEditUI
) {
524 $this->buttons
.= ( new ListToggle( $this->getOutput() ) )->getHTML();
527 $this->buttons
.= '</div>';
529 $s .= $this->buttons
;
530 $s .= '<ul id="pagehistory">' . "\n";
535 private function getRevisionButton( $name, $msg ) {
536 $this->preventClickjacking();
537 # Note bug #20966, <button> is non-standard in IE<8
538 $element = Html
::element(
544 'class' => "historysubmit mw-history-$name-button",
546 $this->msg( $msg )->text()
551 function getEndBody() {
552 if ( $this->lastRow
) {
553 $latest = $this->counter
== 1 && $this->mIsFirst
;
554 $firstInList = $this->counter
== 1;
555 if ( $this->mIsBackwards
) {
556 # Next row is unknown, but for UI reasons, probably exists if an offset has been specified
557 if ( $this->mOffset
== '' ) {
563 # The next row is the past-the-end row
564 $next = $this->mPastTheEndRow
;
568 $notifTimestamp = $this->getConfig()->get( 'ShowUpdatedMarker' )
569 ?
$this->getTitle()->getNotificationTimestamp( $this->getUser() )
572 $s = $this->historyLine(
573 $this->lastRow
, $next, $notifTimestamp, $latest, $firstInList );
578 # Add second buttons only if there is more than one rev
579 if ( $this->getNumRows() > 2 ) {
580 $s .= $this->buttons
;
588 * Creates a submit button
590 * @param string $message Text of the submit button, will be escaped
591 * @param array $attributes Attributes
592 * @return string HTML output for the submit button
594 function submitButton( $message, $attributes = [] ) {
595 # Disable submit button if history has 1 revision only
596 if ( $this->getNumRows() > 1 ) {
597 return Html
::submitButton( $message, $attributes );
604 * Returns a row from the history printout.
606 * @todo document some more, and maybe clean up the code (some params redundant?)
608 * @param stdClass $row The database row corresponding to the previous line.
609 * @param mixed $next The database row corresponding to the next line
610 * (chronologically previous)
611 * @param bool|string $notificationtimestamp
612 * @param bool $latest Whether this row corresponds to the page's latest revision.
613 * @param bool $firstInList Whether this row corresponds to the first
614 * displayed on this history page.
615 * @return string HTML output for the row
617 function historyLine( $row, $next, $notificationtimestamp = false,
618 $latest = false, $firstInList = false ) {
619 $rev = new Revision( $row );
620 $rev->setTitle( $this->getTitle() );
622 if ( is_object( $next ) ) {
623 $prevRev = new Revision( $next );
624 $prevRev->setTitle( $this->getTitle() );
629 $curlink = $this->curLink( $rev, $latest );
630 $lastlink = $this->lastLink( $rev, $next );
631 $curLastlinks = $curlink . $this->historyPage
->message
['pipe-separator'] . $lastlink;
632 $histLinks = Html
::rawElement(
634 [ 'class' => 'mw-history-histlinks' ],
635 $this->msg( 'parentheses' )->rawParams( $curLastlinks )->escaped()
638 $diffButtons = $this->diffButtons( $rev, $firstInList );
639 $s = $histLinks . $diffButtons;
641 $link = $this->revLink( $rev );
645 $user = $this->getUser();
646 $canRevDelete = $user->isAllowed( 'deleterevision' );
647 // Show checkboxes for each revision, to allow for revision deletion and
649 if ( $canRevDelete ||
$this->showTagEditUI
) {
650 $this->preventClickjacking();
651 // If revision was hidden from sysops and we don't need the checkbox
652 // for anything else, disable it
653 if ( !$this->showTagEditUI
&& !$rev->userCan( Revision
::DELETED_RESTRICTED
, $user ) ) {
654 $del = Xml
::check( 'deleterevisions', false, [ 'disabled' => 'disabled' ] );
655 // Otherwise, enable the checkbox...
657 $del = Xml
::check( 'showhiderevisions', false,
658 [ 'name' => 'ids[' . $rev->getId() . ']' ] );
660 // User can only view deleted revisions...
661 } elseif ( $rev->getVisibility() && $user->isAllowed( 'deletedhistory' ) ) {
662 // If revision was hidden from sysops, disable the link
663 if ( !$rev->userCan( Revision
::DELETED_RESTRICTED
, $user ) ) {
664 $del = Linker
::revDeleteLinkDisabled( false );
665 // Otherwise, show the link...
667 $query = [ 'type' => 'revision',
668 'target' => $this->getTitle()->getPrefixedDBkey(), 'ids' => $rev->getId() ];
669 $del .= Linker
::revDeleteLink( $query,
670 $rev->isDeleted( Revision
::DELETED_RESTRICTED
), false );
677 $lang = $this->getLanguage();
678 $dirmark = $lang->getDirMark();
682 $s .= " <span class='history-user'>" .
683 Linker
::revUserTools( $rev, true ) . "</span>";
686 if ( $rev->isMinor() ) {
687 $s .= ' ' . ChangesList
::flag( 'minor', $this->getContext() );
690 # Sometimes rev_len isn't populated
691 if ( $rev->getSize() !== null ) {
692 # Size is always public data
693 $prevSize = isset( $this->parentLens
[$row->rev_parent_id
] )
694 ?
$this->parentLens
[$row->rev_parent_id
]
696 $sDiff = ChangesList
::showCharacterDifference( $prevSize, $rev->getSize() );
697 $fSize = Linker
::formatRevisionSize( $rev->getSize() );
698 $s .= ' <span class="mw-changeslist-separator">. .</span> ' . "$fSize $sDiff";
701 # Text following the character difference is added just before running hooks
702 $s2 = Linker
::revComment( $rev, false, true );
704 if ( $notificationtimestamp && ( $row->rev_timestamp
>= $notificationtimestamp ) ) {
705 $s2 .= ' <span class="updatedmarker">' . $this->msg( 'updatedmarker' )->escaped() . '</span>';
706 $classes[] = 'mw-history-line-updated';
711 # Rollback and undo links
712 if ( $prevRev && $this->getTitle()->quickUserCan( 'edit', $user ) ) {
713 if ( $latest && $this->getTitle()->quickUserCan( 'rollback', $user ) ) {
714 // Get a rollback link without the brackets
715 $rollbackLink = Linker
::generateRollback(
718 [ 'verify', 'noBrackets' ]
720 if ( $rollbackLink ) {
721 $this->preventClickjacking();
722 $tools[] = $rollbackLink;
726 if ( !$rev->isDeleted( Revision
::DELETED_TEXT
)
727 && !$prevRev->isDeleted( Revision
::DELETED_TEXT
)
729 # Create undo tooltip for the first (=latest) line only
730 $undoTooltip = $latest
731 ?
[ 'title' => $this->msg( 'tooltip-undo' )->text() ]
733 $undolink = Linker
::linkKnown(
735 $this->msg( 'editundo' )->escaped(),
739 'undoafter' => $prevRev->getId(),
740 'undo' => $rev->getId()
743 $tools[] = "<span class=\"mw-history-undo\">{$undolink}</span>";
746 // Allow extension to add their own links here
747 Hooks
::run( 'HistoryRevisionTools', [ $rev, &$tools, $prevRev, $user ] );
750 $s2 .= ' ' . $this->msg( 'parentheses' )->rawParams( $lang->pipeList( $tools ) )->escaped();
754 list( $tagSummary, $newClasses ) = ChangeTags
::formatSummaryRow(
759 $classes = array_merge( $classes, $newClasses );
760 if ( $tagSummary !== '' ) {
761 $s2 .= " $tagSummary";
764 # Include separator between character difference and following text
766 $s .= ' <span class="mw-changeslist-separator">. .</span> ' . $s2;
769 Hooks
::run( 'PageHistoryLineEnding', [ $this, &$row, &$s, &$classes ] );
773 $attribs['class'] = implode( ' ', $classes );
776 return Xml
::tags( 'li', $attribs, $s ) . "\n";
780 * Create a link to view this revision of the page
782 * @param Revision $rev
785 function revLink( $rev ) {
786 $date = $this->getLanguage()->userTimeAndDate( $rev->getTimestamp(), $this->getUser() );
787 $date = htmlspecialchars( $date );
788 if ( $rev->userCan( Revision
::DELETED_TEXT
, $this->getUser() ) ) {
789 $link = Linker
::linkKnown(
792 [ 'class' => 'mw-changeslist-date' ],
793 [ 'oldid' => $rev->getId() ]
798 if ( $rev->isDeleted( Revision
::DELETED_TEXT
) ) {
799 $link = "<span class=\"history-deleted\">$link</span>";
806 * Create a diff-to-current link for this revision for this page
808 * @param Revision $rev
809 * @param bool $latest This is the latest revision of the page?
812 function curLink( $rev, $latest ) {
813 $cur = $this->historyPage
->message
['cur'];
814 if ( $latest ||
!$rev->userCan( Revision
::DELETED_TEXT
, $this->getUser() ) ) {
817 return Linker
::linkKnown(
822 'diff' => $this->getWikiPage()->getLatest(),
823 'oldid' => $rev->getId()
830 * Create a diff-to-previous link for this revision for this page.
832 * @param Revision $prevRev The revision being displayed
833 * @param stdClass|string|null $next The next revision in list (that is
834 * the previous one in chronological order).
835 * May either be a row, "unknown" or null.
838 function lastLink( $prevRev, $next ) {
839 $last = $this->historyPage
->message
['last'];
841 if ( $next === null ) {
842 # Probably no next row
846 if ( $next === 'unknown' ) {
847 # Next row probably exists but is unknown, use an oldid=prev link
848 return Linker
::linkKnown(
853 'diff' => $prevRev->getId(),
859 $nextRev = new Revision( $next );
861 if ( !$prevRev->userCan( Revision
::DELETED_TEXT
, $this->getUser() )
862 ||
!$nextRev->userCan( Revision
::DELETED_TEXT
, $this->getUser() )
867 return Linker
::linkKnown(
872 'diff' => $prevRev->getId(),
873 'oldid' => $next->rev_id
879 * Create radio buttons for page history
881 * @param Revision $rev
882 * @param bool $firstInList Is this version the first one?
884 * @return string HTML output for the radio buttons
886 function diffButtons( $rev, $firstInList ) {
887 if ( $this->getNumRows() > 1 ) {
889 $radio = [ 'type' => 'radio', 'value' => $id ];
890 /** @todo Move title texts to javascript */
891 if ( $firstInList ) {
892 $first = Xml
::element( 'input',
893 array_merge( $radio, [
894 'style' => 'visibility:hidden',
896 'id' => 'mw-oldid-null' ] )
898 $checkmark = [ 'checked' => 'checked' ];
900 # Check visibility of old revisions
901 if ( !$rev->userCan( Revision
::DELETED_TEXT
, $this->getUser() ) ) {
902 $radio['disabled'] = 'disabled';
903 $checkmark = []; // We will check the next possible one
904 } elseif ( !$this->oldIdChecked
) {
905 $checkmark = [ 'checked' => 'checked' ];
906 $this->oldIdChecked
= $id;
910 $first = Xml
::element( 'input',
911 array_merge( $radio, $checkmark, [
913 'id' => "mw-oldid-$id" ] ) );
916 $second = Xml
::element( 'input',
917 array_merge( $radio, $checkmark, [
919 'id' => "mw-diff-$id" ] ) );
921 return $first . $second;
928 * This is called if a write operation is possible from the generated HTML
929 * @param bool $enable
931 function preventClickjacking( $enable = true ) {
932 $this->preventClickjacking
= $enable;
936 * Get the "prevent clickjacking" flag
939 function getPreventClickjacking() {
940 return $this->preventClickjacking
;