MediaWiki  master
SkinTemplate Class Reference

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

Inheritance diagram for SkinTemplate:
Collaboration diagram for SkinTemplate:

Public Member Functions

 formatLanguageName ( $name)
 Format language name for use in sidebar interlanguage links list. More...
 
 getLanguages ()
 Generates array of language links for the current page. More...
 
 getPersonalToolsList ()
 Get the HTML for the p-personal list. More...
 
 getStructuredPersonalTools ()
 Get personal tools for the user. More...
 
 makeArticleUrlDetails ( $name, $urlaction='')
 
 makePersonalToolsList ( $personalTools=null, $options=[])
 Get the HTML for the personal tools list. More...
 
 makeTalkUrlDetails ( $name, $urlaction='')
 
 outputPage ()
 Initialize various variables and generate the template. More...
 
 printOrError ( $str)
 Output the string, or print error message if it's an error object of the appropriate type. More...
 
 setupTemplate ( $classname, $repository=false, $cache_dir=false)
 Create the template engine object; we feed it a bunch of data and eventually it spits out some HTML. More...
 
 tabAction ( $title, $message, $selected, $query='', $checkEdit=false)
 Builds an array with tab definition. More...
 
 useCombinedLoginLink ()
 Output a boolean indicating if buildPersonalUrls should output separate login and create account links or output a combined link By default we simply return a global config setting that affects most skins This is setup as a method so that like with $wgLogo and getLogo() a skin can override this setting and always output one or the other if it has a reason it can't output one of the two modes. More...
 
- Public Member Functions inherited from Skin
 __construct ( $skinname=null)
 
 aboutLink ()
 Gets the link to the wiki's about page. More...
 
 addToBodyAttributes ( $out, &$bodyAttrs)
 This will be called by OutputPage::headElement when it is creating the "<body>" tag, skins can override it if they have a need to add in any body attributes or classes of their own. More...
 
 addToSidebar (&$bar, $message)
 Add content from a sidebar system message Currently only used for MediaWiki:Sidebar (but may be used by Extensions) More...
 
 addToSidebarPlain (&$bar, $text)
 Add content from plain text. More...
 
 bottomScripts ()
 This gets called shortly before the "</body>" tag. More...
 
 buildSidebar ()
 Build an array that represents the sidebar(s), the navigation bar among them. More...
 
 disclaimerLink ()
 Gets the link to the wiki's general disclaimers page. More...
 
 doEditSectionLink (Title $nt, $section, $tooltip, Language $lang)
 Create a section edit link. More...
 
 drawCategoryBrowser ( $tree)
 Render the array as a series of links. More...
 
 editUrlOptions ()
 Return URL options for the 'edit page' link. More...
 
 escapeSearchLink ()
 
 footerLink ( $desc, $page)
 Returns an HTML link for use in the footer. More...
 
 getCategories ()
 
 getCategoryLinks ()
 
 getCopyright ( $type='detect')
 
 getCopyrightIcon ()
 
 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. More...
 
 getHtmlElementAttributes ()
 Return values for <html> element. More...
 
 getLogo ()
 URL to the logo. More...
 
 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) More...
 
 getPageClasses ( $title)
 TODO: document. More...
 
 getPoweredBy ()
 Gets the powered by MediaWiki icon. More...
 
 getRelevantTitle ()
 Return the "relevant" title. More...
 
 getRelevantUser ()
 Return the "relevant" user. More...
 
 getRevisionId ()
 Get the current revision ID. More...
 
 getSearchLink ()
 
 getSiteNotice ()
 Get the site notice. More...
 
 getSkinName ()
 
 getSkinStylePath ( $name)
 Return a fully resolved style path URL to images or styles stored in the current skin's folder. More...
 
 getUndeleteLink ()
 
 initPage (OutputPage $out)
 
 isRevisionCurrent ()
 Whether the revision displayed is the latest revision of the page. More...
 
 logoText ( $align='')
 
 mainPageLink ()
 Gets the link to the wiki's main page. More...
 
 makeFooterIcon ( $icon, $withImage='withImage')
 Renders a $wgFooterIcons icon according to the method's arguments. More...
 
 outputPage ()
 Outputs the HTML generated by other functions. More...
 
 printSource ()
 Text with the permalink to the source page, usually shown on the footer of a printed page. More...
 
 privacyLink ()
 Gets the link to the wiki's privacy policy page. More...
 
 setRelevantTitle ( $t)
 Set the "relevant" title. More...
 
 setRelevantUser ( $u)
 Set the "relevant" user. More...
 
 setupSkinUserCss (OutputPage $out)
 Hook point for adding style modules to OutputPage. More...
 
 shouldPreloadLogo ()
 Whether the logo should be preloaded with an HTTP link header or not. More...
 
 showEmailUser ( $id)
 
 subPageSubtitle ( $out=null)
 
- Public Member Functions inherited from ContextSource
 canUseWikiPage ()
 Check whether a WikiPage object can be get with getWikiPage(). More...
 
 exportSession ()
 Export the resolved user IP, HTTP headers, user ID, and session ID. More...
 
 getConfig ()
 
 getContext ()
 Get the base IContextSource object. More...
 
 getLanguage ()
 
 getOutput ()
 
 getRequest ()
 
 getSkin ()
 
 getStats ()
 
 getTiming ()
 
 getTitle ()
 
 getUser ()
 
 getWikiPage ()
 Get the WikiPage object. More...
 
 msg ( $key)
 Get a Message object with context set Parameters are the same as wfMessage() More...
 
 setContext (IContextSource $context)
 

Public Attributes

 $loggedin
 
string $skinname = 'monobook'
 Name of our skin, it probably needs to be all lower case. More...
 
string $template = QuickTemplate::class
 For QuickTemplate, the name of the subclass which will actually fill the template. More...
 
 $thispage
 
 $thisquery
 
 $titletxt
 
 $username
 
 $userpage
 
 $userpageUrlDetails
 
- Public Attributes inherited from Skin
string $stylename = null
 Stylesheets set to use. More...
 

Protected Member Functions

 buildContentNavigationUrls ()
 a structured array of links usually used for the tabs in a skin More...
 
 buildNavUrls ()
 build array of common navigation links More...
 
 buildPersonalUrls ()
 build array of urls for personal toolbar More...
 
 getNameSpaceKey ()
 Generate strings used for xml 'id' names. More...
 
 prepareQuickTemplate ()
 initialize various variables and generate the template More...
 
 setupTemplateForOutput ()
 
 wrapHTML ( $title, $html)
 Wrap the body text with language information and identifiable element. More...
 
- Protected Member Functions inherited from Skin
 afterContentHook ()
 This runs a hook to allow extensions placing their stuff after content and article metadata (e.g. More...
 
 generateDebugHTML ()
 Generate debug data HTML for displaying at the bottom of the main content area. More...
 
 lastModified ()
 Get the timestamp of the latest revision, formatted in user language. More...
 
 preloadExistence ()
 Preload the existence of three commonly-requested pages in a single query. More...
 

Private Member Functions

 buildContentActionUrls ( $content_navigation)
 an array of edit links by default used for the tabs More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Skin
static checkTitle (&$title, $name)
 make sure we have some title to operate on More...
 
static getAllowedSkins ()
 Fetch the list of user-selectable skins in regards to $wgSkipSkins. More...
 
static getDynamicStylesheetQuery ()
 Get the query to generate a dynamic stylesheet. More...
 
static getSkinNameMessages ()
 Fetch the skinname messages for available skins. More...
 
static getSkinNames ()
 Fetch the set of available skins. More...
 
static makeI18nUrl ( $name, $urlaction='')
 
static makeInternalOrExternalUrl ( $name)
 If url string starts with http, consider as external URL, else internal. More...
 
static makeKnownUrlDetails ( $name, $urlaction='')
 Make URL details where the article exists (or at least it's convenient to think so) More...
 
static makeMainPageUrl ( $urlaction='')
 
static makeNSUrl ( $name, $urlaction='', $namespace=NS_MAIN)
 this can be passed the NS number as defined in Language.php More...
 
static makeSpecialUrl ( $name, $urlaction='', $proto=null)
 Make a URL for a Special Page using the given query and protocol. More...
 
static makeSpecialUrlSubpage ( $name, $subpage, $urlaction='')
 
static makeUrl ( $name, $urlaction='')
 
static makeUrlDetails ( $name, $urlaction='')
 these return an array with the 'href' and boolean 'exists' More...
 
static makeVariablesScript ( $data, $nonce=null)
 
static normalizeKey ( $key)
 Normalize a skin preference value to a form that can be loaded. More...
 
- Protected Attributes inherited from Skin
 $mRelevantTitle = null
 
 $mRelevantUser = null
 
string null $skinname = null
 

Detailed Description

Base class for template-based skins.

Template-filler skin base class Formerly generic PHPTal (http://phptal.sourceforge.net/) skin Based on Brion's smarty skin

Note
Copyright © Gabriel Wicke – http://www.aulinx.de/
Todo:
Needs some serious refactoring into functions that correspond to the computations individual esi snippets need. Most importantly no body parsing for most of those of course.

Definition at line 38 of file SkinTemplate.php.

Member Function Documentation

◆ buildContentActionUrls()

SkinTemplate::buildContentActionUrls (   $content_navigation)
private

an array of edit links by default used for the tabs

Parameters
array$content_navigation
Returns
array

Definition at line 1216 of file SkinTemplate.php.

References $value, as, and wfDebug().

Referenced by prepareQuickTemplate().

◆ buildContentNavigationUrls()

SkinTemplate::buildContentNavigationUrls ( )
protected

a structured array of links usually used for the tabs in a skin

There are 4 standard sections namespaces: Used for namespace tabs like special, page, and talk namespaces views: Used for primary page views like read, edit, history actions: Used for most extra page actions like deletion, protection, etc... variants: Used to list the language variants for the page

Each section's value is a key/value array of links for that section. The links themselves have these common keys:

  • class: The css classes to apply to the tab
  • text: The text to display on the tab
  • href: The href for the tab to point to
  • rel: An optional rel= for the tab's link
  • redundant: If true the tab will be dropped in skins using content_actions this is useful for tabs like "Read" which only have meaning in skins that take special meaning from the grouped structure of content_navigation

Views also have an extra key which can be used:

  • primary: If this is not true skins like vector may try to hide the tab when the user has limited space in their browser window

content_navigation using code also expects these ids to be present on the links, however these are usually automatically generated by SkinTemplate itself and are not necessary when using a hook. The only things these may matter to are people modifying content_navigation after it's initial creation:

  • id: A "preferred" id, most skins are best off outputting this preferred id for best compatibility.
  • tooltiponly: This is set to true for some tabs in cases where the system believes that the accesskey should not be added to the tab.
Returns
array

Definition at line 878 of file SkinTemplate.php.

References $code, $link, $out, $params, $request, $section, $skinname, $title, $user, $wgDisableLangConversion, as, LanguageCode\bcp47(), ContextSource\canUseWikiPage(), Skin\editUrlOptions(), false, Action\getActionName(), ContextSource\getContext(), ContextSource\getOutput(), Skin\getRelevantTitle(), ContextSource\getRequest(), ContextSource\getTitle(), SpecialPage\getTitleFor(), ContextSource\getUser(), ContextSource\getWikiPage(), Skin\isRevisionCurrent(), ContextSource\msg(), NS_MEDIAWIKI, Hooks\run(), Hooks\runWithoutAbort(), ContextSource\setContext(), tabAction(), text, and wfMessageFallback().

Referenced by prepareQuickTemplate().

◆ buildNavUrls()

◆ buildPersonalUrls()

◆ formatLanguageName()

SkinTemplate::formatLanguageName (   $name)

Format language name for use in sidebar interlanguage links list.

By default it is capitalized.

Parameters
string$nameLanguage name, e.g. "English" or "español"
Returns
string
Access:
private

Definition at line 551 of file SkinTemplate.php.

References $name, and ContextSource\getLanguage().

Referenced by getLanguages().

◆ getLanguages()

SkinTemplate::getLanguages ( )

◆ getNameSpaceKey()

SkinTemplate::getNameSpaceKey ( )
protected

Generate strings used for xml 'id' names.

Returns
string

Definition at line 1377 of file SkinTemplate.php.

References ContextSource\getTitle().

◆ getPersonalToolsList()

SkinTemplate::getPersonalToolsList ( )

Get the HTML for the p-personal list.

Returns
string

Definition at line 498 of file SkinTemplate.php.

References makePersonalToolsList().

◆ getStructuredPersonalTools()

SkinTemplate::getStructuredPersonalTools ( )

Get personal tools for the user.

Since
1.31
Returns
array Array of personal tools

Definition at line 536 of file SkinTemplate.php.

References buildPersonalUrls(), and setupTemplateForOutput().

◆ makeArticleUrlDetails()

SkinTemplate::makeArticleUrlDetails (   $name,
  $urlaction = '' 
)
Todo:
is this even used?
Parameters
string$name
string$urlaction
Returns
array

Definition at line 834 of file SkinTemplate.php.

References $name, $title, and Title\newFromText().

◆ 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 511 of file SkinTemplate.php.

References $html, $options, as, buildPersonalUrls(), null, and setupTemplateForOutput().

Referenced by getPersonalToolsList().

◆ makeTalkUrlDetails()

SkinTemplate::makeTalkUrlDetails (   $name,
  $urlaction = '' 
)

Definition at line 815 of file SkinTemplate.php.

References $name, $title, and Title\newFromText().

Referenced by buildPersonalUrls().

◆ outputPage()

SkinTemplate::outputPage ( )

Initialize various variables and generate the template.

Definition at line 212 of file SkinTemplate.php.

References $out, $res, ContextSource\getOutput(), Skin\initPage(), Profiler\instance(), prepareQuickTemplate(), and printOrError().

◆ prepareQuickTemplate()

◆ printOrError()

SkinTemplate::printOrError (   $str)

Output the string, or print error message if it's an error object of the appropriate type.

For the base class, assume strings all around.

Parameters
string$str
Access:
private

Definition at line 563 of file SkinTemplate.php.

Referenced by outputPage().

◆ setupTemplate()

SkinTemplate::setupTemplate (   $classname,
  $repository = false,
  $cache_dir = false 
)

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
bool | string$repositorySubdirectory where we keep template files
bool | string$cache_dir
Returns
QuickTemplate
Access:
private

Definition at line 70 of file SkinTemplate.php.

References ContextSource\getConfig().

Referenced by setupTemplateForOutput().

◆ setupTemplateForOutput()

◆ tabAction()

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

Builds an array with tab definition.

Parameters
Title$titlePage Where the tab links to
string | array$messageMessage key 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 759 of file SkinTemplate.php.

References $query, $services, $title, ContextSource\getContext(), Hooks\run(), true, and wfMessageFallback().

Referenced by buildContentNavigationUrls().

◆ useCombinedLoginLink()

SkinTemplate::useCombinedLoginLink ( )

Output a boolean indicating if buildPersonalUrls should output separate login and create account links or output a combined link By default we simply return a global config setting that affects most skins This is setup as a method so that like with $wgLogo and getLogo() a skin can override this setting and always output one or the other if it has a reason it can't output one of the two modes.

Returns
bool

Definition at line 576 of file SkinTemplate.php.

References $wgUseCombinedLoginLink.

Referenced by buildPersonalUrls().

◆ wrapHTML()

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

Wrap the body text with language information and identifiable element.

Parameters
Title$title
string$htmlbody text
Returns
string html

Definition at line 232 of file SkinTemplate.php.

References $html, $title, Action\getActionName(), NS_FILE, NS_SPECIAL, and Html\rawElement().

Referenced by prepareQuickTemplate().

Member Data Documentation

◆ $loggedin

SkinTemplate::$loggedin

Definition at line 55 of file SkinTemplate.php.

◆ $skinname

string SkinTemplate::$skinname = 'monobook'

Name of our skin, it probably needs to be all lower case.

Child classes should override the default.

Definition at line 43 of file SkinTemplate.php.

Referenced by buildContentNavigationUrls().

◆ $template

string SkinTemplate::$template = QuickTemplate::class

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

Child classes should override the default.

Definition at line 49 of file SkinTemplate.php.

◆ $thispage

SkinTemplate::$thispage

Definition at line 51 of file SkinTemplate.php.

◆ $thisquery

SkinTemplate::$thisquery

Definition at line 54 of file SkinTemplate.php.

◆ $titletxt

SkinTemplate::$titletxt

Definition at line 52 of file SkinTemplate.php.

◆ $username

SkinTemplate::$username

Definition at line 56 of file SkinTemplate.php.

Referenced by buildPersonalUrls().

◆ $userpage

SkinTemplate::$userpage

Definition at line 53 of file SkinTemplate.php.

◆ $userpageUrlDetails

SkinTemplate::$userpageUrlDetails

Definition at line 57 of file SkinTemplate.php.


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