DOM element abstraction.
More...
|
static | warnDeprecation ( $message='') |
| Emits a deprecation warning with provided message.
|
|
static | getDir (Tag $element) |
| Get the direction of the user interface for a given element.
|
|
static | setDefaultDir ( $dir) |
| Set the default direction of the user interface.
|
|
static | configFromHtmlAttributes (array $attrs) |
| A helper method to massage an array of HTML attributes into a format that is more likely to work with an OOUI PHP element, camel-casing attribute names and setting values of boolean ones to true.
|
|
static | generateElementId () |
| Generate a unique ID for element.
|
|
static | resetElementId () |
| Reset the unique ID, for consistent test output.
|
|
static | isSafeUrl ( $url) |
| Check whether user-supplied URL is safe, that is, whether outputting it will not result in XSS vulnerability.
|
|
|
static string | $tagName = 'div' |
| HTML tag name.
|
|
static string | $defaultDir = 'ltr' |
| Default text direction, used for some layout calculations.
|
|
|
mixed | $data = null |
| Element data.
|
|
bool | $visible = true |
|
array | $ownClasses = [] |
| Strings of the CSS classes explicitly configured for this element (as opposed to #$classes, which contains all classes for this element).
|
|
callable[] | $configCallbacks = [] |
|
string | $tag = '' |
| Tag name for this instance.
|
|
array | $attributes = [] |
| Attributes.
|
|
array | $classes = [] |
| Classes.
|
|
array | $content = [] |
| Content.
|
|
GroupElement null | $elementGroup = null |
| Group.
|
|
bool | $infusable = false |
| Infusion support.
|
|
DOM element abstraction.
@abstract
◆ __construct()
OOUI\Element::__construct |
( |
array | $config = [] | ) |
|
- Parameters
-
array | $config | Configuration options
- string[] $config['classes'] CSS class names to add
- string $config['id'] HTML id attribute
- string $config['text'] Text to insert
- string[]|HtmlSnippet[]|Element[] $config['content'] Content to append (after text). Strings will be HTML-escaped for output, use an HtmlSnippet instance to prevent that.
- mixed $config['data'] Element data
|
Reimplemented in OOUI\HiddenInputWidget, OOUI\Layout, OOUI\FieldsetLayout, OOUI\FormLayout, OOUI\HorizontalLayout, OOUI\IndexLayout, OOUI\MenuLayout, OOUI\PanelLayout, OOUI\StackLayout, OOUI\Widget, OOUI\ButtonGroupWidget, OOUI\ButtonInputWidget, OOUI\ButtonWidget, OOUI\CheckboxInputWidget, OOUI\CheckboxMultiselectInputWidget, OOUI\ComboBoxInputWidget, OOUI\DropdownInputWidget, OOUI\IconWidget, OOUI\IndicatorWidget, OOUI\InputWidget, OOUI\LabelWidget, OOUI\MessageWidget, OOUI\MultilineTextInputWidget, OOUI\NumberInputWidget, OOUI\OptionWidget, OOUI\ProgressBarWidget, OOUI\RadioInputWidget, OOUI\RadioSelectInputWidget, OOUI\SearchInputWidget, OOUI\SelectFileInputWidget, OOUI\SelectWidget, OOUI\TabOptionWidget, OOUI\TabSelectWidget, OOUI\TextInputWidget, OOUI\ToggleSwitchWidget, and OOUI\ToggleWidget.
◆ configFromHtmlAttributes()
static OOUI\Element::configFromHtmlAttributes |
( |
array | $attrs | ) |
|
|
static |
A helper method to massage an array of HTML attributes into a format that is more likely to work with an OOUI PHP element, camel-casing attribute names and setting values of boolean ones to true.
Intended as a convenience to be used when refactoring legacy systems using HTML to use OOUI.
- Parameters
-
array | $attrs | HTML attributes, e.g. ‘[ 'disabled’ => '', 'accesskey' => 'k' ] @return array OOUI PHP element config, e.g. [ 'disabled' => true, 'accessKey' => 'k' ]` |
◆ getConfig()
OOUI\Element::getConfig |
( |
& | $config | ) |
|
Add the necessary properties to the given $config
array to allow reconstruction of this widget via its constructor.
- Parameters
-
array | &$config | An array which will be mutated to add the necessary configuration properties. Unless you are implementing a subclass, you should always pass a new empty array [] . |
- Returns
- array A configuration array which can be passed to this object's constructor to recreate it. This is a return value to allow the safe use of copy-by-value functions like
array_merge
in the implementation.
Reimplemented in OOUI\ActionFieldLayout, OOUI\FieldLayout, OOUI\FieldsetLayout, OOUI\FormLayout, OOUI\IndexLayout, OOUI\MenuLayout, OOUI\PanelLayout, OOUI\StackLayout, OOUI\TabPanelLayout, OOUI\Widget, OOUI\ButtonInputWidget, OOUI\ButtonWidget, OOUI\CheckboxInputWidget, OOUI\CheckboxMultiselectInputWidget, OOUI\ComboBoxInputWidget, OOUI\DropdownInputWidget, OOUI\HiddenInputWidget, OOUI\InputWidget, OOUI\LabelWidget, OOUI\MessageWidget, OOUI\MultilineTextInputWidget, OOUI\NumberInputWidget, OOUI\OptionWidget, OOUI\ProgressBarWidget, OOUI\RadioInputWidget, OOUI\RadioSelectInputWidget, OOUI\SelectFileInputWidget, OOUI\TabOptionWidget, OOUI\TabSelectWidget, OOUI\TextInputWidget, OOUI\ToggleSwitchWidget, and OOUI\ToggleWidget.
◆ getData()
OOUI\Element::getData |
( |
| ) |
|
Get element data.
- Returns
- mixed Element data
◆ getDir()
static OOUI\Element::getDir |
( |
Tag | $element | ) |
|
|
static |
Get the direction of the user interface for a given element.
Currently only per-document directionality is supported.
- Parameters
-
Tag | $element | Element to check |
- Returns
- string Text direction, either 'ltr' or 'rtl'
◆ getGeneratedAttributes()
OOUI\Element::getGeneratedAttributes |
( |
| ) |
|
|
protected |
- Returns
- string[]
Reimplemented from OOUI\Tag.
◆ getJavaScriptClassName()
OOUI\Element::getJavaScriptClassName |
( |
| ) |
|
|
protected |
The class name of the JavaScript version of this widget.
- Returns
- string
◆ getTagName()
OOUI\Element::getTagName |
( |
| ) |
|
Get the HTML tag name.
Override this method to base the result on instance information.
- Returns
- string HTML tag name
◆ registerConfigCallback()
OOUI\Element::registerConfigCallback |
( |
callable | $func | ) |
|
Register an additional function to call when building the config.
See ::getConfig().
- Parameters
-
callable | $func | The function. Parameters and return value are the same as ::getConfig(). |
◆ setData()
OOUI\Element::setData |
( |
| $data | ) |
|
Set element data.
- Parameters
-
- Returns
- $this
◆ setDefaultDir()
static OOUI\Element::setDefaultDir |
( |
| $dir | ) |
|
|
static |
Set the default direction of the user interface.
- Parameters
-
string | $dir | Text direction, either 'ltr' or 'rtl' |
◆ supports()
OOUI\Element::supports |
( |
| $methods | ) |
|
Check if element supports one or more methods.
- Parameters
-
string | string[] | $methods | Method or list of methods to check |
- Returns
- bool All methods are supported
◆ toggle()
OOUI\Element::toggle |
( |
| $show = null | ) |
|
Toggle visibility of an element.
- Parameters
-
bool | null | $show | Make element visible, omit to toggle visibility |
- Returns
- $this
◆ toString()
OOUI\Element::toString |
( |
| ) |
|
Render element into HTML.
- Returns
- string HTML serialization
Reimplemented from OOUI\Tag.
◆ warnDeprecation()
static OOUI\Element::warnDeprecation |
( |
| $message = '' | ) |
|
|
static |
Emits a deprecation warning with provided message.
- Parameters
-
string | $message | Message about the deprecation |
◆ $defaultDir
string OOUI\Element::$defaultDir = 'ltr' |
|
static |
Default text direction, used for some layout calculations.
Use setDefaultDir() to change.
Currently only per-document directionality is supported.
◆ $tagName
string OOUI\Element::$tagName = 'div' |
|
static |
HTML tag name.
This may be ignored if getTagName() is overridden.
The documentation for this class was generated from the following file: