2006-12-03 00:05:45 +00:00
|
|
|
<?php
|
2010-06-21 12:59:04 +00:00
|
|
|
/**
|
2010-08-14 19:19:41 +00:00
|
|
|
* Implements Special:Contributions
|
2010-06-21 12:59:04 +00:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
2010-06-21 13:16:32 +00:00
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2010-06-21 12:59:04 +00:00
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
2010-08-14 19:19:41 +00:00
|
|
|
*
|
|
|
|
|
* @file
|
|
|
|
|
* @ingroup SpecialPage
|
2010-06-21 12:59:04 +00:00
|
|
|
*/
|
|
|
|
|
|
2019-05-13 14:18:07 +00:00
|
|
|
use MediaWiki\Block\DatabaseBlock;
|
2018-08-05 17:58:51 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
2019-06-25 18:53:15 +00:00
|
|
|
use Wikimedia\IPUtils;
|
2017-06-23 19:13:02 +00:00
|
|
|
|
2006-12-03 00:05:45 +00:00
|
|
|
/**
|
2007-04-27 18:21:50 +00:00
|
|
|
* Special:Contributions, show user contributions in a paged list
|
2010-08-14 19:19:41 +00:00
|
|
|
*
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup SpecialPage
|
2006-12-03 00:05:45 +00:00
|
|
|
*/
|
2014-01-08 20:05:00 +00:00
|
|
|
class SpecialContributions extends IncludableSpecialPage {
|
2011-01-13 18:04:30 +00:00
|
|
|
protected $opts;
|
2011-01-12 21:21:32 +00:00
|
|
|
|
2008-10-17 01:35:54 +00:00
|
|
|
public function __construct() {
|
|
|
|
|
parent::__construct( 'Contributions' );
|
|
|
|
|
}
|
|
|
|
|
|
2008-10-19 06:40:00 +00:00
|
|
|
public function execute( $par ) {
|
2008-10-17 01:35:54 +00:00
|
|
|
$this->setHeaders();
|
|
|
|
|
$this->outputHeader();
|
2011-09-20 20:00:05 +00:00
|
|
|
$out = $this->getOutput();
|
2018-02-19 11:53:47 +00:00
|
|
|
// Modules required for viewing the list of contributions (also when included on other pages)
|
2016-07-07 05:22:14 +00:00
|
|
|
$out->addModuleStyles( [
|
2019-03-28 00:06:35 +00:00
|
|
|
'jquery.makeCollapsible.styles',
|
2019-01-09 00:30:18 +00:00
|
|
|
'mediawiki.interface.helpers.styles',
|
2016-07-07 05:22:14 +00:00
|
|
|
'mediawiki.special',
|
|
|
|
|
'mediawiki.special.changeslist',
|
|
|
|
|
] );
|
2019-03-28 00:06:35 +00:00
|
|
|
$out->addModules( [
|
|
|
|
|
'mediawiki.special.recentchanges',
|
|
|
|
|
// Certain skins e.g. Minerva might have disabled this module.
|
|
|
|
|
'mediawiki.page.ready'
|
|
|
|
|
] );
|
2015-03-04 23:58:14 +00:00
|
|
|
$this->addHelpLink( 'Help:User contributions' );
|
2008-10-17 01:35:54 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->opts = [];
|
2011-09-20 20:00:05 +00:00
|
|
|
$request = $this->getRequest();
|
2008-10-17 01:35:54 +00:00
|
|
|
|
2018-06-20 05:26:57 +00:00
|
|
|
$target = $par ?? $request->getVal( 'target' );
|
2008-10-17 01:35:54 +00:00
|
|
|
|
2011-09-20 20:00:05 +00:00
|
|
|
$this->opts['deletedOnly'] = $request->getBool( 'deletedOnly' );
|
2010-04-28 21:43:23 +00:00
|
|
|
|
2011-12-16 10:58:20 +00:00
|
|
|
if ( !strlen( $target ) ) {
|
2014-01-08 20:05:00 +00:00
|
|
|
if ( !$this->including() ) {
|
2019-03-28 00:06:35 +00:00
|
|
|
$out->addHTML( $this->getForm( $this->opts ) );
|
2014-01-08 20:05:00 +00:00
|
|
|
}
|
2014-03-22 22:51:18 +00:00
|
|
|
|
2008-10-17 01:35:54 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-20 20:00:05 +00:00
|
|
|
$user = $this->getUser();
|
|
|
|
|
|
2011-12-16 10:58:20 +00:00
|
|
|
$this->opts['limit'] = $request->getInt( 'limit', $user->getOption( 'rclimit' ) );
|
2008-10-19 06:40:00 +00:00
|
|
|
$this->opts['target'] = $target;
|
2011-09-20 20:00:05 +00:00
|
|
|
$this->opts['topOnly'] = $request->getBool( 'topOnly' );
|
2014-02-26 20:57:58 +00:00
|
|
|
$this->opts['newOnly'] = $request->getBool( 'newOnly' );
|
2015-10-07 11:04:09 +00:00
|
|
|
$this->opts['hideMinor'] = $request->getBool( 'hideMinor' );
|
2008-10-17 01:35:54 +00:00
|
|
|
|
2018-02-12 15:11:40 +00:00
|
|
|
$id = 0;
|
2019-08-02 19:06:31 +00:00
|
|
|
if ( ExternalUserNames::isExternal( $target ) ) {
|
2018-02-12 15:11:40 +00:00
|
|
|
$userObj = User::newFromName( $target, false );
|
|
|
|
|
if ( !$userObj ) {
|
2019-03-28 00:06:35 +00:00
|
|
|
$out->addHTML( $this->getForm( $this->opts ) );
|
2018-02-12 15:11:40 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2013-04-14 17:27:14 +00:00
|
|
|
|
2018-02-12 15:11:40 +00:00
|
|
|
$out->addSubtitle( $this->contributionsSub( $userObj ) );
|
|
|
|
|
$out->setHTMLTitle( $this->msg(
|
|
|
|
|
'pagetitle',
|
|
|
|
|
$this->msg( 'contributions-title', $target )->plain()
|
|
|
|
|
)->inContentLanguage() );
|
|
|
|
|
} else {
|
|
|
|
|
$nt = Title::makeTitleSafe( NS_USER, $target );
|
|
|
|
|
if ( !$nt ) {
|
2019-03-28 00:06:35 +00:00
|
|
|
$out->addHTML( $this->getForm( $this->opts ) );
|
2018-02-12 15:11:40 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
$userObj = User::newFromName( $nt->getText(), false );
|
|
|
|
|
if ( !$userObj ) {
|
2019-03-28 00:06:35 +00:00
|
|
|
$out->addHTML( $this->getForm( $this->opts ) );
|
2018-02-12 15:11:40 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
$id = $userObj->getId();
|
2008-10-17 01:35:54 +00:00
|
|
|
|
|
|
|
|
$target = $nt->getText();
|
2011-11-20 11:29:56 +00:00
|
|
|
$out->addSubtitle( $this->contributionsSub( $userObj ) );
|
2013-03-28 11:43:08 +00:00
|
|
|
$out->setHTMLTitle( $this->msg(
|
|
|
|
|
'pagetitle',
|
|
|
|
|
$this->msg( 'contributions-title', $target )->plain()
|
2013-11-12 08:36:00 +00:00
|
|
|
)->inContentLanguage() );
|
2017-04-21 16:17:59 +00:00
|
|
|
|
|
|
|
|
# For IP ranges, we want the contributionsSub, but not the skin-dependent
|
|
|
|
|
# links under 'Tools', which may include irrelevant links like 'Logs'.
|
2019-06-25 18:53:15 +00:00
|
|
|
if ( !IPUtils::isValidRange( $target ) ) {
|
2017-04-21 16:17:59 +00:00
|
|
|
$this->getSkin()->setRelevantUser( $userObj );
|
|
|
|
|
}
|
2008-10-17 01:35:54 +00:00
|
|
|
}
|
|
|
|
|
|
2015-11-01 19:56:20 +00:00
|
|
|
$ns = $request->getVal( 'namespace', null );
|
2016-04-02 08:03:42 +00:00
|
|
|
if ( $ns !== null && $ns !== '' && $ns !== 'all' ) {
|
2008-10-19 06:40:00 +00:00
|
|
|
$this->opts['namespace'] = intval( $ns );
|
2008-10-17 01:35:54 +00:00
|
|
|
} else {
|
2008-10-19 06:40:00 +00:00
|
|
|
$this->opts['namespace'] = '';
|
2008-10-17 01:35:54 +00:00
|
|
|
}
|
2009-01-28 19:08:18 +00:00
|
|
|
|
2016-04-02 08:03:42 +00:00
|
|
|
// Backwards compatibility: Before using OOUI form the old HTML form had
|
|
|
|
|
// fields for nsInvert and associated. These have now been replaced with the
|
|
|
|
|
// wpFilters query string parameters. These are retained to keep old URIs working.
|
2011-12-15 01:02:25 +00:00
|
|
|
$this->opts['associated'] = $request->getBool( 'associated' );
|
2013-03-28 11:43:08 +00:00
|
|
|
$this->opts['nsInvert'] = (bool)$request->getVal( 'nsInvert' );
|
2016-04-02 08:03:42 +00:00
|
|
|
$nsFilters = $request->getArray( 'wpfilters', null );
|
|
|
|
|
if ( $nsFilters !== null ) {
|
|
|
|
|
$this->opts['associated'] = in_array( 'associated', $nsFilters );
|
|
|
|
|
$this->opts['nsInvert'] = in_array( 'nsInvert', $nsFilters );
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-28 11:43:08 +00:00
|
|
|
$this->opts['tagfilter'] = (string)$request->getVal( 'tagfilter' );
|
2010-06-20 11:37:07 +00:00
|
|
|
|
2008-10-17 01:35:54 +00:00
|
|
|
// Allows reverts to have the bot flag in recent changes. It is just here to
|
2010-06-20 11:37:07 +00:00
|
|
|
// be passed in the form at the top of the page
|
2019-08-21 02:01:06 +00:00
|
|
|
if ( MediaWikiServices::getInstance()
|
|
|
|
|
->getPermissionManager()
|
|
|
|
|
->userHasRight( $user, 'markbotedits' ) && $request->getBool( 'bot' )
|
|
|
|
|
) {
|
2008-10-19 06:40:00 +00:00
|
|
|
$this->opts['bot'] = '1';
|
2008-10-17 01:35:54 +00:00
|
|
|
}
|
|
|
|
|
|
2011-09-20 20:00:05 +00:00
|
|
|
$skip = $request->getText( 'offset' ) || $request->getText( 'dir' ) == 'prev';
|
2008-10-17 01:35:54 +00:00
|
|
|
# Offset overrides year/month selection
|
2017-08-03 21:44:49 +00:00
|
|
|
if ( !$skip ) {
|
2016-12-12 14:26:15 +00:00
|
|
|
$this->opts['year'] = $request->getVal( 'year' );
|
|
|
|
|
$this->opts['month'] = $request->getVal( 'month' );
|
|
|
|
|
|
|
|
|
|
$this->opts['start'] = $request->getVal( 'start' );
|
|
|
|
|
$this->opts['end'] = $request->getVal( 'end' );
|
2008-10-17 01:35:54 +00:00
|
|
|
}
|
2017-08-03 21:44:49 +00:00
|
|
|
$this->opts = ContribsPager::processDateFilter( $this->opts );
|
2010-06-20 11:37:07 +00:00
|
|
|
|
2019-02-17 11:38:12 +00:00
|
|
|
if ( $this->opts['namespace'] < NS_MAIN ) {
|
|
|
|
|
$this->getOutput()->wrapWikiMsg(
|
2019-02-19 08:59:20 +00:00
|
|
|
"<div class=\"mw-negative-namespace-not-supported error\">\n\$1\n</div>",
|
|
|
|
|
[ 'negative-namespace-not-supported' ]
|
|
|
|
|
);
|
2019-03-28 00:06:35 +00:00
|
|
|
$out->addHTML( $this->getForm( $this->opts ) );
|
2019-02-17 11:38:12 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-20 20:00:05 +00:00
|
|
|
$feedType = $request->getVal( 'feed' );
|
2014-01-18 21:46:59 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$feedParams = [
|
2014-01-18 21:46:59 +00:00
|
|
|
'action' => 'feedcontributions',
|
|
|
|
|
'user' => $target,
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2014-01-18 21:46:59 +00:00
|
|
|
if ( $this->opts['topOnly'] ) {
|
|
|
|
|
$feedParams['toponly'] = true;
|
|
|
|
|
}
|
2014-02-26 20:57:58 +00:00
|
|
|
if ( $this->opts['newOnly'] ) {
|
|
|
|
|
$feedParams['newonly'] = true;
|
|
|
|
|
}
|
2015-10-07 11:04:09 +00:00
|
|
|
if ( $this->opts['hideMinor'] ) {
|
|
|
|
|
$feedParams['hideminor'] = true;
|
|
|
|
|
}
|
2014-01-18 21:46:59 +00:00
|
|
|
if ( $this->opts['deletedOnly'] ) {
|
|
|
|
|
$feedParams['deletedonly'] = true;
|
|
|
|
|
}
|
|
|
|
|
if ( $this->opts['tagfilter'] !== '' ) {
|
|
|
|
|
$feedParams['tagfilter'] = $this->opts['tagfilter'];
|
|
|
|
|
}
|
|
|
|
|
if ( $this->opts['namespace'] !== '' ) {
|
|
|
|
|
$feedParams['namespace'] = $this->opts['namespace'];
|
|
|
|
|
}
|
|
|
|
|
// Don't use year and month for the feed URL, but pass them on if
|
|
|
|
|
// we redirect to API (if $feedType is specified)
|
|
|
|
|
if ( $feedType && $this->opts['year'] !== null ) {
|
|
|
|
|
$feedParams['year'] = $this->opts['year'];
|
|
|
|
|
}
|
|
|
|
|
if ( $feedType && $this->opts['month'] !== null ) {
|
|
|
|
|
$feedParams['month'] = $this->opts['month'];
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-16 10:58:20 +00:00
|
|
|
if ( $feedType ) {
|
2014-08-13 17:39:07 +00:00
|
|
|
// Maintain some level of backwards compatibility
|
2011-06-26 19:33:05 +00:00
|
|
|
// If people request feeds using the old parameters, redirect to API
|
2014-01-18 21:46:59 +00:00
|
|
|
$feedParams['feedformat'] = $feedType;
|
|
|
|
|
$url = wfAppendQuery( wfScript( 'api' ), $feedParams );
|
2011-06-25 16:41:29 +00:00
|
|
|
|
2011-09-20 20:00:05 +00:00
|
|
|
$out->redirect( $url, '301' );
|
2013-04-14 17:27:14 +00:00
|
|
|
|
2011-06-25 16:41:29 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2008-10-19 06:40:00 +00:00
|
|
|
// Add RSS/atom links
|
2014-01-18 21:46:59 +00:00
|
|
|
$this->addFeedLinks( $feedParams );
|
2008-10-19 06:40:00 +00:00
|
|
|
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
if ( $this->getHookRunner()->onSpecialContributionsBeforeMainOutput(
|
|
|
|
|
$id, $userObj, $this )
|
|
|
|
|
) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$pager = new ContribsPager( $this->getContext(), [
|
2010-06-20 14:48:36 +00:00
|
|
|
'target' => $target,
|
|
|
|
|
'namespace' => $this->opts['namespace'],
|
2013-06-17 20:23:35 +00:00
|
|
|
'tagfilter' => $this->opts['tagfilter'],
|
2016-12-12 14:26:15 +00:00
|
|
|
'start' => $this->opts['start'],
|
|
|
|
|
'end' => $this->opts['end'],
|
2010-06-20 14:48:36 +00:00
|
|
|
'deletedOnly' => $this->opts['deletedOnly'],
|
|
|
|
|
'topOnly' => $this->opts['topOnly'],
|
2014-02-26 20:57:58 +00:00
|
|
|
'newOnly' => $this->opts['newOnly'],
|
2015-10-07 11:04:09 +00:00
|
|
|
'hideMinor' => $this->opts['hideMinor'],
|
2011-11-19 21:03:43 +00:00
|
|
|
'nsInvert' => $this->opts['nsInvert'],
|
2011-12-15 01:02:25 +00:00
|
|
|
'associated' => $this->opts['associated'],
|
2019-08-19 21:41:04 +00:00
|
|
|
], $this->getLinkRenderer() );
|
2019-03-28 00:06:35 +00:00
|
|
|
if ( !$this->including() ) {
|
|
|
|
|
$out->addHTML( $this->getForm( $this->opts ) );
|
|
|
|
|
}
|
2013-03-28 11:43:08 +00:00
|
|
|
|
2019-06-25 18:53:15 +00:00
|
|
|
if ( IPUtils::isValidRange( $target ) && !$pager->isQueryableRange( $target ) ) {
|
2017-04-21 16:17:59 +00:00
|
|
|
// Valid range, but outside CIDR limit.
|
|
|
|
|
$limits = $this->getConfig()->get( 'RangeContributionsCIDRLimit' );
|
2019-06-25 18:53:15 +00:00
|
|
|
$limit = $limits[ IPUtils::isIPv4( $target ) ? 'IPv4' : 'IPv6' ];
|
2017-04-21 16:17:59 +00:00
|
|
|
$out->addWikiMsg( 'sp-contributions-outofrange', $limit );
|
|
|
|
|
} elseif ( !$pager->getNumRows() ) {
|
2011-09-20 20:00:05 +00:00
|
|
|
$out->addWikiMsg( 'nocontribs', $target );
|
2010-01-08 21:00:39 +00:00
|
|
|
} else {
|
2019-11-19 19:36:35 +00:00
|
|
|
// @todo We just want a wiki ID here, not a "DB domain", but
|
|
|
|
|
// current status of MediaWiki conflates the two. See T235955.
|
|
|
|
|
$poolKey = WikiMap::getCurrentWikiDbDomain() . ':SpecialContributions:';
|
|
|
|
|
if ( $this->getUser()->isAnon() ) {
|
|
|
|
|
$poolKey .= 'a:' . $this->getUser()->getName();
|
|
|
|
|
} else {
|
|
|
|
|
$poolKey .= 'u:' . $this->getUser()->getId();
|
2013-03-28 11:43:08 +00:00
|
|
|
}
|
2019-11-19 19:36:35 +00:00
|
|
|
$work = new PoolCounterWorkViaCallback( 'SpecialContributions', $poolKey, [
|
|
|
|
|
'doWork' => function () use ( $pager, $out ) {
|
|
|
|
|
# Show a message about replica DB lag, if applicable
|
|
|
|
|
$lag = $pager->getDatabase()->getSessionLagStatus()['lag'];
|
|
|
|
|
if ( $lag > 0 ) {
|
|
|
|
|
$out->showLagWarning( $lag );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$output = $pager->getBody();
|
|
|
|
|
if ( !$this->including() ) {
|
|
|
|
|
$output = $pager->getNavigationBar() .
|
|
|
|
|
$output .
|
|
|
|
|
$pager->getNavigationBar();
|
|
|
|
|
}
|
|
|
|
|
$out->addHTML( $output );
|
|
|
|
|
},
|
|
|
|
|
'error' => function () use ( $out ) {
|
|
|
|
|
$msg = $this->getUser()->isAnon()
|
|
|
|
|
? 'sp-contributions-concurrency-ip'
|
|
|
|
|
: 'sp-contributions-concurrency-user';
|
|
|
|
|
$out->wrapWikiMsg( "<div class='errorbox'>\n$1\n</div>", $msg );
|
|
|
|
|
}
|
|
|
|
|
] );
|
|
|
|
|
$work->execute();
|
2010-01-08 21:00:39 +00:00
|
|
|
}
|
2017-04-21 16:17:59 +00:00
|
|
|
|
2011-09-20 20:00:05 +00:00
|
|
|
$out->preventClickjacking( $pager->getPreventClickjacking() );
|
2008-10-17 01:35:54 +00:00
|
|
|
|
2010-01-08 21:00:39 +00:00
|
|
|
# Show the appropriate "footer" message - WHOIS tools, etc.
|
2019-06-25 18:53:15 +00:00
|
|
|
if ( IPUtils::isValidRange( $target ) ) {
|
2017-04-21 16:17:59 +00:00
|
|
|
$message = 'sp-contributions-footer-anon-range';
|
2019-06-25 18:53:15 +00:00
|
|
|
} elseif ( IPUtils::isIPAddress( $target ) ) {
|
2012-03-30 18:15:58 +00:00
|
|
|
$message = 'sp-contributions-footer-anon';
|
2013-03-28 11:43:08 +00:00
|
|
|
} elseif ( $userObj->isAnon() ) {
|
2012-03-30 18:15:58 +00:00
|
|
|
// No message for non-existing users
|
|
|
|
|
$message = '';
|
|
|
|
|
} else {
|
2010-01-08 21:00:39 +00:00
|
|
|
$message = 'sp-contributions-footer';
|
2012-03-30 18:15:58 +00:00
|
|
|
}
|
2008-10-17 01:35:54 +00:00
|
|
|
|
2019-03-29 20:12:24 +00:00
|
|
|
if ( $message && !$this->including() && !$this->msg( $message, $target )->isDisabled() ) {
|
|
|
|
|
$out->wrapWikiMsg(
|
|
|
|
|
"<div class='mw-contributions-footer'>\n$1\n</div>",
|
|
|
|
|
[ $message, $target ] );
|
2008-10-17 01:35:54 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-06-20 11:37:07 +00:00
|
|
|
|
2008-10-17 01:35:54 +00:00
|
|
|
/**
|
2009-11-14 20:16:38 +00:00
|
|
|
* Generates the subheading with links
|
2014-04-19 08:16:52 +00:00
|
|
|
* @param User $userObj User object for the target
|
|
|
|
|
* @return string Appropriately-escaped HTML to be output literally
|
2013-10-04 05:54:44 +00:00
|
|
|
* @todo FIXME: Almost the same as getSubTitle in SpecialDeletedContributions.php.
|
|
|
|
|
* Could be combined.
|
2009-11-14 20:16:38 +00:00
|
|
|
*/
|
2011-11-20 11:29:56 +00:00
|
|
|
protected function contributionsSub( $userObj ) {
|
|
|
|
|
if ( $userObj->isAnon() ) {
|
2019-08-08 13:01:15 +00:00
|
|
|
// Show a warning message that the user being searched for doesn't exist.
|
2017-04-21 16:17:59 +00:00
|
|
|
// User::isIP returns true for IP address and usemod IPs like '123.123.123.xxx',
|
|
|
|
|
// but returns false for IP ranges. We don't want to suggest either of these are
|
|
|
|
|
// valid usernames which we would with the 'contributions-userdoesnotexist' message.
|
|
|
|
|
if ( !User::isIP( $userObj->getName() ) && !$userObj->isIPRange() ) {
|
2014-04-10 21:24:35 +00:00
|
|
|
$this->getOutput()->wrapWikiMsg(
|
|
|
|
|
"<div class=\"mw-userpage-userdoesnotexist error\">\n\$1\n</div>",
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
2014-04-10 21:24:35 +00:00
|
|
|
'contributions-userdoesnotexist',
|
|
|
|
|
wfEscapeWikiText( $userObj->getName() ),
|
2016-02-17 09:09:32 +00:00
|
|
|
]
|
2014-04-10 21:24:35 +00:00
|
|
|
);
|
2014-07-24 08:25:01 +00:00
|
|
|
if ( !$this->including() ) {
|
|
|
|
|
$this->getOutput()->setStatusCode( 404 );
|
|
|
|
|
}
|
2014-04-10 21:24:35 +00:00
|
|
|
}
|
2011-11-20 11:29:56 +00:00
|
|
|
$user = htmlspecialchars( $userObj->getName() );
|
2008-10-17 01:35:54 +00:00
|
|
|
} else {
|
2016-08-04 21:48:55 +00:00
|
|
|
$user = $this->getLinkRenderer()->makeLink( $userObj->getUserPage(), $userObj->getName() );
|
2008-10-17 01:35:54 +00:00
|
|
|
}
|
2011-11-20 11:29:56 +00:00
|
|
|
$nt = $userObj->getUserPage();
|
|
|
|
|
$talk = $userObj->getTalkPage();
|
2012-03-09 23:33:42 +00:00
|
|
|
$links = '';
|
2011-12-16 10:58:20 +00:00
|
|
|
if ( $talk ) {
|
2016-08-04 22:19:59 +00:00
|
|
|
$tools = self::getUserLinks( $this, $userObj );
|
2019-03-27 20:16:59 +00:00
|
|
|
$links = Html::openElement( 'span', [ 'class' => 'mw-changeslist-links' ] );
|
|
|
|
|
foreach ( $tools as $tool ) {
|
|
|
|
|
$links .= Html::rawElement( 'span', [], $tool ) . ' ';
|
|
|
|
|
}
|
|
|
|
|
$links = trim( $links ) . Html::closeElement( 'span' );
|
2009-09-13 02:07:21 +00:00
|
|
|
|
|
|
|
|
// Show a note if the user is blocked and display the last block log entry.
|
2012-06-05 22:58:54 +00:00
|
|
|
// Do not expose the autoblocks, since that may lead to a leak of accounts' IPs,
|
|
|
|
|
// and also this will display a totally irrelevant log entry as a current block.
|
2014-05-30 12:34:42 +00:00
|
|
|
if ( !$this->including() ) {
|
2019-05-13 14:18:07 +00:00
|
|
|
// For IP ranges you must give DatabaseBlock::newFromTarget the CIDR string
|
|
|
|
|
// and not a user object.
|
2017-04-21 16:17:59 +00:00
|
|
|
if ( $userObj->isIPRange() ) {
|
2019-05-13 14:18:07 +00:00
|
|
|
$block = DatabaseBlock::newFromTarget( $userObj->getName(), $userObj->getName() );
|
2017-04-21 16:17:59 +00:00
|
|
|
} else {
|
2019-05-13 14:18:07 +00:00
|
|
|
$block = DatabaseBlock::newFromTarget( $userObj, $userObj );
|
2017-04-21 16:17:59 +00:00
|
|
|
}
|
|
|
|
|
|
2020-01-09 23:48:34 +00:00
|
|
|
if ( $block !== null && $block->getType() != DatabaseBlock::TYPE_AUTO ) {
|
2019-05-13 14:18:07 +00:00
|
|
|
if ( $block->getType() == DatabaseBlock::TYPE_RANGE ) {
|
2018-08-05 17:58:51 +00:00
|
|
|
$nt = MediaWikiServices::getInstance()->getNamespaceInfo()->
|
|
|
|
|
getCanonicalName( NS_USER ) . ':' . $block->getTarget();
|
2014-05-30 12:34:42 +00:00
|
|
|
}
|
2014-06-07 22:43:15 +00:00
|
|
|
|
2014-05-30 12:34:42 +00:00
|
|
|
$out = $this->getOutput(); // showLogExtract() wants first parameter by reference
|
2020-03-17 23:06:09 +00:00
|
|
|
if ( $userObj->isAnon() ) {
|
|
|
|
|
$msgKey = $block->isSitewide() ?
|
|
|
|
|
'sp-contributions-blocked-notice-anon' :
|
|
|
|
|
'sp-contributions-blocked-notice-anon-partial';
|
|
|
|
|
} else {
|
|
|
|
|
$msgKey = $block->isSitewide() ?
|
|
|
|
|
'sp-contributions-blocked-notice' :
|
|
|
|
|
'sp-contributions-blocked-notice-partial';
|
|
|
|
|
}
|
|
|
|
|
// Allow local styling overrides for different types of block
|
|
|
|
|
$class = $block->isSitewide() ?
|
|
|
|
|
'mw-contributions-blocked-notice' :
|
|
|
|
|
'mw-contributions-blocked-notice-partial';
|
2014-05-30 12:34:42 +00:00
|
|
|
LogEventsList::showLogExtract(
|
|
|
|
|
$out,
|
|
|
|
|
'block',
|
|
|
|
|
$nt,
|
|
|
|
|
'',
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
2014-05-30 12:34:42 +00:00
|
|
|
'lim' => 1,
|
|
|
|
|
'showIfEmpty' => false,
|
2016-02-17 09:09:32 +00:00
|
|
|
'msgKey' => [
|
2020-03-17 23:06:09 +00:00
|
|
|
$msgKey,
|
2014-05-30 12:34:42 +00:00
|
|
|
$userObj->getName() # Support GENDER in 'sp-contributions-blocked-notice'
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
2020-03-17 23:06:09 +00:00
|
|
|
'offset' => '', # don't use WebRequest parameter offset
|
|
|
|
|
'wrap' => Html::rawElement(
|
|
|
|
|
'div',
|
|
|
|
|
[ 'class' => $class ],
|
|
|
|
|
'$1'
|
|
|
|
|
),
|
2016-02-17 09:09:32 +00:00
|
|
|
]
|
2014-05-30 12:34:42 +00:00
|
|
|
);
|
|
|
|
|
}
|
2009-09-17 17:55:41 +00:00
|
|
|
}
|
2008-10-17 01:35:54 +00:00
|
|
|
}
|
2009-10-07 21:53:13 +00:00
|
|
|
|
2019-03-27 18:31:39 +00:00
|
|
|
return Html::rawElement( 'div', [ 'class' => 'mw-contributions-user-tools' ],
|
2019-03-27 20:16:59 +00:00
|
|
|
$this->msg( 'contributions-subtitle' )->rawParams( $user )->params( $userObj->getName() )
|
|
|
|
|
. ' ' . $links
|
2019-03-27 18:31:39 +00:00
|
|
|
);
|
2008-10-17 01:35:54 +00:00
|
|
|
}
|
|
|
|
|
|
2011-02-10 15:29:54 +00:00
|
|
|
/**
|
|
|
|
|
* Links to different places.
|
2016-08-04 22:19:59 +00:00
|
|
|
*
|
|
|
|
|
* @note This function is also called in DeletedContributionsPage
|
|
|
|
|
* @param SpecialPage $sp SpecialPage instance, for context
|
2014-04-19 08:16:52 +00:00
|
|
|
* @param User $target Target user object
|
2011-12-24 23:11:25 +00:00
|
|
|
* @return array
|
2011-02-10 15:29:54 +00:00
|
|
|
*/
|
2016-08-04 22:19:59 +00:00
|
|
|
public static function getUserLinks( SpecialPage $sp, User $target ) {
|
2011-02-10 15:29:54 +00:00
|
|
|
$id = $target->getId();
|
|
|
|
|
$username = $target->getName();
|
2016-08-04 22:19:59 +00:00
|
|
|
$userpage = $target->getUserPage();
|
|
|
|
|
$talkpage = $target->getTalkPage();
|
2019-06-25 18:53:15 +00:00
|
|
|
$isIP = IPUtils::isValid( $username );
|
|
|
|
|
$isRange = IPUtils::isValidRange( $username );
|
2011-02-10 15:29:54 +00:00
|
|
|
|
2016-08-04 22:19:59 +00:00
|
|
|
$linkRenderer = $sp->getLinkRenderer();
|
2017-04-21 16:17:59 +00:00
|
|
|
|
2019-08-30 17:56:27 +00:00
|
|
|
$tools = [];
|
2017-04-21 16:17:59 +00:00
|
|
|
# No talk pages for IP ranges.
|
2019-04-12 09:20:33 +00:00
|
|
|
if ( !$isRange ) {
|
2017-04-21 16:17:59 +00:00
|
|
|
$tools['user-talk'] = $linkRenderer->makeLink(
|
|
|
|
|
$talkpage,
|
|
|
|
|
$sp->msg( 'sp-contributions-talk' )->text()
|
|
|
|
|
);
|
|
|
|
|
}
|
2011-02-10 15:29:54 +00:00
|
|
|
|
2019-08-21 02:01:06 +00:00
|
|
|
# Block / Change block / Unblock links
|
|
|
|
|
$permissionManager = MediaWikiServices::getInstance()->getPermissionManager();
|
|
|
|
|
if ( $permissionManager->userHasRight( $sp->getUser(), 'block' ) ) {
|
2019-05-13 14:18:07 +00:00
|
|
|
if ( $target->getBlock() && $target->getBlock()->getType() != DatabaseBlock::TYPE_AUTO ) {
|
2019-04-12 09:20:33 +00:00
|
|
|
$tools['block'] = $linkRenderer->makeKnownLink( # Change block link
|
|
|
|
|
SpecialPage::getTitleFor( 'Block', $username ),
|
|
|
|
|
$sp->msg( 'change-blocklink' )->text()
|
|
|
|
|
);
|
|
|
|
|
$tools['unblock'] = $linkRenderer->makeKnownLink( # Unblock link
|
|
|
|
|
SpecialPage::getTitleFor( 'Unblock', $username ),
|
|
|
|
|
$sp->msg( 'unblocklink' )->text()
|
|
|
|
|
);
|
|
|
|
|
} else { # User is not blocked
|
|
|
|
|
$tools['block'] = $linkRenderer->makeKnownLink( # Block link
|
|
|
|
|
SpecialPage::getTitleFor( 'Block', $username ),
|
|
|
|
|
$sp->msg( 'blocklink' )->text()
|
|
|
|
|
);
|
2011-02-10 15:29:54 +00:00
|
|
|
}
|
2019-04-12 09:20:33 +00:00
|
|
|
}
|
2013-04-14 17:27:14 +00:00
|
|
|
|
2019-04-12 09:20:33 +00:00
|
|
|
# Block log link
|
|
|
|
|
$tools['log-block'] = $linkRenderer->makeKnownLink(
|
|
|
|
|
SpecialPage::getTitleFor( 'Log', 'block' ),
|
|
|
|
|
$sp->msg( 'sp-contributions-blocklog' )->text(),
|
|
|
|
|
[],
|
|
|
|
|
[ 'page' => $userpage->getPrefixedText() ]
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
# Suppression log link (T61120)
|
2019-08-21 02:01:06 +00:00
|
|
|
if ( $permissionManager->userHasRight( $sp->getUser(), 'suppressionlog' ) ) {
|
2019-04-12 09:20:33 +00:00
|
|
|
$tools['log-suppression'] = $linkRenderer->makeKnownLink(
|
|
|
|
|
SpecialPage::getTitleFor( 'Log', 'suppress' ),
|
|
|
|
|
$sp->msg( 'sp-contributions-suppresslog', $username )->text(),
|
2016-02-17 09:09:32 +00:00
|
|
|
[],
|
2019-04-12 09:20:33 +00:00
|
|
|
[ 'offender' => $username ]
|
2011-02-10 15:29:54 +00:00
|
|
|
);
|
|
|
|
|
}
|
2017-04-21 16:17:59 +00:00
|
|
|
|
|
|
|
|
# Don't show some links for IP ranges
|
2019-04-12 09:20:33 +00:00
|
|
|
if ( !$isRange ) {
|
|
|
|
|
# Uploads: hide if IPs cannot upload (T220674)
|
2019-08-21 02:01:06 +00:00
|
|
|
if ( !$isIP || $permissionManager->userHasRight( $target, 'upload' ) ) {
|
2019-04-12 09:20:33 +00:00
|
|
|
$tools['uploads'] = $linkRenderer->makeKnownLink(
|
|
|
|
|
SpecialPage::getTitleFor( 'Listfiles', $username ),
|
|
|
|
|
$sp->msg( 'sp-contributions-uploads' )->text()
|
|
|
|
|
);
|
|
|
|
|
}
|
2017-04-21 16:17:59 +00:00
|
|
|
|
|
|
|
|
# Other logs link
|
2019-04-12 09:20:33 +00:00
|
|
|
# Todo: T146628
|
2017-04-21 16:17:59 +00:00
|
|
|
$tools['logs'] = $linkRenderer->makeKnownLink(
|
|
|
|
|
SpecialPage::getTitleFor( 'Log', $username ),
|
|
|
|
|
$sp->msg( 'sp-contributions-logs' )->text()
|
2011-02-10 15:29:54 +00:00
|
|
|
);
|
2017-04-21 16:17:59 +00:00
|
|
|
|
|
|
|
|
# Add link to deleted user contributions for priviledged users
|
2019-04-12 09:20:33 +00:00
|
|
|
# Todo: T183457
|
2019-08-21 02:01:06 +00:00
|
|
|
if ( $permissionManager->userHasRight( $sp->getUser(), 'deletedhistory' ) ) {
|
2017-04-21 16:17:59 +00:00
|
|
|
$tools['deletedcontribs'] = $linkRenderer->makeKnownLink(
|
|
|
|
|
SpecialPage::getTitleFor( 'DeletedContributions', $username ),
|
|
|
|
|
$sp->msg( 'sp-contributions-deleted', $username )->text()
|
|
|
|
|
);
|
|
|
|
|
}
|
2011-02-10 15:29:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Add a link to change user rights for privileged users
|
|
|
|
|
$userrightsPage = new UserrightsPage();
|
2016-08-04 22:19:59 +00:00
|
|
|
$userrightsPage->setContext( $sp->getContext() );
|
2012-04-02 16:32:23 +00:00
|
|
|
if ( $userrightsPage->userCanChangeRights( $target ) ) {
|
2016-08-04 22:19:59 +00:00
|
|
|
$tools['userrights'] = $linkRenderer->makeKnownLink(
|
2011-02-10 15:29:54 +00:00
|
|
|
SpecialPage::getTitleFor( 'Userrights', $username ),
|
2017-04-15 15:21:10 +00:00
|
|
|
$sp->msg( 'sp-contributions-userrights', $username )->text()
|
2011-02-10 15:29:54 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
Hooks::runner()->onContributionsToolLinks( $id, $userpage, $tools, $sp );
|
2013-04-14 17:27:14 +00:00
|
|
|
|
2011-02-10 15:29:54 +00:00
|
|
|
return $tools;
|
|
|
|
|
}
|
|
|
|
|
|
2008-10-17 01:35:54 +00:00
|
|
|
/**
|
|
|
|
|
* Generates the namespace selector form with hidden attributes.
|
2019-03-28 00:06:35 +00:00
|
|
|
* @param array $pagerOptions with keys contribs, user, deletedOnly, limit, target, topOnly,
|
|
|
|
|
* newOnly, hideMinor, namespace, associated, nsInvert, tagfilter, year, start, end
|
2014-04-19 08:16:52 +00:00
|
|
|
* @return string HTML fragment
|
2008-10-17 01:35:54 +00:00
|
|
|
*/
|
2019-03-28 00:06:35 +00:00
|
|
|
protected function getForm( array $pagerOptions ) {
|
2013-12-24 08:07:04 +00:00
|
|
|
$this->opts['title'] = $this->getPageTitle()->getPrefixedText();
|
2018-02-19 11:53:47 +00:00
|
|
|
// Modules required only for the form
|
|
|
|
|
$this->getOutput()->addModules( [
|
|
|
|
|
'mediawiki.special.contributions',
|
|
|
|
|
] );
|
|
|
|
|
$this->getOutput()->addModuleStyles( 'mediawiki.widgets.DateInputWidget.styles' );
|
|
|
|
|
$this->getOutput()->enableOOUI();
|
2016-04-02 08:03:42 +00:00
|
|
|
$fields = [];
|
2010-04-26 16:35:02 +00:00
|
|
|
|
|
|
|
|
# Add hidden params for tracking except for parameters in $skipParameters
|
2016-02-17 09:09:32 +00:00
|
|
|
$skipParameters = [
|
2013-03-28 11:43:08 +00:00
|
|
|
'namespace',
|
|
|
|
|
'nsInvert',
|
|
|
|
|
'deletedOnly',
|
|
|
|
|
'target',
|
|
|
|
|
'year',
|
|
|
|
|
'month',
|
2016-12-12 14:26:15 +00:00
|
|
|
'start',
|
|
|
|
|
'end',
|
2013-03-28 11:43:08 +00:00
|
|
|
'topOnly',
|
2014-02-26 20:57:58 +00:00
|
|
|
'newOnly',
|
2015-10-07 11:04:09 +00:00
|
|
|
'hideMinor',
|
2015-12-06 01:08:44 +00:00
|
|
|
'associated',
|
|
|
|
|
'tagfilter'
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2013-03-28 11:43:08 +00:00
|
|
|
|
2008-10-19 06:40:00 +00:00
|
|
|
foreach ( $this->opts as $name => $value ) {
|
2011-12-16 10:58:20 +00:00
|
|
|
if ( in_array( $name, $skipParameters ) ) {
|
2008-10-17 01:35:54 +00:00
|
|
|
continue;
|
|
|
|
|
}
|
2009-01-30 23:24:29 +00:00
|
|
|
|
2016-04-02 08:03:42 +00:00
|
|
|
$fields[$name] = [
|
|
|
|
|
'name' => $name,
|
|
|
|
|
'type' => 'hidden',
|
|
|
|
|
'default' => $value,
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$target = $this->opts['target'] ?? null;
|
|
|
|
|
$fields['target'] = [
|
2019-10-04 20:49:58 +00:00
|
|
|
'type' => 'user',
|
2016-04-02 08:03:42 +00:00
|
|
|
'default' => $target ?
|
|
|
|
|
str_replace( '_', ' ', $target ) : '' ,
|
|
|
|
|
'label' => $this->msg( 'sp-contributions-username' )->text(),
|
|
|
|
|
'name' => 'target',
|
|
|
|
|
'id' => 'mw-target-user-or-ip',
|
|
|
|
|
'size' => 40,
|
|
|
|
|
'autofocus' => !$target,
|
|
|
|
|
'section' => 'contribs-top',
|
|
|
|
|
];
|
2011-12-15 01:02:25 +00:00
|
|
|
|
2016-04-02 08:03:42 +00:00
|
|
|
$ns = $this->opts['namespace'] ?? null;
|
|
|
|
|
$fields['namespace'] = [
|
|
|
|
|
'type' => 'namespaceselect',
|
|
|
|
|
'label' => $this->msg( 'namespace' )->text(),
|
|
|
|
|
'name' => 'namespace',
|
|
|
|
|
'cssclass' => 'namespaceselector',
|
|
|
|
|
'default' => $ns,
|
|
|
|
|
'id' => 'namespace',
|
|
|
|
|
'section' => 'contribs-top',
|
|
|
|
|
];
|
|
|
|
|
$request = $this->getRequest();
|
|
|
|
|
$nsFilters = $request->getArray( 'wpfilters' );
|
|
|
|
|
$fields['nsFilters'] = [
|
|
|
|
|
'class' => 'HTMLMultiSelectField',
|
|
|
|
|
'label' => '',
|
|
|
|
|
'name' => 'wpfilters',
|
|
|
|
|
'flatlist' => true,
|
|
|
|
|
// Only shown when namespaces are selected.
|
|
|
|
|
'cssclass' => $ns === '' ?
|
|
|
|
|
'contribs-ns-filters mw-input-with-label mw-input-hidden' :
|
|
|
|
|
'contribs-ns-filters mw-input-with-label',
|
|
|
|
|
// `contribs-ns-filters` class allows these fields to be toggled on/off by JavaScript.
|
|
|
|
|
// See resources/src/mediawiki.special.recentchanges.js
|
|
|
|
|
'infusable' => true,
|
|
|
|
|
'options' => [
|
|
|
|
|
$this->msg( 'invert' )->text() => 'nsInvert',
|
|
|
|
|
$this->msg( 'namespace_association' )->text() => 'associated',
|
|
|
|
|
],
|
|
|
|
|
'default' => $nsFilters,
|
|
|
|
|
'section' => 'contribs-top',
|
|
|
|
|
];
|
|
|
|
|
$fields['tagfilter'] = [
|
|
|
|
|
'type' => 'tagfilter',
|
|
|
|
|
'cssclass' => 'mw-tagfilter-input',
|
|
|
|
|
'id' => 'tagfilter',
|
|
|
|
|
'label-message' => [ 'tag-filter', 'parse' ],
|
|
|
|
|
'name' => 'tagfilter',
|
|
|
|
|
'size' => 20,
|
|
|
|
|
'section' => 'contribs-top',
|
|
|
|
|
];
|
2016-01-27 04:29:16 +00:00
|
|
|
|
2019-08-21 02:01:06 +00:00
|
|
|
if ( MediaWikiServices::getInstance()
|
2016-04-02 08:03:42 +00:00
|
|
|
->getPermissionManager()
|
|
|
|
|
->userHasRight( $this->getUser(), 'deletedhistory' )
|
2019-08-21 02:01:06 +00:00
|
|
|
) {
|
2016-04-02 08:03:42 +00:00
|
|
|
$fields['deletedOnly'] = [
|
|
|
|
|
'type' => 'check',
|
|
|
|
|
'id' => 'mw-show-deleted-only',
|
|
|
|
|
'label' => $this->msg( 'history-show-deleted' )->text(),
|
|
|
|
|
'name' => 'deletedOnly',
|
|
|
|
|
'section' => 'contribs-top',
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$fields['topOnly'] = [
|
|
|
|
|
'type' => 'check',
|
|
|
|
|
'id' => 'mw-show-top-only',
|
|
|
|
|
'label' => $this->msg( 'sp-contributions-toponly' )->text(),
|
|
|
|
|
'name' => 'topOnly',
|
|
|
|
|
'section' => 'contribs-top',
|
|
|
|
|
];
|
|
|
|
|
$fields['newOnly'] = [
|
|
|
|
|
'type' => 'check',
|
|
|
|
|
'id' => 'mw-show-new-only',
|
|
|
|
|
'label' => $this->msg( 'sp-contributions-newonly' )->text(),
|
|
|
|
|
'name' => 'newOnly',
|
|
|
|
|
'section' => 'contribs-top',
|
|
|
|
|
];
|
|
|
|
|
$fields['hideMinor'] = [
|
|
|
|
|
'type' => 'check',
|
|
|
|
|
'cssclass' => 'mw-hide-minor-edits',
|
|
|
|
|
'id' => 'mw-show-new-only',
|
|
|
|
|
'label' => $this->msg( 'sp-contributions-hideminor' )->text(),
|
|
|
|
|
'name' => 'hideMinor',
|
|
|
|
|
'section' => 'contribs-top',
|
|
|
|
|
];
|
2016-01-27 04:29:16 +00:00
|
|
|
|
2016-04-02 08:03:42 +00:00
|
|
|
// Allow additions at this point to the filters.
|
|
|
|
|
$rawFilters = [];
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
$this->getHookRunner()->onSpecialContributions__getForm__filters(
|
|
|
|
|
$this, $rawFilters );
|
2016-04-02 08:03:42 +00:00
|
|
|
foreach ( $rawFilters as $filter ) {
|
|
|
|
|
// Backwards compatibility support for previous hook function signature.
|
|
|
|
|
if ( is_string( $filter ) ) {
|
|
|
|
|
$fields[] = [
|
|
|
|
|
'type' => 'info',
|
|
|
|
|
'default' => $filter,
|
|
|
|
|
'raw' => true,
|
|
|
|
|
'section' => 'contribs-top',
|
|
|
|
|
];
|
|
|
|
|
wfDeprecated(
|
Introduce wfDeprecatedMsg()
Deprecating something means to say something nasty about it, or to draw
its character into question. For example, "this function is lazy and good
for nothing". Deprecatory remarks by a developer are generally taken as a
warning that violence will soon be done against the function in question.
Other developers are thus warned to avoid associating with the deprecated
function.
However, since wfDeprecated() was introduced, it has become obvious that
the targets of deprecation are not limited to functions. Developers can
deprecate literally anything: a parameter, a return value, a file
format, Mondays, the concept of being, etc. wfDeprecated() requires
every deprecatory statement to begin with "use of", leading to some
awkward sentences. For example, one might say: "Use of your mouth to
cough without it being covered by your arm is deprecated since 2020."
So, introduce wfDeprecatedMsg(), which allows deprecation messages to be
specified in plain text, with the caller description being optionally
appended. Migrate incorrect or gramatically awkward uses of wfDeprecated()
to wfDeprecatedMsg().
Change-Id: Ib3dd2fe37677d98425d0f3692db5c9e988943ae8
2020-06-12 04:18:35 +00:00
|
|
|
'A SpecialContributions::getForm::filters hook handler returned ' .
|
|
|
|
|
'an array of strings, this is deprecated since MediaWiki 1.33',
|
|
|
|
|
'1.33', false, false
|
2016-04-02 08:03:42 +00:00
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
// Preferred append method.
|
|
|
|
|
$fields[] = $filter;
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-12-12 14:26:15 +00:00
|
|
|
|
2016-04-02 08:03:42 +00:00
|
|
|
$fields['start'] = [
|
|
|
|
|
'type' => 'date',
|
|
|
|
|
'default' => '',
|
|
|
|
|
'id' => 'mw-date-start',
|
|
|
|
|
'label' => $this->msg( 'date-range-from' )->text(),
|
|
|
|
|
'name' => 'start',
|
|
|
|
|
'section' => 'contribs-date',
|
|
|
|
|
];
|
|
|
|
|
$fields['end'] = [
|
|
|
|
|
'type' => 'date',
|
|
|
|
|
'default' => '',
|
|
|
|
|
'id' => 'mw-date-end',
|
|
|
|
|
'label' => $this->msg( 'date-range-to' )->text(),
|
|
|
|
|
'name' => 'end',
|
|
|
|
|
'section' => 'contribs-date',
|
|
|
|
|
];
|
2011-12-15 01:02:25 +00:00
|
|
|
|
2016-04-02 08:03:42 +00:00
|
|
|
$htmlForm = HTMLForm::factory( 'ooui', $fields, $this->getContext() );
|
|
|
|
|
$htmlForm
|
|
|
|
|
->setMethod( 'get' )
|
2019-03-28 00:06:35 +00:00
|
|
|
// When offset is defined, the user is paging through results
|
|
|
|
|
// so we hide the form by default to allow users to focus on browsing
|
|
|
|
|
// rather than defining search parameters
|
|
|
|
|
->setCollapsibleOptions(
|
|
|
|
|
( $pagerOptions['target'] ?? null ) ||
|
|
|
|
|
( $pagerOptions['start'] ?? null ) ||
|
|
|
|
|
( $pagerOptions['end'] ?? null )
|
|
|
|
|
)
|
2016-04-02 08:03:42 +00:00
|
|
|
->setAction( wfScript() )
|
|
|
|
|
->setSubmitText( $this->msg( 'sp-contributions-submit' )->text() )
|
|
|
|
|
->setWrapperLegend( $this->msg( 'sp-contributions-search' )->text() );
|
2011-12-15 01:02:25 +00:00
|
|
|
|
2011-12-26 16:20:30 +00:00
|
|
|
$explain = $this->msg( 'sp-contributions-explain' );
|
2012-11-28 23:12:01 +00:00
|
|
|
if ( !$explain->isBlank() ) {
|
2016-04-02 08:03:42 +00:00
|
|
|
$htmlForm->addFooterText( "<p id='mw-sp-contributions-explain'>{$explain->parse()}</p>" );
|
2010-09-08 11:21:08 +00:00
|
|
|
}
|
2013-03-28 11:43:08 +00:00
|
|
|
|
2016-04-02 08:03:42 +00:00
|
|
|
$htmlForm->loadData();
|
2013-03-28 11:43:08 +00:00
|
|
|
|
2016-04-02 08:03:42 +00:00
|
|
|
return $htmlForm->getHTML( false );
|
2008-10-17 01:35:54 +00:00
|
|
|
}
|
2013-03-07 20:15:54 +00:00
|
|
|
|
2015-12-03 20:08:31 +00:00
|
|
|
/**
|
|
|
|
|
* Return an array of subpages beginning with $search that this special page will accept.
|
|
|
|
|
*
|
|
|
|
|
* @param string $search Prefix to search for
|
|
|
|
|
* @param int $limit Maximum number of results to return (usually 10)
|
|
|
|
|
* @param int $offset Number of results to skip (usually 0)
|
|
|
|
|
* @return string[] Matching subpages
|
|
|
|
|
*/
|
|
|
|
|
public function prefixSearchSubpages( $search, $limit, $offset ) {
|
|
|
|
|
$user = User::newFromName( $search );
|
|
|
|
|
if ( !$user ) {
|
|
|
|
|
// No prefix suggestion for invalid user
|
2016-02-17 09:09:32 +00:00
|
|
|
return [];
|
2015-12-03 20:08:31 +00:00
|
|
|
}
|
|
|
|
|
// Autocomplete subpage as user list - public to allow caching
|
|
|
|
|
return UserNamePrefixSearch::search( 'public', $search, $limit, $offset );
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-07 20:15:54 +00:00
|
|
|
protected function getGroupName() {
|
|
|
|
|
return 'users';
|
|
|
|
|
}
|
2008-10-17 01:35:54 +00:00
|
|
|
}
|