Jdlrobson has uploaded a new change for review.

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

Change subject: Hygiene: Make it possible for alpha to reimplement personal urls
......................................................................

Hygiene: Make it possible for alpha to reimplement personal urls

Create getPersonalUrl helper function

Change-Id: Ice2e08999e943c9617155f60e5529775401c8aae
---
M includes/skins/SkinMinerva.php
1 file changed, 22 insertions(+), 15 deletions(-)


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

diff --git a/includes/skins/SkinMinerva.php b/includes/skins/SkinMinerva.php
index 37f197a..62240cf 100644
--- a/includes/skins/SkinMinerva.php
+++ b/includes/skins/SkinMinerva.php
@@ -69,6 +69,7 @@
                $tpl->set( 'unstyledContent', $out->getProperty( 
'unstyledContent' ) );
 
                $tpl->set( 'site_urls', $this->getSiteLinks() );
+               $tpl->set( 'personal_urls', $this->getPersonalTools() );
                $tpl->set( 'discovery_urls', $this->getDiscoveryTools() );
 
                // Construct various Minerva-specific interface elements
@@ -80,7 +81,6 @@
                $this->prepareWarnings( $tpl );
                $this->preparePageActions( $tpl );
                $this->prepareUserButton( $tpl );
-               $this->preparePersonalTools( $tpl );
                $this->prepareLanguages( $tpl );
 
                // Perform a few extra changes if we are in mobile mode
@@ -310,10 +310,24 @@
        }
 
        /**
-        * Prepares urls and links used by the page
-        * @param QuickTemplate $tpl
+        * Return a url to a resource or to a login screen that redirects to 
that resource.
+        * @param Title $title
+        * @param array $query representation of query string parameters
+        * @return string url
         */
-       protected function preparePersonalTools( QuickTemplate $tpl ) {
+       protected function getPersonalUrl( Title $title, array $query = array() 
) {
+               if ( $this->getUser()->isLoggedIn() ) {
+                       return $title->getLocalUrl( $query );
+               } else {
+                       return $this->getLoginUrl( array( 'returnto' => $title 
) );
+               }
+       }
+
+       /**
+        * Prepares and returns urls and links personal to the given user
+        * @return array
+        */
+       protected function getPersonalTools() {
                $returnToTitle = $this->getTitle()->getPrefixedText();
                $donateTitle = SpecialPage::getTitleFor( 'Uploads' );
                $watchTitle = SpecialPage::getTitleFor( 'Watchlist' );
@@ -337,9 +351,7 @@
                                'links' => array(
                                        array(
                                                'text' => wfMessage( 
'mobile-frontend-main-menu-watchlist' )->escaped(),
-                                               'href' => 
$this->getUser()->isLoggedIn() ?
-                                                       
$watchTitle->getLocalUrl( $watchlistQuery ) :
-                                                       $this->getLoginUrl( 
array( 'returnto' => $watchTitle ) ),
+                                               'href' => 
$this->getPersonalUrl( $watchTitle, $watchlistQuery ),
                                                'class' => MobileUI::iconClass( 
'watchlist', 'before' ),
                                        ),
                                ),
@@ -352,8 +364,7 @@
                                        'links' => array(
                                                array(
                                                        'text' => wfMessage( 
'mobile-frontend-main-menu-upload' )->escaped(),
-                                                       'href' => 
$this->getUser()->isLoggedIn() ? $donateTitle->getLocalUrl() :
-                                                               
$this->getLoginUrl( array( 'returnto' => $donateTitle ) ),
+                                                       'href' => 
$this->getPersonalUrl( $donateTitle ),
                                                        'class' => 
MobileUI::iconClass( 'uploads', 'before' ),
                                                ),
                                        ),
@@ -371,22 +382,18 @@
                                ),
                        );
                } else {
-                       $prefUrl = SpecialPage::getTitleFor( 'Preferences' )->
-                               getLocalUrl( array( 'returnto' => 
$returnToTitle ) );
                        $items['preferences'] = array(
                                'links' => array(
                                        array(
                                                'text' => wfMessage( 
'preferences' )->escaped(),
-                                               'href' => 
$this->getUser()->isLoggedIn() ? $prefUrl :
-                                                       $this->getLoginUrl( 
array( 'returnto' => $prefUrl ) ),
+                                               'href' => 
$this->getPersonalUrl( SpecialPage::getTitleFor( 'Preferences' ) ),
                                                'class' => MobileUI::iconClass( 
'settings', 'before' ),
                                        ),
                                ),
                        );
                }
                $items['auth'] = $this->getLogInOutLink();
-
-               $tpl->set( 'personal_urls', $items );
+               return $items;
        }
 
        /**

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

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