Merge fixes to ?preload= from /branches/conrad/ (cf. bug 5210, r62864, r62035)
[lhc/web/wiklou.git] / includes / Xml.php
index 4929a30..464b142 100644 (file)
@@ -56,7 +56,7 @@ class Xml {
 
        /**
         * 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:
@@ -65,12 +65,13 @@ class Xml {
         * @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 );
@@ -162,12 +163,12 @@ class Xml {
        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' );
@@ -394,7 +395,7 @@ class Xml {
         * @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 );
        }
 
        /**
@@ -568,7 +569,8 @@ class Xml {
                } 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 ) {
@@ -699,14 +701,12 @@ class Xml {
                        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' );
@@ -715,6 +715,7 @@ class Xml {
        
        /**
         * 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
         */
@@ -723,7 +724,6 @@ class Xml {
                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' );