55 throw new MWException(
"$method does not make any sense for given namespace $index" );
74 Hooks::run(
'NamespaceIsMovable', [ $index, &$result ] );
87 return !self::isTalk( $index );
96 public static function isTalk( $index ) {
108 self::isMethodValidFor( $index, __METHOD__ );
109 return self::isTalk( $index )
122 # Handle special namespaces
127 return self::isTalk( $index )
141 self::isMethodValidFor( $index, __METHOD__ );
143 if ( self::isSubject( $index ) ) {
144 return self::getTalk( $index );
145 } elseif ( self::isTalk( $index ) ) {
146 return self::getSubject( $index );
160 public static function exists( $index ) {
161 $nslist = self::getCanonicalNamespaces();
162 return isset( $nslist[$index] );
179 public static function equals( $ns1, $ns2 ) {
195 return self::getSubject( $ns1 ) == self::getSubject( $ns2 );
217 Hooks::run(
'CanonicalNamespaces', [ &
$namespaces ] );
229 $nslist = self::getCanonicalNamespaces();
230 if ( isset( $nslist[$index] ) ) {
231 return $nslist[$index];
245 static $xNamespaces =
false;
246 if ( $xNamespaces ===
false ) {
248 foreach ( self::getCanonicalNamespaces() as $i => $text ) {
249 $xNamespaces[strtolower( $text )] = $i;
252 if ( array_key_exists( $name, $xNamespaces ) ) {
253 return $xNamespaces[
$name];
265 static $mValidNamespaces =
null;
267 if ( is_null( $mValidNamespaces ) ) {
268 foreach ( array_keys( self::getCanonicalNamespaces() ) as $ns ) {
270 $mValidNamespaces[] = $ns;
274 sort( $mValidNamespaces, SORT_NUMERIC );
277 return $mValidNamespaces;
289 return self::hasTalkNamespace( $index );
373 self::getValidNamespaces(),
374 'MWNamespace::isSubject'
386 self::getValidNamespaces(),
387 'MWNamespace::isTalk'
403 $index = self::getSubject( $index );
406 if ( in_array( $index, self::$alwaysCapitalizedNamespaces ) ) {
451 return isset( $wgNamespaceContentModels[$index] )
452 ? $wgNamespaceContentModels[$index]
473 $levels = array_values( array_filter( $levels,
function ( $level ) use ( $user ) {
475 if ( $right ==
'sysop' ) {
476 $right =
'editprotected';
478 if ( $right ==
'autoconfirmed' ) {
479 $right =
'editsemiprotected';
481 return ( $right ==
'' || $user->isAllowed( $right ) );
488 $namespaceGroups = [];
489 $combine =
'array_merge';
491 if ( $right ==
'sysop' ) {
492 $right =
'editprotected';
494 if ( $right ==
'autoconfirmed' ) {
495 $right =
'editsemiprotected';
497 if ( $right !=
'' ) {
498 $namespaceGroups = call_user_func( $combine, $namespaceGroups,
499 User::getGroupsWithPermission( $right ) );
500 $combine =
'array_intersect';
507 $usableLevels = [
'' ];
510 if ( $right ==
'sysop' ) {
511 $right =
'editprotected';
513 if ( $right ==
'autoconfirmed' ) {
514 $right =
'editsemiprotected';
516 if ( $right !=
'' && ( !$user || $user->isAllowed( $right ) ) &&
517 array_diff( $namespaceGroups, User::getGroupsWithPermission( $right ) )
519 $usableLevels[] = $level;
523 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 isMethodValidFor( $index, $method)
Throw an exception when trying to get the subject or talk page for a given namespace where it does no...
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 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...
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
namespace being checked & $result
namespace and then decline to actually register it & $namespaces
Allows to change the fields on the form that will be generated $name