Add hint for pipe-separated list to action=help
authorumherirrender <umherirrender_de.wp@web.de>
Sun, 29 Jul 2012 08:48:52 +0000 (10:48 +0200)
committerumherirrender <umherirrender_de.wp@web.de>
Sun, 29 Jul 2012 08:48:52 +0000 (10:48 +0200)
Also fix helptext for integer min/max for isMulti param

Change-Id: I84caf01ace8eefd9de4fe783a6cafac3201f2e0a

includes/api/ApiBase.php
includes/api/ApiOptions.php
includes/api/ApiProtect.php
includes/api/ApiQueryBlocks.php

index 63624cb..77e1356 100644 (file)
@@ -401,7 +401,9 @@ abstract class ApiBase extends ContextSource {
 
                                $type = isset( $paramSettings[self::PARAM_TYPE] ) ? $paramSettings[self::PARAM_TYPE] : null;
                                if ( isset( $type ) ) {
-                                       if ( isset( $paramSettings[self::PARAM_ISMULTI] ) && $paramSettings[self::PARAM_ISMULTI] ) {
+                                       $hintPipeSeparated = true;
+                                       $multi = isset( $paramSettings[self::PARAM_ISMULTI] ) ? $paramSettings[self::PARAM_ISMULTI] : false;
+                                       if ( $multi ) {
                                                $prompt = 'Values (separate with \'|\'): ';
                                        } else {
                                                $prompt = 'One value: ';
@@ -409,7 +411,7 @@ abstract class ApiBase extends ContextSource {
 
                                        if ( is_array( $type ) ) {
                                                $choices = array();
-                                               $nothingPrompt = false;
+                                               $nothingPrompt = '';
                                                foreach ( $type as $t ) {
                                                        if ( $t === '' ) {
                                                                $nothingPrompt = 'Can be empty, or ';
@@ -420,6 +422,7 @@ abstract class ApiBase extends ContextSource {
                                                $desc .= $paramPrefix . $nothingPrompt . $prompt;
                                                $choicesstring = implode( ', ', $choices );
                                                $desc .= wordwrap( $choicesstring, 100, $descWordwrap );
+                                               $hintPipeSeparated = false;
                                        } else {
                                                switch ( $type ) {
                                                        case 'namespace':
@@ -427,6 +430,7 @@ abstract class ApiBase extends ContextSource {
                                                                $desc .= $paramPrefix . $prompt;
                                                                $desc .= wordwrap( implode( ', ', MWNamespace::getValidNamespaces() ),
                                                                        100, $descWordwrap );
+                                                               $hintPipeSeparated = false;
                                                                break;
                                                        case 'limit':
                                                                $desc .= $paramPrefix . "No more than {$paramSettings[self :: PARAM_MAX]}";
@@ -436,15 +440,16 @@ abstract class ApiBase extends ContextSource {
                                                                $desc .= ' allowed';
                                                                break;
                                                        case 'integer':
+                                                               $s = $multi ? 's' : '';
                                                                $hasMin = isset( $paramSettings[self::PARAM_MIN] );
                                                                $hasMax = isset( $paramSettings[self::PARAM_MAX] );
                                                                if ( $hasMin || $hasMax ) {
                                                                        if ( !$hasMax ) {
-                                                                               $intRangeStr = "The value must be no less than {$paramSettings[self::PARAM_MIN]}";
+                                                                               $intRangeStr = "The value$s must be no less than {$paramSettings[self::PARAM_MIN]}";
                                                                        } elseif ( !$hasMin ) {
-                                                                               $intRangeStr = "The value must be no more than {$paramSettings[self::PARAM_MAX]}";
+                                                                               $intRangeStr = "The value$s must be no more than {$paramSettings[self::PARAM_MAX]}";
                                                                        } else {
-                                                                               $intRangeStr = "The value must be between {$paramSettings[self::PARAM_MIN]} and {$paramSettings[self::PARAM_MAX]}";
+                                                                               $intRangeStr = "The value$s must be between {$paramSettings[self::PARAM_MIN]} and {$paramSettings[self::PARAM_MAX]}";
                                                                        }
 
                                                                        $desc .= $paramPrefix . $intRangeStr;
@@ -453,9 +458,12 @@ abstract class ApiBase extends ContextSource {
                                                }
                                        }
 
-                                       if ( isset( $paramSettings[self::PARAM_ISMULTI] ) && $paramSettings[self::PARAM_ISMULTI] ) {
-                                               $isArray = is_array( $type );
+                                       if ( $multi ) {
+                                               if ( $hintPipeSeparated ) {
+                                                       $desc .= $paramPrefix . "Separate values with '|'";
+                                               }
 
+                                               $isArray = is_array( $type );
                                                if ( !$isArray
                                                                || $isArray && count( $type ) > self::LIMIT_SML1 ) {
                                                        $desc .= $paramPrefix . "Maximum number of values " .
index 2b3d5e3..d3847a0 100644 (file)
@@ -123,7 +123,7 @@ class ApiOptions extends ApiBase {
                return array(
                        'token' => 'An options token previously obtained through the action=tokens',
                        'reset' => 'Resets all preferences to the site defaults',
-                       'change' => 'Pipe-separated list of changes, formatted name=value (e.g. skin=vector), value cannot contain pipe characters',
+                       'change' => 'List of changes, formatted name=value (e.g. skin=vector), value cannot contain pipe characters',
                        'optionname' => 'A name of a option which should have an optionvalue set',
                        'optionvalue' => 'A value of the option specified by the optionname, can contain pipe characters',
                );
index d516504..b3ca67e 100644 (file)
@@ -176,7 +176,7 @@ class ApiProtect extends ApiBase {
                        'title' => "Title of the page you want to (un)protect. Cannot be used together with {$p}pageid",
                        'pageid' => "ID of the page you want to (un)protect. Cannot be used together with {$p}title",
                        'token' => 'A protect token previously retrieved through prop=info',
-                       'protections' => 'Pipe-separated list of protection levels, formatted action=group (e.g. edit=sysop)',
+                       'protections' => 'List of protection levels, formatted action=group (e.g. edit=sysop)',
                        'expiry' => array( 'Expiry timestamps. If only one timestamp is set, it\'ll be used for all protections.',
                                        'Use \'infinite\', \'indefinite\' or \'never\', for a neverexpiring protection.' ),
                        'reason' => 'Reason for (un)protecting',
index 097487e..d88e4da 100644 (file)
@@ -299,8 +299,8 @@ class ApiQueryBlocks extends ApiQueryBase {
                        'start' => 'The timestamp to start enumerating from',
                        'end' => 'The timestamp to stop enumerating at',
                        'dir' => $this->getDirectionDescription( $p ),
-                       'ids' => 'Pipe-separated list of block IDs to list (optional)',
-                       'users' => 'Pipe-separated list of users to search for (optional)',
+                       'ids' => 'List of block IDs to list (optional)',
+                       'users' => 'List of users to search for (optional)',
                        'ip' => array(  'Get all blocks applying to this IP or CIDR range, including range blocks.',
                                        'Cannot be used together with bkusers. CIDR ranges broader than /16 are not accepted' ),
                        'limit' => 'The maximum amount of blocks to list',