CRM-13407 - Conditionally add HTML markup for HEAD and TITLE if not present, using...
authorDave Greenberg <dave@civicrm.org>
Mon, 16 Sep 2013 21:35:03 +0000 (14:35 -0700)
committerDave Greenberg <dave@civicrm.org>
Mon, 16 Sep 2013 21:35:03 +0000 (14:35 -0700)
----------------------------------------
* CRM-13407: View CiviMail Mailings - page should include an HTML title if one isn't provided in the message body
  http://issues.civicrm.org/jira/browse/CRM-13407

CRM/Mailing/Page/View.php

index 59305426d27a16e3dddcb3f500bdfb0e77f1a1d3..352304f3ea08ad08f186e17606663a56bf96d4c7 100644 (file)
@@ -135,9 +135,14 @@ class CRM_Mailing_Page_View extends CRM_Core_Page {
       TRUE, $details, $attachments
     );
 
+    $title = NULL;
     if (isset($this->_mailing->body_html)) {
+      
       $header = 'Content-Type: text/html; charset=utf-8';
       $content = $mime->getHTMLBody();
+      if (strpos($content, '<head>') === FALSE && strpos($content, '<title>') === FALSE) {
+        $title = '<head><title>' . $this->_mailing->subject . '</title></head>';
+      }
     }
     else {
       $header = 'Content-Type: text/plain; charset=utf-8';
@@ -146,6 +151,7 @@ class CRM_Mailing_Page_View extends CRM_Core_Page {
 
     if ($print) {
       header($header);
+      print $title;
       print $content;
       CRM_Utils_System::civiExit();
     }