| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
namespace MediaWiki\Pager; |
| 25 |
|
| 26 |
use ChangesList; |
| 27 |
use ChangeTags; |
| 28 |
use HistoryAction; |
| 29 |
use HtmlArmor; |
| 30 |
use MapCacheLRU; |
| 31 |
use MediaWiki\Cache\LinkBatchFactory; |
| 32 |
use MediaWiki\ChangeTags\ChangeTagsStore; |
| 33 |
use MediaWiki\CommentFormatter\CommentFormatter; |
| 34 |
use MediaWiki\HookContainer\HookContainer; |
| 35 |
use MediaWiki\HookContainer\HookRunner; |
| 36 |
use MediaWiki\Html\Html; |
| 37 |
use MediaWiki\Html\ListToggle; |
| 38 |
use MediaWiki\Linker\Linker; |
| 39 |
use MediaWiki\MainConfigNames; |
| 40 |
use MediaWiki\MediaWikiServices; |
| 41 |
use MediaWiki\Parser\Sanitizer; |
| 42 |
use MediaWiki\Revision\RevisionRecord; |
| 43 |
use MediaWiki\Revision\RevisionStore; |
| 44 |
use MediaWiki\SpecialPage\SpecialPage; |
| 45 |
use MediaWiki\Watchlist\WatchlistManager; |
| 46 |
use stdClass; |
| 47 |
use Wikimedia\Rdbms\IDBAccessObject; |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
#[\AllowDynamicProperties] |
| 54 |
class HistoryPager extends ReverseChronologicalPager { |
| 55 |
|
| 56 |
|
| 57 |
public $mGroupByDate = true; |
| 58 |
|
| 59 |
public HistoryAction $historyPage; |
| 60 |
public string $buttons; |
| 61 |
public array $conds; |
| 62 |
|
| 63 |
|
| 64 |
protected $oldIdChecked; |
| 65 |
|
| 66 |
|
| 67 |
protected $preventClickjacking = false; |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
protected $parentLens; |
| 72 |
|
| 73 |
|
| 74 |
protected $showTagEditUI; |
| 75 |
|
| 76 |
protected MapCacheLRU $tagsCache; |
| 77 |
|
| 78 |
|
| 79 |
private $tagFilter; |
| 80 |
|
| 81 |
|
| 82 |
private $tagInvert; |
| 83 |
|
| 84 |
|
| 85 |
private $notificationTimestamp; |
| 86 |
|
| 87 |
private RevisionStore $revisionStore; |
| 88 |
private WatchlistManager $watchlistManager; |
| 89 |
private LinkBatchFactory $linkBatchFactory; |
| 90 |
private CommentFormatter $commentFormatter; |
| 91 |
private HookRunner $hookRunner; |
| 92 |
private ChangeTagsStore $changeTagsStore; |
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
private $revisions = []; |
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
private $formattedComments = []; |
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
public function __construct( |
| 119 |
HistoryAction $historyPage, |
| 120 |
$year = 0, |
| 121 |
$month = 0, |
| 122 |
$day = 0, |
| 123 |
$tagFilter = '', |
| 124 |
$tagInvert = false, |
| 125 |
array $conds = [], |
| 126 |
?LinkBatchFactory $linkBatchFactory = null, |
| 127 |
?WatchlistManager $watchlistManager = null, |
| 128 |
?CommentFormatter $commentFormatter = null, |
| 129 |
?HookContainer $hookContainer = null, |
| 130 |
?ChangeTagsStore $changeTagsStore = null |
| 131 |
) { |
| 132 |
parent::__construct( $historyPage->getContext() ); |
| 133 |
$this->historyPage = $historyPage; |
| 134 |
$this->tagFilter = $tagFilter; |
| 135 |
$this->tagInvert = $tagInvert; |
| 136 |
$this->getDateCond( $year, $month, $day ); |
| 137 |
$this->conds = $conds; |
| 138 |
$this->showTagEditUI = ChangeTags::showTagEditingUI( $this->getAuthority() ); |
| 139 |
$this->tagsCache = new MapCacheLRU( 50 ); |
| 140 |
$services = MediaWikiServices::getInstance(); |
| 141 |
$this->revisionStore = $services->getRevisionStore(); |
| 142 |
$this->linkBatchFactory = $linkBatchFactory ?? $services->getLinkBatchFactory(); |
| 143 |
$this->watchlistManager = $watchlistManager |
| 144 |
?? $services->getWatchlistManager(); |
| 145 |
$this->commentFormatter = $commentFormatter ?? $services->getCommentFormatter(); |
| 146 |
$this->hookRunner = new HookRunner( $hookContainer ?? $services->getHookContainer() ); |
| 147 |
$this->notificationTimestamp = $this->getConfig()->get( MainConfigNames::ShowUpdatedMarker ) |
| 148 |
? $this->watchlistManager->getTitleNotificationTimestamp( $this->getUser(), $this->getTitle() ) |
| 149 |
: false; |
| 150 |
$this->changeTagsStore = $changeTagsStore ?? $services->getChangeTagsStore(); |
| 151 |
} |
| 152 |
|
| 153 |
… |
| 154 |
public function getArticle() { |
| 155 |
return $this->historyPage->getArticle(); |
| 156 |
} |
| 157 |
|
| 158 |
protected function getSqlComment() { |
| 159 |
if ( $this->conds ) { |
| 160 |
return 'history page filtered'; |
| 161 |
} else { |
| 162 |
return 'history page unfiltered'; |
| 163 |
} |
| 164 |
} |
| 165 |
|
| 166 |
public function getQueryInfo() { |
| 167 |
$queryBuilder = $this->revisionStore->newSelectQueryBuilder( $this->mDb ) |
| 168 |
->joinComment() |
| 169 |
->joinUser() |
| 170 |
->useIndex( [ 'revision' => 'rev_page_timestamp' ] ) |
| 171 |
->where( [ 'rev_page' => $this->getWikiPage()->getId() ] ) |
| 172 |
->andWhere( $this->conds ); |
| 173 |
|
| 174 |
$queryInfo = $queryBuilder->getQueryInfo( 'join_conds' ); |
| 175 |
$this->changeTagsStore->modifyDisplayQuery( |
| 176 |
$queryInfo['tables'], |
| 177 |
$queryInfo['fields'], |
| 178 |
$queryInfo['conds'], |
| 179 |
$queryInfo['join_conds'], |
| 180 |
$queryInfo['options'], |
| 181 |
$this->tagFilter, |
| 182 |
$this->tagInvert |
| 183 |
); |
| 184 |
|
| 185 |
$this->hookRunner->onPageHistoryPager__getQueryInfo( $this, $queryInfo ); |
| 186 |
|
| 187 |
return $queryInfo; |
| 188 |
} |
| 189 |
|
| 190 |
public function getIndexField() { |
| 191 |
return [ [ 'rev_timestamp', 'rev_id' ] ]; |
| 192 |
} |
| 193 |
|
| 194 |
protected function doBatchLookups() { |
| 195 |
if ( !$this->hookRunner->onPageHistoryPager__doBatchLookups( $this, $this->mResult ) ) { |
| 196 |
return; |
| 197 |
} |
| 198 |
|
| 199 |
|
| 200 |
$batch = $this->linkBatchFactory->newLinkBatch(); |
| 201 |
$revIds = []; |
| 202 |
$title = $this->getTitle(); |
| 203 |
foreach ( $this->mResult as $row ) { |
| 204 |
if ( $row->rev_parent_id ) { |
| 205 |
$revIds[] = (int)$row->rev_parent_id; |
| 206 |
} |
| 207 |
if ( $row->user_name !== null ) { |
| 208 |
$batch->add( NS_USER, $row->user_name ); |
| 209 |
$batch->add( NS_USER_TALK, $row->user_name ); |
| 210 |
} else { |
| 211 |
$batch->add( NS_USER, $row->rev_user_text ); |
| 212 |
$batch->add( NS_USER_TALK, $row->rev_user_text ); |
| 213 |
} |
| 214 |
$this->revisions[] = $this->revisionStore->newRevisionFromRow( |
| 215 |
$row, |
| 216 |
IDBAccessObject::READ_NORMAL, |
| 217 |
$title |
| 218 |
); |
| 219 |
} |
| 220 |
$this->parentLens = $this->revisionStore->getRevisionSizes( $revIds ); |
| 221 |
$batch->execute(); |
| 222 |
|
| 223 |
|
| 224 |
$this->formattedComments = $this->commentFormatter->createRevisionBatch() |
| 225 |
->revisions( $this->revisions ) |
| 226 |
->authority( $this->getAuthority() ) |
| 227 |
->samePage( false ) |
| 228 |
->hideIfDeleted( true ) |
| 229 |
->useParentheses( false ) |
| 230 |
->execute(); |
| 231 |
|
| 232 |
$this->mResult->seek( 0 ); |
| 233 |
} |
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
protected function getEmptyBody() { |
| 240 |
return $this->msg( 'history-empty' )->escaped(); |
| 241 |
} |
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
protected function getStartBody() { |
| 249 |
$this->oldIdChecked = 0; |
| 250 |
$s = ''; |
| 251 |
|
| 252 |
$this->buttons = ''; |
| 253 |
if ( $this->getNumRows() > 0 ) { |
| 254 |
$this->getOutput()->wrapWikiMsg( "<div class='mw-history-legend'>\n$1\n</div>", 'histlegend' ); |
| 255 |
|
| 256 |
$s = Html::openElement( 'form', [ |
| 257 |
'action' => wfScript(), |
| 258 |
'id' => 'mw-history-compare' |
| 259 |
] ) . "\n"; |
| 260 |
$s .= Html::hidden( 'title', $this->getTitle()->getPrefixedDBkey() ) . "\n"; |
| 261 |
|
| 262 |
$this->buttons .= Html::openElement( |
| 263 |
'div', [ 'class' => 'mw-history-compareselectedversions' ] ); |
| 264 |
$className = 'historysubmit mw-history-compareselectedversions-button cdx-button'; |
| 265 |
$attrs = [ 'class' => $className ] |
| 266 |
+ Linker::tooltipAndAccesskeyAttribs( 'compareselectedversions' ); |
| 267 |
$this->buttons .= $this->submitButton( $this->msg( 'compareselectedversions' )->text(), |
| 268 |
$attrs |
| 269 |
) . "\n"; |
| 270 |
|
| 271 |
$actionButtons = ''; |
| 272 |
if ( $this->getAuthority()->isAllowed( 'deleterevision' ) ) { |
| 273 |
$actionButtons .= $this->getRevisionButton( |
| 274 |
'Revisiondelete', 'showhideselectedversions', 'mw-history-revisiondelete-button' ); |
| 275 |
} |
| 276 |
if ( $this->showTagEditUI ) { |
| 277 |
$actionButtons .= $this->getRevisionButton( |
| 278 |
'EditTags', 'history-edit-tags', 'mw-history-editchangetags-button' ); |
| 279 |
} |
| 280 |
if ( $actionButtons ) { |
| 281 |
|
| 282 |
e. |
| 283 |
|
| 284 |
|
| 285 |
he |
| 286 |
|
| 287 |
$s = Html::rawElement( 'form', [ |
| 288 |
'action' => wfScript(), |
| 289 |
'id' => 'mw-history-revisionactions', |
| 290 |
] ) . "\n" . $s; |
| 291 |
$s .= Html::hidden( 'type', 'revision', [ 'form' => 'mw-history-revisionactions' ] ) . "\n"; |
| 292 |
|
| 293 |
$this->buttons .= Html::rawElement( 'div', [ 'class' => |
| 294 |
'mw-history-revisionactions' ], $actionButtons ); |
| 295 |
} |
| 296 |
|
| 297 |
if ( $this->getAuthority()->isAllowed( 'deleterevision' ) || $this->showTagEditUI ) { |
| 298 |
$this->buttons .= ( new ListToggle( $this->getOutput() ) )->getHTML(); |
| 299 |
} |
| 300 |
|
| 301 |
$this->buttons .= '</div>'; |
| 302 |
|
| 303 |
$s .= $this->buttons; |
| 304 |
} |
| 305 |
|
| 306 |
$s .= '<section id="pagehistory" class="mw-pager-body">'; |
| 307 |
|
| 308 |
return $s; |
| 309 |
} |
| 310 |
|
| 311 |
private function getRevisionButton( $name, $msg, $class ) { |
| 312 |
$this->preventClickjacking = true; |
| 313 |
$element = Html::element( |
| 314 |
'button', |
| 315 |
[ |
| 316 |
'type' => 'submit', |
| 317 |
'name' => 'title', |
| 318 |
'value' => SpecialPage::getTitleFor( $name )->getPrefixedDBkey(), |
| 319 |
'class' => [ 'cdx-button', $class, 'historysubmit' ], |
| 320 |
'form' => 'mw-history-revisionactions', |
| 321 |
], |
| 322 |
$this->msg( $msg )->text() |
| 323 |
) . "\n"; |
| 324 |
return $element; |
| 325 |
} |
| 326 |
|
| 327 |
protected function getEndBody() { |
| 328 |
if ( $this->getNumRows() == 0 ) { |
| 329 |
return ''; |
| 330 |
} |
| 331 |
$s = ''; |
| 332 |
if ( $this->getNumRows() > 2 ) { |
| 333 |
$s .= $this->buttons; |
| 334 |
} |
| 335 |
$s .= '</section>'; |
| 336 |
$s .= '</form>'; |
| 337 |
return $s; |
| 338 |
} |
| 339 |
|
| 340 |
|
| 341 |
|
| 342 |
|
| 343 |
|
| 344 |
|
| 345 |
|
| 346 |
|
| 347 |
private function submitButton( $message, $attributes = [] ) { |
| 348 |
|
| 349 |
if ( $this->getNumRows() > 1 ) { |
| 350 |
return Html::submitButton( $message, $attributes ); |
| 351 |
} else { |
| 352 |
return ''; |
| 353 |
} |
| 354 |
} |
| 355 |
|
| 356 |
|
| 357 |
|
| 358 |
|
| 359 |
|
| 360 |
|
| 361 |
|
| 362 |
public function formatRow( $row ) { |
| 363 |
$resultOffset = $this->getResultOffset(); |
| 364 |
$numRows = min( $this->mResult->numRows(), $this->mLimit ); |
| 365 |
|
| 366 |
$firstInList = $resultOffset === ( $this->mIsBackwards ? $numRows - 1 : 0 ); |
| 367 |
|
| 368 |
$nextResultOffset = $resultOffset + ( $this->mIsBackwards ? -1 : 1 ); |
| 369 |
|
| 370 |
$revRecord = $this->revisions[$resultOffset]; |
| 371 |
|
| 372 |
$previousRevRecord = $this->revisions[$nextResultOffset] ?? null; |
| 373 |
|
| 374 |
$latest = $revRecord->getId() === $this->getWikiPage()->getLatest(); |
| 375 |
$curlink = $this->curLink( $revRecord ); |
| 376 |
if ( $previousRevRecord ) { |
| 377 |
|
| 378 |
$lastlink = $this->lastLink( $revRecord, $previousRevRecord ); |
| 379 |
} elseif ( $this->mIsBackwards && $this->mOffset !== '' ) { |
| 380 |
|
| 381 |
|
| 382 |
|
| 383 |
|
| 384 |
|
| 385 |
$lastlink = $this->lastLink( $revRecord, null ); |
| 386 |
} else { |
| 387 |
|
| 388 |
$lastlink = Html::element( 'span', [ |
| 389 |
'class' => 'mw-history-histlinks-previous', |
| 390 |
], $this->historyPage->message['last'] ); |
| 391 |
} |
| 392 |
$curLastlinks = Html::rawElement( 'span', [], $curlink ) . |
| 393 |
Html::rawElement( 'span', [], $lastlink ); |
| 394 |
$histLinks = Html::rawElement( |
| 395 |
'span', |
| 396 |
[ 'class' => 'mw-history-histlinks mw-changeslist-links' ], |
| 397 |
$curLastlinks |
| 398 |
); |
| 399 |
|
| 400 |
$diffButtons = $this->diffButtons( $revRecord, $firstInList ); |
| 401 |
$s = $histLinks . $diffButtons; |
| 402 |
|
| 403 |
$link = $this->revLink( $revRecord ); |
| 404 |
$classes = []; |
| 405 |
|
| 406 |
$del = ''; |
| 407 |
$canRevDelete = $this->getAuthority()->isAllowed( 'deleterevision' ); |
| 408 |
|
| 409 |
|
| 410 |
if ( $canRevDelete || $this->showTagEditUI ) { |
| 411 |
$this->preventClickjacking = true; |
| 412 |
|
| 413 |
|
| 414 |
if ( !$this->showTagEditUI |
| 415 |
&& !$revRecord->userCan( RevisionRecord::DELETED_RESTRICTED, $this->getAuthority() ) |
| 416 |
) { |
| 417 |
$del = Html::check( 'deleterevisions', false, [ 'disabled' => 'disabled' ] ); |
| 418 |
… |
| 419 |
} else { |
| 420 |
$del = Html::check( |
| 421 |
'ids[' . $revRecord->getId() . ']', false, |
| 422 |
[ 'form' => 'mw-history-revisionactions' ] |
| 423 |
); |
| 424 |
} |
| 425 |
… |
| 426 |
} elseif ( $revRecord->getVisibility() && $this->getAuthority()->isAllowed( 'deletedhistory' ) ) { |
| 427 |
|
| 428 |
if ( !$revRecord->userCan( RevisionRecord::DELETED_RESTRICTED, $this->getAuthority() ) ) { |
| 429 |
$del = Linker::revDeleteLinkDisabled( false ); |
| 430 |
… |
| 431 |
} else { |
| 432 |
$query = [ |
| 433 |
'type' => 'revision', |
| 434 |
'target' => $this->getTitle()->getPrefixedDBkey(), |
| 435 |
'ids' => $revRecord->getId() |
| 436 |
]; |
| 437 |
$del .= Linker::revDeleteLink( |
| 438 |
$query, |
| 439 |
$revRecord->isDeleted( RevisionRecord::DELETED_RESTRICTED ), |
| 440 |
false |
| 441 |
); |
| 442 |
} |
| 443 |
} |
| 444 |
if ( $del ) { |
| 445 |
$s .= " $del "; |
| 446 |
} |
| 447 |
|
| 448 |
$lang = $this->getLanguage(); |
| 449 |
$s .= ' ' . Html::rawElement( 'bdi', [ 'dir' => $lang->getDir() ], $link ); |
| 450 |
$s .= " <span class='history-user'>" . |
| 451 |
Linker::revUserTools( $revRecord, true, false ) . "</span>"; |
| 452 |
|
| 453 |
if ( $revRecord->isMinor() ) { |
| 454 |
$s .= ' ' . ChangesList::flag( 'minor', $this->getContext() ); |
| 455 |
} |
| 456 |
|
| 457 |
|
| 458 |
if ( $revRecord->getSize() !== null ) { |
| 459 |
|
| 460 |
$prevSize = $this->parentLens[$row->rev_parent_id] ?? 0; |
| 461 |
$sDiff = ChangesList::showCharacterDifference( $prevSize, $revRecord->getSize() ); |
| 462 |
$fSize = Linker::formatRevisionSize( $revRecord->getSize() ); |
| 463 |
$s .= ' <span class="mw-changeslist-separator"></span> ' . "$fSize $sDiff"; |
| 464 |
} |
| 465 |
|
| 466 |
|
| 467 |
$s .= ' <span class="mw-changeslist-separator"></span> '; |
| 468 |
|
| 469 |
|
| 470 |
$comment = $this->formattedComments[$resultOffset]; |
| 471 |
|
| 472 |
if ( $comment === '' ) { |
| 473 |
$defaultComment = $this->historyPage->message['changeslist-nocomment']; |
| 474 |
$comment = "<span class=\"comment mw-comment-none\">$defaultComment</span>"; |
| 475 |
} |
| 476 |
$s .= $comment; |
| 477 |
|
| 478 |
if ( $this->notificationTimestamp && $row->rev_timestamp >= $this->notificationTimestamp ) { |
| 479 |
$s .= ' <span class="updatedmarker">' . $this->historyPage->message['updatedmarker'] . '</span>'; |
| 480 |
$classes[] = 'mw-history-line-updated'; |
| 481 |
} |
| 482 |
|
| 483 |
$pagerTools = new PagerTools( |
| 484 |
$revRecord, |
| 485 |
$previousRevRecord, |
| 486 |
$latest && $previousRevRecord, |
| 487 |
$this->hookRunner, |
| 488 |
$this->getTitle(), |
| 489 |
$this->getContext(), |
| 490 |
$this->getLinkRenderer() |
| 491 |
); |
| 492 |
if ( $pagerTools->shouldPreventClickjacking() ) { |
| 493 |
$this->preventClickjacking = true; |
| 494 |
} |
| 495 |
$s .= $pagerTools->toHTML(); |
| 496 |
|
| 497 |
|
| 498 |
[ $tagSummary, $newClasses ] = $this->tagsCache->getWithSetCallback( |
| 499 |
$this->tagsCache->makeKey( |
| 500 |
$row->ts_tags ?? '', |
| 501 |
$this->getUser()->getName(), |
| 502 |
$lang->getCode() |
| 503 |
), |
| 504 |
fn () => ChangeTags::formatSummaryRow( |
| 505 |
$row->ts_tags, |
| 506 |
'history', |
| 507 |
$this->getContext() |
| 508 |
) |
| 509 |
); |
| 510 |
$classes = array_merge( $classes, $newClasses ); |
| 511 |
if ( $tagSummary !== '' ) { |
| 512 |
$s .= " $tagSummary"; |
| 513 |
} |
| 514 |
|
| 515 |
$attribs = [ 'data-mw-revid' => $revRecord->getId() ]; |
| 516 |
|
| 517 |
$this->hookRunner->onPageHistoryLineEnding( $this, $row, $s, $classes, $attribs ); |
| 518 |
$attribs = array_filter( $attribs, |
| 519 |
[ Sanitizer::class, 'isReservedDataAttribute' ], |
| 520 |
ARRAY_FILTER_USE_KEY |
| 521 |
); |
| 522 |
|
| 523 |
if ( $classes ) { |
| 524 |
$attribs['class'] = implode( ' ', $classes ); |
| 525 |
} |
| 526 |
|
| 527 |
return Html::rawElement( 'li', $attribs, $s ) . "\n"; |
| 528 |
} |
| 529 |
|
| 530 |
|
| 531 |
|
| 532 |
|
| 533 |
|
| 534 |
|
| 535 |
|
| 536 |
private function revLink( RevisionRecord $rev ) { |
| 537 |
return ChangesList::revDateLink( $rev, $this->getAuthority(), $this->getLanguage(), |
| 538 |
$this->getTitle() ); |
| 539 |
} |
| 540 |
|
| 541 |
|
| 542 |
|
| 543 |
|
| 544 |
|
| 545 |
|
| 546 |
|
| 547 |
private function curLink( RevisionRecord $rev ) { |
| 548 |
$cur = $this->historyPage->message['cur']; |
| 549 |
$latest = $this->getWikiPage()->getLatest(); |
| 550 |
if ( $latest === $rev->getId() |
| 551 |
|| !$rev->userCan( RevisionRecord::DELETED_TEXT, $this->getAuthority() ) |
| 552 |
) { |
| 553 |
return Html::element( 'span', [ |
| 554 |
'class' => 'mw-history-histlinks-current', |
| 555 |
], $cur ); |
| 556 |
} else { |
| 557 |
return $this->getLinkRenderer()->makeKnownLink( |
| 558 |
$this->getTitle(), |
| 559 |
new HtmlArmor( $cur ), |
| 560 |
[ |
| 561 |
'class' => 'mw-history-histlinks-current', |
| 562 |
'title' => $this->historyPage->message['tooltip-cur'] |
| 563 |
], |
| 564 |
[ |
| 565 |
'diff' => $latest, |
| 566 |
'oldid' => $rev->getId() |
| 567 |
] |
| 568 |
); |
| 569 |
} |
| 570 |
} |
| 571 |
|
| 572 |
|
| 573 |
|
| 574 |
|
| 575 |
|
| 576 |
|
| 577 |
|
| 578 |
|
| 579 |
|
| 580 |
private function lastLink( RevisionRecord $prevRev, ?RevisionRecord $nextRev ) { |
| 581 |
$last = $this->historyPage->message['last']; |
| 582 |
|
| 583 |
if ( !$prevRev->userCan( RevisionRecord::DELETED_TEXT, $this->getAuthority() ) || |
| 584 |
( $nextRev && !$nextRev->userCan( RevisionRecord::DELETED_TEXT, $this->getAuthority() ) ) |
| 585 |
) { |
| 586 |
return Html::element( 'span', [ |
| 587 |
'class' => 'mw-history-histlinks-previous', |
| 588 |
], $last ); |
| 589 |
} |
| 590 |
|
| 591 |
return $this->getLinkRenderer()->makeKnownLink( |
| 592 |
$this->getTitle(), |
| 593 |
new HtmlArmor( $last ), |
| 594 |
[ |
| 595 |
'class' => 'mw-history-histlinks-previous', |
| 596 |
'title' => $this->historyPage->message['tooltip-last'] |
| 597 |
], |
| 598 |
[ |
| 599 |
'diff' => 'prev', |
| 600 |
'oldid' => $prevRev->getId() |
| 601 |
] |
| 602 |
); |
| 603 |
} |
| 604 |
|
| 605 |
|
| 606 |
|
| 607 |
|
| 608 |
|
| 609 |
|
| 610 |
|
| 611 |
|
| 612 |
|
| 613 |
private function diffButtons( RevisionRecord $rev, $firstInList ) { |
| 614 |
if ( $this->getNumRows() > 1 ) { |
| 615 |
$id = $rev->getId(); |
| 616 |
$radio = [ 'type' => 'radio', 'value' => $id ]; |
| 617 |
|
| 618 |
if ( $firstInList ) { |
| 619 |
$first = Html::element( 'input', |
| 620 |
array_merge( $radio, [ |
| 621 |
|
| 622 |
|
| 623 |
'disabled' => '', |
| 624 |
'name' => 'oldid', |
| 625 |
'id' => 'mw-oldid-null' ] ) |
| 626 |
); |
| 627 |
$checkmark = [ 'checked' => 'checked' ]; |
| 628 |
} else { |
| 629 |
|
| 630 |
if ( !$rev->userCan( RevisionRecord::DELETED_TEXT, $this->getAuthority() ) ) { |
| 631 |
$radio['disabled'] = 'disabled'; |
| 632 |
$checkmark = []; |
| 633 |
} elseif ( !$this->oldIdChecked ) { |
| 634 |
$checkmark = [ 'checked' => 'checked' ]; |
| 635 |
$this->oldIdChecked = $id; |
| 636 |
} else { |
| 637 |
$checkmark = []; |
| 638 |
} |
| 639 |
$first = Html::element( 'input', |
| 640 |
array_merge( $radio, $checkmark, [ |
| 641 |
'name' => 'oldid', |
| 642 |
'id' => "mw-oldid-$id" ] ) ); |
| 643 |
$checkmark = []; |
| 644 |
} |
| 645 |
$second = Html::element( 'input', |
| 646 |
array_merge( $radio, $checkmark, [ |
| 647 |
'name' => 'diff', |
| 648 |
'id' => "mw-diff-$id" ] ) ); |
| 649 |
|
| 650 |
return $first . $second; |
| 651 |
} else { |
| 652 |
return ''; |
| 653 |
} |
| 654 |
} |
| 655 |
|
| 656 |
|
| 657 |
|
| 658 |
|
| 659 |
|
| 660 |
|
| 661 |
protected function isNavigationBarShown() { |
| 662 |
if ( $this->getNumRows() == 0 ) { |
| 663 |
return false; |
| 664 |
} |
| 665 |
return parent::isNavigationBarShown(); |
| 666 |
} |
| 667 |
|
| 668 |
|
| 669 |
|
| 670 |
|
| 671 |
|
| 672 |
public function getPreventClickjacking() { |
| 673 |
return $this->preventClickjacking; |
| 674 |
} |
| 675 |
|
| 676 |
} |
| 677 |
|
| 678 |
|
| 679 |
class_alias( HistoryPager::class, 'HistoryPager' ); |