X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiHelp.php;h=9a0d3ffd4ccc0a67b7ec21c05d943dc9274271f3;hb=ab9beeccdb9ce173e6423b87de1f1a91437182ad;hp=a3bb6a2a50529c3a153c0ff9e152e08c2206990d;hpb=fe79bc528b0e054aa630bd4fcfcdd4a9804892da;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiHelp.php b/includes/api/ApiHelp.php index a3bb6a2a50..9a0d3ffd4c 100644 --- a/includes/api/ApiHelp.php +++ b/includes/api/ApiHelp.php @@ -90,7 +90,6 @@ class ApiHelp extends ApiBase { * @param IContextSource $context * @param ApiBase[]|ApiBase $modules * @param array $options Formatting options (described above) - * @return string */ public static function getHelp( IContextSource $context, $modules, array $options ) { global $wgContLang; @@ -311,11 +310,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 +349,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 +361,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 +405,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 +434,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 +491,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 +501,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 +531,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 +644,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 +669,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 +743,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() ) );