MediaWiki master
|
Represents the target of a wiki link. More...
Inherits Stringable, and 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. | |
Public Member Functions inherited from MediaWiki\Linker\LinkTarget | |
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 (ParsoidLinkTarget $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 | newFromLinkTarget (ParsoidLinkTarget $linkTarget) |
Create a TitleValue from 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 the target of a wiki link.
Definition at line 47 of file TitleValue.php.
MediaWiki\Title\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. |
Definition at line 167 of file TitleValue.php.
MediaWiki\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 251 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 189 of file TitleValue.php.
References NS_MAIN.
Referenced by MediaWiki\Title\MediaWikiTitleCodec\splitTitleString().
|
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 143 of file TitleValue.php.
MediaWiki\Title\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 230 of file TitleValue.php.
MediaWiki\Title\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 226 of file TitleValue.php.
MediaWiki\Title\TitleValue::getFragment | ( | ) |
Get the link fragment in text form (i.e.
the bit after the hash #
).
Implements MediaWiki\Linker\LinkTarget.
Definition at line 222 of file TitleValue.php.
MediaWiki\Title\TitleValue::getInterwiki | ( | ) |
The interwiki component of this LinkTarget.
Implements MediaWiki\Linker\LinkTarget.
Definition at line 239 of file TitleValue.php.
MediaWiki\Title\TitleValue::getNamespace | ( | ) |
Get the namespace index.
Implements MediaWiki\Linker\LinkTarget.
Definition at line 218 of file TitleValue.php.
|
static |
Create a TitleValue from a LinkTarget.
ParsoidLinkTarget | $linkTarget |
Definition at line 120 of file TitleValue.php.
|
static |
Create a TitleValue from a local PageReference.
PageReference | $page |
Definition at line 110 of file TitleValue.php.
|
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. |
Definition at line 87 of file TitleValue.php.
string MediaWiki\Title\TitleValue::$prefixedText = null |
Text form including namespace/interwiki, initialised on demand.
Only public to share cache with TitleFormatter
Definition at line 70 of file TitleValue.php.