function ParseIt($data, $name = 'theater', $path = '', $level = 0) { global $ordered_fields, $object_fields; $out = array(); // Figure out if we are dealing with named objects, or section names // If this is an ordered field, parse the sub-items $path = $path ? "{$path}/{$name}" : $name; $objects = matchTheaterPath($path, $object_fields); $ordered = matchTheaterPath($path, $ordered_fields); // echo "path: {$path} ordered: {$ordered}\n"; if ($ordered) { $items = array(); foreach ($data as $idx => $item) { foreach ($item as $key => $val) { $items[$key] = $val; } } } else { $items = $data; } foreach ($items as $key => $val) { $title = $objects ? "@name" : $key; if (is_array($val)) { $pdata = ParseIt($val, $title, $path, $level + 1); if (isset($out[$title])) { $pdata = theater_array_replace_recursive($out[$title], $pdata); } $out[$title] = $pdata; uksort($out[$title], "strnatcasecmp"); } else { $out[$title] = vartype($val); } } uksort($out, "strnatcasecmp"); return $out; }
/** * @brief Add a new part to the message * * This method will convert the main entity of the body to be a * MimeMultipartEntity instance if it is not already. The existing * body will be added to the multipart entity. * * @param Mixed $part The part to add */ public function addPart($part) { if (vartype($this->body) != 'MimeMultipartEntity') { $this->body = new MimeMultipartEntity($this->body); } $this->body->addMessagePart($part); }
function ParseIt($data, $name = '', $level = 0, $objects = 0) { global $ordered_fields; $out = array('type' => 'object'); // Figure out if we are dealing with named objects, or section names switch ($name) { case 'weapon_upgrade': $out['sort'] = "unique"; case 'ammo': case 'explosives': case 'player_gear': case 'player_templates': case 'teams': case 'squads': case 'weapons': case 'weapon_upgrades': $objects = 1; break; default: $objects = 0; break; } // If this is an ordered field, parse the sub-items if (!isAssoc($data)) { $out['sort'] = "unique"; foreach ($data as $key => $val) { if (is_array($val)) { foreach ($val as $skey => $sval) { $title = $objects ? "@name" : $skey; $out['items'][$title] = vartype($sval); } } else { $title = $objects ? "@name" : $key; $out['items'][$title] = vartype($val); } } } else { // Otherwise, parse the data natively foreach ($data as $key => $val) { $title = $objects ? "@name" : $key; if (is_array($val)) { $setval = ParseIt($val, $title, $level + 1, $objects); foreach ($setval as $skey => $sval) { // if ($skey == "items") { $out['items'][$title][$skey] = $sval; // } else { // $out['items'][$title][$skey] = vartype($sval); // } } } else { $out['items'][$title] = vartype($val); } } } return $out; }