HTML_BBCodeParser
[ class tree: HTML_BBCodeParser ] [ index: HTML_BBCodeParser ] [ all elements ]

Source for file Lists.php

Documentation is available at Lists.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. // +----------------------------------------------------------------------+
  4. // | PHP Version 4                                                        |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2003 The PHP Group                                |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 2.02 of the PHP license,      |
  9. // | that is bundled with this package in the file LICENSE, and is        |
  10. // | available at through the world-wide-web at                           |
  11. // | http://www.php.net/license/2_02.txt.                                 |
  12. // | If you did not receive a copy of the PHP license and are unable to   |
  13. // | obtain it through the world-wide-web, please send a note to          |
  14. // | license@php.net so we can mail you a copy immediately.               |
  15. // +----------------------------------------------------------------------+
  16. // | Author: Stijn de Reede <sjr@gmx.co.uk>                               |
  17. // +----------------------------------------------------------------------+
  18. //
  19. // $Id: Lists.php,v 1.4 2005/10/14 07:05:49 arnaud Exp $
  20. //
  21.  
  22.  
  23. /**
  24. @package  HTML_BBCodeParser
  25. @author   Stijn de Reede  <sjr@gmx.co.uk>
  26. */
  27.  
  28. /**
  29.  * 
  30.  */
  31. require_once('HTML/BBCodeParser.php');
  32.  
  33. /**
  34.  * 
  35.  */
  36. class HTML_BBCodeParser_Filter_Lists extends HTML_BBCodeParser
  37. {
  38.  
  39.     /**
  40.     * An array of tags parsed by the engine
  41.     *
  42.     * @access   private
  43.     * @var      array 
  44.     */
  45.     var $_definedTags = array(  'list'  => array(   'htmlopen'  => 'ol',
  46.                                                     'htmlclose' => 'ol',
  47.                                                     'allowed'   => 'all',
  48.                                                     'child'     => 'none^li',
  49.                                                     'attributes'=> array('list'  => 'style=%2$slist-style-type:%1$s;%2$s')
  50.                                                     ),
  51.                                 'ulist' => array(   'htmlopen'  => 'ul',
  52.                                                     'htmlclose' => 'ul',
  53.                                                     'allowed'   => 'all',
  54.                                                     'child'     => 'none^li',
  55.                                                     'attributes'=> array('list'  => 'style=%2$slist-style-type:%1$s;%2$s')
  56.                                                     ),
  57.                                 'li'    => array(   'htmlopen'  => 'li',
  58.                                                     'htmlclose' => 'li',
  59.                                                     'allowed'   => 'all',
  60.                                                     'parent'    => 'none^ulist,list',
  61.                                                     'attributes'=> array()
  62.                                                     )
  63.                                 );
  64.  
  65.  
  66.     /**
  67.     * Executes statements before the actual array building starts
  68.     *
  69.     * This method should be overwritten in a filter if you want to do
  70.     * something before the parsing process starts. This can be useful to
  71.     * allow certain short alternative tags which then can be converted into
  72.     * proper tags with preg_replace() calls.
  73.     * The main class walks through all the filters and and calls this
  74.     * method if it exists. The filters should modify their private $_text
  75.     * variable.
  76.     *
  77.     * @return   none 
  78.     * @access   private
  79.     * @see      $_text
  80.     * @author   Stijn de Reede <sjr@gmx.co.uk>, Seth Price <seth@pricepages.org>
  81.     */
  82.     function _preparse()
  83.     {
  84.         $options = PEAR::getStaticProperty('HTML_BBCodeParser','_options');
  85.         $o $options['open'];
  86.         $c $options['close'];
  87.         $oe $options['open_esc'];
  88.         $ce $options['close_esc'];
  89.         
  90.         $pattern = array(   "!".$oe."\*".$ce."!",
  91.                             "!".$oe."(u?)list=(?-i:A)(\s*[^".$ce."]*)".$ce."!i",
  92.                             "!".$oe."(u?)list=(?-i:a)(\s*[^".$ce."]*)".$ce."!i",
  93.                             "!".$oe."(u?)list=(?-i:I)(\s*[^".$ce."]*)".$ce."!i",
  94.                             "!".$oe."(u?)list=(?-i:i)(\s*[^".$ce."]*)".$ce."!i",
  95.                             "!".$oe."(u?)list=(?-i:1)(\s*[^".$ce."]*)".$ce."!i",
  96.                             "!".$oe."(u?)list([^".$ce."]*)".$ce."!i");
  97.         
  98.         $replace = array(   $o."li".$c,
  99.                             $o."\$1list=upper-alpha\$2".$c,
  100.                             $o."\$1list=lower-alpha\$2".$c,
  101.                             $o."\$1list=upper-roman\$2".$c,
  102.                             $o."\$1list=lower-roman\$2".$c,
  103.                             $o."\$1list=decimal\$2".$c,
  104.                             $o."\$1list\$2".$c );
  105.         
  106.         $this->_preparsed preg_replace($pattern$replace$this->_text);
  107.     }
  108. }
  109.  
  110.  
  111. ?>

Documentation generated on Tue, 05 Jun 2007 17:30:06 -0400 by phpDocumentor 1.3.2. PEAR Logo Copyright © PHP Group 2004.