本文整理汇总了PHP中PhabricatorDraft类的典型用法代码示例。如果您正苦于以下问题:PHP PhabricatorDraft类的具体用法?PHP PhabricatorDraft怎么用?PHP PhabricatorDraft使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PhabricatorDraft类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processRequest
public function processRequest()
{
$request = $this->getRequest();
$author_phid = $request->getUser()->getPHID();
$action = $request->getStr('action');
$engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine();
$comment = new DifferentialComment();
$comment->setContent($request->getStr('content'));
$comment->setAction($action);
$comment->setAuthorPHID($author_phid);
$handles = array($author_phid);
$reviewers = $request->getStr('reviewers');
if (($action == DifferentialAction::ACTION_ADDREVIEWERS || $action == DifferentialAction::ACTION_REQUEST) && $reviewers) {
$reviewers = explode(',', $reviewers);
$comment->setMetadata(array(DifferentialComment::METADATA_ADDED_REVIEWERS => $reviewers));
$handles = array_merge($handles, $reviewers);
}
$ccs = $request->getStr('ccs');
if ($action == DifferentialAction::ACTION_ADDCCS && $ccs) {
$ccs = explode(',', $ccs);
$comment->setMetadata(array(DifferentialComment::METADATA_ADDED_CCS => $ccs));
$handles = array_merge($handles, $ccs);
}
$handles = id(new PhabricatorObjectHandleData($handles))->loadHandles();
$view = new DifferentialRevisionCommentView();
$view->setUser($request->getUser());
$view->setComment($comment);
$view->setHandles($handles);
$view->setMarkupEngine($engine);
$view->setPreview(true);
$view->setTargetDiff(null);
$draft = new PhabricatorDraft();
$draft->setAuthorPHID($author_phid)->setDraftKey('differential-comment-' . $this->id)->setDraft($comment->getContent())->replace();
return id(new AphrontAjaxResponse())->setContent($view->render());
}
示例2: newFromUserAndKey
public static function newFromUserAndKey(PhabricatorUser $user, $key)
{
if ($user->getPHID() && strlen($key)) {
$draft = id(new PhabricatorDraft())->loadOneWhere('authorPHID = %s AND draftKey = %s', $user->getPHID(), $key);
if ($draft) {
return $draft;
}
}
$draft = new PhabricatorDraft();
if ($user->getPHID()) {
$draft->setAuthorPHID($user->getPHID())->setDraftKey($key);
}
return $draft;
}
示例3: processRequest
public function processRequest()
{
$request = $this->getRequest();
$user = $request->getUser();
$comments = $request->getStr('comments');
$task = id(new ManiphestTask())->load($this->id);
if (!$task) {
return new Aphront404Response();
}
$draft = id(new PhabricatorDraft())->loadOneWhere('authorPHID = %s AND draftKey = %s', $user->getPHID(), $task->getPHID());
if (!$draft) {
$draft = new PhabricatorDraft();
$draft->setAuthorPHID($user->getPHID());
$draft->setDraftKey($task->getPHID());
}
$draft->setDraft($comments);
$draft->save();
$phids = array($user->getPHID());
$action = $request->getStr('action');
$transaction = new ManiphestTransaction();
$transaction->setAuthorPHID($user->getPHID());
$transaction->setComments($comments);
$transaction->setTransactionType($action);
$value = $request->getStr('value');
switch ($action) {
case ManiphestTransactionType::TYPE_OWNER:
if (!$value) {
$value = $user->getPHID();
}
$phids[] = $value;
break;
case ManiphestTransactionType::TYPE_PRIORITY:
$transaction->setOldValue($task->getPriority());
break;
}
$transaction->setNewValue($value);
$handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
$transactions = array();
$transactions[] = $transaction;
$engine = PhabricatorMarkupEngine::newManiphestMarkupEngine();
$transaction_view = new ManiphestTransactionListView();
$transaction_view->setTransactions($transactions);
$transaction_view->setHandles($handles);
$transaction_view->setUser($user);
$transaction_view->setMarkupEngine($engine);
$transaction_view->setPreview(true);
return id(new AphrontAjaxResponse())->setContent($transaction_view->render());
}
示例4: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$paste = id(new PhabricatorPasteQuery())->setViewer($viewer)->withIDs(array($id))->needContent(true)->executeOne();
if (!$paste) {
return new Aphront404Response();
}
$file = id(new PhabricatorFileQuery())->setViewer($viewer)->withPHIDs(array($paste->getFilePHID()))->executeOne();
if (!$file) {
return new Aphront400Response();
}
$forks = id(new PhabricatorPasteQuery())->setViewer($viewer)->withParentPHIDs(array($paste->getPHID()))->execute();
$fork_phids = mpull($forks, 'getPHID');
$header = $this->buildHeaderView($paste);
$actions = $this->buildActionView($viewer, $paste, $file);
$properties = $this->buildPropertyView($paste, $fork_phids, $actions);
$object_box = id(new PHUIObjectBoxView())->setHeader($header)->addPropertyList($properties);
$source_code = $this->buildSourceCodeView($paste, null, $this->highlightMap);
$source_code = id(new PHUIBoxView())->appendChild($source_code)->addMargin(PHUI::MARGIN_LARGE_LEFT)->addMargin(PHUI::MARGIN_LARGE_RIGHT)->addMargin(PHUI::MARGIN_LARGE_TOP);
$crumbs = $this->buildApplicationCrumbs($this->buildSideNavView())->addTextCrumb('P' . $paste->getID(), '/P' . $paste->getID());
$timeline = $this->buildTransactionTimeline($paste, new PhabricatorPasteTransactionQuery());
$is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
$add_comment_header = $is_serious ? pht('Add Comment') : pht('Eat Paste');
$draft = PhabricatorDraft::newFromUserAndKey($viewer, $paste->getPHID());
$add_comment_form = id(new PhabricatorApplicationTransactionCommentView())->setUser($viewer)->setObjectPHID($paste->getPHID())->setDraft($draft)->setHeaderText($add_comment_header)->setAction($this->getApplicationURI('/comment/' . $paste->getID() . '/'))->setSubmitButtonName(pht('Add Comment'));
return $this->buildApplicationPage(array($crumbs, $object_box, $source_code, $timeline, $add_comment_form), array('title' => $paste->getFullName(), 'pageObjects' => array($paste->getPHID())));
}
示例5: buildCommentForm
private function buildCommentForm(PhamePost $post)
{
$viewer = $this->getViewer();
$draft = PhabricatorDraft::newFromUserAndKey($viewer, $post->getPHID());
$box = id(new PhabricatorApplicationTransactionCommentView())->setUser($viewer)->setObjectPHID($post->getPHID())->setDraft($draft)->setHeaderText(pht('Add Comment'))->setAction($this->getApplicationURI('post/comment/' . $post->getID() . '/'))->setSubmitButtonName(pht('Add Comment'));
return phutil_tag_div('phui-document-view-pro-box', $box);
}
示例6: processRequest
public function processRequest()
{
$request = $this->getRequest();
$user = $request->getUser();
if (!$request->isFormPost()) {
return new Aphront400Response();
}
$poll = id(new PhabricatorSlowvoteQuery())->setViewer($user)->withIDs(array($this->id))->executeOne();
if (!$poll) {
return new Aphront404Response();
}
$is_preview = $request->isPreviewRequest();
$draft = PhabricatorDraft::buildFromRequest($request);
$view_uri = '/V' . $poll->getID();
$xactions = array();
$xactions[] = id(new PhabricatorSlowvoteTransaction())->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)->attachComment(id(new PhabricatorSlowvoteTransactionComment())->setContent($request->getStr('comment')));
$editor = id(new PhabricatorSlowvoteEditor())->setActor($user)->setContinueOnNoEffect($request->isContinueRequest())->setContentSourceFromRequest($request)->setIsPreview($is_preview);
try {
$xactions = $editor->applyTransactions($poll, $xactions);
} catch (PhabricatorApplicationTransactionNoEffectException $ex) {
return id(new PhabricatorApplicationTransactionNoEffectResponse())->setCancelURI($view_uri)->setException($ex);
}
if ($draft) {
$draft->replaceOrDelete();
}
if ($request->isAjax() && $is_preview) {
return id(new PhabricatorApplicationTransactionResponse())->setViewer($user)->setTransactions($xactions)->setIsPreview($is_preview)->setAnchorOffset($request->getStr('anchor'));
} else {
return id(new AphrontRedirectResponse())->setURI($view_uri);
}
}
示例7: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$macro = id(new PhabricatorMacroQuery())->setViewer($viewer)->withIDs(array($id))->needFiles(true)->executeOne();
if (!$macro) {
return new Aphront404Response();
}
$title_short = pht('Macro "%s"', $macro->getName());
$title_long = pht('Image Macro "%s"', $macro->getName());
$curtain = $this->buildCurtain($macro);
$subheader = $this->buildSubheaderView($macro);
$file = $this->buildFileView($macro);
$details = $this->buildPropertySectionView($macro);
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb($macro->getName());
$crumbs->setBorder(true);
$timeline = $this->buildTransactionTimeline($macro, new PhabricatorMacroTransactionQuery());
$header = id(new PHUIHeaderView())->setUser($viewer)->setPolicyObject($macro)->setHeader($macro->getName())->setHeaderIcon('fa-file-image-o');
if (!$macro->getIsDisabled()) {
$header->setStatus('fa-check', 'bluegrey', pht('Active'));
} else {
$header->setStatus('fa-ban', 'red', pht('Archived'));
}
$is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
$comment_header = $is_serious ? pht('Add Comment') : pht('Grovel in Awe');
$draft = PhabricatorDraft::newFromUserAndKey($viewer, $macro->getPHID());
$add_comment_form = id(new PhabricatorApplicationTransactionCommentView())->setUser($viewer)->setObjectPHID($macro->getPHID())->setDraft($draft)->setHeaderText($comment_header)->setAction($this->getApplicationURI('/comment/' . $macro->getID() . '/'))->setSubmitButtonName(pht('Add Comment'));
$view = id(new PHUITwoColumnView())->setHeader($header)->setSubheader($subheader)->setCurtain($curtain)->setMainColumn(array($timeline, $add_comment_form))->addPropertySection(pht('Macro'), $file)->addPropertySection(pht('Details'), $details);
return $this->newPage()->setTitle($title_short)->setCrumbs($crumbs)->setPageObjectPHIDs(array($macro->getPHID()))->appendChild($view);
}
示例8: processRequest
public function processRequest()
{
$request = $this->getRequest();
$document = $request->getStr('document');
$draft_key = $request->getStr('draftkey');
if ($draft_key) {
$table = new PhabricatorDraft();
queryfx($table->establishConnection('w'), 'INSERT INTO %T (authorPHID, draftKey, draft) VALUES (%s, %s, %s)
ON DUPLICATE KEY UPDATE draft = VALUES(draft)', $table->getTableName(), $request->getUser()->getPHID(), $draft_key, $document);
}
$content_obj = new PhrictionContent();
$content_obj->setContent($document);
$engine = PhabricatorMarkupEngine::newPhrictionMarkupEngine();
$content = $content_obj->renderContent();
return id(new AphrontAjaxResponse())->setContent($content);
}
示例9: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$timeline = null;
$url = id(new PhabricatorPhurlURLQuery())->setViewer($viewer)->withIDs(array($id))->executeOne();
if (!$url) {
return new Aphront404Response();
}
$title = $url->getMonogram();
$page_title = $title . ' ' . $url->getName();
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb($title, $url->getURI());
$timeline = $this->buildTransactionTimeline($url, new PhabricatorPhurlURLTransactionQuery());
$header = $this->buildHeaderView($url);
$actions = $this->buildActionView($url);
$properties = $this->buildPropertyView($url);
$properties->setActionList($actions);
$url_error = id(new PHUIInfoView())->setErrors(array(pht('This URL is invalid due to a bad protocol.')))->setIsHidden($url->isValid());
$box = id(new PHUIObjectBoxView())->setHeader($header)->addPropertyList($properties)->setInfoView($url_error);
$is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
$add_comment_header = $is_serious ? pht('Add Comment') : pht('More Cowbell');
$draft = PhabricatorDraft::newFromUserAndKey($viewer, $url->getPHID());
$comment_uri = $this->getApplicationURI('/phurl/comment/' . $url->getID() . '/');
$add_comment_form = id(new PhabricatorApplicationTransactionCommentView())->setUser($viewer)->setObjectPHID($url->getPHID())->setDraft($draft)->setHeaderText($add_comment_header)->setAction($comment_uri)->setSubmitButtonName(pht('Add Comment'));
return $this->buildApplicationPage(array($crumbs, $box, $timeline, $add_comment_form), array('title' => $page_title, 'pageObjects' => array($url->getPHID())));
}
示例10: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$id = $request->getURIData('id');
if (!$request->isFormPost()) {
return new Aphront400Response();
}
$document = id(new LegalpadDocumentQuery())->setViewer($viewer)->withIDs(array($id))->needDocumentBodies(true)->executeOne();
if (!$document) {
return new Aphront404Response();
}
$is_preview = $request->isPreviewRequest();
$draft = PhabricatorDraft::buildFromRequest($request);
$document_uri = $this->getApplicationURI('view/' . $document->getID());
$comment = $request->getStr('comment');
$xactions = array();
if (strlen($comment)) {
$xactions[] = id(new LegalpadTransaction())->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)->attachComment(id(new LegalpadTransactionComment())->setDocumentID($document->getID())->setLineNumber(0)->setLineLength(0)->setContent($comment));
}
$editor = id(new LegalpadDocumentEditor())->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnNoEffect($request->isContinueRequest())->setIsPreview($is_preview);
try {
$xactions = $editor->applyTransactions($document, $xactions);
} catch (PhabricatorApplicationTransactionNoEffectException $ex) {
return id(new PhabricatorApplicationTransactionNoEffectResponse())->setCancelURI($document_uri)->setException($ex);
}
if ($draft) {
$draft->replaceOrDelete();
}
if ($request->isAjax() && $is_preview) {
return id(new PhabricatorApplicationTransactionResponse())->setViewer($viewer)->setTransactions($xactions)->setIsPreview($is_preview);
} else {
return id(new AphrontRedirectResponse())->setURI($document_uri);
}
}
示例11: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$id = $request->getURIData('id');
if (!$request->isFormPost()) {
return new Aphront400Response();
}
$paste = id(new PhabricatorPasteQuery())->setViewer($viewer)->withIDs(array($id))->executeOne();
if (!$paste) {
return new Aphront404Response();
}
$is_preview = $request->isPreviewRequest();
$draft = PhabricatorDraft::buildFromRequest($request);
$view_uri = $paste->getURI();
$xactions = array();
$xactions[] = id(new PhabricatorPasteTransaction())->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)->attachComment(id(new PhabricatorPasteTransactionComment())->setContent($request->getStr('comment')));
$editor = id(new PhabricatorPasteEditor())->setActor($viewer)->setContinueOnNoEffect($request->isContinueRequest())->setContentSourceFromRequest($request)->setIsPreview($is_preview);
try {
$xactions = $editor->applyTransactions($paste, $xactions);
} catch (PhabricatorApplicationTransactionNoEffectException $ex) {
return id(new PhabricatorApplicationTransactionNoEffectResponse())->setCancelURI($view_uri)->setException($ex);
}
if ($draft) {
$draft->replaceOrDelete();
}
if ($request->isAjax() && $is_preview) {
return id(new PhabricatorApplicationTransactionResponse())->setViewer($viewer)->setTransactions($xactions)->setIsPreview($is_preview);
} else {
return id(new AphrontRedirectResponse())->setURI($view_uri);
}
}
示例12: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$sequence = $request->getURIData('sequence');
$timeline = null;
$event = id(new PhabricatorCalendarEventQuery())->setViewer($viewer)->withIDs(array($id))->executeOne();
if (!$event) {
return new Aphront404Response();
}
if ($sequence) {
$result = $this->getEventAtIndexForGhostPHID($viewer, $event->getPHID(), $sequence);
if ($result) {
$parent_event = $event;
$event = $result;
$event->attachParentEvent($parent_event);
return id(new AphrontRedirectResponse())->setURI('/E' . $result->getID());
} else {
if ($sequence && $event->getIsRecurring()) {
$parent_event = $event;
$event = $event->generateNthGhost($sequence, $viewer);
$event->attachParentEvent($parent_event);
} else {
if ($sequence) {
return new Aphront404Response();
}
}
}
$title = $event->getMonogram() . ' (' . $sequence . ')';
$page_title = $title . ' ' . $event->getName();
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb($title, '/' . $event->getMonogram() . '/' . $sequence);
} else {
$title = 'E' . $event->getID();
$page_title = $title . ' ' . $event->getName();
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb($title);
$crumbs->setBorder(true);
}
if (!$event->getIsGhostEvent()) {
$timeline = $this->buildTransactionTimeline($event, new PhabricatorCalendarEventTransactionQuery());
}
$header = $this->buildHeaderView($event);
$actions = $this->buildActionView($event);
$properties = $this->buildPropertyListView($event);
$details = $this->buildPropertySection($event);
$description = $this->buildDescriptionView($event);
$is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
$add_comment_header = $is_serious ? pht('Add Comment') : pht('Add To Plate');
$draft = PhabricatorDraft::newFromUserAndKey($viewer, $event->getPHID());
if ($sequence) {
$comment_uri = $this->getApplicationURI('/event/comment/' . $event->getID() . '/' . $sequence . '/');
} else {
$comment_uri = $this->getApplicationURI('/event/comment/' . $event->getID() . '/');
}
$add_comment_form = id(new PhabricatorApplicationTransactionCommentView())->setUser($viewer)->setObjectPHID($event->getPHID())->setDraft($draft)->setHeaderText($add_comment_header)->setAction($comment_uri)->setSubmitButtonName(pht('Add Comment'));
$view = id(new PHUITwoColumnView())->setHeader($header)->setMainColumn($timeline)->setPropertyList($properties)->addPropertySection(pht('DETAILS'), $details)->addPropertySection(pht('DESCRIPTION'), $description)->setActionList($actions);
return $this->newPage()->setTitle($page_title)->setCrumbs($crumbs)->setPageObjectPHIDs(array($event->getPHID()))->appendChild(array($view));
}
示例13: buildCommentForm
private function buildCommentForm(PhabricatorSlowvotePoll $poll)
{
$viewer = $this->getRequest()->getUser();
$is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
$add_comment_header = $is_serious ? pht('Add Comment') : pht('Enter Deliberations');
$draft = PhabricatorDraft::newFromUserAndKey($viewer, $poll->getPHID());
return id(new PhabricatorApplicationTransactionCommentView())->setUser($viewer)->setObjectPHID($poll->getPHID())->setDraft($draft)->setHeaderText($add_comment_header)->setAction($this->getApplicationURI('/comment/' . $poll->getID() . '/'))->setSubmitButtonName(pht('Add Comment'));
}
示例14: buildCommentForm
private function buildCommentForm(PhabricatorBadgesBadge $badge)
{
$viewer = $this->getViewer();
$is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
$add_comment_header = $is_serious ? pht('Add Comment') : pht('Render Honors');
$draft = PhabricatorDraft::newFromUserAndKey($viewer, $badge->getPHID());
return id(new PhabricatorApplicationTransactionCommentView())->setUser($viewer)->setObjectPHID($badge->getPHID())->setDraft($draft)->setHeaderText($add_comment_header)->setAction($this->getApplicationURI('/comment/' . $badge->getID() . '/'))->setSubmitButtonName(pht('Add Comment'));
}
示例15: buildAddCommentView
private function buildAddCommentView(LegalpadDocument $document, $comment_form_id)
{
$viewer = $this->getViewer();
$draft = PhabricatorDraft::newFromUserAndKey($viewer, $document->getPHID());
$is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
$title = $is_serious ? pht('Add Comment') : pht('Debate Legislation');
$form = id(new PhabricatorApplicationTransactionCommentView())->setUser($viewer)->setObjectPHID($document->getPHID())->setFormID($comment_form_id)->setHeaderText($title)->setDraft($draft)->setSubmitButtonName(pht('Add Comment'))->setAction($this->getApplicationURI('/comment/' . $document->getID() . '/'))->setRequestURI($this->getRequest()->getRequestURI());
return $form;
}