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 if ( $config->get( 'UseMediaWikiUIEverywhere' ) ) {
120 $out = $this->getOutput();
121 $out->addModuleStyles( [
122 'mediawiki.ui.input',
123 'mediawiki.ui.checkbox',
127 // Handle atom/RSS feeds.
128 $feedType = $request->getVal( 'feed' );
130 $this->feed( $feedType );
135 $this->addHelpLink( '//meta.wikimedia.org/wiki/Special:MyLanguage/Help:Page_history', true );
137 // Fail nicely if article doesn't exist.
138 if ( !$this->page
->exists() ) {
139 $out->addWikiMsg( 'nohistory' );
140 # show deletion/move log if there is an entry
141 LogEventsList
::showLogExtract(
143 [ 'delete', 'move' ],
147 'conds' => [ "log_action != 'revision'" ],
148 'showIfEmpty' => false,
149 'msgKey' => [ 'moveddeleted-notice' ]
157 * Add date selector to quickly get to a certain time
159 $year = $request->getInt( 'year' );
160 $month = $request->getInt( 'month' );
161 $tagFilter = $request->getVal( 'tagfilter' );
162 $tagSelector = ChangeTags
::buildTagFilterSelector( $tagFilter );
165 * Option to show only revisions that have been (partially) hidden via RevisionDelete
167 if ( $request->getBool( 'deleted' ) ) {
168 $conds = [ 'rev_deleted != 0' ];
172 if ( $this->getUser()->isAllowed( 'deletedhistory' ) ) {
173 $checkDeleted = Xml
::checkLabel( $this->msg( 'history-show-deleted' )->text(),
174 'deleted', 'mw-show-deleted-only', $request->getBool( 'deleted' ) ) . "\n";
179 // Add the general form
180 $action = htmlspecialchars( wfScript() );
182 "<form action=\"$action\" method=\"get\" id=\"mw-history-searchform\">" .
184 $this->msg( 'history-fieldset-title' )->text(),
186 [ 'id' => 'mw-history-search' ]
188 Html
::hidden( 'title', $this->getTitle()->getPrefixedDBkey() ) . "\n" .
189 Html
::hidden( 'action', 'history' ) . "\n" .
191 ( $year == null ? MWTimestamp
::getLocalInstance()->format( 'Y' ) : $year ),
194 ( $tagSelector ?
( implode( ' ', $tagSelector ) . ' ' ) : '' ) .
197 $this->msg( 'historyaction-submit' )->text(),
199 [ 'mw-ui-progressive' ]
204 Hooks
::run( 'PageHistoryBeforeList', [ &$this->page
, $this->getContext() ] );
206 // Create and output the list.
207 $pager = new HistoryPager( $this, $year, $month, $tagFilter, $conds );
209 $pager->getNavigationBar() .
211 $pager->getNavigationBar()
213 $out->preventClickjacking( $pager->getPreventClickjacking() );
218 * Fetch an array of revisions, specified by a given limit, offset and
219 * direction. This is now only used by the feeds. It was previously
220 * used by the main UI but that's now handled by the pager.
222 * @param int $limit The limit number of revisions to get
224 * @param int $direction Either self::DIR_PREV or self::DIR_NEXT
225 * @return ResultWrapper
227 function fetchRevisions( $limit, $offset, $direction ) {
228 // Fail if article doesn't exist.
229 if ( !$this->getTitle()->exists() ) {
230 return new FakeResultWrapper( [] );
233 $dbr = wfGetDB( DB_SLAVE
);
235 if ( $direction === self
::DIR_PREV
) {
236 list( $dirs, $oper ) = [ "ASC", ">=" ];
237 } else { /* $direction === self::DIR_NEXT */
238 list( $dirs, $oper ) = [ "DESC", "<=" ];
242 $offsets = [ "rev_timestamp $oper " . $dbr->addQuotes( $dbr->timestamp( $offset ) ) ];
247 $page_id = $this->page
->getId();
249 return $dbr->select( 'revision',
250 Revision
::selectFields(),
251 array_merge( [ 'rev_page' => $page_id ], $offsets ),
253 [ 'ORDER BY' => "rev_timestamp $dirs",
254 'USE INDEX' => 'page_timestamp', 'LIMIT' => $limit ]
259 * Output a subscription feed listing recent edits to this page.
261 * @param string $type Feed type
263 function feed( $type ) {
264 if ( !FeedUtils
::checkFeedOutput( $type ) ) {
267 $request = $this->getRequest();
269 $feedClasses = $this->context
->getConfig()->get( 'FeedClasses' );
270 /** @var RSSFeed|AtomFeed $feed */
271 $feed = new $feedClasses[$type](
272 $this->getTitle()->getPrefixedText() . ' - ' .
273 $this->msg( 'history-feed-title' )->inContentLanguage()->text(),
274 $this->msg( 'history-feed-description' )->inContentLanguage()->text(),
275 $this->getTitle()->getFullURL( 'action=history' )
278 // Get a limit on number of feed entries. Provide a sane default
279 // of 10 if none is defined (but limit to $wgFeedLimit max)
280 $limit = $request->getInt( 'limit', 10 );
283 $this->context
->getConfig()->get( 'FeedLimit' )
286 $items = $this->fetchRevisions( $limit, 0, self
::DIR_NEXT
);
288 // Generate feed elements enclosed between header and footer.
290 if ( $items->numRows() ) {
291 foreach ( $items as $row ) {
292 $feed->outItem( $this->feedItem( $row ) );
295 $feed->outItem( $this->feedEmpty() );
300 function feedEmpty() {
302 $this->msg( 'nohistory' )->inContentLanguage()->text(),
303 $this->msg( 'history-feed-empty' )->inContentLanguage()->parseAsBlock(),
304 $this->getTitle()->getFullURL(),
305 wfTimestamp( TS_MW
),
307 $this->getTitle()->getTalkPage()->getFullURL()
312 * Generate a FeedItem object from a given revision table row
313 * Borrows Recent Changes' feed generation functions for formatting;
314 * includes a diff to the previous revision (if any).
316 * @param stdClass|array $row Database row
319 function feedItem( $row ) {
320 $rev = new Revision( $row );
321 $rev->setTitle( $this->getTitle() );
322 $text = FeedUtils
::formatDiffRow(
324 $this->getTitle()->getPreviousRevisionID( $rev->getId() ),
326 $rev->getTimestamp(),
329 if ( $rev->getComment() == '' ) {
331 $title = $this->msg( 'history-feed-item-nocomment',
333 $wgContLang->timeanddate( $rev->getTimestamp() ),
334 $wgContLang->date( $rev->getTimestamp() ),
335 $wgContLang->time( $rev->getTimestamp() ) )->inContentLanguage()->text();
337 $title = $rev->getUserText() .
338 $this->msg( 'colon-separator' )->inContentLanguage()->text() .
339 FeedItem
::stripComment( $rev->getComment() );
345 $this->getTitle()->getFullURL( 'diff=' . $rev->getId() . '&oldid=prev' ),
346 $rev->getTimestamp(),
348 $this->getTitle()->getTalkPage()->getFullURL()
357 class HistoryPager
extends ReverseChronologicalPager
{
361 public $lastRow = false;
363 public $counter, $historyPage, $buttons, $conds;
365 protected $oldIdChecked;
367 protected $preventClickjacking = false;
371 protected $parentLens;
373 /** @var bool Whether to show the tag editing UI */
374 protected $showTagEditUI;
377 * @param HistoryAction $historyPage
378 * @param string $year
379 * @param string $month
380 * @param string $tagFilter
381 * @param array $conds
383 function __construct( $historyPage, $year = '', $month = '', $tagFilter = '', $conds = [] ) {
384 parent
::__construct( $historyPage->getContext() );
385 $this->historyPage
= $historyPage;
386 $this->tagFilter
= $tagFilter;
387 $this->getDateCond( $year, $month );
388 $this->conds
= $conds;
389 $this->showTagEditUI
= ChangeTags
::showTagEditingUI( $this->getUser() );
392 // For hook compatibility...
393 function getArticle() {
394 return $this->historyPage
->getArticle();
397 function getSqlComment() {
398 if ( $this->conds
) {
399 return 'history page filtered'; // potentially slow, see CR r58153
401 return 'history page unfiltered';
405 function getQueryInfo() {
407 'tables' => [ 'revision', 'user' ],
408 'fields' => array_merge( Revision
::selectFields(), Revision
::selectUserFields() ),
409 'conds' => array_merge(
410 [ 'rev_page' => $this->getWikiPage()->getId() ],
412 'options' => [ 'USE INDEX' => [ 'revision' => 'page_timestamp' ] ],
413 'join_conds' => [ 'user' => Revision
::userJoinCond() ],
415 ChangeTags
::modifyDisplayQuery(
416 $queryInfo['tables'],
417 $queryInfo['fields'],
419 $queryInfo['join_conds'],
420 $queryInfo['options'],
423 Hooks
::run( 'PageHistoryPager::getQueryInfo', [ &$this, &$queryInfo ] );
428 function getIndexField() {
429 return 'rev_timestamp';
433 * @param stdClass $row
436 function formatRow( $row ) {
437 if ( $this->lastRow
) {
438 $latest = ( $this->counter
== 1 && $this->mIsFirst
);
439 $firstInList = $this->counter
== 1;
442 $notifTimestamp = $this->getConfig()->get( 'ShowUpdatedMarker' )
443 ?
$this->getTitle()->getNotificationTimestamp( $this->getUser() )
446 $s = $this->historyLine(
447 $this->lastRow
, $row, $notifTimestamp, $latest, $firstInList );
451 $this->lastRow
= $row;
456 function doBatchLookups() {
457 if ( !Hooks
::run( 'PageHistoryPager::doBatchLookups', [ $this, $this->mResult
] ) ) {
461 # Do a link batch query
462 $this->mResult
->seek( 0 );
463 $batch = new LinkBatch();
465 foreach ( $this->mResult
as $row ) {
466 if ( $row->rev_parent_id
) {
467 $revIds[] = $row->rev_parent_id
;
469 if ( !is_null( $row->user_name
) ) {
470 $batch->add( NS_USER
, $row->user_name
);
471 $batch->add( NS_USER_TALK
, $row->user_name
);
472 } else { # for anons or usernames of imported revisions
473 $batch->add( NS_USER
, $row->rev_user_text
);
474 $batch->add( NS_USER_TALK
, $row->rev_user_text
);
477 $this->parentLens
= Revision
::getParentLengths( $this->mDb
, $revIds );
479 $this->mResult
->seek( 0 );
483 * Creates begin of history list with a submit button
485 * @return string HTML output
487 function getStartBody() {
488 $this->lastRow
= false;
490 $this->oldIdChecked
= 0;
492 $this->getOutput()->wrapWikiMsg( "<div class='mw-history-legend'>\n$1\n</div>", 'histlegend' );
493 $s = Html
::openElement( 'form', [ 'action' => wfScript(),
494 'id' => 'mw-history-compare' ] ) . "\n";
495 $s .= Html
::hidden( 'title', $this->getTitle()->getPrefixedDBkey() ) . "\n";
496 $s .= Html
::hidden( 'action', 'historysubmit' ) . "\n";
497 $s .= Html
::hidden( 'type', 'revision' ) . "\n";
499 // Button container stored in $this->buttons for re-use in getEndBody()
500 $this->buttons
= '<div>';
501 $className = 'historysubmit mw-history-compareselectedversions-button';
502 $attrs = [ 'class' => $className ]
503 + Linker
::tooltipAndAccesskeyAttribs( 'compareselectedversions' );
504 $this->buttons
.= $this->submitButton( $this->msg( 'compareselectedversions' )->text(),
508 $user = $this->getUser();
510 if ( $user->isAllowed( 'deleterevision' ) ) {
511 $actionButtons .= $this->getRevisionButton( 'revisiondelete', 'showhideselectedversions' );
513 if ( $this->showTagEditUI
) {
514 $actionButtons .= $this->getRevisionButton( 'editchangetags', 'history-edit-tags' );
516 if ( $actionButtons ) {
517 $this->buttons
.= Xml
::tags( 'div', [ 'class' =>
518 'mw-history-revisionactions' ], $actionButtons );
521 if ( $user->isAllowed( 'deleterevision' ) ||
$this->showTagEditUI
) {
522 $this->buttons
.= ( new ListToggle( $this->getOutput() ) )->getHTML();
525 $this->buttons
.= '</div>';
527 $s .= $this->buttons
;
528 $s .= '<ul id="pagehistory">' . "\n";
533 private function getRevisionButton( $name, $msg ) {
534 $this->preventClickjacking();
535 # Note bug #20966, <button> is non-standard in IE<8
536 $element = Html
::element(
542 'class' => "historysubmit mw-history-$name-button",
544 $this->msg( $msg )->text()
549 function getEndBody() {
550 if ( $this->lastRow
) {
551 $latest = $this->counter
== 1 && $this->mIsFirst
;
552 $firstInList = $this->counter
== 1;
553 if ( $this->mIsBackwards
) {
554 # Next row is unknown, but for UI reasons, probably exists if an offset has been specified
555 if ( $this->mOffset
== '' ) {
561 # The next row is the past-the-end row
562 $next = $this->mPastTheEndRow
;
566 $notifTimestamp = $this->getConfig()->get( 'ShowUpdatedMarker' )
567 ?
$this->getTitle()->getNotificationTimestamp( $this->getUser() )
570 $s = $this->historyLine(
571 $this->lastRow
, $next, $notifTimestamp, $latest, $firstInList );
576 # Add second buttons only if there is more than one rev
577 if ( $this->getNumRows() > 2 ) {
578 $s .= $this->buttons
;
586 * Creates a submit button
588 * @param string $message Text of the submit button, will be escaped
589 * @param array $attributes Attributes
590 * @return string HTML output for the submit button
592 function submitButton( $message, $attributes = [] ) {
593 # Disable submit button if history has 1 revision only
594 if ( $this->getNumRows() > 1 ) {
595 return Html
::submitButton( $message, $attributes );
602 * Returns a row from the history printout.
604 * @todo document some more, and maybe clean up the code (some params redundant?)
606 * @param stdClass $row The database row corresponding to the previous line.
607 * @param mixed $next The database row corresponding to the next line
608 * (chronologically previous)
609 * @param bool|string $notificationtimestamp
610 * @param bool $latest Whether this row corresponds to the page's latest revision.
611 * @param bool $firstInList Whether this row corresponds to the first
612 * displayed on this history page.
613 * @return string HTML output for the row
615 function historyLine( $row, $next, $notificationtimestamp = false,
616 $latest = false, $firstInList = false ) {
617 $rev = new Revision( $row );
618 $rev->setTitle( $this->getTitle() );
620 if ( is_object( $next ) ) {
621 $prevRev = new Revision( $next );
622 $prevRev->setTitle( $this->getTitle() );
627 $curlink = $this->curLink( $rev, $latest );
628 $lastlink = $this->lastLink( $rev, $next );
629 $curLastlinks = $curlink . $this->historyPage
->message
['pipe-separator'] . $lastlink;
630 $histLinks = Html
::rawElement(
632 [ 'class' => 'mw-history-histlinks' ],
633 $this->msg( 'parentheses' )->rawParams( $curLastlinks )->escaped()
636 $diffButtons = $this->diffButtons( $rev, $firstInList );
637 $s = $histLinks . $diffButtons;
639 $link = $this->revLink( $rev );
643 $user = $this->getUser();
644 $canRevDelete = $user->isAllowed( 'deleterevision' );
645 // Show checkboxes for each revision, to allow for revision deletion and
647 if ( $canRevDelete ||
$this->showTagEditUI
) {
648 $this->preventClickjacking();
649 // If revision was hidden from sysops and we don't need the checkbox
650 // for anything else, disable it
651 if ( !$this->showTagEditUI
&& !$rev->userCan( Revision
::DELETED_RESTRICTED
, $user ) ) {
652 $del = Xml
::check( 'deleterevisions', false, [ 'disabled' => 'disabled' ] );
653 // Otherwise, enable the checkbox...
655 $del = Xml
::check( 'showhiderevisions', false,
656 [ 'name' => 'ids[' . $rev->getId() . ']' ] );
658 // User can only view deleted revisions...
659 } elseif ( $rev->getVisibility() && $user->isAllowed( 'deletedhistory' ) ) {
660 // If revision was hidden from sysops, disable the link
661 if ( !$rev->userCan( Revision
::DELETED_RESTRICTED
, $user ) ) {
662 $del = Linker
::revDeleteLinkDisabled( false );
663 // Otherwise, show the link...
665 $query = [ 'type' => 'revision',
666 'target' => $this->getTitle()->getPrefixedDBkey(), 'ids' => $rev->getId() ];
667 $del .= Linker
::revDeleteLink( $query,
668 $rev->isDeleted( Revision
::DELETED_RESTRICTED
), false );
675 $lang = $this->getLanguage();
676 $dirmark = $lang->getDirMark();
680 $s .= " <span class='history-user'>" .
681 Linker
::revUserTools( $rev, true ) . "</span>";
684 if ( $rev->isMinor() ) {
685 $s .= ' ' . ChangesList
::flag( 'minor', $this->getContext() );
688 # Sometimes rev_len isn't populated
689 if ( $rev->getSize() !== null ) {
690 # Size is always public data
691 $prevSize = isset( $this->parentLens
[$row->rev_parent_id
] )
692 ?
$this->parentLens
[$row->rev_parent_id
]
694 $sDiff = ChangesList
::showCharacterDifference( $prevSize, $rev->getSize() );
695 $fSize = Linker
::formatRevisionSize( $rev->getSize() );
696 $s .= ' <span class="mw-changeslist-separator">. .</span> ' . "$fSize $sDiff";
699 # Text following the character difference is added just before running hooks
700 $s2 = Linker
::revComment( $rev, false, true );
702 if ( $notificationtimestamp && ( $row->rev_timestamp
>= $notificationtimestamp ) ) {
703 $s2 .= ' <span class="updatedmarker">' . $this->msg( 'updatedmarker' )->escaped() . '</span>';
704 $classes[] = 'mw-history-line-updated';
709 # Rollback and undo links
710 if ( $prevRev && $this->getTitle()->quickUserCan( 'edit', $user ) ) {
711 if ( $latest && $this->getTitle()->quickUserCan( 'rollback', $user ) ) {
712 // Get a rollback link without the brackets
713 $rollbackLink = Linker
::generateRollback(
716 [ 'verify', 'noBrackets' ]
718 if ( $rollbackLink ) {
719 $this->preventClickjacking();
720 $tools[] = $rollbackLink;
724 if ( !$rev->isDeleted( Revision
::DELETED_TEXT
)
725 && !$prevRev->isDeleted( Revision
::DELETED_TEXT
)
727 # Create undo tooltip for the first (=latest) line only
728 $undoTooltip = $latest
729 ?
[ 'title' => $this->msg( 'tooltip-undo' )->text() ]
731 $undolink = Linker
::linkKnown(
733 $this->msg( 'editundo' )->escaped(),
737 'undoafter' => $prevRev->getId(),
738 'undo' => $rev->getId()
741 $tools[] = "<span class=\"mw-history-undo\">{$undolink}</span>";
744 // Allow extension to add their own links here
745 Hooks
::run( 'HistoryRevisionTools', [ $rev, &$tools, $prevRev, $user ] );
748 $s2 .= ' ' . $this->msg( 'parentheses' )->rawParams( $lang->pipeList( $tools ) )->escaped();
752 list( $tagSummary, $newClasses ) = ChangeTags
::formatSummaryRow(
757 $classes = array_merge( $classes, $newClasses );
758 if ( $tagSummary !== '' ) {
759 $s2 .= " $tagSummary";
762 # Include separator between character difference and following text
764 $s .= ' <span class="mw-changeslist-separator">. .</span> ' . $s2;
767 Hooks
::run( 'PageHistoryLineEnding', [ $this, &$row, &$s, &$classes ] );
771 $attribs['class'] = implode( ' ', $classes );
774 return Xml
::tags( 'li', $attribs, $s ) . "\n";
778 * Create a link to view this revision of the page
780 * @param Revision $rev
783 function revLink( $rev ) {
784 $date = $this->getLanguage()->userTimeAndDate( $rev->getTimestamp(), $this->getUser() );
785 $date = htmlspecialchars( $date );
786 if ( $rev->userCan( Revision
::DELETED_TEXT
, $this->getUser() ) ) {
787 $link = Linker
::linkKnown(
790 [ 'class' => 'mw-changeslist-date' ],
791 [ 'oldid' => $rev->getId() ]
796 if ( $rev->isDeleted( Revision
::DELETED_TEXT
) ) {
797 $link = "<span class=\"history-deleted\">$link</span>";
804 * Create a diff-to-current link for this revision for this page
806 * @param Revision $rev
807 * @param bool $latest This is the latest revision of the page?
810 function curLink( $rev, $latest ) {
811 $cur = $this->historyPage
->message
['cur'];
812 if ( $latest ||
!$rev->userCan( Revision
::DELETED_TEXT
, $this->getUser() ) ) {
815 return Linker
::linkKnown(
820 'diff' => $this->getWikiPage()->getLatest(),
821 'oldid' => $rev->getId()
828 * Create a diff-to-previous link for this revision for this page.
830 * @param Revision $prevRev The revision being displayed
831 * @param stdClass|string|null $next The next revision in list (that is
832 * the previous one in chronological order).
833 * May either be a row, "unknown" or null.
836 function lastLink( $prevRev, $next ) {
837 $last = $this->historyPage
->message
['last'];
839 if ( $next === null ) {
840 # Probably no next row
844 if ( $next === 'unknown' ) {
845 # Next row probably exists but is unknown, use an oldid=prev link
846 return Linker
::linkKnown(
851 'diff' => $prevRev->getId(),
857 $nextRev = new Revision( $next );
859 if ( !$prevRev->userCan( Revision
::DELETED_TEXT
, $this->getUser() )
860 ||
!$nextRev->userCan( Revision
::DELETED_TEXT
, $this->getUser() )
865 return Linker
::linkKnown(
870 'diff' => $prevRev->getId(),
871 'oldid' => $next->rev_id
877 * Create radio buttons for page history
879 * @param Revision $rev
880 * @param bool $firstInList Is this version the first one?
882 * @return string HTML output for the radio buttons
884 function diffButtons( $rev, $firstInList ) {
885 if ( $this->getNumRows() > 1 ) {
887 $radio = [ 'type' => 'radio', 'value' => $id ];
888 /** @todo Move title texts to javascript */
889 if ( $firstInList ) {
890 $first = Xml
::element( 'input',
891 array_merge( $radio, [
892 'style' => 'visibility:hidden',
894 'id' => 'mw-oldid-null' ] )
896 $checkmark = [ 'checked' => 'checked' ];
898 # Check visibility of old revisions
899 if ( !$rev->userCan( Revision
::DELETED_TEXT
, $this->getUser() ) ) {
900 $radio['disabled'] = 'disabled';
901 $checkmark = []; // We will check the next possible one
902 } elseif ( !$this->oldIdChecked
) {
903 $checkmark = [ 'checked' => 'checked' ];
904 $this->oldIdChecked
= $id;
908 $first = Xml
::element( 'input',
909 array_merge( $radio, $checkmark, [
911 'id' => "mw-oldid-$id" ] ) );
914 $second = Xml
::element( 'input',
915 array_merge( $radio, $checkmark, [
917 'id' => "mw-diff-$id" ] ) );
919 return $first . $second;
926 * This is called if a write operation is possible from the generated HTML
927 * @param bool $enable
929 function preventClickjacking( $enable = true ) {
930 $this->preventClickjacking
= $enable;
934 * Get the "prevent clickjacking" flag
937 function getPreventClickjacking() {
938 return $this->preventClickjacking
;