Parsoid
A bidirectional parser between wikitext and HTML5
Loading...
Searching...
No Matches
Wikimedia\Parsoid\Core\LinkTarget Interface Reference

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

+ Inheritance diagram for Wikimedia\Parsoid\Core\LinkTarget:

Public Member Functions

 getNamespace ()
 Get the namespace index.
 
 inNamespace (int $ns)
 Convenience function to check if the target is in a given namespace.
 
 getFragment ()
 Get the link fragment in text form (i.e.
 
 hasFragment ()
 Whether the link target has a fragment.
 
 getDBkey ()
 Get the main part of the link target, in canonical database form.
 
 getText ()
 Get the main part of the link target, in text form.
 
 createFragmentTarget (string $fragment)
 Create a new LinkTarget with a different fragment on the same page.
 
 isExternal ()
 Whether this LinkTarget has an interwiki component.
 
 getInterwiki ()
 The interwiki component of this LinkTarget.
 
 isSameLinkAs (LinkTarget $other)
 Check whether the given LinkTarget refers to the same target as this LinkTarget.
 
 __toString ()
 Return an informative human-readable representation of the link target, for use in logging and debugging.
 

Detailed Description

Represents the target of a wiki link.

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

Member Function Documentation

◆ __toString()

Wikimedia\Parsoid\Core\LinkTarget::__toString ( )

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

Returns
string

◆ createFragmentTarget()

Wikimedia\Parsoid\Core\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.

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

Implemented in Wikimedia\Parsoid\Utils\Title, and Wikimedia\Parsoid\Utils\TitleValue.

◆ getDBkey()

Wikimedia\Parsoid\Core\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.

Returns
string

Implemented in Wikimedia\Parsoid\Utils\Title, and Wikimedia\Parsoid\Utils\TitleValue.

◆ getFragment()

Wikimedia\Parsoid\Core\LinkTarget::getFragment ( )

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

the bit after the hash #).

Returns
string link fragment

Implemented in Wikimedia\Parsoid\Utils\Title, and Wikimedia\Parsoid\Utils\TitleValue.

◆ getInterwiki()

Wikimedia\Parsoid\Core\LinkTarget::getInterwiki ( )

The interwiki component of this LinkTarget.

Returns
string

Implemented in Wikimedia\Parsoid\Utils\Title, and Wikimedia\Parsoid\Utils\TitleValue.

◆ getNamespace()

Wikimedia\Parsoid\Core\LinkTarget::getNamespace ( )

Get the namespace index.

Returns
int Namespace index

Implemented in Wikimedia\Parsoid\Utils\Title, and Wikimedia\Parsoid\Utils\TitleValue.

◆ getText()

Wikimedia\Parsoid\Core\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.
Returns
string

◆ hasFragment()

Wikimedia\Parsoid\Core\LinkTarget::hasFragment ( )

Whether the link target has a fragment.

Returns
bool

◆ inNamespace()

Wikimedia\Parsoid\Core\LinkTarget::inNamespace ( int $ns)

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

Parameters
int$ns
Returns
bool

◆ isExternal()

Wikimedia\Parsoid\Core\LinkTarget::isExternal ( )

Whether this LinkTarget has an interwiki component.

Returns
bool

◆ isSameLinkAs()

Wikimedia\Parsoid\Core\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.

Parameters
LinkTarget$other
Returns
bool

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