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
- BBCODE_HAS_ATTACH = 2
- BBCODE_HAS_IMG = 1
- BBCODE_HAS_RELPATH = 8
- BBCODE_HAS_SIGPIC = 4
- 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.
- $stripSpaceAfter : bool
- Global override for space stripping
- $attachments : array<string|int, mixed>
- Reference to attachment information pertaining to this post Uses nodeid as key
- $baseurl : string
- Forum config baseurl, passed in from presentation
- $baseurl_core : mixed
- $bbUrl : mixed
- $cached : array<string|int, mixed>
- Holds the cached post if caching was enabled
- $containerid : mixed
- Id of the outer container, if applicable
- $currentTag : mixed
- Used alongside the stack. Holds a reference to the node on the stack that is currently being processed. Only applicable in callback functions.
- $customTags : array<string|int, mixed>
- A list of custom tags to be parsed.
- $defaultOptions : array<string|int, mixed>
- A list of default options for most types.
- $defaultTags : array<string|int, mixed>
- A list of default tags to be parsed.
- $delayedUnsetAttachments : mixed
- $doLightbox : mixed
- $filedataidsToAttachmentids : array<string|int, mixed>
- Mapping of filedataid to array of attachment nodeids (aka attachmentids) that uses that filedata.
- $filedatas : mixed
- $forumid : int
- Id of the forum the source string is in for permissions
- $frontendRootProtocolless : mixed
- $frontendurl : mixed
- $frontendUrlProtocolless : mixed
- $initialized : vB_Library_BbCode
- $multiPageRender : mixed
- Tells the parser to handle a multi-page render, in which case, the [PAGE] and [PRBREAK] bbcodes are handled differently and are discarded. Used for CMS Articles.
- $oldAttachments : mixed
- $options : array<string|int, mixed>
- Holds various options such what type of things to parse and cachability.
- $parseUserinfo : array<string|int, mixed>
- If we need to parse using specific user information (such as in a sig), set that info in this member. This should include userid, custom image revision info, and the user's permissions, at the least.
- $printable : bool
- Whether this parser is parsing for printable output
- $quotePrintableTemplate : mixed
- Template for generating quote links. We need to override for cms comments" *
- $quoteTemplate : mixed
- Template for generating quote links. We need to override for cms comments" *
- $quoteVars : mixed
- $sessionSuffix : mixed
- Display full size image attachment if an image is [attach] using without =config, otherwise display a thumbnail
- $sessionUrl : mixed
- $showAttachViews : mixed
- Show attachment view counts in alt texts. *
- $sigpicUrl : mixed
- $skipAttachmentList : mixed
- $smilieCache : array<string|int, mixed>
- Local cache of smilies for this parser. This is per object to allow WYSIWYG and non-WYSIWYG versions on the same page.
- $smilies : array<string|int, mixed>
- List of smilies
- $stringUtil : mixed
- $tableHelper : vB_Library_BbCode_Table
- Object to provide the implementation of the table helper to use.
- $tag_list : array<string|int, mixed>
- A list of tags to be parsed.
- $unsetattach : bool
- Whether this parser unsets attachment info in $this->attachments when an inline attachment is found
- $urlNoFollow : mixed
- $urlNoFollowWhiteList : mixed
- $useFileAvatar : mixed
- $userImagePermissions : mixed
- $vBHttpHost : mixed
- $viewAttachedImages : mixed
- $wordWrap : mixed
- $regexesForUrlDetection : mixed
- $renderImmediate : mixed
- __construct() : mixed
- Constructor. Sets up the tag list.
- __serialize() : mixed
- __sleep() : mixed
- __unserialize() : mixed
- __wakeup() : mixed
- 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.
- 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.
- handle_bbcode_user() : string
- Handles a [USER] tag. Creates a link to the user profile
- handle_external() : string
- Allows extension of the class functionality at run time by calling an external function. To use this, your tag must have a callback of 'handle_external' and define an additional 'external_callback' entry.
- 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.
- 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.
- 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.
- addAnchorAndConvertToHtml() : mixed
- addCaption() : mixed
- attachReplaceCallback() : mixed
- attachReplaceCallbackFinal() : mixed
- bbcodeHtmlTagPregreplace1() : mixed
- Callback for preg_replace_callback used in handle_bbcode_html
- bbcodeHtmlTagPregreplace2() : mixed
- Callback for preg_replace_callback used in handle_bbcode_html
- buildParseArray() : array<string|int, mixed>
- Takes a raw string and builds an array of tokens for parsing.
- cacheSmilies() : array<string|int, mixed>
- Caches the smilies in a form ready to be executed.
- checkImagePermissions() : bool
- Returns true of provided $currentUserid has either cangetimageattachment or canseethumbnails permission for the provided $parentid of the attachment.
- checkImagePermissions2() : mixed
- containsBbcodeImgTags() : bool
- Determines whether a string contains an [img] tag.
- convertImgBitsArrayToHtml() : mixed
- doWordWrap() : string
- Word wraps the text if enabled.
- emulatePreTag() : mixed
- Emulates the behavior of a pre tag in HTML. Tabs and multiple spaces are replaced with spaces mixed with non-breaking spaces. Usually combined with code tags. Note: this still allows the browser to wrap lines.
- fetchBbcodeHtmlColors() : array<string|int, mixed>
- Fetches the colors used to highlight HTML in an [html] tag.
- fetchBlockHeight() : int
- Returns the height of a block of text in pixels (assuming 16px per line).
- findFirstTag() : mixed
- Find the first instance of a tag in an array
- findLastTag() : mixed
- Find the last instance of a tag in an array.
- fixQuoteTags() : mixed
- fixTags() : array<string|int, mixed>
- Traverses parse array and fixes nesting and mismatched tags.
- getNearestImageSize() : mixed
- getPhrase() : mixed
- getUserValue() : mixed
- handle_bbcode_attach() : mixed
- handle_bbcode_email() : string
- Handles an [email] tag. Creates a link to email an address.
- handle_bbcode_img2() : mixed
- handle_bbcode_indent() : string
- Handles an [indent] tag.
- handle_bbcode_node() : string
- Handles a [node] tag. Creates a link to a node.
- handle_bbcode_video() : string
- Handles a [video] tag. Displays a movie.
- handleBbcodeImgMatchCallback() : mixed
- Callback for preg_replace_callback in handle_bbcode_img
- handleBBCodeSigPicCallback() : mixed
- Callback for preg_replace_callback in handle_bbcode_img
- handleBbcodeUrlCallback() : mixed
- Callback for preg_replace_callback in handle_bbcode_img
- isValidOption() : bool
- Checks if the specified tag option is valid (matches the regex if there is one)
- isValidTag() : bool
- Checks if the specified tag exists in the list of parsable tags
- isWysiwyg() : bool
- Returns whether this parser is a WYSIWYG parser. Useful to change behavior slightly for a WYSIWYG parser without rewriting code.
- parseArray() : string
- Takes a parse array and parses it into the final HTML.
- parseBbcode() : string
- Parse an input string with BB code to a final output string of HTML
- parseDiscard() : string
- Used for any tag we ignore. At the time of this, writing that means PRBREAK and PAGE. Both are cms-only and handled outside the parser.
- parsePageBbcode() : string
- Handles the [PAGE] bbcode
- parsePrbreakBbcode() : string
- Handles the [PRBREAK] bbcode
- parseSmilies() : string
- Parses smilie codes into their appropriate HTML image versions
- parseTableTag() : string
- Parses the [table] tag and returns the necessary HTML representation.
- parseWhitespaceNewlines() : string
- Parses out specific white space before or after cetain tags and does nl2br
- processAttachBBCode() : mixed
- processCustomImgConfig() : mixed
- processImg2BBCode() : mixed
- stripSmilies() : string
- Removes translated smilies from a string.
- addLightboxDataToImgbits() : mixed
- addSessionSuffixForMobile() : mixed
- convertUrlToBbcodeCallback() : string
- Callback function for convertUrlToBbcode
- convertUrlToBbcodePregReplace() : text
- Callback for preg_replace_callback in convertUrlToBbcode
- doLightbox() : mixed
- getImageHtml() : mixed
- getLinkHtml() : mixed
- isLocalUrl() : mixed
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
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.
Properties
$stripSpaceAfter
Global override for space stripping
public
bool
$stripSpaceAfter
= rue
$attachments
Reference to attachment information pertaining to this post Uses nodeid as key
protected
array<string|int, mixed>
$attachments
=
ull
$baseurl
Forum config baseurl, passed in from presentation
protected
static string
$baseurl
= ''
$baseurl_core
protected
static mixed
$baseurl_core
= ''
$bbUrl
protected
static mixed
$bbUrl
$cached
Holds the cached post if caching was enabled
protected
array<string|int, mixed>
$cached
= array()
$containerid
Id of the outer container, if applicable
protected
mixed
$containerid
= 0
$currentTag
Used alongside the stack. Holds a reference to the node on the stack that is currently being processed. Only applicable in callback functions.
protected
mixed
$currentTag
=
ull
$customTags
A list of custom tags to be parsed.
protected
static array<string|int, mixed>
$customTags
= array()
$defaultOptions
A list of default options for most types.
protected
static array<string|int, mixed>
$defaultOptions
= array()
Use
$defaultTags
A list of default tags to be parsed.
protected
static array<string|int, mixed>
$defaultTags
= array()
Takes a specific format. See function that defines the array passed into the c'tor.
$delayedUnsetAttachments
protected
mixed
$delayedUnsetAttachments
= array()
$doLightbox
protected
mixed
$doLightbox
= rue
$filedataidsToAttachmentids
Mapping of filedataid to array of attachment nodeids (aka attachmentids) that uses that filedata.
protected
array<string|int, mixed>
$filedataidsToAttachmentids
=
ull
Uses filedataid as first key, then nodeid as next key. Inner value is nodeid. Ex, node 84 & 85 point to filedataid 14, node 86 points to filedataid 15 array( 14 => array(84 => 84, 85 => 85), 15 => array(86), );
Tags
$filedatas
protected
mixed
$filedatas
=
ull
$forumid
Id of the forum the source string is in for permissions
protected
int
$forumid
= 0
$frontendRootProtocolless
protected
mixed
$frontendRootProtocolless
= NULL
$frontendurl
protected
static mixed
$frontendurl
= ''
$frontendUrlProtocolless
protected
mixed
$frontendUrlProtocolless
= NULL
$initialized
protected
static vB_Library_BbCode
$initialized
= alse
$multiPageRender
Tells the parser to handle a multi-page render, in which case, the [PAGE] and [PRBREAK] bbcodes are handled differently and are discarded. Used for CMS Articles.
protected
mixed
$multiPageRender
= alse
$oldAttachments
protected
mixed
$oldAttachments
= array()
$options
Holds various options such what type of things to parse and cachability.
protected
array<string|int, mixed>
$options
= array()
$parseUserinfo
If we need to parse using specific user information (such as in a sig), set that info in this member. This should include userid, custom image revision info, and the user's permissions, at the least.
protected
array<string|int, mixed>
$parseUserinfo
= array()
$printable
Whether this parser is parsing for printable output
protected
bool
$printable
= alse
$quotePrintableTemplate
Template for generating quote links. We need to override for cms comments" *
protected
mixed
$quotePrintableTemplate
= 'bbcode_quote_printable'
$quoteTemplate
Template for generating quote links. We need to override for cms comments" *
protected
mixed
$quoteTemplate
= 'bbcode_quote'
$quoteVars
protected
mixed
$quoteVars
= alse
$sessionSuffix
Display full size image attachment if an image is [attach] using without =config, otherwise display a thumbnail
protected
mixed
$sessionSuffix
= ''
$sessionUrl
protected
static mixed
$sessionUrl
$showAttachViews
Show attachment view counts in alt texts. *
protected
mixed
$showAttachViews
= rue
$sigpicUrl
protected
static mixed
$sigpicUrl
$skipAttachmentList
protected
mixed
$skipAttachmentList
= array()
$smilieCache
Local cache of smilies for this parser. This is per object to allow WYSIWYG and non-WYSIWYG versions on the same page.
protected
array<string|int, mixed>
$smilieCache
= array()
$smilies
List of smilies
protected
static array<string|int, mixed>
$smilies
= array()
$stringUtil
protected
mixed
$stringUtil
$tableHelper
Object to provide the implementation of the table helper to use.
protected
vB_Library_BbCode_Table
$tableHelper
=
ull
See setTableHelper and getTableHelper.
$tag_list
A list of tags to be parsed.
protected
array<string|int, mixed>
$tag_list
= array()
Takes a specific format. See function that defines the array passed into the c'tor.
$unsetattach
Whether this parser unsets attachment info in $this->attachments when an inline attachment is found
protected
bool
$unsetattach
= rue
$urlNoFollow
protected
static mixed
$urlNoFollow
$urlNoFollowWhiteList
protected
static mixed
$urlNoFollowWhiteList
$useFileAvatar
protected
static mixed
$useFileAvatar
$userImagePermissions
protected
mixed
$userImagePermissions
= []
$vBHttpHost
protected
static mixed
$vBHttpHost
$viewAttachedImages
protected
static mixed
$viewAttachedImages
$wordWrap
protected
static mixed
$wordWrap
$regexesForUrlDetection
private
mixed
$regexesForUrlDetection
$renderImmediate
private
mixed
$renderImmediate
= rue
Methods
__construct()
Constructor. Sets up the tag list.
public
__construct([mixed $appendCustomTags = true ][, mixed $appendSessionHashToImage = false ]) : mixed
Parameters
- $appendCustomTags : mixed = true
- $appendSessionHashToImage : mixed = false
Return values
mixed —__serialize()
public
__serialize() : mixed
Return values
mixed —__sleep()
public
__sleep() : mixed
Return values
mixed —__unserialize()
public
__unserialize(mixed $serialized) : mixed
Parameters
- $serialized : mixed
Return values
mixed —__wakeup()
public
__wakeup() : mixed
Return values
mixed —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 = array() ]) : mixed
Parameters
- $text : mixed
- $attachments : mixed
- $do_imgcode : mixed = false
- $skiptheseattachments : mixed = array()
Return values
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(mixed $text[, mixed $do_html = false ][, mixed $do_smilies = true ][, mixed $do_bbcode = true ][, mixed $do_imgcode = true ][, mixed $do_nl2br = true ][, mixed $cachable = false ][, mixed $htmlstate = null ][, mixed $minimal = false ][, mixed $fulltext = '' ][, mixed $do_censor = true ]) : string
Parameters
- $text : mixed
- $do_html : mixed = false
- $do_smilies : mixed = true
- $do_bbcode : mixed = true
- $do_imgcode : mixed = true
- $do_nl2br : mixed = true
- $cachable : mixed = false
- $htmlstate : mixed = null
- $minimal : mixed = false
- $fulltext : mixed = ''
- $do_censor : mixed = true
Return values
string —Parsed text
fetchBBCodes()
Gets the current bbCode List
public
fetchBBCodes() : mixed
Return values
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[, mixed $do_html = false ][, mixed $do_nl2br = true ][, mixed $htmlstate = null ][, mixed $options = array() ]) : array<string|int, mixed>
Parameters
- $pagetext : mixed
- $initial_length : mixed
- $do_html : mixed = false
- $do_nl2br : mixed = true
- $htmlstate : mixed = null
- $options : mixed = array()
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
Return values
mixed —getAttachments()
public
getAttachments() : mixed
Return values
mixed —getRegexesForUrlDetection()
public
getRegexesForUrlDetection() : mixed
Return values
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
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
Return values
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 $image = false ]) : string
Parameters
- $text : mixed
- $link : mixed
- $image : mixed = false
Return values
string —HTML representation of the tag.
handle_bbcode_user()
Handles a [USER] tag. Creates a link to the user profile
public
handle_bbcode_user([mixed $username = '' ][, mixed $userid = '' ]) : string
Parameters
- $username : mixed = ''
- $userid : mixed = ''
Return values
string —HTML representation of the tag.
handle_external()
Allows extension of the class functionality at run time by calling an external function. To use this, your tag must have a callback of 'handle_external' and define an additional 'external_callback' entry.
public
handle_external(mixed $value[, mixed $option = null ]) : string
Your function will receive 3 parameters: A reference to this BB code parser The value for the tag The option for the tag Ensure that you accept at least the first parameter by reference!
Parameters
- $value : mixed
- $option : mixed = null
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[, mixed $allowsmilie = true ][, mixed $isimgcheck = false ][, mixed $parsedtext = '' ][, mixed $parsedhasimages = 3 ][, mixed $cachable = false ][, mixed $htmlstate = null ]) : string
Parameters
- $text : mixed
- $forumid : mixed
- $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.
Return values
mixed —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
Return values
mixed —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
Return values
mixed —setPrintable()
Sets whether this parser is parsing for printable output
public
setPrintable(mixed $bool) : mixed
Parameters
- $bool : mixed
Return values
mixed —setQuotePrintableTemplate()
Sets the template to be used for generating quotes
public
setQuotePrintableTemplate(mixed $template_name) : mixed
Parameters
- $template_name : mixed
Return values
mixed —setQuoteTemplate()
Sets the template to be used for generating quotes
public
setQuoteTemplate(mixed $templateName) : mixed
Parameters
- $templateName : mixed
Return values
mixed —setQuoteVars()
Sets variables to be passed to the quote template
public
setQuoteVars(mixed $var_array) : mixed
Parameters
- $var_array : mixed
Return values
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
Return values
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
Return values
mixed —addAnchorAndConvertToHtml()
protected
addAnchorAndConvertToHtml(mixed $imgbits, mixed $settings, mixed $link, mixed $size) : mixed
Parameters
- $imgbits : mixed
- $settings : mixed
- $link : mixed
- $size : mixed
Return values
mixed —addCaption()
protected
addCaption(mixed $insertHtml, mixed $settings) : mixed
Parameters
- $insertHtml : mixed
- $settings : mixed
Return values
mixed —attachReplaceCallback()
protected
attachReplaceCallback(mixed $matches) : mixed
Parameters
- $matches : mixed
Return values
mixed —attachReplaceCallbackFinal()
protected
attachReplaceCallbackFinal(mixed $matches) : mixed
Parameters
- $matches : mixed
Return values
mixed —bbcodeHtmlTagPregreplace1()
Callback for preg_replace_callback used in handle_bbcode_html
protected
bbcodeHtmlTagPregreplace1(mixed $matches) : mixed
Parameters
- $matches : mixed
Return values
mixed —bbcodeHtmlTagPregreplace2()
Callback for preg_replace_callback used in handle_bbcode_html
protected
bbcodeHtmlTagPregreplace2(mixed $matches) : mixed
Parameters
- $matches : mixed
Return values
mixed —buildParseArray()
Takes a raw string and builds an array of tokens for parsing.
protected
buildParseArray(mixed $text) : array<string|int, mixed>
Parameters
- $text : mixed
Return values
array<string|int, mixed> —List of tokens
cacheSmilies()
Caches the smilies in a form ready to be executed.
protected
cacheSmilies(mixed $do_html) : array<string|int, mixed>
Parameters
- $do_html : mixed
Return values
array<string|int, mixed> —Reference to smilie cache (key: find text; value: replace text)
checkImagePermissions()
Returns true of provided $currentUserid has either cangetimageattachment or canseethumbnails permission for the provided $parentid of the attachment.
protected
checkImagePermissions(int $currentUserid, int $parentid) : bool
Also stores the already checked permissions in the userImagePermissions class variable.
Parameters
- $currentUserid : int
- $parentid : int
-
Parent of attachment, usually the "content" post (starter/reply)
Return values
bool —checkImagePermissions2()
protected
checkImagePermissions2(mixed $currentUserid, mixed $parentid) : mixed
Parameters
- $currentUserid : mixed
- $parentid : mixed
Return values
mixed —containsBbcodeImgTags()
Determines whether a string contains an [img] tag.
protected
containsBbcodeImgTags(mixed $text) : bool
Parameters
- $text : mixed
Return values
bool —Whether the text contains an [img] tag
convertImgBitsArrayToHtml()
protected
convertImgBitsArrayToHtml(mixed $imgbits) : mixed
Parameters
- $imgbits : mixed
Return values
mixed —doWordWrap()
Word wraps the text if enabled.
protected
doWordWrap(mixed $text) : string
Parameters
- $text : mixed
Return values
string —Wrapped text
emulatePreTag()
Emulates the behavior of a pre tag in HTML. Tabs and multiple spaces are replaced with spaces mixed with non-breaking spaces. Usually combined with code tags. Note: this still allows the browser to wrap lines.
protected
emulatePreTag(mixed $text) : mixed
Parameters
- $text : mixed
Return values
mixed —fetchBbcodeHtmlColors()
Fetches the colors used to highlight HTML in an [html] tag.
protected
fetchBbcodeHtmlColors() : array<string|int, mixed>
Return values
array<string|int, mixed> —array of type (key) to color (value)
fetchBlockHeight()
Returns the height of a block of text in pixels (assuming 16px per line).
protected
fetchBlockHeight(mixed $code) : int
Limited by your "codemaxlines" setting (if > 0).
Parameters
- $code : mixed
Return values
int —Number of lines
findFirstTag()
Find the first instance of a tag in an array
protected
findFirstTag(mixed $tagName, mixed &$stack) : mixed
Parameters
- $tagName : mixed
- $stack : mixed
Return values
mixed —findLastTag()
Find the last instance of a tag in an array.
protected
findLastTag(mixed $tag_name, mixed &$stack) : mixed
Parameters
- $tag_name : mixed
- $stack : mixed
Return values
mixed —fixQuoteTags()
protected
fixQuoteTags(mixed $elements) : mixed
Parameters
- $elements : mixed
Tags
Return values
mixed —fixTags()
Traverses parse array and fixes nesting and mismatched tags.
protected
fixTags(mixed $preparsed) : array<string|int, mixed>
Parameters
- $preparsed : mixed
Return values
array<string|int, mixed> —Parse array with specific data fixed
getNearestImageSize()
protected
getNearestImageSize(mixed $settings) : mixed
Parameters
- $settings : mixed
Return values
mixed —getPhrase()
protected
getPhrase() : mixed
Return values
mixed —getUserValue()
protected
getUserValue(mixed $value) : mixed
Parameters
- $value : mixed
Return values
mixed —handle_bbcode_attach()
protected
handle_bbcode_attach(mixed $text, mixed $option) : mixed
Parameters
- $text : mixed
- $option : mixed
Return values
mixed —handle_bbcode_email()
Handles an [email] tag. Creates a link to email an address.
protected
handle_bbcode_email(mixed $text[, mixed $link = '' ]) : string
Parameters
- $text : mixed
- $link : mixed = ''
Return values
string —HTML representation of the tag.
handle_bbcode_img2()
protected
handle_bbcode_img2(mixed $text, mixed $option) : mixed
Parameters
- $text : mixed
- $option : mixed
Return values
mixed —handle_bbcode_indent()
Handles an [indent] tag.
protected
handle_bbcode_indent(mixed $text[, mixed $type = '' ]) : string
Parameters
- $text : mixed
- $type : mixed = ''
Return values
string —HTML representation of the tag.
handle_bbcode_node()
Handles a [node] tag. Creates a link to a node.
protected
handle_bbcode_node(mixed $text, mixed $nodeId) : string
Parameters
- $text : mixed
- $nodeId : mixed
Return values
string —HTML representation of the tag.
handle_bbcode_video()
Handles a [video] tag. Displays a movie.
protected
handle_bbcode_video(mixed $url, mixed $option) : string
Parameters
- $url : mixed
- $option : mixed
Return values
string —HTML representation of the tag.
handleBbcodeImgMatchCallback()
Callback for preg_replace_callback in handle_bbcode_img
protected
handleBbcodeImgMatchCallback(mixed $matches) : mixed
Parameters
- $matches : mixed
Return values
mixed —handleBBCodeSigPicCallback()
Callback for preg_replace_callback in handle_bbcode_img
protected
handleBBCodeSigPicCallback(mixed $matches) : mixed
Parameters
- $matches : mixed
Return values
mixed —handleBbcodeUrlCallback()
Callback for preg_replace_callback in handle_bbcode_img
protected
handleBbcodeUrlCallback(mixed $matches) : mixed
Parameters
- $matches : mixed
Return values
mixed —isValidOption()
Checks if the specified tag option is valid (matches the regex if there is one)
protected
isValidOption(mixed $tagName, mixed $tagOption) : bool
Parameters
- $tagName : mixed
- $tagOption : mixed
Return values
bool —Whether the option is valid
isValidTag()
Checks if the specified tag exists in the list of parsable tags
protected
isValidTag(mixed $tagName[, mixed $hasOption = null ]) : bool
Parameters
- $tagName : mixed
- $hasOption : mixed = null
Return values
bool —Whether the tag is valid
isWysiwyg()
Returns whether this parser is a WYSIWYG parser. Useful to change behavior slightly for a WYSIWYG parser without rewriting code.
protected
isWysiwyg() : bool
Return values
bool —True if it is; false otherwise
parseArray()
Takes a parse array and parses it into the final HTML.
protected
parseArray(mixed $preparsed, mixed $do_smilies, mixed $do_imgcode[, mixed $do_html = false ][, mixed $do_censor = true ]) : string
Tags are assumed to be matched.
Parameters
- $preparsed : mixed
- $do_smilies : mixed
- $do_imgcode : mixed
- $do_html : mixed = false
- $do_censor : mixed = true
Return values
string —Final HTML
parseBbcode()
Parse an input string with BB code to a final output string of HTML
protected
parseBbcode(mixed $input_text, mixed $do_smilies, mixed $do_imgcode[, mixed $do_html = false ][, mixed $do_censor = true ]) : string
Parameters
- $input_text : mixed
- $do_smilies : mixed
- $do_imgcode : mixed
- $do_html : mixed = false
- $do_censor : mixed = true
Return values
string —Ouput Text (HTML)
parseDiscard()
Used for any tag we ignore. At the time of this, writing that means PRBREAK and PAGE. Both are cms-only and handled outside the parser.
protected
parseDiscard(mixed $text) : string
Parameters
- $text : mixed
Return values
string —Output of the page header in multi page views, nothing in single page views
parsePageBbcode()
Handles the [PAGE] bbcode
protected
parsePageBbcode(mixed $text) : string
Parameters
- $text : mixed
Return values
string —parsePrbreakBbcode()
Handles the [PRBREAK] bbcode
protected
parsePrbreakBbcode(mixed $text) : string
Parameters
- $text : mixed
Return values
string —parseSmilies()
Parses smilie codes into their appropriate HTML image versions
protected
parseSmilies(mixed $text[, mixed $do_html = false ]) : string
Parameters
- $text : mixed
- $do_html : mixed = false
Return values
string —Text with HTML images in place of smilies
parseTableTag()
Parses the [table] tag and returns the necessary HTML representation.
protected
parseTableTag(mixed $content[, mixed $params = '' ]) : string
TRs and TDs are parsed by this function (they are not real BB codes). Classes are pushed down to inner tags (TRs and TDs) and TRs are automatically valigned top.
Parameters
- $content : mixed
- $params : mixed = ''
Return values
string —HTML representation of the table and its contents.
parseWhitespaceNewlines()
Parses out specific white space before or after cetain tags and does nl2br
protected
parseWhitespaceNewlines(mixed $text[, mixed $do_nl2br = true ]) : string
Parameters
- $text : mixed
- $do_nl2br : mixed = true
Return values
string —Processed text
processAttachBBCode()
protected
processAttachBBCode(mixed $data) : mixed
Parameters
- $data : mixed
Return values
mixed —processCustomImgConfig()
protected
processCustomImgConfig(mixed $config_array) : mixed
Parameters
- $config_array : mixed
Return values
mixed —processImg2BBCode()
protected
processImg2BBCode(mixed $data) : mixed
Parameters
- $data : mixed
Return values
mixed —stripSmilies()
Removes translated smilies from a string.
protected
stripSmilies(mixed $text) : string
Parameters
- $text : mixed
Return values
string —Text with smilie HTML returned to smilie codes
addLightboxDataToImgbits()
private
addLightboxDataToImgbits(mixed &$imgbits, mixed $settings, mixed $link, mixed $size, mixed $attachment) : mixed
Parameters
- $imgbits : mixed
- $settings : mixed
- $link : mixed
- $size : mixed
- $attachment : mixed
Return values
mixed —addSessionSuffixForMobile()
private
addSessionSuffixForMobile(mixed $url) : mixed
Parameters
- $url : mixed
Return values
mixed —convertUrlToBbcodeCallback()
Callback function for convertUrlToBbcode
private
convertUrlToBbcodeCallback(mixed $messagetext, mixed $prepend) : string
Parameters
- $messagetext : mixed
- $prepend : mixed
Return values
string —convertUrlToBbcodePregReplace()
Callback for preg_replace_callback in convertUrlToBbcode
private
convertUrlToBbcodePregReplace(mixed $matches) : text
Parameters
- $matches : mixed
Return values
text —Text with the URLs converted to BBcode
doLightbox()
private
doLightbox(mixed $settings, mixed $attachment) : mixed
Parameters
- $settings : mixed
- $attachment : mixed
Return values
mixed —getImageHtml()
private
getImageHtml(mixed $settings, mixed $link, mixed $size[, mixed $attachment = [] ][, mixed $imgbitsExtras = [] ]) : mixed
Parameters
- $settings : mixed
- $link : mixed
- $size : mixed
- $attachment : mixed = []
- $imgbitsExtras : mixed = []
Return values
mixed —getLinkHtml()
private
getLinkHtml(mixed $settings, mixed $link, mixed $size[, mixed $attachment = [] ]) : mixed
Parameters
- $settings : mixed
- $link : mixed
- $size : mixed
- $attachment : mixed = []
Return values
mixed —isLocalUrl()
private
isLocalUrl(mixed $url) : mixed
Parameters
- $url : mixed