class parse_message extends bbcode_firstpass

Main message parser for posting, pm, etc. takes raw message and parses it for attachments, bbcode and smilies

Properties

$bbcode_uid from  bbcode
$bbcode_bitfield from  bbcode
$bbcode_cache from  bbcode
$bbcode_template from  bbcode
$bbcodes from  bbcode
$template_bitfield from  bbcode
protected $template_filename from  bbcode
$message from  bbcode_firstpass
$warn_msg from  bbcode_firstpass
$parsed_items from  bbcode_firstpass
$mode from  bbcode_firstpass
$attachment_data
$filename_data
$message_status
$allow_img_bbcode
$allow_quote_bbcode
$allow_url_bbcode
protected plupload $plupload

The plupload object used for dealing with attachments

Methods

__construct($message = '')

Init - give message here or manually

bbcode_set_bitfield(string $bitfield = '')

Init bbcode cache entries if bitfield is specified

from  bbcode
bbcode_second_pass($message, $bbcode_uid = '', $bbcode_bitfield = false)

Second pass bbcodes

from  bbcode
bbcode_cache_init()

Init bbcode cache

from  bbcode
bbcode_tpl($tpl_name, $bbcode_id = -1, $skip_bitfield_check = false)

Return bbcode template

from  bbcode
bbcode_tpl_replace($tpl_name, $tpl)

Return bbcode template replacement

from  bbcode
bbcode_list($type)

Second parse list bbcode

from  bbcode
bbcode_second_pass_quote($username, $quote)

Second parse quote tag

from  bbcode
bbcode_second_pass_code($type, $code)

Second parse code tag

from  bbcode
bool
bbcode_second_pass_by_extension() deprecated

Function to perform custom bbcode second pass by extensions can be used to assign bbcode pattern replacement Example: '#[list=([^[]+):$uid]#e' => "\$this->bbcode_second_pass_by_extension('\$1')"

from  bbcode
parse_bbcode()

Parse BBCode

prepare_bbcodes()

Prepare some bbcodes for better parsing

bbcode_init($allow_custom_bbcode = true)

Init bbcode data for later parsing

check_bbcode($bbcode, $in)

Making some pre-checks for bbcodes as well as increasing the number of parsed items

bbcode_specialchars($text)

Transform some characters in valid bbcodes

bbcode_size($stx, $in)

Parse size tag

bbcode_color($stx, $in)

Parse color tag

bbcode_underline($in)

Parse u tag

bbcode_strong($in)

Parse b tag

bbcode_italic($in)

Parse i tag

bbcode_img($in)

Parse img tag

bbcode_attachment($stx, $in)

Parse inline attachments [ia]

bbcode_code($stx, $in)

Parse code tag Expects the argument to start right after the opening [code] tag and to end with [/code]

bbcode_parse_list($in)

Parse list bbcode Expects the argument to start with a tag

bbcode_quote($in)

Parse quote bbcode Expects the argument to start with a tag

validate_email($var1, $var2)

Validate email

validate_url(string $var1, string $var2)

Validate url

parse($allow_bbcode, $allow_magic_url, $allow_smilies, $allow_img_bbcode = true, $allow_quote_bbcode = true, $allow_url_bbcode = true, $update_this_message = true, $mode = 'post')

Parse Message

format_display($allow_bbcode, $allow_magic_url, $allow_smilies, $update_this_message = true)

Formatting text for display

decode_message($custom_bbcode_uid = '', $update_this_message = true)

Decode message to be placed back into form box

magic_url($server_url)

Replace magic urls of form http://xxx.xxx., www.xxx. and xxx@xxx.xxx.

smilies($max_smilies = 0)

Parse Smilies

bool
check_attachment_form_token(language $language, request_interface $request, string $form_name)

Check attachment form token depending on submit type

parse_attachments($form_name, $mode, $forum_id, $submit, $preview, $refresh, $is_message = false)

Parse Attachments

get_submitted_attachment_data($check_user_id = false)

Get Attachment Data

parse_poll($poll)

Parse Poll

void
remove_nested_quotes(int $max_depth)

Remove nested quotes at given depth in current parsed message

null
set_plupload(plupload $plupload)

Setter function for passing the plupload object

mixed
validate_bbcode_by_extension()

Function to perform custom bbcode validation by extensions can be used in bbcode_init() to assign regexp replacement Example: 'regexp' => array('#[b](.*?)[/b]#uise' => "\$this->validate_bbcode_by_extension('\$1')")

Details

at line 1056
__construct($message = '')

Init - give message here or manually

Parameters

$message

in bbcode at line 51
bbcode_set_bitfield(string $bitfield = '')

Init bbcode cache entries if bitfield is specified

Parameters

string $bitfield

The bbcode bitfield

in bbcode at line 63
bbcode_second_pass($message, $bbcode_uid = '', $bbcode_bitfield = false)

Second pass bbcodes

Parameters

$message
$bbcode_uid
$bbcode_bitfield

in bbcode at line 152
bbcode_cache_init()

Init bbcode cache

requires: $this->bbcode_bitfield sets: $this->bbcode_cache with bbcode templates needed for bbcode_bitfield

in bbcode at line 449
bbcode_tpl($tpl_name, $bbcode_id = -1, $skip_bitfield_check = false)

Return bbcode template

Parameters

$tpl_name
$bbcode_id
$skip_bitfield_check

in bbcode at line 514
bbcode_tpl_replace($tpl_name, $tpl)

Return bbcode template replacement

Parameters

$tpl_name
$tpl

in bbcode at line 542
bbcode_list($type)

Second parse list bbcode

Parameters

$type

in bbcode at line 591
bbcode_second_pass_quote($username, $quote)

Second parse quote tag

Parameters

$username
$quote

in bbcode at line 612
bbcode_second_pass_code($type, $code)

Second parse code tag

Parameters

$type
$code

in bbcode at line 665
bool bbcode_second_pass_by_extension() deprecated

deprecated 3.2.10 (To be removed 4.0.0)

Function to perform custom bbcode second pass by extensions can be used to assign bbcode pattern replacement Example: '#[list=([^[]+):$uid]#e' => "\$this->bbcode_second_pass_by_extension('\$1')"

Accepts variable number of parameters

Return Value

bool

Second pass result

in bbcode_firstpass at line 54
parse_bbcode()

Parse BBCode

in bbcode_firstpass at line 107
prepare_bbcodes()

Prepare some bbcodes for better parsing

in bbcode_firstpass at line 128
bbcode_init($allow_custom_bbcode = true)

Init bbcode data for later parsing

Parameters

$allow_custom_bbcode

in bbcode_firstpass at line 263
check_bbcode($bbcode, $in)

Making some pre-checks for bbcodes as well as increasing the number of parsed items

Parameters

$bbcode
$in

in bbcode_firstpass at line 283
bbcode_specialchars($text)

Transform some characters in valid bbcodes

Parameters

$text

in bbcode_firstpass at line 294
bbcode_size($stx, $in)

Parse size tag

Parameters

$stx
$in

in bbcode_firstpass at line 322
bbcode_color($stx, $in)

Parse color tag

Parameters

$stx
$in

in bbcode_firstpass at line 335
bbcode_underline($in)

Parse u tag

Parameters

$in

in bbcode_firstpass at line 348
bbcode_strong($in)

Parse b tag

Parameters

$in

in bbcode_firstpass at line 361
bbcode_italic($in)

Parse i tag

Parameters

$in

in bbcode_firstpass at line 374
bbcode_img($in)

Parse img tag

Parameters

$in

in bbcode_firstpass at line 411
bbcode_attachment($stx, $in)

Parse inline attachments [ia]

Parameters

$stx
$in

in bbcode_firstpass at line 494
bbcode_code($stx, $in)

Parse code tag Expects the argument to start right after the opening [code] tag and to end with [/code]

Parameters

$stx
$in

in bbcode_firstpass at line 587
bbcode_parse_list($in)

Parse list bbcode Expects the argument to start with a tag

Parameters

$in

in bbcode_firstpass at line 715
bbcode_quote($in)

Parse quote bbcode Expects the argument to start with a tag

Parameters

$in

in bbcode_firstpass at line 884
validate_email($var1, $var2)

Validate email

Parameters

$var1
$var2

in bbcode_firstpass at line 924
validate_url(string $var1, string $var2)

Validate url

Parameters

string $var1

optional url parameter for url bbcode: [url(=$var1)]$var2[/url]

string $var2

url bbcode content: [url(=$var1)]$var2[/url]

at line 1067
parse($allow_bbcode, $allow_magic_url, $allow_smilies, $allow_img_bbcode = true, $allow_quote_bbcode = true, $allow_url_bbcode = true, $update_this_message = true, $mode = 'post')

Parse Message

Parameters

$allow_bbcode
$allow_magic_url
$allow_smilies
$allow_img_bbcode
$allow_quote_bbcode
$allow_url_bbcode
$update_this_message
$mode

at line 1243
format_display($allow_bbcode, $allow_magic_url, $allow_smilies, $update_this_message = true)

Formatting text for display

Parameters

$allow_bbcode
$allow_magic_url
$allow_smilies
$update_this_message

at line 1333
decode_message($custom_bbcode_uid = '', $update_this_message = true)

Decode message to be placed back into form box

Parameters

$custom_bbcode_uid
$update_this_message

at line 1360
magic_url($server_url)

Replace magic urls of form http://xxx.xxx., www.xxx. and xxx@xxx.xxx.

Cuts down displayed size of link if over 50 chars, turns absolute links into relative versions when the server/script path matches the link

Parameters

$server_url

at line 1369
smilies($max_smilies = 0)

Parse Smilies

Parameters

$max_smilies

at line 1448
bool check_attachment_form_token(language $language, request_interface $request, string $form_name)

Check attachment form token depending on submit type

Parameters

language $language Language
request_interface $request Request
string $form_name

Form name for checking form key

Return Value

bool

True if form token is not needed or valid, false if needed and invalid

at line 1471
parse_attachments($form_name, $mode, $forum_id, $submit, $preview, $refresh, $is_message = false)

Parse Attachments

Parameters

$form_name
$mode
$forum_id
$submit
$preview
$refresh
$is_message

at line 1763
get_submitted_attachment_data($check_user_id = false)

Get Attachment Data

Parameters

$check_user_id

at line 1851
parse_poll($poll)

Parse Poll

Parameters

$poll

at line 1914
void remove_nested_quotes(int $max_depth)

Remove nested quotes at given depth in current parsed message

Parameters

int $max_depth

Depth limit

Return Value

void

at line 1972
null set_plupload(plupload $plupload)

Setter function for passing the plupload object

Parameters

plupload $plupload

The plupload object

Return Value

null

at line 1986
mixed validate_bbcode_by_extension()

Function to perform custom bbcode validation by extensions can be used in bbcode_init() to assign regexp replacement Example: 'regexp' => array('#[b](.*?)[/b]#uise' => "\$this->validate_bbcode_by_extension('\$1')")

Accepts variable number of parameters

Return Value

mixed

Validation result