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--;
}
$options = self::option( $other, 'other', $selected === 'other' );
foreach ( explode( "\n", $list ) as $option ) {
- $value = trim( $option );
- if ( $value == '' ) {
- continue;
- } elseif ( substr( $value, 0, 1 ) == '*' && substr( $value, 1, 1 ) != '*' ) {
- // A new group is starting ...
- $value = trim( substr( $value, 1 ) );
- if ( $optgroup ) {
- $options .= self::closeElement( 'optgroup' );
- }
- $options .= self::openElement( 'optgroup', array( 'label' => $value ) );
- $optgroup = true;
- } elseif ( substr( $value, 0, 2 ) == '**' ) {
- // groupmember
- $value = trim( substr( $value, 2 ) );
- $options .= self::option( $value, $value, $selected === $value );
- } else {
- // groupless reason list
- if ( $optgroup ) {
- $options .= self::closeElement( 'optgroup' );
- }
- $options .= self::option( $value, $value, $selected === $value );
- $optgroup = false;
+ $value = trim( $option );
+ if ( $value == '' ) {
+ continue;
+ } elseif ( substr( $value, 0, 1 ) == '*' && substr( $value, 1, 1 ) != '*' ) {
+ // A new group is starting ...
+ $value = trim( substr( $value, 1 ) );
+ if ( $optgroup ) {
+ $options .= self::closeElement( 'optgroup' );
}
+ $options .= self::openElement( 'optgroup', array( 'label' => $value ) );
+ $optgroup = true;
+ } elseif ( substr( $value, 0, 2 ) == '**' ) {
+ // groupmember
+ $value = trim( substr( $value, 2 ) );
+ $options .= self::option( $value, $value, $selected === $value );
+ } else {
+ // groupless reason list
+ if ( $optgroup ) {
+ $options .= self::closeElement( 'optgroup' );
+ }
+ $options .= self::option( $value, $value, $selected === $value );
+ $optgroup = false;
}
+ }
- if ( $optgroup ) {
- $options .= self::closeElement( 'optgroup' );
- }
+ if ( $optgroup ) {
+ $options .= self::closeElement( 'optgroup' );
+ }
$attribs = array();
* Output optionally includes a 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>";
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' );
}