[ Index ]

PHP Cross Reference of Joomla 1.5.26 DE

title

Body

[close]

/libraries/pattemplate/patTemplate/OutputFilter/ -> BBCode.php (source)

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


Generated: Wed Mar 28 15:54:07 2012 Cross-referenced by PHPXref 0.7.1