|
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.
|
|
|
| getGeneratedAttributes () |
| Return an augmented attributes array, including synthetic attributes which are created from other properties (like the classes array) but which shouldn't be retained in the user-visible attributes .
|
|
◆ __construct()
OOUI\Tag::__construct |
( |
| $tag = 'div' | ) |
|
Create element.
- Parameters
-
◆ __toString()
Magic method implementation.
It was not possible to throw an exception from within a __toString() method prior to PHP 7.4.0. Doing so will result in a fatal error. This is a wrapper around the real toString() to convert them to errors instead.
- Returns
- string
◆ addClasses()
OOUI\Tag::addClasses |
( |
array | $classes | ) |
|
Add CSS classes.
- Parameters
-
array | $classes | List of classes to add |
- Returns
- $this
◆ appendContent()
OOUI\Tag::appendContent |
( |
| $content | ) |
|
Add content to the end.
Strings will be HTML-escaped, use HtmlSnippet to prevent that.
Accepts either variadic arguments (the $content argument can be repeated any number of times) or an array of arguments.
For example, these uses are valid:
- $tag->appendContent( [ $element1, $element2 ] );
- $tag->appendContent( $element1, $element2 ); This, however, is not acceptable
- $tag->appendContent( [ $element1, $element2 ], $element3 );
Objects that are already in $this->content will be moved to the end of the list, not duplicated.
- Parameters
-
string|Tag|HtmlSnippet|array | ...$content Content to append |
- Returns
- $this
◆ clearContent()
OOUI\Tag::clearContent |
( |
| ) |
|
Remove all content.
- Returns
- $this
◆ ensureInfusableId()
OOUI\Tag::ensureInfusableId |
( |
| ) |
|
Ensure that this given Tag is infusable and has a unique id
attribute.
- Returns
- $this
◆ generateElementId()
static OOUI\Tag::generateElementId |
( |
| ) |
|
|
static |
Generate a unique ID for element.
- Returns
- string ID
◆ getAttribute()
OOUI\Tag::getAttribute |
( |
| $key | ) |
|
Get HTML attribute value.
- Parameters
-
string | $key | HTML attribute name |
- Returns
- string|null
◆ getElementGroup()
OOUI\Tag::getElementGroup |
( |
| ) |
|
Get group element is in.
- Returns
- GroupElement|null Group element, null if none
◆ getGeneratedAttributes()
OOUI\Tag::getGeneratedAttributes |
( |
| ) |
|
|
protected |
Return an augmented attributes
array, including synthetic attributes which are created from other properties (like the classes
array) but which shouldn't be retained in the user-visible attributes
.
- Returns
- string[]
Reimplemented in OOUI\Element.
◆ getTag()
◆ hasClass()
OOUI\Tag::hasClass |
( |
| $class | ) |
|
Check for CSS class.
- Parameters
-
string | $class | CSS class name |
- Returns
- bool
◆ isInfusable()
OOUI\Tag::isInfusable |
( |
| ) |
|
Get client-side infusability.
- Returns
- bool If this tag/element/widget can be referenced client-side.
◆ isSafeUrl()
static OOUI\Tag::isSafeUrl |
( |
| $url | ) |
|
|
static |
Check whether user-supplied URL is safe, that is, whether outputting it will not result in XSS vulnerability.
(Note that URLs must be HTML-escaped regardless of this check.)
The point is to disallow 'javascript:' URLs (there are no good reasons to ever use them anyway), but there's no good way to prohibit them because of very lax parsing in browsers.
An URL is safe if:
- it is empty, or
- it starts with an allowed protocol, followed by a colon (absolute URL), or
- it starts with two slashes
//
(protocol-relative URL), or
- it starts with a single slash
/
, or dot and slash ./
(relative URL), or
- it starts with a question mark
?
(replace query part in current URL), or
- it starts with a pound sign
#
(replace fragment part in current URL)
Plain relative URLs (like index.php
) are not allowed, since it's pretty much impossible to distinguish them from malformed absolute ones (again, very lax rules for parsing protocols).
- Parameters
-
- Returns
- bool [description]
◆ prependContent()
OOUI\Tag::prependContent |
( |
| $content | ) |
|
Add content to the beginning.
Accepts either variadic arguments (the $content argument can be repeated any number of times) or an array of arguments.
Objects that are already in $this->content will be moved to the end of the list, not duplicated.
For example, these uses are valid:
- $tag->prependContent( [ $element1, $element2 ] );
- $tag->prependContent( $element1, $element2 ); This, however, is not acceptable
- $tag->prependContent( [ $element1, $element2 ], $element3 );
- Parameters
-
string|Tag|HtmlSnippet|array | ...$content Content to prepend. Strings will be HTML-escaped for output, use a HtmlSnippet instance to prevent that. |
- Returns
- $this
◆ removeAttributes()
OOUI\Tag::removeAttributes |
( |
array | $keys | ) |
|
Remove HTML attributes.
- Parameters
-
array | $keys | List of attribute keys to remove |
- Returns
- $this
◆ removeClasses()
OOUI\Tag::removeClasses |
( |
array | $classes | ) |
|
Remove CSS classes.
- Parameters
-
array | $classes | List of classes to remove |
- Returns
- $this
◆ removeContent()
OOUI\Tag::removeContent |
( |
| $content | ) |
|
Remove any items that match by reference.
String items should never match by reference so will not be removed.
- Parameters
-
string|Tag|HtmlSnippet|array | ...$content Content to remove. |
- Returns
- $this
◆ resetElementId()
static OOUI\Tag::resetElementId |
( |
| ) |
|
|
static |
◆ setAttributes()
OOUI\Tag::setAttributes |
( |
array | $attributes | ) |
|
Add HTML attributes.
- Parameters
-
array | $attributes | List of attribute key/value pairs to add |
- Returns
- $this
◆ setElementGroup()
OOUI\Tag::setElementGroup |
( |
| $group | ) |
|
Set group element is in.
- Parameters
-
GroupElement | null | $group | Group element, null if none |
- Returns
- $this
◆ setInfusable()
OOUI\Tag::setInfusable |
( |
| $infusable | ) |
|
Enable widget for client-side infusion.
- Parameters
-
bool | $infusable | True to allow tag/element/widget to be referenced client-side. |
- Returns
- $this
◆ setValue()
OOUI\Tag::setValue |
( |
| $value | ) |
|
◆ toggleClasses()
OOUI\Tag::toggleClasses |
( |
array | $classes, |
|
|
| $toggle = null ) |
Toggle CSS classes.
- Parameters
-
array | $classes | List of classes to add |
bool | null | $toggle | Add classes |
- Returns
- $this
◆ toString()
Render element into HTML.
- Returns
- string HTML serialization
Reimplemented in OOUI\Element.
◆ $attributes
array OOUI\Tag::$attributes = [] |
|
protected |
Attributes.
HTML attributes
◆ $classes
array OOUI\Tag::$classes = [] |
|
protected |
◆ $content
array OOUI\Tag::$content = [] |
|
protected |
Content.
Content text and elements
◆ $elementGroup
GroupElement null OOUI\Tag::$elementGroup = null |
|
protected |
Group.
Group element is in
◆ $infusable
bool OOUI\Tag::$infusable = false |
|
protected |
Infusion support.
Whether to serialize tag/element/widget state for client-side use.
◆ $tag
string OOUI\Tag::$tag = '' |
|
protected |
Tag name for this instance.
HTML tag name
The documentation for this class was generated from the following file: