From 9fe114978201e2f306a524f4d7382f951f088a2b Mon Sep 17 00:00:00 2001 From: icewing Date: Fri, 28 Mar 2008 14:25:27 +0000 Subject: Marcus Povey * Moved XML serialisation functions to export.php git-svn-id: https://code.elgg.org/elgg/trunk@279 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/api.php | 77 ------------------------------------------------------ 1 file changed, 77 deletions(-) diff --git a/engine/lib/api.php b/engine/lib/api.php index 9e2ec6301..d04a7029b 100644 --- a/engine/lib/api.php +++ b/engine/lib/api.php @@ -736,83 +736,6 @@ return false; } - // XML functions ////////////////////////////////////////////////////////////////////////// - - /** - * This function serialises an object recursively into an XML representation. - * @param $data object The object to serialise. - * @param $n int Level, only used for recursion. - * @return string The serialised XML output. - */ - function serialise_object_to_xml($data, $name = "", $n = 0) - { - $classname = ($name=="" ? get_class($data) : $name); - - $vars = get_object_vars($data); - - $output = ""; - - if ($n==0) $output = "<$classname>"; - - foreach ($vars as $key => $value) - { - $output .= "<$key type=\"".gettype($value)."\">"; - - if (is_object($value)) - $output .= serialise_object_to_xml($value, $key, $n+1); - else if (is_array($value)) - $output .= serialise_array_to_xml($value, $n+1); - else - $output .= htmlentities($value); - - $output .= "\n"; - } - - if ($n==0) $output .= "\n"; - - return $output; - } - - /** - * Serialise an array. - * - * @param array $data - * @param int $n Used for recursion - * @return string - */ - function serialise_array_to_xml(array $data, $n = 0) - { - $output = ""; - - if ($n==0) $output = "\n"; - - foreach ($data as $key => $value) - { - $item = "array_item"; - - if (is_numeric($key)) - $output .= "<$item name=\"$key\" type=\"".gettype($value)."\">"; - else - { - $item = $key; - $output .= "<$item type=\"".gettype($value)."\">"; - } - - if (is_object($value)) - $output .= serialise_object_to_xml($value, $item, $n+1); - else if (is_array($value)) - $output .= serialise_array_to_xml($value, $n+1); - else - $output .= htmlentities($value); - - $output .= "\n"; - } - - if ($n==0) $output = "\n"; - - return $output; - } - // Output functions /////////////////////////////////////////////////////////////////////// $API_OUTPUT_FUNCTIONS = array(); -- cgit v1.2.3