Version: current

      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.5 2007/07/02 16:54:25 cweiske Exp $
     20 //
     21
     22
     23 /**
     24  * @package  sapphire
     25  * @subpackage misc
     26  * @author   Stijn de Reede  <sjr@gmx.co.uk>
     27  */
     28
     29 /**
     30  */
     31 require_once 'HTML/BBCodeParser/Filter.php';
     32
     33 /**
     34  * @package  sapphire
     35  * @subpackage misc
     36  */
     37 class SSHTMLBBCodeParser_Filter_Lists extends SSHTMLBBCodeParser_Filter
     38 {
     39
     40     /**
     41     * An array of tags parsed by the engine
     42     *
     43     * @access   private
     44     * @var      array
     45     */
     46     var $_definedTags = array(  'list'  => array(   'htmlopen'  => 'ol',
     47                                                     'htmlclose' => 'ol',
     48                                                     'allowed'   => 'all',
     49                                                     'child'     => 'none^li',
     50                                                     'attributes'=> array('list'  => 'style=%2$slist-style-type:%1$s;%2$s')
     51                                                     ),
     52                                 'ulist' => array(   'htmlopen'  => 'ul',
     53                                                     'htmlclose' => 'ul',
     54                                                     'allowed'   => 'all',
     55                                                     'child'     => 'none^li',
     56                                                     'attributes'=> array('list'  => 'style=%2$slist-style-type:%1$s;%2$s')
     57                                                     ),
     58                                 'li'    => array(   'htmlopen'  => 'li',
     59                                                     'htmlclose' => 'li',
     60                                                     'allowed'   => 'all',
     61                                                     'parent'    => 'none^ulist,list',
     62                                                     'attributes'=> array()
     63                                                     )
     64                                 );
     65
     66
     67     /**
     68     * Executes statements before the actual array building starts
     69     *
     70     * This method should be overwritten in a filter if you want to do
     71     * something before the parsing process starts. This can be useful to
     72     * allow certain short alternative tags which then can be converted into
     73     * proper tags with preg_replace() calls.
     74     * The main class walks through all the filters and and calls this
     75     * method if it exists. The filters should modify their private $_text
     76     * variable.
     77     *
     78     * @return   none
     79     * @access   private
     80     * @see      $_text
     81     * @author   Stijn de Reede <sjr@gmx.co.uk>, Seth Price <seth@pricepages.org>
     82     */
     83     function _preparse()
     84     {
     85         $options = SSHTMLBBCodeParser::getStaticProperty('SSHTMLBBCodeParser','_options');
     86         $o = $options['open'];
     87         $c = $options['close'];
     88         $oe = $options['open_esc'];
     89         $ce = $options['close_esc'];
     90
     91         $pattern = array(   "!".$oe."\*".$ce."!",
     92                             "!".$oe."(u?)list=(?-i:A)(\s*[^".$ce."]*)".$ce."!i",
     93                             "!".$oe."(u?)list=(?-i:a)(\s*[^".$ce."]*)".$ce."!i",
     94                             "!".$oe."(u?)list=(?-i:I)(\s*[^".$ce."]*)".$ce."!i",
     95                             "!".$oe."(u?)list=(?-i:i)(\s*[^".$ce."]*)".$ce."!i",
     96                             "!".$oe."(u?)list=(?-i:1)(\s*[^".$ce."]*)".$ce."!i",
     97                             "!".$oe."(u?)list([^".$ce."]*)".$ce."!i");
     98
     99         $replace = array(   $o."li".$c,
    100                             $o."\$1list=upper-alpha\$2".$c,
    101                             $o."\$1list=lower-alpha\$2".$c,
    102                             $o."\$1list=upper-roman\$2".$c,
    103                             $o."\$1list=lower-roman\$2".$c,
    104                             $o."\$1list=decimal\$2".$c,
    105                             $o."\$1list\$2".$c );
    106
    107         $this->_preparsed = preg_replace($pattern, $replace, $this->_text);
    108     }
    109 }
    110
    111
    112 ?>

[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -