From ed2277aa8dde6e9183357dca00e1ad74ba8a6c49 Mon Sep 17 00:00:00 2001 From: Andrew O'Neil Date: Thu, 13 Dec 2007 21:49:18 +0000 Subject: [PATCH] Merged revisions 46560 via svnmerge from svn://svn.silverstripe.com/silverstripe/modules/sapphire/branches/2.2.0-privacy ........ r46560 | aoneil | 2007-12-11 10:09:07 +1300 (Tue, 11 Dec 2007) | 2 lines Added FirstItem() and LastItem() functions, which return the number of the first and last items in the current page ........ git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@46777 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/model/DataObjectSet.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/core/model/DataObjectSet.php b/core/model/DataObjectSet.php index 65a1331b3..cc6d49a41 100644 --- a/core/model/DataObjectSet.php +++ b/core/model/DataObjectSet.php @@ -309,6 +309,18 @@ class DataObjectSet extends ViewableData implements Iterator { return $this->TotalPages() > 1; } + function FirstItem() { + return isset($this->pageStart) ? $this->pageStart + 1 : 1; + } + + function LastItem() { + if(isset($this->pageStart)) { + return min($this->pageStart + $this->pageLength, $this->totalSize); + } else { + return min($this->pageLength, $this->totalSize); + } + } + /** * Returns the URL of the previous page. * @return string @@ -1006,4 +1018,4 @@ function column_sort_callback_basic($a, $b) { return $result; } -?> \ No newline at end of file +?>