MediaWiki REL1_37
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 }
43 }
44
51 public function generateHTML() {
52 $this->setupTemplateContext();
53 $out = $this->getOutput();
54 $tp = $this->getTemplateParser();
55 $template = $this->options['template'] ?? 'skin';
56 $data = $this->getTemplateData();
57
58 // T259955: OutputPage::headElement must be called last (after getTemplateData)
59 // as it calls OutputPage::getRlClient, which freezes the ResourceLoader
60 // modules queue for the current page load.
61 $html = $out->headElement( $this );
62
63 $html .= $tp->processTemplate( $template, $data );
64 $html .= $out->tailElement( $this );
65 return $html;
66 }
67
72 public function getTemplateData() {
73 $out = $this->getOutput();
74 $printSource = Html::rawElement( 'div', [ 'class' => 'printfooter' ], $this->printSource() );
75 $bodyContent = $out->getHTML() . "\n" . $printSource;
76
77 $newTalksHtml = $this->getNewtalks() ?: null;
78
79 $data = parent::getTemplateData() + [
80 // Array objects
81 'array-indicators' => $this->getIndicatorsData( $out->getIndicators() ),
82 // HTML strings
83 'html-site-notice' => $this->getSiteNotice() ?: null,
84 'html-user-message' => $newTalksHtml ?
85 Html::rawElement( 'div', [ 'class' => 'usermessage' ], $newTalksHtml ) : null,
86 'html-title' => $out->getPageTitle(),
87 'html-subtitle' => $this->prepareSubtitle(),
88 'html-body-content' => $this->wrapHTML( $out->getTitle(), $bodyContent ),
89 'html-categories' => $this->getCategories(),
90 'html-after-content' => $this->afterContentHook(),
91 'html-undelete-link' => $this->prepareUndeleteLink(),
92 'html-user-language-attributes' => $this->prepareUserLanguageAttributes(),
93
94 // links
95 'link-mainpage' => Title::newMainPage()->getLocalUrl(),
96 ];
97
98 foreach ( $this->options['messages'] ?? [] as $message ) {
99 $data["msg-{$message}"] = $this->msg( $message )->text();
100 }
101 return $data;
102 }
103}
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...
TemplateParser null $templateParser
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.
prepareUserLanguageAttributes()
Prepare user language attribute links.
wrapHTML( $title, $html)
Wrap the body text with language information and identifiable element.
setupTemplateContext()
Setup class properties that are necessary prior to calling setupTemplateForOutput.
prepareUndeleteLink()
Prepare undelete link for output in page.
afterContentHook()
This runs a hook to allow extensions placing their stuff after content and article metadata (e....
Definition Skin.php:694
getNewtalks()
Gets new talk page messages for the current user and returns an appropriate alert message (or an empt...
Definition Skin.php:1808
getSiteNotice()
Definition Skin.php:1962
getIndicatorsData( $indicators)
Return an array of indicator data.
Definition Skin.php:2145
prepareSubtitle()
Prepare the subtitle of the page for output in the skin if one has been set.
Definition Skin.php:2550
printSource()
Text with the permalink to the source page, usually shown on the footer of a printed page.
Definition Skin.php:743
getCategories()
Definition Skin.php:659