vB_Library_BbCode
in package
Uses
vB_Trait_NoSerialize
Stack based BB code parser.
DO NOT USE THIS CLASS UNLESS YOU GET PRIOR APPROVAL
Tags
Table of Contents
Constants
- BBCODE_HAS_ATTACH = 2
- BBCODE_HAS_IMG = 1
- BBCODE_HAS_RELPATH = 8
- BBCODE_HAS_SIGPIC = 4
Properties
- $stripSpaceAfter : bool
- Global override for space stripping
Methods
- __construct() : mixed
- Constructor. Sets up the tag list.
- __serialize() : array<string|int, mixed>
- __sleep() : array<string|int, mixed>
- __unserialize() : void
- __wakeup() : void
- append_noninline_attachments() : mixed
- Appends the non-inline attachment UI to the passed $text
- convertUrlToBbcode() : string
- Converts URLs into bbcode with [URL]
- doParse() : string
- Parse the string with the selected options
- fetchBBCodes() : mixed
- Gets the current bbCode List
- get_preview() : array<string|int, mixed>
- This is copied from the blog bbcode parser. We either have a specific amount of text, or [PRBREAK][/PRBREAK].
- getAttachmentLink() : mixed
- getAttachments() : mixed
- getRegexesForUrlDetection() : mixed
- getTableHelper() : vBForum_BBCodeHelper_Table
- Fetches the table helper in use. It also acts as a lazy initializer.
- getUtilityParser() : mixed
- handle_bbcode_code() : string
- Handles a [code] tag. Displays a preformatted string.
- handle_bbcode_h() : mixed
- handle_bbcode_html() : string
- Handles an [html] tag. Syntax highlights a string of HTML.
- handle_bbcode_html_tag() : string
- Handles an individual HTML tag in a [html] tag.
- handle_bbcode_img() : string
- Handles an [img] tag.
- handle_bbcode_list() : string
- Handles a [list] tag. Makes a bulleted or ordered list.
- handle_bbcode_list_element() : string
- Handles a single bullet of a list
- handle_bbcode_php() : string
- Handles a [php] tag. Syntax highlights a string of PHP.
- handle_bbcode_post() : string
- Handles a [post] tag. Creates a link to another post.
- handle_bbcode_quote() : string
- Handles a [quote] tag. Displays a string in an area indicating it was quoted from someone/somewhere else.
- handle_bbcode_sigpic() : string
- Handles the parsing of a signature picture. Most of this is handled based on the $parseUserinfo member.
- handle_bbcode_size() : string
- Handles a [size] tag
- handle_bbcode_thread() : string
- Handles a [thread] tag. Creates a link to another thread.
- handle_bbcode_url() : string
- Handles a [url] tag. Creates a link to another web page.
- handleBbcodeImgMatch() : string
- Handles a match of the [img] tag that will be displayed as an actual image.
- parse() : string
- Collect parser options and misc data and fully parse the string into an HTML version
- setAttachments() : mixed
- Adds attachments to the class property using attachment nodeid as key.
- setDataCache() : mixed
- setMultiPageRender() : mixed
- Sets the parser to handle a multi-page render, in which case, the [PAGE] and [PRBREAK] bbcodes are handled differently and are discarded.
- setNodeid() : mixed
- setParseUserinfo() : mixed
- Sets the user the BB code as parsed as. As of 3.7, this function should only be called for parsing signatures (for sigpics and permissions).
- setPrintable() : mixed
- Sets whether this parser is parsing for printable output
- setQuotePrintableTemplate() : mixed
- Sets the template to be used for generating quotes
- setQuoteTemplate() : mixed
- Sets the template to be used for generating quotes
- setQuoteVars() : mixed
- Sets variables to be passed to the quote template
- setStripSpace() : mixed
- Override each tag's default strip_space_after setting .. We don't want to strip spaces when parsing bbcode for the editor
- stripFrontBackWhitespace() : mixed
- Removes the specified amount of line breaks from the front and/or back of the input string. Includes HTML line braeks.
Constants
BBCODE_HAS_ATTACH
public
mixed
BBCODE_HAS_ATTACH
= 2
BBCODE_HAS_IMG
public
mixed
BBCODE_HAS_IMG
= 1
BBCODE_HAS_RELPATH
public
mixed
BBCODE_HAS_RELPATH
= 8
BBCODE_HAS_SIGPIC
public
mixed
BBCODE_HAS_SIGPIC
= 4
Properties
$stripSpaceAfter
Global override for space stripping
public
bool
$stripSpaceAfter
= \true
Methods
__construct()
Constructor. Sets up the tag list.
public
__construct([mixed $appendCustomTags = true ][, mixed $appendSessionHashToImage = false ]) : mixed
Parameters
- $appendCustomTags : mixed = true
- $appendSessionHashToImage : mixed = false
__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>
__wakeup()
public
__wakeup() : void
append_noninline_attachments()
Appends the non-inline attachment UI to the passed $text
public
append_noninline_attachments(mixed $text, mixed $attachments[, mixed $do_imgcode = false ][, mixed $skiptheseattachments = [] ]) : mixed
Parameters
- $text : mixed
- $attachments : mixed
- $do_imgcode : mixed = false
- $skiptheseattachments : mixed = []
convertUrlToBbcode()
Converts URLs into bbcode with [URL]
public
convertUrlToBbcode(mixed $messagetext) : string
Parameters
- $messagetext : mixed
Return values
string —Converted text
doParse()
Parse the string with the selected options
public
doParse(string $text[, bool $do_html = false ][, bool $do_smilies = true ][, bool $do_bbcode = true ][, bool $do_imgcode = true ][, bool $do_nl2br = true ][, bool $cachable = false ][, string $htmlstate = null ][, bool $minimal = false ][, string $fulltext = '' ][, bool $do_censor = true ]) : string
Parameters
- $text : string
-
Unparsed text
- $do_html : bool = false
-
Whether to allow HTML (true) or not (false)
- $do_smilies : bool = true
-
Whether to parse smilies or not
- $do_bbcode : bool = true
-
Whether to parse BB code
- $do_imgcode : bool = true
-
Whether to parse the [img] BB code (independent of $do_bbcode)
- $do_nl2br : bool = true
-
Whether to automatically replace new lines with HTML line breaks
- $cachable : bool = false
-
Whether the post text is cachable
- $htmlstate : string = null
-
Switch for dealing with nl2br
- $minimal : bool = false
-
Do minimal required actions to parse bbcode
- $fulltext : string = ''
-
Full rawtext, ignoring pagebreaks.
- $do_censor : bool = true
-
Whether to censor the text
Return values
string —Parsed text
fetchBBCodes()
Gets the current bbCode List
public
fetchBBCodes() : mixed
get_preview()
This is copied from the blog bbcode parser. We either have a specific amount of text, or [PRBREAK][/PRBREAK].
public
get_preview(mixed $pagetext[, mixed $initial_length = 0 ][, mixed $do_html = false ][, mixed $do_nl2br = true ][, mixed $htmlstate = null ][, mixed $options = [] ]) : array<string|int, mixed>
Parameters
- $pagetext : mixed
- $initial_length : mixed = 0
- $do_html : mixed = false
- $do_nl2br : mixed = true
- $htmlstate : mixed = null
- $options : mixed = []
Return values
array<string|int, mixed> —Tokens, chopped to the right length.
getAttachmentLink()
public
getAttachmentLink(mixed $attachment[, mixed $type = vB_Api_Filedata::SIZE_FULL ]) : mixed
Parameters
- $attachment : mixed
- $type : mixed = vB_Api_Filedata::SIZE_FULL
getAttachments()
public
getAttachments() : mixed
getRegexesForUrlDetection()
public
getRegexesForUrlDetection() : mixed
getTableHelper()
Fetches the table helper in use. It also acts as a lazy initializer.
public
getTableHelper() : vBForum_BBCodeHelper_Table
If no table helper has been explicitly set, it will instantiate the class's default.
Return values
vBForum_BBCodeHelper_Table —Table helper object
getUtilityParser()
public
getUtilityParser(mixed $text) : mixed
Parameters
- $text : mixed
handle_bbcode_code()
Handles a [code] tag. Displays a preformatted string.
public
handle_bbcode_code(mixed $code) : string
Parameters
- $code : mixed
Return values
string —HTML representation of the tag.
handle_bbcode_h()
public
handle_bbcode_h(mixed $text, mixed $option) : mixed
Parameters
- $text : mixed
- $option : mixed
handle_bbcode_html()
Handles an [html] tag. Syntax highlights a string of HTML.
public
handle_bbcode_html(mixed $code) : string
Parameters
- $code : mixed
Return values
string —HTML representation of the tag.
handle_bbcode_html_tag()
Handles an individual HTML tag in a [html] tag.
public
handle_bbcode_html_tag(mixed $tag) : string
Parameters
- $tag : mixed
Return values
string —Syntax highlighted, displayable HTML tag.
handle_bbcode_img()
Handles an [img] tag.
public
handle_bbcode_img(mixed $bbcode, mixed $do_imgcode[, mixed $has_img_code = false ][, mixed $fulltext = '' ][, mixed $forceShowImages = false ]) : string
Parameters
- $bbcode : mixed
- $do_imgcode : mixed
- $has_img_code : mixed = false
- $fulltext : mixed = ''
- $forceShowImages : mixed = false
Return values
string —HTML representation of the tag.
handle_bbcode_list()
Handles a [list] tag. Makes a bulleted or ordered list.
public
handle_bbcode_list(mixed $text[, mixed $type = '' ]) : string
Parameters
- $text : mixed
- $type : mixed = ''
Return values
string —HTML representation of the tag.
handle_bbcode_list_element()
Handles a single bullet of a list
public
handle_bbcode_list_element(mixed $text) : string
Parameters
- $text : mixed
Return values
string —HTML for bullet
handle_bbcode_php()
Handles a [php] tag. Syntax highlights a string of PHP.
public
handle_bbcode_php(mixed $code) : string
Parameters
- $code : mixed
Return values
string —HTML representation of the tag.
handle_bbcode_post()
Handles a [post] tag. Creates a link to another post.
public
handle_bbcode_post(mixed $text, mixed $postId) : string
Parameters
- $text : mixed
- $postId : mixed
Return values
string —HTML representation of the tag.
handle_bbcode_quote()
Handles a [quote] tag. Displays a string in an area indicating it was quoted from someone/somewhere else.
public
handle_bbcode_quote(mixed $message[, mixed $username = '' ]) : string
Parameters
- $message : mixed
- $username : mixed = ''
Return values
string —HTML representation of the tag.
handle_bbcode_sigpic()
Handles the parsing of a signature picture. Most of this is handled based on the $parseUserinfo member.
public
handle_bbcode_sigpic(mixed $description) : string
Parameters
- $description : mixed
Return values
string —HTML representation of the sig pic
handle_bbcode_size()
Handles a [size] tag
public
handle_bbcode_size(mixed $text, mixed $size) : string
Parameters
- $text : mixed
- $size : mixed
Return values
string —HTML representation of the tag.
handle_bbcode_thread()
Handles a [thread] tag. Creates a link to another thread.
public
handle_bbcode_thread(mixed $text, mixed $threadId) : string
Parameters
- $text : mixed
- $threadId : mixed
Return values
string —HTML representation of the tag.
handle_bbcode_url()
Handles a [url] tag. Creates a link to another web page.
public
handle_bbcode_url(mixed $text, mixed $link[, mixed $context = [] ]) : string
Parameters
- $text : mixed
- $link : mixed
- $context : mixed = []
Return values
string —HTML representation of the tag.
handleBbcodeImgMatch()
Handles a match of the [img] tag that will be displayed as an actual image.
public
handleBbcodeImgMatch(mixed $link[, mixed $fullsize = false ]) : string
Parameters
- $link : mixed
- $fullsize : mixed = false
Return values
string —HTML representation of the tag.
parse()
Collect parser options and misc data and fully parse the string into an HTML version
public
parse(mixed $text[, mixed $forumid = 0 ][, mixed $allowsmilie = true ][, mixed $isimgcheck = false ][, mixed $parsedtext = '' ][, mixed $parsedhasimages = 3 ][, mixed $cachable = false ][, mixed $htmlstate = null ]) : string
Parameters
- $text : mixed
- $forumid : mixed = 0
- $allowsmilie : mixed = true
- $isimgcheck : mixed = false
- $parsedtext : mixed = ''
- $parsedhasimages : mixed = 3
- $cachable : mixed = false
- $htmlstate : mixed = null
Return values
string —Parsed text
setAttachments()
Adds attachments to the class property using attachment nodeid as key.
public
setAttachments(array<string|int, mixed> $attachments[, bool $skipattachlist = false ]) : mixed
Using nodeid keeps us from overwriting separate attachments that are using the same Filedata record.
Parameters
- $attachments : array<string|int, mixed>
-
Attachments data array with nodeid, filedataid, parentid, contenttypeid etc, typically from @see vB_Api_Node::getNodeAttachments() or @see vB_Api_Node::getNodeAttachmentsPublicInfo()
- $skipattachlist : bool = false
-
Only used internally for legacy attachments. Notifies the class to not append these attachments to the list of non-inline attachments.
setDataCache()
public
setDataCache(vB_BbCodeDataCache|null $cache) : mixed
Parameters
- $cache : vB_BbCodeDataCache|null
setMultiPageRender()
Sets the parser to handle a multi-page render, in which case, the [PAGE] and [PRBREAK] bbcodes are handled differently and are discarded.
public
setMultiPageRender(mixed $multiPage) : mixed
Parameters
- $multiPage : mixed
setNodeid()
public
setNodeid(int $nodeid) : mixed
Parameters
- $nodeid : int
setParseUserinfo()
Sets the user the BB code as parsed as. As of 3.7, this function should only be called for parsing signatures (for sigpics and permissions).
public
setParseUserinfo(int $userId) : mixed
Parameters
- $userId : int
setPrintable()
Sets whether this parser is parsing for printable output
public
setPrintable(mixed $bool) : mixed
Parameters
- $bool : mixed
setQuotePrintableTemplate()
Sets the template to be used for generating quotes
public
setQuotePrintableTemplate(mixed $template_name) : mixed
Parameters
- $template_name : mixed
setQuoteTemplate()
Sets the template to be used for generating quotes
public
setQuoteTemplate(mixed $templateName) : mixed
Parameters
- $templateName : mixed
setQuoteVars()
Sets variables to be passed to the quote template
public
setQuoteVars(mixed $var_array) : mixed
Parameters
- $var_array : mixed
setStripSpace()
Override each tag's default strip_space_after setting .. We don't want to strip spaces when parsing bbcode for the editor
public
setStripSpace(mixed $value) : mixed
Parameters
- $value : mixed
stripFrontBackWhitespace()
Removes the specified amount of line breaks from the front and/or back of the input string. Includes HTML line braeks.
public
stripFrontBackWhitespace(mixed $text[, mixed $max_amount = 1 ][, mixed $strip_front = true ][, mixed $strip_back = true ]) : mixed
Parameters
- $text : mixed
- $max_amount : mixed = 1
- $strip_front : mixed = true
- $strip_back : mixed = true