| | 2093 | * Generate topic pagination |
| | 2094 | */ |
| | 2095 | function generate_topic_pagination($forum_id, $topic_id, $replies, $per_page = 0) |
| | 2096 | { |
| | 2097 | global $config, $template, $images, $lang; |
| | 2098 | |
| | 2099 | $per_page = (!empty($per_page) && intval($per_page)) ? intval($per_page) : $config['posts_per_page']; |
| | 2100 | $topic_pagination = array(); |
| | 2101 | $topic_pagination['base'] = ''; |
| | 2102 | $topic_pagination['full'] = ''; |
| | 2103 | |
| | 2104 | $url_append = ''; |
| | 2105 | $url_append .= (empty($url_append) ? '' : '&') . ((!empty($forum_id) ? (POST_FORUM_URL . '=' . $forum_id) : '')); |
| | 2106 | $url_append .= (empty($url_append) ? '' : '&') . ((!empty($topic_id) ? (POST_TOPIC_URL . '=' . $topic_id) : '')); |
| | 2107 | |
| | 2108 | if(($replies + 1) > $per_page) |
| | 2109 | { |
| | 2110 | $total_pages = ceil(($replies + 1) / $per_page); |
| | 2111 | $goto_page_prefix = ' ['; |
| | 2112 | $goto_page = ' <img src="' . $images['icon_gotopage'] . '" alt="' . $lang['Goto_page'] . '" title="' . $lang['Goto_page'] .
'" /> '; |
| | 2113 | $times = '1'; |
| | 2114 | for($j = 0; $j < $replies + 1; $j += $per_page) |
| | 2115 | { |
| | 2116 | $goto_page .= '<a href="' . append_sid(CMS_PAGE_VIEWTOPIC . '?' . $url_append . '&start=' . $j) . '" title="' . $lang['Goto_page']
. ' ' . $times . '"><b>' . $times . '</b></a>'; |
| | 2117 | if(($times == 1) && ($total_pages > 4)) |
| | 2118 | { |
| | 2119 | $goto_page .= ' ... '; |
| | 2120 | $times = $total_pages - 3; |
| | 2121 | $j += ($total_pages - 4) * $per_page; |
| | 2122 | } |
| | 2123 | elseif($times < $total_pages) |
| | 2124 | { |
| | 2125 | //$goto_page .= ', '; |
| | 2126 | $goto_page .= ' '; |
| | 2127 | } |
| | 2128 | $times++; |
| | 2129 | } |
| | 2130 | $goto_page_suffix = ' ]'; |
| | 2131 | $goto_page .= ' '; |
| | 2132 | |
| | 2133 | $topic_pagination['base'] = '<span class="gotopage">' . $goto_page . '</span>'; |
| | 2134 | $topic_pagination['full'] = '<span class="gotopage">' . $goto_page_prefix . ' ' . $lang['Goto_page'] . $goto_page . $goto_page_suffix .
'</span>'; |
| | 2135 | } |
| | 2136 | |
| | 2137 | return $topic_pagination; |
| | 2138 | } |
| | 2139 | |
| | 2140 | /** |
2093 | * Generate full pagination with template | 2141 | * Generate full pagination with template |
2094 | */ | 2142 | */ |
2095 | function generate_full_pagination($base_url, $num_items, $per_page, $start_item, $add_prevnext_text = true, $start = 'start') | 2143 | function generate_full_pagination($base_url, $num_items, $per_page, $start_item, $add_prevnext_text = true, $start = 'start') |