From 361e0d6f71032e22bc12d30d32e9944f585091f7 Mon Sep 17 00:00:00 2001 From: Jan Drewniak Date: Fri, 10 Jan 2020 16:00:54 +0100 Subject: [PATCH] Extract Portal mustache component from VectorTemplate.php A Portal (or portlet) in the Vector context is a section of the sidebar menu (e.g. Tools, Languges etc.). The hook that places content between the portals (or portlets?) such as `SkinTemplateToolboxEnd` and `otherlanguages` has been enclosed inside of an output buffer so that any content it produces can be passed to a template. Bug: T239248, T240062 Change-Id: I882db161e5462cf88aa48c9cfd91448eb97a4a77 --- includes/VectorTemplate.php | 70 ++++++++++++++---------------- includes/templates/Portal.mustache | 19 ++++++++ 2 files changed, 51 insertions(+), 38 deletions(-) create mode 100644 includes/templates/Portal.mustache diff --git a/includes/VectorTemplate.php b/includes/VectorTemplate.php index 887a9a812..0270b4057 100644 --- a/includes/VectorTemplate.php +++ b/includes/VectorTemplate.php @@ -228,45 +228,39 @@ class VectorTemplate extends BaseTemplate { if ( $msg === null ) { $msg = $name; } - $msgObj = $this->getMsg( $msg ); - $labelId = Sanitizer::escapeIdForAttribute( "p-$name-label" ); - ?> - - getMsg( $msg ); + + $props = [ + 'portal-id' => "p-$name", + 'html-tooltip' => Linker::tooltip( 'p-' . $name ), + 'msg-label' => $msgObj->exists() ? $msgObj->text() : $msg, + 'msg-label-id' => "p-$name-label", + 'html-userlangattributes' => $this->data['userlangattributes'] ?? '', + 'html-portal-content' => '', + 'html-after-portal' => $this->getAfterPortlet( $name ), + ]; + + if ( is_array( $content ) ) { + $props['html-portal-content'] .= ''; + } else { + // Allow raw HTML block to be defined by extensions + $props['html-portal-content'] = $content; + } + + echo $this->templateParser->processTemplate( 'Portal', $props ); } /** diff --git a/includes/templates/Portal.mustache b/includes/templates/Portal.mustache new file mode 100644 index 000000000..3d7cbc201 --- /dev/null +++ b/includes/templates/Portal.mustache @@ -0,0 +1,19 @@ +{{! + string portal-id + string html-tooltip + string msg-label-id + string|null html-userlangattributes + string msg-label} + string html-portal-content + string|null html-after-portal +}} + +