diff --git a/includes/VectorTemplate.php b/includes/VectorTemplate.php index b603912..f587c37 100644 --- a/includes/VectorTemplate.php +++ b/includes/VectorTemplate.php @@ -27,9 +27,10 @@ * @ingroup Skins */ class VectorTemplate extends BaseTemplate { + /* Functions */ /** - * Outputs the entire contents of the HTML page + * Outputs the entire contents of the (X)HTML page */ public function execute() { $this->data['namespace_urls'] = $this->data['content_navigation']['namespaces']; @@ -48,55 +49,102 @@ class VectorTemplate extends BaseTemplate { unset( $this->data['action_urls'][$mode] ); } } + $this->data['pageLanguage'] = + $this->getSkin()->getTitle()->getPageViewLanguage()->getHtmlCode(); - // Naming conventions for Mustache parameters: - // - Prefix "is" for boolean values. - // - Prefix "msg-" for interface messages. - // - Prefix "page-" for data relating to the current page (e.g. Title, WikiPage, or OutputPage). - // - Prefix "html-" for raw HTML (in front of other keys, if applicable). - // - Conditional values are null if absent. - $params = [ - 'html-headelement' => $this->get( 'headelement', '' ), - 'html-sitenotice' => $this->get( 'sitenotice', null ), - 'html-indicators' => $this->getIndicators(), - 'page-langcode' => $this->getSkin()->getTitle()->getPageViewLanguage()->getHtmlCode(), - 'page-isarticle' => !!$this->data['isarticle'], - - // Loose comparison with '!=' is intentional, to catch null and false too, but not '0' - 'html-title' => ( $this->data['title'] != '' ? $this->get( 'title' ) : null ), - - 'html-prebodyhtml' => $this->get( 'prebodyhtml', '' ), - 'msg-tagline' => $this->getMsg( 'tagline' )->text(), - // TODO: mediawiki/SkinTemplate should expose langCode and langDir properly. - 'html-userlangattributes' => $this->get( 'userlangattributes', '' ), - // From OutputPage::getSubtitle() - 'html-subtitle' => $this->get( 'subtitle', '' ), - - // TODO: Use directly Skin::getUndeleteLink() directly. - // Always returns string, cast to null if empty. - 'html-undelete' => $this->get( 'undelete', null ) ?: null, - - // From Skin::getNewtalks(). Always returns string, cast to null if empty. - 'html-newtalk' => $this->get( 'newtalk', '' ) ?: null, - - 'msg-jumptonavigation' => $this->getMsg( 'vector-jumptonavigation' )->text(), - 'msg-jumptosearch' => $this->getMsg( 'vector-jumptosearch' )->text(), - - // Result of OutputPage::addHTML calls - 'html-bodycontent' => $this->get( 'bodycontent' ), - - 'html-printfooter' => $this->get( 'printfooter', null ), - 'html-catlinks' => $this->get( 'catlinks', '' ), - 'html-dataAfterContent' => $this->get( 'dataAfterContent', '' ), - // From MWDebug::getHTMLDebugLog (when $wgShowDebug is enabled) - 'html-debuglog' => $this->get( 'debughtml', '' ), - // From BaseTemplate::getTrail (handles bottom JavaScript) - 'html-printtail' => $this->getTrail(), - ]; - - // TODO: Convert the rest to Mustache - ob_start(); + // Output HTML Page + $this->html( 'headelement' ); ?> +
+
+
+ + data['sitenotice'] ) { + echo Html::rawElement( 'div', + [ + 'id' => 'siteNotice', + 'class' => 'mw-body-content', + ], + // Raw HTML + $this->get( 'sitenotice' ) + ); + } + echo $this->getIndicators(); + // Loose comparison with '!=' is intentional, to catch null and false too, but not '0' + if ( $this->data['title'] != '' ) { + echo Html::rawElement( 'h1', + [ + 'id' => 'firstHeading', + 'class' => 'firstHeading', + 'lang' => $this->get( 'pageLanguage' ), + ], + // Raw HTML + $this->get( 'title' ) + ); + } + + $this->html( 'prebodyhtml' ); + ?> +
+ data['isarticle'] ) { + echo Html::element( 'div', + [ + 'id' => 'siteSub', + 'class' => 'noprint', + ], + $this->getMsg( 'tagline' )->text() + ); + } + ?> +
html( 'userlangattributes' ) ?>>html( 'subtitle' ) + ?>
+ data['undelete'] ) { + echo Html::rawElement( 'div', + [ 'id' => 'contentSub2' ], + // Raw HTML + $this->get( 'undelete' ) + ); + } + if ( $this->data['newtalk'] ) { + echo Html::rawElement( 'div', + [ 'class' => 'usermessage' ], + // Raw HTML + $this->get( 'newtalk' ) + ); + } + // Keep this empty `div` for compatibility with gadgets and user scripts + // using this place to insert extra elements before. + echo Html::element( 'div', [ 'id' => 'jump-to-nav' ] ); + ?> + msg( 'vector-jumptonavigation' ) ?> + msg( 'vector-jumptosearch' ) ?> + html( 'bodycontent' ); + + if ( $this->data['printfooter'] ) { + ?> +
+ html( 'printfooter' ); ?> +
+ data['catlinks'] ) { + $this->html( 'catlinks' ); + } + + if ( $this->data['dataAfterContent'] ) { + $this->html( 'dataAfterContent' ); + } + ?> +
+ html( 'debughtml' ); ?> +
+

msg( 'navigation-heading' ) ?>

@@ -157,13 +205,11 @@ class VectorTemplate extends BaseTemplate { ?>
- printTrail(); ?> - // Prepare and output the HTML response - $templates = new TemplateParser( __DIR__ . '/templates' ); - echo $templates->processTemplate( 'index', $params ); + + +
-
-
- - {{#html-sitenotice}}
{{{html-sitenotice}}}
{{/html-sitenotice}} - {{{html-indicators}}} - {{#html-title}}

{{{html-title}}}

{{/html-title}} - {{{html-prebodyhtml}}} -
- {{#page-isarticle}}
{{msg-tagline}}
{{/page-isarticle}} -
{{{html-subtitle}}}
- {{#html-undelete}}
{{{html-undelete}}}
{{/html-undelete}} - {{#html-newtalk}}
{{{html-newtalk}}}
{{/html-newtalk}} - {{! - Keep this empty `div` for compatibility with gadgets and user scripts - using this place to insert extra elements before. - }} -
- {{msg-jumptonavigation}} - {{msg-jumptosearch}} - {{{html-bodycontent}}} - {{#html-printfooter}} -
{{{html-printfooter}}}
- {{/html-printfooter}} - {{{html-catlinks}}} - {{{html-dataAfterContent}}} -
- {{{html-debuglog}}} -
-
-{{! html-unported outputs
and