API: (bug 19004) Add support for tags. Patch by Matthew Britton
[lhc/web/wiklou.git] / includes / Xml.php
index 5359f32..9466e08 100644 (file)
@@ -398,17 +398,10 @@ class Xml {
        }
 
        /**
-        * Convenience function to build an HTML hidden form field.
-        * @param $name String: name attribute for the field
-        * @param $value String: value for the hidden field
-        * @param $attribs Array: optional custom attributes
-        * @return string HTML
+        * @deprecated Synonymous to Html::hidden()
         */
-       public static function hidden( $name, $value, $attribs=array() ) {
-               return self::element( 'input', array(
-                       'name' => $name,
-                       'type' => 'hidden',
-                       'value' => $value ) + $attribs );
+       public static function hidden( $name, $value, $attribs = array() ) {
+               return Html::hidden( $name, $value, $attribs );
        }
 
        /**
@@ -574,7 +567,10 @@ class Xml {
                        $s = 'null';
                } elseif ( is_int( $value ) ) {
                        $s = $value;
-               } elseif ( is_array( $value ) ) {
+               } elseif ( is_array( $value ) && // Make sure it's not associative.
+                                       array_keys($value) === range( 0, count($value) - 1 ) ||
+                                       count($value) == 0
+                               ) {
                        $s = '[';
                        foreach ( $value as $elt ) {
                                if ( $s != '[' ) {
@@ -583,7 +579,8 @@ class Xml {
                                $s .= self::encodeJsVar( $elt );
                        }
                        $s .= ']';
-               } elseif ( is_object( $value ) ) {
+               } elseif ( is_object( $value ) || is_array( $value ) ) {
+                       // Objects and associative arrays
                        $s = '{';
                        foreach ( (array)$value as $name => $elt ) {
                                if ( $s != '{' ) {
@@ -717,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
         */