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 array( '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 = array( '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( array( &$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( array(
122 'mediawiki.ui.input',
123 'mediawiki.ui.checkbox',
127 // Handle atom/RSS feeds.
128 $feedType = $request->getVal( 'feed' );
130 $this->feed( $feedType );
135 // Fail nicely if article doesn't exist.
136 if ( !$this->page
->exists() ) {
137 $out->addWikiMsg( 'nohistory' );
138 # show deletion/move log if there is an entry
139 LogEventsList
::showLogExtract(
141 array( 'delete', 'move' ),
145 'conds' => array( "log_action != 'revision'" ),
146 'showIfEmpty' => false,
147 'msgKey' => array( 'moveddeleted-notice' )
155 * Add date selector to quickly get to a certain time
157 $year = $request->getInt( 'year' );
158 $month = $request->getInt( 'month' );
159 $tagFilter = $request->getVal( 'tagfilter' );
160 $tagSelector = ChangeTags
::buildTagFilterSelector( $tagFilter );
163 * Option to show only revisions that have been (partially) hidden via RevisionDelete
165 if ( $request->getBool( 'deleted' ) ) {
166 $conds = array( 'rev_deleted != 0' );
170 if ( $this->getUser()->isAllowed( 'deletedhistory' ) ) {
171 $checkDeleted = Xml
::checkLabel( $this->msg( 'history-show-deleted' )->text(),
172 'deleted', 'mw-show-deleted-only', $request->getBool( 'deleted' ) ) . "\n";
177 // Add the general form
178 $action = htmlspecialchars( wfScript() );
180 "<form action=\"$action\" method=\"get\" id=\"mw-history-searchform\">" .
182 $this->msg( 'history-fieldset-title' )->text(),
184 array( 'id' => 'mw-history-search' )
186 Html
::hidden( 'title', $this->getTitle()->getPrefixedDBkey() ) . "\n" .
187 Html
::hidden( 'action', 'history' ) . "\n" .
189 ( $year == null ? MWTimestamp
::getLocalInstance()->format( 'Y' ) : $year ),
192 ( $tagSelector ?
( implode( ' ', $tagSelector ) . ' ' ) : '' ) .
195 $this->msg( 'allpagessubmit' )->text(),
197 array( 'mw-ui-progressive' )
202 Hooks
::run( 'PageHistoryBeforeList', array( &$this->page
, $this->getContext() ) );
204 // Create and output the list.
205 $pager = new HistoryPager( $this, $year, $month, $tagFilter, $conds );
207 $pager->getNavigationBar() .
209 $pager->getNavigationBar()
211 $out->preventClickjacking( $pager->getPreventClickjacking() );
216 * Fetch an array of revisions, specified by a given limit, offset and
217 * direction. This is now only used by the feeds. It was previously
218 * used by the main UI but that's now handled by the pager.
220 * @param int $limit The limit number of revisions to get
222 * @param int $direction Either self::DIR_PREV or self::DIR_NEXT
223 * @return ResultWrapper
225 function fetchRevisions( $limit, $offset, $direction ) {
226 // Fail if article doesn't exist.
227 if ( !$this->getTitle()->exists() ) {
228 return new FakeResultWrapper( array() );
231 $dbr = wfGetDB( DB_SLAVE
);
233 if ( $direction === self
::DIR_PREV
) {
234 list( $dirs, $oper ) = array( "ASC", ">=" );
235 } else { /* $direction === self::DIR_NEXT */
236 list( $dirs, $oper ) = array( "DESC", "<=" );
240 $offsets = array( "rev_timestamp $oper " . $dbr->addQuotes( $dbr->timestamp( $offset ) ) );
245 $page_id = $this->page
->getId();
247 return $dbr->select( 'revision',
248 Revision
::selectFields(),
249 array_merge( array( 'rev_page' => $page_id ), $offsets ),
251 array( 'ORDER BY' => "rev_timestamp $dirs",
252 'USE INDEX' => 'page_timestamp', 'LIMIT' => $limit )
257 * Output a subscription feed listing recent edits to this page.
259 * @param string $type Feed type
261 function feed( $type ) {
262 if ( !FeedUtils
::checkFeedOutput( $type ) ) {
265 $request = $this->getRequest();
267 $feedClasses = $this->context
->getConfig()->get( 'FeedClasses' );
268 /** @var RSSFeed|AtomFeed $feed */
269 $feed = new $feedClasses[$type](
270 $this->getTitle()->getPrefixedText() . ' - ' .
271 $this->msg( 'history-feed-title' )->inContentLanguage()->text(),
272 $this->msg( 'history-feed-description' )->inContentLanguage()->text(),
273 $this->getTitle()->getFullURL( 'action=history' )
276 // Get a limit on number of feed entries. Provide a sane default
277 // of 10 if none is defined (but limit to $wgFeedLimit max)
278 $limit = $request->getInt( 'limit', 10 );
281 $this->context
->getConfig()->get( 'FeedLimit' )
284 $items = $this->fetchRevisions( $limit, 0, self
::DIR_NEXT
);
286 // Generate feed elements enclosed between header and footer.
288 if ( $items->numRows() ) {
289 foreach ( $items as $row ) {
290 $feed->outItem( $this->feedItem( $row ) );
293 $feed->outItem( $this->feedEmpty() );
298 function feedEmpty() {
300 $this->msg( 'nohistory' )->inContentLanguage()->text(),
301 $this->msg( 'history-feed-empty' )->inContentLanguage()->parseAsBlock(),
302 $this->getTitle()->getFullURL(),
303 wfTimestamp( TS_MW
),
305 $this->getTitle()->getTalkPage()->getFullURL()
310 * Generate a FeedItem object from a given revision table row
311 * Borrows Recent Changes' feed generation functions for formatting;
312 * includes a diff to the previous revision (if any).
314 * @param stdClass|array $row Database row
317 function feedItem( $row ) {
318 $rev = new Revision( $row );
319 $rev->setTitle( $this->getTitle() );
320 $text = FeedUtils
::formatDiffRow(
322 $this->getTitle()->getPreviousRevisionID( $rev->getId() ),
324 $rev->getTimestamp(),
327 if ( $rev->getComment() == '' ) {
329 $title = $this->msg( 'history-feed-item-nocomment',
331 $wgContLang->timeanddate( $rev->getTimestamp() ),
332 $wgContLang->date( $rev->getTimestamp() ),
333 $wgContLang->time( $rev->getTimestamp() ) )->inContentLanguage()->text();
335 $title = $rev->getUserText() .
336 $this->msg( 'colon-separator' )->inContentLanguage()->text() .
337 FeedItem
::stripComment( $rev->getComment() );
343 $this->getTitle()->getFullURL( 'diff=' . $rev->getId() . '&oldid=prev' ),
344 $rev->getTimestamp(),
346 $this->getTitle()->getTalkPage()->getFullURL()
355 class HistoryPager
extends ReverseChronologicalPager
{
359 public $lastRow = false;
361 public $counter, $historyPage, $buttons, $conds;
363 protected $oldIdChecked;
365 protected $preventClickjacking = false;
369 protected $parentLens;
372 * @param HistoryAction $historyPage
373 * @param string $year
374 * @param string $month
375 * @param string $tagFilter
376 * @param array $conds
378 function __construct( $historyPage, $year = '', $month = '', $tagFilter = '', $conds = array() ) {
379 parent
::__construct( $historyPage->getContext() );
380 $this->historyPage
= $historyPage;
381 $this->tagFilter
= $tagFilter;
382 $this->getDateCond( $year, $month );
383 $this->conds
= $conds;
386 // For hook compatibility...
387 function getArticle() {
388 return $this->historyPage
->getArticle();
391 function getSqlComment() {
392 if ( $this->conds
) {
393 return 'history page filtered'; // potentially slow, see CR r58153
395 return 'history page unfiltered';
399 function getQueryInfo() {
401 'tables' => array( 'revision', 'user' ),
402 'fields' => array_merge( Revision
::selectFields(), Revision
::selectUserFields() ),
403 'conds' => array_merge(
404 array( 'rev_page' => $this->getWikiPage()->getId() ),
406 'options' => array( 'USE INDEX' => array( 'revision' => 'page_timestamp' ) ),
407 'join_conds' => array( 'user' => Revision
::userJoinCond() ),
409 ChangeTags
::modifyDisplayQuery(
410 $queryInfo['tables'],
411 $queryInfo['fields'],
413 $queryInfo['join_conds'],
414 $queryInfo['options'],
417 Hooks
::run( 'PageHistoryPager::getQueryInfo', array( &$this, &$queryInfo ) );
422 function getIndexField() {
423 return 'rev_timestamp';
427 * @param stdClass $row
430 function formatRow( $row ) {
431 if ( $this->lastRow
) {
432 $latest = ( $this->counter
== 1 && $this->mIsFirst
);
433 $firstInList = $this->counter
== 1;
436 $notifTimestamp = $this->getConfig()->get( 'ShowUpdatedMarker' )
437 ?
$this->getTitle()->getNotificationTimestamp( $this->getUser() )
440 $s = $this->historyLine(
441 $this->lastRow
, $row, $notifTimestamp, $latest, $firstInList );
445 $this->lastRow
= $row;
450 function doBatchLookups() {
451 if ( !Hooks
::run( 'PageHistoryPager::doBatchLookups', array( $this, $this->mResult
) ) ) {
455 # Do a link batch query
456 $this->mResult
->seek( 0 );
457 $batch = new LinkBatch();
459 foreach ( $this->mResult
as $row ) {
460 if ( $row->rev_parent_id
) {
461 $revIds[] = $row->rev_parent_id
;
463 if ( !is_null( $row->user_name
) ) {
464 $batch->add( NS_USER
, $row->user_name
);
465 $batch->add( NS_USER_TALK
, $row->user_name
);
466 } else { # for anons or usernames of imported revisions
467 $batch->add( NS_USER
, $row->rev_user_text
);
468 $batch->add( NS_USER_TALK
, $row->rev_user_text
);
471 $this->parentLens
= Revision
::getParentLengths( $this->mDb
, $revIds );
473 $this->mResult
->seek( 0 );
477 * Creates begin of history list with a submit button
479 * @return string HTML output
481 function getStartBody() {
482 $this->lastRow
= false;
484 $this->oldIdChecked
= 0;
486 $this->getOutput()->wrapWikiMsg( "<div class='mw-history-legend'>\n$1\n</div>", 'histlegend' );
487 $s = Html
::openElement( 'form', array( 'action' => wfScript(),
488 'id' => 'mw-history-compare' ) ) . "\n";
489 $s .= Html
::hidden( 'title', $this->getTitle()->getPrefixedDBkey() ) . "\n";
490 $s .= Html
::hidden( 'action', 'historysubmit' ) . "\n";
491 $s .= Html
::hidden( 'type', 'revision' ) . "\n";
493 // Button container stored in $this->buttons for re-use in getEndBody()
494 $this->buttons
= '<div>';
495 $className = 'historysubmit mw-history-compareselectedversions-button';
496 $attrs = array( 'class' => $className )
497 + Linker
::tooltipAndAccesskeyAttribs( 'compareselectedversions' );
498 $this->buttons
.= $this->submitButton( $this->msg( 'compareselectedversions' )->text(),
502 $user = $this->getUser();
504 if ( $user->isAllowed( 'deleterevision' ) ) {
505 $actionButtons .= $this->getRevisionButton( 'revisiondelete', 'showhideselectedversions' );
507 if ( $user->isAllowed( 'changetags' ) ) {
508 $actionButtons .= $this->getRevisionButton( 'editchangetags', 'history-edit-tags' );
510 if ( $actionButtons ) {
511 $this->buttons
.= Xml
::tags( 'div', array( 'class' =>
512 'mw-history-revisionactions' ), $actionButtons );
514 $this->buttons
.= '</div>';
516 $s .= $this->buttons
;
517 $s .= '<ul id="pagehistory">' . "\n";
522 private function getRevisionButton( $name, $msg ) {
523 $this->preventClickjacking();
524 # Note bug #20966, <button> is non-standard in IE<8
525 $element = Html
::element(
531 'class' => "historysubmit mw-history-$name-button",
533 $this->msg( $msg )->text()
538 function getEndBody() {
539 if ( $this->lastRow
) {
540 $latest = $this->counter
== 1 && $this->mIsFirst
;
541 $firstInList = $this->counter
== 1;
542 if ( $this->mIsBackwards
) {
543 # Next row is unknown, but for UI reasons, probably exists if an offset has been specified
544 if ( $this->mOffset
== '' ) {
550 # The next row is the past-the-end row
551 $next = $this->mPastTheEndRow
;
555 $notifTimestamp = $this->getConfig()->get( 'ShowUpdatedMarker' )
556 ?
$this->getTitle()->getNotificationTimestamp( $this->getUser() )
559 $s = $this->historyLine(
560 $this->lastRow
, $next, $notifTimestamp, $latest, $firstInList );
565 # Add second buttons only if there is more than one rev
566 if ( $this->getNumRows() > 2 ) {
567 $s .= $this->buttons
;
575 * Creates a submit button
577 * @param string $message Text of the submit button, will be escaped
578 * @param array $attributes Attributes
579 * @return string HTML output for the submit button
581 function submitButton( $message, $attributes = array() ) {
582 # Disable submit button if history has 1 revision only
583 if ( $this->getNumRows() > 1 ) {
584 return Html
::submitButton( $message, $attributes );
591 * Returns a row from the history printout.
593 * @todo document some more, and maybe clean up the code (some params redundant?)
595 * @param stdClass $row The database row corresponding to the previous line.
596 * @param mixed $next The database row corresponding to the next line
597 * (chronologically previous)
598 * @param bool|string $notificationtimestamp
599 * @param bool $latest Whether this row corresponds to the page's latest revision.
600 * @param bool $firstInList Whether this row corresponds to the first
601 * displayed on this history page.
602 * @return string HTML output for the row
604 function historyLine( $row, $next, $notificationtimestamp = false,
605 $latest = false, $firstInList = false ) {
606 $rev = new Revision( $row );
607 $rev->setTitle( $this->getTitle() );
609 if ( is_object( $next ) ) {
610 $prevRev = new Revision( $next );
611 $prevRev->setTitle( $this->getTitle() );
616 $curlink = $this->curLink( $rev, $latest );
617 $lastlink = $this->lastLink( $rev, $next );
618 $curLastlinks = $curlink . $this->historyPage
->message
['pipe-separator'] . $lastlink;
619 $histLinks = Html
::rawElement(
621 array( 'class' => 'mw-history-histlinks' ),
622 $this->msg( 'parentheses' )->rawParams( $curLastlinks )->escaped()
625 $diffButtons = $this->diffButtons( $rev, $firstInList );
626 $s = $histLinks . $diffButtons;
628 $link = $this->revLink( $rev );
632 $user = $this->getUser();
633 $canRevDelete = $user->isAllowed( 'deleterevision' );
634 $canModifyTags = $user->isAllowed( 'changetags' );
635 // Show checkboxes for each revision, to allow for revision deletion and
637 if ( $canRevDelete ||
$canModifyTags ) {
638 $this->preventClickjacking();
639 // If revision was hidden from sysops and we don't need the checkbox
640 // for anything else, disable it
641 if ( !$canModifyTags && !$rev->userCan( Revision
::DELETED_RESTRICTED
, $user ) ) {
642 $del = Xml
::check( 'deleterevisions', false, array( 'disabled' => 'disabled' ) );
643 // Otherwise, enable the checkbox...
645 $del = Xml
::check( 'showhiderevisions', false,
646 array( 'name' => 'ids[' . $rev->getId() . ']' ) );
648 // User can only view deleted revisions...
649 } elseif ( $rev->getVisibility() && $user->isAllowed( 'deletedhistory' ) ) {
650 // If revision was hidden from sysops, disable the link
651 if ( !$rev->userCan( Revision
::DELETED_RESTRICTED
, $user ) ) {
652 $del = Linker
::revDeleteLinkDisabled( false );
653 // Otherwise, show the link...
655 $query = array( 'type' => 'revision',
656 'target' => $this->getTitle()->getPrefixedDBkey(), 'ids' => $rev->getId() );
657 $del .= Linker
::revDeleteLink( $query,
658 $rev->isDeleted( Revision
::DELETED_RESTRICTED
), false );
665 $lang = $this->getLanguage();
666 $dirmark = $lang->getDirMark();
670 $s .= " <span class='history-user'>" .
671 Linker
::revUserTools( $rev, true ) . "</span>";
674 if ( $rev->isMinor() ) {
675 $s .= ' ' . ChangesList
::flag( 'minor' );
678 # Sometimes rev_len isn't populated
679 if ( $rev->getSize() !== null ) {
680 # Size is always public data
681 $prevSize = isset( $this->parentLens
[$row->rev_parent_id
] )
682 ?
$this->parentLens
[$row->rev_parent_id
]
684 $sDiff = ChangesList
::showCharacterDifference( $prevSize, $rev->getSize() );
685 $fSize = Linker
::formatRevisionSize( $rev->getSize() );
686 $s .= ' <span class="mw-changeslist-separator">. .</span> ' . "$fSize $sDiff";
689 # Text following the character difference is added just before running hooks
690 $s2 = Linker
::revComment( $rev, false, true );
692 if ( $notificationtimestamp && ( $row->rev_timestamp
>= $notificationtimestamp ) ) {
693 $s2 .= ' <span class="updatedmarker">' . $this->msg( 'updatedmarker' )->escaped() . '</span>';
694 $classes[] = 'mw-history-line-updated';
699 # Rollback and undo links
700 if ( $prevRev && $this->getTitle()->quickUserCan( 'edit', $user ) ) {
701 if ( $latest && $this->getTitle()->quickUserCan( 'rollback', $user ) ) {
702 // Get a rollback link without the brackets
703 $rollbackLink = Linker
::generateRollback(
706 array( 'verify', 'noBrackets' )
708 if ( $rollbackLink ) {
709 $this->preventClickjacking();
710 $tools[] = $rollbackLink;
714 if ( !$rev->isDeleted( Revision
::DELETED_TEXT
)
715 && !$prevRev->isDeleted( Revision
::DELETED_TEXT
)
717 # Create undo tooltip for the first (=latest) line only
718 $undoTooltip = $latest
719 ?
array( 'title' => $this->msg( 'tooltip-undo' )->text() )
721 $undolink = Linker
::linkKnown(
723 $this->msg( 'editundo' )->escaped(),
727 'undoafter' => $prevRev->getId(),
728 'undo' => $rev->getId()
731 $tools[] = "<span class=\"mw-history-undo\">{$undolink}</span>";
734 // Allow extension to add their own links here
735 Hooks
::run( 'HistoryRevisionTools', array( $rev, &$tools ) );
738 $s2 .= ' ' . $this->msg( 'parentheses' )->rawParams( $lang->pipeList( $tools ) )->escaped();
742 list( $tagSummary, $newClasses ) = ChangeTags
::formatSummaryRow( $row->ts_tags
, 'history' );
743 $classes = array_merge( $classes, $newClasses );
744 if ( $tagSummary !== '' ) {
745 $s2 .= " $tagSummary";
748 # Include separator between character difference and following text
750 $s .= ' <span class="mw-changeslist-separator">. .</span> ' . $s2;
753 Hooks
::run( 'PageHistoryLineEnding', array( $this, &$row, &$s, &$classes ) );
757 $attribs['class'] = implode( ' ', $classes );
760 return Xml
::tags( 'li', $attribs, $s ) . "\n";
764 * Create a link to view this revision of the page
766 * @param Revision $rev
769 function revLink( $rev ) {
770 $date = $this->getLanguage()->userTimeAndDate( $rev->getTimestamp(), $this->getUser() );
771 $date = htmlspecialchars( $date );
772 if ( $rev->userCan( Revision
::DELETED_TEXT
, $this->getUser() ) ) {
773 $link = Linker
::linkKnown(
776 array( 'class' => 'mw-changeslist-date' ),
777 array( 'oldid' => $rev->getId() )
782 if ( $rev->isDeleted( Revision
::DELETED_TEXT
) ) {
783 $link = "<span class=\"history-deleted\">$link</span>";
790 * Create a diff-to-current link for this revision for this page
792 * @param Revision $rev
793 * @param bool $latest This is the latest revision of the page?
796 function curLink( $rev, $latest ) {
797 $cur = $this->historyPage
->message
['cur'];
798 if ( $latest ||
!$rev->userCan( Revision
::DELETED_TEXT
, $this->getUser() ) ) {
801 return Linker
::linkKnown(
806 'diff' => $this->getWikiPage()->getLatest(),
807 'oldid' => $rev->getId()
814 * Create a diff-to-previous link for this revision for this page.
816 * @param Revision $prevRev The revision being displayed
817 * @param stdClass|string|null $next The next revision in list (that is
818 * the previous one in chronological order).
819 * May either be a row, "unknown" or null.
822 function lastLink( $prevRev, $next ) {
823 $last = $this->historyPage
->message
['last'];
825 if ( $next === null ) {
826 # Probably no next row
830 if ( $next === 'unknown' ) {
831 # Next row probably exists but is unknown, use an oldid=prev link
832 return Linker
::linkKnown(
837 'diff' => $prevRev->getId(),
843 $nextRev = new Revision( $next );
845 if ( !$prevRev->userCan( Revision
::DELETED_TEXT
, $this->getUser() )
846 ||
!$nextRev->userCan( Revision
::DELETED_TEXT
, $this->getUser() )
851 return Linker
::linkKnown(
856 'diff' => $prevRev->getId(),
857 'oldid' => $next->rev_id
863 * Create radio buttons for page history
865 * @param Revision $rev
866 * @param bool $firstInList Is this version the first one?
868 * @return string HTML output for the radio buttons
870 function diffButtons( $rev, $firstInList ) {
871 if ( $this->getNumRows() > 1 ) {
873 $radio = array( 'type' => 'radio', 'value' => $id );
874 /** @todo Move title texts to javascript */
875 if ( $firstInList ) {
876 $first = Xml
::element( 'input',
877 array_merge( $radio, array(
878 'style' => 'visibility:hidden',
880 'id' => 'mw-oldid-null' ) )
882 $checkmark = array( 'checked' => 'checked' );
884 # Check visibility of old revisions
885 if ( !$rev->userCan( Revision
::DELETED_TEXT
, $this->getUser() ) ) {
886 $radio['disabled'] = 'disabled';
887 $checkmark = array(); // We will check the next possible one
888 } elseif ( !$this->oldIdChecked
) {
889 $checkmark = array( 'checked' => 'checked' );
890 $this->oldIdChecked
= $id;
892 $checkmark = array();
894 $first = Xml
::element( 'input',
895 array_merge( $radio, $checkmark, array(
897 'id' => "mw-oldid-$id" ) ) );
898 $checkmark = array();
900 $second = Xml
::element( 'input',
901 array_merge( $radio, $checkmark, array(
903 'id' => "mw-diff-$id" ) ) );
905 return $first . $second;
912 * This is called if a write operation is possible from the generated HTML
913 * @param bool $enable
915 function preventClickjacking( $enable = true ) {
916 $this->preventClickjacking
= $enable;
920 * Get the "prevent clickjacking" flag
923 function getPreventClickjacking() {
924 return $this->preventClickjacking
;