/** * Dispay the replies of a comment * * @param integer Comment ID * @param array Template params * @param integer Level */ function display_comment_replies($comment_ID, $params = array(), $level = 1) { global $CommentReplies; $params = array_merge(array('comment_template' => '_item_comment.inc.php', 'preview_block_start' => '', 'preview_start' => '<div class="bComment" id="comment_preview">', 'preview_end' => '</div>', 'preview_block_end' => '', 'comment_start' => '<div class="bComment">', 'comment_end' => '</div>', 'comment_error_start' => '<div class="bComment" id="comment_error">', 'comment_error_end' => '</div>', 'link_to' => 'userurl>userpage', 'author_link_text' => 'login'), $params); if (isset($CommentReplies[$comment_ID])) { // This comment has the replies foreach ($CommentReplies[$comment_ID] as $Comment) { // Loop through the replies: if (!empty($Comment->ID)) { // Comment from DB skin_include($params['comment_template'], array('Comment' => &$Comment, 'comment_start' => str_replace('>', ' style="margin-left:' . 20 * $level . 'px">', $params['comment_start']), 'comment_end' => $params['comment_end'], 'link_to' => $params['link_to'], 'author_link_text' => $params['author_link_text'])); } else { // PREVIEW comment skin_include($params['comment_template'], array('Comment' => &$Comment, 'comment_block_start' => $Comment->email_is_detected ? '' : $params['preview_block_start'], 'comment_start' => str_replace('>', ' style="margin-left:' . 20 * $level . 'px">', $Comment->email_is_detected ? $params['comment_error_start'] : $params['preview_start']), 'comment_end' => $Comment->email_is_detected ? $params['comment_error_end'] : $params['preview_end'], 'comment_block_end' => $Comment->email_is_detected ? '' : $params['preview_block_end'], 'author_link_text' => $params['author_link_text'])); } // Display the rest replies recursively display_comment_replies($Comment->ID, $params, $level + 1); } } }
// Store the replies in a special array if (!isset($CommentReplies[$Comment->in_reply_to_cmt_ID])) { $CommentReplies[$Comment->in_reply_to_cmt_ID] = array(); } $CommentReplies[$Comment->in_reply_to_cmt_ID][] = $Comment; continue; // Skip dispay a comment reply here in order to dispay it after parent comment by function display_comment_replies() } // ------------------ COMMENT INCLUDED HERE ------------------ skin_include($params['comment_template'], array('Comment' => &$Comment, 'comment_start' => $params['comment_start'], 'comment_end' => $params['comment_end'], 'author_link_text' => $params['author_link_text'], 'link_to' => $params['link_to'])); // Note: You can customize the default item feedback by copying the generic // /skins/_item_comment.inc.php file into the current skin folder. // ---------------------- END OF COMMENT --------------------- if ($Blog->get_setting('threaded_comments')) { // Display the comment replies display_comment_replies($Comment->ID, $params); } } // End of comment list loop. echo $params['comment_list_end']; if ($Blog->get_setting('paged_comments')) { // Prev/Next page navigation $CommentList->page_links(array('page_url' => url_add_tail($Item->get_permanent_url(), '#comments'))); } // Restore "redir" param forget_param('redir'); // _______________________________________________________________ // Display count of comments to be moderated: $Item->feedback_moderation('feedbacks', '<div class="moderation_msg"><p>', '</p></div>', '', T_('This post has 1 feedback awaiting moderation... %s'), T_('This post has %d feedbacks awaiting moderation... %s')); // _______________________________________________________________ }
/** * Dispay the replies of a comment * * @param integer Comment ID * @param array Template params * @param integer Level */ function display_comment_replies($comment_ID, $params = array(), $level = 1) { global $CommentReplies; $params = array_merge(array('comment_template' => '_item_comment.inc.php', 'preview_block_start' => '', 'preview_start' => '<div class="bComment" id="comment_preview">', 'preview_end' => '</div>', 'preview_block_end' => '', 'comment_start' => '<div class="bComment">', 'comment_end' => '</div>', 'comment_error_start' => '<div class="bComment" id="comment_error">', 'comment_error_end' => '</div>', 'link_to' => 'userurl>userpage', 'author_link_text' => 'name'), $params); if (isset($CommentReplies[$comment_ID])) { // This comment has the replies foreach ($CommentReplies[$comment_ID] as $Comment) { // Loop through the replies: if (empty($Comment->ID)) { // Get html tag of the comment block of preview $comment_start = $Comment->email_is_detected ? $params['comment_error_start'] : $params['preview_start']; } else { // Get html tag of the comment block of existing comment $comment_start = $params['comment_start']; } // Set margin left for each sub level comment $attrs = ' style="margin-left:' . 20 * $level . 'px"'; if (strpos($comment_start, 'class="') === false) { // Add a class attribute for the replied comment $attrs .= ' class="replied_comment"'; } else { // Add a class name for the replied comment $comment_start = str_replace('class="', 'class="replied_comment ', $comment_start); } $comment_start = str_replace('>', $attrs . '>', $comment_start); if (!empty($Comment->ID)) { // Comment from DB skin_include($params['comment_template'], array_merge($params, array('Comment' => &$Comment, 'comment_start' => $comment_start))); } else { // PREVIEW comment skin_include($params['comment_template'], array_merge($params, array('Comment' => &$Comment, 'comment_block_start' => $Comment->email_is_detected ? '' : $params['preview_block_start'], 'comment_start' => $comment_start, 'comment_end' => $Comment->email_is_detected ? $params['comment_error_end'] : $params['preview_end'], 'comment_block_end' => $Comment->email_is_detected ? '' : $params['preview_block_end'], 'author_link_text' => $params['author_link_text']))); } // Display the rest replies recursively display_comment_replies($Comment->ID, $params, $level + 1); } } }