prev = array( 'text' => '« ' . elgg_echo('previous'), 'href' => '', 'is_trusted' => true, ); $pages->next = array( 'text' => elgg_echo('next') . ' »', 'href' => '', 'is_trusted' => true, ); $pages->items = array(); // Add pages before the current page if ($current_page > 1) { $prev_offset = $offset - $limit; if ($prev_offset < 0) { $prev_offset = 0; } $pages->prev['href'] = elgg_http_add_url_query_elements($base_url, array($offset_key => $prev_offset)); $first_page = $current_page - $delta; if ($first_page < 1) { $first_page = 1; } $pages->items = range($first_page, $current_page - 1); } $pages->items[] = $current_page; // add pages after the current one if ($current_page < $total_pages) { $next_offset = $offset + $limit; if ($next_offset >= $count) { $next_offset--; } $pages->next['href'] = elgg_http_add_url_query_elements($base_url, array($offset_key => $next_offset)); $last_page = $current_page + $delta; if ($last_page > $total_pages) { $last_page = $total_pages; } $pages->items = array_merge($pages->items, range($current_page + 1, $last_page)); } echo '