class vB5_Template_BbCode_Wysiwyg extends vB5_Template_BbCode

BB code parser for the WYSIWYG editor

Constants

BBCODE_HAS_IMG

BBCODE_HAS_ATTACH

BBCODE_HAS_SIGPIC

BBCODE_HAS_RELPATH

PARSER_START

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

PARSER_TEXT

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

Requires $internal_data to be set appropriately.

PARSER_TAG_OPENED

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

Properties

static protected vB5_Config $config from vB5_Template_BbCode
static protected vB5_Template_BbCode $initialized from vB5_Template_BbCode
static protected array $defaultTags A list of default tags to be parsed. from vB5_Template_BbCode
static protected array $defaultOptions A list of default options for most types. from vB5_Template_BbCode
static protected array $customTags A list of custom tags to be parsed. from vB5_Template_BbCode
static protected array $smilies List of smilies from vB5_Template_BbCode
static protected array $censorship Censorship info from vB5_Template_BbCode
static protected $sessionUrl from vB5_Template_BbCode
static protected $blankAsciiStrip from vB5_Template_BbCode
static protected $wordWrap from vB5_Template_BbCode
static protected $bbUrl from vB5_Template_BbCode
static protected $viewAttachedImages from vB5_Template_BbCode
static protected $urlNoFollow from vB5_Template_BbCode
static protected $urlNoFollowWhiteList from vB5_Template_BbCode
static protected $vBHttpHost from vB5_Template_BbCode
static protected $useFileAvatar from vB5_Template_BbCode
static protected $sigpicUrl from vB5_Template_BbCode
protected $renderImmediate from vB5_Template_BbCode
protected array $tag_list A list of tags to be parsed. from vB5_Template_BbCode
protected $currentTag Used alongside the stack. Holds a reference to the node on the stack that is currently being processed. Only applicable in callback functions. from vB5_Template_BbCode
protected bool $printable Whether this parser is parsing for printable output from vB5_Template_BbCode
protected array $options Holds various options such what type of things to parse and cachability. from vB5_Template_BbCode
protected array $cached Holds the cached post if caching was enabled from vB5_Template_BbCode
protected array $attachments Reference to attachment information pertaining to this post Uses nodeid as key from vB5_Template_BbCode
protected $filedatas from vB5_Template_BbCode
protected array $filedataidsToAttachmentids Mapping of filedataid to array of attachment nodeids (aka attachmentids) that uses that filedata. from vB5_Template_BbCode
protected $skipAttachmentList from vB5_Template_BbCode
protected $oldAttachments from vB5_Template_BbCode
protected $turnOffSurroundingAnchor from vB5_Template_BbCode
protected bool $unsetattach Whether this parser unsets attachment info in $this->attachments when an inline attachment is found from vB5_Template_BbCode
protected integer $forumid Id of the forum the source string is in for permissions from vB5_Template_BbCode
protected mixed $containerid Id of the outer container, if applicable from vB5_Template_BbCode
protected array $smilieCache Local cache of smilies for this parser. This is per object to allow WYSIWYG and non-WYSIWYG versions on the same page. from vB5_Template_BbCode
protected 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. from vB5_Template_BbCode
bool $stripSpaceAfter Global override for space stripping from vB5_Template_BbCode
protected $quotePrintableTemplate Template for generating quote links. We need to override for cms comments" * from vB5_Template_BbCode
protected $quoteTemplate Template for generating quote links. We need to override for cms comments" * from vB5_Template_BbCode
protected $quoteVars from vB5_Template_BbCode
protected vB5_Template_BbCode_Table $tableHelper Object to provide the implementation of the table helper to use. from vB5_Template_BbCode
protected $multiPageRender Tells the parser to handle a multi-page render, in which case, the [PAGE] and [PRBREAK] bbcodes are handled differently and are discarded. from vB5_Template_BbCode
protected $userImagePermissions from vB5_Template_BbCode
protected array $unparsed_tags List of tags the WYSIWYG BB code parser should not parse.
protected string $type Type of WYISWYG parser (IE or Mozilla at this point)

Methods

__construct(bool $appendCustomTags = true)

Constructor. Sets up the tag list.

setAttachments(Array $attachments, Bool $skipattachlist = false)

Adds attachments to the class property using attachment nodeid as key.

getAndSetAttachments(int $nodeid)

Called by vB5_Template_Nodetext's parse(), this function fetchs publicly available attachment data for the parent $nodeid and sets that data to the class property $this->attachments via setAttachments() above. This method of separate fetching is required as the text data used by the nodetext parser will lack certain attachment information necessary for correctly rendering [attach] bbcodes & the attachments list if the current user lacks certain permissions

prefetchFiledata($filedataids)

No description

setRenderImmediate(bool $immediate = true)

Sets the engine to render immediately

setMultiPageRender($multiPage)

Sets the parser to handle a multi-page render, in which case, the [PAGE] and [PRBREAK] bbcodes are handled differently and are discarded.

setParseUserinfo(int $userId)

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($bool)

Sets whether this parser is parsing for printable output

string
parse(string $text, int|str $forumid = 0, bool $allowsmilie = true, bool $isimgcheck = false, string $parsedtext = '', int $parsedhasimages = 3, bool $cachable = false, string $htmlstate = null)

Collect parser options and misc data and fully parse the string into an HTML version

string
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, boolean $minimal = false, string $fulltext = '')

Parse the string with the selected options

string
parseDiscard(string $text)

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.

string
parsePageBbcode(string $text)

Handles the [PAGE] bbcode

string
parsePrbreakBbcode(string $text)

Handles the [PRBREAK] bbcode

string
fetchCensoredText(string $text)

Replaces any instances of words censored in self::$censorship['words'] with self::$censorship['char']

array
get_preview(string $pagetext, integer $initial_length = 0, boolean $do_html = false, boolean $do_nl2br = true, string $htmlstate = null, array $options = array())

This is copied from the blog bbcode parser. We either have a specific amount of text, or [PRBREAK][/PRBREAK].

string
doWordWrap(string $text)

Word wraps the text if enabled.

string
parseSmilies(string $text, bool $do_html = false)

Parses smilie codes into their appropriate HTML image versions

replaceSmiliesPregMatch($matches)

Callback function for replacing smilies.

array
cacheSmilies(bool $do_html)

Caches the smilies in a form ready to be executed.

string
parseWhitespaceNewlines(string $text, bool $do_nl2br = true)

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

string
parseBbcode(string $input_text, bool $do_smilies, bool $do_imgcode, bool $do_html = false)

Parse an input string with BB code to a final output string of HTML

array
buildParseArray(string $text)

Takes a raw string and builds an array of tokens for parsing.

array
fixTags(array $preparsed)

Traverses parse array and fixes nesting and mismatched tags.

setStripSpace(bool $value)

Override each tag's default strip_space_after setting .

string
parseArray(array $preparsed, bool $do_smilies, bool $do_imgcode, bool $do_html = false)

Takes a parse array and parses it into the final HTML.

bool
isValidTag(string $tagName, bool/null $hasOption = null)

Checks if the specified tag exists in the list of parsable tags

bool
isValidOption(string $tagName, string $tagOption)

Checks if the specified tag option is valid (matches the regex if there is one)

int/false
findFirstTag(string $tagName, array $stack)

Find the first instance of a tag in an array

int/false
findLastTag(string $tag_name, array $stack)

Find the last instance of a tag in an array.

string
handle_bbcode_indent(string $text, string $type = '')

Handles an [indent] tag.

string
handle_external(string $value, string $option = null)

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.

string
handle_bbcode_email(string $text, string $link = '')

Handles an [email] tag. Creates a link to email an address.

string
handle_bbcode_quote(string $message, string $username = '')

Handles a [quote] tag. Displays a string in an area indicating it was quoted from someone/somewhere else.

string
handle_bbcode_post(string $text, string $postId)

Handles a [post] tag. Creates a link to another post.

string
handle_bbcode_thread(string $text, string $threadId)

Handles a [thread] tag. Creates a link to another thread.

string
handle_bbcode_node(string $text, string $nodeId)

Handles a [node] tag. Creates a link to a node.

string
handle_bbcode_user(string $username = '', string $userid = '')

Displays the [USER] bbcode

string
handle_bbcode_php(string $code)

Handles a [php] tag. Syntax highlights a string of PHP.

emulatePreTag($text)

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.

string
handle_bbcode_video($url, $option)

Handles a [video] tag. Displays a movie.

string
handle_bbcode_code(string $code)

Handles a [code] tag. Displays a preformatted string.

string
handle_bbcode_html(string $code)

Handles an [html] tag. Syntax highlights a string of HTML.

string
handleBbcodeHtmlTagPregMatch(array $matches)

Callback for preg_replace_callback, used by handle_bbcode_html

string
handleBbcodeHtmlTagPregMatchNoEscape(array $matches)

Callback for preg_replace_callback, used by handle_bbcode_html

string
handle_bbcode_html_tag(string $tag)

Handles an individual HTML tag in a [html] tag.

handle_bbcode_h($text, $option)

No description

string
handle_bbcode_size(string $text, string $size)

Handles a [size] tag

string
handle_bbcode_list(string $text, string $type = '')

Handles a [list] tag. Makes a bulleted or ordered list.

string
handle_bbcode_list_element(string $text)

Handles a single bullet of a list

string
handle_bbcode_url(string $text, string $link, bool $image = false)

Handles a [url] tag. Creates a link to another web page.

handle_bbcode_attach($text, $option)

No description

handle_bbcode_img2($text, $option)

No description

processImg2BBCode($data)

No description

processAttachBBCode($data)

No description

addCaption($insertHtml, $settings)

No description

convertImgBitsArrayToHtml($imgbits)

No description

addAnchorAndConvertToHtml($imgbits, $settings, $link, $size, $attachment)

No description

getNearestImageSize($settings)

No description

processCustomImgConfig($config_array)

No description

string
handle_bbcode_img($bbcode, $do_imgcode, $has_img_code = false, $fulltext = '', $forceShowImages = false)

Handles an [img] tag.

handleBbcodeImgMatchCallback($matches)

Callback for preg_replace_callback in handle_bbcode_img

handleBbcodeUrlCallback($matches)

Callback for preg_replace_callback in handle_bbcode_img

handleBBCodeSigPicCallback($matches)

Callback for preg_replace_callback in handle_bbcode_img

attachReplaceCallback($matches)

Callback for preg_replace_callback in handle_bbcode_img

attachReplaceCallbackFinal($matches)

No description

string
handleBbcodeImgMatch($link, $fullsize = false)

Handles a match of the [img] tag that will be displayed as an actual image.

string
handle_bbcode_sigpic(string $description)

Handles the parsing of a signature picture. Most of this is handled based on the $parseUserinfo member.

bool
checkImagePermissions(int $currentUserid, int $parentid)

Returns true of provided $currentUserid has either cangetimageattachment or canseethumbnails permission for the provided $parentid of the attachment.

append_noninline_attachments(string $text, array $attachments, bool $do_imgcode = false, array $skiptheseattachments = array())

No-op so that non-inline attchments are not rendered at the end of the text for the WYSIWYG editor, since we're now using the parent implementation of handle_bbcode_img().

stripFrontBackWhitespace(string $text, int $max_amount = 1, bool $strip_front = true, bool $strip_back = true)

Removes the specified amount of line breaks from the front and/or back of the input string. Includes HTML line braeks.

string
stripSmilies(string $text)

Removes translated smilies from a string.

bool
containsBbcodeImgTags(string $text)

Determines whether a string contains an [img] tag.

int
fetchBlockHeight(string $code)

Returns the height of a block of text in pixels (assuming 16px per line).

array
fetchBbcodeHtmlColors()

Fetches the colors used to highlight HTML in an [html] tag.

bool
isWysiwyg()

Returns whether this parser is a WYSIWYG parser. Useful to change behavior slightly for a WYSIWYG parser without rewriting code.

setQuoteTemplate(string $templateName)

Sets the template to be used for generating quotes

setQuotePrintableTemplate(string $template_name)

Sets the template to be used for generating quotes

setQuoteVars(string $var_array)

Sets variables to be passed to the quote template

vBForum_BBCodeHelper_Table
getTableHelper()

Fetches the table helper in use. It also acts as a lazy initializer.

string
parseTableTag(string $content, string $params = '')

Parses the [table] tag and returns the necessary HTML representation.

string
handle_preformatted_tag(string $code)

Handles a [code]/[html]/[php] tag. In WYSIYWYG parsing, keeps the tag but replaces with a non-breaking space followed by a space.

string
emulate_pre_tag(string $code)

This does it's best to emulate an HTML pre tag and keep whitespace visible in a standard HTML environment. Useful with code/html/php tags.

string
do_word_wrap(string $text)

Perform word wrapping on the text. WYSIWYG parsers should not perform wrapping, so this function does nothing.

string
parse_whitespace_newlines(string $text, bool $do_nl2br = true)

Parses out specific white space before or after cetain tags, rematches tags where necessary, and processes line breaks.

bbcodeRematchTagsWysiwygPregMatch1($matches)

Callback for preg_replace_callback in parse_whitespace_newline

bbcodeRematchTagsWysiwygPregMatch2($matches)

Callback for preg_replace_callback in parse_whitespace_newline

removeWysiwygBreaksPregMatch3($matches)

Callback for preg_replace_callback in parse_whitespace_newline

stripSmiliesPregMatch($matches)

Callback for preg_replace_callback in parseBbcode

string
handle_wysiwyg_unparsable(string $text)

Call back to handle any tag that the WYSIWYG editor can't handle. This parses the tag, but returns an unparsed version of it. The advantage of this method is that any parsing directives (no parsing, no smilies, etc) will still be applied to the text within.

bool
is_wysiwyg(string|null $type = null)

Returns whether this parser is a WYSIWYG parser if no type is specified.

string
bbcode_rematch_tags_wysiwyg(string $innertext, string $tagname, string $tagopen_raw = '')

Automatically inserts a closing tag before a line break and reopens it after.

string
remove_wysiwyg_breaks(string $fulltext)

Removes IE's WYSIWYG breaks from within a list.

Details

at line 47
__construct(bool $appendCustomTags = true)

Constructor. Sets up the tag list.

Parameters

bool $appendCustomTags Whether to append customer user tags to the tag list

in vB5_Template_BbCode at line 305
setAttachments(Array $attachments, Bool $skipattachlist = false)

Adds attachments to the class property using attachment nodeid as key.

Using nodeid keeps us from overwriting separate attachments that are using the same Filedata record.

Parameters

Array $attachments Attachments data array with nodeid, filedataid, parentid, contenttypeid etc, typically from see vB_Api_Node::getNodeAttachments() or see vB_Api_Node::getNodeAttachmentsPublicInfo()
Bool $skipattachlist Only used internally for legacy attachments. Notifies the class to not append these attachments to the list of non-inline attachments.

in vB5_Template_BbCode at line 354
getAndSetAttachments(int $nodeid)

Called by vB5_Template_Nodetext's parse(), this function fetchs publicly available attachment data for the parent $nodeid and sets that data to the class property $this->attachments via setAttachments() above. This method of separate fetching is required as the text data used by the nodetext parser will lack certain attachment information necessary for correctly rendering [attach] bbcodes & the attachments list if the current user lacks certain permissions

Parameters

int $nodeid Nodeid of the content node that's currently being rendered.

in vB5_Template_BbCode at line 386
prefetchFiledata($filedataids)

Parameters

$filedataids

in vB5_Template_BbCode at line 405
setRenderImmediate(bool $immediate = true)

Sets the engine to render immediately

Parameters

bool $immediate whether to set immediate on or off

in vB5_Template_BbCode at line 415
setMultiPageRender($multiPage)

Sets the parser to handle a multi-page render, in which case, the [PAGE] and [PRBREAK] bbcodes are handled differently and are discarded.

Parameters

$multiPage

in vB5_Template_BbCode at line 425
setParseUserinfo(int $userId)

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).

Parameters

int $userId

in vB5_Template_BbCode at line 435
setPrintable($bool)

Sets whether this parser is parsing for printable output

Parameters

$bool

in vB5_Template_BbCode at line 454
string parse(string $text, int|str $forumid = 0, bool $allowsmilie = true, bool $isimgcheck = false, string $parsedtext = '', int $parsedhasimages = 3, bool $cachable = false, string $htmlstate = null)

Collect parser options and misc data and fully parse the string into an HTML version

Parameters

string $text Unparsed text
int|str $forumid ID number of the forum whose parsing options should be used or a "special" string
bool $allowsmilie Whether to allow smilies in this post (if the option is allowed)
bool $isimgcheck Whether to parse the text as an image count check
string $parsedtext Preparsed text ([img] tags should not be parsed)
int $parsedhasimages Whether the preparsed text has images
bool $cachable Whether the parsed post is cachable
string $htmlstate Switch for dealing with nl2br

Return Value

string Parsed text

in vB5_Template_BbCode at line 577
string 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, boolean $minimal = false, string $fulltext = '')

Parse the string with the selected options

Parameters

string $text Unparsed text
bool $do_html Whether to allow HTML (true) or not (false)
bool $do_smilies Whether to parse smilies or not
bool $do_bbcode Whether to parse BB code
bool $do_imgcode Whether to parse the [img] BB code (independent of $do_bbcode)
bool $do_nl2br Whether to automatically replace new lines with HTML line breaks
bool $cachable Whether the post text is cachable
string $htmlstate Switch for dealing with nl2br
boolean $minimal do minimal required actions to parse bbcode
string $fulltext Full rawtext, ignoring pagebreaks.

Return Value

string Parsed text

in vB5_Template_BbCode at line 693
protected string parseDiscard(string $text)

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.

Parameters

string $text Page title

Return Value

string Output of the page header in multi page views, nothing in single page views

in vB5_Template_BbCode at line 705
protected string parsePageBbcode(string $text)

Handles the [PAGE] bbcode

Parameters

string $text The text

Return Value

string

in vB5_Template_BbCode at line 724
protected string parsePrbreakBbcode(string $text)

Handles the [PRBREAK] bbcode

Parameters

string $text The text

Return Value

string

in vB5_Template_BbCode at line 743
string fetchCensoredText(string $text)

Replaces any instances of words censored in self::$censorship['words'] with self::$censorship['char']

Parameters

string $text Text to be censored

Return Value

string

in vB5_Template_BbCode at line 798
array get_preview(string $pagetext, integer $initial_length = 0, boolean $do_html = false, boolean $do_nl2br = true, string $htmlstate = null, array $options = array())

This is copied from the blog bbcode parser. We either have a specific amount of text, or [PRBREAK][/PRBREAK].

Parameters

string $pagetext text to parse
integer $initial_length Length of the text before parsing (optional)
boolean $do_html Flag to indicate whether do html or not
boolean $do_nl2br Flag to indicate whether to convert new lines to
or not
string $htmlstate Defines how to handle html while parsing.
array $options Extra options for parsing. 'do_smilies' => boolean used to handle the smilies display

Return Value

array Tokens, chopped to the right length.

in vB5_Template_BbCode at line 1022
protected string doWordWrap(string $text)

Word wraps the text if enabled.

Parameters

string $text Text to wrap

Return Value

string Wrapped text

in vB5_Template_BbCode at line 1039
protected string parseSmilies(string $text, bool $do_html = false)

Parses smilie codes into their appropriate HTML image versions

Parameters

string $text Text with smilie codes
bool $do_html Whether HTML is allowed

Return Value

string Text with HTML images in place of smilies

in vB5_Template_BbCode at line 1082
protected replaceSmiliesPregMatch($matches)

Callback function for replacing smilies.

Parameters

$matches

in vB5_Template_BbCode at line 1094
protected array cacheSmilies(bool $do_html)

Caches the smilies in a form ready to be executed.

Parameters

bool $do_html Whether HTML parsing is enabled

Return Value

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

in vB5_Template_BbCode at line 1141
protected string parseWhitespaceNewlines(string $text, bool $do_nl2br = true)

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

Parameters

string $text Text to process
bool $do_nl2br Whether to translate newlines to
tags

Return Value

string Processed text

at line 285
string parseBbcode(string $input_text, bool $do_smilies, bool $do_imgcode, bool $do_html = false)

Parse an input string with BB code to a final output string of HTML

Parameters

string $input_text Input Text (BB code)
bool $do_smilies Whether to parse smilies
bool $do_imgcode Whether to parse img (for the video bbcodes)
bool $do_html Whether to allow HTML (for smilies)

Return Value

string Ouput Text (HTML)

in vB5_Template_BbCode at line 1207
protected array buildParseArray(string $text)

Takes a raw string and builds an array of tokens for parsing.

Parameters

string $text Raw text input

Return Value

array List of tokens

in vB5_Template_BbCode at line 1393
protected array fixTags(array $preparsed)

Traverses parse array and fixes nesting and mismatched tags.

Parameters

array $preparsed Parsed data array, such as one from buildParseArray

Return Value

array Parse array with specific data fixed

in vB5_Template_BbCode at line 1523
setStripSpace(bool $value)

Override each tag's default strip_space_after setting .

. We don't want to strip spaces when parsing bbcode for the editor

Parameters

bool $value

in vB5_Template_BbCode at line 1539
protected string parseArray(array $preparsed, bool $do_smilies, bool $do_imgcode, bool $do_html = false)

Takes a parse array and parses it into the final HTML.

Tags are assumed to be matched.

Parameters

array $preparsed Parse array
bool $do_smilies Whether to parse smilies
bool $do_imgcode Whether to parse img (for the video tags)
bool $do_html Whether to allow HTML (for smilies)

Return Value

string Final HTML

in vB5_Template_BbCode at line 1785
protected bool isValidTag(string $tagName, bool/null $hasOption = null)

Checks if the specified tag exists in the list of parsable tags

Parameters

string $tagName Name of the tag
bool/null $hasOption true = tag with option, false = tag without option, null = either

Return Value

bool Whether the tag is valid

in vB5_Template_BbCode at line 1817
protected bool isValidOption(string $tagName, string $tagOption)

Checks if the specified tag option is valid (matches the regex if there is one)

Parameters

string $tagName Name of the tag
string $tagOption Value of the option

Return Value

bool Whether the option is valid

in vB5_Template_BbCode at line 1834
protected int/false findFirstTag(string $tagName, array $stack)

Find the first instance of a tag in an array

Parameters

string $tagName Name of tag
array $stack Array to search

Return Value

int/false Array key of first instance; false if it does not exist

in vB5_Template_BbCode at line 1854
protected int/false findLastTag(string $tag_name, array $stack)

Find the last instance of a tag in an array.

Parameters

string $tag_name Name of tag
array $stack Array to search

Return Value

int/false Array key of first instance; false if it does not exist

in vB5_Template_BbCode at line 1876
protected string handle_bbcode_indent(string $text, string $type = '')

Handles an [indent] tag.

Parameters

string $text The text to indent
string $type Indentation level

Return Value

string HTML representation of the tag.

in vB5_Template_BbCode at line 1907
string handle_external(string $value, string $option = null)

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.

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

string $value Value for the tag
string $option Option for the tag (if it has one)

Return Value

string HTML representation of the tag

in vB5_Template_BbCode at line 1925
protected string handle_bbcode_email(string $text, string $link = '')

Handles an [email] tag. Creates a link to email an address.

Parameters

string $text If tag has option, the displayable email name. Else, the email address.
string $link If tag has option, the email address.

Return Value

string HTML representation of the tag.

in vB5_Template_BbCode at line 1966
string handle_bbcode_quote(string $message, string $username = '')

Handles a [quote] tag. Displays a string in an area indicating it was quoted from someone/somewhere else.

Parameters

string $message The body of the quote.
string $username If tag has option, the original user to post.

Return Value

string HTML representation of the tag.

in vB5_Template_BbCode at line 2014
string handle_bbcode_post(string $text, string $postId)

Handles a [post] tag. Creates a link to another post.

Parameters

string $text If tag has option, the displayable name. Else, the postid.
string $postId If tag has option, the postid.

Return Value

string HTML representation of the tag.

in vB5_Template_BbCode at line 2044
string handle_bbcode_thread(string $text, string $threadId)

Handles a [thread] tag. Creates a link to another thread.

Parameters

string $text If tag has option, the displayable name. Else, the threadid.
string $threadId If tag has option, the threadid.

Return Value

string HTML representation of the tag.

in vB5_Template_BbCode at line 2075
string handle_bbcode_node(string $text, string $nodeId)

Handles a [node] tag. Creates a link to a node.

Parameters

string $text If tag has option, the displayable name. Else, the threadid.
string $nodeId If tag has option, the threadid.

Return Value

string HTML representation of the tag.

at line 469
string handle_bbcode_user(string $username = '', string $userid = '')

Displays the [USER] bbcode

Parameters

string $username The username
string $userid The userid

Return Value

string HTML representation of the tag.

in vB5_Template_BbCode at line 2158
string handle_bbcode_php(string $code)

Handles a [php] tag. Syntax highlights a string of PHP.

Parameters

string $code The code to highlight.

Return Value

string HTML representation of the tag.

in vB5_Template_BbCode at line 2267
protected emulatePreTag($text)

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.

Parameters

$text

in vB5_Template_BbCode at line 2285
protected string handle_bbcode_video($url, $option)

Handles a [video] tag. Displays a movie.

Parameters

$url
$option

Return Value

string HTML representation of the tag.

in vB5_Template_BbCode at line 2321
string handle_bbcode_code(string $code)

Handles a [code] tag. Displays a preformatted string.

Parameters

string $code The code to display

Return Value

string HTML representation of the tag.

in vB5_Template_BbCode at line 2361
string handle_bbcode_html(string $code)

Handles an [html] tag. Syntax highlights a string of HTML.

Parameters

string $code The HTML to highlight.

Return Value

string HTML representation of the tag.

in vB5_Template_BbCode at line 2428
protected string handleBbcodeHtmlTagPregMatch(array $matches)

Callback for preg_replace_callback, used by handle_bbcode_html

Parameters

array $matches matches

Return Value

string the transformed value

in vB5_Template_BbCode at line 2440
protected string handleBbcodeHtmlTagPregMatchNoEscape(array $matches)

Callback for preg_replace_callback, used by handle_bbcode_html

Parameters

array $matches matches

Return Value

string the transformed value

in vB5_Template_BbCode at line 2452
string handle_bbcode_html_tag(string $tag)

Handles an individual HTML tag in a [html] tag.

Parameters

string $tag The body of the tag.

Return Value

string Syntax highlighted, displayable HTML tag.

in vB5_Template_BbCode at line 2549
handle_bbcode_h($text, $option)

Parameters

$text
$option

in vB5_Template_BbCode at line 2571
string handle_bbcode_size(string $text, string $size)

Handles a [size] tag

Parameters

string $text The text to size.
string $size The size to size to

Return Value

string HTML representation of the tag.

in vB5_Template_BbCode at line 2625
string handle_bbcode_list(string $text, string $type = '')

Handles a [list] tag. Makes a bulleted or ordered list.

Parameters

string $text The body of the list.
string $type If tag has option, the type of list (ordered, etc).

Return Value

string HTML representation of the tag.

at line 351
string handle_bbcode_list_element(string $text)

Handles a single bullet of a list

Parameters

string $text Text of bullet

Return Value

string HTML for bullet

in vB5_Template_BbCode at line 2700
string handle_bbcode_url(string $text, string $link, bool $image = false)

Handles a [url] tag. Creates a link to another web page.

Parameters

string $text If tag has option, the displayable name. Else, the URL.
string $link If tag has option, the URL.
bool $image If this is for an image, just return the link

Return Value

string HTML representation of the tag.

in vB5_Template_BbCode at line 2771
protected handle_bbcode_attach($text, $option)

Parameters

$text
$option

in vB5_Template_BbCode at line 2819
protected handle_bbcode_img2($text, $option)

Parameters

$text
$option

in vB5_Template_BbCode at line 2863
protected processImg2BBCode($data)

Parameters

$data

in vB5_Template_BbCode at line 2982
protected processAttachBBCode($data)

Parameters

$data

in vB5_Template_BbCode at line 3265
protected addCaption($insertHtml, $settings)

Parameters

$insertHtml
$settings

in vB5_Template_BbCode at line 3303
protected convertImgBitsArrayToHtml($imgbits)

Parameters

$imgbits

in vB5_Template_BbCode at line 3319
protected addAnchorAndConvertToHtml($imgbits, $settings, $link, $size, $attachment)

Parameters

$imgbits
$settings
$link
$size
$attachment

in vB5_Template_BbCode at line 3418
protected getNearestImageSize($settings)

Parameters

$settings

in vB5_Template_BbCode at line 3488
protected processCustomImgConfig($config_array)

Parameters

$config_array

at line 130
string handle_bbcode_img($bbcode, $do_imgcode, $has_img_code = false, $fulltext = '', $forceShowImages = false)

Handles an [img] tag.

NOTE: This calls the parent implementation so that the [ATTACH] and [IMG] bbcodes render (nearly) the same when editing the post as when displaying the post. The main difference is that the surrounding anchor tags are removed for images in the WYSIWYG editor, via turnOffSurroundingAnchor. See comment before parent function call.

Parameters

$bbcode
$do_imgcode
$has_img_code
$fulltext
$forceShowImages

Return Value

string HTML representation of the tag.

in vB5_Template_BbCode at line 3843
protected handleBbcodeImgMatchCallback($matches)

Callback for preg_replace_callback in handle_bbcode_img

Parameters

$matches

in vB5_Template_BbCode at line 3851
protected handleBbcodeUrlCallback($matches)

Callback for preg_replace_callback in handle_bbcode_img

Parameters

$matches

in vB5_Template_BbCode at line 3859
protected handleBBCodeSigPicCallback($matches)

Callback for preg_replace_callback in handle_bbcode_img

Parameters

$matches

in vB5_Template_BbCode at line 3867
protected attachReplaceCallback($matches)

Callback for preg_replace_callback in handle_bbcode_img

Parameters

$matches

in vB5_Template_BbCode at line 4285
protected attachReplaceCallbackFinal($matches)

Parameters

$matches

in vB5_Template_BbCode at line 4316
string handleBbcodeImgMatch($link, $fullsize = false)

Handles a match of the [img] tag that will be displayed as an actual image.

Parameters

$link
$fullsize

Return Value

string HTML representation of the tag.

in vB5_Template_BbCode at line 4337
string handle_bbcode_sigpic(string $description)

Handles the parsing of a signature picture. Most of this is handled based on the $parseUserinfo member.

Parameters

string $description Description for the sig pic

Return Value

string HTML representation of the sig pic

in vB5_Template_BbCode at line 4400
protected bool checkImagePermissions(int $currentUserid, int $parentid)

Returns true of provided $currentUserid has either cangetimageattachment or canseethumbnails permission for the provided $parentid of the attachment.

Also stores the already checked permissions in the userImagePermissions class variable.

Parameters

int $currentUserid
int $parentid Parent of attachment, usually the "content" post (starter/reply)

Return Value

bool

at line 111
append_noninline_attachments(string $text, array $attachments, bool $do_imgcode = false, array $skiptheseattachments = array())

No-op so that non-inline attchments are not rendered at the end of the text for the WYSIWYG editor, since we're now using the parent implementation of handle_bbcode_img().

Parameters

string $text Text to append attachments
array $attachments Attachment data
bool $do_imgcode Whether to show images
array $skiptheseattachments Array of nodeid => (nodeid, filedataid) attachments that should not be included in the attachment box.

in vB5_Template_BbCode at line 4534
stripFrontBackWhitespace(string $text, int $max_amount = 1, bool $strip_front = true, bool $strip_back = true)

Removes the specified amount of line breaks from the front and/or back of the input string. Includes HTML line braeks.

Parameters

string $text Text to remove white space from
int $max_amount Amount of breaks to remove
bool $strip_front Whether to strip from the front of the string
bool $strip_back Whether to strip from the back of the string

in vB5_Template_BbCode at line 4562
protected string stripSmilies(string $text)

Removes translated smilies from a string.

Parameters

string $text Text to search

Return Value

string Text with smilie HTML returned to smilie codes

in vB5_Template_BbCode at line 4577
protected bool containsBbcodeImgTags(string $text)

Determines whether a string contains an [img] tag.

Parameters

string $text Text to search

Return Value

bool Whether the text contains an [img] tag

in vB5_Template_BbCode at line 4619
protected int fetchBlockHeight(string $code)

Returns the height of a block of text in pixels (assuming 16px per line).

Limited by your "codemaxlines" setting (if > 0).

Parameters

string $code Block of text to find the height of

Return Value

int Number of lines

in vB5_Template_BbCode at line 4646
protected array fetchBbcodeHtmlColors()

Fetches the colors used to highlight HTML in an [html] tag.

Return Value

array array of type (key) to color (value)

in vB5_Template_BbCode at line 4667
protected bool isWysiwyg()

Returns whether this parser is a WYSIWYG parser. Useful to change behavior slightly for a WYSIWYG parser without rewriting code.

Return Value

bool True if it is; false otherwise

in vB5_Template_BbCode at line 4778
setQuoteTemplate(string $templateName)

Sets the template to be used for generating quotes

Parameters

string $templateName the template name *

in vB5_Template_BbCode at line 4787
setQuotePrintableTemplate(string $template_name)

Sets the template to be used for generating quotes

Parameters

string $template_name the template name *

in vB5_Template_BbCode at line 4796
setQuoteVars(string $var_array)

Sets variables to be passed to the quote template

Parameters

string $var_array the template name *

at line 451
vBForum_BBCodeHelper_Table getTableHelper()

Fetches the table helper in use. It also acts as a lazy initializer.

If no table helper has been explicitly set, it will instantiate the class's default.

Return Value

vBForum_BBCodeHelper_Table Table helper object

in vB5_Template_BbCode at line 4829
protected string parseTableTag(string $content, string $params = '')

Parses the [table] tag and returns the necessary HTML representation.

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

string $content Content within the table tag
string $params Optional set of parameters in an unparsed format. Parses "param: value, param: value" form.

Return Value

string HTML representation of the table and its contents.

at line 148
string handle_preformatted_tag(string $code)

Handles a [code]/[html]/[php] tag. In WYSIYWYG parsing, keeps the tag but replaces with a non-breaking space followed by a space.

Parameters

string $code The code to display

Return Value

string Tag with spacing replaced

at line 164
string emulate_pre_tag(string $code)

This does it's best to emulate an HTML pre tag and keep whitespace visible in a standard HTML environment. Useful with code/html/php tags.

Parameters

string $code Code to process

Return Value

string Processed code

at line 179
string do_word_wrap(string $text)

Perform word wrapping on the text. WYSIWYG parsers should not perform wrapping, so this function does nothing.

Parameters

string $text Text to be used for wrapping

Return Value

string Input string (unmodified)

at line 193
string parse_whitespace_newlines(string $text, bool $do_nl2br = true)

Parses out specific white space before or after cetain tags, rematches tags where necessary, and processes line breaks.

Parameters

string $text Text to process
bool $do_nl2br Whether to translate newlines to HTML breaks (unused)

Return Value

string Processed text

at line 254
protected bbcodeRematchTagsWysiwygPregMatch1($matches)

Callback for preg_replace_callback in parse_whitespace_newline

Parameters

$matches

at line 262
protected bbcodeRematchTagsWysiwygPregMatch2($matches)

Callback for preg_replace_callback in parse_whitespace_newline

Parameters

$matches

at line 270
protected removeWysiwygBreaksPregMatch3($matches)

Callback for preg_replace_callback in parse_whitespace_newline

Parameters

$matches

at line 319
protected stripSmiliesPregMatch($matches)

Callback for preg_replace_callback in parseBbcode

Parameters

$matches

at line 334
string handle_wysiwyg_unparsable(string $text)

Call back to handle any tag that the WYSIWYG editor can't handle. This parses the tag, but returns an unparsed version of it. The advantage of this method is that any parsing directives (no parsing, no smilies, etc) will still be applied to the text within.

Parameters

string $text Text inside the tag

Return Value

string The unparsed tag and the text within it

at line 386
bool is_wysiwyg(string|null $type = null)

Returns whether this parser is a WYSIWYG parser if no type is specified.

If a type is specified, it checks whether our type matches

Parameters

string|null $type Type of parser to match; null represents any type

Return Value

bool True if it is; false otherwise

at line 408
string bbcode_rematch_tags_wysiwyg(string $innertext, string $tagname, string $tagopen_raw = '')

Automatically inserts a closing tag before a line break and reopens it after.

Also wraps the text in the tag. Workaround for IE WYSIWYG issue.

Parameters

string $innertext Text to search through
string $tagname Tag to close and reopen (can't include the option)
string $tagopen_raw Raw text that opens the tag (this needs to include the option if there is one)

Return Value

string Processed text

at line 430
string remove_wysiwyg_breaks(string $fulltext)

Removes IE's WYSIWYG breaks from within a list.

Parameters

string $fulltext Text to remove breaks from. Should start with [list] and end with [/list]

Return Value

string Text with breaks removed