MediaWiki master
SkinTemplate Class Reference

Base class for QuickTemplate-based skins. More...

Inherits Skin.

Inherited by SkinMustache.

Collaboration diagram for SkinTemplate:

Public Member Functions

 generateHTML ()
 Subclasses not wishing to use the QuickTemplate render method can rewrite this method, for example to use TemplateParser::processTemplate.
 
 getCategoryLinks ()
 Extends category links with Skin::getAfterPortlet functionality.
 
 getStructuredPersonalTools ()
 Get personal tools for the user.
 
 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

 
 makePersonalToolsList ( $personalTools=null, $options=[])
 Get the HTML for the personal tools list.
 
 makeSearchButton ( $mode, $attrs=[])
 
 makeSearchInput ( $attrs=[])
 
 outputPage ()
 Initialize various variables and generate the template.
 
 tabAction ( $title, $message, $selected, $query='', $checkEdit=false)
 Builds an array with tab definition.
 
- Public Member Functions inherited from Skin
 __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.
 
 footerLink ( $desc, $page)
 Given a pair of message keys for link and text label, return an HTML link for use in the footer.
 
 getAfterPortlet (string $name)
 Allows extensions to hook into known portlets and add stuff to them.
 
 getCategories ()
 
 getCopyright ( $type='detect')
 
 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 ()
 
 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.
 
 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?
 
- 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 makeSearchButtonInternal ( $mode, $searchData, $attrs=[])
 
- Static Public Member Functions inherited from Skin
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.
 

Public Attributes

bool $loggedin
 TODO: Rename this to $isRegistered (but that's a breaking change)
 
string $template
 For QuickTemplate, the name of the subclass which will actually fill the template.
 
 $thispage
 
 $titletxt
 
 $username
 
 $userpage
 
 $userpageUrlDetails
 

Protected Member Functions

 buildContentNavigationUrls ()
 Wrapper for private buildContentNavigationUrlsInternal.
 
 buildCreateAccountData ( $returnto)
 Build "Create Account" link data.
 
 buildLoginData ( $returnto, $useCombinedLoginLink)
 Build "Login" link.
 
 buildLogoutLinkData ()
 Build data required for "Logout" link.
 
 buildPersonalPageItem ( $id='pt-userpage')
 Build a user page link data.
 
 buildPersonalUrls (bool $includeNotifications=true)
 Build array of urls for personal toolbar.
 
 injectLegacyMenusIntoPersonalTools (array $contentNavigation)
 Insert legacy menu items from content navigation into the personal toolbar.
 
 prepareQuickTemplate ()
 initialize various variables and generate the template
 
 runOnSkinTemplateNavigationHooks (SkinTemplate $skin, &$content_navigation)
 Run hooks relating to navigation menu data.
 
 setupTemplate ( $classname)
 Create the template engine object; we feed it a bunch of data and eventually it spits out some HTML.
 
 setupTemplateContext ()
 Setup class properties that are necessary prior to calling setupTemplateForOutput.
 
 setupTemplateForOutput ()
 
 useCombinedLoginLink ()
 Returns if a combined login/signup link will be used.
 
- Protected Member Functions inherited from Skin
 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)
 
 getAction ()
 
 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.
 

Additional Inherited Members

- Static Protected Member Functions inherited from Skin
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 inherited from Skin
 $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

Base class for QuickTemplate-based skins.

The template data is filled in SkinTemplate::prepareQuickTemplate.

Stability: stable
to extend

Definition at line 42 of file SkinTemplate.php.

Member Function Documentation

◆ buildContentNavigationUrls()

SkinTemplate::buildContentNavigationUrls ( )
protected

Wrapper for private buildContentNavigationUrlsInternal.

Deprecated
since 1.38 skins can use runOnSkinTemplateNavigationHooks instead.
Returns
array

Definition at line 1449 of file SkinTemplate.php.

References wfDeprecated().

◆ buildCreateAccountData()

SkinTemplate::buildCreateAccountData ( $returnto)
protected

Build "Create Account" link data.

Stability: unstable
Parameters
string[]$returntoquery params for the page to return to
Returns
array

Definition at line 703 of file SkinTemplate.php.

References getTitle().

Referenced by buildPersonalUrls().

◆ buildLoginData()

SkinTemplate::buildLoginData ( $returnto,
$useCombinedLoginLink )
protected

Build "Login" link.

Stability: unstable
Parameters
string[]$returntoquery params for the page to return to
bool$useCombinedLoginLinkwhen set a single link to login form will be created with alternative label.
Returns
array

Definition at line 552 of file SkinTemplate.php.

References getAuthority(), getTitle(), and MediaWiki\Context\ContextSource\msg().

Referenced by buildPersonalUrls().

◆ buildLogoutLinkData()

SkinTemplate::buildLogoutLinkData ( )
finalprotected

Build data required for "Logout" link.

Stability: unstable
Since
1.37
Returns
array Array of data required to create a logout link.

Definition at line 675 of file SkinTemplate.php.

References getAuthority(), getRequest(), and getTitle().

Referenced by buildPersonalUrls().

◆ buildPersonalPageItem()

SkinTemplate::buildPersonalPageItem ( $id = 'pt-userpage')
protected

Build a user page link data.

Parameters
string$idof user page item to be output in HTML attribute (optional)
Returns
array

Definition at line 733 of file SkinTemplate.php.

◆ buildPersonalUrls()

SkinTemplate::buildPersonalUrls ( bool $includeNotifications = true)
protected

Build array of urls for personal toolbar.

Parameters
bool$includeNotificationsSince 1.36, notifications are optional
Returns
array

Definition at line 398 of file SkinTemplate.php.

References buildCreateAccountData(), buildLoginData(), buildLogoutLinkData(), getAuthority(), getRequest(), getTitle(), MediaWiki\Title\Title\isSpecialPage(), MediaWiki\Context\ContextSource\msg(), setupTemplateContext(), and useCombinedLoginLink().

Referenced by getStructuredPersonalTools(), and makePersonalToolsList().

◆ generateHTML()

SkinTemplate::generateHTML ( )

Subclasses not wishing to use the QuickTemplate render method can rewrite this method, for example to use TemplateParser::processTemplate.

Since
1.35
Returns
string of complete skin HTML to output to the page. This varies based on the skin option bodyOnly (see Skin::getOptions):
  • If true, HTML includes <!DOCTYPE> and opening and closing html tags
  • If false, HTML is the contents of the body tag.

Reimplemented in SkinMustache.

Definition at line 144 of file SkinTemplate.php.

References Skin\$options, Skin\getOptions(), MediaWiki\Context\ContextSource\getOutput(), and prepareQuickTemplate().

Referenced by outputPage().

◆ getCategoryLinks()

SkinTemplate::getCategoryLinks ( )

Extends category links with Skin::getAfterPortlet functionality.

Returns
string HTML

Reimplemented from Skin.

Definition at line 593 of file SkinTemplate.php.

◆ getStructuredPersonalTools()

SkinTemplate::getStructuredPersonalTools ( )

Get personal tools for the user.

Since
1.31
Returns
array[]

Definition at line 386 of file SkinTemplate.php.

References buildPersonalUrls(), and Skin\getPersonalToolsForMakeListItem().

◆ getTemplateData()

SkinTemplate::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 from Skin.

Reimplemented in SkinFallback, and SkinMustache.

Definition at line 182 of file SkinTemplate.php.

◆ injectLegacyMenusIntoPersonalTools()

SkinTemplate::injectLegacyMenusIntoPersonalTools ( array $contentNavigation)
finalprotected

Insert legacy menu items from content navigation into the personal toolbar.

Access: internal
Parameters
array$contentNavigation
Returns
array

Definition at line 1502 of file SkinTemplate.php.

References wfArrayInsertAfter().

◆ makePersonalToolsList()

SkinTemplate::makePersonalToolsList ( $personalTools = null,
$options = [] )

Get the HTML for the personal tools list.

Since
1.31
Parameters
array | null$personalTools
array$options
Returns
string

Definition at line 363 of file SkinTemplate.php.

References Skin\$options, buildPersonalUrls(), Skin\getPersonalToolsForMakeListItem(), and Skin\makeListItem().

◆ makeSearchButton()

SkinTemplate::makeSearchButton ( $mode,
$attrs = [] )
final
Since
1.35
Parameters
string$moderepresenting the type of button wanted either go, fulltext or image
array$attrs(optional)
Returns
string of HTML button

Reimplemented from Skin.

Definition at line 1566 of file SkinTemplate.php.

◆ makeSearchButtonInternal()

static SkinTemplate::makeSearchButtonInternal ( $mode,
$searchData,
$attrs = [] )
static
Deprecated
1.38 see
Access: internal
note.
Parameters
string$moderepresenting the type of button wanted either go, fulltext or image
array$searchDataSkin data returned by Skin::getTemplateData()['data-search-box']
array$attrs(optional)
Access: internal
Please use SkinTemplate::makeSearchButton. For usage only inside Skin class to support deprecated Skin::makeSearchButton method. This should be merged with SkinTemplate::makeSearchButton when Skin::makeSearchButton method is removed.
Returns
string of HTML button

Definition at line 1592 of file SkinTemplate.php.

References wfMessage().

◆ makeSearchInput()

SkinTemplate::makeSearchInput ( $attrs = [])
Since
1.35
Parameters
array$attrs(optional) will be passed to tooltipAndAccesskeyAttribs and decorate the resulting input
Returns
string of HTML input

Reimplemented from Skin.

Definition at line 1547 of file SkinTemplate.php.

◆ outputPage()

SkinTemplate::outputPage ( )

Initialize various variables and generate the template.

Stability: stable
to override

Reimplemented from Skin.

Definition at line 168 of file SkinTemplate.php.

References generateHTML(), Skin\getJsConfigVars(), MediaWiki\Context\ContextSource\getOutput(), Skin\initPage(), and Profiler\instance().

◆ prepareQuickTemplate()

◆ runOnSkinTemplateNavigationHooks()

SkinTemplate::runOnSkinTemplateNavigationHooks ( SkinTemplate $skin,
& $content_navigation )
protected

Run hooks relating to navigation menu data.

Skins should extend this if they want to run opinionated transformations to the data after all hooks have been run. Note hooks are run in an arbitrary order.

Parameters
SkinTemplate$skin
array&$content_navigationrepresenting all menus.
Since
1.37

Definition at line 959 of file SkinTemplate.php.

◆ setupTemplate()

SkinTemplate::setupTemplate ( $classname)
protected

Create the template engine object; we feed it a bunch of data and eventually it spits out some HTML.

Should have interface roughly equivalent to PHPTAL 0.7.

Parameters
string$classname
Returns
QuickTemplate

Definition at line 77 of file SkinTemplate.php.

References MediaWiki\Context\ContextSource\getConfig().

Referenced by setupTemplateForOutput().

◆ setupTemplateContext()

SkinTemplate::setupTemplateContext ( )
finalprotected

Setup class properties that are necessary prior to calling setupTemplateForOutput.

It must be called inside prepareQuickTemplate. This function may set local class properties that will be used by other methods, but should not make assumptions about the implementation of setupTemplateForOutput

Since
1.35

Definition at line 106 of file SkinTemplate.php.

References getRequest(), getTitle(), and getUser().

Referenced by buildPersonalUrls(), SkinMustache\generateHTML(), and setupTemplateForOutput().

◆ setupTemplateForOutput()

SkinTemplate::setupTemplateForOutput ( )
protected
Returns
QuickTemplate

Definition at line 84 of file SkinTemplate.php.

References setupTemplate(), and setupTemplateContext().

Referenced by prepareQuickTemplate().

◆ tabAction()

SkinTemplate::tabAction ( $title,
$message,
$selected,
$query = '',
$checkEdit = false )

Builds an array with tab definition.

Parameters
Title$titlePage Where the tab links to
string | string[] | MessageSpecifier$messageMessage or an array of message keys (will fall back)
bool$selectedDisplay the tab as selected
string$queryQuery string attached to tab URL
bool$checkEditCheck if $title exists and mark with .new if one doesn't
Returns
array

Definition at line 782 of file SkinTemplate.php.

References getContext(), and wfMessageFallback().

◆ useCombinedLoginLink()

SkinTemplate::useCombinedLoginLink ( )
protected

Returns if a combined login/signup link will be used.

Stability: unstable
Returns
bool

Definition at line 531 of file SkinTemplate.php.

References MediaWiki\Context\ContextSource\getConfig().

Referenced by buildPersonalUrls().

Member Data Documentation

◆ $loggedin

bool SkinTemplate::$loggedin

TODO: Rename this to $isRegistered (but that's a breaking change)

Definition at line 53 of file SkinTemplate.php.

◆ $template

string SkinTemplate::$template

For QuickTemplate, the name of the subclass which will actually fill the template.

Definition at line 47 of file SkinTemplate.php.

Referenced by SkinMustache\doEditSectionLinksHTML(), and SkinMustache\generateHTML().

◆ $thispage

SkinTemplate::$thispage

Definition at line 49 of file SkinTemplate.php.

◆ $titletxt

SkinTemplate::$titletxt

Definition at line 50 of file SkinTemplate.php.

◆ $username

SkinTemplate::$username

Definition at line 54 of file SkinTemplate.php.

◆ $userpage

SkinTemplate::$userpage

Definition at line 51 of file SkinTemplate.php.

◆ $userpageUrlDetails

SkinTemplate::$userpageUrlDetails

Definition at line 55 of file SkinTemplate.php.


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