<?php if ($topic['topic_status'] == 2 && isset($_COOKIE['mtype'], $_COOKIE['mact']) && $_COOKIE['mtype'] != 1 && $_COOKIE['mact'] < time()) { Redirect('/err'); } $a = GetAttached($topic['topic_id']); $r = TRelation::GetInstance(); $likes = $r->GetDestinationCount($topic['topic_id'], REALTION_LIKE); if (isset($_COOKIE['mid'])) { $liked = $r->Has($_COOKIE['mid'], $topic['topic_id'], REALTION_LIKE); } else { $liked = FALSE; } if ($liked) { $likes--; } //$c = CommentChildCount($topic['topic_id'], 0); $c = ShowCommentByParent($topic['topic_id'], 0, true); $date = TDate::GetInstance(); $topic['topic_time'] = $date->PDate('Y F d H:i', $topic['topic_time']); $smarty->assign('topic', $topic); $smarty->assign('is_attach', count($a) > 0 ? TRUE : FALSE); $smarty->assign('attach', $a); $smarty->assign('likes', $likes); $smarty->assign('liked', $liked); $smarty->assign('commentz', $c);
function ShowCommentByParent($topic_id, $parent, $is_child) { $date = TDate::GetInstance(); global $database_handle; $sql = "SELECT comment_id,comment_member_id,comment_time,comment_text\n , m.member_name, f.manager_displayname \n FROM " . DB_PREFIX . "comment c\n LEFT JOIN " . DB_PREFIX . "member m on m.member_id = c.comment_member_id\n LEFT JOIN " . DB_PREFIX . "manager f on f.manager_id = c.comment_member_id*-1 " . " WHERE comment_parent = :par AND comment_topic_id = :id AND comment_status = 1 " . " ORDER BY comment_id DESC "; $ret = $database_handle->Select($sql, array('comment'), array(':par' => $parent, ':id' => $topic_id)); $result = null; foreach ($ret as $comment) { $result .= '<li>'; $result .= '<div class="head"> <img alt="[avatar]" src="/upload/member/' . $comment['comment_member_id'] . '.jpg" class="avatar"> '; if (isset($_COOKIE['mid'])) { $result .= '<button class="reply left" data-id="' . $comment['comment_id'] . '"> پاسخ</button>'; } if ($comment['comment_member_id'] > 0) { $result .= '<a href="/member/' . $comment['comment_member_id'] . '/' . $comment['member_name'] . '">'; } $result .= '<span class="author"> ' . $comment['manager_displayname'] . $comment['member_name'] . ' </span>'; if ($comment['comment_member_id'] > 0) { $result .= '</a>'; } $result .= '<span class="date"> ' . $date->RDate($comment['comment_time']) . ' </span> </div> <p> ' . $comment['comment_text'] . ' </p>'; if ($is_child && CommentChildCount($topic_id, $comment['comment_id']) > 0) { $result .= '<ul>'; $result .= ShowCommentByParent($topic_id, $comment['comment_id'], $is_child); $result .= '</ul>'; } $result .= '</li>'; } return $result; }