@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at upstream/main 91 lines 2.5 kB view raw
1<?php 2 3final class NuancePhabricatorFormSourceDefinition 4 extends NuanceSourceDefinition { 5 6 public function getName() { 7 return pht('Web Form'); 8 } 9 10 public function getSourceDescription() { 11 return pht('Create a web form that submits into a Nuance queue.'); 12 } 13 14 public function getSourceTypeConstant() { 15 return 'phabricator-form'; 16 } 17 18 public function getSourceViewActions(AphrontRequest $request) { 19 $actions = array(); 20 21 $actions[] = id(new PhabricatorActionView()) 22 ->setName(pht('View Form')) 23 ->setIcon('fa-align-justify') 24 ->setHref($this->getActionURI()); 25 26 return $actions; 27 } 28 29 public function handleActionRequest(AphrontRequest $request) { 30 $viewer = $request->getViewer(); 31 32 // TODO: As above, this would eventually be driven by custom logic. 33 34 if ($request->isFormPost()) { 35 $properties = array( 36 'complaint' => (string)$request->getStr('complaint'), 37 ); 38 39 $content_source = PhabricatorContentSource::newFromRequest($request); 40 41 $item = $this->newItemFromProperties( 42 NuanceFormItemType::ITEMTYPE, 43 $viewer->getPHID(), 44 $properties, 45 $content_source); 46 47 $uri = $item->getURI(); 48 return id(new AphrontRedirectResponse())->setURI($uri); 49 } 50 51 $form = id(new AphrontFormView()) 52 ->setUser($viewer) 53 ->appendRemarkupInstructions( 54 pht('IMPORTANT: This is a very rough prototype.')) 55 ->appendRemarkupInstructions( 56 pht('Got a complaint? Complain here! We love complaints.')) 57 ->appendChild( 58 id(new AphrontFormTextAreaControl()) 59 ->setName('complaint') 60 ->setLabel(pht('Complaint'))) 61 ->appendChild( 62 id(new AphrontFormSubmitControl()) 63 ->setValue(pht('Submit Complaint'))); 64 65 $box = id(new PHUIObjectBoxView()) 66 ->setHeaderText(pht('Complaint Form')) 67 ->appendChild($form); 68 69 return $box; 70 } 71 72 public function renderItemEditProperties( 73 PhabricatorUser $viewer, 74 NuanceItem $item, 75 PHUIPropertyListView $view) { 76 $this->renderItemCommonProperties($viewer, $item, $view); 77 } 78 79 private function renderItemCommonProperties( 80 PhabricatorUser $viewer, 81 NuanceItem $item, 82 PHUIPropertyListView $view) { 83 84 $complaint = $item->getItemProperty('complaint'); 85 $complaint = new PHUIRemarkupView($viewer, $complaint); 86 $view->addSectionHeader( 87 pht('Complaint'), 'fa-exclamation-circle'); 88 $view->addTextContent($complaint); 89 } 90 91}