class vB5_Template_BbCode_Tablewysiwyg extends vB5_Template_BbCode_Table

Implementation of table BB code parsing for the WYSIWYG editor.

Properties

protected array $table_param_list Defines the list of paramaters that can be used in a table BB code. from vB5_Template_BbCode_Table
protected array $tr_param_list Defines a list of params that can be used in a tr BB code. from vB5_Template_BbCode_Table
protected array $td_param_list Defines a list of params that can be used in a td BB code. from vB5_Template_BbCode_Table
protected string $table_class_prefix Prefix to apply to all classes used by the table/tr/td tags.
protected bool $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 $wrap_table Whether to wrap the output table with a div for markup purposes
protected vB_BBCodeParser $parser The BB code parser invoking this object. from vB5_Template_BbCode_Table

Methods

__construct(vB5_Template_Bbcode $parser)

Constructor

string
parseTableTag(string $content, string $params = '')

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

array
modifyTableParams(array $table_params)

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

string
parseTableRows(string $content, array $table_classes, array $table_params)

Parses the rows of a table

string
parseTableCells(string $content, array $row_classes, array $table_params)

Parses the cells of a table row

string
modifyCellContent(string $content)

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

array
getClassList(array $params, string $context = '')

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

array
appendClassList(array $params, array $classes, string $context = '')

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

array
resolveNamedParams(string $param_string, array $param_list, string $context = '')

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

string
convertParamsToHtml(array $css, array $attributes)

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

bool
isValidNamedParam(string $value, array $config, string $context = '')

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

array
parseNamedParams(string $params_raw)

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

bool
validateTableClass(string $class_string, string $context = '')

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

Details

__construct(vB5_Template_Bbcode $parser)

Constructor

Parameters

vB5_Template_Bbcode $parser Invoking BB code parser

string parseTableTag(string $content, string $params = '')

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

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

string $content Content within the table tag
string $params Optional set of parameters in an unparsed format. Parses "param: value, param: value" form.

Return Value

string HTML representation of the table and its contents.

at line 51
protected array modifyTableParams(array $table_params)

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

Parameters

array $table_params Table parameters (in format of resolveNamedParams)

Return Value

array Table parameters modified if necessary

protected string parseTableRows(string $content, array $table_classes, array $table_params)

Parses the rows of a table

Parameters

string $content Content within the table BB code
array $table_classes List of classes applied to the table BB code (from getClassList)
array $table_params Array of table params (from modifyTableParams)

Return Value

string HTML output of the rows

protected string parseTableCells(string $content, array $row_classes, array $table_params)

Parses the cells of a table row

Parameters

string $content Content within the tr BB code
array $row_classes List of classes applied to the table and tr BB codes (from getClassList)
array $table_params Array of table params (from modifyTableParams)

Return Value

string HTML output of the cells

at line 91
protected string modifyCellContent(string $content)

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

Parameters

string $content Cell content

Return Value

string Modified cell content

array getClassList(array $params, string $context = '')

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

Parameters

array $params Param set as returned by resolveNamedParams
string $context Optional context info (primarily used in child classes)

Return Value

array Array of classes

array appendClassList(array $params, array $classes, string $context = '')

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

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

Parameters

array $params resolveNamedParams-formatted param list
array $classes Array of classes to append
string $context Optional context, will be appended to class names that are added

Return Value

array resolveNamedParams-formatted param list with extra classes appended

array resolveNamedParams(string $param_string, array $param_list, string $context = '')

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

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

string $param_string Unparsed string of named params
array $param_list A list of valid params. See $table_param_list for format.
string $context Optional context that can be used to help validation methods.

Return Value

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

string convertParamsToHtml(array $css, array $attributes)

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

Parameters

array $css Key-value array of CSS attributes
array $attributes Key-value array of HTML attributes

Return Value

string HTML attributes that can be applied to a tag.

bool isValidNamedParam(string $value, array $config, string $context = '')

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

Parameters

string $value Value for the parameter
array $config Configuration for the validation of the param
string $context Context value (for a validation callback)

Return Value

bool

array parseNamedParams(string $params_raw)

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

Parameters

string $params_raw Parameters to parse

Return Value

array Key-value formatted array

protected bool validateTableClass(string $class_string, string $context = '')

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

Parameters

string $class_string List of classes. Modified to be prefixed by $table_class_prefix
string $context Optional context. Unused at this time.

Return Value

bool