示例#1
0
    <?php 
if ($answer['accepted']) {
    ?>
        <img src='<?php 
    echo $this->url->asset("img/chk-mark-home-64px.png");
    ?>
' alt="Bra" />
    <?php 
}
?>
    <?php 
echo $this->textFilter->doFilter($answer['content'], 'shortcode, markdown');
?>
    <div class="user-card-answer">
        <p>
            svarade <a href='<?php 
echo $this->url->create('users/profid/' . $user['id']);
?>
'>
                <?php 
echo $user['name'];
?>
            </a> <?php 
echo \Anax\CommentDb\CommentsInDb::humanTiming($answer['created']);
?>
 sedan.
        </p>
    </div>
</div>
<div class="clear"></div>
示例#2
0
    ?>
        <?php 
    foreach ($comments as $comment) {
        ?>
            <div class="comment">
                <?php 
        echo $this->textFilter->doFilter($comment['comment']['content'], 'shortcode, markdown');
        ?>
                <p>
                    - <a href='<?php 
        echo $this->url->create('users/id/' . $comment['user']['id']);
        ?>
'>
                        <?php 
        echo $comment['user']['name'];
        ?>
                    </a>
                    <?php 
        echo \Anax\CommentDb\CommentsInDb::humanTiming($comment['comment']['created']);
        ?>
 sedan.
                </p>
            </div>
        <?php 
    }
    ?>
    <?php 
}
?>
</div>
示例#3
0
 /**
  * List single question
  *
  * @param int $id of question to display
  *
  * @return void
  */
 public function singleAction($id = null)
 {
     $question = $this->questions->query()->where('id = ' . "'{$id}'")->execute()[0];
     // Add view with the question.
     $this->theme->setTitle("{$question->headline}");
     $this->views->add('questions/single', ['question' => $question]);
     // Add view with the questions tags
     $this->dispatcher->forward(['controller' => 'tags', 'action' => 'question', 'params' => [$question->id]]);
     // Add view with user card.
     $humanTime = \Anax\CommentDb\CommentsInDb::humanTiming($question->created);
     $text = "Frågade för {$humanTime} sedan";
     $this->dispatcher->forward(['controller' => 'users', 'action' => 'card', 'params' => [$question->user_id, 'q', $text]]);
     // Add view to comment question, form visible when logged in and clicking link.
     $this->showFormCommentOrAnswer('comment_question', 'comment', $question->id, 'Kommentera ', 'q');
     // Add view to answer question, form visible when logged in and clicking link.
     $this->showFormCommentOrAnswer('answer', 'answers', $question->id, '| Besvara ');
     // Add view with Comments to question
     $allComments = $this->comments->query()->where("q_or_a = 'q'")->andwhere("q_or_a_id = {$id}")->execute();
     $nrOfComments = sizeof($allComments);
     $commentsListData = array();
     for ($j = 0; $j < $nrOfComments; $j++) {
         $commentsListData[$j]['comment'] = $allComments[$j]->getProperties();
         // Get user of comment
         $user = $this->users->find($allComments[$j]->user_id);
         $commentsListData[$j]['user'] = $user->getProperties();
     }
     $this->views->add('questions/comments', ['comments' => $commentsListData]);
     // Display all answers and comments to each answer.
     // Display all answers to question.
     $allAnswers = $this->answers->query()->where("q_id = {$question->id}")->execute();
     $this->views->add('questions/answersheading', ['title' => sizeof($allAnswers) . " svar"]);
     foreach ($allAnswers as $answer) {
         $user = $this->users->find($answer->user_id);
         // Add view to display all answer.
         $this->views->add('questions/answer', ['answer' => $answer->getProperties(), 'user' => $user->getProperties()]);
         // Display link or comment form for commenting the answer
         $this->showFormCommentOrAnswer('comment_answer_' . $answer->id, 'comment', $answer->id, 'Kommentera ', 'a');
         $this->acceptAnswer($answer, $question);
         // Get all comments to answer
         $allComments = $this->comments->query()->where("q_or_a = 'a'")->andwhere("q_or_a_id = {$answer->id}")->execute();
         $commentsListData = array();
         foreach ($allComments as $comment) {
             $user = $this->users->find($comment->user_id);
             $commentsListData[] = ['comment' => $comment->getProperties(), 'user' => $user->getProperties()];
         }
         $this->views->add('questions/comments', ['comments' => $commentsListData]);
     }
     $this->views->add('default/page', ['content' => ' ', 'links' => [['href' => $this->url->create('questions/ask'), 'text' => "Fråga en fråga"]]]);
 }