jenkins-bot has submitted this change and it was merged.
Change subject: Hygiene: Use getter to get main menu and header html
......................................................................
Hygiene: Use getter to get main menu and header html
Change-Id: I864715af082c6596762ae586eb4148084a2ce033
---
M includes/skins/MinervaTemplate.php
M includes/skins/MinervaTemplateAlpha.php
2 files changed, 25 insertions(+), 29 deletions(-)
Approvals:
Bmansurov: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/skins/MinervaTemplate.php
b/includes/skins/MinervaTemplate.php
index b376baf..d730421 100644
--- a/includes/skins/MinervaTemplate.php
+++ b/includes/skins/MinervaTemplate.php
@@ -23,12 +23,12 @@
protected $isMainPage;
/**
- * Renders the header content for the top chrome.
+ * Gets the header content for the top chrome.
* @param array $data Data used to build the page
* @return string
*/
protected function getChromeHeaderContentHtml( $data ) {
- return $this->makeSearchForm( $data );
+ return $this->getSearchForm( $data );
}
/**
@@ -37,7 +37,7 @@
* @param array $data The data used to render the page
* @return string
*/
- protected function makeSearchForm( $data ) {
+ protected function getSearchForm( $data ) {
return Html::openElement( 'form',
array(
'action' => $data['wgScript'],
@@ -351,27 +351,31 @@
}
/**
- * Renders the main menu only on Special:MobileMenu.
+ * Gets the main menu only on Special:MobileMenu.
* On other pages the menu is rendered via JS.
* @param array [$data] Data used to build the page
+ * @return string
*/
- protected function renderMainMenu( $data ) {
+ protected function getMainMenuHtml( $data ) {
if ( $this->isSpecialMobileMenuPage ) {
$templateParser = new TemplateParser(
__DIR__ . '/../../resources/mobile.mainMenu/' );
- echo $templateParser->processTemplate( 'menu',
$data['menu_data'] );
+ return $templateParser->processTemplate( 'menu',
$data['menu_data'] );
+ } else {
+ return '';
}
}
/**
- * Render Header elements
+ * Get HTML for header elements
* @param array $data Data used to build the header
+ * @return string
*/
- protected function renderHeader( $data ) {
- $this->html( 'menuButton' );
- echo $this->getChromeHeaderContentHtml( $data );
- echo $data['secondaryButton'];
+ protected function getHeaderHtml( $data ) {
+ return $data['menuButton']
+ . $this->getChromeHeaderContentHtml( $data )
+ . $data['secondaryButton'];
}
/**
@@ -387,7 +391,7 @@
?>
<div id="mw-mf-viewport">
<nav id="mw-mf-page-left" class="navigation-drawer">
- <?php $this->renderMainMenu( $data ); ?>
+ <?php echo $this->getMainMenuHtml( $data ); ?>
</nav>
<div id="mw-mf-page-center">
<?php
@@ -395,7 +399,7 @@
?>
<div class="header">
<?php
- $this->renderHeader( $data );
+ echo $this->getHeaderHtml(
$data );
?>
</div>
<div id="content_wrapper">
diff --git a/includes/skins/MinervaTemplateAlpha.php
b/includes/skins/MinervaTemplateAlpha.php
index d431450..0663e9d 100644
--- a/includes/skins/MinervaTemplateAlpha.php
+++ b/includes/skins/MinervaTemplateAlpha.php
@@ -53,7 +53,7 @@
/**
* @inheritdoc
*/
- protected function getChromeHeaderContentHtml( $data ) {
+ protected function getHeaderHtml( $data ) {
$templateParser = new TemplateParser( __DIR__ );
$args = array(
'siteName' => SkinMinerva::getSitename(),
@@ -62,7 +62,8 @@
'mobileMenuTitle' => wfMessage(
'mobile-frontend-main-menu' )->parse()
);
- return $templateParser->processTemplate( 'header', $args );
+ return $templateParser->processTemplate( 'header', $args )
+ . $data['secondaryButton'];
}
protected function getSearchAttributes() {
@@ -75,7 +76,7 @@
/**
* @inheritdoc
*/
- protected function makeSearchForm( $data ) {
+ protected function getSearchForm( $data ) {
return Html::openElement( 'form',
array(
'action' => $data['wgScript'],
@@ -96,25 +97,16 @@
}
/**
- * Render Header elements
- * @param array $data Data used to build the header
- */
- protected function renderHeader( $data ) {
- echo $this->getChromeHeaderContentHtml( $data );
- echo $data['secondaryButton'];
- }
-
- /**
* In addition to the main menu, this function renders the search form
on top of the menu
* @inheritdoc
*/
- protected function renderMainMenu( $data ) {
+ protected function getMainMenuHtml( $data ) {
$templateParser = new TemplateParser( __DIR__ );
$args = array(
- 'searchForm' => $this->makeSearchForm( $data )
+ 'searchForm' => $this->getSearchForm( $data )
);
- echo $templateParser->processTemplate( 'searchForm', $args );
- parent::renderMainMenu( $data );
+ return $templateParser->processTemplate( 'searchForm', $args )
+ . parent::getMainMenuHtml( $data );
}
}
--
To view, visit https://gerrit.wikimedia.org/r/216150
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I864715af082c6596762ae586eb4148084a2ce033
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
Gerrit-Reviewer: Bmansurov <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits