API: (bug 19004) Add support for tags. Patch by Matthew Britton
[lhc/web/wiklou.git] / includes / Xml.php
index 4929a30..9466e08 100644 (file)
@@ -568,7 +568,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 +700,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 +714,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 +723,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' );