vBulletin 5.6.5 API

vB_Library_BbCode_Table
in package
Uses vB_Trait_NoSerialize

THIS CLASS IS A DUPLICATE OF vBForum_BBCodeHelper_Table IN CORE Implementation of table BB code parsing outside of the normal class hierarchy.

This is primarily to allow reuse in multiple places in the BB code parsing tree (eg, regular parsing and WYSIWYG parsing).

Table of Contents

$add_formatting_whitespace  : bool
Whether the output should include non-significant whitespace to aid in formatting the HTML output. This will have no difference on the displayed output.
$parser  : vB_BBCodeParser
The BB code parser invoking this object.
$table_class_prefix  : string
Prefix to apply to all classes used by the table/tr/td tags.
$table_param_list  : array<string|int, mixed>
Defines the list of paramaters that can be used in a table BB code.
$td_param_list  : array<string|int, mixed>
Defines a list of params that can be used in a td BB code.
$tr_param_list  : array<string|int, mixed>
Defines a list of params that can be used in a tr BB code.
$wrap_table  : mixed
Whether to wrap the output table with a div for markup purposes
__construct()  : mixed
Constructor
__serialize()  : mixed
__sleep()  : mixed
__unserialize()  : mixed
__wakeup()  : mixed
appendClassList()  : array<string|int, mixed>
Appends an array of classes to a resolveNamedParams-formatted param list.
convertParamsToHtml()  : string
Converts arrays of CSS and HTML attributes to the correct HTML format.
getClassList()  : array<string|int, mixed>
Get the class list from a param list in the format returned by resolveNamedParams.
isValidNamedParam()  : bool
General code to validate a particular parameter for a tag that takes named params.
parseNamedParams()  : array<string|int, mixed>
Parses a string of "key: value, key: value" parameters.
parseTableTag()  : string
Parses the [table] tag and returns the necessary HTML representation.
resolveNamedParams()  : array<string|int, mixed>
Resolves a "param: value, param: value" formatted string of named parameters.
modifyCellContent()  : string
Helper method to modify the cell content before it is placed in the HTML.
modifyTableParams()  : array<string|int, mixed>
Helper method to allow modification of the paramaters for a table tag before they are used in child tags or outputted.
parseTableCells()  : string
Parses the cells of a table row
parseTableRows()  : string
Parses the rows of a table
validateTableClass()  : bool
Validates the class parameter for a table/tr/td tag. The classes passed in will be modified to be prefixed by $table_class_prefix.

Properties

$add_formatting_whitespace

Whether the output should include non-significant whitespace to aid in formatting the HTML output. This will have no difference on the displayed output.

protected bool $add_formatting_whitespace = rue

$parser

The BB code parser invoking this object.

protected vB_BBCodeParser $parser = ull

$table_class_prefix

Prefix to apply to all classes used by the table/tr/td tags.

protected string $table_class_prefix = 'text_table_'

This prevents people from using completely arbitrary classes.

$table_param_list

Defines the list of paramaters that can be used in a table BB code.

protected array<string|int, mixed> $table_param_list = array('width' => array('regex' => '#^(\d+%?)$#'), 'class' => array('callback' => array('$this', 'validateTableClass')), 'align' => array('regex' => '#^(center|right|left)$#i'))

Key is the name of the parameter. Its value is an array with any of these options:

  • regex - regex to validate against; ignored if not matched
  • callback - a callback function to validate against; can modify the param value
  • default - the default value; if specified, the attribute won't be added if its value equals the default
  • attribute - name of html attribute (defaults to key name)
  • css - name of css attribute; if specified, no html attribute will be outputted Note that when a class is specified, a permutation of its name will be "pushed down" to the levels below (eg, tr and td).

$td_param_list

Defines a list of params that can be used in a td BB code.

protected array<string|int, mixed> $td_param_list = array('width' => array('regex' => '#^(\d+%?)$#'), 'colspan' => array('default' => 1, 'regex' => '#^\d+$#'), 'bgcolor' => array('regex' => '/^(#[0-9a-f]{3,6}|[a-z]+)$/i', 'css' => 'background-color'), 'class' => array('callback' => array('$this', 'validateTableClass')), 'align' => array('regex' => '#^(center|right|left)$#i'))

Format is the same as $table_param_list.

$tr_param_list

Defines a list of params that can be used in a tr BB code.

protected array<string|int, mixed> $tr_param_list = array('bgcolor' => array('regex' => '/^(#[0-9a-f]{3,6}|[a-z]+)$/i', 'css' => 'background-color'), 'class' => array('callback' => array('$this', 'validateTableClass')))

Format is the same as $table_param_list.

$wrap_table

Whether to wrap the output table with a div for markup purposes

protected mixed $wrap_table = rue

Methods

__construct()

Constructor

public __construct(vB_Library_Bbcode $parser) : mixed
Parameters
$parser : vB_Library_Bbcode
Return values
mixed

__serialize()

public __serialize() : mixed
Return values
mixed

__sleep()

public __sleep() : mixed
Return values
mixed

__unserialize()

public __unserialize(mixed $serialized) : mixed
Parameters
$serialized : mixed
Return values
mixed

__wakeup()

public __wakeup() : mixed
Return values
mixed

appendClassList()

Appends an array of classes to a resolveNamedParams-formatted param list.

public appendClassList(array<string|int, mixed> $params, array<string|int, mixed> $classes[, mixed $context = '' ]) : array<string|int, mixed>

Optitionally takes a context which will append "_$context" to the appended classes.

Parameters
$params : array<string|int, mixed>
$classes : array<string|int, mixed>
$context : mixed = ''
Return values
array<string|int, mixed>

resolveNamedParams-formatted param list with extra classes appended

convertParamsToHtml()

Converts arrays of CSS and HTML attributes to the correct HTML format.

public convertParamsToHtml(array<string|int, mixed> $css, array<string|int, mixed> $attributes) : string
Parameters
$css : array<string|int, mixed>
$attributes : array<string|int, mixed>
Return values
string

HTML attributes that can be applied to a tag.

getClassList()

Get the class list from a param list in the format returned by resolveNamedParams.

public getClassList(array<string|int, mixed> $params[, mixed $context = '' ]) : array<string|int, mixed>
Parameters
$params : array<string|int, mixed>
$context : mixed = ''
Return values
array<string|int, mixed>

Array of classes

isValidNamedParam()

General code to validate a particular parameter for a tag that takes named params.

public isValidNamedParam(mixed &$value, mixed $config[, mixed $context = '' ]) : bool
Parameters
$value : mixed
$config : mixed
$context : mixed = ''
Return values
bool

parseNamedParams()

Parses a string of "key: value, key: value" parameters.

public parseNamedParams(mixed $params_raw) : array<string|int, mixed>
Parameters
$params_raw : mixed
Return values
array<string|int, mixed>

Key-value formatted array

parseTableTag()

Parses the [table] tag and returns the necessary HTML representation.

public parseTableTag(mixed $content[, mixed $params = '' ]) : string

TRs and TDs are parsed by this function (they are not real BB codes). Classes are pushed down to inner tags (TRs and TDs) and TRs are automatically valigned top.

Parameters
$content : mixed
$params : mixed = ''
Return values
string

HTML representation of the table and its contents.

resolveNamedParams()

Resolves a "param: value, param: value" formatted string of named parameters.

public resolveNamedParams(mixed $param_string, array<string|int, mixed> $param_list[, mixed $context = '' ]) : array<string|int, mixed>

This validates against a list of allowed parameters; only valid params will be returned. Returns array with 2 keys (css, attributes) each with param => value arrays as values.

Parameters
$param_string : mixed
$param_list : array<string|int, mixed>
$context : mixed = ''
Return values
array<string|int, mixed>

array('css' => array( => ...), 'attributes' => array( => ...))

modifyCellContent()

Helper method to modify the cell content before it is placed in the HTML.

protected modifyCellContent(mixed $content) : string
Parameters
$content : mixed
Return values
string

Modified cell content

modifyTableParams()

Helper method to allow modification of the paramaters for a table tag before they are used in child tags or outputted.

protected modifyTableParams(array<string|int, mixed> $table_params) : array<string|int, mixed>
Parameters
$table_params : array<string|int, mixed>
Return values
array<string|int, mixed>

Table parameters modified if necessary

parseTableCells()

Parses the cells of a table row

protected parseTableCells(mixed $content, array<string|int, mixed> $row_classes) : string
Parameters
$content : mixed
$row_classes : array<string|int, mixed>
Return values
string

HTML output of the cells

parseTableRows()

Parses the rows of a table

protected parseTableRows(mixed $content, array<string|int, mixed> $table_classes) : string
Parameters
$content : mixed
$table_classes : array<string|int, mixed>
Return values
string

HTML output of the rows

validateTableClass()

Validates the class parameter for a table/tr/td tag. The classes passed in will be modified to be prefixed by $table_class_prefix.

protected validateTableClass(mixed &$class_string[, mixed $context = '' ]) : bool
Parameters
$class_string : mixed
$context : mixed = ''
Return values
bool

Search results