| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
namespace MediaWiki\Specials; |
| 22 |
|
| 23 |
use MediaWiki\Block\DatabaseBlockStore; |
| 24 |
use MediaWiki\Cache\LinkBatchFactory; |
| 25 |
use MediaWiki\CommentFormatter\CommentFormatter; |
| 26 |
use MediaWiki\Pager\DeletedContribsPager; |
| 27 |
use MediaWiki\Permissions\PermissionManager; |
| 28 |
use MediaWiki\Revision\RevisionStore; |
| 29 |
use MediaWiki\SpecialPage\ContributionsSpecialPage; |
| 30 |
use MediaWiki\SpecialPage\SpecialPage; |
| 31 |
use MediaWiki\Title\NamespaceInfo; |
| 32 |
use MediaWiki\User\Options\UserOptionsLookup; |
| 33 |
use MediaWiki\User\TempUser\TempUserConfig; |
| 34 |
use MediaWiki\User\User; |
| 35 |
use MediaWiki\User\UserFactory; |
| 36 |
use MediaWiki\User\UserIdentity; |
| 37 |
use MediaWiki\User\UserIdentityLookup; |
| 38 |
use MediaWiki\User\UserNamePrefixSearch; |
| 39 |
use MediaWiki\User\UserNameUtils; |
| 40 |
use Wikimedia\IPUtils; |
| 41 |
use Wikimedia\Rdbms\IConnectionProvider; |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
class SpecialDeletedContributions extends ContributionsSpecialPage { |
| 49 |
private ?DeletedContribsPager $pager = null; |
| 50 |
|
| 51 |
private RevisionStore $revisionStore; |
| 52 |
private CommentFormatter $commentFormatter; |
| 53 |
private LinkBatchFactory $linkBatchFactory; |
| 54 |
private TempUserConfig $tempUserConfig; |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
public function __construct( |
| 72 |
PermissionManager $permissionManager, |
| 73 |
IConnectionProvider $dbProvider, |
| 74 |
RevisionStore $revisionStore, |
| 75 |
NamespaceInfo $namespaceInfo, |
| 76 |
UserNameUtils $userNameUtils, |
| 77 |
UserNamePrefixSearch $userNamePrefixSearch, |
| 78 |
UserOptionsLookup $userOptionsLookup, |
| 79 |
CommentFormatter $commentFormatter, |
| 80 |
LinkBatchFactory $linkBatchFactory, |
| 81 |
UserFactory $userFactory, |
| 82 |
UserIdentityLookup $userIdentityLookup, |
| 83 |
DatabaseBlockStore $blockStore, |
| 84 |
TempUserConfig $tempUserConfig |
| 85 |
) { |
| 86 |
parent::__construct( |
| 87 |
$permissionManager, |
| 88 |
$dbProvider, |
| 89 |
$namespaceInfo, |
| 90 |
$userNameUtils, |
| 91 |
$userNamePrefixSearch, |
| 92 |
$userOptionsLookup, |
| 93 |
$userFactory, |
| 94 |
$userIdentityLookup, |
| 95 |
$blockStore, |
| 96 |
'DeletedContributions', |
| 97 |
'deletedhistory' |
| 98 |
); |
| 99 |
$this->revisionStore = $revisionStore; |
| 100 |
$this->commentFormatter = $commentFormatter; |
| 101 |
$this->linkBatchFactory = $linkBatchFactory; |
| 102 |
$this->tempUserConfig = $tempUserConfig; |
| 103 |
} |
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
protected function getPager( $targetUser ) { |
| 109 |
if ( $this->pager === null ) { |
| 110 |
|
| 111 |
|
| 112 |
$options = $this->opts; |
| 113 |
unset( $options['target'] ); |
| 114 |
|
| 115 |
$this->pager = new DeletedContribsPager( |
| 116 |
$this->getHookContainer(), |
| 117 |
$this->getLinkRenderer(), |
| 118 |
$this->dbProvider, |
| 119 |
$this->revisionStore, |
| 120 |
$this->namespaceInfo, |
| 121 |
$this->commentFormatter, |
| 122 |
$this->linkBatchFactory, |
| 123 |
$this->userFactory, |
| 124 |
$this->getContext(), |
| 125 |
$options, |
| 126 |
$targetUser |
| 127 |
); |
| 128 |
} |
| 129 |
|
| 130 |
return $this->pager; |
| 131 |
} |
| 132 |
|
| 133 |
|
| 134 |
public function isIncludable() { |
| 135 |
return false; |
| 136 |
} |
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
protected function getUserLinks( |
| 142 |
SpecialPage $sp, |
| 143 |
User $target |
| 144 |
) { |
| 145 |
$tools = parent::getUserLinks( $sp, $target ); |
| 146 |
$linkRenderer = $sp->getLinkRenderer(); |
| 147 |
|
| 148 |
$contributionsLink = $linkRenderer->makeKnownLink( |
| 149 |
SpecialPage::getTitleFor( 'Contributions', $target->getName() ), |
| 150 |
$this->msg( 'sp-deletedcontributions-contribs' )->text() |
| 151 |
); |
| 152 |
if ( isset( $tools['deletedcontribs'] ) ) { |
| 153 |
|
| 154 |
$tools = wfArrayInsertAfter( |
| 155 |
$tools, [ 'contribs' => $contributionsLink ], 'deletedcontribs' ); |
| 156 |
unset( $tools['deletedcontribs'] ); |
| 157 |
} else { |
| 158 |
$tools['contribs'] = $contributionsLink; |
| 159 |
} |
| 160 |
|
| 161 |
return $tools; |
| 162 |
} |
| 163 |
|
| 164 |
|
| 165 |
protected function getResultsPageTitleMessageKey( UserIdentity $target ) { |
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
$messageKey = 'deletedcontributions-title'; |
| 170 |
if ( $this->tempUserConfig->isEnabled() && IPUtils::isIPAddress( $target->getName() ) ) { |
| 171 |
$messageKey .= '-for-ip-when-temporary-accounts-enabled'; |
| 172 |
} |
| 173 |
return $messageKey; |
| 174 |
} |
| 175 |
} |
| 176 |
|
| 177 |
|
| 178 |
class_alias( SpecialDeletedContributions::class, 'SpecialDeletedContributions' ); |