MediaWiki
REL1_39
SkinMustache.php
Go to the documentation of this file.
1
<?php
25
class
SkinMustache
extends
SkinTemplate
{
29
private
$templateParser =
null
;
30
38
protected
function
getTemplateParser
() {
39
if
( $this->templateParser ===
null
) {
40
$this->templateParser =
new
TemplateParser
( $this->options[
'templateDirectory'
] );
41
// For table of contents rendering.
42
$this->templateParser->enableRecursivePartials(
true
);
43
}
44
return
$this->templateParser;
45
}
46
53
public
function
generateHTML
() {
54
$this->
setupTemplateContext
();
55
$out = $this->
getOutput
();
56
$tp = $this->
getTemplateParser
();
57
$template
= $this->options[
'template'
] ??
'skin'
;
58
$data = $this->
getTemplateData
();
59
60
// T259955: OutputPage::headElement must be called last (after getTemplateData)
61
// as it calls OutputPage::getRlClient, which freezes the ResourceLoader
62
// modules queue for the current page load.
63
$html = $out->headElement( $this );
64
65
$html .= $tp->processTemplate(
$template
, $data );
66
$html .= $out->tailElement( $this );
67
return
$html;
68
}
69
74
public
function
getTemplateData
() {
75
$out = $this->
getOutput
();
76
$printSource = Html::rawElement(
77
'div'
,
78
[
79
'class'
=>
'printfooter'
,
80
'data-nosnippet'
=>
''
81
],
82
$this->
printSource
()
83
);
84
$bodyContent = $out->getHTML() .
"\n"
. $printSource;
85
86
$newTalksHtml = $this->
getNewtalks
() ?:
null
;
87
88
$data = parent::getTemplateData() + [
89
// Array objects
90
'array-indicators'
=> $this->
getIndicatorsData
( $out->getIndicators() ),
91
// HTML strings
92
'html-site-notice'
=> $this->
getSiteNotice
() ?:
null
,
93
'html-user-message'
=> $newTalksHtml ?
94
Html::rawElement(
'div'
, [
'class'
=>
'usermessage'
], $newTalksHtml ) :
null
,
95
'html-subtitle'
=> $this->
prepareSubtitle
(),
96
'html-body-content'
=> $this->
wrapHTML
( $out->getTitle(), $bodyContent ),
97
'html-categories'
=> $this->
getCategories
(),
98
'html-after-content'
=> $this->
afterContentHook
(),
99
'html-undelete-link'
=> $this->
prepareUndeleteLink
(),
100
'html-user-language-attributes'
=> $this->
prepareUserLanguageAttributes
(),
101
102
// links
103
'link-mainpage'
=> Title::newMainPage()->getLocalUrl(),
104
];
105
106
foreach
( $this->options[
'messages'
] ?? [] as $message ) {
107
$data[
"msg-{$message}"
] = $this->
msg
( $message )->text();
108
}
109
return
$data;
110
}
111
}
ContextSource\msg
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
Definition
ContextSource.php:209
ContextSource\getOutput
getOutput()
Definition
ContextSource.php:137
SkinMustache
Generic template for use with Mustache templates.
Definition
SkinMustache.php:25
SkinMustache\getTemplateData
getTemplateData()
Subclasses may extend this method to add additional template data.The data keys should be valid Engli...
Definition
SkinMustache.php:74
SkinMustache\generateHTML
generateHTML()
Subclasses not wishing to use the QuickTemplate render method can rewrite this method,...
Definition
SkinMustache.php:53
SkinMustache\getTemplateParser
getTemplateParser()
Get the template parser, it will be lazily created if not already set.
Definition
SkinMustache.php:38
SkinTemplate
Base class for QuickTemplate-based skins.
Definition
SkinTemplate.php:36
SkinTemplate\$template
string $template
For QuickTemplate, the name of the subclass which will actually fill the template.
Definition
SkinTemplate.php:41
SkinTemplate\setupTemplateContext
setupTemplateContext()
Setup class properties that are necessary prior to calling setupTemplateForOutput.
Definition
SkinTemplate.php:99
Skin\afterContentHook
afterContentHook()
This runs a hook to allow extensions placing their stuff after content and article metadata (e....
Definition
Skin.php:698
Skin\prepareUndeleteLink
prepareUndeleteLink()
Prepare undelete link for output in page.
Definition
Skin.php:2500
Skin\getNewtalks
getNewtalks()
Gets new talk page messages for the current user and returns an appropriate alert message (or an empt...
Definition
Skin.php:1671
Skin\getSiteNotice
getSiteNotice()
Definition
Skin.php:1826
Skin\getIndicatorsData
getIndicatorsData( $indicators)
Return an array of indicator data.
Definition
Skin.php:1982
Skin\prepareSubtitle
prepareSubtitle()
Prepare the subtitle of the page for output in the skin if one has been set.
Definition
Skin.php:2393
Skin\printSource
printSource()
Text with the permalink to the source page, usually shown on the footer of a printed page.
Definition
Skin.php:739
Skin\prepareUserLanguageAttributes
prepareUserLanguageAttributes()
Prepare user language attribute links.
Definition
Skin.php:2489
Skin\wrapHTML
wrapHTML( $title, $html)
Wrap the body text with language information and identifiable element.
Definition
Skin.php:2522
Skin\getCategories
getCategories()
Definition
Skin.php:663
TemplateParser
Definition
TemplateParser.php:28
includes
skins
SkinMustache.php
Generated on Fri Dec 20 2024 15:35:19 for MediaWiki by
1.10.0