3 final class PhabricatorFileLightboxController
4 extends PhabricatorFileController
{
6 public function shouldAllowPublic() {
10 public function handleRequest(AphrontRequest
$request) {
11 $viewer = $request->getViewer();
12 $phid = $request->getURIData('phid');
13 $comment = $request->getStr('comment');
15 $file = id(new PhabricatorFileQuery())
17 ->withPHIDs(array($phid))
20 return new Aphront404Response();
23 if ($comment !== null && strlen($comment)) {
25 $xactions[] = id(new PhabricatorFileTransaction())
26 ->setTransactionType(PhabricatorTransactions
::TYPE_COMMENT
)
28 id(new PhabricatorFileTransactionComment())
29 ->setContent($comment));
31 $editor = id(new PhabricatorFileEditor())
33 ->setContinueOnNoEffect(true)
34 ->setContentSourceFromRequest($request);
36 $editor->applyTransactions($file, $xactions);
39 $transactions = id(new PhabricatorFileTransactionQuery())
40 ->withTransactionTypes(array(PhabricatorTransactions
::TYPE_COMMENT
));
41 $timeline = $this->buildTransactionTimeline($file, $transactions);
43 $comment_form = $this->renderCommentForm($file);
48 'class' => 'phui-comment-panel-header',
52 require_celerity_resource('phui-comment-panel-css');
53 $content = phutil_tag(
56 'class' => 'phui-comment-panel',
64 return id(new AphrontAjaxResponse())
65 ->setContent($content);
68 private function renderCommentForm(PhabricatorFile
$file) {
69 $viewer = $this->getViewer();
71 if (!$viewer->isLoggedIn()) {
72 $login_href = id(new PhutilURI('/auth/start/'))
73 ->replaceQueryParam('next', '/'.$file->getMonogram());
74 return id(new PHUIFormLayoutView())
75 ->addClass('phui-comment-panel-empty')
77 id(new PHUIButtonView())
79 ->setText(pht('Log In to Comment'))
80 ->setHref((string)$login_href));
83 $draft = PhabricatorDraft
::newFromUserAndKey(
86 $post_uri = $this->getApplicationURI('thread/'.$file->getPHID().'/');
88 $form = id(new AphrontFormView())
90 ->setAction($post_uri)
91 ->addSigil('lightbox-comment-form')
92 ->addClass('lightbox-comment-form')
95 id(new PhabricatorRemarkupControl())
98 ->setValue($draft->getDraft()))
100 id(new AphrontFormSubmitControl())
101 ->setValue(pht('Comment')));
103 $view = phutil_tag_div('phui-comment-panel', $form);