. implode( "\n", $options )
. self::closeElement( 'select' );
}
-
+
/**
* @param $year Integer
* @param $month Integer
* @param $text content of the element, will be escaped
* @param $class class name of the span element
* @param $attribs other attributes
- * @return string
+ * @return string
*/
public static function span( $text, $class, $attribs=array() ) {
return self::element( 'span', array( 'class' => $class ) + $attribs, $text );
* @param $class class name of the span element
* @param $tag element name
* @param $attribs other attributes
- * @return string
+ * @return string
*/
public static function wrapClass( $text, $class, $tag='span', $attribs=array() ) {
return self::tags( $tag, array( 'class' => $class ) + $attribs, $text );
* @return string HTML
*/
public static function input( $name, $size=false, $value=false, $attribs=array() ) {
- return self::element( 'input', array(
- 'name' => $name,
- 'size' => $size,
- 'value' => $value ) + $attribs );
+ $attributes = array();
+ if( $size ) {
+ $attributes['size'] = $size;
+ }
+
+ if( $size ) {
+ $attributes['value'] = $value;
+ }
+
+ $attributes['name'] = $name;
+
+ return self::element( 'input', $attributes + $attribs );
}
/**
* Convenience function to build an HTML form label
* @param $label text of the label
* @param $id
- * @param $attribs Array, other attributes
+ * @param $attribs Array, other attributes
* @return string HTML
*/
public static function label( $label, $id, $attribs=array() ) {
return $s;
}
-
+
/**
* Shortcut for creating textareas.
*
array( '"', '>', '<' ),
$in );
}
-
+
/**
* Generate a form (without the opening form element).
* Output optionally includes a submit button.
public static function buildForm( $fields, $submitLabel = null ) {
$form = '';
$form .= "<table><tbody>";
-
+
foreach( $fields as $labelmsg => $input ) {
$id = "mw-$labelmsg";
$form .= Xml::openElement( 'tr', array( 'id' => $id ) );
$form .= Xml::openElement( 'td', array( 'class' => 'mw-submit' ) ) . Xml::submitButton( wfMsg( $submitLabel ) ) . Xml::closeElement( 'td' );
$form .= Xml::closeElement( 'tr' );
}
-
+
$form .= "</tbody></table>";
-
+
return $form;
}
-
+
/**
* Build a table of data
* @param $rows An array of arrays of strings, each to be a row in a table
$s .= Xml::closeElement( 'table' );
return $s;
}
-
+
/**
* Build a row for a table
* @param $attribs An array of attributes to apply to the tr tag
$value = ($value !== false) ? $value : $name;
$this->options[] = Xml::option( $name, $value, $value === $this->default );
}
-
+
// This accepts an array of form
// label => value
// label => ( label => value, label => value )
// This accepts an array of form
// label => value
- // label => ( label => value, label => value )
+ // label => ( label => value, label => value )
static function formatOptions( $options, $default = false ) {
$data = '';
foreach( $options as $label => $value ) {
$data .= Xml::option( $label, $value, $value === $default ) . "\n";
}
}
-
+
return $data;
}