OOUI
Object-Oriented User Interface
Loading...
Searching...
No Matches
OOUI\Element Class Reference

DOM element abstraction. More...

+ Inheritance diagram for OOUI\Element:
+ Collaboration diagram for OOUI\Element:

Public Member Functions

 __construct (array $config=[])
 
 getTagName ()
 Get the HTML tag name.
 
 toggle ( $show=null)
 Toggle visibility of an element.
 
 getData ()
 Get element data.
 
 setData ( $data)
 Set element data.
 
 supports ( $methods)
 Check if element supports one or more methods.
 
 registerConfigCallback (callable $func)
 Register an additional function to call when building the config.
 
 getConfig (&$config)
 Add the necessary properties to the given $config array to allow reconstruction of this widget via its constructor.
 
 toString ()
 Render element into HTML.
 
- Public Member Functions inherited from OOUI\Tag
 __construct ( $tag='div')
 Create element.
 
 hasClass ( $class)
 Check for CSS class.
 
 addClasses (array $classes)
 Add CSS classes.
 
 removeClasses (array $classes)
 Remove CSS classes.
 
 toggleClasses (array $classes, $toggle=null)
 Toggle CSS classes.
 
 getTag ()
 
 getAttribute ( $key)
 Get HTML attribute value.
 
 setAttributes (array $attributes)
 Add HTML attributes.
 
 setValue ( $value)
 Set value of input element ('value' attribute for most, element content for textarea).
 
 removeAttributes (array $keys)
 Remove HTML attributes.
 
 removeContent (... $content)
 Remove any items that match by reference.
 
 appendContent (... $content)
 Add content to the end.
 
 prependContent (... $content)
 Add content to the beginning.
 
 clearContent ()
 Remove all content.
 
 getElementGroup ()
 Get group element is in.
 
 setElementGroup ( $group)
 Set group element is in.
 
 setInfusable ( $infusable)
 Enable widget for client-side infusion.
 
 isInfusable ()
 Get client-side infusability.
 
 ensureInfusableId ()
 Ensure that this given Tag is infusable and has a unique id attribute.
 
 __toString ()
 Magic method implementation.
 

Static Public Member Functions

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 Public Member Functions inherited from OOUI\Tag
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 Public Attributes

static string $tagName = 'div'
 HTML tag name.
 
static string $defaultDir = 'ltr'
 Default text direction, used for some layout calculations.
 

Protected Member Functions

 getJavaScriptClassName ()
 The class name of the JavaScript version of this widget.
 
 getGeneratedAttributes ()
 

Protected Attributes

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 = []
 
- Protected Attributes inherited from OOUI\Tag
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.
 

Detailed Description

DOM element abstraction.

@abstract

Constructor & Destructor Documentation

◆ __construct()

OOUI\Element::__construct ( array $config = [])

Member Function Documentation

◆ 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$attrsHTML 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&$configAn 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$elementElement 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$funcThe function. Parameters and return value are the same as ::getConfig().

◆ setData()

OOUI\Element::setData ( $data)

Set element data.

Parameters
mixed$dataElement data
Returns
$this

◆ setDefaultDir()

static OOUI\Element::setDefaultDir ( $dir)
static

Set the default direction of the user interface.

Parameters
string$dirText direction, either 'ltr' or 'rtl'

◆ supports()

OOUI\Element::supports ( $methods)

Check if element supports one or more methods.

Parameters
string | string[]$methodsMethod 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$showMake 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$messageMessage about the deprecation

Member Data Documentation

◆ $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: