MediaWiki REL1_40
MediaWiki\Linker\Linker Class Reference

Some internal bits split of from Skin.php. More...

Static Public Member Functions

static accesskey ( $name, $localizer=null)
 Given the id of an interface element, constructs the appropriate accesskey attribute from the system messages.
 
static blockLink ( $userId, $userText)
 
static buildRollbackLink (RevisionRecord $revRecord, IContextSource $context=null, $editCount=false)
 Build a raw rollback link, useful for collections of "tool" links.
 
static commentBlock ( $comment, $title=null, $local=false, $wikiId=null, $useParentheses=true)
 Wrap a comment in standard punctuation and formatting if it's non-empty, otherwise return empty string.
 
static emailLink ( $userId, $userText)
 
static expandLocalLinks (string $html)
 Helper function to expand local links.
 
static formatComment ( $comment, $title=null, $local=false, $wikiId=null)
 This function is called by all recent changes variants, by the page history, and by the user contributions list.
 
static formatHiddenCategories ( $hiddencats)
 Returns HTML for the "hidden categories on this page" list.
 
static formatLinksInComment ( $comment, $title=null, $local=false, $wikiId=null)
 Formats wiki links and media links in text; all other wiki formatting is ignored.
 
static formatRevisionSize ( $size)
 
static generateRollback (RevisionRecord $revRecord, IContextSource $context=null, $options=[])
 Generate a rollback link for a given revision.
 
static generateTOC (?TOCData $tocData, Language $lang=null, array $options=[])
 
static getImageLinkMTOParams ( $frameParams, $query='', $parser=null)
 Get the link parameters for MediaTransformOutput::toHtml() from given frame parameters supplied by the Parser.
 
static getInvalidTitleDescription (IContextSource $context, $namespace, $title)
 Get a message saying that an invalid title was encountered.
 
static getRevDeleteLink (Authority $performer, RevisionRecord $revRecord, LinkTarget $title)
 Get a revision-deletion link, or disabled link, or nothing, depending on user permissions & the settings on the revision.
 
static getRevisionDeletedClass (RevisionRecord $revisionRecord)
 Returns css class of a deleted revision.
 
static getRollbackEditCount (RevisionRecord $revRecord, $verify=true)
 This function will return the number of revisions which a rollback would revert and will verify that a revision can be reverted (that the user isn't the only contributor and the revision we might rollback to isn't deleted).
 
static link ( $target, $html=null, $customAttribs=[], $query=[], $options=[])
 This function returns an HTML link to the given target.
 
static linkKnown ( $target, $html=null, $customAttribs=[], $query=[], $options=[ 'known'])
 Identical to link(), except $options defaults to 'known'.
 
static makeBrokenImageLinkObj ( $title, $label='', $query='', $unused1='', $unused2='', $time=false, array $handlerParams=[], bool $currentExists=false)
 Make a "broken" link to an image.
 
static makeExternalImage ( $url, $alt='')
 Return the code for images which were added via external links, via Parser::maybeMakeExternalImage().
 
static makeExternalLink ( $url, $text, $escape=true, $linktype='', $attribs=[], $title=null)
 Make an external link.
 
static makeHeadline ( $level, $attribs, $anchor, $html, $link, $fallbackAnchor=false)
 Create a headline for content.
 
static makeImageLink (Parser $parser, LinkTarget $title, $file, $frameParams=[], $handlerParams=[], $time=false, $query='', $widthOption=null)
 Given parameters derived from [[Image:Foo|options...]], generate the HTML that that syntax inserts in the page.
 
static makeMediaLinkFile (LinkTarget $title, $file, $html='')
 Create a direct link to a given uploaded file.
 
static makeMediaLinkObj ( $title, $html='', $time=false)
 Create a direct link to a given uploaded file.
 
static makeSelfLinkObj ( $nt, $html='', $query='', $trail='', $prefix='', $hash='')
 Make appropriate markup for a link to the current article.
 
static makeThumbLink2 (LinkTarget $title, $file, $frameParams=[], $handlerParams=[], $time=false, $query='', array $classes=[], ?Parser $parser=null)
 
static makeThumbLinkObj (LinkTarget $title, $file, $label='', $alt='', $align=null, $params=[], $framed=false, $manualthumb='')
 Make HTML for a thumbnail including image, border and caption.
 
static normalizeSubpageLink ( $contextTitle, $target, &$text)
 
static processResponsiveImages ( $file, $thumb, $hp)
 Process responsive images: add 1.5x and 2x subimages to the thumbnail, where applicable.
 
static revComment (RevisionRecord $revRecord, $local=false, $isPublic=false, $useParentheses=true)
 Wrap and format the given revision's comment block, if the current user is allowed to view it.
 
static revDeleteLink ( $query=[], $restricted=false, $delete=true)
 Creates a (show/hide) link for deleting revisions/log entries.
 
static revDeleteLinkDisabled ( $delete=true)
 Creates a dead (show/hide) link for deleting revisions/log entries.
 
static revUserLink (RevisionRecord $revRecord, $isPublic=false)
 Generate a user link if the current user is allowed to view it.
 
static revUserTools (RevisionRecord $revRecord, $isPublic=false, $useParentheses=true)
 Generate a user tool link cluster if the current user is allowed to view it.
 
static specialLink ( $name, $key='')
 Make a link to a special page given its name and, optionally, a message key from the link text.
 
static splitTrail ( $trail)
 Split a link trail, return the "inside" portion and the remainder of the trail as a two-element array.
 
static titleAttrib ( $name, $options=null, array $msgParams=[], $localizer=null)
 Given the id of an interface element, constructs the appropriate title attribute from the system messages.
 
static tocIndent ()
 Add another level to the Table of Contents.
 
static tocLine ( $linkAnchor, $tocline, $tocnumber, $level, $sectionIndex=false)
 parameter level defines if we are on an indentation level
 
static tocLineEnd ()
 End a Table Of Contents line.
 
static tocList ( $toc, Language $lang=null)
 Wraps the TOC in a div with ARIA navigation role and provides the hide/collapse JavaScript.
 
static tocUnindent ( $level)
 Finish one or more sublevels on the Table of Contents.
 
static tooltip ( $name, $options=null)
 Returns raw bits of HTML, use titleAttrib()
 
static tooltipAndAccesskeyAttribs ( $name, array $msgParams=[], $options=null, $localizer=null, $user=null, $config=null, $relevantTitle=null)
 Returns the attributes for the tooltip and access key.
 
static userLink ( $userId, $userName, $altUserName=false, $attributes=[])
 Make user link (or user contributions for unregistered users)
 
static userTalkLink ( $userId, $userText)
 
static userToolLinks ( $userId, $userText, $redContribsWhenNoEdits=false, $flags=0, $edits=null, $useParentheses=true)
 Generate standard user tool links (talk, contributions, block link, etc.)
 
static userToolLinksRedContribs ( $userId, $userText, $edits=null, $useParentheses=true)
 Alias for userToolLinks( $userId, $userText, true );.
 

Public Attributes

const TOOL_LINKS_EMAIL = 2
 
const TOOL_LINKS_NOBLOCK = 1
 Flags for userToolLinks()
 

Static Public Attributes

static $accesskeycache
 

Static Protected Member Functions

static getUploadUrl ( $destFile, $query='')
 Get the URL to upload a certain file.
 

Detailed Description

Some internal bits split of from Skin.php.

These functions are used for primarily page content: links, embedded images, table of contents. Links are also used in the skin.

Todo
turn this into a legacy interface for HtmlPageLinkRenderer and similar services.

Definition at line 67 of file Linker.php.

Member Function Documentation

◆ accesskey()

static MediaWiki\Linker\Linker::accesskey ( $name,
$localizer = null )
static

Given the id of an interface element, constructs the appropriate accesskey attribute from the system messages.

(Note, this is usually the id but isn't always, because sometimes the accesskey needs to go on a different element than the id, for reverse-compatibility, etc.)

Since
1.16.3
Parameters
string$nameId of the element, minus prefixes.
MessageLocalizer | null$localizer
Returns
string|false Contents of the accesskey attribute (which you must HTML- escape), or false for no accesskey attribute

Definition at line 2217 of file Linker.php.

Referenced by MediaWiki\Linker\DummyLinker\accesskey().

◆ blockLink()

static MediaWiki\Linker\Linker::blockLink ( $userId,
$userText )
static
Since
1.16.3
Parameters
int$userId
string$userTextUser name in database.
Returns
string HTML fragment with block link

Definition at line 1344 of file Linker.php.

References SpecialPage\getTitleFor(), MediaWiki\Linker\Linker\link(), wfDebug(), and wfMessage().

Referenced by MediaWiki\Linker\DummyLinker\blockLink(), and MediaWiki\Linker\Linker\userToolLinks().

◆ buildRollbackLink()

static MediaWiki\Linker\Linker::buildRollbackLink ( RevisionRecord $revRecord,
IContextSource $context = null,
$editCount = false )
static

Build a raw rollback link, useful for collections of "tool" links.

Since
1.16.3. $context added in 1.20. $editCount added in 1.21 $rev could be a RevisionRecord since 1.35
Todo
Unused outside of this file - should it be made private?
Parameters
RevisionRecord$revRecord(Switched from the old Revision class to RevisionRecord since 1.35)
IContextSource | null$contextContext to use or null for the main context.
int | false | null$editCountNumber of edits that would be reverted
Returns
string HTML fragment

Definition at line 2053 of file Linker.php.

References $title, MediaWiki\Revision\RevisionRecord\getPageAsLinkTarget(), MediaWiki\Revision\RevisionRecord\getUser(), and Message\numParam().

Referenced by MediaWiki\Linker\DummyLinker\buildRollbackLink().

◆ commentBlock()

static MediaWiki\Linker\Linker::commentBlock ( $comment,
$title = null,
$local = false,
$wikiId = null,
$useParentheses = true )
static

Wrap a comment in standard punctuation and formatting if it's non-empty, otherwise return empty string.

This method produces HTML that requires CSS styles in mediawiki.interface.helpers.styles.

Since
1.16.3. $wikiId added in 1.26
Deprecated
since 1.38 use CommentFormatter
Parameters
string$comment
LinkTarget | null$titleLinkTarget object (to generate link to section in autocomment) or null
bool$localWhether section links should refer to local page
string | null$wikiIdId (as used by WikiMap) of the wiki to generate links to. For use with external changes.
bool$useParenthesesWhether the comment is wrapped in parentheses
Returns
string

Definition at line 1662 of file Linker.php.

References $title, and MediaWiki\MediaWikiServices\getInstance().

Referenced by MediaWiki\Linker\DummyLinker\commentBlock().

◆ emailLink()

static MediaWiki\Linker\Linker::emailLink ( $userId,
$userText )
static
Parameters
int$userId
string$userTextUser name in database.
Returns
string HTML fragment with e-mail user link

Definition at line 1365 of file Linker.php.

References SpecialPage\getTitleFor(), MediaWiki\Linker\Linker\link(), wfLogWarning(), and wfMessage().

Referenced by MediaWiki\Linker\DummyLinker\emailLink(), and MediaWiki\Linker\Linker\userToolLinks().

◆ expandLocalLinks()

static MediaWiki\Linker\Linker::expandLocalLinks ( string $html)
static

Helper function to expand local links.

Mostly used in action=render

Since
1.38
Stability: unstable
Parameters
string$html
Returns
string HTML

Definition at line 1492 of file Linker.php.

References PROTO_RELATIVE, and wfExpandUrl().

◆ formatComment()

static MediaWiki\Linker\Linker::formatComment ( $comment,
$title = null,
$local = false,
$wikiId = null )
static

This function is called by all recent changes variants, by the page history, and by the user contributions list.

It is responsible for formatting edit summaries. It escapes any HTML in the summary, but adds some CSS to format auto-generated comments (from section editing) and formats [[wikilinks]].

This method produces HTML that can require CSS styles in mediawiki.interface.helpers.styles.

Since
1.16.3. $wikiId added in 1.26
Deprecated
since 1.38 use CommentFormatter
Parameters
string$comment
LinkTarget | null$titleLinkTarget object (to generate link to the section in autocomment) or null
bool$localWhether section links should refer to local page
string | null$wikiIdId (as used by WikiMap) of the wiki to generate links to. For use with external changes.
Returns
string HTML

Definition at line 1526 of file Linker.php.

References $title, and MediaWiki\MediaWikiServices\getInstance().

Referenced by MediaWiki\Linker\DummyLinker\formatComment().

◆ formatHiddenCategories()

static MediaWiki\Linker\Linker::formatHiddenCategories ( $hiddencats)
static

Returns HTML for the "hidden categories on this page" list.

Since
1.16.3
Parameters
array$hiddencatsArray of hidden categories from WikiPage::getHiddenCategories or similar
Returns
string HTML output

Definition at line 2124 of file Linker.php.

References wfMessage().

Referenced by MediaWiki\Linker\DummyLinker\formatHiddenCategories().

◆ formatLinksInComment()

static MediaWiki\Linker\Linker::formatLinksInComment ( $comment,
$title = null,
$local = false,
$wikiId = null )
static

Formats wiki links and media links in text; all other wiki formatting is ignored.

Since
1.16.3. $wikiId added in 1.26
Deprecated
since 1.38 use CommentFormatter
Parameters
string$commentText to format links in. WARNING! Since the output of this function is html, $comment must be sanitized for use as html. You probably want to pass $comment through Sanitizer::escapeHtmlAllowEntities() before calling this function.
LinkTarget | null$titleAn optional LinkTarget object used to links to sections
bool$localWhether section links should refer to local page
string | null$wikiIdId of the wiki to link to (if not the local wiki), as used by WikiMap.
Returns
string HTML
-taint onlysafefor_html

Definition at line 1552 of file Linker.php.

References $title, and MediaWiki\MediaWikiServices\getInstance().

Referenced by MediaWiki\Linker\DummyLinker\formatLinksInComment().

◆ formatRevisionSize()

static MediaWiki\Linker\Linker::formatRevisionSize ( $size)
static
Since
1.16.3
Parameters
int$size
Returns
string

Definition at line 1700 of file Linker.php.

References wfMessage().

Referenced by MediaWiki\Linker\DummyLinker\formatRevisionSize().

◆ generateRollback()

static MediaWiki\Linker\Linker::generateRollback ( RevisionRecord $revRecord,
IContextSource $context = null,
$options = [] )
static

Generate a rollback link for a given revision.

Currently it's the caller's responsibility to ensure that the revision is the top one. If it's not, of course, the user will get an error message.

If the calling page is called with the parameter &bot=1, all rollback links also get that parameter. It causes the edit itself and the rollback to be marked as "bot" edits. Bot edits are hidden by default from recent changes, so this allows sysops to combat a busy vandal without bothering other users.

This function will return the link only in case the revision can be reverted (not all revisions are by the same user, and the last revision by a different user is visible). Please note that due to performance limitations it might be assumed that a user isn't the only contributor of a page while (s)he is, which will lead to useless rollback links. Furthermore this won't work if $wgShowRollbackEditCount is disabled, so this can only function as an additional check.

If the option noBrackets is set the rollback link wont be enclosed in "[]".

Since
1.16.3. $context added in 1.20. $options added in 1.21 $rev could be a RevisionRecord since 1.35
Parameters
RevisionRecord$revRecord(Switched from the old Revision class to RevisionRecord since 1.35)
IContextSource | null$contextContext to use or null for the main context.
array$options
Returns
string

Definition at line 1928 of file Linker.php.

Referenced by MediaWiki\Linker\DummyLinker\generateRollback().

◆ generateTOC()

static MediaWiki\Linker\Linker::generateTOC ( ?TOCData $tocData,
Language $lang = null,
array $options = [] )
static
Access: internal
For use by ParserOutput and API modules Generate a table of contents from a section tree.
Since
1.16.3. $lang added in 1.17. Parameters changed in 1.40.
Parameters
?TOCData$tocDataReturn value of ParserOutput::getSections()
Language | null$langLanguage for the toc title, defaults to user language
array$optionsFIXME: Document
Returns
string HTML fragment

Definition at line 1820 of file Linker.php.

Referenced by MediaWiki\Linker\DummyLinker\generateTOC().

◆ getImageLinkMTOParams()

static MediaWiki\Linker\Linker::getImageLinkMTOParams ( $frameParams,
$query = '',
$parser = null )
static

Get the link parameters for MediaTransformOutput::toHtml() from given frame parameters supplied by the Parser.

Parameters
array$frameParamsThe frame parameters
string$queryAn optional query string to add to description page links
Parser | null$parser
Returns
array

Definition at line 575 of file Linker.php.

References MediaWiki\MediaWikiServices\getInstance(), and MediaWiki\Title\TitleFactory\newFromLinkTarget().

Referenced by MediaWiki\Linker\Linker\makeImageLink(), and MediaWiki\Linker\Linker\makeThumbLink2().

◆ getInvalidTitleDescription()

static MediaWiki\Linker\Linker::getInvalidTitleDescription ( IContextSource $context,
$namespace,
$title )
static

Get a message saying that an invalid title was encountered.

This should be called after a method like Title::makeTitleSafe() returned a value indicating that the title object is invalid.

Parameters
IContextSource$contextContext to use to get the messages
int$namespaceNamespace number
string$titleText of the title, without the namespace part
Returns
string

Definition at line 226 of file Linker.php.

References $title, MediaWiki\MediaWikiServices\getInstance(), MessageLocalizer\msg(), and NS_MAIN.

Referenced by MediaWiki\Linker\DummyLinker\getInvalidTitleDescription().

◆ getRevDeleteLink()

static MediaWiki\Linker\Linker::getRevDeleteLink ( Authority $performer,
RevisionRecord $revRecord,
LinkTarget $title )
static

Get a revision-deletion link, or disabled link, or nothing, depending on user permissions & the settings on the revision.

Will use forward-compatible revision ID in the Special:RevDelete link if possible, otherwise the timestamp-based ID which may break after undeletion.

Parameters
Authority$performer
RevisionRecord$revRecord(Switched from the old Revision class to RevisionRecord since 1.35)
LinkTarget$title
Returns
string HTML fragment

Definition at line 2242 of file Linker.php.

References $title, MediaWiki\Revision\RevisionRecord\getId(), MediaWiki\Revision\RevisionRecord\getTimestamp(), MediaWiki\Revision\RevisionRecord\getVisibility(), MediaWiki\Permissions\Authority\isAllowed(), MediaWiki\Revision\RevisionRecord\isDeleted(), and MediaWiki\Revision\RevisionRecord\userCan().

Referenced by MediaWiki\Linker\DummyLinker\getRevDeleteLink().

◆ getRevisionDeletedClass()

static MediaWiki\Linker\Linker::getRevisionDeletedClass ( RevisionRecord $revisionRecord)
static

Returns css class of a deleted revision.

Parameters
RevisionRecord$revisionRecord
Returns
string 'history-deleted', 'mw-history-suppressed' added if suppressed too
Since
1.37

Definition at line 1419 of file Linker.php.

Referenced by MediaWiki\Linker\Linker\revUserLink().

◆ getRollbackEditCount()

static MediaWiki\Linker\Linker::getRollbackEditCount ( RevisionRecord $revRecord,
$verify = true )
static

This function will return the number of revisions which a rollback would revert and will verify that a revision can be reverted (that the user isn't the only contributor and the revision we might rollback to isn't deleted).

These checks can only function as an additional check as this function only checks against the last $wgShowRollbackEditCount edits.

Returns null if $wgShowRollbackEditCount is disabled or false if the user is the only contributor of the page.

Todo
Unused outside of this file - should it be made private?
Parameters
RevisionRecord$revRecord(Switched from the old Revision class to RevisionRecord since 1.35)
bool$verifyDeprecated since 1.40, has no effect.
Returns
int|false|null

Definition at line 1982 of file Linker.php.

References $dbr, $res, $revQuery, DB_REPLICA, MediaWiki\Revision\RevisionRecord\getPageId(), MediaWiki\Revision\RevisionRecord\getUser(), wfDeprecated(), and wfGetDB().

Referenced by MediaWiki\Linker\DummyLinker\getRollbackEditCount().

◆ getUploadUrl()

static MediaWiki\Linker\Linker::getUploadUrl ( $destFile,
$query = '' )
staticprotected

Get the URL to upload a certain file.

Since
1.16.3
Parameters
LinkTarget$destFileLinkTarget object of the file to upload
string$queryUrlencoded query string to prepend
Returns
string Urlencoded URL

Definition at line 971 of file Linker.php.

References MediaWiki\Title\TitleFactory\castFromLinkTarget(), MediaWiki\MediaWikiServices\getInstance(), SpecialPage\getTitleFor(), MediaWiki\MainConfigNames\UploadMissingFileUrl, MediaWiki\MainConfigNames\UploadNavigationUrl, and wfAppendQuery().

Referenced by MediaWiki\Linker\Linker\makeMediaLinkFile().

◆ link()

static MediaWiki\Linker\Linker::link ( $target,
$html = null,
$customAttribs = [],
$query = [],
$options = [] )
static

This function returns an HTML link to the given target.

It serves a few purposes: 1) If $target is a LinkTarget, the correct URL to link to will be figured out automatically. 2) It automatically adds the usual classes for various types of link targets: "new" for red links, "stub" for short articles, etc. 3) It escapes all attribute values safely so there's no risk of XSS. 4) It provides a default tooltip if the target is a LinkTarget (the page name of the target). link() replaces the old functions in the makeLink() family.

Since
1.18 Method exists since 1.16 as non-static, made static in 1.18.
Deprecated
since 1.28, use MediaWiki\Linker\LinkRenderer instead
Parameters
LinkTarget$targetCan currently only be a LinkTarget, but this may change to support Images, literal URLs, etc.
string | null$htmlThe HTML contents of the element, i.e., the link text. This is raw HTML and will not be escaped. If null, defaults to the prefixed text of the LinkTarget; or if the LinkTarget is just a fragment, the contents of the fragment.
array$customAttribsA key => value array of extra HTML attributes, such as title and class. (href is ignored.) Classes will be merged with the default classes, while other attributes will replace default attributes. All passed attribute values will be HTML-escaped. A false attribute value means to suppress that attribute.
array$queryThe query string to append to the URL you're linking to, in key => value array form. Query keys and values will be URL-encoded.
string | array$optionsString or array of strings: 'known': Page is known to exist, so don't check if it does. 'broken': Page is known not to exist, so don't check if it does. 'noclasses': Don't add any classes automatically (includes "new", "stub", "mw-redirect", "extiw"). Only use the class attribute provided, if any, so you get a simple blue link with no funny i- cons. 'forcearticlepath': Use the article path always, even with a querystring. Has compatibility issues on some setups, so avoid wherever possible. 'http': Force a full URL with http:// as the scheme. 'https': Force a full URL with https:// as the scheme.
Returns
string HTML attribute

Definition at line 116 of file Linker.php.

References MediaWiki\MediaWikiServices\getInstance(), and wfWarn().

Referenced by MediaWiki\Linker\Linker\blockLink(), MediaWiki\Linker\Linker\emailLink(), MediaWiki\Linker\DummyLinker\link(), MediaWiki\Linker\Linker\linkKnown(), MediaWiki\Linker\Linker\makeBrokenImageLinkObj(), MediaWiki\Linker\Linker\makeImageLink(), MediaWiki\Linker\Linker\userLink(), MediaWiki\Linker\Linker\userTalkLink(), and MediaWiki\Linker\Linker\userToolLinks().

◆ linkKnown()

static MediaWiki\Linker\Linker::linkKnown ( $target,
$html = null,
$customAttribs = [],
$query = [],
$options = [ 'known' ] )
static

Identical to link(), except $options defaults to 'known'.

Since
1.16.3
Deprecated
since 1.28, use MediaWiki\Linker\LinkRenderer instead
See also
Linker::link
Parameters
LinkTarget$target
string | null$html
array$customAttribs
array$query
string | array$options
Returns
string

Definition at line 168 of file Linker.php.

References MediaWiki\Linker\Linker\link().

Referenced by MediaWiki\Linker\DummyLinker\linkKnown(), and MediaWiki\Linker\Linker\specialLink().

◆ makeBrokenImageLinkObj()

static MediaWiki\Linker\Linker::makeBrokenImageLinkObj ( $title,
$label = '',
$query = '',
$unused1 = '',
$unused2 = '',
$time = false,
array $handlerParams = [],
bool $currentExists = false )
static

Make a "broken" link to an image.

Since
1.16.3
Parameters
LinkTarget$title
string$labelLink label (plain text)
string$queryQuery string
string$unused1Unused parameter kept for b/c
string$unused2Unused parameter kept for b/c
bool$timeA file of a certain timestamp was requested
array$handlerParams
Since
1.36
Parameters
bool$currentExists
Returns
string

Definition at line 898 of file Linker.php.

References $title, MediaWiki\Title\TitleFactory\castFromLinkTarget(), MediaWiki\MainConfigNames\EnableUploads, MediaWiki\MediaWikiServices\getInstance(), MediaWiki\Linker\Linker\link(), NS_FILE, MediaWiki\MainConfigNames\ParserEnableLegacyMediaDOM, MediaWiki\MainConfigNames\UploadMissingFileUrl, MediaWiki\MainConfigNames\UploadNavigationUrl, wfCgiToArray(), and wfWarn().

Referenced by MediaWiki\Linker\DummyLinker\makeBrokenImageLinkObj(), MediaWiki\Linker\Linker\makeImageLink(), and MediaWiki\Linker\Linker\makeThumbLink2().

◆ makeExternalImage()

static MediaWiki\Linker\Linker::makeExternalImage ( $url,
$alt = '' )
static

Return the code for images which were added via external links, via Parser::maybeMakeExternalImage().

Since
1.16.3
Parameters
string$url
string$alt
Returns
string

Definition at line 269 of file Linker.php.

References $success, and wfDebug().

Referenced by MediaWiki\Linker\DummyLinker\makeExternalImage().

◆ makeExternalLink()

static MediaWiki\Linker\Linker::makeExternalLink ( $url,
$text,
$escape = true,
$linktype = '',
$attribs = [],
$title = null )
static

Make an external link.

Since
1.16.3. $title added in 1.21
Parameters
string$urlURL to link to
-taint$urlescapes_html
string$textText of link
-taint$textescapes_html
bool$escapeDo we escape the link text?
-taint$escapenone
string$linktypeType of external link. Gets added to the classes
-taint$linktypeescapes_html
array$attribsArray of extra attributes to
-taint$attribsescapes_html
LinkTarget | null$titleLinkTarget object used for title specific link attributes
-taint$titlenone
Returns
string

Definition at line 1110 of file Linker.php.

References $success, $title, $wgTitle, Parser\getExternalLinkRel(), and wfDebug().

Referenced by MediaWiki\Linker\DummyLinker\makeExternalLink().

◆ makeHeadline()

static MediaWiki\Linker\Linker::makeHeadline ( $level,
$attribs,
$anchor,
$html,
$link,
$fallbackAnchor = false )
static

Create a headline for content.

Since
1.16.3
Parameters
int$levelThe level of the headline (1-6)
string$attribsAny attributes for the headline, starting with a space and ending with '>' This must be at least '>' for no attribs
string$anchorThe anchor to give the headline (the bit after the #)
string$htmlHTML for the text of the header
string$linkHTML to add for the section edit link
string | false$fallbackAnchorA second, optional anchor to give for backward compatibility (false to omit)
Returns
string HTML headline

Definition at line 1868 of file Linker.php.

References $fallback.

Referenced by MediaWiki\Linker\DummyLinker\makeHeadline().

◆ makeImageLink()

static MediaWiki\Linker\Linker::makeImageLink ( Parser $parser,
LinkTarget $title,
$file,
$frameParams = [],
$handlerParams = [],
$time = false,
$query = '',
$widthOption = null )
static

Given parameters derived from [[Image:Foo|options...]], generate the HTML that that syntax inserts in the page.

Parameters
Parser$parser
LinkTarget$titleLinkTarget object of the file (not the currently viewed page)
File | false$fileFile object, or false if it doesn't exist
array$frameParamsAssociative array of parameters external to the media handler. Boolean parameters are indicated by presence or absence, the value is arbitrary and will often be false. thumbnail If present, downscale and frame manualthumb Image name to use as a thumbnail, instead of automatic scaling framed Shows image in original size in a frame frameless Downscale but don't frame upright If present, tweak default sizes for portrait orientation upright_factor Fudge factor for "upright" tweak (default 0.75) border If present, show a border around the image align Horizontal alignment (left, right, center, none) valign Vertical alignment (baseline, sub, super, top, text-top, middle, bottom, text-bottom) alt Alternate text for image (i.e. alt attribute). Plain text. title Used for tooltips if caption isn't visible. class HTML for image classes. Plain text. caption HTML for image caption. link-url URL to link to link-title LinkTarget object to link to link-target Value for the target attribute, only with link-url no-link Boolean, suppress description link
array$handlerParamsAssociative array of media handler parameters, to be passed to transform(). Typical keys are "width" and "page". targetlang (optional) Target language code, see Parser::getTargetLanguage()
string | false$timeTimestamp of the file, set as false for current
string$queryQuery params for desc url
int | null$widthOptionUsed by the parser to remember the user preference thumbnailsize
Since
1.20
Returns
string HTML for an image, with links, wrappers, etc.

Definition at line 326 of file Linker.php.

References $file, $res, $title, Parser\getBadFileLookup(), MediaWiki\Linker\Linker\getImageLinkMTOParams(), MediaWiki\MediaWikiServices\getInstance(), Parser\getTargetLanguage(), Parser\getTitle(), MediaWiki\Linker\Linker\link(), MediaWiki\Linker\Linker\makeBrokenImageLinkObj(), MediaWiki\Linker\Linker\makeThumbLink2(), MediaWiki\Title\TitleFactory\newFromLinkTarget(), MediaWiki\MainConfigNames\ParserEnableLegacyMediaDOM, MediaWiki\Linker\Linker\processResponsiveImages(), MediaWiki\MainConfigNames\SVGMaxSize, MediaWiki\MainConfigNames\ThumbLimits, MediaWiki\MainConfigNames\ThumbUpright, wfDebug(), and wfMessage().

Referenced by MediaWiki\Linker\DummyLinker\makeImageLink().

◆ makeMediaLinkFile()

static MediaWiki\Linker\Linker::makeMediaLinkFile ( LinkTarget $title,
$file,
$html = '' )
static

Create a direct link to a given uploaded file.

This will make a broken link if $file is false.

Since
1.16.3
Parameters
LinkTarget$title
File | false$fileFile object or false
string$htmlPre-sanitized HTML
Returns
string HTML
Todo
Handle invalid or missing images better.

Definition at line 1021 of file Linker.php.

References $file, $title, MediaWiki\Title\TitleFactory\castFromLinkTarget(), MediaWiki\Linker\Linker\getUploadUrl(), and wfDebug().

Referenced by MediaWiki\Linker\DummyLinker\makeMediaLinkFile(), and MediaWiki\Linker\Linker\makeMediaLinkObj().

◆ makeMediaLinkObj()

static MediaWiki\Linker\Linker::makeMediaLinkObj ( $title,
$html = '',
$time = false )
static

Create a direct link to a given uploaded file.

Since
1.16.3
Parameters
LinkTarget$title
string$htmlPre-sanitized HTML
string | false$timeMW timestamp of file creation time
Returns
string HTML

Definition at line 1002 of file Linker.php.

References $title, MediaWiki\MediaWikiServices\getInstance(), and MediaWiki\Linker\Linker\makeMediaLinkFile().

Referenced by MediaWiki\Linker\DummyLinker\makeMediaLinkObj().

◆ makeSelfLinkObj()

static MediaWiki\Linker\Linker::makeSelfLinkObj ( $nt,
$html = '',
$query = '',
$trail = '',
$prefix = '',
$hash = '' )
static

Make appropriate markup for a link to the current article.

This is since MediaWiki 1.29.0 rendered as an tag without an href and with a class showing the link text. The calling sequence is the same as for the other make*LinkObj static functions, but $query is not used.

Since
1.16.3
Parameters
LinkTarget$nt
string$html
string$query
string$trail
string$prefix
string$hashhash fragment since 1.40. Should be properly escaped using Sanitizer::escapeIdForLink before being passed to this function.
Returns
string

Definition at line 192 of file Linker.php.

References MediaWiki\Title\TitleFactory\newFromLinkTarget(), and MediaWiki\Linker\Linker\splitTrail().

Referenced by MediaWiki\Linker\DummyLinker\makeSelfLinkObj().

◆ makeThumbLink2()

static MediaWiki\Linker\Linker::makeThumbLink2 ( LinkTarget $title,
$file,
$frameParams = [],
$handlerParams = [],
$time = false,
$query = '',
array $classes = [],
?Parser $parser = null )
static

◆ makeThumbLinkObj()

static MediaWiki\Linker\Linker::makeThumbLinkObj ( LinkTarget $title,
$file,
$label = '',
$alt = '',
$align = null,
$params = [],
$framed = false,
$manualthumb = '' )
static

Make HTML for a thumbnail including image, border and caption.

Parameters
LinkTarget$title
File | false$fileFile object or false if it doesn't exist
string$label
string$alt
string | null$align
array$params
bool$framed
string$manualthumb
Returns
string

Definition at line 618 of file Linker.php.

References $file, $title, and MediaWiki\Linker\Linker\makeThumbLink2().

Referenced by MediaWiki\Linker\DummyLinker\makeThumbLinkObj().

◆ normalizeSubpageLink()

static MediaWiki\Linker\Linker::normalizeSubpageLink ( $contextTitle,
$target,
& $text )
static
Parameters
LinkTarget | null$contextTitle
string$target
string&$text
Returns
string

Definition at line 1565 of file Linker.php.

References MediaWiki\MediaWikiServices\getInstance().

Referenced by MediaWiki\Linker\DummyLinker\normalizeSubpageLink().

◆ processResponsiveImages()

static MediaWiki\Linker\Linker::processResponsiveImages ( $file,
$thumb,
$hp )
static

Process responsive images: add 1.5x and 2x subimages to the thumbnail, where applicable.

Parameters
File$file
MediaTransformOutput | null$thumb
array$hpImage parameters

Definition at line 861 of file Linker.php.

References $file, MediaWiki\MediaWikiServices\getInstance(), and MediaWiki\MainConfigNames\ResponsiveImages.

Referenced by MediaWiki\Linker\Linker\makeImageLink(), MediaWiki\Linker\Linker\makeThumbLink2(), and MediaWiki\Linker\DummyLinker\processResponsiveImages().

◆ revComment()

static MediaWiki\Linker\Linker::revComment ( RevisionRecord $revRecord,
$local = false,
$isPublic = false,
$useParentheses = true )
static

Wrap and format the given revision's comment block, if the current user is allowed to view it.

This method produces HTML that requires CSS styles in mediawiki.interface.helpers.styles.

Since
1.16.3
Deprecated
since 1.38 use CommentFormatter
Parameters
RevisionRecord$revRecord(Switched from the old Revision class to RevisionRecord since 1.35)
bool$localWhether section links should refer to local page
bool$isPublicShow only if all users can see it
bool$useParentheses(optional) Wrap comments in parentheses where needed
Returns
string HTML fragment

Definition at line 1684 of file Linker.php.

References MediaWiki\MediaWikiServices\getInstance().

Referenced by MediaWiki\Linker\DummyLinker\revComment().

◆ revDeleteLink()

static MediaWiki\Linker\Linker::revDeleteLink ( $query = [],
$restricted = false,
$delete = true )
static

Creates a (show/hide) link for deleting revisions/log entries.

This method produces HTML that requires CSS styles in mediawiki.interface.helpers.styles.

Parameters
array$queryQuery parameters to be passed to link()
bool$restrictedSet to true to use a "<strong>" instead of a "<span>"
bool$deleteSet to true to use (show/hide) rather than (show)
Returns
string HTML "<a>" link to Special:Revisiondelete, wrapped in a span to allow for customization of appearance with CSS

Definition at line 2294 of file Linker.php.

References SpecialPage\getTitleFor(), and wfMessage().

Referenced by MediaWiki\Linker\DummyLinker\revDeleteLink().

◆ revDeleteLinkDisabled()

static MediaWiki\Linker\Linker::revDeleteLinkDisabled ( $delete = true)
static

Creates a dead (show/hide) link for deleting revisions/log entries.

This method produces HTML that requires CSS styles in mediawiki.interface.helpers.styles.

Since
1.16.3
Parameters
bool$deleteSet to true to use (show/hide) rather than (show)
Returns
string HTML text wrapped in a span to allow for customization of appearance with CSS

Definition at line 2318 of file Linker.php.

References wfMessage().

Referenced by MediaWiki\Linker\DummyLinker\revDeleteLinkDisabled().

◆ revUserLink()

static MediaWiki\Linker\Linker::revUserLink ( RevisionRecord $revRecord,
$isPublic = false )
static

Generate a user link if the current user is allowed to view it.

This method produces HTML that requires CSS styles in mediawiki.interface.helpers.styles.

Since
1.16.3
Parameters
RevisionRecord$revRecord(Switched from the old Revision class to RevisionRecord since 1.35)
bool$isPublicShow only if all users can see it
Returns
string HTML fragment

Definition at line 1391 of file Linker.php.

References MediaWiki\Linker\Linker\getRevisionDeletedClass(), MediaWiki\Revision\RevisionRecord\getUser(), MediaWiki\Revision\RevisionRecord\isDeleted(), MediaWiki\Revision\RevisionRecord\userCan(), MediaWiki\Linker\Linker\userLink(), and wfMessage().

Referenced by MediaWiki\Linker\DummyLinker\revUserLink().

◆ revUserTools()

static MediaWiki\Linker\Linker::revUserTools ( RevisionRecord $revRecord,
$isPublic = false,
$useParentheses = true )
static

Generate a user tool link cluster if the current user is allowed to view it.

This method produces HTML that requires CSS styles in mediawiki.interface.helpers.styles.

Since
1.16.3
Parameters
RevisionRecord$revRecord(Switched from the old Revision class to RevisionRecord since 1.35)
bool$isPublicShow only if all users can see it
bool$useParentheses(optional) Wrap comments in parentheses where needed
Returns
string HTML

Definition at line 1439 of file Linker.php.

References MediaWiki\Revision\RevisionRecord\getId(), MediaWiki\Revision\RevisionRecord\getUser(), MediaWiki\Revision\RevisionRecord\isDeleted(), MediaWiki\Revision\RevisionRecord\userCan(), and wfMessage().

Referenced by MediaWiki\Linker\DummyLinker\revUserTools().

◆ specialLink()

static MediaWiki\Linker\Linker::specialLink ( $name,
$key = '' )
static

Make a link to a special page given its name and, optionally, a message key from the link text.

Usage example: Linker::specialLink( 'Recentchanges' )

Since
1.16.3
Parameters
string$name
string$key
Returns
string

Definition at line 1063 of file Linker.php.

References SpecialPage\getTitleFor(), MediaWiki\Linker\Linker\linkKnown(), wfCgiToArray(), and wfMessage().

Referenced by MediaWiki\Linker\DummyLinker\specialLink().

◆ splitTrail()

static MediaWiki\Linker\Linker::splitTrail ( $trail)
static

Split a link trail, return the "inside" portion and the remainder of the trail as a two-element array.

Parameters
string$trail
Returns
string[]

Definition at line 1889 of file Linker.php.

Referenced by MediaWiki\Linker\Linker\makeSelfLinkObj(), and MediaWiki\Linker\DummyLinker\splitTrail().

◆ titleAttrib()

static MediaWiki\Linker\Linker::titleAttrib ( $name,
$options = null,
array $msgParams = [],
$localizer = null )
static

Given the id of an interface element, constructs the appropriate title attribute from the system messages.

(Note, this is usually the id but isn't always, because sometimes the accesskey needs to go on a different element than the id, for reverse-compatibility, etc.)

Since
1.16.3 $msgParams added in 1.27
Parameters
string$nameId of the element, minus prefixes.
string | array | null$optionsNull, string or array with some of the following options:
  • 'withaccess' to add an access-key hint
  • 'nonexisting' to add an accessibility hint that page does not exist
array$msgParamsParameters to pass to the message
MessageLocalizer | null$localizer
Returns
string|false Contents of the title attribute (which you must HTML- escape), or false for no title attribute

Definition at line 2169 of file Linker.php.

Referenced by MediaWiki\Linker\DummyLinker\titleAttrib().

◆ tocIndent()

static MediaWiki\Linker\Linker::tocIndent ( )
static

Add another level to the Table of Contents.

Since
1.16.3
Returns
string

Definition at line 1715 of file Linker.php.

Referenced by MediaWiki\Linker\DummyLinker\tocIndent().

◆ tocLine()

static MediaWiki\Linker\Linker::tocLine ( $linkAnchor,
$tocline,
$tocnumber,
$level,
$sectionIndex = false )
static

parameter level defines if we are on an indentation level

Since
1.16.3
Parameters
string$linkAnchor
string$tocline
string$tocnumber
int$level
string | false$sectionIndex
Returns
string

Definition at line 1741 of file Linker.php.

Referenced by MediaWiki\Linker\DummyLinker\tocLine().

◆ tocLineEnd()

static MediaWiki\Linker\Linker::tocLineEnd ( )
static

End a Table Of Contents line.

tocUnindent() will be used instead if we're ending a line below the new level.

Since
1.16.3
Returns
string

Definition at line 1769 of file Linker.php.

Referenced by MediaWiki\Linker\DummyLinker\tocLineEnd().

◆ tocList()

static MediaWiki\Linker\Linker::tocList ( $toc,
Language $lang = null )
static

Wraps the TOC in a div with ARIA navigation role and provides the hide/collapse JavaScript.

Since
1.16.3
Parameters
string$tocHtml of the Table Of Contents
Language | null$langLanguage for the toc title, defaults to user language
Returns
string Full html of the TOC

Definition at line 1781 of file Linker.php.

References $lang, $title, and wfMessage().

Referenced by MediaWiki\Linker\DummyLinker\tocList().

◆ tocUnindent()

static MediaWiki\Linker\Linker::tocUnindent ( $level)
static

Finish one or more sublevels on the Table of Contents.

Since
1.16.3
Parameters
int$level
Returns
string

Definition at line 1726 of file Linker.php.

Referenced by MediaWiki\Linker\DummyLinker\tocUnindent().

◆ tooltip()

static MediaWiki\Linker\Linker::tooltip ( $name,
$options = null )
static

Returns raw bits of HTML, use titleAttrib()

Since
1.16.3
Parameters
string$name
array | null$options
Returns
null|string

Definition at line 2431 of file Linker.php.

Referenced by MediaWiki\Linker\DummyLinker\tooltip().

◆ tooltipAndAccesskeyAttribs()

static MediaWiki\Linker\Linker::tooltipAndAccesskeyAttribs ( $name,
array $msgParams = [],
$options = null,
$localizer = null,
$user = null,
$config = null,
$relevantTitle = null )
static

Returns the attributes for the tooltip and access key.

Since
1.16.3. $msgParams introduced in 1.27
Parameters
string$name
array$msgParamsParams for constructing the message
string | array | null$optionsOptions to be passed to titleAttrib.
MessageLocalizer | null$localizer
User | null$userOnly needed for generating tooltip for watchlist expiry.
Config | null$configOnly needed for generating tooltip for watchlist expiry.
Title | null$relevantTitleOnly needed for generating tooltip for watchlist expiry.
See also
Linker::titleAttrib for what options could be passed to $options.
Returns
array

Definition at line 2388 of file Linker.php.

Referenced by MediaWiki\Linker\DummyLinker\tooltipAndAccesskeyAttribs().

◆ userLink()

static MediaWiki\Linker\Linker::userLink ( $userId,
$userName,
$altUserName = false,
$attributes = [] )
static

Make user link (or user contributions for unregistered users)

This method produces HTML that requires CSS styles in mediawiki.interface.helpers.styles.

Parameters
int$userIdUser id in database.
string$userNameUser name in database.
string | false$altUserNameText to display instead of the user name (optional)
string[]$attributesExtra HTML attributes. See Linker::link.
Returns
string HTML fragment
Since
1.16.3. $altUserName was added in 1.19. $attributes was added in 1.40.

Definition at line 1164 of file Linker.php.

References MediaWiki\MediaWikiServices\getInstance(), SpecialPage\getTitleFor(), MediaWiki\Linker\Linker\link(), NS_USER, wfDebug(), and wfMessage().

Referenced by MediaWiki\Linker\Linker\revUserLink(), and MediaWiki\Linker\DummyLinker\userLink().

◆ userTalkLink()

static MediaWiki\Linker\Linker::userTalkLink ( $userId,
$userText )
static
Since
1.16.3
Parameters
int$userIdUser id in database.
string$userTextUser name in database.
Returns
string HTML fragment with user talk link

Definition at line 1322 of file Linker.php.

References MediaWiki\Linker\Linker\link(), NS_USER_TALK, wfDebug(), and wfMessage().

Referenced by MediaWiki\Linker\DummyLinker\userTalkLink(), and MediaWiki\Linker\Linker\userToolLinks().

◆ userToolLinks()

static MediaWiki\Linker\Linker::userToolLinks ( $userId,
$userText,
$redContribsWhenNoEdits = false,
$flags = 0,
$edits = null,
$useParentheses = true )
static

Generate standard user tool links (talk, contributions, block link, etc.)

Since
1.16.3
Parameters
int$userIdUser identifier
string$userTextUser name or IP address
bool$redContribsWhenNoEditsShould the contributions link be red if the user has no edits?
int$flagsCustomisation flags (e.g. Linker::TOOL_LINKS_NOBLOCK and Linker::TOOL_LINKS_EMAIL).
int | null$editsUser edit count (optional, for performance)
bool$useParentheses(optional) Wrap comments in parentheses where needed
Returns
string HTML fragment

Definition at line 1227 of file Linker.php.

References $wgLang, MediaWiki\Linker\Linker\blockLink(), MediaWiki\MainConfigNames\DisableAnonTalk, MediaWiki\Linker\Linker\emailLink(), MediaWiki\MediaWikiServices\getInstance(), SpecialPage\getTitleFor(), MediaWiki\Linker\Linker\link(), User\newFromId(), MediaWiki\Linker\Linker\TOOL_LINKS_NOBLOCK, MediaWiki\Linker\Linker\userTalkLink(), wfDebug(), and wfMessage().

Referenced by MediaWiki\Linker\DummyLinker\userToolLinks(), and MediaWiki\Linker\Linker\userToolLinksRedContribs().

◆ userToolLinksRedContribs()

static MediaWiki\Linker\Linker::userToolLinksRedContribs ( $userId,
$userText,
$edits = null,
$useParentheses = true )
static

Alias for userToolLinks( $userId, $userText, true );.

Since
1.16.3
Parameters
int$userIdUser identifier
string$userTextUser name or IP address
int | null$editsUser edit count (optional, for performance)
bool$useParentheses(optional) Wrap comments in parentheses where needed
Returns
string

Definition at line 1310 of file Linker.php.

References MediaWiki\Linker\Linker\userToolLinks().

Referenced by MediaWiki\Linker\DummyLinker\userToolLinksRedContribs().

Member Data Documentation

◆ $accesskeycache

MediaWiki\Linker\Linker::$accesskeycache
static

Definition at line 2203 of file Linker.php.

◆ TOOL_LINKS_EMAIL

const MediaWiki\Linker\Linker::TOOL_LINKS_EMAIL = 2

Definition at line 72 of file Linker.php.

◆ TOOL_LINKS_NOBLOCK

const MediaWiki\Linker\Linker::TOOL_LINKS_NOBLOCK = 1

Flags for userToolLinks()

Definition at line 71 of file Linker.php.

Referenced by MediaWiki\Linker\Linker\userToolLinks().


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