- function formatBody($message) {
- for ($i=0; $i < count($message["ENTITIES"]); $i++) {
- if ($message["ENTITIES"][$i]["TYPE0"] == "text") {
- if ($message["ENTITIES"][$i]["PRIORITY"] > $priority)
- $priority = $message["ENTITIES"][$i]["PRIORITY"];
+ /** This returns a parsed string called $body. That string can then
+ be displayed as the actual message in the HTML. It contains
+ everything needed, including HTML Tags, Attachments at the
+ bottom, etc.
+ **/
+ function formatBody($message, $color, $wrap_at) {
+
+ /** this if statement checks for the entity to show as the
+ primary message. To add more of them, just put them in the
+ order that is their priority.
+ **/
+ $id = $message["INFO"]["ID"];
+ $urlmailbox = urlencode($message["INFO"]["MAILBOX"]);
+
+ if (containsType($message, "text", "html", $ent_num)) {
+ $body = decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]);
+ $charset = $message["ENTITIES"][$ent_num]["CHARSET"];
+ } else if (containsType($message, "text", "plain", $ent_num)) {
+ $body = decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]);
+ $charset = $message["ENTITIES"][$ent_num]["CHARSET"];
+ }
+ // add other primary displaying message types here
+ else {
+ // find any type that's displayable
+ if (containsType($message, "text", "any_type", $ent_num)) {
+ $body = decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]);
+ $charset = $message["ENTITIES"][$ent_num]["CHARSET"];
+ } else if (containsType($message, "message", "any_type", $ent_num)) {
+ $body = decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]);
+ $charset = $message["ENTITIES"][$ent_num]["CHARSET"];