修正注释

修正分页
This commit is contained in:
yunwuxin
2016-07-06 19:00:05 +08:00
parent 6c6ac73ee0
commit f19f517c94
2 changed files with 11 additions and 10 deletions

View File

@@ -34,6 +34,7 @@ use think\paginator\Collection as PaginatorCollection;
* @method static integer avg($field = '*') AVG查询 * @method static integer avg($field = '*') AVG查询
* @method static setField($field, $value = '') * @method static setField($field, $value = '')
* @method static Query where($field, $op = null, $condition = null) 指定AND查询条件 * @method static Query where($field, $op = null, $condition = null) 指定AND查询条件
* @method static static findOrFail($data = null) 查找单条记录 如果不存在则抛出异常
* *
*/ */
abstract class Model implements \JsonSerializable, \ArrayAccess abstract class Model implements \JsonSerializable, \ArrayAccess

View File

@@ -66,23 +66,23 @@ class Bootstrap extends Paginator
'last' => null 'last' => null
]; ];
$length = 3; $side = 3;
$window = $side * 2;
if ($this->lastPage < $length * 4) { if ($this->lastPage < $window + 6) {
$block['first'] = $this->getUrlRange(1, $this->lastPage); $block['first'] = $this->getUrlRange(1, $this->lastPage);
} elseif ($this->currentPage <= $length * 2) { } elseif ($this->currentPage <= $window) {
$block['first'] = $this->getUrlRange(1, $length * 2 + 2); $block['first'] = $this->getUrlRange(1, $window + 2);
$block['last'] = $this->getUrlRange($this->lastPage - 1, $this->lastPage); $block['last'] = $this->getUrlRange($this->lastPage - 1, $this->lastPage);
} elseif ($this->currentPage > ($this->lastPage - $length * 2)) { } elseif ($this->currentPage > ($this->lastPage - $window)) {
$block['first'] = $this->getUrlRange(1, 2); $block['first'] = $this->getUrlRange(1, 2);
$block['last'] = $this->getUrlRange($this->lastPage - $length * 2 + 2, $this->lastPage); $block['last'] = $this->getUrlRange($this->lastPage - ($window + 2), $this->lastPage);
} else { } else {
$block['first'] = $this->getUrlRange(1, 2); $block['first'] = $this->getUrlRange(1, 2);
$block['slider'] = $this->getUrlRange($this->currentPage - $length, $this->currentPage + $length); $block['slider'] = $this->getUrlRange($this->currentPage - $side, $this->currentPage + $side);
$block['last'] = $this->getUrlRange($this->lastPage - 1, $this->lastPage); $block['last'] = $this->getUrlRange($this->lastPage - 1, $this->lastPage);
} }
$html = ''; $html = '';
if (is_array($block['first'])) { if (is_array($block['first'])) {