diff --git a/src/applications/audit/controller/PhabricatorAuditPreviewController.php b/src/applications/audit/controller/PhabricatorAuditPreviewController.php index 4e8f3c688b..98c853d688 100644 --- a/src/applications/audit/controller/PhabricatorAuditPreviewController.php +++ b/src/applications/audit/controller/PhabricatorAuditPreviewController.php @@ -61,7 +61,15 @@ final class PhabricatorAuditPreviewController $phids = array_merge($phids, $ccs); } + $engine = new PhabricatorMarkupEngine(); + $engine->setViewer($user); + $engine->addObject( + $comment, + PhabricatorAuditComment::MARKUP_FIELD_BODY); + $engine->process(); + $view = id(new DiffusionCommentView()) + ->setMarkupEngine($engine) ->setUser($user) ->setComment($comment) ->setIsPreview(true); diff --git a/src/applications/audit/storage/PhabricatorAuditComment.php b/src/applications/audit/storage/PhabricatorAuditComment.php index 1a02343fc4..9ad70ecd1a 100644 --- a/src/applications/audit/storage/PhabricatorAuditComment.php +++ b/src/applications/audit/storage/PhabricatorAuditComment.php @@ -16,11 +16,14 @@ * limitations under the License. */ -final class PhabricatorAuditComment extends PhabricatorAuditDAO { +final class PhabricatorAuditComment extends PhabricatorAuditDAO + implements PhabricatorMarkupInterface { const METADATA_ADDED_AUDITORS = 'added-auditors'; const METADATA_ADDED_CCS = 'added-ccs'; + const MARKUP_FIELD_BODY = 'markup:body'; + protected $phid; protected $actorPHID; protected $targetPHID; @@ -41,4 +44,28 @@ final class PhabricatorAuditComment extends PhabricatorAuditDAO { return PhabricatorPHID::generateNewPHID('ACMT'); } + +/* -( PhabricatorMarkupInterface Implementation )-------------------------- */ + + + public function getMarkupFieldKey($field) { + return 'AC:'.$this->getID(); + } + + public function newMarkupEngine($field) { + return PhabricatorMarkupEngine::newDiffusionMarkupEngine(); + } + + public function getMarkupText($field) { + return $this->getContent(); + } + + public function didMarkupText($field, $output, PhutilMarkupEngine $engine) { + return $output; + } + + public function shouldUseMarkupCache($field) { + return (bool)$this->getID(); + } + } diff --git a/src/applications/diffusion/controller/DiffusionCommitController.php b/src/applications/diffusion/controller/DiffusionCommitController.php index 829889bbf7..b9fe53ed84 100644 --- a/src/applications/diffusion/controller/DiffusionCommitController.php +++ b/src/applications/diffusion/controller/DiffusionCommitController.php @@ -498,7 +498,25 @@ final class DiffusionCommitController extends DiffusionController { $path_map = ipull($path_map, 'path', 'id'); } + $engine = new PhabricatorMarkupEngine(); + $engine->setViewer($user); + + foreach ($comments as $comment) { + $engine->addObject( + $comment, + PhabricatorAuditComment::MARKUP_FIELD_BODY); + } + + foreach ($inlines as $inline) { + $engine->addObject( + $inline, + PhabricatorInlineCommentInterface::MARKUP_FIELD_BODY); + } + + $engine->process(); + $view = new DiffusionCommentListView(); + $view->setMarkupEngine($engine); $view->setUser($user); $view->setComments($comments); $view->setInlineComments($inlines); diff --git a/src/applications/diffusion/view/DiffusionCommentListView.php b/src/applications/diffusion/view/DiffusionCommentListView.php index 713a2a300e..0f5b1e0a48 100644 --- a/src/applications/diffusion/view/DiffusionCommentListView.php +++ b/src/applications/diffusion/view/DiffusionCommentListView.php @@ -23,6 +23,7 @@ final class DiffusionCommentListView extends AphrontView { private $inlineComments = array(); private $pathMap = array(); private $handles = array(); + private $markupEngine; public function setUser(PhabricatorUser $user) { $this->user = $user; @@ -46,6 +47,15 @@ final class DiffusionCommentListView extends AphrontView { return $this; } + public function setMarkupEngine(PhabricatorMarkupEngine $markup_engine) { + $this->markupEngine = $markup_engine; + return $this; + } + + public function getMarkupEngine() { + return $this->markupEngine; + } + public function getRequiredHandlePHIDs() { $phids = array(); foreach ($this->comments as $comment) { @@ -87,6 +97,7 @@ final class DiffusionCommentListView extends AphrontView { $inlines = idx($inline_comments, $comment->getID(), array()); $view = id(new DiffusionCommentView()) + ->setMarkupEngine($this->getMarkupEngine()) ->setComment($comment) ->setInlineComments($inlines) ->setCommentNumber($num) diff --git a/src/applications/diffusion/view/DiffusionCommentView.php b/src/applications/diffusion/view/DiffusionCommentView.php index 46aedc8219..42ef8a11f0 100644 --- a/src/applications/diffusion/view/DiffusionCommentView.php +++ b/src/applications/diffusion/view/DiffusionCommentView.php @@ -26,8 +26,7 @@ final class DiffusionCommentView extends AphrontView { private $pathMap; private $inlineComments; - - private $engine; + private $markupEngine; public function setUser(PhabricatorUser $user) { $this->user = $user; @@ -66,6 +65,15 @@ final class DiffusionCommentView extends AphrontView { return $this; } + public function setMarkupEngine(PhabricatorMarkupEngine $markup_engine) { + $this->markupEngine = $markup_engine; + return $this; + } + + public function getMarkupEngine() { + return $this->markupEngine; + } + public function getRequiredHandlePHIDs() { return array($this->comment->getActorPHID()); } @@ -146,14 +154,16 @@ final class DiffusionCommentView extends AphrontView { private function renderContent() { $comment = $this->comment; - $engine = $this->getEngine(); + $engine = $this->getMarkupEngine(); if (!strlen($comment->getContent()) && empty($this->inlineComments)) { return null; } else { return '