Improve link highlight for links in messages if bbcode
This commit is contained in:
parent
74f3307f26
commit
fb7a7d6f4c
@ -880,15 +880,20 @@ function html_parse($text) {
|
|||||||
// split every line into it's words
|
// split every line into it's words
|
||||||
$words=explode(" ",$text);
|
$words=explode(" ",$text);
|
||||||
$n=count($words);
|
$n=count($words);
|
||||||
|
$is_link = 0;
|
||||||
for($i=0; $i<$n; $i++) {
|
for($i=0; $i<$n; $i++) {
|
||||||
$word=$words[$i];
|
$word=$words[$i];
|
||||||
if(preg_match('/(https?|ftp|news|gopher|telnet)\:\/\/[^\",]+/i', $word)) {
|
if(preg_match('/(https?|ftp|news|gopher|telnet)\:\/\/[^\",]+/i', $word)) {
|
||||||
|
$is_link = 1;
|
||||||
$nlink = trim($word, '().,');
|
$nlink = trim($word, '().,');
|
||||||
$nlink = preg_replace('/(\<|\>|\ );/', '', $nlink);
|
$nlink = preg_replace('/(\<|\>|\ );/', '', $nlink);
|
||||||
$nlink = preg_replace('/\[url=/', '', $nlink);
|
$nlink = preg_replace('/\[url=/', '', $nlink);
|
||||||
$bbnlink = explode(']', $nlink);
|
$bbnlink = explode(']', $nlink);
|
||||||
$nlink = $bbnlink[0];
|
$nlink = $bbnlink[0];
|
||||||
$nword = '<a '.$target.' href="'.$nlink.'">'.$word.'</a>';
|
$nword = '<a '.$target.' href="'.$nlink.'">'.$nlink.'</a>';
|
||||||
|
if(isset($bbnlink[1])) {
|
||||||
|
$nword.=' '.$bbnlink[1];
|
||||||
|
}
|
||||||
if($nword!=$word && substr($nlink, strlen($nlink) - 3) != "://") {
|
if($nword!=$word && substr($nlink, strlen($nlink) - 3) != "://") {
|
||||||
$word=$nword;
|
$word=$nword;
|
||||||
}
|
}
|
||||||
@ -896,6 +901,9 @@ function html_parse($text) {
|
|||||||
// add the spaces between the words
|
// add the spaces between the words
|
||||||
if($i>0)
|
if($i>0)
|
||||||
$ntext.=" ";
|
$ntext.=" ";
|
||||||
|
if($is_link) {
|
||||||
|
$word = preg_replace('/\[\/url\]/', '', $word);
|
||||||
|
}
|
||||||
$ntext.=$word;
|
$ntext.=$word;
|
||||||
}
|
}
|
||||||
return($ntext);
|
return($ntext);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user