Differential D14642 Diff 35424 src/applications/phame/controller/post/PhamePostPublishController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phame/controller/post/PhamePostPublishController.php
- This file was copied to src/applications/phame/controller/post/PhamePostPreviewController.php.
Show All 12 Lines | $post = id(new PhamePostQuery()) | ||||
array( | array( | ||||
PhabricatorPolicyCapability::CAN_EDIT, | PhabricatorPolicyCapability::CAN_EDIT, | ||||
)) | )) | ||||
->executeOne(); | ->executeOne(); | ||||
if (!$post) { | if (!$post) { | ||||
return new Aphront404Response(); | return new Aphront404Response(); | ||||
} | } | ||||
$view_uri = $this->getApplicationURI('/post/view/'.$post->getID().'/'); | |||||
if ($request->isFormPost()) { | if ($request->isFormPost()) { | ||||
$xactions = array(); | $xactions = array(); | ||||
$xactions[] = id(new PhamePostTransaction()) | $xactions[] = id(new PhamePostTransaction()) | ||||
->setTransactionType(PhamePostTransaction::TYPE_VISIBILITY) | ->setTransactionType(PhamePostTransaction::TYPE_VISIBILITY) | ||||
->setNewValue(PhameConstants::VISIBILITY_PUBLISHED); | ->setNewValue(PhameConstants::VISIBILITY_PUBLISHED); | ||||
id(new PhamePostEditor()) | id(new PhamePostEditor()) | ||||
->setActor($viewer) | ->setActor($viewer) | ||||
->setContentSourceFromRequest($request) | ->setContentSourceFromRequest($request) | ||||
->setContinueOnNoEffect(true) | ->setContinueOnNoEffect(true) | ||||
->setContinueOnMissingFields(true) | ->setContinueOnMissingFields(true) | ||||
->applyTransactions($post, $xactions); | ->applyTransactions($post, $xactions); | ||||
return id(new AphrontRedirectResponse())->setURI($view_uri); | return id(new AphrontRedirectResponse()) | ||||
->setURI($this->getApplicationURI('/post/view/'.$post->getID().'/')); | |||||
} | } | ||||
$form = id(new AphrontFormView()) | $cancel_uri = $this->getApplicationURI('/post/view/'.$post->getID().'/'); | ||||
->setUser($viewer) | |||||
->appendChild( | |||||
id(new AphrontFormSubmitControl()) | |||||
->setValue(pht('Publish Post')) | |||||
->addCancelButton($view_uri)); | |||||
$frame = $this->renderPreviewFrame($post); | |||||
$form_box = id(new PHUIObjectBoxView()) | |||||
->setHeaderText(pht('Preview Post')) | |||||
->setForm($form); | |||||
$crumbs = $this->buildApplicationCrumbs(); | |||||
$crumbs->addTextCrumb(pht('Preview'), $view_uri); | |||||
return $this->newPage() | |||||
->setTitle(pht('Preview Post')) | |||||
->setCrumbs($crumbs) | |||||
->appendChild( | |||||
array( | |||||
$form_box, | |||||
$frame, | |||||
)); | |||||
} | |||||
private function renderPreviewFrame(PhamePost $post) { | $dialog = $this->newDialog() | ||||
->setTitle(pht('Publish Post?')) | |||||
->appendChild( | |||||
epriestley: Or `$this->newDialog()`. | |||||
pht( | |||||
'The post "%s" will go live once you publish it.', | |||||
$post->getTitle())) | |||||
->addSubmitButton(pht('Publish')) | |||||
->addCancelButton($cancel_uri); | |||||
return phutil_tag( | return id(new AphrontDialogResponse())->setDialog($dialog); | ||||
Done Inline ActionsOr just return $dialog. epriestley: Or just return `$dialog`. | |||||
'div', | |||||
array( | |||||
'style' => 'text-align: center; padding: 16px;', | |||||
), | |||||
phutil_tag( | |||||
'iframe', | |||||
array( | |||||
'style' => 'width: 100%; height: 600px; '. | |||||
'border: 1px solid #BFCFDA; '. | |||||
'background-color: #fff; '. | |||||
'border-radius: 3px; ', | |||||
'src' => $this->getApplicationURI('/post/framed/'.$post->getID().'/'), | |||||
), | |||||
'')); | |||||
} | } | ||||
} | } |
Or $this->newDialog().