MediaWiki REL1_39
SkinMustache.php
Go to the documentation of this file.
1<?php
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}
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
Generic template for use with Mustache templates.
getTemplateData()
Subclasses may extend this method to add additional template data.The data keys should be valid Engli...
generateHTML()
Subclasses not wishing to use the QuickTemplate render method can rewrite this method,...
getTemplateParser()
Get the template parser, it will be lazily created if not already set.
Base class for QuickTemplate-based skins.
string $template
For QuickTemplate, the name of the subclass which will actually fill the template.
setupTemplateContext()
Setup class properties that are necessary prior to calling setupTemplateForOutput.
afterContentHook()
This runs a hook to allow extensions placing their stuff after content and article metadata (e....
Definition Skin.php:698
prepareUndeleteLink()
Prepare undelete link for output in page.
Definition Skin.php:2500
getNewtalks()
Gets new talk page messages for the current user and returns an appropriate alert message (or an empt...
Definition Skin.php:1671
getSiteNotice()
Definition Skin.php:1826
getIndicatorsData( $indicators)
Return an array of indicator data.
Definition Skin.php:1982
prepareSubtitle()
Prepare the subtitle of the page for output in the skin if one has been set.
Definition Skin.php:2393
printSource()
Text with the permalink to the source page, usually shown on the footer of a printed page.
Definition Skin.php:739
prepareUserLanguageAttributes()
Prepare user language attribute links.
Definition Skin.php:2489
wrapHTML( $title, $html)
Wrap the body text with language information and identifiable element.
Definition Skin.php:2522
getCategories()
Definition Skin.php:663