From 02f8c941f4cea9d4a116d5cc7e9239eabf4e6272 Mon Sep 17 00:00:00 2001 From: Tom Needham Date: Thu, 24 Jan 2013 10:39:33 +0000 Subject: API: If key begins with '@' treat it as an xml attribute --- lib/api.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'lib/api.php') diff --git a/lib/api.php b/lib/api.php index 64b2f0fe9c1..47318d4ae1c 100644 --- a/lib/api.php +++ b/lib/api.php @@ -188,18 +188,25 @@ class OC_API { } private static function toXML($array, $writer) { + foreach($array as $k => $v) { - if (is_numeric($k)) { + if (substr($k, 0, 1) === '@') { + $writer->writeAttribute(substr($k, 1), $v); + continue; + } else if (is_numeric($k)) { $k = 'element'; } - if (is_array($v)) { + + if(is_array($v)) { $writer->startElement($k); self::toXML($v, $writer); $writer->endElement(); } else { $writer->writeElement($k, $v); } + } + } } -- cgit v1.2.3 From d89be72972626ed4817df723482f6767372d9391 Mon Sep 17 00:00:00 2001 From: Tom Needham Date: Thu, 24 Jan 2013 10:40:47 +0000 Subject: Remove some whitespace --- lib/api.php | 4 ---- 1 file changed, 4 deletions(-) (limited to 'lib/api.php') diff --git a/lib/api.php b/lib/api.php index 47318d4ae1c..d4deac24c7c 100644 --- a/lib/api.php +++ b/lib/api.php @@ -188,7 +188,6 @@ class OC_API { } private static function toXML($array, $writer) { - foreach($array as $k => $v) { if (substr($k, 0, 1) === '@') { $writer->writeAttribute(substr($k, 1), $v); @@ -196,7 +195,6 @@ class OC_API { } else if (is_numeric($k)) { $k = 'element'; } - if(is_array($v)) { $writer->startElement($k); self::toXML($v, $writer); @@ -204,9 +202,7 @@ class OC_API { } else { $writer->writeElement($k, $v); } - } - } } -- cgit v1.2.3 From b26279546c78618b167e4a8e7a4a10db01c7d479 Mon Sep 17 00:00:00 2001 From: Tom Needham Date: Thu, 24 Jan 2013 10:49:48 +0000 Subject: Simpler method for getting the first char --- lib/api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/api.php') diff --git a/lib/api.php b/lib/api.php index d4deac24c7c..76542156d95 100644 --- a/lib/api.php +++ b/lib/api.php @@ -189,7 +189,7 @@ class OC_API { private static function toXML($array, $writer) { foreach($array as $k => $v) { - if (substr($k, 0, 1) === '@') { + if ($k[0] === '@') { $writer->writeAttribute(substr($k, 1), $v); continue; } else if (is_numeric($k)) { -- cgit v1.2.3