patBBCode is our custom pat BBCode parser, with a slightly different syntax than the widely known BBCode. pat BBCode features tags with attributes, empty tags and even tags with custom namespaces. Tag filters enable mapping classes to tags with a very simple to use API for quick development.
patBBCode uses a sax-based parser to parse the tags, so that developers who want to add their own tags need not worry about that part. A filter class only needs to implement the createContent() method, and gets the content and attributes of the tag to work with. A small, custom template class makes it very easy to generate the needed content from any number of tag template files.
Simple tags that need not be mapped to a class are stored in .bbt (patBBCode templates) files used to render the content of the tag, e.g. the tag template for the [B] tag could look like this: <b>%s</b>, where %s stands for the content of the tag.
The first available version of patBBCode still used rather unflexible tag configuration files, and on Stephan's advice I implemented tag configuration readers. The main patBBCode class takes care of parsing the tags and rendering them from the tag template files, while the tag configuration readers are used to determine wether a tag exists and is allowed. Currently two readers are available:
- The AutoFile reader is the default reader, and determines whether a tag exists and is allowed by checking if the template files are available in the filesystem.
- The INI reader reads tag configurations from .ini files, enabling easy switching between tag configurations.
You can have a look at the CVS tree for this project at
cvs.php-tools.net, and grab the current CVS snapshot from
snaps.php-tools.net.