2004-02-18 02:15:00 +00:00
|
|
|
<?php
|
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-15 07:16:58 +00:00
|
|
|
*
|
|
|
|
|
* @file
|
2010-06-21 12:59:04 +00:00
|
|
|
*/
|
2007-12-15 20:22:16 +00:00
|
|
|
|
2023-09-13 10:31:13 +00:00
|
|
|
namespace MediaWiki\Specials;
|
|
|
|
|
|
|
|
|
|
use HtmlArmor;
|
2020-09-18 20:59:45 +00:00
|
|
|
use MediaWiki\Cache\LinkBatchFactory;
|
2023-06-15 23:17:05 +00:00
|
|
|
use MediaWiki\ChangeTags\ChangeTagsStore;
|
2023-09-20 22:36:46 +00:00
|
|
|
use MediaWiki\CommentFormatter\RowCommentFormatter;
|
2020-09-18 20:59:45 +00:00
|
|
|
use MediaWiki\Content\IContentHandlerFactory;
|
2022-10-17 11:10:57 +00:00
|
|
|
use MediaWiki\Feed\FeedItem;
|
2023-02-16 19:27:21 +00:00
|
|
|
use MediaWiki\Html\FormOptions;
|
|
|
|
|
use MediaWiki\Html\Html;
|
2024-02-08 15:30:18 +00:00
|
|
|
use MediaWiki\HTMLForm\HTMLForm;
|
2022-04-10 15:34:45 +00:00
|
|
|
use MediaWiki\MainConfigNames;
|
2023-09-15 08:38:07 +00:00
|
|
|
use MediaWiki\Pager\NewPagesPager;
|
2021-05-26 05:12:16 +00:00
|
|
|
use MediaWiki\Permissions\GroupPermissionsLookup;
|
2020-09-18 20:59:45 +00:00
|
|
|
use MediaWiki\Revision\RevisionLookup;
|
2020-05-04 17:42:55 +00:00
|
|
|
use MediaWiki\Revision\SlotRecord;
|
2023-09-15 09:32:18 +00:00
|
|
|
use MediaWiki\SpecialPage\IncludableSpecialPage;
|
2023-09-18 14:17:28 +00:00
|
|
|
use MediaWiki\Title\NamespaceInfo;
|
2023-03-01 20:33:26 +00:00
|
|
|
use MediaWiki\Title\Title;
|
2023-11-29 10:21:43 +00:00
|
|
|
use MediaWiki\User\Options\UserOptionsLookup;
|
2024-07-24 12:23:21 +00:00
|
|
|
use MediaWiki\User\TempUser\TempUserConfig;
|
2019-08-22 02:22:26 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2024-05-13 20:18:10 +00:00
|
|
|
* List of newly created pages
|
2010-08-15 07:16:58 +00:00
|
|
|
*
|
2024-05-13 20:18:10 +00:00
|
|
|
* @see SpecialRecentChanges
|
|
|
|
|
* @see SpecialNewFiles
|
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
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2023-09-13 10:31:13 +00:00
|
|
|
class SpecialNewPages extends IncludableSpecialPage {
|
2011-02-21 17:03:18 +00:00
|
|
|
/**
|
|
|
|
|
* @var FormOptions
|
|
|
|
|
*/
|
|
|
|
|
protected $opts;
|
2019-10-11 14:31:51 +00:00
|
|
|
/** @var array[] */
|
2011-05-23 04:28:58 +00:00
|
|
|
protected $customFilters;
|
2011-02-21 17:03:18 +00:00
|
|
|
|
2024-09-13 19:04:26 +00:00
|
|
|
/** @var bool */
|
2008-05-11 21:43:16 +00:00
|
|
|
protected $showNavigation = false;
|
|
|
|
|
|
2023-08-28 15:32:58 +00:00
|
|
|
private LinkBatchFactory $linkBatchFactory;
|
|
|
|
|
private IContentHandlerFactory $contentHandlerFactory;
|
|
|
|
|
private GroupPermissionsLookup $groupPermissionsLookup;
|
|
|
|
|
private RevisionLookup $revisionLookup;
|
|
|
|
|
private NamespaceInfo $namespaceInfo;
|
|
|
|
|
private UserOptionsLookup $userOptionsLookup;
|
2023-09-20 22:36:46 +00:00
|
|
|
private RowCommentFormatter $rowCommentFormatter;
|
2023-06-15 23:17:05 +00:00
|
|
|
private ChangeTagsStore $changeTagsStore;
|
2024-07-24 12:23:21 +00:00
|
|
|
private TempUserConfig $tempUserConfig;
|
2022-12-11 00:15:56 +00:00
|
|
|
|
2020-09-18 20:59:45 +00:00
|
|
|
/**
|
|
|
|
|
* @param LinkBatchFactory $linkBatchFactory
|
|
|
|
|
* @param IContentHandlerFactory $contentHandlerFactory
|
2021-05-26 05:12:16 +00:00
|
|
|
* @param GroupPermissionsLookup $groupPermissionsLookup
|
2020-09-18 20:59:45 +00:00
|
|
|
* @param RevisionLookup $revisionLookup
|
|
|
|
|
* @param NamespaceInfo $namespaceInfo
|
2020-10-18 11:46:56 +00:00
|
|
|
* @param UserOptionsLookup $userOptionsLookup
|
2023-09-20 22:36:46 +00:00
|
|
|
* @param RowCommentFormatter $rowCommentFormatter
|
2024-07-24 12:23:21 +00:00
|
|
|
* @param ChangeTagsStore $changeTagsStore
|
|
|
|
|
* @param TempUserConfig $tempUserConfig
|
2020-09-18 20:59:45 +00:00
|
|
|
*/
|
|
|
|
|
public function __construct(
|
|
|
|
|
LinkBatchFactory $linkBatchFactory,
|
|
|
|
|
IContentHandlerFactory $contentHandlerFactory,
|
2021-05-26 05:12:16 +00:00
|
|
|
GroupPermissionsLookup $groupPermissionsLookup,
|
2020-09-18 20:59:45 +00:00
|
|
|
RevisionLookup $revisionLookup,
|
|
|
|
|
NamespaceInfo $namespaceInfo,
|
2022-12-11 00:15:56 +00:00
|
|
|
UserOptionsLookup $userOptionsLookup,
|
2023-09-20 22:36:46 +00:00
|
|
|
RowCommentFormatter $rowCommentFormatter,
|
2024-07-24 12:23:21 +00:00
|
|
|
ChangeTagsStore $changeTagsStore,
|
|
|
|
|
TempUserConfig $tempUserConfig
|
2020-09-18 20:59:45 +00:00
|
|
|
) {
|
2008-06-18 20:45:10 +00:00
|
|
|
parent::__construct( 'Newpages' );
|
2020-09-18 20:59:45 +00:00
|
|
|
$this->linkBatchFactory = $linkBatchFactory;
|
|
|
|
|
$this->contentHandlerFactory = $contentHandlerFactory;
|
2021-05-26 05:12:16 +00:00
|
|
|
$this->groupPermissionsLookup = $groupPermissionsLookup;
|
2020-09-18 20:59:45 +00:00
|
|
|
$this->revisionLookup = $revisionLookup;
|
|
|
|
|
$this->namespaceInfo = $namespaceInfo;
|
2020-10-18 11:46:56 +00:00
|
|
|
$this->userOptionsLookup = $userOptionsLookup;
|
2023-09-20 22:36:46 +00:00
|
|
|
$this->rowCommentFormatter = $rowCommentFormatter;
|
2023-06-15 23:17:05 +00:00
|
|
|
$this->changeTagsStore = $changeTagsStore;
|
2024-07-24 12:23:21 +00:00
|
|
|
$this->tempUserConfig = $tempUserConfig;
|
2008-06-18 20:45:10 +00:00
|
|
|
}
|
|
|
|
|
|
2019-03-28 11:24:26 +00:00
|
|
|
/**
|
|
|
|
|
* @param string|null $par
|
|
|
|
|
*/
|
2008-05-11 21:43:16 +00:00
|
|
|
protected function setup( $par ) {
|
|
|
|
|
$opts = new FormOptions();
|
2008-05-14 05:18:27 +00:00
|
|
|
$this->opts = $opts; // bind
|
2008-05-11 21:43:16 +00:00
|
|
|
$opts->add( 'hideliu', false );
|
2020-10-18 11:46:56 +00:00
|
|
|
$opts->add(
|
|
|
|
|
'hidepatrolled',
|
|
|
|
|
$this->userOptionsLookup->getBoolOption( $this->getUser(), 'newpageshidepatrolled' )
|
|
|
|
|
);
|
2009-04-19 21:03:30 +00:00
|
|
|
$opts->add( 'hidebots', false );
|
2008-11-02 22:58:35 +00:00
|
|
|
$opts->add( 'hideredirs', true );
|
2020-10-18 11:46:56 +00:00
|
|
|
$opts->add(
|
|
|
|
|
'limit',
|
|
|
|
|
$this->userOptionsLookup->getIntOption( $this->getUser(), 'rclimit' )
|
|
|
|
|
);
|
2008-05-14 13:28:46 +00:00
|
|
|
$opts->add( 'offset', '' );
|
2008-05-11 21:43:16 +00:00
|
|
|
$opts->add( 'namespace', '0' );
|
|
|
|
|
$opts->add( 'username', '' );
|
|
|
|
|
$opts->add( 'feed', '' );
|
2009-01-28 19:08:18 +00:00
|
|
|
$opts->add( 'tagfilter', '' );
|
2023-07-15 10:32:50 +00:00
|
|
|
$opts->add( 'tagInvert', false );
|
2013-02-16 00:43:38 +00:00
|
|
|
$opts->add( 'invert', false );
|
2019-07-16 21:57:51 +00:00
|
|
|
$opts->add( 'associated', false );
|
2016-10-27 01:23:18 +00:00
|
|
|
$opts->add( 'size-mode', 'max' );
|
|
|
|
|
$opts->add( 'size', 0 );
|
2008-05-11 21:43:16 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->customFilters = [];
|
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()->onSpecialNewPagesFilters( $this, $this->customFilters );
|
2019-10-12 17:38:08 +00:00
|
|
|
// @phan-suppress-next-line PhanEmptyForeach False positive
|
2013-04-19 20:55:47 +00:00
|
|
|
foreach ( $this->customFilters as $key => $params ) {
|
2011-05-23 04:28:58 +00:00
|
|
|
$opts->add( $key, $params['default'] );
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-03 05:46:42 +00:00
|
|
|
$opts->fetchValuesFromRequest( $this->getRequest() );
|
2013-04-19 20:55:47 +00:00
|
|
|
if ( $par ) {
|
|
|
|
|
$this->parseParams( $par );
|
|
|
|
|
}
|
2008-05-11 21:43:16 +00:00
|
|
|
|
2024-07-24 12:23:21 +00:00
|
|
|
// The hideliu option is only available when anonymous users can create pages, as if specified when they
|
|
|
|
|
// cannot create pages it always would produce no results. Therefore, if anon users cannot create pages
|
|
|
|
|
// then set hideliu as false overriding the value provided by the user.
|
|
|
|
|
if ( !$this->canAnonymousUsersCreatePages() ) {
|
|
|
|
|
$opts->setValue( 'hideliu', false, true );
|
|
|
|
|
}
|
|
|
|
|
|
2008-05-11 21:43:16 +00:00
|
|
|
$opts->validateIntBounds( 'limit', 0, 5000 );
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-28 11:24:26 +00:00
|
|
|
/**
|
|
|
|
|
* @param string $par
|
|
|
|
|
*/
|
2008-05-11 21:43:16 +00:00
|
|
|
protected function parseParams( $par ) {
|
|
|
|
|
$bits = preg_split( '/\s*,\s*/', trim( $par ) );
|
|
|
|
|
foreach ( $bits as $bit ) {
|
2023-03-30 00:10:52 +00:00
|
|
|
$m = [];
|
2018-06-30 09:43:00 +00:00
|
|
|
if ( $bit === 'shownav' ) {
|
2008-05-11 21:43:16 +00:00
|
|
|
$this->showNavigation = true;
|
2023-03-30 00:10:52 +00:00
|
|
|
} elseif ( $bit === 'hideliu' ) {
|
2008-05-11 21:43:16 +00:00
|
|
|
$this->opts->setValue( 'hideliu', true );
|
2023-03-30 00:10:52 +00:00
|
|
|
} elseif ( $bit === 'hidepatrolled' ) {
|
2008-05-11 21:43:16 +00:00
|
|
|
$this->opts->setValue( 'hidepatrolled', true );
|
2023-03-30 00:10:52 +00:00
|
|
|
} elseif ( $bit === 'hidebots' ) {
|
2008-05-11 21:43:16 +00:00
|
|
|
$this->opts->setValue( 'hidebots', true );
|
2023-03-30 00:10:52 +00:00
|
|
|
} elseif ( $bit === 'showredirs' ) {
|
2008-11-02 22:58:35 +00:00
|
|
|
$this->opts->setValue( 'hideredirs', false );
|
2023-03-30 00:10:52 +00:00
|
|
|
} elseif ( is_numeric( $bit ) ) {
|
2008-05-11 21:43:16 +00:00
|
|
|
$this->opts->setValue( 'limit', intval( $bit ) );
|
2023-03-30 00:10:52 +00:00
|
|
|
} elseif ( preg_match( '/^limit=(\d+)$/', $bit, $m ) ) {
|
2011-02-19 02:07:10 +00:00
|
|
|
$this->opts->setValue( 'limit', intval( $m[1] ) );
|
2023-03-30 00:10:52 +00:00
|
|
|
} elseif ( preg_match( '/^offset=([^=]+)$/', $bit, $m ) ) {
|
|
|
|
|
// PG offsets not just digits!
|
2013-01-28 21:11:10 +00:00
|
|
|
$this->opts->setValue( 'offset', intval( $m[1] ) );
|
2023-03-30 00:10:52 +00:00
|
|
|
} elseif ( preg_match( '/^username=(.*)$/', $bit, $m ) ) {
|
2009-01-06 23:46:32 +00:00
|
|
|
$this->opts->setValue( 'username', $m[1] );
|
2023-03-30 00:10:52 +00:00
|
|
|
} elseif ( preg_match( '/^namespace=(.*)$/', $bit, $m ) ) {
|
2011-11-21 16:13:21 +00:00
|
|
|
$ns = $this->getLanguage()->getNsIndex( $m[1] );
|
2013-04-19 20:55:47 +00:00
|
|
|
if ( $ns !== false ) {
|
2013-01-28 21:11:10 +00:00
|
|
|
$this->opts->setValue( 'namespace', $ns );
|
2008-05-11 21:43:16 +00:00
|
|
|
}
|
2023-03-30 00:10:52 +00:00
|
|
|
} else {
|
|
|
|
|
// T62424 try to interpret unrecognized parameters as a namespace
|
|
|
|
|
$ns = $this->getLanguage()->getNsIndex( $bit );
|
|
|
|
|
if ( $ns !== false ) {
|
|
|
|
|
$this->opts->setValue( 'namespace', $ns );
|
|
|
|
|
}
|
2008-05-11 21:43:16 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-21 06:49:23 +00:00
|
|
|
/**
|
2006-07-10 08:38:48 +00:00
|
|
|
* Show a form for filtering namespace and username
|
2006-04-21 06:49:23 +00:00
|
|
|
*
|
2019-03-28 11:24:26 +00:00
|
|
|
* @param string|null $par
|
2008-02-10 10:05:49 +00:00
|
|
|
*/
|
2008-06-18 20:45:10 +00:00
|
|
|
public function execute( $par ) {
|
2011-04-03 05:46:42 +00:00
|
|
|
$out = $this->getOutput();
|
2007-11-01 16:18:17 +00:00
|
|
|
|
2008-06-18 20:45:10 +00:00
|
|
|
$this->setHeaders();
|
|
|
|
|
$this->outputHeader();
|
|
|
|
|
|
|
|
|
|
$this->showNavigation = !$this->including(); // Maybe changed in setup
|
2008-05-11 21:43:16 +00:00
|
|
|
$this->setup( $par );
|
2007-12-15 20:22:16 +00:00
|
|
|
|
2015-05-02 11:37:19 +00:00
|
|
|
$this->addHelpLink( 'Help:New pages' );
|
2014-08-31 10:25:18 +00:00
|
|
|
|
2013-04-19 20:55:47 +00:00
|
|
|
if ( !$this->including() ) {
|
2008-05-14 05:18:27 +00:00
|
|
|
// Settings
|
|
|
|
|
$this->form();
|
2007-12-15 20:22:16 +00:00
|
|
|
|
2008-05-11 21:43:16 +00:00
|
|
|
$feedType = $this->opts->getValue( 'feed' );
|
2013-04-19 20:55:47 +00:00
|
|
|
if ( $feedType ) {
|
2012-12-09 03:16:14 +00:00
|
|
|
$this->feed( $feedType );
|
2013-05-09 14:51:30 +00:00
|
|
|
|
2012-12-09 03:16:14 +00:00
|
|
|
return;
|
2008-04-15 20:42:42 +00:00
|
|
|
}
|
2011-10-03 14:21:20 +00:00
|
|
|
|
2012-04-04 20:51:51 +00:00
|
|
|
$allValues = $this->opts->getAllValues();
|
|
|
|
|
unset( $allValues['feed'] );
|
2013-01-28 18:04:20 +00:00
|
|
|
$out->setFeedAppendQuery( wfArrayToCgi( $allValues ) );
|
2008-04-13 19:57:12 +00:00
|
|
|
}
|
|
|
|
|
|
2021-09-06 18:29:43 +00:00
|
|
|
$pager = $this->getNewPagesPager();
|
2008-05-11 21:43:16 +00:00
|
|
|
$pager->mLimit = $this->opts->getValue( 'limit' );
|
|
|
|
|
$pager->mOffset = $this->opts->getValue( 'offset' );
|
2007-12-15 20:22:16 +00:00
|
|
|
|
2013-04-19 20:55:47 +00:00
|
|
|
if ( $pager->getNumRows() ) {
|
2008-05-11 21:43:16 +00:00
|
|
|
$navigation = '';
|
2011-02-19 02:07:10 +00:00
|
|
|
if ( $this->showNavigation ) {
|
|
|
|
|
$navigation = $pager->getNavigationBar();
|
|
|
|
|
}
|
2011-04-03 05:46:42 +00:00
|
|
|
$out->addHTML( $navigation . $pager->getBody() . $navigation );
|
2019-06-19 17:27:56 +00:00
|
|
|
// Add styles for change tags
|
|
|
|
|
$out->addModuleStyles( 'mediawiki.interface.helpers.styles' );
|
2008-05-11 21:43:16 +00:00
|
|
|
} else {
|
2011-04-03 05:46:42 +00:00
|
|
|
$out->addWikiMsg( 'specialpage-empty' );
|
2008-04-30 23:49:28 +00:00
|
|
|
}
|
2008-05-11 21:43:16 +00:00
|
|
|
}
|
2008-04-15 20:42:42 +00:00
|
|
|
|
2008-05-11 21:43:16 +00:00
|
|
|
protected function filterLinks() {
|
|
|
|
|
// show/hide links
|
2016-02-17 09:09:32 +00:00
|
|
|
$showhide = [ $this->msg( 'show' )->escaped(), $this->msg( 'hide' )->escaped() ];
|
2007-11-01 16:18:17 +00:00
|
|
|
|
2008-05-11 21:43:16 +00:00
|
|
|
// Option value -> message mapping
|
2016-02-17 09:09:32 +00:00
|
|
|
$filters = [
|
2022-06-24 09:44:59 +00:00
|
|
|
'hideliu' => 'newpages-showhide-registered',
|
|
|
|
|
'hidepatrolled' => 'newpages-showhide-patrolled',
|
|
|
|
|
'hidebots' => 'newpages-showhide-bots',
|
|
|
|
|
'hideredirs' => 'newpages-showhide-redirect'
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2011-05-23 04:28:58 +00:00
|
|
|
foreach ( $this->customFilters as $key => $params ) {
|
|
|
|
|
$filters[$key] = $params['msg'];
|
|
|
|
|
}
|
2008-04-15 20:42:42 +00:00
|
|
|
|
2008-05-11 21:43:16 +00:00
|
|
|
// Disable some if needed
|
2019-11-17 03:46:37 +00:00
|
|
|
if ( !$this->canAnonymousUsersCreatePages() ) {
|
2011-02-19 02:07:10 +00:00
|
|
|
unset( $filters['hideliu'] );
|
|
|
|
|
}
|
2011-04-03 05:46:42 +00:00
|
|
|
if ( !$this->getUser()->useNPPatrol() ) {
|
2011-02-19 02:07:10 +00:00
|
|
|
unset( $filters['hidepatrolled'] );
|
|
|
|
|
}
|
2008-04-13 19:57:12 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$links = [];
|
2008-05-11 21:43:16 +00:00
|
|
|
$changed = $this->opts->getChangedValues();
|
2011-02-19 02:07:10 +00:00
|
|
|
unset( $changed['offset'] ); // Reset offset if query type changes
|
2008-05-11 21:43:16 +00:00
|
|
|
|
2017-03-02 17:34:03 +00:00
|
|
|
// wfArrayToCgi(), called from LinkRenderer/Title, will not output null and false values
|
|
|
|
|
// to the URL, which would omit some options (T158504). Fix it by explicitly setting them
|
|
|
|
|
// to 0 or 1.
|
2019-02-03 12:17:04 +00:00
|
|
|
// Also do this only for boolean options, not eg. namespace or tagfilter
|
|
|
|
|
foreach ( $changed as $key => $value ) {
|
|
|
|
|
if ( array_key_exists( $key, $filters ) ) {
|
|
|
|
|
$changed[$key] = $changed[$key] ? '1' : '0';
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-03-02 17:34:03 +00:00
|
|
|
|
2013-12-24 08:07:04 +00:00
|
|
|
$self = $this->getPageTitle();
|
2016-06-01 03:46:13 +00:00
|
|
|
$linkRenderer = $this->getLinkRenderer();
|
2008-05-11 21:43:16 +00:00
|
|
|
foreach ( $filters as $key => $msg ) {
|
2011-02-19 02:07:10 +00:00
|
|
|
$onoff = 1 - $this->opts->getValue( $key );
|
2016-06-01 03:46:13 +00:00
|
|
|
$link = $linkRenderer->makeLink(
|
|
|
|
|
$self,
|
|
|
|
|
new HtmlArmor( $showhide[$onoff] ),
|
|
|
|
|
[],
|
2016-02-17 09:09:32 +00:00
|
|
|
[ $key => $onoff ] + $changed
|
2008-04-16 15:12:44 +00:00
|
|
|
);
|
2012-04-04 20:15:44 +00:00
|
|
|
$links[$key] = $this->msg( $msg )->rawParams( $link )->escaped();
|
2008-04-13 19:57:12 +00:00
|
|
|
}
|
2008-05-11 21:43:16 +00:00
|
|
|
|
2011-11-21 16:13:21 +00:00
|
|
|
return $this->getLanguage()->pipeList( $links );
|
2008-05-11 21:43:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function form() {
|
2014-10-04 14:35:54 +00:00
|
|
|
$out = $this->getOutput();
|
2014-11-24 06:22:56 +00:00
|
|
|
|
2008-05-11 21:43:16 +00:00
|
|
|
// Consume values
|
2008-05-11 21:55:43 +00:00
|
|
|
$this->opts->consumeValue( 'offset' ); // don't carry offset, DWIW
|
2008-05-11 21:43:16 +00:00
|
|
|
$namespace = $this->opts->consumeValue( 'namespace' );
|
|
|
|
|
$username = $this->opts->consumeValue( 'username' );
|
2009-07-27 10:45:18 +00:00
|
|
|
$tagFilterVal = $this->opts->consumeValue( 'tagfilter' );
|
2023-07-15 10:32:50 +00:00
|
|
|
$tagInvertVal = $this->opts->consumeValue( 'tagInvert' );
|
2013-02-16 00:43:38 +00:00
|
|
|
$nsinvert = $this->opts->consumeValue( 'invert' );
|
2019-07-16 21:57:51 +00:00
|
|
|
$nsassociated = $this->opts->consumeValue( 'associated' );
|
2008-05-11 21:43:16 +00:00
|
|
|
|
2016-10-27 01:23:18 +00:00
|
|
|
$size = $this->opts->consumeValue( 'size' );
|
|
|
|
|
$max = $this->opts->consumeValue( 'size-mode' ) === 'max';
|
|
|
|
|
|
2008-05-11 21:43:16 +00:00
|
|
|
// Check username input validity
|
|
|
|
|
$ut = Title::makeTitleSafe( NS_USER, $username );
|
|
|
|
|
$userText = $ut ? $ut->getText() : '';
|
|
|
|
|
|
2016-03-12 09:53:20 +00:00
|
|
|
$formDescriptor = [
|
2016-02-17 09:09:32 +00:00
|
|
|
'namespace' => [
|
2014-10-04 14:35:54 +00:00
|
|
|
'type' => 'namespaceselect',
|
|
|
|
|
'name' => 'namespace',
|
|
|
|
|
'label-message' => 'namespace',
|
|
|
|
|
'default' => $namespace,
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
'nsinvert' => [
|
2014-10-04 14:35:54 +00:00
|
|
|
'type' => 'check',
|
2014-12-22 18:25:58 +00:00
|
|
|
'name' => 'invert',
|
2014-10-04 14:35:54 +00:00
|
|
|
'label-message' => 'invert',
|
|
|
|
|
'default' => $nsinvert,
|
2015-06-19 15:45:23 +00:00
|
|
|
'tooltip' => 'invert',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
2019-07-16 21:57:51 +00:00
|
|
|
'nsassociated' => [
|
|
|
|
|
'type' => 'check',
|
|
|
|
|
'name' => 'associated',
|
|
|
|
|
'label-message' => 'namespace_association',
|
|
|
|
|
'default' => $nsassociated,
|
|
|
|
|
'tooltip' => 'namespace_association',
|
|
|
|
|
],
|
2016-02-17 09:09:32 +00:00
|
|
|
'tagFilter' => [
|
2014-10-04 14:35:54 +00:00
|
|
|
'type' => 'tagfilter',
|
|
|
|
|
'name' => 'tagfilter',
|
2021-05-08 00:10:46 +00:00
|
|
|
'label-message' => 'tag-filter',
|
2014-10-04 14:35:54 +00:00
|
|
|
'default' => $tagFilterVal,
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
2023-07-15 10:32:50 +00:00
|
|
|
'tagInvert' => [
|
|
|
|
|
'type' => 'check',
|
|
|
|
|
'name' => 'tagInvert',
|
|
|
|
|
'label-message' => 'invert',
|
|
|
|
|
'hide-if' => [ '===', 'tagFilter', '' ],
|
|
|
|
|
'default' => $tagInvertVal,
|
|
|
|
|
],
|
2016-02-17 09:09:32 +00:00
|
|
|
'username' => [
|
2018-04-20 23:41:54 +00:00
|
|
|
'type' => 'user',
|
2014-10-04 14:35:54 +00:00
|
|
|
'name' => 'username',
|
|
|
|
|
'label-message' => 'newpages-username',
|
|
|
|
|
'default' => $userText,
|
|
|
|
|
'id' => 'mw-np-username',
|
|
|
|
|
'size' => 30,
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
2016-10-27 01:23:18 +00:00
|
|
|
'size' => [
|
|
|
|
|
'type' => 'sizefilter',
|
|
|
|
|
'name' => 'size',
|
2022-03-07 23:00:03 +00:00
|
|
|
'default' => ( $max ? -1 : 1 ) * $size,
|
2016-10-27 01:23:18 +00:00
|
|
|
],
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2014-10-04 14:35:54 +00:00
|
|
|
|
2016-03-12 09:53:20 +00:00
|
|
|
$htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() );
|
2018-08-02 04:49:47 +00:00
|
|
|
|
|
|
|
|
// Store query values in hidden fields so that form submission doesn't lose them
|
|
|
|
|
foreach ( $this->opts->getUnconsumedValues() as $key => $value ) {
|
|
|
|
|
$htmlForm->addHiddenField( $key, $value );
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-12 09:53:20 +00:00
|
|
|
$htmlForm
|
|
|
|
|
->setMethod( 'get' )
|
|
|
|
|
->setFormIdentifier( 'newpagesform' )
|
|
|
|
|
// The form should be visible on each request (inclusive requests with submitted forms), so
|
|
|
|
|
// return always false here.
|
|
|
|
|
->setSubmitCallback(
|
2021-02-10 22:31:02 +00:00
|
|
|
static function () {
|
2016-03-12 09:53:20 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
)
|
2021-05-08 00:29:09 +00:00
|
|
|
->setSubmitTextMsg( 'newpages-submit' )
|
|
|
|
|
->setWrapperLegendMsg( 'newpages' )
|
2022-12-18 16:37:55 +00:00
|
|
|
->addFooterHtml( Html::rawElement(
|
2016-03-12 09:53:20 +00:00
|
|
|
'div',
|
2021-09-22 20:47:28 +00:00
|
|
|
[],
|
2016-03-12 09:53:20 +00:00
|
|
|
$this->filterLinks()
|
2018-08-02 04:49:47 +00:00
|
|
|
) )
|
2016-03-12 09:53:20 +00:00
|
|
|
->show();
|
|
|
|
|
$out->addModuleStyles( 'mediawiki.special' );
|
2008-05-11 21:43:16 +00:00
|
|
|
}
|
|
|
|
|
|
2021-09-06 18:29:43 +00:00
|
|
|
private function getNewPagesPager() {
|
|
|
|
|
return new NewPagesPager(
|
2023-09-11 21:45:14 +00:00
|
|
|
$this->getContext(),
|
|
|
|
|
$this->getLinkRenderer(),
|
2021-09-06 18:29:43 +00:00
|
|
|
$this->groupPermissionsLookup,
|
|
|
|
|
$this->getHookContainer(),
|
|
|
|
|
$this->linkBatchFactory,
|
|
|
|
|
$this->namespaceInfo,
|
2023-09-11 21:45:14 +00:00
|
|
|
$this->changeTagsStore,
|
2023-09-20 22:36:46 +00:00
|
|
|
$this->rowCommentFormatter,
|
2023-09-11 21:45:14 +00:00
|
|
|
$this->contentHandlerFactory,
|
2024-07-24 12:23:21 +00:00
|
|
|
$this->tempUserConfig,
|
2023-06-15 23:17:05 +00:00
|
|
|
$this->opts,
|
2021-09-06 18:29:43 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2008-04-13 19:57:12 +00:00
|
|
|
/**
|
|
|
|
|
* Output a subscription feed listing recent edits to this page.
|
2010-05-04 19:28:13 +00:00
|
|
|
*
|
2014-04-19 08:16:52 +00:00
|
|
|
* @param string $type
|
2008-04-13 19:57:12 +00:00
|
|
|
*/
|
2008-06-06 16:42:23 +00:00
|
|
|
protected function feed( $type ) {
|
2022-04-10 15:34:45 +00:00
|
|
|
if ( !$this->getConfig()->get( MainConfigNames::Feed ) ) {
|
2011-06-03 04:22:14 +00:00
|
|
|
$this->getOutput()->addWikiMsg( 'feed-unavailable' );
|
2013-05-09 14:51:30 +00:00
|
|
|
|
2008-04-13 19:57:12 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2022-04-10 15:34:45 +00:00
|
|
|
$feedClasses = $this->getConfig()->get( MainConfigNames::FeedClasses );
|
2014-08-04 00:20:30 +00:00
|
|
|
if ( !isset( $feedClasses[$type] ) ) {
|
2011-06-03 04:22:14 +00:00
|
|
|
$this->getOutput()->addWikiMsg( 'feed-invalid' );
|
2013-05-09 14:51:30 +00:00
|
|
|
|
2008-04-13 19:57:12 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2014-08-04 00:20:30 +00:00
|
|
|
$feed = new $feedClasses[$type](
|
2008-04-13 19:57:12 +00:00
|
|
|
$this->feedTitle(),
|
2012-04-04 20:15:44 +00:00
|
|
|
$this->msg( 'tagline' )->text(),
|
2013-12-24 08:07:04 +00:00
|
|
|
$this->getPageTitle()->getFullURL()
|
2011-02-19 02:07:10 +00:00
|
|
|
);
|
2008-04-13 19:57:12 +00:00
|
|
|
|
2021-09-06 18:29:43 +00:00
|
|
|
$pager = $this->getNewPagesPager();
|
2008-05-16 21:34:46 +00:00
|
|
|
$limit = $this->opts->getValue( 'limit' );
|
2022-04-10 15:34:45 +00:00
|
|
|
$pager->mLimit = min( $limit, $this->getConfig()->get( MainConfigNames::FeedLimit ) );
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-13 19:57:12 +00:00
|
|
|
$feed->outHeader();
|
2013-04-19 20:55:47 +00:00
|
|
|
if ( $pager->getNumRows() > 0 ) {
|
2011-02-17 16:29:13 +00:00
|
|
|
foreach ( $pager->mResult as $row ) {
|
2008-04-13 19:57:12 +00:00
|
|
|
$feed->outItem( $this->feedItem( $row ) );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$feed->outFooter();
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-13 19:57:12 +00:00
|
|
|
protected function feedTitle() {
|
2023-08-08 20:12:30 +00:00
|
|
|
$desc = $this->getDescription()->text();
|
2022-04-10 15:34:45 +00:00
|
|
|
$code = $this->getConfig()->get( MainConfigNames::LanguageCode );
|
|
|
|
|
$sitename = $this->getConfig()->get( MainConfigNames::Sitename );
|
2013-05-09 14:51:30 +00:00
|
|
|
|
2014-08-04 00:20:30 +00:00
|
|
|
return "$sitename - $desc [$code]";
|
2008-04-13 19:57:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function feedItem( $row ) {
|
2012-05-05 14:08:47 +00:00
|
|
|
$title = Title::makeTitle( intval( $row->rc_namespace ), $row->rc_title );
|
2013-04-19 20:55:47 +00:00
|
|
|
if ( $title ) {
|
2008-04-13 19:57:12 +00:00
|
|
|
$date = $row->rc_timestamp;
|
2008-06-05 14:20:59 +00:00
|
|
|
$comments = $title->getTalkPage()->getFullURL();
|
2008-04-13 19:57:12 +00:00
|
|
|
|
|
|
|
|
return new FeedItem(
|
|
|
|
|
$title->getPrefixedText(),
|
|
|
|
|
$this->feedItemDesc( $row ),
|
|
|
|
|
$title->getFullURL(),
|
|
|
|
|
$date,
|
|
|
|
|
$this->feedItemAuthor( $row ),
|
2011-02-19 02:07:10 +00:00
|
|
|
$comments
|
|
|
|
|
);
|
2008-04-13 19:57:12 +00:00
|
|
|
} else {
|
2009-12-11 21:07:27 +00:00
|
|
|
return null;
|
2008-04-13 19:57:12 +00:00
|
|
|
}
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-26 04:00:03 +00:00
|
|
|
protected function feedItemAuthor( $row ) {
|
2017-10-06 22:17:58 +00:00
|
|
|
return $row->rc_user_text ?? '';
|
2008-04-13 19:57:12 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-13 19:57:12 +00:00
|
|
|
protected function feedItemDesc( $row ) {
|
2020-09-18 20:59:45 +00:00
|
|
|
$revisionRecord = $this->revisionLookup->getRevisionById( $row->rev_id );
|
2020-05-04 17:42:55 +00:00
|
|
|
if ( !$revisionRecord ) {
|
2017-08-17 20:53:01 +00:00
|
|
|
return '';
|
2008-04-13 19:57:12 +00:00
|
|
|
}
|
2013-05-09 14:51:30 +00:00
|
|
|
|
2020-05-04 17:42:55 +00:00
|
|
|
$content = $revisionRecord->getContent( SlotRecord::MAIN );
|
2017-08-17 20:53:01 +00:00
|
|
|
if ( $content === null ) {
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// XXX: include content model/type in feed item?
|
2020-05-04 17:42:55 +00:00
|
|
|
$revUser = $revisionRecord->getUser();
|
|
|
|
|
$revUserText = $revUser ? $revUser->getName() : '';
|
|
|
|
|
$revComment = $revisionRecord->getComment();
|
|
|
|
|
$revCommentText = $revComment ? $revComment->text : '';
|
|
|
|
|
return '<p>' . htmlspecialchars( $revUserText ) .
|
2017-08-17 20:53:01 +00:00
|
|
|
$this->msg( 'colon-separator' )->inContentLanguage()->escaped() .
|
2020-05-04 17:42:55 +00:00
|
|
|
htmlspecialchars( FeedItem::stripComment( $revCommentText ) ) .
|
2017-08-17 20:53:01 +00:00
|
|
|
"</p>\n<hr />\n<div>" .
|
|
|
|
|
nl2br( htmlspecialchars( $content->serialize() ) ) . "</div>";
|
2008-04-13 19:57:12 +00:00
|
|
|
}
|
2013-03-07 20:15:54 +00:00
|
|
|
|
2024-07-24 12:23:21 +00:00
|
|
|
/**
|
|
|
|
|
* @return bool Whether any users classed anonymous can create pages (when temporary accounts are enabled, then
|
|
|
|
|
* this definition includes temporary accounts).
|
|
|
|
|
*/
|
|
|
|
|
private function canAnonymousUsersCreatePages(): bool {
|
|
|
|
|
// Get all the groups which anon users can be in.
|
|
|
|
|
$anonGroups = [ '*' ];
|
|
|
|
|
if ( $this->tempUserConfig->isKnown() ) {
|
|
|
|
|
$anonGroups[] = 'temp';
|
|
|
|
|
}
|
|
|
|
|
// Check if any of the groups have the createpage or createtalk right.
|
|
|
|
|
foreach ( $anonGroups as $group ) {
|
|
|
|
|
$anonUsersCanCreatePages = $this->groupPermissionsLookup->groupHasPermission( $group, 'createpage' ) ||
|
|
|
|
|
$this->groupPermissionsLookup->groupHasPermission( $group, 'createtalk' );
|
|
|
|
|
if ( $anonUsersCanCreatePages ) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
2019-11-17 03:46:37 +00:00
|
|
|
}
|
|
|
|
|
|
2013-03-07 20:15:54 +00:00
|
|
|
protected function getGroupName() {
|
|
|
|
|
return 'changes';
|
|
|
|
|
}
|
2014-06-20 16:18:29 +00:00
|
|
|
|
2016-06-15 04:19:43 +00:00
|
|
|
protected function getCacheTTL() {
|
|
|
|
|
return 60 * 5;
|
2014-06-20 16:18:29 +00:00
|
|
|
}
|
2008-04-13 19:57:12 +00:00
|
|
|
}
|
2023-09-13 10:31:13 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Retain the old class name for backwards compatibility.
|
|
|
|
|
* @deprecated since 1.41
|
|
|
|
|
*/
|
|
|
|
|
class_alias( SpecialNewPages::class, 'SpecialNewpages' );
|