Path: blob/master/src/applications/nuance/source/NuancePhabricatorFormSourceDefinition.php
12256 views
<?php12final class NuancePhabricatorFormSourceDefinition3extends NuanceSourceDefinition {45public function getName() {6return pht('Web Form');7}89public function getSourceDescription() {10return pht('Create a web form that submits into a Nuance queue.');11}1213public function getSourceTypeConstant() {14return 'phabricator-form';15}1617public function getSourceViewActions(AphrontRequest $request) {18$actions = array();1920$actions[] = id(new PhabricatorActionView())21->setName(pht('View Form'))22->setIcon('fa-align-justify')23->setHref($this->getActionURI());2425return $actions;26}2728public function handleActionRequest(AphrontRequest $request) {29$viewer = $request->getViewer();3031// TODO: As above, this would eventually be driven by custom logic.3233if ($request->isFormPost()) {34$properties = array(35'complaint' => (string)$request->getStr('complaint'),36);3738$content_source = PhabricatorContentSource::newFromRequest($request);3940$item = $this->newItemFromProperties(41NuanceFormItemType::ITEMTYPE,42$viewer->getPHID(),43$properties,44$content_source);4546$uri = $item->getURI();47return id(new AphrontRedirectResponse())->setURI($uri);48}4950$form = id(new AphrontFormView())51->setUser($viewer)52->appendRemarkupInstructions(53pht('IMPORTANT: This is a very rough prototype.'))54->appendRemarkupInstructions(55pht('Got a complaint? Complain here! We love complaints.'))56->appendChild(57id(new AphrontFormTextAreaControl())58->setName('complaint')59->setLabel(pht('Complaint')))60->appendChild(61id(new AphrontFormSubmitControl())62->setValue(pht('Submit Complaint')));6364$box = id(new PHUIObjectBoxView())65->setHeaderText(pht('Complaint Form'))66->appendChild($form);6768return $box;69}7071public function renderItemEditProperties(72PhabricatorUser $viewer,73NuanceItem $item,74PHUIPropertyListView $view) {75$this->renderItemCommonProperties($viewer, $item, $view);76}7778private function renderItemCommonProperties(79PhabricatorUser $viewer,80NuanceItem $item,81PHUIPropertyListView $view) {8283$complaint = $item->getItemProperty('complaint');84$complaint = new PHUIRemarkupView($viewer, $complaint);85$view->addSectionHeader(86pht('Complaint'), 'fa-exclamation-circle');87$view->addTextContent($complaint);88}8990}919293