Fix api by replacing __toString with parse
[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 var_dump($obj);
57 $obj2 = new $module(
58 [
59 '' => [
60 'type' => BBCODE::TYPE_ROOT,
61 'childs' => ['ul','url','img','b','i']
62 ],
63 'i' => [
64 'type' => BBCODE::TYPE_NOARG
65 //TODO: by default open tag = <KEY> and close tag = </KEY>
66 ],
67 'b' => [
68 'type' => BBCODE::TYPE_NOARG
69 ],
70 'ul' => [
71 'type' => BBCODE::TYPE_NOARG,
72 'childs' => [ 'li' ]
73 ],
74 'li' => [
75 'type' => BBCODE::TYPE_NOARG,
76 'parent' => 'ul',
77 'childs' => ['url','img','b','i']
78 ],
79 'url' => [
80 'type' => BBCODE::TYPE_OPTARG,
81 'open_tag' => '<a href="{PARAM}">',
82 'close_tag' => '</a>',
83 'default_arg' => '{CONTENT}',
84 'parent' => [ '', 'li', 'b', 'i' ]
85 ]
86 ],
87 [
88 ':)' => '<img src="smiley.gif" alt=":)" />',
89 ':(' => '<img src="sad.gif" alt=":(" />',
90 ':D' => '<img src="happy.gif" alt=":D" />',
91 ':p' => '<img src="tong.gif" alt=":p" />',
92 ':|' => '<img src="special.gif" alt=":|" />',
93 ':6:' => '<img src="six.gif" alt=":6:" />'
94 ],
95 BBCode::REMOVE_EMPTY
96 );
97 $obj3 = new $module(
98 [
99 '' => [
100 'type' => BBCODE::TYPE_ROOT,
101 'childs' => ['ul','url','img','b','i']
102 ],
103 'i' => [
104 'type' => BBCODE::TYPE_NOARG
105 //TODO: by default open tag = <KEY> and close tag = </KEY>
106 ],
107 'b' => [
108 'type' => BBCODE::TYPE_NOARG
109 ],
110 'ul' => [
111 'type' => BBCODE::TYPE_NOARG,
112 'childs' => [ 'li' ]
113 ],
114 'li' => [
115 'type' => BBCODE::TYPE_NOARG,
116 'parent' => 'ul',
117 'childs' => ['url','img','b','i']
118 ],
119 'url' => [
120 'type' => BBCODE::TYPE_OPTARG,
121 'open_tag' => '<a href="{PARAM}">',
122 'close_tag' => '</a>',
123 'default_arg' => '{CONTENT}',
124 'parent' => [ '', 'li', 'b', 'i' ]
125 ]
126 ],
127 [
128 ':)' => '<img src="smiley.gif" alt=":)" />',
129 ':(' => '<img src="sad.gif" alt=":(" />',
130 ':D' => '<img src="happy.gif" alt=":D" />',
131 ':p' => '<img src="tong.gif" alt=":p" />',
132 ':|' => '<img src="special.gif" alt=":|" />',
133 ':6:' => '<img src="six.gif" alt=":6:" />'
134 ],
135 BBCode::REMOVE_EMPTY
136 );
137 $obj3 = null;
138 unset($obj2);
139 $obj2 = clone $obj;
140 #var_dump(clone $obj);
141 //var_dump(new $module(BBCode::TYPE_ARG, 'tutu'));
142 exit;
143 //$str = $function($module);
144 } else {
145 $str = "Module $module is not compiled into PHP";
146 }
147 echo "$str\n";
148
149 /*
150 array(
151 'b' => array(
152 'type'=>BBCODE_TYPE_NOARG,
153 'open_tag'=>'<b class="sub">',
154 'close_tag'=>'</b>',
155 'flags'=>BBCODE_FLAGS_REMOVE_IF_EMPTY
156 ),
157 'u' => array(
158 'type'=>BBCODE_TYPE_NOARG,
159 'open_tag'=>'<u>',
160 'close_tag'=>'</u>',
161 'flags'=>BBCODE_FLAGS_SMILEYS_OFF | BBCODE_FLAGS_REMOVE_IF_EMPTY | BBCODE_FLAGS_SMILEYS_OFF
162 ),
163 'i' => array(
164 'type'=>BBCODE_TYPE_NOARG,
165 'open_tag'=>'<i>',
166 'close_tag'=>'</i>',
167 'flags'=>BBCODE_FLAGS_REMOVE_IF_EMPTY
168 )
169 ),
170 */
171