当前位置: 首页>>代码示例>>PHP>>正文


PHP UploadBase::performUpload方法代码示例

本文整理汇总了PHP中UploadBase::performUpload方法的典型用法代码示例。如果您正苦于以下问题:PHP UploadBase::performUpload方法的具体用法?PHP UploadBase::performUpload怎么用?PHP UploadBase::performUpload使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UploadBase的用法示例。


在下文中一共展示了UploadBase::performUpload方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: performUpload

 /**
  * Perform the actual upload. Returns a suitable result array on success;
  * dies on failure.
  *
  * @return array
  */
 protected function performUpload()
 {
     // Use comment as initial page text by default
     if (is_null($this->mParams['text'])) {
         $this->mParams['text'] = $this->mParams['comment'];
     }
     $file = $this->mUpload->getLocalFile();
     $watch = $this->getWatchlistValue($this->mParams['watchlist'], $file->getTitle());
     // Deprecated parameters
     if ($this->mParams['watch']) {
         $watch = true;
     }
     // No errors, no warnings: do the upload
     $status = $this->mUpload->performUpload($this->mParams['comment'], $this->mParams['text'], $watch, $this->getUser());
     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
             return array('result' => 'Queued', 'statuskey' => $error[0][1]);
         } else {
             $this->getResult()->setIndexedTagName($error, 'error');
             $this->dieUsage('An internal error occurred', 'internal-error', 0, $error);
         }
     }
     $file = $this->mUpload->getLocalFile();
     $result['result'] = 'Success';
     $result['filename'] = $file->getName();
     return $result;
 }
开发者ID:slackfaith,项目名称:deadbrain_site,代码行数:36,代码来源:ApiUpload.php

示例2: processUpload

 /**
  * Do the upload.
  * Checks are made in SpecialUpload::execute()
  */
 protected function processUpload()
 {
     // Fetch the file if required
     $status = $this->mUpload->fetchFile();
     if (!$status->isOK()) {
         $this->showUploadError($this->getOutput()->parse($status->getWikiText()));
         return;
     }
     if (!Hooks::run('UploadForm:BeforeProcessing', array(&$this))) {
         wfDebug("Hook 'UploadForm:BeforeProcessing' broke processing the file.\n");
         // This code path is deprecated. If you want to break upload processing
         // do so by hooking into the appropriate hooks in UploadBase::verifyUpload
         // and UploadBase::verifyFile.
         // If you use this hook to break uploading, the user will be returned
         // an empty form with no error message whatsoever.
         return;
     }
     // Upload verification
     $details = $this->mUpload->verifyUpload();
     if ($details['status'] != UploadBase::OK) {
         $this->processVerificationError($details);
         return;
     }
     // Verify permissions for this title
     $permErrors = $this->mUpload->verifyTitlePermissions($this->getUser());
     if ($permErrors !== true) {
         $code = array_shift($permErrors[0]);
         $this->showRecoverableUploadError($this->msg($code, $permErrors[0])->parse());
         return;
     }
     $this->mLocalFile = $this->mUpload->getLocalFile();
     // Check warnings if necessary
     if (!$this->mIgnoreWarning) {
         $warnings = $this->mUpload->checkWarnings();
         if ($this->showUploadWarning($warnings)) {
             return;
         }
     }
     // This is as late as we can throttle, after expected issues have been handled
     if (UploadBase::isThrottled($this->getUser())) {
         $this->showRecoverableUploadError($this->msg('actionthrottledtext')->escaped());
         return;
     }
     // Get the page text if this is not a reupload
     if (!$this->mForReUpload) {
         $pageText = self::getInitialPageText($this->mComment, $this->mLicense, $this->mCopyrightStatus, $this->mCopyrightSource, $this->getConfig());
     } else {
         $pageText = false;
     }
     $status = $this->mUpload->performUpload($this->mComment, $pageText, $this->mWatchthis, $this->getUser());
     if (!$status->isGood()) {
         $this->showUploadError($this->getOutput()->parse($status->getWikiText()));
         return;
     }
     // Success, redirect to description page
     $this->mUploadSuccessful = true;
     Hooks::run('SpecialUploadComplete', array(&$this));
     $this->getOutput()->redirect($this->mLocalFile->getTitle()->getFullURL());
 }
开发者ID:Acidburn0zzz,项目名称:mediawiki,代码行数:63,代码来源:SpecialUpload.php

示例3: performUpload

 /**
  * Perform the actual upload. Returns a suitable result array on success;
  * dies on failure.
  *
  * @param array $warnings Array of Api upload warnings
  * @return array
  */
 protected function performUpload($warnings)
 {
     // Use comment as initial page text by default
     if (is_null($this->mParams['text'])) {
         $this->mParams['text'] = $this->mParams['comment'];
     }
     /** @var $file LocalFile */
     $file = $this->mUpload->getLocalFile();
     // For preferences mode, we want to watch if 'watchdefault' is set,
     // or if the *file* doesn't exist, and either 'watchuploads' or
     // 'watchcreations' is set. But getWatchlistValue()'s automatic
     // handling checks if the *title* exists or not, so we need to check
     // all three preferences manually.
     $watch = $this->getWatchlistValue($this->mParams['watchlist'], $file->getTitle(), 'watchdefault');
     if (!$watch && $this->mParams['watchlist'] == 'preferences' && !$file->exists()) {
         $watch = $this->getWatchlistValue('preferences', $file->getTitle(), 'watchuploads') || $this->getWatchlistValue('preferences', $file->getTitle(), 'watchcreations');
     }
     // Deprecated parameters
     if ($this->mParams['watch']) {
         $watch = true;
     }
     if ($this->mParams['tags']) {
         $status = ChangeTags::canAddTagsAccompanyingChange($this->mParams['tags'], $this->getUser());
         if (!$status->isOK()) {
             $this->dieStatus($status);
         }
     }
     // No errors, no warnings: do the upload
     if ($this->mParams['async']) {
         $progress = UploadBase::getSessionStatus($this->getUser(), $this->mParams['filekey']);
         if ($progress && $progress['result'] === 'Poll') {
             $this->dieUsage('Upload from stash already in progress.', 'publishfailed');
         }
         UploadBase::setSessionStatus($this->getUser(), $this->mParams['filekey'], ['result' => 'Poll', 'stage' => 'queued', 'status' => Status::newGood()]);
         JobQueueGroup::singleton()->push(new PublishStashedFileJob(Title::makeTitle(NS_FILE, $this->mParams['filename']), ['filename' => $this->mParams['filename'], 'filekey' => $this->mParams['filekey'], 'comment' => $this->mParams['comment'], 'tags' => $this->mParams['tags'], 'text' => $this->mParams['text'], 'watch' => $watch, 'session' => $this->getContext()->exportSession()]));
         $result['result'] = 'Poll';
         $result['stage'] = 'queued';
     } else {
         /** @var $status Status */
         $status = $this->mUpload->performUpload($this->mParams['comment'], $this->mParams['text'], $watch, $this->getUser(), $this->mParams['tags']);
         if (!$status->isGood()) {
             // Is there really no better way to do this?
             $errors = $status->getErrorsByType('error');
             $msg = array_merge([$errors[0]['message']], $errors[0]['params']);
             $data = $status->getErrorsArray();
             ApiResult::setIndexedTagName($data, 'error');
             // For backwards-compatibility, we use the 'internal-error' fallback key and merge $data
             // into the root of the response (rather than something sane like [ 'details' => $data ]).
             $this->dieRecoverableError($msg, null, $data, 'internal-error');
         }
         $result['result'] = 'Success';
     }
     $result['filename'] = $file->getName();
     if ($warnings && count($warnings) > 0) {
         $result['warnings'] = $warnings;
     }
     return $result;
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:65,代码来源:ApiUpload.php

示例4: performUpload

 /**
  * Perform the actual upload. Returns a suitable result array on success;
  * dies on failure.
  *
  * @param array $warnings Array of Api upload warnings
  * @return array
  */
 protected function performUpload($warnings)
 {
     // Use comment as initial page text by default
     if (is_null($this->mParams['text'])) {
         $this->mParams['text'] = $this->mParams['comment'];
     }
     /** @var $file File */
     $file = $this->mUpload->getLocalFile();
     // For preferences mode, we want to watch if 'watchdefault' is set or
     // if the *file* doesn't exist and 'watchcreations' is set. But
     // getWatchlistValue()'s automatic handling checks if the *title*
     // exists or not, so we need to check both prefs manually.
     $watch = $this->getWatchlistValue($this->mParams['watchlist'], $file->getTitle(), 'watchdefault');
     if (!$watch && $this->mParams['watchlist'] == 'preferences' && !$file->exists()) {
         $watch = $this->getWatchlistValue($this->mParams['watchlist'], $file->getTitle(), 'watchcreations');
     }
     // Deprecated parameters
     if ($this->mParams['watch']) {
         $watch = true;
     }
     // No errors, no warnings: do the upload
     if ($this->mParams['async']) {
         $progress = UploadBase::getSessionStatus($this->mParams['filekey']);
         if ($progress && $progress['result'] === 'Poll') {
             $this->dieUsage("Upload from stash already in progress.", 'publishfailed');
         }
         UploadBase::setSessionStatus($this->mParams['filekey'], array('result' => 'Poll', 'stage' => 'queued', 'status' => Status::newGood()));
         $ok = JobQueueGroup::singleton()->push(new PublishStashedFileJob(Title::makeTitle(NS_FILE, $this->mParams['filename']), array('filename' => $this->mParams['filename'], 'filekey' => $this->mParams['filekey'], 'comment' => $this->mParams['comment'], 'text' => $this->mParams['text'], 'watch' => $watch, 'session' => $this->getContext()->exportSession())));
         if ($ok) {
             $result['result'] = 'Poll';
         } else {
             UploadBase::setSessionStatus($this->mParams['filekey'], false);
             $this->dieUsage("Failed to start PublishStashedFile.php", 'publishfailed');
         }
     } else {
         /** @var $status Status */
         $status = $this->mUpload->performUpload($this->mParams['comment'], $this->mParams['text'], $watch, $this->getUser());
         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
                 return array('result' => 'Queued', 'statuskey' => $error[0][1]);
             }
             $this->getResult()->setIndexedTagName($error, 'error');
             $this->dieUsage('An internal error occurred', 'internal-error', 0, $error);
         }
         $result['result'] = 'Success';
     }
     $result['filename'] = $file->getName();
     if ($warnings && count($warnings) > 0) {
         $result['warnings'] = $warnings;
     }
     return $result;
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:62,代码来源:ApiUpload.php

示例5: performUpload

 /**
  * Wrapper around the parent function in order to defer uploading to the
  * job queue for asynchronous uploads
  */
 public function performUpload($comment, $pageText, $watch, $user)
 {
     if ($this->mAsync) {
         $sessionKey = $this->insertJob($comment, $pageText, $watch, $user);
         return Status::newFatal('async', $sessionKey);
     }
     return parent::performUpload($comment, $pageText, $watch, $user);
 }
开发者ID:laiello,项目名称:media-wiki-law,代码行数:12,代码来源:UploadFromUrl.php

示例6: performUpload

 /**
  * Perform the upload, then remove the database record afterward.
  * @param string $comment
  * @param string $pageText
  * @param bool $watch
  * @param User $user
  * @return Status
  */
 public function performUpload($comment, $pageText, $watch, $user)
 {
     $rv = parent::performUpload($comment, $pageText, $watch, $user);
     $this->unsaveUploadedFile();
     return $rv;
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:14,代码来源:UploadFromStash.php

示例7: performUpload

 /**
  * Wrapper around the parent function in order to defer uploading to the
  * job queue for asynchronous uploads
  */
 public function performUpload($comment, $pageText, $watch, $user)
 {
     if ($this->mAsync) {
         $sessionKey = $this->insertJob($comment, $pageText, $watch, $user);
         $status = new Status();
         $status->error('async', $sessionKey);
         return $status;
     }
     return parent::performUpload($comment, $pageText, $watch, $user);
 }
开发者ID:GodelDesign,项目名称:Godel,代码行数:14,代码来源:UploadFromUrl.php

示例8: uploadImage

 /**
  * @param UploadBase $upload
  * @return array
  */
 private function uploadImage($upload)
 {
     global $wgRequest, $wgUser, $wgEnableUploads;
     $uploadStatus = array("status" => "error");
     if (empty($wgEnableUploads)) {
         $uploadStatus["errors"] = [wfMessage('themedesigner-upload-disabled')->plain()];
     } else {
         $upload->initializeFromRequest($wgRequest);
         $permErrors = $upload->verifyPermissions($wgUser);
         if ($permErrors !== true) {
             $uploadStatus["errors"] = array(wfMsg('badaccess'));
         } else {
             $details = $upload->verifyUpload();
             if ($details['status'] != UploadBase::OK) {
                 $uploadStatus["errors"] = array($this->getUploadErrorMessage($details));
             } else {
                 $warnings = $upload->checkWarnings();
                 if (!empty($warnings)) {
                     $uploadStatus["errors"] = $this->getUploadWarningMessages($warnings);
                 } else {
                     //save temp file
                     $status = $upload->performUpload();
                     $uploadStatus["status"] = "uploadattempted";
                     $uploadStatus["isGood"] = $status->isGood();
                 }
             }
         }
     }
     return $uploadStatus;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:34,代码来源:ThemeDesignerController.class.php


注:本文中的UploadBase::performUpload方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。