3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
6 * Copyright (c) 2001-2016 *
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')) return;
15 // Les fonctions de ce fichier sont appelees en certains points
16 // de l'analyseur syntaxique afin de normaliser de vieilles syntaxes,
17 // pour fournir au compilateur un arbre de syntaxe abstraite homogene
19 // Cas des pseudos filtres |fichier et |lien qui donnent le chemin du fichier
20 // et son URL, remplaces par ** et *: LOGO_XXX** et LOGO_XXX*
21 // Il y a aussi le futur attribut align et l'ecriture #LOGO|#URL
22 // qui passent en arguments de la balise: #LOGO{left,#URL...}
23 // -> http://www.spip.net/fr_article901.html
25 function phraser_vieux_logos(&$p)
30 $args = array_shift($p->param
);
33 foreach($p->param
as $couple) {
34 $nom = trim($couple[0]);
35 if ($nom == '') {array_shift($p->param
); break;}
36 $r = phraser_logo_faux_filtres($nom);
41 array_shift($p->param
);
42 spip_log("filtre de logo obsolete $nom", 'vieilles_defs');
45 array_shift($p->param
);
46 spip_log("filtre de logo obsolete $nom", 'vieilles_defs');
48 array_shift($p->param
);
50 spip_log("filtre de logo obsolete $nom", 'vieilles_defs');
52 } elseif (preg_match("/^".NOM_DE_CHAMP
.'(.*)$/sS', $nom, $m)) {
54 $champ->nom_boucle
= $m[2];
55 $champ->nom_champ
= $m[3];
56 $champ->etoile
= $m[5];
57 $champ = array($champ);
64 array_shift($p->param
);
65 spip_log("filtre de logo obsolete $nom", 'vieilles_defs');
67 } // le cas else est la seule incompatibilite
70 array_unshift($p->param
, $args);
74 function phraser_logo_faux_filtres($nom)
81 case 'bottom': return 0;
82 case 'lien': return 1;
83 case 'fichier': return 2;
89 // La balise embed_document est a present le modele emb
91 function phraser_vieux_emb(&$p)
93 if (!is_array($p->param
))
96 // Produire le premier argument {emb}
99 $param = array('', array($texte));
101 // Transformer les filtres en arguments
102 for ($i=0; $i<count($p->param
); $i++
) {
103 if ($p->param
[$i][0]) {
104 if (!strstr($p->param
[$i][0], '='))
105 break;# on a rencontre un vrai filtre, c'est fini
107 $texte->texte
=$p->param
[$i][0];
108 $param[] = array($texte);
110 array_shift($p->param
);
112 array_unshift($p->param
, $param);
113 spip_log('balise EMBED_DOCUMENT obsolete', 'vieilles_defs');
114 $p->nom_champ
= 'MODELE';
117 // Vieux formulaire de recherch
119 function phraser_vieux_recherche($p)
121 if ($p->param
[0][0]) {
123 $c->texte
= $p->param
[0][0];
124 $p->param
[0][1] = array($c);
125 $p->param
[0][0] = '';
126 $p->fonctions
= array();
127 spip_log('FORMULAIRE_RECHERCHE avec filtre ' . $c->texte
, 'vieilles_defs');
131 // Gerer la notation [(#EXPOSER|on,off)]
132 function phraser_vieux_exposer($p)
134 if ($a = $p->fonctions
) {
135 preg_match("#([^,]*)(,(.*))?#", $a[0][0], $regs);
139 $a->texte
= $regs[1];
140 $args = array('', array($a));
143 $a->texte
= $regs[3];
147 $p->param
[0] = $args;
148 $p->fonctions
= array();
149 $p->nom_champ
= 'EXPOSE';
153 function phraser_vieux_modele($p) {normaliser_args_inclumodel($p);}
154 function phraser_vieux_inclu($p) {normaliser_args_inclumodel($p);}
156 function normaliser_args_inclumodel($p)
159 if (!$params) return;
161 if ($args[0]) return; // filtre immediat
162 array_shift($p->param
);
163 foreach ($p->param
as $l) {
164 if (!array_shift($l)) {
165 $args = array_merge($args, $l);
166 array_shift($p->param
);
167 } else break; // filtre
169 array_unshift($p->param
, $args);
172 function normaliser_inclure($champ)
174 normaliser_args_inclumodel($champ);
175 $l = $champ->param
[0];
176 if (is_array($l) AND !$l[0]) {
177 foreach ($l as $k => $p) {
178 if ($p AND $p[0]->type
== 'texte' AND !strpos($p[0]->texte
,'=')) {
179 $p[0]->texte
= trim($p[0]->texte
);
182 foreach ($l as $k => $p) {
183 if (!$p OR $p[0]->type
!= 'texte' OR
184 !preg_match('/^fond\s*=\s*(.*)$/',$p[0]->texte
, $r))
188 $p[0]->texte
= $r[1];
191 unset($champ->param
[0][$k]);
192 if (count($champ->param
[0]) ==1)
193 array_shift($champ->param
);
197 spip_log("inclure sans fond ni fichier");