Merge "(bug 42030) Include original URL params in variant links"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 24 Jan 2013 23:16:46 +0000 (23:16 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 24 Jan 2013 23:16:46 +0000 (23:16 +0000)
1  2 
includes/SkinTemplate.php

@@@ -398,7 -398,7 +398,7 @@@ class SkinTemplate extends Skin 
                # not for special pages or file pages AND only when viewing AND if the page exists
                # (or is in MW namespace, because that has default content)
                if ( !in_array( $title->getNamespace(), array( NS_SPECIAL, NS_FILE ) ) &&
 -                      in_array( $request->getVal( 'action', 'view' ), array( 'view', 'historysubmit' ) ) &&
 +                      Action::getActionName( $this ) === 'view' &&
                        ( $title->exists() || $title->getNamespace() == NS_MEDIAWIKI ) ) {
                        $pageLang = $title->getPageViewLanguage();
                        $realBodyAttribs['lang'] = $pageLang->getHtmlCode();
                # $this->getTitle() will just give Special:Badtitle, which is
                # not especially useful as a returnto parameter. Use the title
                # from the request instead, if there was one.
 -              $page = Title::newFromURL( $request->getVal( 'title', '' ) );
 +              if ( $this->getUser()->isAllowed( 'read' ) ) {
 +                      $page = $this->getTitle();
 +              } else {
 +                      $page = Title::newFromText( $request->getVal( 'title', '' ) );
 +              }
                $page = $request->getVal( 'returnto', $page );
                $a = array();
                if ( strval( $page ) !== '' ) {
                        $is_signup = $request->getText( 'type' ) == 'signup';
  
                        # anonlogin & login are the same
 -                      global $wgSecureLogin;
                        $proto = $wgSecureLogin ? PROTO_HTTPS : null;
  
                        $login_id = $this->showIPinHeader() ? 'anonlogin' : 'login';
        }
  
        /**
 -       * 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 ) {
                }
                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
                                        }
                                }
  
 -                              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,
                                        // 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
                                                $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
                                                );
                        $rootUser = $user->getName();
  
                        $nav_urls['contributions'] = array(
 +                              'text' => $this->msg( 'contributions', $rootUser )->text(),
                                'href' => self::makeSpecialUrlSubpage( 'Contributions', $rootUser )
                        );