64 throw new MWException(
"$method does not make any sense for given namespace $index" );
77 self::$canonicalNamespaces =
null;
78 self::$namespaceIndexes =
false;
79 self::$validNamespaces =
null;
96 Hooks::run(
'NamespaceIsMovable', [ $index, &$result ] );
109 return !self::isTalk( $index );
118 public static function isTalk( $index ) {
130 self::isMethodValidFor( $index, __METHOD__ );
131 return self::isTalk( $index )
144 # Handle special namespaces
149 return self::isTalk( $index )
163 self::isMethodValidFor( $index, __METHOD__ );
165 if ( self::isSubject( $index ) ) {
166 return self::getTalk( $index );
167 } elseif ( self::isTalk( $index ) ) {
168 return self::getSubject( $index );
182 public static function exists( $index ) {
183 $nslist = self::getCanonicalNamespaces();
184 return isset( $nslist[$index] );
201 public static function equals( $ns1, $ns2 ) {
217 return self::getSubject( $ns1 ) == self::getSubject( $ns2 );
235 if ( self::$canonicalNamespaces ===
null ) {
239 self::$canonicalNamespaces +=
244 Hooks::run(
'CanonicalNamespaces', [ &self::$canonicalNamespaces ] );
246 return self::$canonicalNamespaces;
256 $nslist = self::getCanonicalNamespaces();
257 if ( isset( $nslist[$index] ) ) {
258 return $nslist[$index];
272 if ( self::$namespaceIndexes ===
false ) {
273 self::$namespaceIndexes = [];
274 foreach ( self::getCanonicalNamespaces() as $i => $text ) {
275 self::$namespaceIndexes[strtolower( $text )] = $i;
278 if ( array_key_exists( $name, self::$namespaceIndexes ) ) {
279 return self::$namespaceIndexes[
$name];
291 if ( is_null( self::$validNamespaces ) ) {
292 foreach ( array_keys( self::getCanonicalNamespaces() ) as $ns ) {
294 self::$validNamespaces[] = $ns;
298 sort( self::$validNamespaces, SORT_NUMERIC );
301 return self::$validNamespaces;
313 return self::hasTalkNamespace( $index );
397 self::getValidNamespaces(),
398 'MWNamespace::isSubject'
410 self::getValidNamespaces(),
411 'MWNamespace::isTalk'
427 $index = self::getSubject( $index );
430 if ( in_array( $index, self::$alwaysCapitalizedNamespaces ) ) {
475 return isset( $wgNamespaceContentModels[$index] )
476 ? $wgNamespaceContentModels[$index]
497 $levels = array_values( array_filter( $levels,
function ( $level ) use ( $user ) {
499 if ( $right ==
'sysop' ) {
500 $right =
'editprotected';
502 if ( $right ==
'autoconfirmed' ) {
503 $right =
'editsemiprotected';
505 return ( $right ==
'' || $user->isAllowed( $right ) );
512 $namespaceGroups = [];
513 $combine =
'array_merge';
515 if ( $right ==
'sysop' ) {
516 $right =
'editprotected';
518 if ( $right ==
'autoconfirmed' ) {
519 $right =
'editsemiprotected';
521 if ( $right !=
'' ) {
522 $namespaceGroups = call_user_func( $combine, $namespaceGroups,
524 $combine =
'array_intersect';
531 $usableLevels = [
'' ];
534 if ( $right ==
'sysop' ) {
535 $right =
'editprotected';
537 if ( $right ==
'autoconfirmed' ) {
538 $right =
'editsemiprotected';
540 if ( $right !=
'' && ( !$user || $user->isAllowed( $right ) ) &&
543 $usableLevels[] = $level;
547 return $usableLevels;
$wgRestrictionLevels
Rights which can be required for each protection level (via action=protect)
$wgAllowImageMoving
Allows to move images and other media files.
$wgExtraSignatureNamespaces
Array of namespaces, in addition to the talk namespaces, where signatures (~~~~) are likely to be use...
$wgNamespacesWithSubpages
Which namespaces should support subpages? See Language.php for a list of namespaces.
$wgCapitalLinks
Set this to false to avoid forcing the first letter of links to capitals.
$wgNonincludableNamespaces
Pages in namespaces in this array can not be used as templates.
$wgContentNamespaces
Array of namespaces which can be deemed to contain valid "content", as far as the site statistics are...
$wgExtraNamespaces
Additional namespaces.
$wgNamespaceProtection
Set the minimum permissions required to edit pages in each namespace.
$wgNamespaceContentModels
Associative array mapping namespace IDs to the name of the content model pages in that namespace shou...
$wgCanonicalNamespaceNames
Definitions of the NS_ constants are in Defines.php.
This is a utility class with only static functions for dealing with namespaces that encodes all the "...
static getContentNamespaces()
Get a list of all namespace indices which are considered to contain content.
static getSubject( $index)
Get the subject namespace index for a given namespace Special namespaces (NS_MEDIA,...
static wantSignatures( $index)
Might pages in this namespace require the use of the Signature button on the edit toolbar?
static exists( $index)
Returns whether the specified namespace exists.
static isSubject( $index)
Is the given namespace is a subject (non-talk) namespace?
static getCanonicalName( $index)
Returns the canonical (English) name for a given index.
static isCapitalized( $index)
Is the namespace first-letter capitalized?
static canTalk( $index)
Does this namespace ever have a talk namespace?
static isWatchable( $index)
Can pages in a namespace be watched?
static hasSubpages( $index)
Does the namespace allow subpages?
static isNonincludable( $index)
It is not possible to use pages from this namespace as template?
static hasGenderDistinction( $index)
Does the namespace (potentially) have different aliases for different genders.
static $alwaysCapitalizedNamespaces
These namespaces should always be first-letter capitalized, now and forevermore.
static isTalk( $index)
Is the given namespace a talk namespace?
static getCanonicalIndex( $name)
Returns the index for a given canonical name, or NULL The input must be converted to lower case first...
static getTalk( $index)
Get the talk namespace index for a given namespace.
static hasTalkNamespace( $index)
Does this namespace ever have a talk namespace?
static equals( $ns1, $ns2)
Returns whether the specified namespaces are the same namespace.
static subjectEquals( $ns1, $ns2)
Returns whether the specified namespaces share the same subject.
static getSubjectNamespaces()
List all namespace indices which are considered subject, aka not a talk or special namespace.
static string[] null $canonicalNamespaces
Canonical namespaces cache.
static isMethodValidFor( $index, $method)
Throw an exception when trying to get the subject or talk page for a given namespace where it does no...
static clearCaches()
Clear internal caches.
static getTalkNamespaces()
List all namespace indices which are considered talks, aka not a subject or special namespace.
static getCanonicalNamespaces( $rebuild=false)
Returns array of all defined namespaces with their canonical (English) names.
static getRestrictionLevels( $index, User $user=null)
Determine which restriction levels it makes sense to use in a namespace, optionally filtered by a use...
static isContent( $index)
Does this namespace contain content, for the purposes of calculating statistics, etc?
static int[] null $validNamespaces
Valid namespaces cache.
static getValidNamespaces()
Returns an array of the namespaces (by integer id) that exist on the wiki.
static isMovable( $index)
Can pages in the given namespace be moved?
static getAssociated( $index)
Get the associated namespace.
static getNamespaceContentModel( $index)
Get the default content model for a namespace This does not mean that all pages in that namespace hav...
static array false $namespaceIndexes
Canonical namespaces index cache.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static getGroupsWithPermission( $role)
Get all the groups who have a given permission.
namespace being checked & $result
Allows to change the fields on the form that will be generated $name