vBulletin v6.1.0

vB_BbCodeHelper
in package
uses vB_Trait_NoSerialize

Table of Contents

Constants

PARSER_START  = 1
BB code parser's start state. Looking for the next tag to start.
PARSER_TAG_OPENED  = 3
Tag has been opened. Now parsing for option and closing ].
PARSER_TEXT  = 2
BB code parser's "this range is just text" state.
STRIP_TAG_CONTENT  = 'c'
STRIP_TAG_CONTENTOPTION  = 'co'
STRIP_TAG_REMOVE  = 'r'

Methods

__construct()  : mixed
__serialize()  : array<string|int, mixed>
__sleep()  : array<string|int, mixed>
__unserialize()  : void
__wakeup()  : void
buildParseArrayAndFixTags()  : array<string|int, mixed>
Convert $text to a bbcode parse array with fixed mismatched tags
cacheSmilies()  : array<string|int, mixed>
Caches the smilies in a form ready to be executed.
generateAndSaveBbCodeData()  : mixed
getTextFromParseArray()  : string
instance()  : vB_BbCodeHelper
Generate an instance of vB_BbCodeHelper with defaults
parseWhitespaceNewlines()  : string
Parses out specific white space before or after cetain tags and does nl2br
replaceInText()  : string
Does a find/replace in the bbcode text
stripSmilies()  : string
Removes translated smilies from a string.
stripTags()  : string
Strip bbcode and produce a plain text version of the bbcode text
tagIsOnOwnLine()  : bool
This is meant to only be used with parseArray() and should be considered a subfunction, as its logic is extremely coupled with parseArray()'s logic, and one cannot be modified without the other.

Constants

PARSER_START

BB code parser's start state. Looking for the next tag to start.

public mixed PARSER_START = 1

PARSER_TAG_OPENED

Tag has been opened. Now parsing for option and closing ].

public mixed PARSER_TAG_OPENED = 3

PARSER_TEXT

BB code parser's "this range is just text" state.

public mixed PARSER_TEXT = 2

Requires $internal_data to be set appropriately.

STRIP_TAG_CONTENTOPTION

public mixed STRIP_TAG_CONTENTOPTION = 'co'

Methods

__construct()

public __construct(array<string|int, mixed> $tag_list, array<string|int, mixed> $smilies) : mixed
Parameters
$tag_list : array<string|int, mixed>
$smilies : array<string|int, mixed>

__serialize()

public __serialize() : array<string|int, mixed>
Return values
array<string|int, mixed>

__sleep()

public __sleep() : array<string|int, mixed>
Return values
array<string|int, mixed>

__unserialize()

public __unserialize(array<string|int, mixed> $serialized) : void
Parameters
$serialized : array<string|int, mixed>

buildParseArrayAndFixTags()

Convert $text to a bbcode parse array with fixed mismatched tags

public buildParseArrayAndFixTags(mixed $text[, array<string|int, mixed> &$bbcodeInfo = [] ]) : array<string|int, mixed>
Parameters
$text : mixed
$bbcodeInfo : array<string|int, mixed> = []
Return values
array<string|int, mixed>

cacheSmilies()

Caches the smilies in a form ready to be executed.

public cacheSmilies(bool $do_html) : array<string|int, mixed>
Parameters
$do_html : bool
Return values
array<string|int, mixed>

Reference to smilie cache (key: find text; value: replace text)

generateAndSaveBbCodeData()

public generateAndSaveBbCodeData(mixed $rawtext, mixed $nodeid) : mixed
Parameters
$rawtext : mixed
$nodeid : mixed

getTextFromParseArray()

public getTextFromParseArray(array<string|int, mixed> $parsearray) : string
Parameters
$parsearray : array<string|int, mixed>
Return values
string

instance()

Generate an instance of vB_BbCodeHelper with defaults

public static instance([mixed $appendCustomTags = true ][, mixed $force_all = false ]) : vB_BbCodeHelper
Parameters
$appendCustomTags : mixed = true
$force_all : mixed = false
Return values
vB_BbCodeHelper

parseWhitespaceNewlines()

Parses out specific white space before or after cetain tags and does nl2br

public parseWhitespaceNewlines(mixed $text[, mixed $do_nl2br = true ]) : string
Parameters
$text : mixed
$do_nl2br : mixed = true
Return values
string

Processed text

replaceInText()

Does a find/replace in the bbcode text

public replaceInText(string $text, array<string|int, mixed>|string $find, array<string|int, mixed>|string|callable $replacements, array<string|int, mixed> $tags[, bool $include = true ]) : string

Note that unlike the standard find/replace this will match all find RE's against the original string and will skip replacementst that would conflict with a previous replacement. So a string of "a b c" with a find/replace of ["#a#", "#d#"] and ["d", "e"] will produce "d b c" and not "e b c" like you would get from preg_replace.

If two replacements overlap we will use the one that has the earliest offset in the string. If two matches have the same offset then we will use the match that appears first in the "find" array.

Parameters
$text : string
$find : array<string|int, mixed>|string

-- regular expression(s) to match against

$replacements : array<string|int, mixed>|string|callable

-- If a string replace all matches with the string value. If a callable then the callback function will be called as $replacements($source, $matches) where $source is the key of the $find array that produced the match and matches is the text matched per the preg library ($matches[0] is the matched string $matches[1] is the first matched group etc). If $find is a string then $source is 0. If $replacements is an array it must have the same keys as $find and the individual string or callable will be used for that match. A value of false in the $replacements array (or a return from the callback) indicates that the replacement should be skipped.

$tags : array<string|int, mixed>

-- a list of tags to include or exclude from matching. If a tag is excluded then none of it's contents will be altered.

$include : bool = true

-- if true the all tags not in the $tags list are excluded. If false then a tag in the $tag list is excluded but all other tags are affected.

Return values
string

stripSmilies()

Removes translated smilies from a string.

public stripSmilies(string $text) : string
Parameters
$text : string
Return values
string

Text with smilie HTML returned to smilie codes

stripTags()

Strip bbcode and produce a plain text version of the bbcode text

public stripTags(mixed $text, mixed $defaultAction, mixed $tags) : string

This is similar to vB_String::stripBbCode but uses the bbcode parsing logic instead of regular expressions. This results is some notable differences:

  1. We allow the caller more fine grained control about how to handle tags.
  2. We only strip actual bbcode tags so [bogus]some text[/bogus] will be unaffected. In most cases this will be a more accurate representation because the rendered bbcode text will show invalid tags as literal text.
Parameters
$text : mixed
$defaultAction : mixed

-- the action that will apply to tags not explicitly mentioned. STRIP_TAG_REMOVE -- removes the tag and its contents entirely. STRIP_TAG_CONTENT -- removes the tag wrapper but leaves the contents intact (though the contents will similarly be stripped if it contains tags); STRIP_TAG_CONTENTOPTION -- removes the tag, leaves the contents, and appends the option in parens after. If the tag does not have an option then acts as STRIP_TAG_CONTENT

$tags : mixed

-- tag => action. Tags are of the form "tag" for tags without options and "tag=" for tags with options. This is intended, for instance, to allow handling [url]http://someurlcom[/url] differently from [url=http://someurlcom]some title[/url] but there is no attempt to made to handle tags that only have options if only the bare tag name is provided. Tag names should be provided in lowercase but will be matched in case insensitive fashion.

Return values
string

tagIsOnOwnLine()

This is meant to only be used with parseArray() and should be considered a subfunction, as its logic is extremely coupled with parseArray()'s logic, and one cannot be modified without the other.

public tagIsOnOwnLine(mixed $openTagPosition, mixed $closeTagPosition, mixed $keys, mixed $preparsed) : bool
Parameters
$openTagPosition : mixed
$closeTagPosition : mixed
$keys : mixed
$preparsed : mixed
Return values
bool

        
On this page

Search results