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); }
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()))); }
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); }
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()))); }
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)); }
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')); }
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')); }
public function processRequest() { $request = $this->getRequest(); $viewer = $request->getUser(); $sequence = $request->getURIData('sequence'); $timeline = null; $event = id(new PhabricatorCalendarEventQuery())->setViewer($viewer)->withIDs(array($this->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, '/E' . $event->getID()); } if (!$event->getIsGhostEvent()) { $timeline = $this->buildTransactionTimeline($event, new PhabricatorCalendarEventTransactionQuery()); } $header = $this->buildHeaderView($event); $actions = $this->buildActionView($event); $properties = $this->buildPropertyView($event); $properties->setActionList($actions); $box = id(new PHUIObjectBoxView())->setHeader($header)->addPropertyList($properties); $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')); return $this->buildApplicationPage(array($crumbs, $box, $timeline, $add_comment_form), array('title' => $page_title)); }
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; }
private function buildTransactionView(PhabricatorFile $file) { $viewer = $this->getViewer(); $timeline = $this->buildTransactionTimeline($file, new PhabricatorFileTransactionQuery()); $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); $add_comment_header = $is_serious ? pht('Add Comment') : pht('Question File Integrity'); $draft = PhabricatorDraft::newFromUserAndKey($viewer, $file->getPHID()); $add_comment_form = id(new PhabricatorApplicationTransactionCommentView())->setUser($viewer)->setObjectPHID($file->getPHID())->setDraft($draft)->setHeaderText($add_comment_header)->setAction($this->getApplicationURI('/comment/' . $file->getID() . '/'))->setSubmitButtonName(pht('Add Comment')); return array($timeline, $add_comment_form); }
public function handleRequest(AphrontRequest $request) { $user = $request->getUser(); $latest_conpherences = array(); $latest_participant = id(new ConpherenceParticipantQuery())->withParticipantPHIDs(array($user->getPHID()))->setLimit(6)->execute(); if ($latest_participant) { $conpherence_phids = mpull($latest_participant, 'getConpherencePHID'); $latest_conpherences = id(new ConpherenceThreadQuery())->setViewer($user)->withPHIDs($conpherence_phids)->needCropPics(true)->needParticipantCache(true)->execute(); $latest_conpherences = mpull($latest_conpherences, null, 'getPHID'); $latest_conpherences = array_select_keys($latest_conpherences, $conpherence_phids); } $conpherence = null; $should_404 = false; if ($request->getInt('id')) { $conpherence = id(new ConpherenceThreadQuery())->setViewer($user)->withIDs(array($request->getInt('id')))->needCropPics(true)->needTransactions(true)->setTransactionLimit(ConpherenceThreadQuery::TRANSACTION_LIMIT)->executeOne(); $should_404 = true; } else { if ($latest_participant) { $participant = head($latest_participant); $conpherence = id(new ConpherenceThreadQuery())->setViewer($user)->withPHIDs(array($participant->getConpherencePHID()))->needCropPics(true)->needTransactions(true)->setTransactionLimit(ConpherenceThreadQuery::TRANSACTION_LIMIT)->executeOne(); $should_404 = true; } } $durable_column = id(new ConpherenceDurableColumnView())->setUser($user)->setVisible(true); if (!$conpherence) { if ($should_404) { return new Aphront404Response(); } $conpherence_id = null; $conpherence_phid = null; $latest_transaction_id = null; $can_edit = false; } else { $this->setConpherence($conpherence); $participant = $conpherence->getParticipant($user->getPHID()); $transactions = $conpherence->getTransactions(); $latest_transaction = head($transactions); $write_guard = AphrontWriteGuard::beginScopedUnguardedWrites(); $participant->markUpToDate($conpherence, $latest_transaction); unset($write_guard); $draft = PhabricatorDraft::newFromUserAndKey($user, $conpherence->getPHID()); $durable_column->setDraft($draft)->setSelectedConpherence($conpherence)->setConpherences($latest_conpherences); $conpherence_id = $conpherence->getID(); $conpherence_phid = $conpherence->getPHID(); $latest_transaction_id = $latest_transaction->getID(); $can_edit = PhabricatorPolicyFilter::hasCapability($user, $conpherence, PhabricatorPolicyCapability::CAN_EDIT); } $dropdown_query = id(new AphlictDropdownDataQuery())->setViewer($user); $dropdown_query->execute(); $response = array('content' => hsprintf('%s', $durable_column), 'threadID' => $conpherence_id, 'threadPHID' => $conpherence_phid, 'latestTransactionID' => $latest_transaction_id, 'canEdit' => $can_edit, 'aphlictDropdownData' => array($dropdown_query->getNotificationData(), $dropdown_query->getConpherenceData())); return id(new AphrontAjaxResponse())->setContent($response); }
private function renderCommentForm(PhabricatorFile $file) { $viewer = $this->getViewer(); if (!$viewer->isLoggedIn()) { $login_href = id(new PhutilURI('/auth/start/'))->setQueryParam('next', '/' . $file->getMonogram()); return id(new PHUIFormLayoutView())->addClass('phui-comment-panel-empty')->appendChild(id(new PHUIButtonView())->setTag('a')->setText(pht('Login to Comment'))->setHref((string) $login_href)); } $draft = PhabricatorDraft::newFromUserAndKey($viewer, $file->getPHID()); $post_uri = $this->getApplicationURI('thread/' . $file->getPHID() . '/'); $form = id(new AphrontFormView())->setUser($viewer)->setAction($post_uri)->addSigil('lightbox-comment-form')->addClass('lightbox-comment-form')->setWorkflow(true)->appendChild(id(new PhabricatorRemarkupControl())->setUser($viewer)->setName('comment')->setValue($draft->getDraft()))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Comment'))); $view = phutil_tag_div('phui-comment-panel', $form); return $view; }
private function buildTransactionView(PhabricatorFile $file, array $xactions) { $user = $this->getRequest()->getUser(); $engine = id(new PhabricatorMarkupEngine())->setViewer($user); foreach ($xactions as $xaction) { if ($xaction->getComment()) { $engine->addObject($xaction->getComment(), PhabricatorApplicationTransactionComment::MARKUP_FIELD_COMMENT); } } $engine->process(); $timeline = id(new PhabricatorApplicationTransactionView())->setUser($user)->setObjectPHID($file->getPHID())->setTransactions($xactions)->setMarkupEngine($engine); $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); $add_comment_header = $is_serious ? pht('Add Comment') : pht('Question File Integrity'); $draft = PhabricatorDraft::newFromUserAndKey($user, $file->getPHID()); $add_comment_form = id(new PhabricatorApplicationTransactionCommentView())->setUser($user)->setObjectPHID($file->getPHID())->setDraft($draft)->setHeaderText($add_comment_header)->setAction($this->getApplicationURI('/comment/' . $file->getID() . '/'))->setSubmitButtonName(pht('Add Comment')); return array($timeline, $add_comment_form); }
public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); $macro = id(new PhabricatorMacroQuery())->setViewer($user)->withIDs(array($this->id))->needFiles(true)->executeOne(); if (!$macro) { return new Aphront404Response(); } $file = $macro->getFile(); $title_short = pht('Macro "%s"', $macro->getName()); $title_long = pht('Image Macro "%s"', $macro->getName()); $actions = $this->buildActionView($macro); $crumbs = $this->buildApplicationCrumbs(); $crumbs->setActionList($actions); $crumbs->addTextCrumb($title_short, $this->getApplicationURI('/view/' . $macro->getID() . '/')); $properties = $this->buildPropertyView($macro, $actions); if ($file) { $file_view = new PHUIPropertyListView(); $file_view->addImageContent(phutil_tag('img', array('src' => $file->getViewURI(), 'class' => 'phabricator-image-macro-hero'))); } $xactions = id(new PhabricatorMacroTransactionQuery())->setViewer($request->getUser())->withObjectPHIDs(array($macro->getPHID()))->execute(); $engine = id(new PhabricatorMarkupEngine())->setViewer($user); foreach ($xactions as $xaction) { if ($xaction->getComment()) { $engine->addObject($xaction->getComment(), PhabricatorApplicationTransactionComment::MARKUP_FIELD_COMMENT); } } $engine->process(); $timeline = id(new PhabricatorApplicationTransactionView())->setUser($user)->setObjectPHID($macro->getPHID())->setTransactions($xactions)->setMarkupEngine($engine); $header = id(new PHUIHeaderView())->setUser($user)->setPolicyObject($macro)->setHeader($title_long); if ($macro->getIsDisabled()) { $header->addTag(id(new PHUITagView())->setType(PHUITagView::TYPE_STATE)->setName(pht('Macro Disabled'))->setBackgroundColor(PHUITagView::COLOR_BLACK)); } $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); $comment_header = $is_serious ? pht('Add Comment') : pht('Grovel in Awe'); $draft = PhabricatorDraft::newFromUserAndKey($user, $macro->getPHID()); $add_comment_form = id(new PhabricatorApplicationTransactionCommentView())->setUser($user)->setObjectPHID($macro->getPHID())->setDraft($draft)->setHeaderText($comment_header)->setAction($this->getApplicationURI('/comment/' . $macro->getID() . '/'))->setSubmitButtonName(pht('Add Comment')); $object_box = id(new PHUIObjectBoxView())->setHeader($header)->addPropertyList($properties); if ($file_view) { $object_box->addPropertyList($file_view); } return $this->buildApplicationPage(array($crumbs, $object_box, $timeline, $add_comment_form), array('title' => $title_short)); }
public function handleRequest(AphrontRequest $request) { $id = $request->getURIData('requestID'); $viewer = $request->getViewer(); $pull = id(new ReleephRequestQuery())->setViewer($viewer)->withIDs(array($id))->executeOne(); if (!$pull) { return new Aphront404Response(); } $this->setBranch($pull->getBranch()); // Redirect older URIs to new "Y" URIs. // TODO: Get rid of this eventually. $actual_path = $request->getRequestURI()->getPath(); $expect_path = '/' . $pull->getMonogram(); if ($actual_path != $expect_path) { return id(new AphrontRedirectResponse())->setURI($expect_path); } // TODO: Break this 1:1 stuff? $branch = $pull->getBranch(); $field_list = PhabricatorCustomField::getObjectFields($pull, PhabricatorCustomField::ROLE_VIEW); $field_list->setViewer($viewer)->readFieldsFromStorage($pull); // TODO: This should be more modern and general. $engine = id(new PhabricatorMarkupEngine())->setViewer($viewer); foreach ($field_list->getFields() as $field) { if ($field->shouldMarkup()) { $field->setMarkupEngine($engine); } } $engine->process(); $pull_box = id(new ReleephRequestView())->setUser($viewer)->setCustomFields($field_list)->setPullRequest($pull); $timeline = $this->buildTransactionTimeline($pull, new ReleephRequestTransactionQuery()); $add_comment_header = pht('Plea or Yield'); $draft = PhabricatorDraft::newFromUserAndKey($viewer, $pull->getPHID()); $title = hsprintf('%s %s', $pull->getMonogram(), $pull->getSummaryForDisplay()); $add_comment_form = id(new PhabricatorApplicationTransactionCommentView())->setUser($viewer)->setObjectPHID($pull->getPHID())->setDraft($draft)->setHeaderText($add_comment_header)->setAction($this->getApplicationURI('/request/comment/' . $pull->getID() . '/'))->setSubmitButtonName(pht('Comment')); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb($pull->getMonogram(), '/' . $pull->getMonogram()); $crumbs->setBorder(true); $header = id(new PHUIHeaderView())->setHeader($title)->setHeaderIcon('fa-flag-checkered'); $view = id(new PHUITwoColumnView())->setHeader($header)->setFooter(array($pull_box, $timeline, $add_comment_form)); return $this->newPage()->setTitle($title)->setCrumbs($crumbs)->appendChild($view); }
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(); } $file = $macro->getFile(); $title_short = pht('Macro "%s"', $macro->getName()); $title_long = pht('Image Macro "%s"', $macro->getName()); $actions = $this->buildActionView($macro); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb($title_short, $this->getApplicationURI('/view/' . $macro->getID() . '/')); $properties = $this->buildPropertyView($macro, $actions); if ($file) { $file_view = new PHUIPropertyListView(); $file_view->addImageContent(phutil_tag('img', array('src' => $file->getViewURI(), 'class' => 'phabricator-image-macro-hero'))); } $timeline = $this->buildTransactionTimeline($macro, new PhabricatorMacroTransactionQuery()); $header = id(new PHUIHeaderView())->setUser($viewer)->setPolicyObject($macro)->setHeader($title_long); 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')); $object_box = id(new PHUIObjectBoxView())->setHeader($header)->addPropertyList($properties); if ($file_view) { $object_box->addPropertyList($file_view); } return $this->buildApplicationPage(array($crumbs, $object_box, $timeline, $add_comment_form), array('title' => $title_short, 'pageObjects' => array($macro->getPHID()))); }
private function buildAddCommentView(PholioMock $mock, $comment_form_id) { $user = $this->getRequest()->getUser(); $draft = PhabricatorDraft::newFromUserAndKey($user, $mock->getPHID()); $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); $title = $is_serious ? pht('Add Comment') : pht('History Beckons'); $form = id(new PhabricatorApplicationTransactionCommentView())->setUser($user)->setObjectPHID($mock->getPHID())->setFormID($comment_form_id)->setDraft($draft)->setHeaderText($title)->setSubmitButtonName(pht('Add Comment'))->setAction($this->getApplicationURI('/comment/' . $mock->getID() . '/'))->setRequestURI($this->getRequest()->getRequestURI()); return $form; }
public function handleRequest(AphrontRequest $request) { $user = $request->getUser(); $conpherence_id = $request->getURIData('id'); if (!$conpherence_id) { return new Aphront404Response(); } $need_participants = false; $needed_capabilities = array(PhabricatorPolicyCapability::CAN_VIEW); $action = $request->getStr('action', ConpherenceUpdateActions::METADATA); switch ($action) { case ConpherenceUpdateActions::REMOVE_PERSON: $person_phid = $request->getStr('remove_person'); if ($person_phid != $user->getPHID()) { $needed_capabilities[] = PhabricatorPolicyCapability::CAN_EDIT; } break; case ConpherenceUpdateActions::ADD_PERSON: case ConpherenceUpdateActions::METADATA: $needed_capabilities[] = PhabricatorPolicyCapability::CAN_EDIT; break; case ConpherenceUpdateActions::JOIN_ROOM: $needed_capabilities[] = PhabricatorPolicyCapability::CAN_JOIN; break; case ConpherenceUpdateActions::NOTIFICATIONS: $need_participants = true; break; case ConpherenceUpdateActions::LOAD: break; } $conpherence = id(new ConpherenceThreadQuery())->setViewer($user)->withIDs(array($conpherence_id))->needFilePHIDs(true)->needOrigPics(true)->needCropPics(true)->needParticipants($need_participants)->requireCapabilities($needed_capabilities)->executeOne(); $latest_transaction_id = null; $response_mode = $request->isAjax() ? 'ajax' : 'redirect'; $error_view = null; $e_file = array(); $errors = array(); $delete_draft = false; $xactions = array(); if ($request->isFormPost() || $action == ConpherenceUpdateActions::LOAD) { $editor = id(new ConpherenceEditor())->setContinueOnNoEffect($request->isContinueRequest())->setContentSourceFromRequest($request)->setActor($user); switch ($action) { case ConpherenceUpdateActions::DRAFT: $draft = PhabricatorDraft::newFromUserAndKey($user, $conpherence->getPHID()); $draft->setDraft($request->getStr('text')); $draft->replaceOrDelete(); return new AphrontAjaxResponse(); case ConpherenceUpdateActions::JOIN_ROOM: $xactions[] = id(new ConpherenceTransaction())->setTransactionType(ConpherenceTransaction::TYPE_PARTICIPANTS)->setNewValue(array('+' => array($user->getPHID()))); $delete_draft = true; $message = $request->getStr('text'); if ($message) { $message_xactions = $editor->generateTransactionsFromText($user, $conpherence, $message); $xactions = array_merge($xactions, $message_xactions); } // for now, just redirect back to the conpherence so everything // will work okay...! $response_mode = 'redirect'; break; case ConpherenceUpdateActions::MESSAGE: $message = $request->getStr('text'); if (strlen($message)) { $xactions = $editor->generateTransactionsFromText($user, $conpherence, $message); $delete_draft = true; } else { $action = ConpherenceUpdateActions::LOAD; $updated = false; $response_mode = 'ajax'; } break; case ConpherenceUpdateActions::ADD_PERSON: $person_phids = $request->getArr('add_person'); if (!empty($person_phids)) { $xactions[] = id(new ConpherenceTransaction())->setTransactionType(ConpherenceTransaction::TYPE_PARTICIPANTS)->setNewValue(array('+' => $person_phids)); } break; case ConpherenceUpdateActions::REMOVE_PERSON: if (!$request->isContinueRequest()) { // do nothing; we'll display a confirmation dialogue instead break; } $person_phid = $request->getStr('remove_person'); if ($person_phid && $person_phid == $user->getPHID()) { $xactions[] = id(new ConpherenceTransaction())->setTransactionType(ConpherenceTransaction::TYPE_PARTICIPANTS)->setNewValue(array('-' => array($person_phid))); $response_mode = 'go-home'; } break; case ConpherenceUpdateActions::NOTIFICATIONS: $notifications = $request->getStr('notifications'); $participant = $conpherence->getParticipantIfExists($user->getPHID()); if (!$participant) { return id(new Aphront404Response()); } $participant->setSettings(array('notifications' => $notifications)); $participant->save(); $result = pht('Updated notification settings to "%s".', ConpherenceSettings::getHumanString($notifications)); return id(new AphrontAjaxResponse())->setContent($result); break; case ConpherenceUpdateActions::METADATA: $top = $request->getInt('image_y'); $left = $request->getInt('image_x'); $file_id = $request->getInt('file_id'); $title = $request->getStr('title'); if ($file_id) { $orig_file = id(new PhabricatorFileQuery())->setViewer($user)->withIDs(array($file_id))->executeOne(); $xactions[] = id(new ConpherenceTransaction())->setTransactionType(ConpherenceTransaction::TYPE_PICTURE)->setNewValue($orig_file); $okay = $orig_file->isTransformableImage(); if ($okay) { $xformer = new PhabricatorImageTransformer(); $crop_file = $xformer->executeConpherenceTransform($orig_file, 0, 0, ConpherenceImageData::CROP_WIDTH, ConpherenceImageData::CROP_HEIGHT); $xactions[] = id(new ConpherenceTransaction())->setTransactionType(ConpherenceTransaction::TYPE_PICTURE_CROP)->setNewValue($crop_file->getPHID()); } $response_mode = 'redirect'; } // all other metadata updates are continue requests if (!$request->isContinueRequest()) { break; } if ($top !== null || $left !== null) { $file = $conpherence->getImage(ConpherenceImageData::SIZE_ORIG); $xformer = new PhabricatorImageTransformer(); $xformed = $xformer->executeConpherenceTransform($file, $top, $left, ConpherenceImageData::CROP_WIDTH, ConpherenceImageData::CROP_HEIGHT); $image_phid = $xformed->getPHID(); $xactions[] = id(new ConpherenceTransaction())->setTransactionType(ConpherenceTransaction::TYPE_PICTURE_CROP)->setNewValue($image_phid); } $title = $request->getStr('title'); $xactions[] = id(new ConpherenceTransaction())->setTransactionType(ConpherenceTransaction::TYPE_TITLE)->setNewValue($title); $xactions[] = id(new ConpherenceTransaction())->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY)->setNewValue($request->getStr('viewPolicy')); $xactions[] = id(new ConpherenceTransaction())->setTransactionType(PhabricatorTransactions::TYPE_EDIT_POLICY)->setNewValue($request->getStr('editPolicy')); $xactions[] = id(new ConpherenceTransaction())->setTransactionType(PhabricatorTransactions::TYPE_JOIN_POLICY)->setNewValue($request->getStr('joinPolicy')); if (!$request->getExists('force_ajax')) { $response_mode = 'redirect'; } break; case ConpherenceUpdateActions::LOAD: $updated = false; $response_mode = 'ajax'; break; default: throw new Exception(pht('Unknown action: %s', $action)); break; } if ($xactions) { try { $xactions = $editor->applyTransactions($conpherence, $xactions); if ($delete_draft) { $draft = PhabricatorDraft::newFromUserAndKey($user, $conpherence->getPHID()); $draft->delete(); } } catch (PhabricatorApplicationTransactionNoEffectException $ex) { return id(new PhabricatorApplicationTransactionNoEffectResponse())->setCancelURI($this->getApplicationURI($conpherence_id . '/'))->setException($ex); } // xactions had no effect...! if (empty($xactions)) { $errors[] = pht('That was a non-update. Try cancel.'); } } if ($xactions || $action == ConpherenceUpdateActions::LOAD) { switch ($response_mode) { case 'ajax': $latest_transaction_id = $request->getInt('latest_transaction_id'); $content = $this->loadAndRenderUpdates($action, $conpherence_id, $latest_transaction_id); return id(new AphrontAjaxResponse())->setContent($content); break; case 'go-home': $content = array('href' => $this->getApplicationURI()); return id(new AphrontAjaxResponse())->setContent($content); break; case 'redirect': default: return id(new AphrontRedirectResponse())->setURI('/' . $conpherence->getMonogram()); break; } } } if ($errors) { $error_view = id(new PHUIInfoView())->setErrors($errors); } switch ($action) { case ConpherenceUpdateActions::ADD_PERSON: $dialogue = $this->renderAddPersonDialogue($conpherence); break; case ConpherenceUpdateActions::REMOVE_PERSON: $dialogue = $this->renderRemovePersonDialogue($conpherence); break; case ConpherenceUpdateActions::METADATA: default: $dialogue = $this->renderMetadataDialogue($conpherence, $error_view); break; } return id(new AphrontDialogResponse())->setDialog($dialogue->setUser($user)->setWidth(AphrontDialogView::WIDTH_FORM)->setSubmitURI($this->getApplicationURI('update/' . $conpherence_id . '/'))->addSubmitButton()->addCancelButton($this->getApplicationURI($conpherence->getID() . '/'))); }
public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); $conpherence_id = $this->getConpherenceID(); if (!$conpherence_id) { return new Aphront404Response(); } $conpherence = id(new ConpherenceThreadQuery())->setViewer($user)->withIDs(array($conpherence_id))->needFilePHIDs(true)->executeOne(); $action = $request->getStr('action', ConpherenceUpdateActions::METADATA); $latest_transaction_id = null; $response_mode = $request->isAjax() ? 'ajax' : 'redirect'; $error_view = null; $e_file = array(); $errors = array(); $delete_draft = false; $xactions = array(); if ($request->isFormPost() || $action == ConpherenceUpdateActions::LOAD) { $editor = id(new ConpherenceEditor())->setContinueOnNoEffect($request->isContinueRequest())->setContentSourceFromRequest($request)->setActor($user); switch ($action) { case ConpherenceUpdateActions::DRAFT: $draft = PhabricatorDraft::newFromUserAndKey($user, $conpherence->getPHID()); $draft->setDraft($request->getStr('text')); $draft->replaceOrDelete(); return new AphrontAjaxResponse(); case ConpherenceUpdateActions::MESSAGE: $message = $request->getStr('text'); $xactions = $editor->generateTransactionsFromText($user, $conpherence, $message); $delete_draft = true; break; case ConpherenceUpdateActions::ADD_PERSON: $person_phids = $request->getArr('add_person'); if (!empty($person_phids)) { $xactions[] = id(new ConpherenceTransaction())->setTransactionType(ConpherenceTransactionType::TYPE_PARTICIPANTS)->setNewValue(array('+' => $person_phids)); } break; case ConpherenceUpdateActions::REMOVE_PERSON: if (!$request->isContinueRequest()) { // do nothing; we'll display a confirmation dialogue instead break; } $person_phid = $request->getStr('remove_person'); if ($person_phid && $person_phid == $user->getPHID()) { $xactions[] = id(new ConpherenceTransaction())->setTransactionType(ConpherenceTransactionType::TYPE_PARTICIPANTS)->setNewValue(array('-' => array($person_phid))); $response_mode = 'go-home'; } break; case ConpherenceUpdateActions::NOTIFICATIONS: $notifications = $request->getStr('notifications'); $participant = $conpherence->getParticipant($user->getPHID()); $participant->setSettings(array('notifications' => $notifications)); $participant->save(); $result = pht('Updated notification settings to "%s".', ConpherenceSettings::getHumanString($notifications)); return id(new AphrontAjaxResponse())->setContent($result); break; case ConpherenceUpdateActions::METADATA: $updated = false; // all metadata updates are continue requests if (!$request->isContinueRequest()) { break; } $title = $request->getStr('title'); if ($title != $conpherence->getTitle()) { $xactions[] = id(new ConpherenceTransaction())->setTransactionType(ConpherenceTransactionType::TYPE_TITLE)->setNewValue($title); $updated = true; $response_mode = 'redirect'; } if (!$updated) { $errors[] = pht('That was a non-update. Try cancel.'); } break; case ConpherenceUpdateActions::LOAD: $updated = false; $response_mode = 'ajax'; break; default: throw new Exception('Unknown action: ' . $action); break; } if ($xactions || $action == ConpherenceUpdateActions::LOAD) { if ($xactions) { try { $xactions = $editor->applyTransactions($conpherence, $xactions); if ($delete_draft) { $draft = PhabricatorDraft::newFromUserAndKey($user, $conpherence->getPHID()); $draft->delete(); } } catch (PhabricatorApplicationTransactionNoEffectException $ex) { return id(new PhabricatorApplicationTransactionNoEffectResponse())->setCancelURI($this->getApplicationURI($conpherence_id . '/'))->setException($ex); } } switch ($response_mode) { case 'ajax': $latest_transaction_id = $request->getInt('latest_transaction_id'); $content = $this->loadAndRenderUpdates($action, $conpherence_id, $latest_transaction_id); return id(new AphrontAjaxResponse())->setContent($content); break; case 'go-home': return id(new AphrontRedirectResponse())->setURI($this->getApplicationURI()); break; case 'redirect': default: return id(new AphrontRedirectResponse())->setURI($this->getApplicationURI($conpherence->getID() . '/')); break; } } } if ($errors) { $error_view = id(new AphrontErrorView())->setErrors($errors); } switch ($action) { case ConpherenceUpdateActions::ADD_PERSON: $dialogue = $this->renderAddPersonDialogue($conpherence); break; case ConpherenceUpdateActions::REMOVE_PERSON: $dialogue = $this->renderRemovePersonDialogue($conpherence); break; case ConpherenceUpdateActions::METADATA: default: $dialogue = $this->renderMetadataDialogue($conpherence, $error_view); break; } return id(new AphrontDialogResponse())->setDialog($dialogue->setUser($user)->setWidth(AphrontDialogView::WIDTH_FORM)->setSubmitURI($this->getApplicationURI('update/' . $conpherence_id . '/'))->addSubmitButton()->addCancelButton($this->getApplicationURI($conpherence->getID() . '/'))); }
private function renderFormContent() { $conpherence = $this->getConpherence(); $user = $this->getRequest()->getUser(); $can_join = PhabricatorPolicyFilter::hasCapability($user, $conpherence, PhabricatorPolicyCapability::CAN_JOIN); $participating = $conpherence->getParticipantIfExists($user->getPHID()); if (!$can_join && !$participating && $user->isLoggedIn()) { return null; } $draft = PhabricatorDraft::newFromUserAndKey($user, $conpherence->getPHID()); $update_uri = $this->getApplicationURI('update/' . $conpherence->getID() . '/'); if ($user->isLoggedIn()) { $this->initBehavior('conpherence-pontificate'); if ($participating) { $action = ConpherenceUpdateActions::MESSAGE; $status = new PhabricatorNotificationStatusView(); } else { $action = ConpherenceUpdateActions::JOIN_ROOM; $status = pht('Sending a message will also join the room.'); } $form = id(new AphrontFormView())->setUser($user)->setAction($update_uri)->addSigil('conpherence-pontificate')->setWorkflow(true)->addHiddenInput('action', $action)->appendChild(id(new PhabricatorRemarkupControl())->setUser($user)->setName('text')->setValue($draft->getDraft())); $status_view = phutil_tag('div', array('class' => 'conpherence-room-status', 'id' => 'conpherence-room-status'), $status); $view = phutil_tag_div('pontificate-container', array($form, $status_view)); return $view; } else { // user not logged in so give them a login button. $login_href = id(new PhutilURI('/auth/start/'))->setQueryParam('next', '/' . $conpherence->getMonogram()); return id(new PHUIFormLayoutView())->addClass('login-to-participate')->appendInstructions(pht('Log in to join this room and participate.'))->appendChild(id(new PHUIButtonView())->setTag('a')->setText(pht('Login to Participate'))->setHref((string) $login_href)); } }
private function renderFormContent() { $conpherence = $this->getConpherence(); $user = $this->getRequest()->getUser(); $can_join = PhabricatorPolicyFilter::hasCapability($user, $conpherence, PhabricatorPolicyCapability::CAN_JOIN); $participating = $conpherence->getParticipantIfExists($user->getPHID()); if (!$can_join && !$participating && $user->isLoggedIn()) { return null; } $draft = PhabricatorDraft::newFromUserAndKey($user, $conpherence->getPHID()); if ($participating) { $action = ConpherenceUpdateActions::MESSAGE; $button_text = pht('Send'); } else { if ($user->isLoggedIn()) { $action = ConpherenceUpdateActions::JOIN_ROOM; $button_text = pht('Join Room'); } else { // user not logged in so give them a login button. $login_href = id(new PhutilURI('/auth/start/'))->setQueryParam('next', '/' . $conpherence->getMonogram()); return id(new PHUIFormLayoutView())->addClass('login-to-participate')->appendChild(id(new PHUIButtonView())->setTag('a')->setText(pht('Login to Participate'))->setHref((string) $login_href)); } } $update_uri = $this->getApplicationURI('update/' . $conpherence->getID() . '/'); $this->initBehavior('conpherence-pontificate'); $form = id(new AphrontFormView())->setUser($user)->setAction($update_uri)->addSigil('conpherence-pontificate')->setWorkflow(true)->addHiddenInput('action', $action)->appendChild(id(new PhabricatorRemarkupControl())->setUser($user)->setName('text')->setValue($draft->getDraft()))->appendChild(id(new AphrontFormSubmitControl())->setValue($button_text))->render(); return $form; }