X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FXml.php;h=3b82c64551f92b8c1166bd43f4f70f652276e3be;hb=ba7f151c0694a403b49ad2e71712350f37d462fe;hp=c62cbdf635a130008d828850dbe2798355290d33;hpb=7c4eccb559754ea70c005dd87705af6bf46089c5;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Xml.php b/includes/Xml.php index c62cbdf635..3b82c64551 100644 --- a/includes/Xml.php +++ b/includes/Xml.php @@ -195,8 +195,9 @@ class Xml { 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--; } @@ -243,7 +244,7 @@ class Xml { $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' ); @@ -499,34 +500,34 @@ class Xml { $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(); @@ -739,17 +740,23 @@ class Xml { /** * 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 .= ""; foreach ( $fields as $labelmsg => $input ) { $id = "mw-$labelmsg"; $form .= Xml::openElement( 'tr', array( 'id' => $id ) ); + + // TODO use a