public function testApplyExtractedStylesheet() { $stylesheets = $this->object->extractStylesheets(null, "testfiles"); $this->object->applyStylesheet($stylesheets); $this->assertEquals($this->object->getHTML(), file_get_contents("testfiles/testApplyExtractedStylesheet.html")); }
public function prepare_content($inline = true) { if (empty($this->content)) { return false; } //strip all unwanted stuff from the content $this->strip_stuff(); //fix for Yahoo background color if (!strpos($this->content, 'body{background-image')) { $this->content = preg_replace('/body{background-color/', 'body,.bodytbl{background-color', $this->content, 1); } //Inline CSS if ($inline) { error_reporting(0); require_once MYMAIL_DIR . '/classes/libs/InlineStyle.php'; $htmldoc = new InlineStyle($this->content); $stylesheet = $htmldoc->extractStylesheets(); $originalstyle = $stylesheet[0]; $mediaBlocks = $this->parseMediaBlocks($originalstyle); $stylesheet = str_replace($mediaBlocks, '', $originalstyle); $htmldoc->applyStylesheet($stylesheet); $html = $this->content; preg_match('#(<style ?[^<]+?>[^<]+<\\/style>)#', $this->content, $styles); $html = $htmldoc->getHTML(); if ($styles[0]) { $html = preg_replace('#(<body ?[^<]+?>)#', "\$1\n" . $styles[0], $html); } //convert urlencode back $this->content = urldecode($html); } $this->content = str_replace(array('%7B', '%7D'), array('{', '}'), $this->content); //return false; return $this->content; }