2012-02-24 14:14:39 -08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class DiffusionCommentListView extends AphrontView {
|
|
|
|
|
|
|
|
private $comments;
|
2012-03-19 19:56:06 -07:00
|
|
|
private $inlineComments = array();
|
|
|
|
private $pathMap = array();
|
2012-10-03 13:32:49 -07:00
|
|
|
private $handles = array();
|
2012-10-23 17:46:44 -07:00
|
|
|
private $markupEngine;
|
2012-02-24 14:14:39 -08:00
|
|
|
|
|
|
|
public function setComments(array $comments) {
|
2012-04-03 16:22:31 -07:00
|
|
|
assert_instances_of($comments, 'PhabricatorAuditComment');
|
2012-02-24 14:14:39 -08:00
|
|
|
$this->comments = $comments;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2012-03-19 19:56:06 -07:00
|
|
|
public function setInlineComments(array $inline_comments) {
|
2012-04-04 13:13:08 -07:00
|
|
|
assert_instances_of($inline_comments, 'PhabricatorInlineCommentInterface');
|
2012-03-19 19:56:06 -07:00
|
|
|
$this->inlineComments = $inline_comments;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setPathMap(array $path_map) {
|
|
|
|
$this->pathMap = $path_map;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2012-10-23 17:46:44 -07:00
|
|
|
public function setMarkupEngine(PhabricatorMarkupEngine $markup_engine) {
|
|
|
|
$this->markupEngine = $markup_engine;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getMarkupEngine() {
|
|
|
|
return $this->markupEngine;
|
|
|
|
}
|
|
|
|
|
2012-02-24 14:14:39 -08:00
|
|
|
public function getRequiredHandlePHIDs() {
|
|
|
|
$phids = array();
|
|
|
|
foreach ($this->comments as $comment) {
|
|
|
|
$phids[$comment->getActorPHID()] = true;
|
2012-04-23 13:50:04 -07:00
|
|
|
$metadata = $comment->getMetaData();
|
|
|
|
|
|
|
|
$ccs_key = PhabricatorAuditComment::METADATA_ADDED_CCS;
|
|
|
|
$added_ccs = idx($metadata, $ccs_key, array());
|
|
|
|
foreach ($added_ccs as $cc) {
|
|
|
|
$phids[$cc] = true;
|
|
|
|
}
|
|
|
|
$auditors_key = PhabricatorAuditComment::METADATA_ADDED_AUDITORS;
|
|
|
|
$added_auditors = idx($metadata, $auditors_key, array());
|
|
|
|
foreach ($added_auditors as $auditor) {
|
|
|
|
$phids[$auditor] = true;
|
|
|
|
}
|
2012-02-24 14:14:39 -08:00
|
|
|
}
|
2012-03-19 19:56:06 -07:00
|
|
|
foreach ($this->inlineComments as $comment) {
|
|
|
|
$phids[$comment->getAuthorPHID()] = true;
|
|
|
|
}
|
2012-02-24 14:14:39 -08:00
|
|
|
return array_keys($phids);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setHandles(array $handles) {
|
2012-04-03 16:22:31 -07:00
|
|
|
assert_instances_of($handles, 'PhabricatorObjectHandle');
|
2012-02-24 14:14:39 -08:00
|
|
|
$this->handles = $handles;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function render() {
|
|
|
|
|
2012-03-19 19:56:06 -07:00
|
|
|
$inline_comments = mgroup($this->inlineComments, 'getAuditCommentID');
|
|
|
|
|
2012-02-24 14:14:39 -08:00
|
|
|
$num = 1;
|
|
|
|
|
|
|
|
$comments = array();
|
|
|
|
foreach ($this->comments as $comment) {
|
2012-03-19 19:56:06 -07:00
|
|
|
|
|
|
|
$inlines = idx($inline_comments, $comment->getID(), array());
|
|
|
|
|
2012-02-24 14:14:39 -08:00
|
|
|
$view = id(new DiffusionCommentView())
|
2012-10-23 17:46:44 -07:00
|
|
|
->setMarkupEngine($this->getMarkupEngine())
|
2012-02-24 14:14:39 -08:00
|
|
|
->setComment($comment)
|
2012-03-19 19:56:06 -07:00
|
|
|
->setInlineComments($inlines)
|
2012-02-24 14:14:39 -08:00
|
|
|
->setCommentNumber($num)
|
|
|
|
->setHandles($this->handles)
|
2012-03-19 19:56:06 -07:00
|
|
|
->setPathMap($this->pathMap)
|
2012-02-24 14:14:39 -08:00
|
|
|
->setUser($this->user);
|
|
|
|
|
|
|
|
$comments[] = $view->render();
|
|
|
|
++$num;
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
'<div class="diffusion-comment-list">'.
|
|
|
|
$this->renderSingleView($comments).
|
|
|
|
'</div>';
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|