3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
6 * Copyright (c) 2001-2019 *
7 * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
9 * Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
10 * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
11 \***************************************************************************/
13 if (!defined('_ECRIRE_INC_VERSION')) {
17 // Les fonctions de ce fichier sont appelees en certains points
18 // de l'analyseur syntaxique afin de normaliser de vieilles syntaxes,
19 // pour fournir au compilateur un arbre de syntaxe abstraite homogene
21 // Cas des pseudos filtres |fichier et |lien qui donnent le chemin du fichier
22 // et son URL, remplaces par ** et *: LOGO_XXX** et LOGO_XXX*
23 // Il y a aussi le futur attribut align et l'ecriture #LOGO|#URL
24 // qui passent en arguments de la balise: #LOGO{left,#URL...}
25 // -> http://www.spip.net/fr_article901.html
27 function phraser_vieux_logos(&$p) {
28 if ($p->param
[0][0]) {
31 $args = array_shift($p->param
);
34 foreach ($p->param
as $couple) {
35 $nom = trim($couple[0]);
37 array_shift($p->param
);
40 $r = phraser_logo_faux_filtres($nom);
45 array_shift($p->param
);
46 spip_log("filtre de logo obsolete $nom", 'vieilles_defs');
49 array_shift($p->param
);
50 spip_log("filtre de logo obsolete $nom", 'vieilles_defs');
52 array_shift($p->param
);
54 spip_log("filtre de logo obsolete $nom", 'vieilles_defs');
56 } elseif (preg_match("/^" . NOM_DE_CHAMP
. '(.*)$/sS', $nom, $m)) {
58 $champ->nom_boucle
= $m[2];
59 $champ->nom_champ
= $m[3];
60 $champ->etoile
= $m[5];
61 $champ = array($champ);
68 array_shift($p->param
);
69 spip_log("filtre de logo obsolete $nom", 'vieilles_defs');
71 } // le cas else est la seule incompatibilite
74 array_unshift($p->param
, $args);
78 function phraser_logo_faux_filtres($nom) {
96 // La balise embed_document est a present le modele emb
98 function phraser_vieux_emb(&$p) {
99 if (!is_array($p->param
)) {
103 // Produire le premier argument {emb}
105 $texte->texte
= 'emb';
106 $param = array('', array($texte));
108 // Transformer les filtres en arguments
109 for ($i = 0; $i < count($p->param
); $i++
) {
110 if ($p->param
[$i][0]) {
111 if (!strstr($p->param
[$i][0], '=')) {
113 }# on a rencontre un vrai filtre, c'est fini
115 $texte->texte
= $p->param
[$i][0];
116 $param[] = array($texte);
118 array_shift($p->param
);
120 array_unshift($p->param
, $param);
121 spip_log('balise EMBED_DOCUMENT obsolete', 'vieilles_defs');
122 $p->nom_champ
= 'MODELE';
125 // Vieux formulaire de recherch
127 function phraser_vieux_recherche($p) {
128 if ($p->param
[0][0]) {
130 $c->texte
= $p->param
[0][0];
131 $p->param
[0][1] = array($c);
132 $p->param
[0][0] = '';
133 $p->fonctions
= array();
134 spip_log('FORMULAIRE_RECHERCHE avec filtre ' . $c->texte
, 'vieilles_defs');
138 // Gerer la notation [(#EXPOSER|on,off)]
139 function phraser_vieux_exposer($p) {
140 if ($a = $p->fonctions
) {
141 preg_match("#([^,]*)(,(.*))?#", $a[0][0], $regs);
145 $a->texte
= $regs[1];
146 $args = array('', array($a));
149 $a->texte
= $regs[3];
153 $p->param
[0] = $args;
154 $p->fonctions
= array();
155 $p->nom_champ
= 'EXPOSE';
159 function phraser_vieux_modele($p) { normaliser_args_inclumodel($p); }
161 function phraser_vieux_inclu($p) { normaliser_args_inclumodel($p); }
163 function normaliser_args_inclumodel($p) {
172 array_shift($p->param
);
173 foreach ($p->param
as $l) {
174 if (!array_shift($l)) {
175 $args = array_merge($args, $l);
176 array_shift($p->param
);
181 array_unshift($p->param
, $args);
184 function normaliser_inclure($champ) {
185 normaliser_args_inclumodel($champ);
186 $l = $champ->param
[0];
187 if (is_array($l) and !$l[0]) {
188 foreach ($l as $k => $p) {
189 if ($p and $p[0]->type
== 'texte' and !strpos($p[0]->texte
, '=')) {
190 $p[0]->texte
= trim($p[0]->texte
);
193 foreach ($l as $k => $p) {
194 if (!$p or $p[0]->type
!= 'texte' or
195 !preg_match('/^fond\s*=\s*(.*)$/', $p[0]->texte
, $r)
201 $p[0]->texte
= $r[1];
206 unset($champ->param
[0][$k]);
207 if (count($champ->param
[0]) == 1) {
208 array_shift($champ->param
);
214 spip_log("inclure sans fond ni fichier");