Go to the documentation of this file.
86 'CanonicalNamespaceNames',
87 'CapitalLinkOverrides',
91 'ExtraSignatureNamespaces',
92 'NamespaceContentModels',
93 'NamespacesWithSubpages',
94 'NonincludableNamespaces',
119 throw new MWException(
"$method does not make any sense for given namespace $index" );
132 ( $index !=
NS_FILE || $this->options->get(
'AllowImageMoving' ) );
137 Hooks::run(
'NamespaceIsMovable', [ $index, &$result ] );
149 return !$this->
isTalk( $index );
173 return $this->
isTalk( $index )
188 if ( $target->
getText() ===
'' ) {
189 throw new MWException(
'Can\'t determine talk page associated with relative section link' );
193 throw new MWException(
'Can\'t determine talk page associated with interwiki link' );
235 # Handle special namespaces
240 return $this->
isTalk( $index )
269 return $this->
getTalk( $index );
281 if ( $target->
getText() ===
'' ) {
282 throw new MWException(
'Can\'t determine talk page associated with relative section link' );
286 throw new MWException(
'Can\'t determine talk page associated with interwiki link' );
302 return isset( $nslist[$index] );
343 if ( $this->canonicalNamespaces ===
null ) {
344 $this->canonicalNamespaces =
345 [
NS_MAIN =>
'' ] + $this->options->get(
'CanonicalNamespaceNames' );
346 $this->canonicalNamespaces +=
348 if ( is_array( $this->options->get(
'ExtraNamespaces' ) ) ) {
349 $this->canonicalNamespaces += $this->options->get(
'ExtraNamespaces' );
351 Hooks::run(
'CanonicalNamespaces', [ &$this->canonicalNamespaces ] );
364 return $nslist[$index] ??
false;
375 if ( $this->namespaceIndexes ===
false ) {
376 $this->namespaceIndexes = [];
378 $this->namespaceIndexes[strtolower( $text )] = $i;
381 if ( array_key_exists( $name, $this->namespaceIndexes ) ) {
382 return $this->namespaceIndexes[$name];
394 if ( is_null( $this->validNamespaces ) ) {
395 $this->validNamespaces = [];
398 $this->validNamespaces[] = $ns;
402 sort( $this->validNamespaces, SORT_NUMERIC );
426 return $index ==
NS_MAIN || in_array( $index, $this->options->get(
'ContentNamespaces' ) );
437 return $this->
isTalk( $index ) ||
438 in_array( $index, $this->options->get(
'ExtraSignatureNamespaces' ) );
458 return !empty( $this->options->get(
'NamespacesWithSubpages' )[$index] );
466 $contentNamespaces = $this->options->get(
'ContentNamespaces' );
467 if ( !is_array( $contentNamespaces ) || $contentNamespaces === [] ) {
469 } elseif ( !in_array(
NS_MAIN, $contentNamespaces ) ) {
471 return array_merge( [
NS_MAIN ], $contentNamespaces );
473 return $contentNamespaces;
486 [ $this,
'isSubject' ]
517 if ( in_array( $index, $this->alwaysCapitalizedNamespaces ) ) {
520 $overrides = $this->options->get(
'CapitalLinkOverrides' );
521 if ( isset( $overrides[$index] ) ) {
523 return $overrides[$index];
526 return $this->options->get(
'CapitalLinks' );
547 $namespaces = $this->options->get(
'NonincludableNamespaces' );
548 return $namespaces && in_array( $index, $namespaces );
562 return $this->options->get(
'NamespaceContentModels' )[$index] ??
null;
578 return MediaWikiServices::getInstance()
579 ->getPermissionManager()
580 ->getNamespaceRestrictionLevels( $index, $user );
597 } elseif ( $index ==
NS_FILE ) {
612 return array_keys( self::CANONICAL_NAMES );
__construct(ServiceOptions $options)
isMovable( $index)
Can pages in the given namespace be moved?
isWatchable( $index)
Can pages in a namespace be watched?
getAssociatedPage(LinkTarget $target)
hasTalkNamespace( $index)
Does this namespace ever have a talk namespace?
getValidNamespaces()
Returns an array of the namespaces (by integer id) that exist on the wiki.
const CANONICAL_NAMES
Definitions of the NS_ constants are in Defines.php.
getCanonicalNamespaces()
Returns array of all defined namespaces with their canonical (English) names.
getCategoryLinkType( $index)
Returns the link type to be used for categories.
wantSignatures( $index)
Might pages in this namespace require the use of the Signature button on the edit toolbar?
subjectEquals( $ns1, $ns2)
Returns whether the specified namespaces share the same subject.
isSubject( $index)
Is the given namespace is a subject (non-talk) namespace?
string[] null $canonicalNamespaces
Canonical namespaces cache.
array false $namespaceIndexes
Canonical namespaces index cache.
hasSubpages( $index)
Does the namespace allow subpages?
getSubjectNamespaces()
List all namespace indices which are considered subject, aka not a talk or special namespace.
getSubject( $index)
Get the subject namespace index for a given namespace Special namespaces (NS_MEDIA,...
getSubjectPage(LinkTarget $target)
getContentNamespaces()
Get a list of all namespace indices which are considered to contain content.
canHaveTalkPage(LinkTarget $target)
Can the title have a corresponding talk page?
getTalkNamespaces()
List all namespace indices which are considered talks, aka not a subject or special namespace.
isContent( $index)
Does this namespace contain content, for the purposes of calculating statistics, etc?
getTalk( $index)
Get the talk namespace index for a given namespace.
const CONSTRUCTOR_OPTIONS
exists( $index)
Returns whether the specified namespace exists.
$alwaysCapitalizedNamespaces
These namespaces should always be first-letter capitalized, now and forevermore.
getCanonicalName( $index)
Returns the canonical (English) name for a given index.
isTalk( $index)
Is the given namespace a talk namespace?
getNamespaceContentModel( $index)
Get the default content model for a namespace This does not mean that all pages in that namespace hav...
hasGenderDistinction( $index)
Does the namespace (potentially) have different aliases for different genders.
equals( $ns1, $ns2)
Returns whether the specified namespaces are the same namespace.
isNonincludable( $index)
It is not possible to use pages from this namespace as template?
getCanonicalIndex( $name)
Returns the index for a given canonical name, or NULL The input must be converted to lower case first...
isCapitalized( $index)
Is the namespace first-letter capitalized?
getTalkPage(LinkTarget $target)
Get a LinkTarget referring to the talk page of $target.
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...
int[] null $validNamespaces
Valid namespaces cache.
static getCommonNamespaces()
Retrieve the indexes for the namespaces defined by core.
isMethodValidFor( $index, $method)
Throw an exception when trying to get the subject or talk page for a given namespace where it does no...
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
getAssociated( $index)
Get the associated namespace.
getRestrictionLevels( $index, User $user=null)
Determine which restriction levels it makes sense to use in a namespace, optionally filtered by a use...
Represents a page (or page fragment) title within MediaWiki.