1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15:
16: class Horde_Core_Text_Filter_Emails extends Horde_Text_Filter_Emails
17: {
18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32:
33: public function __construct(array $params = array())
34: {
35: $this->_params = array_merge(array(
36: 'always_mailto' => false,
37: 'callback' => null
38: ), $this->_params, $params);
39:
40: parent::__construct($params);
41: }
42:
43: 44: 45: 46: 47: 48: 49:
50: protected function _regexCallback($matches)
51: {
52: if ($this->_params['always_mailto'] ||
53: (!$this->_params['callback'] &&
54: (!($app = $GLOBALS['registry']->hasMethod('mail/compose')) ||
55: !$GLOBALS['registry']->hasPermission($app, Horde_Perms::EDIT)))) {
56: return parent::_regexCallback($matches);
57: }
58:
59: if (!isset($matches[10]) || ($matches[10] === '')) {
60: $args = $matches[7];
61: $email = $matches[3];
62: $args_long = $matches[5];
63: } else {
64: $args = isset($matches[13]) ? $matches[13] : '';
65: $email = $matches[10];
66: $args_long = isset($matches[11]) ? $matches[11] : '';
67: }
68:
69: parse_str($args, $extra);
70: try {
71: $url = $this->_params['callback']
72: ? strval(call_user_func($this->_params['callback'], array('to' => $email), $extra))
73: : strval($GLOBALS['registry']->call('mail/compose', array(array('to' => $email), $extra)));
74: } catch (Horde_Exception $e) {
75: return parent::_regexCallback($matches);
76: }
77:
78: if (substr($url, 0, 11) == 'javascript:') {
79: $href = '#';
80: $onclick = ' onclick="' . substr($url, 11) . ';return false;"';
81: } else {
82: $href = htmlspecialchars($url);
83: $onclick = '';
84: }
85:
86: $class = empty($this->_params['class'])
87: ? ''
88: : ' class="' . $this->_params['class'] . '"';
89:
90: return '<a' . $class .' href="' . $href . '"' . $onclick . '>' .
91: htmlspecialchars($email) . htmlspecialchars($args_long) .
92: '</a>';
93: }
94:
95: }
96: