Merge "Render namespace lists in the user's language"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 7 Nov 2018 15:14:20 +0000 (15:14 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 7 Nov 2018 15:14:20 +0000 (15:14 +0000)
1  2 
includes/specials/SpecialContributions.php
includes/specials/SpecialImport.php
includes/specials/SpecialRecentchanges.php
tests/phpunit/includes/HtmlTest.php

@@@ -607,7 -607,7 +607,7 @@@ class SpecialContributions extends Incl
                                ''
                        ) . "\u{00A0}" .
                        Html::namespaceSelector(
-                               [ 'selected' => $this->opts['namespace'], 'all' => '' ],
+                               [ 'selected' => $this->opts['namespace'], 'all' => '', 'in-user-lang' => true ],
                                [
                                        'name' => 'namespace',
                                        'id' => 'namespace',
  
                $explain = $this->msg( 'sp-contributions-explain' );
                if ( !$explain->isBlank() ) {
 -                      $form .= "<p id='mw-sp-contributions-explain'>{$explain->parse()}</p>";
 +                      $form .= Html::rawElement(
 +                              'p', [ 'id' => 'mw-sp-contributions-explain' ], $explain->parse()
 +                      );
                }
  
                $form .= Xml::closeElement( 'form' );
@@@ -179,9 -179,8 +179,9 @@@ class SpecialImport extends SpecialPag
  
                $out = $this->getOutput();
                if ( !$source->isGood() ) {
 -                      $out->addWikiText( "<div class=\"error\">\n" .
 -                              $this->msg( 'importfailed', $source->getWikiText() )->parse() . "\n</div>" );
 +                      $out->wrapWikiTextAsInterface( 'error',
 +                              $this->msg( 'importfailed', $source->getWikiText() )->plain()
 +                      );
                } else {
                        $importer = new WikiImporter( $source->value, $this->getConfig() );
                        if ( !is_null( $this->namespace ) ) {
                                                        'selected' => ( $isSameSourceAsBefore ?
                                                                $this->namespace :
                                                                ( $defaultNamespace || '' ) ),
+                                                       'in-user-lang' => true,
                                                ], [
                                                        'name' => "namespace",
                                                        // mw-import-namespace-interwiki, mw-import-namespace-upload
@@@ -678,7 -678,7 +678,7 @@@ class SpecialRecentChanges extends Chan
         */
        protected function namespaceFilterForm( FormOptions $opts ) {
                $nsSelect = Html::namespaceSelector(
-                       [ 'selected' => $opts['namespace'], 'all' => '' ],
+                       [ 'selected' => $opts['namespace'], 'all' => '', 'in-user-lang' => true ],
                        [ 'name' => 'namespace', 'id' => 'namespace' ]
                );
                $nsLabel = Xml::label( $this->msg( 'namespace' )->text(), 'namespace' );
                $note = '';
                $msg = $this->msg( 'rclegend' );
                if ( !$msg->isDisabled() ) {
 -                      $note .= '<div class="mw-rclegend">' . $msg->parse() . "</div>\n";
 +                      $note .= Html::rawElement(
 +                              'div',
 +                              [ 'class' => 'mw-rclegend' ],
 +                              $msg->parse()
 +                      );
                }
  
                $lang = $this->getLanguage();
                $datenow = $lang->userDate( $timestamp, $user );
                $pipedLinks = '<span class="rcshowhide">' . $lang->pipeList( $links ) . '</span>';
  
 -              $rclinks = '<span class="rclinks">' . $this->msg( 'rclinks' )->rawParams( $cl, $dl, '' )
 -                      ->parse() . '</span>';
 +              $rclinks = Html::rawElement(
 +                      'span',
 +                      [ 'class' => 'rclinks' ],
 +                      $this->msg( 'rclinks' )->rawParams( $cl, $dl, '' )->parse()
 +              );
  
 -              $rclistfrom = '<span class="rclistfrom">' . $this->makeOptionsLink(
 -                      $this->msg( 'rclistfrom' )->rawParams( $now, $timenow, $datenow )->parse(),
 -                      [ 'from' => $timestamp ],
 -                      $nondefaults
 -              ) . '</span>';
 +              $rclistfrom = Html::rawElement(
 +                      'span',
 +                      [ 'class' => 'rclistfrom' ],
 +                      $this->makeOptionsLink(
 +                              $this->msg( 'rclistfrom' )->rawParams( $now, $timenow, $datenow )->parse(),
 +                              [ 'from' => $timestamp ],
 +                              $nondefaults
 +                      )
 +              );
  
                return "{$note}$rclinks<br />$pipedLinks<br />$rclistfrom";
        }
@@@ -66,13 -66,10 +66,13 @@@ class HtmlTest extends MediaWikiTestCas
        }
  
        protected function tearDown() {
 +              Language::factory( 'en' )->resetNamespaces();
 +
                if ( $this->restoreWarnings ) {
                        $this->restoreWarnings = false;
                        Wikimedia\restoreWarnings();
                }
 +
                parent::tearDown();
        }
  
                        ),
                        'Basic namespace selector with a custom label but no id attribtue for the <select>'
                );
+               $this->assertEquals(
+                       '<select id="namespace" name="namespace">' . "\n" .
+                               '<option value="0">(Principal)</option>' . "\n" .
+                               '<option value="1">Discusión</option>' . "\n" .
+                               '<option value="2">Usuario</option>' . "\n" .
+                               '<option value="3">Usuario discusión</option>' . "\n" .
+                               '<option value="4">Wiki</option>' . "\n" .
+                               '<option value="5">Wiki discusión</option>' . "\n" .
+                               '<option value="6">Archivo</option>' . "\n" .
+                               '<option value="7">Archivo discusión</option>' . "\n" .
+                               '<option value="8">MediaWiki</option>' . "\n" .
+                               '<option value="9">MediaWiki discusión</option>' . "\n" .
+                               '<option value="10">Plantilla</option>' . "\n" .
+                               '<option value="11">Plantilla discusión</option>' . "\n" .
+                               '<option value="12">Ayuda</option>' . "\n" .
+                               '<option value="13">Ayuda discusión</option>' . "\n" .
+                               '<option value="14">Categoría</option>' . "\n" .
+                               '<option value="15">Categoría discusión</option>' . "\n" .
+                               '<option value="100">Personalizado</option>' . "\n" .
+                               '<option value="101">Personalizado discusión</option>' . "\n" .
+                               '</select>',
+                       Html::namespaceSelector(
+                               [ 'in-user-lang' => true ]
+                       ),
+                       'Basic namespace selector in user language'
+               );
        }
  
        /**