Merge "'lang' attrib in #mw-content-text should be set to variant code."
authorHashar <hashar@free.fr>
Tue, 4 Sep 2012 15:04:52 +0000 (15:04 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 4 Sep 2012 15:04:52 +0000 (15:04 +0000)
1  2 
includes/ImagePage.php
includes/SkinTemplate.php
includes/Title.php

diff --combined includes/ImagePage.php
@@@ -94,47 -94,10 +94,47 @@@ class ImagePage extends Article 
        /**
         * Handler for action=render
         * Include body text only; none of the image extras
 +       * However, also include the shared description text
 +       * so that cascading ForeignAPIRepo's work.
 +       *
 +       * @note This uses a div with the class "mw-shared-image-desc"
 +       *    as opposed to the id "mw-shared-image-desc" since the text
 +       *    from here may be cascadingly transcluded to other shared
 +       *    repos, and we want all ids to be unique. On normal
 +       *    view, the outermost shared description will still have
 +       *    the id.
 +       *
 +       * This also differs from normal view in that "shareddescriptionfollows"
 +       * message is not shown. I was not sure if it was appropriate to
 +       * add that message here.
         */
        public function render() {
 -              $this->getContext()->getOutput()->setArticleBodyOnly( true );
 -              parent::view();
 +              $out = $this->getContext()->getOutput();
 +                $this->loadFile();
 +
 +                $descText = $this->mPage->getFile()->getDescriptionText();
 +
 +              $out->setArticleBodyOnly( true );
 +
 +              if ( !$descText ) {
 +                      // If no description text, just do standard action=render
 +                      parent::view();
 +              } else {
 +                      if ( $this->mPage->getID() !== 0 ) {
 +                              // Local description exists. We need to output both
 +                              parent::view();
 +                              $out->addHTML( '<div class="mw-shared-image-desc">' . $descText . "</div>\n" );
 +                      } else {
 +                              // We don't want to output both a "noarticletext" message and the shared
 +                              // description, so don't call parent::view().
 +                              $out->addHTML( '<div class="mw-shared-image-desc">' . $descText . "</div>\n" );
 +                              // Since we did not call parent::view(), have to call some methods it
 +                              // normally takes care of. (Not that it matters much since skin not displayed)
 +                              $out->setArticleFlag( true );
 +                              $out->setPageTitle( $this->getTitle()->getPrefixedText() );
 +                              $this->mPage->doViewUpdates( $this->getContext()->getUser() );
 +                      }
 +              }
        }
  
        public function view() {
                if ( $this->mPage->getID() ) {
                        # NS_FILE is in the user language, but this section (the actual wikitext)
                        # should be in page content language
-                       $pageLang = $this->getTitle()->getPageLanguage();
+                       $pageLang = $this->getTitle()->getPageViewLanguage();
                        $out->addHTML( Xml::openElement( 'div', array( 'id' => 'mw-imagepage-content',
                                'lang' => $pageLang->getHtmlCode(), 'dir' => $pageLang->getDir(),
                                'class' => 'mw-content-'.$pageLang->getDir() ) ) );
                        if ( !$fol->isDisabled() ) {
                                $out->addWikiText( $fol->plain() );
                        }
 -                      $out->addHTML( '<div id="shared-image-desc">' . $this->mExtraDescription . "</div>\n" );
 +                      $out->addHTML( '<div id="shared-image-desc" class="mw-shared-image-desc">' . $this->mExtraDescription . "</div>\n" );
                }
  
                $this->closeShowImage();
  
                $out->addHTML( Xml::element( 'h2',
                        array( 'id' => 'filelinks' ),
 -                      wfMsg( 'imagelinks' ) ) . "\n" );
 +                      wfMessage( 'imagelinks' )->text() ) . "\n" );
                $this->imageDupes();
                # @todo FIXME: For some freaky reason, we can't redirect to foreign images.
                # Yet we return metadata about the target. Definitely an issue in the FileRepo
                }
  
                if ( $showmeta ) {
 -                      $out->addHTML( Xml::element( 'h2', array( 'id' => 'metadata' ), wfMsg( 'metadata' ) ) . "\n" );
 +                      $out->addHTML( Xml::element(
 +                              'h2',
 +                              array( 'id' => 'metadata' ),
 +                              wfMessage( 'metadata' )->text() ) . "\n" );
                        $out->addWikiText( $this->makeMetadataTable( $formattedMetadata ) );
                        $out->addModules( array( 'mediawiki.action.view.metadata' ) );
                }
         */
        protected function showTOC( $metadata ) {
                $r = array(
 -                      '<li><a href="#file">' . wfMsgHtml( 'file-anchor-link' ) . '</a></li>',
 -                      '<li><a href="#filehistory">' . wfMsgHtml( 'filehist' ) . '</a></li>',
 -                      '<li><a href="#filelinks">' . wfMsgHtml( 'imagelinks' ) . '</a></li>',
 +                      '<li><a href="#file">' . wfMessage( 'file-anchor-link' )->escaped() . '</a></li>',
 +                      '<li><a href="#filehistory">' . wfMessage( 'filehist' )->escaped() . '</a></li>',
 +                      '<li><a href="#filelinks">' . wfMessage( 'imagelinks' )->escaped() . '</a></li>',
                );
                if ( $metadata ) {
 -                      $r[] = '<li><a href="#metadata">' . wfMsgHtml( 'metadata' ) . '</a></li>';
 +                      $r[] = '<li><a href="#metadata">' . wfMessage( 'metadata' )->escaped() . '</a></li>';
                }
  
                wfRunHooks( 'ImagePageShowTOC', array( $this, &$r ) );
         */
        protected function makeMetadataTable( $metadata ) {
                $r = "<div class=\"mw-imagepage-section-metadata\">";
 -              $r .= wfMsgNoTrans( 'metadata-help' );
 +              $r .= wfMessage( 'metadata-help' )->plain();
                $r .= "<table id=\"mw_metadata\" class=\"mw_metadata\">\n";
                foreach ( $metadata as $type => $stuff ) {
                        foreach ( $stuff as $v ) {
                        $height_orig = $this->displayImg->getHeight( $page );
                        $height = $height_orig;
  
 -                      $longDesc = wfMsg( 'parentheses', $this->displayImg->getLongDesc() );
 +                      $longDesc = wfMessage( 'parentheses', $this->displayImg->getLongDesc() )->text();
  
                        wfRunHooks( 'ImageOpenShowImageInlineBefore', array( &$this, &$out ) );
  
                                # image
  
                                # "Download high res version" link below the image
 -                              # $msgsize = wfMsgHtml( 'file-info-size', $width_orig, $height_orig, Linker::formatSize( $this->displayImg->getSize() ), $mime );
 +                              # $msgsize = wfMessage( 'file-info-size', $width_orig, $height_orig, Linker::formatSize( $this->displayImg->getSize() ), $mime )->escaped();
                                # We'll show a thumbnail of this image
                                if ( $width > $maxWidth || $height > $maxHeight ) {
                                        # Calculate the thumbnail size.
                                                # Note that $height <= $maxHeight now, but might not be identical
                                                # because of rounding.
                                        }
 -                                      $msgbig = wfMsgHtml( 'show-big-image' );
 +                                      $msgbig = wfMessage( 'show-big-image' )->escaped();
                                        if ( $this->displayImg->getRepo()->canTransformVia404() ) {
                                                $thumbSizes = $wgImageLimits;
                                        } else {
                                        $count = $this->displayImg->pageCount();
  
                                        if ( $page > 1 ) {
 -                                              $label = $out->parse( wfMsg( 'imgmultipageprev' ), false );
 +                                              $label = $out->parse( wfMessage( 'imgmultipageprev' )->text(), false );
                                                $link = Linker::linkKnown(
                                                        $this->getTitle(),
                                                        $label,
                                        }
  
                                        if ( $page < $count ) {
 -                                              $label = wfMsg( 'imgmultipagenext' );
 +                                              $label = wfMessage( 'imgmultipagenext' )->text();
                                                $link = Linker::linkKnown(
                                                        $this->getTitle(),
                                                        $label,
                                                '</td><td><div class="multipageimagenavbox">' .
                                                Xml::openElement( 'form', $formParams ) .
                                                Html::hidden( 'title', $this->getTitle()->getPrefixedDBkey() ) .
 -                                              wfMsgExt( 'imgmultigoto', array( 'parseinline', 'replaceafter' ), $select ) .
 -                                              Xml::submitButton( wfMsg( 'imgmultigo' ) ) .
 +                                                      wfMessage( 'imgmultigoto' )->rawParams( $select )->parse() .
 +                                              Xml::submitButton( wfMessage( 'imgmultigo' )->text() ) .
                                                Xml::closeElement( 'form' ) .
                                                "<hr />$thumb1\n$thumb2<br style=\"clear: both\" /></div></td></tr></table>"
                                        );
                                $medialink = "[[Media:$filename|$linktext]]";
  
                                if ( !$this->displayImg->isSafeFile() ) {
 -                                      $warning = wfMsgNoTrans( 'mediawarning' );
 +                                      $warning = wfMessage( 'mediawarning' )->plain();
                                        // dirmark is needed here to separate the file name, which
                                        // most likely ends in Latin characters, from the description,
                                        // which may begin with the file type. In RTL environment
@@@ -547,25 -507,6 +547,25 @@@ EO
                                }
                        }
  
 +                      // Add cannot animate thumbnail warning
 +                      if ( !$this->displayImg->canAnimateThumbIfAppropriate() ) {
 +                              // Include the extension so wiki admins can
 +                              // customize it on a per file-type basis
 +                              // (aka say things like use format X instead).
 +                              // additionally have a specific message for
 +                              // file-no-thumb-animation-gif
 +                              $ext = $this->displayImg->getExtension();
 +                              $noAnimMesg = wfMessageFallback(
 +                                      'file-no-thumb-animation-' . $ext,
 +                                      'file-no-thumb-animation'
 +                              )->plain();
 +
 +                              $out->addWikiText( <<<EOT
 +<div class="mw-noanimatethumb">{$noAnimMesg}</div>
 +EOT
 +                              );
 +                      }
 +
                        if ( !$this->displayImg->isLocal() ) {
                                $this->printSharedImageText();
                        }
                $wrap = "<div class=\"sharedUploadNotice\">\n$1\n</div>\n";
                $repo = $this->mPage->getFile()->getRepo()->getDisplayName();
  
 -              if ( $descUrl && $descText && wfMsgNoTrans( 'sharedupload-desc-here' ) !== '-'  ) {
 +              if ( $descUrl && $descText && wfMessage( 'sharedupload-desc-here' )->plain() !== '-'  ) {
                        $out->wrapWikiMsg( $wrap, array( 'sharedupload-desc-here', $repo, $descUrl ) );
 -              } elseif ( $descUrl && wfMsgNoTrans( 'sharedupload-desc-there' ) !== '-' ) {
 +              } elseif ( $descUrl && wfMessage( 'sharedupload-desc-there' )->plain() !== '-' ) {
                        $out->wrapWikiMsg( $wrap, array( 'sharedupload-desc-there', $repo, $descUrl ) );
                } else {
                        $out->wrapWikiMsg( $wrap, array( 'sharedupload', $repo ), ''/*BACKCOMPAT*/ );
                }
  
                $out = $this->getContext()->getOutput();
 -              $out->addHTML( "<br /><ul>\n" );
 +              $out->addHTML( "<ul>\n" );
  
                # "Upload a new version of this file" link
 -              if ( UploadBase::userCanReUpload( $this->getContext()->getUser(), $this->mPage->getFile()->name ) ) {
 -                      $ulink = Linker::makeExternalLink( $this->getUploadUrl(), wfMsg( 'uploadnewversion-linktext' ) );
 +              $canUpload = $this->getTitle()->userCan( 'upload', $this->getContext()->getUser() );
 +              if ( $canUpload && UploadBase::userCanReUpload( $this->getContext()->getUser(), $this->mPage->getFile()->name ) ) {
 +                      $ulink = Linker::makeExternalLink( $this->getUploadUrl(), wfMessage( 'uploadnewversion-linktext' )->text() );
                        $out->addHTML( "<li id=\"mw-imagepage-reupload-link\"><div class=\"plainlinks\">{$ulink}</div></li>\n" );
 +              } else {
 +                      $out->addHTML( "<li id=\"mw-imagepage-upload-disallowed\">" . $this->getContext()->msg( 'upload-disallowed-here' )->escaped() . "</li>\n" );
                }
  
                # External editing link
                if ( $wgUseExternalEditor ) {
                        $elink = Linker::linkKnown(
                                $this->getTitle(),
 -                              wfMsgHtml( 'edit-externally' ),
 +                              wfMessage( 'edit-externally' )->escaped(),
                                array(),
                                array(
                                        'action' => 'edit',
                        );
                        $out->addHTML(
                                '<li id="mw-imagepage-edit-external">' . $elink . ' <small>' .
 -                              wfMsgExt( 'edit-externally-help', array( 'parseinline' ) ) .
 -                              "</small></li>\n"
 +                                      wfMessage( 'edit-externally-help' )->parse() .
 +                                      "</small></li>\n"
                        );
                }
  
                        } else {
                                $link = Linker::makeExternalLink( $file->getDescriptionUrl(),
                                        $file->getTitle()->getPrefixedText() );
 -                              $fromSrc = wfMsg( 'shared-repo-from', $file->getRepo()->getDisplayName() );
 +                              $fromSrc = wfMessage( 'shared-repo-from', $file->getRepo()->getDisplayName() )->text();
                        }
                        $out->addHTML( "<li>{$link} {$fromSrc}</li>\n" );
                }
@@@ -40,7 -40,7 +40,7 @@@ class MediaWiki_I18N 
                // Hack for i18n:attributes in PHPTAL 1.0.0 dev version as of 2004-10-23
                $value = preg_replace( '/^string:/', '', $value );
  
 -              $value = wfMsg( $value );
 +              $value = wfMessage( $value )->text();
                // interpolate variables
                $m = array();
                while( preg_match( '/\$([0-9]*?)/sm', $value, $m ) ) {
@@@ -135,6 -135,7 +135,6 @@@ class SkinTemplate extends Skin 
                global $wgDisableCounters, $wgSitename, $wgLogo, $wgHideInterlanguageLinks;
                global $wgMaxCredits, $wgShowCreditsIfMax;
                global $wgPageShowWatchingUsers;
 -              global $wgDebugComments;
                global $wgArticlePath, $wgScriptPath, $wgServer;
  
                wfProfileIn( __METHOD__ );
                        }
                }
  
 -              if ( $wgDebugComments ) {
 -                      $tpl->setRef( 'debug', $out->mDebugtext );
 -              } else {
 -                      $tpl->set( 'debug', '' );
 -              }
 -
                $tpl->set( 'sitenotice', $this->getSiteNotice() );
                $tpl->set( 'bottomscripts', $this->bottomScripts() );
                $tpl->set( 'printfooter', $this->printSource() );
                if ( !in_array( $title->getNamespace(), array( NS_SPECIAL, NS_FILE ) ) &&
                        in_array( $request->getVal( 'action', 'view' ), array( 'view', 'historysubmit' ) ) &&
                        ( $title->exists() || $title->getNamespace() == NS_MEDIAWIKI ) ) {
-                       $pageLang = $title->getPageLanguage();
+                       $pageLang = $title->getPageViewLanguage();
                        $realBodyAttribs['lang'] = $pageLang->getHtmlCode();
                        $realBodyAttribs['dir'] = $pageLang->getDir();
                        $realBodyAttribs['class'] = 'mw-content-'.$pageLang->getDir();
                        $tpl->set( 'headscripts', $out->getHeadScripts() . $out->getHeadItems() );
                }
  
 +              $tpl->set( 'debug', '' );
                $tpl->set( 'debughtml', $this->generateDebugHTML() );
                $tpl->set( 'reporttime', wfReportTime() );
  
                                'text' => $this->username,
                                'href' => &$this->userpageUrlDetails['href'],
                                'class' => $this->userpageUrlDetails['exists'] ? false : 'new',
 -                              'active' => ( $this->userpageUrlDetails['href'] == $pageurl )
 +                              'active' => ( $this->userpageUrlDetails['href'] == $pageurl ),
 +                              'dir' => 'auto'
                        );
                        $usertalkUrlDetails = $this->makeTalkUrlDetails( $this->userpage );
                        $personal_urls['mytalk'] = array(
                        $is_signup = $request->getText( 'type' ) == 'signup';
  
                        # anonlogin & login are the same
 +                      global $wgSecureLogin;
 +                      $proto = $wgSecureLogin ? PROTO_HTTPS : null;
 +
 +                      $login_id = $this->showIPinHeader() ? 'anonlogin' : 'login';
                        $login_url = array(
                                'text' => $this->msg( $loginlink )->text(),
 -                              'href' => self::makeSpecialUrl( 'Userlogin', $returnto ),
 -                              'active' => $title->isSpecial( 'Userlogin' ) && ( $loginlink == 'nav-login-createaccount' || !$is_signup )
 +                              'href' => self::makeSpecialUrl( 'Userlogin', $returnto, $proto ),
 +                              'active' => $title->isSpecial( 'Userlogin' ) && ( $loginlink == 'nav-login-createaccount' || !$is_signup ),
 +                              'class' => $wgSecureLogin ? 'link-https' : ''
 +                      );
 +                      $createaccount_url = array(
 +                              'text' => $this->msg( 'createaccount' )->text(),
 +                              'href' => self::makeSpecialUrl( 'Userlogin', "$returnto&type=signup", $proto ),
 +                              'active' => $title->isSpecial( 'Userlogin' ) && $is_signup,
 +                              'class' => $wgSecureLogin ? 'link-https' : ''
                        );
 -                      if ( $this->getUser()->isAllowed( 'createaccount' ) && !$useCombinedLoginLink ) {
 -                              $createaccount_url = array(
 -                                      'text' => $this->msg( 'createaccount' )->text(),
 -                                      'href' => self::makeSpecialUrl( 'Userlogin', "$returnto&type=signup" ),
 -                                      'active' => $title->isSpecial( 'Userlogin' ) && $is_signup
 -                              );
 -                      }
 -                      global $wgServer, $wgSecureLogin;
 -                      if( substr( $wgServer, 0, 5 ) === 'http:' && $wgSecureLogin ) {
 -                              $title = SpecialPage::getTitleFor( 'Userlogin' );
 -                              $https_url = preg_replace( '/^http:/', 'https:', $title->getFullURL() );
 -                              $login_url['href']  = $https_url;
 -                              # @todo FIXME: Class depends on skin
 -                              $login_url['class'] = 'link-https';
 -                              if ( isset( $createaccount_url ) ) {
 -                                      $https_url = preg_replace( '/^http:/', 'https:',
 -                                              $title->getFullURL( 'type=signup' ) );
 -                                      $createaccount_url['href']  = $https_url;
 -                                      # @todo FIXME: Class depends on skin
 -                                      $createaccount_url['class'] = 'link-https';
 -                              }
 -                      }
 -
 -                      if ( isset( $createaccount_url ) ) {
 -                              $personal_urls['createaccount'] = $createaccount_url;
 -                      }
  
                        if( $this->showIPinHeader() ) {
                                $href = &$this->userpageUrlDetails['href'];
                                        'class' => $usertalkUrlDetails['exists'] ? false : 'new',
                                        'active' => ( $pageurl == $href )
                                );
 -                              $personal_urls['anonlogin'] = $login_url;
 -                      } else {
 -                              $personal_urls['login'] = $login_url;
                        }
 +
 +                      if ( $this->getUser()->isAllowed( 'createaccount' ) && !$useCombinedLoginLink ) {
 +                              $personal_urls['createaccount'] = $createaccount_url;
 +                      }
 +
 +                      $personal_urls[$login_id] = $login_url;
                }
  
                wfRunHooks( 'PersonalUrls', array( &$personal_urls, &$title ) );
@@@ -1403,7 -1420,6 +1403,7 @@@ abstract class BaseTemplate extends Qui
                }
                if ( isset( $this->data['nav_urls']['print'] ) && $this->data['nav_urls']['print'] ) {
                        $toolbox['print'] = $this->data['nav_urls']['print'];
 +                      $toolbox['print']['id'] = 't-print';
                        $toolbox['print']['rel'] = 'alternate';
                        $toolbox['print']['msg'] = 'printableversion';
                }
        function printTrail() { ?>
  <?php $this->html( 'bottomscripts' ); /* JS call to runBodyOnloadHook */ ?>
  <?php $this->html( 'reporttime' ) ?>
 -<?php if ( $this->data['debug'] ): ?>
 -<!-- Debug output:
 -<?php $this->text( 'debug' ); ?>
 -
 --->
 -<?php endif;
 +<?php echo MWDebug::getDebugHTML( $this->getSkin()->getContext() );
        }
  
  }
 -
diff --combined includes/Title.php
@@@ -347,7 -347,7 +347,7 @@@ class Title 
         * @return Title the new object
         */
        public static function newMainPage() {
 -              $title = Title::newFromText( wfMsgForContent( 'mainpage' ) );
 +              $title = Title::newFromText( wfMessage( 'mainpage' )->inContentLanguage()->text() );
                // Don't give fatal errors if the message is broken
                if ( !$title ) {
                        $title = Title::newFromText( 'Main Page' );
  
        /**
         * Returns true if the title is inside the specified namespace.
 -       * 
 +       *
         * Please make use of this instead of comparing to getNamespace()
         * This function is much more resistant to changes we may make
         * to namespaces than code that makes direct comparisons.
         * See getLocalURL for the arguments.
         *
         * @see self::getLocalURL
 +       * @see wfExpandUrl
 +       * @param $proto Protocol type to use in URL
         * @return String the URL
         */
 -      public function getFullURL( $query = '', $query2 = false ) {
 +      public function getFullURL( $query = '', $query2 = false, $proto = PROTO_RELATIVE ) {
                $query = self::fixUrlQueryArgs( $query, $query2 );
  
                # Hand off all the decisions on urls to getLocalURL
                # Expand the url to make it a full url. Note that getLocalURL has the
                # potential to output full urls for a variety of reasons, so we use
                # wfExpandUrl instead of simply prepending $wgServer
 -              $url = wfExpandUrl( $url, PROTO_RELATIVE );
 +              $url = wfExpandUrl( $url, $proto );
  
                # Finally, add the fragment.
                $url .= $this->getFragmentForURL();
         *   queries by skipping checks for cascading protections and user blocks.
         * @param $ignoreErrors Array of Strings Set this to a list of message keys
         *   whose corresponding errors may be ignored.
 -       * @return Array of arguments to wfMsg to explain permissions problems.
 +       * @return Array of arguments to wfMessage to explain permissions problems.
         */
        public function getUserPermissionsErrors( $action, $user, $doExpensiveQueries = true, $ignoreErrors = array() ) {
                $errors = $this->getUserPermissionsErrorsInternal( $action, $user, $doExpensiveQueries );
                # Check $wgNamespaceProtection for restricted namespaces
                if ( $this->isNamespaceProtected( $user ) ) {
                        $ns = $this->mNamespace == NS_MAIN ?
 -                              wfMsg( 'nstab-main' ) : $this->getNsText();
 +                              wfMessage( 'nstab-main' )->text() : $this->getNsText();
                        $errors[] = $this->mNamespace == NS_MEDIAWIKI ?
                                array( 'protectedinterface' ) : array( 'namespaceprotected',  $ns );
                }
                                        $title_protection['pt_create_perm'] = 'protect'; // B/C
                                }
                                if( $title_protection['pt_create_perm'] == '' ||
 -                                      !$user->isAllowed( $title_protection['pt_create_perm'] ) ) 
 +                                      !$user->isAllowed( $title_protection['pt_create_perm'] ) )
                                {
                                        $errors[] = array( 'titleprotected', User::whoIs( $title_protection['pt_user'] ), $title_protection['pt_reason'] );
                                }
                        $id = $user->blockedBy();
                        $reason = $user->blockedFor();
                        if ( $reason == '' ) {
 -                              $reason = wfMsg( 'blockednoreason' );
 +                              $reason = wfMessage( 'blockednoreason' )->text();
                        }
                        $ip = $user->getRequest()->getIP();
  
         * @param $user User to check
         * @param $doExpensiveQueries Bool Set this to false to avoid doing unnecessary queries.
         * @param $short Bool Set this to true to stop after the first permission error.
 -       * @return Array of arrays of the arguments to wfMsg to explain permissions problems.
 +       * @return Array of arrays of the arguments to wfMessage to explain permissions problems.
         */
        protected function getUserPermissionsErrorsInternal( $action, $user, $doExpensiveQueries = true, $short = false ) {
                wfProfileIn( __METHOD__ );
                        );
                        # Update the protection log
                        $log = new LogPage( 'protect' );
 -                      $comment = wfMsgForContent( 'prot_1movedto2', $this->getPrefixedText(), $nt->getPrefixedText() );
 +                      $comment = wfMessage(
 +                              'prot_1movedto2',
 +                              $this->getPrefixedText(),
 +                              $nt->getPrefixedText()
 +                      )->inContentLanguage()->text();
                        if ( $reason ) {
 -                              $comment .= wfMsgForContent( 'colon-separator' ) . $reason;
 +                              $comment .= wfMessage( 'colon-separator' )->inContentLanguage()->text() . $reason;
                        }
                        // @todo FIXME: $params?
                        $log->addEntry( 'move_prot', $nt, $comment, array( $this->getPrefixedText() ) );
                $formatter->setContext( RequestContext::newExtraneousContext( $this ) );
                $comment = $formatter->getPlainActionText();
                if ( $reason ) {
 -                      $comment .= wfMsgForContent( 'colon-separator' ) . $reason;
 +                      $comment .= wfMessage( 'colon-separator' )->inContentLanguage()->text() . $reason;
                }
                # Truncate for whole multibyte characters.
                $comment = $wgContLang->truncate( $comment, 255 );
                        return false;
                }
                # Get the article text
 -              $rev = Revision::newFromTitle( $nt );
 +              $rev = Revision::newFromTitle( $nt, false, Revision::READ_LATEST );
                if( !is_object( $rev ) ){
                        return false;
                }
        }
  
        /**
 -       * Get the number of authors between the given revision IDs.
 +       * Get the number of authors between the given revisions or revision IDs.
         * Used for diffs and other things that really need it.
         *
 -       * @param $old int|Revision Old revision or rev ID (first before range)
 -       * @param $new int|Revision New revision or rev ID (first after range)
 -       * @param $limit Int Maximum number of authors
 -       * @return Int Number of revision authors between these revisions.
 -       */
 -      public function countAuthorsBetween( $old, $new, $limit ) {
 +       * @param $old int|Revision Old revision or rev ID (first before range by default)
 +       * @param $new int|Revision New revision or rev ID (first after range by default)
 +       * @param $limit int Maximum number of authors
 +       * @param $options string|array (Optional): Single option, or an array of options:
 +       *     'include_old' Include $old in the range; $new is excluded.
 +       *     'include_new' Include $new in the range; $old is excluded.
 +       *     'include_both' Include both $old and $new in the range.
 +       *     Unknown option values are ignored.
 +       * @return int Number of revision authors in the range; zero if not both revisions exist
 +       */
 +      public function countAuthorsBetween( $old, $new, $limit, $options = array() ) {
                if ( !( $old instanceof Revision ) ) {
                        $old = Revision::newFromTitle( $this, (int)$old );
                }
                if ( !( $new instanceof Revision ) ) {
                        $new = Revision::newFromTitle( $this, (int)$new );
                }
 +              // XXX: what if Revision objects are passed in, but they don't refer to this title?
 +              // Add $old->getPage() != $new->getPage() || $old->getPage() != $this->getArticleID()
 +              // in the sanity check below?
                if ( !$old || !$new ) {
                        return 0; // nothing to compare
                }
 +              $old_cmp = '>';
 +              $new_cmp = '<';
 +              $options = (array) $options;
 +              if ( in_array( 'include_old', $options ) ) {
 +                      $old_cmp = '>=';
 +              }
 +              if ( in_array( 'include_new', $options ) ) {
 +                      $new_cmp = '<=';
 +              }
 +              if ( in_array( 'include_both', $options ) ) {
 +                      $old_cmp = '>=';
 +                      $new_cmp = '<=';
 +              }
 +              // No DB query needed if $old and $new are the same or successive revisions:
 +              if ( $old->getId() === $new->getId() ) {
 +                      return ( $old_cmp === '>' && $new_cmp === '<' ) ? 0 : 1;
 +              } else if ( $old->getId() === $new->getParentId() ) {
 +                      if ( $old_cmp === '>' || $new_cmp === '<' ) {
 +                              return ( $old_cmp === '>' && $new_cmp === '<' ) ? 0 : 1;
 +                      }
 +                      return ( $old->getRawUserText() === $new->getRawUserText() ) ? 1 : 2;
 +              }
                $dbr = wfGetDB( DB_SLAVE );
                $res = $dbr->select( 'revision', 'DISTINCT rev_user_text',
                        array(
                                'rev_page' => $this->getArticleID(),
 -                              'rev_timestamp > ' . $dbr->addQuotes( $dbr->timestamp( $old->getTimestamp() ) ),
 -                              'rev_timestamp < ' . $dbr->addQuotes( $dbr->timestamp( $new->getTimestamp() ) )
 +                              "rev_timestamp $old_cmp " . $dbr->addQuotes( $dbr->timestamp( $old->getTimestamp() ) ),
 +                              "rev_timestamp $new_cmp " . $dbr->addQuotes( $dbr->timestamp( $new->getTimestamp() ) )
                        ), __METHOD__,
                        array( 'LIMIT' => $limit + 1 ) // add one so caller knows it was truncated
                );
        }
  
        /**
-        * Get the language in which the content of this page is written.
-        * Defaults to $wgContLang, but in certain cases it can be e.g.
-        * $wgLang (such as special pages, which are in the user language).
+        * Get the language in which the content of this page is written in
+        * wikitext. Defaults to $wgContLang, but in certain cases it can be
+        * e.g. $wgLang (such as special pages, which are in the user language).
         *
         * @since 1.18
         * @return Language
                wfRunHooks( 'PageContentLanguage', array( $this, &$pageLang, $wgLang ) );
                return wfGetLangObj( $pageLang );
        }
+       /**
+        * Get the language in which the content of this page is written when
+        * viewed by user. Defaults to $wgContLang, but in certain cases it can be
+        * e.g. $wgLang (such as special pages, which are in the user language).
+        *
+        * @since 1.20
+        * @return Language
+        */
+       public function getPageViewLanguage() {
+               $pageLang = $this->getPageLanguage();
+               // If this is nothing special (so the content is converted when viewed)
+               if ( !$this->isSpecialPage()
+                       && !$this->isCssOrJsPage() && !$this->isCssJsSubpage()
+                       && $this->getNamespace() !== NS_MEDIAWIKI
+               ) {
+                       // If the user chooses a variant, the content is actually
+                       // in a language whose code is the variant code.
+                       $variant = $pageLang->getPreferredVariant();
+                       if ( $pageLang->getCode() !== $variant ) {
+                               $pageLang = Language::factory( $variant );
+                       }
+               }
+               return $pageLang;
+       }
  }