MediaWiki  1.28.0
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)
 
 getExpandURLs ()
 
 getForceArticlePath ()
 
 getLinkClasses (LinkTarget $target)
 Return the CSS classes of a known link. More...
 
 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. More...
 
 setExpandURLs ($expand)
 
 setForceArticlePath ($force)
 
 setRunLegacyBeginHook ($run)
 
 setStubThreshold ($threshold)
 

Private Member Functions

 buildAElement (LinkTarget $target, $text, array $attribs, $isKnown)
 Builds the final element. More...
 
 getLegacyOptions ($isKnown)
 Get the options in the legacy format. More...
 
 getLinkText (LinkTarget $target)
 
 getLinkURL (LinkTarget $target, array $query=[])
 
 mergeAttribs ($defaults, $attribs)
 Merges two sets of attributes. More...
 
 normalizeTarget (LinkTarget $target)
 Normalizes the provided target. More...
 
 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. More...
 
bool $forceArticlePath = false
 Whether to force the pretty article path. More...
 
LinkCache $linkCache
 
bool $runLegacyBeginHook = true
 Whether to run the legacy Linker hooks. More...
 
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 42 of file LinkRenderer.php.

Constructor & Destructor Documentation

MediaWiki\Linker\LinkRenderer::__construct ( TitleFormatter  $titleFormatter,
LinkCache  $linkCache 
)
Parameters
TitleFormatter$titleFormatter
LinkCache$linkCache

Definition at line 84 of file LinkRenderer.php.

References MediaWiki\Linker\LinkRenderer\$linkCache, and MediaWiki\Linker\LinkRenderer\$titleFormatter.

Member Function Documentation

MediaWiki\Linker\LinkRenderer::buildAElement ( LinkTarget  $target,
  $text,
array  $attribs,
  $isKnown 
)
private
MediaWiki\Linker\LinkRenderer::getExpandURLs ( )
Returns
string|bool|int a PROTO_* constant or false

Definition at line 113 of file LinkRenderer.php.

References MediaWiki\Linker\LinkRenderer\$expandUrls.

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

Definition at line 99 of file LinkRenderer.php.

References MediaWiki\Linker\LinkRenderer\$forceArticlePath.

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 162 of file LinkRenderer.php.

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

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

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

Return the CSS classes of a known link.

Parameters
LinkTarget$target
Returns
string CSS class

Definition at line 461 of file LinkRenderer.php.

References MediaWiki\Linker\LinkRenderer\$stubThreshold, MediaWiki\Linker\LinkTarget\getNamespace(), and MWNamespace\isContent().

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

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

Definition at line 127 of file LinkRenderer.php.

References MediaWiki\Linker\LinkRenderer\$stubThreshold.

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

Definition at line 282 of file LinkRenderer.php.

References $query, MediaWiki\Linker\LinkRenderer\getLinkClasses(), MediaWiki\Linker\LinkTarget\isExternal(), and MediaWiki\Linker\LinkRenderer\makePreloadedLink().

Referenced by MediaWiki\Linker\LinkRenderer\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

Definition at line 145 of file LinkRenderer.php.

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

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 248 of file LinkRenderer.php.

References $attribs, $query, $ret, 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().

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

Merges two sets of attributes.

Parameters
array$defaults
array$attribs
Returns
array

Definition at line 438 of file LinkRenderer.php.

References $attribs, $ret, as, and Sanitizer\mergeAttributes().

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

MediaWiki\Linker\LinkRenderer::normalizeTarget ( LinkTarget  $target)
private

Normalizes the provided target.

Todo:
move the code from Linker actually here
Parameters
LinkTarget$target
Returns
LinkTarget

Definition at line 426 of file LinkRenderer.php.

References Linker\normaliseSpecialPage().

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

MediaWiki\Linker\LinkRenderer::runBeginHook ( LinkTarget  $target,
$text,
$extraAttribs,
$query,
  $isKnown 
)
private
MediaWiki\Linker\LinkRenderer::runLegacyBeginHook ( LinkTarget  $target,
$text,
$extraAttribs,
$query,
  $isKnown 
)
private
MediaWiki\Linker\LinkRenderer::setExpandURLs (   $expand)
Parameters
string | bool | int$expandA PROTO_* constant or false

Definition at line 106 of file LinkRenderer.php.

References $expand.

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

Definition at line 92 of file LinkRenderer.php.

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

Definition at line 134 of file LinkRenderer.php.

References $run, and MediaWiki\Linker\LinkRenderer\runLegacyBeginHook().

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

Definition at line 120 of file LinkRenderer.php.

Member Data Documentation

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

A PROTO_* constant or false.

Definition at line 56 of file LinkRenderer.php.

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

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

Whether to force the pretty article path.

Definition at line 49 of file LinkRenderer.php.

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

LinkCache MediaWiki\Linker\LinkRenderer::$linkCache
private

Definition at line 71 of file LinkRenderer.php.

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

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

Whether to run the legacy Linker hooks.

Definition at line 78 of file LinkRenderer.php.

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

Definition at line 66 of file LinkRenderer.php.

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


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