LogEventsList::showLogExtract(
$out,
'block',
- MWNamespace::getCanonicalName( NS_USER ) . ':' . $block->getTarget(),
+ MediaWikiServices::getInstance()->getNamespaceInfo()->
+ getCanonicalName( NS_USER ) . ':' . $block->getTarget(),
'',
[
'lim' => 1,
protected function addPageProtectionWarningHeaders() {
$out = $this->context->getOutput();
if ( $this->mTitle->isProtected( 'edit' ) &&
- MWNamespace::getRestrictionLevels( $this->mTitle->getNamespace() ) !== [ '' ]
+ MediaWikiServices::getInstance()->getNamespaceInfo()->getRestrictionLevels(
+ $this->mTitle->getNamespace()
+ ) !== [ '' ]
) {
# Is the title semi-protected?
if ( $this->mTitle->isSemiProtected() ) {
*/
public static function getInvalidTitleDescription( IContextSource $context, $namespace, $title ) {
// First we check whether the namespace exists or not.
- if ( MWNamespace::exists( $namespace ) ) {
+ if ( MediaWikiServices::getInstance()->getNamespaceInfo()->exists( $namespace ) ) {
if ( $namespace == NS_MAIN ) {
$name = $context->msg( 'blanknamespace' )->text();
} else {
([^[]*) # 3. link trail (the text up until the next link)
/x',
function ( $match ) use ( $title, $local, $wikiId ) {
- $medians = '(?:' . preg_quote( MWNamespace::getCanonicalName( NS_MEDIA ), '/' ) . '|';
+ $services = MediaWikiServices::getInstance();
+
+ $medians = '(?:';
+ $medians .= preg_quote(
+ $services->getNamespaceInfo()->getCanonicalName( NS_MEDIA ), '/' );
+ $medians .= '|';
$medians .= preg_quote(
MediaWikiServices::getInstance()->getContentLanguage()->getNsText( NS_MEDIA ),
'/'
$wikiId,
$linkTarget->getNamespace() === 0
? $linkTarget->getDBkey()
- : MWNamespace::getCanonicalName( $linkTarget->getNamespace() ) . ':'
- . $linkTarget->getDBkey(),
+ : MediaWikiServices::getInstance()->getNamespaceInfo()->
+ getCanonicalName( $linkTarget->getNamespace() ) .
+ ':' . $linkTarget->getDBkey(),
$linkTarget->getFragment()
),
$text,
# Some namespaces don't allow subpages,
# so only perform processing if subpages are allowed
- if ( $contextTitle && MWNamespace::hasSubpages( $contextTitle->getNamespace() ) ) {
+ if (
+ $contextTitle && MediaWikiServices::getInstance()->getNamespaceInfo()->
+ hasSubpages( $contextTitle->getNamespace() )
+ ) {
$hash = strpos( $target, '#' );
if ( $hash !== false ) {
$suffix = substr( $target, $hash );
[ 'cl_from' => $pageid ],
__METHOD__
);
- $type = MediaWikiServices::getInstance()->getNamespaceInfo()->
+ $services = MediaWikiServices::getInstance();
+ $type = $services->getNamespaceInfo()->
getCategoryLinkType( $this->newTitle->getNamespace() );
foreach ( $prefixes as $prefixRow ) {
$prefix = $prefixRow->cl_sortkey_prefix;
# Update watchlists
$oldtitle = $this->oldTitle->getDBkey();
$newtitle = $this->newTitle->getDBkey();
- $oldsnamespace = MWNamespace::getSubject( $this->oldTitle->getNamespace() );
- $newsnamespace = MWNamespace::getSubject( $this->newTitle->getNamespace() );
+ $oldsnamespace = $services->getNamespaceInfo()->
+ getSubject( $this->oldTitle->getNamespace() );
+ $newsnamespace = $services->getNamespaceInfo()->
+ getSubject( $this->newTitle->getNamespace() );
if ( $oldsnamespace != $newsnamespace || $oldtitle != $newtitle ) {
- $store = MediaWikiServices::getInstance()->getWatchedItemStore();
- $store->duplicateAllAssociatedEntries( $this->oldTitle, $this->newTitle );
+ $services->getWatchedItemStore()->duplicateAllAssociatedEntries(
+ $this->oldTitle, $this->newTitle );
}
// If it is a file then move it last.
$title = $this->getTitle();
$ns = $title->getNamespace();
- $canonicalNamespace = MWNamespace::exists( $ns )
- ? MWNamespace::getCanonicalName( $ns )
+ $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
+ $canonicalNamespace = $nsInfo->exists( $ns )
+ ? $nsInfo->getCanonicalName( $ns )
: $title->getNsText();
$sk = $this->getSkin();
* Loads the current state of protection into the object.
*/
function loadData() {
- $levels = MWNamespace::getRestrictionLevels(
+ $levels = MediaWikiServices::getInstance()->getNamespaceInfo()->getRestrictionLevels(
$this->mTitle->getNamespace(), $this->mContext->getUser()
);
$this->mCascade = $this->mTitle->areRestrictionsCascading();
* Main entry point for action=protect and action=unprotect
*/
function execute() {
- if ( MWNamespace::getRestrictionLevels( $this->mTitle->getNamespace() ) === [ '' ] ) {
+ if (
+ MediaWikiServices::getInstance()->getNamespaceInfo()->getRestrictionLevels(
+ $this->mTitle->getNamespace()
+ ) === [ '' ]
+ ) {
throw new ErrorPageError( 'protect-badnamespace-title', 'protect-badnamespace-text' );
}
function buildSelector( $action, $selected ) {
// If the form is disabled, display all relevant levels. Otherwise,
// just show the ones this user can use.
- $levels = MWNamespace::getRestrictionLevels( $this->mTitle->getNamespace(),
+ $levels = MediaWikiServices::getInstance()->getNamespaceInfo()->getRestrictionLevels(
+ $this->mTitle->getNamespace(),
$this->disabled ? null : $this->mContext->getUser()
);
* @return int
*/
public function articles() {
- $config = MediaWikiServices::getInstance()->getMainConfig();
+ $services = MediaWikiServices::getInstance();
$tables = [ 'page' ];
$conds = [
- 'page_namespace' => MWNamespace::getContentNamespaces(),
+ 'page_namespace' => $services->getNamespaceInfo()->getContentNamespaces(),
'page_is_redirect' => 0,
];
- if ( $config->get( 'ArticleCountMethod' ) == 'link' ) {
+ if ( $services->getMainConfig()->get( 'ArticleCountMethod' ) == 'link' ) {
$tables[] = 'pagelinks';
$conds[] = 'pl_from=page_id';
}
// NOTE: ideally, this would just call makeTitle() and then isValid(),
// but presently, that means more overhead on a potential performance hotspot.
- if ( !MWNamespace::exists( $ns ) ) {
+ if ( !MediaWikiServices::getInstance()->getNamespaceInfo()->exists( $ns ) ) {
return null;
}
$canonicalNamespace = false
) {
if ( $canonicalNamespace ) {
- $namespace = MWNamespace::getCanonicalName( $ns );
+ $namespace = MediaWikiServices::getInstance()->getNamespaceInfo()->
+ getCanonicalName( $ns );
} else {
$namespace = MediaWikiServices::getInstance()->getContentLanguage()->getNsText( $ns );
}
* @return bool
*/
public function isValid() {
- if ( !MWNamespace::exists( $this->mNamespace ) ) {
+ $services = MediaWikiServices::getInstance();
+ if ( !$services->getNamespaceInfo()->exists( $this->mNamespace ) ) {
return false;
}
try {
- $parser = MediaWikiServices::getInstance()->getTitleParser();
- $parser->parseTitle( $this->mDbkeyform, $this->mNamespace );
+ $services->getTitleParser()->parseTitle( $this->mDbkeyform, $this->mNamespace );
return true;
} catch ( MalformedTitleException $ex ) {
return false;
if ( $this->isExternal() ) {
// This probably shouldn't even happen, except for interwiki transclusion.
// If possible, use the canonical name for the foreign namespace.
- $nsText = MWNamespace::getCanonicalName( $this->mNamespace );
+ $nsText = MediaWikiServices::getInstance()->getNamespaceInfo()->
+ getCanonicalName( $this->mNamespace );
if ( $nsText !== false ) {
return $nsText;
}
* @return string Namespace text
*/
public function getSubjectNsText() {
- return MediaWikiServices::getInstance()->getContentLanguage()->
- getNsText( MWNamespace::getSubject( $this->mNamespace ) );
+ $services = MediaWikiServices::getInstance();
+ return $services->getContentLanguage()->
+ getNsText( $services->getNamespaceInfo()->getSubject( $this->mNamespace ) );
}
/**
* @return string Namespace text
*/
public function getTalkNsText() {
- return MediaWikiServices::getInstance()->getContentLanguage()->
- getNsText( MWNamespace::getTalk( $this->mNamespace ) );
+ $services = MediaWikiServices::getInstance();
+ return $services->getContentLanguage()->
+ getNsText( $services->getNamespaceInfo()->getTalk( $this->mNamespace ) );
}
/**
* Can this title have a corresponding talk page?
*
- * @see MWNamespace::hasTalkNamespace
+ * @see NamespaceInfo::hasTalkNamespace
* @since 1.30
*
* @return bool True if this title either is a talk page or can have a talk page associated.
*/
public function canHaveTalkPage() {
- return MWNamespace::hasTalkNamespace( $this->mNamespace );
+ return MediaWikiServices::getInstance()->getNamespaceInfo()->
+ hasTalkNamespace( $this->mNamespace );
}
/**
* @return bool
*/
public function isWatchable() {
- return !$this->isExternal() && MWNamespace::isWatchable( $this->mNamespace );
+ return !$this->isExternal() && MediaWikiServices::getInstance()->getNamespaceInfo()->
+ isWatchable( $this->mNamespace );
}
/**
* @since 1.19
*/
public function inNamespace( $ns ) {
- return MWNamespace::equals( $this->mNamespace, $ns );
+ return MediaWikiServices::getInstance()->getNamespaceInfo()->
+ equals( $this->mNamespace, $ns );
}
/**
* @return bool
*/
public function hasSubjectNamespace( $ns ) {
- return MWNamespace::subjectEquals( $this->mNamespace, $ns );
+ return MediaWikiServices::getInstance()->getNamespaceInfo()->
+ subjectEquals( $this->mNamespace, $ns );
}
/**
* @return bool
*/
public function isContentPage() {
- return MWNamespace::isContent( $this->mNamespace );
+ return MediaWikiServices::getInstance()->getNamespaceInfo()->
+ isContent( $this->mNamespace );
}
/**
* @return bool
*/
public function isMovable() {
- if ( !MWNamespace::isMovable( $this->mNamespace ) || $this->isExternal() ) {
+ if (
+ !MediaWikiServices::getInstance()->getNamespaceInfo()->
+ isMovable( $this->mNamespace ) || $this->isExternal()
+ ) {
// Interwiki title or immovable namespace. Hooks don't get to override here
return false;
}
* @return bool
*/
public function isSubpage() {
- return MWNamespace::hasSubpages( $this->mNamespace )
+ return MediaWikiServices::getInstance()->getNamespaceInfo()->
+ hasSubpages( $this->mNamespace )
? strpos( $this->getText(), '/' ) !== false
: false;
}
* @return bool
*/
public function isTalkPage() {
- return MWNamespace::isTalk( $this->mNamespace );
+ return MediaWikiServices::getInstance()->getNamespaceInfo()->
+ isTalk( $this->mNamespace );
}
/**
* @since 1.20
*/
public function getRootText() {
- if ( !MWNamespace::hasSubpages( $this->mNamespace ) ) {
+ if (
+ !MediaWikiServices::getInstance()->getNamespaceInfo()->
+ hasSubpages( $this->mNamespace )
+ ) {
return $this->getText();
}
*/
public function getBaseText() {
$text = $this->getText();
- if ( !MWNamespace::hasSubpages( $this->mNamespace ) ) {
+ if (
+ !MediaWikiServices::getInstance()->getNamespaceInfo()->
+ hasSubpages( $this->mNamespace )
+ ) {
return $text;
}
* @return string Subpage name
*/
public function getSubpageText() {
- if ( !MWNamespace::hasSubpages( $this->mNamespace ) ) {
+ if (
+ !MediaWikiServices::getInstance()->getNamespaceInfo()->
+ hasSubpages( $this->mNamespace )
+ ) {
return $this->mTextform;
}
$parts = explode( '/', $this->mTextform );
* @return bool
*/
public function hasSubpages() {
- if ( !MWNamespace::hasSubpages( $this->mNamespace ) ) {
+ if (
+ !MediaWikiServices::getInstance()->getNamespaceInfo()->
+ hasSubpages( $this->mNamespace )
+ ) {
# Duh
return false;
}
* doesn't allow subpages
*/
public function getSubpages( $limit = -1 ) {
- if ( !MWNamespace::hasSubpages( $this->mNamespace ) ) {
+ if (
+ !MediaWikiServices::getInstance()->getNamespaceInfo()->
+ hasSubpages( $this->mNamespace )
+ ) {
return [];
}
* @return string Containing capitalized title
*/
public static function capitalize( $text, $ns = NS_MAIN ) {
- if ( MWNamespace::isCapitalized( $ns ) ) {
+ $services = MediaWikiServices::getInstance();
+ if ( $services->getNamespaceInfo()->isCapitalized( $ns ) ) {
return MediaWikiServices::getInstance()->getContentLanguage()->ucfirst( $text );
} else {
return $text;
];
}
// Do the source and target namespaces support subpages?
- if ( !MWNamespace::hasSubpages( $this->mNamespace ) ) {
+ $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
+ if ( !$nsInfo->hasSubpages( $this->mNamespace ) ) {
return [
- [ 'namespace-nosubpages', MWNamespace::getCanonicalName( $this->mNamespace ) ],
+ [ 'namespace-nosubpages', $nsInfo->getCanonicalName( $this->mNamespace ) ],
];
}
- if ( !MWNamespace::hasSubpages( $nt->getNamespace() ) ) {
+ if ( !$nsInfo->hasSubpages( $nt->getNamespace() ) ) {
return [
- [ 'namespace-nosubpages', MWNamespace::getCanonicalName( $nt->getNamespace() ) ],
+ [ 'namespace-nosubpages', $nsInfo->getCanonicalName( $nt->getNamespace() ) ],
];
}
*/
public function getNamespaceKey( $prepend = 'nstab-' ) {
// Gets the subject namespace of this title
- $subjectNS = MWNamespace::getSubject( $this->mNamespace );
+ $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
+ $subjectNS = $nsInfo->getSubject( $this->mNamespace );
// Prefer canonical namespace name for HTML IDs
- $namespaceKey = MWNamespace::getCanonicalName( $subjectNS );
+ $namespaceKey = $nsInfo->getCanonicalName( $subjectNS );
if ( $namespaceKey === false ) {
// Fallback to localised text
$namespaceKey = $this->getSubjectNsText();
public function canUseNoindex() {
global $wgExemptFromUserRobotsControl;
- $bannedNamespaces = $wgExemptFromUserRobotsControl ?? MWNamespace::getContentNamespaces();
+ $bannedNamespaces = $wgExemptFromUserRobotsControl ??
+ MediaWikiServices::getInstance()->getNamespaceInfo()->getContentNamespaces();
return !in_array( $this->mNamespace, $bannedNamespaces );
}
}
}
- if ( MWNamespace::hasSubpages( $this->mNamespace ) ) {
+ if (
+ MediaWikiServices::getInstance()->getNamespaceInfo()->
+ hasSubpages( $this->mNamespace )
+ ) {
// Optional notice for page itself and any parent page
$editnotice_base = $editnotice_ns;
foreach ( explode( '/', $this->mDbkeyform ) as $part ) {
* @ingroup Categories
*/
+use MediaWiki\MediaWikiServices;
+
/**
* This class performs some operations related to tracking categories, such as creating
* a list of all such categories.
}
$trackingCategories = [];
+ $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
foreach ( $categories as $catMsg ) {
/*
* Check if the tracking category varies by namespace
// Match things like {{NAMESPACE}} and {{NAMESPACENUMBER}}.
// False positives are ok, this is just an efficiency shortcut
if ( strpos( $msgObj->plain(), '{{' ) !== false ) {
- $ns = MWNamespace::getValidNamespaces();
+ $ns = $nsInfo->getValidNamespaces();
foreach ( $ns as $namesp ) {
$tempTitle = Title::makeTitleSafe( $namesp, $catMsg );
if ( !$tempTitle ) {
}
// Subpages of this page, if subpages are enabled for the current NS
- if ( MWNamespace::hasSubpages( $title->getNamespace() ) ) {
+ if ( $services->getNamespaceInfo()->hasSubpages( $title->getNamespace() ) ) {
$prefixIndex = SpecialPage::getTitleFor(
'Prefixindex', $title->getPrefixedText() . '/' );
$pageInfo['header-basic'][] = [
protected function pageCounts( Page $page ) {
$fname = __METHOD__;
$config = $this->context->getConfig();
- $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
+ $services = MediaWikiServices::getInstance();
+ $cache = $services->getMainWANObjectCache();
return $cache->getWithSetCallback(
self::getCacheKey( $cache, $page->getTitle(), $page->getLatest() ),
WANObjectCache::TTL_WEEK,
- function ( $oldValue, &$ttl, &$setOpts ) use ( $page, $config, $fname ) {
+ function ( $oldValue, &$ttl, &$setOpts ) use ( $page, $config, $fname, $services ) {
global $wgActorTableSchemaMigrationStage;
$title = $page->getTitle();
$joins = [];
}
- $watchedItemStore = MediaWikiServices::getInstance()->getWatchedItemStore();
+ $watchedItemStore = $services->getWatchedItemStore();
$result = [];
$result['watchers'] = $watchedItemStore->countWatchers( $title );
);
// Subpages (if enabled)
- if ( MWNamespace::hasSubpages( $title->getNamespace() ) ) {
+ if ( $services->getNamespaceInfo()->hasSubpages( $title->getNamespace() ) ) {
$conds = [ 'page_namespace' => $title->getNamespace() ];
$conds[] = 'page_title ' .
$dbr->buildLike( $title->getDBkey() . '/', $dbr->anyString() );
* @file
*/
+use MediaWiki\MediaWikiServices;
use Wikimedia\Rdbms\IDatabase;
/**
$provided = $this->getMain()->getCheck( $encParamName );
if ( isset( $value ) && $type == 'namespace' ) {
- $type = MWNamespace::getValidNamespaces();
+ $type = MediaWikiServices::getInstance()->getNamespaceInfo()->
+ getValidNamespaces();
if ( isset( $paramSettings[self::PARAM_EXTRA_NAMESPACES] ) &&
is_array( $paramSettings[self::PARAM_EXTRA_NAMESPACES] )
) {
break;
case 'namespace':
- $namespaces = MWNamespace::getValidNamespaces();
+ $namespaces = MediaWikiServices::getInstance()->
+ getNamespaceInfo()->getValidNamespaces();
if ( isset( $settings[ApiBase::PARAM_EXTRA_NAMESPACES] ) &&
is_array( $settings[ApiBase::PARAM_EXTRA_NAMESPACES] )
) {
ApiBase::dieDebug( __METHOD__, 'Missing $processTitles parameter when $remaining is provided' );
}
+ $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
+
$usernames = [];
if ( $res ) {
foreach ( $res as $row ) {
$this->processDbRow( $row );
// Need gender information
- if ( MWNamespace::hasGenderDistinction( $row->page_namespace ) ) {
+ if ( $nsInfo->hasGenderDistinction( $row->page_namespace ) ) {
$usernames[] = $row->page_title;
}
}
$this->mTitles[] = $title;
// need gender information
- if ( MWNamespace::hasGenderDistinction( $ns ) ) {
+ if ( $nsInfo->hasGenderDistinction( $ns ) ) {
$usernames[] = $dbkey;
}
}
}
// Need gender information
- if ( MWNamespace::hasGenderDistinction( $titleObj->getNamespace() ) ) {
+ if (
+ MediaWikiServices::getInstance()->getNamespaceInfo()->
+ hasGenderDistinction( $titleObj->getNamespace() )
+ ) {
$usernames[] = $titleObj->getText();
}
}
$user = $this->getUser();
$db = $this->getDB();
$params = $this->extractRequestParams( false );
- $revisionStore = MediaWikiServices::getInstance()->getRevisionStore();
+ $services = MediaWikiServices::getInstance();
+ $revisionStore = $services->getRevisionStore();
$result = $this->getResult();
$miser_ns = null;
if ( $mode == 'all' ) {
- $namespaces = $params['namespace'] ?? MWNamespace::getValidNamespaces();
+ $namespaces = $params['namespace'] ??
+ $services->getNamespaceInfo()->getValidNamespaces();
$this->addWhereFld( 'ar_namespace', $namespaces );
// For from/to/prefix, we have to consider the potential
$res = $this->select( __METHOD__ );
// Get gender information
- if ( MWNamespace::hasGenderDistinction( $params['namespace'] ) ) {
+ $services = MediaWikiServices::getInstance();
+ if ( $services->getNamespaceInfo()->hasGenderDistinction( $params['namespace'] ) ) {
$users = [];
foreach ( $res as $row ) {
$users[] = $row->page_title;
}
- MediaWikiServices::getInstance()->getGenderCache()->doQuery( $users, __METHOD__ );
+ $services->getGenderCache()->doQuery( $users, __METHOD__ );
$res->rewind(); // reset
}
$db = $this->getDB();
$params = $this->extractRequestParams( false );
- $revisionStore = MediaWikiServices::getInstance()->getRevisionStore();
+ $services = MediaWikiServices::getInstance();
+ $revisionStore = $services->getRevisionStore();
$result = $this->getResult();
if ( $params['namespace'] !== null ) {
$params['namespace'] = array_unique( $params['namespace'] );
sort( $params['namespace'] );
- if ( $params['namespace'] != MWNamespace::getValidNamespaces() ) {
+ if ( $params['namespace'] != $services->getNamespaceInfo()->getValidNamespaces() ) {
$needPageTable = true;
if ( $this->getConfig()->get( 'MiserMode' ) ) {
$miser_ns = $params['namespace'];
*/
private function getTSIDs() {
$getTitles = $this->talkids = $this->subjectids = [];
+ $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
/** @var Title $t */
foreach ( $this->everything as $t ) {
- if ( MWNamespace::isTalk( $t->getNamespace() ) ) {
+ if ( $nsInfo->isTalk( $t->getNamespace() ) ) {
if ( $this->fld_subjectid ) {
$getTitles[] = $t->getSubjectPage();
}
$this->addWhere( $lb->constructSet( 'page', $db ) );
$res = $this->select( __METHOD__ );
foreach ( $res as $row ) {
- if ( MWNamespace::isTalk( $row->page_namespace ) ) {
- $this->talkids[MWNamespace::getSubject( $row->page_namespace )][$row->page_title] =
- (int)$row->page_id;
+ if ( $nsInfo->isTalk( $row->page_namespace ) ) {
+ $this->talkids[$nsInfo->getSubject( $row->page_namespace )][$row->page_title] =
+ (int)( $row->page_id );
} else {
- $this->subjectids[MWNamespace::getTalk( $row->page_namespace )][$row->page_title] =
- (int)$row->page_id;
+ $this->subjectids[$nsInfo->getTalk( $row->page_namespace )][$row->page_title] =
+ (int)( $row->page_id );
}
}
}
$data = [
ApiResult::META_TYPE => 'assoc',
];
+ $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
foreach (
MediaWikiServices::getInstance()->getContentLanguage()->getFormattedNamespaces()
as $ns => $title
) {
$data[$ns] = [
'id' => (int)$ns,
- 'case' => MWNamespace::isCapitalized( $ns ) ? 'first-letter' : 'case-sensitive',
+ 'case' => $nsInfo->isCapitalized( $ns ) ? 'first-letter' : 'case-sensitive',
];
ApiResult::setContentValue( $data[$ns], 'name', $title );
- $canonical = MWNamespace::getCanonicalName( $ns );
+ $canonical = $nsInfo->getCanonicalName( $ns );
- $data[$ns]['subpages'] = MWNamespace::hasSubpages( $ns );
+ $data[$ns]['subpages'] = $nsInfo->hasSubpages( $ns );
if ( $canonical ) {
$data[$ns]['canonical'] = strtr( $canonical, '_', ' ' );
}
- $data[$ns]['content'] = MWNamespace::isContent( $ns );
- $data[$ns]['nonincludable'] = MWNamespace::isNonincludable( $ns );
+ $data[$ns]['content'] = $nsInfo->isContent( $ns );
+ $data[$ns]['nonincludable'] = $nsInfo->isNonincludable( $ns );
- $contentmodel = MWNamespace::getNamespaceContentModel( $ns );
+ $contentmodel = $nsInfo->getNamespaceContentModel( $ns );
if ( $contentmodel ) {
$data[$ns]['defaultcontentmodel'] = $contentmodel;
}
* @file
*/
+use MediaWiki\MediaWikiServices;
+
/**
* Feed to Special:RecentChanges and Special:RecentChangesLinked.
*
}
}
+ $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
foreach ( $sorted as $obj ) {
$title = Title::makeTitle( $obj->rc_namespace, $obj->rc_title );
- $talkpage = MWNamespace::hasTalkNamespace( $obj->rc_namespace )
+ $talkpage = $nsInfo->hasTalkNamespace( $obj->rc_namespace )
? $title->getTalkPage()->getFullURL()
: '';
<?php
+
/**
* Base class for content handling.
*
namespace MediaWiki\EditPage;
-use MWNamespace;
+use MediaWiki\MediaWikiServices;
use Sanitizer;
use Title;
use User;
public function getTextboxProtectionCSSClasses( Title $title ) {
$classes = []; // Textarea CSS
if ( $title->isProtected( 'edit' ) &&
- MWNamespace::getRestrictionLevels( $title->getNamespace() ) !== [ '' ]
+ MediaWikiServices::getInstance()->getNamespaceInfo()->
+ getRestrictionLevels( $title->getNamespace() ) !== [ '' ]
) {
# Is the title semi-protected?
if ( $title->isSemiProtected() ) {
* @file
*/
+use MediaWiki\MediaWikiServices;
+
/**
* @ingroup Dump
*/
* @return bool
*/
protected function pass( $page ) {
- return !MWNamespace::isTalk( $page->page_namespace );
+ return !MediaWikiServices::getInstance()->getNamespaceInfo()->
+ isTalk( $page->page_namespace );
}
}
*/
function namespaces() {
$spaces = "<namespaces>\n";
+ $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
foreach (
MediaWikiServices::getInstance()->getContentLanguage()->getFormattedNamespaces()
as $ns => $title
Xml::element( 'namespace',
[
'key' => $ns,
- 'case' => MWNamespace::isCapitalized( $ns ) ? 'first-letter' : 'case-sensitive',
+ 'case' => $nsInfo->isCapitalized( $ns )
+ ? 'first-letter' : 'case-sensitive',
], $title ) . "\n";
}
$spaces .= " </namespaces>";
}
// Optional settings that have a default
- $this->initialCapital = $info['initialCapital'] ?? MWNamespace::isCapitalized( NS_FILE );
+ $this->initialCapital = $info['initialCapital'] ??
+ MediaWikiServices::getInstance()->getNamespaceInfo()->isCapitalized( NS_FILE );
$this->url = $info['url'] ?? false; // a subclass may set the URL (e.g. ForeignAPIRepo)
if ( isset( $info['thumbUrl'] ) ) {
$this->thumbUrl = $info['thumbUrl'];
* @return string
*/
public function getNameFromTitle( Title $title ) {
- if ( $this->initialCapital != MWNamespace::isCapitalized( NS_FILE ) ) {
+ if (
+ $this->initialCapital !=
+ MediaWikiServices::getInstance()->getNamespaceInfo()->isCapitalized( NS_FILE )
+ ) {
$name = $title->getUserCaseDBKey();
if ( $this->initialCapital ) {
$name = MediaWikiServices::getInstance()->getContentLanguage()->ucfirst( $name );
// @todo Code is incomplete.
// $linkTarget = Title::newFromText( MediaWikiServices::getInstance()->
- // getContentLanguage()->getNsText( MWNamespace::getUser() ) . ":{$ut}" );
+ // getContentLanguage()->getNsText( MediaWikiServices::getInstance()->
+ // getNamespaceInfo()->getUser() ) . ":{$ut}" );
// $ul = Linker::link( $linkTarget, $ut );
$meta = [];
return true;
} elseif (
$namespace >= 0 &&
- MWNamespace::exists( intval( $namespace ) )
+ MediaWikiServices::getInstance()->getNamespaceInfo()->exists( intval( $namespace ) )
) {
$namespace = intval( $namespace );
$this->setImportTitleFactory( new NamespaceImportTitleFactory( $namespace ) );
if ( !$title || $title->isExternal() ) {
$status->fatal( 'import-rootpage-invalid' );
- } elseif ( !MWNamespace::hasSubpages( $title->getNamespace() ) ) {
+ } elseif (
+ !MediaWikiServices::getInstance()->getNamespaceInfo()->
+ hasSubpages( $title->getNamespace() )
+ ) {
$displayNSText = $title->getNamespace() == NS_MAIN
? wfMessage( 'blanknamespace' )->text()
: MediaWikiServices::getInstance()->getContentLanguage()->
$title = $this->getTitle();
+ $services = MediaWikiServices::getInstance();
+
# Show info in user (talk) namespace. Does the user exist? Is he blocked?
if ( $title->getNamespace() == NS_USER
|| $title->getNamespace() == NS_USER_TALK
LogEventsList::showLogExtract(
$outputPage,
'block',
- MWNamespace::getCanonicalName( NS_USER ) . ':' . $block->getTarget(),
+ $services->getNamespaceInfo()->getCanonicalName( NS_USER ) . ':' .
+ $block->getTarget(),
'',
[
'lim' => 1,
# Show delete and move logs if there were any such events.
# The logging query can DOS the site when bots/crawlers cause 404 floods,
# so be careful showing this. 404 pages must be cheap as they are hard to cache.
- $cache = MediaWikiServices::getInstance()->getMainObjectStash();
+ $cache = $services->getMainObjectStash();
$key = $cache->makeKey( 'page-recent-delete', md5( $title->getPrefixedText() ) );
$loggedIn = $this->getContext()->getUser()->isLoggedIn();
$sessionExists = $this->getContext()->getRequest()->getSession()->isPersistent();
$contLang = MediaWikiServices::getInstance()->getContentLanguage();
$namespaceIds = $contLang->getNamespaceIds();
$caseSensitiveNamespaces = [];
- foreach ( MWNamespace::getCanonicalNamespaces() as $index => $name ) {
+ $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
+ foreach ( $nsInfo->getCanonicalNamespaces() as $index => $name ) {
$namespaceIds[$contLang->lc( $name )] = $index;
- if ( !MWNamespace::isCapitalized( $index ) ) {
+ if ( !$nsInfo->isCapitalized( $index ) ) {
$caseSensitiveNamespaces[] = $index;
}
}
'wgEnableWriteAPI' => true, // Deprecated since MW 1.32
'wgFormattedNamespaces' => $contLang->getFormattedNamespaces(),
'wgNamespaceIds' => $namespaceIds,
- 'wgContentNamespaces' => MWNamespace::getContentNamespaces(),
+ 'wgContentNamespaces' => $nsInfo->getContentNamespaces(),
'wgSiteName' => $conf->get( 'Sitename' ),
'wgDBname' => $conf->get( 'DBname' ),
'wgExtraSignatureNamespaces' => $conf->get( 'ExtraSignatureNamespaces' ),
return $subpages;
}
- if ( $out->isArticle() && MWNamespace::hasSubpages( $title->getNamespace() ) ) {
+ if (
+ $out->isArticle() && MediaWikiServices::getInstance()->getNamespaceInfo()->
+ hasSubpages( $title->getNamespace() )
+ ) {
$ptext = $title->getPrefixedText();
if ( strpos( $ptext, '/' ) !== false ) {
$links = explode( '/', $ptext );
}
}
- $linkClass = MediaWikiServices::getInstance()->getLinkRenderer()->getLinkClasses( $title );
+ $services = MediaWikiServices::getInstance();
+ $linkClass = $services->getLinkRenderer()->getLinkClasses( $title );
// wfMessageFallback will nicely accept $message as an array of fallbacks
// or just a single key
if ( $msg->exists() ) {
$text = $msg->text();
} else {
- $text = MediaWikiServices::getInstance()->getContentLanguage()->getConverter()->
- convertNamespace( MWNamespace::getSubject( $title->getNamespace() ) );
+ $text = $services->getContentLanguage()->getConverter()->
+ convertNamespace( $services->getNamespaceInfo()->
+ getSubject( $title->getNamespace() ) );
}
// Avoid PHP 7.1 warning of passing $this by reference
}
if ( $title->quickUserCan( 'protect', $user ) && $title->getRestrictionTypes() &&
- MWNamespace::getRestrictionLevels( $title->getNamespace(), $user ) !== [ '' ]
+ MediaWikiServices::getInstance()->getNamespaceInfo()->
+ getRestrictionLevels( $title->getNamespace(), $user ) !== [ '' ]
) {
$mode = $title->isProtected() ? 'unprotect' : 'protect';
$content_navigation['actions'][$mode] = [
* @file
* @ingroup SpecialPage
*/
+
use MediaWiki\Logger\LoggerFactory;
+use MediaWiki\MediaWikiServices;
use Wikimedia\Rdbms\DBQueryTimeoutError;
use Wikimedia\Rdbms\IResultWrapper;
use Wikimedia\Rdbms\FakeResultWrapper;
use Wikimedia\Rdbms\IDatabase;
-use MediaWiki\MediaWikiServices;
/**
* Special page which uses a ChangesList to show query results.
if ( $opts[ 'associated' ] ) {
$associatedNamespaces = array_map(
function ( $ns ) {
- return MWNamespace::getAssociated( $ns );
+ return MediaWikiServices::getInstance()->getNamespaceInfo()->
+ getAssociated( $ns );
},
$namespaces
);
public function getQueryInfo() {
$tables = [ 'page', 'revision' ];
$conds = [
- 'page_namespace' => MWNamespace::getContentNamespaces(),
+ 'page_namespace' =>
+ MediaWikiServices::getInstance()->getNamespaceInfo()->getContentNamespaces(),
'page_is_redirect' => 0
];
$joinConds = [
* @ingroup SpecialPage
*/
+use MediaWiki\MediaWikiServices;
use MediaWiki\Widget\DateInputWidget;
/**
if ( !is_null( $block ) && $block->getType() != Block::TYPE_AUTO ) {
if ( $block->getType() == Block::TYPE_RANGE ) {
- $nt = MWNamespace::getCanonicalName( NS_USER ) . ':' . $block->getTarget();
+ $nt = MediaWikiServices::getInstance()->getNamespaceInfo()->
+ getCanonicalName( NS_USER ) . ':' . $block->getTarget();
}
$out = $this->getOutput(); // showLogExtract() wants first parameter by reference
* @ingroup SpecialPage
*/
+use MediaWiki\MediaWikiServices;
+
/**
* A special page that list pages that contain no link to other pages
*
],
'conds' => [
'pl_from IS NULL',
- 'page_namespace' => MWNamespace::getContentNamespaces(),
+ 'page_namespace' => MediaWikiServices::getInstance()->getNamespaceInfo()->
+ getContentNamespaces(),
'page_is_redirect' => 0
],
'join_conds' => [
function getOrderFields() {
// For some crazy reason ordering by a constant
// causes a filesort
- if ( count( MWNamespace::getContentNamespaces() ) > 1 ) {
+ if ( count( MediaWikiServices::getInstance()->getNamespaceInfo()->
+ getContentNamespaces() ) > 1
+ ) {
return [ 'page_namespace', 'page_title' ];
} else {
return [ 'page_title' ];
* @ingroup SpecialPage
*/
+use MediaWiki\MediaWikiServices;
+
/**
* Implements Special:DeletedContributions to display archived revisions
* @ingroup SpecialPage
$block = Block::newFromTarget( $userObj, $userObj );
if ( !is_null( $block ) && $block->getType() != Block::TYPE_AUTO ) {
if ( $block->getType() == Block::TYPE_RANGE ) {
- $nt = MWNamespace::getCanonicalName( NS_USER ) . ':' . $block->getTarget();
+ $nt = MediaWikiServices::getInstance()->getNamespaceInfo()->
+ getCanonicalName( NS_USER ) . ':' . $block->getTarget();
}
// LogEventsList::showLogExtract() wants the first parameter by ref
*/
protected function getWatchlistInfo() {
$titles = [];
+ $services = MediaWikiServices::getInstance();
- $watchedItems = MediaWikiServices::getInstance()->getWatchedItemStore()
+ $watchedItems = $services->getWatchedItemStore()
->getWatchedItemsForUser( $this->getUser(), [ 'sort' => WatchedItemStore::SORT_ASC ] );
$lb = new LinkBatch();
$namespace = $watchedItem->getLinkTarget()->getNamespace();
$dbKey = $watchedItem->getLinkTarget()->getDBkey();
$lb->add( $namespace, $dbKey );
- if ( !MWNamespace::isTalk( $namespace ) ) {
+ if ( !$services->getNamespaceInfo()->isTalk( $namespace ) ) {
$titles[$namespace][$dbKey] = 1;
}
}
*/
private function getExpandedTargets( array $targets ) {
$expandedTargets = [];
+ $services = MediaWikiServices::getInstance();
foreach ( $targets as $target ) {
if ( !$target instanceof LinkTarget ) {
try {
$ns = $target->getNamespace();
$dbKey = $target->getDBkey();
- $expandedTargets[] = new TitleValue( MWNamespace::getSubject( $ns ), $dbKey );
- $expandedTargets[] = new TitleValue( MWNamespace::getTalk( $ns ), $dbKey );
+ $expandedTargets[] =
+ new TitleValue( $services->getNamespaceInfo()->getSubject( $ns ), $dbKey );
+ $expandedTargets[] =
+ new TitleValue( $services->getNamespaceInfo()->getTalk( $ns ), $dbKey );
}
return $expandedTargets;
}
'redirect' => 'page_is_redirect'
],
'conds' => [
- 'page_namespace' => MWNamespace::getContentNamespaces(),
+ 'page_namespace' => MediaWikiServices::getInstance()->getNamespaceInfo()->
+ getContentNamespaces(),
'page_id = rev_page' ],
'options' => [
'GROUP BY' => [ 'page_namespace', 'page_title', 'page_is_redirect' ]
$groupnameLocalized = UserGroupMembership::getGroupName( $groupname );
$grouppageLocalizedTitle = UserGroupMembership::getGroupPage( $groupname )
- ?: Title::newFromText( MWNamespace::getCanonicalName( NS_PROJECT ) . ':' . $groupname );
+ ?: Title::newFromText( MediaWikiServices::getInstance()->getNamespaceInfo()->
+ getCanonicalName( NS_PROJECT ) . ':' . $groupname );
if ( $group == '*' || !$grouppageLocalizedTitle ) {
// Do not make a link for the generic * group or group with invalid group page
);
$linkRenderer = $this->getLinkRenderer();
ksort( $namespaceProtection );
- $validNamespaces = MWNamespace::getValidNamespaces();
+ $validNamespaces =
+ MediaWikiServices::getInstance()->getNamespaceInfo()->getValidNamespaces();
$contLang = MediaWikiServices::getInstance()->getContentLanguage();
foreach ( $namespaceProtection as $namespace => $rights ) {
if ( !in_array( $namespace, $validNamespaces ) ) {
* @ingroup SpecialPage
*/
+use MediaWiki\MediaWikiServices;
+
/**
* A special page looking for articles with no article linking to them,
* thus being lonely.
$tables = [ 'page', 'pagelinks', 'templatelinks' ];
$conds = [
'pl_namespace IS NULL',
- 'page_namespace' => MWNamespace::getContentNamespaces(),
+ 'page_namespace' => MediaWikiServices::getInstance()->getNamespaceInfo()->
+ getContentNamespaces(),
'page_is_redirect' => 0,
'tl_namespace IS NULL'
];
function getOrderFields() {
// For some crazy reason ordering by a constant
// causes a filesort in MySQL 5
- if ( count( MWNamespace::getContentNamespaces() ) > 1 ) {
+ if ( count( MediaWikiServices::getInstance()->getNamespaceInfo()->
+ getContentNamespaces() ) > 1
+ ) {
return [ 'page_namespace', 'page_title' ];
} else {
return [ 'page_title' ];
* @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
*/
+use MediaWiki\MediaWikiServices;
use Wikimedia\Rdbms\IResultWrapper;
use Wikimedia\Rdbms\IDatabase;
'title' => 'page_title',
'value' => 'COUNT(*)'
],
- 'conds' => [ 'page_namespace' => MWNamespace::getContentNamespaces() ],
+ 'conds' => [ 'page_namespace' =>
+ MediaWikiServices::getInstance()->getNamespaceInfo()->getContentNamespaces() ],
'options' => [
'HAVING' => 'COUNT(*) > 1',
'GROUP BY' => [ 'page_namespace', 'page_title' ]
* @ingroup SpecialPage
*/
+use MediaWiki\MediaWikiServices;
use Wikimedia\Rdbms\IResultWrapper;
use Wikimedia\Rdbms\IDatabase;
'title' => 'page_title',
'value' => 'COUNT(*)'
], 'conds' => [
- 'page_namespace' => MWNamespace::getContentNamespaces()
+ 'page_namespace' =>
+ MediaWikiServices::getInstance()->getNamespaceInfo()->getContentNamespaces()
], 'options' => [
'HAVING' => 'COUNT(*) > 1',
'GROUP BY' => [
* @ingroup SpecialPage
*/
+use MediaWiki\MediaWikiServices;
+
/**
* A special page that allows users to change page titles
*
$immovableNamespaces = [];
foreach ( array_keys( $this->getLanguage()->getNamespaces() ) as $nsId ) {
- if ( !MWNamespace::isMovable( $nsId ) ) {
+ if ( !MediaWikiServices::getInstance()->getNamespaceInfo()->isMovable( $nsId ) ) {
$immovableNamespaces[] = $nsId;
}
}
*/
// @todo FIXME: Use Title::moveSubpages() here
+ $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
$dbr = wfGetDB( DB_MASTER );
if ( $this->moveSubpages && (
- MWNamespace::hasSubpages( $nt->getNamespace() ) || (
+ $nsInfo->hasSubpages( $nt->getNamespace() ) || (
$this->moveTalk
- && MWNamespace::hasSubpages( $nt->getTalkPage()->getNamespace() )
+ && $nsInfo->hasSubpages( $nt->getTalkPage()->getNamespace() )
)
) ) {
$conds = [
. ' OR page_title = ' . $dbr->addQuotes( $ot->getDBkey() )
];
$conds['page_namespace'] = [];
- if ( MWNamespace::hasSubpages( $nt->getNamespace() ) ) {
+ if ( $nsInfo->hasSubpages( $nt->getNamespace() ) ) {
$conds['page_namespace'][] = $ot->getNamespace();
}
if ( $this->moveTalk &&
- MWNamespace::hasSubpages( $nt->getTalkPage()->getNamespace() )
+ $nsInfo->hasSubpages( $nt->getTalkPage()->getNamespace() )
) {
$conds['page_namespace'][] = $ot->getTalkPage()->getNamespace();
}
* @param Title $title Page being moved.
*/
function showSubpages( $title ) {
- $nsHasSubpages = MWNamespace::hasSubpages( $title->getNamespace() );
+ $nsHasSubpages = MediaWikiServices::getInstance()->getNamespaceInfo()->
+ hasSubpages( $title->getNamespace() );
$subpages = $title->getSubpages();
$count = $subpages instanceof TitleArray ? $subpages->count() : 0;
* @ingroup SpecialPage
*/
+use MediaWiki\MediaWikiServices;
+
/**
* This special page lists the defined password policies for user groups.
* See also @ref $wgPasswordPolicy.
$groupnameLocalized = UserGroupMembership::getGroupName( $group );
$grouppageLocalizedTitle = UserGroupMembership::getGroupPage( $group )
- ?: Title::newFromText( MWNamespace::getCanonicalName( NS_PROJECT ) . ':' . $group );
+ ?: Title::newFromText( MediaWikiServices::getInstance()->getNamespaceInfo()->
+ getCanonicalName( NS_PROJECT ) . ':' . $group );
$grouppage = $linkRenderer->makeLink(
$grouppageLocalizedTitle,
protected $extra = []; // Extra SQL statements
public function __construct( $name = 'Randompage' ) {
- $this->namespaces = MWNamespace::getContentNamespaces();
+ $this->namespaces = MediaWikiServices::getInstance()->getNamespaceInfo()->
+ getContentNamespaces();
parent::__construct( $name );
}
) {
// Reset namespace preferences: namespaces are not searched
// when they're not mentioned in the URL parameters.
- foreach ( MWNamespace::getValidNamespaces() as $n ) {
+ foreach ( MediaWikiServices::getInstance()->getNamespaceInfo()->getValidNamespaces()
+ as $n
+ ) {
$user->setOption( 'searchNs' . $n, false );
}
// The request parameters include all the namespaces to be searched.
* @ingroup SpecialPage
*/
+use MediaWiki\MediaWikiServices;
use Wikimedia\Rdbms\IResultWrapper;
use Wikimedia\Rdbms\IDatabase;
$blacklist = $config->get( 'ShortPagesNamespaceBlacklist' );
$tables = [ 'page' ];
$conds = [
- 'page_namespace' => array_diff( MWNamespace::getContentNamespaces(), $blacklist ),
+ 'page_namespace' => array_diff(
+ MediaWikiServices::getInstance()->getNamespaceInfo()->getContentNamespaces(),
+ $blacklist
+ ),
'page_is_redirect' => 0
];
$joinConds = [];
* @ingroup SpecialPage
*/
+use MediaWiki\MediaWikiServices;
+
/**
* Special page lists various statistics, including the contents of
* `site_stats`, plus page view details if enabled
}
$msg = $this->msg( 'grouppage-' . $groupname )->inContentLanguage();
if ( $msg->isBlank() ) {
- $grouppageLocalized = MWNamespace::getCanonicalName( NS_PROJECT ) .
- ':' . $groupname;
+ $grouppageLocalized = MediaWikiServices::getInstance()->getNamespaceInfo()->
+ getCanonicalName( NS_PROJECT ) . ':' . $groupname;
} else {
$grouppageLocalized = $msg->text();
}
* @ingroup SpecialPage
*/
+use MediaWiki\MediaWikiServices;
+
/**
* A special page looking for page without any category.
*
'cl_from IS NULL',
'page_namespace' => $this->requestedNamespace !== false
? $this->requestedNamespace
- : MWNamespace::getContentNamespaces(),
+ : MediaWikiServices::getInstance()->getNamespaceInfo()->
+ getContentNamespaces(),
'page_is_redirect' => 0
],
'join_conds' => [
function getOrderFields() {
// For some crazy reason ordering by a constant
// causes a filesort
- if ( $this->requestedNamespace === false && count( MWNamespace::getContentNamespaces() ) > 1 ) {
+ if ( $this->requestedNamespace === false &&
+ count( MediaWikiServices::getInstance()->getNamespaceInfo()->
+ getContentNamespaces() ) > 1
+ ) {
return [ 'page_namespace', 'page_title' ];
}
* @author Rob Church <robchur@gmail.com>
*/
+use MediaWiki\MediaWikiServices;
+
/**
* Special page lists pages without language links
*
],
'conds' => [
'll_title IS NULL',
- 'page_namespace' => MWNamespace::getContentNamespaces(),
+ 'page_namespace' => MediaWikiServices::getInstance()->getNamespaceInfo()->
+ getContentNamespaces(),
'page_is_redirect' => 0
],
'join_conds' => [ 'langlinks' => [ 'LEFT JOIN', 'll_from = page_id' ] ]
'wgCheckFileExtensions' => $config->get( 'CheckFileExtensions' ),
'wgStrictFileExtensions' => $config->get( 'StrictFileExtensions' ),
'wgFileExtensions' => array_values( array_unique( $config->get( 'FileExtensions' ) ) ),
- 'wgCapitalizeUploads' => MWNamespace::isCapitalized( NS_FILE ),
+ 'wgCapitalizeUploads' => MediaWikiServices::getInstance()->getNamespaceInfo()->
+ isCapitalized( NS_FILE ),
'wgMaxUploadSize' => $this->mMaxUploadSize,
'wgFileCanRotate' => SpecialUpload::rotationEnabled(),
];
}
$associatedNS = $this->mDb->addQuotes(
- MWNamespace::getAssociated( $this->namespace )
+ MediaWikiServices::getInstance()->getAssociated( $this->namespace )
);
return [
// For built-in namespaces (0 <= ID < 100), we try to find a local NS with
// the same namespace ID
- if ( $foreignNs < 100 && MWNamespace::exists( $foreignNs ) ) {
+ if (
+ $foreignNs < 100 &&
+ MediaWikiServices::getInstance()->getNamespaceInfo()->exists( $foreignNs )
+ ) {
return Title::makeTitleSafe( $foreignNs, $foreignTitle->getText() );
}
}
* @file
*/
+use MediaWiki\MediaWikiServices;
+
/**
* A class to convert page titles on a foreign wiki (ForeignTitle objects) into
* page titles on the local wiki (Title objects), placing all pages in a fixed
* @param int $ns The namespace to use for all pages
*/
public function __construct( $ns ) {
- if ( !MWNamespace::exists( $ns ) ) {
+ if ( !MediaWikiServices::getInstance()->getNamespaceInfo()->exists( $ns ) ) {
throw new MWException( "Namespace $ns doesn't exist on this wiki" );
}
$this->ns = $ns;
* @file
*/
+use MediaWiki\MediaWikiServices;
+
/**
* A class to convert page titles on a foreign wiki (ForeignTitle objects) into
* page titles on the local wiki (Title objects), placing all pages as subpages
* created
*/
public function __construct( Title $rootPage ) {
- if ( !MWNamespace::hasSubpages( $rootPage->getNamespace() ) ) {
+ if (
+ !MediaWikiServices::getInstance()->getNamespaceInfo()->
+ hasSubpages( $rootPage->getNamespace() )
+ ) {
throw new MWException( "The root page you specified, $rootPage, is in a " .
"namespace where subpages are not allowed" );
}
if ( $pos !== false ) {
$iw = explode( ':', substr( $userName, 0, $pos ) );
$firstIw = array_shift( $iw );
- $interwikiLookup = MediaWikiServices::getInstance()->getInterwikiLookup();
+ $services = MediaWikiServices::getInstance();
+ $interwikiLookup = $services->getInterwikiLookup();
if ( $interwikiLookup->isValidInterwiki( $firstIw ) ) {
- $title = MWNamespace::getCanonicalName( NS_USER ) . ':' . substr( $userName, $pos + 1 );
+ $title = $services->getNamespaceInfo()->getCanonicalName( NS_USER ) .
+ ':' . substr( $userName, $pos + 1 );
if ( $iw ) {
$title = implode( ':', $iw ) . ':' . $title;
}
use Html;
use MediaWiki\MediaWikiServices;
use MediaWiki\Widget\SearchInputWidget;
-use MWNamespace;
use SearchEngineConfig;
use SpecialSearch;
use Xml;
$activeNamespaces = $this->specialSearch->getNamespaces();
$langConverter = $this->specialSearch->getLanguage();
foreach ( $this->searchConfig->searchableNamespaces() as $namespace => $name ) {
- $subject = MWNamespace::getSubject( $namespace );
+ $subject = MediaWikiServices::getInstance()->getNamespaceInfo()->
+ getSubject( $namespace );
if ( !isset( $rows[$subject] ) ) {
$rows[$subject] = "";
}
*/
use CLDRPluralRuleParser\Evaluator;
+use MediaWiki\MediaWikiServices;
use Wikimedia\Assert\Assert;
/**
if ( is_null( $this->namespaceNames ) ) {
global $wgMetaNamespace, $wgMetaNamespaceTalk, $wgExtraNamespaces;
- $validNamespaces = MWNamespace::getCanonicalNamespaces();
+ $validNamespaces = MediaWikiServices::getInstance()->getNamespaceInfo()->
+ getCanonicalNamespaces();
$this->namespaceNames = $wgExtraNamespaces +
self::$dataCache->getItem( $this->mCode, 'namespaceNames' );
*/
public function getNsIndex( $text ) {
$lctext = $this->lc( $text );
- $ns = MWNamespace::getCanonicalIndex( $lctext );
+ $ns = MediaWikiServices::getInstance()->getNamespaceInfo()->
+ getCanonicalIndex( $lctext );
if ( $ns !== null ) {
return $ns;
}
$this->namespace = intval( $this->getOption( 'namespace', 0 ) );
- if ( MWNamespace::isCapitalized( $this->namespace ) ) {
+ if (
+ MediaWikiServices::getInstance()->getNamespaceInfo()->
+ isCapitalized( $this->namespace )
+ ) {
$this->output( "Will be moving pages to first letter capitalized titles" );
$callback = 'processRowToUppercase';
} else {
# Namespace which no longer exists. Put the page in the main namespace
# since we don't have any idea of the old namespace name. See T70501.
- if ( !MWNamespace::exists( $ns ) ) {
+ if ( !MediaWikiServices::getInstance()->getNamespaceInfo()->exists( $ns ) ) {
$ns = 0;
}
* @return string
*/
function guessPriority( $namespace ) {
- return MWNamespace::isSubject( $namespace )
+ return MediaWikiServices::getInstance()->getNamespaceInfo()->isSubject( $namespace )
? $this->priorities[self::GS_MAIN]
: $this->priorities[self::GS_TALK];
}
}
// Now pull in all canonical and alias namespaces...
- foreach ( MWNamespace::getCanonicalNamespaces() as $ns => $name ) {
+ foreach (
+ MediaWikiServices::getInstance()->getNamespaceInfo()->getCanonicalNamespaces()
+ as $ns => $name
+ ) {
// This includes $wgExtraNamespaces
if ( $name !== '' ) {
$spaces[$name] = $ns;
* @return ResultWrapper
*/
private function getTargetList( $ns, $name, $options ) {
- if ( $options['move-talk'] && MWNamespace::isSubject( $ns ) ) {
+ if (
+ $options['move-talk'] &&
+ MediaWikiServices::getInstance()->getNamespaceInfo()->isSubject( $ns )
+ ) {
$checkNamespaces = [ NS_MAIN, NS_TALK ];
} else {
$checkNamespaces = NS_MAIN;
$dbk = "$name-" . $dbk;
}
$destNS = $ns;
- if ( $sourceNs == NS_TALK && MWNamespace::isSubject( $ns ) ) {
+ $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
+ if ( $sourceNs == NS_TALK && $nsInfo->isSubject( $ns ) ) {
// This is an associated talk page moved with the --move-talk feature.
- $destNS = MWNamespace::getTalk( $destNS );
+ $destNS = $nsInfo->getTalk( $destNS );
}
$newTitle = Title::makeTitleSafe( $destNS, $dbk );
if ( !$newTitle || !$newTitle->canExist() ) {
* @ingroup Maintenance
*/
+use MediaWiki\MediaWikiServices;
+
require_once __DIR__ . '/Maintenance.php';
/**
// Get the pages
$res = $dbr->select( 'page',
[ 'page_namespace', 'page_title', 'page_id' ],
- [ 'page_namespace' => MWNamespace::getContentNamespaces(),
+ [ 'page_namespace' => MediaWikiServices::getInstance()->getNamespaceInfo()->
+ getContentNamespaces(),
"page_id BETWEEN " . (int)$blockStart . " AND " . (int)$blockEnd ],
__METHOD__,
[ 'ORDER BY' => 'page_id ASC', 'USE INDEX' => 'PRIMARY' ]
'wgLanguageCode' => $langCode,
'wgRawHtml' => self::getOptionValue( 'wgRawHtml', $opts, false ),
'wgNamespacesWithSubpages' => array_fill_keys(
- MWNamespace::getValidNamespaces(), isset( $opts['subpage'] )
+ MediaWikiServices::getInstance()->getNamespaceInfo()->getValidNamespaces(),
+ isset( $opts['subpage'] )
),
'wgMaxTocLevel' => $maxtoclevel,
'wgAllowExternalImages' => self::getOptionValue( 'wgAllowExternalImages', $opts, true ),
}
// NOTE: prefer content namespaces
+ $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
$namespaces = array_unique( array_merge(
- MWNamespace::getContentNamespaces(),
+ $nsInfo->getContentNamespaces(),
[ NS_MAIN, NS_HELP, NS_PROJECT ], // prefer these
- MWNamespace::getValidNamespaces()
+ $nsInfo->getValidNamespaces()
) );
$namespaces = array_diff( $namespaces, [
NS_FILE, NS_CATEGORY, NS_MEDIAWIKI, NS_USER // don't mess with magic namespaces
] );
- $talk = array_filter( $namespaces, function ( $ns ) {
- return MWNamespace::isTalk( $ns );
+ $talk = array_filter( $namespaces, function ( $ns ) use ( $nsInfo ) {
+ return $nsInfo->isTalk( $ns );
} );
// prefer non-talk pages
<?php
+use MediaWiki\MediaWikiServices;
+
/**
* @covers PageProps
*
( $model === null || $model === CONTENT_MODEL_WIKITEXT )
) {
$ns = $this->getDefaultWikitextNS();
- $page = MWNamespace::getCanonicalName( $ns ) . ':' . $page;
+ $page = MediaWikiServices::getInstance()->getNamespaceInfo()->
+ getCanonicalName( $ns ) . ':' . $page;
}
$page = Title::newFromText( $page );
( $model === null || $model === CONTENT_MODEL_WIKITEXT )
) {
$ns = $this->getDefaultWikitextNS();
- $titleString = MWNamespace::getCanonicalName( $ns ) . ':' . $titleString;
+ $titleString = MediaWikiServices::getInstance()->getNamespaceInfo()->
+ getCanonicalName( $ns ) . ':' . $titleString;
}
$title = Title::newFromText( $titleString );
<?php
+use MediaWiki\MediaWikiServices;
use Wikimedia\TestingAccessWrapper;
/**
ApiBase::PARAM_ISMULTI => true,
ApiBase::PARAM_TYPE => 'namespace',
],
- MWNamespace::getValidNamespaces(),
+ MediaWikiServices::getInstance()->getNamespaceInfo()->getValidNamespaces(),
[],
],
// PARAM_ALL is ignored with namespace types.
ApiBase::PARAM_TYPE => 'namespace',
ApiBase::PARAM_ALL => false,
],
- MWNamespace::getValidNamespaces(),
+ MediaWikiServices::getInstance()->getNamespaceInfo()->getValidNamespaces(),
[],
],
'Namespace with wildcard "x"' => [
$expected
) {
$this->setMwGlobals( [
- // set to trick MWNamespace::getRestrictionLevels
+ // set to trick NamespaceInfo::getRestrictionLevels
'wgRestrictionLevels' => $restrictionLevels
] );
<?php
+use MediaWiki\MediaWikiServices;
use Wikimedia\TestingAccessWrapper;
/**
break;
case 'namespace':
- $validValues = MWNamespace::getValidNamespaces();
+ $validValues = MediaWikiServices::getInstance()->getNamespaceInfo()->
+ getValidNamespaces();
if (
isset( $config[ApiBase::PARAM_EXTRA_NAMESPACES] ) &&
is_array( $config[ApiBase::PARAM_EXTRA_NAMESPACES] )