123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- <?php
- if (!defined('STATUSNET')) {
-
-
- exit(1);
- }
- class QnAListItem extends NoticeListItemAdapter
- {
-
- function showNotice(Notice $notice, $out)
- {
- switch ($notice->object_type) {
- case QnA_Question::OBJECT_TYPE:
- return $this->showNoticeQuestion($notice, $out);
- case QnA_Answer::OBJECT_TYPE:
- return $this->showNoticeAnswer($notice, $out);
- default:
- throw new Exception(
-
-
- sprintf(_m('Unexpected type for QnA plugin: %s.'),
- $notice->object_type
- )
- );
- }
- }
- function showNoticeQuestion(Notice $notice, $out)
- {
- $user = common_current_user();
-
- $nli = new NoticeListItem($notice, $out);
- $nli->showNotice();
- $out->elementStart('div', array('class' => 'e-content question-description'));
- $question = QnA_Question::getByNotice($notice);
- if (!empty($question)) {
- $form = new QnashowquestionForm($out, $question);
- $form->show();
- } else {
-
- $out->text(_m('Question data is missing.'));
- }
- $out->elementEnd('div');
-
- $out->elementStart('div', array('class' => 'e-content'));
- }
- function showNoticeAnswer(Notice $notice, $out)
- {
- $user = common_current_user();
- $answer = QnA_Answer::getByNotice($notice);
- $question = $answer->getQuestion();
- $nli = new NoticeListItem($notice, $out);
- $nli->showNotice();
- $out->elementStart('div', array('class' => 'e-content answer-content'));
- if (!empty($answer)) {
- $form = new QnashowanswerForm($out, $answer);
- $form->show();
- } else {
-
- $out->text(_m('Answer data is missing.'));
- }
- $out->elementEnd('div');
-
- $out->elementStart('div', array('class' => 'e-content'));
- }
- }
|