From 67fd89cace72de67250ad7619a666913a14d21fd Mon Sep 17 00:00:00 2001 From: yunwuxin <448901948@qq.com> Date: Mon, 9 May 2016 12:31:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=88=86=E9=A1=B5=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Paginator.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/library/think/Paginator.php b/library/think/Paginator.php index 7f046591..ba8aba2e 100644 --- a/library/think/Paginator.php +++ b/library/think/Paginator.php @@ -44,7 +44,7 @@ abstract class Paginator 'fragment' => '' ]; - public function __construct(Collection $items, $listRows, $currentPage = null, $simple = false, $total = null, $options = []) + public function __construct($items, $listRows, $currentPage = null, $simple = false, $total = null, $options = []) { $this->options = array_merge($this->options, $options); @@ -53,17 +53,18 @@ abstract class Paginator $this->simple = $simple; $this->listRows = $listRows; + $this->items = PaginatorCollection::make($items, $this); + if ($simple) { $this->currentPage = $this->setCurrentPage($currentPage); - $this->hasMore = count($items) > ($this->listRows); - $items = $items->slice(0, $this->listRows); + $this->hasMore = count($this->items) > ($this->listRows); + $this->items = $this->items->slice(0, $this->listRows); } else { $this->lastPage = (int)ceil($total / $listRows); $this->currentPage = $this->setCurrentPage($currentPage); $this->hasMore = $this->currentPage < $this->lastPage; } - $this->items = PaginatorCollection::make($items, $this); } public function items() @@ -113,7 +114,7 @@ abstract class Paginator /** * 自动获取当前页码 * @param string $varPage - * @param int $default + * @param int $default * @return int */ public static function getCurrentPage($varPage = 'page', $default = 1) @@ -165,6 +166,7 @@ abstract class Paginator /** * 数据是否足够分页 + * @return boolean */ public function hasPages() { @@ -205,7 +207,7 @@ abstract class Paginator * 添加URL参数 * * @param array|string $key - * @param string|null $value + * @param string|null $value * @return $this */ public function appends($key, $value = null)