Completed
Push — master ( 59acee...7a72c7 )
by cam
04:42
created
ecrire/plugins/extraire_boutons.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 /**
@@ -21,30 +21,30 @@  discard block
 block discarded – undo
21 21
  * @return <type>
22 22
  */
23 23
 function plugins_extraire_boutons_dist($arbre) {
24
-	$ret = array('bouton' => array(), 'onglet' => array());
25
-	// recuperer les boutons et onglets si necessaire
26
-	spip_xml_match_nodes(",^(bouton|onglet)\s,", $arbre, $les_boutons);
27
-	if (is_array($les_boutons) && count($les_boutons)) {
28
-		$ret['bouton'] = array();
29
-		$ret['onglet'] = array();
30
-		foreach ($les_boutons as $bouton => $val) {
31
-			$bouton = spip_xml_decompose_tag($bouton);
32
-			$type = reset($bouton);
33
-			$bouton = end($bouton);
34
-			if (isset($bouton['id'])) {
35
-				$id = $bouton['id'];
36
-				$val = reset($val);
37
-				if (is_array($val)) {
38
-					$ret[$type][$id]['parent'] = isset($bouton['parent']) ? $bouton['parent'] : '';
39
-					$ret[$type][$id]['position'] = isset($bouton['position']) ? $bouton['position'] : '';
40
-					$ret[$type][$id]['titre'] = isset($val['titre']) ? trim(spip_xml_aplatit($val['titre'])) : '';
41
-					$ret[$type][$id]['icone'] = isset($val['icone']) ? trim(end($val['icone'])) : '';
42
-					$ret[$type][$id]['action'] = isset($val['url']) ? trim(end($val['url'])) : '';
43
-					$ret[$type][$id]['parametres'] = isset($val['args']) ? trim(end($val['args'])) : '';
44
-				}
45
-			}
46
-		}
47
-	}
24
+    $ret = array('bouton' => array(), 'onglet' => array());
25
+    // recuperer les boutons et onglets si necessaire
26
+    spip_xml_match_nodes(",^(bouton|onglet)\s,", $arbre, $les_boutons);
27
+    if (is_array($les_boutons) && count($les_boutons)) {
28
+        $ret['bouton'] = array();
29
+        $ret['onglet'] = array();
30
+        foreach ($les_boutons as $bouton => $val) {
31
+            $bouton = spip_xml_decompose_tag($bouton);
32
+            $type = reset($bouton);
33
+            $bouton = end($bouton);
34
+            if (isset($bouton['id'])) {
35
+                $id = $bouton['id'];
36
+                $val = reset($val);
37
+                if (is_array($val)) {
38
+                    $ret[$type][$id]['parent'] = isset($bouton['parent']) ? $bouton['parent'] : '';
39
+                    $ret[$type][$id]['position'] = isset($bouton['position']) ? $bouton['position'] : '';
40
+                    $ret[$type][$id]['titre'] = isset($val['titre']) ? trim(spip_xml_aplatit($val['titre'])) : '';
41
+                    $ret[$type][$id]['icone'] = isset($val['icone']) ? trim(end($val['icone'])) : '';
42
+                    $ret[$type][$id]['action'] = isset($val['url']) ? trim(end($val['url'])) : '';
43
+                    $ret[$type][$id]['parametres'] = isset($val['args']) ? trim(end($val['args'])) : '';
44
+                }
45
+            }
46
+        }
47
+    }
48 48
 
49
-	return $ret;
49
+    return $ret;
50 50
 }
Please login to merge, or discard this patch.
ecrire/plugins/afficher_repertoires.php 3 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -58,8 +58,8 @@  discard block
 block discarded – undo
58 58
 				$plug = $liste_plugins[$key];
59 59
 				$actif = @isset($fast_liste_plugins_actifs[$plug]);
60 60
 				$id = substr(md5($plug), 0, 16);
61
-				$res .= $ligne_plug($url_page, str_replace(_DIR_PLUGINS, '', _DIR_RACINE . $plug), $actif,
62
-						'menu-entree') . "\n";
61
+				$res .= $ligne_plug($url_page, str_replace(_DIR_PLUGINS, '', _DIR_RACINE.$plug), $actif,
62
+						'menu-entree')."\n";
63 63
 				unset($liste_plugins[$key]);
64 64
 			}
65 65
 		}
@@ -101,12 +101,12 @@  discard block
 block discarded – undo
101 101
 	}
102 102
 	$chemin = "";
103 103
 	if (count($tcom)) {
104
-		$chemin .= implode("/", $tcom) . "/";
104
+		$chemin .= implode("/", $tcom)."/";
105 105
 	}
106 106
 	// ouvrir les repertoires jusqu'a la cible
107 107
 	while ($open = array_shift($ttarg)) {
108
-		$visible = @isset($deplie[$chemin . $open]);
109
-		$chemin .= $open . "/";
108
+		$visible = @isset($deplie[$chemin.$open]);
109
+		$chemin .= $open."/";
110 110
 		$output .= "<li>";
111 111
 		$output .= bouton_block_depliable($chemin, $visible);
112 112
 		$output .= debut_block_depliable($visible);
Please login to merge, or discard this patch.
Doc Comments   +8 added lines patch added patch discarded remove patch
@@ -75,11 +75,19 @@
 block discarded – undo
75 75
 // vraiment n'importe quoi la gestion des chemins des plugins
76 76
 // une fonction pour aider...
77 77
 // https://code.spip.net/@chemin_plug
78
+/**
79
+ * @param string $racine
80
+ *
81
+ * @return string
82
+ */
78 83
 function chemin_plug($racine, $plug) {
79 84
 	return preg_replace(',[^/]+/\.\./,', '', "$racine/$plug");
80 85
 }
81 86
 
82 87
 // https://code.spip.net/@tree_open_close_dir
88
+/**
89
+ * @param string $target
90
+ */
83 91
 function tree_open_close_dir(&$current, $target, $deplie = array()) {
84 92
 	if ($current == $target) {
85 93
 		return "";
Please login to merge, or discard this patch.
Indentation   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -11,64 +11,64 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 // https://code.spip.net/@affiche_arbre_plugins
18 18
 function plugins_afficher_repertoires_dist($url_page, $liste_plugins, $liste_plugins_actifs) {
19
-	$ligne_plug = charger_fonction('afficher_plugin', 'plugins');
20
-	$racine = basename(_DIR_PLUGINS);
21
-	$init_dir = $current_dir = "";
22
-	// liste des repertoires deplies : construit en remontant l'arbo de chaque plugin actif
23
-	// des qu'un path est deja note deplie on s'arrete
24
-	$deplie = array($racine => true);
25
-	$fast_liste_plugins_actifs = array();
26
-	foreach ($liste_plugins_actifs as $key => $plug) {
27
-		$chemin_plug = chemin_plug($racine, $plug);
28
-		$fast_liste_plugins_actifs[$chemin_plug] = true;
29
-		$dir = dirname($chemin_plug);
30
-		$maxiter = 100;
31
-		while (strlen($dir) && !isset($deplie[$dir]) && $dir != $racine && $maxiter-- > 0) {
32
-			$deplie[$dir] = true;
33
-			$dir = dirname($dir);
34
-		}
35
-	}
19
+    $ligne_plug = charger_fonction('afficher_plugin', 'plugins');
20
+    $racine = basename(_DIR_PLUGINS);
21
+    $init_dir = $current_dir = "";
22
+    // liste des repertoires deplies : construit en remontant l'arbo de chaque plugin actif
23
+    // des qu'un path est deja note deplie on s'arrete
24
+    $deplie = array($racine => true);
25
+    $fast_liste_plugins_actifs = array();
26
+    foreach ($liste_plugins_actifs as $key => $plug) {
27
+        $chemin_plug = chemin_plug($racine, $plug);
28
+        $fast_liste_plugins_actifs[$chemin_plug] = true;
29
+        $dir = dirname($chemin_plug);
30
+        $maxiter = 100;
31
+        while (strlen($dir) && !isset($deplie[$dir]) && $dir != $racine && $maxiter-- > 0) {
32
+            $deplie[$dir] = true;
33
+            $dir = dirname($dir);
34
+        }
35
+    }
36 36
 
37
-	// index repertoires --> plugin
38
-	$dir_index = array();
39
-	foreach ($liste_plugins as $key => $plug) {
40
-		$liste_plugins[$key] = chemin_plug($racine, $plug);
41
-		$dir_index[dirname($liste_plugins[$key])][] = $key;
42
-	}
37
+    // index repertoires --> plugin
38
+    $dir_index = array();
39
+    foreach ($liste_plugins as $key => $plug) {
40
+        $liste_plugins[$key] = chemin_plug($racine, $plug);
41
+        $dir_index[dirname($liste_plugins[$key])][] = $key;
42
+    }
43 43
 
44
-	$visible = @isset($deplie[$current_dir]);
45
-	$maxiter = 1000;
44
+    $visible = @isset($deplie[$current_dir]);
45
+    $maxiter = 1000;
46 46
 
47
-	$res = '';
48
-	while (count($liste_plugins) && $maxiter--) {
49
-		// le rep suivant
50
-		$dir = dirname(reset($liste_plugins));
51
-		if ($dir != $current_dir) {
52
-			$res .= tree_open_close_dir($current_dir, $dir, $deplie);
53
-		}
47
+    $res = '';
48
+    while (count($liste_plugins) && $maxiter--) {
49
+        // le rep suivant
50
+        $dir = dirname(reset($liste_plugins));
51
+        if ($dir != $current_dir) {
52
+            $res .= tree_open_close_dir($current_dir, $dir, $deplie);
53
+        }
54 54
 
55
-		// d'abord tous les plugins du rep courant
56
-		if (isset($dir_index[$current_dir])) {
57
-			foreach ($dir_index[$current_dir] as $key) {
58
-				$plug = $liste_plugins[$key];
59
-				$actif = @isset($fast_liste_plugins_actifs[$plug]);
60
-				$id = substr(md5($plug), 0, 16);
61
-				$res .= $ligne_plug($url_page, str_replace(_DIR_PLUGINS, '', _DIR_RACINE . $plug), $actif,
62
-						'menu-entree') . "\n";
63
-				unset($liste_plugins[$key]);
64
-			}
65
-		}
66
-	}
67
-	$res .= tree_open_close_dir($current_dir, $init_dir, true);
55
+        // d'abord tous les plugins du rep courant
56
+        if (isset($dir_index[$current_dir])) {
57
+            foreach ($dir_index[$current_dir] as $key) {
58
+                $plug = $liste_plugins[$key];
59
+                $actif = @isset($fast_liste_plugins_actifs[$plug]);
60
+                $id = substr(md5($plug), 0, 16);
61
+                $res .= $ligne_plug($url_page, str_replace(_DIR_PLUGINS, '', _DIR_RACINE . $plug), $actif,
62
+                        'menu-entree') . "\n";
63
+                unset($liste_plugins[$key]);
64
+            }
65
+        }
66
+    }
67
+    $res .= tree_open_close_dir($current_dir, $init_dir, true);
68 68
 
69
-	return "<ul class='menu-liste plugins'>"
70
-	. $res
71
-	. "</ul>";
69
+    return "<ul class='menu-liste plugins'>"
70
+    . $res
71
+    . "</ul>";
72 72
 }
73 73
 
74 74
 
@@ -76,44 +76,44 @@  discard block
 block discarded – undo
76 76
 // une fonction pour aider...
77 77
 // https://code.spip.net/@chemin_plug
78 78
 function chemin_plug($racine, $plug) {
79
-	return preg_replace(',[^/]+/\.\./,', '', "$racine/$plug");
79
+    return preg_replace(',[^/]+/\.\./,', '', "$racine/$plug");
80 80
 }
81 81
 
82 82
 // https://code.spip.net/@tree_open_close_dir
83 83
 function tree_open_close_dir(&$current, $target, $deplie = array()) {
84
-	if ($current == $target) {
85
-		return "";
86
-	}
87
-	$tcur = explode("/", $current);
88
-	$ttarg = explode("/", $target);
89
-	$tcom = array();
90
-	$output = "";
91
-	// la partie commune
92
-	while (reset($tcur) == reset($ttarg)) {
93
-		$tcom[] = array_shift($tcur);
94
-		array_shift($ttarg);
95
-	}
96
-	// fermer les repertoires courant jusqu'au point de fork
97
-	while ($close = array_pop($tcur)) {
98
-		$output .= "</ul>\n";
99
-		$output .= fin_block();
100
-		$output .= "</li>\n";
101
-	}
102
-	$chemin = "";
103
-	if (count($tcom)) {
104
-		$chemin .= implode("/", $tcom) . "/";
105
-	}
106
-	// ouvrir les repertoires jusqu'a la cible
107
-	while ($open = array_shift($ttarg)) {
108
-		$visible = @isset($deplie[$chemin . $open]);
109
-		$chemin .= $open . "/";
110
-		$output .= "<li>";
111
-		$output .= bouton_block_depliable($chemin, $visible);
112
-		$output .= debut_block_depliable($visible);
84
+    if ($current == $target) {
85
+        return "";
86
+    }
87
+    $tcur = explode("/", $current);
88
+    $ttarg = explode("/", $target);
89
+    $tcom = array();
90
+    $output = "";
91
+    // la partie commune
92
+    while (reset($tcur) == reset($ttarg)) {
93
+        $tcom[] = array_shift($tcur);
94
+        array_shift($ttarg);
95
+    }
96
+    // fermer les repertoires courant jusqu'au point de fork
97
+    while ($close = array_pop($tcur)) {
98
+        $output .= "</ul>\n";
99
+        $output .= fin_block();
100
+        $output .= "</li>\n";
101
+    }
102
+    $chemin = "";
103
+    if (count($tcom)) {
104
+        $chemin .= implode("/", $tcom) . "/";
105
+    }
106
+    // ouvrir les repertoires jusqu'a la cible
107
+    while ($open = array_shift($ttarg)) {
108
+        $visible = @isset($deplie[$chemin . $open]);
109
+        $chemin .= $open . "/";
110
+        $output .= "<li>";
111
+        $output .= bouton_block_depliable($chemin, $visible);
112
+        $output .= debut_block_depliable($visible);
113 113
 
114
-		$output .= "<ul>\n";
115
-	}
116
-	$current = $target;
114
+        $output .= "<ul>\n";
115
+    }
116
+    $current = $target;
117 117
 
118
-	return $output;
118
+    return $output;
119 119
 }
Please login to merge, or discard this patch.
ecrire/plugins/afficher_liste.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	asort($liste_plugins);
65 65
 	$exposed = urldecode(_request('plugin'));
66 66
 
67
-	$block_par_lettre = false;//count($liste_plugins)>10;
67
+	$block_par_lettre = false; //count($liste_plugins)>10;
68 68
 	$fast_liste_plugins_actifs = array();
69 69
 	$fast_liste_plugins_checked = array();
70 70
 	if (is_array($liste_plugins_actifs)) {
@@ -89,9 +89,9 @@  discard block
 block discarded – undo
89 89
 		$actif = isset($fast_liste_plugins_actifs[$plug]);
90 90
 		$checked = isset($fast_liste_plugins_checked[$plug]);
91 91
 		$block_actif = $block_actif | $actif;
92
-		$expose = ($exposed and ($exposed == $plug or $exposed == $dir_plugins . $plug or $exposed == substr($dir_plugins,
93
-					strlen(_DIR_RACINE)) . $plug));
94
-		$block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, "item", $dir_plugins) . "\n";
92
+		$expose = ($exposed and ($exposed == $plug or $exposed == $dir_plugins.$plug or $exposed == substr($dir_plugins,
93
+					strlen(_DIR_RACINE)).$plug));
94
+		$block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, "item", $dir_plugins)."\n";
95 95
 	}
96 96
 	$res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block;
97 97
 	$class = basename($dir_plugins);
Please login to merge, or discard this patch.
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 include_spip('inc/charsets');
17 17
 
@@ -28,88 +28,88 @@  discard block
 block discarded – undo
28 28
  * @return string
29 29
  */
30 30
 function plugins_afficher_liste_dist(
31
-	$url_page,
32
-	$liste_plugins,
33
-	$liste_plugins_checked,
34
-	$liste_plugins_actifs,
35
-	$dir_plugins = _DIR_PLUGINS,
36
-	$afficher_un = 'afficher_plugin'
31
+    $url_page,
32
+    $liste_plugins,
33
+    $liste_plugins_checked,
34
+    $liste_plugins_actifs,
35
+    $dir_plugins = _DIR_PLUGINS,
36
+    $afficher_un = 'afficher_plugin'
37 37
 ) {
38
-	$get_infos = charger_fonction('get_infos', 'plugins');
39
-	$ligne_plug = charger_fonction($afficher_un, 'plugins');
38
+    $get_infos = charger_fonction('get_infos', 'plugins');
39
+    $ligne_plug = charger_fonction($afficher_un, 'plugins');
40 40
 
41
-	$all_infos = $get_infos($liste_plugins, false, $dir_plugins);
41
+    $all_infos = $get_infos($liste_plugins, false, $dir_plugins);
42 42
 
43
-	$all_infos = pipeline('filtrer_liste_plugins',
44
-		array(
45
-			'args' => array(
46
-				'liste_plugins' => $liste_plugins,
47
-				'liste_plugins_checked' => $liste_plugins_checked,
48
-				'liste_plugins_actifs' => $liste_plugins_actifs,
49
-				'dir_plugins' => $dir_plugins
50
-			),
51
-			'data' => $all_infos
52
-		)
53
-	);
43
+    $all_infos = pipeline('filtrer_liste_plugins',
44
+        array(
45
+            'args' => array(
46
+                'liste_plugins' => $liste_plugins,
47
+                'liste_plugins_checked' => $liste_plugins_checked,
48
+                'liste_plugins_actifs' => $liste_plugins_actifs,
49
+                'dir_plugins' => $dir_plugins
50
+            ),
51
+            'data' => $all_infos
52
+        )
53
+    );
54 54
 
55
-	$liste_plugins = array_flip($liste_plugins);
56
-	foreach ($liste_plugins as $chemin => $v) {
57
-		// des plugins ont pu etre enleves de la liste par le pipeline. On en tient compte.
58
-		if (isset($all_infos[$chemin])) {
59
-			$liste_plugins[$chemin] = strtoupper(trim(typo(translitteration(unicode2charset(html2unicode($all_infos[$chemin]['nom']))))));
60
-		} else {
61
-			unset($liste_plugins[$chemin]);
62
-		}
63
-	}
64
-	asort($liste_plugins);
65
-	$exposed = urldecode(_request('plugin'));
55
+    $liste_plugins = array_flip($liste_plugins);
56
+    foreach ($liste_plugins as $chemin => $v) {
57
+        // des plugins ont pu etre enleves de la liste par le pipeline. On en tient compte.
58
+        if (isset($all_infos[$chemin])) {
59
+            $liste_plugins[$chemin] = strtoupper(trim(typo(translitteration(unicode2charset(html2unicode($all_infos[$chemin]['nom']))))));
60
+        } else {
61
+            unset($liste_plugins[$chemin]);
62
+        }
63
+    }
64
+    asort($liste_plugins);
65
+    $exposed = urldecode(_request('plugin'));
66 66
 
67
-	$block_par_lettre = false;//count($liste_plugins)>10;
68
-	$fast_liste_plugins_actifs = array();
69
-	$fast_liste_plugins_checked = array();
70
-	if (is_array($liste_plugins_actifs)) {
71
-		$fast_liste_plugins_actifs = array_flip($liste_plugins_actifs);
72
-	}
73
-	if (is_array($liste_plugins_checked)) {
74
-		$fast_liste_plugins_checked = array_flip($liste_plugins_checked);
75
-	}
67
+    $block_par_lettre = false;//count($liste_plugins)>10;
68
+    $fast_liste_plugins_actifs = array();
69
+    $fast_liste_plugins_checked = array();
70
+    if (is_array($liste_plugins_actifs)) {
71
+        $fast_liste_plugins_actifs = array_flip($liste_plugins_actifs);
72
+    }
73
+    if (is_array($liste_plugins_checked)) {
74
+        $fast_liste_plugins_checked = array_flip($liste_plugins_checked);
75
+    }
76 76
 
77
-	$res = '';
78
-	$block = '';
79
-	$initiale = '';
80
-	$block_actif = false;
81
-	foreach ($liste_plugins as $plug => $nom) {
82
-		if (($i = substr($nom, 0, 1)) !== $initiale) {
83
-			$res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block;
84
-			$initiale = $i;
85
-			$block = '';
86
-			$block_actif = false;
87
-		}
88
-		// le rep suivant
89
-		$actif = isset($fast_liste_plugins_actifs[$plug]);
90
-		$checked = isset($fast_liste_plugins_checked[$plug]);
91
-		$block_actif = $block_actif | $actif;
92
-		$expose = ($exposed and ($exposed == $plug or $exposed == $dir_plugins . $plug or $exposed == substr($dir_plugins,
93
-					strlen(_DIR_RACINE)) . $plug));
94
-		$block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, "item", $dir_plugins) . "\n";
95
-	}
96
-	$res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block;
97
-	$class = basename($dir_plugins);
77
+    $res = '';
78
+    $block = '';
79
+    $initiale = '';
80
+    $block_actif = false;
81
+    foreach ($liste_plugins as $plug => $nom) {
82
+        if (($i = substr($nom, 0, 1)) !== $initiale) {
83
+            $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block;
84
+            $initiale = $i;
85
+            $block = '';
86
+            $block_actif = false;
87
+        }
88
+        // le rep suivant
89
+        $actif = isset($fast_liste_plugins_actifs[$plug]);
90
+        $checked = isset($fast_liste_plugins_checked[$plug]);
91
+        $block_actif = $block_actif | $actif;
92
+        $expose = ($exposed and ($exposed == $plug or $exposed == $dir_plugins . $plug or $exposed == substr($dir_plugins,
93
+                    strlen(_DIR_RACINE)) . $plug));
94
+        $block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, "item", $dir_plugins) . "\n";
95
+    }
96
+    $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block;
97
+    $class = basename($dir_plugins);
98 98
 
99
-	return $res ? "<ul class='liste-items plugins $class'>$res</ul>" : "";
99
+    return $res ? "<ul class='liste-items plugins $class'>$res</ul>" : "";
100 100
 }
101 101
 
102 102
 
103 103
 // https://code.spip.net/@affiche_block_initiale
104 104
 function affiche_block_initiale($initiale, $block, $block_actif) {
105
-	if (strlen($block)) {
106
-		return "<li class='item'>"
107
-		. bouton_block_depliable($initiale, $block_actif ? true : false)
108
-		. debut_block_depliable($block_actif)
109
-		. "<ul>$block</ul>"
110
-		. fin_block()
111
-		. "</li>";
112
-	}
105
+    if (strlen($block)) {
106
+        return "<li class='item'>"
107
+        . bouton_block_depliable($initiale, $block_actif ? true : false)
108
+        . debut_block_depliable($block_actif)
109
+        . "<ul>$block</ul>"
110
+        . fin_block()
111
+        . "</li>";
112
+    }
113 113
 
114
-	return "";
114
+    return "";
115 115
 }
Please login to merge, or discard this patch.
ecrire/urls/page.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 # attention toutefois seuls '' et '=' figurent dans les modes de compatibilite
24 24
 define('_separateur_urls_page', '');
25 25
 # on peut indiquer '' si on a installe le .htaccess
26
-define('_debut_urls_page', get_spip_script('./') . '?');
26
+define('_debut_urls_page', get_spip_script('./').'?');
27 27
 #######
28 28
 
29 29
 
@@ -37,14 +37,14 @@  discard block
 block discarded – undo
37 37
 		}
38 38
 	}
39 39
 
40
-	$url = _debut_urls_page . $type . _separateur_urls_page
41
-		. $id . _terminaison_urls_page;
40
+	$url = _debut_urls_page.$type._separateur_urls_page
41
+		. $id._terminaison_urls_page;
42 42
 
43 43
 	if ($args) {
44 44
 		$args = strpos($url, '?') ? "&$args" : "?$args";
45 45
 	}
46 46
 
47
-	return _DIR_RACINE . $url . $args . ($ancre ? "#$ancre" : '');
47
+	return _DIR_RACINE.$url.$args.($ancre ? "#$ancre" : '');
48 48
 }
49 49
 
50 50
 // retrouve le fond et les parametres d'une URL abregee
Please login to merge, or discard this patch.
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 define('URLS_PAGE_EXEMPLE', 'spip.php?article12');
@@ -30,74 +30,74 @@  discard block
 block discarded – undo
30 30
 // https://code.spip.net/@_generer_url_page
31 31
 function _generer_url_page($type, $id, $args = '', $ancre = '') {
32 32
 
33
-	if ($generer_url_externe = charger_fonction("generer_url_$type", 'urls', true)) {
34
-		$url = $generer_url_externe($id, $args, $ancre);
35
-		if (null != $url) {
36
-			return $url;
37
-		}
38
-	}
33
+    if ($generer_url_externe = charger_fonction("generer_url_$type", 'urls', true)) {
34
+        $url = $generer_url_externe($id, $args, $ancre);
35
+        if (null != $url) {
36
+            return $url;
37
+        }
38
+    }
39 39
 
40
-	$url = _debut_urls_page . $type . _separateur_urls_page
41
-		. $id . _terminaison_urls_page;
40
+    $url = _debut_urls_page . $type . _separateur_urls_page
41
+        . $id . _terminaison_urls_page;
42 42
 
43
-	if ($args) {
44
-		$args = strpos($url, '?') ? "&$args" : "?$args";
45
-	}
43
+    if ($args) {
44
+        $args = strpos($url, '?') ? "&$args" : "?$args";
45
+    }
46 46
 
47
-	return _DIR_RACINE . $url . $args . ($ancre ? "#$ancre" : '');
47
+    return _DIR_RACINE . $url . $args . ($ancre ? "#$ancre" : '');
48 48
 }
49 49
 
50 50
 // retrouve le fond et les parametres d'une URL abregee
51 51
 // le contexte deja existant est fourni dans args sous forme de tableau ou query string
52 52
 // https://code.spip.net/@urls_page_dist
53 53
 function urls_page_dist($i, &$entite, $args = '', $ancre = '') {
54
-	if (is_numeric($i)) {
55
-		return _generer_url_page($entite, $i, $args, $ancre);
56
-	}
54
+    if (is_numeric($i)) {
55
+        return _generer_url_page($entite, $i, $args, $ancre);
56
+    }
57 57
 
58
-	// traiter les injections du type domaine.org/spip.php/cestnimportequoi/ou/encore/plus/rubrique23
59
-	if ($GLOBALS['profondeur_url'] > 0 and $entite == 'sommaire') {
60
-		return array(array(), '404');
61
-	}
58
+    // traiter les injections du type domaine.org/spip.php/cestnimportequoi/ou/encore/plus/rubrique23
59
+    if ($GLOBALS['profondeur_url'] > 0 and $entite == 'sommaire') {
60
+        return array(array(), '404');
61
+    }
62 62
 
63
-	// voir s'il faut recuperer le id_* implicite et les &debut_xx;
64
-	if (is_array($args)) {
65
-		$contexte = $args;
66
-	} else {
67
-		parse_str($args, $contexte);
68
-	}
69
-	include_spip('inc/urls');
70
-	$r = nettoyer_url_page($i, $contexte);
71
-	if ($r) {
72
-		array_pop($r); // nettoyer_url_page renvoie un argument de plus inutile ici
73
-		return $r;
74
-	}
63
+    // voir s'il faut recuperer le id_* implicite et les &debut_xx;
64
+    if (is_array($args)) {
65
+        $contexte = $args;
66
+    } else {
67
+        parse_str($args, $contexte);
68
+    }
69
+    include_spip('inc/urls');
70
+    $r = nettoyer_url_page($i, $contexte);
71
+    if ($r) {
72
+        array_pop($r); // nettoyer_url_page renvoie un argument de plus inutile ici
73
+        return $r;
74
+    }
75 75
 
76
-	/*
76
+    /*
77 77
 	 * Le bloc qui suit sert a faciliter les transitions depuis
78 78
 	 * le mode 'urls-propres' vers les modes 'urls-standard' et 'url-html'
79 79
 	 * Il est inutile de le recopier si vous personnalisez vos URLs
80 80
 	 * et votre .htaccess
81 81
 	 */
82
-	// Si on est revenu en mode html, mais c'est une ancienne url_propre
83
-	// on ne redirige pas, on assume le nouveau contexte (si possible)
84
-	$url = $i;
85
-	$url_propre = isset($url)
86
-		? $url
87
-		: (isset($_SERVER['REDIRECT_url_propre'])
88
-			? $_SERVER['REDIRECT_url_propre']
89
-			: (isset($_ENV['url_propre'])
90
-				? $_ENV['url_propre']
91
-				: ''
92
-			));
93
-	if ($url_propre) {
94
-		if ($GLOBALS['profondeur_url'] <= 0) {
95
-			$urls_anciennes = charger_fonction('propres', 'urls', true);
96
-		} else {
97
-			$urls_anciennes = charger_fonction('arbo', 'urls', true);
98
-		}
82
+    // Si on est revenu en mode html, mais c'est une ancienne url_propre
83
+    // on ne redirige pas, on assume le nouveau contexte (si possible)
84
+    $url = $i;
85
+    $url_propre = isset($url)
86
+        ? $url
87
+        : (isset($_SERVER['REDIRECT_url_propre'])
88
+            ? $_SERVER['REDIRECT_url_propre']
89
+            : (isset($_ENV['url_propre'])
90
+                ? $_ENV['url_propre']
91
+                : ''
92
+            ));
93
+    if ($url_propre) {
94
+        if ($GLOBALS['profondeur_url'] <= 0) {
95
+            $urls_anciennes = charger_fonction('propres', 'urls', true);
96
+        } else {
97
+            $urls_anciennes = charger_fonction('arbo', 'urls', true);
98
+        }
99 99
 
100
-		return $urls_anciennes ? $urls_anciennes($url_propre, $entite, $contexte) : '';
101
-	}
102
-	/* Fin du bloc compatibilite url-propres */
100
+        return $urls_anciennes ? $urls_anciennes($url_propre, $entite, $contexte) : '';
101
+    }
102
+    /* Fin du bloc compatibilite url-propres */
103 103
 }
Please login to merge, or discard this patch.
ecrire/xml/interfaces.php 2 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 define('_REGEXP_DOCTYPE',
@@ -33,14 +33,14 @@  discard block
 block discarded – undo
33 33
 define('_REGEXP_ENTITY_DEF', '/^%(' . _SUB_REGEXP_SYMBOL . '+);/');
34 34
 define('_REGEXP_TYPE_XML', 'PUBLIC|SYSTEM|INCLUDE|IGNORE|CDATA');
35 35
 define('_REGEXP_ENTITY_DECL', '/^<!ENTITY\s+(%?)\s*(' .
36
-	_SUB_REGEXP_SYMBOL .
37
-	'+;?)\s+(' .
38
-	_REGEXP_TYPE_XML .
39
-	')?\s*(' .
40
-	"('([^']*)')" .
41
-	'|("([^"]*)")' .
42
-	'|\s*(%' . _SUB_REGEXP_SYMBOL . '+;)\s*' .
43
-	')\s*(--.*?--)?("([^"]*)")?\s*>\s*(.*)$/s');
36
+    _SUB_REGEXP_SYMBOL .
37
+    '+;?)\s+(' .
38
+    _REGEXP_TYPE_XML .
39
+    ')?\s*(' .
40
+    "('([^']*)')" .
41
+    '|("([^"]*)")' .
42
+    '|\s*(%' . _SUB_REGEXP_SYMBOL . '+;)\s*' .
43
+    ')\s*(--.*?--)?("([^"]*)")?\s*>\s*(.*)$/s');
44 44
 
45 45
 define('_REGEXP_INCLUDE_USE', '/^<!\[\s*%\s*([^;]*);\s*\[\s*(.*)$/s');
46 46
 
@@ -50,11 +50,11 @@  discard block
 block discarded – undo
50 50
  * Document Type Compilation
51 51
  **/
52 52
 class DTC {
53
-	public $macros = array();
54
-	public $elements = array();
55
-	public $peres = array();
56
-	public $attributs = array();
57
-	public $entites = array();
58
-	public $regles = array();
59
-	public $pcdata = array();
53
+    public $macros = array();
54
+    public $elements = array();
55
+    public $peres = array();
56
+    public $attributs = array();
57
+    public $entites = array();
58
+    public $regles = array();
59
+    public $pcdata = array();
60 60
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -23,23 +23,23 @@
 block discarded – undo
23 23
 
24 24
 define('_SUB_REGEXP_SYMBOL', '[\w_:.-]');
25 25
 
26
-define('_REGEXP_NMTOKEN', '/^' . _SUB_REGEXP_SYMBOL . '+$/');
26
+define('_REGEXP_NMTOKEN', '/^'._SUB_REGEXP_SYMBOL.'+$/');
27 27
 
28
-define('_REGEXP_NMTOKENS', '/^(' . _SUB_REGEXP_SYMBOL . '+\s*)*$/');
28
+define('_REGEXP_NMTOKENS', '/^('._SUB_REGEXP_SYMBOL.'+\s*)*$/');
29 29
 
30
-define('_REGEXP_ID', '/^[A-Za-z_:]' . _SUB_REGEXP_SYMBOL . '*$/');
30
+define('_REGEXP_ID', '/^[A-Za-z_:]'._SUB_REGEXP_SYMBOL.'*$/');
31 31
 
32
-define('_REGEXP_ENTITY_USE', '/%(' . _SUB_REGEXP_SYMBOL . '+);/');
33
-define('_REGEXP_ENTITY_DEF', '/^%(' . _SUB_REGEXP_SYMBOL . '+);/');
32
+define('_REGEXP_ENTITY_USE', '/%('._SUB_REGEXP_SYMBOL.'+);/');
33
+define('_REGEXP_ENTITY_DEF', '/^%('._SUB_REGEXP_SYMBOL.'+);/');
34 34
 define('_REGEXP_TYPE_XML', 'PUBLIC|SYSTEM|INCLUDE|IGNORE|CDATA');
35
-define('_REGEXP_ENTITY_DECL', '/^<!ENTITY\s+(%?)\s*(' .
36
-	_SUB_REGEXP_SYMBOL .
37
-	'+;?)\s+(' .
38
-	_REGEXP_TYPE_XML .
39
-	')?\s*(' .
40
-	"('([^']*)')" .
41
-	'|("([^"]*)")' .
42
-	'|\s*(%' . _SUB_REGEXP_SYMBOL . '+;)\s*' .
35
+define('_REGEXP_ENTITY_DECL', '/^<!ENTITY\s+(%?)\s*('.
36
+	_SUB_REGEXP_SYMBOL.
37
+	'+;?)\s+('.
38
+	_REGEXP_TYPE_XML.
39
+	')?\s*('.
40
+	"('([^']*)')".
41
+	'|("([^"]*)")'.
42
+	'|\s*(%'._SUB_REGEXP_SYMBOL.'+;)\s*'.
43 43
 	')\s*(--.*?--)?("([^"]*)")?\s*>\s*(.*)$/s');
44 44
 
45 45
 define('_REGEXP_INCLUDE_USE', '/^<!\[\s*%\s*([^;]*);\s*\[\s*(.*)$/s');
Please login to merge, or discard this patch.
ecrire/xml/analyser_dtd.php 3 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 		$grammaire = find_in_path($grammaire);
29 29
 	}
30 30
 
31
-	$file = _DIR_CACHE_XML . preg_replace('/[^\w.]/', '_', $rotlvl) . '.gz';
31
+	$file = _DIR_CACHE_XML.preg_replace('/[^\w.]/', '_', $rotlvl).'.gz';
32 32
 
33 33
 	if (lire_fichier($file, $r)) {
34 34
 		if (!$grammaire) {
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 				$dtc->peres[$k] = $v;
56 56
 			}
57 57
 
58
-			spip_log("Analyser DTD $avail $grammaire (" . spip_timer('dtd') . ") " . count($dtc->macros) . ' macros, ' . count($dtc->elements) . ' elements, ' . count($dtc->attributs) . " listes d'attributs, " . count($dtc->entites) . " entites");
58
+			spip_log("Analyser DTD $avail $grammaire (".spip_timer('dtd').") ".count($dtc->macros).' macros, '.count($dtc->elements).' elements, '.count($dtc->attributs)." listes d'attributs, ".count($dtc->entites)." entites");
59 59
 			#	$r = $dtc->regles; ksort($r);foreach($r as $l => $v) {$t=array_keys($dtc->attributs[$l]);echo "<b>$l</b> '$v' ", count($t), " attributs: ", join (', ',$t);$t=$dtc->peres[$l];echo "<br />",count($t), " peres: ", @join (', ',$t), "<br />\n";}exit;
60 60
 			ecrire_fichier($file, serialize($dtc), true);
61 61
 		}
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 			}
157 157
 		}
158 158
 		if (!is_string($r)) {
159
-			spip_log("erreur $r dans la DTD  " . substr($dtd, 0, 80) . ".....");
159
+			spip_log("erreur $r dans la DTD  ".substr($dtd, 0, 80).".....");
160 160
 
161 161
 			return false;
162 162
 		}
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 		if (($n[0] == 'PUBLIC')
204 204
 			and !tester_url_absolue($n[1])
205 205
 		) {
206
-			$n[1] = substr($grammaire, 0, strrpos($grammaire, '/') + 1) . $n[1];
206
+			$n[1] = substr($grammaire, 0, strrpos($grammaire, '/') + 1).$n[1];
207 207
 		}
208 208
 		analyser_dtd($n[1], $n[0], $dtc);
209 209
 	}
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 	}
228 228
 
229 229
 	if ($dtc->macros[$m[1]] == 'INCLUDE') {
230
-		$retour = $r[1] . substr($m[2], strlen($r[0]));
230
+		$retour = $r[1].substr($m[2], strlen($r[0]));
231 231
 	} else {
232 232
 		$retour = substr($m[2], strlen($r[0]));
233 233
 	}
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 		spip_log("redefinition de l'entite $nom");
261 261
 	}
262 262
 	if ($k6) {
263
-		return $k6 . $dtd;
263
+		return $k6.$dtd;
264 264
 	} // cas du synonyme complet
265 265
 	$val = expanserEntite(($k2 ? $k3 : ($k4 ? $k5 : $k6)), $dtc->macros);
266 266
 
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
 	if (preg_match_all("/\s*(\S+)\s+(([(][^)]*[)])|(\S+))\s+([^\s']*)(\s*'[^']*')?/", $val, $r2, PREG_SET_ORDER)) {
367 367
 		foreach ($r2 as $m2) {
368 368
 			$v = preg_match('/^\w+$/', $m2[2]) ? $m2[2]
369
-				: ('/^' . preg_replace('/\s+/', '', $m2[2]) . '$/');
369
+				: ('/^'.preg_replace('/\s+/', '', $m2[2]).'$/');
370 370
 			$m21 = expanserEntite($m2[1], $dtc->macros);
371 371
 			$m25 = expanserEntite($m2[5], $dtc->macros);
372 372
 			$dtc->attributs[$nom][$m21] = array($v, $m25);
Please login to merge, or discard this patch.
Doc Comments   +24 added lines patch added patch discarded remove patch
@@ -167,6 +167,9 @@  discard block
 block discarded – undo
167 167
 }
168 168
 
169 169
 // https://code.spip.net/@analyser_dtd_comment
170
+/**
171
+ * @param string $dtd
172
+ */
170 173
 function analyser_dtd_comment($dtd, &$dtc, $grammaire) {
171 174
 	// ejecter les commentaires, surtout quand ils contiennent du code.
172 175
 	// Option /s car sur plusieurs lignes parfois
@@ -179,6 +182,9 @@  discard block
 block discarded – undo
179 182
 }
180 183
 
181 184
 // https://code.spip.net/@analyser_dtd_pi
185
+/**
186
+ * @param string $dtd
187
+ */
182 188
 function analyser_dtd_pi($dtd, &$dtc, $grammaire) {
183 189
 	if (!preg_match('/^<\?.*?>\s*(.*)$/s', $dtd, $m)) {
184 190
 		return -10;
@@ -188,6 +194,9 @@  discard block
 block discarded – undo
188 194
 }
189 195
 
190 196
 // https://code.spip.net/@analyser_dtd_lexeme
197
+/**
198
+ * @param string $dtd
199
+ */
191 200
 function analyser_dtd_lexeme($dtd, &$dtc, $grammaire) {
192 201
 
193 202
 	if (!preg_match(_REGEXP_ENTITY_DEF, $dtd, $m)) {
@@ -215,6 +224,9 @@  discard block
 block discarded – undo
215 224
 // ca ne depasse pas 3 ici.
216 225
 
217 226
 // https://code.spip.net/@analyser_dtd_data
227
+/**
228
+ * @param string $dtd
229
+ */
218 230
 function analyser_dtd_data($dtd, &$dtc, $grammaire) {
219 231
 
220 232
 	if (!preg_match(_REGEXP_INCLUDE_USE, $dtd, $m)) {
@@ -236,6 +248,9 @@  discard block
 block discarded – undo
236 248
 }
237 249
 
238 250
 // https://code.spip.net/@analyser_dtd_notation
251
+/**
252
+ * @param string $dtd
253
+ */
239 254
 function analyser_dtd_notation($dtd, &$dtc, $grammaire) {
240 255
 	if (!preg_match('/^<!NOTATION.*?>\s*(.*)$/s', $dtd, $m)) {
241 256
 		return -8;
@@ -246,6 +261,9 @@  discard block
 block discarded – undo
246 261
 }
247 262
 
248 263
 // https://code.spip.net/@analyser_dtd_entity
264
+/**
265
+ * @param string $dtd
266
+ */
249 267
 function analyser_dtd_entity($dtd, &$dtc, $grammaire) {
250 268
 	if (!preg_match(_REGEXP_ENTITY_DECL, $dtd, $m)) {
251 269
 		return -2;
@@ -303,6 +321,9 @@  discard block
 block discarded – undo
303 321
 // Fin du controle en finElement
304 322
 
305 323
 // https://code.spip.net/@analyser_dtd_element
324
+/**
325
+ * @param string $dtd
326
+ */
306 327
 function analyser_dtd_element($dtd, &$dtc, $grammaire) {
307 328
 	if (!preg_match('/^<!ELEMENT\s+([^>\s]+)([^>]*)>\s*(.*)$/s', $dtd, $m)) {
308 329
 		return -3;
@@ -351,6 +372,9 @@  discard block
 block discarded – undo
351 372
 
352 373
 
353 374
 // https://code.spip.net/@analyser_dtd_attlist
375
+/**
376
+ * @param string $dtd
377
+ */
354 378
 function analyser_dtd_attlist($dtd, &$dtc, $grammaire) {
355 379
 	if (!preg_match('/^<!ATTLIST\s+(\S+)\s+([^>]*)>\s*(.*)/s', $dtd, $m)) {
356 380
 		return -5;
Please login to merge, or discard this patch.
Indentation   +311 added lines, -311 removed lines patch added patch discarded remove patch
@@ -11,59 +11,59 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 include_spip('xml/interfaces');
18 18
 
19 19
 // https://code.spip.net/@charger_dtd
20 20
 function charger_dtd($grammaire, $avail, $rotlvl) {
21
-	static $dtd = array(); # cache bien utile pour le validateur en boucle
22
-
23
-	if (isset($dtd[$grammaire])) {
24
-		return $dtd[$grammaire];
25
-	}
26
-
27
-	if ($avail == 'SYSTEM') {
28
-		$grammaire = find_in_path($grammaire);
29
-	}
30
-
31
-	$file = _DIR_CACHE_XML . preg_replace('/[^\w.]/', '_', $rotlvl) . '.gz';
32
-
33
-	if (lire_fichier($file, $r)) {
34
-		if (!$grammaire) {
35
-			return array();
36
-		}
37
-		if (($avail == 'SYSTEM') and filemtime($file) < filemtime($grammaire)) {
38
-			$r = false;
39
-		}
40
-	}
41
-
42
-	if ($r) {
43
-		$dtc = unserialize($r);
44
-	} else {
45
-		spip_timer('dtd');
46
-		$dtc = new DTC;
47
-		// L'analyseur retourne un booleen de reussite et modifie $dtc.
48
-		// Retourner vide en cas d'echec
49
-		if (!analyser_dtd($grammaire, $avail, $dtc)) {
50
-			$dtc = array();
51
-		} else {
52
-			// tri final pour presenter les suggestions de corrections
53
-			foreach ($dtc->peres as $k => $v) {
54
-				asort($v);
55
-				$dtc->peres[$k] = $v;
56
-			}
57
-
58
-			spip_log("Analyser DTD $avail $grammaire (" . spip_timer('dtd') . ") " . count($dtc->macros) . ' macros, ' . count($dtc->elements) . ' elements, ' . count($dtc->attributs) . " listes d'attributs, " . count($dtc->entites) . " entites");
59
-			#	$r = $dtc->regles; ksort($r);foreach($r as $l => $v) {$t=array_keys($dtc->attributs[$l]);echo "<b>$l</b> '$v' ", count($t), " attributs: ", join (', ',$t);$t=$dtc->peres[$l];echo "<br />",count($t), " peres: ", @join (', ',$t), "<br />\n";}exit;
60
-			ecrire_fichier($file, serialize($dtc), true);
61
-		}
62
-
63
-	}
64
-	$dtd[$grammaire] = $dtc;
65
-
66
-	return $dtc;
21
+    static $dtd = array(); # cache bien utile pour le validateur en boucle
22
+
23
+    if (isset($dtd[$grammaire])) {
24
+        return $dtd[$grammaire];
25
+    }
26
+
27
+    if ($avail == 'SYSTEM') {
28
+        $grammaire = find_in_path($grammaire);
29
+    }
30
+
31
+    $file = _DIR_CACHE_XML . preg_replace('/[^\w.]/', '_', $rotlvl) . '.gz';
32
+
33
+    if (lire_fichier($file, $r)) {
34
+        if (!$grammaire) {
35
+            return array();
36
+        }
37
+        if (($avail == 'SYSTEM') and filemtime($file) < filemtime($grammaire)) {
38
+            $r = false;
39
+        }
40
+    }
41
+
42
+    if ($r) {
43
+        $dtc = unserialize($r);
44
+    } else {
45
+        spip_timer('dtd');
46
+        $dtc = new DTC;
47
+        // L'analyseur retourne un booleen de reussite et modifie $dtc.
48
+        // Retourner vide en cas d'echec
49
+        if (!analyser_dtd($grammaire, $avail, $dtc)) {
50
+            $dtc = array();
51
+        } else {
52
+            // tri final pour presenter les suggestions de corrections
53
+            foreach ($dtc->peres as $k => $v) {
54
+                asort($v);
55
+                $dtc->peres[$k] = $v;
56
+            }
57
+
58
+            spip_log("Analyser DTD $avail $grammaire (" . spip_timer('dtd') . ") " . count($dtc->macros) . ' macros, ' . count($dtc->elements) . ' elements, ' . count($dtc->attributs) . " listes d'attributs, " . count($dtc->entites) . " entites");
59
+            #	$r = $dtc->regles; ksort($r);foreach($r as $l => $v) {$t=array_keys($dtc->attributs[$l]);echo "<b>$l</b> '$v' ", count($t), " attributs: ", join (', ',$t);$t=$dtc->peres[$l];echo "<br />",count($t), " peres: ", @join (', ',$t), "<br />\n";}exit;
60
+            ecrire_fichier($file, serialize($dtc), true);
61
+        }
62
+
63
+    }
64
+    $dtd[$grammaire] = $dtc;
65
+
66
+    return $dtc;
67 67
 }
68 68
 
69 69
 // Compiler une regle de production en une Regexp qu'on appliquera sur la
@@ -76,139 +76,139 @@  discard block
 block discarded – undo
76 76
 
77 77
 // https://code.spip.net/@compilerRegle
78 78
 function compilerRegle($val) {
79
-	$x = str_replace('()', '',
80
-		preg_replace('/\s*,\s*/', '',
81
-			preg_replace('/(\w+)\s*/', '(?:\1 )',
82
-				preg_replace('/\s*\)/', ')',
83
-					preg_replace('/\s*([(+*|?])\s*/', '\1',
84
-						preg_replace('/\s*#\w+\s*[,|]?\s*/', '', $val))))));
85
-
86
-	return $x;
79
+    $x = str_replace('()', '',
80
+        preg_replace('/\s*,\s*/', '',
81
+            preg_replace('/(\w+)\s*/', '(?:\1 )',
82
+                preg_replace('/\s*\)/', ')',
83
+                    preg_replace('/\s*([(+*|?])\s*/', '\1',
84
+                        preg_replace('/\s*#\w+\s*[,|]?\s*/', '', $val))))));
85
+
86
+    return $x;
87 87
 }
88 88
 
89 89
 
90 90
 // https://code.spip.net/@analyser_dtd
91 91
 function analyser_dtd($loc, $avail, &$dtc) {
92
-	// creer le repertoire de cache si ce n'est fait
93
-	// (utile aussi pour le resultat de la compil)
94
-	$file = sous_repertoire(_DIR_CACHE_XML);
95
-	// si DTD locale, ignorer ce repertoire pour le moment
96
-	if ($avail == 'SYSTEM') {
97
-		$file = $loc;
98
-		if (_DIR_RACINE and strncmp($file, _DIR_RACINE, strlen(_DIR_RACINE)) == 0) {
99
-			$file = substr($file, strlen(_DIR_RACINE));
100
-		}
101
-		$file = find_in_path($file);
102
-	} else {
103
-		$file .= preg_replace('/[^\w.]/', '_', $loc);
104
-	}
105
-
106
-	$dtd = '';
107
-	if (@is_readable($file)) {
108
-		lire_fichier($file, $dtd);
109
-	} else {
110
-		if ($avail == 'PUBLIC') {
111
-			include_spip('inc/distant');
112
-			if ($dtd = trim(recuperer_page($loc))) {
113
-				ecrire_fichier($file, $dtd, true);
114
-			}
115
-		}
116
-	}
117
-
118
-	$dtd = ltrim($dtd);
119
-	if (!$dtd) {
120
-		spip_log("DTD '$loc' ($file) inaccessible");
121
-
122
-		return false;
123
-	} else {
124
-		spip_log("analyse de la DTD $loc ");
125
-	}
126
-
127
-	while ($dtd) {
128
-		if ($dtd[0] != '<') {
129
-			$r = analyser_dtd_lexeme($dtd, $dtc, $loc);
130
-		} elseif ($dtd[1] != '!') {
131
-			$r = analyser_dtd_pi($dtd, $dtc, $loc);
132
-		} elseif ($dtd[2] == '[') {
133
-			$r = analyser_dtd_data($dtd, $dtc, $loc);
134
-		} else {
135
-			switch ($dtd[3]) {
136
-				case '%' :
137
-					$r = analyser_dtd_data($dtd, $dtc, $loc);
138
-					break;
139
-				case 'T' :
140
-					$r = analyser_dtd_attlist($dtd, $dtc, $loc);
141
-					break;
142
-				case 'L' :
143
-					$r = analyser_dtd_element($dtd, $dtc, $loc);
144
-					break;
145
-				case 'N' :
146
-					$r = analyser_dtd_entity($dtd, $dtc, $loc);
147
-					break;
148
-				case 'O' :
149
-					$r = analyser_dtd_notation($dtd, $dtc, $loc);
150
-					break;
151
-				case '-' :
152
-					$r = analyser_dtd_comment($dtd, $dtc, $loc);
153
-					break;
154
-				default:
155
-					$r = -1;
156
-			}
157
-		}
158
-		if (!is_string($r)) {
159
-			spip_log("erreur $r dans la DTD  " . substr($dtd, 0, 80) . ".....");
160
-
161
-			return false;
162
-		}
163
-		$dtd = $r;
164
-	}
165
-
166
-	return true;
92
+    // creer le repertoire de cache si ce n'est fait
93
+    // (utile aussi pour le resultat de la compil)
94
+    $file = sous_repertoire(_DIR_CACHE_XML);
95
+    // si DTD locale, ignorer ce repertoire pour le moment
96
+    if ($avail == 'SYSTEM') {
97
+        $file = $loc;
98
+        if (_DIR_RACINE and strncmp($file, _DIR_RACINE, strlen(_DIR_RACINE)) == 0) {
99
+            $file = substr($file, strlen(_DIR_RACINE));
100
+        }
101
+        $file = find_in_path($file);
102
+    } else {
103
+        $file .= preg_replace('/[^\w.]/', '_', $loc);
104
+    }
105
+
106
+    $dtd = '';
107
+    if (@is_readable($file)) {
108
+        lire_fichier($file, $dtd);
109
+    } else {
110
+        if ($avail == 'PUBLIC') {
111
+            include_spip('inc/distant');
112
+            if ($dtd = trim(recuperer_page($loc))) {
113
+                ecrire_fichier($file, $dtd, true);
114
+            }
115
+        }
116
+    }
117
+
118
+    $dtd = ltrim($dtd);
119
+    if (!$dtd) {
120
+        spip_log("DTD '$loc' ($file) inaccessible");
121
+
122
+        return false;
123
+    } else {
124
+        spip_log("analyse de la DTD $loc ");
125
+    }
126
+
127
+    while ($dtd) {
128
+        if ($dtd[0] != '<') {
129
+            $r = analyser_dtd_lexeme($dtd, $dtc, $loc);
130
+        } elseif ($dtd[1] != '!') {
131
+            $r = analyser_dtd_pi($dtd, $dtc, $loc);
132
+        } elseif ($dtd[2] == '[') {
133
+            $r = analyser_dtd_data($dtd, $dtc, $loc);
134
+        } else {
135
+            switch ($dtd[3]) {
136
+                case '%' :
137
+                    $r = analyser_dtd_data($dtd, $dtc, $loc);
138
+                    break;
139
+                case 'T' :
140
+                    $r = analyser_dtd_attlist($dtd, $dtc, $loc);
141
+                    break;
142
+                case 'L' :
143
+                    $r = analyser_dtd_element($dtd, $dtc, $loc);
144
+                    break;
145
+                case 'N' :
146
+                    $r = analyser_dtd_entity($dtd, $dtc, $loc);
147
+                    break;
148
+                case 'O' :
149
+                    $r = analyser_dtd_notation($dtd, $dtc, $loc);
150
+                    break;
151
+                case '-' :
152
+                    $r = analyser_dtd_comment($dtd, $dtc, $loc);
153
+                    break;
154
+                default:
155
+                    $r = -1;
156
+            }
157
+        }
158
+        if (!is_string($r)) {
159
+            spip_log("erreur $r dans la DTD  " . substr($dtd, 0, 80) . ".....");
160
+
161
+            return false;
162
+        }
163
+        $dtd = $r;
164
+    }
165
+
166
+    return true;
167 167
 }
168 168
 
169 169
 // https://code.spip.net/@analyser_dtd_comment
170 170
 function analyser_dtd_comment($dtd, &$dtc, $grammaire) {
171
-	// ejecter les commentaires, surtout quand ils contiennent du code.
172
-	// Option /s car sur plusieurs lignes parfois
171
+    // ejecter les commentaires, surtout quand ils contiennent du code.
172
+    // Option /s car sur plusieurs lignes parfois
173 173
 
174
-	if (!preg_match('/^<!--.*?-->\s*(.*)$/s', $dtd, $m)) {
175
-		return -6;
176
-	}
174
+    if (!preg_match('/^<!--.*?-->\s*(.*)$/s', $dtd, $m)) {
175
+        return -6;
176
+    }
177 177
 
178
-	return $m[1];
178
+    return $m[1];
179 179
 }
180 180
 
181 181
 // https://code.spip.net/@analyser_dtd_pi
182 182
 function analyser_dtd_pi($dtd, &$dtc, $grammaire) {
183
-	if (!preg_match('/^<\?.*?>\s*(.*)$/s', $dtd, $m)) {
184
-		return -10;
185
-	}
183
+    if (!preg_match('/^<\?.*?>\s*(.*)$/s', $dtd, $m)) {
184
+        return -10;
185
+    }
186 186
 
187
-	return $m[1];
187
+    return $m[1];
188 188
 }
189 189
 
190 190
 // https://code.spip.net/@analyser_dtd_lexeme
191 191
 function analyser_dtd_lexeme($dtd, &$dtc, $grammaire) {
192 192
 
193
-	if (!preg_match(_REGEXP_ENTITY_DEF, $dtd, $m)) {
194
-		return -9;
195
-	}
196
-
197
-	list(, $s) = $m;
198
-	$n = $dtc->macros[$s];
199
-
200
-	if (is_array($n)) {
201
-		// en cas d'inclusion, l'espace de nom est le meme
202
-		// mais gaffe aux DTD dont l'URL est relative a l'engloblante
203
-		if (($n[0] == 'PUBLIC')
204
-			and !tester_url_absolue($n[1])
205
-		) {
206
-			$n[1] = substr($grammaire, 0, strrpos($grammaire, '/') + 1) . $n[1];
207
-		}
208
-		analyser_dtd($n[1], $n[0], $dtc);
209
-	}
210
-
211
-	return ltrim(substr($dtd, strlen($m[0])));
193
+    if (!preg_match(_REGEXP_ENTITY_DEF, $dtd, $m)) {
194
+        return -9;
195
+    }
196
+
197
+    list(, $s) = $m;
198
+    $n = $dtc->macros[$s];
199
+
200
+    if (is_array($n)) {
201
+        // en cas d'inclusion, l'espace de nom est le meme
202
+        // mais gaffe aux DTD dont l'URL est relative a l'engloblante
203
+        if (($n[0] == 'PUBLIC')
204
+            and !tester_url_absolue($n[1])
205
+        ) {
206
+            $n[1] = substr($grammaire, 0, strrpos($grammaire, '/') + 1) . $n[1];
207
+        }
208
+        analyser_dtd($n[1], $n[0], $dtc);
209
+    }
210
+
211
+    return ltrim(substr($dtd, strlen($m[0])));
212 212
 }
213 213
 
214 214
 // il faudrait gerer plus proprement les niveaux d'inclusion:
@@ -217,80 +217,80 @@  discard block
 block discarded – undo
217 217
 // https://code.spip.net/@analyser_dtd_data
218 218
 function analyser_dtd_data($dtd, &$dtc, $grammaire) {
219 219
 
220
-	if (!preg_match(_REGEXP_INCLUDE_USE, $dtd, $m)) {
221
-		return -11;
222
-	}
223
-	if (!preg_match('/^((\s*<!(\[\s*%\s*[^;]*;\s*\[([^]<]*<[^>]*>)*[^]<]*\]\]>)|([^]>]*>))*[^]<]*)\]\]>\s*/s', $m[2],
224
-		$r)
225
-	) {
226
-		return -12;
227
-	}
228
-
229
-	if ($dtc->macros[$m[1]] == 'INCLUDE') {
230
-		$retour = $r[1] . substr($m[2], strlen($r[0]));
231
-	} else {
232
-		$retour = substr($m[2], strlen($r[0]));
233
-	}
234
-
235
-	return $retour;
220
+    if (!preg_match(_REGEXP_INCLUDE_USE, $dtd, $m)) {
221
+        return -11;
222
+    }
223
+    if (!preg_match('/^((\s*<!(\[\s*%\s*[^;]*;\s*\[([^]<]*<[^>]*>)*[^]<]*\]\]>)|([^]>]*>))*[^]<]*)\]\]>\s*/s', $m[2],
224
+        $r)
225
+    ) {
226
+        return -12;
227
+    }
228
+
229
+    if ($dtc->macros[$m[1]] == 'INCLUDE') {
230
+        $retour = $r[1] . substr($m[2], strlen($r[0]));
231
+    } else {
232
+        $retour = substr($m[2], strlen($r[0]));
233
+    }
234
+
235
+    return $retour;
236 236
 }
237 237
 
238 238
 // https://code.spip.net/@analyser_dtd_notation
239 239
 function analyser_dtd_notation($dtd, &$dtc, $grammaire) {
240
-	if (!preg_match('/^<!NOTATION.*?>\s*(.*)$/s', $dtd, $m)) {
241
-		return -8;
242
-	}
243
-	spip_log("analyser_dtd_notation a ecrire");
240
+    if (!preg_match('/^<!NOTATION.*?>\s*(.*)$/s', $dtd, $m)) {
241
+        return -8;
242
+    }
243
+    spip_log("analyser_dtd_notation a ecrire");
244 244
 
245
-	return $m[1];
245
+    return $m[1];
246 246
 }
247 247
 
248 248
 // https://code.spip.net/@analyser_dtd_entity
249 249
 function analyser_dtd_entity($dtd, &$dtc, $grammaire) {
250
-	if (!preg_match(_REGEXP_ENTITY_DECL, $dtd, $m)) {
251
-		return -2;
252
-	}
253
-
254
-	list($t, $term, $nom, $type, $k1, $k2, $k3, $k4, $k5, $k6, $c, $q, $alt, $dtd) = $m;
255
-
256
-	if (isset($dtc->macros[$nom]) and $dtc->macros[$nom]) {
257
-		return $dtd;
258
-	}
259
-	if (isset($dtc->entites[$nom])) {
260
-		spip_log("redefinition de l'entite $nom");
261
-	}
262
-	if ($k6) {
263
-		return $k6 . $dtd;
264
-	} // cas du synonyme complet
265
-	$val = expanserEntite(($k2 ? $k3 : ($k4 ? $k5 : $k6)), $dtc->macros);
266
-
267
-	// cas particulier double evaluation: 'PUBLIC "..." "...."' 
268
-	if (preg_match('/(PUBLIC|SYSTEM)\s+"([^"]*)"\s*("([^"]*)")?\s*$/s', $val, $r)) {
269
-		list($t, $type, $val, $q, $alt) = $r;
270
-	}
271
-
272
-	if (!$term) {
273
-		$dtc->entites[$nom] = $val;
274
-	} elseif (!$type) {
275
-		$dtc->macros[$nom] = $val;
276
-	} else {
277
-		if (($type == 'SYSTEM') and !$alt) {
278
-			$alt = $val;
279
-		}
280
-		if (!$alt) {
281
-			$dtc->macros[$nom] = $val;
282
-		} else {
283
-			if (($type == 'PUBLIC')
284
-				and (strpos($alt, '/') === false)
285
-			) {
286
-				$alt = preg_replace(',/[^/]+$,', '/', $grammaire)
287
-					. $alt;
288
-			}
289
-			$dtc->macros[$nom] = array($type, $alt);
290
-		}
291
-	}
292
-
293
-	return $dtd;
250
+    if (!preg_match(_REGEXP_ENTITY_DECL, $dtd, $m)) {
251
+        return -2;
252
+    }
253
+
254
+    list($t, $term, $nom, $type, $k1, $k2, $k3, $k4, $k5, $k6, $c, $q, $alt, $dtd) = $m;
255
+
256
+    if (isset($dtc->macros[$nom]) and $dtc->macros[$nom]) {
257
+        return $dtd;
258
+    }
259
+    if (isset($dtc->entites[$nom])) {
260
+        spip_log("redefinition de l'entite $nom");
261
+    }
262
+    if ($k6) {
263
+        return $k6 . $dtd;
264
+    } // cas du synonyme complet
265
+    $val = expanserEntite(($k2 ? $k3 : ($k4 ? $k5 : $k6)), $dtc->macros);
266
+
267
+    // cas particulier double evaluation: 'PUBLIC "..." "...."' 
268
+    if (preg_match('/(PUBLIC|SYSTEM)\s+"([^"]*)"\s*("([^"]*)")?\s*$/s', $val, $r)) {
269
+        list($t, $type, $val, $q, $alt) = $r;
270
+    }
271
+
272
+    if (!$term) {
273
+        $dtc->entites[$nom] = $val;
274
+    } elseif (!$type) {
275
+        $dtc->macros[$nom] = $val;
276
+    } else {
277
+        if (($type == 'SYSTEM') and !$alt) {
278
+            $alt = $val;
279
+        }
280
+        if (!$alt) {
281
+            $dtc->macros[$nom] = $val;
282
+        } else {
283
+            if (($type == 'PUBLIC')
284
+                and (strpos($alt, '/') === false)
285
+            ) {
286
+                $alt = preg_replace(',/[^/]+$,', '/', $grammaire)
287
+                    . $alt;
288
+            }
289
+            $dtc->macros[$nom] = array($type, $alt);
290
+        }
291
+    }
292
+
293
+    return $dtd;
294 294
 }
295 295
 
296 296
 // Dresser le tableau des filles potentielles de l'element
@@ -304,76 +304,76 @@  discard block
 block discarded – undo
304 304
 
305 305
 // https://code.spip.net/@analyser_dtd_element
306 306
 function analyser_dtd_element($dtd, &$dtc, $grammaire) {
307
-	if (!preg_match('/^<!ELEMENT\s+([^>\s]+)([^>]*)>\s*(.*)$/s', $dtd, $m)) {
308
-		return -3;
309
-	}
310
-
311
-	list(, $nom, $contenu, $dtd) = $m;
312
-	$nom = expanserEntite($nom, $dtc->macros);
313
-
314
-	if (isset($dtc->elements[$nom])) {
315
-		spip_log("redefinition de l'element $nom dans la DTD");
316
-
317
-		return -4;
318
-	}
319
-	$filles = array();
320
-	$contenu = expanserEntite($contenu, $dtc->macros);
321
-	$val = $contenu ? compilerRegle($contenu) : '(?:EMPTY )';
322
-	if ($val == '(?:EMPTY )') {
323
-		$dtc->regles[$nom] = 'EMPTY';
324
-	} elseif ($val == '(?:ANY )') {
325
-		$dtc->regles[$nom] = 'ANY';
326
-	} else {
327
-		$last = substr($val, -1);
328
-		if (preg_match('/ \w/', $val)
329
-			or (!empty($last) and strpos('*+?', $last) === false)
330
-		) {
331
-			$dtc->regles[$nom] = "/^$val$/";
332
-		} else {
333
-			$dtc->regles[$nom] = $last;
334
-		}
335
-		$filles = array_values(preg_split('/\W+/', $val, -1, PREG_SPLIT_NO_EMPTY));
336
-
337
-		foreach ($filles as $k) {
338
-			if (!isset($dtc->peres[$k])) {
339
-				$dtc->peres[$k] = array();
340
-			}
341
-			if (!in_array($nom, $dtc->peres[$k])) {
342
-				$dtc->peres[$k][] = $nom;
343
-			}
344
-		}
345
-	}
346
-	$dtc->pcdata[$nom] = (strpos($contenu, '#PCDATA') === false);
347
-	$dtc->elements[$nom] = $filles;
348
-
349
-	return $dtd;
307
+    if (!preg_match('/^<!ELEMENT\s+([^>\s]+)([^>]*)>\s*(.*)$/s', $dtd, $m)) {
308
+        return -3;
309
+    }
310
+
311
+    list(, $nom, $contenu, $dtd) = $m;
312
+    $nom = expanserEntite($nom, $dtc->macros);
313
+
314
+    if (isset($dtc->elements[$nom])) {
315
+        spip_log("redefinition de l'element $nom dans la DTD");
316
+
317
+        return -4;
318
+    }
319
+    $filles = array();
320
+    $contenu = expanserEntite($contenu, $dtc->macros);
321
+    $val = $contenu ? compilerRegle($contenu) : '(?:EMPTY )';
322
+    if ($val == '(?:EMPTY )') {
323
+        $dtc->regles[$nom] = 'EMPTY';
324
+    } elseif ($val == '(?:ANY )') {
325
+        $dtc->regles[$nom] = 'ANY';
326
+    } else {
327
+        $last = substr($val, -1);
328
+        if (preg_match('/ \w/', $val)
329
+            or (!empty($last) and strpos('*+?', $last) === false)
330
+        ) {
331
+            $dtc->regles[$nom] = "/^$val$/";
332
+        } else {
333
+            $dtc->regles[$nom] = $last;
334
+        }
335
+        $filles = array_values(preg_split('/\W+/', $val, -1, PREG_SPLIT_NO_EMPTY));
336
+
337
+        foreach ($filles as $k) {
338
+            if (!isset($dtc->peres[$k])) {
339
+                $dtc->peres[$k] = array();
340
+            }
341
+            if (!in_array($nom, $dtc->peres[$k])) {
342
+                $dtc->peres[$k][] = $nom;
343
+            }
344
+        }
345
+    }
346
+    $dtc->pcdata[$nom] = (strpos($contenu, '#PCDATA') === false);
347
+    $dtc->elements[$nom] = $filles;
348
+
349
+    return $dtd;
350 350
 }
351 351
 
352 352
 
353 353
 // https://code.spip.net/@analyser_dtd_attlist
354 354
 function analyser_dtd_attlist($dtd, &$dtc, $grammaire) {
355
-	if (!preg_match('/^<!ATTLIST\s+(\S+)\s+([^>]*)>\s*(.*)/s', $dtd, $m)) {
356
-		return -5;
357
-	}
358
-
359
-	list(, $nom, $val, $dtd) = $m;
360
-	$nom = expanserEntite($nom, $dtc->macros);
361
-	$val = expanserEntite($val, $dtc->macros);
362
-	if (!isset($dtc->attributs[$nom])) {
363
-		$dtc->attributs[$nom] = array();
364
-	}
365
-
366
-	if (preg_match_all("/\s*(\S+)\s+(([(][^)]*[)])|(\S+))\s+([^\s']*)(\s*'[^']*')?/", $val, $r2, PREG_SET_ORDER)) {
367
-		foreach ($r2 as $m2) {
368
-			$v = preg_match('/^\w+$/', $m2[2]) ? $m2[2]
369
-				: ('/^' . preg_replace('/\s+/', '', $m2[2]) . '$/');
370
-			$m21 = expanserEntite($m2[1], $dtc->macros);
371
-			$m25 = expanserEntite($m2[5], $dtc->macros);
372
-			$dtc->attributs[$nom][$m21] = array($v, $m25);
373
-		}
374
-	}
375
-
376
-	return $dtd;
355
+    if (!preg_match('/^<!ATTLIST\s+(\S+)\s+([^>]*)>\s*(.*)/s', $dtd, $m)) {
356
+        return -5;
357
+    }
358
+
359
+    list(, $nom, $val, $dtd) = $m;
360
+    $nom = expanserEntite($nom, $dtc->macros);
361
+    $val = expanserEntite($val, $dtc->macros);
362
+    if (!isset($dtc->attributs[$nom])) {
363
+        $dtc->attributs[$nom] = array();
364
+    }
365
+
366
+    if (preg_match_all("/\s*(\S+)\s+(([(][^)]*[)])|(\S+))\s+([^\s']*)(\s*'[^']*')?/", $val, $r2, PREG_SET_ORDER)) {
367
+        foreach ($r2 as $m2) {
368
+            $v = preg_match('/^\w+$/', $m2[2]) ? $m2[2]
369
+                : ('/^' . preg_replace('/\s+/', '', $m2[2]) . '$/');
370
+            $m21 = expanserEntite($m2[1], $dtc->macros);
371
+            $m25 = expanserEntite($m2[5], $dtc->macros);
372
+            $dtc->attributs[$nom][$m21] = array($v, $m25);
373
+        }
374
+    }
375
+
376
+    return $dtd;
377 377
 }
378 378
 
379 379
 
@@ -389,26 +389,26 @@  discard block
 block discarded – undo
389 389
  * @return string|array
390 390
  **/
391 391
 function expanserEntite($val, $macros = array()) {
392
-	static $vu = array();
393
-	if (!is_string($val)) {
394
-		return $vu;
395
-	}
396
-
397
-	if (preg_match_all(_REGEXP_ENTITY_USE, $val, $r, PREG_SET_ORDER)) {
398
-		foreach ($r as $m) {
399
-			$ent = $m[1];
400
-			// il peut valoir ""
401
-			if (!isset($macros[$ent])) {
402
-				spip_log("Entite $ent inconnu");
403
-			} else {
404
-				if (!isset($vu[$ent])) {
405
-					$vu[$ent] = 0;
406
-				}
407
-				++$vu[$ent];
408
-				$val = str_replace($m[0], $macros[$ent], $val);
409
-			}
410
-		}
411
-	}
412
-
413
-	return trim(preg_replace('/\s+/', ' ', $val));
392
+    static $vu = array();
393
+    if (!is_string($val)) {
394
+        return $vu;
395
+    }
396
+
397
+    if (preg_match_all(_REGEXP_ENTITY_USE, $val, $r, PREG_SET_ORDER)) {
398
+        foreach ($r as $m) {
399
+            $ent = $m[1];
400
+            // il peut valoir ""
401
+            if (!isset($macros[$ent])) {
402
+                spip_log("Entite $ent inconnu");
403
+            } else {
404
+                if (!isset($vu[$ent])) {
405
+                    $vu[$ent] = 0;
406
+                }
407
+                ++$vu[$ent];
408
+                $val = str_replace($m[0], $macros[$ent], $val);
409
+            }
410
+        }
411
+    }
412
+
413
+    return trim(preg_replace('/\s+/', ' ', $val));
414 414
 }
Please login to merge, or discard this patch.
ecrire/xml/indenter.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -63,9 +63,9 @@
 block discarded – undo
63 63
 	$f = new IndenteurXML();
64 64
 	$sax($page, $apply, $f);
65 65
 	if (!$f->err) {
66
-		return $f->entete . $f->res;
66
+		return $f->entete.$f->res;
67 67
 	}
68
-	spip_log("indentation impossible " . count($f->err) . " erreurs de validation");
68
+	spip_log("indentation impossible ".count($f->err)." erreurs de validation");
69 69
 
70
-	return $f->entete . $f->page;
70
+	return $f->entete.$f->page;
71 71
 }
Please login to merge, or discard this patch.
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -11,61 +11,61 @@
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 class IndenteurXML {
18 18
 
19
-	// https://code.spip.net/@debutElement
20
-	public function debutElement($phraseur, $name, $attrs) {
21
-		xml_debutElement($this, $name, $attrs);
22
-	}
19
+    // https://code.spip.net/@debutElement
20
+    public function debutElement($phraseur, $name, $attrs) {
21
+        xml_debutElement($this, $name, $attrs);
22
+    }
23 23
 
24
-	// https://code.spip.net/@finElement
25
-	public function finElement($phraseur, $name) {
26
-		xml_finElement($this, $name);
27
-	}
24
+    // https://code.spip.net/@finElement
25
+    public function finElement($phraseur, $name) {
26
+        xml_finElement($this, $name);
27
+    }
28 28
 
29
-	// https://code.spip.net/@textElement
30
-	public function textElement($phraseur, $data) {
31
-		xml_textElement($this, $data);
32
-	}
29
+    // https://code.spip.net/@textElement
30
+    public function textElement($phraseur, $data) {
31
+        xml_textElement($this, $data);
32
+    }
33 33
 
34
-	public function piElement($phraseur, $target, $data) {
35
-		xml_PiElement($this, $target, $data);
36
-	}
34
+    public function piElement($phraseur, $target, $data) {
35
+        xml_PiElement($this, $target, $data);
36
+    }
37 37
 
38
-	// https://code.spip.net/@defautElement
39
-	public function defaultElement($phraseur, $data) {
40
-		xml_defaultElement($this, $data);
41
-	}
38
+    // https://code.spip.net/@defautElement
39
+    public function defaultElement($phraseur, $data) {
40
+        xml_defaultElement($this, $data);
41
+    }
42 42
 
43
-	// https://code.spip.net/@phraserTout
44
-	public function phraserTout($phraseur, $data) {
45
-		xml_parsestring($this, $data);
46
-	}
43
+    // https://code.spip.net/@phraserTout
44
+    public function phraserTout($phraseur, $data) {
45
+        xml_parsestring($this, $data);
46
+    }
47 47
 
48
-	public $depth = "";
49
-	public $res = "";
50
-	public $err = array();
51
-	public $contenu = array();
52
-	public $ouvrant = array();
53
-	public $reperes = array();
54
-	public $entete = '';
55
-	public $page = '';
56
-	public $dtc = null;
57
-	public $sax = null;
48
+    public $depth = "";
49
+    public $res = "";
50
+    public $err = array();
51
+    public $contenu = array();
52
+    public $ouvrant = array();
53
+    public $reperes = array();
54
+    public $entete = '';
55
+    public $page = '';
56
+    public $dtc = null;
57
+    public $sax = null;
58 58
 }
59 59
 
60 60
 // https://code.spip.net/@xml_indenter_dist
61 61
 function xml_indenter_dist($page, $apply = false) {
62
-	$sax = charger_fonction('sax', 'xml');
63
-	$f = new IndenteurXML();
64
-	$sax($page, $apply, $f);
65
-	if (!$f->err) {
66
-		return $f->entete . $f->res;
67
-	}
68
-	spip_log("indentation impossible " . count($f->err) . " erreurs de validation");
62
+    $sax = charger_fonction('sax', 'xml');
63
+    $f = new IndenteurXML();
64
+    $sax($page, $apply, $f);
65
+    if (!$f->err) {
66
+        return $f->entete . $f->res;
67
+    }
68
+    spip_log("indentation impossible " . count($f->err) . " erreurs de validation");
69 69
 
70
-	return $f->entete . $f->page;
70
+    return $f->entete . $f->page;
71 71
 }
Please login to merge, or discard this patch.
ecrire/xml/sax.php 3 patches
Spacing   +21 added lines, -22 removed lines patch added patch discarded remove patch
@@ -45,8 +45,8 @@  discard block
 block discarded – undo
45 45
 	$t = isset($phraseur->ouvrant[$depth]) ? $phraseur->ouvrant[$depth] : ' ';
46 46
 	// espace initial signifie: deja integree au resultat
47 47
 	if ($t[0] != ' ') {
48
-		$phraseur->res .= '<' . $t . '>';
49
-		$phraseur->ouvrant[$depth] = ' ' . $t;
48
+		$phraseur->res .= '<'.$t.'>';
49
+		$phraseur->ouvrant[$depth] = ' '.$t;
50 50
 	}
51 51
 	$t = $phraseur->contenu[$depth];
52 52
 	// n'indenter que s'il y a un separateur avant
@@ -57,14 +57,14 @@  discard block
 block discarded – undo
57 57
 	foreach ($attrs as $k => $v) {
58 58
 		$delim = strpos($v, "'") === false ? "'" : '"';
59 59
 		$val = xml_entites_html($v);
60
-		$att .= $sep . $k . "=" . $delim
60
+		$att .= $sep.$k."=".$delim
61 61
 			. ($delim !== '"' ? str_replace('&quot;', '"', $val) : $val)
62 62
 			. $delim;
63 63
 		$sep = "\n $depth";
64 64
 	}
65 65
 	$phraseur->depth .= '  ';
66 66
 	$phraseur->contenu[$phraseur->depth] = "";
67
-	$phraseur->ouvrant[$phraseur->depth] = $name . $att;
67
+	$phraseur->ouvrant[$phraseur->depth] = $name.$att;
68 68
 	$phraseur->reperes[$phraseur->depth] = xml_get_current_line_number($phraseur->sax);
69 69
 }
70 70
 
@@ -73,13 +73,13 @@  discard block
 block discarded – undo
73 73
 	$ouv = $phraseur->ouvrant[$phraseur->depth];
74 74
 
75 75
 	if ($ouv[0] != ' ') {
76
-		$phraseur->ouvrant[$phraseur->depth] = ' ' . $ouv;
76
+		$phraseur->ouvrant[$phraseur->depth] = ' '.$ouv;
77 77
 	} else {
78 78
 		$ouv = "";
79 79
 	}
80 80
 	$t = $phraseur->contenu[$phraseur->depth];
81 81
 	$phraseur->depth = substr($phraseur->depth, 2);
82
-	$t = preg_replace("/[\n\t ]+$/", "\n" . $phraseur->depth, $t);
82
+	$t = preg_replace("/[\n\t ]+$/", "\n".$phraseur->depth, $t);
83 83
 
84 84
 	// fusion <balise></balise> en <balise />.
85 85
 	// ATTENTION,  certains clients http croient que fusion ==> pas d'atttributs
@@ -88,9 +88,9 @@  discard block
 block discarded – undo
88 88
 	// (param fusion_bal)
89 89
 
90 90
 	if ($t || (($ouv != $name) and !$fusion_bal)) {
91
-		$phraseur->res .= ($ouv ? ('<' . $ouv . '>') : '') . $t . "</" . $name . ">";
91
+		$phraseur->res .= ($ouv ? ('<'.$ouv.'>') : '').$t."</".$name.">";
92 92
 	} else {
93
-		$phraseur->res .= ($ouv ? ('<' . $ouv . ' />') : ("</" . $name . ">"));
93
+		$phraseur->res .= ($ouv ? ('<'.$ouv.' />') : ("</".$name.">"));
94 94
 	}
95 95
 }
96 96
 
@@ -134,16 +134,15 @@  discard block
 block discarded – undo
134 134
 	if (!xml_parse($phraseur->sax, $data, true)) {
135 135
 		coordonnees_erreur($phraseur,
136 136
 			xml_error_string(xml_get_error_code($phraseur->sax))
137
-			. "<br />\n" .
138
-			(!$phraseur->depth ? '' :
139
-				('(' .
140
-					_T('erreur_balise_non_fermee') .
141
-					" <tt>" .
142
-					$phraseur->ouvrant[$phraseur->depth] .
143
-					"</tt> " .
144
-					_T('ligne') .
145
-					" " .
146
-					$phraseur->reperes[$phraseur->depth] .
137
+			. "<br />\n".
138
+			(!$phraseur->depth ? '' : ('('.
139
+					_T('erreur_balise_non_fermee').
140
+					" <tt>".
141
+					$phraseur->ouvrant[$phraseur->depth].
142
+					"</tt> ".
143
+					_T('ligne').
144
+					" ".
145
+					$phraseur->reperes[$phraseur->depth].
147 146
 					") <br />\n")));
148 147
 	}
149 148
 }
@@ -185,7 +184,7 @@  discard block
 block discarded – undo
185 184
 	// et escamoter le doctype que sax mange en php5 mais pas en  php4
186 185
 	if (!$doctype) {
187 186
 		if (!$r = analyser_doctype($page)) {
188
-			$page = _MESSAGE_DOCTYPE . _DOCTYPE_ECRIRE
187
+			$page = _MESSAGE_DOCTYPE._DOCTYPE_ECRIRE
189 188
 				. preg_replace(_REGEXP_DOCTYPE, '', $page);
190 189
 			$r = analyser_doctype($page);
191 190
 		}
@@ -286,18 +285,18 @@  discard block
 block discarded – undo
286 285
 					'rss-0.91.dtd'
287 286
 				);
288 287
 			} else {
289
-				$dtd = $topelement . '.dtd';
288
+				$dtd = $topelement.'.dtd';
290 289
 				$f = find_in_path($dtd);
291 290
 				if (file_exists($f)) {
292 291
 					return array($entete, 'SYSTEM', $f, $dtd);
293 292
 				}
294 293
 			}
295 294
 		}
296
-		spip_log("Dtd pas vu pour " . substr($data, 0, 100));
295
+		spip_log("Dtd pas vu pour ".substr($data, 0, 100));
297 296
 
298 297
 		return array();
299 298
 	}
300
-	list($entete, , $topelement, $avail, $suite) = $page;
299
+	list($entete,, $topelement, $avail, $suite) = $page;
301 300
 
302 301
 	if (!preg_match('/^"([^"]*)"\s*(.*)$/', $suite, $r)) {
303 302
 		if (!preg_match("/^'([^']*)'\s*(.*)$/", $suite, $r)) {
Please login to merge, or discard this patch.
Doc Comments   +9 added lines patch added patch discarded remove patch
@@ -102,6 +102,9 @@  discard block
 block discarded – undo
102 102
 		: xml_entites_html($data);
103 103
 }
104 104
 
105
+/**
106
+ * @param IndenteurXML $phraseur
107
+ */
105 108
 function xml_piElement($phraseur, $target, $data) {
106 109
 	$depth = $phraseur->depth;
107 110
 
@@ -118,6 +121,9 @@  discard block
 block discarded – undo
118 121
 
119 122
 
120 123
 // https://code.spip.net/@xml_defautElement
124
+/**
125
+ * @param IndenteurXML $phraseur
126
+ */
121 127
 function xml_defaultElement($phraseur, $data) {
122 128
 	$depth = $phraseur->depth;
123 129
 
@@ -149,6 +155,9 @@  discard block
 block discarded – undo
149 155
 }
150 156
 
151 157
 // https://code.spip.net/@coordonnees_erreur
158
+/**
159
+ * @param string $msg
160
+ */
152 161
 function coordonnees_erreur($phraseur, $msg) {
153 162
 	$entete_length = substr_count($phraseur->entete, "\n");
154 163
 	$phraseur->err[] = array(
Please login to merge, or discard this patch.
Indentation   +246 added lines, -246 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 include_spip('inc/charsets');
@@ -24,218 +24,218 @@  discard block
 block discarded – undo
24 24
  * @return string
25 25
  */
26 26
 function xml_entites_html($texte) {
27
-	if (!is_string($texte) or !$texte
28
-		or strpbrk($texte, "&\"'<>") == false
29
-	) {
30
-		return $texte;
31
-	}
32
-
33
-	if (!function_exists('spip_htmlspecialchars')) {
34
-		include_spip("inc/filtres_mini");
35
-	}
36
-	$texte = spip_htmlspecialchars($texte, ENT_QUOTES);
37
-
38
-	return $texte;
27
+    if (!is_string($texte) or !$texte
28
+        or strpbrk($texte, "&\"'<>") == false
29
+    ) {
30
+        return $texte;
31
+    }
32
+
33
+    if (!function_exists('spip_htmlspecialchars')) {
34
+        include_spip("inc/filtres_mini");
35
+    }
36
+    $texte = spip_htmlspecialchars($texte, ENT_QUOTES);
37
+
38
+    return $texte;
39 39
 }
40 40
 
41 41
 // https://code.spip.net/@xml_debutElement
42 42
 function xml_debutElement($phraseur, $name, $attrs) {
43
-	$depth = $phraseur->depth;
44
-
45
-	$t = isset($phraseur->ouvrant[$depth]) ? $phraseur->ouvrant[$depth] : ' ';
46
-	// espace initial signifie: deja integree au resultat
47
-	if ($t[0] != ' ') {
48
-		$phraseur->res .= '<' . $t . '>';
49
-		$phraseur->ouvrant[$depth] = ' ' . $t;
50
-	}
51
-	$t = $phraseur->contenu[$depth];
52
-	// n'indenter que s'il y a un separateur avant
53
-	$phraseur->res .= preg_replace("/[\n\t ]+$/", "\n$depth", $t);
54
-	$phraseur->contenu[$depth] = "";
55
-	$att = '';
56
-	$sep = ' ';
57
-	foreach ($attrs as $k => $v) {
58
-		$delim = strpos($v, "'") === false ? "'" : '"';
59
-		$val = xml_entites_html($v);
60
-		$att .= $sep . $k . "=" . $delim
61
-			. ($delim !== '"' ? str_replace('&quot;', '"', $val) : $val)
62
-			. $delim;
63
-		$sep = "\n $depth";
64
-	}
65
-	$phraseur->depth .= '  ';
66
-	$phraseur->contenu[$phraseur->depth] = "";
67
-	$phraseur->ouvrant[$phraseur->depth] = $name . $att;
68
-	$phraseur->reperes[$phraseur->depth] = xml_get_current_line_number($phraseur->sax);
43
+    $depth = $phraseur->depth;
44
+
45
+    $t = isset($phraseur->ouvrant[$depth]) ? $phraseur->ouvrant[$depth] : ' ';
46
+    // espace initial signifie: deja integree au resultat
47
+    if ($t[0] != ' ') {
48
+        $phraseur->res .= '<' . $t . '>';
49
+        $phraseur->ouvrant[$depth] = ' ' . $t;
50
+    }
51
+    $t = $phraseur->contenu[$depth];
52
+    // n'indenter que s'il y a un separateur avant
53
+    $phraseur->res .= preg_replace("/[\n\t ]+$/", "\n$depth", $t);
54
+    $phraseur->contenu[$depth] = "";
55
+    $att = '';
56
+    $sep = ' ';
57
+    foreach ($attrs as $k => $v) {
58
+        $delim = strpos($v, "'") === false ? "'" : '"';
59
+        $val = xml_entites_html($v);
60
+        $att .= $sep . $k . "=" . $delim
61
+            . ($delim !== '"' ? str_replace('&quot;', '"', $val) : $val)
62
+            . $delim;
63
+        $sep = "\n $depth";
64
+    }
65
+    $phraseur->depth .= '  ';
66
+    $phraseur->contenu[$phraseur->depth] = "";
67
+    $phraseur->ouvrant[$phraseur->depth] = $name . $att;
68
+    $phraseur->reperes[$phraseur->depth] = xml_get_current_line_number($phraseur->sax);
69 69
 }
70 70
 
71 71
 // https://code.spip.net/@xml_finElement
72 72
 function xml_finElement($phraseur, $name, $fusion_bal = false) {
73
-	$ouv = $phraseur->ouvrant[$phraseur->depth];
74
-
75
-	if ($ouv[0] != ' ') {
76
-		$phraseur->ouvrant[$phraseur->depth] = ' ' . $ouv;
77
-	} else {
78
-		$ouv = "";
79
-	}
80
-	$t = $phraseur->contenu[$phraseur->depth];
81
-	$phraseur->depth = substr($phraseur->depth, 2);
82
-	$t = preg_replace("/[\n\t ]+$/", "\n" . $phraseur->depth, $t);
83
-
84
-	// fusion <balise></balise> en <balise />.
85
-	// ATTENTION,  certains clients http croient que fusion ==> pas d'atttributs
86
-	// en particulier pour les balises Script et A.
87
-	// en presence d'attributs ne le faire que si la DTD est dispo et d'accord
88
-	// (param fusion_bal)
89
-
90
-	if ($t || (($ouv != $name) and !$fusion_bal)) {
91
-		$phraseur->res .= ($ouv ? ('<' . $ouv . '>') : '') . $t . "</" . $name . ">";
92
-	} else {
93
-		$phraseur->res .= ($ouv ? ('<' . $ouv . ' />') : ("</" . $name . ">"));
94
-	}
73
+    $ouv = $phraseur->ouvrant[$phraseur->depth];
74
+
75
+    if ($ouv[0] != ' ') {
76
+        $phraseur->ouvrant[$phraseur->depth] = ' ' . $ouv;
77
+    } else {
78
+        $ouv = "";
79
+    }
80
+    $t = $phraseur->contenu[$phraseur->depth];
81
+    $phraseur->depth = substr($phraseur->depth, 2);
82
+    $t = preg_replace("/[\n\t ]+$/", "\n" . $phraseur->depth, $t);
83
+
84
+    // fusion <balise></balise> en <balise />.
85
+    // ATTENTION,  certains clients http croient que fusion ==> pas d'atttributs
86
+    // en particulier pour les balises Script et A.
87
+    // en presence d'attributs ne le faire que si la DTD est dispo et d'accord
88
+    // (param fusion_bal)
89
+
90
+    if ($t || (($ouv != $name) and !$fusion_bal)) {
91
+        $phraseur->res .= ($ouv ? ('<' . $ouv . '>') : '') . $t . "</" . $name . ">";
92
+    } else {
93
+        $phraseur->res .= ($ouv ? ('<' . $ouv . ' />') : ("</" . $name . ">"));
94
+    }
95 95
 }
96 96
 
97 97
 // https://code.spip.net/@xml_textElement
98 98
 function xml_textElement($phraseur, $data) {
99
-	$depth = $phraseur->depth;
100
-	$phraseur->contenu[$depth] .= preg_match('/^script/', $phraseur->ouvrant[$depth])
101
-		? $data
102
-		: xml_entites_html($data);
99
+    $depth = $phraseur->depth;
100
+    $phraseur->contenu[$depth] .= preg_match('/^script/', $phraseur->ouvrant[$depth])
101
+        ? $data
102
+        : xml_entites_html($data);
103 103
 }
104 104
 
105 105
 function xml_piElement($phraseur, $target, $data) {
106
-	$depth = $phraseur->depth;
107
-
108
-	if (strtolower($target) != "php") {
109
-		$phraseur->contenu[$depth] .= $data;
110
-	} else {
111
-		ob_start();
112
-		eval($data);
113
-		$data = ob_get_contents();
114
-		ob_end_clean();
115
-		$phraseur->contenu[$depth] .= $data;
116
-	}
106
+    $depth = $phraseur->depth;
107
+
108
+    if (strtolower($target) != "php") {
109
+        $phraseur->contenu[$depth] .= $data;
110
+    } else {
111
+        ob_start();
112
+        eval($data);
113
+        $data = ob_get_contents();
114
+        ob_end_clean();
115
+        $phraseur->contenu[$depth] .= $data;
116
+    }
117 117
 }
118 118
 
119 119
 
120 120
 // https://code.spip.net/@xml_defautElement
121 121
 function xml_defaultElement($phraseur, $data) {
122
-	$depth = $phraseur->depth;
122
+    $depth = $phraseur->depth;
123 123
 
124
-	if (!isset($phraseur->contenu[$depth])) {
125
-		$phraseur->contenu[$depth] = '';
126
-	}
127
-	$phraseur->contenu[$depth] .= $data;
124
+    if (!isset($phraseur->contenu[$depth])) {
125
+        $phraseur->contenu[$depth] = '';
126
+    }
127
+    $phraseur->contenu[$depth] .= $data;
128 128
 }
129 129
 
130 130
 // https://code.spip.net/@xml_parsestring
131 131
 function xml_parsestring($phraseur, $data) {
132
-	$phraseur->contenu[$phraseur->depth] = '';
133
-
134
-	if (!xml_parse($phraseur->sax, $data, true)) {
135
-		coordonnees_erreur($phraseur,
136
-			xml_error_string(xml_get_error_code($phraseur->sax))
137
-			. "<br />\n" .
138
-			(!$phraseur->depth ? '' :
139
-				('(' .
140
-					_T('erreur_balise_non_fermee') .
141
-					" <tt>" .
142
-					$phraseur->ouvrant[$phraseur->depth] .
143
-					"</tt> " .
144
-					_T('ligne') .
145
-					" " .
146
-					$phraseur->reperes[$phraseur->depth] .
147
-					") <br />\n")));
148
-	}
132
+    $phraseur->contenu[$phraseur->depth] = '';
133
+
134
+    if (!xml_parse($phraseur->sax, $data, true)) {
135
+        coordonnees_erreur($phraseur,
136
+            xml_error_string(xml_get_error_code($phraseur->sax))
137
+            . "<br />\n" .
138
+            (!$phraseur->depth ? '' :
139
+                ('(' .
140
+                    _T('erreur_balise_non_fermee') .
141
+                    " <tt>" .
142
+                    $phraseur->ouvrant[$phraseur->depth] .
143
+                    "</tt> " .
144
+                    _T('ligne') .
145
+                    " " .
146
+                    $phraseur->reperes[$phraseur->depth] .
147
+                    ") <br />\n")));
148
+    }
149 149
 }
150 150
 
151 151
 // https://code.spip.net/@coordonnees_erreur
152 152
 function coordonnees_erreur($phraseur, $msg) {
153
-	$entete_length = substr_count($phraseur->entete, "\n");
154
-	$phraseur->err[] = array(
155
-		$msg,
156
-		xml_get_current_line_number($phraseur->sax) + $entete_length,
157
-		xml_get_current_column_number($phraseur->sax)
158
-	);
153
+    $entete_length = substr_count($phraseur->entete, "\n");
154
+    $phraseur->err[] = array(
155
+        $msg,
156
+        xml_get_current_line_number($phraseur->sax) + $entete_length,
157
+        xml_get_current_column_number($phraseur->sax)
158
+    );
159 159
 }
160 160
 
161 161
 // https://code.spip.net/@xml_sax_dist
162 162
 function xml_sax_dist($page, $apply = false, $phraseur = null, $doctype = '', $charset = null) {
163
-	if (is_null($charset)) {
164
-		$charset = $GLOBALS['meta']['charset'];
165
-	}
166
-	if ($apply) {
167
-		ob_start();
168
-		if (is_array($apply)) {
169
-			$r = call_user_func_array($page, $apply);
170
-		} else {
171
-			$r = $page();
172
-		}
173
-		$page = ob_get_contents();
174
-		ob_end_clean();
175
-		// fonction sans aucun "echo", ca doit etre le resultat
176
-		if (!$page) {
177
-			$page = $r;
178
-		}
179
-	}
180
-
181
-	if (!$page) {
182
-		return '';
183
-	}
184
-	// charger la DTD et transcoder les entites,
185
-	// et escamoter le doctype que sax mange en php5 mais pas en  php4
186
-	if (!$doctype) {
187
-		if (!$r = analyser_doctype($page)) {
188
-			$page = _MESSAGE_DOCTYPE . _DOCTYPE_ECRIRE
189
-				. preg_replace(_REGEXP_DOCTYPE, '', $page);
190
-			$r = analyser_doctype($page);
191
-		}
192
-		list($entete, $avail, $grammaire, $rotlvl) = array_pad($r, 4, null);
193
-		$page = substr($page, strlen($entete));
194
-	} else {
195
-		$avail = 'SYSTEM';
196
-		$grammaire = $doctype;
197
-		$rotlvl = basename($grammaire);
198
-	}
199
-
200
-	include_spip('xml/analyser_dtd');
201
-	$dtc = charger_dtd($grammaire, $avail, $rotlvl);
202
-	$page = sax_bug($page, $dtc, $charset);
203
-
204
-	// compatibilite Tidy espace public
205
-	if (!$phraseur) {
206
-		$indenter_xml = charger_fonction('indenter', 'xml');
207
-
208
-		return $indenter_xml($page, $apply);
209
-	}
210
-
211
-	$xml_parser = xml_parser_create($charset);
212
-
213
-	xml_set_element_handler($xml_parser,
214
-		array($phraseur, "debutElement"),
215
-		array($phraseur, "finElement"));
216
-
217
-	xml_set_character_data_handler($xml_parser,
218
-		array($phraseur, "textElement"));
219
-
220
-	xml_set_processing_instruction_handler($xml_parser,
221
-		array($phraseur, 'piElement'));
222
-
223
-	xml_set_default_handler($xml_parser,
224
-		array($phraseur, "defaultElement"));
225
-
226
-	xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, false);
227
-
228
-	$phraseur->sax = $xml_parser;
229
-	if (isset($entete)) {
230
-		$phraseur->entete = $entete;
231
-	}
232
-	$phraseur->page = $page;
233
-	$phraseur->dtc = $dtc;
234
-	$phraseur->phraserTout($xml_parser, $page);
235
-	xml_parser_free($xml_parser);
236
-	$phraseur->sax = '';
237
-
238
-	return $phraseur;
163
+    if (is_null($charset)) {
164
+        $charset = $GLOBALS['meta']['charset'];
165
+    }
166
+    if ($apply) {
167
+        ob_start();
168
+        if (is_array($apply)) {
169
+            $r = call_user_func_array($page, $apply);
170
+        } else {
171
+            $r = $page();
172
+        }
173
+        $page = ob_get_contents();
174
+        ob_end_clean();
175
+        // fonction sans aucun "echo", ca doit etre le resultat
176
+        if (!$page) {
177
+            $page = $r;
178
+        }
179
+    }
180
+
181
+    if (!$page) {
182
+        return '';
183
+    }
184
+    // charger la DTD et transcoder les entites,
185
+    // et escamoter le doctype que sax mange en php5 mais pas en  php4
186
+    if (!$doctype) {
187
+        if (!$r = analyser_doctype($page)) {
188
+            $page = _MESSAGE_DOCTYPE . _DOCTYPE_ECRIRE
189
+                . preg_replace(_REGEXP_DOCTYPE, '', $page);
190
+            $r = analyser_doctype($page);
191
+        }
192
+        list($entete, $avail, $grammaire, $rotlvl) = array_pad($r, 4, null);
193
+        $page = substr($page, strlen($entete));
194
+    } else {
195
+        $avail = 'SYSTEM';
196
+        $grammaire = $doctype;
197
+        $rotlvl = basename($grammaire);
198
+    }
199
+
200
+    include_spip('xml/analyser_dtd');
201
+    $dtc = charger_dtd($grammaire, $avail, $rotlvl);
202
+    $page = sax_bug($page, $dtc, $charset);
203
+
204
+    // compatibilite Tidy espace public
205
+    if (!$phraseur) {
206
+        $indenter_xml = charger_fonction('indenter', 'xml');
207
+
208
+        return $indenter_xml($page, $apply);
209
+    }
210
+
211
+    $xml_parser = xml_parser_create($charset);
212
+
213
+    xml_set_element_handler($xml_parser,
214
+        array($phraseur, "debutElement"),
215
+        array($phraseur, "finElement"));
216
+
217
+    xml_set_character_data_handler($xml_parser,
218
+        array($phraseur, "textElement"));
219
+
220
+    xml_set_processing_instruction_handler($xml_parser,
221
+        array($phraseur, 'piElement'));
222
+
223
+    xml_set_default_handler($xml_parser,
224
+        array($phraseur, "defaultElement"));
225
+
226
+    xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, false);
227
+
228
+    $phraseur->sax = $xml_parser;
229
+    if (isset($entete)) {
230
+        $phraseur->entete = $entete;
231
+    }
232
+    $phraseur->page = $page;
233
+    $phraseur->dtc = $dtc;
234
+    $phraseur->phraserTout($xml_parser, $page);
235
+    xml_parser_free($xml_parser);
236
+    $phraseur->sax = '';
237
+
238
+    return $phraseur;
239 239
 }
240 240
 
241 241
 // SAX ne dit pas si une Entite est dans un attribut ou non.
@@ -247,24 +247,24 @@  discard block
 block discarded – undo
247 247
 
248 248
 // https://code.spip.net/@sax_bug
249 249
 function sax_bug($data, $dtc, $charset = null) {
250
-	if (is_null($charset)) {
251
-		$charset = $GLOBALS['meta']['charset'];
252
-	}
253
-
254
-	if ($dtc) {
255
-		$trans = array();
256
-
257
-		foreach ($dtc->entites as $k => $v) {
258
-			if (!strpos(" amp lt gt quot ", $k)) {
259
-				$trans["&$k;"] = $v;
260
-			}
261
-		}
262
-		$data = strtr($data, $trans);
263
-	} else {
264
-		$data = html2unicode($data, true);
265
-	}
266
-
267
-	return unicode2charset($data, $charset);
250
+    if (is_null($charset)) {
251
+        $charset = $GLOBALS['meta']['charset'];
252
+    }
253
+
254
+    if ($dtc) {
255
+        $trans = array();
256
+
257
+        foreach ($dtc->entites as $k => $v) {
258
+            if (!strpos(" amp lt gt quot ", $k)) {
259
+                $trans["&$k;"] = $v;
260
+            }
261
+        }
262
+        $data = strtr($data, $trans);
263
+    } else {
264
+        $data = html2unicode($data, true);
265
+    }
266
+
267
+    return unicode2charset($data, $charset);
268 268
 }
269 269
 
270 270
 // Retirer < ? xml... ? > et autre PI, ainsi que les commentaires en debut
@@ -275,52 +275,52 @@  discard block
 block discarded – undo
275 275
 // mais un XML Schema que SPIP ne fait pas encore lire.
276 276
 // https://code.spip.net/@analyser_doctype
277 277
 function analyser_doctype($data) {
278
-	if (!preg_match(_REGEXP_DOCTYPE, $data, $page)) {
279
-		if (preg_match(_REGEXP_XML, $data, $page)) {
280
-			list(, $entete, $topelement) = $page;
281
-			if ($topelement == 'rss') {
282
-				return array(
283
-					$entete,
284
-					'PUBLIC',
285
-					_DOCTYPE_RSS,
286
-					'rss-0.91.dtd'
287
-				);
288
-			} else {
289
-				$dtd = $topelement . '.dtd';
290
-				$f = find_in_path($dtd);
291
-				if (file_exists($f)) {
292
-					return array($entete, 'SYSTEM', $f, $dtd);
293
-				}
294
-			}
295
-		}
296
-		spip_log("Dtd pas vu pour " . substr($data, 0, 100));
297
-
298
-		return array();
299
-	}
300
-	list($entete, , $topelement, $avail, $suite) = $page;
301
-
302
-	if (!preg_match('/^"([^"]*)"\s*(.*)$/', $suite, $r)) {
303
-		if (!preg_match("/^'([^']*)'\s*(.*)$/", $suite, $r)) {
304
-			return array();
305
-		}
306
-	}
307
-	list(, $rotlvl, $suite) = $r;
308
-
309
-	if (!$suite) {
310
-		if ($avail != 'SYSTEM') {
311
-			return array();
312
-		}
313
-		$grammaire = $rotlvl;
314
-		$rotlvl = '';
315
-	} else {
316
-		if (!preg_match('/^"([^"]*)"\s*$/', $suite, $r)) {
317
-			if (!preg_match("/^'([^']*)'\s*$/", $suite, $r)) {
318
-				return array();
319
-			}
320
-		}
321
-
322
-		$grammaire = $r[1];
323
-	}
324
-
325
-	return array($entete, $avail, $grammaire, $rotlvl);
278
+    if (!preg_match(_REGEXP_DOCTYPE, $data, $page)) {
279
+        if (preg_match(_REGEXP_XML, $data, $page)) {
280
+            list(, $entete, $topelement) = $page;
281
+            if ($topelement == 'rss') {
282
+                return array(
283
+                    $entete,
284
+                    'PUBLIC',
285
+                    _DOCTYPE_RSS,
286
+                    'rss-0.91.dtd'
287
+                );
288
+            } else {
289
+                $dtd = $topelement . '.dtd';
290
+                $f = find_in_path($dtd);
291
+                if (file_exists($f)) {
292
+                    return array($entete, 'SYSTEM', $f, $dtd);
293
+                }
294
+            }
295
+        }
296
+        spip_log("Dtd pas vu pour " . substr($data, 0, 100));
297
+
298
+        return array();
299
+    }
300
+    list($entete, , $topelement, $avail, $suite) = $page;
301
+
302
+    if (!preg_match('/^"([^"]*)"\s*(.*)$/', $suite, $r)) {
303
+        if (!preg_match("/^'([^']*)'\s*(.*)$/", $suite, $r)) {
304
+            return array();
305
+        }
306
+    }
307
+    list(, $rotlvl, $suite) = $r;
308
+
309
+    if (!$suite) {
310
+        if ($avail != 'SYSTEM') {
311
+            return array();
312
+        }
313
+        $grammaire = $rotlvl;
314
+        $rotlvl = '';
315
+    } else {
316
+        if (!preg_match('/^"([^"]*)"\s*$/', $suite, $r)) {
317
+            if (!preg_match("/^'([^']*)'\s*$/", $suite, $r)) {
318
+                return array();
319
+            }
320
+        }
321
+
322
+        $grammaire = $r[1];
323
+    }
324
+
325
+    return array($entete, $avail, $grammaire, $rotlvl);
326 326
 }
Please login to merge, or discard this patch.
ecrire/public/balises.php 3 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -2884,8 +2884,7 @@
 block discarded – undo
2884 2884
 	$_const = interprete_argument_balise(1, $p);
2885 2885
 	if (!strlen($_const)) {
2886 2886
 		$p->code = "''";
2887
-	}
2888
-	else {
2887
+	} else {
2889 2888
 		$p->code = "(defined($_const)?constant($_const):'')";
2890 2889
 	}
2891 2890
 	$p->interdire_scripts = false;
Please login to merge, or discard this patch.
Indentation   +913 added lines, -913 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
  **/
27 27
 
28 28
 if (!defined('_ECRIRE_INC_VERSION')) {
29
-	return;
29
+    return;
30 30
 }
31 31
 
32 32
 /**
@@ -48,14 +48,14 @@  discard block
 block discarded – undo
48 48
  *     Code PHP si cet argument est présent, sinon null
49 49
  **/
50 50
 function interprete_argument_balise($n, $p) {
51
-	if (($p->param) && (!$p->param[0][0]) && (count($p->param[0]) > $n)) {
52
-		return calculer_liste($p->param[0][$n],
53
-			$p->descr,
54
-			$p->boucles,
55
-			$p->id_boucle);
56
-	} else {
57
-		return null;
58
-	}
51
+    if (($p->param) && (!$p->param[0][0]) && (count($p->param[0]) > $n)) {
52
+        return calculer_liste($p->param[0][$n],
53
+            $p->descr,
54
+            $p->boucles,
55
+            $p->id_boucle);
56
+    } else {
57
+        return null;
58
+    }
59 59
 }
60 60
 
61 61
 
@@ -75,10 +75,10 @@  discard block
 block discarded – undo
75 75
  *     Pile complétée par le code à générer
76 76
  **/
77 77
 function balise_NOM_SITE_SPIP_dist($p) {
78
-	$p->code = "\$GLOBALS['meta']['nom_site']";
78
+    $p->code = "\$GLOBALS['meta']['nom_site']";
79 79
 
80
-	#$p->interdire_scripts = true;
81
-	return $p;
80
+    #$p->interdire_scripts = true;
81
+    return $p;
82 82
 }
83 83
 
84 84
 /**
@@ -94,10 +94,10 @@  discard block
 block discarded – undo
94 94
  *     Pile complétée par le code à générer
95 95
  **/
96 96
 function balise_EMAIL_WEBMASTER_dist($p) {
97
-	$p->code = "\$GLOBALS['meta']['email_webmaster']";
97
+    $p->code = "\$GLOBALS['meta']['email_webmaster']";
98 98
 
99
-	#$p->interdire_scripts = true;
100
-	return $p;
99
+    #$p->interdire_scripts = true;
100
+    return $p;
101 101
 }
102 102
 
103 103
 /**
@@ -113,10 +113,10 @@  discard block
 block discarded – undo
113 113
  *     Pile complétée par le code à générer
114 114
  **/
115 115
 function balise_DESCRIPTIF_SITE_SPIP_dist($p) {
116
-	$p->code = "\$GLOBALS['meta']['descriptif_site']";
116
+    $p->code = "\$GLOBALS['meta']['descriptif_site']";
117 117
 
118
-	#$p->interdire_scripts = true;
119
-	return $p;
118
+    #$p->interdire_scripts = true;
119
+    return $p;
120 120
 }
121 121
 
122 122
 
@@ -137,10 +137,10 @@  discard block
 block discarded – undo
137 137
  *     Pile complétée par le code à générer
138 138
  **/
139 139
 function balise_CHARSET_dist($p) {
140
-	$p->code = "\$GLOBALS['meta']['charset']";
140
+    $p->code = "\$GLOBALS['meta']['charset']";
141 141
 
142
-	#$p->interdire_scripts = true;
143
-	return $p;
142
+    #$p->interdire_scripts = true;
143
+    return $p;
144 144
 }
145 145
 
146 146
 /**
@@ -165,11 +165,11 @@  discard block
 block discarded – undo
165 165
  *     Pile complétée par le code à générer
166 166
  **/
167 167
 function balise_LANG_LEFT_dist($p) {
168
-	$_lang = champ_sql('lang', $p);
169
-	$p->code = "lang_dir($_lang, 'left','right')";
170
-	$p->interdire_scripts = false;
168
+    $_lang = champ_sql('lang', $p);
169
+    $p->code = "lang_dir($_lang, 'left','right')";
170
+    $p->interdire_scripts = false;
171 171
 
172
-	return $p;
172
+    return $p;
173 173
 }
174 174
 
175 175
 /**
@@ -189,11 +189,11 @@  discard block
 block discarded – undo
189 189
  *     Pile complétée par le code à générer
190 190
  **/
191 191
 function balise_LANG_RIGHT_dist($p) {
192
-	$_lang = champ_sql('lang', $p);
193
-	$p->code = "lang_dir($_lang, 'right','left')";
194
-	$p->interdire_scripts = false;
192
+    $_lang = champ_sql('lang', $p);
193
+    $p->code = "lang_dir($_lang, 'right','left')";
194
+    $p->interdire_scripts = false;
195 195
 
196
-	return $p;
196
+    return $p;
197 197
 }
198 198
 
199 199
 /**
@@ -218,11 +218,11 @@  discard block
 block discarded – undo
218 218
  *     Pile complétée par le code à générer
219 219
  **/
220 220
 function balise_LANG_DIR_dist($p) {
221
-	$_lang = champ_sql('lang', $p);
222
-	$p->code = "lang_dir($_lang, 'ltr','rtl')";
223
-	$p->interdire_scripts = false;
221
+    $_lang = champ_sql('lang', $p);
222
+    $p->code = "lang_dir($_lang, 'ltr','rtl')";
223
+    $p->interdire_scripts = false;
224 224
 
225
-	return $p;
225
+    return $p;
226 226
 }
227 227
 
228 228
 
@@ -239,10 +239,10 @@  discard block
 block discarded – undo
239 239
  *     Pile complétée par le code à générer
240 240
  **/
241 241
 function balise_PUCE_dist($p) {
242
-	$p->code = "definir_puce()";
243
-	$p->interdire_scripts = false;
242
+    $p->code = "definir_puce()";
243
+    $p->interdire_scripts = false;
244 244
 
245
-	return $p;
245
+    return $p;
246 246
 }
247 247
 
248 248
 
@@ -266,12 +266,12 @@  discard block
 block discarded – undo
266 266
  *     Pile completée du code PHP d'exécution de la balise
267 267
  */
268 268
 function balise_DATE_dist($p) {
269
-	$d = champ_sql('date', $p);
269
+    $d = champ_sql('date', $p);
270 270
 #	if ($d === "@\$Pile[0]['date']")
271 271
 #		$d = "isset(\$Pile[0]['date']) ? $d : time()";
272
-	$p->code = $d;
272
+    $p->code = $d;
273 273
 
274
-	return $p;
274
+    return $p;
275 275
 }
276 276
 
277 277
 
@@ -291,13 +291,13 @@  discard block
 block discarded – undo
291 291
  *     Pile completée du code PHP d'exécution de la balise
292 292
  */
293 293
 function balise_DATE_REDAC_dist($p) {
294
-	$d = champ_sql('date_redac', $p);
294
+    $d = champ_sql('date_redac', $p);
295 295
 #	if ($d === "@\$Pile[0]['date_redac']")
296 296
 #		$d = "isset(\$Pile[0]['date_redac']) ? $d : time()";
297
-	$p->code = $d;
298
-	$p->interdire_scripts = false;
297
+    $p->code = $d;
298
+    $p->interdire_scripts = false;
299 299
 
300
-	return $p;
300
+    return $p;
301 301
 }
302 302
 
303 303
 /**
@@ -316,10 +316,10 @@  discard block
 block discarded – undo
316 316
  *     Pile completée du code PHP d'exécution de la balise
317 317
  */
318 318
 function balise_DATE_MODIF_dist($p) {
319
-	$p->code = champ_sql('date_modif', $p);
320
-	$p->interdire_scripts = false;
319
+    $p->code = champ_sql('date_modif', $p);
320
+    $p->interdire_scripts = false;
321 321
 
322
-	return $p;
322
+    return $p;
323 323
 }
324 324
 
325 325
 /**
@@ -337,13 +337,13 @@  discard block
 block discarded – undo
337 337
  *     Pile completée du code PHP d'exécution de la balise
338 338
  */
339 339
 function balise_DATE_NOUVEAUTES_dist($p) {
340
-	$p->code = "((\$GLOBALS['meta']['quoi_de_neuf'] == 'oui'
340
+    $p->code = "((\$GLOBALS['meta']['quoi_de_neuf'] == 'oui'
341 341
 	AND isset(\$GLOBALS['meta']['dernier_envoi_neuf'])) ?
342 342
 	\$GLOBALS['meta']['dernier_envoi_neuf'] :
343 343
 	\"'0000-00-00'\")";
344
-	$p->interdire_scripts = false;
344
+    $p->interdire_scripts = false;
345 345
 
346
-	return $p;
346
+    return $p;
347 347
 }
348 348
 
349 349
 
@@ -362,11 +362,11 @@  discard block
 block discarded – undo
362 362
  *     Pile completée du code PHP d'exécution de la balise
363 363
  */
364 364
 function balise_DOSSIER_SQUELETTE_dist($p) {
365
-	$code = substr(addslashes(dirname($p->descr['sourcefile'])), strlen(_DIR_RACINE));
366
-	$p->code = "_DIR_RACINE . '$code'" .
367
-		$p->interdire_scripts = false;
365
+    $code = substr(addslashes(dirname($p->descr['sourcefile'])), strlen(_DIR_RACINE));
366
+    $p->code = "_DIR_RACINE . '$code'" .
367
+        $p->interdire_scripts = false;
368 368
 
369
-	return $p;
369
+    return $p;
370 370
 }
371 371
 
372 372
 /**
@@ -381,11 +381,11 @@  discard block
 block discarded – undo
381 381
  *     Pile completée du code PHP d'exécution de la balise
382 382
  */
383 383
 function balise_SQUELETTE_dist($p) {
384
-	$code = addslashes($p->descr['sourcefile']);
385
-	$p->code = "'$code'" .
386
-		$p->interdire_scripts = false;
384
+    $code = addslashes($p->descr['sourcefile']);
385
+    $p->code = "'$code'" .
386
+        $p->interdire_scripts = false;
387 387
 
388
-	return $p;
388
+    return $p;
389 389
 }
390 390
 
391 391
 /**
@@ -404,10 +404,10 @@  discard block
 block discarded – undo
404 404
  *     Pile completée du code PHP d'exécution de la balise
405 405
  */
406 406
 function balise_SPIP_VERSION_dist($p) {
407
-	$p->code = "spip_version()";
408
-	$p->interdire_scripts = false;
407
+    $p->code = "spip_version()";
408
+    $p->interdire_scripts = false;
409 409
 
410
-	return $p;
410
+    return $p;
411 411
 }
412 412
 
413 413
 
@@ -433,18 +433,18 @@  discard block
 block discarded – undo
433 433
  *     Pile complétée par le code à générer
434 434
  **/
435 435
 function balise_NOM_SITE_dist($p) {
436
-	if (!$p->etoile) {
437
-		$p->code = "supprimer_numero(calculer_url(" .
438
-			champ_sql('url_site', $p) . "," .
439
-			champ_sql('nom_site', $p) .
440
-			", 'titre', \$connect, false))";
441
-	} else {
442
-		$p->code = champ_sql('nom_site', $p);
443
-	}
436
+    if (!$p->etoile) {
437
+        $p->code = "supprimer_numero(calculer_url(" .
438
+            champ_sql('url_site', $p) . "," .
439
+            champ_sql('nom_site', $p) .
440
+            ", 'titre', \$connect, false))";
441
+    } else {
442
+        $p->code = champ_sql('nom_site', $p);
443
+    }
444 444
 
445
-	$p->interdire_scripts = true;
445
+    $p->interdire_scripts = true;
446 446
 
447
-	return $p;
447
+    return $p;
448 448
 }
449 449
 
450 450
 
@@ -461,11 +461,11 @@  discard block
 block discarded – undo
461 461
  *     Pile complétée par le code à générer
462 462
  **/
463 463
 function balise_NOTES_dist($p) {
464
-	// Recuperer les notes
465
-	$p->code = 'calculer_notes()';
464
+    // Recuperer les notes
465
+    $p->code = 'calculer_notes()';
466 466
 
467
-	#$p->interdire_scripts = true;
468
-	return $p;
467
+    #$p->interdire_scripts = true;
468
+    return $p;
469 469
 }
470 470
 
471 471
 
@@ -487,10 +487,10 @@  discard block
 block discarded – undo
487 487
  *     Pile complétée par le code à générer
488 488
  **/
489 489
 function balise_RECHERCHE_dist($p) {
490
-	$p->code = 'entites_html(_request("recherche"))';
491
-	$p->interdire_scripts = false;
490
+    $p->code = 'entites_html(_request("recherche"))';
491
+    $p->interdire_scripts = false;
492 492
 
493
-	return $p;
493
+    return $p;
494 494
 }
495 495
 
496 496
 
@@ -508,17 +508,17 @@  discard block
 block discarded – undo
508 508
  *     Pile complétée par le code à générer
509 509
  **/
510 510
 function balise_COMPTEUR_BOUCLE_dist($p) {
511
-	$b = index_boucle_mere($p);
512
-	if ($b === '') {
513
-		$msg = array('zbug_champ_hors_boucle', array('champ' => zbug_presenter_champ($p)));
514
-		erreur_squelette($msg, $p);
515
-	} else {
516
-		$p->code = "\$Numrows['$b']['compteur_boucle']";
517
-		$p->boucles[$b]->cptrows = true;
518
-		$p->interdire_scripts = false;
511
+    $b = index_boucle_mere($p);
512
+    if ($b === '') {
513
+        $msg = array('zbug_champ_hors_boucle', array('champ' => zbug_presenter_champ($p)));
514
+        erreur_squelette($msg, $p);
515
+    } else {
516
+        $p->code = "\$Numrows['$b']['compteur_boucle']";
517
+        $p->boucles[$b]->cptrows = true;
518
+        $p->interdire_scripts = false;
519 519
 
520
-		return $p;
521
-	}
520
+        return $p;
521
+    }
522 522
 }
523 523
 
524 524
 /**
@@ -536,17 +536,17 @@  discard block
 block discarded – undo
536 536
  *     Pile complétée par le code à générer
537 537
  **/
538 538
 function balise_TOTAL_BOUCLE_dist($p) {
539
-	$b = index_boucle_mere($p);
540
-	if ($b === '') {
541
-		$msg = array('zbug_champ_hors_boucle', array('champ' => zbug_presenter_champ($p)));
542
-		erreur_squelette($msg, $p);
543
-	} else {
544
-		$p->code = "\$Numrows['$b']['total']";
545
-		$p->boucles[$b]->numrows = true;
546
-		$p->interdire_scripts = false;
547
-	}
539
+    $b = index_boucle_mere($p);
540
+    if ($b === '') {
541
+        $msg = array('zbug_champ_hors_boucle', array('champ' => zbug_presenter_champ($p)));
542
+        erreur_squelette($msg, $p);
543
+    } else {
544
+        $p->code = "\$Numrows['$b']['total']";
545
+        $p->boucles[$b]->numrows = true;
546
+        $p->interdire_scripts = false;
547
+    }
548 548
 
549
-	return $p;
549
+    return $p;
550 550
 }
551 551
 
552 552
 
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
  *     Pile complétée par le code à générer
567 567
  **/
568 568
 function balise_POINTS_dist($p) {
569
-	return rindex_pile($p, 'points', 'recherche');
569
+    return rindex_pile($p, 'points', 'recherche');
570 570
 }
571 571
 
572 572
 
@@ -587,12 +587,12 @@  discard block
 block discarded – undo
587 587
  *     Pile complétée par le code à générer
588 588
  **/
589 589
 function balise_POPULARITE_ABSOLUE_dist($p) {
590
-	$p->code = 'ceil(' .
591
-		champ_sql('popularite', $p) .
592
-		')';
593
-	$p->interdire_scripts = false;
590
+    $p->code = 'ceil(' .
591
+        champ_sql('popularite', $p) .
592
+        ')';
593
+    $p->interdire_scripts = false;
594 594
 
595
-	return $p;
595
+    return $p;
596 596
 }
597 597
 
598 598
 /**
@@ -612,10 +612,10 @@  discard block
 block discarded – undo
612 612
  *     Pile complétée par le code à générer
613 613
  **/
614 614
 function balise_POPULARITE_SITE_dist($p) {
615
-	$p->code = 'ceil($GLOBALS["meta"][\'popularite_total\'])';
616
-	$p->interdire_scripts = false;
615
+    $p->code = 'ceil($GLOBALS["meta"][\'popularite_total\'])';
616
+    $p->interdire_scripts = false;
617 617
 
618
-	return $p;
618
+    return $p;
619 619
 }
620 620
 
621 621
 /**
@@ -636,10 +636,10 @@  discard block
 block discarded – undo
636 636
  *     Pile complétée par le code à générer
637 637
  **/
638 638
 function balise_POPULARITE_MAX_dist($p) {
639
-	$p->code = 'ceil($GLOBALS["meta"][\'popularite_max\'])';
640
-	$p->interdire_scripts = false;
639
+    $p->code = 'ceil($GLOBALS["meta"][\'popularite_max\'])';
640
+    $p->interdire_scripts = false;
641 641
 
642
-	return $p;
642
+    return $p;
643 643
 }
644 644
 
645 645
 
@@ -665,14 +665,14 @@  discard block
 block discarded – undo
665 665
  *     Pile complétée par le code à générer
666 666
  **/
667 667
 function balise_VALEUR_dist($p) {
668
-	$b = $p->nom_boucle ? $p->nom_boucle : $p->id_boucle;
669
-	$p->code = index_pile($p->id_boucle, 'valeur', $p->boucles, $b);;
670
-	if (($v = interprete_argument_balise(1, $p)) !== null) {
671
-		$p->code = 'table_valeur(' . $p->code . ', ' . $v . ')';
672
-	}
673
-	$p->interdire_scripts = true;
668
+    $b = $p->nom_boucle ? $p->nom_boucle : $p->id_boucle;
669
+    $p->code = index_pile($p->id_boucle, 'valeur', $p->boucles, $b);;
670
+    if (($v = interprete_argument_balise(1, $p)) !== null) {
671
+        $p->code = 'table_valeur(' . $p->code . ', ' . $v . ')';
672
+    }
673
+    $p->interdire_scripts = true;
674 674
 
675
-	return $p;
675
+    return $p;
676 676
 }
677 677
 
678 678
 /**
@@ -701,17 +701,17 @@  discard block
 block discarded – undo
701 701
  *     Pile complétée par le code à générer
702 702
  **/
703 703
 function balise_EXPOSE_dist($p) {
704
-	$on = "'on'";
705
-	$off = "''";
706
-	if (($v = interprete_argument_balise(1, $p)) !== null) {
707
-		$on = $v;
708
-		if (($v = interprete_argument_balise(2, $p)) !== null) {
709
-			$off = $v;
710
-		}
704
+    $on = "'on'";
705
+    $off = "''";
706
+    if (($v = interprete_argument_balise(1, $p)) !== null) {
707
+        $on = $v;
708
+        if (($v = interprete_argument_balise(2, $p)) !== null) {
709
+            $off = $v;
710
+        }
711 711
 
712
-	}
712
+    }
713 713
 
714
-	return calculer_balise_expose($p, $on, $off);
714
+    return calculer_balise_expose($p, $on, $off);
715 715
 }
716 716
 
717 717
 /**
@@ -729,36 +729,36 @@  discard block
 block discarded – undo
729 729
  *     Pile complétée par le code à générer
730 730
  **/
731 731
 function calculer_balise_expose($p, $on, $off) {
732
-	$b = index_boucle($p);
733
-	if (empty($p->boucles[$b]->primary)) {
734
-		$msg = array('zbug_champ_hors_boucle', array('champ' => zbug_presenter_champ($p)));
735
-		erreur_squelette($msg, $p);
736
-	} else {
732
+    $b = index_boucle($p);
733
+    if (empty($p->boucles[$b]->primary)) {
734
+        $msg = array('zbug_champ_hors_boucle', array('champ' => zbug_presenter_champ($p)));
735
+        erreur_squelette($msg, $p);
736
+    } else {
737 737
 
738
-		$key = $p->boucles[$b]->primary;
739
-		$type = $p->boucles[$p->id_boucle]->primary;
740
-		$desc = $p->boucles[$b]->show;
741
-		$connect = sql_quote($p->boucles[$b]->sql_serveur);
738
+        $key = $p->boucles[$b]->primary;
739
+        $type = $p->boucles[$p->id_boucle]->primary;
740
+        $desc = $p->boucles[$b]->show;
741
+        $connect = sql_quote($p->boucles[$b]->sql_serveur);
742 742
 
743
-		// Ne pas utiliser champ_sql, on jongle avec le nom boucle explicite
744
-		$c = index_pile($p->id_boucle, $type, $p->boucles);
743
+        // Ne pas utiliser champ_sql, on jongle avec le nom boucle explicite
744
+        $c = index_pile($p->id_boucle, $type, $p->boucles);
745 745
 
746
-		if (isset($desc['field']['id_parent'])) {
747
-			$parent = 0; // pour if (!$parent) dans calculer_expose
748
-		} elseif (isset($desc['field']['id_rubrique'])) {
749
-			$parent = index_pile($p->id_boucle, 'id_rubrique', $p->boucles, $b);
750
-		} elseif (isset($desc['field']['id_groupe'])) {
751
-			$parent = index_pile($p->id_boucle, 'id_groupe', $p->boucles, $b);
752
-		} else {
753
-			$parent = "''";
754
-		}
746
+        if (isset($desc['field']['id_parent'])) {
747
+            $parent = 0; // pour if (!$parent) dans calculer_expose
748
+        } elseif (isset($desc['field']['id_rubrique'])) {
749
+            $parent = index_pile($p->id_boucle, 'id_rubrique', $p->boucles, $b);
750
+        } elseif (isset($desc['field']['id_groupe'])) {
751
+            $parent = index_pile($p->id_boucle, 'id_groupe', $p->boucles, $b);
752
+        } else {
753
+            $parent = "''";
754
+        }
755 755
 
756
-		$p->code = "(calcul_exposer($c, '$type', \$Pile[0], $parent, '$key', $connect) ? $on : $off)";
757
-	}
756
+        $p->code = "(calcul_exposer($c, '$type', \$Pile[0], $parent, '$key', $connect) ? $on : $off)";
757
+    }
758 758
 
759
-	$p->interdire_scripts = false;
759
+    $p->interdire_scripts = false;
760 760
 
761
-	return $p;
761
+    return $p;
762 762
 }
763 763
 
764 764
 
@@ -796,47 +796,47 @@  discard block
 block discarded – undo
796 796
  **/
797 797
 function balise_INTRODUCTION_dist($p) {
798 798
 
799
-	$type = $p->type_requete;
800
-
801
-	$_texte = champ_sql('texte', $p);
802
-	$trouver_table = charger_fonction('trouver_table', 'base');
803
-	$desc = $trouver_table(table_objet_sql($type));
804
-	$_descriptif = "''";
805
-	if ($desc and isset($desc['field']['descriptif'])) {
806
-		// notamment articles et rubriques mais aussi tout nouvel objet concerne
807
-		$_descriptif = champ_sql('descriptif', $p);
808
-	}
809
-
810
-	// notamment les articles mais aussi tout nouvel objet concerne
811
-	if ($desc and isset($desc['field']['chapo'])) {
812
-		$_chapo = champ_sql('chapo', $p);
813
-		$_texte = "(strlen($_descriptif))
799
+    $type = $p->type_requete;
800
+
801
+    $_texte = champ_sql('texte', $p);
802
+    $trouver_table = charger_fonction('trouver_table', 'base');
803
+    $desc = $trouver_table(table_objet_sql($type));
804
+    $_descriptif = "''";
805
+    if ($desc and isset($desc['field']['descriptif'])) {
806
+        // notamment articles et rubriques mais aussi tout nouvel objet concerne
807
+        $_descriptif = champ_sql('descriptif', $p);
808
+    }
809
+
810
+    // notamment les articles mais aussi tout nouvel objet concerne
811
+    if ($desc and isset($desc['field']['chapo'])) {
812
+        $_chapo = champ_sql('chapo', $p);
813
+        $_texte = "(strlen($_descriptif))
814 814
 		? ''
815 815
 		: $_chapo . \"\\n\\n\" . $_texte";
816
-	}
816
+    }
817 817
 
818
-	// longueur en parametre, ou valeur par defaut
819
-	$longueur_defaut = objet_info($type, 'introduction_longueur');
820
-	if (!$longueur_defaut) {
821
-		$longueur_defaut = 600;
822
-	}
818
+    // longueur en parametre, ou valeur par defaut
819
+    $longueur_defaut = objet_info($type, 'introduction_longueur');
820
+    if (!$longueur_defaut) {
821
+        $longueur_defaut = 600;
822
+    }
823 823
 
824
-	$_suite = 'null';
825
-	$_longueur = $longueur_defaut;
826
-	if (($v = interprete_argument_balise(1, $p)) !== null) {
827
-		$_longueur = 'is_numeric(' . $v . ')?intval(' . $v . '):' . $longueur_defaut;
828
-		$_suite = '!is_numeric(' . $v . ')?' . $v . ':null';
829
-	}
830
-	if (($v2 = interprete_argument_balise(2, $p)) !== null) {
831
-		$_suite = $v2;
832
-	}
824
+    $_suite = 'null';
825
+    $_longueur = $longueur_defaut;
826
+    if (($v = interprete_argument_balise(1, $p)) !== null) {
827
+        $_longueur = 'is_numeric(' . $v . ')?intval(' . $v . '):' . $longueur_defaut;
828
+        $_suite = '!is_numeric(' . $v . ')?' . $v . ':null';
829
+    }
830
+    if (($v2 = interprete_argument_balise(2, $p)) !== null) {
831
+        $_suite = $v2;
832
+    }
833 833
 
834
-	$f = chercher_filtre('introduction');
835
-	$p->code = "$f($_descriptif, $_texte, $_longueur, \$connect, $_suite)";
834
+    $f = chercher_filtre('introduction');
835
+    $p->code = "$f($_descriptif, $_texte, $_longueur, \$connect, $_suite)";
836 836
 
837
-	#$p->interdire_scripts = true;
838
-	$p->etoile = '*'; // propre est deja fait dans le calcul de l'intro
839
-	return $p;
837
+    #$p->interdire_scripts = true;
838
+    $p->etoile = '*'; // propre est deja fait dans le calcul de l'intro
839
+    return $p;
840 840
 }
841 841
 
842 842
 
@@ -856,15 +856,15 @@  discard block
 block discarded – undo
856 856
  *     Pile complétée par le code à générer
857 857
  **/
858 858
 function balise_LANG_dist($p) {
859
-	$_lang = champ_sql('lang', $p);
860
-	if (!$p->etoile) {
861
-		$p->code = "spip_htmlentities($_lang ? $_lang : \$GLOBALS['spip_lang'])";
862
-	} else {
863
-		$p->code = "spip_htmlentities($_lang)";
864
-	}
865
-	$p->interdire_scripts = false;
859
+    $_lang = champ_sql('lang', $p);
860
+    if (!$p->etoile) {
861
+        $p->code = "spip_htmlentities($_lang ? $_lang : \$GLOBALS['spip_lang'])";
862
+    } else {
863
+        $p->code = "spip_htmlentities($_lang)";
864
+    }
865
+    $p->interdire_scripts = false;
866 866
 
867
-	return $p;
867
+    return $p;
868 868
 }
869 869
 
870 870
 /**
@@ -886,44 +886,44 @@  discard block
 block discarded – undo
886 886
  *     Pile complétée par le code à générer
887 887
  */
888 888
 function balise_LESAUTEURS_dist($p) {
889
-	// Cherche le champ 'lesauteurs' dans la pile
890
-	$_lesauteurs = champ_sql('lesauteurs', $p, false);
891
-
892
-	// Si le champ n'existe pas (cas de spip_articles), on applique
893
-	// le modele lesauteurs.html en passant id_article dans le contexte;
894
-	// dans le cas contraire on prend le champ 'lesauteurs'
895
-	// (cf extension sites/)
896
-	if ($_lesauteurs
897
-		and $_lesauteurs != '@$Pile[0][\'lesauteurs\']'
898
-	) {
899
-		$p->code = "safehtml($_lesauteurs)";
900
-		// $p->interdire_scripts = true;
901
-	} else {
902
-		if (!$p->id_boucle) {
903
-			$connect = '';
904
-			$objet = 'article';
905
-			$id_table_objet = 'id_article';
906
-		} else {
907
-			$b = $p->nom_boucle ? $p->nom_boucle : $p->id_boucle;
908
-			$connect = $p->boucles[$b]->sql_serveur;
909
-			$type_boucle = $p->boucles[$b]->type_requete;
910
-			$objet = objet_type($type_boucle);
911
-			$id_table_objet = id_table_objet($type_boucle);
912
-		}
913
-		$c = memoriser_contexte_compil($p);
914
-
915
-		$p->code = sprintf(CODE_RECUPERER_FOND, "'modeles/lesauteurs'",
916
-			"array('objet'=>'" . $objet .
917
-			"','id_objet' => " . champ_sql($id_table_objet, $p) .
918
-			",'$id_table_objet' => " . champ_sql($id_table_objet, $p) .
919
-			($objet == 'article' ? "" : ",'id_article' => " . champ_sql('id_article', $p)) .
920
-			")",
921
-			"'trim'=>true, 'compil'=>array($c)",
922
-			_q($connect));
923
-		$p->interdire_scripts = false; // securite apposee par recuperer_fond()
924
-	}
925
-
926
-	return $p;
889
+    // Cherche le champ 'lesauteurs' dans la pile
890
+    $_lesauteurs = champ_sql('lesauteurs', $p, false);
891
+
892
+    // Si le champ n'existe pas (cas de spip_articles), on applique
893
+    // le modele lesauteurs.html en passant id_article dans le contexte;
894
+    // dans le cas contraire on prend le champ 'lesauteurs'
895
+    // (cf extension sites/)
896
+    if ($_lesauteurs
897
+        and $_lesauteurs != '@$Pile[0][\'lesauteurs\']'
898
+    ) {
899
+        $p->code = "safehtml($_lesauteurs)";
900
+        // $p->interdire_scripts = true;
901
+    } else {
902
+        if (!$p->id_boucle) {
903
+            $connect = '';
904
+            $objet = 'article';
905
+            $id_table_objet = 'id_article';
906
+        } else {
907
+            $b = $p->nom_boucle ? $p->nom_boucle : $p->id_boucle;
908
+            $connect = $p->boucles[$b]->sql_serveur;
909
+            $type_boucle = $p->boucles[$b]->type_requete;
910
+            $objet = objet_type($type_boucle);
911
+            $id_table_objet = id_table_objet($type_boucle);
912
+        }
913
+        $c = memoriser_contexte_compil($p);
914
+
915
+        $p->code = sprintf(CODE_RECUPERER_FOND, "'modeles/lesauteurs'",
916
+            "array('objet'=>'" . $objet .
917
+            "','id_objet' => " . champ_sql($id_table_objet, $p) .
918
+            ",'$id_table_objet' => " . champ_sql($id_table_objet, $p) .
919
+            ($objet == 'article' ? "" : ",'id_article' => " . champ_sql('id_article', $p)) .
920
+            ")",
921
+            "'trim'=>true, 'compil'=>array($c)",
922
+            _q($connect));
923
+        $p->interdire_scripts = false; // securite apposee par recuperer_fond()
924
+    }
925
+
926
+    return $p;
927 927
 }
928 928
 
929 929
 
@@ -950,75 +950,75 @@  discard block
 block discarded – undo
950 950
  *     Pile complétée par le code à générer
951 951
  */
952 952
 function balise_RANG_dist($p) {
953
-	$b = index_boucle($p);
954
-	if ($b === '') {
955
-		$msg = array(
956
-			'zbug_champ_hors_boucle',
957
-			array('champ' => '#RANG')
958
-		);
959
-		erreur_squelette($msg, $p);
960
-	} else {
961
-		// chercher d'abord un champ sql rang (mais pas dans le env : defaut '' si on trouve pas de champ sql)
962
-		// dans la boucle immediatement englobante uniquement
963
-		// sinon on compose le champ calcule
964
-		$_rang = champ_sql('rang', $p, '', false);
965
-
966
-		// si pas trouve de champ sql rang :
967
-		if (!$_rang or $_rang == "''") {
968
-			$boucle = &$p->boucles[$b];
969
-
970
-			// on gere le cas ou #RANG est une extraction du numero dans le titre
971
-			$trouver_table = charger_fonction('trouver_table', 'base');
972
-			$desc = $trouver_table($boucle->id_table);
973
-			$_titre = ''; # où extraire le numero ?
953
+    $b = index_boucle($p);
954
+    if ($b === '') {
955
+        $msg = array(
956
+            'zbug_champ_hors_boucle',
957
+            array('champ' => '#RANG')
958
+        );
959
+        erreur_squelette($msg, $p);
960
+    } else {
961
+        // chercher d'abord un champ sql rang (mais pas dans le env : defaut '' si on trouve pas de champ sql)
962
+        // dans la boucle immediatement englobante uniquement
963
+        // sinon on compose le champ calcule
964
+        $_rang = champ_sql('rang', $p, '', false);
965
+
966
+        // si pas trouve de champ sql rang :
967
+        if (!$_rang or $_rang == "''") {
968
+            $boucle = &$p->boucles[$b];
969
+
970
+            // on gere le cas ou #RANG est une extraction du numero dans le titre
971
+            $trouver_table = charger_fonction('trouver_table', 'base');
972
+            $desc = $trouver_table($boucle->id_table);
973
+            $_titre = ''; # où extraire le numero ?
974 974
 			
975
-			if (isset($desc['titre'])) {
976
-				$t = $desc['titre'];
977
-				if (
978
-					// Soit on trouve avec la déclaration de la lang AVANT
979
-					preg_match(';(?:lang\s*,)\s*(.*?titre)\s*(,|$);', $t, $m)
980
-					// Soit on prend depuis le début
981
-					or preg_match(';^(.*?titre)\s*(,|$);', $t, $m)
982
-				) {
983
-					$m = preg_replace(',as\s+titre$,i', '', $m[1]);
984
-					$m = trim($m);
985
-					if ($m != "''") {
986
-						if (!preg_match(",\W,", $m)) {
987
-							$m = $boucle->id_table . ".$m";
988
-						}
975
+            if (isset($desc['titre'])) {
976
+                $t = $desc['titre'];
977
+                if (
978
+                    // Soit on trouve avec la déclaration de la lang AVANT
979
+                    preg_match(';(?:lang\s*,)\s*(.*?titre)\s*(,|$);', $t, $m)
980
+                    // Soit on prend depuis le début
981
+                    or preg_match(';^(.*?titre)\s*(,|$);', $t, $m)
982
+                ) {
983
+                    $m = preg_replace(',as\s+titre$,i', '', $m[1]);
984
+                    $m = trim($m);
985
+                    if ($m != "''") {
986
+                        if (!preg_match(",\W,", $m)) {
987
+                            $m = $boucle->id_table . ".$m";
988
+                        }
989 989
 						
990
-						$m .= " AS titre_rang";
991
-
992
-						$boucle->select[] = $m;
993
-						$_titre = '$Pile[$SP][\'titre_rang\']';
994
-					}
995
-				}
996
-			}
997
-
998
-			// si on n'a rien trouvé, on utilise le champ titre classique
999
-			if (!$_titre) {
1000
-				$_titre = champ_sql('titre', $p);
1001
-			}
1002
-
1003
-			// et on recupere aussi les infos de liaison si on est en train d'editer les liens justement
1004
-			// cas des formulaires xxx_lies utilises par #FORMULAIRE_EDITER_LIENS
1005
-			$type_boucle = $boucle->type_requete;
1006
-			$objet = objet_type($type_boucle);
1007
-			$id_table_objet = id_table_objet($type_boucle);
1008
-			$_primary = champ_sql($id_table_objet, $p, '', false);
1009
-			$_env = '$Pile[0]';
1010
-
1011
-			if (!$_titre) {$_titre = "''";}
1012
-			if (!$_primary) {$_primary = "''";}
1013
-			$_rang = "calculer_rang_smart($_titre, '$objet', $_primary, $_env)";
1014
-
1015
-		}
990
+                        $m .= " AS titre_rang";
991
+
992
+                        $boucle->select[] = $m;
993
+                        $_titre = '$Pile[$SP][\'titre_rang\']';
994
+                    }
995
+                }
996
+            }
997
+
998
+            // si on n'a rien trouvé, on utilise le champ titre classique
999
+            if (!$_titre) {
1000
+                $_titre = champ_sql('titre', $p);
1001
+            }
1002
+
1003
+            // et on recupere aussi les infos de liaison si on est en train d'editer les liens justement
1004
+            // cas des formulaires xxx_lies utilises par #FORMULAIRE_EDITER_LIENS
1005
+            $type_boucle = $boucle->type_requete;
1006
+            $objet = objet_type($type_boucle);
1007
+            $id_table_objet = id_table_objet($type_boucle);
1008
+            $_primary = champ_sql($id_table_objet, $p, '', false);
1009
+            $_env = '$Pile[0]';
1010
+
1011
+            if (!$_titre) {$_titre = "''";}
1012
+            if (!$_primary) {$_primary = "''";}
1013
+            $_rang = "calculer_rang_smart($_titre, '$objet', $_primary, $_env)";
1014
+
1015
+        }
1016 1016
 		
1017
-		$p->code = $_rang;
1018
-		$p->interdire_scripts = false;
1019
-	}
1017
+        $p->code = $_rang;
1018
+        $p->interdire_scripts = false;
1019
+    }
1020 1020
 	
1021
-	return $p;
1021
+    return $p;
1022 1022
 }
1023 1023
 
1024 1024
 
@@ -1040,12 +1040,12 @@  discard block
 block discarded – undo
1040 1040
  *     Pile complétée par le code à générer
1041 1041
  **/
1042 1042
 function balise_POPULARITE_dist($p) {
1043
-	$_popularite = champ_sql('popularite', $p);
1044
-	$p->code = "(ceil(min(100, 100 * $_popularite
1043
+    $_popularite = champ_sql('popularite', $p);
1044
+    $p->code = "(ceil(min(100, 100 * $_popularite
1045 1045
 	/ max(1 , 0 + \$GLOBALS['meta']['popularite_max']))))";
1046
-	$p->interdire_scripts = false;
1046
+    $p->interdire_scripts = false;
1047 1047
 
1048
-	return $p;
1048
+    return $p;
1049 1049
 }
1050 1050
 
1051 1051
 /**
@@ -1092,65 +1092,65 @@  discard block
 block discarded – undo
1092 1092
  *     Pile complétée par le code à générer
1093 1093
  */
1094 1094
 function balise_PAGINATION_dist($p, $liste = 'true') {
1095
-	$b = index_boucle_mere($p);
1096
-
1097
-	// s'il n'y a pas de nom de boucle, on ne peut pas paginer
1098
-	if ($b === '') {
1099
-		$msg = array(
1100
-			'zbug_champ_hors_boucle',
1101
-			array('champ' => $liste ? 'PAGINATION' : 'ANCRE_PAGINATION')
1102
-		);
1103
-		erreur_squelette($msg, $p);
1104
-
1105
-		return $p;
1106
-	}
1107
-
1108
-	// s'il n'y a pas de mode_partie, c'est qu'on se trouve
1109
-	// dans un boucle recursive ou qu'on a oublie le critere {pagination}
1110
-	if (!$p->boucles[$b]->mode_partie) {
1111
-		if (!$p->boucles[$b]->table_optionnelle) {
1112
-			$msg = array(
1113
-				'zbug_pagination_sans_critere',
1114
-				array('champ' => '#PAGINATION')
1115
-			);
1116
-			erreur_squelette($msg, $p);
1117
-		}
1118
-
1119
-		return $p;
1120
-	}
1121
-
1122
-	// a priori true
1123
-	// si false, le compilo va bloquer sur des syntaxes avec un filtre sans argument qui suit la balise
1124
-	// si true, les arguments simples (sans truc=chose) vont degager
1125
-	$_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $p->id_boucle, false, false);
1126
-	if (count($_contexte)) {
1127
-		$key = key($_contexte);
1128
-		if (is_numeric($key)) {
1129
-			array_shift($_contexte);
1130
-			$__modele = interprete_argument_balise(1, $p);
1131
-		}
1132
-	}
1133
-
1134
-	if (count($_contexte)) {
1135
-		$code_contexte = implode(',', $_contexte);
1136
-	} else {
1137
-		$code_contexte = '';
1138
-	}
1139
-
1140
-	$connect = $p->boucles[$b]->sql_serveur;
1141
-	$pas = $p->boucles[$b]->total_parties;
1142
-	$f_pagination = chercher_filtre('pagination');
1143
-	$type = $p->boucles[$b]->modificateur['debut_nom'];
1144
-	$modif = ($type[0] !== "'") ? "'debut'.$type"
1145
-		: ("'debut" . substr($type, 1));
1146
-
1147
-	$p->code = sprintf(CODE_PAGINATION, $f_pagination, $b, $type, $modif, $pas, $liste,
1148
-		((isset($__modele) and $__modele) ? $__modele : "''"), _q($connect), $code_contexte);
1149
-
1150
-	$p->boucles[$b]->numrows = true;
1151
-	$p->interdire_scripts = false;
1152
-
1153
-	return $p;
1095
+    $b = index_boucle_mere($p);
1096
+
1097
+    // s'il n'y a pas de nom de boucle, on ne peut pas paginer
1098
+    if ($b === '') {
1099
+        $msg = array(
1100
+            'zbug_champ_hors_boucle',
1101
+            array('champ' => $liste ? 'PAGINATION' : 'ANCRE_PAGINATION')
1102
+        );
1103
+        erreur_squelette($msg, $p);
1104
+
1105
+        return $p;
1106
+    }
1107
+
1108
+    // s'il n'y a pas de mode_partie, c'est qu'on se trouve
1109
+    // dans un boucle recursive ou qu'on a oublie le critere {pagination}
1110
+    if (!$p->boucles[$b]->mode_partie) {
1111
+        if (!$p->boucles[$b]->table_optionnelle) {
1112
+            $msg = array(
1113
+                'zbug_pagination_sans_critere',
1114
+                array('champ' => '#PAGINATION')
1115
+            );
1116
+            erreur_squelette($msg, $p);
1117
+        }
1118
+
1119
+        return $p;
1120
+    }
1121
+
1122
+    // a priori true
1123
+    // si false, le compilo va bloquer sur des syntaxes avec un filtre sans argument qui suit la balise
1124
+    // si true, les arguments simples (sans truc=chose) vont degager
1125
+    $_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $p->id_boucle, false, false);
1126
+    if (count($_contexte)) {
1127
+        $key = key($_contexte);
1128
+        if (is_numeric($key)) {
1129
+            array_shift($_contexte);
1130
+            $__modele = interprete_argument_balise(1, $p);
1131
+        }
1132
+    }
1133
+
1134
+    if (count($_contexte)) {
1135
+        $code_contexte = implode(',', $_contexte);
1136
+    } else {
1137
+        $code_contexte = '';
1138
+    }
1139
+
1140
+    $connect = $p->boucles[$b]->sql_serveur;
1141
+    $pas = $p->boucles[$b]->total_parties;
1142
+    $f_pagination = chercher_filtre('pagination');
1143
+    $type = $p->boucles[$b]->modificateur['debut_nom'];
1144
+    $modif = ($type[0] !== "'") ? "'debut'.$type"
1145
+        : ("'debut" . substr($type, 1));
1146
+
1147
+    $p->code = sprintf(CODE_PAGINATION, $f_pagination, $b, $type, $modif, $pas, $liste,
1148
+        ((isset($__modele) and $__modele) ? $__modele : "''"), _q($connect), $code_contexte);
1149
+
1150
+    $p->boucles[$b]->numrows = true;
1151
+    $p->interdire_scripts = false;
1152
+
1153
+    return $p;
1154 1154
 }
1155 1155
 
1156 1156
 
@@ -1177,11 +1177,11 @@  discard block
 block discarded – undo
1177 1177
  *     Pile complétée par le code à générer
1178 1178
  **/
1179 1179
 function balise_ANCRE_PAGINATION_dist($p) {
1180
-	if ($f = charger_fonction('PAGINATION', 'balise', true)) {
1181
-		return $f($p, $liste = 'false');
1182
-	} else {
1183
-		return null;
1184
-	} // ou une erreur ?
1180
+    if ($f = charger_fonction('PAGINATION', 'balise', true)) {
1181
+        return $f($p, $liste = 'false');
1182
+    } else {
1183
+        return null;
1184
+    } // ou une erreur ?
1185 1185
 }
1186 1186
 
1187 1187
 
@@ -1202,18 +1202,18 @@  discard block
 block discarded – undo
1202 1202
  *     Pile complétée par le code à générer
1203 1203
  **/
1204 1204
 function balise_GRAND_TOTAL_dist($p) {
1205
-	$b = index_boucle_mere($p);
1206
-	if ($b === '') {
1207
-		$msg = array('zbug_champ_hors_boucle', array('champ' => zbug_presenter_champ($p)));
1208
-		erreur_squelette($msg, $p);
1209
-	} else {
1210
-		$p->code = "(isset(\$Numrows['$b']['grand_total'])
1205
+    $b = index_boucle_mere($p);
1206
+    if ($b === '') {
1207
+        $msg = array('zbug_champ_hors_boucle', array('champ' => zbug_presenter_champ($p)));
1208
+        erreur_squelette($msg, $p);
1209
+    } else {
1210
+        $p->code = "(isset(\$Numrows['$b']['grand_total'])
1211 1211
 			? \$Numrows['$b']['grand_total'] : \$Numrows['$b']['total'])";
1212
-		$p->boucles[$b]->numrows = true;
1213
-		$p->interdire_scripts = false;
1214
-	}
1212
+        $p->boucles[$b]->numrows = true;
1213
+        $p->interdire_scripts = false;
1214
+    }
1215 1215
 
1216
-	return $p;
1216
+    return $p;
1217 1217
 }
1218 1218
 
1219 1219
 
@@ -1241,10 +1241,10 @@  discard block
 block discarded – undo
1241 1241
  *     Pile complétée par le code à générer
1242 1242
  **/
1243 1243
 function balise_SELF_dist($p) {
1244
-	$p->code = 'self()';
1245
-	$p->interdire_scripts = false;
1244
+    $p->code = 'self()';
1245
+    $p->interdire_scripts = false;
1246 1246
 
1247
-	return $p;
1247
+    return $p;
1248 1248
 }
1249 1249
 
1250 1250
 
@@ -1271,17 +1271,17 @@  discard block
 block discarded – undo
1271 1271
  *     Pile complétée par le code à générer
1272 1272
  **/
1273 1273
 function balise_CHEMIN_dist($p) {
1274
-	$arg = interprete_argument_balise(1, $p);
1275
-	if (!$arg) {
1276
-		$msg = array('zbug_balise_sans_argument', array('balise' => ' CHEMIN'));
1277
-		erreur_squelette($msg, $p);
1278
-	} else {
1279
-		$p->code = 'find_in_path(' . $arg . ')';
1280
-	}
1274
+    $arg = interprete_argument_balise(1, $p);
1275
+    if (!$arg) {
1276
+        $msg = array('zbug_balise_sans_argument', array('balise' => ' CHEMIN'));
1277
+        erreur_squelette($msg, $p);
1278
+    } else {
1279
+        $p->code = 'find_in_path(' . $arg . ')';
1280
+    }
1281 1281
 
1282
-	$p->interdire_scripts = false;
1282
+    $p->interdire_scripts = false;
1283 1283
 
1284
-	return $p;
1284
+    return $p;
1285 1285
 }
1286 1286
 
1287 1287
 /**
@@ -1306,16 +1306,16 @@  discard block
 block discarded – undo
1306 1306
  *     Pile complétée par le code à générer
1307 1307
  **/
1308 1308
 function balise_CHEMIN_IMAGE_dist($p) {
1309
-	$arg = interprete_argument_balise(1, $p);
1310
-	if (!$arg) {
1311
-		$msg = array('zbug_balise_sans_argument', array('balise' => ' CHEMIN_IMAGE'));
1312
-		erreur_squelette($msg, $p);
1313
-	} else {
1314
-		$p->code = 'chemin_image(' . $arg . ')';
1315
-	}
1309
+    $arg = interprete_argument_balise(1, $p);
1310
+    if (!$arg) {
1311
+        $msg = array('zbug_balise_sans_argument', array('balise' => ' CHEMIN_IMAGE'));
1312
+        erreur_squelette($msg, $p);
1313
+    } else {
1314
+        $p->code = 'chemin_image(' . $arg . ')';
1315
+    }
1316 1316
 
1317
-	$p->interdire_scripts = false;
1318
-	return $p;
1317
+    $p->interdire_scripts = false;
1318
+    return $p;
1319 1319
 }
1320 1320
 
1321 1321
 
@@ -1353,36 +1353,36 @@  discard block
 block discarded – undo
1353 1353
  **/
1354 1354
 function balise_ENV_dist($p, $src = null) {
1355 1355
 
1356
-	// cle du tableau desiree
1357
-	$_nom = interprete_argument_balise(1, $p);
1358
-	// valeur par defaut
1359
-	$_sinon = interprete_argument_balise(2, $p);
1356
+    // cle du tableau desiree
1357
+    $_nom = interprete_argument_balise(1, $p);
1358
+    // valeur par defaut
1359
+    $_sinon = interprete_argument_balise(2, $p);
1360 1360
 
1361
-	// $src est un tableau de donnees sources eventuellement transmis
1362
-	// en absence, on utilise l'environnement du squelette $Pile[0]
1361
+    // $src est un tableau de donnees sources eventuellement transmis
1362
+    // en absence, on utilise l'environnement du squelette $Pile[0]
1363 1363
 
1364
-	if (!$_nom) {
1365
-		// cas de #ENV sans argument : on retourne le serialize() du tableau
1366
-		// une belle fonction [(#ENV|affiche_env)] serait pratique
1367
-		if ($src) {
1368
-			$p->code = '(is_array($a = (' . $src . ')) ? serialize($a) : "")';
1369
-		} else {
1370
-			$p->code = '@serialize($Pile[0])';
1371
-		}
1372
-	} else {
1373
-		if (!$src) {
1374
-			$src = '@$Pile[0]';
1375
-		}
1376
-		if ($_sinon) {
1377
-			$p->code = "sinon(table_valeur($src, (string)$_nom, null), $_sinon)";
1378
-		} else {
1379
-			$p->code = "table_valeur($src, (string)$_nom, null)";
1380
-		}
1381
-	}
1364
+    if (!$_nom) {
1365
+        // cas de #ENV sans argument : on retourne le serialize() du tableau
1366
+        // une belle fonction [(#ENV|affiche_env)] serait pratique
1367
+        if ($src) {
1368
+            $p->code = '(is_array($a = (' . $src . ')) ? serialize($a) : "")';
1369
+        } else {
1370
+            $p->code = '@serialize($Pile[0])';
1371
+        }
1372
+    } else {
1373
+        if (!$src) {
1374
+            $src = '@$Pile[0]';
1375
+        }
1376
+        if ($_sinon) {
1377
+            $p->code = "sinon(table_valeur($src, (string)$_nom, null), $_sinon)";
1378
+        } else {
1379
+            $p->code = "table_valeur($src, (string)$_nom, null)";
1380
+        }
1381
+    }
1382 1382
 
1383
-	#$p->interdire_scripts = true;
1383
+    #$p->interdire_scripts = true;
1384 1384
 
1385
-	return $p;
1385
+    return $p;
1386 1386
 }
1387 1387
 
1388 1388
 /**
@@ -1412,16 +1412,16 @@  discard block
 block discarded – undo
1412 1412
  *     Pile completée du code PHP d'exécution de la balise
1413 1413
  */
1414 1414
 function balise_CONFIG_dist($p) {
1415
-	if (!$arg = interprete_argument_balise(1, $p)) {
1416
-		$arg = "''";
1417
-	}
1418
-	$_sinon = interprete_argument_balise(2, $p);
1419
-	$_unserialize = sinon(interprete_argument_balise(3, $p), "false");
1415
+    if (!$arg = interprete_argument_balise(1, $p)) {
1416
+        $arg = "''";
1417
+    }
1418
+    $_sinon = interprete_argument_balise(2, $p);
1419
+    $_unserialize = sinon(interprete_argument_balise(3, $p), "false");
1420 1420
 
1421
-	$p->code = '(include_spip(\'inc/config\')?lire_config(' . $arg . ',' .
1422
-		($_sinon && $_sinon != "''" ? $_sinon : 'null') . ',' . $_unserialize . "):'')";
1421
+    $p->code = '(include_spip(\'inc/config\')?lire_config(' . $arg . ',' .
1422
+        ($_sinon && $_sinon != "''" ? $_sinon : 'null') . ',' . $_unserialize . "):'')";
1423 1423
 
1424
-	return $p;
1424
+    return $p;
1425 1425
 }
1426 1426
 
1427 1427
 
@@ -1444,10 +1444,10 @@  discard block
 block discarded – undo
1444 1444
  *     Pile completée du code PHP d'exécution de la balise
1445 1445
  */
1446 1446
 function balise_CONNECT_dist($p) {
1447
-	$p->code = '($connect ? $connect : NULL)';
1448
-	$p->interdire_scripts = false;
1447
+    $p->code = '($connect ? $connect : NULL)';
1448
+    $p->interdire_scripts = false;
1449 1449
 
1450
-	return $p;
1450
+    return $p;
1451 1451
 }
1452 1452
 
1453 1453
 
@@ -1475,15 +1475,15 @@  discard block
 block discarded – undo
1475 1475
  *     Pile completée du code PHP d'exécution de la balise
1476 1476
  **/
1477 1477
 function balise_SESSION_dist($p) {
1478
-	$p->descr['session'] = true;
1478
+    $p->descr['session'] = true;
1479 1479
 
1480
-	$f = function_exists('balise_ENV')
1481
-		? 'balise_ENV'
1482
-		: 'balise_ENV_dist';
1480
+    $f = function_exists('balise_ENV')
1481
+        ? 'balise_ENV'
1482
+        : 'balise_ENV_dist';
1483 1483
 
1484
-	$p = $f($p, '$GLOBALS["visiteur_session"]');
1484
+    $p = $f($p, '$GLOBALS["visiteur_session"]');
1485 1485
 
1486
-	return $p;
1486
+    return $p;
1487 1487
 }
1488 1488
 
1489 1489
 
@@ -1506,18 +1506,18 @@  discard block
 block discarded – undo
1506 1506
  *     Pile completée du code PHP d'exécution de la balise
1507 1507
  **/
1508 1508
 function balise_SESSION_SET_dist($p) {
1509
-	$_nom = interprete_argument_balise(1, $p);
1510
-	$_val = interprete_argument_balise(2, $p);
1511
-	if (!$_nom or !$_val) {
1512
-		$err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'SESSION_SET'));
1513
-		erreur_squelette($err_b_s_a, $p);
1514
-	} else {
1515
-		$p->code = '(include_spip("inc/session") AND session_set(' . $_nom . ',' . $_val . '))';
1516
-	}
1509
+    $_nom = interprete_argument_balise(1, $p);
1510
+    $_val = interprete_argument_balise(2, $p);
1511
+    if (!$_nom or !$_val) {
1512
+        $err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'SESSION_SET'));
1513
+        erreur_squelette($err_b_s_a, $p);
1514
+    } else {
1515
+        $p->code = '(include_spip("inc/session") AND session_set(' . $_nom . ',' . $_val . '))';
1516
+    }
1517 1517
 
1518
-	$p->interdire_scripts = false;
1518
+    $p->interdire_scripts = false;
1519 1519
 
1520
-	return $p;
1520
+    return $p;
1521 1521
 }
1522 1522
 
1523 1523
 
@@ -1548,25 +1548,25 @@  discard block
 block discarded – undo
1548 1548
  *     Pile completée du code PHP d'exécution de la balise
1549 1549
  **/
1550 1550
 function balise_EVAL_dist($p) {
1551
-	$php = interprete_argument_balise(1, $p);
1552
-	if ($php) {
1553
-		# optimisation sur les #EVAL{une expression sans #BALISE}
1554
-		# attention au commentaire "// x signes" qui precede
1555
-		if (preg_match(",^([[:space:]]*//[^\n]*\n)'([^']+)'$,ms",
1556
-			$php, $r)) {
1557
-			$p->code = /* $r[1]. */
1558
-				'(' . $r[2] . ')';
1559
-		} else {
1560
-			$p->code = "eval('return '.$php.';')";
1561
-		}
1562
-	} else {
1563
-		$msg = array('zbug_balise_sans_argument', array('balise' => ' EVAL'));
1564
-		erreur_squelette($msg, $p);
1565
-	}
1551
+    $php = interprete_argument_balise(1, $p);
1552
+    if ($php) {
1553
+        # optimisation sur les #EVAL{une expression sans #BALISE}
1554
+        # attention au commentaire "// x signes" qui precede
1555
+        if (preg_match(",^([[:space:]]*//[^\n]*\n)'([^']+)'$,ms",
1556
+            $php, $r)) {
1557
+            $p->code = /* $r[1]. */
1558
+                '(' . $r[2] . ')';
1559
+        } else {
1560
+            $p->code = "eval('return '.$php.';')";
1561
+        }
1562
+    } else {
1563
+        $msg = array('zbug_balise_sans_argument', array('balise' => ' EVAL'));
1564
+        erreur_squelette($msg, $p);
1565
+    }
1566 1566
 
1567
-	#$p->interdire_scripts = true;
1567
+    #$p->interdire_scripts = true;
1568 1568
 
1569
-	return $p;
1569
+    return $p;
1570 1570
 }
1571 1571
 
1572 1572
 
@@ -1596,18 +1596,18 @@  discard block
 block discarded – undo
1596 1596
  **/
1597 1597
 function balise_CHAMP_SQL_dist($p) {
1598 1598
 
1599
-	if ($p->param
1600
-		and isset($p->param[0][1][0])
1601
-		and $champ = ($p->param[0][1][0]->texte)
1602
-	) {
1603
-		$p->code = champ_sql($champ, $p);
1604
-	} else {
1605
-		$err_b_s_a = array('zbug_balise_sans_argument', array('balise' => ' CHAMP_SQL'));
1606
-		erreur_squelette($err_b_s_a, $p);
1607
-	}
1599
+    if ($p->param
1600
+        and isset($p->param[0][1][0])
1601
+        and $champ = ($p->param[0][1][0]->texte)
1602
+    ) {
1603
+        $p->code = champ_sql($champ, $p);
1604
+    } else {
1605
+        $err_b_s_a = array('zbug_balise_sans_argument', array('balise' => ' CHAMP_SQL'));
1606
+        erreur_squelette($err_b_s_a, $p);
1607
+    }
1608 1608
 
1609
-	#$p->interdire_scripts = true;
1610
-	return $p;
1609
+    #$p->interdire_scripts = true;
1610
+    return $p;
1611 1611
 }
1612 1612
 
1613 1613
 /**
@@ -1633,13 +1633,13 @@  discard block
 block discarded – undo
1633 1633
  *     Pile complétée par le code à générer
1634 1634
  **/
1635 1635
 function balise_VAL_dist($p) {
1636
-	$p->code = interprete_argument_balise(1, $p);
1637
-	if (!strlen($p->code)) {
1638
-		$p->code = "''";
1639
-	}
1640
-	$p->interdire_scripts = false;
1636
+    $p->code = interprete_argument_balise(1, $p);
1637
+    if (!strlen($p->code)) {
1638
+        $p->code = "''";
1639
+    }
1640
+    $p->interdire_scripts = false;
1641 1641
 
1642
-	return $p;
1642
+    return $p;
1643 1643
 }
1644 1644
 
1645 1645
 /**
@@ -1685,10 +1685,10 @@  discard block
 block discarded – undo
1685 1685
  *     Pile complétée par le code à générer
1686 1686
  **/
1687 1687
 function balise_REM_dist($p) {
1688
-	$p->code = "''";
1689
-	$p->interdire_scripts = false;
1688
+    $p->code = "''";
1689
+    $p->interdire_scripts = false;
1690 1690
 
1691
-	return $p;
1691
+    return $p;
1692 1692
 }
1693 1693
 
1694 1694
 /**
@@ -1698,10 +1698,10 @@  discard block
 block discarded – undo
1698 1698
  * @return mixed
1699 1699
  */
1700 1700
 function balise_NULL_dist($p) {
1701
-	$p->code = "null";
1702
-	$p->interdire_scripts = false;
1701
+    $p->code = "null";
1702
+    $p->interdire_scripts = false;
1703 1703
 
1704
-	return $p;
1704
+    return $p;
1705 1705
 }
1706 1706
 
1707 1707
 
@@ -1725,18 +1725,18 @@  discard block
 block discarded – undo
1725 1725
  **/
1726 1726
 function balise_HTTP_HEADER_dist($p) {
1727 1727
 
1728
-	$header = interprete_argument_balise(1, $p);
1729
-	if (!$header) {
1730
-		$err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'HTTP_HEADER'));
1731
-		erreur_squelette($err_b_s_a, $p);
1732
-	} else {
1733
-		$p->code = "'<'.'?php header(' . _q("
1734
-			. $header
1735
-			. ") . '); ?'.'>'";
1736
-	}
1737
-	$p->interdire_scripts = false;
1728
+    $header = interprete_argument_balise(1, $p);
1729
+    if (!$header) {
1730
+        $err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'HTTP_HEADER'));
1731
+        erreur_squelette($err_b_s_a, $p);
1732
+    } else {
1733
+        $p->code = "'<'.'?php header(' . _q("
1734
+            . $header
1735
+            . ") . '); ?'.'>'";
1736
+    }
1737
+    $p->interdire_scripts = false;
1738 1738
 
1739
-	return $p;
1739
+    return $p;
1740 1740
 }
1741 1741
 
1742 1742
 
@@ -1761,20 +1761,20 @@  discard block
 block discarded – undo
1761 1761
  *     Pile complétée par le code à générer
1762 1762
  **/
1763 1763
 function balise_FILTRE_dist($p) {
1764
-	if ($p->param) {
1765
-		$args = array();
1766
-		foreach ($p->param as $i => $ignore) {
1767
-			$args[] = interprete_argument_balise($i + 1, $p);
1768
-		}
1769
-		$p->code = "'<' . '"
1770
-			. '?php header("X-Spip-Filtre: \'.'
1771
-			. join('.\'|\'.', $args)
1772
-			. " . '\"); ?'.'>'";
1764
+    if ($p->param) {
1765
+        $args = array();
1766
+        foreach ($p->param as $i => $ignore) {
1767
+            $args[] = interprete_argument_balise($i + 1, $p);
1768
+        }
1769
+        $p->code = "'<' . '"
1770
+            . '?php header("X-Spip-Filtre: \'.'
1771
+            . join('.\'|\'.', $args)
1772
+            . " . '\"); ?'.'>'";
1773 1773
 
1774
-		$p->interdire_scripts = false;
1774
+        $p->interdire_scripts = false;
1775 1775
 
1776
-		return $p;
1777
-	}
1776
+        return $p;
1777
+    }
1778 1778
 }
1779 1779
 
1780 1780
 
@@ -1810,53 +1810,53 @@  discard block
 block discarded – undo
1810 1810
  **/
1811 1811
 function balise_CACHE_dist($p) {
1812 1812
 
1813
-	if ($p->param) {
1814
-		$duree = valeur_numerique($p->param[0][1][0]->texte);
1815
-
1816
-		// noter la duree du cache dans un entete proprietaire
1817
-
1818
-		$code = "'<'.'" . '?php header("X-Spip-Cache: '
1819
-			. $duree
1820
-			. '"); ?' . "'.'>'";
1821
-
1822
-		// Remplir le header Cache-Control
1823
-		// cas #CACHE{0}
1824
-		if ($duree == 0) {
1825
-			$code .= ".'<'.'"
1826
-				. '?php header("Cache-Control: no-cache, must-revalidate"); ?'
1827
-				. "'.'><'.'"
1828
-				. '?php header("Pragma: no-cache"); ?'
1829
-				. "'.'>'";
1830
-		}
1831
-
1832
-		// recuperer les parametres suivants
1833
-		$i = 1;
1834
-		while (isset($p->param[0][++$i])) {
1835
-			$pa = ($p->param[0][$i][0]->texte);
1836
-
1837
-			if ($pa == 'cache-client'
1838
-				and $duree > 0
1839
-			) {
1840
-				$code .= ".'<'.'" . '?php header("Cache-Control: max-age='
1841
-					. $duree
1842
-					. '"); ?' . "'.'>'";
1843
-				// il semble logique, si on cache-client, de ne pas invalider
1844
-				$pa = 'statique';
1845
-			}
1846
-
1847
-			if ($pa == 'statique'
1848
-				and $duree > 0
1849
-			) {
1850
-				$code .= ".'<'.'" . '?php header("X-Spip-Statique: oui"); ?' . "'.'>'";
1851
-			}
1852
-		}
1853
-	} else {
1854
-		$code = "''";
1855
-	}
1856
-	$p->code = $code;
1857
-	$p->interdire_scripts = false;
1858
-
1859
-	return $p;
1813
+    if ($p->param) {
1814
+        $duree = valeur_numerique($p->param[0][1][0]->texte);
1815
+
1816
+        // noter la duree du cache dans un entete proprietaire
1817
+
1818
+        $code = "'<'.'" . '?php header("X-Spip-Cache: '
1819
+            . $duree
1820
+            . '"); ?' . "'.'>'";
1821
+
1822
+        // Remplir le header Cache-Control
1823
+        // cas #CACHE{0}
1824
+        if ($duree == 0) {
1825
+            $code .= ".'<'.'"
1826
+                . '?php header("Cache-Control: no-cache, must-revalidate"); ?'
1827
+                . "'.'><'.'"
1828
+                . '?php header("Pragma: no-cache"); ?'
1829
+                . "'.'>'";
1830
+        }
1831
+
1832
+        // recuperer les parametres suivants
1833
+        $i = 1;
1834
+        while (isset($p->param[0][++$i])) {
1835
+            $pa = ($p->param[0][$i][0]->texte);
1836
+
1837
+            if ($pa == 'cache-client'
1838
+                and $duree > 0
1839
+            ) {
1840
+                $code .= ".'<'.'" . '?php header("Cache-Control: max-age='
1841
+                    . $duree
1842
+                    . '"); ?' . "'.'>'";
1843
+                // il semble logique, si on cache-client, de ne pas invalider
1844
+                $pa = 'statique';
1845
+            }
1846
+
1847
+            if ($pa == 'statique'
1848
+                and $duree > 0
1849
+            ) {
1850
+                $code .= ".'<'.'" . '?php header("X-Spip-Statique: oui"); ?' . "'.'>'";
1851
+            }
1852
+        }
1853
+    } else {
1854
+        $code = "''";
1855
+    }
1856
+    $p->code = $code;
1857
+    $p->interdire_scripts = false;
1858
+
1859
+    return $p;
1860 1860
 }
1861 1861
 
1862 1862
 
@@ -1888,13 +1888,13 @@  discard block
 block discarded – undo
1888 1888
  *     Pile complétée par le code à générer
1889 1889
  */
1890 1890
 function balise_INSERT_HEAD_dist($p) {
1891
-	$p->code = "'<'.'"
1892
-		. '?php header("X-Spip-Filtre: insert_head_css_conditionnel"); ?'
1893
-		. "'.'>'";
1894
-	$p->code .= ". pipeline('insert_head','<!-- insert_head -->')";
1895
-	$p->interdire_scripts = false;
1891
+    $p->code = "'<'.'"
1892
+        . '?php header("X-Spip-Filtre: insert_head_css_conditionnel"); ?'
1893
+        . "'.'>'";
1894
+    $p->code .= ". pipeline('insert_head','<!-- insert_head -->')";
1895
+    $p->interdire_scripts = false;
1896 1896
 
1897
-	return $p;
1897
+    return $p;
1898 1898
 }
1899 1899
 
1900 1900
 /**
@@ -1912,10 +1912,10 @@  discard block
 block discarded – undo
1912 1912
  *     Pile complétée par le code à générer
1913 1913
  */
1914 1914
 function balise_INSERT_HEAD_CSS_dist($p) {
1915
-	$p->code = "pipeline('insert_head_css','<!-- insert_head_css -->')";
1916
-	$p->interdire_scripts = false;
1915
+    $p->code = "pipeline('insert_head_css','<!-- insert_head_css -->')";
1916
+    $p->interdire_scripts = false;
1917 1917
 
1918
-	return $p;
1918
+    return $p;
1919 1919
 }
1920 1920
 
1921 1921
 /**
@@ -1930,11 +1930,11 @@  discard block
 block discarded – undo
1930 1930
  *     Pile complétée par le code à générer
1931 1931
  **/
1932 1932
 function balise_INCLUDE_dist($p) {
1933
-	if (function_exists('balise_INCLURE')) {
1934
-		return balise_INCLURE($p);
1935
-	} else {
1936
-		return balise_INCLURE_dist($p);
1937
-	}
1933
+    if (function_exists('balise_INCLURE')) {
1934
+        return balise_INCLURE($p);
1935
+    } else {
1936
+        return balise_INCLURE_dist($p);
1937
+    }
1938 1938
 }
1939 1939
 
1940 1940
 /**
@@ -1968,68 +1968,68 @@  discard block
 block discarded – undo
1968 1968
  *     Pile complétée par le code à générer
1969 1969
  **/
1970 1970
 function balise_INCLURE_dist($p) {
1971
-	$id_boucle = $p->id_boucle;
1972
-	// la lang n'est pas passe de facon automatique par argumenter
1973
-	// mais le sera pas recuperer_fond, sauf si etoile=>true est passe
1974
-	// en option
1975
-
1976
-	$_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $id_boucle, false, false);
1977
-
1978
-	// erreur de syntaxe = fond absent
1979
-	// (2 messages d'erreur SPIP pour le prix d'un, mais pas d'erreur PHP
1980
-	if (!$_contexte) {
1981
-		$contexte = array();
1982
-	}
1983
-
1984
-	if (isset($_contexte['fond'])) {
1985
-
1986
-		$f = $_contexte['fond'];
1987
-		// toujours vrai :
1988
-		if (preg_match('/^.fond.\s*=>(.*)$/s', $f, $r)) {
1989
-			$f = $r[1];
1990
-			unset($_contexte['fond']);
1991
-		} else {
1992
-			spip_log("compilation de #INCLURE a revoir");
1993
-		}
1994
-
1995
-		// #INCLURE{doublons}
1996
-		if (isset($_contexte['doublons'])) {
1997
-			$_contexte['doublons'] = "'doublons' => \$doublons";
1998
-		}
1999
-
2000
-		// Critere d'inclusion {env} (et {self} pour compatibilite ascendante)
2001
-		$flag_env = false;
2002
-		if (isset($_contexte['env']) or isset($_contexte['self'])) {
2003
-			$flag_env = true;
2004
-			unset($_contexte['env']);
2005
-		}
2006
-
2007
-		$_options = array();
2008
-		if (isset($_contexte['ajax'])) {
2009
-			$_options[] = preg_replace(",=>(.*)$,ims", '=> ($v=(\\1))?$v:true', $_contexte['ajax']);
2010
-			unset($_contexte['ajax']);
2011
-		}
2012
-		if ($p->etoile) {
2013
-			$_options[] = "'etoile'=>true";
2014
-		}
2015
-		$_options[] = "'compil'=>array(" . memoriser_contexte_compil($p) . ")";
2016
-
2017
-		$_l = 'array(' . join(",\n\t", $_contexte) . ')';
2018
-		if ($flag_env) {
2019
-			$_l = "array_merge(\$Pile[0],$_l)";
2020
-		}
2021
-
2022
-		$p->code = sprintf(CODE_RECUPERER_FOND, $f, $_l, join(',', $_options), "_request('connect')");
2023
-
2024
-	} elseif (!isset($_contexte[1])) {
2025
-		$msg = array('zbug_balise_sans_argument', array('balise' => ' INCLURE'));
2026
-		erreur_squelette($msg, $p);
2027
-	} else {
2028
-		$p->code = 'charge_scripts(' . $_contexte[1] . ',false)';
2029
-	}
2030
-
2031
-	$p->interdire_scripts = false; // la securite est assuree par recuperer_fond
2032
-	return $p;
1971
+    $id_boucle = $p->id_boucle;
1972
+    // la lang n'est pas passe de facon automatique par argumenter
1973
+    // mais le sera pas recuperer_fond, sauf si etoile=>true est passe
1974
+    // en option
1975
+
1976
+    $_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $id_boucle, false, false);
1977
+
1978
+    // erreur de syntaxe = fond absent
1979
+    // (2 messages d'erreur SPIP pour le prix d'un, mais pas d'erreur PHP
1980
+    if (!$_contexte) {
1981
+        $contexte = array();
1982
+    }
1983
+
1984
+    if (isset($_contexte['fond'])) {
1985
+
1986
+        $f = $_contexte['fond'];
1987
+        // toujours vrai :
1988
+        if (preg_match('/^.fond.\s*=>(.*)$/s', $f, $r)) {
1989
+            $f = $r[1];
1990
+            unset($_contexte['fond']);
1991
+        } else {
1992
+            spip_log("compilation de #INCLURE a revoir");
1993
+        }
1994
+
1995
+        // #INCLURE{doublons}
1996
+        if (isset($_contexte['doublons'])) {
1997
+            $_contexte['doublons'] = "'doublons' => \$doublons";
1998
+        }
1999
+
2000
+        // Critere d'inclusion {env} (et {self} pour compatibilite ascendante)
2001
+        $flag_env = false;
2002
+        if (isset($_contexte['env']) or isset($_contexte['self'])) {
2003
+            $flag_env = true;
2004
+            unset($_contexte['env']);
2005
+        }
2006
+
2007
+        $_options = array();
2008
+        if (isset($_contexte['ajax'])) {
2009
+            $_options[] = preg_replace(",=>(.*)$,ims", '=> ($v=(\\1))?$v:true', $_contexte['ajax']);
2010
+            unset($_contexte['ajax']);
2011
+        }
2012
+        if ($p->etoile) {
2013
+            $_options[] = "'etoile'=>true";
2014
+        }
2015
+        $_options[] = "'compil'=>array(" . memoriser_contexte_compil($p) . ")";
2016
+
2017
+        $_l = 'array(' . join(",\n\t", $_contexte) . ')';
2018
+        if ($flag_env) {
2019
+            $_l = "array_merge(\$Pile[0],$_l)";
2020
+        }
2021
+
2022
+        $p->code = sprintf(CODE_RECUPERER_FOND, $f, $_l, join(',', $_options), "_request('connect')");
2023
+
2024
+    } elseif (!isset($_contexte[1])) {
2025
+        $msg = array('zbug_balise_sans_argument', array('balise' => ' INCLURE'));
2026
+        erreur_squelette($msg, $p);
2027
+    } else {
2028
+        $p->code = 'charge_scripts(' . $_contexte[1] . ',false)';
2029
+    }
2030
+
2031
+    $p->interdire_scripts = false; // la securite est assuree par recuperer_fond
2032
+    return $p;
2033 2033
 }
2034 2034
 
2035 2035
 
@@ -2057,69 +2057,69 @@  discard block
 block discarded – undo
2057 2057
  **/
2058 2058
 function balise_MODELE_dist($p) {
2059 2059
 
2060
-	$_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $p->id_boucle, false);
2061
-
2062
-	// erreur de syntaxe = fond absent
2063
-	// (2 messages d'erreur SPIP pour le prix d'un, mais pas d'erreur PHP
2064
-	if (!$_contexte) {
2065
-		$_contexte = array();
2066
-	}
2067
-
2068
-	if (!isset($_contexte[1])) {
2069
-		$msg = array('zbug_balise_sans_argument', array('balise' => ' MODELE'));
2070
-		erreur_squelette($msg, $p);
2071
-	} else {
2072
-		$nom = $_contexte[1];
2073
-		unset($_contexte[1]);
2074
-
2075
-		if (preg_match("/^\s*'[^']*'/s", $nom)) {
2076
-			$nom = "'modeles/" . substr($nom, 1);
2077
-		} else {
2078
-			$nom = "'modeles/' . $nom";
2079
-		}
2080
-
2081
-		$flag_env = false;
2082
-		if (isset($_contexte['env'])) {
2083
-			$flag_env = true;
2084
-			unset($_contexte['env']);
2085
-		}
2086
-
2087
-		// Incoherence dans la syntaxe du contexte. A revoir.
2088
-		// Reserver la cle primaire de la boucle courante si elle existe
2089
-		if (isset($p->boucles[$p->id_boucle]->primary)) {
2090
-			$primary = $p->boucles[$p->id_boucle]->primary;
2091
-			if (!strpos($primary, ',')) {
2092
-				$id = champ_sql($primary, $p);
2093
-				$_contexte[] = "'$primary'=>" . $id;
2094
-				$_contexte[] = "'id'=>" . $id;
2095
-			}
2096
-		}
2097
-		$_contexte[] = "'recurs'=>(++\$recurs)";
2098
-		$connect = '';
2099
-		if (isset($p->boucles[$p->id_boucle])) {
2100
-			$connect = $p->boucles[$p->id_boucle]->sql_serveur;
2101
-		}
2102
-
2103
-		$_options = memoriser_contexte_compil($p);
2104
-		$_options = "'compil'=>array($_options), 'trim'=>true";
2105
-		if (isset($_contexte['ajax'])) {
2106
-			$_options .= ", " . preg_replace(",=>(.*)$,ims", '=> ($v=(\\1))?$v:true', $_contexte['ajax']);
2107
-			unset($_contexte['ajax']);
2108
-		}
2109
-
2110
-		$_l = 'array(' . join(",\n\t", $_contexte) . ')';
2111
-		if ($flag_env) {
2112
-			$_l = "array_merge(\$Pile[0],$_l)";
2113
-		}
2114
-
2115
-		$page = sprintf(CODE_RECUPERER_FOND, $nom, $_l, $_options, _q($connect));
2116
-
2117
-		$p->code = "\n\t(((\$recurs=(isset(\$Pile[0]['recurs'])?\$Pile[0]['recurs']:0))>=5)? '' :\n\t$page)\n";
2118
-
2119
-		$p->interdire_scripts = false; // securite assuree par le squelette
2120
-	}
2121
-
2122
-	return $p;
2060
+    $_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $p->id_boucle, false);
2061
+
2062
+    // erreur de syntaxe = fond absent
2063
+    // (2 messages d'erreur SPIP pour le prix d'un, mais pas d'erreur PHP
2064
+    if (!$_contexte) {
2065
+        $_contexte = array();
2066
+    }
2067
+
2068
+    if (!isset($_contexte[1])) {
2069
+        $msg = array('zbug_balise_sans_argument', array('balise' => ' MODELE'));
2070
+        erreur_squelette($msg, $p);
2071
+    } else {
2072
+        $nom = $_contexte[1];
2073
+        unset($_contexte[1]);
2074
+
2075
+        if (preg_match("/^\s*'[^']*'/s", $nom)) {
2076
+            $nom = "'modeles/" . substr($nom, 1);
2077
+        } else {
2078
+            $nom = "'modeles/' . $nom";
2079
+        }
2080
+
2081
+        $flag_env = false;
2082
+        if (isset($_contexte['env'])) {
2083
+            $flag_env = true;
2084
+            unset($_contexte['env']);
2085
+        }
2086
+
2087
+        // Incoherence dans la syntaxe du contexte. A revoir.
2088
+        // Reserver la cle primaire de la boucle courante si elle existe
2089
+        if (isset($p->boucles[$p->id_boucle]->primary)) {
2090
+            $primary = $p->boucles[$p->id_boucle]->primary;
2091
+            if (!strpos($primary, ',')) {
2092
+                $id = champ_sql($primary, $p);
2093
+                $_contexte[] = "'$primary'=>" . $id;
2094
+                $_contexte[] = "'id'=>" . $id;
2095
+            }
2096
+        }
2097
+        $_contexte[] = "'recurs'=>(++\$recurs)";
2098
+        $connect = '';
2099
+        if (isset($p->boucles[$p->id_boucle])) {
2100
+            $connect = $p->boucles[$p->id_boucle]->sql_serveur;
2101
+        }
2102
+
2103
+        $_options = memoriser_contexte_compil($p);
2104
+        $_options = "'compil'=>array($_options), 'trim'=>true";
2105
+        if (isset($_contexte['ajax'])) {
2106
+            $_options .= ", " . preg_replace(",=>(.*)$,ims", '=> ($v=(\\1))?$v:true', $_contexte['ajax']);
2107
+            unset($_contexte['ajax']);
2108
+        }
2109
+
2110
+        $_l = 'array(' . join(",\n\t", $_contexte) . ')';
2111
+        if ($flag_env) {
2112
+            $_l = "array_merge(\$Pile[0],$_l)";
2113
+        }
2114
+
2115
+        $page = sprintf(CODE_RECUPERER_FOND, $nom, $_l, $_options, _q($connect));
2116
+
2117
+        $p->code = "\n\t(((\$recurs=(isset(\$Pile[0]['recurs'])?\$Pile[0]['recurs']:0))>=5)? '' :\n\t$page)\n";
2118
+
2119
+        $p->interdire_scripts = false; // securite assuree par le squelette
2120
+    }
2121
+
2122
+    return $p;
2123 2123
 }
2124 2124
 
2125 2125
 
@@ -2143,21 +2143,21 @@  discard block
 block discarded – undo
2143 2143
  *     Pile complétée par le code à générer
2144 2144
  **/
2145 2145
 function balise_SET_dist($p) {
2146
-	$_nom = interprete_argument_balise(1, $p);
2147
-	$_val = interprete_argument_balise(2, $p);
2146
+    $_nom = interprete_argument_balise(1, $p);
2147
+    $_val = interprete_argument_balise(2, $p);
2148 2148
 
2149
-	if (!$_nom or !$_val) {
2150
-		$err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'SET'));
2151
-		erreur_squelette($err_b_s_a, $p);
2152
-	}
2153
-	// affectation $_zzz inutile, mais permet de contourner un bug OpCode cache sous PHP 5.5.4
2154
-	// cf https://bugs.php.net/bug.php?id=65845
2155
-	else {
2156
-		$p->code = "vide(\$Pile['vars'][\$_zzz=(string)$_nom] = $_val)";
2157
-	}
2149
+    if (!$_nom or !$_val) {
2150
+        $err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'SET'));
2151
+        erreur_squelette($err_b_s_a, $p);
2152
+    }
2153
+    // affectation $_zzz inutile, mais permet de contourner un bug OpCode cache sous PHP 5.5.4
2154
+    // cf https://bugs.php.net/bug.php?id=65845
2155
+    else {
2156
+        $p->code = "vide(\$Pile['vars'][\$_zzz=(string)$_nom] = $_val)";
2157
+    }
2158 2158
 
2159
-	$p->interdire_scripts = false; // la balise ne renvoie rien
2160
-	return $p;
2159
+    $p->interdire_scripts = false; // la balise ne renvoie rien
2160
+    return $p;
2161 2161
 }
2162 2162
 
2163 2163
 
@@ -2187,12 +2187,12 @@  discard block
 block discarded – undo
2187 2187
  *     Pile complétée par le code à générer
2188 2188
  **/
2189 2189
 function balise_GET_dist($p) {
2190
-	$p->interdire_scripts = false; // le contenu vient de #SET, donc il est de confiance
2191
-	if (function_exists('balise_ENV')) {
2192
-		return balise_ENV($p, '$Pile["vars"]');
2193
-	} else {
2194
-		return balise_ENV_dist($p, '$Pile["vars"]');
2195
-	}
2190
+    $p->interdire_scripts = false; // le contenu vient de #SET, donc il est de confiance
2191
+    if (function_exists('balise_ENV')) {
2192
+        return balise_ENV($p, '$Pile["vars"]');
2193
+    } else {
2194
+        return balise_ENV_dist($p, '$Pile["vars"]');
2195
+    }
2196 2196
 }
2197 2197
 
2198 2198
 
@@ -2215,22 +2215,22 @@  discard block
 block discarded – undo
2215 2215
  *     Pile complétée par le code à générer
2216 2216
  **/
2217 2217
 function balise_DOUBLONS_dist($p) {
2218
-	if ($type = interprete_argument_balise(1, $p)) {
2219
-		if ($famille = interprete_argument_balise(2, $p)) {
2220
-			$type .= '.' . $famille;
2221
-		}
2222
-		$p->code = '(isset($doublons[' . $type . ']) ? $doublons[' . $type . '] : "")';
2223
-		if (!$p->etoile) {
2224
-			$p->code = 'array_filter(array_map("intval",explode(",",'
2225
-				. $p->code . ')))';
2226
-		}
2227
-	} else {
2228
-		$p->code = '$doublons';
2229
-	}
2218
+    if ($type = interprete_argument_balise(1, $p)) {
2219
+        if ($famille = interprete_argument_balise(2, $p)) {
2220
+            $type .= '.' . $famille;
2221
+        }
2222
+        $p->code = '(isset($doublons[' . $type . ']) ? $doublons[' . $type . '] : "")';
2223
+        if (!$p->etoile) {
2224
+            $p->code = 'array_filter(array_map("intval",explode(",",'
2225
+                . $p->code . ')))';
2226
+        }
2227
+    } else {
2228
+        $p->code = '$doublons';
2229
+    }
2230 2230
 
2231
-	$p->interdire_scripts = false;
2231
+    $p->interdire_scripts = false;
2232 2232
 
2233
-	return $p;
2233
+    return $p;
2234 2234
 }
2235 2235
 
2236 2236
 
@@ -2253,18 +2253,18 @@  discard block
 block discarded – undo
2253 2253
  *     Pile complétée par le code à générer
2254 2254
  **/
2255 2255
 function balise_PIPELINE_dist($p) {
2256
-	$_pipe = interprete_argument_balise(1, $p);
2257
-	if (!$_pipe) {
2258
-		$err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'PIPELINE'));
2259
-		erreur_squelette($err_b_s_a, $p);
2260
-	} else {
2261
-		$_flux = interprete_argument_balise(2, $p);
2262
-		$_flux = $_flux ? $_flux : "''";
2263
-		$p->code = "pipeline( $_pipe , $_flux )";
2264
-		$p->interdire_scripts = false;
2265
-	}
2256
+    $_pipe = interprete_argument_balise(1, $p);
2257
+    if (!$_pipe) {
2258
+        $err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'PIPELINE'));
2259
+        erreur_squelette($err_b_s_a, $p);
2260
+    } else {
2261
+        $_flux = interprete_argument_balise(2, $p);
2262
+        $_flux = $_flux ? $_flux : "''";
2263
+        $p->code = "pipeline( $_pipe , $_flux )";
2264
+        $p->interdire_scripts = false;
2265
+    }
2266 2266
 
2267
-	return $p;
2267
+    return $p;
2268 2268
 }
2269 2269
 
2270 2270
 
@@ -2289,10 +2289,10 @@  discard block
 block discarded – undo
2289 2289
  *     Pile complétée par le code à générer
2290 2290
  **/
2291 2291
 function balise_EDIT_dist($p) {
2292
-	$p->code = "''";
2293
-	$p->interdire_scripts = false;
2292
+    $p->code = "''";
2293
+    $p->interdire_scripts = false;
2294 2294
 
2295
-	return $p;
2295
+    return $p;
2296 2296
 }
2297 2297
 
2298 2298
 
@@ -2315,11 +2315,11 @@  discard block
 block discarded – undo
2315 2315
  *     Pile complétée par le code à générer
2316 2316
  **/
2317 2317
 function balise_TOTAL_UNIQUE_dist($p) {
2318
-	$_famille = interprete_argument_balise(1, $p);
2319
-	$_famille = $_famille ? $_famille : "''";
2320
-	$p->code = "unique('', $_famille, true)";
2318
+    $_famille = interprete_argument_balise(1, $p);
2319
+    $_famille = $_famille ? $_famille : "''";
2320
+    $p->code = "unique('', $_famille, true)";
2321 2321
 
2322
-	return $p;
2322
+    return $p;
2323 2323
 }
2324 2324
 
2325 2325
 /**
@@ -2342,19 +2342,19 @@  discard block
 block discarded – undo
2342 2342
  *     Pile complétée par le code à générer
2343 2343
  **/
2344 2344
 function balise_ARRAY_dist($p) {
2345
-	$_code = array();
2346
-	$n = 1;
2347
-	do {
2348
-		$_key = interprete_argument_balise($n++, $p);
2349
-		$_val = interprete_argument_balise($n++, $p);
2350
-		if ($_key and $_val) {
2351
-			$_code[] = "$_key => $_val";
2352
-		}
2353
-	} while ($_key && $_val);
2354
-	$p->code = 'array(' . join(', ', $_code) . ')';
2355
-	$p->interdire_scripts = false;
2345
+    $_code = array();
2346
+    $n = 1;
2347
+    do {
2348
+        $_key = interprete_argument_balise($n++, $p);
2349
+        $_val = interprete_argument_balise($n++, $p);
2350
+        if ($_key and $_val) {
2351
+            $_code[] = "$_key => $_val";
2352
+        }
2353
+    } while ($_key && $_val);
2354
+    $p->code = 'array(' . join(', ', $_code) . ')';
2355
+    $p->interdire_scripts = false;
2356 2356
 
2357
-	return $p;
2357
+    return $p;
2358 2358
 }
2359 2359
 
2360 2360
 /**
@@ -2373,15 +2373,15 @@  discard block
 block discarded – undo
2373 2373
  *     Pile complétée par le code à générer
2374 2374
  */
2375 2375
 function balise_LISTE_dist($p) {
2376
-	$_code = array();
2377
-	$n = 1;
2378
-	while ($_val = interprete_argument_balise($n++, $p)) {
2379
-		$_code[] = $_val;
2380
-	}
2381
-	$p->code = 'array(' . join(', ', $_code) . ')';
2382
-	$p->interdire_scripts = false;
2376
+    $_code = array();
2377
+    $n = 1;
2378
+    while ($_val = interprete_argument_balise($n++, $p)) {
2379
+        $_code[] = $_val;
2380
+    }
2381
+    $p->code = 'array(' . join(', ', $_code) . ')';
2382
+    $p->interdire_scripts = false;
2383 2383
 
2384
-	return $p;
2384
+    return $p;
2385 2385
 }
2386 2386
 
2387 2387
 
@@ -2415,19 +2415,19 @@  discard block
 block discarded – undo
2415 2415
  *     Pile complétée par le code à générer
2416 2416
  **/
2417 2417
 function balise_AUTORISER_dist($p) {
2418
-	$_code = array();
2419
-	$p->descr['session'] = true; // faire un cache par session
2418
+    $_code = array();
2419
+    $p->descr['session'] = true; // faire un cache par session
2420 2420
 
2421
-	$n = 1;
2422
-	while ($_v = interprete_argument_balise($n++, $p)) {
2423
-		$_code[] = $_v;
2424
-	}
2421
+    $n = 1;
2422
+    while ($_v = interprete_argument_balise($n++, $p)) {
2423
+        $_code[] = $_v;
2424
+    }
2425 2425
 
2426
-	$p->code = '((function_exists("autoriser")||include_spip("inc/autoriser"))&&autoriser(' . join(', ',
2427
-			$_code) . ')?" ":"")';
2428
-	$p->interdire_scripts = false;
2426
+    $p->code = '((function_exists("autoriser")||include_spip("inc/autoriser"))&&autoriser(' . join(', ',
2427
+            $_code) . ')?" ":"")';
2428
+    $p->interdire_scripts = false;
2429 2429
 
2430
-	return $p;
2430
+    return $p;
2431 2431
 }
2432 2432
 
2433 2433
 
@@ -2451,15 +2451,15 @@  discard block
 block discarded – undo
2451 2451
  *     Pile complétée par le code à générer
2452 2452
  **/
2453 2453
 function balise_PLUGIN_dist($p) {
2454
-	$plugin = interprete_argument_balise(1, $p);
2455
-	$plugin = isset($plugin) ? str_replace('\'', '"', $plugin) : '""';
2456
-	$type_info = interprete_argument_balise(2, $p);
2457
-	$type_info = isset($type_info) ? str_replace('\'', '"', $type_info) : '"est_actif"';
2454
+    $plugin = interprete_argument_balise(1, $p);
2455
+    $plugin = isset($plugin) ? str_replace('\'', '"', $plugin) : '""';
2456
+    $type_info = interprete_argument_balise(2, $p);
2457
+    $type_info = isset($type_info) ? str_replace('\'', '"', $type_info) : '"est_actif"';
2458 2458
 
2459
-	$f = chercher_filtre('info_plugin');
2460
-	$p->code = $f . '(' . $plugin . ', ' . $type_info . ')';
2459
+    $f = chercher_filtre('info_plugin');
2460
+    $p->code = $f . '(' . $plugin . ', ' . $type_info . ')';
2461 2461
 
2462
-	return $p;
2462
+    return $p;
2463 2463
 }
2464 2464
 
2465 2465
 /**
@@ -2480,9 +2480,9 @@  discard block
 block discarded – undo
2480 2480
  *     Pile complétée par le code à générer
2481 2481
  **/
2482 2482
 function balise_AIDER_dist($p) {
2483
-	$_motif = interprete_argument_balise(1, $p);
2484
-	$p->code = "((\$aider=charger_fonction('aide','inc',true))?\$aider($_motif):'')";
2485
-	return $p;
2483
+    $_motif = interprete_argument_balise(1, $p);
2484
+    $p->code = "((\$aider=charger_fonction('aide','inc',true))?\$aider($_motif):'')";
2485
+    return $p;
2486 2486
 }
2487 2487
 
2488 2488
 /**
@@ -2508,16 +2508,16 @@  discard block
 block discarded – undo
2508 2508
  *     Pile complétée par le code à générer
2509 2509
  **/
2510 2510
 function balise_ACTION_FORMULAIRE($p) {
2511
-	if (!$_url = interprete_argument_balise(1, $p)) {
2512
-		$_url = "@\$Pile[0]['action']";
2513
-	}
2514
-	if (!$_form = interprete_argument_balise(2, $p)) {
2515
-		$_form = "@\$Pile[0]['form']";
2516
-	}
2517
-
2518
-	// envoyer le nom du formulaire que l'on traite
2519
-	// transmettre les eventuels args de la balise formulaire
2520
-	$p->code = "	'<span class=\"form-hidden\">' .
2511
+    if (!$_url = interprete_argument_balise(1, $p)) {
2512
+        $_url = "@\$Pile[0]['action']";
2513
+    }
2514
+    if (!$_form = interprete_argument_balise(2, $p)) {
2515
+        $_form = "@\$Pile[0]['form']";
2516
+    }
2517
+
2518
+    // envoyer le nom du formulaire que l'on traite
2519
+    // transmettre les eventuels args de la balise formulaire
2520
+    $p->code = "	'<span class=\"form-hidden\">' .
2521 2521
 	form_hidden($_url) .
2522 2522
 	'<input name=\'formulaire_action\' type=\'hidden\'
2523 2523
 		value=\'' . $_form . '\' />' .
@@ -2526,9 +2526,9 @@  discard block
 block discarded – undo
2526 2526
 	(!empty(\$Pile[0]['_hidden']) ? @\$Pile[0]['_hidden'] : '') .
2527 2527
 	'</span>'";
2528 2528
 
2529
-	$p->interdire_scripts = false;
2529
+    $p->interdire_scripts = false;
2530 2530
 
2531
-	return $p;
2531
+    return $p;
2532 2532
 }
2533 2533
 
2534 2534
 
@@ -2569,25 +2569,25 @@  discard block
 block discarded – undo
2569 2569
  */
2570 2570
 function balise_BOUTON_ACTION_dist($p) {
2571 2571
 
2572
-	$args = array();
2573
-	for ($k = 1; $k <= 6; $k++) {
2574
-		$_a = interprete_argument_balise($k, $p);
2575
-		if (!$_a) {
2576
-			$_a = "''";
2577
-		}
2578
-		$args[] = $_a;
2579
-	}
2580
-	// supprimer les args vides
2581
-	while (end($args) == "''" and count($args) > 2) {
2582
-		array_pop($args);
2583
-	}
2584
-	$args = implode(",", $args);
2572
+    $args = array();
2573
+    for ($k = 1; $k <= 6; $k++) {
2574
+        $_a = interprete_argument_balise($k, $p);
2575
+        if (!$_a) {
2576
+            $_a = "''";
2577
+        }
2578
+        $args[] = $_a;
2579
+    }
2580
+    // supprimer les args vides
2581
+    while (end($args) == "''" and count($args) > 2) {
2582
+        array_pop($args);
2583
+    }
2584
+    $args = implode(",", $args);
2585 2585
 
2586
-	$bouton_action = chercher_filtre("bouton_action");
2587
-	$p->code = "$bouton_action($args)";
2588
-	$p->interdire_scripts = false;
2586
+    $bouton_action = chercher_filtre("bouton_action");
2587
+    $p->code = "$bouton_action($args)";
2588
+    $p->interdire_scripts = false;
2589 2589
 
2590
-	return $p;
2590
+    return $p;
2591 2591
 }
2592 2592
 
2593 2593
 
@@ -2606,10 +2606,10 @@  discard block
 block discarded – undo
2606 2606
  *     Pile complétée par le code à générer
2607 2607
  */
2608 2608
 function balise_SLOGAN_SITE_SPIP_dist($p) {
2609
-	$p->code = "\$GLOBALS['meta']['slogan_site']";
2609
+    $p->code = "\$GLOBALS['meta']['slogan_site']";
2610 2610
 
2611
-	#$p->interdire_scripts = true;
2612
-	return $p;
2611
+    #$p->interdire_scripts = true;
2612
+    return $p;
2613 2613
 }
2614 2614
 
2615 2615
 
@@ -2633,10 +2633,10 @@  discard block
 block discarded – undo
2633 2633
  *     Pile complétée par le code à générer
2634 2634
  */
2635 2635
 function balise_HTML5_dist($p) {
2636
-	$p->code = html5_permis() ? "' '" : "''";
2637
-	$p->interdire_scripts = false;
2636
+    $p->code = html5_permis() ? "' '" : "''";
2637
+    $p->interdire_scripts = false;
2638 2638
 
2639
-	return $p;
2639
+    return $p;
2640 2640
 }
2641 2641
 
2642 2642
 
@@ -2662,61 +2662,61 @@  discard block
 block discarded – undo
2662 2662
  *     Pile complétée par le code à générer
2663 2663
  */
2664 2664
 function balise_TRI_dist($p, $liste = 'true') {
2665
-	$b = index_boucle_mere($p);
2666
-	// s'il n'y a pas de nom de boucle, on ne peut pas trier
2667
-	if ($b === '') {
2668
-		$msg = array('zbug_champ_hors_boucle', array('champ' => zbug_presenter_champ($p)));
2669
-		erreur_squelette($msg, $p);
2670
-		$p->code = "''";
2665
+    $b = index_boucle_mere($p);
2666
+    // s'il n'y a pas de nom de boucle, on ne peut pas trier
2667
+    if ($b === '') {
2668
+        $msg = array('zbug_champ_hors_boucle', array('champ' => zbug_presenter_champ($p)));
2669
+        erreur_squelette($msg, $p);
2670
+        $p->code = "''";
2671 2671
 
2672
-		return $p;
2673
-	}
2674
-	$boucle = $p->boucles[$b];
2672
+        return $p;
2673
+    }
2674
+    $boucle = $p->boucles[$b];
2675 2675
 
2676
-	// s'il n'y a pas de tri_champ, c'est qu'on se trouve
2677
-	// dans un boucle recursive ou qu'on a oublie le critere {tri}
2678
-	if (!isset($boucle->modificateur['tri_champ'])) {
2679
-		$msg = array('zbug_champ_hors_critere', array(
2680
-			'champ' => zbug_presenter_champ($p),
2681
-			'critere' => 'tri'
2682
-		));
2683
-		erreur_squelette($msg, $p);
2684
-		$p->code = "''";
2676
+    // s'il n'y a pas de tri_champ, c'est qu'on se trouve
2677
+    // dans un boucle recursive ou qu'on a oublie le critere {tri}
2678
+    if (!isset($boucle->modificateur['tri_champ'])) {
2679
+        $msg = array('zbug_champ_hors_critere', array(
2680
+            'champ' => zbug_presenter_champ($p),
2681
+            'critere' => 'tri'
2682
+        ));
2683
+        erreur_squelette($msg, $p);
2684
+        $p->code = "''";
2685 2685
 
2686
-		return $p;
2687
-	}
2686
+        return $p;
2687
+    }
2688 2688
 
2689
-	$_champ = interprete_argument_balise(1, $p);
2690
-	// si pas de champ, renvoyer le critere de tri utilise
2691
-	if (!$_champ) {
2692
-		$p->code = $boucle->modificateur['tri_champ'];
2689
+    $_champ = interprete_argument_balise(1, $p);
2690
+    // si pas de champ, renvoyer le critere de tri utilise
2691
+    if (!$_champ) {
2692
+        $p->code = $boucle->modificateur['tri_champ'];
2693 2693
 
2694
-		return $p;
2695
-	}
2696
-	// forcer la jointure si besoin, et si le champ est statique
2697
-	if (preg_match(",^'([\w.]+)'$,i", $_champ, $m)) {
2698
-		index_pile($b, $m[1], $p->boucles, '', null, true, false);
2699
-	}
2694
+        return $p;
2695
+    }
2696
+    // forcer la jointure si besoin, et si le champ est statique
2697
+    if (preg_match(",^'([\w.]+)'$,i", $_champ, $m)) {
2698
+        index_pile($b, $m[1], $p->boucles, '', null, true, false);
2699
+    }
2700 2700
 
2701
-	$_libelle = interprete_argument_balise(2, $p);
2702
-	$_libelle = $_libelle ? $_libelle : $_champ;
2701
+    $_libelle = interprete_argument_balise(2, $p);
2702
+    $_libelle = $_libelle ? $_libelle : $_champ;
2703 2703
 
2704
-	$_class = interprete_argument_balise(3, $p);
2705
-	// si champ = ">" c'est un lien vers le tri croissant : de gauche a droite ==> 1
2706
-	// si champ = "<" c'est un lien vers le tri decroissant : (sens inverse) == -1
2707
-	$_issens = "in_array($_champ,array('>','<'))";
2708
-	$_sens = "(strpos('< >',$_champ)-1)";
2704
+    $_class = interprete_argument_balise(3, $p);
2705
+    // si champ = ">" c'est un lien vers le tri croissant : de gauche a droite ==> 1
2706
+    // si champ = "<" c'est un lien vers le tri decroissant : (sens inverse) == -1
2707
+    $_issens = "in_array($_champ,array('>','<'))";
2708
+    $_sens = "(strpos('< >',$_champ)-1)";
2709 2709
 
2710
-	$_variable = "((\$s=$_issens)?'sens':'tri')." . $boucle->modificateur['tri_nom'];
2711
-	$_url = "parametre_url(self(),$_variable,\$s?$_sens:$_champ)";
2712
-	$_url = "parametre_url($_url,'var_memotri',strncmp(" . $boucle->modificateur['tri_nom'] . ",'session',7)==0?$_variable:'')";
2713
-	$_on = "\$s?(" . $boucle->modificateur['tri_sens'] . "==$_sens" . '):(' . $boucle->modificateur['tri_champ'] . "==$_champ)";
2710
+    $_variable = "((\$s=$_issens)?'sens':'tri')." . $boucle->modificateur['tri_nom'];
2711
+    $_url = "parametre_url(self(),$_variable,\$s?$_sens:$_champ)";
2712
+    $_url = "parametre_url($_url,'var_memotri',strncmp(" . $boucle->modificateur['tri_nom'] . ",'session',7)==0?$_variable:'')";
2713
+    $_on = "\$s?(" . $boucle->modificateur['tri_sens'] . "==$_sens" . '):(' . $boucle->modificateur['tri_champ'] . "==$_champ)";
2714 2714
 
2715
-	$p->code = "lien_ou_expose($_url,$_libelle,$_on" . ($_class ? ",$_class" : "") . ")";
2716
-	//$p->code = "''";
2717
-	$p->interdire_scripts = false;
2715
+    $p->code = "lien_ou_expose($_url,$_libelle,$_on" . ($_class ? ",$_class" : "") . ")";
2716
+    //$p->code = "''";
2717
+    $p->interdire_scripts = false;
2718 2718
 
2719
-	return $p;
2719
+    return $p;
2720 2720
 }
2721 2721
 
2722 2722
 
@@ -2737,22 +2737,22 @@  discard block
 block discarded – undo
2737 2737
  *     Pile complétée par le code à générer
2738 2738
  */
2739 2739
 function balise_SAUTER_dist($p) {
2740
-	$id_boucle = $p->id_boucle;
2740
+    $id_boucle = $p->id_boucle;
2741 2741
 
2742
-	if (empty($p->boucles[$id_boucle])) {
2743
-		$msg = array('zbug_champ_hors_boucle', array('champ' => '#SAUTER'));
2744
-		erreur_squelette($msg, $p);
2745
-	} else {
2746
-		$boucle = $p->boucles[$id_boucle];
2747
-		$_saut = interprete_argument_balise(1, $p);
2748
-		$_compteur = "\$Numrows['$id_boucle']['compteur_boucle']";
2749
-		$_total = "\$Numrows['$id_boucle']['total']";
2742
+    if (empty($p->boucles[$id_boucle])) {
2743
+        $msg = array('zbug_champ_hors_boucle', array('champ' => '#SAUTER'));
2744
+        erreur_squelette($msg, $p);
2745
+    } else {
2746
+        $boucle = $p->boucles[$id_boucle];
2747
+        $_saut = interprete_argument_balise(1, $p);
2748
+        $_compteur = "\$Numrows['$id_boucle']['compteur_boucle']";
2749
+        $_total = "\$Numrows['$id_boucle']['total']";
2750 2750
 
2751
-		$p->code = "vide($_compteur=\$iter->skip($_saut,$_total))";
2752
-	}
2753
-	$p->interdire_scripts = false;
2751
+        $p->code = "vide($_compteur=\$iter->skip($_saut,$_total))";
2752
+    }
2753
+    $p->interdire_scripts = false;
2754 2754
 
2755
-	return $p;
2755
+    return $p;
2756 2756
 }
2757 2757
 
2758 2758
 
@@ -2774,22 +2774,22 @@  discard block
 block discarded – undo
2774 2774
  *     Pile complétée par le code à générer
2775 2775
  */
2776 2776
 function balise_PUBLIE_dist($p) {
2777
-	if (!$_type = interprete_argument_balise(1, $p)) {
2778
-		$_type = _q($p->type_requete);
2779
-		$_id = champ_sql($p->boucles[$p->id_boucle]->primary, $p);
2780
-	} else {
2781
-		$_id = interprete_argument_balise(2, $p);
2782
-	}
2777
+    if (!$_type = interprete_argument_balise(1, $p)) {
2778
+        $_type = _q($p->type_requete);
2779
+        $_id = champ_sql($p->boucles[$p->id_boucle]->primary, $p);
2780
+    } else {
2781
+        $_id = interprete_argument_balise(2, $p);
2782
+    }
2783 2783
 
2784
-	$connect = '';
2785
-	if (isset($p->boucles[$p->id_boucle])) {
2786
-		$connect = $p->boucles[$p->id_boucle]->sql_serveur;
2787
-	}
2784
+    $connect = '';
2785
+    if (isset($p->boucles[$p->id_boucle])) {
2786
+        $connect = $p->boucles[$p->id_boucle]->sql_serveur;
2787
+    }
2788 2788
 
2789
-	$p->code = "(objet_test_si_publie(" . $_type . ",intval(" . $_id . ")," . _q($connect) . ")?' ':'')";
2790
-	$p->interdire_scripts = false;
2789
+    $p->code = "(objet_test_si_publie(" . $_type . ",intval(" . $_id . ")," . _q($connect) . ")?' ':'')";
2790
+    $p->interdire_scripts = false;
2791 2791
 
2792
-	return $p;
2792
+    return $p;
2793 2793
 }
2794 2794
 
2795 2795
 /**
@@ -2818,12 +2818,12 @@  discard block
 block discarded – undo
2818 2818
  *     Pile complétée par le code à générer
2819 2819
  */
2820 2820
 function balise_PRODUIRE_dist($p) {
2821
-	$balise_inclure = charger_fonction('INCLURE', 'balise');
2822
-	$p = $balise_inclure($p);
2821
+    $balise_inclure = charger_fonction('INCLURE', 'balise');
2822
+    $p = $balise_inclure($p);
2823 2823
 
2824
-	$p->code = str_replace('recuperer_fond(', 'produire_fond_statique(', $p->code);
2824
+    $p->code = str_replace('recuperer_fond(', 'produire_fond_statique(', $p->code);
2825 2825
 
2826
-	return $p;
2826
+    return $p;
2827 2827
 }
2828 2828
 
2829 2829
 /**
@@ -2842,13 +2842,13 @@  discard block
 block discarded – undo
2842 2842
  *     Pile complétée par le code à générer
2843 2843
  */
2844 2844
 function balise_LARGEUR_ECRAN_dist($p) {
2845
-	$_class = interprete_argument_balise(1, $p);
2846
-	if (!$_class) {
2847
-		$_class = 'null';
2848
-	}
2849
-	$p->code = "(is_string($_class)?vide(\$GLOBALS['largeur_ecran']=$_class):(isset(\$GLOBALS['largeur_ecran'])?\$GLOBALS['largeur_ecran']:''))";
2845
+    $_class = interprete_argument_balise(1, $p);
2846
+    if (!$_class) {
2847
+        $_class = 'null';
2848
+    }
2849
+    $p->code = "(is_string($_class)?vide(\$GLOBALS['largeur_ecran']=$_class):(isset(\$GLOBALS['largeur_ecran'])?\$GLOBALS['largeur_ecran']:''))";
2850 2850
 
2851
-	return $p;
2851
+    return $p;
2852 2852
 }
2853 2853
 
2854 2854
 
@@ -2864,14 +2864,14 @@  discard block
 block discarded – undo
2864 2864
  *     Pile complétée par le code à générer
2865 2865
  **/
2866 2866
 function balise_CONST_dist($p) {
2867
-	$_const = interprete_argument_balise(1, $p);
2868
-	if (!strlen($_const)) {
2869
-		$p->code = "''";
2870
-	}
2871
-	else {
2872
-		$p->code = "(defined($_const)?constant($_const):'')";
2873
-	}
2874
-	$p->interdire_scripts = false;
2875
-
2876
-	return $p;
2867
+    $_const = interprete_argument_balise(1, $p);
2868
+    if (!strlen($_const)) {
2869
+        $p->code = "''";
2870
+    }
2871
+    else {
2872
+        $p->code = "(defined($_const)?constant($_const):'')";
2873
+    }
2874
+    $p->interdire_scripts = false;
2875
+
2876
+    return $p;
2877 2877
 }
Please login to merge, or discard this patch.
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
  */
364 364
 function balise_DOSSIER_SQUELETTE_dist($p) {
365 365
 	$code = substr(addslashes(dirname($p->descr['sourcefile'])), strlen(_DIR_RACINE));
366
-	$p->code = "_DIR_RACINE . '$code'" .
366
+	$p->code = "_DIR_RACINE . '$code'".
367 367
 		$p->interdire_scripts = false;
368 368
 
369 369
 	return $p;
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
  */
383 383
 function balise_SQUELETTE_dist($p) {
384 384
 	$code = addslashes($p->descr['sourcefile']);
385
-	$p->code = "'$code'" .
385
+	$p->code = "'$code'".
386 386
 		$p->interdire_scripts = false;
387 387
 
388 388
 	return $p;
@@ -434,9 +434,9 @@  discard block
 block discarded – undo
434 434
  **/
435 435
 function balise_NOM_SITE_dist($p) {
436 436
 	if (!$p->etoile) {
437
-		$p->code = "supprimer_numero(calculer_url(" .
438
-			champ_sql('url_site', $p) . "," .
439
-			champ_sql('nom_site', $p) .
437
+		$p->code = "supprimer_numero(calculer_url(".
438
+			champ_sql('url_site', $p).",".
439
+			champ_sql('nom_site', $p).
440 440
 			", 'titre', \$connect, false))";
441 441
 	} else {
442 442
 		$p->code = champ_sql('nom_site', $p);
@@ -587,8 +587,8 @@  discard block
 block discarded – undo
587 587
  *     Pile complétée par le code à générer
588 588
  **/
589 589
 function balise_POPULARITE_ABSOLUE_dist($p) {
590
-	$p->code = 'ceil(' .
591
-		champ_sql('popularite', $p) .
590
+	$p->code = 'ceil('.
591
+		champ_sql('popularite', $p).
592 592
 		')';
593 593
 	$p->interdire_scripts = false;
594 594
 
@@ -666,9 +666,9 @@  discard block
 block discarded – undo
666 666
  **/
667 667
 function balise_VALEUR_dist($p) {
668 668
 	$b = $p->nom_boucle ? $p->nom_boucle : $p->id_boucle;
669
-	$p->code = index_pile($p->id_boucle, 'valeur', $p->boucles, $b);;
669
+	$p->code = index_pile($p->id_boucle, 'valeur', $p->boucles, $b); ;
670 670
 	if (($v = interprete_argument_balise(1, $p)) !== null) {
671
-		$p->code = 'table_valeur(' . $p->code . ', ' . $v . ')';
671
+		$p->code = 'table_valeur('.$p->code.', '.$v.')';
672 672
 	}
673 673
 	$p->interdire_scripts = true;
674 674
 
@@ -824,8 +824,8 @@  discard block
 block discarded – undo
824 824
 	$_suite = 'null';
825 825
 	$_longueur = $longueur_defaut;
826 826
 	if (($v = interprete_argument_balise(1, $p)) !== null) {
827
-		$_longueur = 'is_numeric(' . $v . ')?intval(' . $v . '):' . $longueur_defaut;
828
-		$_suite = '!is_numeric(' . $v . ')?' . $v . ':null';
827
+		$_longueur = 'is_numeric('.$v.')?intval('.$v.'):'.$longueur_defaut;
828
+		$_suite = '!is_numeric('.$v.')?'.$v.':null';
829 829
 	}
830 830
 	if (($v2 = interprete_argument_balise(2, $p)) !== null) {
831 831
 		$_suite = $v2;
@@ -913,10 +913,10 @@  discard block
 block discarded – undo
913 913
 		$c = memoriser_contexte_compil($p);
914 914
 
915 915
 		$p->code = sprintf(CODE_RECUPERER_FOND, "'modeles/lesauteurs'",
916
-			"array('objet'=>'" . $objet .
917
-			"','id_objet' => " . champ_sql($id_table_objet, $p) .
918
-			",'$id_table_objet' => " . champ_sql($id_table_objet, $p) .
919
-			($objet == 'article' ? "" : ",'id_article' => " . champ_sql('id_article', $p)) .
916
+			"array('objet'=>'".$objet.
917
+			"','id_objet' => ".champ_sql($id_table_objet, $p).
918
+			",'$id_table_objet' => ".champ_sql($id_table_objet, $p).
919
+			($objet == 'article' ? "" : ",'id_article' => ".champ_sql('id_article', $p)).
920 920
 			")",
921 921
 			"'trim'=>true, 'compil'=>array($c)",
922 922
 			_q($connect));
@@ -984,7 +984,7 @@  discard block
 block discarded – undo
984 984
 					$m = trim($m);
985 985
 					if ($m != "''") {
986 986
 						if (!preg_match(",\W,", $m)) {
987
-							$m = $boucle->id_table . ".$m";
987
+							$m = $boucle->id_table.".$m";
988 988
 						}
989 989
 						
990 990
 						$m .= " AS titre_rang";
@@ -1008,8 +1008,8 @@  discard block
 block discarded – undo
1008 1008
 			$_primary = champ_sql($id_table_objet, $p, '', false);
1009 1009
 			$_env = '$Pile[0]';
1010 1010
 
1011
-			if (!$_titre) {$_titre = "''";}
1012
-			if (!$_primary) {$_primary = "''";}
1011
+			if (!$_titre) {$_titre = "''"; }
1012
+			if (!$_primary) {$_primary = "''"; }
1013 1013
 			$_rang = "calculer_rang_smart($_titre, '$objet', $_primary, $_env)";
1014 1014
 
1015 1015
 		}
@@ -1142,7 +1142,7 @@  discard block
 block discarded – undo
1142 1142
 	$f_pagination = chercher_filtre('pagination');
1143 1143
 	$type = $p->boucles[$b]->modificateur['debut_nom'];
1144 1144
 	$modif = ($type[0] !== "'") ? "'debut'.$type"
1145
-		: ("'debut" . substr($type, 1));
1145
+		: ("'debut".substr($type, 1));
1146 1146
 
1147 1147
 	$p->code = sprintf(CODE_PAGINATION, $f_pagination, $b, $type, $modif, $pas, $liste,
1148 1148
 		((isset($__modele) and $__modele) ? $__modele : "''"), _q($connect), $code_contexte);
@@ -1276,7 +1276,7 @@  discard block
 block discarded – undo
1276 1276
 		$msg = array('zbug_balise_sans_argument', array('balise' => ' CHEMIN'));
1277 1277
 		erreur_squelette($msg, $p);
1278 1278
 	} else {
1279
-		$p->code = 'find_in_path(' . $arg . ')';
1279
+		$p->code = 'find_in_path('.$arg.')';
1280 1280
 	}
1281 1281
 
1282 1282
 	$p->interdire_scripts = false;
@@ -1311,7 +1311,7 @@  discard block
 block discarded – undo
1311 1311
 		$msg = array('zbug_balise_sans_argument', array('balise' => ' CHEMIN_IMAGE'));
1312 1312
 		erreur_squelette($msg, $p);
1313 1313
 	} else {
1314
-		$p->code = 'chemin_image(' . $arg . ')';
1314
+		$p->code = 'chemin_image('.$arg.')';
1315 1315
 	}
1316 1316
 
1317 1317
 	$p->interdire_scripts = false;
@@ -1365,7 +1365,7 @@  discard block
 block discarded – undo
1365 1365
 		// cas de #ENV sans argument : on retourne le serialize() du tableau
1366 1366
 		// une belle fonction [(#ENV|affiche_env)] serait pratique
1367 1367
 		if ($src) {
1368
-			$p->code = '(is_array($a = (' . $src . ')) ? serialize($a) : "")';
1368
+			$p->code = '(is_array($a = ('.$src.')) ? serialize($a) : "")';
1369 1369
 		} else {
1370 1370
 			$p->code = '@serialize($Pile[0])';
1371 1371
 		}
@@ -1418,8 +1418,8 @@  discard block
 block discarded – undo
1418 1418
 	$_sinon = interprete_argument_balise(2, $p);
1419 1419
 	$_unserialize = sinon(interprete_argument_balise(3, $p), "false");
1420 1420
 
1421
-	$p->code = '(include_spip(\'inc/config\')?lire_config(' . $arg . ',' .
1422
-		($_sinon && $_sinon != "''" ? $_sinon : 'null') . ',' . $_unserialize . "):'')";
1421
+	$p->code = '(include_spip(\'inc/config\')?lire_config('.$arg.','.
1422
+		($_sinon && $_sinon != "''" ? $_sinon : 'null').','.$_unserialize."):'')";
1423 1423
 
1424 1424
 	return $p;
1425 1425
 }
@@ -1512,7 +1512,7 @@  discard block
 block discarded – undo
1512 1512
 		$err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'SESSION_SET'));
1513 1513
 		erreur_squelette($err_b_s_a, $p);
1514 1514
 	} else {
1515
-		$p->code = '(include_spip("inc/session") AND session_set(' . $_nom . ',' . $_val . '))';
1515
+		$p->code = '(include_spip("inc/session") AND session_set('.$_nom.','.$_val.'))';
1516 1516
 	}
1517 1517
 
1518 1518
 	$p->interdire_scripts = false;
@@ -1555,7 +1555,7 @@  discard block
 block discarded – undo
1555 1555
 		if (preg_match(",^([[:space:]]*//[^\n]*\n)'([^']+)'$,ms",
1556 1556
 			$php, $r)) {
1557 1557
 			$p->code = /* $r[1]. */
1558
-				'(' . $r[2] . ')';
1558
+				'('.$r[2].')';
1559 1559
 		} else {
1560 1560
 			$p->code = "eval('return '.$php.';')";
1561 1561
 		}
@@ -1815,9 +1815,9 @@  discard block
 block discarded – undo
1815 1815
 
1816 1816
 		// noter la duree du cache dans un entete proprietaire
1817 1817
 
1818
-		$code = "'<'.'" . '?php header("X-Spip-Cache: '
1818
+		$code = "'<'.'".'?php header("X-Spip-Cache: '
1819 1819
 			. $duree
1820
-			. '"); ?' . "'.'>'";
1820
+			. '"); ?'."'.'>'";
1821 1821
 
1822 1822
 		// Remplir le header Cache-Control
1823 1823
 		// cas #CACHE{0}
@@ -1837,9 +1837,9 @@  discard block
 block discarded – undo
1837 1837
 			if ($pa == 'cache-client'
1838 1838
 				and $duree > 0
1839 1839
 			) {
1840
-				$code .= ".'<'.'" . '?php header("Cache-Control: max-age='
1840
+				$code .= ".'<'.'".'?php header("Cache-Control: max-age='
1841 1841
 					. $duree
1842
-					. '"); ?' . "'.'>'";
1842
+					. '"); ?'."'.'>'";
1843 1843
 				// il semble logique, si on cache-client, de ne pas invalider
1844 1844
 				$pa = 'statique';
1845 1845
 			}
@@ -1847,7 +1847,7 @@  discard block
 block discarded – undo
1847 1847
 			if ($pa == 'statique'
1848 1848
 				and $duree > 0
1849 1849
 			) {
1850
-				$code .= ".'<'.'" . '?php header("X-Spip-Statique: oui"); ?' . "'.'>'";
1850
+				$code .= ".'<'.'".'?php header("X-Spip-Statique: oui"); ?'."'.'>'";
1851 1851
 			}
1852 1852
 		}
1853 1853
 	} else {
@@ -2012,9 +2012,9 @@  discard block
 block discarded – undo
2012 2012
 		if ($p->etoile) {
2013 2013
 			$_options[] = "'etoile'=>true";
2014 2014
 		}
2015
-		$_options[] = "'compil'=>array(" . memoriser_contexte_compil($p) . ")";
2015
+		$_options[] = "'compil'=>array(".memoriser_contexte_compil($p).")";
2016 2016
 
2017
-		$_l = 'array(' . join(",\n\t", $_contexte) . ')';
2017
+		$_l = 'array('.join(",\n\t", $_contexte).')';
2018 2018
 		if ($flag_env) {
2019 2019
 			$_l = "array_merge(\$Pile[0],$_l)";
2020 2020
 		}
@@ -2025,7 +2025,7 @@  discard block
 block discarded – undo
2025 2025
 		$msg = array('zbug_balise_sans_argument', array('balise' => ' INCLURE'));
2026 2026
 		erreur_squelette($msg, $p);
2027 2027
 	} else {
2028
-		$p->code = 'charge_scripts(' . $_contexte[1] . ',false)';
2028
+		$p->code = 'charge_scripts('.$_contexte[1].',false)';
2029 2029
 	}
2030 2030
 
2031 2031
 	$p->interdire_scripts = false; // la securite est assuree par recuperer_fond
@@ -2073,7 +2073,7 @@  discard block
 block discarded – undo
2073 2073
 		unset($_contexte[1]);
2074 2074
 
2075 2075
 		if (preg_match("/^\s*'[^']*'/s", $nom)) {
2076
-			$nom = "'modeles/" . substr($nom, 1);
2076
+			$nom = "'modeles/".substr($nom, 1);
2077 2077
 		} else {
2078 2078
 			$nom = "'modeles/' . $nom";
2079 2079
 		}
@@ -2090,8 +2090,8 @@  discard block
 block discarded – undo
2090 2090
 			$primary = $p->boucles[$p->id_boucle]->primary;
2091 2091
 			if (!strpos($primary, ',')) {
2092 2092
 				$id = champ_sql($primary, $p);
2093
-				$_contexte[] = "'$primary'=>" . $id;
2094
-				$_contexte[] = "'id'=>" . $id;
2093
+				$_contexte[] = "'$primary'=>".$id;
2094
+				$_contexte[] = "'id'=>".$id;
2095 2095
 			}
2096 2096
 		}
2097 2097
 		$_contexte[] = "'recurs'=>(++\$recurs)";
@@ -2103,11 +2103,11 @@  discard block
 block discarded – undo
2103 2103
 		$_options = memoriser_contexte_compil($p);
2104 2104
 		$_options = "'compil'=>array($_options), 'trim'=>true";
2105 2105
 		if (isset($_contexte['ajax'])) {
2106
-			$_options .= ", " . preg_replace(",=>(.*)$,ims", '=> ($v=(\\1))?$v:true', $_contexte['ajax']);
2106
+			$_options .= ", ".preg_replace(",=>(.*)$,ims", '=> ($v=(\\1))?$v:true', $_contexte['ajax']);
2107 2107
 			unset($_contexte['ajax']);
2108 2108
 		}
2109 2109
 
2110
-		$_l = 'array(' . join(",\n\t", $_contexte) . ')';
2110
+		$_l = 'array('.join(",\n\t", $_contexte).')';
2111 2111
 		if ($flag_env) {
2112 2112
 			$_l = "array_merge(\$Pile[0],$_l)";
2113 2113
 		}
@@ -2217,12 +2217,12 @@  discard block
 block discarded – undo
2217 2217
 function balise_DOUBLONS_dist($p) {
2218 2218
 	if ($type = interprete_argument_balise(1, $p)) {
2219 2219
 		if ($famille = interprete_argument_balise(2, $p)) {
2220
-			$type .= '.' . $famille;
2220
+			$type .= '.'.$famille;
2221 2221
 		}
2222
-		$p->code = '(isset($doublons[' . $type . ']) ? $doublons[' . $type . '] : "")';
2222
+		$p->code = '(isset($doublons['.$type.']) ? $doublons['.$type.'] : "")';
2223 2223
 		if (!$p->etoile) {
2224 2224
 			$p->code = 'array_filter(array_map("intval",explode(",",'
2225
-				. $p->code . ')))';
2225
+				. $p->code.')))';
2226 2226
 		}
2227 2227
 	} else {
2228 2228
 		$p->code = '$doublons';
@@ -2351,7 +2351,7 @@  discard block
 block discarded – undo
2351 2351
 			$_code[] = "$_key => $_val";
2352 2352
 		}
2353 2353
 	} while ($_key && $_val);
2354
-	$p->code = 'array(' . join(', ', $_code) . ')';
2354
+	$p->code = 'array('.join(', ', $_code).')';
2355 2355
 	$p->interdire_scripts = false;
2356 2356
 
2357 2357
 	return $p;
@@ -2378,7 +2378,7 @@  discard block
 block discarded – undo
2378 2378
 	while ($_val = interprete_argument_balise($n++, $p)) {
2379 2379
 		$_code[] = $_val;
2380 2380
 	}
2381
-	$p->code = 'array(' . join(', ', $_code) . ')';
2381
+	$p->code = 'array('.join(', ', $_code).')';
2382 2382
 	$p->interdire_scripts = false;
2383 2383
 
2384 2384
 	return $p;
@@ -2423,8 +2423,8 @@  discard block
 block discarded – undo
2423 2423
 		$_code[] = $_v;
2424 2424
 	}
2425 2425
 
2426
-	$p->code = '((function_exists("autoriser")||include_spip("inc/autoriser"))&&autoriser(' . join(', ',
2427
-			$_code) . ')?" ":"")';
2426
+	$p->code = '((function_exists("autoriser")||include_spip("inc/autoriser"))&&autoriser('.join(', ',
2427
+			$_code).')?" ":"")';
2428 2428
 	$p->interdire_scripts = false;
2429 2429
 
2430 2430
 	return $p;
@@ -2457,7 +2457,7 @@  discard block
 block discarded – undo
2457 2457
 	$type_info = isset($type_info) ? str_replace('\'', '"', $type_info) : '"est_actif"';
2458 2458
 
2459 2459
 	$f = chercher_filtre('info_plugin');
2460
-	$p->code = $f . '(' . $plugin . ', ' . $type_info . ')';
2460
+	$p->code = $f.'('.$plugin.', '.$type_info.')';
2461 2461
 
2462 2462
 	return $p;
2463 2463
 }
@@ -2707,12 +2707,12 @@  discard block
 block discarded – undo
2707 2707
 	$_issens = "in_array($_champ,array('>','<'))";
2708 2708
 	$_sens = "(strpos('< >',$_champ)-1)";
2709 2709
 
2710
-	$_variable = "((\$s=$_issens)?'sens':'tri')." . $boucle->modificateur['tri_nom'];
2710
+	$_variable = "((\$s=$_issens)?'sens':'tri').".$boucle->modificateur['tri_nom'];
2711 2711
 	$_url = "parametre_url(self(),$_variable,\$s?$_sens:$_champ)";
2712
-	$_url = "parametre_url($_url,'var_memotri',strncmp(" . $boucle->modificateur['tri_nom'] . ",'session',7)==0?$_variable:'')";
2713
-	$_on = "\$s?(" . $boucle->modificateur['tri_sens'] . "==$_sens" . '):(' . $boucle->modificateur['tri_champ'] . "==$_champ)";
2712
+	$_url = "parametre_url($_url,'var_memotri',strncmp(".$boucle->modificateur['tri_nom'].",'session',7)==0?$_variable:'')";
2713
+	$_on = "\$s?(".$boucle->modificateur['tri_sens']."==$_sens".'):('.$boucle->modificateur['tri_champ']."==$_champ)";
2714 2714
 
2715
-	$p->code = "lien_ou_expose($_url,$_libelle,$_on" . ($_class ? ",$_class" : "") . ")";
2715
+	$p->code = "lien_ou_expose($_url,$_libelle,$_on".($_class ? ",$_class" : "").")";
2716 2716
 	//$p->code = "''";
2717 2717
 	$p->interdire_scripts = false;
2718 2718
 
@@ -2786,7 +2786,7 @@  discard block
 block discarded – undo
2786 2786
 		$connect = $p->boucles[$p->id_boucle]->sql_serveur;
2787 2787
 	}
2788 2788
 
2789
-	$p->code = "(objet_test_si_publie(" . $_type . ",intval(" . $_id . ")," . _q($connect) . ")?' ':'')";
2789
+	$p->code = "(objet_test_si_publie(".$_type.",intval(".$_id."),"._q($connect).")?' ':'')";
2790 2790
 	$p->interdire_scripts = false;
2791 2791
 
2792 2792
 	return $p;
Please login to merge, or discard this patch.