MediaWiki  master
MediaWiki\Linker\LinkRenderer Class Reference

Class that generates HTML anchor link elements for pages. More...

Collaboration diagram for MediaWiki\Linker\LinkRenderer:

Public Member Functions

 __construct (TitleFormatter $titleFormatter, LinkCache $linkCache, SpecialPageFactory $specialPageFactory, HookContainer $hookContainer, ServiceOptions $options)
 
 getExpandURLs ()
 
 getForceArticlePath ()
 
 getLinkClasses ( $target)
 Return the CSS classes of a known link. More...
 
 isForComment ()
 
 makeBrokenLink ( $target, $text=null, array $extraAttribs=[], array $query=[])
 
 makeKnownLink ( $target, $text=null, array $extraAttribs=[], array $query=[])
 
 makeLink ( $target, $text=null, array $extraAttribs=[], array $query=[])
 
 makePreloadedLink ( $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...
 
 normalizeTarget ( $target)
 Normalizes the provided target. More...
 
 setExpandURLs ( $expand)
 
 setForceArticlePath ( $force)
 

Public Attributes

const CONSTRUCTOR_OPTIONS
 

Private Member Functions

 buildAElement ( $target, $text, array $attribs, $isKnown)
 Builds the final element. More...
 
 castToLinkTarget ( $target)
 
 castToTitle ( $target)
 
 getLinkText ( $target)
 
 getLinkURL ( $target, $query=[])
 
 mergeAttribs ( $defaults, $attribs)
 Merges two sets of attributes. More...
 
 runBeginHook ( $target, &$text, &$extraAttribs, &$query, $isKnown)
 

Private Attributes

bool $comment = false
 Whether links are being rendered for comments. More...
 
string bool int $expandUrls = false
 A PROTO_* constant or false. More...
 
bool $forceArticlePath = false
 Whether to force the pretty article path. More...
 
HookRunner $hookRunner
 
LinkCache $linkCache
 
SpecialPageFactory $specialPageFactory
 
TitleFormatter $titleFormatter
 

Detailed Description

Class that generates HTML anchor link elements 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()

MediaWiki\Linker\LinkRenderer::__construct ( TitleFormatter  $titleFormatter,
LinkCache  $linkCache,
SpecialPageFactory  $specialPageFactory,
HookContainer  $hookContainer,
ServiceOptions  $options 
)

Member Function Documentation

◆ buildAElement()

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

Builds the final element.

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

Definition at line 312 of file LinkRenderer.php.

References HtmlArmor\getHtml(), and Html\rawElement().

◆ castToLinkTarget()

MediaWiki\Linker\LinkRenderer::castToLinkTarget (   $target)
private
Parameters
LinkTarget | PageReference$target
Returns
LinkTarget

Definition at line 456 of file LinkRenderer.php.

References Title\castFromPageReference().

◆ castToTitle()

MediaWiki\Linker\LinkRenderer::castToTitle (   $target)
private
Parameters
LinkTarget | PageReference$target
Returns
Title

Definition at line 443 of file LinkRenderer.php.

References Title\newFromLinkTarget().

◆ getExpandURLs()

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

Definition at line 137 of file LinkRenderer.php.

References MediaWiki\Linker\LinkRenderer\$expandUrls.

◆ getForceArticlePath()

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

Definition at line 123 of file LinkRenderer.php.

References MediaWiki\Linker\LinkRenderer\$forceArticlePath.

◆ getLinkClasses()

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

Return the CSS classes of a known link.

Parameters
LinkTarget | PageReference$target
Returns
string CSS class

Definition at line 417 of file LinkRenderer.php.

◆ getLinkText()

MediaWiki\Linker\LinkRenderer::getLinkText (   $target)
private
Parameters
LinkTarget | PageReference$target
Returns
string

Definition at line 328 of file LinkRenderer.php.

References MediaWiki\Linker\LinkTarget\hasFragment().

◆ getLinkURL()

MediaWiki\Linker\LinkRenderer::getLinkURL (   $target,
  $query = [] 
)
private
Parameters
LinkTarget | PageReference$target
array$query
Returns
string non-escaped text

Definition at line 344 of file LinkRenderer.php.

References wfAppendQuery().

◆ isForComment()

MediaWiki\Linker\LinkRenderer::isForComment ( )

Definition at line 141 of file LinkRenderer.php.

◆ makeBrokenLink()

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

Definition at line 258 of file LinkRenderer.php.

References NS_SPECIAL, and wfMessage().

Referenced by AllMessagesTablePager\formatValue().

◆ makeKnownLink()

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

Definition at line 221 of file LinkRenderer.php.

Referenced by AllMessagesTablePager\formatValue(), ProtectedPagesPager\formatValue(), BlockListPager\formatValue(), TraditionalImageGallery\getCaptionHtml(), Article\getRedirectHeaderHtml(), and InfoAction\pageInfo().

◆ makeLink()

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

Definition at line 153 of file LinkRenderer.php.

Referenced by ProtectedPagesPager\formatValue(), Article\getRedirectHeaderHtml(), BlockListPager\getRestrictionListHTML(), and InfoAction\pageInfo().

◆ makePreloadedLink()

MediaWiki\Linker\LinkRenderer::makePreloadedLink (   $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 | PageReference$target
string | HtmlArmor | null$text
string$classesCSS classes to add
array$extraAttribs
array$query
Returns
string

Definition at line 185 of file LinkRenderer.php.

◆ mergeAttribs()

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

Merges two sets of attributes.

Parameters
array$defaults
array$attribs
Returns
array

Definition at line 394 of file LinkRenderer.php.

References Sanitizer\mergeAttributes().

◆ normalizeTarget()

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

Normalizes the provided target.

Definition at line 368 of file LinkRenderer.php.

References NS_SPECIAL.

◆ runBeginHook()

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

Definition at line 164 of file LinkRenderer.php.

◆ setExpandURLs()

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

Definition at line 130 of file LinkRenderer.php.

◆ setForceArticlePath()

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

Definition at line 116 of file LinkRenderer.php.

Member Data Documentation

◆ $comment

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

Whether links are being rendered for comments.

Definition at line 68 of file LinkRenderer.php.

◆ $expandUrls

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

A PROTO_* constant or false.

Definition at line 61 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 54 of file LinkRenderer.php.

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

◆ $hookRunner

HookRunner MediaWiki\Linker\LinkRenderer::$hookRunner
private

Definition at line 81 of file LinkRenderer.php.

◆ $linkCache

LinkCache MediaWiki\Linker\LinkRenderer::$linkCache
private

Definition at line 78 of file LinkRenderer.php.

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

◆ $specialPageFactory

SpecialPageFactory MediaWiki\Linker\LinkRenderer::$specialPageFactory
private

Definition at line 86 of file LinkRenderer.php.

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

◆ $titleFormatter

TitleFormatter MediaWiki\Linker\LinkRenderer::$titleFormatter
private

Definition at line 73 of file LinkRenderer.php.

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

◆ CONSTRUCTOR_OPTIONS

const MediaWiki\Linker\LinkRenderer::CONSTRUCTOR_OPTIONS
Initial value:
= [
'renderForComment',
]

Definition at line 45 of file LinkRenderer.php.

Referenced by MediaWiki\Linker\LinkRendererFactory\create().


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