3 * Template_Lite bbcode modifier plugin
7 * Purpose: converts special bbcode syntax into standard html
9 * - string: data to convert
11 function tpl_modifier_bbcode2html($data)
13 $data = nl2br(stripslashes(addslashes($data)));
15 $search = array("\n", "\r", "[b]", "[/b]", "[i]", "[/i]", "[u]", "[/u]");
16 $replace = array("", "", "<b>", "</b>", "<i>", "</i>", "<u>", "</u>");
17 $data = str_replace($search, $replace, $data);
20 "/\[email\](.*?)\[\/email\]/si",
21 "/\[email=(.*?)\](.*?)\[\/email\]/si",
22 "/\[url\](.*?)\[\/url\]/si",
23 "/\[url=(.*?)\](.*?)\[\/url\]/si",
24 "/\[img\](.*?)\[\/img\]/si",
25 "/\[code\](.*?)\[\/code\]/si",
26 "/\[pre\](.*?)\[\/pre\]/si",
27 "/\[list\](.*?)\[\/list\]/si",
31 "<a href=\"mailto:\\1\">\\1</a>",
32 "<a href=\"mailto:\\1\">\\2</a>",
33 "<a href=\"\\1\" target=\"_blank\">\\1</a>",
34 "<a href=\"\\1\" target=\"_blank\">\\2</a>",
35 "<img src=\"\\1\" border=\"0\">",
36 "<p><blockquote><font size=\"1\">code:</font><hr noshade size=\"1\"><pre>\\1</pre><br><hr noshade size=\"1\"></blockquote></p>",
41 $data = preg_replace($search, $replace, $data);