2 ===================================================================
3 Cannot display: file marked as a binary type.
4 svn:mime-type = application/xml
6 ===================================================================
7 --- config.w32 (.../tags/RELEASE_1_0_2)
8 +++ config.w32 (.../trunk)
13 +ARG_ENABLE("bbcode", "BBcode", "no");
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');
21 Property changes on: config.w32
22 ___________________________________________________________________
26 + Id Rev Revision Date LastChangedDate LastChangedRevision Author LastChangedBy HeadURL URL
27 Added: cvs2svn:cvs-rev
30 Index: tests/test_ivy.phpt
31 ===================================================================
32 --- tests/test_ivy.phpt (.../tags/RELEASE_1_0_2)
33 +++ tests/test_ivy.phpt (.../trunk)
39 +if (!extension_loaded("bbcode")){
40 + if (!dl('bbcode.so')){
41 + die ('bbcode not loadable');
44 +define("____page","");
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 />
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 />
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 />
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 />
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 />
62 +[just][center][round][color=lightblue][b][u]Caractéristiques :[/u][/b][/color]<br />
64 +[*]300 presets modifiables<br />
65 +[*]32 modélisations d'amplis<br />
66 +[*]16 modélisations d'enceintes<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 />
76 +[just][center][round][color=lightgreen][b][u]Modèles d’amplis basés sur:[/u][/b][/color]<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 />
93 +[just][center][round][color=lightyellow][b][u]Modèles d’enceintes basés sur:[/u][b][/color]<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 />
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 />
118 +[just][center][round][color=red][b][u]Prix :[/u][/b][/color] <br />
120 +[*][color=red]99,00€[/color] sur www.woodbrass.com<br />
121 +[*][color=grey]119,00€[/color] prix public conseillé.[/list]<br />
123 +[color=lime][b][u]Liens :[/u][/b][/color]<br />
125 +infos tirées des sites suivants :<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 />
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]
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"?' ':'').''),
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"?' ':'').''),
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"?' ':'').''),
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'=>'"> </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"?' ':'').''),
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"?' ':'').'', '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"?' ':'').'', '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"?' ':'').'', '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"?' ':'').'', '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"?' ':'').'', '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"?' ':'').'<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"?' ':'').''),
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é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]'),
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',
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',
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",
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);
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);
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){
336 + $err=error_reporting(E_ALL);
337 + $message=bbcode_parse($BBHandler,$message);
338 + $message=str_replace(" "," ",$message);
339 + error_reporting($err);
341 + //$BBHandler->treat($message);
346 +function BBSize($content,$param){
347 + $param=min(24,max(4,$param));
350 +function BBList($content,$param){
352 + return '<ul>'.$content.'</ul>';
354 + return '<ol type="'.$param.'">'.$content.'</ol>';
357 +function BBInt($content,$param){
358 + $param= (int) $param;
361 +function BBBorder($content,$param){
362 + $param= min(8,max(1,$param));
365 +function bbid2user($content,$param){
366 + if ($param=='{SELF}'){
367 + $param=(int)$content;
371 + $content="<a href='".$content."'>".$content."</a>";
374 +function BBId2Msg($content,$param){
375 + if ($param=='{SELF}'){
376 + $param=(int)$content;
380 + $content="<a href='/message.php?destinataire=$id'>".html_encode_string($content)."</a>";
383 +function BBWave($content,$param="8:24"){
384 + if ($_GET['page']=="chat-2.php"){
385 + return ("[wave=$param]".$content."[/wave]");
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);
399 + if (strlen($content)<$max-$min && $content!=0){
400 + $step=round(($max-$min)/$content);
407 + foreach ($string as $car){
408 + $car=html_encode_string($car);
409 + $out.="<span style='font-size:".$i."px;'>".$car."</span>";
427 +function shortenAuthor($content,$param=""){
428 + if (strlen($param)>150){
429 + $param=substr($param,0,150);
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);
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));
441 + $str_size=sizeof($string);
442 + $nb_col=sizeof($col);
447 + $steps=max(round($str_size/($nb_col-1)),1);
449 + foreach ($string as $k=>$car){
450 + $car=html_encode_string($car);
453 + $r=sprintf("%02x",$col[$nb]['r']);
454 + $g=sprintf("%02x",$col[$nb]['g']);
455 + $b=sprintf("%02x",$col[$nb]['b']);
457 + elseif($k>($steps*($nb_col-1))){
459 + $r=sprintf("%02x",$col[$nb]['r']);
460 + $g=sprintf("%02x",$col[$nb]['g']);
461 + $b=sprintf("%02x",$col[$nb]['b']);
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))))));
469 + if (is_null($last)){
472 + if ($current!=$last){
473 + $out.='</span><span style="color:#'.$current.';">';
479 + return substr($out,strlen('</span>'));
481 +function BBVoid($content,$param){
484 +function BBBackTrace($string,$base)
486 + $string=br2nl($string);
487 + $base=base_convert($base,16,10);
491 + while ($i<strlen($string))
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";
499 +function BBHexDump($string,$base)
501 + $string=br2nl($string);
502 + $base=base_convert($base,16,10);
506 + while ($i<strlen($string))
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)));
518 +function random_id($content, $param){
519 + return uniqid($param."_");
521 +function content_validate_url($content,$param){
522 + if ($param=="{CONTENT}"){
523 + return validate_url($param,$content);
527 +function validate_url($content, $param){
529 +//$text="[i] Parser [b] Auto Correction [/i] at work [/b]\n";
536 +bbcode_destroy($BBHandler);
542 Property changes on: tests/test_ivy.phpt
543 ___________________________________________________________________
547 + Id Rev Revision Date LastChangedDate LastChangedRevision Author LastChangedBy HeadURL URL
548 Added: cvs2svn:cvs-rev
551 Index: tests/test_26.phpt
552 ===================================================================
553 --- tests/test_26.phpt (.../tags/RELEASE_1_0_2)
554 +++ tests/test_26.phpt (.../trunk)
557 +BBCODE Param and Content Callbacks
560 +if (!extension_loaded('bbcode')){
561 + if (!dl('bbcode.so')){
562 + die ('bbcode not loadable');
566 + static function bar($content,$param){
567 + return "Foo_C::bar ".$content;
569 + function foo($content, $param) {
570 + return "Foo_C->foo_cb() ".$content;
573 +function C_callback($content, $param){
574 + return "C_Callback ".$content;
577 + static function bar($content,$param){
578 + return "Foo_P::bar ".$param;
580 + function foo($content, $param) {
581 + return "Foo_P->foo() ".$param;
584 +function P_callback($content, $param){
585 + return "P_Callback ".$param;
587 +function f_empty(){}
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'),
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'),
601 + 'u'=> array('type' => BBCODE_TYPE_ARG, 'open_tag' => '<u {PARAM}>', 'close_tag' => '</u>',
602 + 'content_handling' => 'C_callback',
603 + 'param_handling' => 'P_callback',
605 + 'e'=> array('type' => BBCODE_TYPE_ARG, 'open_tag' => '<e {PARAM}>', 'close_tag' => '</e>',
606 + 'content_handling' => 'f_empty',
607 + 'param_handling' => 'f_empty',
611 +[u=aa]Underlined Text[/u]
612 +[i=aa]Italic Text[/i]
614 +[e=aa]Emptied Text[/e]
616 +$BBHandler = bbcode_create($arrayBBCode);
617 +echo "== Run #1 ==\n", bbcode_parse($BBHandler,$text);
619 +echo "== Run #2 ==\n", bbcode_parse($BBHandler,$text);
621 +echo "== Run #3 ==\n", bbcode_parse($BBHandler,$text);
622 +bbcode_destroy($BBHandler);
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>
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>
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>
641 Property changes on: tests/test_26.phpt
642 ___________________________________________________________________
646 + Id Rev Revision Date LastChangedDate LastChangedRevision Author LastChangedBy HeadURL URL
647 Added: cvs2svn:cvs-rev
650 Index: tests/test_27.phpt
651 ===================================================================
652 --- tests/test_27.phpt (.../tags/RELEASE_1_0_2)
653 +++ tests/test_27.phpt (.../trunk)
656 +BBCODE Invalid quote segfaults
659 +if (!extension_loaded('bbcode')){
660 + die ('skip bbcode not loadable');
667 +[quote=a]foo[/quote]
668 +[quote="b]bar[/quote]
672 + 'quote' => array('type'=> BBCODE_TYPE_OPTARG),
675 +echo bbcode_parse(bbcode_create($BBCode), $text);
679 +[quote="b]bar[/quote]
681 Property changes on: tests/test_27.phpt
682 ___________________________________________________________________
686 + Id Rev Revision Date LastChangedDate LastChangedRevision Author LastChangedBy HeadURL URL
687 Added: cvs2svn:cvs-rev
691 Property changes on: tests
692 ___________________________________________________________________
705 ===================================================================
706 --- bbcode.php (.../tags/RELEASE_1_0_2)
707 +++ bbcode.php (.../trunk)
715 + * A complex BBCode Tags Parser
717 + * The BBCode Array Arguments
722 + * flags > BBCode::FLAGS_*
726 + * type > BBCode::TYPE_*
729 + const TYPE_NOARG= 1;
730 + const TYPE_SINGLE= 2;
732 + const TYPE_OPTARG= 4;
733 + const TYPE_ROOT= 10;
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 */
743 + * Accepts args with no quotes ([tag=arg])
744 + * Cannot be disabled
746 + const ARG_NO_QUOTE=0;
748 + * Accepts args with double quotes ([tag="arg"])
750 + const ARG_DOUBLE_QUOTE=1;
752 + * Accepts args with single quotes ([tag='arg'])
753 + * one of the Double / Single quote is needed for subparsing
755 + const ARG_SINGLE_QUOTE=2;
758 + * Enable autocorrection of HTML By closing "still opened tags"
762 + public $auto_correct=true;
764 + * If tags are incorrectly nested, they are closed and reopened
765 + * after the previous tag close
769 + public $correct_reopen_tags=true;
771 + * Indicate wheter smileys are treated or not if no tag level
772 + * instructions override this
776 + public $default_smileys=true;
778 + * Indicates what styles of quotes are accepted
782 + public $quote_styles;
784 + * Disable BBCode Parsing
788 + public $noTreeBuild=false;
794 + public $force_smileys_off=false;
799 + * @var BBCode - if a specific parser is needed for argument parsing
801 + private $arg_parser=null;
804 + * The internal working Tree
810 + * Lists Levels to access the root level
815 + * An index to lists tags opened through the stack
818 + private $stackIndex;
823 + private $currentNode;
825 + * Lists of unclosed stack
830 + * An index to lists unclosed tag
833 + private $toCloseIndex;
836 + * The List of tags (external representation)
842 + * The List of tags (internal representation)
846 + private $tagListCache;
848 + * The index to map TagName to tagid
852 + private $tagListIndex;
854 + * The list of smileys
860 + private $close_time=0;
861 + private $add_time=0;
866 + * @param array $tag_init a list of BBCode for quick init
867 + * @param array $smileys_init a list of smileys for quick init
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;
875 + if (is_array($smileys_init)){
876 + $this->smileys=$smileys_init;
878 + $this->quote_styles=self::ARG_NO_QUOTE|self::ARG_DOUBLE_QUOTE|self::ARG_SINGLE_QUOTE;
882 + * Attach a parser as argument sub-parser
884 + * @param BBCode $bbcode_parser
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;
893 + * This function is there to add an individual tag to the list
895 + * @param string $tag_name
896 + * @param array $array
898 + public function add_element($tag_name,$array){
899 + $this->tagList[$tag_name]=$array;
900 + $this->tagListCache=null;
903 + * Adds an individual smiley to the list
905 + * @param string $smiley
906 + * @param string $replacement
908 + public function attach_smileys($smiley, $replacement){
909 + $this->smileys[$smiley]=$replacement;
913 + * Parse a string from BBCode following the rules given
915 + * @param String $string
918 + public function parse($string){
920 + $this->toCloseIndex=$this->toClose=$this->stackIndex=$this->stack=array();
922 + if ($this->noTreeBuild){
923 + $this->tree=array('i'=>$this->get_tag_id(''),'p'=>true,'s'=>'');
924 + $this->tree['c'][] = $string;
926 + $this->prepareTagList();
927 + // Tree construction
928 + $this->build_tree($string);
929 + // Tree corrections and fetch
930 + $this->correct_tree();
933 + return $this->apply_rules($this->tree);
937 + * Convert external representation of the taglist to internal
940 + private function prepareTagList(){
941 + if ($this->tagListCache!=null){
944 + if (!isset($this->tagList[''])){
945 + $this->tagList['']=array();
948 + // 1. Populate the tagListCache
950 + foreach($this->tagList as $tag=>$tag_datas){
952 + $this->tagListIndex[$tag]=$i;
963 + * 7 'content_handling'
964 + * 8 'content_handling_is_callback'
965 + * 9 'param_handling'
966 + * 10 'param_handling_is_callback'
968 + * 12 'accept_noarg'
969 + * 13 'start_has_bracket_open'
970 + * 14 'end_has_bracket_open'
971 + * 15 'accept_smileys'
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,
980 + isset($tag_datas['default_arg'])?$tag_datas['default_arg']:'',
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']:'',
986 + isset($tag_datas['param_handling'])?$tag['param_handling']:'',
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),
996 + // 2. Parse Child / Parents List
997 + foreach($this->tagListCache as $i=>$val){
999 + if ($val[6]=='all'){
1001 + } elseif ($val[6]==''){
1003 + } elseif ($val[6][0]=='!'){
1004 + $values=explode(',',substr($val[6],1));
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]);
1013 + $values=explode(',',$val[6]);
1014 + foreach ($values as $element){
1016 + if($tag_id=$this->get_tag_id($element)){
1017 + $val[6][]=$tag_id;
1022 + if ($val[5]=='all'){
1024 + } elseif ($val[5]==''){
1026 + } elseif ($val[5][0]=='!'){
1028 + $values=explode(',',substr($val[5],1));
1029 + foreach ($values as $element){
1031 + if($tag_id=$this->get_tag_id($element)){
1032 + $pos=array_search($val[5],$tag_id);
1033 + unset($val[5][$pos]);
1037 + $values=explode(',',$val[5]);
1038 + foreach ($values as $element){
1040 + if($tag_id=$this->get_tag_id($element)){
1041 + $val[5][]=$tag_id;
1045 + $this->tagListCache[$i]=$val;
1050 + * Build the tree representation of the given string
1052 + * @param string $string
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 ;
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));
1068 + if ($string[$offset]=='['){
1069 + if (($string[$offset+1])!='/'){
1072 + if ($next_equal<=$offset){
1073 + if (false===$next_equal=strpos($string,'=',$offset)){
1074 + $next_equal=$strlen+5;
1077 + if ($next_close<=$offset){
1078 + if (false===$next_close=strpos($string,']',$offset)){
1079 + $next_close=$strlen+5;
1082 + if ($next_close<$strlen){
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))){
1088 + if ($this->quote_styles>0){
1091 + if ($quote_single && $string[$next_equal+1]=="'"){
1093 + } elseif ($quote_double && $string[$next_equal+1]=='"') {
1096 + if ($end_quote==''){
1097 + $argument=substr($string,$next_equal+1,$next_close-$next_equal-1);
1099 + if (false!==$end=strpos($string,"$end_quote]",$next_equal+1)){
1100 + $argument=substr($string,$next_equal+2,$end++ - $next_equal - 2);
1106 + $argument=substr($string,$next_equal+1,$next_close-$next_equal-1);
1108 + if ($argument!==false){
1109 + $this->add_child(substr($string,$offset,$end-$offset+1),$tagId,$argument);
1117 + $tag=substr($string,$offset+1,$next_close-$offset-1);
1119 + if (false!==($tagId=$this->get_tag_id($tag,false))){
1120 + $this->add_child(substr($string,$offset,$end-$offset+1),$tagId);
1126 + if ($next_close<=$offset){
1127 + if (false===($next_close=strpos($string,']',$offset))){;
1128 + $next_close=$strlen+5;
1132 + $tag=substr($string,$offset+2,$next_close-$offset-2);
1134 + if (false!==($tagId=$this->get_tag_id($tag))){
1135 + $this->close_tag($tagId,substr($string,$offset,$end-$offset+1));
1141 + $end=strpos($string,'[',$offset+1);
1147 + $this->add_child(substr($string,$offset,$end-$offset+1));
1150 + } while($offset<$strlen);
1154 + * Adds a child to the tree
1156 + * @param string $string
1157 + * @param int $tagId
1158 + * @param string $argument
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;
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);
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);
1182 + // Close last element
1183 + $this->close_tag($tagId,'');
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,'');
1202 + * @param int $tag_id
1203 + * @param string $string
1204 + * @param boolean $true_close
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)){
1217 + if ($this->currentNode['i']==$tag_id){
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;
1226 + if (!$true_close){
1227 + $this->toClose[] =& $this->currentNode;
1230 + if (!in_array($tag_id,$this->tagListCache[$this->currentNode['i']][6])){
1231 + $conds[] =& $this->currentNode;
1233 + $this->currentNode['cs']='';
1234 + if ($this->tagListCache[$this->currentNode['i']][4]&BBCode::FLAGS_ONE_OPEN_PER_LEVEL){
1235 + $this->currentNode['p'] = true;
1237 + $this->currentNode['p'] = false;
1238 + $this->toClose[] =& $this->currentNode;
1239 + $this->toCloseIndex[] = $this->currentNode['i'];
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]);
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'],
1261 + if (isset($this->toClose[$i]['a'])){
1262 + $new_node[$i]['a']=$this->toClose[$i]['a'];
1264 + $new_node[$i]['mp'][] =& $new_node;
1265 + for ($j=$i-1;$j>=0;--$j){
1266 + $new_node[$i]['par'][] =& $this->toClose[$j];
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'];
1273 + $this->toCloseIndex=$this->toClose=array();
1277 + $this->add_child($string);
1281 + * Validates a tree and applying Childs / Parent Rules
1283 + * @param array $tree
1284 + * @param int $parent
1285 + * @param boolean $force_false
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;
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;
1306 + if ($force_false){
1307 + /* if force_false is enabled, unpair tags */
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 */
1313 + if (!$ac && !$tree['p']){
1314 + /* If no auto_correction neither pairing, force false */
1315 + $force_false=true;
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']){
1327 + /* If one condition is paired, this element can not exists */
1332 + /* Forcing child_list presence */
1333 + if (!isset($tree['c'])){
1334 + $tree['c']= array();
1336 + /* Browsing child_list for corrections */
1337 + for($i=0; $i<count($tree['c']);++$i){
1338 + $child =& $tree['c'][$i];
1340 + if (is_array($child)){
1341 + /* If the child is a multipart and not done */
1342 + if (isset($child['mp']) && !$child['d']){
1344 + foreach($child['mp'] as $child_part){
1345 + /* TODO Comments */
1346 + if (is_array($child_part)){
1347 + if (!isset($child_part['i'])){
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']){
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])){
1372 + /* Mark Child as done */
1374 + /* If no autocorrection & unpaired */
1375 + if (!$ac && !$tree['p']){
1377 + $force_false=true;
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);
1386 + /* The tag can not be a subelement of this one */
1387 + $return =& $this->correct_tree($child, $parent, true);
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);
1393 + /* The tag cannot be a subelement of this one */
1394 + $return =& $this->correct_tree($child, $parent, true);
1396 + /* Appending return(s) to new_tree */
1397 + array_splice($new_tree, count($new_tree), 0, $return);
1400 + $new_tree[] =& $child;
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;
1409 + if ($restore_tree){
1410 + $tree['c'] =& $new_tree;
1412 + return array(&$tree);
1415 + /* If force false or no autocorrection and unpaired tag */
1416 + if ($force_false){
1417 + /* If force false flag is set, force unpair */
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'];
1425 + if ($restore_tree){
1426 + $this->tree =& $new_tree;
1433 + * Apply the ruleset to transform BBCode tree to Markup
1435 + * @param array $tree
1438 + private function apply_rules($tree){
1439 + //Fetch datas locally - Performance
1440 + $default_smileys=$this->default_smileys;
1441 + $auto_correct=$this->auto_correct;
1444 + if (isset($tree['i'])){
1445 + $tag=$this->tagListCache[$tree['i']];
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];
1457 + for ($k=0;$k<count($tree['c'][$j]['c']);++$k){
1458 + $tree['c'][$i]['c'][] =& $tree['c'][$j]['c'][$k];
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);
1466 + unset($tree['c'][$j]['mp'][0]['ref_test_key']);
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);
1480 + $string.=$last_string;
1483 + $string.=$this->apply_rules($child);
1486 + //Concat String for Smiley treatment
1487 + $last_string.=$child;
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);
1495 + $string.=$last_string;
1498 + if (!($auto_correct || $tree['p'] || ($tag[4]&BBCode::FLAGS_ONE_OPEN_PER_LEVEL))){
1499 + return ($tree['s']).$string;
1506 + if ($tree['a']!=''){
1511 + if ($tag[4] & BBCode::FLAGS_ARG_PARSING){
1512 + if ($this->arg_parser!==null){
1513 + $arg=$this->arg_parser->parse($arg);
1515 + $arg=$this->parse($arg);
1519 + /* Search For CallBacks */
1520 + if ($cb=$this->get_callback($tree['i'],true)){
1521 + $arg=$cb($string,$arg);
1523 + if ($cb=$this->get_callback($tree['i'],false)){
1524 + $string=$cb($string,$arg);
1526 + /* Replacing {ARG} by $arg and {CONTENT} by $string in arg & start */
1527 + $arg =str_replace("{CONTENT}",$string,$arg);
1529 + $start=str_replace("{CONTENT}",$string,$start);
1530 + $start=str_replace("{ARG}",$arg,$start);
1533 + /* Replacing {ARG} by $arg in string & end */
1534 + $string =str_replace("{ARG}",$arg,$string);
1536 + $end=str_replace("{ARG}",$arg,$end);
1539 + return $start.$string.$end;
1543 + * Returns a callback for a tag_id
1545 + * @param int $tagid
1546 + * @param bolean $is_arg
1547 + * @return callback
1549 + private function get_callback($tagid,$is_arg){
1550 + $tag = $this->tagListCache[$tagid];
1552 + if ($tag[10]===null){
1553 + $this->tagListCache[$tagid][10]=is_callable($tag[9])?$tag[9]:false;
1555 + return $this->tagListCache[$tagid][10];
1557 + if ($tag[8]===null){
1558 + $this->tagListCache[$tagid][8]=is_callable($tag[7])?$tag[7]:false;
1560 + return $this->tagListCache[$tagid][8];
1566 + * @param string $smileys
1569 + private function smileys($string){
1570 + $keys=array_keys($this->smileys);
1571 + return str_replace($keys,$this->smileys,$string);
1574 + * Returns a tag_id from his name (tag_id is internal)
1576 + * @param string $tag_name
1577 + * @param boolean $has_args
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){
1586 + } elseif ($has_arg===false){
1587 + if ($this->tagListCache[$tag_id][12]===true){
1591 + if ($this->tagListCache[$tag_id][11]===true){
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'=>'"> </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 />'),
1638 +$bbcode=new BBCode($arrayBBCode,array(':)'=>'\\o/',':|'=>'/o\\'));
1639 +$bbcode->auto_correct=false;
1640 +$bbcode->correct_reopen_tags=true;
1641 +$time=microtime(true);
1643 +[list][*]List[list][*]SubList[/list][/list]
1645 +echo $bbcode->parse($string)."\n";
1646 +$val[]=microtime(true)-$time;
1647 +echo (microtime(true)-$time)."\n";
1648 +$time=microtime(true);
1650 +UUU[quote="[u]:) :|UUU[/u]"][b]:)Te[b]st[/b][/quote]AAAAA
1653 +[*][list=a][*]Coucou
1657 +echo $bbcode->parse($string)."\n";
1658 +$val[]=microtime(true)-$time;
1659 +echo (microtime(true)-$time)."\n";
1660 +$time=microtime(true);
1662 +[b][u]Hello[/b] W[i]o[b]r [b]ld[/u] Coucou[/i] Vro[/b] Vroum
1664 +echo $bbcode->parse($string)."\n";
1665 +$val[]=microtime(true)-$time;
1666 +echo (microtime(true)-$time)."\n";
1667 +$time=microtime(true);
1669 +[list][*]List[list][*]SubList[*]element2[list][*]SubSubList[/list][/list][*]element 3[/list]
1671 +echo $bbcode->parse($string)."\n";
1672 +$val[]=microtime(true)-$time;
1673 +echo (microtime(true)-$time)."\n";
1674 +$time=microtime(true);
1676 +[list][*]List[list][*]SubList[/list][/list]
1678 +echo $bbcode->parse($string)."\n";
1679 +$val[]=microtime(true)-$time;
1680 +echo (microtime(true)-$time)."\n";
1681 +$time=microtime(true);
1683 +[b]Test[u]Test[b] [i] Glup [u] [*][*][barre][i]Glop[/i] [/u][/i]Zop[/b] [/u][/b]
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;
1692 +[b][i] [code] [u][/i][/b][b][/u] [/code] [u] Test [/b][/u]
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
1700 Property changes on: bbcode.php
1701 ___________________________________________________________________
1702 Added: svn:eol-style
1705 + Id Rev Revision Date LastChangedDate LastChangedRevision Author LastChangedBy HeadURL URL
1706 Added: cvs2svn:cvs-rev
1710 ===================================================================
1711 --- config.m4 (.../tags/RELEASE_1_0_2)
1712 +++ config.m4 (.../trunk)
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")
1723 Property changes on: config.m4
1724 ___________________________________________________________________
1725 Modified: cvs2svn:cvs-rev
1729 Index: lib/bbcode2.c
1730 ===================================================================
1731 --- lib/bbcode2.c (.../tags/RELEASE_1_0_2)
1732 +++ lib/bbcode2.c (.../trunk)
1734 /* Parse a BBCoded string to is treated equivalent */
1735 char *bbcode_parse(bbcode_parser_p parser, char *string, int string_size,
1737 + char *return_value;
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));
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);
1753 /* Prepare Datas for smiley */
1754 @@ -115,12 +118,14 @@
1755 /* Smiley Parsing */
1756 bbcode_parse_smileys(to_parse, parser->smileys);
1758 + /* starting the tree */
1759 + bbcode_parse_tree_p tree = bbcode_tree_create();
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();
1768 /* Preparing tag_list if needed */
1769 bbcode_prepare_tag_list(parser);
1770 /* Build the BBCode Tree from the string */
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);
1781 struct bstrList *bsplited;
1782 char accept_smileys;
1783 char default_smileys;
1787 if (parser->options & BBCODE_FORCE_SMILEYS_OFF) {
1790 if (parser->options & BBCODE_DEFAULT_SMILEYS_ON) {
1796 list=parser->bbcodes;
1797 /* Resolve cache preparation */
1798 @@ -211,8 +218,11 @@
1799 list->search_cache[i]=NULL;
1801 for (i=0; i<bbcode_array_length(list->bbcodes); i++) {
1803 + bbcode_search temp;
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));
1812 list->search_cache[slen]=(bbcode_search_p) realloc(
1813 list->search_cache[slen], sizeof(bbcode_search) * (list->num_cache[slen]+1));
1815 - bbcode_search temp;
1817 temp.tag_name=bbcode->tag;
1819 list->search_cache[slen][list->num_cache[slen]]=temp;
1822 list->root->childs->type=BBCODE_ALLOW_LIST_TYPE_ALL;
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;
1830 /* We add all entries */
1831 bsplited=bsplit (work, ',');
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);
1839 bbcode->parents->type=BBCODE_ALLOW_LIST_TYPE_ALL;
1843 bstring work = bstrcpy(bbcode->parent_list);
1844 if (bchar(bbcode->parent_list, 0) == '!') {
1845 bbcode->parents->type=BBCODE_ALLOW_LIST_TYPE_EXCLUDE;
1848 /* We add all entries */
1849 bsplited=bsplit (work, ',');
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);
1857 bbcode->childs->type=BBCODE_ALLOW_LIST_TYPE_ALL;
1861 bstring work=bstrcpy(bbcode->child_list);
1862 if (bchar(bbcode->child_list, 0) == '!') {
1863 bbcode->childs->type=BBCODE_ALLOW_LIST_TYPE_EXCLUDE;
1866 /* We add all entries */
1867 bsplited=bsplit (work, ',');
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);
1874 int offset, end, next_equal, next_close, string_length;
1876 int quote_enabled=(quote_double || quote_single || quote_html);
1877 + bbcode_parse_tree_array_p work_stack = NULL, close_stack = NULL;
1879 string_length=blength(string);
1880 tag_id=end=next_equal=next_close=0;
1881 end_double=bfromcstr("\"]");
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 @@
1893 if (quote_enabled) {
1900 if (quote_single && bchar(string, next_equal+1)
1902 end_quote=end_single;
1905 /* No Ending Quote, go to next tag */
1906 end=next_equal+diff;
1907 - bdestroy(argument);
1921 long parent_id, char force_false) {
1922 int autocorrect, orig_parent, ret;
1924 + bbcode_parse_tree_child_p child = NULL;
1926 bbcode_p tag= bbcode_get_bbcode(parser,tree->tag_id);
1928 autocorrect = parser->options & BBCODE_AUTO_CORRECT;
1933 - bbcode_parse_tree_child_p child = NULL;
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;
1942 + bbcode_parse_tree_p to_drop = NULL;
1943 + bstring arg, content;
1945 last_string=bfromcstr("");
1946 tmp_string=bfromcstr("");
1947 working_string=bfromcstr("");
1948 /* Dropped elements */
1949 - bbcode_parse_tree_p to_drop = NULL;
1951 to_drop=bbcode_tree_create();
1952 - bstring arg, content;
1955 /* Multipart Merging */
1956 for (i=0 ; i < tree->childs.size; i++) {
1957 @@ -977,14 +999,16 @@
1962 + long right=count-1;
1966 bstring lower_tag = NULL;
1967 lower_tag=bstrcpy(value);
1968 btolower(lower_tag);
1969 /* We start true binary */
1971 - long right=count-1;
1976 equal=bstrcmp(lower_tag, list[i].tag_name);
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) {
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) {
1997 for(i=index;i<stack->size;i++){
1998 stack->element[i]=stack->element[i+1];
2001 Property changes on: lib/bbcode2.c
2002 ___________________________________________________________________
2003 Modified: cvs2svn:cvs-rev
2007 Index: lib/bbcode2.h
2008 ===================================================================
2009 --- lib/bbcode2.h (.../tags/RELEASE_1_0_2)
2010 +++ lib/bbcode2.h (.../trunk)
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) \
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); \
2025 Property changes on: lib/bbcode2.h
2026 ___________________________________________________________________
2027 Modified: cvs2svn:cvs-rev
2032 Property changes on: lib
2033 ___________________________________________________________________
2067 scan_makefile_in.awk
2083 run-tests-config.php
2088 ===================================================================
2089 --- php_bbcode.c (.../tags/RELEASE_1_0_2)
2090 +++ php_bbcode.c (.../trunk)
2092 +----------------------------------------------------------------------+
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 |
2101 +----------------------------------------------------------------------+
2102 | Author: Xavier De Cock <void@php.net> |
2103 +----------------------------------------------------------------------+
2110 #ifdef HAVE_CONFIG_H
2114 #include "lib/bbcode2.h"
2115 #include "lib/bstrlib.h"
2118 -typedef struct _bbcode_object {
2123 +static 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}
2136 +#define PHP_BBCODE_CONTENT_CB 1
2137 +#define PHP_BBCODE_PARAM_CB 2
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}
2150 -zend_module_entry bbcode_module_entry = {
2151 -#if ZEND_MODULE_API_NO >= 20010901
2152 - STANDARD_MODULE_HEADER,
2154 - PHP_BBCODE_EXTNAME,
2156 - PHP_MINIT(bbcode),
2160 - PHP_MINFO(bbcode),
2161 -#if ZEND_MODULE_API_NO >= 20010901
2162 - PHP_BBCODE_VERSION,
2164 - STANDARD_MODULE_PROPERTIES
2167 -#ifdef COMPILE_DL_BBCODE
2168 -ZEND_GET_MODULE(bbcode)
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)
2178 zval *retval = NULL;
2179 zval ***zargs = NULL;
2181 + char *callable = NULL;
2183 - char *callable = NULL, *errbuf=NULL;
2184 - funcname = ((zval **) datas);
2186 + char *cb_name = "";
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);
2195 + switch (cb_type) {
2196 + case PHP_BBCODE_CONTENT_CB:
2200 + case PHP_BBCODE_PARAM_CB:
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);
2210 - res = call_user_function_ex(EG(function_table), NULL, *funcname, &retval, 2, zargs, 1, NULL TSRMLS_CC);
2212 - if (res == SUCCESS) {
2214 - for (i = 0; i < 2; i++) {
2215 - zval_ptr_dtor(zargs[i]);
2219 + res = call_user_function_ex(EG(function_table), NULL, func_name, &retval, 2, zargs, 1, NULL TSRMLS_CC);
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);
2225 + php_error_docref(NULL TSRMLS_CC, E_WARNING, "callback function %s() failed", callable);
2228 - zend_error(E_WARNING, "[BBCode] (_php_bbcode_handling_content) call_user_function_ex failed for function %s()", 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));
2240 - bdelete(content,0,blength(content));
2241 + bdelete(target, 0, blength(target));
2243 zval_ptr_dtor(&retval);
2247 + for (i = 0; i < 2; i++) {
2248 + zval_ptr_dtor(zargs[i]);
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;
2262 - char *callable = NULL, *errbuf=NULL;
2263 - funcname = ((zval **) datas);
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);
2273 +/* {{{ _php_bbcode_content_handler */
2274 +static int _php_bbcode_content_handler(bstring content, bstring param, void *func_data)
2276 + return _php_bbcode_callback_handler(PHP_BBCODE_CONTENT_CB, content, param, func_data);
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);
2288 - res = call_user_function_ex(EG(function_table), NULL, *funcname, &retval, 2, zargs, 1, NULL TSRMLS_CC);
2290 - if (res == SUCCESS) {
2292 - for (i = 0; i < 2; i++) {
2293 - zval_ptr_dtor(zargs[i]);
2299 - zend_error(E_WARNING, "[BBCode] (_php_bbcode_handling_param) call_user_function_ex failed for function %s()", callable);
2303 - convert_to_string_ex(&retval);
2304 - if(Z_STRLEN_P(retval)){
2305 - bassignblk(param,Z_STRVAL_P(retval), Z_STRLEN_P(retval));
2307 - bdelete(param,0,blength(param));
2309 - zval_ptr_dtor(&retval);
2312 +/* {{{ _php_bbcode_param_handler */
2313 +static int _php_bbcode_param_handler(bstring content, bstring param, void *func_data)
2315 + return _php_bbcode_callback_handler(PHP_BBCODE_PARAM_CB, content, param, func_data);
2317 -/* End User function Callback */
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) {
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)
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;
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;
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;
2357 - if (Z_TYPE_P(content) == IS_ARRAY) {
2358 - ht = HASH_OF(content);
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;
2367 + if (Z_TYPE_P(content) == IS_ARRAY) {
2368 + ht = HASH_OF(content);
2370 - if ((SUCCESS == zend_hash_find(ht, "type", sizeof("type"), (void *) &e))
2371 - && (Z_TYPE_PP(e) == IS_LONG)) {
2374 + if ((SUCCESS == zend_hash_find(ht, "flags", sizeof("flags"), (void *) &e)) &&
2375 + (Z_TYPE_PP(e) == IS_LONG)
2377 + flags = Z_LVAL_PP(e);
2381 + if ((SUCCESS == zend_hash_find(ht, "type", sizeof("type"), (void *) &e)) &&
2382 + (Z_TYPE_PP(e) == IS_LONG)
2384 type = Z_LVAL_PP(e);
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);
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)) {
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)
2397 open_tag = Z_STRVAL_PP(e);
2398 - open_tag_len=Z_STRLEN_PP(e);
2399 + open_tag_len = Z_STRLEN_PP(e);
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)) {
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)
2411 close_tag = Z_STRVAL_PP(e);
2412 - close_tag_len=Z_STRLEN_PP(e);
2413 + close_tag_len = Z_STRLEN_PP(e);
2416 + close_tag = empty;
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)) {
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)
2425 default_arg = Z_STRVAL_PP(e);
2426 default_arg_len = Z_STRLEN_PP(e);
2428 default_arg = empty;
2430 - if ((SUCCESS == zend_hash_find(ht, "content_handling", sizeof("content_handling"), (void *) &e))) {
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))
2437 if (Z_TYPE_PP(e) != IS_STRING && Z_TYPE_PP(e) != IS_ARRAY){
2439 convert_to_string_ex(e);
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);
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);
2450 - content_handling = e;
2451 -#if (PHP_MAJOR_VERSION >= 5) && (PHP_MINOR_VERSION >= 3)
2452 - Z_ADDREF_P(*content_handling);
2454 - ZVAL_ADDREF(*content_handling);
2456 - content_handling_func= _php_bbcode_handling_content;
2457 + efree(callback_name);
2458 + content_handling = *e;
2459 + content_handling_func = _php_bbcode_content_handler;
2461 - content_handling=NULL;
2462 + content_handling_func = NULL;
2463 + content_handling = NULL;
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))) {
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))
2473 if (Z_TYPE_PP(e) != IS_STRING && Z_TYPE_PP(e) != IS_ARRAY){
2475 convert_to_string_ex(e);
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);
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);
2486 - param_handling = e;
2487 -#if (PHP_MAJOR_VERSION >= 5) && (PHP_MINOR_VERSION >= 3)
2488 - Z_ADDREF_P(*param_handling);
2490 - ZVAL_ADDREF(*param_handling);
2492 - param_handling_func= _php_bbcode_handling_param;
2493 + efree(callback_name);
2494 + param_handling = *e;
2495 + param_handling_func = _php_bbcode_param_handler;
2497 + param_handling_func = NULL;
2498 + param_handling = NULL;
2500 - if ((SUCCESS == zend_hash_find(ht, "childs", sizeof("childs"), (void *) &e))
2501 - && (Z_TYPE_PP(e) == IS_STRING)) {
2504 + if ((SUCCESS == zend_hash_find(ht, "childs", sizeof("childs"), (void *) &e)) &&
2505 + (Z_TYPE_PP(e) == IS_STRING)
2507 childs = Z_STRVAL_PP(e);
2508 childs_len = Z_STRLEN_PP(e);
2510 - if ((SUCCESS == zend_hash_find(ht, "parents", sizeof("parents"), (void *) &e))
2511 - && (Z_TYPE_PP(e) == IS_STRING) && Z_STRLEN_PP(e)) {
2514 + if ((SUCCESS == zend_hash_find(ht, "parents", sizeof("parents"), (void *) &e)) &&
2515 + (Z_TYPE_PP(e) == IS_STRING) && Z_STRLEN_PP(e)
2517 parents = Z_STRVAL_PP(e);
2518 parents_len = Z_STRLEN_PP(e);
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
2544 -ZEND_RSRC_DTOR_FUNC(php_bbcode_dtor)
2546 +/* {{{ Resource destructor */
2547 +static ZEND_RSRC_DTOR_FUNC(php_bbcode_dtor)
2549 - bbcode_parser_p parser = (bbcode_parser_p)rsrc->ptr;
2551 - bbcode_parser_free(parser);
2553 + bbcode_parser_p parser = (bbcode_parser_p)rsrc->ptr;
2555 + bbcode_parser_free(parser);
2558 -/* End destructors */
2559 -/* INIT / SHUTDOWN */
2560 -PHP_MINIT_FUNCTION(bbcode)
2563 +/* {{{ Module INIT / SHUTDOWN */
2564 +static PHP_MINIT_FUNCTION(bbcode)
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);
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);
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 */
2585 + /* Parser Flags */
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);
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 */
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);
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);
2613 -/* END INIT/SHUTDOWN */
2618 - * Working on it, not finished yet
2620 -static void _php_bbcode_object_free_storage(void *object TSRMLS_DC){
2621 +typedef struct _bbcode_object {
2626 +/* {{{ TODO: Not finished yet! */
2627 +static void _php_bbcode_object_free_storage(void *object TSRMLS_DC)
2629 bbcode_object *intern = (bbcode_object *)object;
2634 zend_object_std_dtor(&intern->std TSRMLS_CC);
2636 bbcode_container *container;
2639 if (intern->rsrc_id) {
2640 ALLOC_INIT_ZVAL(pointer);
2641 ALLOC_INIT_ZVAL(return_value);
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);
2655 @@ -397,120 +360,130 @@
2657 retval->handlers = handlers;
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)
2672 - zval *bbcode_entry=NULL;
2673 + zval *bbcode_entry = NULL;
2674 bbcode_parser_p parser = NULL;
2677 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a", &bbcode_entry) == FAILURE) {
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");
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){
2690 - HashTable *myht=NULL;
2692 - if (Z_TYPE_P(bbcode_entry) == IS_ARRAY) {
2693 - myht = HASH_OF(bbcode_entry);
2696 - i = myht ? zend_hash_num_elements(myht) : 0;
2703 - HashTable *tmp_ht;
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");
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);
2714 + /* If array given initialisation */
2715 + if (bbcode_entry != NULL) {
2717 + HashTable *myht = NULL;
2719 + if (Z_TYPE_P(bbcode_entry) == IS_ARRAY) {
2720 + myht = HASH_OF(bbcode_entry);
2723 + i = myht ? zend_hash_num_elements(myht) : 0;
2730 + HashTable *tmp_ht;
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)
2739 - if (zend_hash_get_current_data_ex(myht, (void **) &data, &pos) == SUCCESS) {
2740 - tmp_ht = HASH_OF(*data);
2742 - tmp_ht->nApplyCount++;
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) {
2752 + if (zend_hash_get_current_data_ex(myht, (void **) &data, &pos) == SUCCESS) {
2753 + tmp_ht = HASH_OF(*data);
2755 + tmp_ht->nApplyCount++;
2757 + if (i == HASH_KEY_IS_STRING) {
2758 /* Add Element to container */
2759 - _php_bbcode_add_element(parser,key,*data TSRMLS_CC);
2762 - tmp_ht->nApplyCount--;
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);
2773 + tmp_ht->nApplyCount--;
2780 + /* Register resource and return it */
2781 + ZEND_REGISTER_RESOURCE(return_value, parser, le_bbcode);
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:
2788 - * 'type' => Type of the tag (view BBCODE_TYPE_* to view available tags)
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
2800 -PHP_FUNCTION(bbcode_add_element)
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)
2806 zval *z_bbcode_parser;
2808 - bbcode_parser_p parser=NULL;
2809 + bbcode_parser_p parser = NULL;
2813 - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsa", &z_bbcode_parser, &tag_name, &tag_len, &bbcode_entry) == FAILURE) {
2818 + /* tag_definition is an array with these elements:
2821 + o 'type' => Type of the tag (view BBCODE_TYPE_* to view available tags)
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
2833 + [1] note that the {CONTENT} string is automatically replaced by the content of the tag and {PARAM} by the parameter
2836 + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsa", &z_bbcode_parser, &tag_name, &tag_name_len, &bbcode_entry) == FAILURE) {
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);
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)
2853 zval *z_bbcode_parser;
2856 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &z_bbcode_parser) == FAILURE) {
2863 RETURN_BOOL(zend_list_delete(Z_LVAL_P(z_bbcode_parser)) == SUCCESS);
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)
2873 zval *z_bbcode_parser;
2874 bbcode_parser_p parser;
2875 @@ -518,101 +491,165 @@
2881 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &z_bbcode_parser, &string, &str_len) == FAILURE) {
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);
2892 + /* convert string for bbcode_parse_string usage */
2893 + ret_string = bbcode_parse(parser, string, str_len, &ret_size);
2895 RETVAL_STRINGL(ret_string, ret_size , 1);
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)
2906 zval *z_bbcode_parser;
2907 char *search, *replace;
2909 - bbcode_parser_p parser=NULL;
2911 + bbcode_parser_p parser = NULL;
2913 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss", &z_bbcode_parser, &search, &s_len, &replace, &r_len) == FAILURE) {
2920 ZEND_FETCH_RESOURCE(parser, bbcode_parser_p, &z_bbcode_parser, -1, PHP_BBCODE_RES_NAME, le_bbcode);
2923 bbcode_parser_add_smiley(parser, search, s_len, replace, r_len);
2924 RETURN_BOOL(SUCCESS);
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)
2934 zval *z_bbcode_parser;
2939 bbcode_parser_p parser=NULL;
2942 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|l", &z_bbcode_parser, &new_flags, &mode) == FAILURE) {
2949 ZEND_FETCH_RESOURCE(parser, bbcode_parser_p, &z_bbcode_parser, -1, PHP_BBCODE_RES_NAME, le_bbcode);
2951 - flags=bbcode_parser_get_flags(parser);
2954 + flags = bbcode_parser_get_flags(parser);
2957 case BBCODE_SET_FLAGS_ADD:
2958 bbcode_parser_set_flags(parser, flags | new_flags);
2962 case BBCODE_SET_FLAGS_REMOVE:
2963 bbcode_parser_set_flags(parser, flags & (~new_flags));
2968 case BBCODE_SET_FLAGS_SET:
2969 bbcode_parser_set_flags(parser, new_flags);
2975 RETURN_BOOL(SUCCESS);
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)
2985 zval *z_bbcode_parser;
2986 zval *z_bbcode_parser_child;
2987 - bbcode_parser_p parser=NULL;
2988 - bbcode_parser_p arg_parser=NULL;
2990 + bbcode_parser_p parser = NULL;
2991 + bbcode_parser_p arg_parser = NULL;
2993 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr", &z_bbcode_parser, &z_bbcode_parser_child) == FAILURE) {
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);
3003 + bbcode_parser_set_arg_parser(parser, arg_parser);
3005 RETURN_BOOL(SUCCESS);
3009 -/*** Module Infos ***/
3010 -PHP_MINFO_FUNCTION(bbcode)
3011 +/* {{{ Module Info */
3012 +static PHP_MINFO_FUNCTION(bbcode)
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();
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}
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}
3052 +zend_module_entry bbcode_module_entry = {
3053 +#if ZEND_MODULE_API_NO >= 20010901
3054 + STANDARD_MODULE_HEADER,
3056 + PHP_BBCODE_EXTNAME,
3058 + PHP_MINIT(bbcode),
3062 + PHP_MINFO(bbcode),
3063 +#if ZEND_MODULE_API_NO >= 20010901
3064 + PHP_BBCODE_VERSION,
3066 + STANDARD_MODULE_PROPERTIES
3069 +#ifdef COMPILE_DL_BBCODE
3070 +ZEND_GET_MODULE(bbcode)
3074 + * Local variables:
3076 + * c-basic-offset: 4
3078 + * vim600: noet sw=4 ts=4 fdm=marker
3079 + * vim<600: noet sw=4 ts=4
3082 Property changes on: php_bbcode.c
3083 ___________________________________________________________________
3084 Modified: cvs2svn:cvs-rev
3089 ===================================================================
3090 --- php_bbcode.h (.../tags/RELEASE_1_0_2)
3091 +++ php_bbcode.h (.../trunk)
3093 +----------------------------------------------------------------------+
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 |
3102 +----------------------------------------------------------------------+
3103 | Author: Xavier De Cock <void@php.net> |
3104 +----------------------------------------------------------------------+
3111 #ifndef PHP_BBCODE_H
3112 -#define PHP_BBCODE_H 1
3113 +#define PHP_BBCODE_H
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"
3120 #define BBCODE_SET_FLAGS_SET 0
3121 #define BBCODE_SET_FLAGS_ADD 1
3122 #define BBCODE_SET_FLAGS_REMOVE 2
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);
3134 extern zend_module_entry bbcode_module_entry;
3135 #define phpext_bbcode_ptr &bbcode_module_entry
3137 -#define PHP_BBCODE_RES_NAME "BBCode resource"
3142 + * Local variables:
3144 + * c-basic-offset: 4
3146 + * vim600: noet sw=4 ts=4 fdm=marker
3147 + * vim<600: noet sw=4 ts=4
3150 Property changes on: php_bbcode.h
3151 ___________________________________________________________________
3152 Modified: cvs2svn:cvs-rev
3157 Property changes on: .
3158 ___________________________________________________________________
3192 scan_makefile_in.awk
3208 run-tests-config.php