Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
89.83% |
53 / 59 |
|
60.00% |
3 / 5 |
CRAP | |
0.00% |
0 / 1 |
SpecialContributions | |
91.38% |
53 / 58 |
|
60.00% |
3 / 5 |
9.05 | |
0.00% |
0 / 1 |
__construct | |
100.00% |
17 / 17 |
|
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 | * This program is free software; you can redistribute it and/or modify |
4 | * it under the terms of the GNU General Public License as published by |
5 | * the Free Software Foundation; either version 2 of the License, or |
6 | * (at your option) any later version. |
7 | * |
8 | * This program is distributed in the hope that it will be useful, |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 | * GNU General Public License for more details. |
12 | * |
13 | * You should have received a copy of the GNU General Public License along |
14 | * with this program; if not, write to the Free Software Foundation, Inc., |
15 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
16 | * http://www.gnu.org/copyleft/gpl.html |
17 | * |
18 | * @file |
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 | * Special:Contributions, show user contributions in a paged list |
45 | * |
46 | * @ingroup SpecialPage |
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 | * @param LinkBatchFactory $linkBatchFactory |
57 | * @param PermissionManager $permissionManager |
58 | * @param IConnectionProvider $dbProvider |
59 | * @param RevisionStore $revisionStore |
60 | * @param NamespaceInfo $namespaceInfo |
61 | * @param UserNameUtils $userNameUtils |
62 | * @param UserNamePrefixSearch $userNamePrefixSearch |
63 | * @param UserOptionsLookup $userOptionsLookup |
64 | * @param CommentFormatter $commentFormatter |
65 | * @param UserFactory $userFactory |
66 | * @param UserIdentityLookup $userIdentityLookup |
67 | * @param DatabaseBlockStore $blockStore |
68 | * @param TempUserConfig $tempUserConfig |
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 | * @inheritDoc |
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 | * @inheritDoc |
142 | */ |
143 | public function getShortDescription( string $path = '' ): string { |
144 | return $this->msg( 'special-tab-contributions-short' )->text(); |
145 | } |
146 | |
147 | /** |
148 | * @inheritDoc |
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 | /** @inheritDoc */ |
166 | protected function getResultsPageTitleMessageKey( UserIdentity $target ) { |
167 | // The following messages are generated here: |
168 | // * contributions-title |
169 | // * contributions-title-for-ip-when-temporary-accounts-enabled |
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 | /** @deprecated class alias since 1.41 */ |
179 | class_alias( SpecialContributions::class, 'SpecialContributions' ); |