Changeset 3807 in subversion
- Timestamp:
- Jul 7, 2010 1:40:32 PM (3 years ago)
- File:
-
- 1 edited
-
trunk/plugins/emoticons/emoticons.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/plugins/emoticons/emoticons.php
r3600 r3807 6 6 * Sample plugin to replace emoticons in plain text message body with real icons 7 7 * 8 * @version 1. 0.18 * @version 1.1.0 9 9 * @author Thomas Bruederli 10 * @author Aleksander Machniak 10 11 * @website http://roundcube.net 11 12 */ 12 13 class emoticons extends rcube_plugin 13 14 { 14 public $task = 'mail';15 private $map;15 public $task = 'mail'; 16 private $map; 16 17 17 function init()18 {19 $this->task = 'mail';20 $this->add_hook('message_part_after', array($this, 'replace'));18 function init() 19 { 20 $this->task = 'mail'; 21 $this->add_hook('message_part_after', array($this, 'replace')); 21 22 22 $this->map = array(23 ':)' => html::img(array('src' => './program/js/tiny_mce/plugins/emotions/img/smiley-smile.gif', 'title' => ':)')),24 ':-)' => html::img(array('src' => './program/js/tiny_mce/plugins/emotions/img/smiley-smile.gif', 'title' => ':-)')),25 ':D'=> html::img(array('src' => './program/js/tiny_mce/plugins/emotions/img/smiley-laughing.gif', 'title' => ':D')),26 ':-D' => html::img(array('src' => './program/js/tiny_mce/plugins/emotions/img/smiley-laughing.gif', 'title' => ':-D')),27 ';)' => html::img(array('src' => './program/js/tiny_mce/plugins/emotions/img/smiley-wink.gif', 'title' => ';)')),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-frown.gif', 'title' => ':(')),30 ':-(' => html::img(array('src' => './program/js/tiny_mce/plugins/emotions/img/smiley-frown.gif', 'title' => ':-(')),31 );32 }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 } 33 34 34 function replace($args) 35 { 36 if ($args['type'] == 'plain') 37 return array('body' => strtr($args['body'], $this->map)); 38 39 return null; 40 } 35 function replace($args) 36 { 37 if ($args['type'] == 'plain') { 38 $args['body'] = preg_replace( 39 array_keys($this->map), array_values($this->map), $args['body']); 40 } 41 return $args; 42 } 41 43 42 44 } 43
Note: See TracChangeset
for help on using the changeset viewer.
