示例#1
0
function cmtx_calc_permalink($id)
{
    //calculate the page of the permalink
    global $cmtx_mysql_table_prefix, $cmtx_page_id, $cmtx_perm_counter, $cmtx_exit_loop;
    $cmtx_perm_counter++;
    $cmtx_perm = (int) $_GET['cmtx_perm'];
    if ($cmtx_perm == $id) {
        $cmtx_page = ceil($cmtx_perm_counter / cmtx_setting('comments_per_page'));
        $_GET['cmtx_page'] = strval($cmtx_page);
        $cmtx_exit_loop = true;
        //exit the loop to save on performance
    }
    if (cmtx_comment_has_reply($id)) {
        //get all of its replies
        $reply_q = cmtx_db_query("SELECT `id` FROM `" . $cmtx_mysql_table_prefix . "comments` WHERE `reply_to` = '{$id}' AND `is_approved` = '1' AND `page_id` = '{$cmtx_page_id}' ORDER BY `dated` ASC");
        while ($replies = cmtx_db_fetch_assoc($reply_q)) {
            //while there are replies
            cmtx_calc_permalink($replies['id']);
            //re-call this function to calculate the reply AND any replies it may have
        }
    }
}
示例#2
0
}
?>

<div class="cmtx_success_ajax"></div>
<div class="cmtx_error_ajax"></div>

<?php 
//Permalink (Calculation Only)
if (isset($_GET['cmtx_perm']) && ctype_digit($_GET['cmtx_perm'])) {
    global $cmtx_perm_counter;
    $cmtx_sort = cmtx_get_sort_by();
    $cmtx_comments_query = cmtx_db_query("SELECT `id` FROM `" . $cmtx_mysql_table_prefix . "comments` WHERE `reply_to` = '0' AND `is_approved` = '1' AND `page_id` = '{$cmtx_page_id}' ORDER BY {$cmtx_sort};");
    $cmtx_perm_counter = 0;
    $cmtx_exit_loop = false;
    while ($cmtx_comments = cmtx_db_fetch_assoc($cmtx_comments_query)) {
        cmtx_calc_permalink($cmtx_comments['id']);
        if ($cmtx_exit_loop) {
            break;
        }
    }
}
?>

<?php 
//get number of approved comments for current page
$cmtx_number_of_comments = cmtx_number_of_comments();
?>

<h3 class="cmtx_comments_heading" id="<?php 
echo str_ireplace('#', '', CMTX_ANCHOR_COMMENTS);
?>