MediaWiki master
MediaWiki\Linker\LinkTarget Interface Reference

Represents the target of a wiki link. More...

Inherits Stringable, and ParsoidLinkTarget.

Inherited by MediaWiki\Title\Title, and MediaWiki\Title\TitleValue.

Collaboration diagram for MediaWiki\Linker\LinkTarget:

Public Member Functions

 __toString ()
 Return an informative human-readable representation of the link target, for use in logging and debugging.
 
 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 (ParsoidLinkTarget $other)
 Check whether the given LinkTarget refers to the same target as this LinkTarget.
 

Detailed Description

Represents the target of a wiki link.

See also
https://www.mediawiki.org/wiki/Manual:Modeling_pages
Since
1.27

Definition at line 33 of file LinkTarget.php.

Member Function Documentation

◆ __toString()

MediaWiki\Linker\LinkTarget::__toString ( )

Return an informative human-readable representation of the link target, for use in logging and debugging.

Returns
string

Implemented in MediaWiki\Title\Title, and MediaWiki\Title\TitleValue.

◆ createFragmentTarget()

MediaWiki\Linker\LinkTarget::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.

Since
1.27
Parameters
string$fragmentThe fragment override, or "" to remove it.
Returns
LinkTarget

Implemented in MediaWiki\Title\Title, and MediaWiki\Title\TitleValue.

◆ getDBkey()

MediaWiki\Linker\LinkTarget::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.

Since
1.27
Returns
string

Implemented in MediaWiki\Title\Title, and MediaWiki\Title\TitleValue.

Referenced by MediaWiki\Parser\Parser\getTemplateDom(), MediaWiki\Linker\Linker\makeImageLink(), and MediaWiki\Linker\Linker\makeThumbLink2().

◆ getFragment()

MediaWiki\Linker\LinkTarget::getFragment ( )

Get the link fragment in text form (i.e.

the bit after the hash #).

Since
1.27
Returns
string link fragment

Implemented in MediaWiki\Title\Title, and MediaWiki\Title\TitleValue.

◆ getInterwiki()

MediaWiki\Linker\LinkTarget::getInterwiki ( )

The interwiki component of this LinkTarget.

Since
1.27
Returns
string

Implemented in MediaWiki\Title\Title, and MediaWiki\Title\TitleValue.

◆ getNamespace()

MediaWiki\Linker\LinkTarget::getNamespace ( )

Get the namespace index.

Since
1.27
Returns
int Namespace index

Implemented in MediaWiki\Title\Title, and MediaWiki\Title\TitleValue.

Referenced by MediaWiki\Title\NamespaceInfo\canHaveTalkPage(), and MediaWiki\Parser\Parser\getTemplateDom().

◆ getText()

MediaWiki\Linker\LinkTarget::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.

Note
To get a title string that includes the namespace and/or fragment, use a TitleFormatter.
Since
1.27
Returns
string

Implemented in MediaWiki\Title\Title.

Referenced by MediaWiki\Title\NamespaceInfo\canHaveTalkPage(), MediaWiki\Parser\Parser\makeImage(), and MediaWiki\Linker\Linker\makeMediaLinkFile().

◆ hasFragment()

MediaWiki\Linker\LinkTarget::hasFragment ( )

Whether the link target has a fragment.

Since
1.27
Returns
bool

Referenced by MediaWiki\Parser\CoreParserFunctions\displaytitle().

◆ inNamespace()

MediaWiki\Linker\LinkTarget::inNamespace ( int $ns)

Convenience function to check if the target is in a given namespace.

Since
1.27
Parameters
int$ns
Returns
bool

Implemented in MediaWiki\Title\Title.

◆ isExternal()

MediaWiki\Linker\LinkTarget::isExternal ( )

◆ isSameLinkAs()

MediaWiki\Linker\LinkTarget::isSameLinkAs ( ParsoidLinkTarget $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.

Since
1.36
Parameters
ParsoidLinkTarget$other
Returns
bool

Referenced by MediaWiki\Parser\Parser\fetchFileAndTitle().


The documentation for this interface was generated from the following file: