MediaWiki REL1_40
|
Represents a page (or page fragment) title within MediaWiki. More...
Inherits MediaWiki\Linker\LinkTarget.
Public Member Functions | |
__construct ( $namespace, $title, $fragment='', $interwiki='') | |
Construct a TitleValue. | |
__toString () | |
Returns a string representation of the title, for logging. | |
createFragmentTarget (string $fragment) | |
Create a new LinkTarget with a different fragment on the same page. | |
getDBkey () | |
Get the main part of the link target, in canonical database form. | |
getFragment () | |
Get the link fragment in text form (i.e. | |
getInterwiki () | |
The interwiki component of this LinkTarget. | |
getNamespace () | |
Get the namespace index. | |
getText () | |
Get the main part of the link target, in text form. | |
hasFragment () | |
Whether the link target has a fragment. | |
inNamespace (int $ns) | |
Convenience function to check if the target is in a given namespace. | |
isExternal () | |
Whether this LinkTarget has an interwiki component. | |
isSameLinkAs (LinkTarget $other) | |
Check whether the given LinkTarget refers to the same target as this LinkTarget. | |
Static Public Member Functions | |
static | assertValidSpec ( $namespace, $title, $fragment='', $interwiki='') |
Assert that the given parameters could be used to construct a TitleValue object. | |
static | castPageToLinkTarget (?PageReference $page) |
Casts a PageReference to a LinkTarget. | |
static | newFromPage (PageReference $page) |
Create a TitleValue from a local PageReference. | |
static | tryNew ( $namespace, $title, $fragment='', $interwiki='') |
Constructs a TitleValue, or returns null if the parameters are not valid. | |
Public Attributes | |
string | $prefixedText = null |
Text form including namespace/interwiki, initialised on demand. | |
Represents a page (or page fragment) title within MediaWiki.
Definition at line 40 of file TitleValue.php.
TitleValue::__construct | ( | $namespace, | |
$title, | |||
$fragment = '', | |||
$interwiki = '' ) |
Construct a TitleValue.
int | $namespace | The namespace ID. This is not validated. |
string | $title | The page title in either DBkey or text form. No normalization is applied beyond underscore/space conversion. |
string | $fragment | The fragment title. Use '' to represent the whole page. No validation or normalization is applied. |
string | $interwiki | The interwiki component. No validation or normalization is applied. |
InvalidArgumentException |
Definition at line 143 of file TitleValue.php.
References $title.
TitleValue::__toString | ( | ) |
Returns a string representation of the title, for logging.
This is purely informative and must not be used programmatically. Use the appropriate TitleFormatter to generate the correct string representation for a given use.
Implements MediaWiki\Linker\LinkTarget.
Definition at line 243 of file TitleValue.php.
|
static |
Assert that the given parameters could be used to construct a TitleValue object.
Performs basic syntax and consistency checks. Does not perform full validation, use TitleParser::makeTitleValueSafe() for that.
int | $namespace | |
string | $title | |
string | $fragment | |
string | $interwiki |
InvalidArgumentException | if the combination of parameters is not valid for constructing a TitleValue. |
Definition at line 165 of file TitleValue.php.
|
static |
Casts a PageReference to a LinkTarget.
If $page is null, null is returned. If $page is also an instance of LinkTarget, $page is returned unchanged.
PageReference | null | $page |
Definition at line 118 of file TitleValue.php.
TitleValue::createFragmentTarget | ( | string | $fragment | ) |
Create a new LinkTarget with a different fragment on the same page.
It is expected that the same type of object will be returned, but the only requirement is that it is a LinkTarget.
string | $fragment | The fragment override, or "" to remove it. |
Implements MediaWiki\Linker\LinkTarget.
Definition at line 218 of file TitleValue.php.
TitleValue::getDBkey | ( | ) |
Get the main part of the link target, in canonical database form.
The main part is the link target without namespace prefix or hash fragment. The database form means that spaces become underscores, this is also used for URLs.
Implements MediaWiki\Linker\LinkTarget.
Definition at line 210 of file TitleValue.php.
Referenced by newFromPage().
TitleValue::getFragment | ( | ) |
Get the link fragment in text form (i.e.
the bit after the hash #
).
Implements MediaWiki\Linker\LinkTarget.
Definition at line 202 of file TitleValue.php.
TitleValue::getInterwiki | ( | ) |
The interwiki component of this LinkTarget.
Implements MediaWiki\Linker\LinkTarget.
Definition at line 231 of file TitleValue.php.
TitleValue::getNamespace | ( | ) |
Get the namespace index.
Implements MediaWiki\Linker\LinkTarget.
Definition at line 194 of file TitleValue.php.
Referenced by newFromPage().
TitleValue::getText | ( | ) |
Get the main part of the link target, in text form.
The main part is the link target without namespace prefix or hash fragment. The text form is used for display purposes.
This is computed from the DB key by replacing any underscores with spaces.
Implements MediaWiki\Linker\LinkTarget.
Definition at line 214 of file TitleValue.php.
TitleValue::hasFragment | ( | ) |
Whether the link target has a fragment.
Implements MediaWiki\Linker\LinkTarget.
Definition at line 206 of file TitleValue.php.
TitleValue::inNamespace | ( | int | $ns | ) |
Convenience function to check if the target is in a given namespace.
int | $ns |
Implements MediaWiki\Linker\LinkTarget.
Definition at line 198 of file TitleValue.php.
TitleValue::isExternal | ( | ) |
Whether this LinkTarget has an interwiki component.
Implements MediaWiki\Linker\LinkTarget.
Definition at line 227 of file TitleValue.php.
TitleValue::isSameLinkAs | ( | LinkTarget | $other | ) |
Check whether the given LinkTarget refers to the same target as this LinkTarget.
Two link targets are considered the same if they have the same interwiki prefix, are in the same namespace, have the same main part, and the same fragment.
LinkTarget | $other |
Implements MediaWiki\Linker\LinkTarget.
Definition at line 257 of file TitleValue.php.
|
static |
Create a TitleValue from a local PageReference.
PageReference | $page |
Definition at line 103 of file TitleValue.php.
References getDBkey(), and getNamespace().
|
static |
Constructs a TitleValue, or returns null if the parameters are not valid.
int | $namespace | The namespace ID. This is not validated. |
string | $title | The page title in either DBkey or text form. No normalization is applied beyond underscore/space conversion. |
string | $fragment | The fragment title. Use '' to represent the whole page. No validation or normalization is applied. |
string | $interwiki | The interwiki component. No validation or normalization is applied. |
InvalidArgumentException |
Definition at line 80 of file TitleValue.php.
References $title.
string TitleValue::$prefixedText = null |
Text form including namespace/interwiki, initialised on demand.
Only public to share cache with TitleFormatter
Definition at line 62 of file TitleValue.php.