PHP Class TableSummaryModule, vanilla

Since: 2.3
Author: Becky Van Bussel ([email protected])
Inheritance: extends Gdn_Module
显示文件 Open project: vanilla/vanilla Class Usage Examples

Public Methods

Method Description
__construct ( $title = '' )
addColumn ( string $key, string $name = '', array $attributes = [], string $columnClass = '' ) : TableSummaryModule Add a column to the table.
addColumnIf ( boolean | string | array $isAllowed, string $key, string $name = '', array $attributes = [], string $columnClass = '' ) : TableSummaryModule Add a column to the table if it satisfies the $isAllowed condition.
addRow ( array $row = [], string $key = '', array $attributes = [] ) : TableSummaryModule Adds a row to the table. Constrains our data to the columns we've added.
getColumns ( ) : array
getRows ( ) : array
getTitle ( ) : string
prepare ( ) : boolean Prepares the media item for rendering. Adds column-type css classes to cells in the table.
setTitle ( string $title )

Method Details

__construct() public method

public __construct ( $title = '' )

addColumn() public method

Add a column to the table.
public addColumn ( string $key, string $name = '', array $attributes = [], string $columnClass = '' ) : TableSummaryModule
$key string The key name of the column.
$name string The display-name of the column.
$attributes array The attributes for the heading cell.
$columnClass string The css class to propagate to every cell in this column.
return TableSummaryModule $this

addColumnIf() public method

Add a column to the table if it satisfies the $isAllowed condition.
public addColumnIf ( boolean | string | array $isAllowed, string $key, string $name = '', array $attributes = [], string $columnClass = '' ) : TableSummaryModule
$isAllowed boolean | string | array Either a boolean to indicate whether to actually add the item or a permission string or array of permission strings (full match) to check.
$key string The key name of the column.
$name string The display-name of the column.
$attributes array The attributes for the th cell.
$columnClass string The css class to propagate to every cell in this column.
return TableSummaryModule $this

addRow() public method

Adds a row to the table. Constrains our data to the columns we've added.
public addRow ( array $row = [], string $key = '', array $attributes = [] ) : TableSummaryModule
$row array An array representing a row where the key matches a column key and the value is either an HTML-formatted string or an object with a toString() method. (Something echo-able.)
$key string The key for the row. Nothing to do with the column key. Here for expansion, like in case we want to sort items eventually.
$attributes array The attributes on the tr element.
return TableSummaryModule $this

getColumns() public method

public getColumns ( ) : array
return array An array of column-type arrays. A column array has the following keys: key, name, attributes, columnClass.

getRows() public method

public getRows ( ) : array
return array An array of row-type arrays. Each row array has a cells and attributes key. The cells key holds an array of 'column-key' => 'cell-content' data.

getTitle() public method

public getTitle ( ) : string
return string The table title.

prepare() public method

Prepares the media item for rendering. Adds column-type css classes to cells in the table.
public prepare ( ) : boolean
return boolean Whether to render the module.

setTitle() public method

public setTitle ( string $title )
$title string