Overview

Packages

  • application
    • commands
    • components
      • actions
      • filters
      • leftWidget
      • permissions
      • sortableWidget
      • util
      • webupdater
      • x2flow
        • actions
        • triggers
      • X2GridView
      • X2Settings
    • controllers
    • models
      • embedded
    • modules
      • accounts
        • controllers
        • models
      • actions
        • controllers
        • models
      • calendar
        • controllers
        • models
      • charts
        • models
      • contacts
        • controllers
        • models
      • docs
        • components
        • controllers
        • models
      • groups
        • controllers
        • models
      • marketing
        • components
        • controllers
        • models
      • media
        • controllers
        • models
      • mobile
        • components
      • opportunities
        • controllers
        • models
      • products
        • controllers
        • models
      • quotes
        • controllers
        • models
      • services
        • controllers
        • models
      • template
        • models
      • users
        • controllers
        • models
      • workflow
        • controllers
        • models
      • x2Leads
        • controllers
        • models
  • Net
  • None
  • PHP
  • system
    • base
    • caching
      • dependencies
    • collections
    • console
    • db
      • ar
      • schema
        • cubrid
        • mssql
        • mysql
        • oci
        • pgsql
        • sqlite
    • i18n
      • gettext
    • logging
    • test
    • utils
    • validators
    • web
      • actions
      • auth
      • filters
      • form
      • helpers
      • renderers
      • services
      • widgets
        • captcha
        • pagers
  • Text
    • Highlighter
  • zii
    • behaviors
    • widgets
      • grid
      • jui

Classes

  • ActionFormModelBase
  • CActiveDataProvider
  • CalendarEventFormModel
  • CallFormModel
  • CArrayDataProvider
  • CAssetManager
  • CBaseController
  • CBaseUrlRule
  • CCacheHttpSession
  • CClientScript
  • CController
  • CCookieCollection
  • CDataProvider
  • CDataProviderIterator
  • CDbHttpSession
  • CExtController
  • CFormModel
  • CHttpCookie
  • CHttpRequest
  • CHttpSession
  • CHttpSessionIterator
  • COutputEvent
  • CPagination
  • CreatePageFormModel
  • CSort
  • CSqlDataProvider
  • CTheme
  • CThemeManager
  • CUploadedFile
  • CUrlManager
  • CUrlRule
  • CWebApplication
  • CWebModule
  • CWidgetFactory
  • EditMobileFormsFormModel
  • EventCommentPublisherFormModel
  • EventFormModel
  • EventPublisherFormModel
  • FileSystemObjectDataProvider
  • MassActionFormModel
  • MobilePagination
  • NoteFormModel
  • NotificationsController
  • TimeFormModel
  • UploadLogoFormModel
  • X2FormModel
  • X2HttpRequest

Interfaces

  • IDataProvider
  • IWidgetFactory
  • Overview
  • Package
  • Class
  • Tree

Class CPagination

CPagination represents information relevant to pagination.

When data needs to be rendered in multiple pages, we can use CPagination to represent information such as getItemCount total item count, getPageSize page size, getCurrentPage current page, etc. These information can be passed to CBasePager pagers to render pagination buttons or links.

Example:

Controller action:

function actionIndex(){
    $criteria=new CDbCriteria();
    $count=Article::model()->count($criteria);
    $pages=new CPagination($count);

    // results per page
    $pages->pageSize=10;
    $pages->applyLimit($criteria);
    $models=Article::model()->findAll($criteria);

    $this->render('index', array(
    'models' => $models,
         'pages' => $pages
    ));
}

View:

<?php foreach($models as $model): ?>
    // display a model
<?php endforeach; ?>

// display pagination
<?php $this->widget('CLinkPager', array(
    'pages' => $pages,
)) ?>
CComponent
Extended by CPagination

Direct known subclasses

MobilePagination, RememberPagination
Package: system\web
Copyright: 2008-2013 Yii Software LLC
License: http://www.yiiframework.com/license/
Author: Qiang Xue <qiang.xue@gmail.com>
Since: 1.0
Located at x2engine/framework/web/CPagination.php
Methods summary
public
# __construct( integer $itemCount = 0 )

Constructor.

Constructor.

Parameters

$itemCount
integer
$itemCount total number of items.
public integer
# getPageSize( )

Returns

integer
number of items in each page. Defaults to 10.
public
# setPageSize( integer $value )

Parameters

$value
integer
$value number of items in each page
public integer
# getItemCount( )

Returns

integer
total number of items. Defaults to 0.
public
# setItemCount( integer $value )

Parameters

$value
integer
$value total number of items.
public integer
# getPageCount( )

Returns

integer
number of pages
public integer
# getCurrentPage( boolean $recalculate = true )

Parameters

$recalculate
boolean
$recalculate whether to recalculate the current page based on the page size and item count.

Returns

integer
the zero-based index of the current page. Defaults to 0.
public
# setCurrentPage( integer $value )

Parameters

$value
integer
$value the zero-based index of the current page.
public string
# createPageUrl( CController $controller, integer $page )

Creates the URL suitable for pagination. This method is mainly called by pagers when creating URLs used to perform pagination. The default implementation is to call the controller's createUrl method with the page information. You may override this method if your URL scheme is not the same as the one supported by the controller's createUrl method.

Creates the URL suitable for pagination. This method is mainly called by pagers when creating URLs used to perform pagination. The default implementation is to call the controller's createUrl method with the page information. You may override this method if your URL scheme is not the same as the one supported by the controller's createUrl method.

Parameters

$controller
CController
$controller the controller that will create the actual URL
$page
integer
$page the page that the URL should point to. This is a zero-based index.

Returns

string
the created URL
public
# applyLimit( CDbCriteria $criteria )

Applies LIMIT and OFFSET to the specified query criteria.

Applies LIMIT and OFFSET to the specified query criteria.

Parameters

$criteria
CDbCriteria
$criteria the query criteria that should be applied with the limit
public integer
# getOffset( )

Returns

integer
the offset of the data. This may be used to set the OFFSET value for a SQL statement for fetching the current page of data.

Since

1.1.0
public integer
# getLimit( )

Returns

integer
the limit of the data. This may be used to set the LIMIT value for a SQL statement for fetching the current page of data. This returns the same value as pageSize.

Since

1.1.0
Methods inherited from CComponent
__call(), __get(), __isset(), __set(), __unset(), asa(), attachBehavior(), attachBehaviors(), attachEventHandler(), canGetProperty(), canSetProperty(), detachBehavior(), detachBehaviors(), detachEventHandler(), disableBehavior(), disableBehaviors(), enableBehavior(), enableBehaviors(), evaluateExpression(), getEventHandlers(), hasEvent(), hasEventHandler(), hasProperty(), raiseEvent()
Constants summary
integer DEFAULT_PAGE_SIZE 10
#

The default page size.

The default page size.

Properties summary
public string $pageVar 'page'
#

name of the GET variable storing the current page index. Defaults to 'page'.

name of the GET variable storing the current page index. Defaults to 'page'.

public string $route ''
#

the route (controller ID and action ID) for displaying the paged contents. Defaults to empty string, meaning using the current route.

the route (controller ID and action ID) for displaying the paged contents. Defaults to empty string, meaning using the current route.

public array $params
#

of parameters (name=>value) that should be used instead of GET when generating pagination URLs. Defaults to null, meaning using the currently available GET parameters.

of parameters (name=>value) that should be used instead of GET when generating pagination URLs. Defaults to null, meaning using the currently available GET parameters.

public boolean $validateCurrentPage true
#

whether to ensure currentPage is returning a valid page number. When this property is true, the value returned by currentPage will always be between 0 and (pageCount-1). Because pageCount relies on the correct value of itemCount, it means you must have knowledge about the total number of data items when you want to access currentPage. This is fine for SQL-based queries, but may not be feasible for other kinds of queries (e.g. MongoDB). In those cases, you may set this property to be false to skip the validation (you may need to validate yourself then). Defaults to true.

whether to ensure currentPage is returning a valid page number. When this property is true, the value returned by currentPage will always be between 0 and (pageCount-1). Because pageCount relies on the correct value of itemCount, it means you must have knowledge about the total number of data items when you want to access currentPage. This is fine for SQL-based queries, but may not be feasible for other kinds of queries (e.g. MongoDB). In those cases, you may set this property to be false to skip the validation (you may need to validate yourself then). Defaults to true.

Since

1.1.4
Magic properties summary
public integer $pageSize
#

Number of items in each page. Defaults to 10.

Number of items in each page. Defaults to 10.

public integer $itemCount
#

Total number of items. Defaults to 0.

Total number of items. Defaults to 0.

public integer $pageCount
#

Number of pages.

Number of pages.

public integer $currentPage
#

The zero-based index of the current page. Defaults to 0.

The zero-based index of the current page. Defaults to 0.

public integer $offset
#

The offset of the data. This may be used to set the OFFSET value for a SQL statement for fetching the current page of data.

The offset of the data. This may be used to set the OFFSET value for a SQL statement for fetching the current page of data.

public integer $limit
#

The limit of the data. This may be used to set the LIMIT value for a SQL statement for fetching the current page of data. This returns the same value as pageSize.

The limit of the data. This may be used to set the LIMIT value for a SQL statement for fetching the current page of data. This returns the same value as pageSize.

API documentation generated by ApiGen 2.8.0