]> git.pld-linux.org Git - packages/php-pecl-bbcode.git/blame - branch.diff
- build with svn snapshot (1.1.0-dev), builds with php5.3
[packages/php-pecl-bbcode.git] / branch.diff
CommitLineData
baa408b8
ER
1Index: package2.xml
2===================================================================
3Cannot display: file marked as a binary type.
4svn:mime-type = application/xml
5Index: config.w32
6===================================================================
7--- config.w32 (.../tags/RELEASE_1_0_2)
8+++ config.w32 (.../trunk)
9@@ -0,0 +1,10 @@
10+// $Id$
11+// vim:ft=javascript
12+
13+ARG_ENABLE("bbcode", "BBcode", "no");
14+
15+if (PHP_BBCODE != "no") {
16+ EXTENSION("bbcode", "php_bbcode.c");
17+ ADD_SOURCES(configure_module_dirname + "/lib", "bbcode2.c bstrlib.c", "bbcode");
18+ AC_DEFINE('HAVE_BBCODE', 1, 'Have BBCODE library');
19+}
20
21Property changes on: config.w32
22___________________________________________________________________
23Added: svn:eol-style
24 + native
25Added: svn:keywords
26 + Id Rev Revision Date LastChangedDate LastChangedRevision Author LastChangedBy HeadURL URL
27Added: cvs2svn:cvs-rev
28 + 1.2
29
30Index: tests/test_ivy.phpt
31===================================================================
32--- tests/test_ivy.phpt (.../tags/RELEASE_1_0_2)
33+++ tests/test_ivy.phpt (.../trunk)
34@@ -0,0 +1,506 @@
35+--TEST--
36+BBCODE No parse Test
37+--FILE--
38+<?php
39+if (!extension_loaded("bbcode")){
40+ if (!dl('bbcode.so')){
41+ die ('bbcode not loadable');
42+ }
43+}
44+define("____page","");
45+$text=<<<EOF
46+[just][center][round][color=red][size=18]Nous Recherchons un(e) ministre d'urgence Contactez [id=7760]moi[/id][/size][/color][/round][/center][/just]<br />
47+<br />
48+<br />
49+<br />
50+<br />
51+[just][center][quote=[color=green]Pod Pocket[/color]]<br />
52+[color=teal]Avec l'arrivé de l'été, arrive le nouveau line 6 Pod Pocket, quelle coinsidence !!!<br />
53+Il s'agit donc d'un mini simulateur d'ampli de la célèbre ligné Pod qui est le fer de lance de la marque depuis son lancement en 1998.<br />
54+<br />
55+Line 6 étant les rois de la simulation d'ampli, la firme s'oriente donc avec ce produit vers le marché de la musique mobile. Cette nouveauté ne sort pas avant les vacances d'été pour rien, il s'avère être très design, facile à transporter et donc l'outil idéal pour les vacances.<br />
56+<br />
57+De la taille d'un simple accordeur, le Pod pocket est tout de même ultra complet. En effet, il possède à son menu 32 modélisations d'amplis, 16 baffles et pas moins de 16 effets intégrés. Vous ne rêvez pas, vous vous dites il est si petit mais offre-t-il les mêmes capacités que le Pod II ? et bien oui !<br />
58+Et tenez vous bien, il marche à piles (pour se la jouer rebelz sur la plage... :p) ou sur secteur (pour vous perfectionner avant de vous la jouer sur la plage...:p). Donc que vous soyez frimeur à montrer vos 4 accords aux potes en exterieur espérant attirer les demoiselles, ou que vous soyez enfermé dans votre cagibi depuis 2 mois jonglant entre la carte son du pc et votre guitare, il vous est déstiné et vous simplifira certainement les choses.[/color][/quote][/center][/just]<br />
59+<br />
60+[just][center][size=16][color=red][b][u][just][center][round][color=lightblue][b][u]Voici les données constructeur :[/just][/center][/size][/color][/b][/u][/just][/center][/round][/color][/b][/u]<br />
61+<br />
62+[just][center][round][color=lightblue][b][u]Caractéristiques :[/u][/b][/color]<br />
63+[list]<br />
64+[*]300 presets modifiables<br />
65+[*]32 modélisations d'amplis<br />
66+[*]16 modélisations d'enceintes<br />
67+[*]16 effets<br />
68+[*]alimentation par un pile AAA<br />
69+[*]Entrées jack 6.35 et 3.5<br />
70+[*]Connexion USB<br />
71+[*]technologie A.I.R. II permettant un enregistrement direct<br />
72+[*]connexion au site customtone.com pour télécharger jusqu'à 3000 sons<br />
73+[*]logiciel d'édition PC[/round][/center][/just]<br />
74+[/list]<br />
75+<br />
76+[just][center][round][color=lightgreen][b][u]Modèles d’amplis basés sur:[/u][/b][/color]<br />
77+[list]<br />
78+[*]’64 Fender® Deluxe Reverb®<br />
79+[*]’59 Fender® Bassman®<br />
80+[*]’68 Marshall® Plexi 100 watt <br />
81+[*]Rencontre d’un Marshall® JTM-45 et d’un Budda Twinmaster <br />
82+[*]’60 Tweed Fender® Champ® <br />
83+[*]Tête Budda Twinmaster<br />
84+[*]’65 Blackface Fender® Twin Reverb® <br />
85+[*]’60 Vox® AC 15 <br />
86+[*]’60 Vox® AC 30 non-Top Boost <br />
87+[*]’85 Mesa/Boogie® Mark IIc+ canal Clean<br />
88+[*]’85 Mesa/Boogie® Mark IIc+ canal Drive Canal Clean du Dumble® Overdrive Special<br />
89+[*]’95 Tête Mesa/Boogie® Dual Rectifier®<br />
90+[*]’89 Soldano SLO Super Lead Overdrive Canal Drive du Dumble® Overdrive Special <br />
91+[*]1987 Roland® JC-120 Jazz Chorus Line 6® Insane[/round][/center][/just]<br />
92+[/list]<br />
93+[just][center][round][color=lightyellow][b][u]Modèles d’enceintes basés sur:[/u][b][/color]<br />
94+[list]<br />
95+[*]1960 Fender® Tweed Champ®<br />
96+[*]1952 Fender® Tweed Deluxe Reverb® <br />
97+[*]1960 Vox® AC-15 <br />
98+[*]1964 Fender® Deluxe Reverb® <br />
99+[*]1965 Fender® Blackface Twin Reverb®<br />
100+[*]1967 Vox® AC-30 <br />
101+[*]1995 Matchless Chieftain <br />
102+[*]1959 Fender® Bassman® <br />
103+[*]1996 Marshall® avec haut-parleurs 30 vintage <br />
104+[*]1978 Marshall® avec haut-parleurs 70 d’origine <br />
105+[*]1968 Marshall® Basketweave avec Greenbacks Line 6® 4x12 Line 6® 1x12 Line 6® 2x12 Line 6® 4x10 [/round][/center][/just][/list]<br />
106+<br />
107+<br />
108+[just][center][round][color=pink][b][u]16 effets :[/u][/b][/color]<br />
109+Compresseur ; Délai/Compresseur <br />
110+Trémolo ; Délai/Trémolo <br />
111+Chorus 1 ; Délai/Chorus <br />
112+Chorus 2 ; Délai/Chorus <br />
113+Flanger 1 ; Délai/Flanger1 <br />
114+Flanger 2 ; Délai/Flanger<br />
115+Haut-parleur rotatif<br />
116+Délai/Délai ; Délai Réverbération.[/round][/center][/just] <br />
117+<br />
118+[just][center][round][color=red][b][u]Prix :[/u][/b][/color] <br />
119+[list]<br />
120+[*][color=red]99,00€[/color] sur www.woodbrass.com<br />
121+[*][color=grey]119,00€[/color] prix public conseillé.[/list]<br />
122+<br />
123+[color=lime][b][u]Liens :[/u][/b][/color]<br />
124+<br />
125+infos tirées des sites suivants :<br />
126+<br />
127+[url=http://www.guitariste.com/articles/pocket-pod,890,1.html]www.guitariste.com[/url]<br />
128+[url=http://fr.line6.com/pocketpod/index.html]www.line6.com[/url]<br />
129+[/round][/center][/just] <br />
130+<br />
131+[just][center][size=16][color=blue][u][border]Questions :[/border][/u][/color][/size]<br />
132+[list][color="blue]<br />
133+[*] Pour vous ce type d'appareil est-il indispensable ?<br />
134+[*] Selon vous c'est une innovation ou une remasterisation ?<br />
135+[*] Le trouvez vous pratique de par sa taille et ses capacités ?[/color]<br />
136+[/center][/just][/list]
137+EOF;
138+$arrayBBCode=array(
139+ 'h1'=> array('type'=>BBCODE_TYPE_NOARG, 'flags'=>BBCODE_FLAGS_REMOVE_IF_EMPTY, 'open_tag'=>'<h1>', 'close_tag'=>'</h1>'),
140+ 'h2'=> array('type'=>BBCODE_TYPE_NOARG, 'flags'=>BBCODE_FLAGS_REMOVE_IF_EMPTY, 'open_tag'=>'<h2>', 'close_tag'=>'</h2>'),
141+ 'h3'=> array('type'=>BBCODE_TYPE_NOARG, 'flags'=>BBCODE_FLAGS_REMOVE_IF_EMPTY, 'open_tag'=>'<h3>', 'close_tag'=>'</h3>'),
142+ 'b'=> array('type'=>BBCODE_TYPE_NOARG, 'flags'=>BBCODE_FLAGS_REMOVE_IF_EMPTY, 'open_tag'=>'<b>', 'close_tag'=>'</b>'),
143+ 'u'=> array('type'=>BBCODE_TYPE_NOARG, 'flags'=>BBCODE_FLAGS_REMOVE_IF_EMPTY, 'open_tag'=>'<u>', 'close_tag'=>'</u>'),
144+ 'i'=> array('type'=>BBCODE_TYPE_NOARG, 'flags'=>BBCODE_FLAGS_REMOVE_IF_EMPTY, 'open_tag'=>'<i>', 'close_tag'=>'</i>'),
145+ 'm'=> array('type'=>BBCODE_TYPE_NOARG, 'flags'=>BBCODE_FLAGS_REMOVE_IF_EMPTY, 'open_tag'=>'<a href="/maraboutage.php">', 'close_tag'=>'</a>'),
146+ 'cap'=> array('type'=>BBCODE_TYPE_NOARG, 'flags'=>BBCODE_FLAGS_REMOVE_IF_EMPTY, 'open_tag'=>'<span style="text-transform:capitalize;">', 'close_tag'=>'</span>'),
147+ 'mini'=> array('type'=>BBCODE_TYPE_NOARG, 'flags'=>BBCODE_FLAGS_REMOVE_IF_EMPTY, 'open_tag'=>'<span class="mini">', 'close_tag'=>'</span>'),
148+ 'right'=> array('type'=>BBCODE_TYPE_NOARG, 'flags'=>BBCODE_FLAGS_REMOVE_IF_EMPTY, 'open_tag'=>'<div style="text-align:right;">', 'close_tag'=>'</div>'.(basename(____page,".php")=="chat-2"?'&nbsp; &nbsp; &nbsp;':'').''),
149+ 'center'=> array('type'=>BBCODE_TYPE_NOARG, 'flags'=>BBCODE_FLAGS_REMOVE_IF_EMPTY, 'open_tag'=>'<div style="text-align:center;">', 'close_tag'=>'</div>'.(basename(____page,".php")=="chat-2"?'&nbsp; &nbsp; &nbsp;':'').''),
150+ 'just'=> array('type'=>BBCODE_TYPE_NOARG, 'flags'=>BBCODE_FLAGS_REMOVE_IF_EMPTY, 'open_tag'=>'<div style="text-align:justify;width:450px;margin:0 auto;">', 'close_tag'=>'</div>'.(basename(____page,".php")=="chat-2"?'&nbsp; &nbsp; &nbsp;':'').''),
151+ 'strike'=> array('type'=>BBCODE_TYPE_NOARG, 'flags'=>BBCODE_FLAGS_REMOVE_IF_EMPTY, 'open_tag'=>'<span style="text-decoration:line-through;">', 'close_tag'=>'</span>'),
152+ 'ancre'=> array('type'=>BBCODE_TYPE_NOARG, 'childs'=>'', 'open_tag'=>'<a name="', 'close_tag'=>'"> &nbsp;</a>'),
153+ 'moumou'=> array('type'=>BBCODE_TYPE_NOARG, 'childs'=>'', 'open_tag'=>'<img src="', 'close_tag'=>'" />'),
154+ 'round'=> array('type'=>BBCODE_TYPE_NOARG, 'flags'=>BBCODE_FLAGS_REMOVE_IF_EMPTY, 'open_tag'=>'<div style="border:2px double white;border-radius: 8px; padding:6px; -moz-border-radius: 8px; background-color:#000; color:#FFF;">', 'close_tag'=>'</div>'.(basename(____page,".php")=="chat-2"?'&nbsp; &nbsp; &nbsp;':'').''),
155+ 'hide'=> array('type'=>BBCODE_TYPE_NOARG, 'childs'=>'', 'open_tag'=>'', 'close_tag'=>'', 'content_handling'=>'BBVoid'),
156+ 'np'=> array('type'=>BBCODE_TYPE_NOARG, 'childs'=>'', 'open_tag'=>'', 'close_tag'=>''),
157+ 'img'=> array('type'=>BBCODE_TYPE_NOARG, 'childs'=>'', 'open_tag'=>'<img src="{CONTENT}" alt="', 'close_tag'=>'" />', 'content_handling'=>'content_validate_url'),
158+ 'swf'=> array('type'=>BBCODE_TYPE_NOARG, 'open_tag'=>'<object width="320" height="240"><param name="movie" value="{CONTENT}"></param><param name="wmode" value="transparent"></param><embed src="', 'close_tag'=>'" type="application/x-shockwave-flash" wmode="transparent" width="320" height="240"></embed></object>'),
159+ 'quote'=> array('type'=>BBCODE_TYPE_OPTARG, 'flags'=>BBCODE_FLAGS_ARG_PARSING|BBCODE_FLAGS_REMOVE_IF_EMPTY, 'open_tag'=>'<fieldset><legend>{PARAM}</legend>', 'close_tag'=>'</fieldset>'.(basename(____page,".php")=="chat-2"?'&nbsp; &nbsp; &nbsp;':'').'', 'default_arg'=>'Citation'),
160+ 'id'=> array('type'=>BBCODE_TYPE_OPTARG, 'flags'=>BBCODE_FLAGS_REMOVE_IF_EMPTY, 'open_tag'=>'', 'close_tag'=>'', 'default_arg'=>'{SELF}', 'content_handling'=>'BBId2User'),
161+ 'msg'=> array('type'=>BBCODE_TYPE_OPTARG, 'flags'=>BBCODE_FLAGS_REMOVE_IF_EMPTY, 'open_tag'=>'', 'close_tag'=>'', 'default_arg'=>'{SELF}', 'content_handling'=>'BBId2Msg'),
162+ 'url'=> array('type'=>BBCODE_TYPE_OPTARG, 'flags'=>BBCODE_FLAGS_REMOVE_IF_EMPTY, 'open_tag'=>'<a href="{PARAM}">', 'close_tag'=>'</a>', 'default_arg'=>'{CONTENT}', 'param_handling'=>'validate_url', 'content_handling'=>'content_validate_url'),
163+ 'mail'=> array('type'=>BBCODE_TYPE_OPTARG, 'flags'=>BBCODE_FLAGS_REMOVE_IF_EMPTY, 'open_tag'=>'<a href="mailto:{PARAM}">', 'close_tag'=>'</a>', 'default_arg'=>'{CONTENT}'),
164+ 'border'=> array('type'=>BBCODE_TYPE_OPTARG, 'flags'=>BBCODE_FLAGS_REMOVE_IF_EMPTY, 'open_tag'=>'<div style="border:{PARAM}px solid;'.(basename(____page,".php")=="chat-2"?'margin-left:15px;padding-left:15px;':'').'">', 'close_tag'=>'</div>'.(basename(____page,".php")=="chat-2"?'&nbsp; &nbsp; &nbsp;':'').'', 'default_arg'=>'5'),
165+ 'list'=> array('type'=>BBCODE_TYPE_OPTARG, 'flags'=>BBCODE_FLAGS_REMOVE_IF_EMPTY, 'childs'=>'*', 'open_tag'=>'', 'close_tag'=>'', 'default_arg'=>'-1', 'content_handling'=>'BBList'),
166+ '*'=> array('type'=>BBCODE_TYPE_NOARG, 'flags'=>BBCODE_FLAGS_REMOVE_IF_EMPTY|BBCODE_FLAGS_ONE_OPEN_PER_LEVEL, 'open_tag'=>'<li>', 'close_tag'=>'</li>'),
167+ 'col'=> array('type'=>BBCODE_TYPE_OPTARG, 'flags'=>BBCODE_FLAGS_REMOVE_IF_EMPTY, 'open_tag'=>'<div style="-moz-column-count:{PARAM}; text-align:justify;-moz-column-gap:8px;'.(basename(____page,".php")=="chat-2"?'margin-left:15px;padding-left:15px;':'').'">', 'close_tag'=>'</div>'.(basename(____page,".php")=="chat-2"?'&nbsp; &nbsp; &nbsp;':'').'', 'default_arg'=>'2'),
168+ 'hexdump'=> array('type'=>BBCODE_TYPE_OPTARG, 'flags'=>BBCODE_FLAGS_REMOVE_IF_EMPTY, 'childs'=>'', 'open_tag'=>'[Hex Dump]<br />', 'close_tag'=>''.(basename(____page,".php")=="chat-2"?'&nbsp; &nbsp; &nbsp;':'').'', 'default_arg'=>'0x345622', 'content_handling'=>'BBHexDump'),
169+ 'bcktrc'=> array('type'=>BBCODE_TYPE_OPTARG, 'flags'=>BBCODE_FLAGS_REMOVE_IF_EMPTY, 'childs'=>'', 'open_tag'=>'', 'close_tag'=>''.(basename(____page,".php")=="chat-2"?'&nbsp; &nbsp; &nbsp;':'').'', 'default_arg'=>'0x345622', 'content_handling'=>'BBBackTrace'),
170+ 'bong'=> array('type'=>BBCODE_TYPE_OPTARG, 'flags'=>BBCODE_FLAGS_REMOVE_IF_EMPTY, 'childs'=>'onglet', 'open_tag'=>'<div id="{PARAM}"'.(basename(____page,".php")=="chat-2"?' style="margin-left:15px;padding-left:15px;"':'').'>', 'close_tag'=>'</div>'.(basename(____page,".php")=="chat-2"?'&nbsp; &nbsp; &nbsp;':'').'<script type="text/javascript">new OngletsBlock(\'{PARAM}\');</script>','default_arg'=>'Fiche', 'param_handling'=>'random_id'),
171+ 'onglet'=> array('type'=>BBCODE_TYPE_ARG, 'flags'=>BBCODE_FLAGS_REMOVE_IF_EMPTY, 'parents'=>'bong', 'open_tag'=>'<h4>{PARAM}</h4><div title="{PARAM}" closable="true" style="clear:both;'.(basename(____page,".php")=="chat-2"?'margin-left:15px;padding-left:15px;':'').'">','close_tag'=>'</div>','default_arg'=>'Default'),
172+ 'color'=> array('type'=>BBCODE_TYPE_ARG, 'flags'=>BBCODE_FLAGS_REMOVE_IF_EMPTY, 'open_tag'=>'<span style="color:{PARAM}">', 'close_tag'=>'</span>'),
173+ 'size'=> array('type'=>BBCODE_TYPE_ARG, 'flags'=>BBCODE_FLAGS_REMOVE_IF_EMPTY, 'open_tag'=>'<span style="font-size:{PARAM}px;">', 'close_tag'=>'</span>'),
174+ 'goto'=> array('type'=>BBCODE_TYPE_ARG, 'flags'=>BBCODE_FLAGS_REMOVE_IF_EMPTY, 'open_tag'=>'<a href="#{PARAM}" onmouseover="this.href=document.location.href.replace(/#.*/img ,\'\')+\'#{PARAM}\'">', 'close_tag'=>'</a>'),
175+ 'fade'=> array('type'=>BBCODE_TYPE_ARG, 'flags'=>BBCODE_FLAGS_REMOVE_IF_EMPTY, 'childs'=>'', 'open_tag'=>'', 'close_tag'=>'', 'content_handling'=>'BBDegrade'),
176+ 'wave'=> array('type'=>BBCODE_TYPE_ARG, 'flags'=>BBCODE_FLAGS_REMOVE_IF_EMPTY, 'childs'=>'', 'open_tag'=>'', 'close_tag'=>'', 'content_handling'=>'BBWave'),
177+ 'barre'=> array('type'=>BBCODE_TYPE_SINGLE, 'open_tag'=>'<hr />'.(basename(____page,".php")=="chat-2"?'&nbsp; &nbsp; &nbsp;':'').''),
178+);
179+$arrayBBCode_meta=array(
180+ 'b'=> array('name'=>'G', 'title'=>'Placer le texte en gras [b][/b]', 'style'=>'font-weight:bold;'),
181+ 'u'=> array('name'=>'S', 'title'=>'Souligner le texte [u][/u]', 'style'=>'text-decoration:underline;'),
182+ 'i'=> array('name'=>'I', 'title'=>'Placer le texte en italique[i][/i]', 'style'=>'font-style:italic;'),
183+ 'm'=> array('name'=>'Marabou', 'title'=>'Faites de la pub pour le marabou![m][/m]'),
184+ 'cap'=> array('name'=>'Majusc.', 'title'=>'Force le texte à être affiché en capitales [cap][/cap]', 'style'=>'text-transform:capitalize;'),
185+ 'mini'=> array('name'=>'Mini', 'title'=>'Rendez votre texte tout petit [mini][/mini]', 'class'=>'mini'),
186+ 'right'=> array('name'=>'Right', 'title'=>'Aligner votre texte à droite [right][/right]', 'style'=>'text-align:right;'),
187+ 'center'=> array('name'=>'Center', 'title'=>'Centrer votre texte [center][/center]', 'style'=>'text-align:center;'),
188+ 'just'=> array('name'=>'Justifié', 'title'=>'Justifier votre texte [just][/just]', 'style'=>'text-align:justify;'),
189+ 'strike'=> array('name'=>'Strike', 'title'=>'Barre votre texte [strike] [/strike]', 'style'=>'text-decoration:line-through;'),
190+ 'ancre'=> array('name'=>'Ancre', 'title'=>'Placez sur votre fiche un point de repere [ancre][/ancre]'),
191+ 'moumou'=> 'hidden',
192+ 'round'=> array('name'=>'Round', 'title'=>'Un cadre sur fond noir à bord arrondi à essayer [round][/round]', 'style'=>'border:2px double white;border-radius: 8px; padding:6px; -moz-border-radius: 8px; background-color:#000; color:#FFF;'),
193+ 'hide'=> array('name'=>'Masquer', 'title'=>'Masquer le contenu (rendre invisible) [hide][/hide]'),
194+ 'np'=> array('name'=>'Bloc non traité', 'title'=>'Défini un bloc dont le bbcode ne sera pas traité [np][/np]'),
195+ 'quote'=> array('name'=>'Citation', 'title'=>'Faire une citation [quote]ou [quote=auteur] [/quote]', 'prompt'=>'Auteur de la citation (Esc si aucun)'),
196+ 'id'=> array('name'=>'Lien Fiche', 'title'=>'Faire un lien vers la fiche d\'un utilisateur [id=115][/id]', 'prompt'=>'Id de l\'Ivyen?'),
197+ 'url'=> array('name'=>'Lien', 'title'=>'Créez un lien à partir d\'une url [url] ou [url=http://...][/url]', 'prompt'=>'Url du lien avec http:// (Esc si url dans la balise)'),
198+ 'img'=> array('name'=>'Image', 'title'=>'Créez un lien image [img]http://...[/img]', 'img_prompt'=>'Url de l\'image avec http:// '),
199+ 'mail'=> array('name'=>'Lien Mail', 'title'=>'Créez un lien à partir d\'une url [mail] ou [mail=u@c.c][/mail]', 'prompt'=>'Adresse mail (Esc si adresse dans la balise)'),
200+ 'border'=> array('name'=>'Bordure', 'title'=>'Créez un cadre avec une bordure [border] ou [border=X][/border]', 'prompt'=>'Taille de la bordure (Esc pour defaut)'),
201+ 'list'=> array('name'=>'Listes', 'title'=>'Créez une liste avec puce [list] ou [list=X][*]element1[*]element2[/list]', 'prompt'=>'Type de liste: (1 / I / a / ...) ( Esc pour défaut )'),
202+ 'col'=> array('name'=>'Colonnes', 'title'=>'Divise le texte en X colonnes (Firefox 1.5) [col=X][/col]', 'prompt'=>'Nombre de colonnes'),
203+ 'hexdump'=> array('name'=>'HexDump', 'title'=>'HexDump (truc me faisant marrer, je suis désolé) [hexdump=0X3456][/hexdump]', 'prompt'=>'Adresse de démarrage format 0xFED3'),
204+ 'bcktrc'=> array('name'=>'BackTrace', 'title'=>'BackTrace (comme HexDump) [bcktrc=0X3456][/bcktrc]', 'prompt'=>'Adresse de démarrage format 0xFED3'),
205+ 'msg'=> array('name'=>'Lien Message','title'=>'Créer un lien direct pour envoyer un message à ivyen [msg=X][/msg]', 'prompt'=>'Id de l\'ivyen'),
206+ 'color'=> array('name'=>'Couleur', 'title'=>'Défini la couleur du texte [color=XXX][/color]', 'prompt'=>'Entrez la couleur désirée', 'dropdown'=>array('aqua'=> 'Aqua', 'black'=> 'Noir', 'blue'=> 'Bleu', 'fuchsia'=> 'Fuschia', 'gray'=> 'Gris', 'green'=> 'Vert', 'lime'=> 'Citron Vert', 'maroon'=> 'Marron', 'navy'=> 'Bleu Marine', 'olive'=> 'Olive', 'purple'=> 'Violet', 'red'=> 'Rouge', 'silver'=> 'Argent', 'teal'=> 'Teal', 'white'=> 'Blanc', 'yellow'=> 'Jaune','--'=>'Couleur personnalis&eacute;e', 'def'=>'Choisir couleur')),
207+ 'size'=> array('name'=>'Size', 'title'=>'Taille du texte [size=XXX][/size]', 'dropdown'=>array('24'=> 'Gigantesque (24)', '20'=> 'Enorme (20)', '16'=> 'Grand(16)', '12'=> 'Normal(12)', '8'=> 'Petit(8)', 'def'=>'Taille du texte'),),
208+ 'goto'=> array('name'=>'Goto', 'title'=>'Crée un lien vers une ancre du meme bloc [goto=X][/goto]', 'prompt'=>'Ancre à cibler'),
209+ 'fade'=> array('name'=>'Dégradé', 'title'=>'Fournis des dégradés d\'une couleur à une autre [wave=XX:YY:ZZ:...][/wave] Séparez les couleurs par des : (donnez les couleurs en Hexa ex: 000000:FF0000:00FF00 (ne supporte pas les tags internes)', 'prompt'=>'Donnez les couleurs séparées par un : ex 0000FF:00FF00:FF0000'),
210+ 'wave'=> array('name'=>'Vagues', 'title'=>'Fait aller en vague un texte [wave=XX:YY][/wave] avec les tailles oscillant entre XX et YY (ne supporte pas les tags internes)', 'prompt'=>'Donnez le min et le max séparés par un :'),
211+ 'barre'=> array('name'=>'Barre', 'title'=>'Insere une barre horizontale [barre]'),
212+);
213+
214+$BBHandler=bbcode_create($arrayBBCode);
215+$array_smileys=array(
216+ "[fight]" =>'/smileys/smile142.gif',
217+ ":p" =>'/smileys/smile019.gif',
218+ ":-/" =>'/smileys/smile046.gif',
219+ "[fuck]" =>'/smileys/smile007.gif',
220+ "[y]" =>'/smileys/smile054.gif',
221+ "[l]" =>'/smileys/smile121.gif',
222+ ":D" =>'/smileys/smile004.gif',
223+ ":B" =>'/smileys/2pointsB.gif',
224+ ":*" =>'/smileys/smile013.gif',
225+ ":))))" =>'/smileys/smile008.gif',
226+ ":))" =>'/smileys/smile005.gif',
227+ ":)" =>'/smileys/smile147.gif',
228+ ";)" =>'/smileys/smile144.gif',
229+ ":(" =>'/smileys/smile001.gif',
230+ ":'(" =>'/smileys/smile002.gif',
231+ "[6]" =>'/smileys/smile006.gif',
232+ ":@" =>'/smileys/smile003.gif',
233+ ":o" =>'/smileys/smile145.gif',
234+ ":$" =>'/smileys/smile146.gif',
235+ ":cret:" =>'/smileys/lapin.png',
236+ ":sm:" =>'/smileys/sm.gif',
237+ "(8)" =>'/smileys/note.gif',
238+ "",
239+ "[vtff]" =>'/smileys/smile149.gif',
240+ "[f]" =>'/smileys/smile143.gif',
241+ "[bou]" =>'/smileys/smile148.gif',
242+ "[serenade]"=>'/smileys/smile052.gif',
243+ "[Love]" =>'/smileys/smile009.gif',
244+ );
245+$array_smileys_yahoo=array(
246+ "yh;))" =>"/yahoo/yb671.gif",
247+ "yh;)" =>"/yahoo/yb63.gif",
248+ "yh;;)" =>"/yahoo/yb65.gif",
249+ "yh:-/" =>"/yahoo/yb67.gif",
250+ "yh:x" =>"/yahoo/yb68.gif",
251+ "yh:-x" =>"/yahoo/yb68.gif",
252+ "yh:\">" =>"/yahoo/yb69.gif",
253+ "yh:-P" =>"/yahoo/yb610.gif",
254+ "yh:P" =>"/yahoo/yb610.gif",
255+ "yh:-*" =>"/yahoo/yb611.gif",
256+ "yh:*" =>"/yahoo/yb611.gif",
257+ "yh:-O" =>"/yahoo/yb613.gif",
258+ "yhX-(" =>"/yahoo/yb614.gif",
259+ "yh:->" =>"/yahoo/yb615.gif",
260+ "yhB-)" =>"/yahoo/yb616.gif",
261+ "yh:-S" =>"/yahoo/yb617.gif",
262+ "yh>;:)" =>"/yahoo/yb619.gif",
263+ "yh>:)" =>"/yahoo/yb619.gif",
264+ "yh:((" =>"/yahoo/yb620.gif",
265+ "yh:))" =>"/yahoo/yb621.gif",
266+ "yh:|" =>"/yahoo/yb622.gif",
267+ "yh/:)" =>"/yahoo/yb623.gif",
268+ "yhO:-)" =>"/yahoo/yb625.gif",
269+ "yh:-B" =>"/yahoo/yb626.gif",
270+ "yh=;" =>"/yahoo/yb627.gif",
271+ "yhI-)" =>"/yahoo/yb628.gif",
272+ "yh|-)" =>"/yahoo/yb628.gif",
273+ "yh8-|" =>"/yahoo/yb629.gif",
274+ "yh:-$" =>"/yahoo/yb632.gif",
275+ "yh[-(" =>"/yahoo/yb633.gif",
276+ "yh:o)" =>"/yahoo/yb634.gif",
277+ "yh8-}" =>"/yahoo/yb635.gif",
278+ "yh(:|" =>"/yahoo/yb637.gif",
279+ "yh=P~" =>"/yahoo/yb638.gif",
280+ "yh:-?" =>"/yahoo/yb639.gif",
281+ "yh#-o" =>"/yahoo/yb640.gif",
282+ "yh=D>" =>"/yahoo/yb641.gif",
283+ "yh:@)" =>"/yahoo/yb649.gif",
284+ "yh3:-o" =>"/yahoo/yb650.gif",
285+ "yh3:-0" =>"/yahoo/yb650.gif",
286+ "yh:(|)" =>"/yahoo/yb651.gif",
287+ "yh@};-" =>"/yahoo/yb653.gif",
288+ "yh%%-" =>"/yahoo/yb654.gif",
289+ "yh**==" =>"/yahoo/yb655.gif",
290+ "yh(~~)" =>"/yahoo/yb656.gif",
291+ "yh~o)" =>"/yahoo/yb657.gif",
292+ "yh*-:)" =>"/yahoo/yb658.gif",
293+ "yh8-x" =>"/yahoo/yb659.gif",
294+ "yh=:)" =>"/yahoo/yb660.gif",
295+ "yh>-)" =>"/yahoo/yb661.gif",
296+ "yh:-L" =>"/yahoo/yb662.gif",
297+ "yh>):)" =>"/yahoo/yb648.gif",
298+ "yh[-o<" =>"/yahoo/yb663.gif",
299+ "yh@-) " =>"/yahoo/yb643.gif",
300+ "yh$-)" =>"/yahoo/yb664.gif",
301+ "yh:-\"" =>"/yahoo/yb665.gif",
302+ "yh:^O" =>"/yahoo/yb644.gif",
303+ "yhb-(" =>"/yahoo/yb666.gif",
304+ "yh:)>-" =>"/yahoo/yb667.gif",
305+ "yh[-X" =>"/yahoo/yb668.gif",
306+ "yh\\:D/" =>"/yahoo/wbyim59.gif",
307+ "yh>:D<" =>"/yahoo/yb66.gif",
308+ "yh=))" =>"/yahoo/yb624.gif",
309+ "yhL-)" =>"/yahoo/yb630.gif",
310+ "yh:-w" =>"/yahoo/yb645.gif",
311+ "yh:-<" =>"/yahoo/yb646.gif",
312+ "yh>:P" =>"/yahoo/yb647.gif",
313+ "yh>:/" =>"/yahoo/yb670.gif",
314+ "yh:-@" =>"/yahoo/yb676.gif",
315+ "yh^:)^" =>"/yahoo/yb677.gif",
316+ "yh:-j" =>"/yahoo/yb678.gif",
317+ "yh(*)" =>"/yahoo/yb679.gif",
318+ "yh:D" =>"/yahoo/yb64.gif",
319+ "yh:(" =>"/yahoo/yb62.gif",
320+ "yh:)" =>"/yahoo/yb61.gif",
321+ "yh:-&" =>"/yahoo/yb631.gif",
322+ );
323+
324+foreach($array_smileys as $smil=>$replacement){
325+ $replacement=" <img src=\"http://images.ivynet.org".$replacement."\" alt=\"".($smil)."\" /> ";
326+ bbcode_add_smiley($BBHandler,$smil,$replacement);
327+}
328+foreach($array_smileys_yahoo as $smil=>$replacement){
329+ $replacement=" <img src=\"http://images.ivynet.org".$replacement."\" alt=\"".($smil)."\" /> ";
330+ bbcode_add_smiley($BBHandler,$smil,$replacement);
331+}
332+bbcode_set_flags($BBHandler,BBCODE_CORRECT_REOPEN_TAGS | BBCODE_ARG_DOUBLE_QUOTE | BBCODE_ARG_SINGLE_QUOTE | BBCODE_ARG_HTML_QUOTE | BBCODE_AUTO_CORRECT, BBCODE_SET_FLAGS_SET);
333+if (!function_exists('bbCode')){
334+ function bbCode($message){
335+ global $BBHandler;
336+ $err=error_reporting(E_ALL);
337+ $message=bbcode_parse($BBHandler,$message);
338+ $message=str_replace(" "," &nbsp;",$message);
339+ error_reporting($err);
340+ return $message;
341+ //$BBHandler->treat($message);
342+ //return $message;
343+ }
344+}
345+
346+function BBSize($content,$param){
347+ $param=min(24,max(4,$param));
348+ return $param;
349+}
350+function BBList($content,$param){
351+ if ($param=="-1"){
352+ return '<ul>'.$content.'</ul>';
353+ } else {
354+ return '<ol type="'.$param.'">'.$content.'</ol>';
355+ }
356+}
357+function BBInt($content,$param){
358+ $param= (int) $param;
359+ return $param;
360+}
361+function BBBorder($content,$param){
362+ $param= min(8,max(1,$param));
363+ return $param;
364+}
365+function bbid2user($content,$param){
366+ if ($param=='{SELF}'){
367+ $param=(int)$content;
368+ $content='pseudo';
369+ }
370+ $id=$param;
371+ $content="<a href='".$content."'>".$content."</a>";
372+ return $content;
373+}
374+function BBId2Msg($content,$param){
375+ if ($param=='{SELF}'){
376+ $param=(int)$content;
377+ $content='pseudo';
378+ }
379+ $id=$param;
380+ $content="<a href='/message.php?destinataire=$id'>".html_encode_string($content)."</a>";
381+ return $content;
382+}
383+function BBWave($content,$param="8:24"){
384+ if ($_GET['page']=="chat-2.php"){
385+ return ("[wave=$param]".$content."[/wave]");
386+ }
387+ $content=str_replace("\r\n","\n",$content);
388+ $string=preg_split('//u',html_entity_decode(strip_tags($content),ENT_QUOTES,"UTF-8"),-1,PREG_SPLIT_NO_EMPTY);
389+ list ($min, $max)=explode(":",$param);
390+ $out="";
391+ if ($max==$min){
392+ return true;
393+ }
394+ if ($max<$min){
395+ $tmp=$max;
396+ $max=$min;
397+ $min=$tmp;
398+ }
399+ if (strlen($content)<$max-$min && $content!=0){
400+ $step=round(($max-$min)/$content);
401+ }
402+ else{
403+ $step=1;
404+ }
405+ $i=$min;
406+ $up=true;
407+ foreach ($string as $car){
408+ $car=html_encode_string($car);
409+ $out.="<span style='font-size:".$i."px;'>".$car."</span>";
410+ if ($up){
411+ $i+=$step;
412+ }else {
413+ $i-=$step;
414+ }
415+ if ($i>=$max){
416+ $up=false;
417+ $i=$max;
418+ }
419+ elseif($i<=$min){
420+ $up=true;
421+ $i=$min;
422+ }
423+ }
424+ $content=$out;
425+ return $content;
426+}
427+function shortenAuthor($content,$param=""){
428+ if (strlen($param)>150){
429+ $param=substr($param,0,150);
430+ }
431+ return $param;
432+}
433+function BBDegrade($content,$param=""){
434+ $content=str_replace("\r\n","\n",$content);
435+ $string=preg_split('//u',html_entity_decode(strip_tags($content),ENT_QUOTES,"UTF-8"),-1,PREG_SPLIT_NO_EMPTY);
436+ $colors=explode(":",$param);
437+ $out="";
438+ foreach($colors as $v){
439+ $col[]=array('r'=>base_convert(substr($v,0,2),16,10),'g'=>base_convert(substr($v,2,2),16,10),'b'=>base_convert(substr($v,4,6),16,10));
440+ }
441+ $str_size=sizeof($string);
442+ $nb_col=sizeof($col);
443+ if ($nb_col<2)
444+ {
445+ return $content;
446+ }
447+ $steps=max(round($str_size/($nb_col-1)),1);
448+ $last=null;
449+ foreach ($string as $k=>$car){
450+ $car=html_encode_string($car);
451+ if ($k%$steps==0){
452+ $nb=$k/$steps;
453+ $r=sprintf("%02x",$col[$nb]['r']);
454+ $g=sprintf("%02x",$col[$nb]['g']);
455+ $b=sprintf("%02x",$col[$nb]['b']);
456+ }
457+ elseif($k>($steps*($nb_col-1))){
458+ $nb=$nb_col-1;
459+ $r=sprintf("%02x",$col[$nb]['r']);
460+ $g=sprintf("%02x",$col[$nb]['g']);
461+ $b=sprintf("%02x",$col[$nb]['b']);
462+ }else{
463+ $nb=ceil($k/$steps);
464+ $r=sprintf("%02x",(abs(round($col[$nb-1]['r']-((($col[$nb-1]['r']-$col[$nb]['r'])/$steps)*($k%$steps))))));
465+ $g=sprintf("%02x",(abs(round($col[$nb-1]['g']-((($col[$nb-1]['g']-$col[$nb]['g'])/$steps)*($k%$steps))))));
466+ $b=sprintf("%02x",(abs(round($col[$nb-1]['b']-((($col[$nb-1]['b']-$col[$nb]['b'])/$steps)*($k%$steps))))));
467+ }
468+ $current=$r.$g.$b;
469+ if (is_null($last)){
470+ $first=$current;
471+ }
472+ if ($current!=$last){
473+ $out.='</span><span style="color:#'.$current.';">';
474+ $last=$current;
475+ }
476+ $out.=$car;
477+ }
478+ $out.='</span>';
479+ return substr($out,strlen('</span>'));
480+}
481+function BBVoid($content,$param){
482+ return " ";
483+}
484+function BBBackTrace($string,$base)
485+{
486+ $string=br2nl($string);
487+ $base=base_convert($base,16,10);
488+ $step=16;
489+ $tmp="";
490+ $i=0;
491+ while ($i<strlen($string))
492+ {
493+ $tmp.="[<b>0x".base_convert($base+$i,10,16)."-0x".base_convert($base+$i+$step-1,10,16)."</b> : \"".addcslashes(substr($string,$i,$step),"\n\t\\'\"\0")."\"]<br />\n";
494+ $i+=$step;
495+ }
496+ $string=$tmp;
497+ return $string;
498+}
499+function BBHexDump($string,$base)
500+{
501+ $string=br2nl($string);
502+ $base=base_convert($base,16,10);
503+ $step=16;
504+ $tmp="";
505+ $i=0;
506+ while ($i<strlen($string))
507+ {
508+ $tmp.="[<b>0x".base_convert($base+$i,10,16)."-0x".base_convert($base+$i+$step-1,10,16)."</b> : 0x";
509+ for ($j=0;$j<$step;$j++){
510+ $tmp.=sprintf("%02x",ord(substr($string,$i+$j,1)));
511+ }
512+ $tmp.="]<br />\n";
513+ $i+=$step;
514+ }
515+ $string=$tmp;
516+ return $string;
517+}
518+function random_id($content, $param){
519+ return uniqid($param."_");
520+}
521+function content_validate_url($content,$param){
522+ if ($param=="{CONTENT}"){
523+ return validate_url($param,$content);
524+ }
525+ return $content;
526+}
527+function validate_url($content, $param){
528+}
529+//$text="[i] Parser [b] Auto Correction [/i] at work [/b]\n";
530+bbCode($text);
531+bbCode($text);
532+bbCode($text);
533+bbCode($text);
534+bbCode($text);
535+bbCode($text);
536+bbcode_destroy($BBHandler);
537+echo "Nothing";
538+?>
539+--EXPECT--
540+Nothing
541
542Property changes on: tests/test_ivy.phpt
543___________________________________________________________________
544Added: svn:eol-style
545 + native
546Added: svn:keywords
547 + Id Rev Revision Date LastChangedDate LastChangedRevision Author LastChangedBy HeadURL URL
548Added: cvs2svn:cvs-rev
549 + 1.4
550
551Index: tests/test_26.phpt
552===================================================================
553--- tests/test_26.phpt (.../tags/RELEASE_1_0_2)
554+++ tests/test_26.phpt (.../trunk)
555@@ -0,0 +1,84 @@
556+--TEST--
557+BBCODE Param and Content Callbacks
558+--FILE--
559+<?php
560+if (!extension_loaded('bbcode')){
561+ if (!dl('bbcode.so')){
562+ die ('bbcode not loadable');
563+ }
564+}
565+Class Foo_C{
566+ static function bar($content,$param){
567+ return "Foo_C::bar ".$content;
568+ }
569+ function foo($content, $param) {
570+ return "Foo_C->foo_cb() ".$content;
571+ }
572+}
573+function C_callback($content, $param){
574+ return "C_Callback ".$content;
575+}
576+Class Foo_P{
577+ static function bar($content,$param){
578+ return "Foo_P::bar ".$param;
579+ }
580+ function foo($content, $param) {
581+ return "Foo_P->foo() ".$param;
582+ }
583+}
584+function P_callback($content, $param){
585+ return "P_Callback ".$param;
586+}
587+function f_empty(){}
588+
589+$foo_C = new Foo_C;
590+$foo_P = new Foo_P;
591+
592+$arrayBBCode=array(
593+ 'i'=> array('type' => BBCODE_TYPE_ARG, 'open_tag' => '<i {PARAM}>', 'close_tag' => '</i>',
594+ 'content_handling' => array('Foo_C', 'bar'),
595+ 'param_handling' => array('Foo_P', 'bar'),
596+ ),
597+ 'b'=> array('type' => BBCODE_TYPE_ARG, 'open_tag' => '<b {PARAM}>', 'close_tag' => '</b>',
598+ 'content_handling' => array($foo_C, 'foo'),
599+ 'param_handling' => array($foo_P, 'foo'),
600+ ),
601+ 'u'=> array('type' => BBCODE_TYPE_ARG, 'open_tag' => '<u {PARAM}>', 'close_tag' => '</u>',
602+ 'content_handling' => 'C_callback',
603+ 'param_handling' => 'P_callback',
604+ ),
605+ 'e'=> array('type' => BBCODE_TYPE_ARG, 'open_tag' => '<e {PARAM}>', 'close_tag' => '</e>',
606+ 'content_handling' => 'f_empty',
607+ 'param_handling' => 'f_empty',
608+ ),
609+);
610+$text=<<<EOF
611+[u=aa]Underlined Text[/u]
612+[i=aa]Italic Text[/i]
613+[b=aa]Bold Text[/b]
614+[e=aa]Emptied Text[/e]
615+EOF;
616+$BBHandler = bbcode_create($arrayBBCode);
617+echo "== Run #1 ==\n", bbcode_parse($BBHandler,$text);
618+echo "\n";
619+echo "== Run #2 ==\n", bbcode_parse($BBHandler,$text);
620+echo "\n";
621+echo "== Run #3 ==\n", bbcode_parse($BBHandler,$text);
622+bbcode_destroy($BBHandler);
623+?>
624+--EXPECT--
625+== Run #1 ==
626+<u P_Callback aa>C_Callback Underlined Text</u>
627+<i Foo_P::bar aa>Foo_C::bar Italic Text</i>
628+<b Foo_P->foo() aa>Foo_C->foo_cb() Bold Text</b>
629+<e ></e>
630+== Run #2 ==
631+<u P_Callback aa>C_Callback Underlined Text</u>
632+<i Foo_P::bar aa>Foo_C::bar Italic Text</i>
633+<b Foo_P->foo() aa>Foo_C->foo_cb() Bold Text</b>
634+<e ></e>
635+== Run #3 ==
636+<u P_Callback aa>C_Callback Underlined Text</u>
637+<i Foo_P::bar aa>Foo_C::bar Italic Text</i>
638+<b Foo_P->foo() aa>Foo_C->foo_cb() Bold Text</b>
639+<e ></e>
640
641Property changes on: tests/test_26.phpt
642___________________________________________________________________
643Added: svn:eol-style
644 + native
645Added: svn:keywords
646 + Id Rev Revision Date LastChangedDate LastChangedRevision Author LastChangedBy HeadURL URL
647Added: cvs2svn:cvs-rev
648 + 1.1
649
650Index: tests/test_27.phpt
651===================================================================
652--- tests/test_27.phpt (.../tags/RELEASE_1_0_2)
653+++ tests/test_27.phpt (.../trunk)
654@@ -0,0 +1,25 @@
655+--TEST--
656+BBCODE Invalid quote segfaults
657+--SKIP--
658+<?php
659+if (!extension_loaded('bbcode')){
660+ die ('skip bbcode not loadable');
661+}
662+?>
663+--FILE--
664+<?php
665+
666+$text = <<< MSG
667+[quote=a]foo[/quote]
668+[quote="b]bar[/quote]
669+MSG;
670+
671+$BBCode = array(
672+ 'quote' => array('type'=> BBCODE_TYPE_OPTARG),
673+);
674+
675+echo bbcode_parse(bbcode_create($BBCode), $text);
676+?>
677+--EXPECT--
678+foo
679+[quote="b]bar[/quote]
680
681Property changes on: tests/test_27.phpt
682___________________________________________________________________
683Added: svn:eol-style
684 + native
685Added: svn:keywords
686 + Id Rev Revision Date LastChangedDate LastChangedRevision Author LastChangedBy HeadURL URL
687Added: cvs2svn:cvs-rev
688 + 1.1
689
690
691Property changes on: tests
692___________________________________________________________________
693Added: svn:ignore
694 + *.diff
695*.mem
696*.log
697*.out
698*.exp
699*.swp
700*.php
701phpt.*
702
703
704Index: bbcode.php
705===================================================================
706--- bbcode.php (.../tags/RELEASE_1_0_2)
707+++ bbcode.php (.../trunk)
708@@ -0,0 +1,989 @@
709+<?php
710+/**
711+ * BBCode Library
712+ *
713+ */
714+/**
715+ * A complex BBCode Tags Parser
716+ *
717+ * The BBCode Array Arguments
718+ * childs
719+ * close_tag
720+ * content_handling
721+ * default_arg
722+ * flags > BBCode::FLAGS_*
723+ * open_tag
724+ * parents
725+ * param_handling
726+ * type > BBCode::TYPE_*
727+ */
728+Class BBCode{
729+ const TYPE_NOARG= 1;
730+ const TYPE_SINGLE= 2;
731+ const TYPE_ARG= 3;
732+ const TYPE_OPTARG= 4;
733+ const TYPE_ROOT= 10;
734+
735+ // Flags
736+ const FLAGS_ARG_PARSING= 1;
737+ const FLAGS_CDATA_NOT_ALLOWED= 2;
738+ const FLAGS_SMILEYS_ON= 4;
739+ const FLAGS_SMILEYS_OFF= 8;
740+ const FLAGS_ONE_OPEN_PER_LEVEL= 16;
741+ /* Quote style accepted */
742+ /**
743+ * Accepts args with no quotes ([tag=arg])
744+ * Cannot be disabled
745+ */
746+ const ARG_NO_QUOTE=0;
747+ /**
748+ * Accepts args with double quotes ([tag="arg"])
749+ */
750+ const ARG_DOUBLE_QUOTE=1;
751+ /**
752+ * Accepts args with single quotes ([tag='arg'])
753+ * one of the Double / Single quote is needed for subparsing
754+ */
755+ const ARG_SINGLE_QUOTE=2;
756+
757+ /**
758+ * Enable autocorrection of HTML By closing "still opened tags"
759+ *
760+ * @var boolean
761+ */
762+ public $auto_correct=true;
763+ /**
764+ * If tags are incorrectly nested, they are closed and reopened
765+ * after the previous tag close
766+ *
767+ * @var boolean
768+ */
769+ public $correct_reopen_tags=true;
770+ /**
771+ * Indicate wheter smileys are treated or not if no tag level
772+ * instructions override this
773+ *
774+ * @var boolean
775+ */
776+ public $default_smileys=true;
777+ /**
778+ * Indicates what styles of quotes are accepted
779+ *
780+ * @var int
781+ */
782+ public $quote_styles;
783+ /**
784+ * Disable BBCode Parsing
785+ *
786+ * @var boolean
787+ */
788+ public $noTreeBuild=false;
789+ /**
790+ * Disable Smileys
791+ *
792+ * @var boolean
793+ */
794+ public $force_smileys_off=false;
795+
796+ /**
797+ * Privates Vars
798+ *
799+ * @var BBCode - if a specific parser is needed for argument parsing
800+ */
801+ private $arg_parser=null;
802+
803+ /**
804+ * The internal working Tree
805+ *
806+ * @var Array
807+ */
808+ private $tree;
809+ /**
810+ * Lists Levels to access the root level
811+ * @var array
812+ */
813+ private $stack;
814+ /**
815+ * An index to lists tags opened through the stack
816+ * @var array
817+ */
818+ private $stackIndex;
819+ /**
820+ * The active Node
821+ * @var array
822+ */
823+ private $currentNode;
824+ /**
825+ * Lists of unclosed stack
826+ * @var array
827+ */
828+ private $toClose;
829+ /**
830+ * An index to lists unclosed tag
831+ * @var array
832+ */
833+ private $toCloseIndex;
834+
835+ /**
836+ * The List of tags (external representation)
837+ *
838+ * @var array
839+ */
840+ private $tagList;
841+ /**
842+ * The List of tags (internal representation)
843+ *
844+ * @var array
845+ */
846+ private $tagListCache;
847+ /**
848+ * The index to map TagName to tagid
849+ *
850+ * @var array
851+ */
852+ private $tagListIndex;
853+ /**
854+ * The list of smileys
855+ *
856+ * @var array
857+ */
858+ private $smileys;
859+
860+ private $close_time=0;
861+ private $add_time=0;
862+
863+ /**
864+ * The Constructor
865+ *
866+ * @param array $tag_init a list of BBCode for quick init
867+ * @param array $smileys_init a list of smileys for quick init
868+ */
869+ public function __construct($tag_init=null,$smileys_init=null){
870+ $this->tagList=$this->smileys=array();
871+ if (is_array($tag_init)){
872+ $this->tagList=$tag_init;
873+ $this->tagListCache=null;
874+ }
875+ if (is_array($smileys_init)){
876+ $this->smileys=$smileys_init;
877+ }
878+ $this->quote_styles=self::ARG_NO_QUOTE|self::ARG_DOUBLE_QUOTE|self::ARG_SINGLE_QUOTE;
879+ $this->tree=null;
880+ }
881+ /**
882+ * Attach a parser as argument sub-parser
883+ *
884+ * @param BBCode $bbcode_parser
885+ */
886+ public function set_arg_parser($bbcode_parser){
887+ $this->arg_parser=null;
888+ if ($bbcode_parser instanceof BBCode){
889+ $this->arg_parser=$bbcode_parser;
890+ }
891+ }
892+ /**
893+ * This function is there to add an individual tag to the list
894+ *
895+ * @param string $tag_name
896+ * @param array $array
897+ */
898+ public function add_element($tag_name,$array){
899+ $this->tagList[$tag_name]=$array;
900+ $this->tagListCache=null;
901+ }
902+ /**
903+ * Adds an individual smiley to the list
904+ *
905+ * @param string $smiley
906+ * @param string $replacement
907+ */
908+ public function attach_smileys($smiley, $replacement){
909+ $this->smileys[$smiley]=$replacement;
910+ }
911+
912+ /**
913+ * Parse a string from BBCode following the rules given
914+ *
915+ * @param String $string
916+ * @return string
917+ */
918+ public function parse($string){
919+ // Init
920+ $this->toCloseIndex=$this->toClose=$this->stackIndex=$this->stack=array();
921+ $this->tree=null;
922+ if ($this->noTreeBuild){
923+ $this->tree=array('i'=>$this->get_tag_id(''),'p'=>true,'s'=>'');
924+ $this->tree['c'][] = $string;
925+ } else {
926+ $this->prepareTagList();
927+ // Tree construction
928+ $this->build_tree($string);
929+ // Tree corrections and fetch
930+ $this->correct_tree();
931+ }
932+ // Conversion
933+ return $this->apply_rules($this->tree);
934+ }
935+
936+ /**
937+ * Convert external representation of the taglist to internal
938+ *
939+ */
940+ private function prepareTagList(){
941+ if ($this->tagListCache!=null){
942+ return;
943+ }
944+ if (!isset($this->tagList[''])){
945+ $this->tagList['']=array();
946+ }
947+ $i=0;
948+ // 1. Populate the tagListCache
949+ $all=array();
950+ foreach($this->tagList as $tag=>$tag_datas){
951+ $all[]=$i;
952+ $this->tagListIndex[$tag]=$i;
953+ /**
954+ * Internal fields:
955+ *
956+ * 0 'type'
957+ * 1 'open_tag'
958+ * 2 'close_tag'
959+ * 3 'default_arg'
960+ * 4 'flags'
961+ * 5 'parents'
962+ * 6 'childs'
963+ * 7 'content_handling'
964+ * 8 'content_handling_is_callback'
965+ * 9 'param_handling'
966+ * 10 'param_handling_is_callback'
967+ * 11 'accept_arg'
968+ * 12 'accept_noarg'
969+ * 13 'start_has_bracket_open'
970+ * 14 'end_has_bracket_open'
971+ * 15 'accept_smileys'
972+ */
973+ $type=isset($tag_datas['type'])?$tag_datas['type']:BBCODE_TYPE_NOARG;
974+ $start=isset($tag_datas['open_tag'])?$tag_datas['open_tag']:'';
975+ $end=isset($tag_datas['close_tag'])?$tag_datas['close_tag']:'';
976+ $flags=isset($tag_datas['flags'])?$tag_datas['flags']:0;
977+ $this->tagListCache[$i]=array($type,
978+ $start,
979+ $end,
980+ isset($tag_datas['default_arg'])?$tag_datas['default_arg']:'',
981+ $flags,
982+ isset($tag_datas['parents'])?$tag_datas['parents']:'all',
983+ isset($tag_datas['childs'])?$tag_datas['childs']:'all',
984+ isset($tag_datas['content_handling'])?$tag['content_handling']:'',
985+ null,
986+ isset($tag_datas['param_handling'])?$tag['param_handling']:'',
987+ null,
988+ (bool)($type==BBCode::TYPE_ARG || $type==BBCode::TYPE_OPTARG),
989+ (bool)($type==BBCode::TYPE_NOARG || $type==BBCode::TYPE_OPTARG || $type==BBCode::TYPE_SINGLE),
990+ (bool)(strpos($start,"{")),
991+ (bool)(strpos($end,"{")),
992+ ((($flags&(BBCode::FLAGS_SMILEYS_OFF|BBCode::FLAGS_SMILEYS_ON))==0)&& $this->default_smileys ) || $flags&(BBCode::FLAGS_SMILEYS_ON),
993+ );
994+ ++$i;
995+ }
996+ // 2. Parse Child / Parents List
997+ foreach($this->tagListCache as $i=>$val){
998+ // Childs
999+ if ($val[6]=='all'){
1000+ $val[6]=$all;
1001+ } elseif ($val[6]==''){
1002+ $val[6]=array();
1003+ } elseif ($val[6][0]=='!'){
1004+ $values=explode(',',substr($val[6],1));
1005+ $val[6]=$all;
1006+ foreach ($values as $element){
1007+ if($tag_id=$this->get_tag_id($element)){
1008+ $pos=array_search($tag_id,$val[6]);
1009+ unset($val[6][$pos]);
1010+ }
1011+ }
1012+ } else {
1013+ $values=explode(',',$val[6]);
1014+ foreach ($values as $element){
1015+ $val[6]=array();
1016+ if($tag_id=$this->get_tag_id($element)){
1017+ $val[6][]=$tag_id;
1018+ }
1019+ }
1020+ }
1021+ //Parents
1022+ if ($val[5]=='all'){
1023+ $val[5]=$all;
1024+ } elseif ($val[5]==''){
1025+ $val[5]=array();
1026+ } elseif ($val[5][0]=='!'){
1027+ $val[5]=$all;
1028+ $values=explode(',',substr($val[5],1));
1029+ foreach ($values as $element){
1030+ $val[5]=array();
1031+ if($tag_id=$this->get_tag_id($element)){
1032+ $pos=array_search($val[5],$tag_id);
1033+ unset($val[5][$pos]);
1034+ }
1035+ }
1036+ } else {
1037+ $values=explode(',',$val[5]);
1038+ foreach ($values as $element){
1039+ $val[5]=array();
1040+ if($tag_id=$this->get_tag_id($element)){
1041+ $val[5][]=$tag_id;
1042+ }
1043+ }
1044+ }
1045+ $this->tagListCache[$i]=$val;
1046+ }
1047+ }
1048+
1049+ /**
1050+ * Build the tree representation of the given string
1051+ *
1052+ * @param string $string
1053+ */
1054+ private function build_tree($string){
1055+ $strlen=strlen($string);
1056+ $quote_double=(bool)$this->quote_styles&self::ARG_DOUBLE_QUOTE;
1057+ $quote_single=(bool)$this->quote_styles&self::ARG_SINGLE_QUOTE ;
1058+ $end_quote="";
1059+ $end=0;
1060+ $this->tree=array('i'=>$this->get_tag_id(''),'p'=>true,'s'=>'');
1061+ $this->currentNode =& $this->tree;
1062+ // Init Working Var
1063+ $next_close=$next_equal=0;
1064+ $offset=strpos($string,'[');
1065+ $this->add_child(substr($string,0,$offset));
1066+ do {
1067+ $added=false;
1068+ if ($string[$offset]=='['){
1069+ if (($string[$offset+1])!='/'){
1070+ //Open
1071+ // Equal
1072+ if ($next_equal<=$offset){
1073+ if (false===$next_equal=strpos($string,'=',$offset)){
1074+ $next_equal=$strlen+5;
1075+ }
1076+ }
1077+ if ($next_close<=$offset){
1078+ if (false===$next_close=strpos($string,']',$offset)){
1079+ $next_close=$strlen+5;
1080+ }
1081+ }
1082+ if ($next_close<$strlen){
1083+ // With Arg
1084+ if ($next_equal<$next_close){
1085+ $tag=substr($string,$offset+1,$next_equal-$offset-1);
1086+ if (false!==($tagId=$this->get_tag_id($tag,true))){
1087+ $argument=false;
1088+ if ($this->quote_styles>0){
1089+ $end_quote='';
1090+ $end=$next_close;
1091+ if ($quote_single && $string[$next_equal+1]=="'"){
1092+ $end_quote="'";
1093+ } elseif ($quote_double && $string[$next_equal+1]=='"') {
1094+ $end_quote='"';
1095+ }
1096+ if ($end_quote==''){
1097+ $argument=substr($string,$next_equal+1,$next_close-$next_equal-1);
1098+ } else {
1099+ if (false!==$end=strpos($string,"$end_quote]",$next_equal+1)){
1100+ $argument=substr($string,$next_equal+2,$end++ - $next_equal - 2);
1101+ } else {
1102+ $end=$strlen+5;
1103+ }
1104+ }
1105+ } else {
1106+ $argument=substr($string,$next_equal+1,$next_close-$next_equal-1);
1107+ }
1108+ if ($argument!==false){
1109+ $this->add_child(substr($string,$offset,$end-$offset+1),$tagId,$argument);
1110+ $added=true;
1111+ }
1112+ } else {
1113+ $end=$next_close;
1114+ }
1115+ } else {
1116+ // Without Args
1117+ $tag=substr($string,$offset+1,$next_close-$offset-1);
1118+ $end=$next_close;
1119+ if (false!==($tagId=$this->get_tag_id($tag,false))){
1120+ $this->add_child(substr($string,$offset,$end-$offset+1),$tagId);
1121+ $added=true;
1122+ }
1123+ }
1124+ }
1125+ } else {
1126+ if ($next_close<=$offset){
1127+ if (false===($next_close=strpos($string,']',$offset))){;
1128+ $next_close=$strlen+5;
1129+ }
1130+ }
1131+ //Close
1132+ $tag=substr($string,$offset+2,$next_close-$offset-2);
1133+ $end=$next_close;
1134+ if (false!==($tagId=$this->get_tag_id($tag))){
1135+ $this->close_tag($tagId,substr($string,$offset,$end-$offset+1));
1136+ $added=true;
1137+ }
1138+ }
1139+ }
1140+ if (!$added){
1141+ $end=strpos($string,'[',$offset+1);
1142+ if ($end==false){
1143+ $end=$strlen;
1144+ } else {
1145+ --$end;
1146+ }
1147+ $this->add_child(substr($string,$offset,$end-$offset+1));
1148+ }
1149+ $offset=$end+1;
1150+ } while($offset<$strlen);
1151+ }
1152+
1153+ /**
1154+ * Adds a child to the tree
1155+ *
1156+ * @param string $string
1157+ * @param int $tagId
1158+ * @param string $argument
1159+ */
1160+ private function add_child($string,$tagId=null,$argument=null){
1161+ if ($tagId===null){
1162+ // Only a textNode => Adding to childs
1163+ $this->currentNode['c'][]=$string;
1164+ } else {
1165+ $tag=$this->tagListCache[$tagId];
1166+ // Auto Closing some elements
1167+ if ($tag[4]&BBCode::FLAGS_ONE_OPEN_PER_LEVEL){
1168+ //Fixme Multiple parents cases
1169+ $index=array_reverse($this->stackIndex);
1170+ array_unshift($index,$this->currentNode['i']);
1171+ $parent_pos=PHP_INT_MAX;
1172+ foreach($tag[5] as $poss_parent){
1173+ $parent_pos=min(array_search($poss_parent,$index),$parent_pos);
1174+ }
1175+ if (false!==($last_el_pos=array_search($tagId,$index))){
1176+ if ($parent_pos<$last_el_pos){
1177+ // Return to parent
1178+ for($i=0;$i<$parent_pos;++$i){
1179+ $this->close_tag($index[$i],'',false);
1180+ }
1181+ } else {
1182+ // Close last element
1183+ $this->close_tag($tagId,'');
1184+ }
1185+ }
1186+ }
1187+ // Creating Node
1188+ $new_node=array('i'=>$tagId,'c'=>array(),'s'=>$string,'a'=>$argument===null?'':$argument,'p'=>false);
1189+ $this->currentNode['c'][] =& $new_node;
1190+ $this->stack[] =& $this->currentNode;
1191+ $this->currentNode =& $new_node;
1192+ $this->stackIndex[]=$tagId;
1193+ if ($tag[0]==BBCode::TYPE_SINGLE){
1194+ $this->close_tag($tagId,'');
1195+ }
1196+ }
1197+ }
1198+
1199+ /**
1200+ * Closes a tag
1201+ *
1202+ * @param int $tag_id
1203+ * @param string $string
1204+ * @param boolean $true_close
1205+ */
1206+ private function close_tag($tag_id, $string,$true_close=true){
1207+ if (in_array($tag_id,$this->toCloseIndex)){
1208+ $closeIndex = array_search($tag_id, $this->toCloseIndex);
1209+ $this->toClose[$closeIndex]['p']=true;
1210+ array_splice($this->toClose,$closeIndex,1);
1211+ array_splice($this->toCloseIndex,$closeIndex,1);
1212+ } elseif (in_array($tag_id,$this->stackIndex)){
1213+ // Tag Open
1214+ $searching=true;
1215+ $conds=array();
1216+ do{
1217+ if ($this->currentNode['i']==$tag_id){
1218+ $searching=false;
1219+ // Mark this node as paired (we found close tag)
1220+ $this->currentNode['p']=$true_close;
1221+ $this->currentNode['cs']=$string;
1222+ $this->currentNode['cond'] =& $conds;
1223+ if (isset($this->currentNode['mp'])){
1224+ $this->currentNode['l']=true;
1225+ }
1226+ if (!$true_close){
1227+ $this->toClose[] =& $this->currentNode;
1228+ }
1229+ } else {
1230+ if (!in_array($tag_id,$this->tagListCache[$this->currentNode['i']][6])){
1231+ $conds[] =& $this->currentNode;
1232+ }
1233+ $this->currentNode['cs']='';
1234+ if ($this->tagListCache[$this->currentNode['i']][4]&BBCode::FLAGS_ONE_OPEN_PER_LEVEL){
1235+ $this->currentNode['p'] = true;
1236+ } else {
1237+ $this->currentNode['p'] = false;
1238+ $this->toClose[] =& $this->currentNode;
1239+ $this->toCloseIndex[] = $this->currentNode['i'];
1240+ }
1241+ }
1242+ array_pop($this->stackIndex);
1243+ $this->currentNode =& $this->stack[count($this->stack)-1];
1244+ array_pop($this->stack);
1245+ } while($searching);
1246+ if ($this->correct_reopen_tags){
1247+ $new_node = array();
1248+ for($i=count($this->toClose)-1;$i>=0;--$i){
1249+ if (!isset($this->toClose[$i]['mp'])){
1250+ $this->toClose[$i]['d'] = false;
1251+ $this->toClose[$i]['mp'] = array(& $this->toClose[$i]);
1252+ }
1253+ $new_node[$i] = array(
1254+ 'i'=>$this->toClose[$i]['i'],
1255+ 's'=>'', 'cs'=>'',
1256+ 'p'=>& $this->toClose[$i]['p'],
1257+ 'd'=>& $this->toClose[$i]['d'],
1258+ 'mp'=>& $this->toClose[$i]['mp'],
1259+ 'par'=>array()
1260+ );
1261+ if (isset($this->toClose[$i]['a'])){
1262+ $new_node[$i]['a']=$this->toClose[$i]['a'];
1263+ }
1264+ $new_node[$i]['mp'][] =& $new_node;
1265+ for ($j=$i-1;$j>=0;--$j){
1266+ $new_node[$i]['par'][] =& $this->toClose[$j];
1267+ }
1268+ $this->currentNode['c'][] =& $new_node[$i];
1269+ $this->stack[] =& $this->currentNode;
1270+ $this->currentNode =& $new_node[$i];
1271+ $this->stackIndex[] = $this->toClose[$i]['i'];
1272+ }
1273+ $this->toCloseIndex=$this->toClose=array();
1274+ }
1275+ } else {
1276+ // Tag Not Open
1277+ $this->add_child($string);
1278+ }
1279+ }
1280+ /**
1281+ * Validates a tree and applying Childs / Parent Rules
1282+ *
1283+ * @param array $tree
1284+ * @param int $parent
1285+ * @param boolean $force_false
1286+ * @return array
1287+ */
1288+ private function correct_tree(&$tree=null,$parent=0,$force_false=false){
1289+ /* Getting all options localy to use local symbol table */
1290+ $restore_tree=false;
1291+ /* Fetching tree if using object internal tree */
1292+ if (is_null($tree)){
1293+ $tree =& $this->tree;
1294+ $restore_tree=true;
1295+ }
1296+ /* fetch auto_correct localy */
1297+ $ac=$this->auto_correct;
1298+ /* Starting new tree for corrected version */
1299+ $new_tree=array();
1300+ /* fetch tag localy */
1301+ $tag=$this->tagListCache[$tree['i']];
1302+ /* Check if parent is in parent_allow_list */
1303+ if (!in_array($parent,$tag[5])){
1304+ $force_false=true;
1305+ }
1306+ if ($force_false){
1307+ /* if force_false is enabled, unpair tags */
1308+ $tree['p']=false;
1309+ } elseif (isset($tree['i']) && $tag[4]&BBCode::FLAGS_ONE_OPEN_PER_LEVEL){
1310+ /* If this tag has the special flag ONE_OPEN_PER_LEVEL, force pairing */
1311+ $tree['p']=true;
1312+ }
1313+ if (!$ac && !$tree['p']){
1314+ /* If no auto_correction neither pairing, force false */
1315+ $force_false=true;
1316+ }
1317+ /* Fetch the parent, according to force_false setting */
1318+ $orig_parent=$parent;
1319+ $parent=$force_false?$parent:$tree['i'];
1320+ /* If some elements has some conditions over other elements */
1321+ if (isset($tree['cond'])){
1322+ /* searching trough conditions lists */
1323+ foreach ($tree['cond'] as $element){
1324+ if (!$element['p']){
1325+ continue;
1326+ } else {
1327+ /* If one condition is paired, this element can not exists */
1328+ $tree['p']=false;
1329+ }
1330+ }
1331+ }
1332+ /* Forcing child_list presence */
1333+ if (!isset($tree['c'])){
1334+ $tree['c']= array();
1335+ }
1336+ /* Browsing child_list for corrections */
1337+ for($i=0; $i<count($tree['c']);++$i){
1338+ $child =& $tree['c'][$i];
1339+ /* Subtree */
1340+ if (is_array($child)){
1341+ /* If the child is a multipart and not done */
1342+ if (isset($child['mp']) && !$child['d']){
1343+ //Multipart Child
1344+ foreach($child['mp'] as $child_part){
1345+ /* TODO Comments */
1346+ if (is_array($child_part)){
1347+ if (!isset($child_part['i'])){
1348+ continue;
1349+ }
1350+ /* If one child has parents and if one parent is unpaired mark as unpaired */
1351+ if (isset($child_part['par'])){
1352+ for($j=0;$j<count($child_part['par']);++$j){
1353+ if ($child_part['par'][$j]['p']){
1354+ continue;
1355+ }
1356+ $tree['p']=false;
1357+ break;
1358+ }
1359+ } else {
1360+ /* Check for mutual inclusion as child else, mark as unpaired */
1361+ /* TODO: Check if the original way was not parent / child checking */
1362+ if (in_array($child_part['i'],$this->tagListCache[$parent][6])){
1363+ if (in_array($parent,$this->tagListCache[$child_part['i']][6])){
1364+ continue;
1365+ }
1366+ }
1367+ $tree['p']=false;
1368+ break;
1369+ }
1370+ }
1371+ }
1372+ /* Mark Child as done */
1373+ $child['d']=true;
1374+ /* If no autocorrection & unpaired */
1375+ if (!$ac && !$tree['p']){
1376+ /* Force False */
1377+ $force_false=true;
1378+ }
1379+ /* Get Parent for allow_list resolv */
1380+ $parent=$force_false?$orig_parent:$tree['i'];
1381+ /* Checking allow_list */
1382+ if (in_array($child['i'], $this->tagListCache[$parent][6])){
1383+ /* The tag can be a subelement of this one */
1384+ $return =& $this->correct_tree($child, $parent, false);
1385+ } else {
1386+ /* The tag can not be a subelement of this one */
1387+ $return =& $this->correct_tree($child, $parent, true);
1388+ }
1389+ } elseif (in_array($child['i'], $this->tagListCache[$parent][6])){
1390+ /* The tag can be a subelement of this one */
1391+ $return =& $this->correct_tree($child, $parent, false);
1392+ } else {
1393+ /* The tag cannot be a subelement of this one */
1394+ $return =& $this->correct_tree($child, $parent, true);
1395+ }
1396+ /* Appending return(s) to new_tree */
1397+ array_splice($new_tree, count($new_tree), 0, $return);
1398+ } else {
1399+ /* String */
1400+ $new_tree[] =& $child;
1401+ }
1402+ }
1403+ if (!$force_false && ($tree['p'] || $ac)){
1404+ /* If tree is correct or autocorrection is ON */
1405+ /* Replace Child List with corrected one */
1406+ $tree['c'] =& $new_tree;
1407+ // Multipart_Join
1408+ /* Return data */
1409+ if ($restore_tree){
1410+ $tree['c'] =& $new_tree;
1411+ } else {
1412+ return array(&$tree);
1413+ }
1414+ } else {
1415+ /* If force false or no autocorrection and unpaired tag */
1416+ if ($force_false){
1417+ /* If force false flag is set, force unpair */
1418+ $tree['p']=false;
1419+ }
1420+ /* prepend the current open String to corrected Child_list */
1421+ array_unshift($new_tree,$tree['s']);
1422+ /* append the closing string to corrected child list */
1423+ $new_tree[] =& $tree['cs'];
1424+ /* Return data */
1425+ if ($restore_tree){
1426+ $this->tree =& $new_tree;
1427+ } else {
1428+ return $new_tree;
1429+ }
1430+ }
1431+ }
1432+ /**
1433+ * Apply the ruleset to transform BBCode tree to Markup
1434+ *
1435+ * @param array $tree
1436+ * @return string
1437+ */
1438+ private function apply_rules($tree){
1439+ //Fetch datas locally - Performance
1440+ $default_smileys=$this->default_smileys;
1441+ $auto_correct=$this->auto_correct;
1442+ $string="";
1443+ $tag=array();
1444+ if (isset($tree['i'])){
1445+ $tag=$this->tagListCache[$tree['i']];
1446+ }
1447+ $last_string='';
1448+ for ($i=0;$i<count($tree['c']);++$i){
1449+ if (is_array($tree['c'][$i]) && isset($tree['c'][$i]['mp'])){
1450+ for($j=$i+1;$j<count($tree['c']);++$j){
1451+ if (is_array($tree['c'][$j]) && isset($tree['c'][$j]['mp'])){
1452+ $tree['c'][$j]['mp'][0]['ref_test_key']='TEST';
1453+ if (isset($tree['c'][$i]['mp'][0]['ref_test_key'])){
1454+ for ($k=$i+1;$k<$j;++$k){
1455+ $tree['c'][$i]['c'][] =& $tree['c'][$k];
1456+ }
1457+ for ($k=0;$k<count($tree['c'][$j]['c']);++$k){
1458+ $tree['c'][$i]['c'][] =& $tree['c'][$j]['c'][$k];
1459+ }
1460+ $tree['c'][$i]['cs']=$tree['c'][$j]['cs'];
1461+ unset($tree['c'][$j]['mp'][0]['ref_test_key']);
1462+ array_splice($tree['c'],$i+1,$j-$i);
1463+ $i=0;
1464+ continue 2;
1465+ } else {
1466+ unset($tree['c'][$j]['mp'][0]['ref_test_key']);
1467+ break;
1468+ }
1469+ }
1470+ }
1471+ }
1472+ }
1473+ foreach($tree['c'] as $child){
1474+ if (is_array($child)){
1475+ //Make a one block treatment for smileys
1476+ if (strlen($last_string)){
1477+ if (!$this->force_smileys_off && $tag[15]){
1478+ $string.=$this->smileys($last_string);
1479+ } else {
1480+ $string.=$last_string;
1481+ }
1482+ }
1483+ $string.=$this->apply_rules($child);
1484+ $last_string='';
1485+ } else {
1486+ //Concat String for Smiley treatment
1487+ $last_string.=$child;
1488+ }
1489+ }
1490+ //Make a one block treatment for smileys
1491+ if (strlen($last_string)){
1492+ if (!$this->force_smileys_off && $tag[15]){
1493+ $string.=$this->smileys($last_string);
1494+ } else {
1495+ $string.=$last_string;
1496+ }
1497+ }
1498+ if (!($auto_correct || $tree['p'] || ($tag[4]&BBCode::FLAGS_ONE_OPEN_PER_LEVEL))){
1499+ return ($tree['s']).$string;
1500+ } else {
1501+ $start=$tag[1];
1502+ $end=$tag[2];
1503+
1504+ $arg='';
1505+ if ($tag[11]){
1506+ if ($tree['a']!=''){
1507+ $arg=$tree['a'];
1508+ } else {
1509+ $arg=$tag[3];
1510+ }
1511+ if ($tag[4] & BBCode::FLAGS_ARG_PARSING){
1512+ if ($this->arg_parser!==null){
1513+ $arg=$this->arg_parser->parse($arg);
1514+ } else {
1515+ $arg=$this->parse($arg);
1516+ }
1517+ }
1518+ }
1519+ /* Search For CallBacks */
1520+ if ($cb=$this->get_callback($tree['i'],true)){
1521+ $arg=$cb($string,$arg);
1522+ }
1523+ if ($cb=$this->get_callback($tree['i'],false)){
1524+ $string=$cb($string,$arg);
1525+ }
1526+ /* Replacing {ARG} by $arg and {CONTENT} by $string in arg & start */
1527+ $arg =str_replace("{CONTENT}",$string,$arg);
1528+ if ($tag[13]){
1529+ $start=str_replace("{CONTENT}",$string,$start);
1530+ $start=str_replace("{ARG}",$arg,$start);
1531+ }
1532+
1533+ /* Replacing {ARG} by $arg in string & end */
1534+ $string =str_replace("{ARG}",$arg,$string);
1535+ if ($tag[14]){
1536+ $end=str_replace("{ARG}",$arg,$end);
1537+ }
1538+
1539+ return $start.$string.$end;
1540+ }
1541+ }
1542+ /**
1543+ * Returns a callback for a tag_id
1544+ *
1545+ * @param int $tagid
1546+ * @param bolean $is_arg
1547+ * @return callback
1548+ */
1549+ private function get_callback($tagid,$is_arg){
1550+ $tag = $this->tagListCache[$tagid];
1551+ if ($is_arg){
1552+ if ($tag[10]===null){
1553+ $this->tagListCache[$tagid][10]=is_callable($tag[9])?$tag[9]:false;
1554+ }
1555+ return $this->tagListCache[$tagid][10];
1556+ } else {
1557+ if ($tag[8]===null){
1558+ $this->tagListCache[$tagid][8]=is_callable($tag[7])?$tag[7]:false;
1559+ }
1560+ return $this->tagListCache[$tagid][8];
1561+ }
1562+ }
1563+ /**
1564+ * Treats smileys
1565+ *
1566+ * @param string $smileys
1567+ * @return string
1568+ */
1569+ private function smileys($string){
1570+ $keys=array_keys($this->smileys);
1571+ return str_replace($keys,$this->smileys,$string);
1572+ }
1573+ /**
1574+ * Returns a tag_id from his name (tag_id is internal)
1575+ *
1576+ * @param string $tag_name
1577+ * @param boolean $has_args
1578+ * @return string
1579+ */
1580+ private function get_tag_id($tag_name, $has_arg=null){
1581+ $tag_name=strtolower($tag_name);
1582+ if (isset($this->tagListIndex[$tag_name])){
1583+ $tag_id=$this->tagListIndex[$tag_name];
1584+ if ($has_arg===null){
1585+ return $tag_id;
1586+ } elseif ($has_arg===false){
1587+ if ($this->tagListCache[$tag_id][12]===true){
1588+ return $tag_id;
1589+ }
1590+ } else {
1591+ if ($this->tagListCache[$tag_id][11]===true){
1592+ return $tag_id;
1593+ }
1594+ }
1595+ }
1596+ return false;
1597+ }
1598+}
1599+$arrayBBCode=array(
1600+''=> array('open_tag'=>'', 'close_tag'=>'', 'type'=>BBCode::TYPE_ROOT),
1601+'b'=> array('type'=>BBCode::TYPE_NOARG, 'childs'=>'all', 'open_tag'=>'<b>', 'close_tag'=>'</b>'),
1602+'u'=> array('type'=>BBCode::TYPE_NOARG, 'childs'=>'all', 'smileys'=>false, 'open_tag'=>'<u>', 'close_tag'=>'</u>'),
1603+'i'=> array('type'=>BBCode::TYPE_NOARG, 'childs'=>'all', 'open_tag'=>'<i>', 'close_tag'=>'</i>'),
1604+'code'=> array('type'=>BBCode::TYPE_NOARG, 'childs'=>'u', 'open_tag'=>'<code>', 'close_tag'=>'</code>'),
1605+'m'=> array('type'=>BBCode::TYPE_NOARG, 'open_tag'=>'<a href="/maraboutage.php">', 'close_tag'=>'</a>'),
1606+'cap'=> array('type'=>BBCode::TYPE_NOARG, 'open_tag'=>'<span style="text-transform:capitalize;">', 'close_tag'=>'</span>'),
1607+'mini'=> array('type'=>BBCode::TYPE_NOARG, 'open_tag'=>'<span class="mini">', 'close_tag'=>'</span>'),
1608+'right'=> array('type'=>BBCode::TYPE_NOARG, 'open_tag'=>'<div style="text-align:right;">', 'close_tag'=>'</div>'),
1609+'center'=> array('type'=>BBCode::TYPE_NOARG, 'open_tag'=>'<div style="text-align:center;">', 'close_tag'=>'</div>'),
1610+'just'=> array('type'=>BBCode::TYPE_NOARG, 'open_tag'=>'<div style="text-align:justify;width:450px;margin:0 auto;">', 'close_tag'=>'</div>'),
1611+'strike'=> array('type'=>BBCode::TYPE_NOARG, 'open_tag'=>'<span style="text-decoration:line-through;">', 'close_tag'=>'</span>'),
1612+'ancre'=> array('type'=>BBCode::TYPE_NOARG, 'open_tag'=>'<a name="', 'close_tag'=>'"> &nbsp;</a>'),
1613+'moumou'=> array('type'=>BBCode::TYPE_NOARG, 'open_tag'=>'<img src="', 'close_tag'=>'" />'),
1614+'round'=> array('type'=>BBCode::TYPE_NOARG, 'open_tag'=>'<div style="border:2px double white;border-radius: 8px; padding:6px; -moz-border-radius: 8px; background-color:#000; color:#FFF;">', 'close_tag'=>'</div>'),
1615+'hide'=> array('type'=>BBCode::TYPE_NOARG, 'open_tag'=>'', 'close_tag'=>'', 'content_handling'=>'BBVoid'),
1616+'np'=> array('type'=>BBCode::TYPE_NOARG, 'open_tag'=>'', 'close_tag'=>''),
1617+'quote'=> array('type'=>BBCode::TYPE_OPTARG, 'flags'=>BBCode::FLAGS_ARG_PARSING , 'open_tag'=>'<fieldset><legend>{ARG}</legend>', 'close_tag'=>'</fieldset>', 'default_arg'=>'Citation'),
1618+'id'=> array('type'=>BBCode::TYPE_OPTARG, 'arg_parse'=>false, 'open_tag'=>'', 'close_tag'=>'', 'default_arg'=>'{SELF}', 'content_handling'=>'BBId2User'),
1619+'msg'=> array('type'=>BBCode::TYPE_OPTARG, 'arg_parse'=>false, 'open_tag'=>'', 'close_tag'=>'', 'default_arg'=>'{SELF}', 'content_handling'=>'BBId2Msg'),
1620+'url'=> array('type'=>BBCode::TYPE_OPTARG, 'arg_parse'=>false, 'open_tag'=>'<a href="{ARG}">', 'close_tag'=>'</a>', 'default_arg'=>'{CONTENT}', 'arg_handling'=>'validate_url'),
1621+'img'=> array('type'=>BBCode::TYPE_OPTARG, 'arg_parse'=>false, 'open_tag'=>'<img src="{ARG}" alt="', 'close_tag'=>'" />', 'default_arg'=>'{CONTENT}'),
1622+'mail'=> array('type'=>BBCode::TYPE_OPTARG, 'arg_parse'=>false, 'open_tag'=>'<a href="mailto:{ARG}">', 'close_tag'=>'</a>', 'default_arg'=>'{CONTENT}'),
1623+'border'=> array('type'=>BBCode::TYPE_OPTARG, 'arg_parse'=>false, 'open_tag'=>'<div style="border:{ARG}px solid;">', 'close_tag'=>'</div>', 'default_arg'=>'5'),
1624+'list'=> array('type'=>BBCode::TYPE_OPTARG, 'arg_parse'=>false, 'open_tag'=>'<ol type="{ARG}">', 'close_tag'=>'</ol>', 'default_arg'=>'1', 'content_handling'=>'BBlist'),
1625+'*' => array('type'=>BBCode::TYPE_NOARG, 'flags'=>BBCode::FLAGS_ONE_OPEN_PER_LEVEL,'parents'=>'list', 'open_tag'=>'<li>', 'close_tag'=>'</li>',),
1626+'col'=> array('type'=>BBCode::TYPE_OPTARG, 'arg_parse'=>false, 'open_tag'=>'<div style="-moz-column-count:{ARG}; text-align:justify;-moz-column-gap:8px;">', 'close_tag'=>'</div>', 'default_arg'=>'2'),
1627+'hexdump'=> array('type'=>BBCode::TYPE_OPTARG, 'arg_parse'=>false, 'open_tag'=>'[Hex Dump]<br />', 'close_tag'=>'', 'default_arg'=>'0x345622', 'content_handling'=>'BBHexDump'),
1628+'bcktrc'=> array('type'=>BBCode::TYPE_OPTARG, 'arg_parse'=>false, 'open_tag'=>'', 'close_tag'=>'', 'default_arg'=>'0x345622', 'content_handling'=>'BBBackTrace'),
1629+'bong'=> array('type'=>BBCode::TYPE_OPTARG, 'arg_parse'=>false, 'open_tag'=>'<div id="{ARG}">', 'close_tag'=>'</div><script type="text/javascript">new OngletsBlock(\'{ARG}\');</script>','default_arg'=>'Fiche'),
1630+'onglet'=> array('type'=>BBCode::TYPE_ARG, 'arg_parse'=>false, 'open_tag'=>'<h4>{ARG}</h4><div title="{ARG}" closable="true" style="clear:both;">','close_tag'=>'</div>','default_arg'=>'Default'),
1631+'color'=> array('type'=>BBCode::TYPE_ARG, 'arg_parse'=>false, 'open_tag'=>'<span style="color:{ARG}">', 'close_tag'=>'</span>'),
1632+'size'=> array('type'=>BBCode::TYPE_ARG, 'arg_parse'=>false, 'open_tag'=>'<span style="font-size:{ARG}px;">', 'close_tag'=>'</span>'),
1633+'goto'=> array('type'=>BBCode::TYPE_ARG, 'arg_parse'=>false, 'open_tag'=>'<a href="#{ARG}" onmouseover="this.href=document.location.href.replace(/#.*/img ,\'\')+\'#{ARG}\'">', 'close_tag'=>'</a>'),
1634+'fade'=> array('type'=>BBCode::TYPE_ARG, 'arg_parse'=>false, 'open_tag'=>'', 'close_tag'=>'', 'content_handling'=>'BBDegrade'),
1635+'wave'=> array('type'=>BBCode::TYPE_ARG, 'arg_parse'=>false, 'open_tag'=>'', 'close_tag'=>'', 'content_handling'=>'BBWave'),
1636+'barre'=> array('type'=>BBCode::TYPE_SINGLE, 'open_tag'=>'<hr />'),
1637+);
1638+$bbcode=new BBCode($arrayBBCode,array(':)'=>'\\o/',':|'=>'/o\\'));
1639+$bbcode->auto_correct=false;
1640+$bbcode->correct_reopen_tags=true;
1641+$time=microtime(true);
1642+$string=<<<EOF
1643+[list][*]List[list][*]SubList[/list][/list]
1644+EOF;
1645+echo $bbcode->parse($string)."\n";
1646+$val[]=microtime(true)-$time;
1647+echo (microtime(true)-$time)."\n";
1648+$time=microtime(true);
1649+$string=<<<EOF
1650+UUU[quote="[u]:) :|UUU[/u]"][b]:)Te[b]st[/b][/quote]AAAAA
1651+[LIST=0][*]Test
1652+TEst
1653+[*][list=a][*]Coucou
1654+[/list]
1655+[/list]
1656+EOF;
1657+echo $bbcode->parse($string)."\n";
1658+$val[]=microtime(true)-$time;
1659+echo (microtime(true)-$time)."\n";
1660+$time=microtime(true);
1661+$string=<<<EOF
1662+[b][u]Hello[/b] W[i]o[b]r [b]ld[/u] Coucou[/i] Vro[/b] Vroum
1663+EOF;
1664+echo $bbcode->parse($string)."\n";
1665+$val[]=microtime(true)-$time;
1666+echo (microtime(true)-$time)."\n";
1667+$time=microtime(true);
1668+$string=<<<EOF
1669+[list][*]List[list][*]SubList[*]element2[list][*]SubSubList[/list][/list][*]element 3[/list]
1670+EOF;
1671+echo $bbcode->parse($string)."\n";
1672+$val[]=microtime(true)-$time;
1673+echo (microtime(true)-$time)."\n";
1674+$time=microtime(true);
1675+$string=<<<EOF
1676+[list][*]List[list][*]SubList[/list][/list]
1677+EOF;
1678+echo $bbcode->parse($string)."\n";
1679+$val[]=microtime(true)-$time;
1680+echo (microtime(true)-$time)."\n";
1681+$time=microtime(true);
1682+$string=<<<EOF
1683+[b]Test[u]Test[b] [i] Glup [u] [*][*][barre][i]Glop[/i] [/u][/i]Zop[/b] [/u][/b]
1684+EOF;
1685+echo $bbcode->parse($string)."\n";
1686+$val[]=microtime(true)-$time;
1687+echo (microtime(true)-$time)."\n";
1688+$time=microtime(true);
1689+//$bbcode->noTreeBuild=true;
1690+$bbcode->default_smileys=true;
1691+$string=<<<EOF
1692+[b][i] [code] [u][/i][/b][b][/u] [/code] [u] Test [/b][/u]
1693+EOF;
1694+echo $bbcode->parse($string)."\n";
1695+$val[]=microtime(true)-$time;
1696+echo (microtime(true)-$time)."\n";
1697+echo array_sum($val);
1698\ No newline at end of file
1699
1700Property changes on: bbcode.php
1701___________________________________________________________________
1702Added: svn:eol-style
1703 + native
1704Added: svn:keywords
1705 + Id Rev Revision Date LastChangedDate LastChangedRevision Author LastChangedBy HeadURL URL
1706Added: cvs2svn:cvs-rev
1707 + 1.4
1708
1709Index: config.m4
1710===================================================================
1711--- config.m4 (.../tags/RELEASE_1_0_2)
1712+++ config.m4 (.../trunk)
1713@@ -7,7 +7,7 @@
1714
1715 if test "$PHP_BBCODE" = "yes"; then
1716 AC_DEFINE(HAVE_BBCODE,1,[Whether you want BBCode support])
1717+ PHP_NEW_EXTENSION(bbcode, php_bbcode.c lib/bstrlib.c lib/bbcode2.c, $ext_shared,, "-I@ext_srcdir@/lib")
1718 PHP_ADD_BUILD_DIR(lib)
1719- PHP_NEW_EXTENSION(bbcode, php_bbcode.c lib/bstrlib.c lib/bbcode2.c, $ext_shared, , "-I@ext_srcdir@/lib")
1720 fi
1721
1722
1723Property changes on: config.m4
1724___________________________________________________________________
1725Modified: cvs2svn:cvs-rev
1726 - 1.4
1727 + 1.5
1728
1729Index: lib/bbcode2.c
1730===================================================================
1731--- lib/bbcode2.c (.../tags/RELEASE_1_0_2)
1732+++ lib/bbcode2.c (.../trunk)
1733@@ -95,6 +95,8 @@
1734 /* Parse a BBCoded string to is treated equivalent */
1735 char *bbcode_parse(bbcode_parser_p parser, char *string, int string_size,
1736 int *result_size) {
1737+ char *return_value;
1738+
1739 bstring to_parse = NULL;
1740 bstring parsed = NULL;
1741 to_parse=bfromcstr("");
1742@@ -103,9 +105,10 @@
1743 if (parser->options & BBCODE_DISABLE_TREE_BUILD) {
1744 /* No BBCode Parsing */
1745 if (parser->options & BBCODE_FORCE_SMILEYS_OFF) {
1746+ char *return_value=(char *)malloc(string_size * sizeof(char));
1747+
1748 /* No Smiley Treatment */
1749 *result_size=string_size;
1750- char *return_value=(char *)malloc(string_size * sizeof(char));
1751 return memcpy(return_value, string, string_size);
1752 }
1753 /* Prepare Datas for smiley */
1754@@ -115,12 +118,14 @@
1755 /* Smiley Parsing */
1756 bbcode_parse_smileys(to_parse, parser->smileys);
1757 } else {
1758+ /* starting the tree */
1759+ bbcode_parse_tree_p tree = bbcode_tree_create();
1760+
1761 /* Prepare Datas for parsing */
1762 balloc(to_parse, string_size+5);
1763 to_parse->slen=string_size;
1764 memcpy(to_parse->data, string, string_size);
1765- /* starting the tree */
1766- bbcode_parse_tree_p tree = bbcode_tree_create();
1767+
1768 /* Preparing tag_list if needed */
1769 bbcode_prepare_tag_list(parser);
1770 /* Build the BBCode Tree from the string */
1771@@ -136,7 +141,7 @@
1772 }
1773 /* Getting the return string */
1774 *result_size=to_parse->slen;
1775- char *return_value=(char *)malloc(*result_size * sizeof(char)+1);
1776+ return_value=(char *)malloc(*result_size * sizeof(char)+1);
1777 return_value=memcpy(return_value, to_parse->data, to_parse->slen+1);
1778 bdestroy(to_parse);
1779 bdestroy(parsed);
1780@@ -173,6 +178,8 @@
1781 struct bstrList *bsplited;
1782 char accept_smileys;
1783 char default_smileys;
1784+ int i, j, max;
1785+
1786 accept_smileys=1;
1787 if (parser->options & BBCODE_FORCE_SMILEYS_OFF) {
1788 accept_smileys=0;
1789@@ -181,7 +188,7 @@
1790 if (parser->options & BBCODE_DEFAULT_SMILEYS_ON) {
1791 default_smileys=1;
1792 }
1793- int i, j, max;
1794+
1795 max=0;
1796 list=parser->bbcodes;
1797 /* Resolve cache preparation */
1798@@ -211,8 +218,11 @@
1799 list->search_cache[i]=NULL;
1800 }
1801 for (i=0; i<bbcode_array_length(list->bbcodes); i++) {
1802+ int slen;
1803+ bbcode_search temp;
1804+
1805 bbcode=bbcode_get_bbcode(parser, i);
1806- int slen=blength(bbcode->tag);
1807+ slen=blength(bbcode->tag);
1808 if (list->search_cache[slen]==NULL) {
1809 list->search_cache[slen]
1810 =(bbcode_search_p) malloc(sizeof(bbcode_search));
1811@@ -220,7 +230,7 @@
1812 list->search_cache[slen]=(bbcode_search_p) realloc(
1813 list->search_cache[slen], sizeof(bbcode_search) * (list->num_cache[slen]+1));
1814 }
1815- bbcode_search temp;
1816+
1817 temp.tag_name=bbcode->tag;
1818 temp.tag_id=i;
1819 list->search_cache[slen][list->num_cache[slen]]=temp;
1820@@ -239,6 +249,7 @@
1821 /* All Accepted */
1822 list->root->childs->type=BBCODE_ALLOW_LIST_TYPE_ALL;
1823 } else {
1824+ long find;
1825 bstring work = bstrcpy(list->root->child_list);
1826 if ((bchar(list->root->child_list, 0) == '!') == 1) {
1827 list->root->childs->type=BBCODE_ALLOW_LIST_TYPE_EXCLUDE;
1828@@ -249,7 +260,7 @@
1829 }
1830 /* We add all entries */
1831 bsplited=bsplit (work, ',');
1832- long find;
1833+
1834 bbcode_allow_list_check_size(list->root->childs, bsplited->qty);
1835 for (j=0; j<bsplited->qty; j++) {
1836 find = bbcode_get_tag_id (parser, bsplited->entry[j], -1);
1837@@ -294,6 +305,8 @@
1838 /* All Accepted */
1839 bbcode->parents->type=BBCODE_ALLOW_LIST_TYPE_ALL;
1840 } else {
1841+ long find;
1842+
1843 bstring work = bstrcpy(bbcode->parent_list);
1844 if (bchar(bbcode->parent_list, 0) == '!') {
1845 bbcode->parents->type=BBCODE_ALLOW_LIST_TYPE_EXCLUDE;
1846@@ -303,7 +316,7 @@
1847 }
1848 /* We add all entries */
1849 bsplited=bsplit (work, ',');
1850- long find;
1851+
1852 bbcode_allow_list_check_size(bbcode->parents, bsplited->qty);
1853 for (j=0; j<bsplited->qty; j++) {
1854 find = bbcode_get_tag_id (parser, bsplited->entry[j], -1);
1855@@ -324,6 +337,8 @@
1856 /* All Accepted */
1857 bbcode->childs->type=BBCODE_ALLOW_LIST_TYPE_ALL;
1858 } else {
1859+ long find;
1860+
1861 bstring work=bstrcpy(bbcode->child_list);
1862 if (bchar(bbcode->child_list, 0) == '!') {
1863 bbcode->childs->type=BBCODE_ALLOW_LIST_TYPE_EXCLUDE;
1864@@ -333,7 +348,7 @@
1865 }
1866 /* We add all entries */
1867 bsplited=bsplit (work, ',');
1868- long find;
1869+
1870 bbcode_allow_list_check_size(bbcode->childs, bsplited->qty);
1871 for (j=0; j<bsplited->qty; j++) {
1872 find = bbcode_get_tag_id (parser, bsplited->entry[j], -1);
1873@@ -367,6 +382,8 @@
1874 int offset, end, next_equal, next_close, string_length;
1875 long tag_id;
1876 int quote_enabled=(quote_double || quote_single || quote_html);
1877+ bbcode_parse_tree_array_p work_stack = NULL, close_stack = NULL;
1878+
1879 string_length=blength(string);
1880 tag_id=end=next_equal=next_close=0;
1881 end_double=bfromcstr("\"]");
1882@@ -376,7 +393,6 @@
1883 /* END INIT */
1884 offset=bstrchr(string, '[');
1885 bbcode_tree_push_string_child(tree, bmidstr(string, 0, offset), offset);
1886- bbcode_parse_tree_array_p work_stack = NULL, close_stack = NULL;
1887 work_stack=bbcode_parse_stack_create();
1888 bbcode_parse_stack_push_element(work_stack,tree);
1889 close_stack=bbcode_parse_stack_create();
1890@@ -398,9 +414,11 @@
1891 1))) {
1892 /* Quotes */
1893 if (quote_enabled) {
1894+ int diff=0;
1895+
1896 end=next_close;
1897 no_quote=0;
1898- int diff=0;
1899+
1900 if (quote_single && bchar(string, next_equal+1)
1901 =='\'') {
1902 end_quote=end_single;
1903@@ -445,8 +463,6 @@
1904 } else {
1905 /* No Ending Quote, go to next tag */
1906 end=next_equal+diff;
1907- bdestroy(argument);
1908- argument=NULL;
1909 }
1910 }
1911 } else {
1912@@ -465,6 +481,7 @@
1913 +1), tag_id,
1914 argument, offset);
1915 bdestroy(argument);
1916+ argument=NULL;
1917 end=next_close;
1918 added=1;
1919 }
1920@@ -659,6 +676,8 @@
1921 long parent_id, char force_false) {
1922 int autocorrect, orig_parent, ret;
1923 long i,j;
1924+ bbcode_parse_tree_child_p child = NULL;
1925+
1926 bbcode_p tag= bbcode_get_bbcode(parser,tree->tag_id);
1927 /* Options */
1928 autocorrect = parser->options & BBCODE_AUTO_CORRECT;
1929@@ -687,7 +706,7 @@
1930 }
1931 }
1932 }
1933- bbcode_parse_tree_child_p child = NULL;
1934+
1935 for (i = 0; i < tree->childs.size ; i++) {
1936 child=(tree->childs.element[i]);
1937 if (child->type==BBCODE_TREE_CHILD_TYPE_TREE) {
1938@@ -796,13 +815,16 @@
1939 bstring last_string = NULL;
1940 bstring tmp_string = NULL;
1941 long i;
1942+ bbcode_parse_tree_p to_drop = NULL;
1943+ bstring arg, content;
1944+
1945 last_string=bfromcstr("");
1946 tmp_string=bfromcstr("");
1947 working_string=bfromcstr("");
1948 /* Dropped elements */
1949- bbcode_parse_tree_p to_drop = NULL;
1950+
1951 to_drop=bbcode_tree_create();
1952- bstring arg, content;
1953+
1954 content=arg=NULL;
1955 /* Multipart Merging */
1956 for (i=0 ; i < tree->childs.size; i++) {
1957@@ -977,14 +999,16 @@
1958 }
1959 }
1960 } else {
1961+ long left=0;
1962+ long right=count-1;
1963+ long i=count/2;
1964+ long equal, pos;
1965+
1966 bstring lower_tag = NULL;
1967 lower_tag=bstrcpy(value);
1968 btolower(lower_tag);
1969 /* We start true binary */
1970- long left=0;
1971- long right=count-1;
1972- long i=count/2;
1973- long equal, pos;
1974+
1975 while (1) {
1976 equal=bstrcmp(lower_tag, list[i].tag_name);
1977 if (equal==0) {
1978@@ -1450,8 +1474,9 @@
1979 /* Insert a given child on a given position */
1980 void bbcode_tree_insert_child_at(bbcode_parse_tree_p tree,
1981 bbcode_parse_tree_child_p bbcode_parse_tree_child, long pos) {
1982+ long size;
1983 bbcode_tree_check_child_size(tree, tree->childs.size+1);
1984- long size=sizeof(bbcode_parse_tree_child_p);
1985+ size=sizeof(bbcode_parse_tree_child_p);
1986 memmove(&(tree->childs.element[pos+1]),
1987 &(tree->childs.element[pos]), size*(tree->childs.size-pos-1));
1988 tree->childs.element[pos]=bbcode_parse_tree_child;
1989@@ -1552,8 +1577,9 @@
1990 /* Remove element from the Tree array @ index */
1991 void bbcode_parse_drop_element_at(bbcode_parse_tree_array_p stack, long index) {
1992 if (index<stack->size) {
1993+ long i;
1994 stack->size--;
1995- long i;
1996+
1997 for(i=index;i<stack->size;i++){
1998 stack->element[i]=stack->element[i+1];
1999 }
2000
2001Property changes on: lib/bbcode2.c
2002___________________________________________________________________
2003Modified: cvs2svn:cvs-rev
2004 - 1.25
2005 + 1.27
2006
2007Index: lib/bbcode2.h
2008===================================================================
2009--- lib/bbcode2.h (.../tags/RELEASE_1_0_2)
2010+++ lib/bbcode2.h (.../trunk)
2011@@ -75,10 +75,11 @@
2012 #define bbcode_array_element(array, pos) ((((unsigned)(pos)) < (unsigned)bbcode_array_length(array)) ? ((array)->element[(pos)]) : NULL)
2013 #define bbcode_find_next(to_update,string,offset,char) if (to_update <= offset){ if (0>(to_update = bstrchrp( string, char, offset))){ to_update = blength( string )+5; } }
2014 #define BBCODE_SPECIAL_CASE_NO_CHILD(argument) \
2015+ int sc_offset; \
2016 bstring close_tag=bfromcstr("[/"); \
2017 bconcat(close_tag,tag); \
2018 bcatcstr(close_tag,"]"); \
2019- int sc_offset=binstrcaseless(string, next_close, close_tag); \
2020+ sc_offset=binstrcaseless(string, next_close, close_tag); \
2021 if (sc_offset!=BSTR_ERR){ \
2022 bbcode_tree_push_tree_child(parser, bbcode_get_cn(parser), work_stack, close_stack, bmidstr(string, offset, end-offset+1),tag_id, argument, offset); \
2023 bbcode_tree_push_string_child(bbcode_get_cn(parser), bmidstr(string,next_close+1,sc_offset-next_close-1), offset+next_close+1); \
2024
2025Property changes on: lib/bbcode2.h
2026___________________________________________________________________
2027Modified: cvs2svn:cvs-rev
2028 - 1.18
2029 + 1.19
2030
2031
2032Property changes on: lib
2033___________________________________________________________________
2034Added: svn:ignore
2035 + .deps
2036Makefile
2037*.lo
2038*.loT
2039*.slo
2040*.mk
2041*.la
2042.libs
2043libs.mk
2044ac*.m4
2045build
2046config.h
2047config.h.in
2048config.nice
2049config.sub
2050configure
2051configure.in
2052config.status
2053config.cache
2054conftest
2055conftest.c
2056core
2057dynlib.m4
2058install-sh
2059ltmain.sh
2060include
2061Makefile.fragments
2062Makefile.global
2063Makefile.objects
2064missing
2065mkinstalldirs
2066modules
2067scan_makefile_in.awk
2068config.guess
2069*swp
2070config.log
2071libtool
2072Debug
2073Release
2074Debug_TS
2075Release_TS
2076*.plg
2077*.patch
2078*.tgz
2079*.ncb
2080*.opt
2081*.dsw
2082autom4te.cache
2083run-tests-config.php
2084run-tests.php
2085
2086
2087Index: php_bbcode.c
2088===================================================================
2089--- php_bbcode.c (.../tags/RELEASE_1_0_2)
2090+++ php_bbcode.c (.../trunk)
2091@@ -2,7 +2,7 @@
2092 +----------------------------------------------------------------------+
2093 | PHP Version 5 |
2094 +----------------------------------------------------------------------+
2095- | Copyright (c) 1997-2007 The PHP Group |
2096+ | Copyright (c) 1997-2008 The PHP Group |
2097 +----------------------------------------------------------------------+
2098 | This source file is subject to version 3.01 of the PHP license, |
2099 | that is bundled with this package in the file LICENSE, and is |
2100@@ -14,9 +14,10 @@
2101 +----------------------------------------------------------------------+
2102 | Author: Xavier De Cock <void@php.net> |
2103 +----------------------------------------------------------------------+
2104+*/
2105
2106- $Id$
2107-*/
2108+/* $Id$ */
2109+
2110 #ifdef HAVE_CONFIG_H
2111 #include "config.h"
2112 #endif
2113@@ -27,74 +28,31 @@
2114 #include "lib/bbcode2.h"
2115 #include "lib/bstrlib.h"
2116
2117-#if Void_0
2118-typedef struct _bbcode_object {
2119- zend_object std;
2120- int rsrc_id;
2121-} bbcode_object;
2122-#endif
2123+static int le_bbcode;
2124
2125-int le_bbcode;
2126-static function_entry bbcode_functions[] = {
2127- PHP_FE(bbcode_create, NULL)
2128- PHP_FE(bbcode_add_element, NULL)
2129- PHP_FE(bbcode_destroy, NULL)
2130- PHP_FE(bbcode_parse, NULL)
2131- PHP_FE(bbcode_add_smiley, NULL)
2132- PHP_FE(bbcode_set_flags, NULL)
2133- PHP_FE(bbcode_set_arg_parser, NULL)
2134- {NULL, NULL, NULL}
2135-};
2136+#define PHP_BBCODE_CONTENT_CB 1
2137+#define PHP_BBCODE_PARAM_CB 2
2138
2139-#if Void_0
2140-/* Object Part, working on it */
2141-zend_function_entry bbcode_funcs_object[] = {
2142- PHP_ME_MAPPING(__construct, bbcode_create, NULL,0)
2143- PHP_ME_MAPPING(addElement, bbcode_add_element, NULL,0)
2144- PHP_ME_MAPPING(destroy, bbcode_destroy, NULL,0)
2145- PHP_ME_MAPPING(parse, bbcode_parse, NULL,0)
2146- {NULL, NULL, NULL}
2147-};
2148-#endif
2149-
2150-zend_module_entry bbcode_module_entry = {
2151-#if ZEND_MODULE_API_NO >= 20010901
2152- STANDARD_MODULE_HEADER,
2153-#endif
2154- PHP_BBCODE_EXTNAME,
2155- bbcode_functions,
2156- PHP_MINIT(bbcode),
2157- NULL,
2158- NULL,
2159- NULL,
2160- PHP_MINFO(bbcode),
2161-#if ZEND_MODULE_API_NO >= 20010901
2162- PHP_BBCODE_VERSION,
2163-#endif
2164- STANDARD_MODULE_PROPERTIES
2165-};
2166-
2167-#ifdef COMPILE_DL_BBCODE
2168-ZEND_GET_MODULE(bbcode)
2169-#endif
2170-
2171-/* {{{ _php_bbcode_handling_content */
2172-/* Start user functions callback */
2173-int _php_bbcode_handling_content(bstring content, bstring param, void *datas){
2174+/* {{{ _php_bbcode_callback_handler
2175+ Common code for content and parameter handlers */
2176+static int _php_bbcode_callback_handler(int cb_type, bstring content, bstring param, zval *func_name)
2177+{
2178 zval *retval = NULL;
2179 zval ***zargs = NULL;
2180- zval **funcname;
2181+ char *callable = NULL;
2182 int i, res;
2183- char *callable = NULL, *errbuf=NULL;
2184- funcname = ((zval **) datas);
2185+ bstring target;
2186+ char *cb_name = "";
2187 TSRMLS_FETCH();
2188
2189- if (!zend_is_callable(*funcname, 0, &callable)) {
2190- spprintf(&errbuf, 0, "function `%s' is not a function name", callable);
2191- zend_error(E_WARNING, "[BBCode] (_php_bbcode_handling_content) %s", errbuf);
2192- efree(errbuf);
2193- efree(callable);
2194- return 0;
2195+ switch (cb_type) {
2196+ case PHP_BBCODE_CONTENT_CB:
2197+ target = content;
2198+ break;
2199+
2200+ case PHP_BBCODE_PARAM_CB:
2201+ target = param;
2202+ break;
2203 }
2204
2205 zargs = (zval ***) emalloc(sizeof(zval **) * 2);
2206@@ -105,223 +63,218 @@
2207 MAKE_STD_ZVAL(*zargs[1]);
2208 ZVAL_STRINGL(*zargs[1], bdata(param), blength(param), 1);
2209
2210- res = call_user_function_ex(EG(function_table), NULL, *funcname, &retval, 2, zargs, 1, NULL TSRMLS_CC);
2211-
2212- if (res == SUCCESS) {
2213- if (zargs) {
2214- for (i = 0; i < 2; i++) {
2215- zval_ptr_dtor(zargs[i]);
2216- efree(zargs[i]);
2217- }
2218- efree(zargs);
2219+ res = call_user_function_ex(EG(function_table), NULL, func_name, &retval, 2, zargs, 1, NULL TSRMLS_CC);
2220+
2221+ if (res != SUCCESS) {
2222+ if (!zend_is_callable(func_name, 0, &callable TSRMLS_CC)) {
2223+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "function `%s' is not callable", callable);
2224+ } else {
2225+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "callback function %s() failed", callable);
2226 }
2227- } else {
2228- zend_error(E_WARNING, "[BBCode] (_php_bbcode_handling_content) call_user_function_ex failed for function %s()", callable);
2229- }
2230- efree(callable);
2231- if (&retval) {
2232+ efree(callable);
2233+ } else if (&retval != NULL) {
2234 convert_to_string_ex(&retval);
2235- if(Z_STRLEN_P(retval)){
2236- bassignblk(content,Z_STRVAL_P(retval), Z_STRLEN_P(retval));
2237+ if (Z_STRLEN_P(retval)) {
2238+ bassignblk(target, Z_STRVAL_P(retval), Z_STRLEN_P(retval));
2239 } else {
2240- bdelete(content,0,blength(content));
2241+ bdelete(target, 0, blength(target));
2242 }
2243 zval_ptr_dtor(&retval);
2244 }
2245+
2246+ /* Free zargs */
2247+ for (i = 0; i < 2; i++) {
2248+ zval_ptr_dtor(zargs[i]);
2249+ efree(zargs[i]);
2250+ }
2251+ efree(zargs);
2252+
2253 return 0;
2254 }
2255 /* }}} */
2256-/* {{{ _php_bbcode_handling_param */
2257-int _php_bbcode_handling_param(bstring content, bstring param, void *datas){
2258- zval *retval = NULL;
2259- zval ***zargs = NULL;
2260- zval **funcname;
2261- int i, res;
2262- char *callable = NULL, *errbuf=NULL;
2263- funcname = ((zval **) datas);
2264- TSRMLS_FETCH();
2265
2266- if (!zend_is_callable(*funcname, 0, &callable)) {
2267- spprintf(&errbuf, 0, "function `%s' is not a function name", callable);
2268- zend_error(E_WARNING, "[BBCode] (_php_bbcode_handling_param) %s", errbuf);
2269- efree(errbuf);
2270- efree(callable);
2271- return 0;
2272- }
2273+/* {{{ _php_bbcode_content_handler */
2274+static int _php_bbcode_content_handler(bstring content, bstring param, void *func_data)
2275+{
2276+ return _php_bbcode_callback_handler(PHP_BBCODE_CONTENT_CB, content, param, func_data);
2277+}
2278+/* }}} */
2279
2280- zargs = (zval ***) emalloc(sizeof(zval **) * 2);
2281- zargs[0] = emalloc(sizeof(zval *));
2282- MAKE_STD_ZVAL(*zargs[0]);
2283- ZVAL_STRINGL(*zargs[0], bdata(content), blength(content), 1);
2284- zargs[1] = emalloc(sizeof(zval *));
2285- MAKE_STD_ZVAL(*zargs[1]);
2286- ZVAL_STRINGL(*zargs[1], bdata(param), blength(param), 1);
2287-
2288- res = call_user_function_ex(EG(function_table), NULL, *funcname, &retval, 2, zargs, 1, NULL TSRMLS_CC);
2289-
2290- if (res == SUCCESS) {
2291- if (zargs) {
2292- for (i = 0; i < 2; i++) {
2293- zval_ptr_dtor(zargs[i]);
2294- efree(zargs[i]);
2295- }
2296- efree(zargs);
2297- }
2298- } else {
2299- zend_error(E_WARNING, "[BBCode] (_php_bbcode_handling_param) call_user_function_ex failed for function %s()", callable);
2300- }
2301- efree(callable);
2302- if (&retval) {
2303- convert_to_string_ex(&retval);
2304- if(Z_STRLEN_P(retval)){
2305- bassignblk(param,Z_STRVAL_P(retval), Z_STRLEN_P(retval));
2306- } else {
2307- bdelete(param,0,blength(param));
2308- }
2309- zval_ptr_dtor(&retval);
2310- }
2311- return 0;
2312+/* {{{ _php_bbcode_param_handler */
2313+static int _php_bbcode_param_handler(bstring content, bstring param, void *func_data)
2314+{
2315+ return _php_bbcode_callback_handler(PHP_BBCODE_PARAM_CB, content, param, func_data);
2316 }
2317-/* End User function Callback */
2318 /* }}} */
2319-/* {{{ _php_bbcode_add_element */
2320-/* Fill a bbcode_container */
2321-static void _php_bbcode_add_element(bbcode_parser_p parser, char *tag_name, zval *content TSRMLS_DC) {
2322+
2323+/* {{{ _php_bbcode_add_element
2324+ Fills a bbcode_container */
2325+static void _php_bbcode_add_element(bbcode_parser_p parser, char *tag_name, int tag_name_len, zval *content TSRMLS_DC)
2326+{
2327 zval **e;
2328 long type;
2329- char *name;
2330- char empty[]="";
2331- char all[]="all";
2332- int (*content_handling_func)(bstring content, bstring param, void *func_data)=NULL;
2333- int (*param_handling_func)(bstring content, bstring param, void *func_data)=NULL;
2334- HashTable *ht=NULL;
2335- long flags=0;
2336- char *childs=all;
2337- int childs_len=3;
2338- char *parents=all;
2339- int parents_len=3;
2340+ char *callback_name;
2341+ char empty[] = "";
2342+ char all[] = "all";
2343+ int (*content_handling_func)(bstring content, bstring param, void *func_data) = NULL;
2344+ int (*param_handling_func)(bstring content, bstring param, void *func_data) = NULL;
2345+ HashTable *ht = NULL;
2346+ long flags = 0;
2347+ char *childs = all;
2348+ int childs_len = 3;
2349+ char *parents = all;
2350+ int parents_len = 3;
2351 char *open_tag, *close_tag, *default_arg;
2352- int open_tag_len, close_tag_len, default_arg_len;
2353- open_tag_len = close_tag_len = default_arg_len = 0;
2354- zval **content_handling = NULL;
2355- zval **param_handling = NULL;
2356-
2357- if (Z_TYPE_P(content) == IS_ARRAY) {
2358- ht = HASH_OF(content);
2359- }
2360- if ((SUCCESS == zend_hash_find(ht, "flags", sizeof("flags"), (void *) &e))
2361- && (Z_TYPE_PP(e) == IS_LONG)) {
2362- flags = Z_LVAL_PP(e);
2363+ int open_tag_len = 0, close_tag_len = 0, default_arg_len = 0;
2364+ zval *content_handling = NULL;
2365+ zval *param_handling = NULL;
2366+
2367+ if (Z_TYPE_P(content) == IS_ARRAY) {
2368+ ht = HASH_OF(content);
2369 }
2370- if ((SUCCESS == zend_hash_find(ht, "type", sizeof("type"), (void *) &e))
2371- && (Z_TYPE_PP(e) == IS_LONG)) {
2372+
2373+ /* flags */
2374+ if ((SUCCESS == zend_hash_find(ht, "flags", sizeof("flags"), (void *) &e)) &&
2375+ (Z_TYPE_PP(e) == IS_LONG)
2376+ ) {
2377+ flags = Z_LVAL_PP(e);
2378+ }
2379+
2380+ /* type */
2381+ if ((SUCCESS == zend_hash_find(ht, "type", sizeof("type"), (void *) &e)) &&
2382+ (Z_TYPE_PP(e) == IS_LONG)
2383+ ) {
2384 type = Z_LVAL_PP(e);
2385 } else {
2386- zend_error(E_WARNING, "[BBCode] (bbcode_add_element) No type specified for tag : [%s]",tag_name);
2387+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "No type specified for tag [%s]", tag_name);
2388 return;
2389 }
2390- if ((SUCCESS == zend_hash_find(ht, "open_tag", sizeof("open_tag"), (void *) &e))
2391- && (Z_TYPE_PP(e) == IS_STRING) && Z_STRLEN_PP(e)) {
2392+
2393+ /* open_tag */
2394+ if ((SUCCESS == zend_hash_find(ht, "open_tag", sizeof("open_tag"), (void *) &e)) &&
2395+ (Z_TYPE_PP(e) == IS_STRING) && Z_STRLEN_PP(e)
2396+ ) {
2397 open_tag = Z_STRVAL_PP(e);
2398- open_tag_len=Z_STRLEN_PP(e);
2399+ open_tag_len = Z_STRLEN_PP(e);
2400 } else {
2401- open_tag=empty;
2402+ open_tag = empty;
2403 }
2404- if ((SUCCESS == zend_hash_find(ht, "close_tag", sizeof("close_tag"), (void *) &e))
2405- && (Z_TYPE_PP(e) == IS_STRING) && Z_STRLEN_PP(e)) {
2406+
2407+ /* close_tag */
2408+ if ((SUCCESS == zend_hash_find(ht, "close_tag", sizeof("close_tag"), (void *) &e)) &&
2409+ (Z_TYPE_PP(e) == IS_STRING) && Z_STRLEN_PP(e)
2410+ ) {
2411 close_tag = Z_STRVAL_PP(e);
2412- close_tag_len=Z_STRLEN_PP(e);
2413+ close_tag_len = Z_STRLEN_PP(e);
2414 } else {
2415- close_tag=empty;
2416+ close_tag = empty;
2417 }
2418- if ((SUCCESS == zend_hash_find(ht, "default_arg", sizeof("default_arg"), (void *) &e))
2419- && (Z_TYPE_PP(e) == IS_STRING) && Z_STRLEN_PP(e)) {
2420+
2421+ /* default_arg */
2422+ if ((SUCCESS == zend_hash_find(ht, "default_arg", sizeof("default_arg"), (void *) &e)) &&
2423+ (Z_TYPE_PP(e) == IS_STRING) && Z_STRLEN_PP(e)
2424+ ) {
2425 default_arg = Z_STRVAL_PP(e);
2426 default_arg_len = Z_STRLEN_PP(e);
2427 } else {
2428 default_arg = empty;
2429 }
2430- if ((SUCCESS == zend_hash_find(ht, "content_handling", sizeof("content_handling"), (void *) &e))) {
2431+
2432+ /* content_handling */
2433+ if ((SUCCESS == zend_hash_find(ht, "content_handling", sizeof("content_handling"), (void *) &e)) &&
2434+ ((Z_TYPE_PP(e) == IS_STRING && Z_STRLEN_PP(e)) || (Z_TYPE_PP(e) == IS_ARRAY))
2435+ ) {
2436+ SEPARATE_ZVAL(e);
2437 if (Z_TYPE_PP(e) != IS_STRING && Z_TYPE_PP(e) != IS_ARRAY){
2438- SEPARATE_ZVAL(e);
2439 convert_to_string_ex(e);
2440 }
2441- if (!zend_is_callable(*e, 0, &name)) {
2442- php_error_docref(NULL TSRMLS_CC, E_WARNING, "First argument is expected to be a valid callback, '%s' was given", name);
2443- efree(name);
2444+ if (!zend_is_callable(*e, 0, &callback_name TSRMLS_CC)) {
2445+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "First argument is expected to be a valid callback, '%s' was given", callback_name);
2446+ efree(callback_name);
2447 return;
2448 }
2449- efree(name);
2450- content_handling = e;
2451-#if (PHP_MAJOR_VERSION >= 5) && (PHP_MINOR_VERSION >= 3)
2452- Z_ADDREF_P(*content_handling);
2453-#else
2454- ZVAL_ADDREF(*content_handling);
2455-#endif
2456- content_handling_func= _php_bbcode_handling_content;
2457+ efree(callback_name);
2458+ content_handling = *e;
2459+ content_handling_func = _php_bbcode_content_handler;
2460 } else {
2461- content_handling=NULL;
2462+ content_handling_func = NULL;
2463+ content_handling = NULL;
2464 }
2465- if ((SUCCESS == zend_hash_find(ht, "param_handling", sizeof("param_handling"), (void *) &e))
2466- && ((Z_TYPE_PP(e) == IS_STRING && Z_STRLEN_PP(e)) || (Z_TYPE_PP(e)==IS_ARRAY))) {
2467+
2468+ /* param_handling */
2469+ if ((SUCCESS == zend_hash_find(ht, "param_handling", sizeof("param_handling"), (void *) &e)) &&
2470+ ((Z_TYPE_PP(e) == IS_STRING && Z_STRLEN_PP(e)) || (Z_TYPE_PP(e) == IS_ARRAY))
2471+ ) {
2472+ SEPARATE_ZVAL(e);
2473 if (Z_TYPE_PP(e) != IS_STRING && Z_TYPE_PP(e) != IS_ARRAY){
2474- SEPARATE_ZVAL(e);
2475 convert_to_string_ex(e);
2476 }
2477- if (!zend_is_callable(*e, 0, &name)) {
2478- php_error_docref(NULL TSRMLS_CC, E_WARNING, "First argument is expected to be a valid callback, '%s' was given", name);
2479- efree(name);
2480+ if (!zend_is_callable(*e, 0, &callback_name TSRMLS_CC)) {
2481+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "First argument is expected to be a valid callback, '%s' was given", callback_name);
2482+ efree(callback_name);
2483 return;
2484 }
2485- efree(name);
2486- param_handling = e;
2487-#if (PHP_MAJOR_VERSION >= 5) && (PHP_MINOR_VERSION >= 3)
2488- Z_ADDREF_P(*param_handling);
2489-#else
2490- ZVAL_ADDREF(*param_handling);
2491-#endif
2492- param_handling_func= _php_bbcode_handling_param;
2493+ efree(callback_name);
2494+ param_handling = *e;
2495+ param_handling_func = _php_bbcode_param_handler;
2496+ } else {
2497+ param_handling_func = NULL;
2498+ param_handling = NULL;
2499 }
2500- if ((SUCCESS == zend_hash_find(ht, "childs", sizeof("childs"), (void *) &e))
2501- && (Z_TYPE_PP(e) == IS_STRING)) {
2502+
2503+ /* childs */
2504+ if ((SUCCESS == zend_hash_find(ht, "childs", sizeof("childs"), (void *) &e)) &&
2505+ (Z_TYPE_PP(e) == IS_STRING)
2506+ ) {
2507 childs = Z_STRVAL_PP(e);
2508 childs_len = Z_STRLEN_PP(e);
2509 }
2510- if ((SUCCESS == zend_hash_find(ht, "parents", sizeof("parents"), (void *) &e))
2511- && (Z_TYPE_PP(e) == IS_STRING) && Z_STRLEN_PP(e)) {
2512+
2513+ /* parents */
2514+ if ((SUCCESS == zend_hash_find(ht, "parents", sizeof("parents"), (void *) &e)) &&
2515+ (Z_TYPE_PP(e) == IS_STRING) && Z_STRLEN_PP(e)
2516+ ) {
2517 parents = Z_STRVAL_PP(e);
2518 parents_len = Z_STRLEN_PP(e);
2519 }
2520+
2521 bbcode_parser_add_ruleset(parser, type, flags,
2522- tag_name, strlen(tag_name),
2523- open_tag, open_tag_len,
2524- close_tag, close_tag_len, default_arg, default_arg_len, parents,
2525- parents_len, childs, childs_len,
2526- param_handling_func,
2527- content_handling_func,
2528- (void *)param_handling,
2529- (void *)content_handling);
2530+ tag_name, tag_name_len,
2531+ open_tag, open_tag_len,
2532+ close_tag, close_tag_len,
2533+ default_arg, default_arg_len,
2534+ parents, parents_len,
2535+ childs, childs_len,
2536+ param_handling_func,
2537+ content_handling_func,
2538+ (void *)param_handling,
2539+ (void *)content_handling
2540+ );
2541 }
2542 /* }}} */
2543-/* Destructors */
2544-ZEND_RSRC_DTOR_FUNC(php_bbcode_dtor)
2545+
2546+/* {{{ Resource destructor */
2547+static ZEND_RSRC_DTOR_FUNC(php_bbcode_dtor)
2548 {
2549- bbcode_parser_p parser = (bbcode_parser_p)rsrc->ptr;
2550- if (parser) {
2551- bbcode_parser_free(parser);
2552- }
2553+ bbcode_parser_p parser = (bbcode_parser_p)rsrc->ptr;
2554+ if (parser) {
2555+ bbcode_parser_free(parser);
2556+ }
2557 }
2558-/* End destructors */
2559-/* INIT / SHUTDOWN */
2560-PHP_MINIT_FUNCTION(bbcode)
2561+/* }}} */
2562+
2563+/* {{{ Module INIT / SHUTDOWN */
2564+static PHP_MINIT_FUNCTION(bbcode)
2565 {
2566- le_bbcode = zend_register_list_destructors_ex(php_bbcode_dtor, NULL, PHP_BBCODE_RES_NAME, module_number);
2567+ le_bbcode = zend_register_list_destructors_ex(php_bbcode_dtor, NULL, PHP_BBCODE_RES_NAME, module_number);
2568+
2569 /* BBCODE Types */
2570 REGISTER_LONG_CONSTANT("BBCODE_TYPE_NOARG", BBCODE_TYPE_NOARG, CONST_CS|CONST_PERSISTENT);
2571 REGISTER_LONG_CONSTANT("BBCODE_TYPE_SINGLE", BBCODE_TYPE_SINGLE, CONST_CS|CONST_PERSISTENT);
2572 REGISTER_LONG_CONSTANT("BBCODE_TYPE_ARG", BBCODE_TYPE_ARG, CONST_CS|CONST_PERSISTENT);
2573 REGISTER_LONG_CONSTANT("BBCODE_TYPE_OPTARG", BBCODE_TYPE_OPTARG, CONST_CS|CONST_PERSISTENT);
2574 REGISTER_LONG_CONSTANT("BBCODE_TYPE_ROOT", BBCODE_TYPE_ROOT, CONST_CS|CONST_PERSISTENT);
2575+
2576 /* BBCODE Flags */
2577 REGISTER_LONG_CONSTANT("BBCODE_FLAGS_ARG_PARSING", BBCODE_FLAGS_ARG_PARSING, CONST_CS|CONST_PERSISTENT);
2578 REGISTER_LONG_CONSTANT("BBCODE_FLAGS_CDATA_NOT_ALLOWED", BBCODE_FLAGS_CDATA_NOT_ALLOWED, CONST_CS|CONST_PERSISTENT);
2579@@ -330,42 +283,52 @@
2580 REGISTER_LONG_CONSTANT("BBCODE_FLAGS_ONE_OPEN_PER_LEVEL", BBCODE_FLAGS_ONE_OPEN_PER_LEVEL, CONST_CS|CONST_PERSISTENT);
2581 REGISTER_LONG_CONSTANT("BBCODE_FLAGS_REMOVE_IF_EMPTY", BBCODE_FLAGS_REMOVE_IF_EMPTY, CONST_CS|CONST_PERSISTENT);
2582 REGISTER_LONG_CONSTANT("BBCODE_FLAGS_DENY_REOPEN_CHILD", BBCODE_FLAGS_DENY_REOPEN_CHILD, CONST_CS|CONST_PERSISTENT);
2583- /* Parsers Flags */
2584+
2585+ /* Parser Flags */
2586+
2587 /* Quotes styles */
2588 REGISTER_LONG_CONSTANT("BBCODE_ARG_DOUBLE_QUOTE", BBCODE_ARG_DOUBLE_QUOTE, CONST_CS|CONST_PERSISTENT);
2589 REGISTER_LONG_CONSTANT("BBCODE_ARG_SINGLE_QUOTE", BBCODE_ARG_SINGLE_QUOTE, CONST_CS|CONST_PERSISTENT);
2590 REGISTER_LONG_CONSTANT("BBCODE_ARG_HTML_QUOTE", BBCODE_ARG_HTML_QUOTE, CONST_CS|CONST_PERSISTENT);
2591 REGISTER_LONG_CONSTANT("BBCODE_ARG_QUOTE_ESCAPING", BBCODE_ARG_QUOTE_ESCAPING, CONST_CS|CONST_PERSISTENT);
2592+
2593 /* Parsing Options */
2594 REGISTER_LONG_CONSTANT("BBCODE_AUTO_CORRECT", BBCODE_AUTO_CORRECT, CONST_CS|CONST_PERSISTENT);
2595 REGISTER_LONG_CONSTANT("BBCODE_CORRECT_REOPEN_TAGS", BBCODE_CORRECT_REOPEN_TAGS, CONST_CS|CONST_PERSISTENT);
2596 REGISTER_LONG_CONSTANT("BBCODE_DISABLE_TREE_BUILD", BBCODE_DISABLE_TREE_BUILD, CONST_CS|CONST_PERSISTENT);
2597- /* Smileys Options */
2598+
2599+ /* Smiley Options */
2600 REGISTER_LONG_CONSTANT("BBCODE_DEFAULT_SMILEYS_ON", BBCODE_DEFAULT_SMILEYS_ON, CONST_CS|CONST_PERSISTENT);
2601 REGISTER_LONG_CONSTANT("BBCODE_DEFAULT_SMILEYS_OFF", BBCODE_DEFAULT_SMILEYS_OFF, CONST_CS|CONST_PERSISTENT);
2602 REGISTER_LONG_CONSTANT("BBCODE_FORCE_SMILEYS_OFF", BBCODE_FORCE_SMILEYS_OFF, CONST_CS|CONST_PERSISTENT);
2603 REGISTER_LONG_CONSTANT("BBCODE_SMILEYS_CASE_INSENSITIVE", BBCODE_SMILEYS_CASE_INSENSITIVE, CONST_CS|CONST_PERSISTENT);
2604+
2605 /* FLAG SET / ADD / REMOVE */
2606 REGISTER_LONG_CONSTANT("BBCODE_SET_FLAGS_SET", BBCODE_SET_FLAGS_SET, CONST_CS|CONST_PERSISTENT);
2607 REGISTER_LONG_CONSTANT("BBCODE_SET_FLAGS_ADD", BBCODE_SET_FLAGS_ADD, CONST_CS|CONST_PERSISTENT);
2608 REGISTER_LONG_CONSTANT("BBCODE_SET_FLAGS_REMOVE", BBCODE_SET_FLAGS_REMOVE, CONST_CS|CONST_PERSISTENT);
2609- return SUCCESS;
2610+
2611+ return SUCCESS;
2612 }
2613-/* END INIT/SHUTDOWN */
2614+/* }}} */
2615
2616 #if Void_0
2617-/* {{{
2618- * Working on it, not finished yet
2619- * OBJECT START */
2620-static void _php_bbcode_object_free_storage(void *object TSRMLS_DC){
2621+typedef struct _bbcode_object {
2622+ zend_object std;
2623+ int rsrc_id;
2624+} bbcode_object;
2625+
2626+/* {{{ TODO: Not finished yet! */
2627+static void _php_bbcode_object_free_storage(void *object TSRMLS_DC)
2628+{
2629 bbcode_object *intern = (bbcode_object *)object;
2630 zval *pointer;
2631 zval *return_value;
2632-
2633+
2634 zend_object_std_dtor(&intern->std TSRMLS_CC);
2635
2636 bbcode_container *container;
2637-
2638+
2639 if (intern->rsrc_id) {
2640 ALLOC_INIT_ZVAL(pointer);
2641 ALLOC_INIT_ZVAL(return_value);
2642@@ -373,9 +336,9 @@
2643 Z_TYPE_P(pointer) = IS_LONG;
2644 Z_LVAL_P(pointer) = intern->rsrc_id;
2645 ZEND_FETCH_RESOURCE(container, bbcode_container*, &pointer, -1, PHP_BBCODE_RES_NAME, le_bbcode);
2646- bbcode_destroy_tag_stack(container);
2647- efree(return_value);
2648- zval_ptr_dtor(&pointer);
2649+ bbcode_destroy_tag_stack(container);
2650+ efree(return_value);
2651+ zval_ptr_dtor(&pointer);
2652 zend_list_delete(intern->rsrc_id);
2653 }
2654 efree(object);
2655@@ -397,120 +360,130 @@
2656 NULL TSRMLS_CC);
2657 retval->handlers = handlers;
2658 }
2659-/* END OBJECT
2660- * }}} */
2661+/* }}} */
2662 #endif
2663+
2664 /* {{{ proto resource bbcode_container bbcode_create([array initial_tags])
2665- create a new bbcode_container and add elements given in the array to the resource
2666- initial_tags is an associative array with tag_name=>tag_definition
2667- (see bbcode_add_element to view tag_definition format) */
2668-PHP_FUNCTION(bbcode_create)
2669+ Creates a new bbcode_container and adds elements given in the array to the resource. */
2670+static PHP_FUNCTION(bbcode_create)
2671 {
2672- zval *bbcode_entry=NULL;
2673+ zval *bbcode_entry = NULL;
2674 bbcode_parser_p parser = NULL;
2675-
2676+
2677 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a", &bbcode_entry) == FAILURE) {
2678- RETURN_NULL();
2679- }
2680-
2681- /* Container init */
2682- parser=bbcode_parser_create();
2683- if (parser==NULL){
2684- zend_error(E_ERROR, "[BBCode] (bbcode_create) Unable to allocate memory for tag_stack");
2685- }
2686- bbcode_parser_set_flags(parser, BBCODE_AUTO_CORRECT|BBCODE_ARG_DOUBLE_QUOTE|BBCODE_ARG_SINGLE_QUOTE|BBCODE_ARG_HTML_QUOTE|BBCODE_DEFAULT_SMILEYS_ON);
2687- /* If array given initialisation */
2688- if(bbcode_entry!=NULL){
2689- int i;
2690- HashTable *myht=NULL;
2691-
2692- if (Z_TYPE_P(bbcode_entry) == IS_ARRAY) {
2693- myht = HASH_OF(bbcode_entry);
2694- }
2695-
2696- i = myht ? zend_hash_num_elements(myht) : 0;
2697- if (i > 0) {
2698- char *key;
2699- zval **data;
2700- ulong index;
2701- uint key_len;
2702- HashPosition pos;
2703- HashTable *tmp_ht;
2704+ RETURN_NULL();
2705+ }
2706+
2707+ /* Container init */
2708+ parser = bbcode_parser_create();
2709+ if (parser == NULL){
2710+ php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to allocate memory for tag_stack");
2711+ }
2712+ bbcode_parser_set_flags(parser, BBCODE_AUTO_CORRECT|BBCODE_ARG_DOUBLE_QUOTE|BBCODE_ARG_SINGLE_QUOTE|BBCODE_ARG_HTML_QUOTE|BBCODE_DEFAULT_SMILEYS_ON);
2713+
2714+ /* If array given initialisation */
2715+ if (bbcode_entry != NULL) {
2716+ int i;
2717+ HashTable *myht = NULL;
2718+
2719+ if (Z_TYPE_P(bbcode_entry) == IS_ARRAY) {
2720+ myht = HASH_OF(bbcode_entry);
2721+ }
2722+
2723+ i = myht ? zend_hash_num_elements(myht) : 0;
2724+ if (i > 0) {
2725+ char *key;
2726+ zval **data;
2727+ ulong index;
2728+ uint key_len;
2729+ HashPosition pos;
2730+ HashTable *tmp_ht;
2731+
2732 /* Array walking */
2733- zend_hash_internal_pointer_reset_ex(myht, &pos);
2734- for (;; zend_hash_move_forward_ex(myht, &pos)) {
2735- i = zend_hash_get_current_key_ex(myht, &key, &key_len, &index, 0, &pos);
2736- if (i == HASH_KEY_NON_EXISTANT)
2737- break;
2738-
2739- if (zend_hash_get_current_data_ex(myht, (void **) &data, &pos) == SUCCESS) {
2740- tmp_ht = HASH_OF(*data);
2741- if (tmp_ht) {
2742- tmp_ht->nApplyCount++;
2743- }
2744- if (i == HASH_KEY_IS_STRING) {
2745+ zend_hash_internal_pointer_reset_ex(myht, &pos);
2746+ for (;; zend_hash_move_forward_ex(myht, &pos)) {
2747+ i = zend_hash_get_current_key_ex(myht, &key, &key_len, &index, 0, &pos);
2748+ if (i == HASH_KEY_NON_EXISTANT) {
2749+ break;
2750+ }
2751+
2752+ if (zend_hash_get_current_data_ex(myht, (void **) &data, &pos) == SUCCESS) {
2753+ tmp_ht = HASH_OF(*data);
2754+ if (tmp_ht) {
2755+ tmp_ht->nApplyCount++;
2756+ }
2757+ if (i == HASH_KEY_IS_STRING) {
2758 /* Add Element to container */
2759- _php_bbcode_add_element(parser,key,*data TSRMLS_CC);
2760- }
2761- if (tmp_ht) {
2762- tmp_ht->nApplyCount--;
2763- }
2764- }
2765- }
2766- }
2767- }
2768- /* Registering Resource & returning */
2769- ZEND_REGISTER_RESOURCE(return_value, parser, le_bbcode);
2770+ _php_bbcode_add_element(parser, key, key_len - 1, *data TSRMLS_CC);
2771+ }
2772+ if (tmp_ht) {
2773+ tmp_ht->nApplyCount--;
2774+ }
2775+ }
2776+ }
2777+ }
2778+ }
2779+
2780+ /* Register resource and return it */
2781+ ZEND_REGISTER_RESOURCE(return_value, parser, le_bbcode);
2782 }
2783 /* }}} */
2784-/* {{{ proto boolean bbcode_add_element(resource bbcode_container, string tag_name , array tag_definition)
2785- add a new tag to the given bbcode_container
2786- tag_definition is an array with those elements:
2787- needed:
2788- * 'type' => Type of the tag (view BBCODE_TYPE_* to view available tags)
2789- optionnals:
2790- * 'flags' =0 => features of the tag (view BBCODE_FLAGS_* to view capacities)
2791- * 'open_tag' = '' => the replacement open_tag (1)
2792- * 'close_tag' = '' => the replacement close_tag (1)
2793- * 'default_argument' = '' => For Optionnal argument tags argument taken if not given (1)
2794- * 'content_handling' = '' => Function name called as callback for content ( string new_content content_function ( content, param ); )
2795- * 'param_handling' = '' => Function name called as callback for content ( string new_content content_function ( content, param ); )
2796- * 'childs' = 'all' => Comma separated list of accepted childs (use !list to make a list of non accepted childs, no space between tag_names)
2797- * 'parents' = 'all' => Comma separated list of tags of which this tag could be a child
2798- (1) note that the {CONTENT} string is automatically replaced by the content of the tag and {PARAM} by the parameter
2799- */
2800-PHP_FUNCTION(bbcode_add_element)
2801+
2802+/* {{{ proto boolean bbcode_add_element(resource bbcode_container, string tag_name, array tag_definition)
2803+ Adds a new tag to the given bbcode_container. */
2804+static PHP_FUNCTION(bbcode_add_element)
2805 {
2806 zval *z_bbcode_parser;
2807 zval *bbcode_entry;
2808- bbcode_parser_p parser=NULL;
2809+ bbcode_parser_p parser = NULL;
2810 char *tag_name;
2811- int tag_len;
2812-
2813- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsa", &z_bbcode_parser, &tag_name, &tag_len, &bbcode_entry) == FAILURE) {
2814- RETURN_NULL();
2815- }
2816+ int tag_name_len;
2817+
2818+ /* tag_definition is an array with these elements:
2819+
2820+ - required:
2821+ o 'type' => Type of the tag (view BBCODE_TYPE_* to view available tags)
2822+
2823+ - optional:
2824+ o 'flags' =0 => features of the tag (view BBCODE_FLAGS_* to view capacities)
2825+ o 'open_tag' = '' => the replacement open_tag (1)
2826+ o 'close_tag' = '' => the replacement close_tag (1)
2827+ o 'default_argument' = '' => For Optionnal argument tags argument taken if not given [1]
2828+ o 'content_handling' = '' => Function name called as callback for content ( string new_content content_function ( content, param ); )
2829+ o 'param_handling' = '' => Function name called as callback for content ( string new_content content_function ( content, param ); )
2830+ o 'childs' = 'all' => Comma separated list of accepted childs (use !list to make a list of non accepted childs, no space between tag_names)
2831+ o 'parents' = 'all' => Comma separated list of tags of which this tag could be a child
2832+
2833+ [1] note that the {CONTENT} string is automatically replaced by the content of the tag and {PARAM} by the parameter
2834+ */
2835+
2836+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsa", &z_bbcode_parser, &tag_name, &tag_name_len, &bbcode_entry) == FAILURE) {
2837+ RETURN_NULL();
2838+ }
2839+
2840 ZEND_FETCH_RESOURCE(parser, bbcode_parser_p, &z_bbcode_parser, -1, PHP_BBCODE_RES_NAME, le_bbcode);
2841- _php_bbcode_add_element(parser, tag_name, bbcode_entry TSRMLS_CC);
2842+ _php_bbcode_add_element(parser, tag_name, tag_name_len, bbcode_entry TSRMLS_CC);
2843 RETURN_TRUE;
2844 }
2845 /* }}} */
2846+
2847 /* {{{ proto boolean bbcode_destroy(resource bbcode_container)
2848- free memory resources of the given bbcode_container */
2849-PHP_FUNCTION(bbcode_destroy)
2850+ Frees memory resources of the given bbcode_container. */
2851+static PHP_FUNCTION(bbcode_destroy)
2852 {
2853 zval *z_bbcode_parser;
2854-
2855+
2856 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &z_bbcode_parser) == FAILURE) {
2857- RETURN_NULL();
2858- }
2859-
2860+ RETURN_NULL();
2861+ }
2862+
2863 RETURN_BOOL(zend_list_delete(Z_LVAL_P(z_bbcode_parser)) == SUCCESS);
2864 }
2865 /* }}} */
2866+
2867 /* {{{ proto string bbcode_parse(resource bbcode_container, string to_parse)
2868- returns the bbcode parsed value of the to_parse string with definitions given by bbcode_container */
2869-PHP_FUNCTION(bbcode_parse)
2870+ Returns the bbcode parsed value of the to_parse string with definitions given by bbcode_container. */
2871+static PHP_FUNCTION(bbcode_parse)
2872 {
2873 zval *z_bbcode_parser;
2874 bbcode_parser_p parser;
2875@@ -518,101 +491,165 @@
2876 int str_len;
2877 char *ret_string;
2878 int ret_size;
2879-
2880+
2881 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &z_bbcode_parser, &string, &str_len) == FAILURE) {
2882- RETURN_NULL();
2883- }
2884+ RETURN_NULL();
2885+ }
2886+
2887 ZEND_FETCH_RESOURCE(parser, bbcode_parser_p, &z_bbcode_parser, -1, PHP_BBCODE_RES_NAME, le_bbcode);
2888- /* converting string for bbcode_parse_string usage */
2889- ret_string=bbcode_parse(parser, string, str_len, &ret_size);
2890-
2891+
2892+ /* convert string for bbcode_parse_string usage */
2893+ ret_string = bbcode_parse(parser, string, str_len, &ret_size);
2894+
2895 RETVAL_STRINGL(ret_string, ret_size , 1);
2896 free(ret_string);
2897 }
2898 /* }}} */
2899+
2900 /* {{{ proto boolean bbcode_add_smiley(resource bbcode_container, string find, string replace)
2901- add a smiley find and replace ruleset */
2902-PHP_FUNCTION(bbcode_add_smiley)
2903+ Adds a smiley to find and replace ruleset. */
2904+static PHP_FUNCTION(bbcode_add_smiley)
2905 {
2906 zval *z_bbcode_parser;
2907 char *search, *replace;
2908 int s_len, r_len;
2909- bbcode_parser_p parser=NULL;
2910-
2911+ bbcode_parser_p parser = NULL;
2912+
2913 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss", &z_bbcode_parser, &search, &s_len, &replace, &r_len) == FAILURE) {
2914- RETURN_NULL();
2915- }
2916-
2917+ RETURN_NULL();
2918+ }
2919+
2920 ZEND_FETCH_RESOURCE(parser, bbcode_parser_p, &z_bbcode_parser, -1, PHP_BBCODE_RES_NAME, le_bbcode);
2921-
2922+
2923 bbcode_parser_add_smiley(parser, search, s_len, replace, r_len);
2924 RETURN_BOOL(SUCCESS);
2925 }
2926 /* }}} */
2927+
2928 /* {{{ proto boolean bbcode_set_flags(resource bbcode_container, long flag, long mode)
2929- manage flags on parser using BBCODE_SET_FLAGS_* */
2930-PHP_FUNCTION(bbcode_set_flags)
2931+ Set flags on parser using BBCODE_SET_FLAGS_* constants. */
2932+static PHP_FUNCTION(bbcode_set_flags)
2933 {
2934 zval *z_bbcode_parser;
2935 long new_flags;
2936- long mode=0;
2937+ long mode = 0;
2938 long flags;
2939 bbcode_parser_p parser=NULL;
2940-
2941+
2942 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|l", &z_bbcode_parser, &new_flags, &mode) == FAILURE) {
2943- RETURN_NULL();
2944- }
2945-
2946+ RETURN_NULL();
2947+ }
2948+
2949 ZEND_FETCH_RESOURCE(parser, bbcode_parser_p, &z_bbcode_parser, -1, PHP_BBCODE_RES_NAME, le_bbcode);
2950-
2951- flags=bbcode_parser_get_flags(parser);
2952- switch (mode){
2953+
2954+ flags = bbcode_parser_get_flags(parser);
2955+
2956+ switch (mode) {
2957 case BBCODE_SET_FLAGS_ADD:
2958 bbcode_parser_set_flags(parser, flags | new_flags);
2959 break;
2960-
2961+
2962 case BBCODE_SET_FLAGS_REMOVE:
2963 bbcode_parser_set_flags(parser, flags & (~new_flags));
2964 break;
2965-
2966+
2967 default:
2968 case BBCODE_SET_FLAGS_SET:
2969 bbcode_parser_set_flags(parser, new_flags);
2970 break;
2971-
2972 }
2973-
2974+
2975 RETURN_BOOL(SUCCESS);
2976 }
2977 /* }}} */
2978+
2979 /* {{{ proto boolean bbcode_set_arg_parser(resource bbcode_container, resource bbcode_child)
2980- Sets a bbcode_argument_parser */
2981-PHP_FUNCTION(bbcode_set_arg_parser)
2982+ Defines a bbcode_argument_parser. */
2983+static PHP_FUNCTION(bbcode_set_arg_parser)
2984 {
2985 zval *z_bbcode_parser;
2986 zval *z_bbcode_parser_child;
2987- bbcode_parser_p parser=NULL;
2988- bbcode_parser_p arg_parser=NULL;
2989-
2990+ bbcode_parser_p parser = NULL;
2991+ bbcode_parser_p arg_parser = NULL;
2992+
2993 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr", &z_bbcode_parser, &z_bbcode_parser_child) == FAILURE) {
2994- RETURN_NULL();
2995- }
2996+ RETURN_NULL();
2997+ }
2998+
2999 ZEND_FETCH_RESOURCE(parser, bbcode_parser_p, &z_bbcode_parser, -1, PHP_BBCODE_RES_NAME, le_bbcode);
3000 ZEND_FETCH_RESOURCE(arg_parser, bbcode_parser_p, &z_bbcode_parser_child, -1, PHP_BBCODE_RES_NAME, le_bbcode);
3001- bbcode_parser_set_arg_parser(parser, arg_parser);
3002+
3003+ bbcode_parser_set_arg_parser(parser, arg_parser);
3004+
3005 RETURN_BOOL(SUCCESS);
3006 }
3007 /* }}} */
3008
3009-/*** Module Infos ***/
3010-PHP_MINFO_FUNCTION(bbcode)
3011+/* {{{ Module Info */
3012+static PHP_MINFO_FUNCTION(bbcode)
3013 {
3014 php_info_print_table_start();
3015 php_info_print_table_header(2, "BBCode support", "enabled");
3016- php_info_print_table_row(2, "BBCode Version Support", PHP_BBCODE_VERSION);
3017+ php_info_print_table_row(2, "BBCode Extension Version", PHP_BBCODE_VERSION);
3018 php_info_print_table_row(2, "BBCode Library Version", BBCODE_LIB_VERSION);
3019 php_info_print_table_row(2, "BBCode Max Stack Size", "Dynamic");
3020 php_info_print_table_row(2, "BBCode Max Elements", "No Limit");
3021- php_info_print_table_header(1, "This extension makes use of Bstrlib available at http://bstrlib.sf.net");
3022 php_info_print_table_end();
3023+ php_info_print_box_start(0);
3024+ PUTS("This extension makes use of Bstrlib available at http://bstrlib.sf.net");
3025+ php_info_print_box_end();
3026 }
3027+/* }}} */
3028+
3029+static zend_function_entry bbcode_functions[] = { /* {{{ */
3030+ PHP_FE(bbcode_create, NULL)
3031+ PHP_FE(bbcode_add_element, NULL)
3032+ PHP_FE(bbcode_destroy, NULL)
3033+ PHP_FE(bbcode_parse, NULL)
3034+ PHP_FE(bbcode_add_smiley, NULL)
3035+ PHP_FE(bbcode_set_flags, NULL)
3036+ PHP_FE(bbcode_set_arg_parser, NULL)
3037+ {NULL, NULL, NULL}
3038+};
3039+/* }}} */
3040+
3041+#if Void_0
3042+/* Object Part, working on it */
3043+zend_function_entry bbcode_funcs_object[] = {
3044+ PHP_ME_MAPPING(__construct, bbcode_create, NULL, 0)
3045+ PHP_ME_MAPPING(addElement, bbcode_add_element, NULL, 0)
3046+ PHP_ME_MAPPING(destroy, bbcode_destroy, NULL, 0)
3047+ PHP_ME_MAPPING(parse, bbcode_parse, NULL, 0)
3048+ {NULL, NULL, NULL}
3049+};
3050+#endif
3051+
3052+zend_module_entry bbcode_module_entry = {
3053+#if ZEND_MODULE_API_NO >= 20010901
3054+ STANDARD_MODULE_HEADER,
3055+#endif
3056+ PHP_BBCODE_EXTNAME,
3057+ bbcode_functions,
3058+ PHP_MINIT(bbcode),
3059+ NULL,
3060+ NULL,
3061+ NULL,
3062+ PHP_MINFO(bbcode),
3063+#if ZEND_MODULE_API_NO >= 20010901
3064+ PHP_BBCODE_VERSION,
3065+#endif
3066+ STANDARD_MODULE_PROPERTIES
3067+};
3068+
3069+#ifdef COMPILE_DL_BBCODE
3070+ZEND_GET_MODULE(bbcode)
3071+#endif
3072+
3073+/*
3074+ * Local variables:
3075+ * tab-width: 4
3076+ * c-basic-offset: 4
3077+ * End:
3078+ * vim600: noet sw=4 ts=4 fdm=marker
3079+ * vim<600: noet sw=4 ts=4
3080+ */
3081
3082Property changes on: php_bbcode.c
3083___________________________________________________________________
3084Modified: cvs2svn:cvs-rev
3085 - 1.25
3086 + 1.30
3087
3088Index: php_bbcode.h
3089===================================================================
3090--- php_bbcode.h (.../tags/RELEASE_1_0_2)
3091+++ php_bbcode.h (.../trunk)
3092@@ -2,7 +2,7 @@
3093 +----------------------------------------------------------------------+
3094 | PHP Version 5 |
3095 +----------------------------------------------------------------------+
3096- | Copyright (c) 1997-2007 The PHP Group |
3097+ | Copyright (c) 1997-2008 The PHP Group |
3098 +----------------------------------------------------------------------+
3099 | This source file is subject to version 3.01 of the PHP license, |
3100 | that is bundled with this package in the file LICENSE, and is |
3101@@ -14,32 +14,31 @@
3102 +----------------------------------------------------------------------+
3103 | Author: Xavier De Cock <void@php.net> |
3104 +----------------------------------------------------------------------+
3105-
3106- $Id$
3107 */
3108+
3109+/* $Id$ */
3110+
3111 #ifndef PHP_BBCODE_H
3112-#define PHP_BBCODE_H 1
3113+#define PHP_BBCODE_H
3114
3115-#define PHP_BBCODE_VERSION "1.0.2"
3116+#define PHP_BBCODE_VERSION "1.1.0-dev"
3117 #define PHP_BBCODE_EXTNAME "bbcode"
3118+#define PHP_BBCODE_RES_NAME "BBCode resource"
3119
3120 #define BBCODE_SET_FLAGS_SET 0
3121 #define BBCODE_SET_FLAGS_ADD 1
3122 #define BBCODE_SET_FLAGS_REMOVE 2
3123
3124-PHP_MINIT_FUNCTION(bbcode);
3125-PHP_MINFO_FUNCTION(bbcode);
3126-PHP_FUNCTION(bbcode_create);
3127-PHP_FUNCTION(bbcode_add_element);
3128-PHP_FUNCTION(bbcode_destroy);
3129-PHP_FUNCTION(bbcode_parse);
3130-PHP_FUNCTION(bbcode_add_smiley);
3131-PHP_FUNCTION(bbcode_set_flags);
3132-PHP_FUNCTION(bbcode_set_arg_parser);
3133-
3134 extern zend_module_entry bbcode_module_entry;
3135 #define phpext_bbcode_ptr &bbcode_module_entry
3136
3137-#define PHP_BBCODE_RES_NAME "BBCode resource"
3138-
3139 #endif
3140+
3141+/*
3142+ * Local variables:
3143+ * tab-width: 4
3144+ * c-basic-offset: 4
3145+ * End:
3146+ * vim600: noet sw=4 ts=4 fdm=marker
3147+ * vim<600: noet sw=4 ts=4
3148+ */
3149
3150Property changes on: php_bbcode.h
3151___________________________________________________________________
3152Modified: cvs2svn:cvs-rev
3153 - 1.13
3154 + 1.14
3155
3156
3157Property changes on: .
3158___________________________________________________________________
3159Added: svn:ignore
3160 + .deps
3161Makefile
3162*.lo
3163*.loT
3164*.slo
3165*.mk
3166*.la
3167.libs
3168libs.mk
3169ac*.m4
3170build
3171config.h
3172config.h.in
3173config.nice
3174config.sub
3175configure
3176configure.in
3177config.status
3178config.cache
3179conftest
3180conftest.c
3181core
3182dynlib.m4
3183install-sh
3184ltmain.sh
3185include
3186Makefile.fragments
3187Makefile.global
3188Makefile.objects
3189missing
3190mkinstalldirs
3191modules
3192scan_makefile_in.awk
3193config.guess
3194*swp
3195config.log
3196libtool
3197Debug
3198Release
3199Debug_TS
3200Release_TS
3201*.plg
3202*.patch
3203*.tgz
3204*.ncb
3205*.opt
3206*.dsw
3207autom4te.cache
3208run-tests-config.php
3209run-tests.php
3210
3211
This page took 0.433605 seconds and 4 git commands to generate.