From ad126ef787d35b4890e46316e2aaf25903e2a869 Mon Sep 17 00:00:00 2001 From: vargenau Date: Thu, 15 Jul 2010 15:56:21 +0000 Subject: [PATCH] Fix paging git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@7614 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- lib/PageList.php | 6 ++++-- lib/WikiDB.php | 1 + lib/WikiDB/backend/PearDB.php | 6 ++++-- lib/WikiDB/backend/PearDB_ffpgsql.php | 6 ++++-- pgsrc/AllPages | 4 ++-- pgsrc/AllPagesCreatedByMe | 4 ++-- pgsrc/AllPagesLastEditedByMe | 4 ++-- pgsrc/AllPagesOwnedByMe | 4 ++-- pgsrc/AllUserPages | 4 ++-- pgsrc/MyRatings | 4 ++-- pgsrc/RateIt | 4 ++-- pgsrc/UserRatings | 4 ++-- themes/gforge/pgsrc/ExternalPages | 4 ++-- 13 files changed, 31 insertions(+), 24 deletions(-) diff --git a/lib/PageList.php b/lib/PageList.php index 18014068b..1d28ecc33 100644 --- a/lib/PageList.php +++ b/lib/PageList.php @@ -861,7 +861,9 @@ class PageList { $this->addPage($page); } } - if ($i and empty($this->_options['count'])) + if (! is_array($page_iter->_options) || ! array_key_exists('limit_by_db', $page_iter->_options) || ! $page_iter->_options['limit_by_db']) + $this->_options['slice'] = 1; + if ($i and empty($this->_options['count'])) $this->_options['count'] = $i; } @@ -1491,7 +1493,7 @@ class PageList { count($this->_columns), $this->_options['limit']); if ($tokens and !empty($this->_options['slice'])) - $this->_pages = array_slice($this->_pages, $tokens['OFFSET'], $tokens['COUNT']); + $this->_pages = array_slice($this->_pages, $tokens['OFFSET'], $tokens['SIZE']); } foreach ($this->_pages as $pagenum => $page) { $one_row = $this->_renderPageRow($page, $i++); diff --git a/lib/WikiDB.php b/lib/WikiDB.php index 3e0d8a997..9c2517eed 100644 --- a/lib/WikiDB.php +++ b/lib/WikiDB.php @@ -280,6 +280,7 @@ class WikiDB { return new WikiDB_PageIterator($this, $result, array('include_empty' => $include_empty, 'exclude' => $exclude, + 'limit_by_db' => $result->_options['limit_by_db'], 'limit' => $result->limit())); } diff --git a/lib/WikiDB/backend/PearDB.php b/lib/WikiDB/backend/PearDB.php index 959a90398..f82e784c0 100644 --- a/lib/WikiDB/backend/PearDB.php +++ b/lib/WikiDB/backend/PearDB.php @@ -661,14 +661,16 @@ extends WikiDB_backend . $orderby; } } - if ($limit) { + if ($limit && $orderby) { // extract from,count from limit list($from,$count) = $this->limit($limit); $result = $dbh->limitQuery($sql, $from, $count); + $options = array('limit_by_db' => 1); } else { $result = $dbh->query($sql); + $options = array('limit_by_db' => 0); } - return new WikiDB_backend_PearDB_iter($this, $result); + return new WikiDB_backend_PearDB_iter($this, $result, $options); } /** diff --git a/lib/WikiDB/backend/PearDB_ffpgsql.php b/lib/WikiDB/backend/PearDB_ffpgsql.php index a0e2055d1..e002f4d35 100644 --- a/lib/WikiDB/backend/PearDB_ffpgsql.php +++ b/lib/WikiDB/backend/PearDB_ffpgsql.php @@ -361,14 +361,16 @@ extends WikiDB_backend_PearDB_pgsql . $orderby; } } - if ($limit) { + if ($limit && $orderby) { // extract from,count from limit list($from,$count) = $this->limit($limit); $result = $dbh->limitQuery($sql, $from, $count); + $options = array('limit_by_db' => 1); } else { $result = $dbh->query($sql); + $options = array('limit_by_db' => 0); } - return new WikiDB_backend_PearDB_iter($this, $result); + return new WikiDB_backend_PearDB_iter($this, $result, $options); } function most_popular($limit=20, $sortby='-hits') { diff --git a/pgsrc/AllPages b/pgsrc/AllPages index d840e0128..fe384993d 100644 --- a/pgsrc/AllPages +++ b/pgsrc/AllPages @@ -1,4 +1,4 @@ -Date: Thu, 15 Apr 2010 16:32:58 +0000 +Date: Tue, 13 Jul 2010 17:31:16 +0000 Mime-Version: 1.0 (Produced by PhpWiki 1.4.0RC-20100415) X-Rcs-Id: $Id$ Content-Type: application/x-phpwiki; @@ -11,7 +11,7 @@ Content-Transfer-Encoding: binary Here is the list of **all pages** on this Wiki, including any [[OrphanedPages|orphaned pages]] which are otherwise inaccessible. [[AllUserPages|Show only user pages]]. -<> +<> ---- [[CategoryActionPage]] diff --git a/pgsrc/AllPagesCreatedByMe b/pgsrc/AllPagesCreatedByMe index 124ba6894..bf956278b 100644 --- a/pgsrc/AllPagesCreatedByMe +++ b/pgsrc/AllPagesCreatedByMe @@ -1,4 +1,4 @@ -Date: Thu, 15 Apr 2010 16:32:58 +0000 +Date: Tue, 13 Jul 2010 17:31:16 +0000 Mime-Version: 1.0 (Produced by PhpWiki 1.4.0RC-20100415) X-Rcs-Id: $Id$ Content-Type: application/x-phpwiki; @@ -10,7 +10,7 @@ Content-Transfer-Encoding: binary The list of pages which were created by you. (If you are authenticated only) -<> +<> ---- [[CategoryActionPage]] diff --git a/pgsrc/AllPagesLastEditedByMe b/pgsrc/AllPagesLastEditedByMe index 246a00d0f..c02d42682 100644 --- a/pgsrc/AllPagesLastEditedByMe +++ b/pgsrc/AllPagesLastEditedByMe @@ -1,4 +1,4 @@ -Date: Thu, 15 Apr 2010 16:32:58 +0000 +Date: Tue, 13 Jul 2010 17:31:16 +0000 Mime-Version: 1.0 (Produced by PhpWiki 1.4.0RC-20100415) X-Rcs-Id: $Id$ Content-Type: application/x-phpwiki; @@ -10,7 +10,7 @@ Content-Transfer-Encoding: binary The list of pages for which you were the last author. (If you are authenticated only) -<> +<> ---- [[CategoryActionPage]] diff --git a/pgsrc/AllPagesOwnedByMe b/pgsrc/AllPagesOwnedByMe index d423c1337..65c06b273 100644 --- a/pgsrc/AllPagesOwnedByMe +++ b/pgsrc/AllPagesOwnedByMe @@ -1,4 +1,4 @@ -Date: Thu, 15 Apr 2010 16:32:58 +0000 +Date: Tue, 13 Jul 2010 17:31:16 +0000 Mime-Version: 1.0 (Produced by PhpWiki 1.4.0RC-20100415) X-Rcs-Id: $Id$ Content-Type: application/x-phpwiki; @@ -10,7 +10,7 @@ Content-Transfer-Encoding: binary The list of pages which you own. (If you are authenticated only) -<> +<> ---- [[CategoryActionPage]] diff --git a/pgsrc/AllUserPages b/pgsrc/AllUserPages index 0a7c110b8..1509d5be0 100644 --- a/pgsrc/AllUserPages +++ b/pgsrc/AllUserPages @@ -1,4 +1,4 @@ -Date: Thu, 15 Apr 2010 16:32:58 +0000 +Date: Tue, 13 Jul 2010 17:31:16 +0000 Mime-Version: 1.0 (Produced by PhpWiki 1.4.0RC-20100415) X-Rcs-Id: $Id$ Content-Type: application/x-phpwiki; @@ -10,7 +10,7 @@ Content-Transfer-Encoding: binary Here is the list of **all user pages** on this Wiki (pages that were not created at initialisation of the wiki). [[AllPages|Show all pages]]. -<> +<> ---- [[CategoryActionPage]] diff --git a/pgsrc/MyRatings b/pgsrc/MyRatings index 2088c35cb..5458938f7 100644 --- a/pgsrc/MyRatings +++ b/pgsrc/MyRatings @@ -1,4 +1,4 @@ -Date: Fri, 2 Jul 2010 13:54:01 +0000 +Date: Tue, 13 Jul 2010 17:31:16 +0000 Mime-Version: 1.0 (Produced by PhpWiki 1.4.0RC-20100415) X-Rcs-Id: $Id$ Content-Type: application/x-phpwiki; @@ -8,7 +8,7 @@ Content-Type: application/x-phpwiki; charset=UTF-8 Content-Transfer-Encoding: binary -<> +<> ---- [[CategoryActionPage]] diff --git a/pgsrc/RateIt b/pgsrc/RateIt index 0e3413437..85a96062c 100644 --- a/pgsrc/RateIt +++ b/pgsrc/RateIt @@ -1,4 +1,4 @@ -Date: Fri, 2 Jul 2010 13:54:01 +0000 +Date: Tue, 13 Jul 2010 17:31:16 +0000 Mime-Version: 1.0 (Produced by PhpWiki 1.4.0RC-20100415) X-Rcs-Id: $Id$ Content-Type: application/x-phpwiki; @@ -10,7 +10,7 @@ Content-Transfer-Encoding: binary <> -<> +<> ---- [[CategoryActionPage]] diff --git a/pgsrc/UserRatings b/pgsrc/UserRatings index 8bde48766..4e2e9bd93 100644 --- a/pgsrc/UserRatings +++ b/pgsrc/UserRatings @@ -1,4 +1,4 @@ -Date: Fri, 2 Jul 2010 13:54:01 +0000 +Date: Tue, 13 Jul 2010 17:31:16 +0000 Mime-Version: 1.0 (Produced by PhpWiki 1.4.0RC-20100415) X-Rcs-Id: $Id$ Content-Type: application/x-phpwiki; @@ -8,7 +8,7 @@ Content-Type: application/x-phpwiki; charset=UTF-8 Content-Transfer-Encoding: binary -<> +<> ---- [[CategoryActionPage]] diff --git a/themes/gforge/pgsrc/ExternalPages b/themes/gforge/pgsrc/ExternalPages index b0f1bba15..7e85342ac 100644 --- a/themes/gforge/pgsrc/ExternalPages +++ b/themes/gforge/pgsrc/ExternalPages @@ -1,4 +1,4 @@ -Date: Thu, 15 Apr 2010 16:33:18 +0000 +Date: Tue, 13 Jul 2010 17:28:03 +0000 Mime-Version: 1.0 (Produced by PhpWiki 1.4.0RC-20100415) X-Rcs-Id: $Id$ Content-Type: application/x-phpwiki; @@ -8,7 +8,7 @@ Content-Type: application/x-phpwiki; charset=UTF-8 Content-Transfer-Encoding: binary -<> +<> ---- [[CategoryActionPage]] -- 2.45.0