MediaWiki REL1_38
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.
 
 getStubThreshold ()
 
 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.
 
 normalizeTarget ( $target)
 Normalizes the provided target.
 
 setExpandURLs ( $expand)
 
 setForceArticlePath ( $force)
 
 setStubThreshold ( $threshold)
 

Public Attributes

const CONSTRUCTOR_OPTIONS
 

Private Member Functions

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

Private Attributes

bool $comment = false
 Whether links are being rendered for comments.
 
string bool int $expandUrls = false
 A PROTO_* constant or false.
 
bool $forceArticlePath = false
 Whether to force the pretty article path.
 
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 
)
Access: internal
For use by LinkRendererFactory
Parameters
TitleFormatter$titleFormatter
LinkCache$linkCache
SpecialPageFactory$specialPageFactory
HookContainer$hookContainer
ServiceOptions$options

Definition at line 97 of file LinkRenderer.php.

References MediaWiki\Linker\LinkRenderer\$linkCache, MediaWiki\Linker\LinkRenderer\$specialPageFactory, MediaWiki\Linker\LinkRenderer\$titleFormatter, MediaWiki\Config\ServiceOptions\assertRequiredOptions(), and MediaWiki\Config\ServiceOptions\get().

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

◆ castToLinkTarget()

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

Definition at line 470 of file LinkRenderer.php.

◆ castToTitle()

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

Definition at line 458 of file LinkRenderer.php.

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

◆ getLinkText()

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

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

References wfAppendQuery().

◆ getStubThreshold()

MediaWiki\Linker\LinkRenderer::getStubThreshold ( )
Deprecated:
since 1.37. Stub threshold feature was removed. See T284917
Returns
int

Definition at line 158 of file LinkRenderer.php.

References wfDeprecated().

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

References NS_SPECIAL, and wfMessage().

Referenced by WantedQueryPage\formatResult(), SpecialBrokenRedirects\formatResult(), and 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 237 of file LinkRenderer.php.

Referenced by MovePageForm\doSubmit(), SpecialTags\doTagRow(), SpecialListGroupRights\execute(), SpecialPasswordPolicies\execute(), SpecialAncientPages\formatResult(), SpecialBrokenRedirects\formatResult(), SpecialDoubleRedirects\formatResult(), SpecialFewestRevisions\formatResult(), SpecialMostCategories\formatResult(), SpecialMostInterwikis\formatResult(), SpecialShortPages\formatResult(), SpecialUnusedTemplates\formatResult(), SpecialUnwatchedPages\formatResult(), SpecialMergeHistory\formatRevisionRow(), AllMessagesTablePager\formatValue(), ProtectedPagesPager\formatValue(), BlockListPager\formatValue(), BlockLogFormatter\getActionLinks(), DeleteLogFormatter\getActionLinks(), ProtectLogFormatter\getActionLinks(), TraditionalImageGallery\getCaptionHtml(), SpecialBotPasswords\getFormFields(), SpecialStatistics\getGroupStats(), SpecialStatistics\getPageStats(), Article\getRedirectHeaderHtml(), SpecialDeletedContributions\getSubTitle(), ImagePage\imageDupes(), ImagePage\imageLinks(), SpecialMostLinked\makeWlhLink(), ImagePage\openShowImage(), InfoAction\pageInfo(), SpecialBlock\postText(), SpecialAllPages\showChunk(), SpecialEditTags\showConvenienceLinks(), SpecialRevisionDelete\showConvenienceLinks(), SpecialRevisionDelete\showForm(), SpecialUndelete\showList(), SpecialUploadStash\showUploads(), and SpecialUpload\showUploadWarning().

◆ makeLink()

◆ 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 201 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 409 of file LinkRenderer.php.

◆ normalizeTarget()

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

Normalizes the provided target.

Access: internal
For use by deprecated Linker & DummyLinker ::normaliseSpecialPage() methods
Parameters
LinkTarget | PageReference$target
Returns
LinkTarget

Definition at line 383 of file LinkRenderer.php.

References NS_SPECIAL.

◆ runBeginHook()

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

Definition at line 181 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.

◆ setStubThreshold()

MediaWiki\Linker\LinkRenderer::setStubThreshold (   $threshold)
Deprecated:
since 1.37. Stub threshold feature was removed. See T284917
Parameters
int$threshold

Definition at line 150 of file LinkRenderer.php.

References wfDeprecated().

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: