]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/QnA/actions/qnashowquestion.php
Merge branch '1.1.x'
[quix0rs-gnu-social.git] / plugins / QnA / actions / qnashowquestion.php
index d128eeec2fcdef171fc144db3dbcff3c11df8ba8..ca2cb74ba1d751c2279b4c5db7007a39f154b02d 100644 (file)
@@ -57,7 +57,7 @@ class QnashowquestionAction extends ShownoticeAction
      */
     function prepare($argarray)
     {
-        OwnerDesignAction::prepare($argarray);
+        Action::prepare($argarray);
 
         $this->id = $this->trimmed('id');
 
@@ -97,7 +97,43 @@ class QnashowquestionAction extends ShownoticeAction
 
     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 = Notice::multiGet('id', $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');
     }
 
     /**
@@ -109,11 +145,13 @@ class QnashowquestionAction extends ShownoticeAction
      */
     function title()
     {
-        // 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(
+            // TRANS: Page title for a question.
+            // TRANS: %1$s is the nickname of the user who asked the question, %2$s is the question.
+            _m('%1$s\'s question: %2$s'),
+            $this->user->nickname,
+            $this->question->title
+        );
     }
 
     /**
@@ -124,7 +162,6 @@ class QnashowquestionAction extends ShownoticeAction
         return Action::lastModified();
     }
 
-
     /**
      * @fixme combine the notice time with question update time
      */