MediaWiki REL1_39
|
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 (ServiceOptions $options, HookContainer $hookContainer) | |
canHaveTalkPage (LinkTarget $target) | |
Can the title have a corresponding talk page? | |
equals ( $ns1, $ns2) | |
Returns whether the specified namespaces are the same namespace. | |
exists ( $index) | |
Returns whether the specified namespace exists. | |
getAssociated ( $index) | |
Get the associated namespace. | |
getAssociatedPage (LinkTarget $target) | |
getCanonicalIndex ( $name) | |
Returns the index for a given canonical name, or NULL The input must be converted to lower case first. | |
getCanonicalName ( $index) | |
Returns the canonical (English) name for a given index. | |
getCanonicalNamespaces () | |
Returns array of all defined namespaces with their canonical (English) names. | |
getCategoryLinkType ( $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 ( $index) | |
Get the default content model for a namespace This does not mean that all pages in that namespace have the model. | |
getRestrictionLevels ( $index, User $user=null) | |
Determine which restriction levels it makes sense to use in a namespace, optionally filtered by a user's rights. | |
getSubject ( $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 ( $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 ( $index) | |
Does the namespace (potentially) have different aliases for different genders. | |
hasSubpages ( $index) | |
Does the namespace allow subpages? Note that this refers to structured handling of subpages, and does not include SpecialPage subpage parameters. | |
hasTalkNamespace ( $index) | |
Does this namespace ever have a talk namespace? | |
isCapitalized ( $index) | |
Is the namespace first-letter capitalized? | |
isContent ( $index) | |
Does this namespace contain content, for the purposes of calculating statistics, etc? | |
isMovable ( $index) | |
Can pages in the given namespace be moved? | |
isNonincludable ( $index) | |
It is not possible to use pages from this namespace as template? | |
isSubject ( $index) | |
Is the given namespace is a subject (non-talk) namespace? | |
isTalk ( $index) | |
Is the given namespace a talk namespace? | |
isWatchable ( $index) | |
Can pages in a namespace be watched? | |
subjectEquals ( $ns1, $ns2) | |
Returns whether the specified namespaces share the same subject. | |
wantSignatures ( $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 36 of file NamespaceInfo.php.
NamespaceInfo::__construct | ( | ServiceOptions | $options, |
HookContainer | $hookContainer ) |
ServiceOptions | $options | |
HookContainer | $hookContainer |
Definition at line 105 of file NamespaceInfo.php.
References MediaWiki\Config\ServiceOptions\assertRequiredOptions().
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.
LinkTarget | $target |
Definition at line 252 of file NamespaceInfo.php.
References MediaWiki\Linker\LinkTarget\getInterwiki(), MediaWiki\Linker\LinkTarget\getNamespace(), MediaWiki\Linker\LinkTarget\getText(), and NS_MAIN.
NamespaceInfo::equals | ( | $ns1, | |
$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 357 of file NamespaceInfo.php.
NamespaceInfo::exists | ( | $index | ) |
Returns whether the specified namespace exists.
int | $index |
Definition at line 339 of file NamespaceInfo.php.
Referenced by NamespaceImportTitleFactory\__construct().
NamespaceInfo::getAssociated | ( | $index | ) |
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 |
MWException | if called on a namespace that has no talk pages (e.g., NS_SPECIAL) |
Definition at line 304 of file NamespaceInfo.php.
NamespaceInfo::getAssociatedPage | ( | LinkTarget | $target | ) |
LinkTarget | $target |
MWException | if $target's namespace doesn't have talk pages (e.g., NS_SPECIAL) |
Definition at line 319 of file NamespaceInfo.php.
NamespaceInfo::getCanonicalIndex | ( | $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 413 of file NamespaceInfo.php.
NamespaceInfo::getCanonicalName | ( | $index | ) |
Returns the canonical (English) name for a given index.
int | $index | Namespace index |
Definition at line 401 of file NamespaceInfo.php.
NamespaceInfo::getCanonicalNamespaces | ( | ) |
Returns array of all defined namespaces with their canonical (English) names.
Definition at line 381 of file NamespaceInfo.php.
References NS_MAIN.
NamespaceInfo::getCategoryLinkType | ( | $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.
int | $index | Namespace index |
Definition at line 634 of file NamespaceInfo.php.
References NS_CATEGORY, and NS_FILE.
|
static |
Retrieve the indexes for the namespaces defined by core.
Definition at line 653 of file NamespaceInfo.php.
NamespaceInfo::getContentNamespaces | ( | ) |
Get a list of all namespace indices which are considered to contain content.
Definition at line 506 of file NamespaceInfo.php.
References NS_MAIN.
NamespaceInfo::getNamespaceContentModel | ( | $index | ) |
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 602 of file NamespaceInfo.php.
NamespaceInfo::getRestrictionLevels | ( | $index, | |
User | $user = null ) |
Determine which restriction levels it makes sense to use in a namespace, optionally filtered by a user's rights.
Definition at line 615 of file NamespaceInfo.php.
References wfDeprecated().
NamespaceInfo::getSubject | ( | $index | ) |
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 271 of file NamespaceInfo.php.
References NS_MAIN.
NamespaceInfo::getSubjectNamespaces | ( | ) |
List all namespace indices which are considered subject, aka not a talk or special namespace.
See also NamespaceInfo::isSubject
Definition at line 524 of file NamespaceInfo.php.
NamespaceInfo::getSubjectPage | ( | LinkTarget | $target | ) |
LinkTarget | $target |
Definition at line 288 of file NamespaceInfo.php.
NamespaceInfo::getTalk | ( | $index | ) |
Get the talk namespace index for a given namespace.
int | $index | Namespace index |
MWException | if the given namespace doesn't have an associated talk namespace (e.g. NS_SPECIAL). |
Definition at line 206 of file NamespaceInfo.php.
References isTalk().
NamespaceInfo::getTalkNamespaces | ( | ) |
List all namespace indices which are considered talks, aka not a subject or special namespace.
See also NamespaceInfo::isTalk
Definition at line 537 of file NamespaceInfo.php.
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 224 of file NamespaceInfo.php.
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 432 of file NamespaceInfo.php.
NamespaceInfo::hasGenderDistinction | ( | $index | ) |
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 577 of file NamespaceInfo.php.
References NS_USER, and NS_USER_TALK.
NamespaceInfo::hasSubpages | ( | $index | ) |
Does the namespace allow subpages? Note that this refers to structured handling of subpages, and does not include SpecialPage subpage parameters.
int | $index | Index to check |
Definition at line 498 of file NamespaceInfo.php.
Referenced by SubpageImportTitleFactory\__construct().
NamespaceInfo::hasTalkNamespace | ( | $index | ) |
Does this namespace ever have a talk namespace?
int | $index | Namespace ID |
Definition at line 453 of file NamespaceInfo.php.
References NS_MAIN.
NamespaceInfo::isCapitalized | ( | $index | ) |
Is the namespace first-letter capitalized?
int | $index | Index to check |
Definition at line 550 of file NamespaceInfo.php.
NamespaceInfo::isContent | ( | $index | ) |
Does this namespace contain content, for the purposes of calculating statistics, etc?
int | $index | Index to check |
Definition at line 464 of file NamespaceInfo.php.
References NS_MAIN.
NamespaceInfo::isMovable | ( | $index | ) |
Can pages in the given namespace be moved?
int | $index | Namespace index |
Definition at line 161 of file NamespaceInfo.php.
References NS_MAIN.
NamespaceInfo::isNonincludable | ( | $index | ) |
It is not possible to use pages from this namespace as template?
int | $index | Index to check |
Definition at line 587 of file NamespaceInfo.php.
NamespaceInfo::isSubject | ( | $index | ) |
Is the given namespace is a subject (non-talk) namespace?
int | $index | Namespace index |
Definition at line 181 of file NamespaceInfo.php.
References isTalk().
Referenced by CoreMagicVariables\expand().
NamespaceInfo::isTalk | ( | $index | ) |
Is the given namespace a talk namespace?
int | $index | Namespace index |
Definition at line 191 of file NamespaceInfo.php.
References NS_MAIN.
Referenced by getTalk(), and isSubject().
NamespaceInfo::isWatchable | ( | $index | ) |
Can pages in a namespace be watched?
int | $index |
Definition at line 487 of file NamespaceInfo.php.
References NS_MAIN.
NamespaceInfo::subjectEquals | ( | $ns1, | |
$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 371 of file NamespaceInfo.php.
NamespaceInfo::wantSignatures | ( | $index | ) |
Might pages in this namespace require the use of the Signature button on the edit toolbar?
int | $index | Index to check |
Definition at line 476 of file NamespaceInfo.php.
const NamespaceInfo::CANONICAL_NAMES |
Definitions of the NS_ constants are in Defines.php.
Definition at line 65 of file NamespaceInfo.php.
const NamespaceInfo::CONSTRUCTOR_OPTIONS |
Definition at line 89 of file NamespaceInfo.php.