* @param $element String: element name
* @param $attribs Array: Name=>value pairs. Values will be escaped.
* @param $contents String: NULL to make an open tag only; '' for a contentless closed tag (default)
+ * @param $allowShortTag Bool: whether '' in $contents will result in a contentless closed tag
* @return string
*/
- public static function element( $element, $attribs = null, $contents = '') {
+ public static function element( $element, $attribs = null, $contents = '', $allowShortTag = true ) {
$out = '<' . $element;
if( !is_null( $attribs ) ) {
$out .= self::expandAttributes( $attribs );
if( is_null( $contents ) ) {
$out .= '>';
} else {
- if( $contents === '' ) {
+ if( $allowShortTag && $contents === '' ) {
$out .= ' />';
} else {
$out .= '>' . htmlspecialchars( $contents ) . "</$element>";
* Return null if no attributes given.
* @param $attribs Array of attributes for an XML element
*/
- private static function expandAttributes( $attribs ) {
+ public static function expandAttributes( $attribs ) {
$out = '';
if( is_null( $attribs ) ) {
return null;
'cols' => $cols,
'rows' => $rows
) + $attribs,
- $content );
+ $content, false );
}
/**
$id = "mw-$labelmsg";
$form .= Xml::openElement( 'tr', array( 'id' => $id ) );
- $form .= Xml::tags( 'td', array('valign'=>'top','align' => 'right'), wfMsgExt( $labelmsg, array('parseinline') ) );
+ $form .= Xml::tags( 'td', array('class' => 'mw-label'), wfMsgExt( $labelmsg, array('parseinline') ) );
$form .= Xml::openElement( 'td' ) . $input . Xml::closeElement( 'td' );
$form .= Xml::closeElement( 'tr' );
}
}
public function addOption( $name, $value = false ) {
- $value = $value ? $value : $name;
+ // Stab stab stab
+ $value = ($value !== false) ? $value : $name;
$this->options[] = Xml::option( $name, $value, $value === $this->default );
}
return Xml::tags( 'select', $this->attributes, implode( "\n", $this->options ) );
}
-}
\ No newline at end of file
+}