MediaWiki REL1_31
|
Module of static functions for generating XML. More...
Static Public Member Functions | |
static | attrib ( $name, $present=true) |
Internal function for use in checkboxes and radio buttons and such. | |
static | buildForm ( $fields, $submitLabel=null, $submitAttribs=[]) |
Generate a form (without the opening form element). | |
static | buildTable ( $rows, $attribs=[], $headers=null) |
Build a table of data. | |
static | buildTableRow ( $attribs, $cells) |
Build a row for a table. | |
static | check ( $name, $checked=false, $attribs=[]) |
Convenience function to build an HTML checkbox. | |
static | checkLabel ( $label, $name, $id, $checked=false, $attribs=[]) |
Convenience function to build an HTML checkbox with a label. | |
static | closeElement ( $element) |
Shortcut to close an XML element. | |
static | dateMenu ( $year, $month) |
static | element ( $element, $attribs=null, $contents='', $allowShortTag=true) |
Format an XML element with given attributes and, optionally, text content. | |
static | elementClean ( $element, $attribs=[], $contents='') |
Format an XML element as with self::element(), but run text through the $wgContLang->normalize() validator first to ensure that no invalid UTF-8 is passed. | |
static | encodeJsCall ( $name, $args, $pretty=false) |
Create a call to a JavaScript function. | |
static | encodeJsVar ( $value, $pretty=false) |
Encode a variable of arbitrary type to JavaScript. | |
static | escapeTagsOnly ( $in) |
Replace " > and < with their respective HTML entities ( ", >, <) | |
static | expandAttributes ( $attribs) |
Given an array of ('attributename' => 'value'), it generates the code to set the XML attributes : attributename="value". | |
static | fieldset ( $legend=false, $content=false, $attribs=[]) |
Shortcut for creating fieldsets. | |
static | input ( $name, $size=false, $value=false, $attribs=[]) |
Convenience function to build an HTML text input field. | |
static | inputLabel ( $label, $name, $id, $size=false, $value=false, $attribs=[]) |
Convenience function to build an HTML text input field with a label. | |
static | inputLabelSep ( $label, $name, $id, $size=false, $value=false, $attribs=[]) |
Same as Xml::inputLabel() but return input and label in an array. | |
static | isWellFormedXmlFragment ( $text) |
Check if a string is a well-formed XML fragment. | |
static | label ( $label, $id, $attribs=[]) |
Convenience function to build an HTML form label. | |
static | languageSelector ( $selected, $customisedOnly=true, $inLanguage=null, $overrideAttrs=[], Message $msg=null) |
Construct a language selector appropriate for use in a form or preferences. | |
static | listDropDown ( $name='', $list='', $other='', $selected='', $class='', $tabindex=null) |
Build a drop-down box from a textual list. | |
static | listDropDownOptions ( $list, $params=[]) |
Build options for a drop-down box from a textual list. | |
static | listDropDownOptionsOoui ( $options) |
Convert options for a drop-down box into a format accepted by OOUI\DropdownInputWidget etc. | |
static | monthSelector ( $selected='', $allmonths=null, $id='month') |
Create a date selector. | |
static | openElement ( $element, $attribs=null) |
This opens an XML element. | |
static | option ( $text, $value=null, $selected=false, $attribs=[]) |
Convenience function to build an HTML drop-down list item. | |
static | password ( $name, $size=false, $value=false, $attribs=[]) |
Convenience function to build an HTML password input field. | |
static | radio ( $name, $value, $checked=false, $attribs=[]) |
Convenience function to build an HTML radio button. | |
static | radioLabel ( $label, $name, $value, $id, $checked=false, $attribs=[]) |
Convenience function to build an HTML radio button with a label. | |
static | span ( $text, $class, $attribs=[]) |
Shortcut to make a span element. | |
static | submitButton ( $value, $attribs=[]) |
Convenience function to build an HTML submit button When $wgUseMediaWikiUIEverywhere is true it will default to a progressive button. | |
static | tags ( $element, $attribs=null, $contents) |
Same as Xml::element(), but does not escape contents. | |
static | textarea ( $name, $content, $cols=40, $rows=5, $attribs=[]) |
Shortcut for creating textareas. | |
static | wrapClass ( $text, $class, $tag='span', $attribs=[]) |
Shortcut to make a specific element with a class attribute. | |
Static Private Member Functions | |
static | isWellFormed ( $text) |
Check if a string is well-formed XML. | |
|
static |
|
static |
Generate a form (without the opening form element).
Output optionally includes a submit button.
array | $fields | Associative array, key is the name of a message that contains a description for the field, value is an HTML string containing the appropriate input. |
string | $submitLabel | The name of a message containing a label for the submit button. |
array | $submitAttribs | The attributes to add to the submit button |
Definition at line 766 of file Xml.php.
References $input, text, and wfMessage().
|
static |
|
static |
|
static |
|
static |
Convenience function to build an HTML checkbox with a label.
string | $label | |
string | $name | |
string | $id | |
bool | $checked | |
array | $attribs |
Definition at line 420 of file Xml.php.
References $attribs, $wgUseMediaWikiUIEverywhere, and check.
|
static |
|
static |
int | string | $year | Use '' or 0 to start with no year preselected. |
int | string | $month | A month in the 1..12 range. Use '', 0 or -1 to start with no month preselected. |
Definition at line 168 of file Xml.php.
References text, and wfMessage().
|
static |
Format an XML element with given attributes and, optionally, text content.
Element and attribute names are assumed to be ready for literal inclusion. Strings are assumed to not contain XML-illegal characters; special characters (<, >, &) are escaped but illegals are not touched.
string | $element | Element name |
array | $attribs | Name=>value pairs. Values will be escaped. |
string | $contents | Null to make an open tag only; '' for a contentless closed tag (default) |
bool | $allowShortTag | Whether '' in $contents will result in a contentless closed tag |
Definition at line 39 of file Xml.php.
References $attribs, and $out.
Referenced by MediaWiki\Preferences\DefaultPreferencesFactory\datetimePreferences(), and MediaWiki\Preferences\DefaultPreferencesFactory\validateSignature().
|
static |
Format an XML element as with self::element(), but run text through the $wgContLang->normalize() validator first to ensure that no invalid UTF-8 is passed.
string | $element | |
array | $attribs | Name=>value pairs. Values will be escaped. |
string | $contents | Null to make an open tag only; '' for a contentless closed tag (default) |
Definition at line 91 of file Xml.php.
References $attribs, and $wgContLang.
|
static |
Create a call to a JavaScript function.
The supplied arguments will be encoded using Xml::encodeJsVar().
string | $name | The name of the function to call, or a JavaScript expression which evaluates to a function object which is called. |
array | $args | The arguments to pass to the function. |
bool | $pretty | If true, add non-significant whitespace to improve readability. |
Definition at line 678 of file Xml.php.
References $args.
|
static |
Encode a variable of arbitrary type to JavaScript.
If the value is an XmlJsCode object, pass through the object's value verbatim.
mixed | $value | The value being encoded. Can be any type except a resource. |
bool | $pretty | If true, add non-significant whitespace to improve readability. |
Definition at line 660 of file Xml.php.
References $value.
|
static |
|
static |
Given an array of ('attributename' => 'value'), it generates the code to set the XML attributes : attributename="value".
The values are passed to Sanitizer::encodeAttribute. Returns null or empty string if no attributes given.
array | null | $attribs | Array of attributes for an XML element |
MWException |
|
static |
Shortcut for creating fieldsets.
string | bool | $legend | Legend of the fieldset. If evaluates to false, legend is not added. |
string | $content | Pre-escaped content for the fieldset. If false, only open fieldset is returned. |
array | $attribs | Any attributes to fieldset-element. |
|
static |
|
static |
Convenience function to build an HTML text input field with a label.
string | $label | Text of the label |
string | $name | Value of the name attribute |
string | $id | Id of the input |
int | bool | $size | Value of the size attribute |
string | bool | $value | Value of the value attribute |
array | $attribs | Other attributes |
|
static |
|
staticprivate |
|
static |
|
static |
Convenience function to build an HTML form label.
string | $label | Text of the label |
string | $id | |
array | $attribs | An attribute array. This will usually be the same array as is passed to the corresponding input element, so this function will cherry-pick appropriate attributes to apply to the label as well; only class and title are applied. |
Definition at line 359 of file Xml.php.
References $attribs.
|
static |
Construct a language selector appropriate for use in a form or preferences.
string | $selected | The language code of the selected language |
bool | $customisedOnly | If true only languages which have some content are listed |
string | $inLanguage | The ISO code of the language to display the select list in (optional) |
array | $overrideAttrs | Override the attributes of the select tag (since 1.20) |
Message | null | $msg | Label message key (since 1.20) |
Definition at line 205 of file Xml.php.
References $code, $languages, $options, $wgLanguageCode, and wfMessage().
|
static |
Build a drop-down box from a textual list.
This is a wrapper for Xml::listDropDownOptions() plus the XmlSelect class.
string | $name | Name and id for the drop-down |
string | $list | Correctly formatted text (newline delimited) to be used to generate the options. |
string | $other | Text for the "Other reasons" option |
string | $selected | Option which should be pre-selected |
string | $class | CSS classes for the drop-down |
int | $tabindex | Value of the tabindex attribute |
|
static |
Build options for a drop-down box from a textual list.
The result of this function can be passed to XmlSelect::addOptions() (to render a plain <select>
dropdown box) or to Xml::listDropDownOptionsOoui() and then OOUI\DropdownInputWidget() (to render a pretty one).
string | $list | Correctly formatted text (newline delimited) to be used to generate the options. |
array | $params | Extra parameters:
|
|
static |
|
static |
Create a date selector.
string | $selected | The month which should be selected, default ''. |
string | $allmonths | Value of a special item denoting all month. Null to not include (default). |
string | $id | Element identifier |
Definition at line 144 of file Xml.php.
References $options, $wgLang, and wfMessage().
|
static |
|
static |
Convenience function to build an HTML drop-down list item.
string | $text | Text for this item. Will be HTML escaped |
string | $value | Form submission value; if empty, use text |
bool | $selected | If true, will be the default selected item |
array | $attribs | Optional additional HTML attributes |
|
static |
|
static |
|
static |
|
static |
|
static |
Convenience function to build an HTML submit button When $wgUseMediaWikiUIEverywhere is true it will default to a progressive button.
string | $value | Label text for the button |
array | $attribs | Optional custom attributes |
Definition at line 460 of file Xml.php.
References $attribs, $value, and $wgUseMediaWikiUIEverywhere.
|
static |
|
static |
Shortcut for creating textareas.
string | $name | The 'name' for the textarea |
string | $content | Content for the textarea |
int | $cols | The number of columns for the textarea |
int | $rows | The number of rows for the textarea |
array | $attribs | Any other attributes for the textarea |
|
static |