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


PHP UploadBase类代码示例

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


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

示例1: onUploadComplete

 public static function onUploadComplete(UploadBase $oForm)
 {
     wfProfileIn(__METHOD__);
     $oLocalFile = $oForm->getLocalFile();
     $oScribeProducer = new ScribeEventProducer('edit');
     if ($oScribeProducer->buildEditPackage(self::$oPage, self::$oUser, self::$oRevision, null, $oLocalFile)) {
         $oScribeProducer->sendLog();
     }
     wfProfileOut(__METHOD__);
     return true;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:11,代码来源:ScribeEventProducerController.class.php

示例2: loadRequest

 private function loadRequest($request)
 {
     global $wgUser;
     $this->mRequest = $request;
     $this->mAction = $request->getInt(ADD_RESOURCE_ACTION_FIELD);
     switch ($this->mAction) {
         case ADD_RESOURCE_ACTION_UPLOAD:
             $this->mUpload = UploadBase::createFromRequest($request);
             # used by copied processUpload()
             $this->mUploadClicked = true;
             $this->mComment = $request->getVal('wpUploadDescription');
             break;
         case ADD_RESOURCE_ACTION_SUBPAGE:
             $this->mSubpageDest = $request->getVal('wpSubpageDest');
             break;
         case ADD_RESOURCE_ACTION_LINK:
             $this->mLinkUrl = $request->getVal('wpLinkUrl');
             $this->mLinkTitle = $request->getVal('wpLinkTitle');
             $this->mLinkDesc = $request->getVal('wpLinkDesc');
             break;
         default:
             break;
     }
     $this->mTokenOk = $wgUser->matchEditToken($request->getVal('wpEditToken'));
     $this->mCancelUpload = false;
 }
开发者ID:n0g,项目名称:AddResource,代码行数:26,代码来源:SpecialAddResource.php

示例3: checkPermission

 protected function checkPermission()
 {
     $permissionRequired = UploadBase::isAllowed($this->getUser());
     if ($permissionRequired !== true) {
         throw new PermissionsError($permissionRequired);
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:7,代码来源:WikiaVideoAdd_body.php

示例4: onSkinTemplateNavigation

 /**
  * Add "replace" button to File pages
  * Add "remove" action to MenuButtons on premium video file pages
  * This button will remove a video from a wiki but keep it on the Video Wiki.
  */
 public static function onSkinTemplateNavigation($skin, &$tabs)
 {
     global $wgUser;
     $app = F::app();
     $title = $app->wg->Title;
     if ($title instanceof Title && $title->getNamespace() == NS_FILE && $title->exists()) {
         $file = wfFindFile($title);
         if ($file instanceof File && UploadBase::userCanReUpload($wgUser, $file->getName())) {
             if (WikiaFileHelper::isFileTypeVideo($file)) {
                 $uploadTitle = SpecialPage::getTitleFor('WikiaVideoAdd');
                 $href = $uploadTitle->getFullURL(array('name' => $file->getName()));
             } else {
                 $uploadTitle = SpecialPage::getTitleFor('Upload');
                 $href = $uploadTitle->getFullURL(array('wpDestFile' => $file->getName(), 'wpForReUpload' => 1));
             }
             $tabs['actions']['replace-file'] = array('class' => 'replace-file', 'text' => wfMessage('file-page-replace-button'), 'href' => $href);
         }
     }
     // Ignore Video Wiki videos beyond this point
     if ($app->wg->CityId == self::VIDEO_WIKI) {
         return true;
     }
     if (WikiaFileHelper::isFileTypeVideo($title)) {
         $file = wfFindFile($title);
         if (!$file->isLocal()) {
             // Prevent move tab being shown.
             unset($tabs['actions']['move']);
         }
     }
     return true;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:36,代码来源:FilePageHooks.class.php

示例5: run

 public function run()
 {
     $scope = RequestContext::importScopedSession($this->params['session']);
     $context = RequestContext::getMain();
     try {
         $user = $context->getUser();
         if (!$user->isLoggedIn()) {
             $this->setLastError("Could not load the author user from session.");
             return false;
         }
         if (count($_SESSION) === 0) {
             // Empty session probably indicates that we didn't associate
             // with the session correctly. Note that being able to load
             // the user does not necessarily mean the session was loaded.
             // Most likely cause by suhosin.session.encrypt = On.
             $this->setLastError("Error associating with user session. " . "Try setting suhosin.session.encrypt = Off");
             return false;
         }
         UploadBase::setSessionStatus($this->params['filekey'], array('result' => 'Poll', 'stage' => 'publish', 'status' => Status::newGood()));
         $upload = new UploadFromStash($user);
         // @todo initialize() causes a GET, ideally we could frontload the antivirus
         // checks and anything else to the stash stage (which includes concatenation and
         // the local file is thus already there). That way, instead of GET+PUT, there could
         // just be a COPY operation from the stash to the public zone.
         $upload->initialize($this->params['filekey'], $this->params['filename']);
         // Check if the local file checks out (this is generally a no-op)
         $verification = $upload->verifyUpload();
         if ($verification['status'] !== UploadBase::OK) {
             $status = Status::newFatal('verification-error');
             $status->value = array('verification' => $verification);
             UploadBase::setSessionStatus($this->params['filekey'], array('result' => 'Failure', 'stage' => 'publish', 'status' => $status));
             $this->setLastError("Could not verify upload.");
             return false;
         }
         // Upload the stashed file to a permanent location
         $status = $upload->performUpload($this->params['comment'], $this->params['text'], $this->params['watch'], $user);
         if (!$status->isGood()) {
             UploadBase::setSessionStatus($this->params['filekey'], array('result' => 'Failure', 'stage' => 'publish', 'status' => $status));
             $this->setLastError($status->getWikiText());
             return false;
         }
         // Build the image info array while we have the local reference handy
         $apiMain = new ApiMain();
         // dummy object (XXX)
         $imageInfo = $upload->getImageInfo($apiMain->getResult());
         // Cleanup any temporary local file
         $upload->cleanupTempFile();
         // Cache the info so the user doesn't have to wait forever to get the final info
         UploadBase::setSessionStatus($this->params['filekey'], array('result' => 'Success', 'stage' => 'publish', 'filename' => $upload->getLocalFile()->getName(), 'imageinfo' => $imageInfo, 'status' => Status::newGood()));
     } catch (MWException $e) {
         UploadBase::setSessionStatus($this->params['filekey'], array('result' => 'Failure', 'stage' => 'publish', 'status' => Status::newFatal('api-error-publishfailed')));
         $this->setLastError(get_class($e) . ": " . $e->getText());
         // To prevent potential database referential integrity issues.
         // See bug 32551.
         MWExceptionHandler::rollbackMasterChangesAndLog($e);
         return false;
     }
     return true;
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:59,代码来源:PublishStashedFileJob.php

示例6: isUploadEnabled

 function isUploadEnabled()
 {
     if (\UploadBase::isEnabled() == true) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:mediawiki-extensions,项目名称:mediawiki-page-attachment,代码行数:8,代码来源:AbstractUploadPermissionChecker.php

示例7: isUploadAllowed

 function isUploadAllowed()
 {
     global $wgUser;
     if (\UploadBase::isAllowed($wgUser) == true) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:mediawiki-extensions,项目名称:mediawiki-page-attachment,代码行数:9,代码来源:UploadPermissionChecker_MediaWiki_v1170.php

示例8: uploadImage

 /**
  * Handle image upload
  *
  * Returns array with uploaded files details or error details
  */
 public function uploadImage($uploadFieldName = self::DEFAULT_FILE_FIELD_NAME, $destFileName = null, $forceOverwrite = false)
 {
     global $IP, $wgRequest, $wgUser;
     wfProfileIn(__METHOD__);
     $ret = false;
     // check whether upload is enabled (RT #53714)
     if (!WikiaPhotoGalleryHelper::isUploadAllowed()) {
         $ret = array('error' => true, 'message' => wfMsg('uploaddisabled'));
         wfProfileOut(__METHOD__);
         return $ret;
     }
     $imageName = stripslashes(!empty($destFileName) ? $destFileName : $wgRequest->getFileName($uploadFieldName));
     // validate name and content of uploaded photo
     $nameValidation = $this->checkImageName($imageName, $uploadFieldName);
     if ($nameValidation == UploadBase::SUCCESS) {
         // get path to uploaded image
         $imagePath = $wgRequest->getFileTempName($uploadFieldName);
         // check if image with this name is already uploaded
         if ($this->imageExists($imageName) && !$forceOverwrite) {
             // upload as temporary file
             $this->log(__METHOD__, "image '{$imageName}' already exists!");
             $tempName = $this->tempFileName($wgUser);
             $title = Title::makeTitle(NS_FILE, $tempName);
             $localRepo = RepoGroup::singleton()->getLocalRepo();
             $file = new FakeLocalFile($title, $localRepo);
             $file->upload($wgRequest->getFileTempName($uploadFieldName), '', '');
             // store uploaded image in GarbageCollector (image will be removed if not used)
             $tempId = $this->tempFileStoreInfo($tempName);
             // generate thumbnail (to fit 200x200 box) of temporary file
             $width = min(WikiaPhotoGalleryHelper::thumbnailMaxWidth, $file->width);
             $height = min(WikiaPhotoGalleryHelper::thumbnailMaxHeight, $file->height);
             $thumbnail = $file->transform(array('height' => $height, 'width' => $width));
             // split uploaded file name into name + extension (foo-bar.png => foo-bar + png)
             list($fileName, $extensionsName) = UploadBase::splitExtensions($imageName);
             $extensionName = !empty($extensionsName) ? end($extensionsName) : '';
             $this->log(__METHOD__, 'upload successful');
             $ret = array('conflict' => true, 'name' => $imageName, 'nameParts' => array($fileName, $extensionName), 'tempId' => $tempId, 'size' => array('height' => $file->height, 'width' => $file->width), 'thumbnail' => array('height' => $thumbnail->height, 'url' => $thumbnail->url, 'width' => $thumbnail->width));
         } else {
             // use regular MW upload
             $this->log(__METHOD__, "image '{$imageName}' is new one - uploading as MW file");
             $this->log(__METHOD__, "uploading '{$imagePath}' as File:{$imageName}");
             // create title and file objects for MW image to create
             $imageTitle = Title::newFromText($imageName, NS_FILE);
             $imageFile = new LocalFile($imageTitle, RepoGroup::singleton()->getLocalRepo());
             // perform upload
             $result = $imageFile->upload($imagePath, '', '');
             $this->log(__METHOD__, !empty($result->ok) ? 'upload successful' : 'upload failed');
             $ret = array('success' => !empty($result->ok), 'name' => $imageName, 'size' => array('height' => !empty($result->ok) ? $imageFile->getHeight() : 0, 'width' => !empty($result->ok) ? $imageFile->getWidth() : 0));
         }
     } else {
         $reason = $nameValidation;
         $this->log(__METHOD__, "upload failed - file name is not valid (error #{$reason})");
         $ret = array('error' => true, 'reason' => $reason, 'message' => $this->translateError($reason));
     }
     wfProfileOut(__METHOD__);
     return $ret;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:62,代码来源:WikiaPhotoGalleryUpload.class.php

示例9: 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

示例10: run

 public function run()
 {
     $scope = RequestContext::importScopedSession($this->params['session']);
     $this->addTeardownCallback(function () use(&$scope) {
         ScopedCallback::consume($scope);
         // T126450
     });
     $context = RequestContext::getMain();
     $user = $context->getUser();
     try {
         if (!$user->isLoggedIn()) {
             $this->setLastError("Could not load the author user from session.");
             return false;
         }
         UploadBase::setSessionStatus($user, $this->params['filekey'], ['result' => 'Poll', 'stage' => 'publish', 'status' => Status::newGood()]);
         $upload = new UploadFromStash($user);
         // @todo initialize() causes a GET, ideally we could frontload the antivirus
         // checks and anything else to the stash stage (which includes concatenation and
         // the local file is thus already there). That way, instead of GET+PUT, there could
         // just be a COPY operation from the stash to the public zone.
         $upload->initialize($this->params['filekey'], $this->params['filename']);
         // Check if the local file checks out (this is generally a no-op)
         $verification = $upload->verifyUpload();
         if ($verification['status'] !== UploadBase::OK) {
             $status = Status::newFatal('verification-error');
             $status->value = ['verification' => $verification];
             UploadBase::setSessionStatus($user, $this->params['filekey'], ['result' => 'Failure', 'stage' => 'publish', 'status' => $status]);
             $this->setLastError("Could not verify upload.");
             return false;
         }
         // Upload the stashed file to a permanent location
         $status = $upload->performUpload($this->params['comment'], $this->params['text'], $this->params['watch'], $user, isset($this->params['tags']) ? $this->params['tags'] : []);
         if (!$status->isGood()) {
             UploadBase::setSessionStatus($user, $this->params['filekey'], ['result' => 'Failure', 'stage' => 'publish', 'status' => $status]);
             $this->setLastError($status->getWikiText(false, false, 'en'));
             return false;
         }
         // Build the image info array while we have the local reference handy
         $apiMain = new ApiMain();
         // dummy object (XXX)
         $imageInfo = $upload->getImageInfo($apiMain->getResult());
         // Cleanup any temporary local file
         $upload->cleanupTempFile();
         // Cache the info so the user doesn't have to wait forever to get the final info
         UploadBase::setSessionStatus($user, $this->params['filekey'], ['result' => 'Success', 'stage' => 'publish', 'filename' => $upload->getLocalFile()->getName(), 'imageinfo' => $imageInfo, 'status' => Status::newGood()]);
     } catch (Exception $e) {
         UploadBase::setSessionStatus($user, $this->params['filekey'], ['result' => 'Failure', 'stage' => 'publish', 'status' => Status::newFatal('api-error-publishfailed')]);
         $this->setLastError(get_class($e) . ": " . $e->getMessage());
         // To prevent potential database referential integrity issues.
         // See bug 32551.
         MWExceptionHandler::rollbackMasterChangesAndLog($e);
         return false;
     }
     return true;
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:55,代码来源:PublishStashedFileJob.php

示例11: verifyUpload

 /**
  * @return array
  */
 public function verifyUpload()
 {
     # Check for a post_max_size or upload_max_size overflow, so that a
     # proper error can be shown to the user
     if (is_null($this->mTempPath) || $this->isEmptyFile()) {
         if ($this->mUpload->isIniSizeOverflow()) {
             return array('status' => UploadBase::FILE_TOO_LARGE, 'max' => min(self::getMaxUploadSize($this->getSourceType()), wfShorthandToInteger(ini_get('upload_max_filesize')), wfShorthandToInteger(ini_get('post_max_size'))));
         }
     }
     return parent::verifyUpload();
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:14,代码来源:UploadFromFile.php

示例12: run

 public function run()
 {
     $scope = RequestContext::importScopedSession($this->params['session']);
     $context = RequestContext::getMain();
     try {
         $user = $context->getUser();
         if (!$user->isLoggedIn()) {
             $this->setLastError("Could not load the author user from session.");
             return false;
         }
         if (count($_SESSION) === 0) {
             // Empty session probably indicates that we didn't associate
             // with the session correctly. Note that being able to load
             // the user does not necessarily mean the session was loaded.
             // Most likely cause by suhosin.session.encrypt = On.
             $this->setLastError("Error associating with user session. " . "Try setting suhosin.session.encrypt = Off");
             return false;
         }
         UploadBase::setSessionStatus($this->params['filekey'], array('result' => 'Poll', 'stage' => 'assembling', 'status' => Status::newGood()));
         $upload = new UploadFromChunks($user);
         $upload->continueChunks($this->params['filename'], $this->params['filekey'], $context->getRequest());
         // Combine all of the chunks into a local file and upload that to a new stash file
         $status = $upload->concatenateChunks();
         if (!$status->isGood()) {
             UploadBase::setSessionStatus($this->params['filekey'], array('result' => 'Failure', 'stage' => 'assembling', 'status' => $status));
             $this->setLastError($status->getWikiText());
             return false;
         }
         // We have a new filekey for the fully concatenated file
         $newFileKey = $upload->getLocalFile()->getFileKey();
         // Remove the old stash file row and first chunk file
         $upload->stash->removeFileNoAuth($this->params['filekey']);
         // Build the image info array while we have the local reference handy
         $apiMain = new ApiMain();
         // dummy object (XXX)
         $imageInfo = $upload->getImageInfo($apiMain->getResult());
         // Cleanup any temporary local file
         $upload->cleanupTempFile();
         // Cache the info so the user doesn't have to wait forever to get the final info
         UploadBase::setSessionStatus($this->params['filekey'], array('result' => 'Success', 'stage' => 'assembling', 'filekey' => $newFileKey, 'imageinfo' => $imageInfo, 'status' => Status::newGood()));
     } catch (MWException $e) {
         UploadBase::setSessionStatus($this->params['filekey'], array('result' => 'Failure', 'stage' => 'assembling', 'status' => Status::newFatal('api-error-stashfailed')));
         $this->setLastError(get_class($e) . ": " . $e->getText());
         // To be extra robust.
         MWExceptionHandler::rollbackMasterChangesAndLog($e);
         return false;
     }
     return true;
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:49,代码来源:AssembleUploadChunksJob.php

示例13: loadRequest

 /**
  * Initialize instance variables from request and create an Upload handler
  *
  * @param WebRequest $request The request to extract variables from
  */
 protected function loadRequest($request)
 {
     global $wgUser, $wgMaxUploadFiles;
     // let's make the parent happy
     wfSuppressWarnings();
     $_FILES['wpUploadFile'] = $_FILES['wpUploadFile0'];
     wfRestoreWarnings();
     // Guess the desired name from the filename if not provided
     $this->mDesiredDestNames = array();
     $this->mUploads = array();
     // deal with session keys, if we have some pick the first one, for now
     $vals = $request->getValues();
     $fromsession = false;
     foreach ($vals as $k => $v) {
         if (preg_match("@^wpSessionKey@", $k)) {
             $request->setVal('wpSessionKey', $v);
             $fromsession = true;
             $filenum = preg_replace("@wpSessionKey@", '', $k);
             $request->setVal('wpDestFile', $request->getVal('wpDestFile' . $filenum));
             $up = UploadBase::createFromRequest($request);
             $this->mUploads[] = $up;
             $this->mDesiredDestNames[] = $request->getVal('wpDestFile' . $filenum);
         }
     }
     parent::loadRequest($request);
     $this->mUploadClicked = $request->wasPosted() && ($request->getCheck('wpUpload') || $request->getCheck('wpUploadIgnoreWarning'));
     if (!$fromsession) {
         for ($i = 0; $i < $wgMaxUploadFiles; $i++) {
             $this->mDesiredDestNames[$i] = $request->getText('wpDestFile' . $i);
             if (!$this->mDesiredDestNames[$i] && $request->getFileName('wpUploadFile' . $i) !== null) {
                 $this->mDesiredDestNames[$i] = $request->getFileName('wpUploadFile' . $i);
             }
             wfSuppressWarnings();
             $request->setVal('wpUploadFile', $_FILES['wpUploadFile' . $i]);
             wfRestoreWarnings();
             $request->setVal('wpDestFile', $request->getVal('wpDestFile' . $i));
             move_uploaded_file('wpUploadFile' . $i, 'wpUploadFile');
             wfSuppressWarnings();
             $_FILES['wpUploadFile'] = $_FILES['wpUploadFile' . $i];
             wfRestoreWarnings();
             $up = UploadBase::createFromRequest($request);
             if ($up) {
                 $this->mUploads[] = $up;
             }
         }
     }
     $this->mDesiredDestName = $this->mDesiredDestNames[0];
     $this->mUpload = $this->mUploads[0];
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:54,代码来源:MultiUpload.body.php

示例14: run

 public function run()
 {
     $scope = RequestContext::importScopedSession($this->params['session']);
     $this->addTeardownCallback(function () use(&$scope) {
         ScopedCallback::consume($scope);
         // T126450
     });
     $context = RequestContext::getMain();
     $user = $context->getUser();
     try {
         if (!$user->isLoggedIn()) {
             $this->setLastError("Could not load the author user from session.");
             return false;
         }
         UploadBase::setSessionStatus($user, $this->params['filekey'], ['result' => 'Poll', 'stage' => 'assembling', 'status' => Status::newGood()]);
         $upload = new UploadFromChunks($user);
         $upload->continueChunks($this->params['filename'], $this->params['filekey'], new WebRequestUpload($context->getRequest(), 'null'));
         // Combine all of the chunks into a local file and upload that to a new stash file
         $status = $upload->concatenateChunks();
         if (!$status->isGood()) {
             UploadBase::setSessionStatus($user, $this->params['filekey'], ['result' => 'Failure', 'stage' => 'assembling', 'status' => $status]);
             $this->setLastError($status->getWikiText(false, false, 'en'));
             return false;
         }
         // We can only get warnings like 'duplicate' after concatenating the chunks
         $status = Status::newGood();
         $status->value = ['warnings' => $upload->checkWarnings()];
         // We have a new filekey for the fully concatenated file
         $newFileKey = $upload->getStashFile()->getFileKey();
         // Remove the old stash file row and first chunk file
         $upload->stash->removeFileNoAuth($this->params['filekey']);
         // Build the image info array while we have the local reference handy
         $apiMain = new ApiMain();
         // dummy object (XXX)
         $imageInfo = $upload->getImageInfo($apiMain->getResult());
         // Cleanup any temporary local file
         $upload->cleanupTempFile();
         // Cache the info so the user doesn't have to wait forever to get the final info
         UploadBase::setSessionStatus($user, $this->params['filekey'], ['result' => 'Success', 'stage' => 'assembling', 'filekey' => $newFileKey, 'imageinfo' => $imageInfo, 'status' => $status]);
     } catch (Exception $e) {
         UploadBase::setSessionStatus($user, $this->params['filekey'], ['result' => 'Failure', 'stage' => 'assembling', 'status' => Status::newFatal('api-error-stashfailed')]);
         $this->setLastError(get_class($e) . ": " . $e->getMessage());
         // To be extra robust.
         MWExceptionHandler::rollbackMasterChangesAndLog($e);
         return false;
     }
     return true;
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:48,代码来源:AssembleUploadChunksJob.php

示例15: loadFile

 function loadFile($type)
 {
     global $wgRequest, $wgUser;
     $ext = $type;
     $file_name = "Drawio_" . $wgRequest->getVal('drawio') . "." . $ext;
     $wgRequest->setVal('wpDestFile', $file_name);
     $wgRequest->setVal('wpIgnoreWarning', '1');
     $wgRequest->setVal('wpDestFileWarningAck', '1');
     $wgRequest->setVal('wpUploadDescription', "");
     $wgRequest->setVal('action', "");
     if ($type == "png") {
         $file_type = "image/png";
         $pngval = $wgRequest->getVal($type);
         $comma_pos = strpos($pngval, ',');
         if ($comma_pos === false) {
             $file_body = stripslashes($pngval);
         } else {
             $file_body = base64_decode(substr($pngval, $comma_pos + 1));
         }
     } else {
         $file_type = "text/xml";
         $file_body = $wgRequest->getVal($type);
     }
     $file_len = strlen($file_body);
     if ($file_len > 0) {
         $_FILES['wpUploadFile']['name'] = $file_name;
         $_FILES['wpUploadFile']['type'] = $file_type;
         $_FILES['wpUploadFile']['error'] = 0;
         $_FILES['wpUploadFile']['size'] = $file_len;
         // $tmp_name = $_SERVER["DOCUMENT_ROOT"] . "tmp/tmp_".rand(0,1000).rand(0,1000).".".$ext;
         $tmp_name = wfTempDir() . "tmp_" . rand(0, 1000) . rand(0, 1000) . "." . $ext;
         $f = fopen($tmp_name, "w");
         fwrite($f, $file_body);
         fclose($f);
         $_FILES['wpUploadFile']['tmp_name'] = $tmp_name;
         // Upload
         $form = UploadBase::createFromRequest($wgRequest, null);
         $outcome = $form->verifyUpload();
         $res = $form->performUpload("", "", true, $wgUser);
         if (file_exists($tmp_name)) {
             unlink($tmp_name);
         }
     }
     // $outcome['request'] = $wgRequest;
     // $outcome['form'] = $form;
     return $outcome;
 }
开发者ID:tosher,项目名称:wiki_drawio,代码行数:47,代码来源:Drawio.body.php


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