MediaWiki  master
MediaWiki\Linker\LinkTarget Interface Reference
Inheritance 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. More...
 
 createFragmentTarget (string $fragment)
 Create a new LinkTarget with a different fragment on the same page. More...
 
 getDBkey ()
 Get the main part of the link target, in canonical database form. More...
 
 getFragment ()
 Get the link fragment in text form (i.e. More...
 
 getInterwiki ()
 The interwiki component of this LinkTarget. More...
 
 getNamespace ()
 Get the namespace index. More...
 
 getText ()
 Get the main part of the link target, in text form. More...
 
 hasFragment ()
 Whether the link target has a fragment. More...
 
 inNamespace (int $ns)
 Convenience function to check if the target is in a given namespace. More...
 
 isExternal ()
 Whether this LinkTarget has an interwiki component. More...
 
 isSameLinkAs (LinkTarget $other)
 Check whether the given LinkTarget refers to the same target as this LinkTarget. More...
 

Detailed Description

Since
1.27

Definition at line 26 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 TitleValue, and Title.

◆ 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 TitleValue, and Title.

◆ getDBkey()

◆ 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 TitleValue, and Title.

Referenced by MediaWiki\CommentFormatter\CommentParser\addPageLink(), WikiPage\insertRedirectEntry(), Title\isSameLinkAs(), TitleValue\isSameLinkAs(), MediaWiki\CommentFormatter\CommentParser\makeSectionLink(), and Title\newFromLinkTarget().

◆ getInterwiki()

MediaWiki\Linker\LinkTarget::getInterwiki ( )

◆ getNamespace()

◆ 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 TitleValue, and Title.

Referenced by NamespaceInfo\canHaveTalkPage(), NamespaceInfo\getAssociatedPage(), NamespaceInfo\getTalkPage(), Parser\makeImage(), and Title\newFromLinkTarget().

◆ hasFragment()

MediaWiki\Linker\LinkTarget::hasFragment ( )

Whether the link target has a fragment.

Since
1.27
Returns
bool

Implemented in TitleValue, and Title.

Referenced by MediaWiki\Linker\LinkRenderer\getLinkText().

◆ 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 TitleValue, and Title.

◆ isExternal()

MediaWiki\Linker\LinkTarget::isExternal ( )

Whether this LinkTarget has an interwiki component.

Since
1.27
Returns
bool

Implemented in TitleValue, and Title.

Referenced by ParserOutput\addLink(), MediaWiki\CommentFormatter\CommentParser\addPageLink(), and MediaWiki\CommentFormatter\CommentParser\makeSectionLink().

◆ isSameLinkAs()

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

Since
1.36
Parameters
LinkTarget$other
Returns
bool

Implemented in TitleValue, and Title.

Referenced by Parser\fetchFileAndTitle().


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