function showContent()
{
+ $this->elementStart('div', 'qna-full-question');
$this->raw($this->question->asHTML());
+
+ $answer = $this->question->getAnswers();
+
+ $this->elementStart('div', 'qna-full-question-answers');
+
+ $answerIds = array();
+
+ // @fixme use a filtered stream!
+
+ if (!empty($answer)) {
+ while ($answer->fetch()) {
+ $answerIds[] = $answer->getNotice()->id;
+ }
+ }
+
+ if (count($answerIds) > 0) {
+ $notice = new Notice();
+ $notice->query(
+ sprintf(
+ 'SELECT notice.* FROM notice WHERE notice.id IN (%s)',
+ implode(',', $answerIds)
+ )
+ );
+
+ $nli = new NoticeList($notice, $this);
+ $nli->show();
+ }
+
+ $user = common_current_user();
+
+ if (!empty($user)) {
+ $profile = $user->getProfile();
+ $answer = QnA_Question::getAnswer($profile);
+ if (empty($answer)) {
+ $form = new QnanewanswerForm($this, $this->question, false);
+ $form->show();
+ }
+ }
+
+ $this->elementEnd('div');
+ $this->elementEnd('div');
}
/**
{
// TRANS: Page title for a question.
// TRANS: %1$s is the nickname of the user who asked the question, %2$s is the question.
- return sprintf(_m('%1$s\'s question: %2$s'),
- $this->user->nickname,
- $this->question->title);
+ return sprintf(
+ _m('%1$s\'s question: %2$s'),
+ $this->user->nickname,
+ $this->question->title
+ );
}
/**
return Notice::staticGet('uri', $this->uri);
}
+ static function fromNotice($notice)
+ {
+ return QnA_Answer::staticGet('uri', $notice->uri);
+ }
+
function bestUrl()
{
return $this->getNotice()->bestUrl();
class QnanewanswerForm extends Form
{
protected $question;
+ protected $showQuestion;
/**
* Construct a new answer form
*
* @return void
*/
- function __construct(HTMLOutputter $out, QnA_Question $question)
+ function __construct(HTMLOutputter $out, QnA_Question $question, $showQuestion = true)
{
parent::__construct($out);
$this->question = $question;
+ $this->showQuestion = $showQuestion;
}
/**
$out = $this->out;
$id = "question-" . $question->id;
- $out->raw($this->question->asHTML());
+ if ($this->showQuestion) {
+ $out->raw($this->question->asHTML());
+ }
- $out->element('p', 'answer', 'Your answer');
$out->hidden('id', $id);
$out->textarea('answer', 'answer');
}
class QnashowanswerForm extends Form
{
/**
- * The answer to revise
+ * The answer to show
*/
- var $answer = null;
+ protected $answer = null;
/**
* The question this is an answer to
*/
- var $question = null;
+ protected $question = null;
/**
* Constructor
*/
function id()
{
- return 'revise-' . $this->answer->id;
+ return 'show-' . $this->answer->id;
}
/**
*/
function formLegend()
{
- // TRANS: Form legend for revising the answer.
- $this->out->element('legend', null, _('Revise your answer'));
+ // TRANS: Form legend for showing the answer.
+ $this->out->element('legend', null, _('Answer'));
}
/**
{
$this->out->hidden(
'id',
- 'revise-' . $this->answer->id
+ 'answer-' . $this->answer->id
);
-
- $this->out->raw($this->answer->asHTML());
+
+
+
+ // $this->out->raw($this->answer->asHTML());
}
/**
*/
function formClass()
{
- return 'form_revise ajax';
+ return 'form_show ajax';
}
}