3 final class PonderAddAnswerView
extends AphrontView
{
9 public function setQuestion($question) {
10 $this->question
= $question;
14 public function setActionURI($uri) {
15 $this->actionURI
= $uri;
19 public function render() {
20 $question = $this->question
;
21 $viewer = $this->getViewer();
23 $authors = mpull($question->getAnswers(), null, 'getAuthorPHID');
24 if (isset($authors[$viewer->getPHID()])) {
25 $view = id(new PHUIInfoView())
26 ->setSeverity(PHUIInfoView
::SEVERITY_NOTICE
)
27 ->setTitle(pht('Already Answered'))
30 'You have already answered this question. You can not answer '.
31 'twice, but you can edit your existing answer.'));
32 return phutil_tag_div('ponder-add-answer-view', $view);
36 if ($question->getStatus() != PonderQuestionStatus
::STATUS_OPEN
) {
37 $info_panel = id(new PHUIInfoView())
38 ->setSeverity(PHUIInfoView
::SEVERITY_NOTICE
)
41 'This question has been marked as closed,
42 but you can still leave a new answer.'));
46 $header = id(new PHUIHeaderView())
47 ->setHeader(pht('New Answer'))
48 ->addClass('ponder-add-answer-header');
50 $form = new AphrontFormView();
53 ->setAction($this->actionURI
)
55 ->addHiddenInput('question_id', $question->getID())
57 id(new PhabricatorRemarkupControl())
59 ->setLabel(pht('Answer'))
61 ->setID('answer-content')
64 id(new AphrontFormSubmitControl())
65 ->setValue(pht('Add Answer')));
67 if (!$viewer->isLoggedIn()) {
68 $login_href = id(new PhutilURI('/auth/start/'))
69 ->replaceQueryParam('next', '/Q'.$question->getID());
70 $form = id(new PHUIFormLayoutView())
71 ->addClass('login-to-participate')
73 id(new PHUIButtonView())
75 ->setText(pht('Log In to Answer'))
76 ->setHref((string)$login_href));
79 $box = id(new PHUIObjectBoxView())
81 ->setHeaderText(pht('Answer'))
82 ->addClass('ponder-add-answer-view');
85 $box->setInfoView($info_panel);
88 return array($header, $box);