]> Raphaƫl G. Git Repositories - bbcode/blob - test.php
Switch to single|root|multi type
[bbcode] / test.php
1 <?php
2 $br = (php_sapi_name() == "cli")? "":"<br>";
3
4 if(!extension_loaded('bbcode')) {
5 dl('bbcode.' . PHP_SHLIB_SUFFIX);
6 }
7 $module = 'bbcode';
8 $functions = get_extension_funcs($module);
9 /*echo "Functions available in the test extension:$br\n";
10 foreach($functions as $func) {
11 echo $func."$br\n";
12 }*/
13 echo "$br\n";
14 $function = 'confirm_' . $module . '_compiled';
15 if (extension_loaded($module)) {
16 $obj = new $module(
17 [
18 '' => [
19 'type' => BBCODE::TYPE_ROOT,
20 'childs' => ['ul','url','img','b','i']
21 ],
22 'i' => [
23 'type' => BBCODE::TYPE_NOARG
24 //TODO: by default open tag = <KEY> and close tag = </KEY>
25 ],
26 'b' => [
27 'type' => BBCODE::TYPE_NOARG
28 ],
29 'ul' => [
30 'type' => BBCODE::TYPE_NOARG,
31 'childs' => [ 'li' ]
32 ],
33 'li' => [
34 'type' => BBCODE::TYPE_NOARG,
35 'parent' => 'ul',
36 'childs' => ['url','img','b','i']
37 ],
38 'url' => [
39 'type' => BBCODE::TYPE_OPTARG,
40 'open_tag' => '<a href="{PARAM}">',
41 'close_tag' => '</a>',
42 'default_arg' => '{CONTENT}',
43 'parent' => [ '', 'li', 'b', 'i' ]
44 ]
45 ],
46 [
47 ':)' => '<img src="smiley.gif" alt=":)" />',
48 ':(' => '<img src="sad.gif" alt=":(" />',
49 ':D' => '<img src="happy.gif" alt=":D" />',
50 ':p' => '<img src="tong.gif" alt=":p" />',
51 ':|' => '<img src="special.gif" alt=":|" />',
52 ':6:' => '<img src="six.gif" alt=":6:" />'
53 ],
54 BBCode::REMOVE_EMPTY
55 );
56 $obj2 = new $module(
57 [
58 '' => [
59 'type' => BBCODE::TYPE_ROOT,
60 'childs' => ['ul','url','img','b','i']
61 ],
62 'i' => [
63 'type' => BBCODE::TYPE_NOARG
64 //TODO: by default open tag = <KEY> and close tag = </KEY>
65 ],
66 'b' => [
67 'type' => BBCODE::TYPE_NOARG
68 ],
69 'ul' => [
70 'type' => BBCODE::TYPE_NOARG,
71 'childs' => [ 'li' ]
72 ],
73 'li' => [
74 'type' => BBCODE::TYPE_NOARG,
75 'parent' => 'ul',
76 'childs' => ['url','img','b','i']
77 ],
78 'url' => [
79 'type' => BBCODE::TYPE_OPTARG,
80 'open_tag' => '<a href="{PARAM}">',
81 'close_tag' => '</a>',
82 'default_arg' => '{CONTENT}',
83 'parent' => [ '', 'li', 'b', 'i' ]
84 ]
85 ],
86 [
87 ':)' => '<img src="smiley.gif" alt=":)" />',
88 ':(' => '<img src="sad.gif" alt=":(" />',
89 ':D' => '<img src="happy.gif" alt=":D" />',
90 ':p' => '<img src="tong.gif" alt=":p" />',
91 ':|' => '<img src="special.gif" alt=":|" />',
92 ':6:' => '<img src="six.gif" alt=":6:" />'
93 ],
94 BBCode::REMOVE_EMPTY
95 );
96 $obj3 = new $module(
97 [
98 '' => [
99 'type' => BBCODE::TYPE_ROOT,
100 'childs' => ['ul','url','img','b','i']
101 ],
102 'i' => [
103 'type' => BBCODE::TYPE_NOARG
104 //TODO: by default open tag = <KEY> and close tag = </KEY>
105 ],
106 'b' => [
107 'type' => BBCODE::TYPE_NOARG
108 ],
109 'ul' => [
110 'type' => BBCODE::TYPE_NOARG,
111 'childs' => [ 'li' ]
112 ],
113 'li' => [
114 'type' => BBCODE::TYPE_NOARG,
115 'parent' => 'ul',
116 'childs' => ['url','img','b','i']
117 ],
118 'url' => [
119 'type' => BBCODE::TYPE_OPTARG,
120 'open_tag' => '<a href="{PARAM}">',
121 'close_tag' => '</a>',
122 'default_arg' => '{CONTENT}',
123 'parent' => [ '', 'li', 'b', 'i' ]
124 ]
125 ],
126 [
127 ':)' => '<img src="smiley.gif" alt=":)" />',
128 ':(' => '<img src="sad.gif" alt=":(" />',
129 ':D' => '<img src="happy.gif" alt=":D" />',
130 ':p' => '<img src="tong.gif" alt=":p" />',
131 ':|' => '<img src="special.gif" alt=":|" />',
132 ':6:' => '<img src="six.gif" alt=":6:" />'
133 ],
134 BBCode::REMOVE_EMPTY
135 );
136 $obj3 = null;
137 unset($obj2);
138 var_dump($obj2 = clone $obj);
139 var_dump($obj3 = clone $obj);
140 var_dump($obj4 = clone $obj);
141 var_dump($obj5 = clone $obj);
142 var_dump($obj6 = clone $obj);
143 var_dump($obj2 = clone $obj);
144 //var_dump(new $module(BBCode::TYPE_ARG, 'tutu'));
145 exit;
146 //$str = $function($module);
147 } else {
148 $str = "Module $module is not compiled into PHP";
149 }
150 echo "$str\n";
151
152 /*
153 array(
154 'b' => array(
155 'type'=>BBCODE_TYPE_NOARG,
156 'open_tag'=>'<b class="sub">',
157 'close_tag'=>'</b>',
158 'flags'=>BBCODE_FLAGS_REMOVE_IF_EMPTY
159 ),
160 'u' => array(
161 'type'=>BBCODE_TYPE_NOARG,
162 'open_tag'=>'<u>',
163 'close_tag'=>'</u>',
164 'flags'=>BBCODE_FLAGS_SMILEYS_OFF | BBCODE_FLAGS_REMOVE_IF_EMPTY | BBCODE_FLAGS_SMILEYS_OFF
165 ),
166 'i' => array(
167 'type'=>BBCODE_TYPE_NOARG,
168 'open_tag'=>'<i>',
169 'close_tag'=>'</i>',
170 'flags'=>BBCODE_FLAGS_REMOVE_IF_EMPTY
171 )
172 ),
173 */
174