interface utils_interface

Used to manipulate a parsed text

In this interface, "plain text" refers to regular text as it would be inputted by a user. "Parsed text" refers to whichever form is returned by the implementation after parsing, which should be suitable to be reinserted into the database.

Methods

string
clean_formatting(string $text)

Replace BBCodes and other formatting elements with whitespace

string
generate_quote(string $text, array $attributes = array())

Create a quote block for given text

string[]
get_outermost_quote_authors(string $text)

Get a list of quote authors, limited to the outermost quotes

string
remove_bbcode(string $text, string $bbcode_name, int $depth = 0)

Remove given BBCode and its content, at given nesting depth

string
unparse(string $text)

Return a parsed text to its original form

bool
is_empty(string $text)

Return whether or not a parsed text represent an empty text.

Details

at line 33
string clean_formatting(string $text)

Replace BBCodes and other formatting elements with whitespace

NOTE: preserves smilies as text

Parameters

string $text

Parsed text

Return Value

string

Plain text

at line 48
string generate_quote(string $text, array $attributes = array())

Create a quote block for given text

Possible attributes:

  • author: author's name (usually a username)
  • post_id: post_id of the post being quoted
  • user_id: user_id of the user being quoted
  • time: timestamp of the original message

Parameters

string $text

Quote's text

array $attributes

Quote's attributes

Return Value

string

Quote block to be used in a new post/text

at line 56
string[] get_outermost_quote_authors(string $text)

Get a list of quote authors, limited to the outermost quotes

Parameters

string $text

Parsed text

Return Value

string[]

List of authors

at line 66
string remove_bbcode(string $text, string $bbcode_name, int $depth = 0)

Remove given BBCode and its content, at given nesting depth

Parameters

string $text

Parsed text

string $bbcode_name

BBCode's name

int $depth

Minimum nesting depth (number of parents of the same name)

Return Value

string

Parsed text

at line 74
string unparse(string $text)

Return a parsed text to its original form

Parameters

string $text

Parsed text

Return Value

string

Original plain text

at line 82
bool is_empty(string $text)

Return whether or not a parsed text represent an empty text.

Parameters

string $text

Parsed text

Return Value

bool

True if the original text is empty