BBCode Constructor.
bbcode
bbcode
()
Function to handle the processing of nested bbcode [quote] tags within a string.
void
bbcode_quote_handler
( &$output, string $str)
-
string
$str: Passed by reference
-
&$output
Function to convert a string formatted in BBCode [B]xx[/B] into HTML format <strong>xx</strong>.
string
bbcode_to_html
([string $text = ''], [boolean $doamperstand = false])
-
string
$text: text
-
boolean
$doamperstand: do amperstand & conversion? ie: & = & (default false)
Function to convert HTML code into BBCode.
$search = array(
"'<pre>(.*)</pre>'siU",
"'<b>(.*)</b>'siU",
"'<strong>(.*)</strong>'siU",
"'<i>(.*)</i>'siU",
"'<em>(.*)</em>'siU",
"'<u>(.*)</u>'siU",
"'<strike>(.*)</strike>'siU",
"'<p align=\"justify\">(.*)</p>'siU",
"'<div style=\"text-align: left;\">(.*)</div>'siU",
"'<p align=\"left\">(.*)</p>'siU",
"'<div style=\"text-align: center;\">(.*)</div>'siU",
"'<p align=\"center\">(.*)</p>'siU",
"'<div style=\"text-align: right;\">(.*)</div>'siU",
"'<p align=\"right\">(.*)</p>'siU",
"'<blockquote dir=\"ltr\" style=\"margin-right: 0px\">(.*)</blockquote>'siU",
"'<div style=\"margin-left: 40px;\">(.*)</div>'siU",
"'<ol>(.*)</ol>'siU",
"'<ul>(.*)</ul>'siU",
"'<li>(.*)</li>'siU",
"'<img(.*)src=\"([^\"]+)\"(.*)>'siU",
"'<a href=\"mailto:(.*)\">(.*)</a>'siU",
"'<a href=(.*)>(.*)</a>'siU",
"'<font size=(.*)>(.*)</font>'siU",
"'<font face=(.*) size=(.*)>(.*)</font>'siU",
"'<font face=(.*)>(.*)</font>'siU",
"'<font color=(.*) size=(.*)>(.*)</font>'siU",
"'<font color=(.*)>(.*)</font>'siU",
"'<p>(.*)</p>'siU",
"'<div>(.*)</div>'siU",
"'<p />'siU",
"'<(br|br /)>'si",
"'<hr />'siU",
"'<hr style=\"(.*)\">(.*)'siU",
"'<div class=(.*)>(.*)'siU",
"'<div class=\"(.*)\">(.*)'siU",
"'<h(.*)>(.*)</h(.*)>'siU",
);
$replace = array(
"[PHP]$1[/PHP]",
"[B]$1[/B]",
"[B]$1[/B]",
"[I]$1[/I]",
"[I]$1[/I]",
"[U]$1[/U]",
"[STRIKE]$1[/STRIKE]",
"[JUSTIFY]$1[/JUSTIFY]",
"[LEFT]$1[/LEFT]",
"[LEFT]$1[/LEFT]",
"[CENTER]$1[/CENTER]",
"[CENTER]$1[/CENTER]",
"[RIGHT]$1[/RIGHT]",
"[RIGHT]$1[/RIGHT]",
"[INDENT]$1[/INDENT]",
"[INDENT]$1[/INDENT]",
"[list=1]$1[/list]",
"[list=a]$1[/list]",
"[*]$1",
"[IMG]$2[/IMG]",
"[EMAIL=\"$1\"]$2[/EMAIL]",
"[URL=\"$1\"]$2[/URL]",
"[SIZE=\"$1\"]$2[/SIZE]",
"[FONT=\"$1\" SIZE=\"$2\"]$3[/FONT]",
"[FONT=\"$1\"]$2[/FONT]",
"[COLOR=\"$1\" SIZE=\"$2\"]$3[/FONT]",
"[COLOR=\"$1\"]$2[/COLOR]",
"[P]$1[/P]",
"[P]$1[/P]",
"",
"[BR]",
"[HR]",
"[HR]",
"",
"",
"[P][B]$2[/B][/P]",
);
($apihook = $ilance->api('html_to_bbcode_start')) ? eval($apihook) : false;
unset($search, $replace);
$search = array(
"[P][/P]",
"[B][/B]",
"[I][/I]",
"[U][/U]",
"[STRIKE][/STRIKE]",
"[JUSTIFY][/JUSTIFY]",
"[LEFT][/LEFT]",
"[CENTER][/CENTER]",
"[RIGHT][/RIGHT]",
"[INDENT][/INDENT]",
"[TABLE][/TABLE]",
);
$replace = array(
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
);
($apihook = $ilance->api('html_to_bbcode_end')) ? eval($apihook) : false;
unset($search, $replace);
return $text;
}
string
html_to_bbcode
([string $text = ''])
Function to prepare special tags supplied to the function along with any text string.
string
prepare_special_codes
([string $tag = ''], [string $html = ''])
-
string
$tag: tag to match
-
string
$html: text
Function to restore any stripped out special tags.
string
restore_special_codes
([string $tag = ''], array &$text, array &$matches)
-
string
$tag: tag to restore (example: PHP)
-
array
&$text: text
-
array
&$matches: matches text
Function to strip out any BBCode tags within the supplied text string.
string
strip_bb_tags
([string $text = ''])
Function to strip out any HTML tags within the supplied text string.
string
strip_html_tags
([array $matches = array()])
-
array
$matches: matches text
Function to strip out any special tags we provide the function and then have them replaced at the very end. This is useful for stripping out [PHP]xxxx[/PHP] tags so we don't process anything within the [PHP]..[/PHP] tags and other situations that may arise.
string
strip_special_codes
([string $tag = ''], string &$text, array &$matches)
-
string
$tag: tag to strip (example: PHP)
-
string
&$text: text
-
array
&$matches: matches text