开发者

bbcode to html in vbulletin

开发者 https://www.devze.com 2023-03-31 06:30 出处:网络
What is the function in vbulletin that convert bbcode to html ?? I found this : convert_wysiwyg_html_to_bbcode() but it\'s convert html to bbcode, I want the oppos开发者_高级运维ite of this function.

What is the function in vbulletin that convert bbcode to html ??

I found this : convert_wysiwyg_html_to_bbcode() but it's convert html to bbcode, I want the oppos开发者_高级运维ite of this function.


I have recently used this bb2html parser to convert calendar events from vBulletin to another platform.

vBulletin uses a class vB_BbCodeParser to do its conversions. In my old vBulletin installation, that is in includes/class_bbcode.php


You can do this by replacing bbcode with corresponding html tags by using str_replace

function bb2html($text)
{
  $bbcode = array("<", ">",
                "[list]", "[*]", "[/list]", 
                "[img]", "[/img]", 
                "[b]", "[/b]", 
                "[u]", "[/u]", 
                "[i]", "[/i]",
                '[color="', "[/color]",
                "[size=\"", "[/size]",
                '[url="', "[/url]",
                "[mail=\"", "[/mail]",
                "[code]", "[/code]",
                "[quote]", "[/quote]",
                '"]');
  $htmlcode = array("&lt;", "&gt;",
                "<ul>", "<li>", "</ul>", 
                "<img src=\"", "\">", 
                "<b>", "</b>", 
                "<u>", "</u>", 
                "<i>", "</i>",
                "<span style=\"color:", "</span>",
                "<span style=\"font-size:", "</span>",
                '<a href="', "</a>",
                "<a href=\"mailto:", "</a>",
                "<code>", "</code>",
                "<table width=100% bgcolor=lightgray><tr><td bgcolor=white>", "</td></tr></table>",
                '">');
  $newtext = str_replace($bbcode, $htmlcode, $text);
  $newtext = nl2br($newtext);//second pass
  return $newtext;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消