License: Use typed properties
[mediawiki.git] / includes / specials / SpecialDeletedContributions.php
blob7e381d9627522977434af7d94e15e460b35e2ce0
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;
129 * @inheritDoc
131 protected function getUserLinks(
132 SpecialPage $sp,
133 User $target
135 $tools = parent::getUserLinks( $sp, $target );
136 $linkRenderer = $sp->getLinkRenderer();
138 $contributionsLink = $linkRenderer->makeKnownLink(
139 SpecialPage::getTitleFor( 'Contributions', $target->getName() ),
140 $this->msg( 'sp-deletedcontributions-contribs' )->text()
142 if ( isset( $tools['deletedcontribs'] ) ) {
143 // Swap out the deletedcontribs link for our contribs one
144 $tools = wfArrayInsertAfter(
145 $tools, [ 'contribs' => $contributionsLink ], 'deletedcontribs' );
146 unset( $tools['deletedcontribs'] );
147 } else {
148 $tools['contribs'] = $contributionsLink;
151 return $tools;
154 /** @inheritDoc */
155 protected function getResultsPageTitleMessageKey( UserIdentity $target ) {
156 // The following messages are generated here:
157 // * deletedcontributions-title
158 // * deletedcontributions-title-for-ip-when-temporary-accounts-enabled
159 $messageKey = 'deletedcontributions-title';
160 if ( $this->tempUserConfig->isEnabled() && IPUtils::isIPAddress( $target->getName() ) ) {
161 $messageKey .= '-for-ip-when-temporary-accounts-enabled';
163 return $messageKey;
167 /** @deprecated class alias since 1.41 */
168 class_alias( SpecialDeletedContributions::class, 'SpecialDeletedContributions' );