/**
* Format an XML element as with self::element(), but run text through the
- * UtfNormal::cleanUp() validator first to ensure that no invalid UTF-8
+ * $wgContLang->normalize() validator first to ensure that no invalid UTF-8
* is passed.
*
* @param $element String:
* @return string
*/
public static function elementClean( $element, $attribs = array(), $contents = '') {
+ global $wgContLang;
if( $attribs ) {
$attribs = array_map( array( 'UtfNormal', 'cleanUp' ), $attribs );
}
if( $contents ) {
wfProfileIn( __METHOD__ . '-norm' );
- $contents = UtfNormal::cleanUp( $contents );
+ $contents = $wgContLang->normalize( $contents );
wfProfileOut( __METHOD__ . '-norm' );
}
return self::element( $element, $attribs, $contents );
public static function monthSelector( $selected = '', $allmonths = null, $id = 'month' ) {
global $wgLang;
$options = array();
- if( is_null( $selected ) )
+ if( is_null( $selected ) )
$selected = '';
- if( !is_null( $allmonths ) )
+ if( !is_null( $allmonths ) )
$options[] = self::option( wfMsg( 'monthsall' ), $allmonths, $selected === $allmonths );
for( $i = 1; $i < 13; $i++ )
- $options[] = self::option( $wgLang->getMonthName( $i ), $i, $selected === $i );
+ $options[] = self::option( $wgLang->getMonthName( $i ), $i, $selected === $i );
return self::openElement( 'select', array( 'id' => $id, 'name' => 'month', 'class' => 'mw-month-selector' ) )
. implode( "\n", $options )
. self::closeElement( 'select' );
* @return string HTML
*/
public static function submitButton( $value, $attribs=array() ) {
- return self::element( 'input', array( 'type' => 'submit', 'value' => $value ) + $attribs );
+ return Html::element( 'input', array( 'type' => 'submit', 'value' => $value ) + $attribs );
}
/**
} elseif ( is_int( $value ) ) {
$s = $value;
} elseif ( is_array( $value ) && // Make sure it's not associative.
- array_keys($value) === range(0,count($value)-1)
+ array_keys($value) === range( 0, count($value) - 1 ) ||
+ count($value) == 0
) {
$s = '[';
foreach ( $value as $elt ) {
foreach( $headers as $id => $header ) {
$attribs = array();
if ( is_string( $id ) ) $attribs['id'] = $id;
- if ( is_array( $id ) ) $attribs = $id;
$s .= Xml::element( 'th', $attribs, $header );
}
}
foreach( $rows as $id => $row ) {
$attribs = array();
if ( is_string( $id ) ) $attribs['id'] = $id;
- if ( is_array( $id ) ) $attribs = $id;
$s .= Xml::buildTableRow( $attribs, $row );
}
$s .= Xml::closeElement( 'table' );
/**
* Build a row for a table
+ * @param $attribs An array of attributes to apply to the tr tag
* @param $cells An array of strings to put in <td>
* @return string
*/
foreach( $cells as $id => $cell ) {
$attribs = array();
if ( is_string( $id ) ) $attribs['id'] = $id;
- if ( is_array( $id ) ) $attribs = $id;
$s .= Xml::element( 'td', $attribs, $cell );
}
$s .= Xml::closeElement( 'tr' );