$current_page = 1; } $offset = ($current_page - 1) * $globals['comments_page_size']; $limit = $globals['comments_page_size']; $global_limit = $limit * 2; // The limit including references if ($show_relevants || $no_page) { print_external_analysis($link); print_relevant_comments($link); } if ($link->page_mode == 'interview') { $sql = "select t1.comment_id as parent, t1.w1 as w1, t2.comment_id as child, t2.comment_karma + 200 * (t2.comment_user_id = {$link->author}) as w2 FROM comments as t0 INNER JOIN (select comment_id, comment_karma + 200 * (comment_user_id = {$link->author}) as w1 from comments WHERE comment_link_id = {$link->id} order by w1 desc LIMIT {$offset}, {$limit}) t1 ON t1.comment_id = t0.comment_id LEFT JOIN (conversations as c, comments as t2) ON conversation_type='comment' and conversation_to = t0.comment_id and c.conversation_from = t2.comment_id order by w1 desc, w2 desc LIMIT {$global_limit}"; $res = $db->get_results($sql); if ($res) { foreach ($res as $c) { $tree->addByIds($c->parent, $c->child); } } $sort_roots = true; } else { $sql = "select t1.comment_id as parent, c.conversation_from as child FROM comments as t0 INNER JOIN (select comment_id from comments WHERE comment_link_id = {$link->id} order by comment_id asc LIMIT {$offset}, {$limit}) t1 ON t1.comment_id = t0.comment_id LEFT JOIN conversations c ON c.conversation_type='comment' and c.conversation_to = t0.comment_id order by t0.comment_id, c.conversation_from LIMIT {$global_limit}"; $res = $db->get_results($sql); if ($res) { foreach ($res as $c) { $tree->addByIds($c->parent, $c->child); } } $sort_roots = false; } // A /url/c0#comment_order all, we add it if (!empty($globals['referenced_comment'])) {
} $canonical_base .= 'c/'; $globals['extra_head'] = '<link rel="canonical" href="' . $globals['scheme'] . '//' . $canonical_server . $canonical_base . $comment->id . '"/>'; do_header($title); /*** SIDEBAR ****/ echo '<div id="sidebar">'; do_banner_right(); //do_best_stories(); do_best_comments(); do_banner_promotions(); echo '</div>'; /*** END SIDEBAR ***/ echo '<div id="newswrap">'; echo '<h3><a href="' . $link->get_permalink() . '">' . $link->title . '</a></h3>'; $tree = new CommentTree(); $tree->addByIds($comment->id); for ($i = 0; $i < 4; $i++) { if (!fill_tree($tree) || $tree->size() > 30) { break; } } echo '<div class="comments">'; echo '<div style="text-align:right">'; $vars = array('link' => $globals['permalink'], 'title' => $title); Haanga::Load('share.html', $vars); echo '</div>'; Comment::print_tree($tree, $link); echo '</div></div>'; do_footer(); exit(0); function fill_tree($tree, $limit = 30)