IV. API Reference

[ Previous: E. Root-Class Functions | Next: G. Wiki-Link Functions ]

F. Rule Functions

void BBCode::AddRule ( string $name , array $params )
This function adds a new tag rule. Tag rules control the processing of BBCode [tags]; with the correct rule definition, you can make a tag do just about anything you can think of. To add a rule for a given tag, call AddRule() and provide the name of the tag rule you wish to add or replace, and an array containing rule parameters that defines what NBBC should do when it sees that tag. Any old rule parameters defined for that tag will be removed by this function, so this can also replace tag rules as well as adding new rules.
Parameters:
  • name: The name of a tag you wish to add or replace, like "b" or "url" or "larry". Nearly any name is allowed; however, the name may not include the following characters: '[', ']', '=', or any whitespace character.
  • params: An array of rule parameters defining what NBBC should do when it processes this tag.
Return Value: None.
(The user's manual, sections III.C through III.F as well as appendix B and appendix E, contains extensive documentation on using this function, so that information will not be repeated here.)
void BBCode::RemoveRule ( string $name )
This function un-defines the current rule for the given tag --- in short, this causes NBBC to stop recognizing the given tag as a tag.
Parameters:
  • name: The name of a tag to remove from the ruleset.
Return Value: None.
array BBCode::GetRule ( string $name )
This function returns the parameter array for a given tag, by name, the same array as was most recently given to AddRule() for that same tag name.
Parameters:
  • name: The name of the tag whose parameters you'd like to retrieve.
Return values: The parameter array for the given tag, if the tag has a rule; if it does not, the return value is false.
void BBCode::ClearRules ( )
This function removes all rules currently associated with this BBCode object, after which the BBCode object will have no rules defined at all. This is useful if you want to replace the default ruleset entirely with your own custom ruleset.
Parameters: None.
Return Value: None.
array BBCode::GetDefaultRule ( string $name )
This function returns the default parameter array for a given tag, by name, the same array that would be used by a newly-constructed BBCode object. This provides you with an easy way to look up a rule provided by the Standard BBCode Library.
Parameters:
  • name: The name of the tag whose parameters you'd like to retrieve.
Return values: The Standard BBCode Library's parameter array for the given tag, if the tag has a rule; if it does not, the return value is false.
void BBCode::SetDefaultRule ( string $name )
This function changes the parameter array for a given tag, by name, to the same array that would be used by a newly-constructed BBCode object, the same array that would be returned by GetDefaultRule().
Parameters:
  • name: The name of the tag whose rule you'd like to revert to its default setting.
array BBCode::GetDefaultRules ( )
This function returns a key => value array that contains all of the default rules --- all of the rules for the Standard BBCode Library. Each key is the name of a tag, and each value is an array containing rule parameters. This is exactly the same as calling GetDefaultRule() many times, once for each tag in the Standard BBCode Library, only much, much faster.
Parameters: None.
Return Value: An array containing all of the default BBCode rules.
void BBCode::SetDefaultRules ( )
This function causes the BBCode object's entire current ruleset to be replaced with the default rules --- in other words, to be changed back to the rules that it had just after it was newly-created --- in other words, to the ruleset for the Standard BBCode Library. All of the existing rules of this object will be deleted, and the new, default rules will be installed instead.
Parameters: None.
Return Value: None.

[ Previous: E. Root-Class Functions | Next: G. Wiki-Link Functions ]


Copyright © 2010, the Phantom Inker. All rights reserved.