API: Remove deprecated response values from action=login
[lhc/web/wiklou.git] / includes / api / ApiHelp.php
index f7539ce..a3bb6a2 100644 (file)
@@ -100,8 +100,10 @@ class ApiHelp extends ApiBase {
                }
 
                $out = $context->getOutput();
-               $out->addModuleStyles( 'mediawiki.hlist' );
-               $out->addModuleStyles( 'mediawiki.apihelp' );
+               $out->addModuleStyles( [
+                       'mediawiki.hlist',
+                       'mediawiki.apihelp',
+               ] );
                if ( !empty( $options['toc'] ) ) {
                        $out->addModules( 'mediawiki.toc' );
                }
@@ -255,28 +257,43 @@ class ApiHelp extends ApiBase {
                                }
 
                                if ( $module->isMain() ) {
-                                       $header = $context->msg( 'api-help-main-header' )->parse();
+                                       $headerContent = $context->msg( 'api-help-main-header' )->parse();
+                                       $headerAttr = [
+                                               'class' => 'apihelp-header',
+                                       ];
                                } else {
                                        $name = $module->getModuleName();
-                                       $header = $module->getParent()->getModuleManager()->getModuleGroup( $name ) .
+                                       $headerContent = $module->getParent()->getModuleManager()->getModuleGroup( $name ) .
                                                "=$name";
                                        if ( $module->getModulePrefix() !== '' ) {
-                                               $header .= ' ' .
+                                               $headerContent .= ' ' .
                                                        $context->msg( 'parentheses', $module->getModulePrefix() )->parse();
                                        }
+                                       // Module names are always in English and not localized,
+                                       // so English language and direction must be set explicitly,
+                                       // otherwise parentheses will get broken in RTL wikis
+                                       $headerAttr = [
+                                               'class' => 'apihelp-header apihelp-module-name',
+                                               'dir' => 'ltr',
+                                               'lang' => 'en',
+                                       ];
                                }
+
+                               $headerAttr['id'] = $anchor;
+
                                $haveModules[$anchor] = [
                                        'toclevel' => count( $tocnumber ),
                                        'level' => $level,
                                        'anchor' => $anchor,
-                                       'line' => $header,
+                                       'line' => $headerContent,
                                        'number' => implode( '.', $tocnumber ),
                                        'index' => false,
                                ];
                                if ( empty( $options['noheader'] ) ) {
-                                       $help['header'] .= Html::element( 'h' . min( 6, $level ),
-                                               [ 'id' => $anchor, 'class' => 'apihelp-header' ],
-                                               $header
+                                       $help['header'] .= Html::element(
+                                               'h' . min( 6, $level ),
+                                               $headerAttr,
+                                               $headerContent
                                        );
                                }
                        } else {