Jdlrobson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/270335
Change subject: Hygiene: Switch skin methods to get method
......................................................................
Hygiene: Switch skin methods to get method
This allows us to move towards a more template driven approach
* renderContent is now getContentHtml
* renderPageActions->getPageActionsHtml
* renderPreContent -> getPreContentHtml
* renderContentWrapper->getContentWrapperHtml
* renderFooter -> getFooterHtml
Change-Id: Id46aa47f12cbe909e444c3742f5ef8c7484bec70
---
M includes/skins/MinervaTemplate.php
A includes/skins/minerva.mustache
2 files changed, 67 insertions(+), 54 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend
refs/changes/35/270335/1
diff --git a/includes/skins/MinervaTemplate.php
b/includes/skins/MinervaTemplate.php
index 15aaac2..bb7428c 100644
--- a/includes/skins/MinervaTemplate.php
+++ b/includes/skins/MinervaTemplate.php
@@ -97,43 +97,40 @@
/**
* Render Footer elements
* @param array $data Data used to build the footer
+ * @return string html
*/
- protected function renderFooter( $data ) {
- ?>
- <div id="footer" class="post-content">
- <?php
- foreach ( $this->getFooterLinks() as $category
=> $links ) {
- ?>
- <ul class="footer-<?php echo $category; ?>">
- <?php
- foreach ( $links as $link ) {
- if ( isset(
$this->data[$link] ) && $this->data[$link] !== '' ) {
- echo
Html::openElement( 'li', array( 'id' => "footer-{$category}-{$link}" ) );
- $this->html(
$link );
- echo
Html::closeElement( 'li' );
- }
- }
- ?>
- </ul>
- <?php
+ protected function getFooterHtml( $data ) {
+ $footer = '<div id="footer" class="post-content">';
+ foreach ( $this->getFooterLinks() as $category => $links ) {
+ $footer .= Html::openElement( 'ul', array( 'class' =>
'footer-' . $category ) );
+ foreach ( $links as $link ) {
+ if ( isset( $this->data[$link] ) &&
$this->data[$link] !== '' ) {
+ $footer .= Html::openElement( 'li',
array( 'id' => "footer-{$category}-{$link}" ) );
+ $footer .= $data[$link];
+ $footer .= Html::closeElement( 'li' );
}
- ?>
- </div>
- <?php
+ }
+ $footer .= '</ul>';
+ }
+ $footer .= '</div>';
+ return $footer;
}
/**
* Render available page actions
* @param array $data Data used to build page actions
+ * @return string
*/
- protected function renderPageActions( $data ) {
+ protected function getPageActionsHtml( $data ) {
$actions = $this->getPageActions();
if ( $actions ) {
- ?><ul id="page-actions" class="hlist"><?php
+ $html = '<ul id="page-actions" class="hlist">';
foreach ( $actions as $key => $val ) {
- echo $this->makeListItem( $key, $val );
+ $html .= $this->makeListItem( $key, $val );
}
- ?></ul><?php
+ $html .= '</ul>';
+ } else {
+ return '';
}
}
@@ -216,58 +213,56 @@
}
/**
- * Renders the content of a page
+ * Get the HTML for the content of a page
* @param array $data Data used to build the page
+ * @return string representing HTML of content
*/
- protected function renderContent( $data ) {
+ protected function getContentHtml( $data ) {
if ( !$data[ 'unstyledContent' ] ) {
- echo Html::openElement( 'div', array(
+ $content = Html::openElement( 'div', array(
'id' => 'bodyContent',
'class' => 'content',
) );
- echo $data[ 'bodytext' ];
+ $content .= $data[ 'bodytext' ];
if ( isset( $data['subject-page'] ) ) {
- echo $data['subject-page'];
+ $content .= $data['subject-page'];
}
- ?>
- </div>
- <?php
+ return $content . Html::closeElement( 'div' );
} else {
- echo $data[ 'bodytext' ];
+ return $data[ 'bodytext' ];
}
}
/**
* Renders pre-content (e.g. heading)
* @param array $data Data used to build the page
+ * @return string HTML
*/
- protected function renderPreContent( $data ) {
+ protected function getPreContentHtml( $data ) {
$internalBanner = $data[ 'internalBanner' ];
$preBodyText = isset( $data['prebodyhtml'] ) ?
$data['prebodyhtml'] : '';
$headingHtml = isset( $data['headinghtml'] ) ?
$data['headinghtml'] : '';
$postHeadingHtml = isset( $data['postheadinghtml'] ) ?
$data['postheadinghtml'] : '';
+ $html = '';
if ( $internalBanner || $preBodyText || isset(
$data['page_actions'] ) ) {
- echo $preBodyText;
- ?>
- <div class="pre-content heading-holder">
- <?php
+ $html .= $preBodyText
+ . Html::openElement( 'div', array( 'class' =>
'pre-content heading-holder' ) );
if ( !$this->isSpecialPage ){
- $this->renderPageActions( $data );
+ $html .= $this->getPageActionsHtml(
$data );
}
- echo $headingHtml;
- echo $postHeadingHtml;
- echo $this->html( 'subtitle' );
+ $html .= $headingHtml;
+ $html .= $postHeadingHtml;
+ $html .= $data['subtitle'];
// FIXME: Temporary solution until we have
design
if ( isset( $data['_old_revision_warning'] ) ) {
- echo $data['_old_revision_warning'];
+ $html .= $data['_old_revision_warning'];
}
- echo $internalBanner;
- ?>
- </div>
- <?php
+ $html .= $internalBanner;
+ $html .= '</div>';
}
+ return $html;
}
/**
@@ -284,11 +279,12 @@
/**
* Render wrapper for loading content
* @param array $data Data used to build the page
+ * @return string HTML
*/
- protected function renderContentWrapper( $data ) {
- $this->renderPreContent( $data );
- $this->renderContent( $data );
- echo $this->getPostContentHtml( $data );
+ protected function getContentWrapperHtml( $data ) {
+ return $this->getPreContentHtml( $data ) .
+ $this->getContentHtml( $data ) .
+ $this->getPostContentHtml( $data );
}
/**
@@ -349,11 +345,11 @@
</div>
<div id="content" class="mw-body">
<?php
- $this->renderContentWrapper( $data );
+ echo $this->getContentWrapperHtml(
$data );
?>
</div>
<?php
- $this->renderFooter( $data );
+ echo $this->getFooterHtml( $data );
?>
</div>
</div>
diff --git a/includes/skins/minerva.mustache b/includes/skins/minerva.mustache
new file mode 100644
index 0000000..b6abdd4
--- /dev/null
+++ b/includes/skins/minerva.mustache
@@ -0,0 +1,17 @@
+<div id="mw-mf-viewport">
+ <nav id="mw-mf-page-left" class="navigation-drawer view-border-box">
+ {{{mainmenuhtml}}}
+ </nav>
+ <div id="mw-mf-page-center">
+ <div class="banner-container">
+ {{>banners}}
+ </div>
+ <div class="header">
+ {{{headerhtml}}}
+ </div>
+ <div id="content" class="mw-body">
+ {{{contenthtml}}}
+ </div>
+ {{{footerhtml}}}
+ </div>
+</div>
\ No newline at end of file
--
To view, visit https://gerrit.wikimedia.org/r/270335
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id46aa47f12cbe909e444c3742f5ef8c7484bec70
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