MediaWiki REL1_41
SkinMustache.php
Go to the documentation of this file.
1<?php
26
35 private $templateParser = null;
36
44 protected function getTemplateParser() {
45 if ( $this->templateParser === null ) {
46 $this->templateParser = new TemplateParser( $this->options['templateDirectory'] );
47 // For table of contents rendering.
48 $this->templateParser->enableRecursivePartials( true );
49 }
50 return $this->templateParser;
51 }
52
59 private function createTempUserBannerHTML() {
60 $isSupportedSkin = $this->getOptions()['tempUserBanner'];
61 $isTempUser = $this->getUser()->isTemp();
62
63 if ( !$isSupportedSkin || !$isTempUser ) {
64 return '';
65 }
66
67 $returntoParam = SkinComponentUtils::getReturnToParam(
68 $this->getTitle(),
69 $this->getRequest(),
70 $this->getAuthority()
71 );
72
73 $tempUserBanner = new SkinComponentTempUserBanner(
74 $returntoParam,
75 $this->getContext(),
76 $this->getUser(),
77 );
78 return $tempUserBanner->getTemplateData()['html'];
79 }
80
87 public function generateHTML() {
88 $this->setupTemplateContext();
89 $out = $this->getOutput();
90 $tp = $this->getTemplateParser();
91 $template = $this->options['template'] ?? 'skin';
92 $data = $this->getTemplateData();
93 $tempUserBannerHTML = $this->createTempUserBannerHTML();
94
95 // T259955: OutputPage::headElement must be called last (after getTemplateData)
96 // as it calls OutputPage::getRlClient, which freezes the ResourceLoader
97 // modules queue for the current page load.
98 $html = $out->headElement( $this );
99
100 $html .= $tempUserBannerHTML;
101
102 $html .= $tp->processTemplate( $template, $data );
103 $html .= $out->tailElement( $this );
104 return $html;
105 }
106
111 public function getTemplateData() {
112 $out = $this->getOutput();
113 $printSource = Html::rawElement(
114 'div',
115 [
116 'class' => 'printfooter',
117 'data-nosnippet' => ''
118 ] + $this->getUserLanguageAttributes(),
119 $this->printSource()
120 );
121 $bodyContent = $out->getHTML() . "\n" . $printSource;
122
123 $newTalksHtml = $this->getNewtalks() ?: null;
124
125 $data = parent::getTemplateData() + [
126 // Array objects
127 'array-indicators' => $this->getIndicatorsData( $out->getIndicators() ),
128 // HTML strings
129 'html-site-notice' => $this->getSiteNotice() ?: null,
130 'html-user-message' => $newTalksHtml ?
131 Html::rawElement( 'div', [ 'class' => 'usermessage' ], $newTalksHtml ) : null,
132 'html-subtitle' => $this->prepareSubtitle(),
133 'html-body-content' => $this->wrapHTML( $out->getTitle(), $bodyContent ),
134 'html-categories' => $this->getCategories(),
135 'html-after-content' => $this->afterContentHook(),
136 'html-undelete-link' => $this->prepareUndeleteLink(),
137 'html-user-language-attributes' => $this->prepareUserLanguageAttributes(),
138
139 // links
140 'link-mainpage' => Title::newMainPage()->getLocalURL(),
141 ];
142
143 foreach ( $this->options['messages'] ?? [] as $message ) {
144 $data["msg-{$message}"] = $this->msg( $message )->text();
145 }
146 return $data;
147 }
148}
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
getContext()
Get the base IContextSource object.
This class is a collection of static functions that serve two purposes:
Definition Html.php:57
Represents a title within MediaWiki.
Definition Title.php:76
Generic template for use with Mustache templates.
getTemplateData()
to extend. Subclasses may extend this method to add additional template data. this method should neve...
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:771
prepareUndeleteLink()
Prepare undelete link for output in page.
Definition Skin.php:2332
getNewtalks()
Gets new talk page messages for the current user and returns an appropriate alert message (or an empt...
Definition Skin.php:1704
getUserLanguageAttributes()
Get user language attribute links array.
Definition Skin.php:2299
getSiteNotice()
Definition Skin.php:1859
getIndicatorsData( $indicators)
Return an array of indicator data.
Definition Skin.php:2016
getOptions()
Get current skin's options.
Definition Skin.php:2387
printSource()
Text with the permalink to the source page, usually shown on the footer of a printed page.
Definition Skin.php:828
prepareSubtitle(bool $withContainer=true)
Prepare the subtitle of the page for output in the skin if one has been set.
Definition Skin.php:2271
prepareUserLanguageAttributes()
Prepare user language attribute links.
Definition Skin.php:2321
wrapHTML( $title, $html)
Wrap the body text with language information and identifiable element.
Definition Skin.php:2354
getCategories()
Definition Skin.php:736