Page 1 of 1

No external Links in comments

Posted: Tue Nov 22, 2005 11:08 am
by Tscherno
URLs in Comments are not clickable for me... But the option is set to make them clickable...

Posted: Tue Nov 22, 2005 11:17 am
by MySchizoBuddy
html inside comments isn't allowed. you will need BBcode and use the [url] tag.

Posted: Tue Nov 22, 2005 11:26 am
by Tscherno
Isn't it possible to automatically make the Links clickable?

Posted: Tue Nov 22, 2005 11:51 am
by garvinhicking
You would need to write a HTTP link code parser. My experience is that it only works in 60% of all cases and does more bad then good by transforming links that are no links.

BBCode is the common way to go.

Regards,
Garvin

Posted: Tue Nov 22, 2005 12:22 pm
by Tscherno
This should it do:
function make_urls($messagetext)
{
var $urlSearchArray, $urlReplaceArray;

$urlSearchArray = array(
"/([^]_a-z0-9-=\"'\/])((https?|ftp|gopher|news|telnet):\/\/|www\.)([^ \r\n\(\)\^\$!`\"'\|\[\]\{\}<>]*)/si",
"/^((https?|ftp|gopher|news|telnet):\/\/|www\.)([^ \r\n\(\)\^\$!`\"'\|\[\]\{\}<>]*)/si"

$urlReplaceArray = array(
'\\1<a href="\\2\\4" target="_blank">\\2\\4</a>',
'<a href="\\1\\3" target="_blank">\\1\\3</a>'
);


$text = preg_replace($urlSearchArray, $urlReplaceArray, $messagetext);

return $text;

}
Should i package it in an textformatting plugin?