cvs: pear /Structures_DataGrid/DataGrid Renderer.php

From: Date: Fri, 17 Mar 2006 12:45:06 +0000
Subject: cvs: pear /Structures_DataGrid/DataGrid Renderer.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-39148@lists.php.net to get a copy of this message
olivierg Fri Mar 17 12:45:06 2006 UTC Modified files: /pear/Structures_DataGrid/DataGrid Renderer.php Log: Added firstRecord, lastRecord and pagesNum protected properties http://cvs.php.net/viewcvs.cgi/pear/Structures_DataGrid/DataGrid/Renderer.php?r1=1.34&r2=1.35&diff_format=u Index: pear/Structures_DataGrid/DataGrid/Renderer.php diff -u pear/Structures_DataGrid/DataGrid/Renderer.php:1.34 pear/Structures_DataGrid/DataGrid/Renderer.php:1.35 --- pear/Structures_DataGrid/DataGrid/Renderer.php:1.34 Thu Mar 16 14:05:48 2006 +++ pear/Structures_DataGrid/DataGrid/Renderer.php Fri Mar 17 12:45:06 2006 @@ -17,7 +17,7 @@ // | Olivier Guilyardi <olivier@samalyse.com> | // +----------------------------------------------------------------------+ // -// $Id: Renderer.php,v 1.34 2006/03/16 14:05:48 olivierg Exp $ +// $Id: Renderer.php,v 1.35 2006/03/17 12:45:06 olivierg Exp $ require_once 'PHP/Compat/Function/http_build_query.php'; @@ -65,10 +65,13 @@ * - $_records * - $_columnsNum * - $_recordsNum + * - $_firstRecord; + * - $_lastRecord; * - $_totalRecordsNum * - $_currentSort * - $_page * - $_pageLimit + * - $_pagesNum * - $_requestPrefix * - $_sortableFields * - $_options @@ -78,7 +81,7 @@ * - fillWithEmptyRows * - numberAlign * - * @version $Revision: 1.34 $ + * @version $Revision: 1.35 $ * @author Olivier Guilyardi <olivier@samalyse.com> * @access public * @package Structures_DataGrid @@ -154,8 +157,24 @@ var $_totalRecordsNum; /** + * First record number (zero-based), in the current page + * @var int + * @access protected + */ + var $_firstRecord; + + /** + * Last record number (zero-base), in the current page + * @var int + * @access protected + */ + var $_lastRecord; + + /** * Current page * + * Page number starting from 1. + * * Drivers can read the content of this property but must not change it. * * @var int @@ -173,6 +192,13 @@ */ var $_pageLimit = null; + /** + * Number of pages + * @var int + * @access protected + */ + var $_pagesNum; + /** * GET/POST/Cookie parameters prefix * @@ -340,9 +366,15 @@ * @access public */ function setLimit($currentPage, $rowsPerPage, $totalRowNum) { - $this->_page = $currentPage; - $this->_pageLimit = $rowsPerPage; + $this->_page = $currentPage; + $this->_pageLimit = $rowsPerPage; $this->_totalRecordsNum = $totalRowNum; + $this->_pagesNum = ceil($totalRowNum / $rowsPerPage); + $this->_firstRecord = ($currentPage - 1) * $rowsPerPage; + $this->_lastRecord = $currentPage * $rowsPerPage - 1; + if ($this->_lastRecord >= $totalRowNum) { + $this->_lastRecord = $totalRowNum - 1; + } } /**

« previous php.pear.cvs (#39148) next »