示例#1
0
 /**
  * Show an Ajax-y answer form
  *
  * Goes back to the browser, where it's shown in a popup.
  *
  * @param string $msg Message to show
  *
  * @return void
  */
 function ajaxShowForm()
 {
     common_debug('ajaxShowForm()');
     $this->startHTML('text/xml;charset=utf-8', true);
     $this->elementStart('head');
     // TRANS: Title for form to send answer to a question.
     $this->element('title', null, _m('TITLE', 'Your answer'));
     $this->elementEnd('head');
     $this->elementStart('body');
     $form = new QnanewanswerForm($this, $this->question);
     $form->show();
     $this->elementEnd('body');
     $this->elementEnd('html');
 }
 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');
 }