Localisation updates from https://translatewiki.net.
[mediawiki.git] / includes / specials / SpecialContributions.php
bloba5a5ab9265616e700298d8c44c6bbc79438eccc6
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.
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.
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
18 * @file
21 namespace MediaWiki\Specials;
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;
43 /**
44 * Special:Contributions, show user contributions in a paged list
46 * @ingroup SpecialPage
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;
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
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',
98 $this->linkBatchFactory = $linkBatchFactory;
99 $this->revisionStore = $revisionStore;
100 $this->commentFormatter = $commentFormatter;
101 $this->tempUserConfig = $tempUserConfig;
105 * @inheritDoc
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'],
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
137 return $this->pager;
141 * @inheritDoc
143 public function getShortDescription( string $path = '' ): string {
144 return $this->msg( 'special-tab-contributions-short' )->text();
148 * @inheritDoc
150 public function getAssociatedNavigationLinks(): array {
151 if (
152 ContributeFactory::isEnabledOnCurrentSkin(
153 $this->getSkin(),
154 $this->getConfig()->get( MainConfigNames::SpecialContributeSkinsEnabled )
157 return ContributeFactory::getAssociatedNavigationLinks(
158 $this->getUser(),
159 $this->getSkin()->getRelevantUser()
162 return [];
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';
174 return $messageKey;
178 /** @deprecated class alias since 1.41 */
179 class_alias( SpecialContributions::class, 'SpecialContributions' );