Jdlrobson has uploaded a new change for review.

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


Change subject: Make the universe explode by making a desktop AND mobile skin 
called Minerva
......................................................................

Make the universe explode by making a desktop AND mobile skin called Minerva

This kicks off some work which can lead to consistency between
desktop html markup and mobile html markup by beginning to surface
the mobile skin on the desktop site o_O

To test on desktop apply query string parameter ?useskin=mfe
or set $wgDefaultSkin = 'mfe';
Currently desktop skin is just bare bones content
with search (uses desktop search javascript)

TODO: Currently user menu is not surfaced (e.g. login/logout)
TODO: Currently no watchlist icon on desktop
TODO: Probably want to rewrite footer without ob_start (also
        add desktop footer)
TODO: Ideally want to use a template engine such as mustache
FIXME: mysterious 404 hamburger icon

Change-Id: Iff02c75ff263436de5ea1381d59adf58e20019c6
---
M MobileFrontend.php
M includes/modules/MFResourceLoaderModule.php
A includes/skins/SkinMinerva.php
M includes/skins/SkinMobile.php
M includes/skins/SkinMobileBase.php
M includes/skins/SkinMobileTemplate.php
6 files changed, 306 insertions(+), 190 deletions(-)


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

diff --git a/MobileFrontend.php b/MobileFrontend.php
index 75bb06f..cd834b4 100644
--- a/MobileFrontend.php
+++ b/MobileFrontend.php
@@ -60,6 +60,7 @@
        'UnlistedSpecialMobilePage' => 'specials/UnlistedSpecialMobilePage',
        'SpecialLoginHandshake' => 'specials/SpecialLoginHandshake',
 
+       'SkinMinerva' => 'skins/SkinMinerva',
        'SkinMobile' => 'skins/SkinMobile',
        'SkinMobileTemplate' => 'skins/SkinMobileTemplate',
        'SkinMobileBase' => 'skins/SkinMobileBase',
@@ -73,6 +74,7 @@
 foreach ( $autoloadClasses as $className => $classFilename ) {
        $wgAutoloadClasses[$className] = "$cwd/includes/$classFilename.php";
 }
+$wgValidSkinNames['minerva'] = "Minerva";
 
 $wgExtensionFunctions[] = 'efMobileFrontend_Setup';
 
@@ -154,7 +156,7 @@
        'raw' => true,
        'localBasePath' => $localBasePath,
        'remoteExtPath' => $remoteExtPath,
-       'targets' => 'mobile',
+       'targets' => array( 'mobile', 'desktop' ),
 );
 
 // Filepages
@@ -198,6 +200,7 @@
        'mobileTargets' => array(),
 );
 
+// Important: This module is loaded on both mobile and desktop skin
 $wgResourceModules['mobile.startup'] = $wgMFMobileResourceBoilerplate + array(
        'styles' => array(
        ),
@@ -387,12 +390,11 @@
        'mobileTargets' => array( 'stable', 'beta', 'alpha' ),
 );
 
-$wgResourceModules['mobile.stable'] = $wgMFMobileResourceBoilerplate + array(
+// Important: This module is loaded on both mobile and desktop skin
+$wgResourceModules['mobile.stable.universal'] = $wgMFMobileResourceBoilerplate 
+ array(
        'dependencies' => array(
-               'mediawiki.jqueryMsg',
                'mobile.startup',
                'mobile.stable.dependencies',
-               'mediawiki.util',
                'mobile.stable.styles',
        ),
        'scripts' => array(
@@ -402,6 +404,18 @@
                'javascripts/common/mf-view.js',
                'javascripts/widgets/progress-bar.js',
                'javascripts/common/mf-navigation.js',
+       ),
+       'mobileTargets' => array( 'stable', 'beta', 'alpha' ),
+);
+
+$wgResourceModules['mobile.stable'] = $wgMFMobileResourceBoilerplate + array(
+       'dependencies' => array(
+               'mediawiki.jqueryMsg',
+               'mobile.startup',
+               'mobile.stable.universal',
+               'mediawiki.util',
+       ),
+       'scripts' => array(
                'javascripts/common/mf-notification.js', 
'javascripts/modules/mf-homepage.js',
                'javascripts/modules/mf-cleanuptemplates.js',
                'javascripts/modules/mf-last-modified.js',
diff --git a/includes/modules/MFResourceLoaderModule.php 
b/includes/modules/MFResourceLoaderModule.php
index 2737ee4..a1cecb2 100644
--- a/includes/modules/MFResourceLoaderModule.php
+++ b/includes/modules/MFResourceLoaderModule.php
@@ -9,7 +9,7 @@
        protected $messages = array();
        protected $templates = array();
        protected $localBasePath;
-       protected $targets = array( 'mobile' );
+       protected $targets = array( 'mobile', 'desktop' );
        /** String: The local path to where templates are located, see 
__construct() */
        protected $localTemplateBasePath = '';
 
diff --git a/includes/skins/SkinMinerva.php b/includes/skins/SkinMinerva.php
new file mode 100644
index 0000000..f57d073
--- /dev/null
+++ b/includes/skins/SkinMinerva.php
@@ -0,0 +1,127 @@
+<?php
+
+/**
+ * Minerva: Born from the godhead of Jupiter with weapons!
+ * A skin that works on both desktop and mobile
+ * @ingroup Skins
+ */
+class SkinMinerva extends SkinTemplate {
+       var $skinname = 'minerva',
+               $template = 'MinervaTemplate', $useHeadElement = true;
+
+       /**
+        * Initializes output page and sets up skin-specific parameters
+        * @param $out OutputPage object to initialize
+        */
+       public function initPage( OutputPage $out ) {
+               global $wgLocalStylePath;
+
+               parent::initPage( $out );
+               $modules = array(
+                       'mobile.startup',
+                       'mobile.stable.universal',
+               );
+               $out->addModules( $modules );
+
+       }
+
+       /**
+        * @param $out OutputPage
+        */
+       public function setupSkinUserCss( OutputPage $out ) {
+               parent::setupSkinUserCss( $out );
+               // Add the ResourceLoader module to the page output
+               $styles = array(
+                       'mobile.styles',
+                       'mobile.styles.page',
+               );
+               $out->addModuleStyles( $styles );
+       }
+}
+
+class MinervaTemplate extends BaseTemplate {
+       private function prepareCommonData() {
+               $searchBox = $this->makeSearchInput(
+                       array(
+                               'id' => 'searchInput',
+                               'class' => 'search',
+                               'autocomplete' => 'off',
+                               'placeholder' => 
$this->data['search-input-placeholder'],
+                       )
+               );
+               $script = $this->data['wgScript'];
+               $searchButton = $this->makeSearchButton( 'go', array( 'class' 
=> 'searchSubmit' ) );
+               $header = <<<HTML
+<form action="{$script}" class="search-box">
+       <div class="divclearable">
+               {$searchBox}
+               {$searchButton}
+       </div>
+</form>
+HTML;
+               $this->set( 'header', $header );
+       }
+
+       public function prepareData() {
+               $this->set( 'prebodytext', '<h1>' . $this->data[ 'title' ] . 
'</h1>' );
+               $this->set( 'menuButton', '<a href="#" 
id="mw-mf-main-menu-button"></a>' );
+       }
+
+       public function execute() {
+               // Suppress warnings to prevent notices about missing indexes 
in $this->data
+               wfSuppressWarnings();
+               $this->prepareCommonData();
+               $this->prepareData();
+               if ( $this->data['sitenotice'] ):
+                       $siteNotice = '<div id="siteNotice">' . 
$this->data['sitenotice'] . '</div>';
+                       $this->set( 'siteNoticeBanner', $siteNotice );
+               endif;
+
+               $this->render( $this->data );
+               wfRestoreWarnings();
+       } // end of execute() method
+
+       private function render( $data ) { // FIXME: replace with template 
engine
+               ?>
+               <?php echo $data[ 'headelement' ] ?>
+               <div id="mw-mf-viewport">
+                       <div id="mw-mf-page-left">
+                               <ul id="mw-mf-menu-main">
+                               <?php
+                               foreach( $this->data['sidebar']['navigation'] 
as $key => $val ):
+                                       echo $this->makeListItem( $key, $val );
+                               endforeach;
+                               ?>
+                               </ul>
+                       </div>
+                       <div id='mw-mf-page-center'>
+                               <!-- start -->
+                               <?php
+                                       echo $this->html( 'zeroRatedBanner' );
+                                       echo $this->html( 'notice' );
+                                       echo $this->html( 'siteNoticeBanner' );
+                               ?>
+                               <div id="mw-mf-header">
+                               <?php
+                                       echo $this->html( 'menuButton' );
+                                       echo $this->html( 'header' );
+                               ?>
+                                       <div id="mw-mf-menu-page"></div>
+                               </div>
+                               <div class='show <?php $this->html( 
'articleClass' ); ?>' id='content_wrapper'>
+                                       <div id="content" class="content">
+                                               <?php echo $data['prebodytext'] 
?>
+                                               <?php echo $data[ 'bodytext' ] 
?>
+                                       </div>
+                               </div><!-- close #mw-mf-page-center -->
+               </div><!-- close #mw-mf-viewport -->
+               <?php echo $data[ 'footer' ] ?>
+               <?php echo $data['reporttime'] ?>
+               <?php echo $data['bottomscripts'] ?>
+       </body>
+       </html>
+               <?php
+       }
+}
+
+
diff --git a/includes/skins/SkinMobile.php b/includes/skins/SkinMobile.php
index bfc890e..a694197 100644
--- a/includes/skins/SkinMobile.php
+++ b/includes/skins/SkinMobile.php
@@ -26,6 +26,15 @@
                $inBeta = $context->isBetaGroupMember();
                $inAlpha = $context->isAlphaGroupMember();
 
+               if ( $inAlpha ) {
+                       $placeholder = wfMessage( 
'mobile-frontend-placeholder-alpha' )->text();
+               } else if ( $inBeta ) {
+                       $placeholder = wfMessage( 
'mobile-frontend-placeholder-beta' )->text();
+               } else {
+                       $placeholder = wfMessage( 'mobile-frontend-placeholder' 
)->text();
+               }
+               $tpl->set( 'search-input-placeholder', $placeholder );
+
                $tpl->set( 'action', $context->getRequest()->getText( 'action' 
) );
                $tpl->set( 'isAlphaGroupMember', $inAlpha );
                $tpl->set( 'isBetaGroupMember', $inBeta );
@@ -127,6 +136,7 @@
                $nearbyUrl = SpecialPage::getTitleFor( 'Nearby' 
)->getLocalURL();
                $settingsUrl = SpecialPage::getTitleFor( 'MobileOptions' )->
                        getLocalUrl( array( 'returnto' => $returnToTitle ) );
+               $link = $this->getLogInOutLink( $tpl );
 
                // set urls
                $tpl->set( 'canonicalUrl', $title->getCanonicalURL() );
@@ -136,8 +146,9 @@
                $tpl->set( 'settingsUrl', $settingsUrl );
                $tpl->set( 'disclaimerLink', $this->disclaimerLink() );
                $tpl->set( 'privacyLink', $this->footerLink( 
'mobile-frontend-privacy-link-text', 'privacypage' ) );
+               $tpl->set( 'loginLogoutText', $link['text'] );
+               $tpl->set( 'loginLogoutUrl', $link['href'] );
                $tpl->set( 'aboutLink', $this->footerLink( 
'mobile-frontend-about-link-text', 'aboutpage' ) );
-               $tpl->set( 'logInOut', $this->getLogInOutLink() );
        }
 
        /**
@@ -216,11 +227,11 @@
                $htmlHeader = $this->getHtmlHeader();
                if ( !$htmlHeader && $isSpecialPage ) {
                        $htmlHeader = Html::element( 'h1', array( 'class' => 
'header' ), $pageHeading );
+                       $tpl->set( 'specialPageHeader', $htmlHeader );
                }
 
                $tpl->set( 'prebodytext', $preBodyText );
                $tpl->set( 'postbodytext', $postBodyText );
-               $tpl->set( 'htmlHeader', $htmlHeader );
        }
 
        /**
@@ -640,6 +651,10 @@
                return $robots;
        }
 
+       /**
+        * Creates a login or logout button
+        * @return Array: Representation of button with text and href keys
+        */
        private function getLogInOutLink() {
                global $wgMFForceSecureLogin;
                wfProfileIn( __METHOD__ );
@@ -658,31 +673,24 @@
                        }
                        $url = SpecialPage::getTitleFor( 'UserLogout' 
)->getFullURL( $query );
                        $url = $context->getMobileUrl( $url, 
$wgMFForceSecureLogin );
-                       $link = Linker::makeExternalLink(
-                               $url,
-                               wfMessage( 'mobile-frontend-main-menu-logout' 
)->escaped(),
-                               true,
-                               '',
-                               array( 'class' => 'logout' )
-                       );
+                       $text = wfMessage( 'mobile-frontend-main-menu-logout' 
)->escaped();
                } else {
                         // note returnto is not set for mobile (per product 
spec)
                        $returntoquery[ 'welcome' ] = 'yes';
                        $query[ 'returntoquery' ] = wfArrayToCgi( 
$returntoquery );
                        $url = SpecialPage::getTitleFor( 'UserLogin' 
)->getFullURL( $query );
                        $url = $context->getMobileUrl( $url, 
$wgMFForceSecureLogin );
-                       $link = Linker::makeExternalLink(
-                               $url,
-                               wfMessage( 'mobile-frontend-main-menu-login' 
)->escaped(),
-                               true,
-                               '',
-                               array( 'class' => 'login' )
-                       );
+                       $text = wfMessage( 'mobile-frontend-main-menu-login' 
)->escaped();
                }
+               return array(
+                       'text' => $text,
+                       'href' => $url,
+               );
                wfProfileOut( __METHOD__ );
                return $link;
        }
 
+       // FIXME: move to SkinMFE.php
        public function getMenuButton() {
                $url = SpecialPage::getTitleFor( 'MobileMenu' )->getLocalUrl() 
. '#mw-mf-page-left';
                return Html::element( 'a', array(
diff --git a/includes/skins/SkinMobileBase.php 
b/includes/skins/SkinMobileBase.php
index 297db88..903eee1 100644
--- a/includes/skins/SkinMobileBase.php
+++ b/includes/skins/SkinMobileBase.php
@@ -1,6 +1,6 @@
 <?php
 
-abstract class SkinMobileBase extends SkinTemplate {
+class SkinMobileBase extends SkinMinerva {
        /**
         * @var ExtMobileFrontend
         */
@@ -116,6 +116,7 @@
                $tpl->set( 'code', $lang->getHtmlCode() );
                $tpl->set( 'dir', $lang->getDir() );
                $tpl->set( 'scriptUrl', wfScript() );
+               $tpl->set( 'wgScript', wfScript() ); // FIXME: duplication
 
                $url = MobileContext::singleton()->getDesktopUrl( wfExpandUrl(
                        $this->getRequest()->appendQuery( 
'mobileaction=toggle_view_desktop' )
diff --git a/includes/skins/SkinMobileTemplate.php 
b/includes/skins/SkinMobileTemplate.php
index a53d4de..c0865b9 100644
--- a/includes/skins/SkinMobileTemplate.php
+++ b/includes/skins/SkinMobileTemplate.php
@@ -1,156 +1,17 @@
 <?php
 
-class SkinMobileTemplate extends BaseTemplate {
-       public function renderArticleSkin() {
-               $this->navigationStart();
-               ?>
-               <?php $this->html( 'zeroRatedBanner' ) ?>
-               <?php $this->html( 'notice' ) ?>
-               <?php if ( $this->data[ 'enableSiteNotice' ] ) { ?>
-                       <div id="siteNotice"></div>
-               <?php } ?>
-               <?php $this->renderArticleHeader() ?>
-       <div class='show <?php $this->html( 'articleClass' ); ?>' 
id='content_wrapper'>
-                       <div id="content" class="content">
-                       <?php $this->html( 'prebodytext' ) ?>
-                       <?php $this->html( 'bodytext' ) ?>
-                       <?php $this->html( 'postbodytext' ) ?>
-                       </div><!-- close #content -->
-       </div><!-- close #content_wrapper -->
-               <?php
-               if ( !$this->data[ 'isSpecialPage' ] ) {
-                       $this->footer();
-               } ?>
-               <?php
-                       $this->navigationEnd();
-       }
-
-       public function renderArticleHeader() {
-               echo '<div id="mw-mf-header">';
-               if ( $this->data['htmlHeader'] ) {
-                       $this->html( 'menuButton' );
-                       echo $this->data['htmlHeader'];
-               } else {
-                       $this->searchBox();
-               }
-               echo '</div>';
-       }
-
-       public function execute() {
-               $this->prepareData();
-               if ( $this->data['isAlphaGroupMember'] ) {
-                       $this->set( 'bodyClasses', 'mobile alpha' );
-               } else {
-                       $this->data['isBetaGroupMember'] ? $this->set( 
'bodyClasses', 'mobile beta' ) :
-                               $this->set( 'bodyClasses', 'mobile live' );
-               }
-
-               $htmlClass = '';
-               if ( $this->data[ 'isSpecialPage' ] ) {
-                       $htmlClass .= ' specialPage';
-               }
-               if ( $this->data['renderLeftMenu'] ) {
-                       $htmlClass .= ' navigationEnabled navigationFullScreen';
-               }
-               if ( $this->data['action'] == 'edit' ) {
-                       $htmlClass .= ' actionEdit';
-               }
-               $this->set( 'htmlClasses', trim( $htmlClass ) );
-
-               ?><!doctype html>
-       <html lang="<?php $this->text('code') ?>" dir="<?php $this->html( 'dir' 
) ?>" class="<?php $this->text( 'htmlClasses' )  ?>">
-       <head>
-               <title><?php $this->text( 'pagetitle' ) ?></title>
-               <meta http-equiv="content-type" content="text/html; 
charset=utf-8" />
-               <?php $this->html( 'robots' ) ?>
-               <meta name="viewport" content="initial-scale=1.0, 
user-scalable=<?php $this->text( 'viewport-scaleable' ) ?>">
-               <?php $this->html( 'touchIcon' ) ?>
-               <?php if ( $this->data['supports_jquery'] ) { ?>
-               <script type="text/javascript">
-                       document.documentElement.className += ' jsEnabled 
page-loading';
-               </script>
-               <?php } ?>
-               <?php $this->html( 'preamble' ) ?>
-               <link rel="canonical" href="<?php $this->html( 'canonicalUrl' ) 
?>" >
-       </head>
-       <body class="<?php $this->text( 'bodyClasses' ) ?>">
-               <?php $this->renderArticleSkin(); ?>
-               <?php $this->html( 'bcHack' ) ?>
-               <?php $this->html( 'bottomScripts' ) ?>
-       </body>
-       </html><?php
-       }
-
-       public function navigationStart() {
-               global $wgMFNearby;
-
-               ?>
-               <div id="mw-mf-viewport">
-               <div id="mw-mf-page-left">
-               <ul id="mw-mf-menu-main">
-                       <li class="icon-home"><a href="<?php $this->text( 
'mainPageUrl' ) ?>"
-                               title="<?php $this->msg( 
'mobile-frontend-home-button' ) ?>">
-                               <?php $this->msg( 'mobile-frontend-home-button' 
) ?></a></li>
-                       <li class="icon-random"><a href="<?php $this->text( 
'randomPageUrl' ) ?>#mw-mf-page-left" id="randomButton"
-                               title="<?php $this->msg( 
'mobile-frontend-random-button' ) ?>"
-                               ><?php $this->msg( 
'mobile-frontend-random-button' ) ?></a></li>
-                       <?php if ( $this->data['supports_jquery'] && 
$this->data['isAlphaGroupMember'] && $wgMFNearby ) { ?>
-                       <li class='icon-nearby'>
-                               <a href="<?php $this->text( 'nearbyURL' ) ?>"
-                                       title="<?php $this->msg( 
'mobile-frontend-main-menu-nearby' ) ?>">
-                               <?php $this->msg( 
'mobile-frontend-main-menu-nearby' ) ?>
-                               </a>
-                       </li>
-                       <?php } ?>
-                       <?php if ( $this->data['supports_jquery'] ) { ?>
-                       <li class='icon-watchlist'>
-                               <a href="<?php $this->text( 'watchlistUrl' ) ?>"
-                                       title="<?php $this->msg( 
'mobile-frontend-main-menu-watchlist' ) ?>">
-                               <?php $this->msg( 
'mobile-frontend-main-menu-watchlist' ) ?>
-                               </a>
-                       </li>
-                       <?php } ?>
-                       <?php if ( $this->data['supports_jquery'] && 
$this->data['isBetaGroupMember'] ) { ?>
-                       <li class='icon-uploads'>
-                                       <a href="<?php $this->text( 
'donateImageUrl' ) ?>"
-                                               class="noHijack"
-                                               title="<?php $this->msg( 
'mobile-frontend-main-menu-upload' ) ?>">
-                                       <?php $this->msg( 
'mobile-frontend-main-menu-upload' ) ?>
-                                       </a>
-                               </li>
-                       <?php } ?>
-                       <li class='icon-settings'>
-                               <a href="<?php $this->text( 'settingsUrl' ) ?>"
-                                       title="<?php $this->msg( 
'mobile-frontend-main-menu-settings' ) ?>">
-                               <?php $this->msg( 
'mobile-frontend-main-menu-settings' ) ?>
-                               </a>
-                       </li>
-                       <?php if ( $this->data['supports_jquery'] ) { ?>
-                       <li class='icon-loginout'>
-                               <?php $this->html( 'logInOut' ) ?>
-                       </li>
-                       <?php } ?>
-               </ul>
-               </div>
-               <div id='mw-mf-page-center'>
-               <?php
-       }
-
-       public function navigationEnd() {
-               //close #mw-mf-page-center then viewport;
-               ?>
-               </div><!-- close #mw-mf-page-center -->
-               </div><!-- close #mw-mf-viewport -->
-               <?php
-       }
+class SkinMobileTemplate extends MinervaTemplate {
 
        public function prepareData() {
-               global $wgExtensionAssetsPath,
-                       $wgMobileFrontendLogo;
-
                wfProfileIn( __METHOD__ );
+               global $wgExtensionAssetsPath, $wgMobileFrontendLogo;
+               $data = $this->data;
+               $isSpecialPage = $data[ 'isSpecialPage' ];
+               $inAlpha = $data['isAlphaGroupMember'];
+               $inBeta = $data['isBetaGroupMember'];
+
                $this->setRef( 'wgExtensionAssetsPath', $wgExtensionAssetsPath 
);
-               if ( $this->data['wgAppleTouchIcon'] !== false ) {
+               if ( $data['wgAppleTouchIcon'] !== false ) {
                        $link = Html::element( 'link', array( 'rel' => 
'apple-touch-icon', 'href' => $this->data['wgAppleTouchIcon'] ) );
                } else {
                        $link = '';
@@ -159,31 +20,136 @@
 
                $this->set( 'wgMobileFrontendLogo', $wgMobileFrontendLogo );
 
+               if ( $inAlpha ) {
+                       $this->set( 'bodyClasses', 'mobile alpha' );
+               } else {
+                       $inBeta ? $this->set( 'bodyClasses', 'mobile beta' ) :
+                               $this->set( 'bodyClasses', 'mobile live' );
+               }
+
+               $htmlClass = '';
+               if ( $isSpecialPage ) {
+                       $htmlClass .= ' specialPage';
+               }
+               if ( $data['renderLeftMenu'] ) {
+                       $htmlClass .= ' navigationEnabled navigationFullScreen';
+               }
+               if ( $data['action'] == 'edit' ) {
+                       $htmlClass .= ' actionEdit';
+               }
+               $this->set( 'htmlClasses', trim( $htmlClass ) );
+
+               ob_start();
+               ?><!doctype html>
+       <html lang="<?php $this->text('code') ?>" dir="<?php $this->html( 'dir' 
) ?>" class="<?php $this->text( 'htmlClasses' )  ?>">
+       <head>
+               <title><?php $this->text( 'pagetitle' ) ?></title>
+               <meta http-equiv="content-type" content="text/html; 
charset=utf-8" />
+               <?php $this->html( 'robots' ) ?>
+               <meta name="viewport" content="initial-scale=1.0, 
user-scalable=<?php $this->text( 'viewport-scaleable' ) ?>">
+               <?php $this->html( 'touchIcon' ) ?>
+               <?php if ( $data['supports_jquery'] ) { ?>
+               <script type="text/javascript">
+                       document.documentElement.className += ' client-js 
page-loading';
+               </script>
+               <?php } ?>
+               <?php $this->html( 'preamble' ) ?>
+               <link rel="canonical" href="<?php $this->html( 'canonicalUrl' ) 
?>" >
+       </head>
+       <body class="<?php $this->text( 'bodyClasses' ) ?>">
+       <?php
+               $headElement = ob_get_contents();
+               ob_end_clean();
+
+               $this->prepareMenuData();
+
+               // collect footer
+               if ( !$isSpecialPage ) {
+                       ob_start();
+                       $this->footer();
+                       $footer = ob_get_contents();
+                       ob_end_clean();
+               } else {
+                       $footer = '';
+               }
+
+               // define template data
+               if ( !$data[ 'enableSiteNotice' ] ) {
+                       $this->set( 'sitenotice', '' );
+               }
+               $this->set( 'headelement', $headElement );
+               $this->set( 'bodytext', $data['bodytext'] . 
$data['postbodytext'] );
+               $this->set( 'footer', $footer );
+               $this->set( 'bottomscripts', $data['bcHack'] . 
$data['bottomScripts'] );
+               if ( $data['specialPageHeader'] ) {
+                       $this->set( 'header', $data['specialPageHeader'] );
+               }
                wfProfileOut( __METHOD__ );
        }
 
-       private function searchBox() {
-               if ( $this->data['isAlphaGroupMember'] ) {
-                       $placeholder = wfMessage( 
'mobile-frontend-placeholder-alpha' )->text();
-               } else if ( $this->data['isBetaGroupMember'] ) {
-                       $placeholder = wfMessage( 
'mobile-frontend-placeholder-beta' )->text();
-               } else {
-                       $placeholder = wfMessage( 'mobile-frontend-placeholder' 
)->text();
+       public function prepareMenuData() {
+               global $wgMFNearby;
+               $data = $this->data;
+               $enhancedSite = $data['supports_jquery'];
+               $items = array(
+                       'home' => array(
+                               'text' => wfMessage( 
'mobile-frontend-home-button' )->escaped(),
+                               'href' => $data['mainPageUrl'],
+                               'class' => 'icon-home',
+                       ),
+                       'random' => array(
+                               'text' => wfMessage( 
'mobile-frontend-random-button' )->escaped(),
+                               'href' => $data['randomPageUrl'],
+                               'class' => 'icon-random',
+                       ),
+                       'nearby' => array(
+                               'text' => wfMessage( 
'mobile-frontend-main-menu-nearby' )->escaped(),
+                               'href' => $data['nearbyURL'],
+                               'class' => 'icon-nearby',
+                       ),
+                       'watchlist' => array(
+                               'text' => wfMessage( 
'mobile-frontend-main-menu-watchlist' )->escaped(),
+                               'href' => $data['watchlistUrl'],
+                               'class' => 'icon-watchlist',
+                       ),
+                       'uploads' => array(
+                               'text' => wfMessage( 
'mobile-frontend-main-menu-upload' )->escaped(),
+                               'href' => $data['donateImageUrl'],
+                               'class' => 'icon-uploads',
+                       ),
+                       'settings' => array(
+                               'text' => wfMessage( 
'mobile-frontend-main-menu-settings' )->escaped(),
+                               'href' => $data['settingsUrl'],
+                               'class' => 'icon-settings',
+                       ),
+                       'auth' => array(
+                               'text' => $data['loginLogoutText'],
+                               'href' => $data['loginLogoutUrl'],
+                               'class' => 'icon-loginout',
+                       ),
+               );
+
+               $nav = array( $items['home'], $items['random'] );
+               if ( $enhancedSite ) {
+
+                       if ( $data['isAlphaGroupMember'] && $wgMFNearby ) {
+                               $nav[] = $items['nearby'];
+                       }
+
+                       $nav[] = $items['watchlist'];
+
+                       if ( $data['isBetaGroupMember'] ) {
+                               $nav[] = $items['uploads'];
+                       }
                }
-               ?>
-               <?php $this->html( 'menuButton' ) ?>
-               <form id="mw-mf-searchForm" action="<?php $this->text( 
'scriptUrl' ) ?>" class="search-box" method="get">
-                       <input type="hidden" value="Special:Search" 
name="title" />
-                       <div id="mw-mf-sq" class="divclearable">
-                               <input type="search" name="search" 
id="mw-mf-search" size="22" value="<?php $this->text( 'searchField' )
-                                       ?>" autocomplete="off" maxlength="1024" 
class="search"
-                                       placeholder="<?php echo $placeholder ?>"
-                                       />
-                               <input class='searchSubmit' type="submit" 
value="<?php $this->msg( 'mobile-frontend-search-submit' ) ?>">
-                       </div>
-               </form>
-               <div id="mw-mf-menu-page"></div>
-               <?php
+
+               $nav[] = $items['settings'];
+
+               if ( $enhancedSite ) {
+                       $nav[] = $items['auth'];
+               }
+
+               $this->data['sidebar']['navigation'] = $nav;
        }
 
        private function footer() {

-- 
To view, visit https://gerrit.wikimedia.org/r/56351
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iff02c75ff263436de5ea1381d59adf58e20019c6
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