From b41c7ca7be0693380a55aadaa79dee4f608f702e Mon Sep 17 00:00:00 2001 From: jdlrobson Date: Tue, 19 Oct 2021 11:49:54 -0700 Subject: [PATCH] Inline PageActionsMenu template Avoid usage of an additional TemplateParser Bug: T293813 Change-Id: I1cef873d8a3226c9180a0731834f0ecf961f7ece --- includes/Skins/SkinMinerva.php | 31 ++++++------------------------- includes/Skins/skin.mustache | 6 +++--- 2 files changed, 9 insertions(+), 28 deletions(-) diff --git a/includes/Skins/SkinMinerva.php b/includes/Skins/SkinMinerva.php index 832dccfc1..7c94ed53a 100644 --- a/includes/Skins/SkinMinerva.php +++ b/includes/Skins/SkinMinerva.php @@ -91,30 +91,13 @@ class SkinMinerva extends SkinMustache { } /** - * Returns available page actions - * @return array + * Returns available page actions if the page has any. + * + * @return array|null */ private function getPageActions() { - return $this->isFallbackEditor() ? [] : $this->pageActionsMenu; - } - - /** - * Get the HTML for rendering the available page actions - * @return string - */ - private function getPageActionsHtml() { - $hasPageActions = $this->hasPageActions(); - if ( !$hasPageActions ) { - return ''; - } - $templateParser = new TemplateParser( __DIR__ . '/../../includes/Skins' ); - $pageActions = $this->getPageActions(); - $html = ''; - - if ( $pageActions && $pageActions['toolbar'] ) { - $html = $templateParser->processTemplate( 'PageActionsMenu', $pageActions ); - } - return $html; + return $this->isFallbackEditor() || !$this->hasPageActions() ? + null : $this->pageActionsMenu; } /** @@ -125,14 +108,12 @@ class SkinMinerva extends SkinMustache { if ( !$this->hasCategoryLinks() ) { unset( $data['html-categories'] ); } - $hasPageActions = $this->hasPageActions(); $tpl = $this->prepareQuickTemplate(); $tplData = $tpl->execute(); return $data + $tplData + [ - 'has-minerva-page-actions' => $hasPageActions, 'data-minerva-tabs' => $this->getTabsData(), - 'html-minerva-page-actions' => $this->getPageActionsHtml(), + 'data-minerva-page-actions' => $this->getPageActions(), 'html-minerva-subject-link' => $this->getSubjectPage(), 'data-minerva-secondary-actions' => $this->hasSecondaryActions() ? $this->getSecondaryActions() : [], ]; diff --git a/includes/Skins/skin.mustache b/includes/Skins/skin.mustache index 8cd472881..4bff86066 100644 --- a/includes/Skins/skin.mustache +++ b/includes/Skins/skin.mustache @@ -62,9 +62,9 @@ {{/items}} {{/data-minerva-tabs}} - {{#has-minerva-page-actions}} - {{{html-minerva-page-actions}}} - {{/has-minerva-page-actions}} + {{#data-minerva-page-actions}} + {{>PageActionsMenu}} + {{/data-minerva-page-actions}} {{{postheadinghtml}}}
{{{html-subtitle}}}