| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | /** |
|---|
| 4 | * Display Emoticons |
|---|
| 5 | * |
|---|
| 6 | * Sample plugin to replace emoticons in plain text message body with real icons |
|---|
| 7 | * |
|---|
| 8 | * @version 1.1.0 |
|---|
| 9 | * @author Thomas Bruederli |
|---|
| 10 | * @author Aleksander Machniak |
|---|
| 11 | * @website http://roundcube.net |
|---|
| 12 | */ |
|---|
| 13 | class emoticons extends rcube_plugin |
|---|
| 14 | { |
|---|
| 15 | public $task = 'mail'; |
|---|
| 16 | private $map; |
|---|
| 17 | |
|---|
| 18 | function init() |
|---|
| 19 | { |
|---|
| 20 | $this->task = 'mail'; |
|---|
| 21 | $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 | } |
|---|
| 34 | |
|---|
| 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 | } |
|---|
| 43 | |
|---|
| 44 | } |
|---|