Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function get_paginator() {
- $display = array();
- if ($this->current_page <= $this->num_pages) {
- $visible_pages = floor($this->window_size/2) * 2 + 1;
- if ($this->num_pages <= $visible_pages) {
- $minp = 1;
- $maxp = $this->num_pages;
- } else {
- $minp = $this->current_page - floor($this->window_size/2);
- if ($minp < 1) $minp = 1;
- $maxp = $minp + $visible_pages - 1;
- if ($maxp > $this->num_pages) {
- $maxp = $this->num_pages;
- $minp = $maxp - $visible_pages + 1;
- }
- }
- if ($minp > 1) {
- $page = new stdClass();
- $page->number = '…';
- $page->selected = False;
- $page->link = False;
- $display[] = $page;
- }
- for ($i = $minp; $i <= $maxp; $i++) {
- $page = new stdClass();
- $page->number = $i;
- $page->selected = False;
- $page->link = True;
- if ($i == $this->current_page) {
- $page->selected = True;
- }
- $display[] = $page;
- }
- if ($maxp < $this->num_pages) {
- $page = new stdClass();
- $page->number = '…';
- $page->selected = False;
- $page->link = False;
- $display[] = $page;
- }
- }
- return $display;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement