MediaWiki REL1_40
SkinMustache.php
Go to the documentation of this file.
1<?php
24
33 private $templateParser = null;
34
42 protected function getTemplateParser() {
43 if ( $this->templateParser === null ) {
44 $this->templateParser = new TemplateParser( $this->options['templateDirectory'] );
45 // For table of contents rendering.
46 $this->templateParser->enableRecursivePartials( true );
47 }
48 return $this->templateParser;
49 }
50
57 public function generateHTML() {
58 $this->setupTemplateContext();
59 $out = $this->getOutput();
60 $tp = $this->getTemplateParser();
61 $template = $this->options['template'] ?? 'skin';
62 $data = $this->getTemplateData();
63
64 // T259955: OutputPage::headElement must be called last (after getTemplateData)
65 // as it calls OutputPage::getRlClient, which freezes the ResourceLoader
66 // modules queue for the current page load.
67 $html = $out->headElement( $this );
68
69 $html .= $tp->processTemplate( $template, $data );
70 $html .= $out->tailElement( $this );
71 return $html;
72 }
73
78 public function getTemplateData() {
79 $out = $this->getOutput();
80 $printSource = Html::rawElement(
81 'div',
82 [
83 'class' => 'printfooter',
84 'data-nosnippet' => ''
85 ],
86 $this->printSource()
87 );
88 $bodyContent = $out->getHTML() . "\n" . $printSource;
89
90 $newTalksHtml = $this->getNewtalks() ?: null;
91
92 $data = parent::getTemplateData() + [
93 // Array objects
94 'array-indicators' => $this->getIndicatorsData( $out->getIndicators() ),
95 // HTML strings
96 'html-site-notice' => $this->getSiteNotice() ?: null,
97 'html-user-message' => $newTalksHtml ?
98 Html::rawElement( 'div', [ 'class' => 'usermessage' ], $newTalksHtml ) : null,
99 'html-subtitle' => $this->prepareSubtitle(),
100 'html-body-content' => $this->wrapHTML( $out->getTitle(), $bodyContent ),
101 'html-categories' => $this->getCategories(),
102 'html-after-content' => $this->afterContentHook(),
103 'html-undelete-link' => $this->prepareUndeleteLink(),
104 'html-user-language-attributes' => $this->prepareUserLanguageAttributes(),
105
106 // links
107 'link-mainpage' => Title::newMainPage()->getLocalURL(),
108 ];
109
110 foreach ( $this->options['messages'] ?? [] as $message ) {
111 $data["msg-{$message}"] = $this->msg( $message )->text();
112 }
113 return $data;
114 }
115}
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
This class is a collection of static functions that serve two purposes:
Definition Html.php:55
Represents a title within MediaWiki.
Definition Title.php:82
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:715
prepareUndeleteLink()
Prepare undelete link for output in page.
Definition Skin.php:2268
getNewtalks()
Gets new talk page messages for the current user and returns an appropriate alert message (or an empt...
Definition Skin.php:1640
getSiteNotice()
Definition Skin.php:1795
getIndicatorsData( $indicators)
Return an array of indicator data.
Definition Skin.php:1951
printSource()
Text with the permalink to the source page, usually shown on the footer of a printed page.
Definition Skin.php:772
prepareSubtitle(bool $withContainer=true)
Prepare the subtitle of the page for output in the skin if one has been set.
Definition Skin.php:2207
prepareUserLanguageAttributes()
Prepare user language attribute links.
Definition Skin.php:2257
wrapHTML( $title, $html)
Wrap the body text with language information and identifiable element.
Definition Skin.php:2290
getCategories()
Definition Skin.php:680