From 74728935122fe35ed97c40092080cc7dfd4b7052 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Mon, 06 Dec 2010 06:13:55 -0500
Subject: [PATCH] - Fix plaintext versions of HTML messages don't contain placeholders for emotions (#1485206)

---
 program/include/main.inc |   38 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/program/include/main.inc b/program/include/main.inc
index 6d4e19c..ad0bccd 100644
--- a/program/include/main.inc
+++ b/program/include/main.inc
@@ -1647,6 +1647,43 @@
 
 
 /**
+ * Replaces TinyMCE's emoticon images with plain-text representation
+ *
+ * @param string HTML content
+ * @return string HTML content
+ */
+function rcmail_replace_emoticons($html)
+{
+  $emoticons = array(
+    '8-)' => 'smiley-cool',
+    ':-#' => 'smiley-foot-in-mouth',
+    ':-*' => 'smiley-kiss',
+    ':-X' => 'smiley-sealed',
+    ':-P' => 'smiley-tongue-out',
+    ':-@' => 'smiley-yell',
+    ":'(" => 'smiley-cry',
+    ':-(' => 'smiley-frown',
+    ':-D' => 'smiley-laughing',
+    ':-)' => 'smiley-smile',
+    ':-/' => 'smiley-undecided',
+    ':-X' => 'smiley-embarassed',
+    '0:-)' => 'smiley-innocent',
+    ':-|' => 'smiley-money-mouth',
+    ':-0' => 'smiley-surprised',
+    ';-)' => 'smiley-wink',
+  );
+
+  foreach ($emoticons as $idx => $file) {
+    // <img title="Cry" src="http://.../program/js/tiny_mce/plugins/emotions/img/smiley-cry.gif" border="0" alt="Cry" />
+    $search[]  = '/<img title="[a-z ]+" src="https?:\/\/[a-z0-9_.\/-]+\/tiny_mce\/plugins\/emotions\/img\/'.$file.'.gif"[^>]+\/>/i';
+    $replace[] = $idx;
+  }
+
+  return preg_replace($search, $replace, $html);
+}
+
+
+/**
  * Check if working in SSL mode
  *
  * @param integer HTTPS port number
@@ -1881,3 +1918,4 @@
         flush();
     }
 }
+

--
Gitblit v1.9.1