Merge "(bug 42030) Include original URL params in variant links"
[lhc/web/wiklou.git] / includes / SkinTemplate.php
index 173d37a..611223e 100644 (file)
@@ -643,7 +643,6 @@ class SkinTemplate extends Skin {
                        $is_signup = $request->getText( 'type' ) == 'signup';
 
                        # anonlogin & login are the same
-                       global $wgSecureLogin;
                        $proto = $wgSecureLogin ? PROTO_HTTPS : null;
 
                        $login_id = $this->showIPinHeader() ? 'anonlogin' : 'login';
@@ -691,12 +690,14 @@ class SkinTemplate extends Skin {
        }
 
        /**
-        * TODO document
-        * @param  $title Title
-        * @param  $message String message key
-        * @param  $selected Bool
-        * @param  $query String
-        * @param  $checkEdit Bool
+        * Builds an array with tab definition
+        *
+        * @param Title $title page where the tab links to
+        * @param string|array $message message key or an array of message keys (will fall back)
+        * @param boolean $selected display the tab as selected
+        * @param string $query query string attached to tab URL
+        * @param boolean $checkEdit check if $title exists and mark with .new if one doesn't
+        *
         * @return array
         */
        function tabAction( $title, $message, $selected, $query = '', $checkEdit = false ) {
@@ -706,7 +707,11 @@ class SkinTemplate extends Skin {
                }
                if( $checkEdit && !$title->isKnown() ) {
                        $classes[] = 'new';
-                       $query = 'action=edit&redlink=1';
+                       if ( $query !== '' ) {
+                               $query = 'action=edit&redlink=1&' . $query;
+                       } else {
+                               $query = 'action=edit&redlink=1';
+                       }
                }
 
                // wfMessageFallback will nicely accept $message as an array of fallbacks
@@ -958,7 +963,7 @@ class SkinTemplate extends Skin {
                                        }
                                }
 
-                               if ( $title->getNamespace() !== NS_MEDIAWIKI && $title->quickUserCan( 'protect', $user ) ) {
+                               if ( $title->getNamespace() !== NS_MEDIAWIKI && $title->quickUserCan( 'protect', $user ) && $title->getRestrictionTypes() ) {
                                        $mode = $title->isProtected() ? 'unprotect' : 'protect';
                                        $content_navigation['actions'][$mode] = array(
                                                'class' => ( $onPage && $action == $mode ) ? 'selected' : false,
@@ -1003,6 +1008,12 @@ class SkinTemplate extends Skin {
                                        // Gets preferred variant (note that user preference is
                                        // only possible for wiki content language variant)
                                        $preferred = $pageLang->getPreferredVariant();
+                                       if ( Action::getActionName( $this ) === 'view' ) {
+                                               $params = $request->getQueryValues();
+                                               unset( $params['title'] );
+                                       } else {
+                                               $params = array();
+                                       }
                                        // Loops over each variant
                                        foreach( $variants as $code ) {
                                                // Gets variant name from language code
@@ -1016,7 +1027,7 @@ class SkinTemplate extends Skin {
                                                $content_navigation['variants'][] = array(
                                                        'class' => ( $code == $preferred ) ? 'selected' : false,
                                                        'text' => $varname,
-                                                       'href' => $title->getLocalURL( array( 'variant' => $code ) ),
+                                                       'href' => $title->getLocalURL( array( 'variant' => $code ) + $params ),
                                                        'lang' => $code,
                                                        'hreflang' => $code
                                                );
@@ -1208,6 +1219,7 @@ class SkinTemplate extends Skin {
                        $rootUser = $user->getName();
 
                        $nav_urls['contributions'] = array(
+                               'text' => $this->msg( 'contributions', $rootUser )->text(),
                                'href' => self::makeSpecialUrlSubpage( 'Contributions', $rootUser )
                        );