X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FHtml.php;h=14456e4beeeedda2653a73b889021a28082b716d;hb=6d5c59d905349fe960b7dac8f95332f0f56ba0a2;hp=d4d0203ae64164bcf684001996f980c9d7758575;hpb=06bb061e5ed3d390a1a04c9d0a46fb5ebef249cd;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Html.php b/includes/Html.php index d4d0203ae6..14456e4bee 100644 --- a/includes/Html.php +++ b/includes/Html.php @@ -48,7 +48,7 @@ * @since 1.16 */ class Html { - # List of void elements from HTML5, section 8.1.2 as of 2011-08-12 + // List of void elements from HTML5, section 8.1.2 as of 2011-08-12 private static $voidElements = array( 'area', 'base', @@ -68,8 +68,8 @@ class Html { 'wbr', ); - # Boolean attributes, which may have the value omitted entirely. Manually - # collected from the HTML5 spec as of 2011-08-12. + // Boolean attributes, which may have the value omitted entirely. Manually + // collected from the HTML5 spec as of 2011-08-12. private static $boolAttribs = array( 'async', 'autofocus', @@ -97,7 +97,7 @@ class Html { 'selected', 'truespeed', 'typemustmatch', - # HTML5 Microdata + // HTML5 Microdata 'itemscope', ); @@ -139,7 +139,7 @@ class Html { $start = self::openElement( $element, $attribs ); if ( in_array( $element, self::$voidElements ) ) { if ( $wgWellFormedXml ) { - # Silly XML. + // Silly XML. return substr( $start, 0, -1 ) . ' />'; } return $start; @@ -160,8 +160,8 @@ class Html { */ public static function element( $element, $attribs = array(), $contents = '' ) { return self::rawElement( $element, $attribs, strtr( $contents, array( - # There's no point in escaping quotes, >, etc. in the contents of - # elements. + // There's no point in escaping quotes, >, etc. in the contents of + // elements. '&' => '&', '<' => '<' ) ) ); @@ -179,24 +179,20 @@ class Html { public static function openElement( $element, $attribs = array() ) { global $wgHtml5, $wgWellFormedXml; $attribs = (array)$attribs; - # This is not required in HTML5, but let's do it anyway, for - # consistency and better compression. + // This is not required in HTML5, but let's do it anyway, for + // consistency and better compression. $element = strtolower( $element ); - # In text/html, initial and tags can be omitted under - # pretty much any sane circumstances, if they have no attributes. See: - # + // In text/html, initial and tags can be omitted under + // pretty much any sane circumstances, if they have no attributes. See: + // if ( !$wgWellFormedXml && !$attribs && in_array( $element, array( 'html', 'head' ) ) ) { return ''; } - # Remove HTML5-only attributes if we aren't doing HTML5, and disable - # form validation regardless (see bug 23769 and the more detailed - # comment in expandAttributes()) + // Remove invalid input types if ( $element == 'input' ) { - # Whitelist of types that don't cause validation. All except - # 'search' are valid in XHTML1. $validTypes = array( 'hidden', 'text', @@ -208,24 +204,43 @@ class Html { 'image', 'reset', 'button', - 'search', ); + // Allow more input types in HTML5 mode + if( $wgHtml5 ) { + $validTypes = array_merge( $validTypes, array( + 'datetime', + 'datetime-local', + 'date', + 'month', + 'time', + 'week', + 'number', + 'range', + 'email', + 'url', + 'search', + 'tel', + 'color', + ) ); + } if ( isset( $attribs['type'] ) && !in_array( $attribs['type'], $validTypes ) ) { unset( $attribs['type'] ); } - - if ( isset( $attribs['type'] ) && $attribs['type'] == 'search' - && !$wgHtml5 ) { - unset( $attribs['type'] ); - } } if ( !$wgHtml5 && $element == 'textarea' && isset( $attribs['maxlength'] ) ) { unset( $attribs['maxlength'] ); } + // According to standard the default type for