utils
class utils implements utils_interface
Text manipulation utilities
In this implementation, "plain text" refers to regular text as it would be inputted by a user. "Parsed text" is XML suitable to be reinserted into the database.
Methods
Replace BBCodes and other formatting elements with whitespace
Format given string to be used as an attribute value
Create a quote block for given text
Get a list of quote authors, limited to the outermost quotes
Remove given BBCode and its content, at given nesting depth
Return a parsed text to its original form
Return whether or not a parsed text represent an empty text.
Details
at line 32
string
clean_formatting(string $xml)
Replace BBCodes and other formatting elements with whitespace
NOTE: preserves smilies as text
at line 50
protected string
format_attribute_value(string $str)
Format given string to be used as an attribute value
Will return the string as-is if it can be used in a BBCode without quotes. Otherwise, it will use either single- or double- quotes depending on whichever requires less escaping. Quotes and backslashes are escaped with backslashes where necessary
at line 66
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
at line 100
string[]
get_outermost_quote_authors(string $xml)
Get a list of quote authors, limited to the outermost quotes
at line 127
string
remove_bbcode(string $xml, string $bbcode_name, int $depth = 0)
Remove given BBCode and its content, at given nesting depth
at line 138
string
unparse(string $xml)
Return a parsed text to its original form
at line 146
bool
is_empty(string $text)
Return whether or not a parsed text represent an empty text.