3 final class PonderAnswerView
extends AphrontTagView
{
10 public function setAnswer($answer) {
11 $this->answer
= $answer;
15 public function setTransactions($transactions) {
16 $this->transactions
= $transactions;
20 public function setTimeline($timeline) {
21 $this->timeline
= $timeline;
25 public function setHandle($handle) {
26 $this->handle
= $handle;
30 protected function getTagAttributes() {
32 'class' => 'ponder-answer-view',
36 protected function getTagContent() {
37 require_celerity_resource('ponder-view-css');
38 $answer = $this->answer
;
39 $viewer = $this->getUser();
40 $status = $answer->getStatus();
41 $author_phid = $answer->getAuthorPHID();
42 $actions = $this->buildAnswerActions();
43 $handle = $this->handle
;
44 $id = $answer->getID();
46 if ($status == PonderAnswerStatus
::ANSWER_STATUS_HIDDEN
) {
47 $can_edit = PhabricatorPolicyFilter
::hasCapability(
50 PhabricatorPolicyCapability
::CAN_EDIT
);
53 $message[] = phutil_tag(
56 pht('This answer has been hidden.'));
59 $message[] = phutil_tag(
62 'href' => "/ponder/answer/edit/{$id}/",
66 $message = phutil_implode_html(' ', $message);
68 return id(new PHUIInfoView())
69 ->setSeverity(PHUIInfoView
::SEVERITY_NODATA
)
70 ->appendChild($message);
73 $action_button = id(new PHUIButtonView())
75 ->setText(pht('Actions'))
78 ->setDropdownMenu($actions);
80 $header_name = phutil_tag(
83 'href' => $handle->getURI(),
87 $header = id(new PHUIHeaderView())
89 ->setEpoch($answer->getDateModified())
90 ->setHeader($header_name)
91 ->addActionLink($action_button)
92 ->setImage($handle->getImageURI())
93 ->setImageURL($handle->getURI());
95 $content = phutil_tag(
98 'class' => 'phabricator-remarkup',
100 PhabricatorMarkupEngine
::renderOneObject(
102 $answer->getMarkupField(),
105 $anchor = id(new PhabricatorAnchorView())
106 ->setAnchorName("A$id");
108 $content_id = celerity_generate_unique_node_id();
109 $footer = id(new PonderFooterView())
110 ->setContentID($content_id)
111 ->setCount(count($this->transactions
));
113 $content = phutil_tag_div(
114 'ponder-answer-content', array($anchor, $content, $footer));
116 $answer_view = id(new PHUIObjectBoxView())
118 ->setBackground(PHUIObjectBoxView
::GREY
)
119 ->addClass('ponder-answer')
120 ->appendChild($content);
122 $comment_view = id(new PhabricatorApplicationTransactionCommentView())
124 ->setObjectPHID($answer->getPHID())
125 ->setShowPreview(false)
126 ->setHeaderText(pht('Answer Comment'))
127 ->setAction("/ponder/answer/comment/{$id}/")
128 ->setSubmitButtonName(pht('Comment'));
130 $hidden_view = phutil_tag(
134 'style' => 'display: none;',
147 private function buildAnswerActions() {
148 $viewer = $this->getUser();
149 $answer = $this->answer
;
150 $id = $answer->getID();
152 $can_edit = PhabricatorPolicyFilter
::hasCapability(
155 PhabricatorPolicyCapability
::CAN_EDIT
);
157 $view = id(new PhabricatorActionListView())
159 ->setObject($answer);
162 id(new PhabricatorActionView())
163 ->setIcon('fa-pencil')
164 ->setName(pht('Edit Answer'))
165 ->setHref("/ponder/answer/edit/{$id}/")
166 ->setDisabled(!$can_edit)
167 ->setWorkflow(!$can_edit));
170 id(new PhabricatorActionView())
172 ->setName(pht('View History'))
173 ->setHref("/ponder/answer/history/{$id}/"));