jenkins-bot has submitted this change and it was merged.
Change subject: Hygiene: Prepare renderContent function for templates
......................................................................
Hygiene: Prepare renderContent function for templates
Change-Id: I7405aa57d2479a4a37db26ed8fb24e637982a443
---
M includes/skins/MinervaTemplate.php
M includes/skins/MinervaTemplateBeta.php
2 files changed, 38 insertions(+), 24 deletions(-)
Approvals:
Bmansurov: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/skins/MinervaTemplate.php
b/includes/skins/MinervaTemplate.php
index 77db269..d8fc8b6 100644
--- a/includes/skins/MinervaTemplate.php
+++ b/includes/skins/MinervaTemplate.php
@@ -159,10 +159,11 @@
}
/**
- * Outputs the 'Last edited' message, e.g. 'Last edited on...'
+ * Returns the 'Last edited' message, e.g. 'Last edited on...'
* @param array $data Data used to build the page
+ * @return string
*/
- protected function renderHistoryLink( $data ) {
+ protected function getHistoryLinkHtml( $data ) {
$action = Action::getActionName( RequestContext::getMain() );
if ( isset( $data['historyLink'] ) && $action === 'view' ) {
$historyLink = $data['historyLink'];
@@ -175,27 +176,35 @@
'timestamp' => $historyLink['data-timestamp']
);
$templateParser = new TemplateParser( __DIR__ );
- echo $templateParser->processTemplate( 'history', $args
);
+ return $templateParser->processTemplate( 'history',
$args );
+ } else {
+ return '';
}
}
/**
- * Renders history link at top of page if it isn't the main page
+ * Gets history link at top of page if it isn't the main page
* @param array $data Data used to build the page
+ * @return string
*/
- protected function renderHistoryLinkTop( $data ) {
+ protected function getHistoryLinkTopHtml( $data ) {
if ( !$this->isMainPage ) {
- $this->renderHistoryLink( $data );
+ return $this->getHistoryLinkHtml( $data );
+ } else {
+ return '';
}
}
/**
- * Renders history link at bottom of page if it is the main page
+ * Gets history link at bottom of page if it is the main page
* @param array $data Data used to build the page
+ * @return string
*/
- protected function renderHistoryLinkBottom( $data ) {
+ protected function getHistoryLinkBottomHtml( $data ) {
if ( $this->isMainPage ) {
- $this->renderHistoryLink( $data );
+ return $this->getHistoryLinkHtml( $data );
+ } else {
+ return '';
}
}
@@ -225,11 +234,12 @@
}
/**
- * Render secondary page actions like language selector
+ * Get HTML representing secondary page actions like language selector
+ * @return string
*/
- protected function renderSecondaryActions() {
+ protected function getSecondaryActionsHtml() {
$baseClass = MobileUI::buttonClass( '', 'button' );
- echo Html::openElement( 'div', array( 'id' =>
'page-secondary-actions' ) );
+ $html = Html::openElement( 'div', array( 'id' =>
'page-secondary-actions' ) );
foreach ( $this->getSecondaryActions() as $el ) {
if ( isset( $el['attributes']['class'] ) ) {
@@ -237,10 +247,10 @@
} else {
$el['attributes']['class'] = $baseClass;
}
- echo Html::element( 'a', $el['attributes'],
$el['label'] );
+ $html .= Html::element( 'a', $el['attributes'],
$el['label'] );
}
- echo Html::closeElement( 'div' );
+ return $html . Html::closeElement( 'div' );
}
/**
@@ -261,9 +271,9 @@
if ( isset( $data['subject-page'] ) ) {
echo $data['subject-page'];
}
- $this->renderPostContent( $data );
- $this->renderSecondaryActions();
- $this->renderHistoryLinkBottom( $data );
+ echo $this->getPostContentHtml( $data );
+ echo $this->getSecondaryActionsHtml();
+ echo $this->getHistoryLinkBottomHtml( $data );
?>
</div>
<?php
@@ -300,11 +310,13 @@
}
/**
- * Renders any content after the main content and before the secondary
actions.
+ * Gets HTML that needs to come after the main content and before the
secondary actions.
*
* @param array $data The data used to build the page
+ * @return string
*/
- protected function renderPostContent( $data ) {
+ protected function getPostContentHtml( $data ) {
+ return '';
}
/**
@@ -313,7 +325,7 @@
*/
protected function renderContentWrapper( $data ) {
if ( $this->renderHistoryLinkBeforeContent ) {
- $this->renderHistoryLinkTop( $data );
+ echo $this->getHistoryLinkTopHtml( $data );
?>
<script>
if ( window.mw && mw.mobileFrontend ) {
mw.mobileFrontend.emit( 'history-link-loaded' ); }
@@ -328,7 +340,7 @@
$this->renderPreContent( $data );
$this->renderContent( $data );
if ( !$this->renderHistoryLinkBeforeContent ) {
- $this->renderHistoryLinkTop( $data );
+ echo $this->getHistoryLinkTopHtml( $data );
?>
<script>
if ( window.mw && mw.mobileFrontend ) {
mw.mobileFrontend.emit( 'history-link-loaded' ); }
diff --git a/includes/skins/MinervaTemplateBeta.php
b/includes/skins/MinervaTemplateBeta.php
index 5269d6d..7a73347 100644
--- a/includes/skins/MinervaTemplateBeta.php
+++ b/includes/skins/MinervaTemplateBeta.php
@@ -103,9 +103,11 @@
}
}
- /** @inheritdoc */
- protected function renderPostContent( $data ) {
- echo $this->renderBrowseTags( $data );
+ /**
+ * @inheritdoc
+ */
+ protected function getPostContentHtml( $data ) {
+ return $this->renderBrowseTags( $data );
}
/**
--
To view, visit https://gerrit.wikimedia.org/r/216142
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I7405aa57d2479a4a37db26ed8fb24e637982a443
Gerrit-PatchSet: 3
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