|
static | buttonAttributes (array $attrs, array $modifiers=[]) |
| Modifies a set of attributes meant for button elements and apply a set of default attributes when $wgUseMediaWikiUIEverywhere enabled.
|
|
static | check ( $name, $checked=false, array $attribs=[]) |
| Convenience function to produce a checkbox (input element with type=checkbox)
|
|
static | closeElement ( $element) |
| Returns "</$element>".
|
|
static | element ( $element, $attribs=[], $contents='') |
| Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
|
|
static | errorBox ( $html, $heading='') |
| Return an error box.
|
|
static | expandAttributes (array $attribs) |
| Given an associative array of element attributes, generate a string to stick after the element name in HTML output.
|
|
static | getTextInputAttributes (array $attrs) |
| Modifies a set of attributes meant for text input elements and apply a set of default attributes.
|
|
static | hidden ( $name, $value, array $attribs=[]) |
| Convenience function to produce an input element with type=hidden.
|
|
static | htmlHeader (array $attribs=[]) |
| Constructs the opening html-tag with necessary doctypes depending on global variables.
|
|
static | infoBox ( $text, $icon, $alt, $class='') |
| Get HTML for an info box with an icon.
|
|
static | inlineScript ( $contents) |
| Output a "<script>" tag with the given contents.
|
|
static | inlineStyle ( $contents, $media='all', $attribs=[]) |
| Output a "<style>" tag with the given contents for the given media type (if any).
|
|
static | input ( $name, $value='', $type='text', array $attribs=[]) |
| Convenience function to produce an "<input>" element.
|
|
static | isXmlMimeType ( $mimetype) |
| Determines if the given MIME type is xml.
|
|
static | label ( $label, $id, array $attribs=[]) |
| Convenience function for generating a label for inputs.
|
|
static | linkButton ( $contents, array $attrs, array $modifiers=[]) |
| Returns an HTML link element in a string styled as a button (when $wgUseMediaWikiUIEverywhere is enabled).
|
|
static | linkedScript ( $url) |
| Output a "<script>" tag linking to the given URL, e.g., "<script src=foo.js></script>".
|
|
static | linkedStyle ( $url, $media='all') |
| Output a "<link rel=stylesheet>" linking to the given URL for the given media type (if any).
|
|
static | namespaceSelector (array $params=[], array $selectAttribs=[]) |
| Build a drop-down box for selecting a namespace.
|
|
static | namespaceSelectorOptions (array $params=[]) |
| Helper for Html::namespaceSelector().
|
|
static | openElement ( $element, $attribs=[]) |
| Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing '/' in XML mode for empty elements).
|
|
static | radio ( $name, $checked=false, array $attribs=[]) |
| Convenience function to produce a radio button (input element with type=radio)
|
|
static | rawElement ( $element, $attribs=[], $contents='') |
| Returns an HTML element in a string.
|
|
static | srcSet (array $urls) |
| Generate a srcset attribute value.
|
|
static | submitButton ( $contents, array $attrs, array $modifiers=[]) |
| Returns an HTML link element in a string styled as a button (when $wgUseMediaWikiUIEverywhere is enabled).
|
|
static | successBox ( $html) |
| Return a success box.
|
|
static | textarea ( $name, $value='', array $attribs=[]) |
| Convenience function to produce a <textarea> element.
|
|
static | warningBox ( $html) |
| Return a warning box.
|
|
This class is a collection of static functions that serve two purposes:
1) Implement any algorithms specified by HTML5, or other HTML specifications, in a convenient and self-contained way.
2) Allow HTML elements to be conveniently and safely generated, like the current Xml class but a) less confused (Xml supports HTML-specific things, but only sometimes!) and b) not necessarily confined to XML-compatible output.
There are two important configuration options this class uses:
$wgMimeType: If this is set to an xml MIME type then output should be valid XHTML5.
This class is meant to be confined to utility functions that are called from trusted code paths. It does not do enforcement of policy like not allowing elements.
- Since
- 1.16
Definition at line 48 of file Html.php.
static Html::dropDefaults |
( |
| $element, |
|
|
array | $attribs ) |
|
staticprivate |
Given an element name and an associative array of element attributes, return an array that is functionally identical to the input array, but possibly smaller.
In particular, attributes might be stripped if they are given their default values.
This method is not guaranteed to remove all redundant attributes, only some common ones and some others selected arbitrarily at random. It only guarantees that the output array should be functionally identical to the input array (currently per the HTML 5 draft as of 2009-09-06).
- Parameters
-
string | $element | Name of the element, e.g., 'a' |
array | $attribs | Associative array of attributes, e.g., [ 'href' => 'https://www.mediawiki.org/' ]. See expandAttributes() for further documentation. |
- Returns
- array An array of attributes functionally identical to $attribs
Definition at line 332 of file Html.php.
References $attribs, $type, and $value.
static Html::expandAttributes |
( |
array | $attribs | ) |
|
|
static |
Given an associative array of element attributes, generate a string to stick after the element name in HTML output.
Like [ 'href' => 'https://www.mediawiki.org/' ] becomes something like ' href="https://www.mediawiki.org"'. Again, this is like Xml::expandAttributes(), but it implements some HTML-specific logic.
Attributes that can contain space-separated lists ('class', 'accesskey' and 'rel') array values are allowed as well, which will automagically be normalized and converted to a space-separated string. In addition to a numerical array, the attribute value may also be an associative array. See the example below for how that works.
- Numerical array
'class' => [ 'foo', 'bar' ]
] );
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
- Associative array
'class' => [ 'foo', 'bar', 'foo' => false, 'quux' => true ]
] );
- Parameters
-
array | $attribs | Associative array of attributes, e.g., [ 'href' => 'https://www.mediawiki.org/' ]. Values will be HTML-escaped. A value of false or null means to omit the attribute. For boolean attributes, you can omit the key, e.g., [ 'checked' ] instead of [ 'checked' => 'checked' ] or such. |
- Exceptions
-
MWException | If an attribute that doesn't allow lists is set to an array |
- Returns
- string HTML fragment that goes between element name and '>' (starting with a space if at least one attribute is output)
Definition at line 474 of file Html.php.
References $attribs, $ret, and $value.