paginator::links PHP Method

    public function links()
    {
        $html = '';
        $pages = ceil($this->count / $this->perpage);
        $range = 4;
        if ($pages > 1) {
            if ($this->page > 1) {
                $page = $this->page - 1;
                $html = '<a href="' . $this->url . '">' . $this->first . '</a>
					<a href="' . $this->url . '/' . $page . '">' . $this->prev . '</a>';
            }
            for ($i = $this->page - $range; $i < $this->page + $range; $i++) {
                if ($i < 0) {
                    continue;
                }
                $page = $i + 1;
                if ($page > $pages) {
                    break;
                }
                if ($page == $this->page) {
                    $html .= ' <strong>' . $page . '</strong> ';
                } else {
                    $html .= ' ' . $this->link($page, $this->url . '/' . $page) . ' ';
                }
            }
            if ($this->page < $pages) {
                $page = $this->page + 1;
                $html .= $this->link($this->next, $this->url . '/' . $page) . $this->link($this->last, $this->url . '/' . $pages);
            }
        }
        return $html;
    }