[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/includes/ -> Linker.php (summary)

Methods to make links and related items. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

File Size: 2400 lines (79 kb)
Included or required:0 times
Referenced: 2 times
Includes or requires: 0 files

Defines 2 classes

Linker:: (66 methods):
  getExternalLinkAttributes()
  getInterwikiLinkAttributes()
  getInternalLinkAttributes()
  getInternalLinkAttributesObj()
  getLinkAttributesInternal()
  getLinkColour()
  link()
  linkKnown()
  linkUrl()
  linkAttribs()
  linkText()
  makeSelfLinkObj()
  getInvalidTitleDescription()
  normaliseSpecialPage()
  fnamePart()
  makeExternalImage()
  makeImageLink()
  makeImageLink2()
  getImageLinkMTOParams()
  makeThumbLinkObj()
  makeThumbLink2()
  processResponsiveImages()
  makeBrokenImageLinkObj()
  getUploadUrl()
  makeMediaLinkObj()
  makeMediaLinkFile()
  specialLink()
  makeExternalLink()
  userLink()
  userToolLinks()
  userToolLinksRedContribs()
  userTalkLink()
  blockLink()
  emailLink()
  revUserLink()
  revUserTools()
  formatComment()
  formatAutocomments()
  formatLinksInComment()
  normalizeSubpageLink()
  commentBlock()
  revComment()
  formatRevisionSize()
  tocIndent()
  tocUnindent()
  tocLine()
  tocLineEnd()
  tocList()
  generateTOC()
  makeHeadline()
  splitTrail()
  generateRollback()
  getRollbackEditCount()
  buildRollbackLink()
  formatTemplates()
  formatHiddenCategories()
  formatSize()
  titleAttrib()
  accesskey()
  getRevDeleteLink()
  revDeleteLink()
  revDeleteLinkDisabled()
  makeLinkObj()
  makeKnownLinkObj()
  tooltipAndAccesskeyAttribs()
  tooltip()

DummyLinker:: (1 method):
  __call()


Class: Linker  - X-Ref

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.

getExternalLinkAttributes( $class = 'external' )   X-Ref
Get the appropriate HTML attributes to add to the "a" element of an
external link, as created by [wikisyntax].

param: string $class The contents of the class attribute; if an empty
return: string

getInterwikiLinkAttributes( $title, $unused = null, $class = 'external' )   X-Ref
Get the appropriate HTML attributes to add to the "a" element of an interwiki link.

param: string $title The title text for the link, URL-encoded (???) but
param: string $unused Unused
param: string $class The contents of the class attribute; if an empty
return: string

getInternalLinkAttributes( $title, $unused = null, $class = '' )   X-Ref
Get the appropriate HTML attributes to add to the "a" element of an internal link.

param: string $title The title text for the link, URL-encoded (???) but
param: string $unused Unused
param: string $class The contents of the class attribute, default none
return: string

getInternalLinkAttributesObj( $nt, $unused = null, $class = '', $title = false )   X-Ref
Get the appropriate HTML attributes to add to the "a" element of an internal
link, given the Title object for the page we want to link to.

param: Title $nt
param: string $unused Unused
param: string $class The contents of the class attribute, default none
param: string|bool $title Optional (unescaped) string to use in the title
return: string

getLinkAttributesInternal( $title, $class )   X-Ref
Common code for getLinkAttributesX functions

param: string $title
param: string $class
return: string

getLinkColour( $t, $threshold )   X-Ref
Return the CSS colour of a known link

param: Title $t
param: int $threshold User defined threshold
return: string CSS class

link($target, $html = null, $customAttribs = array()   X-Ref
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.

param: Title $target Can currently only be a Title, but this may
param: string $html The HTML contents of the <a> element, i.e.,
param: array $customAttribs A key => value array of extra HTML attributes,
param: array $query The query string to append to the URL
param: string|array $options String or array of strings:
return: string HTML <a> attribute

linkKnown($target, $html = null, $customAttribs = array()   X-Ref
Identical to link(), except $options defaults to 'known'.

return: string

linkUrl( $target, $query, $options )   X-Ref
Returns the Url used to link to a Title

param: Title $target
param: array $query Query parameters
param: array $options
return: string

linkAttribs( $target, $attribs, $options )   X-Ref
Returns the array of attributes used when linking to the Title $target

param: Title $target
param: array $attribs
param: array $options
return: array

linkText( $target )   X-Ref
Default text of the links to the Title $target

param: Title $target
return: string

makeSelfLinkObj( $nt, $html = '', $query = '', $trail = '', $prefix = '' )   X-Ref
Make appropriate markup for a link to the current article. This is
currently rendered as the bold link text. The calling sequence is the
same as the other make*LinkObj static functions, despite $query not
being used.

param: Title $nt
param: string $html [optional]
param: string $query [optional]
param: string $trail [optional]
param: string $prefix [optional]
return: string

getInvalidTitleDescription( IContextSource $context, $namespace, $title )   X-Ref
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.

param: IContextSource $context Context to use to get the messages
param: int $namespace Namespace number
param: string $title Text of the title, without the namespace part
return: string

normaliseSpecialPage( Title $title )   X-Ref

param: Title $title
return: Title

fnamePart( $url )   X-Ref
Returns the filename part of an url.
Used as alternative text for external images.

param: string $url
return: string

makeExternalImage( $url, $alt = '' )   X-Ref
Return the code for images which were added via external links,
via Parser::maybeMakeExternalImage().

param: string $url
param: string $alt
return: string

makeImageLink( Parser $parser, Title $title,$file, $frameParams = array()   X-Ref
Given parameters derived from [[Image:Foo|options...]], generate the
HTML that that syntax inserts in the page.

param: Parser $parser
param: Title $title Title object of the file (not the currently viewed page)
param: File $file File object, or false if it doesn't exist
param: array $frameParams Associative array of parameters external to the media handler.
param: array $handlerParams Associative array of media handler parameters, to be passed
param: string|bool $time Timestamp of the file, set as false for current
param: string $query Query params for desc url
param: int|null $widthOption Used by the parser to remember the user preference thumbnailsize
return: string HTML for an image, with links, wrappers, etc.

makeImageLink2( Title $title, $file, $frameParams = array()   X-Ref
See makeImageLink()
When this function is removed, remove if( $parser instanceof Parser ) check there too


getImageLinkMTOParams( $frameParams, $query = '', $parser = null )   X-Ref
Get the link parameters for MediaTransformOutput::toHtml() from given
frame parameters supplied by the Parser.

param: array $frameParams The frame parameters
param: string $query An optional query string to add to description page links
param: Parser|null $parser
return: array

makeThumbLinkObj( Title $title, $file, $label = '', $alt,$align = 'right', $params = array()   X-Ref
Make HTML for a thumbnail including image, border and caption

param: Title $title
param: File|bool $file File object or false if it doesn't exist
param: string $label
param: string $alt
param: string $align
param: array $params
param: bool $framed
param: string $manualthumb
return: string

makeThumbLink2( Title $title, $file, $frameParams = array()   X-Ref

param: Title $title
param: File $file
param: array $frameParams
param: array $handlerParams
param: bool $time
param: string $query
return: string

processResponsiveImages( $file, $thumb, $hp )   X-Ref
Process responsive images: add 1.5x and 2x subimages to the thumbnail, where
applicable.

param: File $file
param: MediaTransformOutput $thumb
param: array $hp Image parameters

makeBrokenImageLinkObj( $title, $label = '',$query = '', $unused1 = '', $unused2 = '', $time = false)   X-Ref
Make a "broken" link to an image

param: Title $title
param: string $label Link label (plain text)
param: string $query Query string
param: string $unused1 Unused parameter kept for b/c
param: string $unused2 Unused parameter kept for b/c
param: bool $time A file of a certain timestamp was requested
return: string

getUploadUrl( $destFile, $query = '' )   X-Ref
Get the URL to upload a certain file

param: Title $destFile Title object of the file to upload
param: string $query Urlencoded query string to prepend
return: string Urlencoded URL

makeMediaLinkObj( $title, $html = '', $time = false )   X-Ref
Create a direct link to a given uploaded file.

param: Title $title
param: string $html Pre-sanitized HTML
param: string $time MW timestamp of file creation time
return: string HTML

makeMediaLinkFile( Title $title, $file, $html = '' )   X-Ref
Create a direct link to a given uploaded file.
This will make a broken link if $file is false.

param: Title $title
param: File|bool $file File object or false
param: string $html Pre-sanitized HTML
return: string HTML

specialLink( $name, $key = '' )   X-Ref
Make a link to a special page given its name and, optionally,
a message key from the link text.
Usage example: Linker::specialLink( 'Recentchanges' )

param: string $name
param: string $key
return: string

makeExternalLink( $url, $text, $escape = true,$linktype = '', $attribs = array()   X-Ref
Make an external link

param: string $url URL to link to
param: string $text Text of link
param: bool $escape Do we escape the link text?
param: string $linktype Type of external link. Gets added to the classes
param: array $attribs Array of extra attributes to <a>
param: Title|null $title Title object used for title specific link attributes
return: string

userLink( $userId, $userName, $altUserName = false )   X-Ref
Make user link (or user contributions for unregistered users)

param: int $userId User id in database.
param: string $userName User name in database.
param: string $altUserName Text to display instead of the user name (optional)
return: string HTML fragment

userToolLinks($userId, $userText, $redContribsWhenNoEdits = false, $flags = 0, $edits = null)   X-Ref
Generate standard user tool links (talk, contributions, block link, etc.)

param: int $userId User identifier
param: string $userText User name or IP address
param: bool $redContribsWhenNoEdits Should the contributions link be
param: int $flags Customisation flags (e.g. Linker::TOOL_LINKS_NOBLOCK
param: int $edits User edit count (optional, for performance)
return: string HTML fragment

userToolLinksRedContribs( $userId, $userText, $edits = null )   X-Ref
Alias for userToolLinks( $userId, $userText, true );

param: int $userId User identifier
param: string $userText User name or IP address
param: int $edits User edit count (optional, for performance)
return: string

userTalkLink( $userId, $userText )   X-Ref

param: int $userId User id in database.
param: string $userText User name in database.
return: string HTML fragment with user talk link

blockLink( $userId, $userText )   X-Ref

param: int $userId Userid
param: string $userText User name in database.
return: string HTML fragment with block link

emailLink( $userId, $userText )   X-Ref

param: int $userId Userid
param: string $userText User name in database.
return: string HTML fragment with e-mail user link

revUserLink( $rev, $isPublic = false )   X-Ref
Generate a user link if the current user is allowed to view it

param: Revision $rev
param: bool $isPublic Show only if all users can see it
return: string HTML fragment

revUserTools( $rev, $isPublic = false )   X-Ref
Generate a user tool link cluster if the current user is allowed to view it

param: Revision $rev
param: bool $isPublic Show only if all users can see it
return: string HTML

formatComment( $comment, $title = null, $local = false )   X-Ref
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 <[email protected]>
param: string $comment
param: Title|null $title Title object (to generate link to the section in autocomment) or null
param: bool $local Whether section links should refer to local page
return: mixed|string

formatAutocomments( $comment, $title = null, $local = false )   X-Ref
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.

param: string $comment Comment text
param: Title|null $title An optional title object used to links to sections
param: bool $local Whether section links should refer to local page
return: string Formatted comment

formatLinksInComment( $comment, $title = null, $local = false )   X-Ref
No description

normalizeSubpageLink( $contextTitle, $target, &$text )   X-Ref
No description

commentBlock( $comment, $title = null, $local = false )   X-Ref
Wrap a comment in standard punctuation and formatting if
it's non-empty, otherwise return empty string.

param: string $comment
param: Title|null $title Title object (to generate link to section in autocomment) or null
param: bool $local Whether section links should refer to local page
return: string

revComment( Revision $rev, $local = false, $isPublic = false )   X-Ref
Wrap and format the given revision's comment block, if the current
user is allowed to view it.

param: Revision $rev
param: bool $local Whether section links should refer to local page
param: bool $isPublic Show only if all users can see it
return: string HTML fragment

formatRevisionSize( $size )   X-Ref

param: int $size
return: string

tocIndent()   X-Ref
Add another level to the Table of Contents

return: string

tocUnindent( $level )   X-Ref
Finish one or more sublevels on the Table of Contents

param: int $level
return: string

tocLine( $anchor, $tocline, $tocnumber, $level, $sectionIndex = false )   X-Ref
parameter level defines if we are on an indentation level

param: string $anchor
param: string $tocline
param: string $tocnumber
param: string $level
param: string|bool $sectionIndex
return: string

tocLineEnd()   X-Ref
End a Table Of Contents line.
tocUnindent() will be used instead if we're ending a line below
the new level.

return: string

tocList( $toc, $lang = false )   X-Ref
Wraps the TOC in a table and provides the hide/collapse javascript.

param: string $toc Html of the Table Of Contents
param: string|Language|bool $lang Language for the toc title, defaults to user language
return: string Full html of the TOC

generateTOC( $tree )   X-Ref
Generate a table of contents from a section tree
Currently unused.

param: array $tree Return value of ParserOutput::getSections()
return: string HTML fragment

makeHeadline( $level, $attribs, $anchor, $html,$link, $legacyAnchor = false)   X-Ref
Create a headline for content

param: int $level The level of the headline (1-6)
param: string $attribs Any attributes for the headline, starting with
param: string $anchor The anchor to give the headline (the bit after the #)
param: string $html Html for the text of the header
param: string $link HTML to add for the section edit link
param: bool|string $legacyAnchor A second, optional anchor to give for
return: string HTML headline

splitTrail( $trail )   X-Ref
Split a link trail, return the "inside" portion and the remainder of the trail
as a two-element array

param: string $trail
return: array

generateRollback( $rev, IContextSource $context = null,$options = array( 'verify' )   X-Ref
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 []

param: Revision $rev
param: IContextSource $context Context to use or null for the main context.
param: array $options
return: string

getRollbackEditCount( $rev, $verify )   X-Ref
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.

param: Revision $rev
param: bool $verify Try to verify that this revision can really be rolled back
return: int|bool|null

buildRollbackLink( $rev, IContextSource $context = null,$editCount = false)   X-Ref
Build a raw rollback link, useful for collections of "tool" links

param: Revision $rev
param: IContextSource|null $context Context to use or null for the main context.
param: int $editCount Number of edits that would be reverted
return: string HTML fragment

formatTemplates( $templates, $preview = false,$section = false, $more = null)   X-Ref
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().

param: array $templates Array of templates from Article::getUsedTemplate or similar
param: bool $preview Whether this is for a preview
param: bool $section Whether this is for a section edit
param: Title|Message|string|null $more An escaped link for "More..." of the templates
return: string HTML output

formatHiddenCategories( $hiddencats )   X-Ref
Returns HTML for the "hidden categories on this page" list.

param: array $hiddencats Array of hidden categories from Article::getHiddenCategories
return: string HTML output

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

param: int $size Size to format
return: string

titleAttrib( $name, $options = null )   X-Ref
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.)

param: string $name Id of the element, minus prefixes.
param: string|null $options Null or the string 'withaccess' to add an access-
return: string Contents of the title attribute (which you must HTML-

accesskey( $name )   X-Ref
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.)

param: string $name Id of the element, minus prefixes.
return: string Contents of the accesskey attribute (which you must HTML-

getRevDeleteLink( User $user, Revision $rev, Title $title )   X-Ref
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.

param: User $user
param: Revision $rev
param: Title $title
return: string HTML fragment

revDeleteLink( $query = array()   X-Ref
Creates a (show/hide) link for deleting revisions/log entries

param: array $query Query parameters to be passed to link()
param: bool $restricted Set to true to use a "<strong>" instead of a "<span>"
param: bool $delete Set to true to use (show/hide) rather than (show)
return: string HTML "<a>" link to Special:Revisiondelete, wrapped in a

revDeleteLinkDisabled( $delete = true )   X-Ref
Creates a dead (show/hide) link for deleting revisions/log entries

param: bool $delete Set to true to use (show/hide) rather than (show)
return: string HTML text wrapped in a span to allow for customization

makeLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' )   X-Ref

param: Title $nt The title object to make the link from, e.g. from Title::newFromText.
param: string $text Link text
param: string $query Optional query part
param: string $trail Optional trail. Alphabetic characters at the start of this string will
param: string $prefix Optional prefix. As trail, only before instead of after.
return: string

makeKnownLinkObj($title, $text = '', $query = '', $trail = '', $prefix = '', $aprops = '', $style = '')   X-Ref

param: Title $title Title object of target page
param: string $text Text to replace the title
param: string $query Link target
param: string $trail Text after link
param: string $prefix Text before link text
param: string $aprops Extra attributes to the a-element
param: string $style Style to apply - if empty, use getInternalLinkAttributesObj instead
return: string The a-element

tooltipAndAccesskeyAttribs( $name )   X-Ref
Returns the attributes for the tooltip and access key.

param: string $name
return: array

tooltip( $name, $options = null )   X-Ref
Returns raw bits of HTML, use titleAttrib()

param: string $name
param: array|null $options
return: null|string

Class: DummyLinker  - X-Ref


__call( $fname, $args )   X-Ref
Use PHP's magic __call handler to transform instance calls to a dummy instance
into static calls to the new Linker for backwards compatibility.

param: string $fname Name of called method
param: array $args Arguments to the method
return: mixed



Generated: Fri Nov 28 14:03:12 2014 Cross-referenced by PHPXref 0.7.1