| 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\MainConfigNames; |
| 27 |
use MediaWiki\Pager\ContribsPager; |
| 28 |
use MediaWiki\Permissions\PermissionManager; |
| 29 |
use MediaWiki\Revision\RevisionStore; |
| 30 |
use MediaWiki\SpecialPage\ContributionsSpecialPage; |
| 31 |
use MediaWiki\Specials\Contribute\ContributeFactory; |
| 32 |
use MediaWiki\Title\NamespaceInfo; |
| 33 |
use MediaWiki\User\Options\UserOptionsLookup; |
| 34 |
use MediaWiki\User\TempUser\TempUserConfig; |
| 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 SpecialContributions extends ContributionsSpecialPage { |
| 49 |
private LinkBatchFactory $linkBatchFactory; |
| 50 |
private RevisionStore $revisionStore; |
| 51 |
private CommentFormatter $commentFormatter; |
| 52 |
private TempUserConfig $tempUserConfig; |
| 53 |
private ?ContribsPager $pager = null; |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
public function __construct( |
| 71 |
LinkBatchFactory $linkBatchFactory, |
| 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 |
UserFactory $userFactory, |
| 81 |
UserIdentityLookup $userIdentityLookup, |
| 82 |
DatabaseBlockStore $blockStore, |
| 83 |
TempUserConfig $tempUserConfig |
| 84 |
) { |
| 85 |
parent::__construct( |
| 86 |
$permissionManager, |
| 87 |
$dbProvider, |
| 88 |
$namespaceInfo, |
| 89 |
$userNameUtils, |
| 90 |
$userNamePrefixSearch, |
| 91 |
$userOptionsLookup, |
| 92 |
$userFactory, |
| 93 |
$userIdentityLookup, |
| 94 |
$blockStore, |
| 95 |
'Contributions', |
| 96 |
'' |
| 97 |
); |
| 98 |
$this->linkBatchFactory = $linkBatchFactory; |
| 99 |
$this->revisionStore = $revisionStore; |
| 100 |
$this->commentFormatter = $commentFormatter; |
| 101 |
$this->tempUserConfig = $tempUserConfig; |
| 102 |
} |
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
protected function getPager( $targetUser ) { |
| 108 |
if ( $this->pager === null ) { |
| 109 |
$options = [ |
| 110 |
'namespace' => $this->opts['namespace'], |
| 111 |
'tagfilter' => $this->opts['tagfilter'], |
| 112 |
'start' => $this->opts['start'] ?? '', |
| 113 |
'end' => $this->opts['end'] ?? '', |
| 114 |
'deletedOnly' => $this->opts['deletedOnly'], |
| 115 |
'topOnly' => $this->opts['topOnly'], |
| 116 |
'newOnly' => $this->opts['newOnly'], |
| 117 |
'hideMinor' => $this->opts['hideMinor'], |
| 118 |
'nsInvert' => $this->opts['nsInvert'], |
| 119 |
'associated' => $this->opts['associated'], |
| 120 |
'tagInvert' => $this->opts['tagInvert'], |
| 121 |
]; |
| 122 |
|
| 123 |
$this->pager = new ContribsPager( |
| 124 |
$this->getContext(), |
| 125 |
$options, |
| 126 |
$this->getLinkRenderer(), |
| 127 |
$this->linkBatchFactory, |
| 128 |
$this->getHookContainer(), |
| 129 |
$this->dbProvider, |
| 130 |
$this->revisionStore, |
| 131 |
$this->namespaceInfo, |
| 132 |
$targetUser, |
| 133 |
$this->commentFormatter |
| 134 |
); |
| 135 |
} |
| 136 |
|
| 137 |
return $this->pager; |
| 138 |
} |
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
public function getShortDescription( string $path = '' ): string { |
| 144 |
return $this->msg( 'special-tab-contributions-short' )->text(); |
| 145 |
} |
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
public function getAssociatedNavigationLinks(): array { |
| 151 |
if ( |
| 152 |
ContributeFactory::isEnabledOnCurrentSkin( |
| 153 |
$this->getSkin(), |
| 154 |
$this->getConfig()->get( MainConfigNames::SpecialContributeSkinsEnabled ) |
| 155 |
) |
| 156 |
) { |
| 157 |
return ContributeFactory::getAssociatedNavigationLinks( |
| 158 |
$this->getUser(), |
| 159 |
$this->getSkin()->getRelevantUser() |
| 160 |
); |
| 161 |
} |
| 162 |
return []; |
| 163 |
} |
| 164 |
|
| 165 |
|
| 166 |
protected function getResultsPageTitleMessageKey( UserIdentity $target ) { |
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
$messageKey = 'contributions-title'; |
| 171 |
if ( $this->tempUserConfig->isEnabled() && IPUtils::isIPAddress( $target->getName() ) ) { |
| 172 |
$messageKey .= '-for-ip-when-temporary-accounts-enabled'; |
| 173 |
} |
| 174 |
return $messageKey; |
| 175 |
} |
| 176 |
} |
| 177 |
|
| 178 |
|
| 179 |
class_alias( SpecialContributions::class, 'SpecialContributions' ); |