Localisation updates from https://translatewiki.net.
[mediawiki.git] / includes / specials / SpecialDeletedContributions.php
blob05981d7acd80e85c396d16b0fd9be13f53f59ee4
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\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;
43 /**
44 * Implements Special:DeletedContributions to display archived revisions
46 * @ingroup SpecialPage
48 class SpecialDeletedContributions extends ContributionsSpecialPage {
49 private ?DeletedContribsPager $pager = null;
51 private RevisionStore $revisionStore;
52 private CommentFormatter $commentFormatter;
53 private LinkBatchFactory $linkBatchFactory;
54 private TempUserConfig $tempUserConfig;
56 /**
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 LinkBatchFactory $linkBatchFactory
66 * @param UserFactory $userFactory
67 * @param UserIdentityLookup $userIdentityLookup
68 * @param DatabaseBlockStore $blockStore
69 * @param TempUserConfig $tempUserConfig
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'
99 $this->revisionStore = $revisionStore;
100 $this->commentFormatter = $commentFormatter;
101 $this->linkBatchFactory = $linkBatchFactory;
102 $this->tempUserConfig = $tempUserConfig;
106 * @inheritDoc
108 protected function getPager( $target ) {
109 if ( $this->pager === null ) {
110 $this->pager = new DeletedContribsPager(
111 $this->getHookContainer(),
112 $this->getLinkRenderer(),
113 $this->dbProvider,
114 $this->revisionStore,
115 $this->namespaceInfo,
116 $this->commentFormatter,
117 $this->linkBatchFactory,
118 $this->userFactory,
119 $this->getContext(),
120 $this->opts,
121 $target
125 return $this->pager;
128 /** @inheritDoc */
129 public function isIncludable() {
130 return false;
134 * @inheritDoc
136 protected function getUserLinks(
137 SpecialPage $sp,
138 User $target
140 $tools = parent::getUserLinks( $sp, $target );
141 $linkRenderer = $sp->getLinkRenderer();
143 $contributionsLink = $linkRenderer->makeKnownLink(
144 SpecialPage::getTitleFor( 'Contributions', $target->getName() ),
145 $this->msg( 'sp-deletedcontributions-contribs' )->text()
147 if ( isset( $tools['deletedcontribs'] ) ) {
148 // Swap out the deletedcontribs link for our contribs one
149 $tools = wfArrayInsertAfter(
150 $tools, [ 'contribs' => $contributionsLink ], 'deletedcontribs' );
151 unset( $tools['deletedcontribs'] );
152 } else {
153 $tools['contribs'] = $contributionsLink;
156 return $tools;
159 /** @inheritDoc */
160 protected function getResultsPageTitleMessageKey( UserIdentity $target ) {
161 // The following messages are generated here:
162 // * deletedcontributions-title
163 // * deletedcontributions-title-for-ip-when-temporary-accounts-enabled
164 $messageKey = 'deletedcontributions-title';
165 if ( $this->tempUserConfig->isEnabled() && IPUtils::isIPAddress( $target->getName() ) ) {
166 $messageKey .= '-for-ip-when-temporary-accounts-enabled';
168 return $messageKey;
172 /** @deprecated class alias since 1.41 */
173 class_alias( SpecialDeletedContributions::class, 'SpecialDeletedContributions' );