'seamless',
);
+ # A nested associative array of element => content attribute => default
+ # value. Attributes that have the default value will be omitted, since
+ # they're pointless. Currently the list hasn't been systematically
+ # populated.
+ private static $attribDefaults = array(
+ 'input' => array(
+ 'value' => '',
+ 'type' => 'text',
+ ),
+ );
+
/**
* Returns an HTML element in a string. The major advantage here over
* manually typing out the HTML is that it will escape all attribute
}
}
+ # Don't bother outputting the default values for attributes
+ foreach ( $attribs as $attrib => $value ) {
+ $lcattrib = strtolower( $attrib );
+ if ( isset( self::$attribDefaults[$element][$lcattrib] ) &&
+ self::$attribDefaults[$element][$lcattrib] === $value ) {
+ unset( $attribs[$attrib] );
+ }
+ }
+
$start = "<$element" . self::expandAttributes( $attribs );
if ( in_array( $element, self::$voidElements ) ) {
if ( $wgWellFormedXml ) {
* @return string Raw HTML
*/
public static function input( $name, $value = null, $type = 'text', $attribs = array() ) {
- if ( $type != 'text' ) {
- $attribs['type'] = $type;
- }
- if ( $value !== null && $value !== '' ) {
+ $attribs['type'] = $type;
+ if ( $value !== null ) {
$attribs['value'] = $value;
}
$attribs['name'] = $name;