Mailer.php
authorAlan Knowles <alan@roojs.com>
Fri, 21 Nov 2014 09:16:27 +0000 (17:16 +0800)
committerAlan Knowles <alan@roojs.com>
Fri, 21 Nov 2014 09:16:27 +0000 (17:16 +0800)
Mailer.php

index 9bf73f8..719675f 100644 (file)
@@ -354,7 +354,29 @@ class Pman_Core_Mailer {
     }
     function htmlbodyCssEmbed($html)
     {
-        
+        $dom = new DOMDocument();
+        // this may raise parse errors as some html may be a component..
+        @$dom->loadHTML('<?xml encoding="UTF-8">' .$html);
+        $links = $dom->getElementsByTagName('link');
+        //<link rel="stylesheet" type="text/css" href="{rootURL}/roojs1/css-mailer/mailer.css"> 
+        foreach ($links as $i=>$link) {
+            if ($link->getAttribute('rel') != 'stylesheet') {
+                continue;
+            }
+            $url  = $link->getAttribute('href');
+            $file = $ff->rootDir . $url;
+            if (!file_exists($file)) {
+                continue;
+            }
+            $par = $img->parentNode();
+            $par->removeChild($link);
+            $s = $dom->createElement('style');
+            $e = $dom->createTextNode(file_get_contents($file));
+            $s->appendChild($e);
+            $par->appendChild($e);
+            
+        }
+        return $dom->saveHTML();
         
         
     }