X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fapi%2FApiHelp.php;h=2a6c938a4796ec606d88f4204b53cd9729d6d881;hp=a3bb6a2a50529c3a153c0ff9e152e08c2206990d;hb=9964ca1a390c446397dcd466916ffed356cdc3c9;hpb=500889f19005b4aed93c5b6eaafd35689fce7dcd diff --git a/includes/api/ApiHelp.php b/includes/api/ApiHelp.php index a3bb6a2a50..2a6c938a47 100644 --- a/includes/api/ApiHelp.php +++ b/includes/api/ApiHelp.php @@ -311,11 +311,11 @@ class ApiHelp extends ApiBase { if ( count( $modules ) === 1 && $m === $modules[0] && !( !empty( $options['submodules'] ) && $m->getModuleManager() ) ) { - $link = Html::element( 'b', null, $name ); + $link = Html::element( 'b', [ 'dir' => 'ltr', 'lang' => 'en' ], $name ); } else { $link = SpecialPage::getTitleFor( 'ApiHelp', $m->getModulePath() )->getLocalURL(); $link = Html::element( 'a', - [ 'href' => $link, 'class' => 'apihelp-linktrail' ], + [ 'href' => $link, 'class' => 'apihelp-linktrail', 'dir' => 'ltr', 'lang' => 'en' ], $name ); $any = true; @@ -350,7 +350,8 @@ class ApiHelp extends ApiBase { if ( isset( $sourceInfo['namemsg'] ) ) { $extname = $context->msg( $sourceInfo['namemsg'] )->text(); } else { - $extname = $sourceInfo['name']; + // Probably English, so wrap it. + $extname = Html::element( 'span', [ 'dir' => 'ltr', 'lang' => 'en' ], $sourceInfo['name'] ); } $help['flags'] .= Html::rawElement( 'li', null, self::wrap( @@ -361,7 +362,9 @@ class ApiHelp extends ApiBase { $link = SpecialPage::getTitleFor( 'Version', 'License/' . $sourceInfo['name'] ); if ( isset( $sourceInfo['license-name'] ) ) { - $msg = $context->msg( 'api-help-license', $link, $sourceInfo['license-name'] ); + $msg = $context->msg( 'api-help-license', $link, + Html::element( 'span', [ 'dir' => 'ltr', 'lang' => 'en' ], $sourceInfo['license-name'] ) + ); } elseif ( SpecialVersion::getExtLicenseFileName( dirname( $sourceInfo['path'] ) ) ) { $msg = $context->msg( 'api-help-license-noname', $link ); } else { @@ -403,7 +406,7 @@ class ApiHelp extends ApiBase { $help['help-urls'] .= Html::openElement( 'ul' ); foreach ( $urls as $url ) { $help['help-urls'] .= Html::rawElement( 'li', null, - Html::element( 'a', [ 'href' => $url ], $url ) + Html::element( 'a', [ 'href' => $url, 'dir' => 'ltr' ], $url ) ); } $help['help-urls'] .= Html::closeElement( 'ul' ); @@ -432,8 +435,9 @@ class ApiHelp extends ApiBase { $settings = [ ApiBase::PARAM_DFLT => $settings ]; } - $help['parameters'] .= Html::element( 'dt', null, - $module->encodeParamName( $name ) ); + $help['parameters'] .= Html::rawElement( 'dt', null, + Html::element( 'span', [ 'dir' => 'ltr', 'lang' => 'en' ], $module->encodeParamName( $name ) ) + ); // Add description $description = []; @@ -488,8 +492,9 @@ class ApiHelp extends ApiBase { $links = isset( $settings[ApiBase::PARAM_VALUE_LINKS] ) ? $settings[ApiBase::PARAM_VALUE_LINKS] : []; - $type = array_map( function ( $v ) use ( $links ) { - $ret = wfEscapeWikiText( $v ); + $values = array_map( function ( $v ) use ( $links ) { + // We can't know whether this contains LTR or RTL text. + $ret = $v === '' ? $v : Html::element( 'span', [ 'dir' => 'auto' ], $v ); if ( isset( $links[$v] ) ) { $ret = "[[{$links[$v]}|$ret]]"; } @@ -497,17 +502,17 @@ class ApiHelp extends ApiBase { }, $type ); $i = array_search( '', $type, true ); if ( $i === false ) { - $type = $context->getLanguage()->commaList( $type ); + $values = $context->getLanguage()->commaList( $values ); } else { - unset( $type[$i] ); - $type = $context->msg( 'api-help-param-list-can-be-empty' ) - ->numParams( count( $type ) ) - ->params( $context->getLanguage()->commaList( $type ) ) + unset( $values[$i] ); + $values = $context->msg( 'api-help-param-list-can-be-empty' ) + ->numParams( count( $values ) ) + ->params( $context->getLanguage()->commaList( $values ) ) ->parse(); } $info[] = $context->msg( 'api-help-param-list' ) ->params( $multi ? 2 : 1 ) - ->params( $type ) + ->params( $values ) ->parse(); $hintPipeSeparated = false; } else { @@ -527,7 +532,8 @@ class ApiHelp extends ApiBase { $prefix = $module->isMain() ? '' : ( $module->getModulePath() . '+' ); $submodules = array_map( function ( $name ) use ( $prefix ) { - return "[[Special:ApiHelp/{$prefix}{$name}|{$name}]]"; + $text = Html::element( 'span', [ 'dir' => 'ltr', 'lang' => 'en' ], $name ); + return "[[Special:ApiHelp/{$prefix}{$name}|{$text}]]"; }, $submodules ); } $count = count( $submodules ); @@ -639,6 +645,20 @@ class ApiHelp extends ApiBase { if ( $extra ) { $info[] = implode( ' ', $extra ); } + + $allowAll = isset( $settings[ApiBase::PARAM_ALL] ) + ? $settings[ApiBase::PARAM_ALL] + : false; + if ( $allowAll || $settings[ApiBase::PARAM_TYPE] === 'namespace' ) { + if ( $settings[ApiBase::PARAM_TYPE] === 'namespace' ) { + $allSpecifier = ApiBase::ALL_DEFAULT_STRING; + } else { + $allSpecifier = ( is_string( $allowAll ) ? $allowAll : ApiBase::ALL_DEFAULT_STRING ); + } + $info[] = $context->msg( 'api-help-param-multi-all' ) + ->params( $allSpecifier ) + ->parse(); + } } } @@ -650,8 +670,9 @@ class ApiHelp extends ApiBase { $info[] = $context->msg( 'api-help-param-default-empty' ) ->parse(); } elseif ( $default !== null && $default !== false ) { + // We can't know whether this contains LTR or RTL text. $info[] = $context->msg( 'api-help-param-default' ) - ->params( wfEscapeWikiText( $default ) ) + ->params( Html::element( 'span', [ 'dir' => 'auto' ], $default ) ) ->parse(); } @@ -723,7 +744,7 @@ class ApiHelp extends ApiBase { $sandbox = SpecialPage::getTitleFor( 'ApiSandbox' )->getLocalURL() . '#' . $qs; $help['examples'] .= Html::rawElement( 'dt', null, $msg->parse() ); $help['examples'] .= Html::rawElement( 'dd', null, - Html::element( 'a', [ 'href' => $link ], "api.php?$qs" ) . ' ' . + Html::element( 'a', [ 'href' => $link, 'dir' => 'ltr' ], "api.php?$qs" ) . ' ' . Html::rawElement( 'a', [ 'href' => $sandbox ], $context->msg( 'api-help-open-in-apisandbox' )->parse() ) );