3 * patTemplate BBCode output filter
5 * $Id: BBCode.php 440 2008-03-30 09:00:16Z fishbone $
11 * @author Stephan Schmidt <schst@php.net>
15 * patTemplate BBCode output filter
17 * $Id: BBCode.php 440 2008-03-30 09:00:16Z fishbone $
19 * Uses patBBCode. Note that patBBCode's syntax is not
20 * entirely the same than the 'official' BBCode. See the
21 * patBBCode projet page for details.
23 * The following parameters are available:
25 * - skinDir (required)
26 * The folder where BBCode templates are stored
29 * The type of reader to use
32 * A fully configured BBCode objet to use. The other
33 * two options are not required if you set this.
35 * @package patTemplate
37 * @author Stephan Schmidt <schst@php.net>
38 * @author Sebastian Mordziol <argh@php-tools.net>
39 * @link http://www.php-tools.net/site.php?file=patBBCode/Overview.xml
41 class patTemplate_OutputFilter_BBCode extends patTemplate_OutputFilter
50 var $_name = 'BBCode';
56 * @var object patBBCode
61 * remove all whitespace from the output
65 * @return string data without whitespace
67 function apply( $data )
69 if( !$this->_prepare() )
72 $data = $this->BBCode->parseString( $data );
78 * prepare BBCode object
84 // there already is a BBCode object
85 if( is_object( $this->BBCode ) ) {
89 // maybe a fully configured BBCode object was provided?
90 if( isset( $this->_params['BBCode'] ) ) {
91 $this->BBCode =& $this->_params['BBCode'];
95 // include the patBBCode class
96 if( !class_exists( 'patBBCode' ) )
98 if( !@include_once 'pat/patBBCode.php' )
102 $this->BBCode = &new patBBCode();
104 if( isset( $this->_params['skinDir'] ) )
105 $this->BBCode->setSkinDir( $this->_params['skinDir'] );
107 $reader =& $this->BBCode->createConfigReader( $this->_params['reader'] );
109 // give patBBCode the reader we just created
110 $this->BBCode->setConfigReader( $reader );