MediaWiki
1.33.0
|
This is a utility class with only static functions for dealing with namespaces that encodes all the "magic" behaviors of them based on index. More...
Static Public Member Functions | |
static | canTalk ( $index) |
Does this namespace ever have a talk namespace? More... | |
static | clearCaches () |
Clear internal caches. More... | |
static | equals ( $ns1, $ns2) |
Returns whether the specified namespaces are the same namespace. More... | |
static | exists ( $index) |
Returns whether the specified namespace exists. More... | |
static | getAssociated ( $index) |
Get the associated namespace. More... | |
static | getCanonicalIndex ( $name) |
Returns the index for a given canonical name, or NULL The input must be converted to lower case first. More... | |
static | getCanonicalName ( $index) |
Returns the canonical (English) name for a given index. More... | |
static | getCanonicalNamespaces ( $rebuild=false) |
Returns array of all defined namespaces with their canonical (English) names. More... | |
static | getCategoryLinkType ( $index) |
Returns the link type to be used for categories. More... | |
static | getContentNamespaces () |
Get a list of all namespace indices which are considered to contain content. More... | |
static | getNamespaceContentModel ( $index) |
Get the default content model for a namespace This does not mean that all pages in that namespace have the model. More... | |
static | getRestrictionLevels ( $index, User $user=null) |
Determine which restriction levels it makes sense to use in a namespace, optionally filtered by a user's rights. More... | |
static | getSubject ( $index) |
Get the subject namespace index for a given namespace Special namespaces (NS_MEDIA, NS_SPECIAL) are always the subject. More... | |
static | getSubjectNamespaces () |
List all namespace indices which are considered subject, aka not a talk or special namespace. More... | |
static | getTalk ( $index) |
Get the talk namespace index for a given namespace. More... | |
static | getTalkNamespaces () |
List all namespace indices which are considered talks, aka not a subject or special namespace. More... | |
static | getValidNamespaces () |
Returns an array of the namespaces (by integer id) that exist on the wiki. More... | |
static | hasGenderDistinction ( $index) |
Does the namespace (potentially) have different aliases for different genders. More... | |
static | hasSubpages ( $index) |
Does the namespace allow subpages? More... | |
static | hasTalkNamespace ( $index) |
Does this namespace ever have a talk namespace? More... | |
static | isCapitalized ( $index) |
Is the namespace first-letter capitalized? More... | |
static | isContent ( $index) |
Does this namespace contain content, for the purposes of calculating statistics, etc? More... | |
static | isMovable ( $index) |
Can pages in the given namespace be moved? More... | |
static | isNonincludable ( $index) |
It is not possible to use pages from this namespace as template? More... | |
static | isSubject ( $index) |
Is the given namespace is a subject (non-talk) namespace? More... | |
static | isTalk ( $index) |
Is the given namespace a talk namespace? More... | |
static | isWatchable ( $index) |
Can pages in a namespace be watched? More... | |
static | subjectEquals ( $ns1, $ns2) |
Returns whether the specified namespaces share the same subject. More... | |
static | wantSignatures ( $index) |
Might pages in this namespace require the use of the Signature button on the edit toolbar? More... | |
Static Private Member Functions | |
static | isMethodValidFor ( $index, $method) |
Throw an exception when trying to get the subject or talk page for a given namespace where it does not make sense. More... | |
Static Private Attributes | |
static | $alwaysCapitalizedNamespaces = [ NS_SPECIAL, NS_USER, NS_MEDIAWIKI ] |
These namespaces should always be first-letter capitalized, now and forevermore. More... | |
static string[] null | $canonicalNamespaces = null |
Canonical namespaces cache. More... | |
static array false | $namespaceIndexes = false |
Canonical namespaces index cache. More... | |
static int[] null | $validNamespaces = null |
Valid namespaces cache. More... | |
This is a utility class with only static functions for dealing with namespaces that encodes all the "magic" behaviors of them based on index.
The textual names of the namespaces are handled by Language.php.
These are synonyms for the names given in the language file Users and translators should not change them
Definition at line 33 of file MWNamespace.php.
|
static |
Does this namespace ever have a talk namespace?
int | $index | Namespace index |
Definition at line 309 of file MWNamespace.php.
References hasTalkNamespace(), and wfDeprecated().
Referenced by MWNamespaceTest\testCanTalk().
|
static |
Clear internal caches.
For use in unit testing when namespace configuration is changed.
Definition at line 77 of file MWNamespace.php.
Referenced by getCanonicalNamespaces(), and MediaWikiTestCase\resetNamespaces().
|
static |
Returns whether the specified namespaces are the same namespace.
int | $ns1 | The first namespace index |
int | $ns2 | The second namespace index |
Definition at line 202 of file MWNamespace.php.
Referenced by Title\inNamespace(), and MWNamespaceTest\testEquals().
|
static |
Returns whether the specified namespace exists.
int | $index |
Definition at line 183 of file MWNamespace.php.
References getCanonicalNamespaces().
Referenced by NamespaceImportTitleFactory\__construct(), NaiveImportTitleFactory\createTitleFromForeignTitle(), Linker\getInvalidTitleDescription(), Title\isValid(), Title\makeTitleSafe(), TitleCleanup\moveInconsistentPage(), and WikiImporter\setTargetNamespace().
|
static |
Get the associated namespace.
For talk namespaces, returns the subject (non-talk) namespace For subject (non-talk) namespaces, returns the talk namespace
int | $index | Namespace index |
Definition at line 163 of file MWNamespace.php.
References getSubject(), getTalk(), and isMethodValidFor().
Referenced by ChangesListSpecialPage\buildQuery(), ContribsPager\getNamespaceCond(), MWNamespaceTest\testGetAssociated(), MWNamespaceTest\testGetAssociatedExceptionsForNsMedia(), and MWNamespaceTest\testGetAssociatedExceptionsForNsSpecial().
|
static |
Returns the index for a given canonical name, or NULL The input must be converted to lower case first.
string | $name | Namespace name |
Definition at line 268 of file MWNamespace.php.
Referenced by Language\getNsIndex().
|
static |
Returns the canonical (English) name for a given index.
int | $index | Namespace index |
Definition at line 256 of file MWNamespace.php.
References getCanonicalNamespaces().
Referenced by SpecialContributions\contributionsSub(), RevisionDbTestBase\createPage(), PagePropsTest\createPage(), SpecialPasswordPolicies\execute(), SpecialListGroupRights\execute(), Linker\formatLinksInComment(), SpecialStatistics\getGroupStats(), Title\getNamespaceKey(), Title\getNsText(), DeletedContributionsPage\getSubTitle(), ExternalUserNames\getUserLinkTitle(), Linker\makeCommentLink(), Title\makeName(), Title\moveSubpages(), EditPage\showIntro(), and Article\showMissingArticle().
|
static |
Returns array of all defined namespaces with their canonical (English) names.
bool | $rebuild | Rebuild namespace list (default = false). Used for testing. Deprecated since 1.31, use self::clearCaches() instead. |
Definition at line 231 of file MWNamespace.php.
References $canonicalNamespaces, $wgCanonicalNamespaceNames, $wgExtraNamespaces, clearCaches(), ExtensionRegistry\getInstance(), NS_MAIN, and Hooks\run().
Referenced by NamespaceDupes\checkAll(), exists(), getCanonicalName(), ResourceLoaderStartUpModule\getConfigSettings(), ReplaceAll\getNamespaces(), Language\getNamespaces(), and ReplaceAll\listNamespaces().
|
static |
Returns the link type to be used for categories.
This determines which section of a category page titles in the namespace will appear within.
int | $index | Namespace index |
Definition at line 560 of file MWNamespace.php.
References isMethodValidFor(), NS_CATEGORY, and NS_FILE.
Referenced by UpdateCollation\execute(), LinksUpdate\getCategoryInsertions(), MovePage\move(), MWNamespaceTest\testGetCategoryLinkType(), and WikiPage\updateCategoryCounts().
|
static |
Get a list of all namespace indices which are considered to contain content.
Definition at line 375 of file MWNamespace.php.
References $wgContentNamespaces, and NS_MAIN.
Referenced by RandomPage\__construct(), SiteStatsInit\articles(), Title\canUseNoindex(), RebuildFileCache\execute(), ResourceLoaderStartUpModule\getConfigSettings(), MediaWikiTestCase\getDefaultWikitextNS(), UncategorizedPagesPage\getOrderFields(), DeadendPagesPage\getOrderFields(), LonelyPagesPage\getOrderFields(), ShortPagesPage\getQueryInfo(), FewestrevisionsPage\getQueryInfo(), MostinterwikisPage\getQueryInfo(), AncientPagesPage\getQueryInfo(), MostcategoriesPage\getQueryInfo(), UncategorizedPagesPage\getQueryInfo(), LonelyPagesPage\getQueryInfo(), DeadendPagesPage\getQueryInfo(), WithoutInterwikiPage\getQueryInfo(), and MWNamespaceTest\testGetContentNamespaces().
|
static |
Get the default content model for a namespace This does not mean that all pages in that namespace have the model.
int | $index | Index to check |
Definition at line 474 of file MWNamespace.php.
Determine which restriction levels it makes sense to use in a namespace, optionally filtered by a user's rights.
Definition at line 489 of file MWNamespace.php.
References $user, $wgNamespaceProtection, $wgRestrictionLevels, array(), as, User\getGroupsWithPermission(), and use.
Referenced by EditPage\addPageProtectionWarningHeaders(), SkinTemplate\buildContentNavigationUrls(), ProtectionForm\buildSelector(), ProtectionForm\execute(), MediaWiki\EditPage\TextboxBuilder\getTextboxProtectionCSSClasses(), and ProtectionForm\loadData().
|
static |
Get the subject namespace index for a given namespace Special namespaces (NS_MEDIA, NS_SPECIAL) are always the subject.
int | $index | Namespace index |
Definition at line 144 of file MWNamespace.php.
References isTalk(), and NS_MAIN.
Referenced by getAssociated(), SpecialEditWatchlist\getExpandedTargets(), Title\getNamespaceKey(), Title\getSubjectNsText(), Title\getSubjectPage(), ApiQueryInfo\getTSIDs(), isCapitalized(), MovePage\move(), SpecialReplaceText\namespaceTables(), MediaWiki\Widget\Search\SearchFormWidget\powerSearchBox(), subjectEquals(), SkinTemplate\tabAction(), and MWNamespaceTest\testGetSubject().
|
static |
List all namespace indices which are considered subject, aka not a talk or special namespace.
See also MWNamespace::isSubject
Definition at line 393 of file MWNamespace.php.
Referenced by MWNamespaceTest\testGetSubjectNamespaces().
|
static |
Get the talk namespace index for a given namespace.
int | $index | Namespace index |
Definition at line 130 of file MWNamespace.php.
References isMethodValidFor(), and isTalk().
Referenced by getAssociated(), NamespaceDupes\getDestinationTitle(), SpecialEditWatchlist\getExpandedTargets(), Title\getTalkNsText(), Title\getTalkPage(), ApiQueryInfo\getTSIDs(), MWNamespaceTest\testGetTalk(), MWNamespaceTest\testGetTalkExceptionsForNsMedia(), and MWNamespaceTest\testGetTalkExceptionsForNsSpecial().
|
static |
List all namespace indices which are considered talks, aka not a subject or special namespace.
See also MWNamespace::isTalk
Definition at line 406 of file MWNamespace.php.
Referenced by MWNamespaceTest\testGetTalkNamespaces().
|
static |
Returns an array of the namespaces (by integer id) that exist on the wiki.
Used primarily by the api in help documentation.
Definition at line 287 of file MWNamespace.php.
References $validNamespaces, and as.
Referenced by MediaWikiTestCase\getDefaultWikitextNS(), ApiHelp\getHelpInternal(), ApiBase\getParameterFromSettings(), TrackingCategories\getTrackingCategories(), SpecialListGroupRights\outputNamespaceProtectionInfo(), ApiBaseTest\provideGetParameterFromSettings(), ApiQueryAllRevisions\run(), ApiQueryAllDeletedRevisions\run(), SpecialSearch\saveNamespaces(), and MediaWiki\Preferences\DefaultPreferencesFactory\searchPreferences().
|
static |
Does the namespace (potentially) have different aliases for different genders.
Not all languages make a distinction here.
int | $index | Index to check |
Definition at line 447 of file MWNamespace.php.
References NS_USER, and NS_USER_TALK.
Referenced by GenderCache\doLinkBatch(), GenderCache\doTitlesArray(), MediaWikiTitleCodec\getNamespaceName(), ApiPageSet\initFromQueryResult(), ApiPageSet\processTitlesArray(), ApiQueryAllPages\run(), and MWNamespaceTest\testHasGenderDistinction().
|
static |
Does the namespace allow subpages?
int | $index | Index to check |
Definition at line 366 of file MWNamespace.php.
References $wgNamespacesWithSubpages.
Referenced by SubpageImportTitleFactory\__construct(), MWNamespaceTest\assertHasNotSubpages(), MWNamespaceTest\assertHasSubpages(), MediaWiki\Permissions\PermissionManager\checkQuickPermissions(), MovePageForm\doSubmit(), Title\getBaseText(), Title\getEditNotices(), Title\getRootText(), Title\getSubpages(), Title\getSubpageText(), Title\hasSubpages(), Title\isSubpage(), Title\moveSubpages(), Linker\normalizeSubpageLink(), InfoAction\pageCounts(), InfoAction\pageInfo(), WikiImporter\setTargetRootPage(), MovePageForm\showSubpages(), and Skin\subPageSubtitle().
|
static |
Does this namespace ever have a talk namespace?
int | $index | Namespace ID |
Definition at line 322 of file MWNamespace.php.
References NS_MAIN.
Referenced by ChangesFeed\buildItems(), Title\canHaveTalkPage(), canTalk(), and MWNamespaceTest\testHasTalkNamespace().
|
static |
Is the namespace first-letter capitalized?
int | $index | Index to check |
Definition at line 419 of file MWNamespace.php.
References $wgCapitalLinkOverrides, $wgCapitalLinks, getSubject(), NS_FILE, and NS_MEDIA.
Referenced by FileRepo\__construct(), UploadForm\addUploadJS(), MWNamespaceTest\assertIsCapitalized(), MWNamespaceTest\assertIsNotCapitalized(), Title\capitalize(), CleanupCaps\execute(), ResourceLoaderStartUpModule\getConfigSettings(), FileRepo\getNameFromTitle(), XmlDumpWriter\namespaces(), and MWNamespaceTest\testIsCapitalizedHardcodedAssertions().
|
static |
Does this namespace contain content, for the purposes of calculating statistics, etc?
int | $index | Index to check |
Definition at line 333 of file MWNamespace.php.
References $wgContentNamespaces, and NS_MAIN.
Referenced by MWNamespaceTest\assertIsContent(), MWNamespaceTest\assertIsNotContent(), MediaWiki\Linker\LinkRenderer\getLinkClasses(), LinkCache\isCacheable(), and Title\isContentPage().
|
staticprivate |
Throw an exception when trying to get the subject or talk page for a given namespace where it does not make sense.
Special namespaces are defined in includes/Defines.php and have a value below 0 (ex: NS_SPECIAL = -1 , NS_MEDIA = -2)
int | $index | |
string | $method |
MWException |
Definition at line 63 of file MWNamespace.php.
References NS_MAIN.
Referenced by getAssociated(), getCategoryLinkType(), and getTalk().
|
static |
Can pages in the given namespace be moved?
int | $index | Namespace index |
Definition at line 89 of file MWNamespace.php.
References $wgAllowImageMoving, NS_FILE, NS_MAIN, and Hooks\run().
Referenced by MediaWiki\Permissions\PermissionManager\checkActionPermissions(), Title\isMovable(), MovePageForm\showForm(), and MWNamespaceTest\testIsMovable().
|
static |
It is not possible to use pages from this namespace as template?
int | $index | Index to check |
Definition at line 458 of file MWNamespace.php.
References $wgNonincludableNamespaces.
Referenced by MWNamespaceTest\testIsNonincludable().
|
static |
Is the given namespace is a subject (non-talk) namespace?
int | $index | Namespace index |
Definition at line 109 of file MWNamespace.php.
References isTalk().
Referenced by MWNamespaceTest\assertIsNotSubject(), MWNamespaceTest\assertIsSubject(), NamespaceDupes\getDestinationTitle(), NamespaceDupes\getTargetList(), and LinkCache\isCacheable().
|
static |
Is the given namespace a talk namespace?
int | $index | Namespace index |
Definition at line 119 of file MWNamespace.php.
References NS_MAIN.
Referenced by MWNamespaceTest\assertIsNotTalk(), MWNamespaceTest\assertIsTalk(), MediaWiki\Permissions\PermissionManager\checkQuickPermissions(), MediaWikiTestCase\getDefaultWikitextNS(), getSubject(), getTalk(), ApiQueryInfo\getTSIDs(), SpecialEditWatchlist\getWatchlistInfo(), isSubject(), Title\isTalkPage(), DumpNotalkFilter\pass(), and wantSignatures().
|
static |
Can pages in a namespace be watched?
int | $index |
Definition at line 356 of file MWNamespace.php.
References NS_MAIN.
Referenced by MWNamespaceTest\assertIsNotWatchable(), MWNamespaceTest\assertIsWatchable(), and Title\isWatchable().
|
static |
Returns whether the specified namespaces share the same subject.
eg: NS_USER and NS_USER wil return true, as well NS_USER and NS_USER_TALK will return true.
int | $ns1 | The first namespace index |
int | $ns2 | The second namespace index |
Definition at line 217 of file MWNamespace.php.
References getSubject().
Referenced by MWNamespaceTest\assertDifferentSubject(), MWNamespaceTest\assertSameSubject(), and Title\hasSubjectNamespace().
|
static |
Might pages in this namespace require the use of the Signature button on the edit toolbar?
int | $index | Index to check |
Definition at line 345 of file MWNamespace.php.
References $wgExtraSignatureNamespaces, and isTalk().
|
staticprivate |
These namespaces should always be first-letter capitalized, now and forevermore.
Historically, they could've probably been lowercased too, but some things are just too ingrained now. :)
Definition at line 40 of file MWNamespace.php.
Canonical namespaces cache.
Definition at line 43 of file MWNamespace.php.
Referenced by getCanonicalNamespaces().
Canonical namespaces index cache.
Definition at line 46 of file MWNamespace.php.
Valid namespaces cache.
Definition at line 49 of file MWNamespace.php.
Referenced by getValidNamespaces().