total = (int)$total_items; $this->perpage = (int)$items_perpage; $this->current = (int)$current_start; $this->extra = $extra_arg; if ($extra_arg != '' && (substr($extra_arg, -5) !== '&' || substr($extra_arg, -1) !== '&')) { $this->extra = '&' . $extra_arg; } $this->url = htmlspecialchars(Request::getString('PHP_SELF', '', 'SERVER'), ENT_QUOTES) . '?' . trim($start_name) . '='; } /** * Create text navigation * * @param integer $offset * @return string */ public function renderNav($offset = 4) { $ret = ''; if ($this->total <= $this->perpage) { return $ret; } if (($this->total != 0) && ($this->perpage != 0)) { $total_pages = ceil($this->total / $this->perpage); if ($total_pages > 1) { $ret .= '
'; $prev = $this->current - $this->perpage; if ($prev >= 0) { $ret .= '« '; } $counter = 1; $current_page = (int)floor(($this->current + $this->perpage) / $this->perpage); while ($counter <= $total_pages) { if ($counter == $current_page) { $ret .= '(' . $counter . ') '; } elseif (($counter > $current_page - $offset && $counter < $current_page + $offset) || $counter == 1 || $counter == $total_pages) { if ($counter == $total_pages && $current_page < $total_pages - $offset) { $ret .= '... '; } $ret .= '' . $counter . ' '; if ($counter == 1 && $current_page > 1 + $offset) { $ret .= '... '; } } ++$counter; } $next = $this->current + $this->perpage; if ($this->total > $next) { $ret .= '» '; } $ret .= '
'; } } return $ret; } /** * Create a navigational dropdown list * * @param boolean $showbutton Show the "Go" button? * @return string */ public function renderSelect($showbutton = false) { if ($this->total < $this->perpage) { return null; } $total_pages = ceil($this->total / $this->perpage); $ret = ''; if ($total_pages > 1) { $ret = '
'; $ret .= ''; if ($showbutton) { $ret .= ' '; } $ret .= '
'; } return $ret; } /** * Create navigation with images * * @param integer $offset * @return string */ public function renderImageNav($offset = 4) { if ($this->total < $this->perpage) { return null; } $total_pages = ceil($this->total / $this->perpage); $ret = ''; if ($total_pages > 1) { $ret = ''; $prev = $this->current - $this->perpage; if ($prev >= 0) { $ret .= ''; } else { $ret .= ''; } $counter = 1; $current_page = (int)floor(($this->current + $this->perpage) / $this->perpage); while ($counter <= $total_pages) { if ($counter == $current_page) { $ret .= ''; } elseif (($counter > $current_page - $offset && $counter < $current_page + $offset) || $counter == 1 || $counter == $total_pages) { if ($counter == $total_pages && $current_page < $total_pages - $offset) { $ret .= ''; } $ret .= ''; if ($counter == 1 && $current_page > 1 + $offset) { $ret .= ''; } } ++$counter; } $next = $this->current + $this->perpage; if ($this->total > $next) { $ret .= ''; } else { $ret .= ''; } $ret .= '
<' . $counter . '...' . $counter . '...>
'; } return $ret; } }