asgarosforum = $object;
}
public function renderTopicOverviewPagination($topic_id, $topic_counter) {
$num_pages = ceil($topic_counter / $this->asgarosforum->options['posts_per_page']);
// Only show pagination when there is more than one page.
if ($num_pages > 1) {
echo ' ·
';
if ($num_pages <= 5) {
for ($i = 1; $i <= $num_pages; $i++) {
echo $this->page_link('topic', $topic_id, $i);
}
} else {
for ($i = 1; $i <= 3; $i++) {
echo $this->page_link('topic', $topic_id, $i);
}
$link = $this->asgarosforum->get_link('topic', $topic_id, array('part' => $num_pages));
echo '
'.__('Last', 'asgaros-forum').' »';
}
echo '
';
}
}
public function page_link($location, $id, $page) {
$link = $this->asgarosforum->get_link($location, $id, array('part' => $page));
return '';
if ($num_pages <= 5) {
for ($i = 1; $i <= $num_pages; $i++) {
if ($i == ($current_page + 1)) {
$out .= '
'.number_format_i18n($i).'';
} else {
$link = add_query_arg('part', $i, $select_url);
$out .= '
'.number_format_i18n($i).'';
}
}
} else {
if ($current_page >= 3) {
$link = remove_query_arg('part', $select_url);
$out .= '
« '.__('First', 'asgaros-forum').'';
}
for ($i = 2; $i > 0; $i--) {
if ((($current_page + 1) - $i) > 0) {
$link = add_query_arg('part', (($current_page + 1) - $i), $select_url);
$out .= '
'.number_format_i18n(($current_page + 1) - $i).'';
}
}
$out .= '
'.number_format_i18n($current_page + 1).'';
for ($i = 1; $i <= 2; $i++) {
if ((($current_page + 1) + $i) <= $num_pages) {
$link = add_query_arg('part', (($current_page + 1) + $i), $select_url);
$out .= '
'.number_format_i18n(($current_page + 1) + $i).'';
}
}
if ($num_pages - $current_page >= 4) {
$link = add_query_arg('part', $num_pages, $select_url);
$out .= '
'.__('Last', 'asgaros-forum').' »';
}
}
$out .= '
';
return $out;
} else {
return false;
}
}
}