Revision: 1670
          http://mrbs.svn.sourceforge.net/mrbs/?rev=1670&view=rev
Author:   cimorrison
Date:     2010-12-06 15:33:01 +0000 (Mon, 06 Dec 2010)

Log Message:
-----------
Tidied up HTML

Modified Paths:
--------------
    mrbs/branches/ics_attachments/web/functions_ical.inc
    mrbs/branches/ics_attachments/web/functions_mail.inc
    mrbs/branches/ics_attachments/web/lang.en

Modified: mrbs/branches/ics_attachments/web/functions_ical.inc
===================================================================
--- mrbs/branches/ics_attachments/web/functions_ical.inc        2010-12-06 
13:32:33 UTC (rev 1669)
+++ mrbs/branches/ics_attachments/web/functions_ical.inc        2010-12-06 
15:33:01 UTC (rev 1670)
@@ -126,12 +126,12 @@
 
 
 // Creates an iCalendar object in RFC 5545 format
-function create_icalendar($method, $data, $description, $series=FALSE, 
$html_cid)
+function create_icalendar($method, $data, $text_description, 
$html_description, $series=FALSE)
 {
   require_once "version.inc";
   
   global $timezone, $confirmation_enabled, $mail_settings;
-  
+
   $eol = "\r\n";
   
   $results = array();
@@ -154,9 +154,14 @@
   $results[] = "DTSTART;TZID=$timezone:" . date(RFC5545_FORMAT, 
$data['start_time']);
   $results[] = "DTEND;TZID=$timezone:" . date(RFC5545_FORMAT, 
$data['end_time']);
   $results[] = "SUMMARY:" . ical_escape_text($data['name']);
+  // Put the HTML version in an ALTREP, just in case there are any Calendars 
out there
+  // that support it (although at the time of writing, Dec 2010, none are 
known)
   $results[] = "DESCRIPTION" .
-               (($mail_settings['html']) ? ";ALTREP=\"CID:$html_cid\"" : "") . 
":" .
-               ical_escape_text($description);
+               ((($mail_settings['html']) ? ";ALTREP=\"CID:" . 
$html_description['cid'] . "\"" : "") . ":" .
+               ical_escape_text($text_description['content']));
+  // This is another way of getting an HTML description, used by Outlook.  
However it 
+  // seems to be very limited
+  $results[] = "X-ALT-DESC;FMTTYPE=text/html:" . 
ical_escape_text($html_description['content']);
   $results[] = "LOCATION:" . ical_escape_text($data['area_name'] . " - " . 
$data['room_name']);
   $results[] = "SEQUENCE:" . $data['ical_sequence'];
   // If this is an individual member of a series then set the recurrence id

Modified: mrbs/branches/ics_attachments/web/functions_mail.inc
===================================================================
--- mrbs/branches/ics_attachments/web/functions_mail.inc        2010-12-06 
13:32:33 UTC (rev 1669)
+++ mrbs/branches/ics_attachments/web/functions_mail.inc        2010-12-06 
15:33:01 UTC (rev 1670)
@@ -304,7 +304,7 @@
   
   // The label
   $result .= ($as_html) ? "<td>" : "";
-  $result .= ($as_html) ? htmlspecialchars($label) : "$label: ";
+  $result .= ($as_html) ? htmlspecialchars("$label: ") : "$label: ";
   $result .= ($as_html) ? "</td>\n" : "";
   // The new value
   $result .= ($as_html) ? "<td>" : "";
@@ -320,7 +320,10 @@
     }
     else
     {
-      $result .= ($as_html) ? htmlspecialchars($old) : " ($old)";
+      // Put parentheses around the HTML version as well as the plain text
+      // version in case the table is not rendered properly in HTML.  The
+      // parentheses will make the old value stand out.
+      $result .= ($as_html) ? htmlspecialchars(" ($old)") : " ($old)";
     }
     $result .= ($as_html) ? "<td>\n" : "";
   }
@@ -340,15 +343,20 @@
   $body = "";
   if ($as_html)
   {
+    $body .= DOCTYPE . "\n";
     $body .= "<html>\n";
     $body .= "<head>\n";
+    $body .= "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=" 
. get_mail_charset() . "\">\n";
     $body .= "<title></title>\n";
     $body .= "<style type=\"text/css\">\n";
     $css_file = 'mrbs-mail.css';
     if (file_exists($css_file))
     {
       $fh = fopen($css_file, 'r');
-      $body .= fread($fh, filesize($css_file));
+      $css .= fread($fh, filesize($css_file));
+      $css = preg_replace('!/\*.*?\*/!s', '', $css);  // Remove comments
+      $css = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $css);  
// Remove blank lines
+      $body .= $css;
     }
     $body .= "</style>\n";
     $body .= "</head>\n";
@@ -419,17 +427,22 @@
     }
     $body .= ($as_html) ? "\">" . convertToMailCharset($data['name']) . "</a>" 
: "";
   }
-  $body .= ($as_html) ? "</p>" : "\n\n";
+  $body .= ($as_html) ? "</p>\n" : "\n\n";
   
-  if ($as_html)
+  $body .= ($as_html) ? "<table>\n" : "\n";
+  if ($compare && $as_html)
   {
-    $body .= "<table>\n";
-    $body .= "<tbody>\n";
+    $body .= "<thead>\n";
+    $body .= "<tr>\n";
+    $body .= "<th>&nbsp;</th>\n";
+    $body .= "<th>" . get_vocab("new_value") . "</th>\n";
+    $body .= "<th>(" . get_vocab("old_value") . ")</th>\n";
+    $body .= "</tr>\n";
+    $body .= "</thead>\n";
   }
-  else
-  {
-    $body .= "\n";
-  }
+    
+  $body .= ($as_html) ? "<tbody>\n" : "";
+
   
   // Always display the brief description
   $body .= create_body_table_row (get_mail_vocab("namebooker"),
@@ -793,7 +806,7 @@
   if ($mail_settings['icalendar'])
   {
     $attachment['method']   = "REQUEST";
-    $attachment['content']  = create_icalendar($attachment['method'], $data, 
$text_body['content'], $series, $html_body['cid']);
+    $attachment['content']  = create_icalendar($attachment['method'], $data, 
$text_body, $html_body, $series);
     $attachment['name']     = "meeting.ics";
   }
 
@@ -862,7 +875,7 @@
   if ($mail_settings['icalendar'])
   {
     $attachment['method']   = "CANCEL";
-    $attachment['content']  = create_icalendar($attachment['method'], 
$mail_previous, $text_body['content'], $series, $html_body['cid']);
+    $attachment['content']  = create_icalendar($attachment['method'], 
$mail_previous, $text_body, $html_body, $series);
     $attachment['name']     = "meeting.ics";
   }
   

Modified: mrbs/branches/ics_attachments/web/lang.en
===================================================================
--- mrbs/branches/ics_attachments/web/lang.en   2010-12-06 13:32:33 UTC (rev 
1669)
+++ mrbs/branches/ics_attachments/web/lang.en   2010-12-06 15:33:01 UTC (rev 
1670)
@@ -166,6 +166,8 @@
 $vocab["mail_body_new_entry"]     = "A new entry has been booked, here are the 
details:";
 $vocab["mail_body_changed_entry"] = "An entry has been modified, here are the 
details:";
 $vocab["mail_body_del_entry"]     = "An entry has been deleted, here are the 
details:";
+$vocab["new_value"]           = "New";
+$vocab["old_value"]           = "Old";
 $vocab["deleted_by"]          = "Deleted by";
 $vocab["reason"]              = "Reason";
 $vocab["info_requested"]      = "Information requested";


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
What happens now with your Lotus Notes apps - do you make another costly 
upgrade, or settle for being marooned without product support? Time to move
off Lotus Notes and onto the cloud with Force.com, apps are easier to build,
use, and manage than apps on traditional platforms. Sign up for the Lotus 
Notes Migration Kit to learn more. http://p.sf.net/sfu/salesforce-d2d
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to