$choices[] = $t;
}
}
- $desc .= $paramPrefix . $nothingPrompt . $prompt . implode( ', ', $choices );
+ $desc .= $paramPrefix . $nothingPrompt . $prompt;
+ $choicesstring = implode( ', ', $choices );
+ $desc .= wordwrap( $choicesstring, 100, "\n " );
} else {
switch ( $type ) {
case 'namespace':
$isArray = is_array( $paramSettings[self::PARAM_TYPE] );
if ( !$isArray
- || $isArray && count( $paramSettings[self::PARAM_TYPE] ) > self::LIMIT_SML1) {
+ || $isArray && count( $paramSettings[self::PARAM_TYPE] ) > self::LIMIT_SML1 ) {
$desc .= $paramPrefix . "Maximum number of values " .
self::LIMIT_SML1 . " (" . self::LIMIT_SML2 . " for bots)";
}
*/
public function makeHelpMsg_callback( $matches ) {
global $wgAutoloadClasses, $wgAutoloadLocalClasses;
+
+ $file = '';
if ( isset( $wgAutoloadLocalClasses[get_class( $this )] ) ) {
$file = $wgAutoloadLocalClasses[get_class( $this )];
} elseif ( isset( $wgAutoloadClasses[get_class( $this )] ) ) {
}
}
+ /**
+ * Generates the possible errors requireOnlyOneParameter() can die with
+ *
+ * @param $params array
+ * @return array
+ */
+ public function getRequireOnlyOneParameterErrorMessages( $params ) {
+ $p = $this->getModulePrefix();
+ $params = implode( ", {$p}", $params );
+
+ return array(
+ array( 'code' => "{$p}missingparam", 'info' => "One of the parameters {$p}{$params} is required" ),
+ array( 'code' => "{$p}invalidparammix", 'info' => "The parameters {$p}{$params} can not be used together" )
+ );
+ }
+
/**
* Callback function used in requireOnlyOneParameter to check whether reequired parameters are set
*
* @param $titleObj Title the page under consideration
* @param $userOption String The user option to consider when $watchlist=preferences.
* If not set will magically default to either watchdefault or watchcreations
- * @returns mixed
+ * @returns Boolean
*/
protected function getWatchlistValue ( $watchlist, $titleObj, $userOption = null ) {
+
+ $userWatching = $titleObj->userIsWatching();
+
global $wgUser;
switch ( $watchlist ) {
case 'watch':
case 'preferences':
# If the user is already watching, don't bother checking
- if ( $titleObj->userIsWatching() ) {
- return null;
+ if ( $userWatching ) {
+ return true;
}
# If no user option was passed, use watchdefault or watchcreation
if ( is_null( $userOption ) ) {
$userOption = $titleObj->exists()
? 'watchdefault' : 'watchcreations';
}
- # If the corresponding user option is true, watch, else no change
- return $wgUser->getOption( $userOption ) ? true : null;
+ # Watch the article based on the user preference
+ return (bool)$wgUser->getOption( $userOption );
case 'nochange':
- return null;
+ return $userWatching;
default:
- return null;
+ return $userWatching;
}
}
$enforceLimits = isset ( $paramSettings[self::PARAM_RANGE_ENFORCE] )
? $paramSettings[self::PARAM_RANGE_ENFORCE] : false;
- if ( !is_null( $min ) || !is_null( $max ) ) {
- if ( is_array( $value ) ) {
- $value = array_map( 'intval', $value );
- foreach ( $value as &$v ) {
+ if ( is_array( $value ) ) {
+ $value = array_map( 'intval', $value );
+ if ( !is_null( $min ) || !is_null( $max ) ) {
+ foreach ( $value as &$v ) {
$this->validateLimit( $paramName, $v, $min, $max, null, $enforceLimits );
}
- } else {
- $value = intval( $value );
- $this->validateLimit( $paramName, $value, $min, $max, null, $enforceLimits );
- }
+ }
+ } else {
+ $value = intval( $value );
+ if ( !is_null( $min ) || !is_null( $max ) ) {
+ $this->validateLimit( $paramName, $value, $min, $max, null, $enforceLimits );
+ }
}
break;
case 'limit':
* Prints usage info on failure.
* @param $paramName string Parameter name
* @param $value int Parameter value
- * @param $min int Minimum value
- * @param $max int Maximum value for users
+ * @param $min int|null Minimum value
+ * @param $max int|null Maximum value for users
* @param $botMax int Maximum value for sysops/bots
* @param $enforceLimits Boolean Whether to enforce (die) if value is outside limits
*/
'sharedfile-exists' => array( 'code' => 'fileexists-sharedrepo-perm', 'info' => 'The target file exists on a shared repository. Use the ignorewarnings parameter to override it.' ),
'mustbeposted' => array( 'code' => 'mustbeposted', 'info' => "The \$1 module requires a POST request" ),
'show' => array( 'code' => 'show', 'info' => 'Incorrect parameter - mutually exclusive values may not be supplied' ),
+ 'specialpage-cantexecute' => array( 'code' => 'specialpage-cantexecute', 'info' => "You don't have permission to view the results of this special page" ),
// ApiEditPage messages
'noimageredirect-anon' => array( 'code' => 'noimageredirect-anon', 'info' => "Anonymous users can't create image redirects" ),