pageSize = max(1, $page_size); return $this; } final public function setOffset($offset) { $this->offset = max(0, $offset); return $this; } final public function getOffset() { return $this->offset; } final public function getPageSize() { return $this->pageSize; } final public function setCount($count) { $this->count = $count; return $this; } final public function setHasMorePages($has_more) { $this->hasMorePages = $has_more; return $this; } final public function setURI(PhutilURI $uri, $paging_parameter) { $this->uri = $uri; $this->pagingParameter = $paging_parameter; return $this; } final public function setSurroundingPages($pages) { $this->surroundingPages = max(0, $pages); return $this; } private function computeCount() { if ($this->count !== null) { return $this->count; } return $this->getOffset() + $this->getPageSize() + ($this->hasMorePages ? 1 : 0); } private function isExactCountKnown() { return $this->count !== null; } public function render() { require_celerity_resource('aphront-pager-view-css'); $page = (int)floor($this->getOffset() / $this->getPageSize()); $last = ((int)ceil($this->computeCount() / $this->getPageSize())) - 1; $near = $this->surroundingPages; $min = $page - $near; $max = $page + $near; // Limit the window size to no larger than the number of available pages. if ($max - $min > $last) { $max = $min + $last; if ($max == $min) { return '
'; } } // Slide the window so it is entirely over displayable pages. if ($min < 0) { $max += 0 - $min; $min += 0 - $min; } if ($max > $last) { $min -= $max - $last; $max -= $max - $last; } // Build up a list of