本文整理汇总了PHP中UploadBase::getSessionKeyName方法的典型用法代码示例。如果您正苦于以下问题:PHP UploadBase::getSessionKeyName方法的具体用法?PHP UploadBase::getSessionKeyName怎么用?PHP UploadBase::getSessionKeyName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UploadBase
的用法示例。
在下文中一共展示了UploadBase::getSessionKeyName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: selectUploadModule
/**
* 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()
{
global $wgAllowAsyncCopyUploads;
$request = $this->getMain()->getRequest();
// One and only one of the following parameters is needed
$this->requireOnlyOneParameter($this->mParams, 'sessionkey', 'file', 'url', 'statuskey');
if ($wgAllowAsyncCopyUploads && $this->mParams['statuskey']) {
// 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['sessionkey']) {
// Upload stashed in a previous request
$sessionData = $request->getSessionData(UploadBase::getSessionKeyName());
if (!UploadFromStash::isValidSessionKey($this->mParams['sessionkey'], $sessionData)) {
$this->dieUsageMsg(array('invalid-session-key'));
}
$this->mUpload = new UploadFromStash();
$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'] && !$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;
}