|
MediaWiki 1.44.0
|
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) |
| 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 content language's 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 (?array $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. | |
| static | tags ( $element, $attribs, $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 |
Internal function for use in checkboxes and radio buttons and such.
| string | $name | |
| bool | $present |
|
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 | null | $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 838 of file Xml.php.
References MediaWiki\Xml\Xml\closeElement(), MediaWiki\Html\element(), MediaWiki\Xml\Xml\openElement(), MediaWiki\Xml\Xml\tags(), and wfMessage().
|
static |
| string[][] | $rows | |
| array | null | $attribs | An array of attributes to apply to the table tag |
| array | null | $headers | An array of strings to use as table headers |
Definition at line 884 of file Xml.php.
References $header, MediaWiki\Xml\Xml\buildTableRow(), MediaWiki\Xml\Xml\closeElement(), MediaWiki\Xml\Xml\element(), MediaWiki\Xml\Xml\openElement(), and wfDeprecated().
|
static |
Build a row for a table.
| array | null | $attribs | An array of attributes to apply to the tr tag |
| string[] | $cells | An array of strings to put in |
Definition at line 927 of file Xml.php.
References MediaWiki\Xml\Xml\closeElement(), MediaWiki\Xml\Xml\element(), MediaWiki\Xml\Xml\openElement(), and wfDeprecated().
Referenced by MediaWiki\Xml\Xml\buildTable().
|
static |
Convenience function to build an HTML checkbox.
| string | $name | Value of the name attribute |
| bool | $checked | Whether the checkbox is checked or not |
| array | $attribs | Array other attributes |
Definition at line 367 of file Xml.php.
References MediaWiki\Xml\Xml\element(), and wfDeprecated().
Referenced by MediaWiki\Xml\Xml\checkLabel().
|
static |
Convenience function to build an HTML checkbox with a label.
| string | $label | |
| string | $name | |
| string | $id | |
| bool | $checked | |
| array | $attribs |
Definition at line 479 of file Xml.php.
References MediaWiki\Xml\Xml\check(), MediaWiki\Xml\Xml\label(), and wfDeprecated().
|
static |
Shortcut to close an XML element.
| string | $element | Element name |
Definition at line 128 of file Xml.php.
Referenced by MediaWiki\Xml\Xml\buildForm(), MediaWiki\Xml\Xml\buildTable(), MediaWiki\Xml\Xml\buildTableRow(), MediaWiki\Xml\Xml\fieldset(), and MediaWiki\Api\ApiFormatXml\recXmlPrint().
|
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 187 of file Xml.php.
References MediaWiki\Xml\Xml\label(), MediaWiki\Xml\Xml\monthSelector(), wfDeprecated(), 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 | null | $attribs | Name=>value pairs. Values will be escaped. |
| string | null | $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 54 of file Xml.php.
References MediaWiki\Xml\Xml\expandAttributes().
Referenced by MediaWiki\Xml\Xml\buildTable(), MediaWiki\Xml\Xml\buildTableRow(), MediaWiki\Xml\Xml\check(), MediaWiki\Xml\Xml\elementClean(), MediaWiki\Xml\Xml\fieldset(), MediaWiki\Xml\Xml\input(), MediaWiki\Xml\Xml\label(), MediaWiki\Xml\Xml\radio(), MediaWiki\Api\ApiFormatXml\recXmlPrint(), MediaWiki\Xml\Xml\span(), and MediaWiki\Xml\Xml\textarea().
|
static |
Format an XML element as with self::element(), but run text through the content language's normalize() validator first to ensure that no invalid UTF-8 is passed.
| string | $element | |
| array | null | $attribs | Name=>value pairs. Values will be escaped. |
| string | null | $contents | Null to make an open tag only; '' for a contentless closed tag (default) |
Definition at line 101 of file Xml.php.
References MediaWiki\Xml\Xml\element(), and MediaWiki\MediaWikiServices\getInstance().
|
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 756 of file Xml.php.
References wfDeprecated().
|
static |
Encode a variable of arbitrary type to JavaScript.
If the value is an HtmlJsCode 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 734 of file Xml.php.
References wfDeprecated().
|
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 |
Definition at line 79 of file Xml.php.
Referenced by MediaWiki\Xml\Xml\element(), and MediaWiki\Xml\Xml\openElement().
|
static |
Shortcut for creating fieldsets.
| string | false | $legend | Legend of the fieldset. If evaluates to false, legend is not added. |
| string | false | $content | Pre-escaped content for the fieldset. If false, only open fieldset is returned. |
| array | $attribs | Any attributes to fieldset-element. |
Definition at line 679 of file Xml.php.
References MediaWiki\Xml\Xml\closeElement(), MediaWiki\Xml\Xml\element(), and MediaWiki\Xml\Xml\openElement().
|
static |
Convenience function to build an HTML text input field.
| string | $name | Value of the name attribute |
| int | false | $size | Value of the size attribute |
| string | false | $value | Value of the value attribute |
| array | $attribs | Other attributes |
Definition at line 309 of file Xml.php.
References MediaWiki\Xml\Xml\element(), and wfDeprecated().
Referenced by MediaWiki\Xml\Xml\inputLabelSep(), and MediaWiki\Xml\Xml\password().
|
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 | false | $size | Value of the size attribute |
| string | false | $value | Value of the value attribute |
| array | $attribs | Other attributes |
Definition at line 434 of file Xml.php.
References MediaWiki\Xml\Xml\inputLabelSep(), and wfDeprecated().
|
static |
Same as Xml::inputLabel() but return input and label in an array.
| string | $label | |
| string | $name | |
| string | $id | |
| int | false | $size | |
| string | false | $value | |
| array | $attribs |
Definition at line 456 of file Xml.php.
References MediaWiki\Xml\Xml\input(), MediaWiki\Xml\Xml\label(), and wfDeprecated().
Referenced by MediaWiki\Xml\Xml\inputLabel().
|
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 410 of file Xml.php.
References MediaWiki\Xml\Xml\element().
Referenced by MediaWiki\Xml\Xml\checkLabel(), MediaWiki\Xml\Xml\dateMenu(), MediaWiki\Xml\Xml\inputLabelSep(), MediaWiki\Xml\Xml\languageSelector(), and MediaWiki\Xml\Xml\radioLabel().
|
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 | null | $inLanguage | The ISO code of the language to display the select list in |
| array | $overrideAttrs | Override the attributes of the select tag (since 1.20) |
| Message | null | $msg | Label message key (since 1.20) |
Definition at line 227 of file Xml.php.
References MediaWiki\MediaWikiServices\getInstance(), MediaWiki\Xml\Xml\label(), MediaWiki\MainConfigNames\LanguageCode, MediaWiki\Xml\Xml\option(), MediaWiki\Xml\Xml\tags(), wfDeprecated(), 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 | null | $tabindex | Value of the tabindex attribute |
Definition at line 565 of file Xml.php.
References MediaWiki\Xml\Xml\listDropdownOptions().
|
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:
|
Definition at line 598 of file Xml.php.
Referenced by MediaWiki\Xml\Xml\listDropdown().
|
static |
Convert options for a drop-down box into a format accepted by OOUI\DropdownInputWidget etc.
TODO Find a better home for this function.
| array | $options | Options, as returned e.g. by Xml::listDropdownOptions() |
|
static |
Create a date selector.
| string | null | $selected | The month which should be selected, default ''. |
| string | null | $allmonths | Value of a special item denoting all month. Null to not include (default). |
| string | $id | Element identifier |
Definition at line 160 of file Xml.php.
References $wgLang, wfDeprecated(), and wfMessage().
Referenced by MediaWiki\Xml\Xml\dateMenu().
|
static |
This opens an XML element.
| string | $element | Name of the element |
| array | null | $attribs | Array of attributes, see Xml::expandAttributes() |
Definition at line 119 of file Xml.php.
References MediaWiki\Xml\Xml\expandAttributes().
Referenced by MediaWiki\Xml\Xml\buildForm(), MediaWiki\Xml\Xml\buildTable(), MediaWiki\Xml\Xml\buildTableRow(), MediaWiki\Xml\Xml\fieldset(), and MediaWiki\Xml\Xml\tags().
|
static |
Convenience function to build an HTML drop-down list item.
| string | $text | Text for this item. Will be HTML escaped |
| string | null | $value | Form submission value; if empty, use text |
| bool | $selected | If true, will be the default selected item |
| array | $attribs | Optional additional HTML attributes |
Definition at line 539 of file Xml.php.
References MediaWiki\Html\element().
Referenced by MediaWiki\Xml\XmlSelect\formatOptions(), and MediaWiki\Xml\Xml\languageSelector().
|
static |
Convenience function to build an HTML password input field.
| string | $name | Value of the name attribute |
| int | false | $size | Value of the size attribute |
| string | false | $value | Value of the value attribute |
| array | $attribs | Other attributes |
Definition at line 335 of file Xml.php.
References MediaWiki\Xml\Xml\input(), and wfDeprecated().
|
static |
Convenience function to build an HTML radio button.
| string | $name | Value of the name attribute |
| string | $value | Value of the value attribute |
| bool | $checked | Whether the checkbox is checked or not |
| array | $attribs | Other attributes |
Definition at line 389 of file Xml.php.
References MediaWiki\Xml\Xml\element(), and wfDeprecated().
Referenced by MediaWiki\Xml\Xml\radioLabel().
|
static |
Convenience function to build an HTML radio button with a label.
| string | $label | |
| string | $name | |
| string | $value | |
| string | $id | |
| bool | $checked | |
| array | $attribs |
Definition at line 500 of file Xml.php.
References MediaWiki\Xml\Xml\label(), MediaWiki\Xml\Xml\radio(), and wfDeprecated().
|
static |
Shortcut to make a span element.
| string | $text | Content of the element, will be escaped |
| string | $class | Class name of the span element |
| array | $attribs | Other attributes |
Definition at line 277 of file Xml.php.
References MediaWiki\Xml\Xml\element(), and wfDeprecated().
|
static |
Convenience function to build an HTML submit button.
| string | $value | Label text for the button (unescaped) |
| array | $attribs | Optional custom attributes |
Definition at line 519 of file Xml.php.
References MediaWiki\Html\element(), and wfDeprecated().
|
static |
Same as Xml::element(), but does not escape contents.
Handy when the content you have is already valid xml.
| string | $element | Element name |
| array | null | $attribs | Array of attributes |
| string | $contents | Content of the element |
Definition at line 145 of file Xml.php.
References MediaWiki\Xml\Xml\openElement().
Referenced by MediaWiki\Xml\Xml\buildForm(), MediaWiki\Xml\Xml\languageSelector(), and MediaWiki\Xml\Xml\wrapClass().
|
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 |
Definition at line 706 of file Xml.php.
References MediaWiki\Xml\Xml\element(), and wfDeprecated().
|
static |
Shortcut to make a specific element with a class attribute.
| string | $text | Content of the element, will be escaped |
| string | $class | Class name of the span element |
| string | $tag | Element name |
| array | $attribs | Other attributes |
Definition at line 294 of file Xml.php.
References MediaWiki\Xml\Xml\tags(), and wfDeprecated().