Helper methods for the admin template functions/tags.

package XenForo_Template

 Methods

Helper to prepare and return the HTML for a collection of check box inputs.

checkBox(string $name, array $choices, array $controlOptions) : string

Parameters

$name

string

Default name of the chec kbox. If used, [] will be appended.

$choices

array

Choices for the check box

$controlOptions

array

Options that relate to the check box controls

Returns

string

Helper to prepare and return the HTML for a control unit with a collection of check box inputs.

checkBoxUnit(string $label, string $name, array $choices, array $rowOptions, array $controlOptions) : string

Parameters

$label

string

Label for the unit

$name

string

Default name of the chec kbox. If used, [] will be appended.

$choices

array

Choices for the check box

$rowOptions

array

Options that relate to the whole row

$controlOptions

array

Options that relate to the check box controls

Returns

string

Helper to prepare and return the HTML for a control unit with a combo box input.

comboBox(string $name, string $value, array $choices, array $controlOptions) : string

Parameters

$name

string

Name of the text box

$value

string

Default value for the text box

$choices

array

Choices for the select

$controlOptions

array

Options that relate to the text/select controls

Returns

string

Helper to prepare and return the HTML for a control unit with a combo box input.

comboBoxUnit(string $label, string $name, string $value, array $choices, array $rowOptions, array $controlOptions) : string

Parameters

$label

string

Label for the unit

$name

string

Name of the text box

$value

string

Default value for the text box

$choices

array

Choices for the select

$rowOptions

array

Options that relate to the whole row

$controlOptions

array

Options that relate to the text/select controls

Returns

string

Outputs a control unit row.

controlUnit(string $label, array $rowOptions) : string

This does not contain any input field unless you manually include one. Note that the label will not be "for" any input.

Parameters

$label

string

Label text

$rowOptions

array

Collection of options that relate to the row

Returns

string

Outputs an HTML form.

form(string $childElements, array $options) : string

Parameters

$childElements

string

Child elements

$options

array

Returns

string

Returns the ID used for filter list items and lastHash

getListItemId(mixed $id) : string

Parameters

$id

mixed

Returns

string

Returns a list item element.

listItem(array $controlOptions, array $popups) : string

Parameters

$controlOptions

array

Options relating to the item

$popups

array

A list of popups (HTML) that belong to the item

Returns

stringList row HTML

Array merging function to merge option and options tags.

mergeOptionArrays(array $start, array $additional, boolean $raw) : array

"Simple" form (value => label) data will be translated into a simple array format to be unambiguous.

Parameters

$start

array

The base array

$additional

array

The data to add to the base array. Ignored if not an array.

$raw

boolean

If true, escaping is not done on printable components

Returns

array

Helper to prepare and return the HTML for a single password input.

password(string $name, string $value, array $controlOptions) : string

Parameters

$name

string

Name of the text box

$value

string

Default value of the text box

$controlOptions

array

Options that relate to the control

Returns

string

Helper to prepare and return the HTML for a control unit with a single password input.

passwordUnit(string $label, string $name, string $value, array $rowOptions, array $controlOptions) : string

Parameters

$label

string

Label for the row

$name

string

Name of the text box

$value

string

Default value of the text box

$rowOptions

array

Options that relate to the row

$controlOptions

array

Options that relate to the control

Returns

string

Helper to prepare and return the HTML for a collection of radio inputs.

radio(string $name, string $value, array $choices, array $controlOptions) : string

Parameters

$name

string

Name of the radios

$value

string

Selected value for the radio

$choices

array

Choices for the radios

$controlOptions

array

Options that relate to the radio controls

Returns

string

Helper to prepare and return the HTML for a control unit with a collection of radio inputs.

radioUnit(string $label, string $name, string $value, array $choices, array $rowOptions, array $controlOptions) : string

Parameters

$label

string

Label for the unit

$name

string

Name of the radios

$value

string

Selected value for the radio

$choices

array

Choices for the radios

$rowOptions

array

Options that relate to the whole row

$controlOptions

array

Options that relate to the radio controls

Returns

string

Resets the control counter.

resetControlCounter() 

This may cause duplicate IDs. Primarily used for testing.

Helper to prepare and return the HTML for a single select input.

select(string $name, string $value, array $choices, array $controlOptions) : string

Parameters

$name

string

Name of the select

$value

string

Selected value for the select

$choices

array

Choices for the select

$controlOptions

array

Options that relate to the select control

Returns

string

Helper to prepare and return the HTML for a control unit with a single select input.

selectUnit(string $label, string $name, string $value, array $choices, array $rowOptions, array $controlOptions) : string

Parameters

$label

string

Label for the unit

$name

string

Name of the select

$value

string

Selected value for the select

$choices

array

Choices for the select

$rowOptions

array

Options that relate to the whole row

$controlOptions

array

Options that relate to the select control

Returns

string

Helper to prepare and return the HTML for a control unit with a single spin box input.

spinBox(string $name, string $value, array $controlOptions) : string

Parameters

$name

string

Name of the text box

$value

string

Default value of the text box

$controlOptions

array

Options that relate to the control

Returns

string

Helper to prepare and return the HTML for a control unit with a single spin box input.

spinBoxUnit(string $label, string $name, string $value, array $rowOptions, array $controlOptions) : string

Parameters

$label

string

Label for the row

$name

string

Name of the text box

$value

string

Default value of the text box

$rowOptions

array

Options that relate to the row

$controlOptions

array

Options that relate to the control

Returns

string

Outputs a submit unit row containing submit or reset buttons (and any additional HTML).

submitUnit(string $childText, array $controlOptions) : string

Parameters

$childText

string

Output from text that was within the submitunit tag

$controlOptions

array

Options for this control

Returns

string

Helper to prepare and return the HTML for a single text box.

textBox(string $name, string $value, array $controlOptions) : string

Parameters

$name

string

Name of the text box

$value

string

Default value of the text box

$controlOptions

array

Options that relate to the control

Returns

string

Helper to prepare and return the HTML for a control unit with a single text box.

textBoxUnit(string $label, string $name, string $value, array $rowOptions, array $controlOptions) : string

Parameters

$label

string

Label for the row

$name

string

Name of the text box

$value

string

Default value of the text box

$rowOptions

array

Options that relate to the row

$controlOptions

array

Options that relate to the control

Returns

string

Helper to prepare and return the HTML for a single file upload input.

upload(string $name, string $value, array $controlOptions) : string

Parameters

$name

string

Name of the input

$value

string

Default value of the text box (likely ignored)

$controlOptions

array

Options that relate to the control

Returns

string

Helper to prepare and return the HTML for a control unit with a single file upload input.

uploadUnit(string $label, string $name, string $value, array $rowOptions, array $controlOptions) : string

Parameters

$label

string

Label for the row

$name

string

Name of the input

$value

string

Default value of the upload box (likely ignored by browsers)

$rowOptions

array

Options that relate to the row

$controlOptions

array

Options that relate to the control

Returns

string

Helper to quickly append classes to a list that may or not may exist.

_appendClasses(array $array, string $key, string $append) : array

List must be within an array.

Parameters

$array

array

Array that contains the list

$key

string

Key of the list

$append

string

Classes to appended. Separate with spaces.

Returns

arrayOriginal array, updated

Callback for generating check box optgroup HTML.

_getCheckBoxGroupHtml(\$label $label, \$optionHtml $optionHtml) : string

At this time, optgroups are ignored.

Parameters

$label

\$label

Label for the group

$optionHtml

\$optionHtml

HTML for the options within the group

Returns

string

Gets a collection of check box inputs.

_getCheckBoxInput(string $name, array $choices, array $controlOptions) : string

Parameters

$name

string

Default name of the check box. If used, [] will be appended.

$choices

array

Choices for the check box

$controlOptions

array

Control options

Returns

string

Callback for generating check box option HTML.

_getCheckBoxOptionHtml(string $value, string $label, boolean $selected, array $extra, array $options) : string

Parameters

$value

string

Value for the option (what it submitted to the server)

$label

string

Label for the option (printable)

$selected

boolean

Whether this option is selected

$extra

array

Extra data about the check box

$options

array

Parsing options

Returns

string

Callback for generating combo box optgroup HTML.

_getComboBoxGroupHtml(\$label $label, \$optionHtml $optionHtml) : string

Parameters

$label

\$label

Label for the group

$optionHtml

\$optionHtml

HTML for the options within the group

Returns

string

Gets a combo box input.

_getComboBoxInput(string $name, string $value, array $choices, array $controlOptions, string $id) : string

Parameters

$name

string

Name of the select input. If multiple selections are allow, [] will be appended.

$value

string

Default selected option

$choices

array

Choices for the select

$controlOptions

array

Control options

$id

string

Optional ID for the input. If not specified, one will be generated.

Returns

string

Callback for generating combo box option HTML

_getComboBoxOptionHtml(string $value, string $label) : string

Parameters

$value

string

Value for the option (what it submitted to the server)

$label

string

Label for the option (printable)

Returns

string

Gets a unique ID for the control

_getControlId(string $name, array $controlOptions) : string

Parameters

$name

string

Name of the control. Will be used to generate the ID if possible and not overridden.

$controlOptions

Returns

string

Gets the data-* attributes for a tag AS a string, from the list of options.

_getDataAttributesAsString(array $options) : string

The given array should be all options, not just the data array.

Parameters

$options

array

All options, possibly including a _data key.

Returns

stringAttributes AS string, with a leading space if there are attributes

Gets the necessary HTML to make disabler controls (if dependent controls are specified).

_getDisablerHtml(array $optionInfo, string $optionId) : string

Parameters

$optionInfo

array

Information about the option. Disablers searched for in "disabled" key.

$optionId

string

ID that is being used for the parent of the disabler

Returns

stringHTML for the disabled controls, if applicable

Callback for generating radio optgroup HTML.

_getRadioGroupHtml(\$label $label, \$optionHtml $optionHtml) : string

At this time, optgroups are ignored.

Parameters

$label

\$label

Label for the group

$optionHtml

\$optionHtml

HTML for the options within the group

Returns

string

Gets a collection of radio inputs.

_getRadioInput(string $name, string $value, array $choices, array $controlOptions) : string

Parameters

$name

string

Name of the radop inputs.

$value

string

Default selected option

$choices

array

Choices for the radios

$controlOptions

array

Control options

Returns

string

Callback for generating radio option HTML.

_getRadioOptionHtml(string $value, string $label, boolean $selected, array $extra, array $options) : string

Parameters

$value

string

Value for the option (what it submitted to the server)

$label

string

Label for the option (printable)

$selected

boolean

Whether this option is selected

$extra

array

Extra data about the radio

$options

array

Parsing options

Returns

string

Callback for generating select optgroup HTML.

_getSelectGroupHtml(\$label $label, \$optionHtml $optionHtml) : string

Parameters

$label

\$label

Label for the group

$optionHtml

\$optionHtml

HTML for the options within the group

Returns

string

Gets a select input.

_getSelectInput(string $name, string $value, array $choices, array $controlOptions, string $id) : string

Parameters

$name

string

Name of the select input. If multiple selections are allow, [] will be appended.

$value

string

Default selected option

$choices

array

Choices for the select

$controlOptions

array

Control options

$id

string

Optional ID for the input. If not specified, one will be generated.

Returns

string

Callback for generating select option HTML

_getSelectOptionHtml(string $value, string $label, boolean $selected, array $extra) : string

Parameters

$value

string

Value for the option (what it submitted to the server)

$label

string

Label for the option (printable)

$selected

boolean

Whether this option is selected

$extra

array

Extra data about the option

Returns

string

Gets a spin box input.

_getSpinBoxInput(string $name, string $value, array $controlOptions, string $id) : string

Parameters

$name

string

Name of the input

$value

string

Default selected option

$controlOptions

array

Control options

$id

string

Optional ID for the input. If not specified, one will be generated.

Returns

string

Gets a text, password, search, number (etc) text-type input.

_getTextInput(string $type, string $name, string $value, array $controlOptions, string $id) : string

Standard text inputs may span multiple rows, turning into a textarea.

Parameters

$type

string

Type of input requested; either text or password

$name

string

Name of the input field. Already HTML escaped.

$value

string

Default value for the input field. Already HTML escaped.

$controlOptions

array

Array of options for the control

$id

string

Optional ID for the input. If not specified, one will be generated.

Returns

string

Gets a upload input.

_getUploadInput(string $name, string $value, array $controlOptions, string $id) : string

Parameters

$name

string

Name of the input

$value

string

Default selected option

$controlOptions

array

Control options

$id

string

Optional ID for the input. If not specified, one will be generated.

Returns

string

Processes the list of choices for a control into the appropriate HTML output.

_processControlChoices(array $choices, string | array $selectedValue, array $callbacks, array $options) : string

Parameters

$choices

array

Array of choices

$selectedValue

stringarray

Selected value

$callbacks

array

Callbacks. Define 2 keys: group and option

$options

array

Extra options to manipulate the choices.

Returns

string

Wraps the specified control/inner text in a full unit.

_wrapControlUnit(string $label, string $controlText, string $id, array $rowOptions) : string

Parameters

$label

string

Row label

$controlText

string

Text of the control

$id

string

Unique ID for the control

$rowOptions

array

Standard row options: * hint - hint text shown under leabel * class - class to apply to whole unit * explain - text to show under control * labelHidden - boolean, if true label is not shown * html - arbitrary html to add between control and explain text

Returns

stringControl wrapped in label/row markup

Private constructor.

__construct() 

Don't instantiate this object. Use it statically.

 Properties

 

Internal counter used for uniquely ID'ing controls.

$_controlCounter : integer

 

$_controlIdLog

$_controlIdLog 

 

Internal counter for uniquely ID'ing list row popup groups.

$_listItemGroupCounter : integer

 

Stores a single use ID for output.

$_oneUseId : null | string

Useful for generating it in one function and defering to another (possibly recursive function) to use it.

Null means it has not been set.