Author: peter
Date: 2008-09-28 15:44:38 -0700 (Sun, 28 Sep 2008)
New Revision: 1394
Modified:
trunk/apps/qubit/lib/SearchPager.class.php
Log:
add phpDoc header. Convert if statement to a ternary as per coding standard
Modified: trunk/apps/qubit/lib/SearchPager.class.php
===================================================================
--- trunk/apps/qubit/lib/SearchPager.class.php 2008-09-28 18:32:00 UTC (rev
1393)
+++ trunk/apps/qubit/lib/SearchPager.class.php 2008-09-28 22:44:38 UTC (rev
1394)
@@ -7,7 +7,6 @@
* It is based on PHP Array Pagination
* Copyright (C) 2007 Derek Harvey <www.lotsofcode.com>
*
- *
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
@@ -21,11 +20,23 @@
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
+*/
+/*
+ * @package Qubit
+ * @author Peter Van Garderen <[EMAIL PROTECTED]>
+ * @version svn:$Id$
+*/
+
class searchPager
{
+
+ /**
+ * Class constructor
+ *
+ * @param array $hits array of objects returned as hits from Zend Lucene
Search
+ * @param integer $page current page of hits to display
+ */
function __construct($hits, $page)
{
// Assign the items per page variable
@@ -59,11 +70,14 @@
$this->hits = array_slice($hits, $this->start, $this->perPage);
}
+
function getCurrentPage()
{
+
return $this->page;
}
+
function getPages()
{
$links = array();
@@ -75,38 +89,39 @@
return $links;
}
+
function haveToPaginate()
{
- if (count($this->allHits) > $this->perPage)
- {
- return true;
- }
- else
- {
- return false;
- }
+
+ return $haveToPaginate = count($this->allHits) > $this->perPage ? true :
false;
}
+
function getHits()
{
+
return $this->hits;
}
+
function getFirstHit()
{
+
return (($this->page - 1) * $this->perPage) + 1;
}
+
function getLastHit()
{
if (count($this->getPages()) > $this->getCurrentPage())
{
-
- return ($this->getFirstHit() + $this->perPage) -1;
+
+ return ($this->getFirstHit() + $this->perPage) - 1;
}
else
{
+
return (count($this->allHits));
}
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.ca/group/qubit-commits?hl=en
-~----------~----~----~----~------~----~------~--~---