return $text;\r
}\r
\r
+ // remove the spaces in [media] tag, otherwise, the next line converts URL inside [media] into <a> tag\r
+ $text = preg_replace("/(\[media\])([\s]*)(.*)(\[\/media\])/", '$1$3$4', $text);\r
+ $text = preg_replace("/(\[media\])(.*)([\s]*)(\[\/media\])/U", '$1$2$4', $text);\r
+ \r
$media_matches = Array();\r
\r
/*\r
}\r
}\r
\r
- $text = ContentUtility::embedFLV($text);\r
- \r
return $text;\r
}\r
\r
- private static function makeClickable($text) {\r
+ public static function makeClickable($text) {\r
$text = ContentUtility::embedMedia($text);\r
\r
- // $text = eregi_replace("([[:space:]])(http[s]?)://([^[:space:]<]*)([[:alnum:]#?/&=])", "\\1<a href=\"\\2://\\3\\4\">\\3\\4</a>", $text);\r
- //\r
- // $text = eregi_replace( '([_a-zA-Z0-9\-]+(\.[_a-zA-Z0-9\-]+)*'.\r
- // '\@'.'[_a-zA-Z0-9\-]+(\.[_a-zA-Z0-9\-]+)*'.'(\.[a-zA-Z]{1,6})+)',\r
- // "<a href=\"mailto:\\1\">\\1</a>",\r
- // $text);\r
- \r
- $text = preg_replace("/([\s])(http[s]?):\/\/(.*)(\s|\$|<br\s\/\>)(.*)/U", \r
- "\\1<a href=\"\\2://\\3\">\\3</a>\\4\\5", $text);\r
- \r
- $text = preg_replace('/([_a-zA-Z0-9\-]+(\.[_a-zA-Z0-9\-]+)*'.\r
- '\@'.'[_a-zA-Z0-9\-]+(\.[_a-zA-Z0-9\-]+)*'.'(\.[a-zA-Z]{1,6})+)/i',\r
- "<a href=\"mailto:\\1\">\\1</a>",\r
+ // convert plain text URL to clickable URL.\r
+ // Limited conversion: It doesn't cover the case when the stuff in front of the URL is not a word. For example:\r
+ // <p>http://google.ca</p>\r
+ // "http://google.ca" \r
+ $text = preg_replace('/(^|[\n ])([\w]*?[\"]*)((?<!(\[media\]))http(s)?:\/\/[\w]+[^ \,\"\n\r\t\)<]*)/is', \r
+ '$1$2<a href="$3">$3</a>', $text);\r
+ \r
+ // convert email address to clickable URL that pops up "send email" interface with the address filled in\r
+ $text = preg_replace('/(?|<a href="mailto[\s]*:[\s]*([_a-zA-Z0-9\-]+(\.[_a-zA-Z0-9\-]+)*'.'\@'\r
+ .'[_a-zA-Z0-9\-]+(\.[_a-zA-Z0-9\-]+)*'.'(\.[a-zA-Z]{1,6})+)">(.*)<\/a>'\r
+ .'|((((([_a-zA-Z0-9\-]+(\.[_a-zA-Z0-9\-]+)*'.'\@'\r
+ .'[_a-zA-Z0-9\-]+(\.[_a-zA-Z0-9\-]+)*'.'(\.[a-zA-Z]{1,6})+))))))/i',\r
+ "<a href=\"mailto:\\1\">\\5</a>",\r
$text);\r
+ \r
+ // flv conversion needs to come after url conversion (2 lines above) otherwise the url to flowplayer swf file\r
+ // in the script for a.flowplayerholder is converted\r
+ $text = ContentUtility::embedFLV($text);\r
+ \r
return $text;\r
}\r
\r
- private static function myCodes($text, $html = false) {\r
+ public static function myCodes($text, $html = false) {\r
global $_base_path;\r
global $HTTP_USER_AGENT;\r
\r
$text = str_replace("[code]","[code]<?php",$text);\r
$text = str_replace("[/code]","?>[/code]",$text);\r
\r
- $text = preg_replace("/\[code\]\s*(.*)\s*\[\\/code\]/Usei", "highlight_code(fix_quotes('\\1'), $html)", $text);\r
+ $text = preg_replace("/\[code\]\s*(.*)\s*\[\\/code\]/Usei", "ContentUtility::highlightCode(ContentUtility::fixQuotes('\\1'), $html)", $text);\r
// now remove the <?php added above and leave the syntax colour behind.\r
$text = str_replace("<?php", "", $text);\r
$text = str_replace("?>", "", $text);\r
return $text;\r
}\r
\r
- private static function imageReplace($text) {\r
+ /* contributed by Thomas M. Duffey <tduffey at homeboyz.com> */\r
+ private static function highlightCode($code, $html) {\r
+ // XHTMLize PHP highlight_string output until it gets fixed in PHP\r
+ static $search = array(\r
+ '<br>',\r
+ '<font',\r
+ '</font>',\r
+ 'color="');\r
+ \r
+ static $replace = array(\r
+ '<br />',\r
+ '<span',\r
+ '</span>',\r
+ 'style="color:');\r
+ if (!$html) {\r
+ $code = str_replace('<', '<', $code);\r
+ $code = str_replace("\r", '', $code);\r
+ }\r
+ \r
+ return str_replace($search, $replace, highlight_string($code, true));\r
+ }\r
+ \r
+ /* contributed by Thomas M. Duffey <tduffey at homeboyz.com> */\r
+ private static function fixQuotes($text){\r
+ return str_replace('\\"', '"', $text);\r
+ }\r
+\r
+ public static function imageReplace($text) {\r
/* image urls do not require http:// */\r
\r
// $text = eregi_replace("\[image(\|)?([[:alnum:][:space:]]*)\]" .\r