
manson13 - 2007-06-11 13:42:43
if you add this lines in the beginning of parse_bbcode() function (after if(!is_array($tag_data))...), you can parse constructions like:
[url]http://test.com[/url] => <a href="http://test.com">http://test.com</a>
[img]1.gif[/img] => <img src="1.gif" />
if($tagdata['BodyAsParam']) { // added by manson
$startfind = "/\[{$tagdata['Name']}\]((.|\s)+)\[\/{$tagdata['Name']}\]/";
$replace = str_replace(array('%%P%%','%%p%%'),'$1',$tagdata['HtmlBegin']);
$sep = $tagdata['IgnoreBody'] ? '':'$1';
$replace .= $sep . $tagdata['HtmlEnd'];
$text = preg_replace($startfind,$replace,$text);
continue;
}
Definitions for these new constructions will be:
$bbcode=new bbcode();
$bbcode->add_tag(array('Name'=>'url','BodyAsParam'=>true,'HtmlBegin'=>'<a href="%%P%%">','HtmlEnd'=>'</a>'));
$bbcode->add_tag(array('Name'=>'img','BodyAsParam'=>true,'IgnoreBody'=>true,'HtmlBegin'=>'<img src="%%P%%" />','HtmlEnd'=>''));
P.S: Sorry for my bad English :)