2012-08-10 10:44:04 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PonderAddAnswerView extends AphrontView {
|
|
|
|
|
|
|
|
private $question;
|
|
|
|
private $user;
|
|
|
|
private $actionURI;
|
|
|
|
private $draft;
|
|
|
|
|
|
|
|
public function setQuestion($question) {
|
|
|
|
$this->question = $question;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setUser(PhabricatorUser $user) {
|
|
|
|
$this->user = $user;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setActionURI($uri) {
|
|
|
|
$this->actionURI = $uri;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function render() {
|
|
|
|
require_celerity_resource('ponder-core-view-css');
|
|
|
|
|
|
|
|
$is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
|
|
|
|
|
|
|
|
$question = $this->question;
|
|
|
|
|
2012-09-30 20:12:18 -07:00
|
|
|
$header = id(new PhabricatorHeaderView())
|
|
|
|
->setHeader('Add Answer');
|
2012-08-10 10:44:04 -07:00
|
|
|
|
|
|
|
$form = new AphrontFormView();
|
|
|
|
$form
|
2012-09-30 20:12:18 -07:00
|
|
|
->setFlexible(true)
|
2012-08-10 10:44:04 -07:00
|
|
|
->setUser($this->user)
|
|
|
|
->setAction($this->actionURI)
|
2012-09-17 13:48:36 -07:00
|
|
|
->setWorkflow(true)
|
2012-08-10 10:44:04 -07:00
|
|
|
->addHiddenInput('question_id', $question->getID())
|
|
|
|
->appendChild(
|
2012-09-19 12:27:28 -07:00
|
|
|
id(new PhabricatorRemarkupControl())
|
2012-08-10 10:44:04 -07:00
|
|
|
->setName('answer')
|
2012-09-30 20:12:18 -07:00
|
|
|
->setLabel('Answer')
|
|
|
|
->setError(true)
|
2012-10-08 13:26:57 -07:00
|
|
|
->setID('answer-content'))
|
2012-08-10 10:44:04 -07:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormSubmitControl())
|
|
|
|
->setValue($is_serious ? 'Submit' : 'Make it so.'));
|
|
|
|
|
2012-09-30 20:12:18 -07:00
|
|
|
$preview =
|
2012-08-10 10:44:04 -07:00
|
|
|
'<div class="aphront-panel-flush">'.
|
|
|
|
'<div id="answer-preview">'.
|
|
|
|
'<span class="aphront-panel-preview-loading-text">'.
|
|
|
|
'Loading answer preview...'.
|
|
|
|
'</span>'.
|
|
|
|
'</div>'.
|
2012-09-30 20:12:18 -07:00
|
|
|
'</div>';
|
2012-08-10 10:44:04 -07:00
|
|
|
|
|
|
|
Javelin::initBehavior(
|
|
|
|
'ponder-feedback-preview',
|
|
|
|
array(
|
|
|
|
'uri' => '/ponder/answer/preview/',
|
|
|
|
'content' => 'answer-content',
|
|
|
|
'preview' => 'answer-preview',
|
|
|
|
'question_id' => $question->getID()
|
|
|
|
));
|
|
|
|
|
2012-09-30 20:12:18 -07:00
|
|
|
return id(new AphrontNullView())
|
|
|
|
->appendChild(
|
|
|
|
array(
|
|
|
|
$header,
|
|
|
|
$form,
|
|
|
|
$preview,
|
|
|
|
))
|
|
|
|
->render();
|
2012-08-10 10:44:04 -07:00
|
|
|
}
|
|
|
|
}
|