From 5fec6de4216883e625d7e166f862985d00c99d4a Mon Sep 17 00:00:00 2001 From: thomascube Date: Sat, 27 Nov 2010 14:09:03 +0000 Subject: Copy plugins to release branch --- plugins/emoticons/emoticons.php | 80 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 plugins/emoticons/emoticons.php (limited to 'plugins/emoticons/emoticons.php') diff --git a/plugins/emoticons/emoticons.php b/plugins/emoticons/emoticons.php new file mode 100644 index 000000000..e929c9f9d --- /dev/null +++ b/plugins/emoticons/emoticons.php @@ -0,0 +1,80 @@ +add_hook('message_part_after', array($this, 'replace')); + } + + function replace($args) + { + // This is a lookbehind assertion which will exclude html entities + // E.g. situation when ";)" in "")" shouldn't be replaced by the icon + // It's so long because of assertion format restrictions + $entity = '(? html::img(array( + 'src' => './program/js/tiny_mce/plugins/emotions/img/smiley-smile.gif', + 'title' => ':)' + )), + '/:-\)/' => html::img(array( + 'src' => './program/js/tiny_mce/plugins/emotions/img/smiley-smile.gif', + 'title' => ':-)' + )), + '/(? html::img(array( + 'src' => './program/js/tiny_mce/plugins/emotions/img/smiley-laughing.gif', + 'title' => ':D' + )), + '/:-D/' => html::img(array( + 'src' => './program/js/tiny_mce/plugins/emotions/img/smiley-laughing.gif', + 'title' => ':-D' + )), + '/:\(/' => html::img(array( + 'src' => './program/js/tiny_mce/plugins/emotions/img/smiley-frown.gif', + 'title' => ':(' + )), + '/:-\(/' => html::img(array( + 'src' => './program/js/tiny_mce/plugins/emotions/img/smiley-frown.gif', + 'title' => ':-(' + )), + '/'.$entity.';\)/' => html::img(array( + 'src' => './program/js/tiny_mce/plugins/emotions/img/smiley-wink.gif', + 'title' => ';)' + )), + '/'.$entity.';-\)/' => html::img(array( + 'src' => './program/js/tiny_mce/plugins/emotions/img/smiley-wink.gif', + 'title' => ';-)' + )), + ); + + if ($args['type'] == 'plain') { + $args['body'] = preg_replace( + array_keys($map), array_values($map), $args['body']); + } + + return $args; + } + +} -- cgit v1.2.3