MediaWiki master
Skin Class Reference

The base class for all skins. More...

Inherits MediaWiki\Context\ContextSource.

Inherited by SkinTemplate.

Collaboration diagram for Skin:

Public Member Functions

 __construct ( $options=null)
 
 addToSidebar (&$bar, $message)
 Add content from a sidebar system message Currently only used for MediaWiki:Sidebar (but may be used by Extensions)
 
 addToSidebarPlain (&$bar, $text)
 Add content from plain text.
 
 buildSidebar ()
 Build an array that represents the sidebar(s), the navigation bar among them.
 
 doEditSectionLink (Title $nt, $section, $sectionTitle, Language $lang)
 Create a section edit link.
 
 editUrlOptions ()
 Return URL options for the 'edit page' link.
 
 getAfterPortlet (string $name)
 Allows extensions to hook into known portlets and add stuff to them.
 
 getCategories ()
 
 getCategoryLinks ()
 
 getCopyright ()
 
 getDefaultModules ()
 Defines the ResourceLoader modules that should be added to the skin It is recommended that skins wishing to override call parent::getDefaultModules() and substitute out any modules they wish to change by using a key to look them up.
 
 getFooterIcons ()
 Get template representation of the footer.
 
 getHtmlElementAttributes ()
 Return values for <html> element.
 
 getLanguages ()
 Generates array of language links for the current page.
 
 getNewtalks ()
 Gets new talk page messages for the current user and returns an appropriate alert message (or an empty string if there are no messages)
 
 getOptions ()
 Get current skin's options.
 
 getPageClasses ( $title)
 TODO: document.
 
 getPersonalToolsForMakeListItem ( $urls, $applyClassesToListItems=false)
 Create an array of personal tools items from the data in the quicktemplate stored by SkinTemplate.
 
 getRelevantTitle ()
 Return the "relevant" title.
 
 getRelevantUser ()
 Return the "relevant" user.
 
 getSiteNotice ()
 
 getSkinName ()
 
 getTemplateData ()
 
 getUndeleteLink ()
 
 initPage (OutputPage $out)
 
 isResponsive ()
 Indicates if this skin is responsive.
 
 logoText ( $align='')
 
 makeFooterIcon ( $icon, $withImage='withImage')
 Renders a $wgFooterIcons icon according to the method's arguments.
 
 makeLink ( $key, $item, $linkOptions=[])
 Makes a link, usually used by makeListItem to generate a link for an item in a list used in navigation lists, portlets, portals, sidebars, etc...
 
 makeListItem ( $key, $item, $options=[])
 Generates a list item for a navigation, portlet, portal, sidebar... list.
 
 makeToolbox ( $navUrls, $feedUrls)
 Create an array of common toolbox items from the data in the quicktemplate stored by SkinTemplate.
 
 mapInterwikiToLanguage ( $code)
 Allows correcting the language of interlanguage links which, mostly due to legacy reasons, do not always match the standards compliant language tag.
 
 outputPage ()
 Outputs the HTML generated by other functions.
 
 outputPageFinal (OutputPage $out)
 Outputs the HTML for the page.
 
 prepareSubtitle (bool $withContainer=true)
 Prepare the subtitle of the page for output in the skin if one has been set.
 
 printSource ()
 Text with the permalink to the source page, usually shown on the footer of a printed page.
 
 setRelevantTitle ( $t)
 
 setRelevantUser (?UserIdentity $u)
 
 showEmailUser ( $id)
 
 supportsMenu (string $menu)
 Does the skin support the named menu? e.g.
 
- Public Member Functions inherited from MediaWiki\Context\ContextSource
 canUseWikiPage ()
 Check whether a WikiPage object can be get with getWikiPage().
 
 exportSession ()
 Export the resolved user IP, HTTP headers, user ID, and session ID.
 
 getActionName ()
 Get the action name for the current web request.
 
 getAuthority ()
 
 getConfig ()
 
 getContext ()
 Get the base IContextSource object.
 
 getCsrfTokenSet ()
 Get a repository to obtain and match CSRF tokens.
 
 getLanguage ()
 
 getLanguageCode ()
 
 getOutput ()
 
 getRequest ()
 
 getSkin ()
 
 getTiming ()
 
 getTitle ()
 
 getUser ()
 
 getWikiPage ()
 Get the WikiPage object.
 
 msg ( $key,... $params)
 Get a Message object with context set Parameters are the same as wfMessage()
 
 setContext (IContextSource $context)
 

Static Public Member Functions

static getPortletLinkOptions (RL\Context $context)
 Returns skin options for portlet links, used by addPortletLink.
 
static getVersion ()
 Get the current major version of Skin.
 
static makeInternalOrExternalUrl ( $name)
 If url string starts with http, consider as external URL, else internal.
 
static makeMainPageUrl ( $urlaction='')
 
static makeSpecialUrl ( $name, $urlaction='', $proto=null)
 Make a URL for a Special Page using the given query and protocol.
 
static makeSpecialUrlSubpage ( $name, $subpage, $urlaction='')
 
static normalizeKey (string $key)
 Normalize a skin preference value to a form that can be loaded.
 

Protected Member Functions

 afterContentHook ()
 This runs a hook to allow extensions placing their stuff after content and article metadata (e.g.
 
 buildFeedUrls ()
 Build data structure representing syndication links.
 
 buildNavUrls ()
 Build array of common navigation links.
 
 doEditSectionLinksHTML (array $links, Language $lang)
 
 getComponent (string $name)
 
 getIndicatorsData ( $indicators)
 Return an array of indicator data.
 
 getJsConfigVars ()
 Returns array of config variables that should be added only to this skin for use in JavaScript.
 
 getPortletData (string $name, array $items)
 
 getUserLanguageAttributes ()
 Get user language attribute links array.
 
 prepareUndeleteLink ()
 Prepare undelete link for output in page.
 
 prepareUserLanguageAttributes ()
 Prepare user language attribute links.
 
 wrapHTML ( $title, $html)
 Wrap the body text with language information and identifiable element.
 

Static Protected Member Functions

static makeKnownUrlDetails ( $name, $urlaction='')
 Make URL details where the article exists (or at least it's convenient to think so)
 
static makeUrlDetails ( $name, $urlaction='')
 these return an array with the 'href' and boolean 'exists'
 

Protected Attributes

Title null $mRelevantTitle = null
 
array $options = []
 Skin options passed into constructor.
 
string null $skinname = null
 
const VERSION_MAJOR = 1
 The current major version of the skin specification.
 

Detailed Description

The base class for all skins.

See docs/Skin.md for more information.

Stability: stable
to extend

Definition at line 65 of file Skin.php.

Constructor & Destructor Documentation

◆ __construct()

Skin::__construct ( $options = null)
Since
1.31
Parameters
string | array | null$optionsOptions for the skin can be an array (since 1.35). When a string is passed, it's the skinname. When an array is passed:
  • name: Required. Internal skin name, generally in lowercase to comply with conventions for interface message keys and CSS class names which embed this value.
  • format: Enable rendering of skin as json or html.

    Since: MW 1.43 Default: html

  • styles: ResourceLoader style modules to load on all pages. Default: []
  • scripts: ResourceLoader script modules to load on all pages. Default: []
  • toc: Whether a table of contents is included in the main article content area. If your skin has place a table of contents elsewhere (for example, the sidebar), set this to false.

    See ParserOutput::getText() for the implementation logic.

    Default: true

  • bodyClasses: An array of extra class names to add to the HTML <body> element. Default: []
  • clientPrefEnabled: Enable support for mw.user.clientPrefs. This instructs OutputPage and ResourceLoader\ClientHtml to include an inline script in web responses for unregistered users to switch HTML classes as needed.

    Since: MW 1.41 Default: false

  • wrapSiteNotice: Enable support for standard site notice wrapper. This instructs the Skin to wrap banners in div::siteNotice.

    Since: MW 1.42 Default: false

  • responsive: Whether the skin supports responsive behaviour and wants a viewport meta tag to be added to the HTML head. Note, users can disable this feature via a user preference.

    Default: false

  • supportsMwHeading: Whether the skin supports new HTML markup for headings, which uses <div class="mw-heading"> tags (https://www.mediawiki.org/wiki/Heading_HTML_changes). If false, MediaWiki will output the legacy markup instead.

    Since: MW 1.43 Default: false (will become true in and then will be removed in the future)

  • link: An array of link option overriddes. See Skin::makeLink for the available options.

    Default: []

  • tempUserBanner: Whether to display a banner on page views by in temporary user sessions. This will prepend SkinComponentTempUserBanner to the <body> above everything else. See also MediaWiki\MainConfigSchema::AutoCreateTempUser and User::isTemp.

    Default: false

  • menus: Which menus the skin supports, to allow features like SpecialWatchlist to render their own navigation in the skins that don't support certain menus. For any key in the array, the skin is promising to render an element e.g. the presence of associated-pages means the skin will render a menu compatible with mw.util.addPortletLink which has the ID p-associated-pages.

    Default: ‘['namespaces’, 'views', 'actions', 'variants']`

    Opt-in menus:

    • associated-pages
    • notifications
    • user-interface-preferences
    • user-page
    • user-menu

Definition at line 353 of file Skin.php.

Member Function Documentation

◆ addToSidebar()

Skin::addToSidebar ( & $bar,
$message )

Add content from a sidebar system message Currently only used for MediaWiki:Sidebar (but may be used by Extensions)

This is just a wrapper around addToSidebarPlain() for backwards compatibility

Parameters
array&$bar
string$message

Definition at line 1636 of file Skin.php.

◆ addToSidebarPlain()

Skin::addToSidebarPlain ( & $bar,
$text )

Add content from plain text.

Since
1.17
Parameters
array&$bar
string$text
Returns
array

Definition at line 1647 of file Skin.php.

References $lines, and getTitle().

◆ afterContentHook()

Skin::afterContentHook ( )
protected

This runs a hook to allow extensions placing their stuff after content and article metadata (e.g.

categories). Note: This function has nothing to do with afterContent().

This hook is placed here in order to allow using the same hook for all skins, both the SkinTemplate based ones and the older ones, which directly use this class to get their data.

The output of this function gets processed in SkinTemplate::outputPage() for the SkinTemplate based skins, all other skins should directly echo it.

Returns
string Empty by default, if not changed by any hook function.

Definition at line 874 of file Skin.php.

References wfDebug().

Referenced by SkinMustache\getTemplateData(), and SkinTemplate\prepareQuickTemplate().

◆ buildFeedUrls()

Skin::buildFeedUrls ( )
finalprotected

Build data structure representing syndication links.

Since
1.35
Returns
array

Definition at line 1532 of file Skin.php.

Referenced by SkinTemplate\prepareQuickTemplate().

◆ buildNavUrls()

Skin::buildNavUrls ( )
protected

Build array of common navigation links.

Assumes thispage property has been set before execution.

Since
1.35
Returns
array

Definition at line 1370 of file Skin.php.

References getTitle(), NS_CATEGORY, and MediaWiki\SpecialPage\SpecialPage\setContext().

Referenced by SkinTemplate\prepareQuickTemplate().

◆ buildSidebar()

Skin::buildSidebar ( )

Build an array that represents the sidebar(s), the navigation bar among them.

BaseTemplate::getSidebar can be used to simplify the format and id generation in new skins.

The format of the returned array is [ heading => content, ... ], where:

  • heading is the heading of a navigation portlet. It is either:
    • magic string to be handled by the skins ('SEARCH' / 'LANGUAGES' / 'TOOLBOX' / ...) (Note that 'SEARCH' unlike others is not supported out-of-the-box by the skins. For it to work, a skin must add custom support for it.)
    • a message name (e.g. 'navigation'), the message should be HTML-escaped by the skin
    • plain text, which should be HTML-escaped by the skin
  • content is the contents of the portlet.
    • For keys that aren't magic strings, this is an array of link data, where the array items are arrays in the format expected by the $item parameter of self::makeListItem().
    • For magic strings, the format varies. For LANGUAGES and TOOLBOX it is the same as above; for SEARCH the value will be ignored.

Note that extensions can control the sidebar contents using the SkinBuildSidebar hook and can technically insert anything in here; skin creators are expected to handle values described above.

Returns
array

Definition at line 1572 of file Skin.php.

Referenced by SkinTemplate\prepareQuickTemplate().

◆ doEditSectionLink()

Skin::doEditSectionLink ( Title $nt,
$section,
$sectionTitle,
Language $lang )

Create a section edit link.

Parameters
Title$ntThe title being linked to (may not be the same as the current page, if the section is included from a template)
string$sectionThe designation of the section being pointed to, to be included in the link, like "&section=$section"
string$sectionTitleSection title. It is used in the link tooltip, escaped and wrapped in the 'editsectionhint' message
Language$lang
Returns
string HTML to use for edit link

Definition at line 1995 of file Skin.php.

◆ doEditSectionLinksHTML()

Skin::doEditSectionLinksHTML ( array $links,
Language $lang )
protected
Stability: stable
to override by skins
Parameters
array$links
Language$lang
Returns
string

Reimplemented in SkinMustache.

Definition at line 2046 of file Skin.php.

◆ editUrlOptions()

Skin::editUrlOptions ( )

Return URL options for the 'edit page' link.

This may include an 'oldid' specifier, if the current page view is such.

Returns
array
Access: internal

Definition at line 1127 of file Skin.php.

◆ getAfterPortlet()

Skin::getAfterPortlet ( string $name)

Allows extensions to hook into known portlets and add stuff to them.

Unlike its BaseTemplate counterpart, this method does not wrap the html provided by the hook in a div.

Parameters
string$name
Returns
string html
Since
1.35

Definition at line 2329 of file Skin.php.

◆ getCategories()

Skin::getCategories ( )

◆ getCategoryLinks()

Skin::getCategoryLinks ( )
Returns
string HTML

Reimplemented in SkinTemplate.

Definition at line 773 of file Skin.php.

References MediaWiki\User\Options\UserOptionsLookup\getBoolOption(), getTitle(), and NS_CATEGORY.

◆ getComponent()

Skin::getComponent ( string $name)
finalprotected
Access: internal
use in Skin.php, SkinTemplate.php or SkinMustache.php
Parameters
string$name
Returns
SkinComponent

Definition at line 120 of file Skin.php.

Referenced by SkinTemplate\prepareQuickTemplate().

◆ getCopyright()

Skin::getCopyright ( )
final
Returns
string

Definition at line 1061 of file Skin.php.

◆ getDefaultModules()

Skin::getDefaultModules ( )

Defines the ResourceLoader modules that should be added to the skin It is recommended that skins wishing to override call parent::getDefaultModules() and substitute out any modules they wish to change by using a key to look them up.

Any modules defined with the 'styles' key will be added as render blocking CSS via Output::addModuleStyles. Similarly, each key should refer to a list of modules

Stability: stable
to override
Returns
array Array of modules with helper keys for easy overriding

Definition at line 452 of file Skin.php.

References MediaWiki\User\Options\UserOptionsLookup\getBoolOption(), MediaWiki\User\Options\UserOptionsLookup\getOption(), getTitle(), and NS_FILE.

◆ getFooterIcons()

Skin::getFooterIcons ( )

Get template representation of the footer.

Stable to use since 1.40 but should not be overridden.

Since
1.35
Access: internal
for use inside SkinComponentRegistryContext
Returns
array

Definition at line 1095 of file Skin.php.

Referenced by SkinTemplate\prepareQuickTemplate().

◆ getHtmlElementAttributes()

Skin::getHtmlElementAttributes ( )

Return values for <html> element.

Returns
array Array of associative name-to-value elements for <html> element

Definition at line 761 of file Skin.php.

Referenced by MediaWiki\Output\OutputPage\headElement().

◆ getIndicatorsData()

Skin::getIndicatorsData ( $indicators)
protected

Return an array of indicator data.

Can be used by subclasses but should not be extended.

Parameters
array$indicatorsreturn value of OutputPage::getIndicators
Returns
array

Definition at line 2134 of file Skin.php.

Referenced by SkinMustache\getTemplateData().

◆ getJsConfigVars()

Skin::getJsConfigVars ( )
protected

Returns array of config variables that should be added only to this skin for use in JavaScript.

Skins can override this to add variables to the page.

Since
1.38 or 1.35 if extending SkinTemplate.
Returns
array

Definition at line 2362 of file Skin.php.

Referenced by SkinTemplate\outputPage().

◆ getLanguages()

Skin::getLanguages ( )

Generates array of language links for the current page.

This may includes items added to this section by the SidebarBeforeOutput hook (which may not necessarily be language links)

Since
1.35
Returns
array

Definition at line 1265 of file Skin.php.

References getTitle(), and NS_MAIN.

Referenced by SkinTemplate\prepareQuickTemplate().

◆ getNewtalks()

Skin::getNewtalks ( )

Gets new talk page messages for the current user and returns an appropriate alert message (or an empty string if there are no messages)

Returns
string

Definition at line 1785 of file Skin.php.

Referenced by SkinMustache\getTemplateData(), and SkinTemplate\prepareQuickTemplate().

◆ getOptions()

Skin::getOptions ( )
final

Get current skin's options.

For documentation about supported options, refer to the Skin constructor.

Access: internal
Please call SkinFactory::getSkinOptions instead. See Skin::__construct for documentation.
Returns
array

Definition at line 2436 of file Skin.php.

Referenced by SkinMustache\doEditSectionLinksHTML(), SkinTemplate\generateHTML(), and MediaWiki\Output\OutputPage\headElement().

◆ getPageClasses()

Skin::getPageClasses ( $title)

TODO: document.

Parameters
Title$title
Returns
string

Definition at line 719 of file Skin.php.

Referenced by MediaWiki\Output\OutputPage\headElement().

◆ getPersonalToolsForMakeListItem()

Skin::getPersonalToolsForMakeListItem ( $urls,
$applyClassesToListItems = false )
final

Create an array of personal tools items from the data in the quicktemplate stored by SkinTemplate.

The resulting array is built according to a format intended to be passed through makeListItem to generate the html. This is in reality the same list as already stored in personal_urls however it is reformatted so that you can just pass the individual items to makeListItem instead of hardcoding the element creation boilerplate.

Since
1.35
Parameters
array$urls
bool$applyClassesToListItems(optional) when set behaves consistently with other menus, applying the class property applies to list items. When not set will move the class to child links.
Returns
array[]

Definition at line 2160 of file Skin.php.

Referenced by SkinTemplate\getStructuredPersonalTools(), and SkinTemplate\makePersonalToolsList().

◆ getPortletData()

Skin::getPortletData ( string $name,
array $items )
finalprotected
Parameters
string$nameof the portal e.g. p-personal the name is personal.
array$itemsthat are accepted input to Skin::makeListItem
Returns
array data that can be passed to a Mustache template that represents a single menu.

Definition at line 2513 of file Skin.php.

◆ getPortletLinkOptions()

static Skin::getPortletLinkOptions ( RL\Context $context)
static

Returns skin options for portlet links, used by addPortletLink.

Access: internal
Parameters
RL\\Context$context
Returns
array $linkOptions
  • 'text-wrapper' key to specify a list of elements to wrap the text of a link in. This should be an array of arrays containing a 'tag' and optionally an 'attributes' key. If you only have one element you don't need to wrap it in another array. eg: To use ... in all links use [ 'text-wrapper' => [ 'tag' => 'span' ] ] for your options. If text-wrapper contains multiple entries they are interpreted as going from the outer wrapper to the inner wrapper.

Definition at line 2492 of file Skin.php.

◆ getRelevantTitle()

Skin::getRelevantTitle ( )

Return the "relevant" title.

A "relevant" title is not necessarily the actual title of the page. Special pages like Special:MovePage use set the page they are acting on as their "relevant" title, this allows the skin system to display things such as content tabs which belong to that page instead of displaying a basic special page tab which has almost no meaning.

Returns
Title|null the title is null when no relevant title was set, as this falls back to ContextSource::getTitle

Definition at line 631 of file Skin.php.

References getTitle().

◆ getRelevantUser()

Skin::getRelevantUser ( )

Return the "relevant" user.

A "relevant" user is similar to a relevant title. Special pages like Special:Contributions mark the user which they are relevant to so that things like the toolbox can display the information they usually are only able to display on a user's userpage and talkpage.

Returns
UserIdentity|null Null if there's no relevant user or the viewer cannot view it.

Definition at line 652 of file Skin.php.

References NS_USER.

◆ getSiteNotice()

Skin::getSiteNotice ( )
Returns
string HTML fragment

Definition at line 1947 of file Skin.php.

Referenced by SkinMustache\getTemplateData(), and SkinTemplate\prepareQuickTemplate().

◆ getSkinName()

Skin::getSkinName ( )
Returns
string|null Skin name

Definition at line 376 of file Skin.php.

Referenced by MediaWiki\Output\OutputPage\headElement(), and MediaWiki\Context\RequestContext\setSkin().

◆ getTemplateData()

Skin::getTemplateData ( )
Stability: stable
to extend. Subclasses may extend this method to add additional template data.
Access: internal
this method should never be called outside Skin and its subclasses as it can be computationally expensive and typically has side effects on the Skin instance, through execution of hooks.

The data keys should be valid English words. Compound words should be hyphenated except if they are normally written as one word. Each key should be prefixed with a type hint, this may be enforced by the class PHPUnit test.

Plain strings are prefixed with 'html-', plain arrays with 'array-' and complex array data with 'data-'. 'is-' and 'has-' prefixes can be used for boolean variables. Messages are prefixed with 'msg-', followed by their message key. All messages specified in the skin option 'messages' will be available under 'msg-MESSAGE-NAME'.

Returns
array Data for a mustache template

Reimplemented in SkinAuthenticationPopup, SkinFallback, SkinMustache, and SkinTemplate.

Definition at line 145 of file Skin.php.

References getTitle().

◆ getUndeleteLink()

Skin::getUndeleteLink ( )
Returns
string HTML

Definition at line 930 of file Skin.php.

References getTitle().

◆ getUserLanguageAttributes()

Skin::getUserLanguageAttributes ( )
finalprotected

Get user language attribute links array.

Returns
array HTML attributes

Definition at line 2371 of file Skin.php.

Referenced by SkinMustache\getTemplateData().

◆ getVersion()

static Skin::getVersion ( )
static

Get the current major version of Skin.

This is used to manage changes to underlying data and for providing support for older and new versions of code.

Since
1.36
Returns
int

Definition at line 111 of file Skin.php.

References VERSION_MAJOR.

◆ initPage()

Skin::initPage ( OutputPage $out)
Stability: stable
to override
Parameters
OutputPage$out

Reimplemented in SkinFallback.

Definition at line 401 of file Skin.php.

References MediaWiki\Output\OutputPage\addMeta(), and MediaWiki\Output\OutputPage\getHTMLTitle().

Referenced by SkinTemplate\outputPage().

◆ isResponsive()

Skin::isResponsive ( )

Indicates if this skin is responsive.

Responsive skins have skin–responsive added to <body> by OutputPage, and a viewport <meta> tag set by Skin::initPage.

Since
1.36
Stability: stable
to override
Returns
bool

Definition at line 389 of file Skin.php.

References MediaWiki\User\Options\UserOptionsLookup\getBoolOption().

Referenced by MediaWiki\Output\OutputPage\headElement().

◆ logoText()

Skin::logoText ( $align = '')
Parameters
string$align
Returns
string

Definition at line 1069 of file Skin.php.

References $url.

Referenced by SkinTemplate\prepareQuickTemplate().

◆ makeFooterIcon()

Skin::makeFooterIcon ( $icon,
$withImage = 'withImage' )

Renders a $wgFooterIcons icon according to the method's arguments.

Stable to use since 1.40 but should not be overridden.

Parameters
array$iconThe icon to build the html for, see $wgFooterIcons for the format of this array.
bool | string$withImageWhether to use the icon's image or output a text-only footericon.
Returns
string HTML

Definition at line 1113 of file Skin.php.

◆ makeInternalOrExternalUrl()

static Skin::makeInternalOrExternalUrl ( $name)
static

If url string starts with http, consider as external URL, else internal.

Parameters
string$name
Returns
string URL

Definition at line 1205 of file Skin.php.

Referenced by MediaWiki\SpecialPage\LoginSignupSpecialPage\getFieldDefinitions(), and ChangeTags\tagHelpLink().

◆ makeKnownUrlDetails()

static Skin::makeKnownUrlDetails ( $name,
$urlaction = '' )
staticprotected

Make URL details where the article exists (or at least it's convenient to think so)

Parameters
string | Title$nameArticle name
string | array$urlaction
Returns
array

Definition at line 1236 of file Skin.php.

◆ makeLink()

Skin::makeLink ( $key,
$item,
$linkOptions = [] )
final

Makes a link, usually used by makeListItem to generate a link for an item in a list used in navigation lists, portlets, portals, sidebars, etc...

Since
1.35
Parameters
string$keyUsually a key from the list you are generating this link from.
array$itemContains some of a specific set of keys.

If "html" key is present, this will be returned. All other keys will be ignored.

The text of the link will be generated either from the contents of the "text" key in the $item array, if a "msg" key is present a message by that name will be used, and if neither of those are set the $key will be used as a message name.

If a "href" key is not present makeLink will just output htmlescaped text. The "href", "id", "class", "rel", and "type" keys are used as attributes for the link if present.

If an "id" or "single-id" (if you don't want the actual id to be output on the link) is present it will be used to generate a tooltip and accesskey for the link.

The 'link-html' key can be used to prepend additional HTML inside the link HTML. For example to prepend an icon.

The keys "context" and "primary" are ignored; these keys are used internally by skins and are not supposed to be included in the HTML output.

If you don't want an accesskey, set $item['tooltiponly'] = true;

If a "data" key is present, it must be an array, where the keys represent the data-xxx properties with their provided values. For example, $item['data'] = [ 'foo' => 1, 'bar' => 'baz', ]; will render as element properties: data-foo='1' data-bar='baz'

The "class" key currently accepts both a string and an array of classes, but this will be changed to only accept an array in the future.

Parameters
array$linkOptionsCan be used to affect the output of a link. Possible options are:
  • 'text-wrapper' key to specify a list of elements to wrap the text of a link in. This should be an array of arrays containing a 'tag' and optionally an 'attributes' key. If you only have one element you don't need to wrap it in another array. eg: To use ... in all links use [ 'text-wrapper' => [ 'tag' => 'span' ] ] for your options.
  • 'link-class' key can be used to specify additional classes to apply to all links.
  • 'link-fallback' can be used to specify a tag to use instead of "<a>" if there is no link. eg: If you specify 'link-fallback' => 'span' than any non-link will output a "<span>" instead of just text.
Returns
string

Definition at line 2269 of file Skin.php.

◆ makeListItem()

Skin::makeListItem ( $key,
$item,
$options = [] )
final

Generates a list item for a navigation, portlet, portal, sidebar... list.

Since
1.35
Parameters
string$keyUsually a key from the list you are generating this link from.
array$itemArray of list item data containing some of a specific set of keys. The "id", "class" and "itemtitle" keys will be used as attributes for the list item, if "active" contains a value of true an "active" class will also be appended to class. The "class" key currently accepts both a string and an array of classes, but this will be changed to only accept an array in the future. For further options see the $item parameter of SkinComponentLink::makeLink().
array$options

If you want something other than a "<li>" you can pass a tag name such as "tag" => "span" in the $options array to change the tag used. link/content data for the list item may come in one of two forms A "links" key may be used, in which case it should contain an array with a list of links to include inside the list item, see makeLink for the format of individual links array items.

Otherwise the relevant keys from the list item $item array will be passed to makeLink instead. Note however that "id" and "class" are used by the list item directly so they will not be passed to makeLink (however the link will still support a tooltip and accesskey from it) If you need an id or class on a single link you should include a "links" array with just one link item inside of it. You can also set "link-class" in $item to set a class on the link itself. If you want to add a title to the list item itself, you can set "itemtitle" to the value. $options is also passed on to makeLink calls

Returns
string

Definition at line 2312 of file Skin.php.

Referenced by SkinTemplate\makePersonalToolsList().

◆ makeMainPageUrl()

static Skin::makeMainPageUrl ( $urlaction = '')
static
Parameters
string | array$urlaction
Returns
string

Definition at line 1164 of file Skin.php.

◆ makeSpecialUrl()

static Skin::makeSpecialUrl ( $name,
$urlaction = '',
$proto = null )
static

Make a URL for a Special Page using the given query and protocol.

If $proto is set to null, make a local URL. Otherwise, make a full URL with the protocol specified.

Deprecated
since 1.39 - Moved to SkinComponentUtils::makeSpecialUrl
Parameters
string$nameName of the Special page
string | array$urlactionQuery to append
string | null$protoProtocol to use or null for a local URL
Returns
string

Definition at line 1182 of file Skin.php.

References wfDeprecated().

◆ makeSpecialUrlSubpage()

static Skin::makeSpecialUrlSubpage ( $name,
$subpage,
$urlaction = '' )
static
Deprecated
since 1.39 - Moved to SkinComponentUtils::makeSpecialUrlSubpage
Parameters
string$name
string | bool$subpagefalse for no subpage
string | array$urlaction
Returns
string

Definition at line 1194 of file Skin.php.

References wfDeprecated().

◆ makeToolbox()

Skin::makeToolbox ( $navUrls,
$feedUrls )

Create an array of common toolbox items from the data in the quicktemplate stored by SkinTemplate.

The resulting array is built according to a format intended to be passed through makeListItem to generate the html.

Parameters
array$navUrls
array$feedUrls
Returns
array

Definition at line 2078 of file Skin.php.

◆ makeUrlDetails()

static Skin::makeUrlDetails ( $name,
$urlaction = '' )
staticprotected

these return an array with the 'href' and boolean 'exists'

Parameters
string | Title$name
string | array$urlaction
Returns
array

Definition at line 1222 of file Skin.php.

◆ mapInterwikiToLanguage()

Skin::mapInterwikiToLanguage ( $code)

Allows correcting the language of interlanguage links which, mostly due to legacy reasons, do not always match the standards compliant language tag.

Parameters
string$code
Returns
string
Since
1.35

Definition at line 1252 of file Skin.php.

◆ normalizeKey()

static Skin::normalizeKey ( string $key)
static

Normalize a skin preference value to a form that can be loaded.

If a skin can't be found, it will fall back to the configured default ($wgDefaultSkin), or the hardcoded default ($wgFallbackSkin) if the default skin is unavailable too.

Parameters
string$key'monobook', 'vector', etc.
Returns
string

Definition at line 229 of file Skin.php.

References $fallback.

Referenced by MediaWiki\Api\ApiQuerySiteinfo\appendSkins(), MediaWiki\Api\ApiParse\execute(), and MediaWiki\Context\RequestContext\getSkin().

◆ outputPage()

Skin::outputPage ( )
abstract

Outputs the HTML generated by other functions.

Reimplemented in SkinTemplate.

◆ outputPageFinal()

Skin::outputPageFinal ( OutputPage $out)
final

Outputs the HTML for the page.

Access: internal
Only to be called by OutputPage.

Definition at line 690 of file Skin.php.

References MediaWiki\Output\OutputPage\headElement(), and MediaWiki\Output\OutputPage\tailElement().

◆ prepareSubtitle()

Skin::prepareSubtitle ( bool $withContainer = true)
final

Prepare the subtitle of the page for output in the skin if one has been set.

Since
1.35
Parameters
bool$withContainersince 1.40, when provided the mw-content-subtitle element will be output too.
Returns
string HTML

Definition at line 2343 of file Skin.php.

Referenced by SkinMustache\getTemplateData(), and SkinTemplate\prepareQuickTemplate().

◆ prepareUndeleteLink()

Skin::prepareUndeleteLink ( )
finalprotected

Prepare undelete link for output in page.

Since
1.38 on Skin and 1.35 on classes extending SkinTemplate
Returns
null|string HTML, or null if there is no undelete link.

Definition at line 2404 of file Skin.php.

Referenced by SkinMustache\getTemplateData(), and SkinTemplate\prepareQuickTemplate().

◆ prepareUserLanguageAttributes()

Skin::prepareUserLanguageAttributes ( )
finalprotected

Prepare user language attribute links.

Since
1.38 on Skin and 1.35 on classes extending SkinTemplate
Returns
string HTML attributes

Definition at line 2393 of file Skin.php.

Referenced by SkinMustache\getTemplateData(), and SkinTemplate\prepareQuickTemplate().

◆ printSource()

Skin::printSource ( )

Text with the permalink to the source page, usually shown on the footer of a printed page.

Stability: stable
to override
Returns
string HTML text with an URL

Definition at line 918 of file Skin.php.

References $url.

Referenced by SkinMustache\getTemplateData(), and SkinTemplate\prepareQuickTemplate().

◆ setRelevantTitle()

Skin::setRelevantTitle ( $t)
See also
self::getRelevantTitle()
Parameters
Title$t

Definition at line 616 of file Skin.php.

◆ setRelevantUser()

Skin::setRelevantUser ( ?UserIdentity $u)
See also
self::getRelevantUser()
Parameters
UserIdentity | null$u

Definition at line 639 of file Skin.php.

◆ showEmailUser()

Skin::showEmailUser ( $id)
Parameters
UserIdentity | int$id
Returns
bool

Definition at line 1142 of file Skin.php.

◆ supportsMenu()

Skin::supportsMenu ( string $menu)

Does the skin support the named menu? e.g.

has it declared that it will render a menu with the given ID?

Since
1.39
Parameters
string$menuSee Skin::__construct for menu names.
Returns
bool

Definition at line 2473 of file Skin.php.

◆ wrapHTML()

Skin::wrapHTML ( $title,
$html )
protected

Wrap the body text with language information and identifiable element.

Since
1.38 in Skin, previously was a method of SkinTemplate
Parameters
Title$title
string$htmlbody text
Returns
string html

Definition at line 2417 of file Skin.php.

Referenced by SkinMustache\getTemplateData(), and SkinTemplate\prepareQuickTemplate().

Member Data Documentation

◆ $mRelevantTitle

Title null Skin::$mRelevantTitle = null
protected

Definition at line 83 of file Skin.php.

◆ $options

array Skin::$options = []
protected

Skin options passed into constructor.

Definition at line 81 of file Skin.php.

Referenced by SkinTemplate\generateHTML(), and SkinTemplate\makePersonalToolsList().

◆ $skinname

string null Skin::$skinname = null
protected

Definition at line 76 of file Skin.php.

◆ VERSION_MAJOR

const Skin::VERSION_MAJOR = 1
protected

The current major version of the skin specification.

Definition at line 91 of file Skin.php.

Referenced by getVersion().


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