if ( $year ) {
$encYear = intval( $year );
} elseif ( $encMonth ) {
- $thisMonth = intval( gmdate( 'n' ) );
- $thisYear = intval( gmdate( 'Y' ) );
+ $timestamp = MWTimestamp::getInstance();
+ $thisMonth = intval( $timestamp->format( 'n' ) );
+ $thisYear = intval( $timestamp->format( 'Y' ) );
if ( intval( $encMonth ) > $thisMonth ) {
$thisYear--;
}
$selected = isset( $languages[$selected] ) ? $selected : $wgLanguageCode;
$options = "\n";
foreach ( $languages as $code => $name ) {
- $options .= Xml::option( "$code - $name", $code, ($code == $selected) ) . "\n";
+ $options .= Xml::option( "$code - $name", $code, $code == $selected ) . "\n";
}
$attrs = array( 'id' => 'wpUserLanguage', 'name' => 'wpUserLanguage' );
/**
* Generate a form (without the opening form element).
* Output optionally includes a submit button.
- * @param array $fields Associative array, key is message corresponding to a description for the field (colon is in the message), value is appropriate input.
- * @param string $submitLabel A message containing a label for the submit button.
+ * @param array $fields Associative array, key is the name of a message that contains a description for the field, value is an HTML string containing the appropriate input.
+ * @param string $submitLabel The name of a message containing a label for the submit button.
+ * @param array $submitAttribs The attributes to add to the submit button
* @return string HTML form.
*/
- public static function buildForm( $fields, $submitLabel = null ) {
+ public static function buildForm( $fields, $submitLabel = null, $submitAttribs = array() ) {
$form = '';
$form .= "<table><tbody>";
foreach ( $fields as $labelmsg => $input ) {
$id = "mw-$labelmsg";
$form .= Xml::openElement( 'tr', array( 'id' => $id ) );
+
+ // TODO use a <label> here for accessibility purposes - will need
+ // to either not use a table to build the form, or find the ID of
+ // the input somehow.
+
$form .= Xml::tags( 'td', array( 'class' => 'mw-label' ), wfMessage( $labelmsg )->parse() );
$form .= Xml::openElement( 'td', array( 'class' => 'mw-input' ) ) . $input . Xml::closeElement( 'td' );
$form .= Xml::closeElement( 'tr' );
if ( $submitLabel ) {
$form .= Xml::openElement( 'tr' );
$form .= Xml::tags( 'td', array(), '' );
- $form .= Xml::openElement( 'td', array( 'class' => 'mw-submit' ) ) . Xml::submitButton( wfMessage( $submitLabel )->text() ) . Xml::closeElement( 'td' );
+ $form .= Xml::openElement( 'td', array( 'class' => 'mw-submit' ) ) . Xml::submitButton( wfMessage( $submitLabel )->text(), $submitAttribs ) . Xml::closeElement( 'td' );
$form .= Xml::closeElement( 'tr' );
}
*/
public function addOption( $name, $value = false ) {
// Stab stab stab
- $value = ($value !== false) ? $value : $name;
+ $value = $value !== false ? $value : $name;
$this->options[] = array( $name => $value );
}