function cmtx_paginate($current_page, $range_of_pages, $total_pages) { //display pagination if ($current_page > 1) { //if not on the first page echo ' <span class="cmtx_pagination_box"><a href="' . cmtx_url_encode(strtok(cmtx_current_page(), '?') . '?cmtx_page=1' . cmtx_get_query('page') . CMTX_ANCHOR_COMMENTS) . '" class="cmtx_pagination_link" title="' . CMTX_TITLE_PAG_FIRST . '">' . CMTX_PAGINATION_FIRST . '</a></span> '; //display link to go to first page $previous_page = $current_page - 1; //get the previous page number echo ' <span class="cmtx_pagination_box"><a href="' . cmtx_url_encode(strtok(cmtx_current_page(), '?') . '?cmtx_page=' . $previous_page . cmtx_get_query('page') . CMTX_ANCHOR_COMMENTS) . '" class="cmtx_pagination_link" title="' . CMTX_TITLE_PAG_PREVIOUS . '">' . CMTX_PAGINATION_PREVIOUS . '</a></span> '; //display link to go back one page } for ($x = $current_page - $range_of_pages; $x < $current_page + $range_of_pages + 1; $x++) { //loop to display links to range of pages around current page if ($x > 0 && $x <= $total_pages) { //if it's a valid page number if ($x == $current_page) { //if it's the current page echo ' <span class="cmtx_pagination_box cmtx_pagination_box_active">' . $x . '</span> '; //display it but don't make it a link } else { //if it's not the current page echo ' <span class="cmtx_pagination_box"><a href="' . cmtx_url_encode(strtok(cmtx_current_page(), '?') . '?cmtx_page=' . $x . cmtx_get_query('page') . CMTX_ANCHOR_COMMENTS) . '" class="cmtx_pagination_link" title="' . $x . '">' . $x . '</a></span> '; //display it and make it a link } } } if ($current_page != $total_pages) { //if not on the last page $next_page = $current_page + 1; //get the next page number echo ' <span class="cmtx_pagination_box"><a href="' . cmtx_url_encode(strtok(cmtx_current_page(), '?') . '?cmtx_page=' . $next_page . cmtx_get_query('page') . CMTX_ANCHOR_COMMENTS) . '" class="cmtx_pagination_link" title="' . CMTX_TITLE_PAG_NEXT . '">' . CMTX_PAGINATION_NEXT . '</a></span> '; //display link for next page echo ' <span class="cmtx_pagination_box"><a href="' . cmtx_url_encode(strtok(cmtx_current_page(), '?') . '?cmtx_page=' . $total_pages . cmtx_get_query('page') . CMTX_ANCHOR_COMMENTS) . '" class="cmtx_pagination_link" title="' . CMTX_TITLE_PAG_LAST . '">' . CMTX_PAGINATION_LAST . '</a></span> '; //display link for last page } }
?> <div id="cmtx_hide_form" style="display:none;"> <?php } ?> <?php if (isset($cmtx_box) && !empty($cmtx_box)) { //if a box exists echo $cmtx_box; //display box } ?> <form name="commentics" id="commentics" class="cmtx_form" action="<?php echo cmtx_url_encode(strtok(cmtx_current_page(), '?') . cmtx_get_query('form') . CMTX_ANCHOR_FORM); ?> " method="post"> <noscript> <?php if (cmtx_setting('display_javascript_disabled')) { ?> <div class="cmtx_javascript_disabled_message"> <?php echo CMTX_JAVASCRIPT_DISABLED; ?> </div> <div style="clear: left;"></div> <?php }
} else { echo '<option value="' . cmtx_url_encode(strtok(cmtx_current_page(), '?') . '?cmtx_sort=4' . cmtx_get_query('sort') . CMTX_ANCHOR_COMMENTS) . '">' . CMTX_SORT_4 . '</option>'; } } if (cmtx_setting('show_sort_by_5') && cmtx_setting('show_rating')) { if (isset($_GET['cmtx_sort']) && $_GET['cmtx_sort'] == '5' || !isset($_GET['cmtx_sort']) && cmtx_setting('comments_order') == '5') { echo '<option value="' . cmtx_url_encode(strtok(cmtx_current_page(), '?') . '?cmtx_sort=5' . cmtx_get_query('sort') . CMTX_ANCHOR_COMMENTS) . '" selected="selected">' . CMTX_SORT_5 . '</option>'; } else { echo '<option value="' . cmtx_url_encode(strtok(cmtx_current_page(), '?') . '?cmtx_sort=5' . cmtx_get_query('sort') . CMTX_ANCHOR_COMMENTS) . '">' . CMTX_SORT_5 . '</option>'; } } if (cmtx_setting('show_sort_by_6') && cmtx_setting('show_rating')) { if (isset($_GET['cmtx_sort']) && $_GET['cmtx_sort'] == '6' || !isset($_GET['cmtx_sort']) && cmtx_setting('comments_order') == '6') { echo '<option value="' . cmtx_url_encode(strtok(cmtx_current_page(), '?') . '?cmtx_sort=6' . cmtx_get_query('sort') . CMTX_ANCHOR_COMMENTS) . '" selected="selected">' . CMTX_SORT_6 . '</option>'; } else { echo '<option value="' . cmtx_url_encode(strtok(cmtx_current_page(), '?') . '?cmtx_sort=6' . cmtx_get_query('sort') . CMTX_ANCHOR_COMMENTS) . '">' . CMTX_SORT_6 . '</option>'; } } echo '</select>'; echo '</div>'; } if (cmtx_setting('show_topic') || cmtx_setting('show_sort_by')) { echo '<div style="clear: both;"></div>'; echo '<div class="cmtx_height_below_sort_and_topic"></div>'; } /* *** Average Rating *** */ echo '<div class="cmtx_average_rating_block">'; if (cmtx_setting('show_average_rating')) { echo '<div class="cmtx_average_rating_stars"></div>'; $cmtx_average_rating = cmtx_average_rating(); echo '<span class="cmtx_average_rating_text">';