MediaWiki
master
|
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. More... | |
static | buildForm ( $fields, $submitLabel=null, $submitAttribs=[]) |
Generate a form (without the opening form element). More... | |
static | buildTable ( $rows, $attribs=[], $headers=null) |
static | buildTableRow ( $attribs, $cells) |
Build a row for a table. More... | |
static | check ( $name, $checked=false, $attribs=[]) |
Convenience function to build an HTML checkbox. More... | |
static | checkLabel ( $label, $name, $id, $checked=false, $attribs=[]) |
Convenience function to build an HTML checkbox with a label. More... | |
static | closeElement ( $element) |
Shortcut to close an XML element. More... | |
static | dateMenu ( $year, $month) |
static | element ( $element, $attribs=null, $contents='', $allowShortTag=true) |
Format an XML element with given attributes and, optionally, text content. More... | |
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. More... | |
static | encodeJsCall ( $name, $args, $pretty=false) |
Create a call to a JavaScript function. More... | |
static | encodeJsVar ( $value, $pretty=false) |
Encode a variable of arbitrary type to JavaScript. More... | |
static | escapeTagsOnly ( $in) |
Replace " > and < with their respective HTML entities ( ", >, <) More... | |
static | expandAttributes ( $attribs) |
Given an array of ('attributename' => 'value'), it generates the code to set the XML attributes : attributename="value". More... | |
static | fieldset ( $legend=false, $content=false, $attribs=[]) |
Shortcut for creating fieldsets. More... | |
static | input ( $name, $size=false, $value=false, $attribs=[]) |
Convenience function to build an HTML text input field. More... | |
static | inputLabel ( $label, $name, $id, $size=false, $value=false, $attribs=[]) |
Convenience function to build an HTML text input field with a label. More... | |
static | inputLabelSep ( $label, $name, $id, $size=false, $value=false, $attribs=[]) |
Same as Xml::inputLabel() but return input and label in an array. More... | |
static | isWellFormedXmlFragment ( $text) |
Check if a string is a well-formed XML fragment. More... | |
static | label ( $label, $id, $attribs=[]) |
Convenience function to build an HTML form label. More... | |
static | languageSelector ( $selected, $customisedOnly=true, $inLanguage=null, $overrideAttrs=[], Message $msg=null) |
Construct a language selector appropriate for use in a form or preferences. More... | |
static | listDropDown ( $name='', $list='', $other='', $selected='', $class='', $tabindex=null) |
Build a drop-down box from a textual list. More... | |
static | listDropDownOptions ( $list, $params=[]) |
Build options for a drop-down box from a textual list. More... | |
static | listDropDownOptionsOoui ( $options) |
Convert options for a drop-down box into a format accepted by OOUI\DropdownInputWidget etc. More... | |
static | monthSelector ( $selected='', $allmonths=null, $id='month') |
Create a date selector. More... | |
static | openElement ( $element, $attribs=null) |
This opens an XML element. More... | |
static | option ( $text, $value=null, $selected=false, $attribs=[]) |
Convenience function to build an HTML drop-down list item. More... | |
static | password ( $name, $size=false, $value=false, $attribs=[]) |
Convenience function to build an HTML password input field. More... | |
static | radio ( $name, $value, $checked=false, $attribs=[]) |
Convenience function to build an HTML radio button. More... | |
static | radioLabel ( $label, $name, $value, $id, $checked=false, $attribs=[]) |
Convenience function to build an HTML radio button with a label. More... | |
static | span ( $text, $class, $attribs=[]) |
Shortcut to make a span element. More... | |
static | submitButton ( $value, $attribs=[]) |
Convenience function to build an HTML submit button When $wgUseMediaWikiUIEverywhere is true it will default to a progressive button. More... | |
static | tags ( $element, $attribs, $contents) |
Same as Xml::element(), but does not escape contents. More... | |
static | textarea ( $name, $content, $cols=40, $rows=5, $attribs=[]) |
Shortcut for creating textareas. More... | |
static | wrapClass ( $text, $class, $tag='span', $attribs=[]) |
Shortcut to make a specific element with a class attribute. More... | |
|
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 | 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 782 of file Xml.php.
References closeElement(), openElement(), submitButton(), 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 820 of file Xml.php.
References $header, buildTableRow(), closeElement(), element(), and openElement().
|
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 859 of file Xml.php.
References closeElement(), element(), and openElement().
Referenced by 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 330 of file Xml.php.
References element().
Referenced by checkLabel(), SpecialUndelete\formatRevisionRow(), HistoryPager\formatRow(), WebInstaller\getCheckBox(), SpecialRecentChangesLinked\getExtraOptions(), HTMLCheckField\getInputHTML(), HTMLMultiSelectField\getOneCheckbox(), and HTMLCheckMatrix\getOneCheckboxHTML().
|
static |
Convenience function to build an HTML checkbox with a label.
string | $label | |
string | $name | |
string | $id | |
bool | $checked | |
array | $attribs |
Definition at line 426 of file Xml.php.
References check(), closeElement(), label(), and openElement().
Referenced by MediaWiki\Specials\SpecialEditTags\buildCheckBoxes(), SpecialWatchlist\doHeader(), SpecialRecentChanges\getExtraOptions(), SpecialRecentChanges\namespaceFilterForm(), and MediaWiki\EditPage\EditPage\showEditForm().
|
static |
Shortcut to close an XML element.
string | $element | Element name |
Definition at line 122 of file Xml.php.
Referenced by buildForm(), buildTable(), buildTableRow(), checkLabel(), SpecialRecentChanges\doHeader(), SpecialWatchlist\doHeader(), QueryPage\execute(), MediaWiki\Specials\SpecialListGroupRights\execute(), SpecialPasswordPolicies\execute(), SpecialStatistics\execute(), SiteExporter\exportSites(), fieldset(), SpecialWhatLinksHere\listEnd(), ImagePage\openShowImage(), ApiFormatXml\recXmlPrint(), MediaWiki\Search\SearchWidgets\SearchFormWidget\render(), SpecialWatchlist\setTopText(), MediaWiki\EditPage\EditPage\showEditForm(), MediaWiki\Specials\SpecialUserRights\showEditUserGroupsForm(), MediaWiki\Specials\SpecialEditTags\showForm(), and ImagePage\view().
|
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 171 of file Xml.php.
References MWTimestamp\getInstance(), label(), monthSelector(), 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 44 of file Xml.php.
References expandAttributes().
Referenced by MediaWiki\Specials\SpecialEditTags\buildCheckBoxes(), buildTable(), buildTableRow(), check(), TextPassDumper\clearOpenElement(), MediaWiki\Preferences\DefaultPreferencesFactory\datetimePreferences(), SpecialWatchlist\doHeader(), elementClean(), MediaWiki\Specials\SpecialListGroupRights\execute(), SpecialPasswordPolicies\execute(), fieldset(), ImageListPager\formatValue(), input(), ChangesList\insertDateHeader(), label(), MediaWiki\Search\SearchWidgets\SearchFormWidget\makeSearchLink(), XmlDumpWriter\openPage(), XmlDumpWriter\openStream(), Licenses\outputOption(), MediaWiki\Specials\SpecialChangeContentModel\postHtml(), radio(), EnhancedChangesList\recentChangesBlock(), ApiFormatXml\recXmlPrint(), SpecialSearch\setupPage(), MediaWiki\EditPage\EditPage\showEditForm(), MediaWiki\Specials\SpecialUserRights\showEditUserGroupsForm(), SpecialUndelete\showHistory(), MediaWiki\Specials\SpecialUserRights\showLogFragment(), span(), textarea(), ThumbnailImage\toHtml(), ImagePage\view(), wfOpenSearchDescMain(), XmlDumpWriter\writeContributor(), XmlDumpWriter\writeLogItem(), XmlDumpWriter\writeRevision(), and XmlDumpWriter\writeTimestamp().
|
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) |
-taint | $attribs | escapes_html |
-taint | $contents | escapes_html |
Definition at line 95 of file Xml.php.
References element().
Referenced by XmlDumpWriter\openPage(), XmlDumpWriter\writeContributor(), XmlDumpWriter\writeLogItem(), and XmlDumpWriter\writeRevision().
|
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 694 of file Xml.php.
References encodeJsVar().
Referenced by JavaScriptContentHandler\makeRedirectContent().
|
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 676 of file Xml.php.
References FormatJson\encode(), and FormatJson\UTF8_OK.
Referenced by encodeJsCall(), XmlJsCode\encodeObject(), and WebInstallerComplete\execute().
|
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 |
Definition at line 70 of file Xml.php.
References Sanitizer\encodeAttribute().
Referenced by element(), openElement(), and MediaWiki\Linker\Linker\tooltip().
|
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 626 of file Xml.php.
References $content, closeElement(), element(), and openElement().
Referenced by SpecialRecentChanges\doHeader(), HTMLFormFieldCloner\getInputHTMLForKey(), HTMLFormFieldCloner\getInputOOUIForKey(), MediaWiki\Specials\SpecialEditTags\showForm(), MediaWiki\Specials\SpecialUserRights\switchForm(), HTMLForm\wrapFieldSetSection(), and HTMLForm\wrapForm().
|
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 281 of file Xml.php.
References element().
Referenced by ChangeTags\buildTagFilterSelector(), SpecialRecentChangesLinked\getExtraOptions(), WebInstaller\getTextBox(), inputLabelSep(), password(), MediaWiki\Specials\SpecialUserRights\showEditUserGroupsForm(), and MediaWiki\Specials\SpecialEditTags\showForm().
|
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 387 of file Xml.php.
References inputLabelSep().
Referenced by MediaWiki\Specials\SpecialUserRights\switchForm().
|
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 406 of file Xml.php.
References input(), and label().
Referenced by inputLabel().
|
static |
Check if a string is a well-formed XML fragment.
Wraps fragment in an \<html\> bit and doctype, so it can be a fragment and can use HTML named entities.
string | $text |
Definition at line 747 of file Xml.php.
References Sanitizer\hackDocType().
Referenced by Parser\validateSig().
|
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 365 of file Xml.php.
References element().
Referenced by checkLabel(), dateMenu(), SpecialRecentChangesLinked\getExtraOptions(), MediaWiki\Specials\SpecialEditTags\getTagSelect(), inputLabelSep(), languageSelector(), SpecialRecentChanges\namespaceFilterForm(), radioLabel(), MediaWiki\Specials\SpecialUserRights\showEditUserGroupsForm(), and MediaWiki\Specials\SpecialEditTags\showForm().
|
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 208 of file Xml.php.
References label(), option(), tags(), 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 517 of file Xml.php.
References 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 548 of file Xml.php.
Referenced by HTMLFormField\getOptions(), listDropDown(), MediaWiki\Specials\SpecialMovePage\showForm(), and SpecialRevisionDelete\showForm().
|
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() |
Definition at line 598 of file Xml.php.
Referenced by ChangeTags\buildTagFilterSelector(), HTMLMultiSelectField\getInputOOUI(), HTMLFormField\getOptionsOOUI(), and MediaWiki\Specials\SpecialMovePage\showForm().
|
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 148 of file Xml.php.
References $wgLang, and wfMessage().
Referenced by 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 113 of file Xml.php.
References expandAttributes().
Referenced by buildForm(), buildTable(), buildTableRow(), checkLabel(), SpecialRecentChanges\doHeader(), SpecialWatchlist\doHeader(), QueryPage\execute(), MediaWiki\Specials\SpecialListGroupRights\execute(), SpecialPasswordPolicies\execute(), SpecialStatistics\execute(), SiteExporter\exportSites(), fieldset(), AllMessagesTablePager\getStartBody(), SpecialWhatLinksHere\listItem(), SpecialWhatLinksHere\listStart(), ImagePage\openShowImage(), MediaWiki\Search\SearchWidgets\SearchFormWidget\render(), SpecialWatchlist\setTopText(), MediaWiki\EditPage\EditPage\showEditForm(), MediaWiki\Specials\SpecialUserRights\showEditUserGroupsForm(), MediaWiki\Specials\SpecialEditTags\showForm(), Article\showMissingArticle(), tags(), TraditionalImageGallery\toHTML(), SpecialRevisionDelete\tryShowFile(), ImagePage\view(), and wfOpenSearchDescMain().
|
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 493 of file Xml.php.
Referenced by ImagePage\doRenderLangOpt(), XmlSelect\formatOptions(), languageSelector(), and ImagePage\openShowImage().
|
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 304 of file Xml.php.
References input().
|
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 348 of file Xml.php.
References element().
Referenced by HTMLRadioField\formatOptions(), MediaWiki\Specials\SpecialMergeHistory\formatRevisionRow(), WebInstaller\getRadioElements(), and 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 452 of file Xml.php.
References label(), and radio().
Referenced by WebInstallerDBConnect\execute(), and HTMLSizeFilterField\getInputHTML().
|
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 (unescaped) |
array | $attribs | Optional custom attributes |
Definition at line 467 of file Xml.php.
Referenced by buildForm(), SpecialRecentChanges\doHeader(), SpecialWatchlist\doHeader(), ImagePage\doRenderLangOpt(), WebInstallerPage\endForm(), HTMLForm\getButtons(), ImagePage\openShowImage(), SpecialWatchlist\setTopText(), MediaWiki\Specials\SpecialUserRights\showEditUserGroupsForm(), MediaWiki\Specials\SpecialEditTags\showForm(), MediaWiki\Specials\SpecialUserRights\switchForm(), and SpecialRevisionDelete\tryShowFile().
|
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 135 of file Xml.php.
References openElement().
Referenced by buildForm(), ImportReporter\close(), SpecialRecentChanges\doHeader(), SpecialUndelete\formatRevisionRow(), HistoryPager\formatRow(), ChangeTags\formatSummaryRow(), McrUndoAction\getFormFields(), ChangeTagsLogItem\getHTML(), ChangeTagsRevisionItem\getHTML(), RevDelLogItem\getHTML(), RevDelRevisionItem\getHTML(), WebInstaller\getRadioElements(), HistoryPager\getStartBody(), WebInstaller\label(), languageSelector(), MediaTransformOutput\linkWrap(), SpecialWhatLinksHere\listItem(), ImagePage\openShowImage(), MediaWiki\Search\SearchWidgets\SearchFormWidget\profileTabsHtml(), MediaWiki\Linker\Linker\revDeleteLink(), MediaWiki\Linker\Linker\revDeleteLinkDisabled(), MediaWiki\Search\SearchWidgets\SearchFormWidget\shortDialogHtml(), SpecialRevisionDelete\showForm(), wrapClass(), and PreferencesFormOOUI\wrapForm().
|
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 652 of file Xml.php.
References $content, and element().
Referenced by WebInstaller\getTextArea().
|
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 269 of file Xml.php.
References tags().
Referenced by SpecialWhatLinksHere\listItem().