MediaWiki master
SpecialDeletedContributions.php
Go to the documentation of this file.
1<?php
7namespace MediaWiki\Specials;
8
10use MediaWiki\Cache\LinkBatchFactory;
12use MediaWiki\Pager\DeletedContribsPager;
27use Wikimedia\IPUtils;
29
36 private ?DeletedContribsPager $pager = null;
37
38 private RevisionStore $revisionStore;
39 private CommentFormatter $commentFormatter;
40 private LinkBatchFactory $linkBatchFactory;
41 private TempUserConfig $tempUserConfig;
42
43 public function __construct(
46 RevisionStore $revisionStore,
51 CommentFormatter $commentFormatter,
52 LinkBatchFactory $linkBatchFactory,
57 TempUserConfig $tempUserConfig
58 ) {
59 parent::__construct(
70 'DeletedContributions',
71 'deletedhistory'
72 );
73 $this->revisionStore = $revisionStore;
74 $this->commentFormatter = $commentFormatter;
75 $this->linkBatchFactory = $linkBatchFactory;
76 $this->tempUserConfig = $tempUserConfig;
77 }
78
82 protected function getPager( $targetUser ) {
83 if ( $this->pager === null ) {
84 // Fields in the opts property are usually not normalised, mainly
85 // for validations in HTMLForm, especially the 'target' field.
86 $options = $this->opts;
87 unset( $options['target'] );
88
89 $this->pager = new DeletedContribsPager(
90 $this->getHookContainer(),
91 $this->getLinkRenderer(),
92 $this->dbProvider,
93 $this->revisionStore,
94 $this->namespaceInfo,
95 $this->commentFormatter,
96 $this->linkBatchFactory,
97 $this->userFactory,
98 $this->getContext(),
99 $options,
100 $targetUser
101 );
102 }
103
104 return $this->pager;
105 }
106
108 public function isIncludable() {
109 return false;
110 }
111
115 protected function getUserLinks(
116 SpecialPage $sp,
117 User $target
118 ) {
119 $tools = parent::getUserLinks( $sp, $target );
120 $linkRenderer = $sp->getLinkRenderer();
121
122 $contributionsLink = $linkRenderer->makeKnownLink(
123 SpecialPage::getTitleFor( 'Contributions', $target->getName() ),
124 $this->msg( 'sp-deletedcontributions-contribs' )->text()
125 );
126 if ( isset( $tools['deletedcontribs'] ) ) {
127 // Swap out the deletedcontribs link for our contribs one
128 $tools = wfArrayInsertAfter(
129 $tools, [ 'contribs' => $contributionsLink ], 'deletedcontribs' );
130 unset( $tools['deletedcontribs'] );
131 } else {
132 $tools['contribs'] = $contributionsLink;
133 }
134
135 return $tools;
136 }
137
139 protected function getResultsPageTitleMessageKey( UserIdentity $target ) {
140 // The following messages are generated here:
141 // * deletedcontributions-title
142 // * deletedcontributions-title-for-ip-when-temporary-accounts-enabled
143 $messageKey = 'deletedcontributions-title';
144 if ( $this->tempUserConfig->isEnabled() && IPUtils::isIPAddress( $target->getName() ) ) {
145 $messageKey .= '-for-ip-when-temporary-accounts-enabled';
146 }
147 return $messageKey;
148 }
149}
150
152class_alias( SpecialDeletedContributions::class, 'SpecialDeletedContributions' );
wfArrayInsertAfter(array $array, array $insert, $after)
Insert an array into another array after the specified key.
This is the main service interface for converting single-line comments from various DB comment fields...
A service class for checking permissions To obtain an instance, use MediaWikiServices::getInstance()-...
Service for looking up page revisions.
Parent class for all special pages.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
getContext()
Gets the context this SpecialPage is executed in.
Implements Special:DeletedContributions to display archived revisions.
__construct(PermissionManager $permissionManager, IConnectionProvider $dbProvider, RevisionStore $revisionStore, NamespaceInfo $namespaceInfo, UserNameUtils $userNameUtils, UserNamePrefixSearch $userNamePrefixSearch, UserOptionsLookup $userOptionsLookup, CommentFormatter $commentFormatter, LinkBatchFactory $linkBatchFactory, UserFactory $userFactory, UserIdentityLookup $userIdentityLookup, DatabaseBlockStore $blockStore, UserGroupAssignmentService $userGroupAssignmentService, TempUserConfig $tempUserConfig)
isIncludable()
Whether it's allowed to transclude the special page via {{Special:Foo/params}}.to override bool
getUserLinks(SpecialPage $sp, User $target)
Links to different places.This function is also called in DeletedContributionsPage array
getResultsPageTitleMessageKey(UserIdentity $target)
string Message key for the results page title
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...
Provides access to user options.
Create User objects.
This class represents a service that provides high-level operations on user groups.
Handles searching prefixes of user names.
UserNameUtils service.
User class for the MediaWiki software.
Definition User.php:110
getName()
Get the user name, or the IP of an anonymous user.
Definition User.php:1504
Interface for temporary user creation config and name matching.
Service for looking up UserIdentity.
Interface for objects representing user identity.
Provide primary and replica IDatabase connections.