MediaWiki  master
Xml.php
Go to the documentation of this file.
1 <?php
24 
28 class Xml {
41  public static function element( $element, $attribs = null, $contents = '',
42  $allowShortTag = true
43  ) {
44  $out = '<' . $element;
45  if ( $attribs !== null ) {
46  $out .= self::expandAttributes( $attribs );
47  }
48  if ( $contents === null ) {
49  $out .= '>';
50  } elseif ( $allowShortTag && $contents === '' ) {
51  $out .= ' />';
52  } else {
53  $out .= '>' . htmlspecialchars( $contents, ENT_NOQUOTES ) . "</$element>";
54  }
55  return $out;
56  }
57 
67  public static function expandAttributes( $attribs ) {
68  $out = '';
69  if ( $attribs === null ) {
70  return null;
71  } elseif ( is_array( $attribs ) ) {
72  foreach ( $attribs as $name => $val ) {
73  $out .= " {$name}=\"" . Sanitizer::encodeAttribute( $val ) . '"';
74  }
75  return $out;
76  } else {
77  throw new MWException( 'Expected attribute array, got something else in ' . __METHOD__ );
78  }
79  }
80 
90  public static function elementClean( $element, $attribs = [], $contents = '' ) {
91  if ( $attribs ) {
92  $attribs = array_map( [ 'UtfNormal\Validator', 'cleanUp' ], $attribs );
93  }
94  if ( $contents ) {
95  $contents =
96  MediaWikiServices::getInstance()->getContentLanguage()->normalize( $contents );
97  }
98  return self::element( $element, $attribs, $contents );
99  }
100 
108  public static function openElement( $element, $attribs = null ) {
109  return '<' . $element . self::expandAttributes( $attribs ) . '>';
110  }
111 
117  public static function closeElement( $element ) {
118  return "</$element>";
119  }
120 
130  public static function tags( $element, $attribs, $contents ) {
131  return self::openElement( $element, $attribs ) . $contents . "</$element>";
132  }
133 
143  public static function monthSelector( $selected = '', $allmonths = null, $id = 'month' ) {
144  global $wgLang;
145  $options = [];
146 
147  if ( $selected === null ) {
148  $selected = '';
149  }
150  $data = new XmlSelect( 'month', $id, $selected );
151 
152  if ( $allmonths !== null ) {
153  $options[wfMessage( 'monthsall' )->text()] = $allmonths;
154  }
155  for ( $i = 1; $i < 13; $i++ ) {
156  $options[$wgLang->getMonthName( $i )] = $i;
157  }
158  $data->addOptions( $options );
159  $data->setAttribute( 'class', 'mw-month-selector' );
160  return $data->getHTML();
161  }
162 
169  public static function dateMenu( $year, $month ) {
170  # Offset overrides year/month selection
171  if ( $month && $month !== -1 ) {
172  $encMonth = intval( $month );
173  } else {
174  $encMonth = '';
175  }
176  if ( $year ) {
177  $encYear = intval( $year );
178  } elseif ( $encMonth ) {
179  $timestamp = MWTimestamp::getInstance();
180  $thisMonth = intval( $timestamp->format( 'n' ) );
181  $thisYear = intval( $timestamp->format( 'Y' ) );
182  if ( intval( $encMonth ) > $thisMonth ) {
183  $thisYear--;
184  }
185  $encYear = $thisYear;
186  } else {
187  $encYear = '';
188  }
189  $inputAttribs = [ 'id' => 'year', 'maxlength' => 4, 'size' => 7 ];
190  return self::label( wfMessage( 'year' )->text(), 'year' ) . ' ' .
191  Html::input( 'year', $encYear, 'number', $inputAttribs ) . ' ' .
192  self::label( wfMessage( 'month' )->text(), 'month' ) . ' ' .
193  self::monthSelector( $encMonth, -1 );
194  }
195 
206  public static function languageSelector( $selected, $customisedOnly = true,
207  $inLanguage = null, $overrideAttrs = [], Message $msg = null
208  ) {
209  global $wgLanguageCode;
210 
211  $include = $customisedOnly ? 'mwfile' : 'mw';
212  $languages = MediaWikiServices::getInstance()
213  ->getLanguageNameUtils()
214  ->getLanguageNames( $inLanguage, $include );
215 
216  // Make sure the site language is in the list;
217  // a custom language code might not have a defined name...
218  if ( !array_key_exists( $wgLanguageCode, $languages ) ) {
219  $languages[$wgLanguageCode] = $wgLanguageCode;
220  // Sort the array again
221  ksort( $languages );
222  }
223 
229  $selected = isset( $languages[$selected] ) ? $selected : $wgLanguageCode;
230  $options = "\n";
231  foreach ( $languages as $code => $name ) {
232  $options .= self::option( "$code - $name", $code, $code == $selected ) . "\n";
233  }
234 
235  $attrs = [ 'id' => 'wpUserLanguage', 'name' => 'wpUserLanguage' ];
236  $attrs = array_merge( $attrs, $overrideAttrs );
237 
238  if ( $msg === null ) {
239  $msg = wfMessage( 'yourlanguage' );
240  }
241  return [
242  self::label( $msg->text(), $attrs['id'] ),
243  self::tags( 'select', $attrs, $options )
244  ];
245  }
246 
254  public static function span( $text, $class, $attribs = [] ) {
255  return self::element( 'span', [ 'class' => $class ] + $attribs, $text );
256  }
257 
266  public static function wrapClass( $text, $class, $tag = 'span', $attribs = [] ) {
267  return self::tags( $tag, [ 'class' => $class ] + $attribs, $text );
268  }
269 
278  public static function input( $name, $size = false, $value = false, $attribs = [] ) {
279  $attributes = [ 'name' => $name ];
280 
281  if ( $size ) {
282  $attributes['size'] = $size;
283  }
284 
285  if ( $value !== false ) { // maybe 0
286  $attributes['value'] = $value;
287  }
288 
289  return self::element( 'input',
290  Html::getTextInputAttributes( $attributes + $attribs ) );
291  }
292 
301  public static function password( $name, $size = false, $value = false,
302  $attribs = []
303  ) {
304  return self::input( $name, $size, $value,
305  array_merge( $attribs, [ 'type' => 'password' ] ) );
306  }
307 
316  public static function attrib( $name, $present = true ) {
317  return $present ? [ $name => $name ] : [];
318  }
319 
327  public static function check( $name, $checked = false, $attribs = [] ) {
328  return self::element( 'input', array_merge(
329  [
330  'name' => $name,
331  'type' => 'checkbox',
332  'value' => 1 ],
333  self::attrib( 'checked', $checked ),
334  $attribs ) );
335  }
336 
345  public static function radio( $name, $value, $checked = false, $attribs = [] ) {
346  return self::element( 'input', [
347  'name' => $name,
348  'type' => 'radio',
349  'value' => $value ] + self::attrib( 'checked', $checked ) + $attribs );
350  }
351 
362  public static function label( $label, $id, $attribs = [] ) {
363  $a = [ 'for' => $id ];
364 
365  foreach ( [ 'class', 'title' ] as $attr ) {
366  if ( isset( $attribs[$attr] ) ) {
367  $a[$attr] = $attribs[$attr];
368  }
369  }
370 
371  return self::element( 'label', $a, $label );
372  }
373 
384  public static function inputLabel( $label, $name, $id, $size = false,
385  $value = false, $attribs = []
386  ) {
387  list( $label, $input ) = self::inputLabelSep( $label, $name, $id, $size, $value, $attribs );
388  return $label . "\u{00A0}" . $input;
389  }
390 
403  public static function inputLabelSep( $label, $name, $id, $size = false,
404  $value = false, $attribs = []
405  ) {
406  return [
407  self::label( $label, $id, $attribs ),
408  self::input( $name, $size, $value, [ 'id' => $id ] + $attribs )
409  ];
410  }
411 
423  public static function checkLabel( $label, $name, $id, $checked = false, $attribs = [] ) {
425  $chkLabel = self::check( $name, $checked, [ 'id' => $id ] + $attribs ) .
426  "\u{00A0}" .
427  self::label( $label, $id, $attribs );
428 
430  $chkLabel = self::openElement( 'div', [ 'class' => 'mw-ui-checkbox' ] ) .
431  $chkLabel . self::closeElement( 'div' );
432  }
433  return $chkLabel;
434  }
435 
448  public static function radioLabel( $label, $name, $value, $id,
449  $checked = false, $attribs = []
450  ) {
451  return self::radio( $name, $value, $checked, [ 'id' => $id ] + $attribs ) .
452  "\u{00A0}" .
453  self::label( $label, $id, $attribs );
454  }
455 
463  public static function submitButton( $value, $attribs = [] ) {
465  $baseAttrs = [
466  'type' => 'submit',
467  'value' => $value,
468  ];
469  // Done conditionally for time being as it is possible
470  // some submit forms
471  // might need to be mw-ui-destructive (e.g. delete a page)
473  $baseAttrs['class'] = 'mw-ui-button mw-ui-progressive';
474  }
475  // Any custom attributes will take precendence of anything in baseAttrs e.g. override the class
476  $attribs += $baseAttrs;
477  return Html::element( 'input', $attribs );
478  }
479 
488  public static function option( $text, $value = null, $selected = false,
489  $attribs = [] ) {
490  if ( $value !== null ) {
491  $attribs['value'] = $value;
492  }
493  if ( $selected ) {
494  $attribs['selected'] = 'selected';
495  }
496  return Html::element( 'option', $attribs, $text );
497  }
498 
512  public static function listDropDown( $name = '', $list = '', $other = '',
513  $selected = '', $class = '', $tabindex = null
514  ) {
515  $options = self::listDropDownOptions( $list, [ 'other' => $other ] );
516 
517  $xmlSelect = new XmlSelect( $name, $name, $selected );
518  $xmlSelect->addOptions( $options );
519 
520  if ( $class ) {
521  $xmlSelect->setAttribute( 'class', $class );
522  }
523  if ( $tabindex ) {
524  $xmlSelect->setAttribute( 'tabindex', $tabindex );
525  }
526 
527  return $xmlSelect->getHTML();
528  }
529 
543  public static function listDropDownOptions( $list, $params = [] ) {
544  $options = [];
545 
546  if ( isset( $params['other'] ) ) {
547  $options[ $params['other'] ] = 'other';
548  }
549 
550  $optgroup = false;
551  foreach ( explode( "\n", $list ) as $option ) {
552  $value = trim( $option );
553  if ( $value == '' ) {
554  continue;
555  } elseif ( substr( $value, 0, 1 ) == '*' && substr( $value, 1, 1 ) != '*' ) {
556  # A new group is starting...
557  $value = trim( substr( $value, 1 ) );
558  # Do not use the value for 'other' as option group - T251351
559  $optgroup = isset( $params['other'] ) && $params['other'] === $value
560  ? false
561  : $value;
562  } elseif ( substr( $value, 0, 2 ) == '**' ) {
563  # groupmember
564  $opt = trim( substr( $value, 2 ) );
565  if ( $optgroup === false ) {
566  $options[$opt] = $opt;
567  } else {
568  $options[$optgroup][$opt] = $opt;
569  }
570  } else {
571  # groupless reason list
572  $optgroup = false;
573  $options[$option] = $option;
574  }
575  }
576 
577  return $options;
578  }
579 
588  public static function listDropDownOptionsOoui( $options ) {
589  $optionsOoui = [];
590 
591  foreach ( $options as $text => $value ) {
592  if ( is_array( $value ) ) {
593  $optionsOoui[] = [ 'optgroup' => (string)$text ];
594  foreach ( $value as $text2 => $value2 ) {
595  $optionsOoui[] = [ 'data' => (string)$value2, 'label' => (string)$text2 ];
596  }
597  } else {
598  $optionsOoui[] = [ 'data' => (string)$value, 'label' => (string)$text ];
599  }
600  }
601 
602  return $optionsOoui;
603  }
604 
616  public static function fieldset( $legend = false, $content = false, $attribs = [] ) {
617  $s = self::openElement( 'fieldset', $attribs ) . "\n";
618 
619  if ( $legend ) {
620  $s .= self::element( 'legend', null, $legend ) . "\n";
621  }
622 
623  if ( $content !== false ) {
624  $s .= $content . "\n";
625  $s .= self::closeElement( 'fieldset' ) . "\n";
626  }
627 
628  return $s;
629  }
630 
642  public static function textarea( $name, $content, $cols = 40, $rows = 5, $attribs = [] ) {
643  return self::element( 'textarea',
645  [
646  'name' => $name,
647  'id' => $name,
648  'cols' => $cols,
649  'rows' => $rows
650  ] + $attribs
651  ),
652  $content, false );
653  }
654 
666  public static function encodeJsVar( $value, $pretty = false ) {
667  if ( $value instanceof XmlJsCode ) {
668  return $value->value;
669  }
670  return FormatJson::encode( $value, $pretty, FormatJson::UTF8_OK );
671  }
672 
684  public static function encodeJsCall( $name, $args, $pretty = false ) {
685  foreach ( $args as &$arg ) {
686  $arg = self::encodeJsVar( $arg, $pretty );
687  if ( $arg === false ) {
688  return false;
689  }
690  }
691 
692  return "$name(" . ( $pretty
693  ? ( ' ' . implode( ', ', $args ) . ' ' )
694  : implode( ',', $args )
695  ) . ");";
696  }
697 
709  private static function isWellFormed( $text ) {
710  $parser = xml_parser_create( "UTF-8" );
711 
712  # case folding violates XML standard, turn it off
713  xml_parser_set_option( $parser, XML_OPTION_CASE_FOLDING, false );
714 
715  if ( !xml_parse( $parser, $text, true ) ) {
716  // $err = xml_error_string( xml_get_error_code( $parser ) );
717  // $position = xml_get_current_byte_index( $parser );
718  // $fragment = $this->extractFragment( $html, $position );
719  // $this->mXmlError = "$err at byte $position:\n$fragment";
720  xml_parser_free( $parser );
721  return false;
722  }
723 
724  xml_parser_free( $parser );
725 
726  return true;
727  }
728 
737  public static function isWellFormedXmlFragment( $text ) {
738  $html =
740  '<html>' .
741  $text .
742  '</html>';
743 
744  return self::isWellFormed( $html );
745  }
746 
754  public static function escapeTagsOnly( $in ) {
755  return str_replace(
756  [ '"', '>', '<' ],
757  [ '&quot;', '&gt;', '&lt;' ],
758  $in );
759  }
760 
772  public static function buildForm( $fields, $submitLabel = null, $submitAttribs = [] ) {
773  $form = '';
774  $form .= "<table><tbody>";
775 
776  foreach ( $fields as $labelmsg => $input ) {
777  $id = "mw-$labelmsg";
778  $form .= self::openElement( 'tr', [ 'id' => $id ] );
779 
780  // TODO use a <label> here for accessibility purposes - will need
781  // to either not use a table to build the form, or find the ID of
782  // the input somehow.
783 
784  $form .= self::tags( 'td', [ 'class' => 'mw-label' ], wfMessage( $labelmsg )->parse() );
785  $form .= self::openElement( 'td', [ 'class' => 'mw-input' ] )
786  . $input . self::closeElement( 'td' );
787  $form .= self::closeElement( 'tr' );
788  }
789 
790  if ( $submitLabel ) {
791  $form .= self::openElement( 'tr' );
792  $form .= self::tags( 'td', [], '' );
793  $form .= self::openElement( 'td', [ 'class' => 'mw-submit' ] )
794  . self::submitButton( wfMessage( $submitLabel )->text(), $submitAttribs )
795  . self::closeElement( 'td' );
796  $form .= self::closeElement( 'tr' );
797  }
798 
799  $form .= "</tbody></table>";
800 
801  return $form;
802  }
803 
811  public static function buildTable( $rows, $attribs = [], $headers = null ) {
812  $s = self::openElement( 'table', $attribs );
813 
814  if ( is_array( $headers ) ) {
815  $s .= self::openElement( 'thead', $attribs );
816 
817  foreach ( $headers as $id => $header ) {
818  $attribs = [];
819 
820  if ( is_string( $id ) ) {
821  $attribs['id'] = $id;
822  }
823 
824  $s .= self::element( 'th', $attribs, $header );
825  }
826  $s .= self::closeElement( 'thead' );
827  }
828 
829  foreach ( $rows as $id => $row ) {
830  $attribs = [];
831 
832  if ( is_string( $id ) ) {
833  $attribs['id'] = $id;
834  }
835 
836  $s .= self::buildTableRow( $attribs, $row );
837  }
838 
839  $s .= self::closeElement( 'table' );
840 
841  return $s;
842  }
843 
850  public static function buildTableRow( $attribs, $cells ) {
851  $s = self::openElement( 'tr', $attribs );
852 
853  foreach ( $cells as $id => $cell ) {
854  $attribs = [];
855 
856  if ( is_string( $id ) ) {
857  $attribs['id'] = $id;
858  }
859 
860  $s .= self::element( 'td', $attribs, $cell );
861  }
862 
863  $s .= self::closeElement( 'tr' );
864 
865  return $s;
866  }
867 }
Xml\isWellFormed
static isWellFormed( $text)
Check if a string is well-formed XML.
Definition: Xml.php:709
Xml\buildTableRow
static buildTableRow( $attribs, $cells)
Build a row for a table.
Definition: Xml.php:850
Xml\expandAttributes
static expandAttributes( $attribs)
Given an array of ('attributename' => 'value'), it generates the code to set the XML attributes : att...
Definition: Xml.php:67
Xml\listDropDownOptionsOoui
static listDropDownOptionsOoui( $options)
Convert options for a drop-down box into a format accepted by OOUI\DropdownInputWidget etc.
Definition: Xml.php:588
Html\getTextInputAttributes
static getTextInputAttributes(array $attrs)
Modifies a set of attributes meant for text input elements and apply a set of default attributes.
Definition: Html.php:137
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:160
Xml\label
static label( $label, $id, $attribs=[])
Convenience function to build an HTML form label.
Definition: Xml.php:362
$wgUseMediaWikiUIEverywhere
$wgUseMediaWikiUIEverywhere
Temporary variable that applies MediaWiki UI wherever it can be supported.
Definition: DefaultSettings.php:3404
Xml\textarea
static textarea( $name, $content, $cols=40, $rows=5, $attribs=[])
Shortcut for creating textareas.
Definition: Xml.php:642
Xml\radio
static radio( $name, $value, $checked=false, $attribs=[])
Convenience function to build an HTML radio button.
Definition: Xml.php:345
Xml\inputLabelSep
static inputLabelSep( $label, $name, $id, $size=false, $value=false, $attribs=[])
Same as Xml::inputLabel() but return input and label in an array.
Definition: Xml.php:403
Xml\option
static option( $text, $value=null, $selected=false, $attribs=[])
Convenience function to build an HTML drop-down list item.
Definition: Xml.php:488
wfMessage
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Definition: GlobalFunctions.php:1220
$s
$s
Definition: mergeMessageFileList.php:184
Xml\password
static password( $name, $size=false, $value=false, $attribs=[])
Convenience function to build an HTML password input field.
Definition: Xml.php:301
Xml\buildForm
static buildForm( $fields, $submitLabel=null, $submitAttribs=[])
Generate a form (without the opening form element).
Definition: Xml.php:772
Xml\openElement
static openElement( $element, $attribs=null)
This opens an XML element.
Definition: Xml.php:108
Xml\encodeJsVar
static encodeJsVar( $value, $pretty=false)
Encode a variable of arbitrary type to JavaScript.
Definition: Xml.php:666
Xml\languageSelector
static languageSelector( $selected, $customisedOnly=true, $inLanguage=null, $overrideAttrs=[], Message $msg=null)
Construct a language selector appropriate for use in a form or preferences.
Definition: Xml.php:206
FormatJson\UTF8_OK
const UTF8_OK
Skip escaping most characters above U+007F for readability and compactness.
Definition: FormatJson.php:34
Html\input
static input( $name, $value='', $type='text', array $attribs=[])
Convenience function to produce an "<input>" element.
Definition: Html.php:667
XmlSelect
Class for generating HTML <select> or <datalist> elements.
Definition: XmlSelect.php:26
Xml\fieldset
static fieldset( $legend=false, $content=false, $attribs=[])
Shortcut for creating fieldsets.
Definition: Xml.php:616
XmlJsCode
A wrapper class which causes Xml::encodeJsVar() and Xml::encodeJsCall() to interpret a given string a...
Definition: XmlJsCode.php:40
Xml\encodeJsCall
static encodeJsCall( $name, $args, $pretty=false)
Create a call to a JavaScript function.
Definition: Xml.php:684
Sanitizer\hackDocType
static hackDocType()
Hack up a private DOCTYPE with HTML's standard entity declarations.
Definition: Sanitizer.php:1601
Xml\elementClean
static elementClean( $element, $attribs=[], $contents='')
Format an XML element as with self::element(), but run text through the content language's normalize(...
Definition: Xml.php:90
FormatJson\encode
static encode( $value, $pretty=false, $escaping=0)
Returns the JSON representation of a value.
Definition: FormatJson.php:115
Xml\wrapClass
static wrapClass( $text, $class, $tag='span', $attribs=[])
Shortcut to make a specific element with a class attribute.
Definition: Xml.php:266
MWException
MediaWiki exception.
Definition: MWException.php:29
Xml\check
static check( $name, $checked=false, $attribs=[])
Convenience function to build an HTML checkbox.
Definition: Xml.php:327
$wgLang
$wgLang
Definition: Setup.php:776
Sanitizer\encodeAttribute
static encodeAttribute( $text)
Encode an attribute value for HTML output.
Definition: Sanitizer.php:723
Xml\element
static element( $element, $attribs=null, $contents='', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
Definition: Xml.php:41
$args
if( $line===false) $args
Definition: mcc.php:124
MWTimestamp\getInstance
static getInstance( $ts=false)
Get a timestamp instance in GMT.
Definition: MWTimestamp.php:41
$content
$content
Definition: router.php:76
$header
$header
Definition: updateCredits.php:41
Xml\tags
static tags( $element, $attribs, $contents)
Same as Xml::element(), but does not escape contents.
Definition: Xml.php:130
Xml\attrib
static attrib( $name, $present=true)
Internal function for use in checkboxes and radio buttons and such.
Definition: Xml.php:316
$wgLanguageCode
$wgLanguageCode
Site language code.
Definition: DefaultSettings.php:3093
Xml\span
static span( $text, $class, $attribs=[])
Shortcut to make a span element.
Definition: Xml.php:254
Xml\radioLabel
static radioLabel( $label, $name, $value, $id, $checked=false, $attribs=[])
Convenience function to build an HTML radio button with a label.
Definition: Xml.php:448
Xml\closeElement
static closeElement( $element)
Shortcut to close an XML element.
Definition: Xml.php:117
Xml\listDropDown
static listDropDown( $name='', $list='', $other='', $selected='', $class='', $tabindex=null)
Build a drop-down box from a textual list.
Definition: Xml.php:512
Xml\isWellFormedXmlFragment
static isWellFormedXmlFragment( $text)
Check if a string is a well-formed XML fragment.
Definition: Xml.php:737
Xml\dateMenu
static dateMenu( $year, $month)
Definition: Xml.php:169
Message
The Message class deals with fetching and processing of interface message into a variety of formats.
Definition: Message.php:161
Xml\input
static input( $name, $size=false, $value=false, $attribs=[])
Convenience function to build an HTML text input field.
Definition: Xml.php:278
Xml\buildTable
static buildTable( $rows, $attribs=[], $headers=null)
Build a table of data.
Definition: Xml.php:811
Html\element
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:231
Xml\monthSelector
static monthSelector( $selected='', $allmonths=null, $id='month')
Create a date selector.
Definition: Xml.php:143
Xml\inputLabel
static inputLabel( $label, $name, $id, $size=false, $value=false, $attribs=[])
Convenience function to build an HTML text input field with a label.
Definition: Xml.php:384
Xml
Module of static functions for generating XML.
Definition: Xml.php:28
Xml\escapeTagsOnly
static escapeTagsOnly( $in)
Replace " > and < with their respective HTML entities ( ", >, <)
Definition: Xml.php:754
Xml\listDropDownOptions
static listDropDownOptions( $list, $params=[])
Build options for a drop-down box from a textual list.
Definition: Xml.php:543
Xml\submitButton
static submitButton( $value, $attribs=[])
Convenience function to build an HTML submit button When $wgUseMediaWikiUIEverywhere is true it will ...
Definition: Xml.php:463
Xml\checkLabel
static checkLabel( $label, $name, $id, $checked=false, $attribs=[])
Convenience function to build an HTML checkbox with a label.
Definition: Xml.php:423