/** * Formats the content from the email to a normal blog content * * @since 4.0 * @access public * @param string * @return */ public function getMessageContents(EasyBlogMailboxMessage $message, $format = 'html') { $result = new stdClass(); $result->html = $message->getHTML(); $result->plain = nl2br($message->getPlain()); // If plain text is empty, just fall back to html if (empty($result->plain)) { $result->body = nl2br(strip_tags($result->html)); } $result->body = $format == 'html' ? $result->html : $result->plain; // If we can't get any result, just use the plain text $result->body = $result->body ? $result->body : $result->plain; // Filter the contents to avoid any unecessary data $filter = JFilterInput::getInstance(null, null, 1, 1); // JFilterInput doesn't strip css tags $result->body = preg_replace("'<style[^>]*>.*?</style>'si", '', $result->body); // Clean up the input $result->body = $filter->clean($result->body, 'html'); $result->body = JString::trim($result->body); // Tidup content so that does not contain unclosed html codes $result->body = EB::string()->tidyHTMLContent($result->body); return $result; }