if ( $deprecated ) {
$desc = "DEPRECATED! $desc";
}
-
+
$required = isset( $paramSettings[self::PARAM_REQUIRED] ) ?
$paramSettings[self::PARAM_REQUIRED] : false;
if ( $required ) {
if ( $params ) { // getFinalParams() can return false
foreach ( $params as $paramName => $paramSettings ) {
- $results[$paramName] = $this->getParameterFromSettings(
+ $results[$paramName] = $this->getParameterFromSettings(
$paramName, $paramSettings, $parseLimit );
}
}
if ( $value === '' ) {
$this->dieUsageMsg( array( 'missingparam', $paramName ) );
}
-
+
break;
case 'integer': // Force everything using intval() and optionally validate limits
$params = $this->getFinalParams();
if ( $params ) {
foreach ( $params as $paramName => $paramSettings ) {
- if( isset( $paramSettings[ApiBase::PARAM_REQUIRED] ) ) {
+ if ( isset( $paramSettings[ApiBase::PARAM_REQUIRED] ) ) {
$ret[] = array( 'missingparam', $paramName );
}
}
if ( !isset( $this->mUpload ) ) {
$this->dieUsage( 'No upload module set', 'nomodule' );
}
-
+
// First check permission to upload
$this->checkPermissions( $wgUser );
-
+
// Fetch the file
$status = $this->mUpload->fetchFile();
if ( !$status->isGood() ) {
// Check if the uploaded file is sane
$this->verifyUpload();
-
+
// Check permission to upload this file
$permErrors = $this->mUpload->verifyPermissions( $wgUser );
if ( $permErrors !== true ) {
// Cleanup any temporary mess
$this->mUpload->cleanupTempFile();
}
-
+
/**
* Select an upload module and set it to mUpload. Dies on failure.
*/
protected function selectUploadModule() {
$request = $this->getMain()->getRequest();
-
+
// One and only one of the following parameters is needed
$this->requireOnlyOneParameter( $this->mParams,
'sessionkey', 'file', 'url' );
$this->mUpload->initialize( $this->mParams['filename'],
$this->mParams['sessionkey'],
$sessionData[$this->mParams['sessionkey']] );
-
-
+
+
} elseif ( isset( $this->mParams['file'] ) ) {
$this->mUpload = new UploadFromFile();
$this->mUpload->initialize(
$this->mParams['filename'],
$request->getUpload( 'file' )
- );
+ );
} elseif ( isset( $this->mParams['url'] ) ) {
// Make sure upload by URL is enabled:
if ( !UploadFromUrl::isEnabled() ) {
$this->dieUsageMsg( array( 'copyuploaddisabled' ) );
}
-
+
$async = false;
if ( $this->mParams['asyncdownload'] ) {
if ( $this->mParams['leavemessage'] ) {
protected function verifyUpload( ) {
$verification = $this->mUpload->verifyUpload( );
if ( $verification['status'] === UploadBase::OK ) {
- return;
+ return;
}
// TODO: Move them to ApiBase's message map
}
/**
- * Check warnings if ignorewarnings is not set.
+ * Check warnings if ignorewarnings is not set.
* Returns a suitable result array if there were warnings
*/
protected function checkForWarnings() {
*/
protected function performUpload() {
global $wgUser;
-
+
// Use comment as initial page text by default
if ( is_null( $this->mParams['text'] ) ) {
$this->mParams['text'] = $this->mParams['comment'];
if ( !$status->isGood() ) {
$error = $status->getErrorsArray();
-
+
if ( count( $error ) == 1 && $error[0][0] == 'async' ) {
// The upload can not be performed right now, because the user
// requested so
'sessionkey' => null,
);
-
+
global $wgAllowAsyncCopyUploads;
if ( $wgAllowAsyncCopyUploads ) {
$params += array(
'asyncdownload' => false,
- 'leavemessage' => false,
+ 'leavemessage' => false,
);
}
return $params;
if ( $wgAllowAsyncCopyUploads ) {
$params += array(
'asyncdownload' => 'Make fetching a URL asynchronous',
- 'leavemessage' => 'If asyncdownload is used, leave a message on the user talk page if finished',
+ 'leavemessage' => 'If asyncdownload is used, leave a message on the user talk page if finished',
);
}
-
+
return $params;
-
+
}
public function getDescription() {