jenkins-bot has submitted this change and it was merged.

Change subject: Rewrite menu generation
......................................................................


Rewrite menu generation

This no longer varies the html on X-Device

Change-Id: Ia8dae042f3765fc41b1c9c5144359a89906e15c2
---
M includes/skins/SkinMobile.php
M includes/skins/SkinMobileTemplate.php
2 files changed, 87 insertions(+), 52 deletions(-)

Approvals:
  awjrichards: Verified; Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/skins/SkinMobile.php b/includes/skins/SkinMobile.php
index 0e59a74..b95fd8d 100644
--- a/includes/skins/SkinMobile.php
+++ b/includes/skins/SkinMobile.php
@@ -120,6 +120,7 @@
                $nearbyUrl = SpecialPage::getTitleFor( 'Nearby' 
)->getLocalURL();
                $settingsUrl = SpecialPage::getTitleFor( 'MobileOptions' )->
                        getLocalUrl( array( 'returnto' => $returnToTitle ) );
+               $link = $this->getLogInOutLink();
 
                // set urls
                $tpl->set( 'donateImageUrl', $donateUrl );
@@ -127,8 +128,9 @@
                $tpl->set( 'settingsUrl', $settingsUrl );
                $tpl->set( 'disclaimer', $this->disclaimerLink() );
                $tpl->set( 'privacy', $this->footerLink( 
'mobile-frontend-privacy-link-text', 'privacypage' ) );
+               $tpl->set( 'loginLogoutText', $link['text'] );
+               $tpl->set( 'loginLogoutUrl', $link['href'] );
                $tpl->set( 'about', $this->footerLink( 
'mobile-frontend-about-link-text', 'aboutpage' ) );
-               $tpl->set( 'logInOut', $this->getLogInOutLink() );
        }
 
        /**
@@ -457,6 +459,10 @@
                return $languageVariantUrls;
        }
 
+       /**
+        * Creates a login or logout button
+        * @return Array: Representation of button with text and href keys
+       */
        private function getLogInOutLink() {
                global $wgMFForceSecureLogin;
                wfProfileIn( __METHOD__ );
@@ -475,29 +481,20 @@
                        }
                        $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();
                }
                wfProfileOut( __METHOD__ );
-               return $link;
+               return array(
+                       'text' => $text,
+                       'href' => $url,
+               );
        }
 
        public static function getMenuButton() {
diff --git a/includes/skins/SkinMobileTemplate.php 
b/includes/skins/SkinMobileTemplate.php
index 968040a..8a5c88f 100644
--- a/includes/skins/SkinMobileTemplate.php
+++ b/includes/skins/SkinMobileTemplate.php
@@ -53,42 +53,14 @@
                <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['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 } ?>
-                       <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>
-                       <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>
-                       <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>
-                       <li class='icon-loginout'>
-                               <?php $this->html( 'logInOut' ) ?>
-                       </li>
+               <?php
+               foreach( $this->getDiscoveryTools() as $key => $val ):
+                       echo $this->makeListItem( $key, $val );
+               endforeach;
+               foreach( $this->getPersonalTools() as $key => $val ):
+                       echo $this->makeListItem( $key, $val );
+               endforeach;
+               ?>
                </ul>
                </div>
                <div id='mw-mf-page-center'>
@@ -157,6 +129,72 @@
                <?php
        }
 
+       public function getPersonalTools() {
+               global $wgMFNearby;
+               $data = $this->data;
+
+               $items = array(
+                       'nearby' => array(
+                               'text' => wfMessage( 
'mobile-frontend-main-menu-nearby' )->escaped(),
+                               'href' => $data['nearbyURL'],
+                               'class' => 'icon-nearby jsonly',
+                       ),
+                       'watchlist' => array(
+                               'text' => wfMessage( 
'mobile-frontend-main-menu-watchlist' )->escaped(),
+                               'href' => $data['watchlistUrl'],
+                               'class' => 'icon-watchlist jsonly',
+                       ),
+                       'uploads' => array(
+                               'text' => wfMessage( 
'mobile-frontend-main-menu-upload' )->escaped(),
+                               'href' => $data['donateImageUrl'],
+                               'class' => 'icon-uploads jsonly',
+                       ),
+                       '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 jsonly',
+                       ),
+               );
+
+               $nav = array();
+
+               if ( $data['isAlphaGroupMember'] && $wgMFNearby ) {
+                       $nav[] = $items['nearby'];
+               }
+
+               $nav[] = $items['watchlist'];
+               $nav[] = $items['uploads'];
+
+               $nav[] = $items['settings'];
+
+               $nav[] = $items['auth'];
+               return $nav;
+       }
+
+       public function getDiscoveryTools() {
+               $data = $this->data;
+               $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',
+                               'id' => 'randomButton',
+                       ),
+               );
+
+               return $items;
+       }
+
        /**
         * Returns an array of footerlinks trimmed down to only those footer 
links that
         * are valid.

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia8dae042f3765fc41b1c9c5144359a89906e15c2
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: MaxSem <[email protected]>
Gerrit-Reviewer: awjrichards <[email protected]>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to