$succeeded=$bbcode->add_alias($name,$aliasof)
Adds a tag that is an alias of another tag. For example
add_alias('image','img');
Adds an alias of the "img" tag named "image". This function returns
true on success, false on failure.
$error=$bbcode->add_tag($params)
Adds a tag to the current BBCode definition. It returns an error
message if adding did not succeed, otherwise it returns an empty string.
The $params argument is an associative array with parameters to the function.
Parameters
- Name
(required)
This argument specifies what the tag will be called. For a tag
that will be used as [b], for example, this would be "b".
- HasParam
(defaults to false)
This argument is a boolean. True means the tag has a parameter
([tag=parameter] for example), false means it doesn't ([tag] for example)
- HtmlBegin
(required)
The HTML that the start tag is replaced with. "%%P%%" is replaced
by the tag's parameter. For a [b] tag, this would be "<b>".
- HtmlEnd
(required for complex HtmlBegin)
The HTML that the end tag is replaced with. For a [b] tag, this
would be "</b>".
The class attempts to determine HtmlEnd from the HtmlBegin parameter
if HtmlEnd isn't specified, but you should always specify this as it has
trouble with anything more complex than a single tag with no parameters.
- ParamRegex
(defaults to "[^\]]+")
A PCRE-fragment to determine if the parameter is valid. It is
highly reccomened that you do not allow "]" to be in the parameter, as it
tends to be confused with the tag's ending.
- ParamRegexReplace
(defaults to empty array)
Associative array of PCRE replacments to do on the parameter, with
the keys being the search values and the values being the replacment.
- HasEnd
(defaults to true)
Boolean for whether there is an end tag. If it is set to true,
the class ensures that all tags are ended.
$bbcode->change_setting($name,$value)
Changes the
setting named $name to $value.
$bbcode->export_definition()
Returns the a serialized copy of the current tag definition, ready to be
imported with
import_definition.
$data=$bbcode->get_data($name)
Returns an array of the data of the tag named $name. Note that if
$name is an alias, the "Name" property will be the alias's name.
$succeeded=$bbcode->import_definition($definition,$mode)
Imports a tag definition from the
export_definition
function.
Modes
- append
(default)
Appends $definition to the current definition, using $definition's
tag for duplicates.
- prepend
Prepends $definition to the current definition, using the current definition
for duplicates.
- overwrite
Removes the current defintion and adds $definition.
Parses $text according to the current BBCode definition, and returns the
result.
These settings change how certain features
behave. They can be set with the
change_setting
function.
enced
(defaults to true)
Boolean for whether or not strings passes to the
parse_bbcode function are html-encoded.