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


PHP PhabricatorFile::readUploadedFileData方法代码示例

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


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

示例1: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     if ($request->isFormPost()) {
         $parser = new ArcanistDiffParser();
         $diff = null;
         try {
             $diff = PhabricatorFile::readUploadedFileData($_FILES['diff-file']);
         } catch (Exception $ex) {
             $diff = $request->getStr('diff');
         }
         $changes = $parser->parseDiff($diff);
         $diff = DifferentialDiff::newFromRawChanges($changes);
         $diff->setLintStatus(DifferentialLintStatus::LINT_SKIP);
         $diff->setUnitStatus(DifferentialLintStatus::LINT_SKIP);
         $diff->setAuthorPHID($request->getUser()->getPHID());
         $diff->setCreationMethod('web');
         $diff->save();
         return id(new AphrontRedirectResponse())->setURI('/differential/diff/' . $diff->getID() . '/');
     }
     $form = new AphrontFormView();
     $arcanist_href = PhabricatorEnv::getDoclink('article/Arcanist_User_Guide.html');
     $arcanist_link = phutil_render_tag('a', array('href' => $arcanist_href, 'target' => '_blank'), 'Arcanist');
     $form->setAction('/differential/diff/create/')->setEncType('multipart/form-data')->setUser($request->getUser())->appendChild('<p class="aphront-form-instructions">The best way to create a ' . "Differential diff is by using {$arcanist_link}, but you " . 'can also just paste a diff (e.g., from <tt>svn diff</tt> or ' . '<tt>git diff</tt>) into this box or upload it as a file if you ' . 'really want.</p>')->appendChild(id(new AphrontFormTextAreaControl())->setLabel('Raw Diff')->setName('diff')->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL))->appendChild(id(new AphrontFormFileControl())->setLabel('Raw Diff from file')->setName('diff-file'))->appendChild(id(new AphrontFormSubmitControl())->setValue("Create Diff »"));
     $panel = new AphrontPanelView();
     $panel->setHeader('Create New Diff');
     $panel->appendChild($form);
     $panel->setWidth(AphrontPanelView::WIDTH_FORM);
     return $this->buildStandardPageResponse($panel, array('title' => 'Create Diff', 'tab' => 'create'));
 }
开发者ID:netcomtec,项目名称:phabricator,代码行数:30,代码来源:DifferentialDiffCreateController.php

示例2: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $errors = array();
     $e_diff = null;
     $e_file = null;
     if ($request->isFormPost()) {
         $diff = null;
         if ($request->getFileExists('diff-file')) {
             $diff = PhabricatorFile::readUploadedFileData($_FILES['diff-file']);
         } else {
             $diff = $request->getStr('diff');
         }
         if (!strlen($diff)) {
             $errors[] = pht('You can not create an empty diff. Copy/paste a diff, or upload a ' . 'diff file.');
             $e_diff = pht('Required');
             $e_file = pht('Required');
         }
         if (!$errors) {
             $call = new ConduitCall('differential.createrawdiff', array('diff' => $diff));
             $call->setUser($request->getUser());
             $result = $call->execute();
             $path = id(new PhutilURI($result['uri']))->getPath();
             return id(new AphrontRedirectResponse())->setURI($path);
         }
     }
     $form = new AphrontFormView();
     $arcanist_href = PhabricatorEnv::getDoclink('Arcanist User Guide');
     $arcanist_link = phutil_tag('a', array('href' => $arcanist_href, 'target' => '_blank'), 'Arcanist');
     $cancel_uri = $this->getApplicationURI();
     $form->setAction('/differential/diff/create/')->setEncType('multipart/form-data')->setUser($request->getUser())->appendInstructions(pht('The best way to create a Differential diff is by using %s, but you ' . 'can also just paste a diff (for example, from %s, %s or %s) into ' . 'this box, or upload a diff file.', $arcanist_link, phutil_tag('tt', array(), 'svn diff'), phutil_tag('tt', array(), 'git diff'), phutil_tag('tt', array(), 'hg diff --git')))->appendChild(id(new AphrontFormTextAreaControl())->setLabel(pht('Raw Diff'))->setName('diff')->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL)->setError($e_diff))->appendChild(id(new AphrontFormFileControl())->setLabel(pht('Raw Diff From File'))->setName('diff-file')->setError($e_file))->appendChild(id(new AphrontFormSubmitControl())->addCancelButton($cancel_uri)->setValue(pht('Create Diff')));
     $form_box = id(new PHUIObjectBoxView())->setHeaderText(pht('Create New Diff'))->setForm($form)->setFormErrors($errors);
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb(pht('Create Diff'));
     return $this->buildApplicationPage(array($crumbs, $form_box), array('title' => pht('Create Diff')));
 }
开发者ID:denghp,项目名称:phabricator,代码行数:36,代码来源:DifferentialDiffCreateController.php

示例3: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $this->getViewer();
     // If we're on the "Update Diff" workflow, load the revision we're going
     // to update.
     $revision = null;
     $revision_id = $request->getURIData('revisionID');
     if ($revision_id) {
         $revision = id(new DifferentialRevisionQuery())->setViewer($viewer)->withIDs(array($revision_id))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
         if (!$revision) {
             return new Aphront404Response();
         }
     }
     $diff = null;
     // This object is just for policy stuff
     $diff_object = DifferentialDiff::initializeNewDiff($viewer);
     $repository_phid = null;
     $errors = array();
     $e_diff = null;
     $e_file = null;
     $validation_exception = null;
     if ($request->isFormPost()) {
         $repository_tokenizer = $request->getArr(id(new DifferentialRepositoryField())->getFieldKey());
         if ($repository_tokenizer) {
             $repository_phid = reset($repository_tokenizer);
         }
         if ($request->getFileExists('diff-file')) {
             $diff = PhabricatorFile::readUploadedFileData($_FILES['diff-file']);
         } else {
             $diff = $request->getStr('diff');
         }
         if (!strlen($diff)) {
             $errors[] = pht('You can not create an empty diff. Paste a diff or upload a ' . 'file containing a diff.');
             $e_diff = pht('Required');
             $e_file = pht('Required');
         }
         if (!$errors) {
             try {
                 $call = new ConduitCall('differential.createrawdiff', array('diff' => $diff, 'repositoryPHID' => $repository_phid, 'viewPolicy' => $request->getStr('viewPolicy')));
                 $call->setUser($viewer);
                 $result = $call->execute();
                 $diff_id = $result['id'];
                 $uri = $this->getApplicationURI("diff/{$diff_id}/");
                 $uri = new PhutilURI($uri);
                 if ($revision) {
                     $uri->setQueryParam('revisionID', $revision->getID());
                 }
                 return id(new AphrontRedirectResponse())->setURI($uri);
             } catch (PhabricatorApplicationTransactionValidationException $ex) {
                 $validation_exception = $ex;
             }
         }
     }
     $form = new AphrontFormView();
     $arcanist_href = PhabricatorEnv::getDoclink('Arcanist User Guide');
     $arcanist_link = phutil_tag('a', array('href' => $arcanist_href, 'target' => '_blank'), pht('Learn More'));
     $cancel_uri = $this->getApplicationURI();
     $policies = id(new PhabricatorPolicyQuery())->setViewer($viewer)->setObject($diff_object)->execute();
     $info_view = null;
     if (!$request->isFormPost()) {
         $info_view = id(new PHUIInfoView())->setSeverity(PHUIInfoView::SEVERITY_NOTICE)->setErrors(array(array(pht('The best way to create a diff is to use the Arcanist ' . 'command-line tool.'), ' ', $arcanist_link), pht('You can also paste a diff below, or upload a file ' . 'containing a diff (for example, from %s, %s or %s).', phutil_tag('tt', array(), 'svn diff'), phutil_tag('tt', array(), 'git diff'), phutil_tag('tt', array(), 'hg diff --git'))));
     }
     if ($revision) {
         $title = pht('Update Diff');
         $header = pht('Update Diff');
         $button = pht('Continue');
     } else {
         $title = pht('Create Diff');
         $header = pht('Create New Diff');
         $button = pht('Create Diff');
     }
     $form->setEncType('multipart/form-data')->setUser($viewer);
     if ($revision) {
         $form->appendChild(id(new AphrontFormMarkupControl())->setLabel(pht('Updating Revision'))->setValue($viewer->renderHandle($revision->getPHID())));
     }
     if ($repository_phid) {
         $repository_value = array($repository_phid);
     } else {
         $repository_value = array();
     }
     $form->appendChild(id(new AphrontFormTextAreaControl())->setLabel(pht('Raw Diff'))->setName('diff')->setValue($diff)->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL)->setError($e_diff))->appendChild(id(new AphrontFormFileControl())->setLabel(pht('Raw Diff From File'))->setName('diff-file')->setError($e_file))->appendControl(id(new AphrontFormTokenizerControl())->setName(id(new DifferentialRepositoryField())->getFieldKey())->setLabel(pht('Repository'))->setDatasource(new DiffusionRepositoryDatasource())->setValue($repository_value)->setLimit(1))->appendChild(id(new AphrontFormPolicyControl())->setUser($viewer)->setName('viewPolicy')->setPolicyObject($diff_object)->setPolicies($policies)->setCapability(PhabricatorPolicyCapability::CAN_VIEW))->appendChild(id(new AphrontFormSubmitControl())->addCancelButton($cancel_uri)->setValue($button));
     $form_box = id(new PHUIObjectBoxView())->setHeaderText($header)->setValidationException($validation_exception)->setForm($form)->setFormErrors($errors);
     if ($info_view) {
         $form_box->setInfoView($info_view);
     }
     $crumbs = $this->buildApplicationCrumbs();
     if ($revision) {
         $crumbs->addTextCrumb($revision->getMonogram(), '/' . $revision->getMonogram());
     }
     $crumbs->addTextCrumb($title);
     return $this->buildApplicationPage(array($crumbs, $form_box), array('title' => $title));
 }
开发者ID:pugong,项目名称:phabricator,代码行数:92,代码来源:DifferentialDiffCreateController.php


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