OSDN Git Service

初回コミット(v2.6.17.1)
[magic3/magic3.git] / include / lib / HTML_BBCodeParser2-0.1.0 / BBCodeParser2 / Filter / Lists.php
1 <?php
2 /* vim: set expandtab tabstop=4 shiftwidth=4: */
3 // +----------------------------------------------------------------------+
4 // | PHP Version 5                                                        |
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 6079 2013-06-05 00:45:38Z fishbone $
20 //
21
22
23 /**
24 * @package  HTML_BBCodeParser2
25 * @author   Stijn de Reede  <sjr@gmx.co.uk>
26 */
27 //require_once 'HTML/BBCodeParser2/Filter.php';
28 require_once $gEnvManager->getLibPath() . '/HTML_BBCodeParser2-0.1.0/BBCodeParser2/Filter.php'; // modified for Magic3 by naoki
29
30 /**
31  * 
32  */
33 class HTML_BBCodeParser2_Filter_Lists extends HTML_BBCodeParser2_Filter
34 {
35
36     /**
37     * An array of tags parsed by the engine
38     *
39     * @access   private
40     * @var      array
41     */
42     var $_definedTags = array(  'list'  => array(   'htmlopen'  => 'ol',
43                                                     'htmlclose' => 'ol',
44                                                     'allowed'   => 'all',
45                                                     'child'     => 'none^li',
46                                                     'attributes'=> array('list'  => 'style=%2$slist-style-type:%1$s;%2$s')
47                                                     ),
48                                 'ulist' => array(   'htmlopen'  => 'ul',
49                                                     'htmlclose' => 'ul',
50                                                     'allowed'   => 'all',
51                                                     'child'     => 'none^li',
52                                                     'attributes'=> array('list'  => 'style=%2$slist-style-type:%1$s;%2$s')
53                                                     ),
54                                 'li'    => array(   'htmlopen'  => 'li',
55                                                     'htmlclose' => 'li',
56                                                     'allowed'   => 'all',
57                                                     'parent'    => 'none^ulist,list',
58                                                     'attributes'=> array()
59                                                     )
60                                 );
61
62
63     /**
64     * Executes statements before the actual array building starts
65     *
66     * This method should be overwritten in a filter if you want to do
67     * something before the parsing process starts. This can be useful to
68     * allow certain short alternative tags which then can be converted into
69     * proper tags with preg_replace() calls.
70     * The main class walks through all the filters and and calls this
71     * method if it exists. The filters should modify their private $_text
72     * variable.
73     *
74     * @return   none
75     * @access   private
76     * @see      $_text
77     * @author   Stijn de Reede <sjr@gmx.co.uk>, Seth Price <seth@pricepages.org>
78     */
79     function _preparse()
80     {
81         $options = $this->_options;
82         $o = $options['open'];
83         $c = $options['close'];
84         $oe = $options['open_esc'];
85         $ce = $options['close_esc'];
86         
87         $pattern = array(   "!".$oe."\*".$ce."!",
88                             "!".$oe."(u?)list=(?-i:A)(\s*[^".$ce."]*)".$ce."!i",
89                             "!".$oe."(u?)list=(?-i:a)(\s*[^".$ce."]*)".$ce."!i",
90                             "!".$oe."(u?)list=(?-i:I)(\s*[^".$ce."]*)".$ce."!i",
91                             "!".$oe."(u?)list=(?-i:i)(\s*[^".$ce."]*)".$ce."!i",
92                             "!".$oe."(u?)list=(?-i:1)(\s*[^".$ce."]*)".$ce."!i",
93                             "!".$oe."(u?)list([^".$ce."]*)".$ce."!i");
94         
95         $replace = array(   $o."li".$c,
96                             $o."\$1list=upper-alpha\$2".$c,
97                             $o."\$1list=lower-alpha\$2".$c,
98                             $o."\$1list=upper-roman\$2".$c,
99                             $o."\$1list=lower-roman\$2".$c,
100                             $o."\$1list=decimal\$2".$c,
101                             $o."\$1list\$2".$c );
102         
103         $this->_preparsed = preg_replace($pattern, $replace, $this->_text);
104     }
105 }