[ Index ]
 

Code source de PRADO 3.0.6

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/framework/Collections/ -> TPagedList.php (sommaire)

TPagedList, TPagedListFetchDataEventParameter, TPagedListPageChangedEventParameter class file

Author: Qiang Xue <qiang.xue@gmail.com>
Copyright: Copyright © 2005 PradoSoft
License: http://www.pradosoft.com/license/
Version: $Id: TPagedList.php 1397 2006-09-07 07:55:53Z wei $
Poids: 478 lignes (13 kb)
Inclus ou requis:0 fois
Référencé: 0 fois
Nécessite: 0 fichiers

Définit 3 classes

TPagedList:: (24 méthodes):
  __construct()
  getCustomPaging()
  setCustomPaging()
  getPageSize()
  setPageSize()
  getCurrentPageIndex()
  setCurrentPageIndex()
  onPageIndexChanged()
  onFetchData()
  gotoPage()
  nextPage()
  previousPage()
  getVirtualCount()
  setVirtualCount()
  getPageCount()
  getIsFirstPage()
  getIsLastPage()
  getCount()
  getIterator()
  itemAt()
  indexOf()
  offsetExists()
  offsetGet()
  toArray()

TPagedListPageChangedEventParameter:: (2 méthodes):
  __construct()
  getOldPageIndex()

TPagedListFetchDataEventParameter:: (6 méthodes):
  __construct()
  getNewPageIndex()
  getOffset()
  getLimit()
  getData()
  setData()


Classe: TPagedList  - X-Ref

TPagedList class

TPagedList implements a list with paging functionality.

TPagedList works in one of two modes, managed paging or customized paging,
specified by {@link setCustomPaging CustomPaging}.
- Managed paging ({@link setCustomPaging CustomPaging}=false) :
the list is assumed to contain all data and it will manage which page
of data are available to user.
- Customized paging ({@link setCustomPaging CustomPaging}=true) :
the list is assumed to contain only one page of data. An  {@link onFetchData OnFetchData}
event will be raised if the list changes to a different page.
Developers can attach a handler to the event and supply the needed data.
The event handler can be written as follows,
<code>
public function fetchData($sender,$param)
{
$offset=$param->Offset; // beginning index of the data needed
$limit=$param->Limit;   // maximum number of data items needed
// get data according to the above two parameters
$param->Data=$data;
}
</code>

Data in TPagedList can be accessed like an integer-indexed array and can
be traversed using foreach. For example,
<code>
$count=$list->Count;
for($index=0;$index<$count;++$index)
echo $list[$index];
foreach($list as $index=>$item) // traverse each item in the list
</code>

The {@link setPageSize PageSize} property specifies the number of items in each page.
To access different page of data in the list, set {@link setCurrentPageIndex CurrentPageIndex}
or call {@link nextPage()}, {@link previousPage()}, or {@link gotoPage()}.
The total number of pages can be obtained by {@link getPageCount() PageCount}.


__construct($data=null,$readOnly=false)   X-Ref
Constructor.

param: array|Iterator the intial data. Default is null, meaning no initialization.
param: boolean whether the list is read-only. Always true for paged list.

getCustomPaging()   X-Ref

return: boolean whether to use custom paging. Defaults to false.

setCustomPaging($value)   X-Ref

param: boolean whether to allow custom paging

getPageSize()   X-Ref

return: integer number of items in each page. Defaults to 10.

setPageSize($value)   X-Ref

param: integer number of items in each page

getCurrentPageIndex()   X-Ref

return: integer current page index. Defaults to 0.

setCurrentPageIndex($value)   X-Ref

param: integer current page index

onPageIndexChanged($param)   X-Ref
Raises <b>OnPageIndexChanged</b> event.
This event is raised each time when the list changes to a different page.

param: TPagedListPageChangedEventParameter event parameter

onFetchData($param)   X-Ref
Raises <b>OnFetchData</b> event.
This event is raised each time when the list changes to a different page
and needs the new page of data. This event can only be raised when
{@link setCustomPaging CustomPaging} is true.

param: TPagedListFetchDataEventParameter event parameter

gotoPage($pageIndex)   X-Ref
Changes to a page with the specified page index.

param: integer page index
return: integer|boolean the new page index, false if page index is out of range.

nextPage()   X-Ref
Switches to the next page.

return: integer|boolean the new page index, false if next page is not availabe.

previousPage()   X-Ref
Switches to the previous page.

return: integer|boolean the new page index, false if previous page is not availabe.

getVirtualCount()   X-Ref

return: integer user-assigned number of items in data source. Defaults to 0.

setVirtualCount($value)   X-Ref

param: integer user-assigned number of items in data source

getPageCount()   X-Ref

return: integer number of pages, -1 if under custom paging mode and {@link setVirtualCount VirtualCount} is not set.

getIsFirstPage()   X-Ref

return: boolean whether the current page is the first page

getIsLastPage()   X-Ref

return: boolean whether the current page is the last page

getCount()   X-Ref

return: integer the number of items in current page

getIterator()   X-Ref

return: Iterator iterator

itemAt($index)   X-Ref
Returns the item at the specified offset.
This method is exactly the same as {@link offsetGet}.

param: integer the index of the item
return: mixed the item at the index

indexOf($item)   X-Ref

param: mixed the item
return: integer the index of the item in the list (0 based), -1 if not found.

offsetExists($offset)   X-Ref
Returns whether there is an item at the specified offset.
This method is required by the interface ArrayAccess.

param: integer the offset to check on
return: boolean

offsetGet($offset)   X-Ref
Returns the item at the specified offset.
This method is required by the interface ArrayAccess.

param: integer the offset to retrieve item.
return: mixed the item at the offset

toArray()   X-Ref

return: array the list of items in array

Classe: TPagedListPageChangedEventParameter  - X-Ref

TPagedListPageChangedEventParameter class.
TPagedListPageChangedEventParameter is used as the parameter for
{@link TPagedList::onPageChanged OnPageChanged} event.
To obtain the page index before it was changed, use {@link getOldPageIndex OldPageIndex}.

__construct($oldPage)   X-Ref
Constructor.

param: integer old page index

getOldPageIndex()   X-Ref

return: integer the index of the page before the list changed to the new page

Classe: TPagedListFetchDataEventParameter  - X-Ref

TPagedListFetchDataEventParameter class.

TPagedListFetchDataEventParameter is used as the parameter for
{@link TPagedList::onFetchData OnFetchData} event.
To obtain the new page index, use {@link getNewPageIndex NewPageIndex}.
The {@link getOffset Offset} property refers to the index
of the first item in the new page, while {@link getLimit Limit}
specifies how many items are requested for the page.
Newly fetched data should be saved in {@link setData Data} property.

__construct($pageIndex,$offset,$limit)   X-Ref
Constructor.

param: integer new page index
param: integer offset of the first item in the new page
param: integer number of items in the new page desired

getNewPageIndex()   X-Ref

return: integer the zero-based index of the new page

getOffset()   X-Ref

return: integer offset of the first item in the new page

getLimit()   X-Ref

return: integer number of items in the new page

getData()   X-Ref

return: mixed new page data

setData($value)   X-Ref

param: mixed new page data



Généré le : Sun Feb 25 21:07:04 2007 par Balluche grâce à PHPXref 0.7