X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiHelp.php;h=b33b087e6dd436d110fbad1edf353d6b4c2ce10e;hb=6c7bb3a57cb8488549788c208d812718166806ea;hp=8ae05e0a1260d6803b050dc548be6412d1d31764;hpb=07428db8d931f2b4ea6e3c043df924a3f4edfec1;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiHelp.php b/includes/api/ApiHelp.php index 8ae05e0a12..b33b087e6d 100644 --- a/includes/api/ApiHelp.php +++ b/includes/api/ApiHelp.php @@ -60,7 +60,7 @@ class ApiHelp extends ApiBase { if ( $params['wrap'] ) { $data = array( 'mime' => 'text/html', - 'help' => $help, + 'help' => $html, ); $result->setSubelements( $data, 'help' ); $result->addValue( null, $this->getModuleName(), $data ); @@ -369,6 +369,18 @@ class ApiHelp extends ApiBase { $info[] = $context->msg( 'api-help-param-required' )->parse(); } + // Custom info? + if ( !empty( $settings[ApiBase::PARAM_HELP_MSG_INFO] ) ) { + foreach ( $settings[ApiBase::PARAM_HELP_MSG_INFO] as $i ) { + $tag = array_shift( $i ); + $info[] = $context->msg( "apihelp-{$path}-paraminfo-{$tag}" ) + ->numParams( count( $i ) ) + ->params( $context->getLanguage()->commaList( $i ) ) + ->params( $module->getModulePrefix() ) + ->parse(); + } + } + // Type documentation if ( !isset( $settings[ApiBase::PARAM_TYPE] ) ) { $dflt = isset( $settings[ApiBase::PARAM_DFLT] ) @@ -390,7 +402,16 @@ class ApiHelp extends ApiBase { if ( is_array( $type ) ) { $count = count( $type ); - $type = array_map( 'wfEscapeWikiText', $type ); + $links = isset( $settings[ApiBase::PARAM_VALUE_LINKS] ) + ? $settings[ApiBase::PARAM_VALUE_LINKS] + : array(); + $type = array_map( function ( $v ) use ( $links ) { + $ret = wfEscapeWikiText( $v ); + if ( isset( $links[$v] ) ) { + $ret = "[[{$links[$v]}|$ret]]"; + } + return $ret; + }, $type ); $i = array_search( '', $type, true ); if ( $i === false ) { $type = $context->getLanguage()->commaList( $type ); @@ -508,11 +529,11 @@ class ApiHelp extends ApiBase { ->parse(); } - if ( !$description && !$info ) { - $description[] = self::wrap( + if ( !array_filter( $description ) ) { + $description = array( self::wrap( $context->msg( 'api-help-param-no-description' ), 'apihelp-empty' - ); + ) ); } // Add "deprecated" flag @@ -630,12 +651,16 @@ class ApiHelp extends ApiBase { ); } - public function getExamplesMessages() { + protected function getExamplesMessages() { return array( - 'action=help' => 'apihelp-help-example-main', - 'action=help&recursivesubmodules=1' => 'apihelp-help-example-recursive', - 'action=help&modules=help' => 'apihelp-help-example-help', - 'action=help&modules=query+info|query+categorymembers' => 'apihelp-help-example-query', + 'action=help' + => 'apihelp-help-example-main', + 'action=help&recursivesubmodules=1' + => 'apihelp-help-example-recursive', + 'action=help&modules=help' + => 'apihelp-help-example-help', + 'action=help&modules=query+info|query+categorymembers' + => 'apihelp-help-example-query', ); }