Mailer.php
[Pman.Core] / Mailer.php
index 686c89c..8536b4a 100644 (file)
@@ -110,6 +110,8 @@ class Pman_Core_Mailer {
     
     function toData()
     {
+        $ts = microtime(true);
+        
         $templateFile = $this->template;
         $args = (array)$this->contents;
         $content  = clone($this->page);
@@ -156,6 +158,7 @@ class Pman_Core_Mailer {
         $htmlbody = false;
         $html_tmp_opts = $tmp_opts;
         $htmltemplate = new HTML_Template_Flexy( $html_tmp_opts );
+        
         if (is_string($htmltemplate->resolvePath('mail/'.$templateFile.'.body.html')) ) { 
             // then we have a multi-part email...
             if (!empty($this->html_locale)) {
@@ -171,7 +174,7 @@ class Pman_Core_Mailer {
             // for the html body, we may want to convert the attachments to images.
 //            var_dump($htmlbody);exit;
             
-            if($content->body_cls && strlen($content->body_cls)){
+            if(!empty($content->body_cls) && strlen($content->body_cls)){
                 $htmlbody = $this->htmlbodySetClass($htmlbody, $content->body_cls);
             }
             
@@ -190,7 +193,9 @@ class Pman_Core_Mailer {
         }
         $tmp_opts['nonHTML'] = true;
         
+        $diff = microtime(true) - $ts;
         
+        print_r($diff);exit;
         //print_R($tmp_opts);
         // $tmp_opts['force'] = true;
         
@@ -492,6 +497,21 @@ class Pman_Core_Mailer {
         */
     }
     
+    function htmlbodySetClass($html, $cls)
+    {
+        $dom = new DOMDocument();
+        
+        @$dom->loadHTML('<?xml encoding="UTF-8">' .$html);
+        
+        $body = $dom->getElementsByTagName('body');
+        
+        $class = $dom->createAttribute('class');
+        $class->value = $cls;
+        $body->item(0)->appendChild($class);
+        
+        return $dom->saveHTML();
+    }
+    
     function fetchImage($url)
     {