Jdlrobson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/216142

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, 28 insertions(+), 19 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/42/216142/1

diff --git a/includes/skins/MinervaTemplate.php 
b/includes/skins/MinervaTemplate.php
index 3a51db5..b91b440 100644
--- a/includes/skins/MinervaTemplate.php
+++ b/includes/skins/MinervaTemplate.php
@@ -189,7 +189,7 @@
         * Outputs the 'Last edited' message, e.g. 'Last edited on...'
         * @param array $data Data used to build the page
         */
-       protected function renderHistoryLink( $data ) {
+       protected function getHistoryLinkHtml( $data ) {
                $action = Action::getActionName( RequestContext::getMain() );
                if ( isset( $data['historyLink'] ) && $action === 'view' ) {
                        $historyLink = $data['historyLink'];
@@ -202,7 +202,9 @@
                                'timestamp' => $historyLink['data-timestamp']
                        );
                        $templateParser = new TemplateParser( __DIR__ );
-                       echo $templateParser->processTemplate( 'history', $args 
);
+                       return $templateParser->processTemplate( 'history', 
$args );
+               } else {
+                       return '';
                }
        }
 
@@ -210,9 +212,11 @@
         * Renders history link at top of page if it isn't the main page
         * @param array $data Data used to build the page
         */
-       protected function renderHistoryLinkTop( $data ) {
+       protected function getHistoryLinkTopHtml( $data ) {
                if ( !$this->isMainPage ) {
-                       $this->renderHistoryLink( $data );
+                       return $this->getHistoryLinkHtml( $data );
+               } else {
+                       return '';
                }
        }
 
@@ -220,9 +224,11 @@
         * Renders history link at bottom of page if it is the main page
         * @param array $data Data used to build the page
         */
-       protected function renderHistoryLinkBottom( $data ) {
+       protected function getHistoryLinkBottomHtml( $data ) {
                if ( $this->isMainPage ) {
-                       $this->renderHistoryLink( $data );
+                       return $this->getHistoryLinkHtml( $data );
+               } else {
+                       return '';
                }
        }
 
@@ -254,9 +260,9 @@
        /**
         * Render secondary page actions like language selector
         */
-       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'] ) ) {
@@ -264,10 +270,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' );
        }
 
        /**
@@ -288,9 +294,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
@@ -331,7 +337,8 @@
         *
         * @param array $data The data used to build the page
         */
-       protected function renderPostContent( $data ) {
+       protected function getPostContentHtml( $data ) {
+               return '';
        }
 
        /**
@@ -340,7 +347,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' ); }
@@ -355,7 +362,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: newchange
Gerrit-Change-Id: I7405aa57d2479a4a37db26ed8fb24e637982a443
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to