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
Datei anzeigen Open project: atk4/atk4 Class Usage Examples

Public Properties

Property 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

Property 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

Public Methods

Method 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.

Protected Methods

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

Method Details

_addTotals() protected method

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 method

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 method

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 method

Default template.
public defaultTemplate ( ) : array
return array

formatRow() public method

Format lister row.
public formatRow ( )

formatTotalsRow() public method

Additional formatting for Totals row.
public formatTotalsRow ( )

init() public method

Initialization.
public init ( )

removeTotals() public method

Disable totals calculation.
public removeTotals ( )

render() public method

Render lister.
public render ( )

renderDataRow() public method

Render data row.
public renderDataRow ( )

renderRows() public method

Render lister rows.
public renderRows ( )

renderSeparator() public method

public renderSeparator ( )

renderTotalsRow() public method

Render Totals row.
public renderTotalsRow ( )

updateGrandTotals() public method

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

updateTotals() public method

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
return integer

$totals public_oe property

Will contain accumulated totals for all fields
public array|bool $totals
return array | boolean

$totals_t public_oe property

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

$totals_type protected_oe property

Should be changed using addTotals and addGrandTotals methods only
protected string $totals_type
return string