commit | author | age
|
60226a
|
1 |
<?php |
TB |
2 |
|
|
3 |
/* |
|
4 |
+-----------------------------------------------------------------------+ |
|
5 |
| program/include/rcmail_string_replacer.php | |
|
6 |
| | |
|
7 |
| This file is part of the Roundcube Webmail client | |
0301d9
|
8 |
| Copyright (C) 2012-2013, The Roundcube Dev Team | |
60226a
|
9 |
| | |
TB |
10 |
| Licensed under the GNU General Public License version 3 or | |
|
11 |
| any later version with exceptions for skins & plugins. | |
|
12 |
| See the README file for a full license statement. | |
|
13 |
| | |
|
14 |
| PURPOSE: | |
|
15 |
| Turn URLs and email addresses into clickable links | |
|
16 |
| | |
|
17 |
+-----------------------------------------------------------------------+ |
|
18 |
| Author: Thomas Bruederli <roundcube@gmail.com> | |
|
19 |
+-----------------------------------------------------------------------+ |
|
20 |
*/ |
|
21 |
|
|
22 |
/** |
|
23 |
* Helper class for turning URLs and email addresses in plaintext content |
|
24 |
* into clickable links. |
|
25 |
* |
9ba496
|
26 |
* @package Webmail |
60226a
|
27 |
* @subpackage Utils |
TB |
28 |
*/ |
|
29 |
class rcmail_string_replacer extends rcube_string_replacer |
|
30 |
{ |
|
31 |
/** |
|
32 |
* Callback function used to build mailto: links around e-mail strings |
|
33 |
* |
|
34 |
* This also adds an onclick-handler to open the Rouncube compose message screen on such links |
|
35 |
* |
|
36 |
* @param array Matches result from preg_replace_callback |
|
37 |
* @return int Index of saved string value |
|
38 |
* @see rcube_string_replacer::mailto_callback() |
|
39 |
*/ |
|
40 |
public function mailto_callback($matches) |
|
41 |
{ |
0301d9
|
42 |
$href = $matches[1]; |
AM |
43 |
$suffix = $this->parse_url_brackets($href); |
60226a
|
44 |
|
0301d9
|
45 |
$i = $this->add(html::a(array( |
AM |
46 |
'href' => 'mailto:' . $href, |
|
47 |
'onclick' => "return ".rcmail_output::JS_OBJECT_NAME.".command('compose','".rcube::JQ($href)."',this)", |
|
48 |
), |
|
49 |
rcube::Q($href)) . $suffix); |
60226a
|
50 |
|
0301d9
|
51 |
return $i >= 0 ? $this->get_replacement($i) : ''; |
60226a
|
52 |
} |
0301d9
|
53 |
} |