예제 #1
0
 public static function makeClickable($text)
 {
     $text = ContentUtility::embedMedia($text);
     // convert plain text URL to clickable URL.
     // Limited conversion: It doesn't cover the case when the stuff in front of the URL is not a word. For example:
     // <p>http://google.ca</p>
     // "http://google.ca"
     $text = preg_replace('/(^|[\\n ])([\\w]*?)((?<!(\\[media\\]))http(s)?:\\/\\/[\\w]+[^ \\,\\"\\n\\r\\t\\)<]*)/is', '$1$2<a href="$3">$3</a>', $text);
     // convert email address to clickable URL that pops up "send email" interface with the address filled in
     $text = preg_replace('/(?|<a href="mailto[\\s]*:[\\s]*([_a-zA-Z0-9\\-]+(\\.[_a-zA-Z0-9\\-]+)*' . '\\@' . '[_a-zA-Z0-9\\-]+(\\.[_a-zA-Z0-9\\-]+)*' . '(\\.[a-zA-Z]{1,6})+)">(.*)<\\/a>' . '|((((([_a-zA-Z0-9\\-]+(\\.[_a-zA-Z0-9\\-]+)*' . '\\@' . '[_a-zA-Z0-9\\-]+(\\.[_a-zA-Z0-9\\-]+)*' . '(\\.[a-zA-Z]{1,6})+))))))/i', "<a href=\"mailto:\\1\">\\5</a>", $text);
     // flv conversion needs to come after url conversion (2 lines above) otherwise the url to flowplayer swf file
     // in the script for a.flowplayerholder is converted
     $text = ContentUtility::embedFLV($text);
     return $text;
 }