MediaWiki fundraising/REL1_35
|
This class is a collection of static functions that serve two purposes: More...
Static Public Member Functions | |
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='', $className='') |
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 ( $rawHtml, $icon, $alt, $class='') |
Get HTML for an information message box with an icon. | |
static | inlineScript ( $contents, $nonce=null) |
Output an HTML 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 ( $text, array $attrs, array $modifiers=[]) |
Returns an HTML link element in a string styled as a button (when $wgUseMediaWikiUIEverywhere is enabled). | |
static | linkedScript ( $url, $nonce=null) |
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, $className='') |
Return a success box. | |
static | textarea ( $name, $value='', array $attribs=[]) |
Convenience function to produce a <textarea> element. | |
static | warningBox ( $html, $className='') |
Return a warning box. | |
Static Private Member Functions | |
static | dropDefaults ( $element, array $attribs) |
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. | |
static | messageBox ( $html, $className, $heading='') |
Return the HTML for a message box. | |
Static Private Attributes | |
static | $boolAttribs |
static | $voidElements |
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.
|
static |
Modifies a set of attributes meant for button elements and apply a set of default attributes when $wgUseMediaWikiUIEverywhere enabled.
array | $attrs | HTML attributes in an associative array |
string[] | $modifiers | classes to add to the button |
Definition at line 110 of file Html.php.
References $wgUseMediaWikiUIEverywhere.
|
static |
|
static |
|
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).
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. |
Definition at line 338 of file Html.php.
References $type.
|
static |
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
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. |
string | $contents |
|
static |
|
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.
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. |
MWException | If an attribute that doesn't allow lists is set to an array |
|
static |
Modifies a set of attributes meant for text input elements and apply a set of default attributes.
Removes size attribute when $wgUseMediaWikiUIEverywhere enabled.
array | $attrs | An attribute array. |
Definition at line 137 of file Html.php.
References $wgUseMediaWikiUIEverywhere.
|
static |
|
static |
Constructs the opening html-tag with necessary doctypes depending on global variables.
array | $attribs | Associative array of miscellaneous extra attributes, passed to Html::element() of html tag. |
Definition at line 965 of file Html.php.
References $wgHtml5Version, $wgMimeType, and $wgXhtmlNamespaces.
|
static |
|
static |
Output an HTML script tag with the given contents.
It is unsupported for the contents to contain the sequence <script
or </script
(case-insensitive). This ensures the script can be terminated easily and consistently. It is the responsibility of the caller to avoid such character sequence by escaping or avoiding it. If found at run-time, the contents are replaced with a comment, and a warning is logged server-side.
string | $contents | JavaScript |
string | null | $nonce | Nonce for CSP header, from OutputPage->getCSP()->getNonce() |
Definition at line 572 of file Html.php.
References ContentSecurityPolicy\isNonceRequired(), wfLogWarning(), and wfWarn().
|
static |
Output a "<style>" tag with the given contents for the given media type (if any).
TODO: do some useful escaping as well, like if $contents contains literal "</style>" (admittedly unlikely).
string | $contents | CSS |
string | $media | A media type string, like 'screen' |
array | $attribs | (since 1.31) Associative array of attributes, e.g., [ 'href' => 'https://www.mediawiki.org/' ]. See expandAttributes() for further documentation. |
|
static |
Convenience function to produce an "<input>" element.
This supports the new HTML5 input types and attributes.
string | $name | Name attribute |
string | $value | Value attribute |
string | $type | Type attribute |
array | $attribs | Associative array of miscellaneous extra attributes, passed to Html::element() |
Definition at line 667 of file Html.php.
References $type.
|
static |
|
static |
|
static |
Returns an HTML link element in a string styled as a button (when $wgUseMediaWikiUIEverywhere is enabled).
string | $text | The text of the element. Will be escaped (not raw HTML) |
array | $attrs | Associative array of attributes, e.g., [ 'href' => 'https://www.mediawiki.org/' ]. See expandAttributes() for further documentation. |
string[] | $modifiers | classes to add to the button |
|
static |
Output a "<script>" tag linking to the given URL, e.g., "<script src=foo.js></script>".
string | $url | |
string | null | $nonce | Nonce for CSP header, from OutputPage->getCSP()->getNonce() |
Definition at line 596 of file Html.php.
References ContentSecurityPolicy\isNonceRequired(), and wfWarn().
|
static |
|
staticprivate |
|
static |
Build a drop-down box for selecting a namespace.
array | $params | Params to set.
|
array | $selectAttribs | HTML attributes for the generated select element.
|
|
static |
|
static |
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing '/' in XML mode for empty elements).
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. |
Definition at line 251 of file Html.php.
References wfWarn().
|
static |
|
static |
Returns an HTML element in a string.
The major advantage here over manually typing out the HTML is that it will escape all attribute values.
This is quite similar to Xml::tags(), but it implements some useful HTML-specific logic. For instance, there is no $allowShortTag parameter: the closing tag is magically omitted if $element has an empty content model.
string | $element | The element's name, e.g., 'a' |
array | $attribs | Associative array of attributes, e.g., [ 'href' => 'https://www.mediawiki.org/' ]. See expandAttributes() for further documentation. |
string | $contents | The raw HTML contents of the element: not escaped! |
|
static |
Generate a srcset attribute value.
Generates a srcset attribute value from an array mapping pixel densities to URLs. A trailing 'x' in pixel density values is optional.
string[] | $urls |
|
static |
Returns an HTML link element in a string styled as a button (when $wgUseMediaWikiUIEverywhere is enabled).
string | $contents | The raw HTML contents of the element: not escaped! |
array | $attrs | Associative array of attributes, e.g., [ 'href' => 'https://www.mediawiki.org/' ]. See expandAttributes() for further documentation. |
string[] | $modifiers | classes to add to the button |
|
static |
|
static |
Convenience function to produce a <textarea> element.
This supports leaving out the cols= and rows= which Xml requires and are required by HTML4/XHTML but not required by HTML5.
string | $name | Name attribute |
string | $value | Value attribute |
array | $attribs | Associative array of miscellaneous extra attributes, passed to Html::element() |
|
static |
|
staticprivate |
|
staticprivate |