Regular expression callback.
protected _regexCallback ( array $matches ) : string | ||
$matches | array | preg_replace_callback() matches. See regex above for description of matching data. |
Результат | string | Replacement string. |
/** * Regular expression callback. * * @param array $matches preg_replace_callback() matches. * * @return string Replacement string. */ protected function _regexCallback($matches) { if ($this->_params['always_mailto'] || !$this->_params['callback'] && (!($app = $GLOBALS['registry']->hasMethod('mail/compose')) || !$GLOBALS['registry']->hasPermission($app, Horde_Perms::EDIT))) { return parent::_regexCallback($matches); } if (!isset($matches[10]) || $matches[10] === '') { $args = $matches[7]; $email = $matches[3]; $args_long = $matches[5]; } else { $args = isset($matches[13]) ? $matches[13] : ''; $email = $matches[10]; $args_long = isset($matches[11]) ? $matches[11] : ''; } parse_str($args, $extra); try { $url = $this->_params['callback'] ? strval(call_user_func($this->_params['callback'], array('to' => $email), $extra)) : strval($GLOBALS['registry']->call('mail/compose', array(array('to' => $email), $extra))); } catch (Horde_Exception $e) { return parent::_regexCallback($matches); } if (substr($url, 0, 11) == 'javascript:') { $href = '#'; $onclick = ' onclick="' . htmlspecialchars(substr($url, 11)) . ';return false;"'; } else { $href = htmlspecialchars($url); $onclick = ''; } $class = empty($this->_params['class']) ? '' : ' class="' . $this->_params['class'] . '"'; return '<a' . $class . ' href="' . $href . '"' . $onclick . '>' . htmlspecialchars($email) . htmlspecialchars($args_long) . '</a>'; }