mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-23 08:23:12 +01:00
add (and use) preg replace callback for mailto link to text transformation
This commit is contained in:
parent
ace203f868
commit
5299db0f05
@ -962,7 +962,9 @@ class translation
|
||||
$text = str_replace("\r\n",'<#cr-lf#>',$text);
|
||||
// replace emailaddresses eclosed in <> (eg.: <me@you.de>) with the emailaddress only (e.g: me@you.de)
|
||||
$text = preg_replace("/(<|<a href=\")*(mailto:([\w\.,-.,_.,0-9.]+)(@)([\w\.,-.,_.,0-9.]+))(>|>)*/ie","'$2 '", $text);
|
||||
$text = preg_replace('~<a[^>]+href=\"(mailto:)+([^"]+)\"[^>]*>~si','$2 ',$text);
|
||||
//$text = preg_replace_callback("/(<|<a href=\")*(mailto:([\w\.,-.,_.,0-9.]+)(@)([\w\.,-.,_.,0-9.]+))(>|>)*/i",'self::transform_mailto2text',$text);
|
||||
//$text = preg_replace('~<a[^>]+href=\"(mailto:)+([^"]+)\"[^>]*>~si','$2 ',$text);
|
||||
$text = preg_replace_callback('~<a[^>]+href=\"(mailto:)+([^"]+)\"[^>]*>([ @\w\.,-.,_.,0-9.]+)<\/a>~si','self::transform_mailto2text',$text);
|
||||
$text = preg_replace("/(([\w\.,-.,_.,0-9.]+)(@)([\w\.,-.,_.,0-9.]+))( |\s)*(<\/a>)*( |\s)*(>|>)*/ie","'$1 '", $text);
|
||||
$text = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/ie","'$2 '", $text);
|
||||
$text = str_replace('<#cr-lf#>',"\r\n",$text);
|
||||
@ -1019,6 +1021,18 @@ class translation
|
||||
}
|
||||
}
|
||||
|
||||
static function transform_mailto2text($matches)
|
||||
{
|
||||
//error_log(__METHOD__.__LINE__.array2string($matches));
|
||||
$linkTextislink = false;
|
||||
// this is the actual url
|
||||
$matches[2] = trim(strip_tags($matches[2]));
|
||||
$matches[3] = trim(strip_tags($matches[3]));
|
||||
$matches[2] = str_replace(array('%40','%20'),array('@',' '),$matches[2]);
|
||||
$matches[3] = str_replace(array('%40','%20'),array('@',' '),$matches[3]);
|
||||
return $matches[1].$matches[2].($matches[2]==$matches[3]?' ':' -> '.$matches[3].' ');
|
||||
}
|
||||
|
||||
static function transform_url2text($matches)
|
||||
{
|
||||
//error_log(__METHOD__.__LINE__.array2string($matches));
|
||||
|
Loading…
Reference in New Issue
Block a user