Go to the documentation of this file.
91 'CanonicalNamespaceNames',
92 'CapitalLinkOverrides',
96 'ExtraSignatureNamespaces',
97 'NamespaceContentModels',
98 'NamespacesWithSubpages',
99 'NonincludableNamespaces',
124 throw new MWException(
"$method does not make any sense for given namespace $index" );
137 ( $index !=
NS_FILE || $this->options->get(
'AllowImageMoving' ) );
142 Hooks::run(
'NamespaceIsMovable', [ $index, &$result ] );
154 return !$this->
isTalk( $index );
178 return $this->
isTalk( $index )
193 if ( $target->
getText() ===
'' ) {
194 throw new MWException(
'Can\'t determine talk page associated with relative section link' );
198 throw new MWException(
'Can\'t determine talk page associated with interwiki link' );
240 # Handle special namespaces
245 return $this->
isTalk( $index )
274 return $this->
getTalk( $index );
286 if ( $target->
getText() ===
'' ) {
287 throw new MWException(
'Can\'t determine talk page associated with relative section link' );
291 throw new MWException(
'Can\'t determine talk page associated with interwiki link' );
307 return isset( $nslist[$index] );
348 if ( $this->canonicalNamespaces ===
null ) {
349 $this->canonicalNamespaces =
350 [
NS_MAIN =>
'' ] + $this->options->get(
'CanonicalNamespaceNames' );
351 $this->canonicalNamespaces +=
353 if ( is_array( $this->options->get(
'ExtraNamespaces' ) ) ) {
354 $this->canonicalNamespaces += $this->options->get(
'ExtraNamespaces' );
356 Hooks::run(
'CanonicalNamespaces', [ &$this->canonicalNamespaces ] );
369 return $nslist[$index] ??
false;
380 if ( $this->namespaceIndexes ===
false ) {
381 $this->namespaceIndexes = [];
383 $this->namespaceIndexes[strtolower( $text )] = $i;
386 if ( array_key_exists( $name, $this->namespaceIndexes ) ) {
387 return $this->namespaceIndexes[$name];
399 if ( is_null( $this->validNamespaces ) ) {
400 $this->validNamespaces = [];
403 $this->validNamespaces[] = $ns;
407 sort( $this->validNamespaces, SORT_NUMERIC );
__construct(ServiceOptions $options)
isMovable( $index)
Can pages in the given namespace be moved?
getAssociatedPage(LinkTarget $target)
getValidNamespaces()
Returns an array of the namespaces (by integer id) that exist on the wiki.
getCanonicalNamespaces()
Returns array of all defined namespaces with their canonical (English) names.
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.
static array $canonicalNames
Definitions of the NS_ constants are in Defines.php.
getSubject( $index)
Get the subject namespace index for a given namespace Special namespaces (NS_MEDIA,...
getSubjectPage(LinkTarget $target)
canHaveTalkPage(LinkTarget $target)
Can the title have a corresponding talk page?
getTalk( $index)
Get the talk namespace index for a given namespace.
static array $constructorOptions
TODO Make this const when HHVM support is dropped (T192166)
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?
equals( $ns1, $ns2)
Returns whether the specified namespaces are the same namespace.
getCanonicalIndex( $name)
Returns the index for a given canonical name, or NULL The input must be converted to lower case first...
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.
isMethodValidFor( $index, $method)
Throw an exception when trying to get the subject or talk page for a given namespace where it does no...
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
getAssociated( $index)
Get the associated namespace.
Represents a page (or page fragment) title within MediaWiki.