BBCodeParser
in package
Uses
BackwardCompatibility
Parses Bulletin Board Code in a string and converts it to HTML.
The recommended way to use this class to parse BBCode in a string is:
$parsed_string = BBCodeParser::load()->parse($unparsed_string);
Calling the load() method like this will save on memory by reusing a single instance of the BBCodeParser class. However, if you need more control over the parser, you can always instantiate a new one.
The recommended way to get a list of supported BBCodes is:
$codes = BBCodeParser::getCodes();
Calling the getCodes() method is better than reading BBCodeParser::$codes directly, because the results of the method will include any BBC added by mods, whereas BBCodeParser::$codes will not.
The following integration hooks are called during object construction:
integrate_bbc_codes (Used to add or modify BBC)
integrate_smileys (Used for alternative smiley handling)
integrate_autolinker_schemes (Used by the autolinker)
The following integration hooks are called during parsing:
integrate_pre_parsebbc (Allows adjustments before parsing)
integrate_post_parsebbc (Gives access to results of parsing)
integrate_attach_bbc_validate (Adjusts HTML produced by the attach BBC)
integrate_bbc_print (For BBC that need special handling in
print mode)
Table of Contents
Properties
- $autolink_enabled : bool
- $basic_tlds : array<string|int, mixed>
- $codes : array<string|int, mixed>
- $custom_smileys_enabled : bool
- $disabled : array<string|int, mixed>
- $domain_label_chars : string
- $enable_bbc : bool
- $enable_post_html : bool
- $encoding : string
- $excluded_trailing_chars : string
- $for_print : bool
- $itemcodes : array<string|int, mixed>
- $locale : string
- $no_autolink_tags : array<string|int, mixed>
- $parse_tags : array<string|int, mixed>
- $schemes : array<string|int, mixed>
- $smiley_set : string
- $smileys : bool
- $smileys_url : string
- $time_format : string
- $time_offset : int
- $utf8 : bool
- $alltags_regex : string
- $email_regex : string
- $smiley_preg_replacements : array<string|int, mixed>
- $smiley_preg_search : string
- $tld_regex : string
- $url_regex : string
- $backcompat : array<string|int, mixed>
- $bbc_codes : array<string|int, mixed>
- $bbc_lang_locales : array<string|int, mixed>
- $cache_key_extras : array<string|int, mixed>
- $hosturl : string
- $inside : string
- $integrate_bbc_codes_done : bool
- $last_pos : int
- $message : string
- $open_tags : array<string|int, mixed>
- $parser : object
- $placeholder_template : string
- $placeholders : array<string|int, mixed>
- $placeholders_counter : int
- $pos : int
- $pos1 : int
- $results : array<string|int, mixed>
Methods
- __construct() : object
- Constructor.
- attachValidate() : void
- Validation method for the attach BBCode.
- backcompatParseBbc() : string|array<string|int, mixed>
- Backward compatibility wrapper for parse() and/or getCodes().
- backcompatParseSmileys() : mixed
- Backward compatibility wrapper for parseSmileys().
- codeValidate() : void
- Validation method for the code BBCode.
- emailValidate() : void
- Validation method for the email BBCode.
- exportStatic() : void
- Provides a way to export a class's public static properties and methods to global namespace.
- flashValidate() : void
- Validation method for the flash BBCode.
- floatValidate() : void
- Validation method for the float BBCode.
- ftpValidate() : void
- Validation method for the ftp BBCode.
- getCodes() : array<string|int, mixed>
- Get the list of supported BBCodes, including any added by modifications.
- getSigTags() : array<string|int, mixed>
- Returns an array of BBC tags that are allowed in signatures.
- highlightPhpCode() : string
- Highlight any code.
- htmlToBbc() : string
- Backward compatibility wrapper for unparse().
- imgValidate() : void
- Validation method for the img BBCode.
- load() : object
- Returns a reusable instance of this class.
- parse() : string
- Parse bulletin board code in a string, as well as smileys optionally.
- parseSmileys() : string
- Parse smileys in the passed message.
- phpValidate() : void
- Validation method for the php BBCode.
- sanitizeMSCutPaste() : string
- Microsoft uses their own character set Code Page 1252 (CP1252), which is a superset of ISO 8859-1, defining several characters between DEC 128 and 159 that are not normally displayable. This converts the popular ones that appear from a cut and paste from Windows.
- shadowValidate() : void
- Validation method for the shadow BBCode.
- sizeValidate() : void
- Validation method for the size BBCode.
- timeValidate() : void
- Validation method for the time BBCode.
- unparse() : string
- Converts HTML to BBC.
- urlValidate() : void
- Validation method for the url and iurl BBCodes.
- autoLink() : string
- Detects plain text URLs and formats them as BBCode links.
- closeInlineTags() : void
- Similar to $this->closeTags(), but only for inline tags.
- closeTags() : void
- Ensures BBCode markup is well-formed by auto-closing nested tags in the correct order.
- detectTag() : array<string|int, mixed>
- Figures out which BBCode the current tag is.
- fetchTagAttributes() : array<string|int, mixed>
- Helper for unparse().
- fixHtml() : string
- Fixes up any raw HTML in a BBCode string.
- highLoadAverage() : bool
- Checks whether the server's load average is too high to parse BBCode.
- insertTxt() : string
- Replaces {txt_*} tokens with Lang::$txt strings.
- integrateBBC() : void
- Wrapper for the integrate_bbc_codes hook.
- legalise() : string
- Helper for unparse().
- parseItemCode() : void
- Parses itemcodes into normal list items.
- parseMessage() : void
- The method that actually parses the BBCode in $this->message.
- resetRuntimeProperties() : void
- Resets certain runtime properties to their default values.
- setAllTagsRegex() : void
- Sets $this->alltags_regex.
- setBbcCodes() : void
- Sets $this->bbc_codes.
- setDisabled() : void
- Sets $this->disabled.
- setEmailRegex() : void
- Sets $this->email_regex.
- setTldRegex() : void
- Sets $this->tld_regex.
- setUrlRegex() : void
- Sets $this->url_regex.
- transformToHtml() : void
- Transforms a BBCode tag into HTML.
- useDisabledTag() : array<string|int, mixed>
- Adjusts a tag definition so that it uses its disabled version for output.
Properties
$autolink_enabled
public
bool
$autolink_enabled
Whether to autolink plain text URLs.
$basic_tlds
public
static array<string|int, mixed>
$basic_tlds
= ['com', 'net', 'org', 'edu', 'gov', 'mil', 'aero', 'asia', 'biz', 'cat', 'coop', 'info', 'int', 'jobs', 'mobi', 'museum', 'name', 'post', 'pro', 'tel', 'travel', 'xxx', 'ac', 'ad', 'ae', 'af', 'ag', 'ai', 'al', 'am', 'ao', 'aq', 'ar', 'as', 'at', 'au', 'aw', 'ax', 'az', 'ba', 'bb', 'bd', 'be', 'bf', 'bg', 'bh', 'bi', 'bj', 'bm', 'bn', 'bo', 'br', 'bs', 'bt', 'bv', 'bw', 'by', 'bz', 'ca', 'cc', 'cd', 'cf', 'cg', 'ch', 'ci', 'ck', 'cl', 'cm', 'cn', 'co', 'cr', 'cu', 'cv', 'cx', 'cy', 'cz', 'de', 'dj', 'dk', 'dm', 'do', 'dz', 'ec', 'ee', 'eg', 'er', 'es', 'et', 'eu', 'fi', 'fj', 'fk', 'fm', 'fo', 'fr', 'ga', 'gb', 'gd', 'ge', 'gf', 'gg', 'gh', 'gi', 'gl', 'gm', 'gn', 'gp', 'gq', 'gr', 'gs', 'gt', 'gu', 'gw', 'gy', 'hk', 'hm', 'hn', 'hr', 'ht', 'hu', 'id', 'ie', 'il', 'im', 'in', 'io', 'iq', 'ir', 'is', 'it', 'je', 'jm', 'jo', 'jp', 'ke', 'kg', 'kh', 'ki', 'km', 'kn', 'kp', 'kr', 'kw', 'ky', 'kz', 'la', 'lb', 'lc', 'li', 'lk', 'lr', 'ls', 'lt', 'lu', 'lv', 'ly', 'ma', 'mc', 'md', 'me', 'mg', 'mh', 'mk', 'ml', 'mm', 'mn', 'mo', 'mp', 'mq', 'mr', 'ms', 'mt', 'mu', 'mv', 'mw', 'mx', 'my', 'mz', 'na', 'nc', 'ne', 'nf', 'ng', 'ni', 'nl', 'no', 'np', 'nr', 'nu', 'nz', 'om', 'pa', 'pe', 'pf', 'pg', 'ph', 'pk', 'pl', 'pm', 'pn', 'pr', 'ps', 'pt', 'pw', 'py', 'qa', 're', 'ro', 'rs', 'ru', 'rw', 'sa', 'sb', 'sc', 'sd', 'se', 'sg', 'sh', 'si', 'sj', 'sk', 'sl', 'sm', 'sn', 'so', 'sr', 'ss', 'st', 'su', 'sv', 'sx', 'sy', 'sz', 'tc', 'td', 'tf', 'tg', 'th', 'tj', 'tk', 'tl', 'tm', 'tn', 'to', 'tr', 'tt', 'tv', 'tw', 'tz', 'ua', 'ug', 'uk', 'us', 'uy', 'uz', 'va', 'vc', 've', 'vg', 'vi', 'vn', 'vu', 'wf', 'ws', 'ye', 'yt', 'za', 'zm', 'zw']
The 2012 list of top level domains.
$codes
public
static array<string|int, mixed>
$codes
= [
['tag' => 'abbr', 'type' => 'unparsed_equals', 'before' => '<abbr title="$1">', 'after' => '</abbr>', 'quoted' => 'optional', 'disabled_after' => ' ($1)'],
// Legacy (and just an alias for [abbr] even when enabled)
['tag' => 'acronym', 'type' => 'unparsed_equals', 'before' => '<abbr title="$1">', 'after' => '</abbr>', 'quoted' => 'optional', 'disabled_after' => ' ($1)'],
['tag' => 'anchor', 'type' => 'unparsed_equals', 'test' => '[#]?([A-Za-z][A-Za-z0-9_\\-]*)\\]', 'before' => '<span id="post_$1">', 'after' => '</span>'],
['tag' => 'attach', 'type' => 'unparsed_content', 'parameters' => ['id' => ['match' => '(\\d+)'], 'alt' => ['optional' => true], 'width' => ['optional' => true, 'match' => '(\\d+)'], 'height' => ['optional' => true, 'match' => '(\\d+)'], 'display' => ['optional' => true, 'match' => '(link|embed)']], 'content' => '$1', 'validate' => __CLASS__ . '::attachValidate'],
['tag' => 'b', 'before' => '<b>', 'after' => '</b>'],
// Legacy (equivalent to [ltr] or [rtl])
['tag' => 'bdo', 'type' => 'unparsed_equals', 'before' => '<bdo dir="$1">', 'after' => '</bdo>', 'test' => '(rtl|ltr)\\]', 'block_level' => true],
// Legacy (alias of [color=black])
['tag' => 'black', 'before' => '<span style="color: black;" class="bbc_color">', 'after' => '</span>'],
// Legacy (alias of [color=blue])
['tag' => 'blue', 'before' => '<span style="color: blue;" class="bbc_color">', 'after' => '</span>'],
['tag' => 'br', 'type' => 'closed', 'content' => '<br>'],
['tag' => 'center', 'before' => '<div class="centertext"><div class="inline-block">', 'after' => '</div></div>', 'block_level' => true],
['tag' => 'code', 'type' => 'unparsed_content', 'content' => '<div class="codeheader"><span class="code">{txt_code}</span> <a class="codeoperation smf_select_text">{txt_code_select}</a> <a class="codeoperation smf_expand_code hidden" data-shrink-txt="{txt_code_shrink}" data-expand-txt="{txt_code_expand}">{txt_code_expand}</a></div><code class="bbc_code">$1</code>', 'validate' => __CLASS__ . '::codeValidate', 'block_level' => true],
['tag' => 'code', 'type' => 'unparsed_equals_content', 'content' => '<div class="codeheader"><span class="code">{txt_code}</span> ($2) <a class="codeoperation smf_select_text">{txt_code_select}</a> <a class="codeoperation smf_expand_code hidden" data-shrink-txt="{txt_code_shrink}" data-expand-txt="{txt_code_expand}">{txt_code_expand}</a></div><code class="bbc_code">$1</code>', 'validate' => __CLASS__ . '::codeValidate', 'block_level' => true],
['tag' => 'color', 'type' => 'unparsed_equals', 'test' => '(#[\\da-fA-F]{3}|#[\\da-fA-F]{6}|[A-Za-z]{1,20}|rgb\\((?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\s?,\\s?){2}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\))\\]', 'before' => '<span style="color: $1;" class="bbc_color">', 'after' => '</span>'],
['tag' => 'email', 'type' => 'unparsed_content', 'content' => '<a href="mailto:$1" class="bbc_email">$1</a>', 'validate' => __CLASS__ . '::emailValidate'],
['tag' => 'email', 'type' => 'unparsed_equals', 'before' => '<a href="mailto:$1" class="bbc_email">', 'after' => '</a>', 'disallow_children' => ['email', 'ftp', 'url', 'iurl'], 'disabled_after' => ' ($1)'],
// Legacy (and just a link even when not disabled)
['tag' => 'flash', 'type' => 'unparsed_commas_content', 'test' => '\\d+,\\d+\\]', 'content' => '<a href="$1" target="_blank" rel="noopener">$1</a>', 'validate' => __CLASS__ . '::flashValidate'],
['tag' => 'float', 'type' => 'unparsed_equals', 'test' => '(left|right)(\\s+max=\\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)?\\]', 'before' => '<div $1>', 'after' => '</div>', 'validate' => __CLASS__ . '::floatValidate', 'trim' => 'outside', 'block_level' => true],
// Legacy (alias of [url] with an FTP URL)
['tag' => 'ftp', 'type' => 'unparsed_content', 'content' => '<a href="$1" class="bbc_link" target="_blank" rel="noopener">$1</a>', 'validate' => __CLASS__ . '::ftpValidate'],
// Legacy (alias of [url] with an FTP URL)
['tag' => 'ftp', 'type' => 'unparsed_equals', 'before' => '<a href="$1" class="bbc_link" target="_blank" rel="noopener">', 'after' => '</a>', 'validate' => __CLASS__ . '::ftpValidate', 'disallow_children' => ['email', 'ftp', 'url', 'iurl'], 'disabled_after' => ' ($1)'],
['tag' => 'font', 'type' => 'unparsed_equals', 'test' => '[A-Za-z0-9_,\\-\\s]+?\\]', 'before' => '<span style="font-family: $1;" class="bbc_font">', 'after' => '</span>'],
// Legacy (one of those things that should not be done)
['tag' => 'glow', 'type' => 'unparsed_commas', 'test' => '[#0-9a-zA-Z\\-]{3,12},([012]\\d{1,2}|\\d{1,2})(,[^]]+)?\\]', 'before' => '<span style="text-shadow: $1 1px 1px 1px">', 'after' => '</span>'],
// Legacy (alias of [color=green])
['tag' => 'green', 'before' => '<span style="color: green;" class="bbc_color">', 'after' => '</span>'],
['tag' => 'html', 'type' => 'unparsed_content', 'content' => '<div>$1</div>', 'block_level' => true, 'disabled_content' => '$1'],
['tag' => 'hr', 'type' => 'closed', 'content' => '<hr>', 'block_level' => true],
['tag' => 'i', 'before' => '<i>', 'after' => '</i>'],
['tag' => 'img', 'type' => 'unparsed_content', 'parameters' => ['alt' => ['optional' => true], 'title' => ['optional' => true], 'width' => ['optional' => true, 'value' => ' width="$1"', 'match' => '(\\d+)'], 'height' => ['optional' => true, 'value' => ' height="$1"', 'match' => '(\\d+)']], 'content' => '$1', 'validate' => __CLASS__ . '::imgValidate', 'disabled_content' => '($1)'],
['tag' => 'iurl', 'type' => 'unparsed_content', 'content' => '<a href="$1" class="bbc_link">$1</a>', 'validate' => __CLASS__ . '::urlValidate'],
['tag' => 'iurl', 'type' => 'unparsed_equals', 'quoted' => 'optional', 'before' => '<a href="$1" class="bbc_link">', 'after' => '</a>', 'validate' => __CLASS__ . '::urlValidate', 'disallow_children' => ['email', 'ftp', 'url', 'iurl'], 'disabled_after' => ' ($1)'],
['tag' => 'justify', 'before' => '<div class="justifytext">', 'after' => '</div>', 'block_level' => true],
['tag' => 'left', 'before' => '<div class="lefttext">', 'after' => '</div>', 'block_level' => true],
['tag' => 'li', 'before' => '<li>', 'after' => '</li>', 'trim' => 'outside', 'require_parents' => ['list'], 'block_level' => true, 'disabled_before' => '', 'disabled_after' => '<br>'],
['tag' => 'list', 'before' => '<ul class="bbc_list">', 'after' => '</ul>', 'trim' => 'inside', 'require_children' => ['li', 'list'], 'block_level' => true],
['tag' => 'list', 'parameters' => ['type' => ['match' => '(none|disc|circle|square|decimal|decimal-leading-zero|lower-roman|upper-roman|lower-alpha|upper-alpha|lower-greek|upper-greek|lower-latin|upper-latin|hebrew|armenian|georgian|cjk-ideographic|hiragana|katakana|hiragana-iroha|katakana-iroha)']], 'before' => '<ul class="bbc_list" style="list-style-type: {type};">', 'after' => '</ul>', 'trim' => 'inside', 'require_children' => ['li'], 'block_level' => true],
['tag' => 'ltr', 'before' => '<bdo dir="ltr">', 'after' => '</bdo>', 'block_level' => true],
['tag' => 'me', 'type' => 'unparsed_equals', 'before' => '<div class="meaction">* $1 ', 'after' => '</div>', 'quoted' => 'optional', 'block_level' => true, 'disabled_before' => '/me ', 'disabled_after' => '<br>'],
['tag' => 'member', 'type' => 'unparsed_equals', 'before' => '<a href="{scripturl}?action=profile;u=$1" class="mention" data-mention="$1">@', 'after' => '</a>'],
// Legacy (horrible memories of the 1990s)
['tag' => 'move', 'before' => '<marquee>', 'after' => '</marquee>', 'block_level' => true, 'disallow_children' => ['move']],
['tag' => 'nobbc', 'type' => 'unparsed_content', 'content' => '$1'],
['tag' => 'php', 'type' => 'unparsed_content', 'content' => '<span class="phpcode">$1</span>', 'validate' => __CLASS__ . '::phpValidate', 'block_level' => false, 'disabled_content' => '$1'],
['tag' => 'pre', 'before' => '<pre>', 'after' => '</pre>'],
['tag' => 'quote', 'before' => '<blockquote><cite>{txt_quote}</cite>', 'after' => '</blockquote>', 'trim' => 'both', 'block_level' => true],
['tag' => 'quote', 'parameters' => ['author' => ['match' => '(.{1,192}?)', 'quoted' => true]], 'before' => '<blockquote><cite>{txt_quote_from}: {author}</cite>', 'after' => '</blockquote>', 'trim' => 'both', 'block_level' => true],
[
'tag' => 'quote',
'type' => 'parsed_equals',
'before' => '<blockquote><cite>{txt_quote_from}: $1</cite>',
'after' => '</blockquote>',
'trim' => 'both',
'quoted' => 'optional',
// Don't allow everything to be embedded with the author name.
'parsed_tags_allowed' => ['url', 'iurl', 'ftp'],
'block_level' => true,
],
['tag' => 'quote', 'parameters' => ['author' => ['match' => '([^<>]{1,192}?)'], 'link' => ['match' => '(?:board=\\d+;)?((?:topic|threadid)=[\\dmsg#\\./]{1,40}(?:;start=[\\dmsg#\\./]{1,40})?|msg=\\d+?|action=profile;u=\\d+)'], 'date' => ['match' => '(\\d+)', 'validate' => 'SMF\\Time::timeformat']], 'before' => '<blockquote><cite><a href="{scripturl}?{link}">{txt_quote_from}: {author} {txt_search_on} {date}</a></cite>', 'after' => '</blockquote>', 'trim' => 'both', 'block_level' => true],
['tag' => 'quote', 'parameters' => ['author' => ['match' => '(.{1,192}?)']], 'before' => '<blockquote><cite>{txt_quote_from}: {author}</cite>', 'after' => '</blockquote>', 'trim' => 'both', 'block_level' => true],
// Legacy (alias of [color=red])
['tag' => 'red', 'before' => '<span style="color: red;" class="bbc_color">', 'after' => '</span>'],
['tag' => 'right', 'before' => '<div class="righttext"><div class="inline-block">', 'after' => '</div></div>', 'block_level' => true],
['tag' => 'rtl', 'before' => '<bdo dir="rtl">', 'after' => '</bdo>', 'block_level' => true],
['tag' => 's', 'before' => '<s>', 'after' => '</s>'],
// Legacy (never a good idea)
['tag' => 'shadow', 'type' => 'unparsed_commas', 'test' => '[#0-9a-zA-Z\\-]{3,12},(left|right|top|bottom|[0123]\\d{0,2})\\]', 'before' => '<span style="text-shadow: $1 $2">', 'after' => '</span>', 'validate' => __CLASS__ . '::shadowValidate'],
['tag' => 'size', 'type' => 'unparsed_equals', 'test' => '([1-9][\\d]?p[xt]|small(?:er)?|large[r]?|x[x]?-(?:small|large)|medium|(0\\.[1-9]|[1-9](\\.[\\d][\\d]?)?)?em)\\]', 'before' => '<span style="font-size: $1;" class="bbc_size">', 'after' => '</span>'],
['tag' => 'size', 'type' => 'unparsed_equals', 'test' => '[1-7]\\]', 'before' => '<span style="font-size: $1;" class="bbc_size">', 'after' => '</span>', 'validate' => __CLASS__ . '::sizeValidate'],
['tag' => 'sub', 'before' => '<sub>', 'after' => '</sub>'],
['tag' => 'sup', 'before' => '<sup>', 'after' => '</sup>'],
['tag' => 'table', 'before' => '<table class="bbc_table">', 'after' => '</table>', 'trim' => 'inside', 'require_children' => ['tr'], 'block_level' => true],
['tag' => 'td', 'before' => '<td>', 'after' => '</td>', 'require_parents' => ['tr'], 'trim' => 'outside', 'block_level' => true, 'disabled_before' => '', 'disabled_after' => ''],
['tag' => 'time', 'type' => 'unparsed_content', 'content' => '$1', 'validate' => __CLASS__ . '::timeValidate'],
['tag' => 'tr', 'before' => '<tr>', 'after' => '</tr>', 'require_parents' => ['table'], 'require_children' => ['td'], 'trim' => 'both', 'block_level' => true, 'disabled_before' => '', 'disabled_after' => ''],
// Legacy (the <tt> element is dead)
['tag' => 'tt', 'before' => '<span class="monospace">', 'after' => '</span>'],
['tag' => 'u', 'before' => '<u>', 'after' => '</u>'],
['tag' => 'url', 'type' => 'unparsed_content', 'content' => '<a href="$1" class="bbc_link" target="_blank" rel="noopener">$1</a>', 'validate' => __CLASS__ . '::urlValidate'],
['tag' => 'url', 'type' => 'unparsed_equals', 'quoted' => 'optional', 'before' => '<a href="$1" class="bbc_link" target="_blank" rel="noopener">', 'after' => '</a>', 'validate' => __CLASS__ . '::urlValidate', 'disallow_children' => ['email', 'ftp', 'url', 'iurl'], 'disabled_after' => ' ($1)'],
// Legacy (alias of [color=white])
['tag' => 'white', 'before' => '<span style="color: white;" class="bbc_color">', 'after' => '</span>'],
['tag' => 'youtube', 'type' => 'unparsed_content', 'content' => '<div class="videocontainer"><div><iframe frameborder="0" src="https://www.youtube.com/embed/$1?origin={hosturl}&wmode=opaque" data-youtube-id="$1" allowfullscreen loading="lazy"></iframe></div></div>', 'disabled_content' => '<a href="https://www.youtube.com/watch?v=$1" target="_blank" rel="noopener">https://www.youtube.com/watch?v=$1</a>', 'block_level' => true],
]
Definitions of supported BBCodes.
NOTE: Although BBCodeParser::$codes is public in order to allow maximum flexibility, you should call the BBCodeParser::getCodes() method if you want to read this list. Calling the method will ensure that any BBCodes added by modifications are included in the returned array.
The BBCode definitions are formatted as an array, with keys as follows:
tag: The tag's name - should be lowercase!
type: One of... - (missing): [tag]parsed content[/tag] - unparsed_equals: [tag=xyz]parsed content[/tag] - parsed_equals: [tag=parsed data]parsed content[/tag] - unparsed_content: [tag]unparsed content[/tag] - closed: [tag], [tag/], [tag /] - unparsed_commas: [tag=1,2,3]parsed content[/tag] - unparsed_commas_content: [tag=1,2,3]unparsed content[/tag] - unparsed_equals_content: [tag=...]unparsed content[/tag]
parameters: An optional array of parameters, for the form [tag abc=123]content[/tag]. The array is an associative array where the keys are the parameter names, and the values are an array which may contain the following: - match: a regular expression to validate and match the value. - quoted: true if the value should be quoted. - validate: callback to evaluate on the data, which is $data. - value: a string in which to replace $1 with the data. Either value or validate may be used, not both. - optional: true if the parameter is optional. - default: a default value for missing optional parameters.
test: A regular expression to test immediately after the tag's '=', ' ' or ']'. Typically, should have a ] at the end. Optional.
content: Only available for unparsed_content, closed, unparsed_commas_content, and unparsed_equals_content. $1 is replaced with the content of the tag. Parameters are replaced in the form {param}. For unparsed_commas_content, $2, $3, ..., $n are replaced. The form {txt_*} can be used to insert Lang::$txt strings, e.g. {txt_code} will be replaced with the value of Lang::$txt['code'].
before: Only when content is not used, to go before any content. For unparsed_equals, $1 is replaced with the value. For unparsed_commas, $1, $2, ..., $n are replaced.
after: Similar to before in every way, except that it is used when the tag is closed.
disabled_content: Used in place of content when the tag is disabled. For closed, default is '', otherwise it is '$1' if block_level is false, '
disabled_before: Used in place of before when disabled. Defaults to '
disabled_after: Used in place of after when disabled. Defaults to '
block_level: Set to true the tag is a "block level" tag, similar to HTML. Block level tags cannot be nested inside tags that are not block level, and will not be implicitly closed as easily. One break following a block level tag may also be removed.
trim: If set to 'inside', whitespace after the begin tag will be removed. If set to 'outside', whitespace after the end tag will meet the same fate.
validate: A callback to validate the data as $data. Four arguments will be passed to the callback: &$tag, &$data, $disabled, $params. Depending on the tag's type, $data may be a string or an array of strings (corresponding to the replacement.)
quoted: When type is 'unparsed_equals' or 'parsed_equals' only, may be not set, 'optional', or 'required' corresponding to if the content may be quoted. This allows the parser to read [tag="abc]def[esdf]"] properly.
require_parents: An array of tag names, or not set. If set, the enclosing tag must be one of the listed tags, or parsing won't occur.
require_children: Similar to require_parents, if set children won't be parsed if they are not in the list.
disallow_children: Similar to, but very different from, require_children, if it is set the listed tags will not be parsed inside the tag.
parsed_tags_allowed: An array restricting what BBC can be in the parsed_equals parameter, if desired.
$custom_smileys_enabled
public
bool
$custom_smileys_enabled
Whether custom smileys are enabled.
$disabled
public
array<string|int, mixed>
$disabled
= []
List of disabled BBCode tags.
$domain_label_chars
public
static string
$domain_label_chars
= '0-9A-Za-z\\-' . '\\x{A0}-\\x{D7FF}' . '\\x{F900}-\\x{FDCF}' . '\\x{FDF0}-\\x{FFEF}' . '\\x{10000}-\\x{1FFFD}' . '\\x{20000}-\\x{2FFFD}' . '\\x{30000}-\\x{3FFFD}' . '\\x{40000}-\\x{4FFFD}' . '\\x{50000}-\\x{5FFFD}' . '\\x{60000}-\\x{6FFFD}' . '\\x{70000}-\\x{7FFFD}' . '\\x{80000}-\\x{8FFFD}' . '\\x{90000}-\\x{9FFFD}' . '\\x{A0000}-\\x{AFFFD}' . '\\x{B0000}-\\x{BFFFD}' . '\\x{C0000}-\\x{CFFFD}' . '\\x{D0000}-\\x{DFFFD}' . '\\x{E1000}-\\x{EFFFD}'
Regular expression character class to match all characters allowed to appear in a domain name.
$enable_bbc
public
bool
$enable_bbc
Whether BBCode should be parsed.
$enable_post_html
public
bool
$enable_post_html
Whether to allow certain basic HTML tags in the input.
$encoding
public
string
$encoding
= 'UTF-8'
The character encoding of the strings to be parsed.
$excluded_trailing_chars
public
static string
$excluded_trailing_chars
= '!;:.,?'
Characters to exclude from a detected URL if they appear at the end.
$for_print
public
bool
$for_print
= false
Enables special handling if output is meant for paper printing.
$itemcodes
public
static array<string|int, mixed>
$itemcodes
= ['*' => 'disc', '@' => 'disc', '+' => 'square', 'x' => 'square', '#' => 'square', 'o' => 'circle', 'O' => 'circle', '0' => 'circle']
Itemcodes are an alternative syntax for creating lists.
$locale
public
string
$locale
= 'en_US'
Language locale to use.
$no_autolink_tags
public
static array<string|int, mixed>
$no_autolink_tags
= ['url', 'iurl', 'email', 'img', 'html', 'attach', 'ftp', 'flash', 'member', 'code', 'php', 'nobbc']
BBCodes whose content should be skipped when autolinking URLs.
$parse_tags
public
array<string|int, mixed>
$parse_tags
= []
If not empty, only these BBCode tags will be parsed.
$schemes
public
static array<string|int, mixed>
$schemes
= [
// Schemes whose URI definitions require a domain name in the
// authority (or whatever the next part of the URI is).
'need_domain' => ['aaa', 'aaas', 'acap', 'acct', 'afp', 'cap', 'cid', 'coap', 'coap+tcp', 'coap+ws', 'coaps', 'coaps+tcp', 'coaps+ws', 'crid', 'cvs', 'dict', 'dns', 'feed', 'fish', 'ftp', 'git', 'go', 'gopher', 'h323', 'http', 'https', 'iax', 'icap', 'im', 'imap', 'ipp', 'ipps', 'irc', 'irc6', 'ircs', 'ldap', 'ldaps', 'mailto', 'mid', 'mupdate', 'nfs', 'nntp', 'pop', 'pres', 'reload', 'rsync', 'rtsp', 'sftp', 'sieve', 'sip', 'sips', 'smb', 'snmp', 'soap.beep', 'soap.beeps', 'ssh', 'svn', 'stun', 'stuns', 'telnet', 'tftp', 'tip', 'tn3270', 'turn', 'turns', 'tv', 'udp', 'vemmi', 'vnc', 'webcal', 'ws', 'wss', 'xmlrpc.beep', 'xmlrpc.beeps', 'xmpp', 'z39.50', 'z39.50r', 'z39.50s'],
// Schemes that allow an empty authority ("://" followed by "/")
'empty_authority' => ['file', 'ni', 'nih'],
// Schemes that do not use an authority but still have a reasonable
// chance of working as clickable links.
'no_authority' => ['about', 'callto', 'geo', 'gg', 'leaptofrogans', 'magnet', 'mailto', 'maps', 'news', 'ni', 'nih', 'service', 'skype', 'sms', 'tel', 'tv'],
// Schemes that should never be autolinked.
'forbidden' => ['javascript', 'data'],
]
URI schemes that require some sort of special handling.
$smiley_set
public
string
$smiley_set
The smiley set to use when parsing smileys.
$smileys
public
bool
$smileys
= true
Whether smileys should be parsed.
$smileys_url
public
string
$smileys_url
URL of the base smileys directory.
$time_format
public
string
$time_format
User's strftime format.
$time_offset
public
int
$time_offset
User's time offset from UTC.
$utf8
public
bool
$utf8
= true
Shorthand check for whether character encoding is UTF-8.
$alltags_regex
protected
string
$alltags_regex
Regular expression to match all BBCode tags.
$email_regex
protected
string
$email_regex
Regular expression to match e-mail addresses.
$smiley_preg_replacements
protected
array<string|int, mixed>
$smiley_preg_replacements
= []
Replacement values for smileys.
$smiley_preg_search
protected
string
$smiley_preg_search
Regular expression to match smileys.
$tld_regex
protected
string
$tld_regex
Regular expression to match top level domains.
$url_regex
protected
string
$url_regex
Regular expression to match URLs.
$backcompat
private
static array<string|int, mixed>
$backcompat
= ['func_names' => ['getSigTags' => 'get_signature_allowed_bbc_tags', 'highlightPhpCode' => 'highlight_php_code', 'sanitizeMSCutPaste' => 'sanitizeMSCutPaste', 'backcompatParseBbc' => 'parse_bbc', 'backcompatParseSmileys' => 'parseSmileys']]
BackwardCompatibility settings for this class.
$bbc_codes
private
array<string|int, mixed>
$bbc_codes
= []
Version of self::$codes used for interal processing.
$bbc_lang_locales
private
array<string|int, mixed>
$bbc_lang_locales
= []
Copies of $this->bbc_codes for different locales.
$cache_key_extras
private
array<string|int, mixed>
$cache_key_extras
= []
Holds any extra info that should be used in the cache_key.
Data can be added to this variable using the integrate_pre_parsebbc hook.
This is important if your mod can cause the same input string to produce different output strings in different situations. For example, if your mod adds a BBCode that shows different output to guests vs. members, then you need to add information to this variable in order to distinguish the guest version vs. the member version of the output.
$hosturl
private
string
$hosturl
URL of this host/domain. Needed for the YouTube BBCode.
$inside
private
string
$inside
The last item of $this->open_tags.
$integrate_bbc_codes_done
private
static bool
$integrate_bbc_codes_done
= false
Tracks whether the integration_bbc_codes hook was called.
$last_pos
private
int
$last_pos
Previous value of $this->pos.
$message
private
string
$message
= ''
The string in which to parse BBCode.
$open_tags
private
array<string|int, mixed>
$open_tags
= []
BBCode tags that are currently open at any given step of processing $this->message.
$parser
private
static object
$parser
A reference to an existing, reusable instance of this class.
$placeholder_template
private
string
$placeholder_template
= "" . '%1$s' . ""
The sprintf format used to create placeholders. Uses private use Unicode characters to prevent conflicts.
$placeholders
private
array<string|int, mixed>
$placeholders
= []
Placeholders used to protect certain strings from processing.
$placeholders_counter
private
int
$placeholders_counter
= 0
How many placeholders we have created.
$pos
private
int
$pos
= -1
Current position in $this->message.
$pos1
private
int
$pos1
Position where current BBCode tag ends.
$results
private
array<string|int, mixed>
$results
= []
Holds parsed messages.
Methods
__construct()
Constructor.
public
__construct() : object
Return values
object —A reference to this object for method chaining.
attachValidate()
Validation method for the attach BBCode.
public
static attachValidate(array<string|int, mixed> &$tag, array<string|int, mixed>|string &$data, array<string|int, mixed> $disabled, array<string|int, mixed> $params) : void
Parameters
- $tag : array<string|int, mixed>
-
A copy of this tag's definition.
- $data : array<string|int, mixed>|string
-
The data in this particular BBCode instance.
- $disabled : array<string|int, mixed>
-
List of disabled BBCodes.
- $params : array<string|int, mixed>
-
Parameters supplied in this BBCode instance.
backcompatParseBbc()
Backward compatibility wrapper for parse() and/or getCodes().
public
static backcompatParseBbc(string|bool $message[, bool $smileys = true ][, string $cache_id = '' ][, array<string|int, mixed> $parse_tags = [] ]) : string|array<string|int, mixed>
Parameters
- $message : string|bool
-
The message. When a empty string, nothing is done. When false we provide a list of BBC codes available. When a string, the message is parsed and bbc handled.
- $smileys : bool = true
-
Whether to parse smileys as well.
- $cache_id : string = ''
-
The cache ID.
- $parse_tags : array<string|int, mixed> = []
-
If set, only parses these tags rather than all of them.
Return values
string|array<string|int, mixed> —The parsed message or the list of BBCodes.
backcompatParseSmileys()
Backward compatibility wrapper for parseSmileys().
public
static backcompatParseSmileys(string &$message) : mixed
Doesn't return anything, but rather modifies $message directly.
Parameters
- $message : string
-
The message to parse smileys in.
codeValidate()
Validation method for the code BBCode.
public
static codeValidate(array<string|int, mixed> &$tag, array<string|int, mixed>|string &$data, array<string|int, mixed> $disabled, array<string|int, mixed> $params) : void
Parameters
- $tag : array<string|int, mixed>
-
A copy of this tag's definition.
- $data : array<string|int, mixed>|string
-
The data in this particular BBCode instance.
- $disabled : array<string|int, mixed>
-
List of disabled BBCodes.
- $params : array<string|int, mixed>
-
Parameters supplied in this BBCode instance.
emailValidate()
Validation method for the email BBCode.
public
static emailValidate(array<string|int, mixed> &$tag, array<string|int, mixed>|string &$data, array<string|int, mixed> $disabled, array<string|int, mixed> $params) : void
Parameters
- $tag : array<string|int, mixed>
-
A copy of this tag's definition.
- $data : array<string|int, mixed>|string
-
The data in this particular BBCode instance.
- $disabled : array<string|int, mixed>
-
List of disabled BBCodes.
- $params : array<string|int, mixed>
-
Parameters supplied in this BBCode instance.
Tags
exportStatic()
Provides a way to export a class's public static properties and methods to global namespace.
public
static exportStatic() : void
To do so:
- Use this trait in the class.
- At the END of the class's file, call its exportStatic() method.
Although it might not seem that way at first glance, this approach conforms to section 2.3 of PSR 1, since executing this method is simply a dynamic means of declaring functions when the file is included; it has no other side effects.
Regarding the $backcompat items:
A class's static properties are not exported to global variables unless explicitly included in $backcompat['prop_names']. Likewise, a class's static methods are not exported as global functions unless explicitly included in $backcompat['func_names'].
$backcompat['prop_names'] is a simple array where the keys are the names of one or more of a class's static properties, and the values are the names of global variables. In each case, the global variable will be set to a reference to the static property. Static properties that are not named in this array will not be exported.
$backcompat['func_names'] is a simple array where the keys are the names of one or more of a class's static methods, and the values are the names that should be used for global functions that will encapsulate those methods. Methods that are not named in this array will not be exported.
Adding non-static properties or methods to the $backcompat arrays will produce runtime errors. It is the responsibility of the developer to make sure not to do this.
flashValidate()
Validation method for the flash BBCode.
public
static flashValidate(array<string|int, mixed> &$tag, array<string|int, mixed>|string &$data, array<string|int, mixed> $disabled, array<string|int, mixed> $params) : void
Parameters
- $tag : array<string|int, mixed>
-
A copy of this tag's definition.
- $data : array<string|int, mixed>|string
-
The data in this particular BBCode instance.
- $disabled : array<string|int, mixed>
-
List of disabled BBCodes.
- $params : array<string|int, mixed>
-
Parameters supplied in this BBCode instance.
floatValidate()
Validation method for the float BBCode.
public
static floatValidate(array<string|int, mixed> &$tag, array<string|int, mixed>|string &$data, array<string|int, mixed> $disabled, array<string|int, mixed> $params) : void
Parameters
- $tag : array<string|int, mixed>
-
A copy of this tag's definition.
- $data : array<string|int, mixed>|string
-
The data in this particular BBCode instance.
- $disabled : array<string|int, mixed>
-
List of disabled BBCodes.
- $params : array<string|int, mixed>
-
Parameters supplied in this BBCode instance.
ftpValidate()
Validation method for the ftp BBCode.
public
static ftpValidate(array<string|int, mixed> &$tag, array<string|int, mixed>|string &$data, array<string|int, mixed> $disabled, array<string|int, mixed> $params) : void
Parameters
- $tag : array<string|int, mixed>
-
A copy of this tag's definition.
- $data : array<string|int, mixed>|string
-
The data in this particular BBCode instance.
- $disabled : array<string|int, mixed>
-
List of disabled BBCodes.
- $params : array<string|int, mixed>
-
Parameters supplied in this BBCode instance.
getCodes()
Get the list of supported BBCodes, including any added by modifications.
public
static getCodes() : array<string|int, mixed>
Return values
array<string|int, mixed> —List of supported BBCodes
getSigTags()
Returns an array of BBC tags that are allowed in signatures.
public
static getSigTags() : array<string|int, mixed>
Return values
array<string|int, mixed> —An array containing allowed tags for signatures, or an empty array if all tags are allowed.
highlightPhpCode()
Highlight any code.
public
static highlightPhpCode(string $code) : string
Uses PHP's highlight_string() to highlight PHP syntax does special handling to keep the tabs in the code available. used to parse PHP code from inside [code] and [php] tags.
Parameters
- $code : string
-
The code.
Return values
string —The code with highlighted HTML.
htmlToBbc()
Backward compatibility wrapper for unparse().
public
htmlToBbc(string $string) : string
Parameters
- $string : string
-
Text containing HTML
Return values
string —The string with html converted to bbc
imgValidate()
Validation method for the img BBCode.
public
static imgValidate(array<string|int, mixed> &$tag, array<string|int, mixed>|string &$data, array<string|int, mixed> $disabled, array<string|int, mixed> $params) : void
Parameters
- $tag : array<string|int, mixed>
-
A copy of this tag's definition.
- $data : array<string|int, mixed>|string
-
The data in this particular BBCode instance.
- $disabled : array<string|int, mixed>
-
List of disabled BBCodes.
- $params : array<string|int, mixed>
-
Parameters supplied in this BBCode instance.
load()
Returns a reusable instance of this class.
public
static load([bool $init = false ]) : object
Using this method to get a BBCodeParser instance saves memory by avoiding creating redundant instances.
Parameters
- $init : bool = false
-
If true, reinitializes the reusable BBCodeParser.
Return values
object —An instance of this class.
parse()
Parse bulletin board code in a string, as well as smileys optionally.
public
parse(string|bool $message[, bool $smileys = true ][, string|int $cache_id = '' ][, array<string|int, mixed> $parse_tags = [] ]) : string
Parameters
- $message : string|bool
-
The string to parse.
- $smileys : bool = true
-
Whether to parse smileys. Default: true.
- $cache_id : string|int = ''
-
The cache ID. If $cache_id is left empty, an ID will be generated automatically. Manually specifiying a ID is helpful in cases when an integration hook wants to identify particular strings to act upon, but is otherwise unnecessary.
- $parse_tags : array<string|int, mixed> = []
-
If set, only parses these tags rather than all of them.
Return values
string —The parsed string.
parseSmileys()
Parse smileys in the passed message.
public
parseSmileys(string $message) : string
The smiley parsing function which makes pretty faces appear :). If custom smiley sets are turned off by smiley_enable, the default set of smileys will be used. These are specifically not parsed in code tags [url=mailto:Dad@blah.com] Caches the smileys from the database or array in memory.
Parameters
- $message : string
-
The message to parse smileys in.
Return values
string —The message with smiley images inserted.
phpValidate()
Validation method for the php BBCode.
public
static phpValidate(array<string|int, mixed> &$tag, array<string|int, mixed>|string &$data, array<string|int, mixed> $disabled, array<string|int, mixed> $params) : void
Parameters
- $tag : array<string|int, mixed>
-
A copy of this tag's definition.
- $data : array<string|int, mixed>|string
-
The data in this particular BBCode instance.
- $disabled : array<string|int, mixed>
-
List of disabled BBCodes.
- $params : array<string|int, mixed>
-
Parameters supplied in this BBCode instance.
sanitizeMSCutPaste()
Microsoft uses their own character set Code Page 1252 (CP1252), which is a superset of ISO 8859-1, defining several characters between DEC 128 and 159 that are not normally displayable. This converts the popular ones that appear from a cut and paste from Windows.
public
static sanitizeMSCutPaste(string $string) : string
Parameters
- $string : string
-
The string.
Return values
string —The sanitized string.
shadowValidate()
Validation method for the shadow BBCode.
public
static shadowValidate(array<string|int, mixed> &$tag, array<string|int, mixed>|string &$data, array<string|int, mixed> $disabled, array<string|int, mixed> $params) : void
Parameters
- $tag : array<string|int, mixed>
-
A copy of this tag's definition.
- $data : array<string|int, mixed>|string
-
The data in this particular BBCode instance.
- $disabled : array<string|int, mixed>
-
List of disabled BBCodes.
- $params : array<string|int, mixed>
-
Parameters supplied in this BBCode instance.
sizeValidate()
Validation method for the size BBCode.
public
static sizeValidate(array<string|int, mixed> &$tag, array<string|int, mixed>|string &$data, array<string|int, mixed> $disabled, array<string|int, mixed> $params) : void
Parameters
- $tag : array<string|int, mixed>
-
A copy of this tag's definition.
- $data : array<string|int, mixed>|string
-
The data in this particular BBCode instance.
- $disabled : array<string|int, mixed>
-
List of disabled BBCodes.
- $params : array<string|int, mixed>
-
Parameters supplied in this BBCode instance.
timeValidate()
Validation method for the time BBCode.
public
static timeValidate(array<string|int, mixed> &$tag, array<string|int, mixed>|string &$data, array<string|int, mixed> $disabled, array<string|int, mixed> $params) : void
Parameters
- $tag : array<string|int, mixed>
-
A copy of this tag's definition.
- $data : array<string|int, mixed>|string
-
The data in this particular BBCode instance.
- $disabled : array<string|int, mixed>
-
List of disabled BBCodes.
- $params : array<string|int, mixed>
-
Parameters supplied in this BBCode instance.
unparse()
Converts HTML to BBC.
public
unparse(string $string) : string
Only used by ManageBoards.php (and possibly mods).
Parameters
- $string : string
-
Text containing HTML.
Return values
string —The string with HTML converted to BBC.
urlValidate()
Validation method for the url and iurl BBCodes.
public
static urlValidate(array<string|int, mixed> &$tag, array<string|int, mixed>|string &$data, array<string|int, mixed> $disabled, array<string|int, mixed> $params) : void
Parameters
- $tag : array<string|int, mixed>
-
A copy of this tag's definition.
- $data : array<string|int, mixed>|string
-
The data in this particular BBCode instance.
- $disabled : array<string|int, mixed>
-
List of disabled BBCodes.
- $params : array<string|int, mixed>
-
Parameters supplied in this BBCode instance.
autoLink()
Detects plain text URLs and formats them as BBCode links.
protected
autoLink(string $data) : string
Parameters
- $data : string
-
The string to autolink.
Return values
string —The string with linked URLs.
closeInlineTags()
Similar to $this->closeTags(), but only for inline tags.
protected
closeInlineTags() : void
Operates directly on $this->message.
closeTags()
Ensures BBCode markup is well-formed by auto-closing nested tags in the correct order.
protected
closeTags() : void
Operates directly on $this->message.
detectTag()
Figures out which BBCode the current tag is.
protected
detectTag(string $tag_character) : array<string|int, mixed>
Parameters
- $tag_character : string
-
The first character of this (possible) tag.
Return values
array<string|int, mixed> —The tag's definition and the parameter values to use.
fetchTagAttributes()
Helper for unparse().
protected
fetchTagAttributes(string $string) : array<string|int, mixed>
Returns an array of attributes associated with a tag.
Parameters
- $string : string
-
A tag
Return values
array<string|int, mixed> —An array of attributes
fixHtml()
Fixes up any raw HTML in a BBCode string.
protected
fixHtml(string $data) : string
Parameters
- $data : string
-
A string that might contain HTML.
Return values
string —The fixed version of the string.
highLoadAverage()
Checks whether the server's load average is too high to parse BBCode.
protected
highLoadAverage() : bool
Return values
bool —Whether the load average is too high.
insertTxt()
Replaces {txt_*} tokens with Lang::$txt strings.
protected
insertTxt(string $string) : string
Parameters
- $string : string
Return values
string —The string with Lang::$txt string values.
integrateBBC()
Wrapper for the integrate_bbc_codes hook.
protected
static integrateBBC() : void
Prevents duplication in self::$codes.
legalise()
Helper for unparse().
protected
legalise(string $string) : string
Attempt to clean up illegal BBC caused by browsers like Opera that don't obey the rules.
Parameters
- $string : string
-
Text
Return values
string —Cleaned up text
parseItemCode()
Parses itemcodes into normal list items.
protected
parseItemCode() : void
Operates directly on $this->message.
parseMessage()
The method that actually parses the BBCode in $this->message.
protected
parseMessage() : void
resetRuntimeProperties()
Resets certain runtime properties to their default values.
protected
resetRuntimeProperties() : void
setAllTagsRegex()
Sets $this->alltags_regex.
protected
setAllTagsRegex() : void
setBbcCodes()
Sets $this->bbc_codes.
protected
setBbcCodes() : void
setDisabled()
Sets $this->disabled.
protected
setDisabled() : void
setEmailRegex()
Sets $this->email_regex.
protected
setEmailRegex() : void
setTldRegex()
Sets $this->tld_regex.
protected
setTldRegex() : void
setUrlRegex()
Sets $this->url_regex.
protected
setUrlRegex() : void
transformToHtml()
Transforms a BBCode tag into HTML.
protected
transformToHtml(array<string|int, mixed> $tag, array<string|int, mixed> $params) : void
Operates directly on $this->message.
Parameters
- $tag : array<string|int, mixed>
-
The tag definition.
- $params : array<string|int, mixed>
-
Parameter values to use.
useDisabledTag()
Adjusts a tag definition so that it uses its disabled version for output.
protected
useDisabledTag(array<string|int, mixed> $tag) : array<string|int, mixed>
Parameters
- $tag : array<string|int, mixed>
-
A tag definition.
Return values
array<string|int, mixed> —The disabled version of the tag definition.