PHP Class CI_Table, TastyIgniter

Lets you create tables manually or from database result objects, or arrays.
Author: ExpressionEngine Dev Team
Exibir arquivo Open project: tastyigniter/tastyigniter Class Usage Examples

Public Properties

Property Type Description
$auto_heading boolean Whether or not to automatically create the table header
$caption string Table caption
$empty_cells string Contents of empty cells
$function function Callback for custom table layout
$heading array Data for table heading
$newline string Newline setting
$rows array Data for table rows
$template array Table layout template

Public Methods

Method Description
__construct ( array $config = [] ) : void Set the template from the table config file if it exists
add_row ( $args = [] ) : CI_Table Add a table row
clear ( ) : CI_Table Clears the table arrays. Useful if multiple tables are being generated
generate ( mixed $table_data = NULL ) : string Generate the table
make_columns ( array $array = [], integer $col_limit ) : array 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.
set_caption ( string $caption ) : CI_Table Add a table caption
set_empty ( mixed $value ) : CI_Table Set "empty" cells
set_heading ( $args = [] ) : CI_Table Set the table heading
set_template ( array $template ) : boolean Set the template

Protected Methods

Method Description
_compile_template ( ) : void Compile Template
_default_template ( ) : array Default Template
_prep_args ( $args ) : array Prep Args
_set_from_array ( array $data ) : void Set table data from an array
_set_from_db_result ( $object ) : void Set table data from a database result object

Method Details

__construct() public method

Set the template from the table config file if it exists
public __construct ( array $config = [] ) : void
$config array (default: array())
return void

_compile_template() protected method

Compile Template
protected _compile_template ( ) : void
return void

_default_template() protected method

Default Template
protected _default_template ( ) : array
return array

_prep_args() protected method

Ensures a standard associative array format for all cell data
protected _prep_args ( $args ) : array
return array

_set_from_array() protected method

Set table data from an array
protected _set_from_array ( array $data ) : void
$data array
return void

_set_from_db_result() protected method

Set table data from a database result object
protected _set_from_db_result ( $object ) : void
return void

add_row() public method

Can be passed as an array or discreet params
public add_row ( $args = [] ) : CI_Table
return CI_Table

clear() public method

Clears the table arrays. Useful if multiple tables are being generated
public clear ( ) : CI_Table
return CI_Table

generate() public method

Generate the table
public generate ( mixed $table_data = NULL ) : string
$table_data mixed
return string

make_columns() public method

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 make_columns ( array $array = [], integer $col_limit ) : array
$array array
$col_limit integer
return array

set_caption() public method

Add a table caption
public set_caption ( string $caption ) : CI_Table
$caption string
return CI_Table

set_empty() public method

Can be passed as an array or discreet params
public set_empty ( mixed $value ) : CI_Table
$value mixed
return CI_Table

set_heading() public method

Can be passed as an array or discreet params
public set_heading ( $args = [] ) : CI_Table
return CI_Table

set_template() public method

Set the template
public set_template ( array $template ) : boolean
$template array
return boolean

Property Details

$auto_heading public_oe property

Whether or not to automatically create the table header
public bool $auto_heading
return boolean

$caption public_oe property

Table caption
public string $caption
return string

$empty_cells public_oe property

Contents of empty cells
public string $empty_cells
return string

$function public_oe property

Callback for custom table layout
public function $function
return function

$heading public_oe property

Data for table heading
public array $heading
return array

$newline public_oe property

Newline setting
public string $newline
return string

$rows public_oe property

Data for table rows
public array $rows
return array

$template public_oe property

Table layout template
public array $template
return array