}
public function execute() {
- global $wgContLang;
-
// Get parameters
$params = $this->extractRequestParams();
* @param array $res Result array
* @param string $key Result key
* @param Message[] $msgs
+ * @param bool $joinLists
*/
- protected function formatHelpMessages( array &$res, $key, array $msgs ) {
+ protected function formatHelpMessages( array &$res, $key, array $msgs, $joinLists = false ) {
switch ( $this->helpFormat ) {
case 'none':
break;
$ret[] = $m->setContext( $this->context )->text();
}
$res[$key] = join( "\n\n", $ret );
+ if ( $joinLists ) {
+ $res[$key] = preg_replace( '!^(([*#:;])[^\n]*)\n\n(?=\2)!m', "$1\n", $res[$key] );
+ }
break;
case 'html':
foreach ( $msgs as $m ) {
$ret[] = $m->setContext( $this->context )->parseAsBlock();
}
- $res[$key] = join( "\n", $ret );
+ $ret = join( "\n", $ret );
+ if ( $joinLists ) {
+ $ret = preg_replace( '!\s*</([oud]l)>\s*<\1>\s*!', "\n", $ret );
+ }
+ $res[$key] = $ret;
break;
case 'raw':
$res[$key] = array();
foreach ( $msgs as $m ) {
- $res[$key][] = array(
+ $a = array(
'key' => $m->getKey(),
'params' => $m->getParams(),
);
+ if ( $m instanceof ApiHelpParamValueMessage ) {
+ $a['forvalue'] = $m->getParamValue();
+ }
+ $res[$key][] = $a;
}
$this->getResult()->setIndexedTagName( $res[$key], 'msg' );
break;
private function getModuleInfo( $module ) {
$result = $this->getResult();
$ret = array();
+ $path = $module->getModulePath();
$ret['name'] = $module->getModuleName();
$ret['classname'] = get_class( $module );
- $ret['path'] = $module->getModulePath();
+ $ret['path'] = $path;
if ( !$module->isMain() ) {
$ret['group'] = $module->getParent()->getModuleManager()->getModuleGroup(
$module->getModuleName()
'name' => $name
);
if ( isset( $paramDesc[$name] ) ) {
- $this->formatHelpMessages( $item, 'description', $paramDesc[$name] );
+ $this->formatHelpMessages( $item, 'description', $paramDesc[$name], true );
}
if ( !empty( $settings[ApiBase::PARAM_REQUIRED] ) ) {
if ( isset( $settings[ApiBase::PARAM_MIN] ) ) {
$item['min'] = $settings[ApiBase::PARAM_MIN];
}
+
+ if ( !empty( $settings[ApiBase::PARAM_HELP_MSG_INFO] ) ) {
+ $item['info'] = array();
+ foreach ( $settings[ApiBase::PARAM_HELP_MSG_INFO] as $i ) {
+ $tag = array_shift( $i );
+ $info = array(
+ 'name' => $tag,
+ );
+ if ( count( $i ) ) {
+ $info['values'] = $i;
+ $result->setIndexedTagName( $info['values'], 'v' );
+ }
+ $this->formatHelpMessages( $info, 'text', array(
+ $this->context->msg( "apihelp-{$path}-paraminfo-{$tag}" )
+ ->numParams( count( $i ) )
+ ->params( $this->context->getLanguage()->commaList( $i ) )
+ ->params( $module->getModulePrefix() )
+ ) );
+ $result->setSubelements( $info, 'text' );
+ $item['info'][] = $info;
+ }
+ $result->setIndexedTagName( $item['info'], 'i' );
+ }
+
$ret['parameters'][] = $item;
}
$result->setIndexedTagName( $ret['parameters'], 'param' );
);
}
- public function getParamDescription() {
- return array(
- 'modules' => 'List of module names (values of the action= and format= parameters, or "main"). Can specify submodules with a \'+\'',
- 'helpformat' => 'Format of help strings',
-
- 'querymodules' => 'List of query module names (value of prop=, meta= or list= parameter)',
- 'mainmodule' => 'Get information about the main (top-level) module as well',
- 'pagesetmodule' => 'Get information about the pageset module ' .
- '(providing titles= and friends) as well',
- 'formatmodules' => 'List of format module names (value of format= parameter)',
- );
- }
-
- public function getDescription() {
- return 'Obtain information about certain API parameters and errors.';
- }
-
- public function getExamples() {
+ protected function getExamplesMessages() {
return array(
- 'api.php?action=paraminfo&modules=parse|phpfm|query+allpages|query+siteinfo'
+ 'action=paraminfo&modules=parse|phpfm|query+allpages|query+siteinfo'
+ => 'apihelp-paraminfo-example-1',
);
}