if( is_null( $attribs ) ) {
return null;
} elseif( is_array( $attribs ) ) {
- foreach( $attribs as $name => $val )
+ foreach( $attribs as $name => $val ) {
$out .= " {$name}=\"" . Sanitizer::encodeAttribute( $val ) . '"';
+ }
return $out;
} else {
throw new MWException( 'Expected attribute array, got something else in ' . __METHOD__ );
if( !is_null( $all ) )
$namespaces = array( $all => wfMsg( 'namespacesall' ) ) + $namespaces;
foreach( $namespaces as $index => $name ) {
- if( $index < NS_MAIN )
+ if( $index < NS_MAIN ) {
continue;
- if( $index === 0 )
+ }
+ if( $index === 0 ) {
$name = wfMsg( 'blanknamespace' );
+ }
$options[] = self::option( $name, $index, $index === $selected );
}
. "\n"
. Xml::closeElement( 'select' );
if ( !is_null( $label ) ) {
- $ret = Xml::label( $label, $element_name ) . ' ' . $ret;
+ $ret = Xml::label( $label, $element_name ) . ' ' . $ret;
}
return $ret;
}
* @return array of label and select
*/
public static function languageSelector( $selected, $customisedOnly = true ) {
- global $wgContLanguageCode;
+ global $wgLanguageCode;
/**
* Make sure the site language is in the list; a custom language code
* might not have a defined name...
*/
$languages = Language::getLanguageNames( $customisedOnly );
- if( !array_key_exists( $wgContLanguageCode, $languages ) ) {
- $languages[$wgContLanguageCode] = $wgContLanguageCode;
+ if( !array_key_exists( $wgLanguageCode, $languages ) ) {
+ $languages[$wgLanguageCode] = $wgLanguageCode;
}
ksort( $languages );
* Otherwise, no default is selected and the user ends up
* with an Afrikaans interface since it's first in the list.
*/
- $selected = isset( $languages[$selected] ) ? $selected : $wgContLanguageCode;
+ $selected = isset( $languages[$selected] ) ? $selected : $wgLanguageCode;
$options = "\n";
foreach( $languages as $code => $name ) {
$options .= Xml::option( "$code - $name", $code, ($code == $selected) ) . "\n";
* @return string HTML
*/
public static function input( $name, $size=false, $value=false, $attribs=array() ) {
- $attributes = array();
+ $attributes = array( 'name' => $name );
+
if( $size ) {
$attributes['size'] = $size;
}
- if( $size ) {
+ if( $value !== false ) { // maybe 0
$attributes['value'] = $value;
}
- $attributes['name'] = $name;
-
return self::element( 'input', $attributes + $attribs );
}
*/
public static function inputLabel( $label, $name, $id, $size=false, $value=false, $attribs=array() ) {
list( $label, $input ) = self::inputLabelSep( $label, $name, $id, $size, $value, $attribs );
- return $label . ' ' . $input;
+ return $label . ' ' . $input;
}
/**
*/
public static function checkLabel( $label, $name, $id, $checked=false, $attribs=array() ) {
return self::check( $name, $checked, array( 'id' => $id ) + $attribs ) .
- ' ' .
+ ' ' .
self::label( $label, $id, $attribs );
}
*/
public static function radioLabel( $label, $name, $value, $id, $checked=false, $attribs=array() ) {
return self::radio( $name, $value, $checked, array( 'id' => $id ) + $attribs ) .
- ' ' .
+ ' ' .
self::label( $label, $id, $attribs );
}
protected $attributes = array();
public function __construct( $name = false, $id = false, $default = false ) {
- if ( $name ) $this->setAttribute( 'name', $name );
- if ( $id ) $this->setAttribute( 'id', $id );
- if ( $default !== false ) $this->default = $default;
+ if ( $name ) {
+ $this->setAttribute( 'name', $name );
+ }
+ if ( $id ) {
+ $this->setAttribute( 'id', $id );
+ }
+ if ( $default !== false ) {
+ $this->default = $default;
+ }
}
public function setDefault( $default ) {