Merge "Select column page_lang in prop=info"
[lhc/web/wiklou.git] / includes / api / ApiHelp.php
index 8ae05e0..b33b087 100644 (file)
@@ -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',
                );
        }