TYPO3  7.6
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
Table Class Reference

Public Member Functions

 __construct (OutputInterface $output)
 
 setStyle ($name)
 
 getStyle ()
 
 setHeaders (array $headers)
 
 setRows (array $rows)
 
 addRows (array $rows)
 
 addRow ($row)
 
 setRow ($column, array $row)
 
 render ()
 

Static Public Member Functions

static setStyleDefinition ($name, TableStyle $style)
 
static getStyleDefinition ($name)
 

Private Member Functions

 renderRowSeparator ()
 
 renderColumnSeparator ()
 
 renderRow (array $row, $cellFormat)
 
 renderCell (array $row, $column, $cellFormat)
 
 calculateNumberOfColumns ()
 
 buildTableRows ($rows)
 
 fillNextRows ($rows, $line)
 
 fillCells ($row, $column)
 
 copyRow ($rows, $line)
 
 getNumberOfColumns (array $row)
 
 getRowColumns ($row)
 
 getColumnWidth ($column)
 
 getColumnSeparatorWidth ()
 
 getCellWidth (array $row, $column)
 
 cleanup ()
 

Static Private Member Functions

static initStyles ()
 

Private Attributes

 $headers = array()
 
 $rows = array()
 
 $columnWidths = array()
 
 $numberOfColumns
 
 $output
 
 $style
 

Static Private Attributes

static $styles
 

Detailed Description

Provides helpers to display a table.

Author
Fabien Potencier fabie.nosp@m.n@sy.nosp@m.mfony.nosp@m..com
Саша Стаменковић umpir.nosp@m.sky@.nosp@m.gmail.nosp@m..com
Abdellatif Ait boudad a.ait.nosp@m.boud.nosp@m.ad@gm.nosp@m.ail..nosp@m.com

Definition at line 23 of file Table.php.

Constructor & Destructor Documentation

__construct ( OutputInterface  $output)

Definition at line 65 of file Table.php.

References Table\$output, and Table\setStyle().

Member Function Documentation

addRow (   $row)

Definition at line 169 of file Table.php.

Referenced by Table\addRows().

addRows ( array  $rows)

Definition at line 160 of file Table.php.

References Table\addRow().

Referenced by Table\setRows().

buildTableRows (   $rows)
private

Definition at line 338 of file Table.php.

References Table\$rows, Table\fillCells(), and Table\fillNextRows().

Referenced by Table\render().

calculateNumberOfColumns ( )
private

Calculate number of columns for this table.

Definition at line 320 of file Table.php.

References Table\getNumberOfColumns().

Referenced by Table\render().

cleanup ( )
private

Called after rendering to cleanup cache data.

Definition at line 568 of file Table.php.

Referenced by Table\render().

copyRow (   $rows,
  $line 
)
private
Parameters
array$rows
int$line
Returns
array

Definition at line 455 of file Table.php.

References Table\$rows.

Referenced by Table\fillNextRows().

fillCells (   $row,
  $column 
)
private

fill cells for a row that contains colspan > 1.

Parameters
array$row
array$column
Returns
array

Definition at line 436 of file Table.php.

References TableCell\getColspan().

Referenced by Table\buildTableRows().

fillNextRows (   $rows,
  $line 
)
private

fill rows that contains rowspan > 1.

Parameters
array$rows
array$line
Returns
array

Definition at line 383 of file Table.php.

References Table\$rows, Table\copyRow(), Table\getNumberOfColumns(), and TableCell\getRowspan().

Referenced by Table\buildTableRows().

getCellWidth ( array  $row,
  $column 
)
private

Gets cell width.

Parameters
array$row
int$column
Returns
int

Definition at line 549 of file Table.php.

References TableCell\getColspan(), and Helper\strlenWithoutDecoration().

Referenced by Table\getColumnWidth().

getColumnSeparatorWidth ( )
private

Gets column width.

Parameters
int$column
Returns
int

Definition at line 536 of file Table.php.

Referenced by Table\renderCell().

getColumnWidth (   $column)
private

Gets column width.

Parameters
int$column
Returns
int

Definition at line 512 of file Table.php.

References Table\getCellWidth().

Referenced by Table\renderCell(), and Table\renderRowSeparator().

getNumberOfColumns ( array  $row)
private

Gets number of columns by row.

Parameters
array$row
Returns
int

Definition at line 475 of file Table.php.

Referenced by Table\calculateNumberOfColumns(), and Table\fillNextRows().

getRowColumns (   $row)
private

Gets list of columns for the given row.

Parameters
array$row
Returns
array()

Definition at line 492 of file Table.php.

References TableCell\getColspan().

Referenced by Table\renderRow().

getStyle ( )

Gets the current table style.

Returns
TableStyle

Definition at line 136 of file Table.php.

References Table\$style.

static getStyleDefinition (   $name)
static

Gets a style definition by name.

Parameters
string$nameThe style name
Returns
TableStyle A TableStyle instance

Definition at line 98 of file Table.php.

static initStyles ( )
staticprivate

Definition at line 574 of file Table.php.

render ( )

Renders table to output.

Example: +------------—+--------------------—+---------------—+ | ISBN | Title | Author | +------------—+--------------------—+---------------—+ | 99921-58-10-7 | Divine Comedy | Dante Alighieri | | 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens | | 960-425-059-0 | The Lord of the Rings | J. R. R. Tolkien | +------------—+--------------------—+---------------—+

Definition at line 205 of file Table.php.

References Table\buildTableRows(), Table\calculateNumberOfColumns(), Table\cleanup(), Table\renderRow(), and Table\renderRowSeparator().

renderCell ( array  $row,
  $column,
  $cellFormat 
)
private

Renders table cell with padding.

Parameters
array$row
int$column
string$cellFormat

Definition at line 292 of file Table.php.

References TableCell\getColspan(), Table\getColumnSeparatorWidth(), Table\getColumnWidth(), Helper\strlen(), and Helper\strlenWithoutDecoration().

Referenced by Table\renderRow().

renderColumnSeparator ( )
private

Renders vertical column separator.

Definition at line 258 of file Table.php.

Referenced by Table\renderRow().

renderRow ( array  $row,
  $cellFormat 
)
private

Renders table row.

Example: | 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens |

Parameters
array$row
string$cellFormat

Definition at line 271 of file Table.php.

References Table\getRowColumns(), Table\renderCell(), and Table\renderColumnSeparator().

Referenced by Table\render().

renderRowSeparator ( )
private

Renders horizontal header separator.

Example: +--—+--------—+----—+

Definition at line 237 of file Table.php.

References Table\getColumnWidth().

Referenced by Table\render().

setHeaders ( array  $headers)

Definition at line 141 of file Table.php.

References Table\$headers.

setRow (   $column,
array  $row 
)

Definition at line 186 of file Table.php.

setRows ( array  $rows)

Definition at line 153 of file Table.php.

References Table\addRows().

setStyle (   $name)

Sets table style.

Parameters
TableStyle | string$nameThe style name or a TableStyle instance
Returns
Table

Definition at line 118 of file Table.php.

References elseif.

Referenced by Table\__construct().

static setStyleDefinition (   $name,
TableStyle  $style 
)
static

Sets a style definition.

Parameters
string$nameThe style name
TableStyle$styleA TableStyle instance

Definition at line 82 of file Table.php.

References Table\$style.

Referenced by TableTest\testStyle().

Member Data Documentation

$columnWidths = array()
private

Definition at line 44 of file Table.php.

$headers = array()
private

Definition at line 30 of file Table.php.

Referenced by Table\setHeaders().

$numberOfColumns
private

Definition at line 51 of file Table.php.

$output
private

Definition at line 56 of file Table.php.

Referenced by Table\__construct().

$rows = array()
private

Definition at line 37 of file Table.php.

Referenced by Table\buildTableRows(), Table\copyRow(), and Table\fillNextRows().

$style
private

Definition at line 61 of file Table.php.

Referenced by Table\getStyle(), and Table\setStyleDefinition().

$styles
staticprivate

Definition at line 63 of file Table.php.