Changeset 4213 in subversion
- Timestamp:
- Nov 11, 2010 3:18:53 AM (3 years ago)
- File:
-
- 1 edited
-
trunk/plugins/emoticons/emoticons.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/plugins/emoticons/emoticons.php
r3807 r4213 6 6 * Sample plugin to replace emoticons in plain text message body with real icons 7 7 * 8 * @version 1. 1.08 * @version 1.2.0 9 9 * @author Thomas Bruederli 10 10 * @author Aleksander Machniak … … 14 14 { 15 15 public $task = 'mail'; 16 private $map;17 16 18 17 function init() 19 18 { 20 $this->task = 'mail';21 19 $this->add_hook('message_part_after', array($this, 'replace')); 22 23 $this->map = array(24 '/:\)/' => html::img(array('src' => './program/js/tiny_mce/plugins/emotions/img/smiley-smile.gif', 'title' => ':)')),25 '/:-\)/' => html::img(array('src' => './program/js/tiny_mce/plugins/emotions/img/smiley-smile.gif', 'title' => ':-)')),26 '/(?<!mailto):D/' => html::img(array('src' => './program/js/tiny_mce/plugins/emotions/img/smiley-laughing.gif', 'title' => ':D')),27 '/:-D/' => html::img(array('src' => './program/js/tiny_mce/plugins/emotions/img/smiley-laughing.gif', 'title' => ':-D')),28 '/;\)/' => html::img(array('src' => './program/js/tiny_mce/plugins/emotions/img/smiley-wink.gif', 'title' => ';)')),29 '/;-\)/' => html::img(array('src' => './program/js/tiny_mce/plugins/emotions/img/smiley-wink.gif', 'title' => ';-)')),30 '/:\(/' => html::img(array('src' => './program/js/tiny_mce/plugins/emotions/img/smiley-frown.gif', 'title' => ':(')),31 '/:-\(/' => html::img(array('src' => './program/js/tiny_mce/plugins/emotions/img/smiley-frown.gif', 'title' => ':-(')),32 );33 20 } 34 21 35 22 function replace($args) 36 23 { 24 // This is a lookbehind assertion which will exclude html entities 25 // E.g. situation when ";)" in "")" shouldn't be replaced by the icon 26 // It's so long because of assertion format restrictions 27 $entity = '(?<!&' 28 . '[a-zA-Z0-9]{2}' . '|' . '#[0-9]{2}' . '|' 29 . '[a-zA-Z0-9]{3}' . '|' . '#[0-9]{3}' . '|' 30 . '[a-zA-Z0-9]{4}' . '|' . '#[0-9]{4}' . '|' 31 . '[a-zA-Z0-9]{5}' . '|' 32 . '[a-zA-Z0-9]{6}' . '|' 33 . '[a-zA-Z0-9]{7}' 34 . ')'; 35 36 // map of emoticon replacements 37 $map = array( 38 '/:\)/' => html::img(array( 39 'src' => './program/js/tiny_mce/plugins/emotions/img/smiley-smile.gif', 40 'title' => ':)' 41 )), 42 '/:-\)/' => html::img(array( 43 'src' => './program/js/tiny_mce/plugins/emotions/img/smiley-smile.gif', 44 'title' => ':-)' 45 )), 46 '/(?<!mailto):D/' => html::img(array( 47 'src' => './program/js/tiny_mce/plugins/emotions/img/smiley-laughing.gif', 48 'title' => ':D' 49 )), 50 '/:-D/' => html::img(array( 51 'src' => './program/js/tiny_mce/plugins/emotions/img/smiley-laughing.gif', 52 'title' => ':-D' 53 )), 54 '/:\(/' => html::img(array( 55 'src' => './program/js/tiny_mce/plugins/emotions/img/smiley-frown.gif', 56 'title' => ':(' 57 )), 58 '/:-\(/' => html::img(array( 59 'src' => './program/js/tiny_mce/plugins/emotions/img/smiley-frown.gif', 60 'title' => ':-(' 61 )), 62 '/'.$entity.';\)/' => html::img(array( 63 'src' => './program/js/tiny_mce/plugins/emotions/img/smiley-wink.gif', 64 'title' => ';)' 65 )), 66 '/'.$entity.';-\)/' => html::img(array( 67 'src' => './program/js/tiny_mce/plugins/emotions/img/smiley-wink.gif', 68 'title' => ';-)' 69 )), 70 ); 71 37 72 if ($args['type'] == 'plain') { 38 73 $args['body'] = preg_replace( 39 array_keys($ this->map), array_values($this->map), $args['body']);74 array_keys($map), array_values($map), $args['body']); 40 75 } 76 41 77 return $args; 42 78 }
Note: See TracChangeset
for help on using the changeset viewer.
