MediaWiki REL1_35
MediaWiki\Linker\LinkRenderer Class Reference

Class that generates HTML links for pages. More...

Collaboration diagram for MediaWiki\Linker\LinkRenderer:

Public Member Functions

 __construct (TitleFormatter $titleFormatter, LinkCache $linkCache, NamespaceInfo $nsInfo, SpecialPageFactory $specialPageFactory, HookContainer $hookContainer)
 
 getExpandURLs ()
 
 getForceArticlePath ()
 
 getLinkClasses (LinkTarget $target)
 Return the CSS classes of a known link.
 
 getStubThreshold ()
 
 makeBrokenLink (LinkTarget $target, $text=null, array $extraAttribs=[], array $query=[])
 
 makeKnownLink (LinkTarget $target, $text=null, array $extraAttribs=[], array $query=[])
 
 makeLink (LinkTarget $target, $text=null, array $extraAttribs=[], array $query=[])
 
 makePreloadedLink (LinkTarget $target, $text=null, $classes='', array $extraAttribs=[], array $query=[])
 If you have already looked up the proper CSS classes using LinkRenderer::getLinkClasses() or some other method, use this to avoid looking it up again.
 
 normalizeTarget (LinkTarget $target)
 Normalizes the provided target.
 
 setExpandURLs ( $expand)
 
 setForceArticlePath ( $force)
 
 setRunLegacyBeginHook ( $run)
 
 setStubThreshold ( $threshold)
 

Private Member Functions

 buildAElement (LinkTarget $target, $text, array $attribs, $isKnown)
 Builds the final element.
 
 getLegacyOptions ( $isKnown)
 Get the options in the legacy format.
 
 getLinkText (LinkTarget $target)
 
 getLinkURL (LinkTarget $target, array $query=[])
 
 mergeAttribs ( $defaults, $attribs)
 Merges two sets of attributes.
 
 runBeginHook (LinkTarget $target, &$text, &$extraAttribs, &$query, $isKnown)
 
 runLegacyBeginHook (LinkTarget $target, &$text, &$extraAttribs, &$query, $isKnown)
 

Private Attributes

string bool int $expandUrls = false
 A PROTO_* constant or false.
 
bool $forceArticlePath = false
 Whether to force the pretty article path.
 
HookContainer $hookContainer
 
HookRunner $hookRunner
 
LinkCache $linkCache
 
NamespaceInfo $nsInfo
 
bool $runLegacyBeginHook = true
 Whether to run the legacy Linker hooks.
 
SpecialPageFactory $specialPageFactory
 
int $stubThreshold = 0
 
TitleFormatter $titleFormatter
 

Detailed Description

Class that generates HTML links for pages.

See also
https://www.mediawiki.org/wiki/Manual:LinkRenderer
Since
1.28

Definition at line 43 of file LinkRenderer.php.

Constructor & Destructor Documentation

◆ __construct()

Member Function Documentation

◆ buildAElement()

MediaWiki\Linker\LinkRenderer::buildAElement ( LinkTarget  $target,
  $text,
array  $attribs,
  $isKnown 
)
private

Builds the final element.

Parameters
LinkTarget$target
string | HtmlArmor$text
array$attribs
bool$isKnown
Returns
null|string

Definition at line 393 of file LinkRenderer.php.

References $title, and MediaWiki\Linker\LinkRenderer\getLegacyOptions().

Referenced by MediaWiki\Linker\LinkRenderer\makeBrokenLink(), and MediaWiki\Linker\LinkRenderer\makePreloadedLink().

◆ getExpandURLs()

MediaWiki\Linker\LinkRenderer::getExpandURLs ( )
Returns
string|bool|int a PROTO_* constant or false

Definition at line 144 of file LinkRenderer.php.

References MediaWiki\Linker\LinkRenderer\$expandUrls.

◆ getForceArticlePath()

MediaWiki\Linker\LinkRenderer::getForceArticlePath ( )
Returns
bool

Definition at line 130 of file LinkRenderer.php.

References MediaWiki\Linker\LinkRenderer\$forceArticlePath.

◆ getLegacyOptions()

MediaWiki\Linker\LinkRenderer::getLegacyOptions (   $isKnown)
private

Get the options in the legacy format.

Parameters
bool$isKnownWhether the link is known or broken
Returns
array

Definition at line 193 of file LinkRenderer.php.

References MediaWiki\Linker\LinkRenderer\$stubThreshold, PROTO_HTTP, and PROTO_HTTPS.

Referenced by MediaWiki\Linker\LinkRenderer\buildAElement(), and MediaWiki\Linker\LinkRenderer\runLegacyBeginHook().

◆ getLinkClasses()

MediaWiki\Linker\LinkRenderer::getLinkClasses ( LinkTarget  $target)

Return the CSS classes of a known link.

Parameters
LinkTarget$target
Returns
string CSS class

Definition at line 503 of file LinkRenderer.php.

References MediaWiki\Linker\LinkTarget\getNamespace().

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

◆ getLinkText()

MediaWiki\Linker\LinkRenderer::getLinkText ( LinkTarget  $target)
private
Parameters
LinkTarget$target
Returns
string non-escaped text

Definition at line 422 of file LinkRenderer.php.

References MediaWiki\Linker\LinkTarget\getFragment(), and MediaWiki\Linker\LinkTarget\hasFragment().

Referenced by MediaWiki\Linker\LinkRenderer\makeBrokenLink(), and MediaWiki\Linker\LinkRenderer\makePreloadedLink().

◆ getLinkURL()

MediaWiki\Linker\LinkRenderer::getLinkURL ( LinkTarget  $target,
array  $query = [] 
)
private

◆ getStubThreshold()

MediaWiki\Linker\LinkRenderer::getStubThreshold ( )
Returns
int

Definition at line 158 of file LinkRenderer.php.

References MediaWiki\Linker\LinkRenderer\$stubThreshold.

◆ makeBrokenLink()

◆ makeKnownLink()

◆ makeLink()

MediaWiki\Linker\LinkRenderer::makeLink ( LinkTarget  $target,
  $text = null,
array  $extraAttribs = [],
array  $query = [] 
)
Parameters
LinkTarget$target
string | HtmlArmor | null$text
array$extraAttribs
array$query
Returns
string HTML

Definition at line 176 of file LinkRenderer.php.

References $title, MediaWiki\Linker\LinkRenderer\makeBrokenLink(), and MediaWiki\Linker\LinkRenderer\makeKnownLink().

Referenced by ProtectedPagesPager\formatValue(), ProtectLogFormatter\getActionLinks(), Article\getRedirectHeaderHtml(), and BlockListPager\getRestrictionListHTML().

◆ makePreloadedLink()

MediaWiki\Linker\LinkRenderer::makePreloadedLink ( LinkTarget  $target,
  $text = null,
  $classes = '',
array  $extraAttribs = [],
array  $query = [] 
)

If you have already looked up the proper CSS classes using LinkRenderer::getLinkClasses() or some other method, use this to avoid looking it up again.

Parameters
LinkTarget$target
string | HtmlArmor | null$text
string$classesCSS classes to add
array$extraAttribs
array$query
Returns
string

Definition at line 279 of file LinkRenderer.php.

References MediaWiki\Linker\LinkRenderer\buildAElement(), MediaWiki\Linker\LinkRenderer\getLinkText(), MediaWiki\Linker\LinkRenderer\getLinkURL(), MediaWiki\Linker\LinkRenderer\mergeAttribs(), MediaWiki\Linker\LinkRenderer\normalizeTarget(), and MediaWiki\Linker\LinkRenderer\runBeginHook().

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

◆ mergeAttribs()

MediaWiki\Linker\LinkRenderer::mergeAttribs (   $defaults,
  $attribs 
)
private

Merges two sets of attributes.

Parameters
array$defaults
array$attribs
Returns
array

Definition at line 480 of file LinkRenderer.php.

Referenced by MediaWiki\Linker\LinkRenderer\makeBrokenLink(), and MediaWiki\Linker\LinkRenderer\makePreloadedLink().

◆ normalizeTarget()

◆ runBeginHook()

MediaWiki\Linker\LinkRenderer::runBeginHook ( LinkTarget  $target,
$text,
$extraAttribs,
$query,
  $isKnown 
)
private

◆ runLegacyBeginHook()

◆ setExpandURLs()

MediaWiki\Linker\LinkRenderer::setExpandURLs (   $expand)
Parameters
string | bool | int$expandA PROTO_* constant or false

Definition at line 137 of file LinkRenderer.php.

◆ setForceArticlePath()

MediaWiki\Linker\LinkRenderer::setForceArticlePath (   $force)
Parameters
bool$force

Definition at line 123 of file LinkRenderer.php.

◆ setRunLegacyBeginHook()

MediaWiki\Linker\LinkRenderer::setRunLegacyBeginHook (   $run)
Parameters
bool$run

Definition at line 165 of file LinkRenderer.php.

References MediaWiki\Linker\LinkRenderer\runLegacyBeginHook().

◆ setStubThreshold()

MediaWiki\Linker\LinkRenderer::setStubThreshold (   $threshold)
Parameters
int$threshold

Definition at line 151 of file LinkRenderer.php.

Member Data Documentation

◆ $expandUrls

string bool int MediaWiki\Linker\LinkRenderer::$expandUrls = false
private

A PROTO_* constant or false.

Definition at line 57 of file LinkRenderer.php.

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

◆ $forceArticlePath

bool MediaWiki\Linker\LinkRenderer::$forceArticlePath = false
private

Whether to force the pretty article path.

Definition at line 50 of file LinkRenderer.php.

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

◆ $hookContainer

HookContainer MediaWiki\Linker\LinkRenderer::$hookContainer
private

Definition at line 87 of file LinkRenderer.php.

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

◆ $hookRunner

HookRunner MediaWiki\Linker\LinkRenderer::$hookRunner
private

Definition at line 90 of file LinkRenderer.php.

◆ $linkCache

LinkCache MediaWiki\Linker\LinkRenderer::$linkCache
private

Definition at line 72 of file LinkRenderer.php.

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

◆ $nsInfo

NamespaceInfo MediaWiki\Linker\LinkRenderer::$nsInfo
private

Definition at line 77 of file LinkRenderer.php.

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

◆ $runLegacyBeginHook

bool MediaWiki\Linker\LinkRenderer::$runLegacyBeginHook = true
private

Whether to run the legacy Linker hooks.

Definition at line 84 of file LinkRenderer.php.

◆ $specialPageFactory

SpecialPageFactory MediaWiki\Linker\LinkRenderer::$specialPageFactory
private

Definition at line 95 of file LinkRenderer.php.

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

◆ $stubThreshold

int MediaWiki\Linker\LinkRenderer::$stubThreshold = 0
private

◆ $titleFormatter

TitleFormatter MediaWiki\Linker\LinkRenderer::$titleFormatter
private

Definition at line 67 of file LinkRenderer.php.

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


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