Mailer.php
[Pman.Core] / Mailer.php
index fb2364d..f51c527 100644 (file)
@@ -455,18 +455,52 @@ class Pman_Core_Mailer {
     
     function htmlbodyInlineCss($html)
     {
-        $dom = new DOMDocument();
-        
-        @$dom->loadHTML('<?xml encoding="UTF-8">' .$html);
-        
-        $head = $dom->getElementsByTagName('body');
-        
-        $s = $dom->createElement('style');
-        $e = $dom->createTextNode($this->css_inline);
-        $s->appendChild($e);
-        $head->appendChild($s);
-        
-        return $dom->saveHTML();
+        require_once 'HTML/CSS/InlineStyle.php';
+        
+        $doc = new HTML_CSS_InlineStyle($html);
+        
+        $htmldoc->applyStylesheet($this->css_inline);
+        
+        $html = $htmldoc->getHTML();
+        
+//        libxml_use_internal_errors (false);
+//        
+//        if (!function_exists('tidy_repair_string')) {
+//            return "INSTALL TIDY ON SERVER " . $html;
+//        }
+//        
+//        $html = tidy_repair_string(
+//                $html,
+//                array(
+//                  'indent' => TRUE,
+//                    'output-xhtml' => TRUE,
+//                    'wrap' => 120
+//                ),
+//                'UTF8'
+//        );
+        
+        return $html;
+        
+//        $dom = new DOMDocument();
+//        
+//        @$dom->loadHTML('<?xml encoding="UTF-8">' .$html);
+//        
+//        $html = $dom->getElementsByTagName('html');
+//        $head = $dom->getElementsByTagName('head');
+//        $body = $dom->getElementsByTagName('body');
+//        
+//        if(!$head->length){
+//            $head = $dom->createElement('head');
+//            $html->item(0)->insertBefore($head, $body->item(0));
+//            $head = $dom->getElementsByTagName('head');
+//        }
+//        
+//        $s = $dom->createElement('style');
+//        $e = $dom->createTextNode($this->css_inline);
+//        $s->appendChild($e);
+//        $head->item(0)->appendChild($s);
+//        
+//        return $dom->saveHTML();
     }
     
     function fetchImage($url)