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


PHP PhabricatorContentSource::newFromRequest方法代码示例

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


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

示例1: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $viewer = $request->getUser();
     $user = id(new PhabricatorPeopleQuery())->setViewer($viewer)->withIDs(array($this->id))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
     if (!$user) {
         return new Aphront404Response();
     }
     $profile_uri = '/p/' . $user->getUsername() . '/';
     $field_list = PhabricatorCustomField::getObjectFields($user, PhabricatorCustomField::ROLE_EDIT);
     $field_list->setViewer($viewer)->readFieldsFromStorage($user);
     $validation_exception = null;
     if ($request->isFormPost()) {
         $xactions = $field_list->buildFieldTransactionsFromRequest(new PhabricatorUserTransaction(), $request);
         $editor = id(new PhabricatorUserProfileEditor())->setActor($viewer)->setContentSource(PhabricatorContentSource::newFromRequest($request))->setContinueOnNoEffect(true);
         try {
             $editor->applyTransactions($user, $xactions);
             return id(new AphrontRedirectResponse())->setURI($profile_uri);
         } catch (PhabricatorApplicationTransactionValidationException $ex) {
             $validation_exception = $ex;
         }
     }
     $title = pht('Edit Profile');
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb($user->getUsername(), $profile_uri);
     $crumbs->addTextCrumb($title);
     $form = id(new AphrontFormView())->setUser($viewer);
     $field_list->appendFieldsToForm($form);
     $form->appendChild(id(new AphrontFormSubmitControl())->addCancelButton($profile_uri)->setValue(pht('Save Profile')));
     $form_box = id(new PHUIObjectBoxView())->setHeaderText(pht('Edit Profile'))->setValidationException($validation_exception)->setForm($form);
     return $this->buildApplicationPage(array($crumbs, $form_box), array('title' => $title));
 }
开发者ID:denghp,项目名称:phabricator,代码行数:32,代码来源:PhabricatorPeopleProfileEditController.php

示例2: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $viewer = $request->getUser();
     $xaction = id(new PhabricatorObjectQuery())->withPHIDs(array($this->phid))->setViewer($viewer)->executeOne();
     if (!$xaction) {
         return new Aphront404Response();
     }
     if (!$xaction->getComment()) {
         return new Aphront404Response();
     }
     if ($xaction->getComment()->getIsRemoved()) {
         // You can't remove an already-removed comment.
         return new Aphront400Response();
     }
     $obj_phid = $xaction->getObjectPHID();
     $obj_handle = id(new PhabricatorHandleQuery())->setViewer($viewer)->withPHIDs(array($obj_phid))->executeOne();
     if ($request->isDialogFormPost()) {
         $comment = $xaction->getApplicationTransactionCommentObject()->setContent('')->setIsRemoved(true);
         $editor = id(new PhabricatorApplicationTransactionCommentEditor())->setActor($viewer)->setContentSource(PhabricatorContentSource::newFromRequest($request))->applyEdit($xaction, $comment);
         if ($request->isAjax()) {
             return id(new AphrontAjaxResponse())->setContent(array());
         } else {
             return id(new AphrontReloadResponse())->setURI($obj_handle->getURI());
         }
     }
     $form = id(new AphrontFormView())->setUser($viewer);
     $dialog = $this->newDialog()->setTitle(pht('Remove Comment'));
     $dialog->addHiddenInput('anchor', $request->getStr('anchor'))->appendParagraph(pht("Removing a comment prevents anyone (including you) from reading " . "it. Removing a comment also hides the comment's edit history " . "and prevents it from being edited."))->appendParagraph(pht('Really remove this comment?'));
     $dialog->addSubmitButton(pht('Remove Comment'))->addCancelButton($obj_handle->getURI());
     return $dialog;
 }
开发者ID:fengshao0907,项目名称:phabricator,代码行数:32,代码来源:PhabricatorApplicationTransactionCommentRemoveController.php

示例3: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $id = $request->getURIData('id');
     $initiative = id(new FundInitiativeQuery())->setViewer($viewer)->withIDs(array($id))->executeOne();
     if (!$initiative) {
         return new Aphront404Response();
     }
     $merchant = id(new PhortuneMerchantQuery())->setViewer($viewer)->withPHIDs(array($initiative->getMerchantPHID()))->executeOne();
     if (!$merchant) {
         return new Aphront404Response();
     }
     $initiative_uri = '/' . $initiative->getMonogram();
     if ($initiative->isClosed()) {
         return $this->newDialog()->setTitle(pht('Initiative Closed'))->appendParagraph(pht('You can not back a closed initiative.'))->addCancelButton($initiative_uri);
     }
     $accounts = PhortuneAccountQuery::loadAccountsForUser($viewer, PhabricatorContentSource::newFromRequest($request));
     $v_amount = null;
     $e_amount = true;
     $v_account = head($accounts)->getPHID();
     $errors = array();
     if ($request->isFormPost()) {
         $v_amount = $request->getStr('amount');
         $v_account = $request->getStr('accountPHID');
         if (empty($accounts[$v_account])) {
             $errors[] = pht('You must specify an account.');
         } else {
             $account = $accounts[$v_account];
         }
         if (!strlen($v_amount)) {
             $errors[] = pht('You must specify how much money you want to contribute to the ' . 'initiative.');
             $e_amount = pht('Required');
         } else {
             try {
                 $currency = PhortuneCurrency::newFromUserInput($viewer, $v_amount);
                 $currency->assertInRange('1.00 USD', null);
             } catch (Exception $ex) {
                 $errors[] = $ex->getMessage();
                 $e_amount = pht('Invalid');
             }
         }
         if (!$errors) {
             $backer = FundBacker::initializeNewBacker($viewer)->setInitiativePHID($initiative->getPHID())->attachInitiative($initiative)->setAmountAsCurrency($currency)->save();
             $product = id(new PhortuneProductQuery())->setViewer($viewer)->withClassAndRef('FundBackerProduct', $initiative->getPHID())->executeOne();
             $cart_implementation = id(new FundBackerCart())->setInitiative($initiative);
             $cart = $account->newCart($viewer, $cart_implementation, $merchant);
             $purchase = $cart->newPurchase($viewer, $product);
             $purchase->setBasePriceAsCurrency($currency)->setMetadataValue('backerPHID', $backer->getPHID())->save();
             $xactions = array();
             $xactions[] = id(new FundBackerTransaction())->setTransactionType(FundBackerTransaction::TYPE_STATUS)->setNewValue(FundBacker::STATUS_IN_CART);
             $editor = id(new FundBackerEditor())->setActor($viewer)->setContentSourceFromRequest($request);
             $editor->applyTransactions($backer, $xactions);
             $cart->activateCart();
             return id(new AphrontRedirectResponse())->setURI($cart->getCheckoutURI());
         }
     }
     $form = id(new AphrontFormView())->setUser($viewer)->appendChild(id(new AphrontFormSelectControl())->setName('accountPHID')->setLabel(pht('Account'))->setValue($v_account)->setOptions(mpull($accounts, 'getName', 'getPHID')))->appendChild(id(new AphrontFormTextControl())->setName('amount')->setLabel(pht('Amount'))->setValue($v_amount)->setError($e_amount));
     return $this->newDialog()->setTitle(pht('Back %s %s', $initiative->getMonogram(), $initiative->getName()))->setErrors($errors)->appendChild($form->buildLayoutView())->addCancelButton($initiative_uri)->addSubmitButton(pht('Continue'));
 }
开发者ID:pugong,项目名称:phabricator,代码行数:59,代码来源:FundInitiativeBackController.php

示例4: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $title = pht('New Message');
     $participants = array();
     $participant_prefill = null;
     $message = '';
     $e_participants = null;
     $e_message = null;
     // this comes from ajax requests from all over. should be a single phid.
     if ($request->isFormPost()) {
         $participants = $request->getArr('participants');
         $message = $request->getStr('message');
         list($error_codes, $conpherence) = ConpherenceEditor::createConpherence($user, $participants, $conpherence_title = null, $message, PhabricatorContentSource::newFromRequest($request));
         if ($error_codes) {
             foreach ($error_codes as $error_code) {
                 switch ($error_code) {
                     case ConpherenceEditor::ERROR_EMPTY_MESSAGE:
                         $e_message = true;
                         break;
                     case ConpherenceEditor::ERROR_EMPTY_PARTICIPANTS:
                         $e_participants = true;
                         break;
                 }
             }
         } else {
             $uri = $this->getApplicationURI($conpherence->getID());
             return id(new AphrontRedirectResponse())->setURI($uri);
         }
     } else {
         $participant_prefill = $request->getStr('participant');
         if ($participant_prefill) {
             $participants[] = $participant_prefill;
         }
     }
     $participant_handles = array();
     if ($participants) {
         $participant_handles = id(new PhabricatorHandleQuery())->setViewer($user)->withPHIDs($participants)->execute();
     }
     $submit_uri = $this->getApplicationURI('new/');
     $cancel_uri = $this->getApplicationURI();
     // TODO - we can get a better cancel_uri once we get better at crazy
     // ajax jonx T2086
     if ($participant_prefill) {
         $handle = $participant_handles[$participant_prefill];
         $cancel_uri = $handle->getURI();
     }
     $dialog = id(new AphrontDialogView())->setWidth(AphrontDialogView::WIDTH_FORM)->setUser($user)->setTitle($title)->addCancelButton($cancel_uri)->addSubmitButton(pht('Send Message'));
     $form = id(new PHUIFormLayoutView())->setUser($user)->setFullWidth(true)->appendChild(id(new AphrontFormTokenizerControl())->setName('participants')->setValue($participant_handles)->setUser($user)->setDatasource(new PhabricatorPeopleDatasource())->setLabel(pht('To'))->setError($e_participants))->appendChild(id(new PhabricatorRemarkupControl())->setName('message')->setValue($message)->setLabel(pht('Message'))->setError($e_message));
     $dialog->appendChild($form);
     return id(new AphrontDialogResponse())->setDialog($dialog);
 }
开发者ID:denghp,项目名称:phabricator,代码行数:53,代码来源:ConpherenceNewController.php

示例5: manageApplication

 public function manageApplication($issue)
 {
     $key = 'config.ignore-issues';
     $config_entry = PhabricatorConfigEntry::loadConfigEntry($key);
     $list = $config_entry->getValue();
     if (isset($list[$issue])) {
         unset($list[$issue]);
     } else {
         $list[$issue] = true;
     }
     PhabricatorConfigEditor::storeNewValue($this->getRequest()->getUser(), $config_entry, $list, PhabricatorContentSource::newFromRequest($this->getRequest()));
 }
开发者ID:pugong,项目名称:phabricator,代码行数:12,代码来源:PhabricatorConfigIgnoreController.php

示例6: manageApplication

 public function manageApplication()
 {
     $key = 'phabricator.uninstalled-applications';
     $config_entry = PhabricatorConfigEntry::loadConfigEntry($key);
     $list = $config_entry->getValue();
     $uninstalled = PhabricatorEnv::getEnvConfig($key);
     if (isset($uninstalled[$this->application])) {
         unset($list[$this->application]);
     } else {
         $list[$this->application] = true;
     }
     PhabricatorConfigEditor::storeNewValue($this->getViewer(), $config_entry, $list, PhabricatorContentSource::newFromRequest($this->getRequest()));
 }
开发者ID:pugong,项目名称:phabricator,代码行数:13,代码来源:PhabricatorApplicationUninstallController.php

示例7: handleActionRequest

 public function handleActionRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     // TODO: As above, this would eventually be driven by custom logic.
     if ($request->isFormPost()) {
         $properties = array('complaint' => (string) $request->getStr('complaint'));
         $content_source = PhabricatorContentSource::newFromRequest($request);
         $item = $this->newItemFromProperties($properties, $content_source);
         $uri = $item->getURI();
         return id(new AphrontRedirectResponse())->setURI($uri);
     }
     $form = id(new AphrontFormView())->setUser($viewer)->appendRemarkupInstructions(pht('IMPORTANT: This is a very rough prototype.'))->appendRemarkupInstructions(pht('Got a complaint? Complain here! We love complaints.'))->appendChild(id(new AphrontFormTextAreaControl())->setName('complaint')->setLabel(pht('Complaint')))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Submit Complaint')));
     $box = id(new PHUIObjectBoxView())->setHeaderText(pht('Complaint Form'))->appendChild($form);
     return $box;
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:15,代码来源:NuancePhabricatorFormSourceDefinition.php

示例8: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $accounts = id(new PhortuneAccountQuery())->setViewer($viewer)->withMemberPHIDs(array($viewer->getPHID()))->execute();
     if (!$accounts) {
         $account = PhortuneAccount::createNewAccount($viewer, PhabricatorContentSource::newFromRequest($request));
         $accounts = array($account);
     }
     if (count($accounts) == 1) {
         $account = head($accounts);
         $next_uri = $this->getApplicationURI($account->getID() . '/');
     } else {
         $next_uri = $this->getApplicationURI('account/');
     }
     return id(new AphrontRedirectResponse())->setURI($next_uri);
 }
开发者ID:pugong,项目名称:phabricator,代码行数:16,代码来源:PhortuneLandingController.php

示例9: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $user = $request->getUser();
     $title = pht('New Message');
     $participants = array();
     $participant_prefill = null;
     $message = '';
     $e_participants = null;
     $e_message = null;
     $errors = array();
     // this comes from ajax requests from all over. should be a single phid.
     if ($request->isFormPost()) {
         $participants = $request->getArr('participants');
         $message = $request->getStr('message');
         list($error_codes, $conpherence) = ConpherenceEditor::createThread($user, $participants, $conpherence_title = null, $message, PhabricatorContentSource::newFromRequest($request));
         if ($error_codes) {
             foreach ($error_codes as $error_code) {
                 switch ($error_code) {
                     case ConpherenceEditor::ERROR_EMPTY_MESSAGE:
                         $e_message = pht('Required');
                         $errors[] = pht('You can not send an empty message.');
                         break;
                     case ConpherenceEditor::ERROR_EMPTY_PARTICIPANTS:
                         $e_participants = pht('Required');
                         $errors[] = pht('You must choose at least one recipient for your ' . 'message.');
                         break;
                 }
             }
         } else {
             return id(new AphrontRedirectResponse())->setURI('/' . $conpherence->getMonogram());
         }
     } else {
         $participant_prefill = $request->getStr('participant');
         if ($participant_prefill) {
             $participants[] = $participant_prefill;
         }
     }
     $submit_uri = $this->getApplicationURI('new/');
     $cancel_uri = $this->getApplicationURI();
     $dialog = id(new AphrontDialogView())->setWidth(AphrontDialogView::WIDTH_FORM)->setErrors($errors)->setUser($user)->setTitle($title)->addCancelButton($cancel_uri)->addSubmitButton(pht('Send Message'));
     $form = id(new AphrontFormView())->setUser($user)->setFullWidth(true)->appendControl(id(new AphrontFormTokenizerControl())->setName('participants')->setValue($participants)->setUser($user)->setDatasource(new PhabricatorPeopleDatasource())->setLabel(pht('To'))->setError($e_participants))->appendChild(id(new PhabricatorRemarkupControl())->setUser($user)->setName('message')->setValue($message)->setLabel(pht('Message'))->setError($e_message));
     $dialog->appendForm($form);
     return id(new AphrontDialogResponse())->setDialog($dialog);
 }
开发者ID:hrb518,项目名称:phabricator,代码行数:44,代码来源:ConpherenceNewController.php

示例10: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $this->getViewer();
     $id = $request->getURIData('id');
     $user = id(new PhabricatorPeopleQuery())->setViewer($viewer)->withIDs(array($id))->needProfileImage(true)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
     if (!$user) {
         return new Aphront404Response();
     }
     $this->setUser($user);
     $done_uri = $this->getApplicationURI("manage/{$id}/");
     $field_list = PhabricatorCustomField::getObjectFields($user, PhabricatorCustomField::ROLE_EDIT);
     $field_list->setViewer($viewer)->readFieldsFromStorage($user);
     $validation_exception = null;
     if ($request->isFormPost()) {
         $xactions = $field_list->buildFieldTransactionsFromRequest(new PhabricatorUserTransaction(), $request);
         $editor = id(new PhabricatorUserProfileEditor())->setActor($viewer)->setContentSource(PhabricatorContentSource::newFromRequest($request))->setContinueOnNoEffect(true);
         try {
             $editor->applyTransactions($user, $xactions);
             return id(new AphrontRedirectResponse())->setURI($done_uri);
         } catch (PhabricatorApplicationTransactionValidationException $ex) {
             $validation_exception = $ex;
         }
     }
     $title = pht('Edit Profile');
     $form = id(new AphrontFormView())->setUser($viewer);
     $field_list->appendFieldsToForm($form);
     $form->appendChild(id(new AphrontFormSubmitControl())->addCancelButton($done_uri)->setValue(pht('Save Profile')));
     $allow_public = PhabricatorEnv::getEnvConfig('policy.allow-public');
     $note = null;
     if ($allow_public) {
         $note = id(new PHUIInfoView())->setSeverity(PHUIInfoView::SEVERITY_WARNING)->appendChild(pht('Information on user profiles on this install is publicly ' . 'visible.'));
     }
     $form_box = id(new PHUIObjectBoxView())->setHeaderText(pht('Edit Profile'))->setValidationException($validation_exception)->setForm($form);
     if ($note) {
         $form_box->setInfoView($note);
     }
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb(pht('Edit Profile'));
     $nav = $this->getProfileMenu();
     $nav->selectFilter(PhabricatorPeopleProfilePanelEngine::PANEL_MANAGE);
     return $this->newPage()->setTitle($title)->setCrumbs($crumbs)->setNavigation($nav)->appendChild($form_box);
 }
开发者ID:truSense,项目名称:phabricator,代码行数:42,代码来源:PhabricatorPeopleProfileEditController.php

示例11: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $viewer = $request->getUser();
     $dashboard = id(new PhabricatorDashboardQuery())->setViewer($viewer)->withIDs(array($this->id))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
     if (!$dashboard) {
         return new Aphront404Response();
     }
     $redirect_uri = $this->getApplicationURI('manage/' . $dashboard->getID() . '/');
     $v_panel = $request->getStr('panel');
     $e_panel = true;
     $errors = array();
     if ($request->isFormPost()) {
         if (strlen($v_panel)) {
             $panel = id(new PhabricatorDashboardPanelQuery())->setViewer($viewer)->withIDs(array($v_panel))->executeOne();
             if (!$panel) {
                 $errors[] = pht('No such panel!');
                 $e_panel = pht('Invalid');
             }
         } else {
             $errors[] = pht('Select a panel to add.');
             $e_panel = pht('Required');
         }
         if (!$errors) {
             PhabricatorDashboardTransactionEditor::addPanelToDashboard($viewer, PhabricatorContentSource::newFromRequest($request), $panel, $dashboard, $request->getInt('column', 0));
             return id(new AphrontRedirectResponse())->setURI($redirect_uri);
         }
     }
     $panels = id(new PhabricatorDashboardPanelQuery())->setViewer($viewer)->withArchived(false)->execute();
     if (!$panels) {
         return $this->newDialog()->setTitle(pht('No Panels Exist Yet'))->appendParagraph(pht('You have not created any dashboard panels yet, so you can not ' . 'add an existing panel.'))->appendParagraph(pht('Instead, add a new panel.'))->addCancelButton($redirect_uri);
     }
     $panel_options = array();
     foreach ($panels as $panel) {
         $panel_options[$panel->getID()] = pht('%s %s', $panel->getMonogram(), $panel->getName());
     }
     $form = id(new AphrontFormView())->setUser($viewer)->addHiddenInput('column', $request->getInt('column'))->appendRemarkupInstructions(pht('Choose a panel to add to this dashboard:'))->appendChild(id(new AphrontFormSelectControl())->setName('panel')->setLabel(pht('Panel'))->setValue($v_panel)->setError($e_panel)->setOptions($panel_options));
     return $this->newDialog()->setTitle(pht('Add Panel'))->setErrors($errors)->appendChild($form->buildLayoutView())->addCancelButton($redirect_uri)->addSubmitButton(pht('Add Panel'));
 }
开发者ID:denghp,项目名称:phabricator,代码行数:39,代码来源:PhabricatorDashboardAddPanelController.php

示例12: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $xaction = id(new PhabricatorObjectQuery())->withPHIDs(array($this->phid))->setViewer($user)->executeOne();
     if (!$xaction) {
         return new Aphront404Response();
     }
     if (!$xaction->getComment()) {
         // You can't currently edit a transaction which doesn't have a comment.
         // Some day you may be able to edit the visibility.
         return new Aphront404Response();
     }
     if ($xaction->getComment()->getIsRemoved()) {
         // You can't edit history of a transaction with a removed comment.
         return new Aphront400Response();
     }
     $obj_phid = $xaction->getObjectPHID();
     $obj_handle = id(new PhabricatorHandleQuery())->setViewer($user)->withPHIDs(array($obj_phid))->executeOne();
     if ($request->isDialogFormPost()) {
         $text = $request->getStr('text');
         $comment = $xaction->getApplicationTransactionCommentObject();
         $comment->setContent($text);
         if (!strlen($text)) {
             $comment->setIsDeleted(true);
         }
         $editor = id(new PhabricatorApplicationTransactionCommentEditor())->setActor($user)->setContentSource(PhabricatorContentSource::newFromRequest($request))->applyEdit($xaction, $comment);
         if ($request->isAjax()) {
             return id(new AphrontAjaxResponse())->setContent(array());
         } else {
             return id(new AphrontReloadResponse())->setURI($obj_handle->getURI());
         }
     }
     $dialog = id(new AphrontDialogView())->setUser($user)->setSubmitURI($this->getApplicationURI('/transactions/edit/' . $xaction->getPHID() . '/'))->setTitle(pht('Edit Comment'));
     $dialog->addHiddenInput('anchor', $request->getStr('anchor'))->appendChild(id(new PHUIFormLayoutView())->setFullWidth(true)->appendChild(id(new PhabricatorRemarkupControl())->setName('text')->setValue($xaction->getComment()->getContent())));
     $dialog->addSubmitButton(pht('Save Changes'))->addCancelButton($obj_handle->getURI());
     return id(new AphrontDialogResponse())->setDialog($dialog);
 }
开发者ID:denghp,项目名称:phabricator,代码行数:38,代码来源:PhabricatorApplicationTransactionCommentEditController.php

示例13: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $phid = $request->getURIData('phid');
     $handle = id(new PhabricatorHandleQuery())->setViewer($viewer)->withPHIDs(array($phid))->executeOne();
     if (!$handle->isComplete()) {
         return new Aphront404Response();
     }
     $current = id(new PhabricatorTokenGivenQuery())->setViewer($viewer)->withAuthorPHIDs(array($viewer->getPHID()))->withObjectPHIDs(array($handle->getPHID()))->execute();
     if ($current) {
         $is_give = false;
         $title = pht('Rescind Token');
     } else {
         $is_give = true;
         $title = pht('Give Token');
     }
     $done_uri = $handle->getURI();
     if ($request->isDialogFormPost()) {
         $content_source = PhabricatorContentSource::newFromRequest($request);
         $editor = id(new PhabricatorTokenGivenEditor())->setActor($viewer)->setContentSource($content_source);
         if ($is_give) {
             $token_phid = $request->getStr('tokenPHID');
             $editor->addToken($handle->getPHID(), $token_phid);
         } else {
             $editor->deleteToken($handle->getPHID());
         }
         return id(new AphrontReloadResponse())->setURI($done_uri);
     }
     if ($is_give) {
         $dialog = $this->buildGiveTokenDialog();
     } else {
         $dialog = $this->buildRescindTokenDialog(head($current));
     }
     $dialog->setUser($viewer);
     $dialog->addCancelButton($done_uri);
     return id(new AphrontDialogResponse())->setDialog($dialog);
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:37,代码来源:PhabricatorTokenGiveController.php

示例14: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $this->getViewer();
     $xaction = id(new PhabricatorObjectQuery())->setViewer($viewer)->withPHIDs(array($request->getURIData('phid')))->executeOne();
     if (!$xaction) {
         return new Aphront404Response();
     }
     if (!$xaction->getComment()) {
         // You can't currently edit a transaction which doesn't have a comment.
         // Some day you may be able to edit the visibility.
         return new Aphront404Response();
     }
     if ($xaction->getComment()->getIsRemoved()) {
         // You can't edit history of a transaction with a removed comment.
         return new Aphront400Response();
     }
     $phid = $xaction->getObjectPHID();
     $handles = $viewer->loadHandles(array($phid));
     $obj_handle = $handles[$phid];
     if ($request->isDialogFormPost()) {
         $text = $request->getStr('text');
         $comment = $xaction->getApplicationTransactionCommentObject();
         $comment->setContent($text);
         if (!strlen($text)) {
             $comment->setIsDeleted(true);
         }
         $editor = id(new PhabricatorApplicationTransactionCommentEditor())->setActor($viewer)->setContentSource(PhabricatorContentSource::newFromRequest($request))->applyEdit($xaction, $comment);
         if ($request->isAjax()) {
             return id(new AphrontAjaxResponse())->setContent(array());
         } else {
             return id(new AphrontReloadResponse())->setURI($obj_handle->getURI());
         }
     }
     $form = id(new AphrontFormView())->setUser($viewer)->setFullWidth(true)->appendControl(id(new PhabricatorRemarkupControl())->setName('text')->setValue($xaction->getComment()->getContent()));
     return $this->newDialog()->setTitle(pht('Edit Comment'))->addHiddenInput('anchor', $request->getStr('anchor'))->appendForm($form)->addSubmitButton(pht('Save Changes'))->addCancelButton($obj_handle->getURI());
 }
开发者ID:pugong,项目名称:phabricator,代码行数:36,代码来源:PhabricatorApplicationTransactionCommentEditController.php

示例15: setContentSourceFromRequest

 public function setContentSourceFromRequest(AphrontRequest $request)
 {
     return $this->setContentSource(PhabricatorContentSource::newFromRequest($request));
 }
开发者ID:sethkontny,项目名称:phabricator,代码行数:4,代码来源:PhabricatorApplicationTransactionEditor.php


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