From 99bc0ae1a56abeefc402ebd1ff9f4612ca75132b Mon Sep 17 00:00:00 2001 From: umherirrender Date: Sun, 29 Jul 2012 10:48:52 +0200 Subject: [PATCH] Add hint for pipe-separated list to action=help Also fix helptext for integer min/max for isMulti param Change-Id: I84caf01ace8eefd9de4fe783a6cafac3201f2e0a --- includes/api/ApiBase.php | 22 +++++++++++++++------- includes/api/ApiOptions.php | 2 +- includes/api/ApiProtect.php | 2 +- includes/api/ApiQueryBlocks.php | 4 ++-- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index 63624cb58e..77e1356a11 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -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 " . diff --git a/includes/api/ApiOptions.php b/includes/api/ApiOptions.php index 2b3d5e33b4..d3847a03da 100644 --- a/includes/api/ApiOptions.php +++ b/includes/api/ApiOptions.php @@ -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', ); diff --git a/includes/api/ApiProtect.php b/includes/api/ApiProtect.php index d516504393..b3ca67e6f4 100644 --- a/includes/api/ApiProtect.php +++ b/includes/api/ApiProtect.php @@ -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', diff --git a/includes/api/ApiQueryBlocks.php b/includes/api/ApiQueryBlocks.php index 097487e397..d88e4da45e 100644 --- a/includes/api/ApiQueryBlocks.php +++ b/includes/api/ApiQueryBlocks.php @@ -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', -- 2.20.1