Documentation

Table
in package

HTML Table Generating Class

Lets you create tables manually or from database result objects, or arrays.

Table of Contents

$autoHeading  : bool
Whether or not to automatically create the table header
$caption  : string|null
Table caption
$emptyCells  : string
Contents of empty cells
$footing  : array<string|int, mixed>
Data for table footing
$function  : callable|null
Callback for custom table layout
$heading  : array<string|int, mixed>
Data for table heading
$newline  : string
Newline setting
$rows  : array<string|int, mixed>
Data for table rows
$template  : array<string|int, mixed>
Table layout template
__construct()  : void
Set the template from the table config file if it exists
addRow()  : Table
Add a table row
clear()  : Table
Clears the table arrays. Useful if multiple tables are being generated
generate()  : string
Generate the table
makeColumns()  : array<string|int, mixed>|false
Set columns. Takes a one-dimensional array as input and creates a multi-dimensional array with a depth equal to the number of columns. This allows a single array with many elements to be displayed in a table that has a fixed column count.
setCaption()  : Table
Add a table caption
setEmpty()  : Table
Set "empty" cells
setFooting()  : Table
Set the table footing
setHeading()  : Table
Set the table heading
setTemplate()  : bool
Set the template
_compileTemplate()  : void
Compile Template
_defaultTemplate()  : array<string|int, mixed>
Default Template
_prepArgs()  : array<string|int, mixed>
Prep Args
_setFromArray()  : void
Set table data from an array
_setFromDBResult()  : void
Set table data from a database result object

Properties

$autoHeading

Whether or not to automatically create the table header

public bool $autoHeading = true

$caption

Table caption

public string|null $caption

$emptyCells

Contents of empty cells

public string $emptyCells = ''

$footing

Data for table footing

public array<string|int, mixed> $footing = []

$function

Callback for custom table layout

public callable|null $function

$heading

Data for table heading

public array<string|int, mixed> $heading = []

$newline

Newline setting

public string $newline = " "

$rows

Data for table rows

public array<string|int, mixed> $rows = []

$template

Table layout template

public array<string|int, mixed> $template

Methods

__construct()

Set the template from the table config file if it exists

public __construct([array<string|int, mixed> $config = [] ]) : void
Parameters
$config : array<string|int, mixed> = []

(default: array())

Return values
void

addRow()

Add a table row

public addRow() : Table

Can be passed as an array or discreet params

Return values
Table

clear()

Clears the table arrays. Useful if multiple tables are being generated

public clear() : Table
Return values
Table

generate()

Generate the table

public generate([mixed $tableData = null ]) : string
Parameters
$tableData : mixed = null
Return values
string

makeColumns()

Set columns. Takes a one-dimensional array as input and creates a multi-dimensional array with a depth equal to the number of columns. This allows a single array with many elements to be displayed in a table that has a fixed column count.

public makeColumns([array<string|int, mixed> $array = [] ], int $columnLimit) : array<string|int, mixed>|false
Parameters
$array : array<string|int, mixed> = []
$columnLimit : int
Return values
array<string|int, mixed>|false

setCaption()

Add a table caption

public setCaption(string $caption) : Table
Parameters
$caption : string
Return values
Table

setEmpty()

Set "empty" cells

public setEmpty(mixed $value) : Table

Can be passed as an array or discreet params

Parameters
$value : mixed
Return values
Table

setFooting()

Set the table footing

public setFooting() : Table

Can be passed as an array or discreet params

Return values
Table

setHeading()

Set the table heading

public setHeading() : Table

Can be passed as an array or discreet params

Return values
Table

setTemplate()

Set the template

public setTemplate(array<string|int, mixed> $template) : bool
Parameters
$template : array<string|int, mixed>
Return values
bool

_compileTemplate()

Compile Template

protected _compileTemplate() : void
Return values
void

_defaultTemplate()

Default Template

protected _defaultTemplate() : array<string|int, mixed>
Return values
array<string|int, mixed>

_prepArgs()

Prep Args

protected _prepArgs(array<string|int, mixed> $args) : array<string|int, mixed>

Ensures a standard associative array format for all cell data

Parameters
$args : array<string|int, mixed>
Return values
array<string|int, mixed>

_setFromArray()

Set table data from an array

protected _setFromArray(array<string|int, mixed> $data) : void
Parameters
$data : array<string|int, mixed>
Return values
void

_setFromDBResult()

Set table data from a database result object

protected _setFromDBResult(BaseResult $object) : void
Parameters
$object : BaseResult

Database result object

Return values
void

Search results