MediaWiki  master
Linker Class Reference

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

Static Public Member Functions

static accesskey ( $name)
 Given the id of an interface element, constructs the appropriate accesskey attribute from the system messages. More...
 
static blockLink ( $userId, $userText)
 
static buildRollbackLink ( $rev, IContextSource $context=null, $editCount=false)
 Build a raw rollback link, useful for collections of "tool" links. More...
 
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. More...
 
static emailLink ( $userId, $userText)
 
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. More...
 
static formatHiddenCategories ( $hiddencats)
 Returns HTML for the "hidden categories on this page" list. More...
 
static formatLinksInComment ( $comment, $title=null, $local=false, $wikiId=null)
 Formats wiki links and media links in text; all other wiki formatting is ignored. More...
 
static formatRevisionSize ( $size)
 
static formatSize ( $size)
 
static formatTemplates ( $templates, $preview=false, $section=false, $more=null)
 
static generateRollback ( $rev, IContextSource $context=null, $options=[ 'verify'])
 Generate a rollback link for a given revision. More...
 
static generateTOC ( $tree, $lang=false)
 Generate a table of contents from a section tree. More...
 
static getInvalidTitleDescription (IContextSource $context, $namespace, $title)
 Get a message saying that an invalid title was encountered. More...
 
static getRevDeleteLink (User $user, Revision $rev, Title $title)
 Get a revision-deletion link, or disabled link, or nothing, depending on user permissions & the settings on the revision. More...
 
static getRollbackEditCount ( $rev, $verify)
 This function will return the number of revisions which a rollback would revert and, if $verify is set it 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). More...
 
static link ( $target, $html=null, $customAttribs=[], $query=[], $options=[])
 This function returns an HTML link to the given target. More...
 
static linkKnown ( $target, $html=null, $customAttribs=[], $query=[], $options=[ 'known'])
 Identical to link(), except $options defaults to 'known'. More...
 
static makeBrokenImageLinkObj ( $title, $label='', $query='', $unused1='', $unused2='', $time=false)
 Make a "broken" link to an image. More...
 
static makeCommentLink (LinkTarget $linkTarget, $text, $wikiId=null, $options=[])
 Generates a link to the given Title. More...
 
static makeExternalImage ( $url, $alt='')
 Return the code for images which were added via external links, via Parser::maybeMakeExternalImage(). More...
 
static makeExternalLink ( $url, $text, $escape=true, $linktype='', $attribs=[], $title=null)
 Make an external link. More...
 
static makeHeadline ( $level, $attribs, $anchor, $html, $link, $fallbackAnchor=false)
 Create a headline for content. More...
 
static makeImageLink (Parser $parser, Title $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. More...
 
static makeMediaLinkFile (Title $title, $file, $html='')
 Create a direct link to a given uploaded file. More...
 
static makeMediaLinkObj ( $title, $html='', $time=false)
 Create a direct link to a given uploaded file. More...
 
static makeSelfLinkObj ( $nt, $html='', $query='', $trail='', $prefix='')
 Make appropriate markup for a link to the current article. More...
 
static makeThumbLink2 (Title $title, $file, $frameParams=[], $handlerParams=[], $time=false, $query="")
 
static makeThumbLinkObj (Title $title, $file, $label='', $alt='', $align='right', $params=[], $framed=false, $manualthumb="")
 Make HTML for a thumbnail including image, border and caption. More...
 
static normaliseSpecialPage (LinkTarget $target)
 
static normalizeSubpageLink ( $contextTitle, $target, &$text)
 
static processResponsiveImages ( $file, $thumb, $hp)
 Process responsive images: add 1.5x and 2x subimages to the thumbnail, where applicable. More...
 
static revComment (Revision $rev, $local=false, $isPublic=false, $useParentheses=true)
 Wrap and format the given revision's comment block, if the current user is allowed to view it. More...
 
static revDeleteLink ( $query=[], $restricted=false, $delete=true)
 Creates a (show/hide) link for deleting revisions/log entries. More...
 
static revDeleteLinkDisabled ( $delete=true)
 Creates a dead (show/hide) link for deleting revisions/log entries. More...
 
static revUserLink ( $rev, $isPublic=false)
 Generate a user link if the current user is allowed to view it. More...
 
static revUserTools ( $rev, $isPublic=false)
 Generate a user tool link cluster if the current user is allowed to view it. More...
 
static specialLink ( $name, $key='')
 Make a link to a special page given its name and, optionally, a message key from the link text. More...
 
static splitTrail ( $trail)
 Split a link trail, return the "inside" portion and the remainder of the trail as a two-element array. More...
 
static titleAttrib ( $name, $options=null, array $msgParams=[])
 Given the id of an interface element, constructs the appropriate title attribute from the system messages. More...
 
static tocIndent ()
 Add another level to the Table of Contents. More...
 
static tocLine ( $anchor, $tocline, $tocnumber, $level, $sectionIndex=false)
 parameter level defines if we are on an indentation level More...
 
static tocLineEnd ()
 End a Table Of Contents line. More...
 
static tocList ( $toc, $lang=false)
 Wraps the TOC in a table and provides the hide/collapse javascript. More...
 
static tocUnindent ( $level)
 Finish one or more sublevels on the Table of Contents. More...
 
static tooltip ( $name, $options=null)
 Returns raw bits of HTML, use titleAttrib() More...
 
static tooltipAndAccesskeyAttribs ( $name, array $msgParams=[], $options=null)
 Returns the attributes for the tooltip and access key. More...
 
static userLink ( $userId, $userName, $altUserName=false)
 Make user link (or user contributions for unregistered users) More...
 
static userTalkLink ( $userId, $userText)
 
static userToolLinks ( $userId, $userText, $redContribsWhenNoEdits=false, $flags=0, $edits=null)
 Generate standard user tool links (talk, contributions, block link, etc.) More...
 
static userToolLinksRedContribs ( $userId, $userText, $edits=null)
 Alias for userToolLinks( $userId, $userText, true );. More...
 

Public Attributes

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

Static Public Attributes

static $accesskeycache
 

Static Protected Member Functions

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

Static Private Member Functions

static fnamePart ( $url)
 Returns the filename part of an url. More...
 
static formatAutocomments ( $comment, $title=null, $local=false, $wikiId=null)
 Converts autogenerated comments in edit summaries into section links. More...
 
static getImageLinkMTOParams ( $frameParams, $query='', $parser=null)
 Get the link parameters for MediaTransformOutput::toHtml() from given frame parameters supplied by the Parser. More...
 

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 34 of file Linker.php.

Member Function Documentation

◆ accesskey()

static Linker::accesskey (   $name)
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.
Returns
string Contents of the accesskey attribute (which you must HTML- escape), or false for no accesskey attribute

Definition at line 2029 of file Linker.php.

References $name, and wfMessage().

Referenced by DummyLinker\accesskey(), OOUIHTMLForm\getButtons(), EditPage\getEditButtons(), EditPage\getSummaryInputWidget(), and HTMLFormField\getTooltipAndAccessKeyOOUI().

◆ blockLink()

static 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 1002 of file Linker.php.

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

Referenced by DummyLinker\blockLink().

◆ buildRollbackLink()

static Linker::buildRollbackLink (   $rev,
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
Parameters
Revision$rev
IContextSource | null$contextContext to use or null for the main context.
int$editCountNumber of edits that would be reverted
Returns
string HTML fragment

Definition at line 1819 of file Linker.php.

References $context, $html, $options, $query, $rev, $title, $wgMiserMode, $wgShowRollbackEditCount, as, RequestContext\getMain(), MediaWiki\getTitle(), and link.

Referenced by DummyLinker\buildRollbackLink().

◆ commentBlock()

static 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.

Since
1.16.3. $wikiId added in 1.26
Parameters
string$comment
Title | null$titleTitle 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.
Returns
string

Definition at line 1447 of file Linker.php.

References $title, and wfMessage().

Referenced by DummyLinker\commentBlock(), RevDelFileItem\getComment(), LogFormatter\getComment(), SpecialUndelete\getFileComment(), McrUndoAction\getFormFields(), RevDelLogItem\getHTML(), EditPage\getSummaryPreview(), ChangesList\insertComment(), and LogFormatterTest\testLogComment().

◆ emailLink()

static 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 1016 of file Linker.php.

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

Referenced by DummyLinker\emailLink().

◆ fnamePart()

static Linker::fnamePart (   $url)
staticprivate

Returns the filename part of an url.

Used as alternative text for external images.

Parameters
string$url
Returns
string

Definition at line 228 of file Linker.php.

◆ formatAutocomments()

static Linker::formatAutocomments (   $comment,
  $title = null,
  $local = false,
  $wikiId = null 
)
staticprivate

Converts autogenerated comments in edit summaries into section links.

The pattern for autogen comments is / * foo * /, which makes for some nasty regex. We look for all comments, match any text before and after the comment, add a separator where needed and format the comment itself with CSS Called by Linker::formatComment.

Parameters
string$commentComment text
Title | null$titleAn optional title 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 Formatted comment (wikitext)

Definition at line 1121 of file Linker.php.

References $auto, $pre, $section, $title, $wgLang, Parser\guessSectionNameFromStrippedText(), makeCommentLink(), Title\makeTitleSafe(), NS_MAIN, Hooks\run(), use, and wfMessage().

◆ formatComment()

static 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]].

Author
Erik Moeller moell.nosp@m.er@s.nosp@m.cirev.nosp@m.iew..nosp@m.de
Since
1.16.3. $wikiId added in 1.26
Parameters
string$comment
Title | null$titleTitle 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 1089 of file Linker.php.

References $title, and Sanitizer\escapeHtmlAllowEntities().

Referenced by ApiQueryDeletedrevs\execute(), ApiQueryFilearchive\execute(), ApiQueryWatchlist\extractOutputData(), ApiQueryRevisionsBase\extractRevisionInfo(), ApiQueryLogEvents\extractRowInfo(), ApiQueryRecentChanges\extractRowInfo(), ApiQueryUserContribs\extractRowInfo(), DummyLinker\formatComment(), FeedUtils\formatDiffRow(), ApiParse\formatSummary(), BlockListPager\formatValue(), ProtectedPagesPager\formatValue(), ImageListPager\formatValue(), ApiQueryImageInfo\getInfo(), ImageHistoryList\imageHistoryLine(), RollbackAction\onView(), ApiQueryProtectedTitles\run(), ParserTestRunner\runTest(), ApiComparePages\setVals(), and LinkerTest\testFormatComment().

◆ formatHiddenCategories()

static 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 Article::getHiddenCategories or similar
Returns
string HTML output

Definition at line 1929 of file Linker.php.

References as, link, and wfMessage().

Referenced by DummyLinker\formatHiddenCategories(), InfoAction\pageInfo(), and EditPage\showEditForm().

◆ formatLinksInComment()

static 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
Todo:
FIXME: Doesn't handle sub-links as in image thumb texts like the main parser
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.
Title | null$titleAn optional title 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 1220 of file Linker.php.

References $title, StringUtils\escapeRegexReplacement(), MWNamespace\getCanonicalName(), list, makeCommentLink(), makeMediaLinkObj(), Title\makeTitleSafe(), Title\newFromText(), normalizeSubpageLink(), NS_FILE, NS_MEDIA, splitTrail(), and use.

Referenced by DummyLinker\formatLinksInComment(), and LinkerTest\testFormatLinksInComment().

◆ formatRevisionSize()

static Linker::formatRevisionSize (   $size)
static

◆ formatSize()

static Linker::formatSize (   $size)
static
Deprecated:
since 1.28, use Language::formatSize() directly

Format a size in bytes for output, using an appropriate unit (B, KB, MB or GB) according to the magnitude in question

Since
1.16.3
Parameters
int$sizeSize to format
Returns
string

Definition at line 1958 of file Linker.php.

References $wgLang, and wfDeprecated().

Referenced by DummyLinker\formatSize().

◆ formatTemplates()

static Linker::formatTemplates (   $templates,
  $preview = false,
  $section = false,
  $more = null 
)
static
Deprecated:
since 1.28, use TemplatesOnThisPageFormatter directly

Returns HTML for the "templates used on this page" list.

Make an HTML list of templates, and then add a "More..." link at the bottom. If $more is null, do not add a "More..." link. If $more is a Title, make a link to that title and use it. If $more is a string, directly paste it in as the link (escaping needs to be done manually). Finally, if $more is a Message, call toString().

Since
1.16.3. $more added in 1.21
Parameters
Title[]$templates Array of templates
bool$previewWhether this is for a preview
bool$sectionWhether this is for a section edit
Title | Message | string | null$moreAn escaped link for "More..." of the templates
Returns
string HTML output

Definition at line 1898 of file Linker.php.

References $section, $type, RequestContext\getMain(), and wfDeprecated().

Referenced by DummyLinker\formatTemplates().

◆ generateRollback()

static Linker::generateRollback (   $rev,
IContextSource  $context = null,
  $options = [ 'verify' ] 
)
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.

If the option verify is set this function will return the link only in case the revision can be reverted. 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 wont 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
Parameters
Revision$rev
IContextSource | null$contextContext to use or null for the main context.
array$options
Returns
string

Definition at line 1718 of file Linker.php.

References $context, $options, $rev, and RequestContext\getMain().

Referenced by ContribsPager\formatRow(), DummyLinker\generateRollback(), HistoryPager\historyLine(), ChangesList\insertRollback(), and DifferenceEngine\showDiffPage().

◆ generateTOC()

static Linker::generateTOC (   $tree,
  $lang = false 
)
static

Generate a table of contents from a section tree.

Since
1.16.3. $lang added in 1.17
Parameters
array$treeReturn value of ParserOutput::getSections()
string | Language | bool$langLanguage for the toc title, defaults to user language
Returns
string HTML fragment

Definition at line 1617 of file Linker.php.

References $lang, $section, and as.

Referenced by DummyLinker\generateTOC(), and ApiHelp\getHelp().

◆ getImageLinkMTOParams()

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

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 452 of file Linker.php.

References $name, $parser, $query, as, and Title\newFromLinkTarget().

◆ getInvalidTitleDescription()

static 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 186 of file Linker.php.

References $name, $title, MWNamespace\exists(), MessageLocalizer\msg(), and NS_MAIN.

Referenced by PageQueryPage\formatResult(), FewestrevisionsPage\formatResult(), MostlinkedCategoriesPage\formatResult(), MostcategoriesPage\formatResult(), MostinterwikisPage\formatResult(), MostlinkedTemplatesPage\formatResult(), MostlinkedPage\formatResult(), UnwatchedpagesPage\formatResult(), ShortPagesPage\formatResult(), SpecialProtectedtitles\formatRow(), ProtectedPagesPager\formatValue(), DummyLinker\getInvalidTitleDescription(), and SpecialUndelete\showList().

◆ getRevDeleteLink()

static Linker::getRevDeleteLink ( User  $user,
Revision  $rev,
Title  $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
User$user
Revision$rev
Title$title
Returns
string HTML fragment

Definition at line 2065 of file Linker.php.

References $query, Revision\DELETED_RESTRICTED, Revision\getId(), Title\getPrefixedDBkey(), Revision\getTimestamp(), Revision\getVisibility(), User\isAllowed(), Revision\isDeleted(), and Revision\userCan().

Referenced by SpecialUndelete\diffHeader(), DeletedContribsPager\formatRevisionRow(), ContribsPager\formatRow(), DummyLinker\getRevDeleteLink(), DifferenceEngine\revisionDeleteLink(), Article\setOldSubtitle(), and SpecialUndelete\showRevision().

◆ getRollbackEditCount()

static Linker::getRollbackEditCount (   $rev,
  $verify 
)
static

This function will return the number of revisions which a rollback would revert and, if $verify is set it 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 $verify is set and the user is the only contributor of the page.

Parameters
Revision$rev
bool$verifyTry to verify that this revision can really be rolled back
Returns
int|bool|null

Definition at line 1757 of file Linker.php.

References $dbr, $res, $rev, $revQuery, $wgShowRollbackEditCount, as, DB_REPLICA, Revision\DELETED_TEXT, Revision\DELETED_USER, Revision\getQueryInfo(), Revision\RAW, and wfGetDB().

Referenced by DummyLinker\getRollbackEditCount().

◆ getUploadUrl()

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

Get the URL to upload a certain file.

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

Definition at line 724 of file Linker.php.

References $query, $wgUploadMissingFileUrl, $wgUploadNavigationUrl, SpecialPage\getTitleFor(), and wfAppendQuery().

◆ link()

static 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 Title, 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 Title (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$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 Title; or if the Title 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. 'stubThreshold' => (int): Stub threshold to use when determining link classes.
Returns
string HTML attribute

Definition at line 84 of file Linker.php.

References $customAttribs, $html, $linkRenderer, $options, $query, $services, array(), wfCgiToArray(), wfDeprecated(), and wfWarn().

Referenced by Skin\doEditSectionLink(), Skin\drawCategoryBrowser(), Skin\getCategoryLinks(), UserGroupMembership\getLink(), Article\getRedirectHeaderHtml(), BlockListPager\getRestrictionListHTML(), DummyLinker\link(), LinkerTest\testLinkBeginHook(), LinkerTest\testLinkEndHook(), LogFormatterTest\testLogParamsTypeRaw(), LogFormatterTest\testLogParamsTypeTitleLink(), and LogFormatterTest\testNormalLogParams().

◆ linkKnown()

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

◆ makeBrokenImageLinkObj()

static Linker::makeBrokenImageLinkObj (   $title,
  $label = '',
  $query = '',
  $unused1 = '',
  $unused2 = '',
  $time = false 
)
static

Make a "broken" link to an image.

Since
1.16.3
Parameters
Title$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
Returns
string

Definition at line 674 of file Linker.php.

References $query, $time, $title, $wgEnableUploads, $wgUploadMissingFileUrl, $wgUploadNavigationUrl, false, link, RepoGroup\singleton(), wfCgiToArray(), wfFindFile(), and wfWarn().

Referenced by DummyLinker\makeBrokenImageLinkObj().

◆ makeCommentLink()

static Linker::makeCommentLink ( LinkTarget  $linkTarget,
  $text,
  $wikiId = null,
  $options = [] 
)
static

Generates a link to the given Title.

Note
This is only public for technical reasons. It's not intended for use outside Linker.
Parameters
LinkTarget$linkTarget
string$text
string | null$wikiIdId of the wiki to link to (if not the local wiki), as used by WikiMap.
string|string[]$options See the $options parameter in Linker::link.
Returns
string HTML link

Definition at line 1332 of file Linker.php.

References $link, $options, MWNamespace\getCanonicalName(), MediaWiki\Linker\LinkTarget\getDBkey(), WikiMap\getForeignURL(), MediaWiki\Linker\LinkTarget\getFragment(), MediaWiki\Linker\LinkTarget\getNamespace(), MediaWiki\Linker\LinkTarget\isExternal(), and link.

Referenced by formatAutocomments(), formatLinksInComment(), and DummyLinker\makeCommentLink().

◆ makeExternalImage()

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

References $success, Html\element(), Hooks\run(), and wfDebug().

Referenced by DummyLinker\makeExternalImage(), and Parser\maybeMakeExternalImage().

◆ makeExternalLink()

static 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
string$textText of link
bool$escapeDo we escape the link text?
string$linktypeType of external link. Gets added to the classes
array$attribsArray of extra attributes to
Title | null$titleTitle object used for title specific link attributes
Returns
string

Definition at line 827 of file Linker.php.

References $attribs, $link, $success, $title, $wgTitle, Parser\getExternalLinkRel(), Html\rawElement(), Hooks\run(), and wfDebug().

Referenced by LinkSearchPage\formatResult(), AllMessagesTablePager\formatValue(), Skin\getCopyright(), SpecialVersion\getCreditsForExtension(), SpecialVersion\getExternalLibraries(), SpecialVersion\getParserFunctionHooks(), SpecialVersion\getParserTags(), ImagePage\imageDupes(), Parser\magicLinkCallback(), DummyLinker\makeExternalLink(), WikiMap\makeForeignLink(), Parser\makeFreeExternalLink(), Parser\replaceExternalLinks(), Article\showRedirectedFromHeader(), and ImagePage\uploadLinksBox().

◆ makeHeadline()

static 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 | bool$fallbackAnchorA second, optional anchor to give for backward compatibility (false to omit)
Returns
string HTML headline

Definition at line 1655 of file Linker.php.

References $fallback, $link, and $ret.

Referenced by Parser\formatHeadings(), DummyLinker\makeHeadline(), and ApiMain\modifyHelp().

◆ makeImageLink()

static Linker::makeImageLink ( Parser  $parser,
Title  $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
Title$titleTitle object of the file (not the currently viewed page)
File$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. class HTML for image classes. Plain text. caption HTML for image caption. link-url URL to link to link-title Title object to link to link-target Value for the target attribute, only with link-url no-link Boolean, suppress description link targetlang (optional) Target language code, see Parser::getTargetLanguage()
array$handlerParamsAssociative array of media handler parameters, to be passed to transform(). Typical keys are "width" and "page".
string | bool$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 302 of file Linker.php.

References $handlerParams, $params, $query, $res, $s, $time, $wgSVGMaxSize, $wgThumbLimits, $wgThumbUpright, User\getDefaultOption(), Title\getPrefixedDBkey(), Parser\getTargetLanguage(), link, Html\rawElement(), Hooks\run(), and wfDebug().

Referenced by Parser\makeImage(), and DummyLinker\makeImageLink().

◆ makeMediaLinkFile()

static Linker::makeMediaLinkFile ( Title  $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
Title$title
File | bool$fileFile object or false
string$htmlPre-sanitized HTML
Returns
string HTML
Todo:
Handle invalid or missing images better.

Definition at line 767 of file Linker.php.

References $attribs, $html, $ret, Title\getText(), Html\rawElement(), Hooks\run(), and wfDebug().

Referenced by DummyLinker\makeMediaLinkFile(), and Parser\replaceInternalLinks2().

◆ makeMediaLinkObj()

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

Create a direct link to a given uploaded file.

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

Definition at line 750 of file Linker.php.

References $html, $time, $title, and wfFindFile().

Referenced by formatLinksInComment(), MIMEsearchPage\formatResult(), and DummyLinker\makeMediaLinkObj().

◆ makeSelfLinkObj()

static Linker::makeSelfLinkObj (   $nt,
  $html = '',
  $query = '',
  $trail = '',
  $prefix = '' 
)
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
Title$nt
string$html[optional]
string$query[optional]
string$trail[optional]
string$prefix[optional]
Returns
string

Definition at line 163 of file Linker.php.

References $html, $ret, list, and Hooks\run().

Referenced by DummyLinker\makeSelfLinkObj(), LinkHolderArray\replaceInternal(), and Parser\replaceInternalLinks2().

◆ makeThumbLink2()

static Linker::makeThumbLink2 ( Title  $title,
  $file,
  $frameParams = [],
  $handlerParams = [],
  $time = false,
  $query = "" 
)
static
Parameters
Title$title
File$file
array$frameParams
array$handlerParams
bool$time
string$query
Returns
string

Definition at line 517 of file Linker.php.

References $handlerParams, $params, $query, $s, $time, Title\getLocalURL(), Title\makeTitleSafe(), NS_FILE, Html\rawElement(), text, wfAppendQuery(), wfFindFile(), and wfMessage().

Referenced by DummyLinker\makeThumbLink2().

◆ makeThumbLinkObj()

static Linker::makeThumbLinkObj ( Title  $title,
  $file,
  $label = '',
  $alt = '',
  $align = 'right',
  $params = [],
  $framed = false,
  $manualthumb = "" 
)
static

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

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

Definition at line 491 of file Linker.php.

References $params.

Referenced by DummyLinker\makeThumbLinkObj(), and ImagePage\openShowImage().

◆ normaliseSpecialPage()

◆ normalizeSubpageLink()

static Linker::normalizeSubpageLink (   $contextTitle,
  $target,
$text 
)
static
Parameters
Title$contextTitle
string$target
string&$text
Returns
string

Definition at line 1361 of file Linker.php.

References $ret, below(), change, MWNamespace\hasSubpages(), is, and page.

Referenced by formatLinksInComment(), Parser\maybeDoSubpageLink(), and DummyLinker\normalizeSubpageLink().

◆ processResponsiveImages()

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

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

Parameters
File$file
MediaTransformOutput$thumb
array$hpImage parameters

Definition at line 639 of file Linker.php.

References $wgResponsiveImages.

Referenced by ImagePage\openShowImage(), DummyLinker\processResponsiveImages(), and TraditionalImageGallery\toHTML().

◆ revComment()

static Linker::revComment ( Revision  $rev,
  $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.

Since
1.16.3
Parameters
Revision$rev
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 1478 of file Linker.php.

References Revision\DELETED_COMMENT, Revision\FOR_THIS_USER, Revision\getComment(), Revision\getTitle(), Revision\isDeleted(), Revision\RAW, Revision\userCan(), and wfMessage().

Referenced by SpecialUndelete\diffHeader(), DeletedContribsPager\formatRevisionRow(), SpecialMergeHistory\formatRevisionRow(), SpecialUndelete\formatRevisionRow(), SpecialNewpages\formatRow(), ContribsPager\formatRow(), ChangeTagsRevisionItem\getHTML(), RevDelRevisionItem\getHTML(), RevisionItem\getHTML(), HistoryPager\historyLine(), DummyLinker\revComment(), Article\setOldSubtitle(), and DifferenceEngine\showDiffPage().

◆ revDeleteLink()

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

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

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 2106 of file Linker.php.

References $html, $link, $query, SpecialPage\getTitleFor(), link, Xml\tags(), and wfMessage().

Referenced by SpecialUndelete\formatFileRow(), LogEventsList\getShowHideLinks(), HistoryPager\historyLine(), ImageHistoryList\imageHistoryLine(), and DummyLinker\revDeleteLink().

◆ revDeleteLinkDisabled()

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

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

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 2128 of file Linker.php.

References $html, Xml\tags(), and wfMessage().

Referenced by SpecialUndelete\formatFileRow(), LogEventsList\getShowHideLinks(), HistoryPager\historyLine(), ImageHistoryList\imageHistoryLine(), and DummyLinker\revDeleteLinkDisabled().

◆ revUserLink()

static Linker::revUserLink (   $rev,
  $isPublic = false 
)
static

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

Since
1.16.3
Parameters
Revision$rev
bool$isPublicShow only if all users can see it
Returns
string HTML fragment

Definition at line 1032 of file Linker.php.

References $link, $rev, Revision\DELETED_USER, Revision\FOR_THIS_USER, and wfMessage().

Referenced by ChangeTagsRevisionItem\getHTML(), RevDelRevisionItem\getHTML(), RevisionItem\getHTML(), and DummyLinker\revUserLink().

◆ revUserTools()

static Linker::revUserTools (   $rev,
  $isPublic = false 
)
static

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

Since
1.16.3
Parameters
Revision$rev
bool$isPublicShow only if all users can see it
Returns
string HTML

Definition at line 1054 of file Linker.php.

References $link, $rev, Revision\DELETED_USER, Revision\FOR_THIS_USER, and wfMessage().

Referenced by SpecialUndelete\diffHeader(), SpecialMergeHistory\formatRevisionRow(), SpecialUndelete\formatRevisionRow(), SpecialNewpages\formatRow(), HistoryPager\historyLine(), RollbackAction\onView(), InfoAction\pageInfo(), DummyLinker\revUserTools(), Article\setOldSubtitle(), DifferenceEngine\showDiffPage(), and SpecialUndelete\showRevision().

◆ specialLink()

static 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 808 of file Linker.php.

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

Referenced by DummyLinker\specialLink().

◆ splitTrail()

static 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
array

Definition at line 1678 of file Linker.php.

Referenced by formatLinksInComment(), LinkHolderArray\makeHolder(), Parser\makeKnownLinkHolder(), Parser\replaceExternalLinks(), and DummyLinker\splitTrail().

◆ titleAttrib()

static Linker::titleAttrib (   $name,
  $options = null,
array  $msgParams = [] 
)
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
Returns
string Contents of the title attribute (which you must HTML- escape), or false for no title attribute

Definition at line 1981 of file Linker.php.

References $name, $options, array(), and wfMessage().

Referenced by OOUIHTMLForm\getButtons(), EditPage\getCheckboxesWidget(), EditPage\getEditButtons(), EditPage\getSummaryInputWidget(), HTMLFormField\getTooltipAndAccessKeyOOUI(), BaseTemplate\makeLink(), DifferenceEngine\showDiffPage(), EditPage\showEditForm(), and DummyLinker\titleAttrib().

◆ tocIndent()

static Linker::tocIndent ( )
static

Add another level to the Table of Contents.

Since
1.16.3
Returns
string

Definition at line 1519 of file Linker.php.

Referenced by Parser\formatHeadings(), SpecialEditWatchlist\getNormalForm(), and DummyLinker\tocIndent().

◆ tocLine()

static Linker::tocLine (   $anchor,
  $tocline,
  $tocnumber,
  $level,
  $sectionIndex = false 
)
static

parameter level defines if we are on an indentation level

Since
1.16.3
Parameters
string$anchor
string$tocline
string$tocnumber
string$level
string | bool$sectionIndex
Returns
string

Definition at line 1545 of file Linker.php.

References Html\element(), Html\openElement(), and Html\rawElement().

Referenced by Parser\formatHeadings(), SpecialEditWatchlist\getNormalForm(), and DummyLinker\tocLine().

◆ tocLineEnd()

static 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 1569 of file Linker.php.

Referenced by Parser\formatHeadings(), SpecialEditWatchlist\getNormalForm(), and DummyLinker\tocLineEnd().

◆ tocList()

static Linker::tocList (   $toc,
  $lang = false 
)
static

Wraps the TOC in a table and provides the hide/collapse javascript.

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

Definition at line 1581 of file Linker.php.

References $lang, $title, Html\element(), Html\label(), Html\openElement(), wfGetLangObj(), and wfMessage().

Referenced by Parser\formatHeadings(), SpecialEditWatchlist\getNormalForm(), and DummyLinker\tocList().

◆ tocUnindent()

static 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 1530 of file Linker.php.

Referenced by Parser\formatHeadings(), and DummyLinker\tocUnindent().

◆ tooltip()

static 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 2175 of file Linker.php.

References $name, $options, and Xml\expandAttributes().

Referenced by DummyLinker\tooltip().

◆ tooltipAndAccesskeyAttribs()

static Linker::tooltipAndAccesskeyAttribs (   $name,
array  $msgParams = [],
  $options = 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.
See also
Linker::titleAttrib for what options could be passed to $options.
Returns
array

Definition at line 2147 of file Linker.php.

References $attribs, $name, $options, and array().

Referenced by McrUndoAction\alterForm(), VFormHTMLForm\getButtons(), HTMLForm\getButtons(), HistoryPager\getStartBody(), HTMLFormField\getTooltipAndAccessKey(), BaseTemplate\makeLink(), BaseTemplate\makeSearchButton(), BaseTemplate\makeSearchInput(), UserrightsPage\showEditUserGroupsForm(), SpecialImport\showForm(), and DummyLinker\tooltipAndAccesskeyAttribs().

◆ userLink()

static Linker::userLink (   $userId,
  $userName,
  $altUserName = false 
)
static

◆ userTalkLink()

static 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 987 of file Linker.php.

References link, Title\makeTitle(), NS_USER_TALK, and wfMessage().

Referenced by ContribsPager\formatRow(), and DummyLinker\userTalkLink().

◆ userToolLinks()

static Linker::userToolLinks (   $userId,
  $userText,
  $redContribsWhenNoEdits = false,
  $flags = 0,
  $edits = null 
)
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)
Returns
string HTML fragment

Definition at line 915 of file Linker.php.

References $attribs, $user, $wgDisableAnonTalk, $wgLang, SpecialPage\getTitleFor(), ExternalUserNames\isExternal(), link, User\newFromId(), Hooks\run(), and wfMessage().

Referenced by FileDuplicateSearchPage\formatResult(), ActiveUsersPager\formatRow(), BlockListPager\formatValue(), ProtectedPagesPager\formatValue(), SpecialUndelete\getFileUser(), RevDelFileItem\getUserTools(), ImageHistoryList\imageHistoryLine(), ChangesList\insertUserRelatedLinks(), LogFormatter\makeUserLink(), RCCacheEntryFactory\newFromRecentChange(), UserrightsPage\showEditUserGroupsForm(), and DummyLinker\userToolLinks().

◆ userToolLinksRedContribs()

static Linker::userToolLinksRedContribs (   $userId,
  $userText,
  $edits = null 
)
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)
Returns
string

Definition at line 977 of file Linker.php.

Referenced by UsersPager\formatRow(), LogFormatterTest\testNormalLogParams(), and DummyLinker\userToolLinksRedContribs().

Member Data Documentation

◆ $accesskeycache

Linker::$accesskeycache
static

Definition at line 2016 of file Linker.php.

◆ TOOL_LINKS_EMAIL

const Linker::TOOL_LINKS_EMAIL = 2

Definition at line 39 of file Linker.php.

Referenced by UserrightsPage\showEditUserGroupsForm().

◆ TOOL_LINKS_NOBLOCK

const Linker::TOOL_LINKS_NOBLOCK = 1

Flags for userToolLinks()

Definition at line 38 of file Linker.php.

Referenced by BlockListPager\formatValue(), and BlockLogFormatter\getMessageParameters().


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