/** * Get the descriptor of the fieldset that contains the file source * selection. The section is 'source' * * @return array Descriptor array */ protected function getSourceSection() { if ($this->mSessionKey) { return array('SessionKey' => array('type' => 'hidden', 'default' => $this->mSessionKey), 'SourceType' => array('type' => 'hidden', 'default' => 'Stash')); } $canUploadByUrl = UploadFromUrl::isEnabled() && UploadFromUrl::isAllowed($this->getUser()) === true && $this->getConfig()->get('CopyUploadsFromSpecialUpload'); $radio = $canUploadByUrl; $selectedSourceType = strtolower($this->getRequest()->getText('wpSourceType', 'File')); $descriptor = array(); if ($this->mTextTop) { $descriptor['UploadFormTextTop'] = array('type' => 'info', 'section' => 'source', 'default' => $this->mTextTop, 'raw' => true); } $this->mMaxUploadSize['file'] = UploadBase::getMaxUploadSize('file'); # Limit to upload_max_filesize unless we are running under HipHop and # that setting doesn't exist if (!wfIsHHVM()) { $this->mMaxUploadSize['file'] = min($this->mMaxUploadSize['file'], wfShorthandToInteger(ini_get('upload_max_filesize')), wfShorthandToInteger(ini_get('post_max_size'))); } $help = $this->msg('upload-maxfilesize', $this->getContext()->getLanguage()->formatSize($this->mMaxUploadSize['file']))->parse(); // If the user can also upload by URL, there are 2 different file size limits. // This extra message helps stress which limit corresponds to what. if ($canUploadByUrl) { $help .= $this->msg('word-separator')->escaped(); $help .= $this->msg('upload_source_file')->parse(); } $descriptor['UploadFile'] = array('class' => 'UploadSourceField', 'section' => 'source', 'type' => 'file', 'id' => 'wpUploadFile', 'radio-id' => 'wpSourceTypeFile', 'label-message' => 'sourcefilename', 'upload-type' => 'File', 'radio' => &$radio, 'help' => $help, 'checked' => $selectedSourceType == 'file'); if ($canUploadByUrl) { $this->mMaxUploadSize['url'] = UploadBase::getMaxUploadSize('url'); $descriptor['UploadFileURL'] = array('class' => 'UploadSourceField', 'section' => 'source', 'id' => 'wpUploadFileURL', 'radio-id' => 'wpSourceTypeurl', 'label-message' => 'sourceurl', 'upload-type' => 'url', 'radio' => &$radio, 'help' => $this->msg('upload-maxfilesize', $this->getContext()->getLanguage()->formatSize($this->mMaxUploadSize['url']))->parse() . $this->msg('word-separator')->escaped() . $this->msg('upload_source_url')->parse(), 'checked' => $selectedSourceType == 'url'); } Hooks::run('UploadFormSourceDescriptors', array(&$descriptor, &$radio, $selectedSourceType)); $descriptor['Extensions'] = array('type' => 'info', 'section' => 'source', 'default' => $this->getExtensionsMessage(), 'raw' => true); return $descriptor; }
/** * Select an upload module and set it to mUpload. Dies on failure. If the * request was a status request and not a true upload, returns false; * otherwise true * * @return bool */ protected function selectUploadModule() { $request = $this->getMain()->getRequest(); // chunk or one and only one of the following parameters is needed if (!$this->mParams['chunk']) { $this->requireOnlyOneParameter($this->mParams, 'filekey', 'file', 'url'); } // Status report for "upload to stash"/"upload from stash" if ($this->mParams['filekey'] && $this->mParams['checkstatus']) { $progress = UploadBase::getSessionStatus($this->getUser(), $this->mParams['filekey']); if (!$progress) { $this->dieUsage('No result in status data', 'missingresult'); } elseif (!$progress['status']->isGood()) { $this->dieUsage($progress['status']->getWikiText(false, false, 'en'), 'stashfailed'); } if (isset($progress['status']->value['verification'])) { $this->checkVerification($progress['status']->value['verification']); } unset($progress['status']); // remove Status object $this->getResult()->addValue(null, $this->getModuleName(), $progress); return false; } // The following modules all require the filename parameter to be set if (is_null($this->mParams['filename'])) { $this->dieUsageMsg(['missingparam', 'filename']); } if ($this->mParams['chunk']) { // Chunk upload $this->mUpload = new UploadFromChunks(); if (isset($this->mParams['filekey'])) { if ($this->mParams['offset'] === 0) { $this->dieUsage('Cannot supply a filekey when offset is 0', 'badparams'); } // handle new chunk $this->mUpload->continueChunks($this->mParams['filename'], $this->mParams['filekey'], $request->getUpload('chunk')); } else { if ($this->mParams['offset'] !== 0) { $this->dieUsage('Must supply a filekey when offset is non-zero', 'badparams'); } // handle first chunk $this->mUpload->initialize($this->mParams['filename'], $request->getUpload('chunk')); } } elseif (isset($this->mParams['filekey'])) { // Upload stashed in a previous request if (!UploadFromStash::isValidKey($this->mParams['filekey'])) { $this->dieUsageMsg('invalid-file-key'); } $this->mUpload = new UploadFromStash($this->getUser()); // This will not download the temp file in initialize() in async mode. // We still have enough information to call checkWarnings() and such. $this->mUpload->initialize($this->mParams['filekey'], $this->mParams['filename'], !$this->mParams['async']); } 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('copyuploaddisabled'); } if (!UploadFromUrl::isAllowedHost($this->mParams['url'])) { $this->dieUsageMsg('copyuploadbaddomain'); } if (!UploadFromUrl::isAllowedUrl($this->mParams['url'])) { $this->dieUsageMsg('copyuploadbadurl'); } $this->mUpload = new UploadFromUrl(); $this->mUpload->initialize($this->mParams['filename'], $this->mParams['url']); } return true; }
/** * Get the descriptor of the fieldset that contains the file source * selection. The section is 'source' * * @return Array: descriptor array */ protected function getSourceSection() { if ($this->mSessionKey) { return array('SessionKey' => array('type' => 'hidden', 'default' => $this->mSessionKey), 'SourceType' => array('type' => 'hidden', 'default' => 'Stash')); } $canUploadByUrl = UploadFromUrl::isEnabled() && UploadFromUrl::isAllowed($this->getUser()); $radio = $canUploadByUrl; $selectedSourceType = strtolower($this->getRequest()->getText('wpSourceType', 'File')); $descriptor = array(); if ($this->mTextTop) { $descriptor['UploadFormTextTop'] = array('type' => 'info', 'section' => 'source', 'default' => $this->mTextTop, 'raw' => true); } $this->mMaxUploadSize['file'] = UploadBase::getMaxUploadSize('file'); # Limit to upload_max_filesize unless we are running under HipHop and # that setting doesn't exist if (!wfIsHipHop()) { $this->mMaxUploadSize['file'] = min($this->mMaxUploadSize['file'], wfShorthandToInteger(ini_get('upload_max_filesize')), wfShorthandToInteger(ini_get('post_max_size'))); } $descriptor['UploadFile'] = array('class' => 'UploadSourceField', 'section' => 'source', 'type' => 'file', 'id' => 'wpUploadFile', 'label-message' => 'sourcefilename', 'upload-type' => 'File', 'radio' => &$radio, 'help' => $this->msg('upload-maxfilesize', $this->getContext()->getLanguage()->formatSize($this->mMaxUploadSize['file']))->parse() . ' ' . $this->msg('upload_source_file')->escaped(), 'checked' => $selectedSourceType == 'file'); if ($canUploadByUrl) { $this->mMaxUploadSize['url'] = UploadBase::getMaxUploadSize('url'); $descriptor['UploadFileURL'] = array('class' => 'UploadSourceField', 'section' => 'source', 'id' => 'wpUploadFileURL', 'label-message' => 'sourceurl', 'upload-type' => 'url', 'radio' => &$radio, 'help' => $this->msg('upload-maxfilesize', $this->getContext()->getLanguage()->formatSize($this->mMaxUploadSize['url']))->parse() . ' ' . $this->msg('upload_source_url')->escaped(), 'checked' => $selectedSourceType == 'url'); } wfRunHooks('UploadFormSourceDescriptors', array(&$descriptor, &$radio, $selectedSourceType)); $descriptor['Extensions'] = array('type' => 'info', 'section' => 'source', 'default' => $this->getExtensionsMessage(), 'raw' => true); return $descriptor; }
/** * Select an upload module and set it to mUpload. Dies on failure. If the * request was a status request and not a true upload, returns false; * otherwise true * * @return bool */ protected function selectUploadModule() { $request = $this->getMain()->getRequest(); // chunk or one and only one of the following parameters is needed if (!$this->mParams['chunk']) { $this->requireOnlyOneParameter($this->mParams, 'filekey', 'file', 'url', 'statuskey'); } if ($this->mParams['statuskey']) { $this->checkAsyncDownloadEnabled(); // Status request for an async upload $sessionData = UploadFromUrlJob::getSessionData($this->mParams['statuskey']); if (!isset($sessionData['result'])) { $this->dieUsage('No result in session data', 'missingresult'); } if ($sessionData['result'] == 'Warning') { $sessionData['warnings'] = $this->transformWarnings($sessionData['warnings']); $sessionData['sessionkey'] = $this->mParams['statuskey']; } $this->getResult()->addValue(null, $this->getModuleName(), $sessionData); return false; } // The following modules all require the filename parameter to be set if (is_null($this->mParams['filename'])) { $this->dieUsageMsg(array('missingparam', 'filename')); } if ($this->mParams['chunk']) { // Chunk upload $this->mUpload = new UploadFromChunks(); if (isset($this->mParams['filekey'])) { // handle new chunk $this->mUpload->continueChunks($this->mParams['filename'], $this->mParams['filekey'], $request->getUpload('chunk')); } else { // handle first chunk $this->mUpload->initialize($this->mParams['filename'], $request->getUpload('chunk')); } } elseif (isset($this->mParams['filekey'])) { // Upload stashed in a previous request if (!UploadFromStash::isValidKey($this->mParams['filekey'])) { $this->dieUsageMsg('invalid-file-key'); } $this->mUpload = new UploadFromStash($this->getUser()); $this->mUpload->initialize($this->mParams['filekey'], $this->mParams['filename']); } 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('copyuploaddisabled'); } $async = false; if ($this->mParams['asyncdownload']) { $this->checkAsyncDownloadEnabled(); if ($this->mParams['leavemessage'] && !$this->mParams['ignorewarnings']) { $this->dieUsage('Using leavemessage without ignorewarnings is not supported', 'missing-ignorewarnings'); } if ($this->mParams['leavemessage']) { $async = 'async-leavemessage'; } else { $async = 'async'; } } $this->mUpload = new UploadFromUrl(); $this->mUpload->initialize($this->mParams['filename'], $this->mParams['url'], $async); } return true; }
/** * Get the descriptor of the fieldset that contains the file source * selection. The section is 'source' * * @return array Descriptor array */ protected function getSourceSection() { global $wgUser, $wgRequest; if ( $this->mSessionKey ) { return array( 'wpSessionKey' => array( 'type' => 'hidden', 'default' => $this->mSessionKey, ), 'wpSourceType' => array( 'type' => 'hidden', 'default' => 'Stash', ), ); } $canUploadByUrl = UploadFromUrl::isEnabled() && $wgUser->isAllowed( 'upload_by_url' ); $radio = $canUploadByUrl; $selectedSourceType = strtolower( $wgRequest->getText( 'wpSourceType', 'File' ) ); $descriptor = array(); $descriptor['UploadFile'] = array( 'class' => 'UploadSourceField', 'section' => 'source', 'type' => 'file', 'id' => 'wpUploadFile', 'size' => 30, // added for PictureGame 'label-message' => 'sourcefilename', 'upload-type' => 'File', 'radio' => &$radio, // help removed, we don't need any tl,dr on this mini-upload form 'checked' => $selectedSourceType == 'file', ); if ( $canUploadByUrl ) { $descriptor['UploadFileURL'] = array( 'class' => 'UploadSourceField', 'section' => 'source', 'id' => 'wpUploadFileURL', 'label-message' => 'sourceurl', 'upload-type' => 'url', 'radio' => &$radio, 'checked' => $selectedSourceType == 'url', ); } return $descriptor; }
/** * Get the descriptor of the fieldset that contains the file source * selection. The section is 'source' * * @return array Descriptor array */ protected function getSourceSection() { if ($this->mSessionKey) { return array('wpSessionKey' => array('type' => 'hidden', 'default' => $this->mSessionKey), 'wpSourceType' => array('type' => 'hidden', 'default' => 'Stash')); } $canUploadByUrl = UploadFromUrl::isEnabled() && $this->getUser()->isAllowed('upload_by_url'); $radio = $canUploadByUrl; $selectedSourceType = strtolower($this->getRequest()->getText('wpSourceType', 'File')); $descriptor = array(); if ($this->mTextTop) { $descriptor['UploadFormTextTop'] = array('type' => 'info', 'section' => 'source', 'default' => $this->mTextTop, 'raw' => true); } $descriptor['UploadFile'] = array('class' => 'SFUploadSourceField', 'section' => 'source', 'type' => 'file', 'id' => 'wpUploadFile', 'label-message' => 'sourcefilename', 'upload-type' => 'File', 'radio' => &$radio, 'help' => wfMessage('upload-maxfilesize', $this->getLanguage()->formatSize(wfShorthandToInteger(ini_get('upload_max_filesize'))))->parse() . ' ' . wfMessage('upload_source_file')->escaped(), 'checked' => $selectedSourceType == 'file'); if ($canUploadByUrl) { global $wgMaxUploadSize; $descriptor['UploadFileURL'] = array('class' => 'SFUploadSourceField', 'section' => 'source', 'id' => 'wpUploadFileURL', 'label-message' => 'sourceurl', 'upload-type' => 'Url', 'radio' => &$radio, 'help' => wfMessage('upload-maxfilesize', $this->getLanguage()->formatSize($wgMaxUploadSize))->parse() . ' ' . wfMessage('upload_source_url')->escaped(), 'checked' => $selectedSourceType == 'url'); } Hooks::run('UploadFormSourceDescriptors', array(&$descriptor, &$radio, $selectedSourceType)); $descriptor['Extensions'] = array('type' => 'info', 'section' => 'source', 'default' => $this->getExtensionsMessage(), 'raw' => true); return $descriptor; }
/** * Get the descriptor of the fieldset that contains the file source * selection. The section is 'source' * * @return array Descriptor array */ protected function getSourceSection() { if (sizeof($this->mSessionKeys) > 0) { $data = array('wpSourceType' => array('type' => 'hidden', 'default' => 'Stash')); $index = 0; foreach ($this->mDestFiles as $k => $v) { if ($v == '') { continue; } $data['wpDestFile' . $index] = array('type' => 'hidden', 'default' => $v); $data['wpSessionKey' . $index] = array('type' => 'hidden', 'default' => $this->mSessionKeys['sessionkey' . $v]); $index++; } return $data; } $canUploadByUrl = UploadFromUrl::isEnabled() && $this->getUser()->isAllowed('upload_by_url'); $radio = $canUploadByUrl; $selectedSourceType = strtolower($this->getRequest()->getText('wpSourceType', 'File')); $descriptor = array(); if ($this->mTextTop) { $descriptor['UploadFormTextTop'] = array('type' => 'info', 'section' => 'source', 'default' => $this->mTextTop, 'raw' => true); } for ($i = 0; $i < MultipleUpload::getMaxUploadFiles(); $i++) { $descriptor['UploadFile' . $i] = array('class' => 'UploadSourceField', 'section' => 'source', 'type' => 'file', 'id' => 'wpUploadFile' . $i, 'label-message' => 'sourcefilename', 'upload-type' => 'File', 'radio' => &$radio, 'checked' => $selectedSourceType == 'file'); $descriptor['DestFile' . $i] = array('type' => 'text', 'section' => 'source', 'id' => 'wpDestFile' . $i, 'label-message' => 'destfilename', 'size' => 60, 'default' => $this->mDestFiles[$i], 'nodata' => strval($this->mDestFile) !== ''); if ($canUploadByUrl) { global $wgMaxUploadSize; $descriptor['UploadFileURL'] = array('class' => 'UploadSourceField', 'section' => 'source', 'id' => 'wpUploadFileURL', 'label-message' => 'sourceurl', 'upload-type' => 'url', 'radio' => &$radio, 'help' => wfMsgExt('upload-maxfilesize', array('parseinline', 'escapenoentities'), $this->getLang()->formatSize($wgMaxUploadSize)) . ' ' . wfMsgHtml('upload_source_url'), 'checked' => $selectedSourceType == 'url'); } } wfRunHooks('UploadFormSourceDescriptors', array(&$descriptor, &$radio, $selectedSourceType)); $descriptor['Extensions'] = array('type' => 'info', 'section' => 'source', 'default' => $this->getExtensionsMessage(), 'raw' => true, 'help' => wfMsgExt('upload-maxfilesize', array('parseinline', 'escapenoentities'), $this->getLang()->formatSize(wfShorthandToInteger(ini_get('upload_max_filesize')))) . ' ' . wfMsgHtml('upload_source_file')); return $descriptor; }
/** * Select an upload module and set it to mUpload. Dies on failure. If the * request was a status request and not a true upload, returns false; * otherwise true * * @return bool */ protected function selectUploadModule() { $request = $this->getMain()->getRequest(); // chunk or one and only one of the following parameters is needed if ( !$this->mParams['chunk'] ) { $this->requireOnlyOneParameter( $this->mParams, 'filekey', 'file', 'url', 'statuskey' ); } // Status report for "upload to stash"/"upload from stash" if ( $this->mParams['filekey'] && $this->mParams['checkstatus'] ) { $progress = UploadBase::getSessionStatus( $this->mParams['filekey'] ); if ( !$progress ) { $this->dieUsage( 'No result in status data', 'missingresult' ); } elseif ( !$progress['status']->isGood() ) { $this->dieUsage( $progress['status']->getWikiText(), 'stashfailed' ); } if ( isset( $progress['status']->value['verification'] ) ) { $this->checkVerification( $progress['status']->value['verification'] ); } unset( $progress['status'] ); // remove Status object $this->getResult()->addValue( null, $this->getModuleName(), $progress ); return false; } if ( $this->mParams['statuskey'] ) { $this->checkAsyncDownloadEnabled(); // Status request for an async upload $sessionData = UploadFromUrlJob::getSessionData( $this->mParams['statuskey'] ); if ( !isset( $sessionData['result'] ) ) { $this->dieUsage( 'No result in session data', 'missingresult' ); } if ( $sessionData['result'] == 'Warning' ) { $sessionData['warnings'] = $this->transformWarnings( $sessionData['warnings'] ); $sessionData['sessionkey'] = $this->mParams['statuskey']; } $this->getResult()->addValue( null, $this->getModuleName(), $sessionData ); return false; } // The following modules all require the filename parameter to be set if ( is_null( $this->mParams['filename'] ) ) { $this->dieUsageMsg( array( 'missingparam', 'filename' ) ); } if ( $this->mParams['chunk'] ) { // Chunk upload $this->mUpload = new UploadFromChunks(); if ( isset( $this->mParams['filekey'] ) ) { // handle new chunk $this->mUpload->continueChunks( $this->mParams['filename'], $this->mParams['filekey'], $request->getUpload( 'chunk' ) ); } else { // handle first chunk $this->mUpload->initialize( $this->mParams['filename'], $request->getUpload( 'chunk' ) ); } } elseif ( isset( $this->mParams['filekey'] ) ) { // Upload stashed in a previous request if ( !UploadFromStash::isValidKey( $this->mParams['filekey'] ) ) { $this->dieUsageMsg( 'invalid-file-key' ); } $this->mUpload = new UploadFromStash( $this->getUser() ); // This will not download the temp file in initialize() in async mode. // We still have enough information to call checkWarnings() and such. $this->mUpload->initialize( $this->mParams['filekey'], $this->mParams['filename'], !$this->mParams['async'] ); } 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( 'copyuploaddisabled' ); } if ( !UploadFromUrl::isAllowedHost( $this->mParams['url'] ) ) { $this->dieUsageMsg( 'copyuploadbaddomain' ); } if ( !UploadFromUrl::isAllowedUrl( $this->mParams['url'] ) ) { $this->dieUsageMsg( 'copyuploadbadurl' ); } $async = false; if ( $this->mParams['asyncdownload'] ) { $this->checkAsyncDownloadEnabled(); if ( $this->mParams['leavemessage'] && !$this->mParams['ignorewarnings'] ) { $this->dieUsage( 'Using leavemessage without ignorewarnings is not supported', 'missing-ignorewarnings' ); } if ( $this->mParams['leavemessage'] ) { $async = 'async-leavemessage'; } else { $async = 'async'; } } $this->mUpload = new UploadFromUrl; $this->mUpload->initialize( $this->mParams['filename'], $this->mParams['url'], $async ); } return true; }
/** * Get the descriptor of the fieldset that contains the file source * selection. The section is 'source' * * @return array Descriptor array */ protected function getSourceSection() { if ($this->mSessionKey) { return ['SessionKey' => ['type' => 'hidden', 'default' => $this->mSessionKey], 'SourceType' => ['type' => 'hidden', 'default' => 'Stash']]; } $canUploadByUrl = UploadFromUrl::isEnabled() && UploadFromUrl::isAllowed($this->getUser()) === true && $this->getConfig()->get('CopyUploadsFromSpecialUpload'); $radio = $canUploadByUrl; $selectedSourceType = strtolower($this->getRequest()->getText('wpSourceType', 'File')); $descriptor = []; if ($this->mTextTop) { $descriptor['UploadFormTextTop'] = ['type' => 'info', 'section' => 'source', 'default' => $this->mTextTop, 'raw' => true]; } $this->mMaxUploadSize['file'] = min(UploadBase::getMaxUploadSize('file'), UploadBase::getMaxPhpUploadSize()); $help = $this->msg('upload-maxfilesize', $this->getContext()->getLanguage()->formatSize($this->mMaxUploadSize['file']))->parse(); // If the user can also upload by URL, there are 2 different file size limits. // This extra message helps stress which limit corresponds to what. if ($canUploadByUrl) { $help .= $this->msg('word-separator')->escaped(); $help .= $this->msg('upload_source_file')->parse(); } $descriptor['UploadFile'] = ['class' => 'UploadSourceField', 'section' => 'source', 'type' => 'file', 'id' => 'wpUploadFile', 'radio-id' => 'wpSourceTypeFile', 'label-message' => 'sourcefilename', 'upload-type' => 'File', 'radio' => &$radio, 'help' => $help, 'checked' => $selectedSourceType == 'file']; if ($canUploadByUrl) { $this->mMaxUploadSize['url'] = UploadBase::getMaxUploadSize('url'); $descriptor['UploadFileURL'] = ['class' => 'UploadSourceField', 'section' => 'source', 'id' => 'wpUploadFileURL', 'radio-id' => 'wpSourceTypeurl', 'label-message' => 'sourceurl', 'upload-type' => 'url', 'radio' => &$radio, 'help' => $this->msg('upload-maxfilesize', $this->getContext()->getLanguage()->formatSize($this->mMaxUploadSize['url']))->parse() . $this->msg('word-separator')->escaped() . $this->msg('upload_source_url')->parse(), 'checked' => $selectedSourceType == 'url']; } Hooks::run('UploadFormSourceDescriptors', [&$descriptor, &$radio, $selectedSourceType]); $descriptor['Extensions'] = ['type' => 'info', 'section' => 'source', 'default' => $this->getExtensionsMessage(), 'raw' => true]; return $descriptor; }
/** * Select an upload module and set it to mUpload. Dies on failure. If the * request was a status request and not a true upload, returns false; * otherwise true * * @return bool */ protected function selectUploadModule() { $request = $this->getMain()->getRequest(); // chunk or one and only one of the following parameters is needed if (!$this->mParams['chunk']) { $this->requireOnlyOneParameter($this->mParams, 'filekey', 'file', 'url', 'statuskey'); } // The following modules all require the filename parameter to be set if (is_null($this->mParams['filename'])) { $this->dieUsageMsg(array('missingparam', 'filename')); } if ($this->mParams['chunk']) { // Chunk upload $this->mUpload = new UploadFromChunks(); if (isset($this->mParams['filekey'])) { // handle new chunk $this->mUpload->continueChunks($this->mParams['filename'], $this->mParams['filekey'], $request->getUpload('chunk')); } else { // handle first chunk $this->mUpload->initialize($this->mParams['filename'], $request->getUpload('chunk')); } } elseif (isset($this->mParams['filekey'])) { // Upload stashed in a previous request if (!UploadFromStash::isValidKey($this->mParams['filekey'])) { $this->dieUsageMsg('invalid-file-key'); } $this->mUpload = new UploadFromStash($this->getUser()); $this->mUpload->initialize($this->mParams['filekey'], $this->mParams['filename']); } 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('copyuploaddisabled'); } $this->mUpload = new UploadFromUrl(); $this->mUpload->initialize($this->mParams['filename'], $this->mParams['url']); } return true; }