|
MediaWiki master
|
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them based on index. More...
Public Member Functions | |
| __construct (private readonly ServiceOptions $options, HookContainer $hookContainer, private readonly array $extensionNamespaces, private readonly array $immovableNamespaces) | |
| canHaveTalkPage (LinkTarget $target) | |
| Can the title have a corresponding talk page? | |
| equals (int $ns1, int $ns2) | |
| Returns whether the specified namespaces are the same namespace. | |
| exists (int $index) | |
| Returns whether the specified namespace exists. | |
| getAssociated (int $index) | |
| Get the associated namespace. | |
| getAssociatedPage (LinkTarget $target) | |
| getCanonicalIndex (string $name) | |
| Returns the index for a given canonical name, or NULL The input must be converted to lower case first. | |
| getCanonicalName (int $index) | |
| Returns the canonical (English) name for a given index. | |
| getCanonicalNamespaces () | |
| Returns array of all defined namespaces with their canonical (English) names. | |
| getCategoryLinkType (int $index) | |
| Returns the link type to be used for categories. | |
| getContentNamespaces () | |
| Get a list of all namespace indices which are considered to contain content. | |
| getNamespaceContentModel (int $index) | |
| Get the default content model for a namespace This does not mean that all pages in that namespace have the model. | |
| getSubject (int $index) | |
| Get the subject namespace index for a given namespace Special namespaces (NS_MEDIA, NS_SPECIAL) are always the subject. | |
| getSubjectNamespaces () | |
| List all namespace indices which are considered subject, aka not a talk or special namespace. | |
| getSubjectPage (LinkTarget $target) | |
| getTalk (int $index) | |
| Get the talk namespace index for a given namespace. | |
| getTalkNamespaces () | |
| List all namespace indices which are considered talks, aka not a subject or special namespace. | |
| getTalkPage (LinkTarget $target) | |
| Get a LinkTarget referring to the talk page of $target. | |
| getValidNamespaces () | |
| Returns an array of the namespaces (by integer id) that exist on the wiki. | |
| hasGenderDistinction (int $index) | |
| Does the namespace (potentially) have different aliases for different genders. | |
| hasSubpages (int $index) | |
| Does the namespace allow subpages? Note that this refers to structured handling of subpages, and does not include SpecialPage subpage parameters. | |
| hasTalkNamespace (int $index) | |
| Does this namespace ever have a talk namespace? | |
| isCapitalized (int $index) | |
| Is the namespace first-letter capitalized? | |
| isContent (int $index) | |
| Does this namespace contain content, for the purposes of calculating statistics, etc? | |
| isMovable (int $index) | |
| Can pages in the given namespace be moved? | |
| isNonincludable (int $index) | |
| It is not possible to use pages from this namespace as template? | |
| isSubject (int $index) | |
| Is the given namespace is a subject (non-talk) namespace? | |
| isTalk (int $index) | |
| Is the given namespace a talk namespace? | |
| isWatchable (int $index) | |
| Can pages in a namespace be watched? | |
| subjectEquals (int $ns1, int $ns2) | |
| Returns whether the specified namespaces share the same subject. | |
| wantSignatures (int $index) | |
| Might pages in this namespace require the use of the Signature button on the edit toolbar? | |
Static Public Member Functions | |
| static | getCommonNamespaces () |
| Retrieve the indexes for the namespaces defined by core. | |
Public Attributes | |
| const | CANONICAL_NAMES |
| Definitions of the NS_ constants are in Defines.php. | |
| const | CONSTRUCTOR_OPTIONS |
This is a utility class 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.
Definition at line 24 of file NamespaceInfo.php.
| MediaWiki\Title\NamespaceInfo::__construct | ( | private readonly ServiceOptions | $options, |
| HookContainer | $hookContainer, | ||
| private readonly array | $extensionNamespaces, | ||
| private readonly array | $immovableNamespaces ) |
| ServiceOptions | $options | |
| HookContainer | $hookContainer | |
| array<int,string> | $extensionNamespaces From other extension's "ExtensionNamespaces" attributes | |
| int[] | $immovableNamespaces | From other extension's "ImmovableNamespaces" attributes |
Definition at line 92 of file NamespaceInfo.php.
| MediaWiki\Title\NamespaceInfo::canHaveTalkPage | ( | LinkTarget | $target | ) |
Can the title have a corresponding talk page?
False for relative section-only links (with getText() === ''), interwiki links (with getInterwiki() !== ''), and pages in NS_SPECIAL.
Definition at line 197 of file NamespaceInfo.php.
| MediaWiki\Title\NamespaceInfo::equals | ( | int | $ns1, |
| int | $ns2 ) |
Returns whether the specified namespaces are the same namespace.
| int | $ns1 | The first namespace index |
| int | $ns2 | The second namespace index |
Definition at line 283 of file NamespaceInfo.php.
| MediaWiki\Title\NamespaceInfo::exists | ( | int | $index | ) |
Returns whether the specified namespace exists.
Definition at line 267 of file NamespaceInfo.php.
Referenced by MediaWiki\Title\NamespaceImportTitleFactory\__construct().
| MediaWiki\Title\NamespaceInfo::getAssociated | ( | int | $index | ) |
Get the associated namespace.
For talk namespaces, returns the subject (non-talk) namespace For subject (non-talk) namespaces, returns the talk namespace
| MWException | if called on a namespace that has no talk pages (e.g., NS_SPECIAL) |
Definition at line 236 of file NamespaceInfo.php.
| MediaWiki\Title\NamespaceInfo::getAssociatedPage | ( | LinkTarget | $target | ) |
| LinkTarget | $target |
| MWException | if $target's namespace doesn't have talk pages (e.g., NS_SPECIAL) |
Definition at line 251 of file NamespaceInfo.php.
| MediaWiki\Title\NamespaceInfo::getCanonicalIndex | ( | string | $name | ) |
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 334 of file NamespaceInfo.php.
| MediaWiki\Title\NamespaceInfo::getCanonicalName | ( | int | $index | ) |
Returns the canonical (English) name for a given index.
Definition at line 323 of file NamespaceInfo.php.
Referenced by MediaWiki\Logging\LogEventsList\getBlockLogWarningBox().
| MediaWiki\Title\NamespaceInfo::getCanonicalNamespaces | ( | ) |
Returns array of all defined namespaces with their canonical (English) names.
Definition at line 305 of file NamespaceInfo.php.
References NS_MAIN.
| MediaWiki\Title\NamespaceInfo::getCategoryLinkType | ( | int | $index | ) |
Returns the link type to be used for categories.
This determines which section of a category page titles in the namespace will appear within.
Definition at line 507 of file NamespaceInfo.php.
References NS_CATEGORY, and NS_FILE.
|
static |
Retrieve the indexes for the namespaces defined by core.
Definition at line 524 of file NamespaceInfo.php.
| MediaWiki\Title\NamespaceInfo::getContentNamespaces | ( | ) |
Get a list of all namespace indices which are considered to contain content.
Definition at line 410 of file NamespaceInfo.php.
References NS_MAIN.
Referenced by MediaWiki\Specials\SpecialRandomPage\__construct().
| MediaWiki\Title\NamespaceInfo::getNamespaceContentModel | ( | int | $index | ) |
Get the default content model for a namespace This does not mean that all pages in that namespace have the model.
Definition at line 495 of file NamespaceInfo.php.
| MediaWiki\Title\NamespaceInfo::getSubject | ( | int | $index | ) |
Get the subject namespace index for a given namespace Special namespaces (NS_MEDIA, NS_SPECIAL) are always the subject.
Definition at line 207 of file NamespaceInfo.php.
| MediaWiki\Title\NamespaceInfo::getSubjectNamespaces | ( | ) |
List all namespace indices which are considered subject, aka not a talk or special namespace.
See also NamespaceInfo::isSubject
Definition at line 427 of file NamespaceInfo.php.
| MediaWiki\Title\NamespaceInfo::getSubjectPage | ( | LinkTarget | $target | ) |
| LinkTarget | $target |
Definition at line 222 of file NamespaceInfo.php.
| MediaWiki\Title\NamespaceInfo::getTalk | ( | int | $index | ) |
Get the talk namespace index for a given namespace.
| MWException | if the given namespace doesn't have an associated talk namespace (e.g. NS_SPECIAL). |
Definition at line 154 of file NamespaceInfo.php.
| MediaWiki\Title\NamespaceInfo::getTalkNamespaces | ( | ) |
List all namespace indices which are considered talks, aka not a subject or special namespace.
See also NamespaceInfo::isTalk
Definition at line 440 of file NamespaceInfo.php.
| MediaWiki\Title\NamespaceInfo::getTalkPage | ( | LinkTarget | $target | ) |
Get a LinkTarget referring to the talk page of $target.
| LinkTarget | $target |
| MWException | if $target doesn't have talk pages, e.g. because it's in NS_SPECIAL, because it's a relative section-only link, or it's an interwiki link. |
Definition at line 170 of file NamespaceInfo.php.
| MediaWiki\Title\NamespaceInfo::getValidNamespaces | ( | ) |
Returns an array of the namespaces (by integer id) that exist on the wiki.
Used primarily by the API in help documentation. The array is sorted numerically and omits negative namespaces.
Definition at line 349 of file NamespaceInfo.php.
| MediaWiki\Title\NamespaceInfo::hasGenderDistinction | ( | int | $index | ) |
Does the namespace (potentially) have different aliases for different genders.
Not all languages make a distinction here.
Definition at line 474 of file NamespaceInfo.php.
| MediaWiki\Title\NamespaceInfo::hasSubpages | ( | int | $index | ) |
Does the namespace allow subpages? Note that this refers to structured handling of subpages, and does not include SpecialPage subpage parameters.
Definition at line 402 of file NamespaceInfo.php.
Referenced by MediaWiki\Title\SubpageImportTitleFactory\__construct().
| MediaWiki\Title\NamespaceInfo::hasTalkNamespace | ( | int | $index | ) |
Does this namespace ever have a talk namespace?
Definition at line 369 of file NamespaceInfo.php.
| MediaWiki\Title\NamespaceInfo::isCapitalized | ( | int | $index | ) |
Is the namespace first-letter capitalized?
Definition at line 450 of file NamespaceInfo.php.
| MediaWiki\Title\NamespaceInfo::isContent | ( | int | $index | ) |
Does this namespace contain content, for the purposes of calculating statistics, etc?
Definition at line 377 of file NamespaceInfo.php.
| MediaWiki\Title\NamespaceInfo::isMovable | ( | int | $index | ) |
Can pages in the given namespace be moved?
Definition at line 117 of file NamespaceInfo.php.
| MediaWiki\Title\NamespaceInfo::isNonincludable | ( | int | $index | ) |
It is not possible to use pages from this namespace as template?
Definition at line 481 of file NamespaceInfo.php.
| MediaWiki\Title\NamespaceInfo::isSubject | ( | int | $index | ) |
Is the given namespace is a subject (non-talk) namespace?
Definition at line 136 of file NamespaceInfo.php.
| MediaWiki\Title\NamespaceInfo::isTalk | ( | int | $index | ) |
Is the given namespace a talk namespace?
Definition at line 143 of file NamespaceInfo.php.
| MediaWiki\Title\NamespaceInfo::isWatchable | ( | int | $index | ) |
Can pages in a namespace be watched?
Definition at line 394 of file NamespaceInfo.php.
| MediaWiki\Title\NamespaceInfo::subjectEquals | ( | int | $ns1, |
| int | $ns2 ) |
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 295 of file NamespaceInfo.php.
| MediaWiki\Title\NamespaceInfo::wantSignatures | ( | int | $index | ) |
Might pages in this namespace require the use of the Signature button on the edit toolbar?
Definition at line 386 of file NamespaceInfo.php.
| const MediaWiki\Title\NamespaceInfo::CANONICAL_NAMES |
Definitions of the NS_ constants are in Defines.php.
Definition at line 49 of file NamespaceInfo.php.
| const MediaWiki\Title\NamespaceInfo::CONSTRUCTOR_OPTIONS |
Definition at line 73 of file NamespaceInfo.php.