Files
@ c7d7e38b2269
Branch filter:
Location: hot67beta/libraries/pattemplate/patTemplate/OutputFilter/BBCode.php
c7d7e38b2269
2.4 KiB
text/x-php
Initial import of the site.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | <?PHP
/**
* patTemplate BBCode output filter
*
* $Id: BBCode.php 10381 2008-06-01 03:35:53Z pasamio $
*
* Uses patBBCode.
*
* @package patTemplate
* @subpackage Filters
* @author Stephan Schmidt <schst@php.net>
*/
// Check to ensure this file is within the rest of the framework
defined('JPATH_BASE') or die();
/**
* patTemplate BBCode output filter
*
* $Id: BBCode.php 10381 2008-06-01 03:35:53Z pasamio $
*
* Uses patBBCode. Note that patBBCode's syntax is not
* entirely the same than the 'official' BBCode. See the
* patBBCode projet page for details.
*
* The following parameters are available:
*
* - skinDir (required)
* The folder where BBCode templates are stored
*
* - reader (required)
* The type of reader to use
*
* - BBCode (optional)
* A fully configured BBCode objet to use. The other
* two options are not required if you set this.
*
* @package patTemplate
* @subpackage Filters
* @author Stephan Schmidt <schst@php.net>
* @author Sebastian Mordziol <argh@php-tools.net>
* @link http://www.php-tools.net/site.php?file=patBBCode/Overview.xml
*/
class patTemplate_OutputFilter_BBCode extends patTemplate_OutputFilter
{
/**
* filter name
*
* @access protected
* @abstract
* @var string
*/
var $_name = 'BBCode';
/**
* BBCode parser
*
* @access private
* @var object patBBCode
*/
var $BBCode = null;
/**
* remove all whitespace from the output
*
* @access public
* @param string data
* @return string data without whitespace
*/
function apply( $data )
{
if( !$this->_prepare() )
return $data;
$data = $this->BBCode->parseString( $data );
return $data;
}
/**
* prepare BBCode object
*
* @access private
*/
function _prepare()
{
// there already is a BBCode object
if( is_object( $this->BBCode ) ) {
return true;
}
// maybe a fully configured BBCode object was provided?
if( isset( $this->_params['BBCode'] ) ) {
$this->BBCode =& $this->_params['BBCode'];
return true;
}
// include the patBBCode class
if( !class_exists( 'patBBCode' ) )
{
if( !@include_once 'pat/patBBCode.php' )
return false;
}
$this->BBCode = &new patBBCode();
if( isset( $this->_params['skinDir'] ) )
$this->BBCode->setSkinDir( $this->_params['skinDir'] );
$reader =& $this->BBCode->createConfigReader( $this->_params['reader'] );
// give patBBCode the reader we just created
$this->BBCode->setConfigReader( $reader );
return true;
}
}
?>
|