+
+ return $a->count();
+ }
+
+ static function fromNotice($notice)
+ {
+ return QnA_Question::getKV('uri', $notice->uri);
+ }
+
+ function asHTML()
+ {
+ return self::toHTML($this->getProfile(), $this);
+ }
+
+ function asString()
+ {
+ return self::toString($this->getProfile(), $this);
+ }
+
+ static function toHTML($profile, $question)
+ {
+ $notice = $question->getNotice();
+
+ $out = new XMLStringer();
+
+ $cls = array('qna_question');
+
+ if (!empty($question->closed)) {
+ $cls[] = 'closed';
+ }
+
+ $out->elementStart('p', array('class' => implode(' ', $cls)));
+
+ if (!empty($question->description)) {
+ $out->elementStart('span', 'question-description');
+ $out->raw(common_render_text($question->description));
+ $out->elementEnd('span');
+ }
+
+ $cnt = $question->countAnswers();
+
+ if (!empty($cnt)) {
+ $out->elementStart('span', 'answer-count');
+ // TRANS: Number of given answers to a question.
+ // TRANS: %s is the number of given answers.
+ $out->text(sprintf(_m('%s answer','%s answers',$cnt), $cnt));
+ $out->elementEnd('span');
+ }
+
+ if (!empty($question->closed)) {
+ $out->elementStart('span', 'question-closed');
+ // TRANS: Notification that a question cannot be answered anymore because it is closed.
+ $out->text(_m('This question is closed.'));
+ $out->elementEnd('span');
+ }
+
+ $out->elementEnd('p');
+
+ return $out->getString();
+ }
+
+ static function toString($profile, $question, $answers)
+ {
+ return sprintf(htmlspecialchars($question->description));