- 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) {
+
+ /** 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"]);
+ $body = "";
+
+ if (containsType($message, "text", "html", $ent_num)) {
+ $body .= decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]);
+ } else if (containsType($message, "text", "plain", $ent_num)) {
+ $tmpbody = decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]);
+ $body .= "<TT>" . nl2br(trim($tmpbody)) . "</TT>";
+ }
+ // add other primary displaying message types here
+ else {
+ // find any type that's displayable
+ if (containsType($message, "text", "any_type", $ent_num)) {
+ $tmpbody = decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]);
+ $body .= "<TT>" . nl2br(trim($tmpbody)) . "</TT>";
+ } else if (containsType($message, "message", "any_type", $ent_num)) {
+ $tmpbody = decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]);
+ $body .= "<TT>" . nl2br(trim($tmpbody)) . "</TT>";