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
Static

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
Static

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
Static

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
Static

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
Static

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
Static

Parameters

$childElements

string

Child elements

$options

array

Returns

string

Returns the ID used for filter list items and lastHash

getListItemId(mixed $id) : string
Static

Parameters

$id

mixed

Returns

string

Returns a list item element.

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

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
Static

"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
Static

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
Static

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

Returns HTML for a quick and simple popup control.

popup(array $controlOptions, array $choices, string $wrapTag, string $extraMenuClass) : string
Static

Parameters

$controlOptions

array

Options for the control

$choices

array

Choices within the popup; each will be an li

$wrapTag

string

Tag to wrap menu in (div or ul, for example)

$extraMenuClass

string

An extra class (or multiple) set as the menu class

Returns

stringPopup HTML

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

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

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
Static

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() 
Static

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
Static

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
Static

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
Static

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
Static

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
Static

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
Static

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
Static

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
Static

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
Static

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
Static

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, $optionHtml) : string
Static

At this time, optgroups are ignored.

Parameters

$label

Label for the group

$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
Static

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
Static

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, $optionHtml) : string
Static

Parameters

$label

Label for the group

$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
Static

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
Static

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
Static

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
Static

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
Static

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, $optionHtml) : string
Static

At this time, optgroups are ignored.

Parameters

$label

Label for the group

$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
Static

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
Static

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, $optionHtml) : string
Static

Parameters

$label

Label for the group

$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
Static

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
Static

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
Static

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
Static

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
Static

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
Static

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
Static

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

 

$_controlCounter : integer
 

$_controlIdLog 
 

$_listItemGroupCounter : integer
 

$_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.