Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
90.00% |
54 / 60 |
|
60.00% |
3 / 5 |
CRAP | |
0.00% |
0 / 1 |
| SpecialContributions | |
91.53% |
54 / 59 |
|
60.00% |
3 / 5 |
9.05 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
18 / 18 |
|
100.00% |
1 / 1 |
1 | |||
| getPager | |
100.00% |
27 / 27 |
|
100.00% |
1 / 1 |
2 | |||
| getShortDescription | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getAssociatedNavigationLinks | |
55.56% |
5 / 9 |
|
0.00% |
0 / 1 |
2.35 | |||
| getResultsPageTitleMessageKey | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
3 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * @license GPL-2.0-or-later |
| 4 | * @file |
| 5 | */ |
| 6 | |
| 7 | namespace MediaWiki\Specials; |
| 8 | |
| 9 | use MediaWiki\Block\DatabaseBlockStore; |
| 10 | use MediaWiki\CommentFormatter\CommentFormatter; |
| 11 | use MediaWiki\MainConfigNames; |
| 12 | use MediaWiki\Page\LinkBatchFactory; |
| 13 | use MediaWiki\Pager\ContribsPager; |
| 14 | use MediaWiki\Permissions\PermissionManager; |
| 15 | use MediaWiki\Revision\RevisionStore; |
| 16 | use MediaWiki\SpecialPage\ContributionsSpecialPage; |
| 17 | use MediaWiki\Specials\Contribute\ContributeFactory; |
| 18 | use MediaWiki\Title\NamespaceInfo; |
| 19 | use MediaWiki\User\Options\UserOptionsLookup; |
| 20 | use MediaWiki\User\TempUser\TempUserConfig; |
| 21 | use MediaWiki\User\UserFactory; |
| 22 | use MediaWiki\User\UserGroupAssignmentService; |
| 23 | use MediaWiki\User\UserIdentity; |
| 24 | use MediaWiki\User\UserIdentityLookup; |
| 25 | use MediaWiki\User\UserNamePrefixSearch; |
| 26 | use MediaWiki\User\UserNameUtils; |
| 27 | use Wikimedia\IPUtils; |
| 28 | use Wikimedia\Rdbms\IConnectionProvider; |
| 29 | |
| 30 | /** |
| 31 | * Special:Contributions, show user contributions in a paged list |
| 32 | * |
| 33 | * @ingroup SpecialPage |
| 34 | */ |
| 35 | class SpecialContributions extends ContributionsSpecialPage { |
| 36 | private LinkBatchFactory $linkBatchFactory; |
| 37 | private RevisionStore $revisionStore; |
| 38 | private CommentFormatter $commentFormatter; |
| 39 | private TempUserConfig $tempUserConfig; |
| 40 | private ?ContribsPager $pager = null; |
| 41 | |
| 42 | public function __construct( |
| 43 | LinkBatchFactory $linkBatchFactory, |
| 44 | PermissionManager $permissionManager, |
| 45 | IConnectionProvider $dbProvider, |
| 46 | RevisionStore $revisionStore, |
| 47 | NamespaceInfo $namespaceInfo, |
| 48 | UserNameUtils $userNameUtils, |
| 49 | UserNamePrefixSearch $userNamePrefixSearch, |
| 50 | UserOptionsLookup $userOptionsLookup, |
| 51 | CommentFormatter $commentFormatter, |
| 52 | UserFactory $userFactory, |
| 53 | UserIdentityLookup $userIdentityLookup, |
| 54 | DatabaseBlockStore $blockStore, |
| 55 | UserGroupAssignmentService $userGroupAssignmentService, |
| 56 | TempUserConfig $tempUserConfig |
| 57 | ) { |
| 58 | parent::__construct( |
| 59 | $permissionManager, |
| 60 | $dbProvider, |
| 61 | $namespaceInfo, |
| 62 | $userNameUtils, |
| 63 | $userNamePrefixSearch, |
| 64 | $userOptionsLookup, |
| 65 | $userFactory, |
| 66 | $userIdentityLookup, |
| 67 | $blockStore, |
| 68 | $userGroupAssignmentService, |
| 69 | 'Contributions', |
| 70 | '' |
| 71 | ); |
| 72 | $this->linkBatchFactory = $linkBatchFactory; |
| 73 | $this->revisionStore = $revisionStore; |
| 74 | $this->commentFormatter = $commentFormatter; |
| 75 | $this->tempUserConfig = $tempUserConfig; |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * @inheritDoc |
| 80 | */ |
| 81 | protected function getPager( $targetUser ) { |
| 82 | if ( $this->pager === null ) { |
| 83 | $options = [ |
| 84 | 'namespace' => $this->opts['namespace'], |
| 85 | 'tagfilter' => $this->opts['tagfilter'], |
| 86 | 'start' => $this->opts['start'] ?? '', |
| 87 | 'end' => $this->opts['end'] ?? '', |
| 88 | 'deletedOnly' => $this->opts['deletedOnly'], |
| 89 | 'topOnly' => $this->opts['topOnly'], |
| 90 | 'newOnly' => $this->opts['newOnly'], |
| 91 | 'hideMinor' => $this->opts['hideMinor'], |
| 92 | 'nsInvert' => $this->opts['nsInvert'], |
| 93 | 'associated' => $this->opts['associated'], |
| 94 | 'tagInvert' => $this->opts['tagInvert'], |
| 95 | ]; |
| 96 | |
| 97 | $this->pager = new ContribsPager( |
| 98 | $this->getContext(), |
| 99 | $options, |
| 100 | $this->getLinkRenderer(), |
| 101 | $this->linkBatchFactory, |
| 102 | $this->getHookContainer(), |
| 103 | $this->dbProvider, |
| 104 | $this->revisionStore, |
| 105 | $this->namespaceInfo, |
| 106 | $targetUser, |
| 107 | $this->commentFormatter |
| 108 | ); |
| 109 | } |
| 110 | |
| 111 | return $this->pager; |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * @inheritDoc |
| 116 | */ |
| 117 | public function getShortDescription( string $path = '' ): string { |
| 118 | return $this->msg( 'special-tab-contributions-short' )->text(); |
| 119 | } |
| 120 | |
| 121 | /** |
| 122 | * @inheritDoc |
| 123 | */ |
| 124 | public function getAssociatedNavigationLinks(): array { |
| 125 | if ( |
| 126 | ContributeFactory::isEnabledOnCurrentSkin( |
| 127 | $this->getSkin(), |
| 128 | $this->getConfig()->get( MainConfigNames::SpecialContributeSkinsEnabled ) |
| 129 | ) |
| 130 | ) { |
| 131 | return ContributeFactory::getAssociatedNavigationLinks( |
| 132 | $this->getUser(), |
| 133 | $this->getSkin()->getRelevantUser() |
| 134 | ); |
| 135 | } |
| 136 | return []; |
| 137 | } |
| 138 | |
| 139 | /** @inheritDoc */ |
| 140 | protected function getResultsPageTitleMessageKey( UserIdentity $target ) { |
| 141 | // The following messages are generated here: |
| 142 | // * contributions-title |
| 143 | // * contributions-title-for-ip-when-temporary-accounts-enabled |
| 144 | $messageKey = 'contributions-title'; |
| 145 | if ( $this->tempUserConfig->isEnabled() && IPUtils::isIPAddress( $target->getName() ) ) { |
| 146 | $messageKey .= '-for-ip-when-temporary-accounts-enabled'; |
| 147 | } |
| 148 | return $messageKey; |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | /** @deprecated class alias since 1.41 */ |
| 153 | class_alias( SpecialContributions::class, 'SpecialContributions' ); |