diff --git a/src/applications/pholio/controller/PholioInlineController.php b/src/applications/pholio/controller/PholioInlineController.php index 2a17af1bb7..385c4d4a43 100644 --- a/src/applications/pholio/controller/PholioInlineController.php +++ b/src/applications/pholio/controller/PholioInlineController.php @@ -26,15 +26,14 @@ final class PholioInlineController extends PholioController { $inlines = array(); + $engine = new PhabricatorMarkupEngine(); + foreach ($inline_comments as $inline_comment) { $inline_view = id(new PholioInlineCommentView()) + ->setUser($user) ->setHandle($authors[$inline_comment->getAuthorPHID()]) - ->setInlineComment($inline_comment); - - if ($inline_comment->getEditPolicy(PhabricatorPolicyCapability::CAN_EDIT) - == $user->getPHID() && $inline_comment->getTransactionPHID() === null) { - $inline_view->setEditable(true); - } + ->setInlineComment($inline_comment) + ->setEngine($engine); $inlines[] = $inline_comment->toDictionary() + array( 'contentHTML' => $inline_view->render(), diff --git a/src/applications/pholio/controller/PholioInlineSaveController.php b/src/applications/pholio/controller/PholioInlineSaveController.php index 087cbbbaa3..f1d87249d7 100644 --- a/src/applications/pholio/controller/PholioInlineSaveController.php +++ b/src/applications/pholio/controller/PholioInlineSaveController.php @@ -59,13 +59,13 @@ final class PholioInlineSaveController extends PholioController { $draft->save(); + $handle = head($this->loadViewerHandles(array($user->getPHID()))); + $inline_view = id(new PholioInlineCommentView()) ->setInlineComment($draft) - ->setEditable(true) - ->setHandle( - PhabricatorObjectHandleData::loadOneHandle( - $user->getPHID(), - $user)); + ->setEngine(new PhabricatorMarkupEngine()) + ->setUser($user) + ->setHandle($handle); return id(new AphrontAjaxResponse()) ->setContent( diff --git a/src/applications/pholio/controller/PholioInlineViewController.php b/src/applications/pholio/controller/PholioInlineViewController.php index 886e61f57a..42028f3b21 100644 --- a/src/applications/pholio/controller/PholioInlineViewController.php +++ b/src/applications/pholio/controller/PholioInlineViewController.php @@ -16,18 +16,14 @@ final class PholioInlineViewController extends PholioController { $user = $request->getUser(); $inline_comment = id(new PholioTransactionComment())->load($this->id); - $handle = PhabricatorObjectHandleData::loadOneHandle( - $inline_comment->getAuthorPHID(), - $user); + $handle = head($this->loadViewerHandles( + array($inline_comment->getAuthorPHID()))); $inline_view = id(new PholioInlineCommentView()) + ->setUser($user) ->setHandle($handle) - ->setInlineComment($inline_comment); - - if ($inline_comment->getEditPolicy(PhabricatorPolicyCapability::CAN_EDIT) - == $user->getPHID() && $inline_comment->getTransactionPHID() === null) { - $inline_view->setEditable(true); - } + ->setInlineComment($inline_comment) + ->setEngine(new PhabricatorMarkupEngine()); return id(new AphrontAjaxResponse())->setContent( $inline_comment->toDictionary() + array( diff --git a/src/applications/pholio/storage/PholioMock.php b/src/applications/pholio/storage/PholioMock.php index 739efa612e..11bfa75031 100644 --- a/src/applications/pholio/storage/PholioMock.php +++ b/src/applications/pholio/storage/PholioMock.php @@ -123,7 +123,13 @@ final class PholioMock extends PholioDAO } public function didMarkupText($field, $output, PhutilMarkupEngine $engine) { - return $output; + require_celerity_resource('phabricator-remarkup-css'); + return phutil_tag( + 'div', + array( + 'class' => 'phabricator-remarkup', + ), + $output); } public function shouldUseMarkupCache($field) { diff --git a/src/applications/pholio/storage/PholioTransactionComment.php b/src/applications/pholio/storage/PholioTransactionComment.php index ec4ebe4954..4517157a51 100644 --- a/src/applications/pholio/storage/PholioTransactionComment.php +++ b/src/applications/pholio/storage/PholioTransactionComment.php @@ -11,6 +11,7 @@ final class PholioTransactionComment protected $y; protected $width; protected $height; + protected $content; public function getApplicationTransactionObject() { return new PholioTransaction(); @@ -28,4 +29,8 @@ final class PholioTransactionComment ); } + public function shouldUseMarkupCache($field) { + // Only cache submitted comments. + return ($this->getTransactionPHID() != null); + } } diff --git a/src/applications/pholio/view/PholioInlineCommentView.php b/src/applications/pholio/view/PholioInlineCommentView.php index eb2707083f..2fa0bd8515 100644 --- a/src/applications/pholio/view/PholioInlineCommentView.php +++ b/src/applications/pholio/view/PholioInlineCommentView.php @@ -2,10 +2,19 @@ final class PholioInlineCommentView extends AphrontView { + private $engine; + private $handle; private $inlineComment; - private $handle; - private $editable; + public function setEngine(PhabricatorMarkupEngine $engine) { + $this->engine = $engine; + return $this; + } + + public function setHandle(PhabricatorObjectHandle $handle) { + $this->handle = $handle; + return $this; + } public function setInlineComment(PholioTransactionComment $inline_comment) { if ($inline_comment->getImageID() === null) { @@ -16,24 +25,26 @@ final class PholioInlineCommentView extends AphrontView { return $this; } - public function setHandle(PhabricatorObjectHandle $handle) { - $this->handle = $handle; - return $this; - } - - public function setEditable($editable) { - $this->editable = $editable; - return $this; - } - public function render() { if (!$this->inlineComment) { throw new Exception("Call setInlineComment() before render()!"); } + if ($this->user === null) { + throw new Exception("Call setUser() before render()!"); + } + if ($this->engine === null) { + throw new Exception("Call setEngine() before render()!"); + } + if ($this->handle === null) { + throw new Exception("Call setHandle() before render()!"); + } $actions = null; - if ($this->editable) { + if ($this->inlineComment->getTransactionPHID() === null && + $this->inlineComment->getEditPolicy( + PhabricatorPolicyCapability::CAN_EDIT) == $this->user->getPHID()) { + $edit_action = javelin_tag( 'a', array( @@ -74,12 +85,16 @@ final class PholioInlineCommentView extends AphrontView { ), array($this->handle->getName(), $actions)); + + $comment = $this->engine->renderOneObject( + $this->inlineComment, + PholioTransactionComment::MARKUP_FIELD_COMMENT, + $this->user); + $comment_body = phutil_tag( 'div', - array( - - ), - $this->inlineComment->getContent()); + array(), + $comment); $comment_block = javelin_tag( 'div', diff --git a/src/applications/pholio/view/PholioMockImagesView.php b/src/applications/pholio/view/PholioMockImagesView.php index 1764244dd5..8ff70e96f3 100644 --- a/src/applications/pholio/view/PholioMockImagesView.php +++ b/src/applications/pholio/view/PholioMockImagesView.php @@ -74,7 +74,7 @@ final class PholioMockImagesView extends AphrontView { ), array($mock_wrapper, $inline_comments_holder)); - if (count($mock->getImages()) > 1) { + if (count($mock->getImages()) > 0) { $thumbnails = array(); foreach ($mock->getImages() as $image) { $thumbfile = $image->getFile();