From 338ce99c7c4603abe3eed725dedc7c7c5700f27e Mon Sep 17 00:00:00 2001 From: joyqi Date: Thu, 27 Feb 2014 14:04:43 +0800 Subject: [PATCH] =?UTF-8?q?fix=20#196=20=E5=A2=9E=E5=8A=A0=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E9=A1=B5=E9=9D=A2=E6=80=BB=E6=95=B0=E5=87=BD=E6=95=B0?= =?UTF-8?q?$this->getTotalPage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- var/Widget/Archive.php | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/var/Widget/Archive.php b/var/Widget/Archive.php index eb254aa5..dd382234 100644 --- a/var/Widget/Archive.php +++ b/var/Widget/Archive.php @@ -560,6 +560,10 @@ class Widget_Archive extends Widget_Abstract_Contents */ public function getTotal() { + if (false === $this->_total) { + $this->_total = $this->size($this->_countSql); + } + return $this->_total; } @@ -571,6 +575,16 @@ class Widget_Archive extends Widget_Abstract_Contents return $this->_currentPage; } + /** + * 获取页数 + * + * @return integer + */ + public function getTotalPage() + { + return ceil($this->getTotal() / $this->parameter->pageSize); + } + /** * @return the $_themeFile */ @@ -1391,17 +1405,17 @@ class Widget_Archive extends Widget_Abstract_Contents $template = array_merge($default, $config); - $this->_total = (false === $this->_total ? $this->size($this->_countSql) : $this->_total); - $this->pluginHandle()->trigger($hasNav)->pageNav($this->_currentPage, $this->_total, + $total = $this->getTotal(); + $this->pluginHandle()->trigger($hasNav)->pageNav($this->_currentPage, $total, $this->parameter->pageSize, $prev, $next, $splitPage, $splitWord); - if (!$hasNav && $this->_total > $this->parameter->pageSize) { + if (!$hasNav && $total > $this->parameter->pageSize) { $query = Typecho_Router::url($this->parameter->type . (false === strpos($this->parameter->type, '_page') ? '_page' : NULL), $this->_pageRow, $this->options->index); /** 使用盒状分页 */ - $nav = new Typecho_Widget_Helper_PageNavigator_Box($this->_total, + $nav = new Typecho_Widget_Helper_PageNavigator_Box($total, $this->_currentPage, $this->parameter->pageSize, $query); echo '<' . $template['wrapTag'] . (empty($template['wrapClass']) @@ -1429,7 +1443,7 @@ class Widget_Archive extends Widget_Abstract_Contents $this->_pageRow, $this->options->index); /** 使用盒状分页 */ - $this->_pageNav = new Typecho_Widget_Helper_PageNavigator_Classic(false === $this->_total ? $this->_total = $this->size($this->_countSql) : $this->_total, + $this->_pageNav = new Typecho_Widget_Helper_PageNavigator_Classic($this->getTotal(), $this->_currentPage, $this->parameter->pageSize, $query); }