public function getMain()
 {
     global $config;
     $output = "";
     $output .= "<h2>Recent comments</h2>";
     $output .= "<p>There are currently " . $this->commentsCount . " comments. ";
     $output .= "You are now displaying comments " . ($this->page - 1) * $config["comments per page"] . " to " . min($this->page * $config["comments per page"], $this->commentsCount) . " in reverse chronological order.</p>";
     $comments = getComments($this->db, ($this->page - 1) * $config["comments per page"], $config["comments per page"]);
     $output .= "<ul>";
     foreach ($comments as $comment) {
         $output .= printComment($comment);
     }
     $output .= "</ul>";
     return $output;
 }
示例#2
0
function printComment($comment)
{
    if (!isset($comment)) {
        return;
    } else {
        echo '<div class="media">
                <a class="pull-left" href="#">
                    <img class="media-object" src="http://placehold.it/64x64" alt="">
                </a>
                <div class="media-body">
                    <h4 class="media-heading">' . $comment->getCommentedBy()->getFirstName() . '
                        <small>' . $comment->getCommentedAt()->format('Y-m-d H:i:s') . '</small>
                    </h4>';
        echo $comment->getComment();
        foreach ($comment->getComments() as $c) {
            printComment($c);
        }
        echo '   
                </div>
            </div>';
    }
}
示例#3
0
function printComment($comment, $comments, $type)
{
    ?>
    <li id="comment-<?php 
    echo $comment->getId();
    ?>
" class="comment">
        <article class="comment-body">
            <div class="comment-meta">
                <div class="comment-author vcard">
                    <img alt="<?php 
    echo htmlentities($comment->getAuthorName(), ENT_QUOTES, "utf-8");
    ?>
" src="//0.gravatar.com/avatar/<?php 
    echo md5($comment->getAuthorEmail());
    ?>
?s=25&amp;d=identicon" class="avatar" height="25" width="25" />
                    <b class="fn"><?php 
    if ($comment->getAuthorUrl() != null) {
        ?>
<a href="<?php 
        echo htmlentities($comment->getAuthorUrl(), ENT_QUOTES, "utf-8");
        ?>
" rel="external nofollow" class="url"><?php 
    }
    echo htmlentities($comment->getAuthorName(), ENT_QUOTES, "utf-8");
    if ($comment->getAuthorUrl() != null) {
        ?>
</a><?php 
    }
    ?>
</b>
                    <?php 
    $date = new DateTime($comment->getCreatedOn());
    ?>
                    <time datetime="<?php 
    echo $date->format(DateTime::ATOM);
    ?>
"><?php 
    echo $date->format(DateTime::COOKIE);
    ?>
</time>
                    <?php 
    if ($type == Thread::TYPE_NORMAL && $comment->getParentId() != null) {
        ?>
                        <small>(reply to <b><?php 
        echo htmlentities(findCommentById($comment->getParentId(), $comments)->getAuthorName(), ENT_QUOTES, "utf-8");
        ?>
</b>)</small>
                    <?php 
    }
    ?>
                </div><!-- .comment-author -->
            </div><!-- .comment-meta -->
            <div class="comment-content">
                <p><?php 
    echo htmlentities($comment->getContents(), ENT_QUOTES, "utf-8");
    ?>
</p>
            </div><!-- .comment-content -->
        </article><!-- .comment-body -->
<?php 
    if ($type == Thread::TYPE_THREADED && commentHasChildren($comment, $comments)) {
        ?>
        <ol class="comment-list thread">
            <?php 
        $childs = getChildComments($comment, $comments);
        foreach ($childs as $comment2) {
            printComment($comment2, $comments, $type);
        }
        ?>
        </ol><!-- .comment-list -->
<?php 
    }
    ?>
    </li>
<?php 
}