PHP Class CompleteLister, atk4

Also adds support for calculating totals. Use: $list = $this->add('CompleteLister'); $list->setModel('User'); $list->addTotals(); Template (view/users.html):

Users

Joe Blogs

Sample template. Will be ignored

user.
Inheritance: extends Lister
Afficher le fichier Open project: atk4/atk4 Class Usage Examples

Méthodes publiques

Свойство Type Description
$even_css_class Used CSS class for even rows
$odd_css_class Used CSS class for odd rows
$row_t Item ($item_tag) template
$sep_html Separator
$total_rows integer After rendering will contain data row count
$totals array | boolean Will contain accumulated totals for all fields
$totals_t Template Will be initialized to "totals" template when _addTotals() is called

Protected Properties

Свойство Type Description
$container_tag Template tag for container
$item_tag Template tag for item
$odd_even Is current odd or even row?
$totals_type string Should be changed using addTotals and addGrandTotals methods only

Méthodes publiques

Méthode Description
addGrandTotals ( array $fields = UNDEFINED ) Enable totals calculation for specified array of fields.
addTotals ( array $fields = UNDEFINED ) Enable totals calculation for specified array of fields.
defaultTemplate ( ) : array Default template.
formatRow ( ) Format lister row.
formatTotalsRow ( ) Additional formatting for Totals row.
init ( ) Initialization.
removeTotals ( ) Disable totals calculation.
render ( ) Render lister.
renderDataRow ( ) Render data row.
renderRows ( ) Render lister rows.
renderSeparator ( )
renderTotalsRow ( ) Render Totals row.
updateGrandTotals ( ) Calculate grand totals of all rows.
updateTotals ( ) Add current rendered row values to totals.

Méthodes protégées

Méthode Description
_addTotals ( array $fields = UNDEFINED, string $type = null ) Private method to enable / disable totals calculation for specified array of fields.

Method Details

_addTotals() protected méthode

If particular fields not specified, then all field totals are calculated. If you only need to count records, then pass null and no fields will be calculated.
protected _addTotals ( array $fields = UNDEFINED, string $type = null )
$fields array optional array of fieldnames
$type string type of totals calculation (null|onRender|onRequest)

addGrandTotals() public méthode

If particular fields not specified, then all field totals are calculated. If you only need to count records, then pass null and no fields will be calculated. Be aware that this method works ONLY for SQL models set as data source because this calculates grand totals using DSQL.
public addGrandTotals ( array $fields = UNDEFINED )
$fields array optional array of fieldnames

addTotals() public méthode

If particular fields not specified, then all field totals are calculated. If you only need to count records, then pass null and no fields will be calculated. Be aware that if you use Paginator, then only records of current page will be calculated. If you need grand totals for all records, then use method addGrandTotals() instead.
public addTotals ( array $fields = UNDEFINED )
$fields array optional array of fieldnames

defaultTemplate() public méthode

Default template.
public defaultTemplate ( ) : array
Résultat array

formatRow() public méthode

Format lister row.
public formatRow ( )

formatTotalsRow() public méthode

Additional formatting for Totals row.
public formatTotalsRow ( )

init() public méthode

Initialization.
public init ( )

removeTotals() public méthode

Disable totals calculation.
public removeTotals ( )

render() public méthode

Render lister.
public render ( )

renderDataRow() public méthode

Render data row.
public renderDataRow ( )

renderRows() public méthode

Render lister rows.
public renderRows ( )

renderSeparator() public méthode

public renderSeparator ( )

renderTotalsRow() public méthode

Render Totals row.
public renderTotalsRow ( )

updateGrandTotals() public méthode

Called one time on rendering phase - before renderRows() call.
public updateGrandTotals ( )

updateTotals() public méthode

Called before each formatRow() call.
public updateTotals ( )

Property Details

$container_tag protected_oe property

Template tag for container
protected $container_tag

$even_css_class public_oe property

Used CSS class for even rows
public $even_css_class

$item_tag protected_oe property

Template tag for item
protected $item_tag

$odd_css_class public_oe property

Used CSS class for odd rows
public $odd_css_class

$odd_even protected_oe property

Is current odd or even row?
protected $odd_even

$row_t public_oe property

Item ($item_tag) template
public $row_t

$sep_html public_oe property

Separator
public $sep_html

$total_rows public_oe property

After rendering will contain data row count
public int $total_rows
Résultat integer

$totals public_oe property

Will contain accumulated totals for all fields
public array|bool $totals
Résultat array | boolean

$totals_t public_oe property

Will be initialized to "totals" template when _addTotals() is called
public Template $totals_t
Résultat Template

$totals_type protected_oe property

Should be changed using addTotals and addGrandTotals methods only
protected string $totals_type
Résultat string