Completed
Push — master ( 2056af...6c9939 )
by cam
01:09
created
ecrire/public/tracer.php 1 patch
Indentation   +170 added lines, -170 removed lines patch added patch discarded remove patch
@@ -11,190 +11,190 @@
 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/@trace_query_start
18 18
 function trace_query_start() {
19
-	static $trace = '?';
20
-	if ($trace === '?' or defined('_DEBUG_TRACE_QUERIES')) {
21
-		if (defined('_DEBUG_TRACE_QUERIES') and _DEBUG_TRACE_QUERIES) {
22
-			$trace = true;
23
-		}
24
-		else {
25
-			if (empty($GLOBALS['visiteur_session'])) {
26
-				// si un anonyme fait un var_profile on est oblige de remplir le tableau des temps en attendant de savoir
27
-				// car ici on ne sait pas si c'est un hit anonyme
28
-				// ou une requete SQL faite avant chargement de la session
29
-				$trace = (!empty($_GET['var_profile']) ? '?' : false);
30
-			}
31
-			else {
32
-				include_spip('inc/autoriser');
33
-				// gare au bouclage sur calcul de droits au premier appel
34
-				// A fortiori quand on demande une trace
35
-				$trace = false; // on ne trace pas la requete provoquee par autoriser('debug')
36
-				$trace = (!empty($_GET['var_profile']) and autoriser('debug'));
37
-			}
38
-		}
39
-	}
40
-
41
-	return $trace ? microtime() : 0;
19
+    static $trace = '?';
20
+    if ($trace === '?' or defined('_DEBUG_TRACE_QUERIES')) {
21
+        if (defined('_DEBUG_TRACE_QUERIES') and _DEBUG_TRACE_QUERIES) {
22
+            $trace = true;
23
+        }
24
+        else {
25
+            if (empty($GLOBALS['visiteur_session'])) {
26
+                // si un anonyme fait un var_profile on est oblige de remplir le tableau des temps en attendant de savoir
27
+                // car ici on ne sait pas si c'est un hit anonyme
28
+                // ou une requete SQL faite avant chargement de la session
29
+                $trace = (!empty($_GET['var_profile']) ? '?' : false);
30
+            }
31
+            else {
32
+                include_spip('inc/autoriser');
33
+                // gare au bouclage sur calcul de droits au premier appel
34
+                // A fortiori quand on demande une trace
35
+                $trace = false; // on ne trace pas la requete provoquee par autoriser('debug')
36
+                $trace = (!empty($_GET['var_profile']) and autoriser('debug'));
37
+            }
38
+        }
39
+    }
40
+
41
+    return $trace ? microtime() : 0;
42 42
 }
43 43
 
44 44
 // https://code.spip.net/@trace_query_end
45 45
 function trace_query_end($query, $start, $result, $erreur, $serveur = '') {
46
-	static $trace = '?';
47
-	if ($trace === '?') {
48
-		if (empty($GLOBALS['visiteur_session'])) {
49
-			// si un anonyme fait un var_profile on est oblige de remplir le tableau des temps en attendant de savoir
50
-			// car ici on ne sait pas si c'est un hit anonyme
51
-			// ou une requete SQL faite avant chargement de la session
52
-			$trace = (!empty($_GET['var_profile']) ? '?' : false);
53
-		}
54
-		else {
55
-			include_spip('inc/autoriser');
56
-			// gare au bouclage sur calcul de droits au premier appel
57
-			// A fortiori quand on demande une trace
58
-			$trace = false; // on ne trace pas la requete provoquee par autoriser('debug')
59
-			$trace = (!empty($_GET['var_profile']) and autoriser('debug'));
60
-		}
61
-	}
62
-	if ($start) {
63
-		$end = microtime();
64
-		list($usec, $sec) = explode(' ', $start);
65
-		list($usec2, $sec2) = explode(' ', $end);
66
-		$dt = $sec2 + $usec2 - $sec - $usec;
67
-		pipeline('trig_trace_query', ['query' => $query, 'start' => $start, 'end' => $end, 'time' => $dt, 'result' => $result, 'erreur' => $erreur, 'serveur' => $serveur]);
68
-		if ($trace) {
69
-			trace_query_chrono($dt, $query, $result, $serveur);
70
-		}
71
-	}
72
-	// tracer les erreurs, sauf pour select, c'est fait dans abstract_sql
73
-	if ($trace and $erreur and !preg_match('/^select\b/i', $query)) {
74
-		erreur_squelette([sql_errno($serveur), $erreur, $query]);
75
-	}
76
-
77
-	return $result;
46
+    static $trace = '?';
47
+    if ($trace === '?') {
48
+        if (empty($GLOBALS['visiteur_session'])) {
49
+            // si un anonyme fait un var_profile on est oblige de remplir le tableau des temps en attendant de savoir
50
+            // car ici on ne sait pas si c'est un hit anonyme
51
+            // ou une requete SQL faite avant chargement de la session
52
+            $trace = (!empty($_GET['var_profile']) ? '?' : false);
53
+        }
54
+        else {
55
+            include_spip('inc/autoriser');
56
+            // gare au bouclage sur calcul de droits au premier appel
57
+            // A fortiori quand on demande une trace
58
+            $trace = false; // on ne trace pas la requete provoquee par autoriser('debug')
59
+            $trace = (!empty($_GET['var_profile']) and autoriser('debug'));
60
+        }
61
+    }
62
+    if ($start) {
63
+        $end = microtime();
64
+        list($usec, $sec) = explode(' ', $start);
65
+        list($usec2, $sec2) = explode(' ', $end);
66
+        $dt = $sec2 + $usec2 - $sec - $usec;
67
+        pipeline('trig_trace_query', ['query' => $query, 'start' => $start, 'end' => $end, 'time' => $dt, 'result' => $result, 'erreur' => $erreur, 'serveur' => $serveur]);
68
+        if ($trace) {
69
+            trace_query_chrono($dt, $query, $result, $serveur);
70
+        }
71
+    }
72
+    // tracer les erreurs, sauf pour select, c'est fait dans abstract_sql
73
+    if ($trace and $erreur and !preg_match('/^select\b/i', $query)) {
74
+        erreur_squelette([sql_errno($serveur), $erreur, $query]);
75
+    }
76
+
77
+    return $result;
78 78
 }
79 79
 
80 80
 // https://code.spip.net/@trace_query_chrono
81 81
 function trace_query_chrono($dt, $query, $result, $serveur = '') {
82
-	include_spip('inc/filtres_mini');
83
-	static $tt = 0, $nb = 0;
84
-
85
-	$x = _request('var_mode_objet');
86
-	if (isset($GLOBALS['debug']['aucasou'])) {
87
-		list(, $boucle, $serveur, $contexte) = $GLOBALS['debug']['aucasou'];
88
-		if ($x and !preg_match("/$boucle\$/", $x)) {
89
-			return;
90
-		}
91
-		if ($serveur) {
92
-			$boucle .= " ($serveur)";
93
-		}
94
-		$boucle = "<b>$boucle</b>";
95
-	} else {
96
-		if ($x) {
97
-			return;
98
-		}
99
-		$boucle = $contexte = '';
100
-	}
101
-
102
-	$tt += $dt;
103
-	$nb++;
104
-
105
-	$q = preg_replace('/([a-z)`])\s+([A-Z])/', "$1\n<br />$2", spip_htmlentities($query));
106
-	$e = sql_explain($query, $serveur);
107
-	$r = str_replace('Resource id ', '', (is_object($result) ? get_class($result) : $result));
108
-	$GLOBALS['tableau_des_temps'][] = [$dt, $nb, $boucle, $q, $e, $r, $contexte];
82
+    include_spip('inc/filtres_mini');
83
+    static $tt = 0, $nb = 0;
84
+
85
+    $x = _request('var_mode_objet');
86
+    if (isset($GLOBALS['debug']['aucasou'])) {
87
+        list(, $boucle, $serveur, $contexte) = $GLOBALS['debug']['aucasou'];
88
+        if ($x and !preg_match("/$boucle\$/", $x)) {
89
+            return;
90
+        }
91
+        if ($serveur) {
92
+            $boucle .= " ($serveur)";
93
+        }
94
+        $boucle = "<b>$boucle</b>";
95
+    } else {
96
+        if ($x) {
97
+            return;
98
+        }
99
+        $boucle = $contexte = '';
100
+    }
101
+
102
+    $tt += $dt;
103
+    $nb++;
104
+
105
+    $q = preg_replace('/([a-z)`])\s+([A-Z])/', "$1\n<br />$2", spip_htmlentities($query));
106
+    $e = sql_explain($query, $serveur);
107
+    $r = str_replace('Resource id ', '', (is_object($result) ? get_class($result) : $result));
108
+    $GLOBALS['tableau_des_temps'][] = [$dt, $nb, $boucle, $q, $e, $r, $contexte];
109 109
 }
110 110
 
111 111
 
112 112
 function chrono_requete($temps) {
113
-	$total = 0;
114
-	$hors = '<i>' . _T('zbug_hors_compilation') . '</i>';
115
-	$t = $q = $n = $d = [];
116
-	// Totaliser les temps et completer le Explain
117
-	foreach ($temps as $key => $v) {
118
-		list($dt, $nb, $boucle, $query, $explain, $res, $contexte) = $v;
119
-		if (is_array($contexte)) {
120
-			$k = ($contexte[0] . " $boucle");
121
-			include_spip('public/compiler');
122
-			$env = reconstruire_contexte_compil($contexte);
123
-		} else {
124
-			$k = $env = $boucle;
125
-		}
126
-
127
-		$total += $dt;
128
-		$t[$key] = $dt;
129
-		$q[$key] = $nb;
130
-		if (!isset($d[$k])) {
131
-			$d[$k] = 0;
132
-			$n[$k] = 0;
133
-		}
134
-		$d[$k] += $dt;
135
-		++$n[$k];
136
-
137
-		if (!is_array($explain)) {
138
-			$explain = [];
139
-		}
140
-		foreach ($explain as $j => $v) {
141
-			$explain[$j] = "<tr><th>$j</th><td>"
142
-				. str_replace(';', '<br />', $v)
143
-				. '</td></tr>';
144
-		}
145
-		$e = "<table class='explain'>"
146
-			. '<caption>'
147
-			. $query
148
-			. '</caption>'
149
-			. "<tr><th>Time</th><td>$dt</td></tr>"
150
-			. "<tr><th>Order</th><td>$nb</td></tr>"
151
-			. "<tr><th>Res</th><td>$res</td></tr>"
152
-			. join('', $explain)
153
-			. '</table>';
154
-
155
-		$temps[$key] = [$e, $env, $k];
156
-	}
157
-	// Trier par temps d'execution decroissant
158
-	array_multisort($t, SORT_DESC, $q, $temps);
159
-	arsort($d);
160
-	$i = 1;
161
-	$t = [];
162
-	// Fabriquer les liens de navigations dans le tableau des temps
163
-	foreach ($temps as $k => $v) {
164
-		$titre = strip_tags($v[2]);
165
-		$href = quote_amp($GLOBALS['REQUEST_URI']) . "#req$i";
166
-		$href = str_replace("\\'", '&#39;', $href);
167
-
168
-		if (!isset($t[$v[2]])) {
169
-			$t[$v[2]] = [];
170
-		}
171
-		$t[$v[2]][] = "<span class='spip-debug-arg'> "
172
-			. "<a title='$titre' href='$href'>$i</a>"
173
-			. '</span>'
174
-			. ((count($t[$v[2]]) % 10 == 9) ? '<br />' : '');
175
-		$i++;
176
-	}
177
-
178
-	if ($d['']) {
179
-		$d[$hors] = $d[''];
180
-		$n[$hors] = $n[''];
181
-		$t[$hors] = $t[''];
182
-	}
183
-	unset($d['']);
184
-	// Fabriquer le tableau des liens de navigation dans le grand tableau
185
-	foreach ($d as $k => $v) {
186
-		$d[$k] = $n[$k] . "</td><td>$k</td><td class='time'>$v</td><td class='liste-reqs'>"
187
-			. join('', $t[$k]);
188
-	}
189
-
190
-	$navigation = [
191
-		_T('zbug_statistiques'),
192
-		'<tr><td>'
193
-		. join("</td></tr>\n<tr><td>", $d)
194
-		. "</td></tr>\n"
195
-		. (# _request('var_mode_objet') ? '' :
196
-		('<tr><td>' . count($temps) . '</td><td>' . _T('info_total') . '</td><td class="time">' . $total . '</td><td></td></tr>'))
197
-	];
198
-
199
-	return [$temps, $navigation];
113
+    $total = 0;
114
+    $hors = '<i>' . _T('zbug_hors_compilation') . '</i>';
115
+    $t = $q = $n = $d = [];
116
+    // Totaliser les temps et completer le Explain
117
+    foreach ($temps as $key => $v) {
118
+        list($dt, $nb, $boucle, $query, $explain, $res, $contexte) = $v;
119
+        if (is_array($contexte)) {
120
+            $k = ($contexte[0] . " $boucle");
121
+            include_spip('public/compiler');
122
+            $env = reconstruire_contexte_compil($contexte);
123
+        } else {
124
+            $k = $env = $boucle;
125
+        }
126
+
127
+        $total += $dt;
128
+        $t[$key] = $dt;
129
+        $q[$key] = $nb;
130
+        if (!isset($d[$k])) {
131
+            $d[$k] = 0;
132
+            $n[$k] = 0;
133
+        }
134
+        $d[$k] += $dt;
135
+        ++$n[$k];
136
+
137
+        if (!is_array($explain)) {
138
+            $explain = [];
139
+        }
140
+        foreach ($explain as $j => $v) {
141
+            $explain[$j] = "<tr><th>$j</th><td>"
142
+                . str_replace(';', '<br />', $v)
143
+                . '</td></tr>';
144
+        }
145
+        $e = "<table class='explain'>"
146
+            . '<caption>'
147
+            . $query
148
+            . '</caption>'
149
+            . "<tr><th>Time</th><td>$dt</td></tr>"
150
+            . "<tr><th>Order</th><td>$nb</td></tr>"
151
+            . "<tr><th>Res</th><td>$res</td></tr>"
152
+            . join('', $explain)
153
+            . '</table>';
154
+
155
+        $temps[$key] = [$e, $env, $k];
156
+    }
157
+    // Trier par temps d'execution decroissant
158
+    array_multisort($t, SORT_DESC, $q, $temps);
159
+    arsort($d);
160
+    $i = 1;
161
+    $t = [];
162
+    // Fabriquer les liens de navigations dans le tableau des temps
163
+    foreach ($temps as $k => $v) {
164
+        $titre = strip_tags($v[2]);
165
+        $href = quote_amp($GLOBALS['REQUEST_URI']) . "#req$i";
166
+        $href = str_replace("\\'", '&#39;', $href);
167
+
168
+        if (!isset($t[$v[2]])) {
169
+            $t[$v[2]] = [];
170
+        }
171
+        $t[$v[2]][] = "<span class='spip-debug-arg'> "
172
+            . "<a title='$titre' href='$href'>$i</a>"
173
+            . '</span>'
174
+            . ((count($t[$v[2]]) % 10 == 9) ? '<br />' : '');
175
+        $i++;
176
+    }
177
+
178
+    if ($d['']) {
179
+        $d[$hors] = $d[''];
180
+        $n[$hors] = $n[''];
181
+        $t[$hors] = $t[''];
182
+    }
183
+    unset($d['']);
184
+    // Fabriquer le tableau des liens de navigation dans le grand tableau
185
+    foreach ($d as $k => $v) {
186
+        $d[$k] = $n[$k] . "</td><td>$k</td><td class='time'>$v</td><td class='liste-reqs'>"
187
+            . join('', $t[$k]);
188
+    }
189
+
190
+    $navigation = [
191
+        _T('zbug_statistiques'),
192
+        '<tr><td>'
193
+        . join("</td></tr>\n<tr><td>", $d)
194
+        . "</td></tr>\n"
195
+        . (# _request('var_mode_objet') ? '' :
196
+        ('<tr><td>' . count($temps) . '</td><td>' . _T('info_total') . '</td><td class="time">' . $total . '</td><td></td></tr>'))
197
+    ];
198
+
199
+    return [$temps, $navigation];
200 200
 }
Please login to merge, or discard this patch.
ecrire/public/admin.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 /**
@@ -34,33 +34,33 @@  discard block
 block discarded – undo
34 34
  *     Contenu HTML, avec boutons d'administrations et sa CSS
35 35
  **/
36 36
 function affiche_boutons_admin($contenu) {
37
-	include_spip('inc/filtres');
37
+    include_spip('inc/filtres');
38 38
 
39
-	// Inserer le css d'admin
40
-	$css = "<link rel='stylesheet' href='" . url_absolue(direction_css(find_in_path('spip_admin.css')))
41
-		. "' type='text/css' />\n";
42
-	if ($f = find_in_path('spip_admin_perso.css')) {
43
-		$css .= "<link rel='stylesheet' href='"
44
-			. url_absolue(direction_css($f)) . "' type='text/css' />\n";
45
-	}
39
+    // Inserer le css d'admin
40
+    $css = "<link rel='stylesheet' href='" . url_absolue(direction_css(find_in_path('spip_admin.css')))
41
+        . "' type='text/css' />\n";
42
+    if ($f = find_in_path('spip_admin_perso.css')) {
43
+        $css .= "<link rel='stylesheet' href='"
44
+            . url_absolue(direction_css($f)) . "' type='text/css' />\n";
45
+    }
46 46
 
47
-	($pos = stripos($contenu, '</head>'))
48
-	|| ($pos = stripos($contenu, '<body>'))
49
-	|| ($pos = 0);
50
-	$contenu = substr_replace($contenu, $css, $pos, 0);
47
+    ($pos = stripos($contenu, '</head>'))
48
+    || ($pos = stripos($contenu, '<body>'))
49
+    || ($pos = 0);
50
+    $contenu = substr_replace($contenu, $css, $pos, 0);
51 51
 
52 52
 
53
-	// Inserer la balise #FORMULAIRE_ADMIN, en float
54
-	$boutons_admin = inclure_balise_dynamique(
55
-		balise_FORMULAIRE_ADMIN_dyn('spip-admin-float'),
56
-		false
57
-	);
53
+    // Inserer la balise #FORMULAIRE_ADMIN, en float
54
+    $boutons_admin = inclure_balise_dynamique(
55
+        balise_FORMULAIRE_ADMIN_dyn('spip-admin-float'),
56
+        false
57
+    );
58 58
 
59
-	($pos = strripos($contenu, '</body>'))
60
-	|| ($pos = strripos($contenu, '</html>'))
61
-	|| ($pos = strlen($contenu));
62
-	$contenu = substr_replace($contenu, $boutons_admin, $pos, 0);
59
+    ($pos = strripos($contenu, '</body>'))
60
+    || ($pos = strripos($contenu, '</html>'))
61
+    || ($pos = strlen($contenu));
62
+    $contenu = substr_replace($contenu, $boutons_admin, $pos, 0);
63 63
 
64 64
 
65
-	return $contenu;
65
+    return $contenu;
66 66
 }
Please login to merge, or discard this patch.
ecrire/public/normaliser.php 1 patch
Indentation   +159 added lines, -159 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
 // Les fonctions de ce fichier sont appelees en certains points
@@ -25,193 +25,193 @@  discard block
 block discarded – undo
25 25
 // -> https://www.spip.net/fr_article901.html
26 26
 
27 27
 function phraser_vieux_logos(&$p) {
28
-	if ($p->param[0][0]) {
29
-		$args = [''];
30
-	} else {
31
-		$args = array_shift($p->param);
32
-	}
33
-
34
-	foreach ($p->param as $couple) {
35
-		$nom = trim($couple[0]);
36
-		if ($nom == '') {
37
-			array_shift($p->param);
38
-			break;
39
-		}
40
-		$r = phraser_logo_faux_filtres($nom);
41
-		if ($r === 0) {
42
-			$c = new Texte();
43
-			$c->texte = $nom;
44
-			$args[] = [$c];
45
-			array_shift($p->param);
46
-			spip_log("filtre de logo obsolete $nom", 'vieilles_defs');
47
-		} elseif ($r === 2) {
48
-			$p->etoile = '**';
49
-			array_shift($p->param);
50
-			spip_log("filtre de logo obsolete $nom", 'vieilles_defs');
51
-		} elseif ($r === 1) {
52
-			array_shift($p->param);
53
-			$p->etoile = '*';
54
-			spip_log("filtre de logo obsolete $nom", 'vieilles_defs');
55
-		} elseif (preg_match('/^' . NOM_DE_CHAMP . '(.*)$/sS', $nom, $m)) {
56
-			$champ = new Champ();
57
-			$champ->nom_boucle = $m[2];
58
-			$champ->nom_champ = $m[3];
59
-			$champ->etoile = $m[5];
60
-			$champ = [$champ];
61
-			if ($m[6]) {
62
-				$r = new Texte();
63
-				$r->texte = $m[6];
64
-				$champ[] = $r;
65
-			}
66
-			$args[] = $champ;
67
-			array_shift($p->param);
68
-			spip_log("filtre de logo obsolete $nom", 'vieilles_defs');
69
-		} // le cas else est la seule incompatibilite
70
-	}
71
-	array_unshift($p->param, $args);
28
+    if ($p->param[0][0]) {
29
+        $args = [''];
30
+    } else {
31
+        $args = array_shift($p->param);
32
+    }
33
+
34
+    foreach ($p->param as $couple) {
35
+        $nom = trim($couple[0]);
36
+        if ($nom == '') {
37
+            array_shift($p->param);
38
+            break;
39
+        }
40
+        $r = phraser_logo_faux_filtres($nom);
41
+        if ($r === 0) {
42
+            $c = new Texte();
43
+            $c->texte = $nom;
44
+            $args[] = [$c];
45
+            array_shift($p->param);
46
+            spip_log("filtre de logo obsolete $nom", 'vieilles_defs');
47
+        } elseif ($r === 2) {
48
+            $p->etoile = '**';
49
+            array_shift($p->param);
50
+            spip_log("filtre de logo obsolete $nom", 'vieilles_defs');
51
+        } elseif ($r === 1) {
52
+            array_shift($p->param);
53
+            $p->etoile = '*';
54
+            spip_log("filtre de logo obsolete $nom", 'vieilles_defs');
55
+        } elseif (preg_match('/^' . NOM_DE_CHAMP . '(.*)$/sS', $nom, $m)) {
56
+            $champ = new Champ();
57
+            $champ->nom_boucle = $m[2];
58
+            $champ->nom_champ = $m[3];
59
+            $champ->etoile = $m[5];
60
+            $champ = [$champ];
61
+            if ($m[6]) {
62
+                $r = new Texte();
63
+                $r->texte = $m[6];
64
+                $champ[] = $r;
65
+            }
66
+            $args[] = $champ;
67
+            array_shift($p->param);
68
+            spip_log("filtre de logo obsolete $nom", 'vieilles_defs');
69
+        } // le cas else est la seule incompatibilite
70
+    }
71
+    array_unshift($p->param, $args);
72 72
 }
73 73
 
74 74
 
75 75
 function phraser_logo_faux_filtres($nom) {
76
-	switch ($nom) {
77
-		case 'top':
78
-		case 'left':
79
-		case 'right':
80
-		case 'center':
81
-		case 'bottom':
82
-			return 0;
83
-		case 'lien':
84
-			return 1;
85
-		case 'fichier':
86
-			return 2;
87
-		default:
88
-			return $nom;
89
-	}
76
+    switch ($nom) {
77
+        case 'top':
78
+        case 'left':
79
+        case 'right':
80
+        case 'center':
81
+        case 'bottom':
82
+            return 0;
83
+        case 'lien':
84
+            return 1;
85
+        case 'fichier':
86
+            return 2;
87
+        default:
88
+            return $nom;
89
+    }
90 90
 }
91 91
 
92 92
 
93 93
 // La balise embed_document est a present le modele emb
94 94
 
95 95
 function phraser_vieux_emb(&$p) {
96
-	if (!is_array($p->param)) {
97
-		$p->param = [];
98
-	}
99
-
100
-	// Produire le premier argument {emb}
101
-	$texte = new Texte();
102
-	$texte->texte = 'emb';
103
-	$param = ['', [$texte]];
104
-
105
-	// Transformer les filtres en arguments
106
-	for ($i = 0; $i < count($p->param); $i++) {
107
-		if ($p->param[$i][0]) {
108
-			if (!strstr($p->param[$i][0], '=')) {
109
-				break;
110
-			}# on a rencontre un vrai filtre, c'est fini
111
-			$texte = new Texte();
112
-			$texte->texte = $p->param[$i][0];
113
-			$param[] = [$texte];
114
-		}
115
-		array_shift($p->param);
116
-	}
117
-	array_unshift($p->param, $param);
118
-	spip_log('balise EMBED_DOCUMENT obsolete', 'vieilles_defs');
119
-	$p->nom_champ = 'MODELE';
96
+    if (!is_array($p->param)) {
97
+        $p->param = [];
98
+    }
99
+
100
+    // Produire le premier argument {emb}
101
+    $texte = new Texte();
102
+    $texte->texte = 'emb';
103
+    $param = ['', [$texte]];
104
+
105
+    // Transformer les filtres en arguments
106
+    for ($i = 0; $i < count($p->param); $i++) {
107
+        if ($p->param[$i][0]) {
108
+            if (!strstr($p->param[$i][0], '=')) {
109
+                break;
110
+            }# on a rencontre un vrai filtre, c'est fini
111
+            $texte = new Texte();
112
+            $texte->texte = $p->param[$i][0];
113
+            $param[] = [$texte];
114
+        }
115
+        array_shift($p->param);
116
+    }
117
+    array_unshift($p->param, $param);
118
+    spip_log('balise EMBED_DOCUMENT obsolete', 'vieilles_defs');
119
+    $p->nom_champ = 'MODELE';
120 120
 }
121 121
 
122 122
 // Vieux formulaire de recherch
123 123
 
124 124
 function phraser_vieux_recherche($p) {
125
-	if ($p->param[0][0]) {
126
-		$c = new Texte();
127
-		$c->texte = $p->param[0][0];
128
-		$p->param[0][1] = [$c];
129
-		$p->param[0][0] = '';
130
-		$p->fonctions = [];
131
-		spip_log('FORMULAIRE_RECHERCHE avec filtre ' . $c->texte, 'vieilles_defs');
132
-	}
125
+    if ($p->param[0][0]) {
126
+        $c = new Texte();
127
+        $c->texte = $p->param[0][0];
128
+        $p->param[0][1] = [$c];
129
+        $p->param[0][0] = '';
130
+        $p->fonctions = [];
131
+        spip_log('FORMULAIRE_RECHERCHE avec filtre ' . $c->texte, 'vieilles_defs');
132
+    }
133 133
 }
134 134
 
135 135
 // Gerer la notation [(#EXPOSER|on,off)]
136 136
 function phraser_vieux_exposer($p) {
137
-	if ($a = $p->fonctions) {
138
-		preg_match('#([^,]*)(,(.*))?#', $a[0][0], $regs);
139
-		$args = [];
140
-		if ($regs[1]) {
141
-			$a = new Texte();
142
-			$a->texte = $regs[1];
143
-			$args = ['', [$a]];
144
-			if ($regs[3]) {
145
-				$a = new Texte();
146
-				$a->texte = $regs[3];
147
-				$args[] = [$a];
148
-			}
149
-		}
150
-		$p->param[0] = $args;
151
-		$p->fonctions = [];
152
-		$p->nom_champ = 'EXPOSE';
153
-	}
137
+    if ($a = $p->fonctions) {
138
+        preg_match('#([^,]*)(,(.*))?#', $a[0][0], $regs);
139
+        $args = [];
140
+        if ($regs[1]) {
141
+            $a = new Texte();
142
+            $a->texte = $regs[1];
143
+            $args = ['', [$a]];
144
+            if ($regs[3]) {
145
+                $a = new Texte();
146
+                $a->texte = $regs[3];
147
+                $args[] = [$a];
148
+            }
149
+        }
150
+        $p->param[0] = $args;
151
+        $p->fonctions = [];
152
+        $p->nom_champ = 'EXPOSE';
153
+    }
154 154
 }
155 155
 
156 156
 function phraser_vieux_modele($p) {
157
- normaliser_args_inclumodel($p);
157
+    normaliser_args_inclumodel($p);
158 158
 }
159 159
 
160 160
 function phraser_vieux_inclu($p) {
161
- normaliser_args_inclumodel($p);
161
+    normaliser_args_inclumodel($p);
162 162
 }
163 163
 
164 164
 function normaliser_args_inclumodel($p) {
165
-	$params = $p->param;
166
-	if (!$params) {
167
-		return;
168
-	}
169
-	$args = $params[0];
170
-	if ($args[0]) {
171
-		return;
172
-	} // filtre immediat
173
-	array_shift($p->param);
174
-	foreach ($p->param as $l) {
175
-		if (!array_shift($l)) {
176
-			$args = array_merge($args, $l);
177
-			array_shift($p->param);
178
-		} else {
179
-			break;
180
-		} // filtre
181
-	}
182
-	array_unshift($p->param, $args);
165
+    $params = $p->param;
166
+    if (!$params) {
167
+        return;
168
+    }
169
+    $args = $params[0];
170
+    if ($args[0]) {
171
+        return;
172
+    } // filtre immediat
173
+    array_shift($p->param);
174
+    foreach ($p->param as $l) {
175
+        if (!array_shift($l)) {
176
+            $args = array_merge($args, $l);
177
+            array_shift($p->param);
178
+        } else {
179
+            break;
180
+        } // filtre
181
+    }
182
+    array_unshift($p->param, $args);
183 183
 }
184 184
 
185 185
 function normaliser_inclure($champ) {
186
-	normaliser_args_inclumodel($champ);
187
-	$l = $champ->param[0];
188
-	if (is_array($l) and !$l[0]) {
189
-		foreach ($l as $k => $p) {
190
-			if ($p and $p[0]->type == 'texte' and !strpos($p[0]->texte, '=')) {
191
-				$p[0]->texte = trim($p[0]->texte);
192
-			}
193
-		}
194
-		foreach ($l as $k => $p) {
195
-			if (
196
-				!$p or $p[0]->type != 'texte' or
197
-				!preg_match('/^fond\s*=\s*(.*)$/', $p[0]->texte, $r)
198
-			) {
199
-				continue;
200
-			}
201
-
202
-			if ($r[1]) {
203
-				$p[0]->texte = $r[1];
204
-			} else {
205
-				unset($p[0]);
206
-			}
207
-			$champ->texte = $p;
208
-			unset($champ->param[0][$k]);
209
-			if (count($champ->param[0]) == 1) {
210
-				array_shift($champ->param);
211
-			}
212
-
213
-			return;
214
-		}
215
-	}
216
-	spip_log('inclure sans fond ni fichier');
186
+    normaliser_args_inclumodel($champ);
187
+    $l = $champ->param[0];
188
+    if (is_array($l) and !$l[0]) {
189
+        foreach ($l as $k => $p) {
190
+            if ($p and $p[0]->type == 'texte' and !strpos($p[0]->texte, '=')) {
191
+                $p[0]->texte = trim($p[0]->texte);
192
+            }
193
+        }
194
+        foreach ($l as $k => $p) {
195
+            if (
196
+                !$p or $p[0]->type != 'texte' or
197
+                !preg_match('/^fond\s*=\s*(.*)$/', $p[0]->texte, $r)
198
+            ) {
199
+                continue;
200
+            }
201
+
202
+            if ($r[1]) {
203
+                $p[0]->texte = $r[1];
204
+            } else {
205
+                unset($p[0]);
206
+            }
207
+            $champ->texte = $p;
208
+            unset($champ->param[0][$k]);
209
+            if (count($champ->param[0]) == 1) {
210
+                array_shift($champ->param);
211
+            }
212
+
213
+            return;
214
+        }
215
+    }
216
+    spip_log('inclure sans fond ni fichier');
217 217
 }
Please login to merge, or discard this patch.
ecrire/public/sandbox.php 1 patch
Indentation   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  **/
24 24
 
25 25
 if (!defined('_ECRIRE_INC_VERSION')) {
26
-	return;
26
+    return;
27 27
 }
28 28
 
29 29
 /**
@@ -41,9 +41,9 @@  discard block
 block discarded – undo
41 41
  *     Texte
42 42
  */
43 43
 function sandbox_composer_texte($texte, &$p) {
44
-	$code = "'" . str_replace(['\\', "'"], ['\\\\', "\\'"], $texte) . "'";
44
+    $code = "'" . str_replace(['\\', "'"], ['\\\\', "\\'"], $texte) . "'";
45 45
 
46
-	return $code;
46
+    return $code;
47 47
 }
48 48
 
49 49
 
@@ -59,42 +59,42 @@  discard block
 block discarded – undo
59 59
  * @return string
60 60
  */
61 61
 function sandbox_composer_filtre($fonc, $code, $arglist, &$p, $nb_arg_droite = 1000): string {
62
-	if (isset($GLOBALS['spip_matrice'][$fonc])) {
63
-		$code = "filtrer('$fonc',$code$arglist)";
64
-	}
65
-
66
-	// le filtre est defini sous forme de fonction ou de methode
67
-	// par ex. dans inc_texte, inc_filtres ou mes_fonctions
68
-	elseif ($f = chercher_filtre($fonc)) {
69
-		// cas particulier : le filtre |set doit acceder a la $Pile
70
-		// proto: filtre_set(&$Pile, $val, $args...)
71
-		if (strpbrk($f, ':')) { // Class::method
72
-			$refl = new ReflectionMethod($f);
73
-		} else {
74
-			$refl = new ReflectionFunction($f);
75
-		}
76
-		$refs = $refl->getParameters();
77
-		if (isset($refs[0]) and $refs[0]->name == 'Pile') {
78
-			$code = "$f(\$Pile,$code$arglist)";
79
-			$nb_arg_gauche = 2; // la balise à laquelle s'applique le filtre + $Pile
80
-		} else {
81
-			$code = "$f($code$arglist)";
82
-			$nb_arg_gauche = 1; // la balise à laquelle s'applique le filtre
83
-		}
84
-		$nb_args_f = $nb_arg_gauche + $nb_arg_droite;
85
-		$min_f = $refl->getNumberOfRequiredParameters();
86
-		if (($nb_args_f < $min_f)) {
87
-			$msg_args = ['filtre' => texte_script($fonc), 'nb' => $min_f - $nb_args_f];
88
-			erreur_squelette([ 'zbug_erreur_filtre_nbarg_min', $msg_args], $p);
89
-		}
90
-	}
91
-	// le filtre n'existe pas,
92
-	// on le notifie
93
-	else {
94
-		erreur_squelette(['zbug_erreur_filtre', ['filtre' => texte_script($fonc)]], $p);
95
-	}
96
-
97
-	return $code;
62
+    if (isset($GLOBALS['spip_matrice'][$fonc])) {
63
+        $code = "filtrer('$fonc',$code$arglist)";
64
+    }
65
+
66
+    // le filtre est defini sous forme de fonction ou de methode
67
+    // par ex. dans inc_texte, inc_filtres ou mes_fonctions
68
+    elseif ($f = chercher_filtre($fonc)) {
69
+        // cas particulier : le filtre |set doit acceder a la $Pile
70
+        // proto: filtre_set(&$Pile, $val, $args...)
71
+        if (strpbrk($f, ':')) { // Class::method
72
+            $refl = new ReflectionMethod($f);
73
+        } else {
74
+            $refl = new ReflectionFunction($f);
75
+        }
76
+        $refs = $refl->getParameters();
77
+        if (isset($refs[0]) and $refs[0]->name == 'Pile') {
78
+            $code = "$f(\$Pile,$code$arglist)";
79
+            $nb_arg_gauche = 2; // la balise à laquelle s'applique le filtre + $Pile
80
+        } else {
81
+            $code = "$f($code$arglist)";
82
+            $nb_arg_gauche = 1; // la balise à laquelle s'applique le filtre
83
+        }
84
+        $nb_args_f = $nb_arg_gauche + $nb_arg_droite;
85
+        $min_f = $refl->getNumberOfRequiredParameters();
86
+        if (($nb_args_f < $min_f)) {
87
+            $msg_args = ['filtre' => texte_script($fonc), 'nb' => $min_f - $nb_args_f];
88
+            erreur_squelette([ 'zbug_erreur_filtre_nbarg_min', $msg_args], $p);
89
+        }
90
+    }
91
+    // le filtre n'existe pas,
92
+    // on le notifie
93
+    else {
94
+        erreur_squelette(['zbug_erreur_filtre', ['filtre' => texte_script($fonc)]], $p);
95
+    }
96
+
97
+    return $code;
98 98
 }
99 99
 
100 100
 // Calculer un <INCLURE(xx.php)>
@@ -117,15 +117,15 @@  discard block
 block discarded – undo
117 117
  * @return string
118 118
  */
119 119
 function sandbox_composer_inclure_php($fichier, &$p, $_contexte) {
120
-	$compil = texte_script(memoriser_contexte_compil($p));
121
-	// si inexistant, on essaiera a l'execution
122
-	if ($path = find_in_path($fichier)) {
123
-		$path = "\"$path\"";
124
-	} else {
125
-		$path = "find_in_path(\"$fichier\")";
126
-	}
127
-
128
-	return sprintf(CODE_INCLURE_SCRIPT, $path, $fichier, $compil, $_contexte);
120
+    $compil = texte_script(memoriser_contexte_compil($p));
121
+    // si inexistant, on essaiera a l'execution
122
+    if ($path = find_in_path($fichier)) {
123
+        $path = "\"$path\"";
124
+    } else {
125
+        $path = "find_in_path(\"$fichier\")";
126
+    }
127
+
128
+    return sprintf(CODE_INCLURE_SCRIPT, $path, $fichier, $compil, $_contexte);
129 129
 }
130 130
 
131 131
 /**
@@ -137,20 +137,20 @@  discard block
 block discarded – undo
137 137
  * @return string
138 138
  */
139 139
 function sandbox_composer_interdire_scripts($code, &$p) {
140
-	// Securite
141
-	if (
142
-		$p->interdire_scripts
143
-		and $p->etoile != '**'
144
-	) {
145
-		if (!preg_match("/^sinon[(](.*),'([^']*)'[)]$/", $code, $r)) {
146
-			$code = "interdire_scripts($code)";
147
-		} else {
148
-			$code = interdire_scripts($r[2]);
149
-			$code = "sinon(interdire_scripts($r[1]),'$code')";
150
-		}
151
-	}
152
-
153
-	return $code;
140
+    // Securite
141
+    if (
142
+        $p->interdire_scripts
143
+        and $p->etoile != '**'
144
+    ) {
145
+        if (!preg_match("/^sinon[(](.*),'([^']*)'[)]$/", $code, $r)) {
146
+            $code = "interdire_scripts($code)";
147
+        } else {
148
+            $code = interdire_scripts($r[2]);
149
+            $code = "sinon(interdire_scripts($r[1]),'$code')";
150
+        }
151
+    }
152
+
153
+    return $code;
154 154
 }
155 155
 
156 156
 
@@ -169,30 +169,30 @@  discard block
 block discarded – undo
169 169
  * @return mixed|string
170 170
  */
171 171
 function sandbox_filtrer_squelette($skel, $corps, $filtres) {
172
-	$series_filtres = func_get_args();
173
-	array_shift($series_filtres);// skel
174
-	array_shift($series_filtres);// corps
175
-
176
-	// proteger les <INCLUDE> et tous les morceaux de php licites
177
-	if ($skel['process_ins'] == 'php') {
178
-		$corps = preg_replace_callback(',<[?](\s|php|=).*[?]>,UimsS', 'echapper_php_callback', $corps);
179
-	}
180
-
181
-	// recuperer les couples de remplacement
182
-	$replace = echapper_php_callback();
183
-
184
-	foreach ($series_filtres as $filtres) {
185
-		if (count($filtres)) {
186
-			foreach ($filtres as $filtre) {
187
-				if ($filtre and $f = chercher_filtre($filtre)) {
188
-					$corps = $f($corps);
189
-				}
190
-			}
191
-		}
192
-	}
193
-
194
-	// restaurer les echappements
195
-	return str_replace($replace[0], $replace[1], $corps);
172
+    $series_filtres = func_get_args();
173
+    array_shift($series_filtres);// skel
174
+    array_shift($series_filtres);// corps
175
+
176
+    // proteger les <INCLUDE> et tous les morceaux de php licites
177
+    if ($skel['process_ins'] == 'php') {
178
+        $corps = preg_replace_callback(',<[?](\s|php|=).*[?]>,UimsS', 'echapper_php_callback', $corps);
179
+    }
180
+
181
+    // recuperer les couples de remplacement
182
+    $replace = echapper_php_callback();
183
+
184
+    foreach ($series_filtres as $filtres) {
185
+        if (count($filtres)) {
186
+            foreach ($filtres as $filtre) {
187
+                if ($filtre and $f = chercher_filtre($filtre)) {
188
+                    $corps = $f($corps);
189
+                }
190
+            }
191
+        }
192
+    }
193
+
194
+    // restaurer les echappements
195
+    return str_replace($replace[0], $replace[1], $corps);
196 196
 }
197 197
 
198 198
 
@@ -211,21 +211,21 @@  discard block
 block discarded – undo
211 211
  *     - array : Liste( liste des codes PHP, liste des substitutions )
212 212
  **/
213 213
 function echapper_php_callback($r = null) {
214
-	static $src = [];
215
-	static $dst = [];
214
+    static $src = [];
215
+    static $dst = [];
216 216
 
217
-	// si on recoit un tableau, on est en mode echappement
218
-	// on enregistre le code a echapper dans dst, et le code echappe dans src
219
-	if (is_array($r)) {
220
-		$dst[] = $r[0];
217
+    // si on recoit un tableau, on est en mode echappement
218
+    // on enregistre le code a echapper dans dst, et le code echappe dans src
219
+    if (is_array($r)) {
220
+        $dst[] = $r[0];
221 221
 
222
-		return $src[] = '___' . md5($r[0]) . '___';
223
-	}
222
+        return $src[] = '___' . md5($r[0]) . '___';
223
+    }
224 224
 
225
-	// si on recoit pas un tableau, on renvoit les couples de substitution
226
-	// et on RAZ les remplacements
227
-	$r = [$src, $dst];
228
-	$src = $dst = [];
225
+    // si on recoit pas un tableau, on renvoit les couples de substitution
226
+    // et on RAZ les remplacements
227
+    $r = [$src, $dst];
228
+    $src = $dst = [];
229 229
 
230
-	return $r;
230
+    return $r;
231 231
 }
Please login to merge, or discard this patch.
ecrire/public/format_html.php 1 patch
Indentation   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -11,129 +11,129 @@
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 function format_boucle_html($preaff, $avant, $nom, $type, $crit, $corps, $apres, $altern, $postaff, $prof) {
18
-	$preaff = $preaff ? "<BB$nom>$preaff" : '';
19
-	$avant = $avant ? "<B$nom>$avant" : '';
20
-	$apres = $apres ? "$apres</B$nom>" : '';
21
-	$altern = $altern ? "$altern<//B$nom>" : '';
22
-	$postaff = $postaff ? "$postaff</BB$nom>" : '';
23
-	if (!$corps) {
24
-		$corps = ' />';
25
-	} else {
26
-		$corps = ">$corps</BOUCLE$nom>";
27
-	}
28
-
29
-	return "$preaff$avant<BOUCLE$nom($type)$crit$corps$apres$altern$postaff";
18
+    $preaff = $preaff ? "<BB$nom>$preaff" : '';
19
+    $avant = $avant ? "<B$nom>$avant" : '';
20
+    $apres = $apres ? "$apres</B$nom>" : '';
21
+    $altern = $altern ? "$altern<//B$nom>" : '';
22
+    $postaff = $postaff ? "$postaff</BB$nom>" : '';
23
+    if (!$corps) {
24
+        $corps = ' />';
25
+    } else {
26
+        $corps = ">$corps</BOUCLE$nom>";
27
+    }
28
+
29
+    return "$preaff$avant<BOUCLE$nom($type)$crit$corps$apres$altern$postaff";
30 30
 }
31 31
 
32 32
 function format_inclure_html($file, $args, $prof) {
33
-	if (strpos($file, '#') === false) {
34
-		$t = $file ? ('(' . $file . ')') : '';
35
-	} else {
36
-		$t = '{fond=' . $file . '}';
37
-	}
38
-	$args = !$args ? '' : ('{' . join(', ', $args) . '}');
39
-
40
-	return ('<INCLURE' . $t . $args . '>');
33
+    if (strpos($file, '#') === false) {
34
+        $t = $file ? ('(' . $file . ')') : '';
35
+    } else {
36
+        $t = '{fond=' . $file . '}';
37
+    }
38
+    $args = !$args ? '' : ('{' . join(', ', $args) . '}');
39
+
40
+    return ('<INCLURE' . $t . $args . '>');
41 41
 }
42 42
 
43 43
 function format_polyglotte_html($args, $prof) {
44
-	$contenu = [];
45
-	foreach ($args as $l => $t) {
46
-		$contenu[] = ($l ? "[$l]" : '') . $t;
47
-	}
44
+    $contenu = [];
45
+    foreach ($args as $l => $t) {
46
+        $contenu[] = ($l ? "[$l]" : '') . $t;
47
+    }
48 48
 
49
-	return ('<multi>' . join(' ', $contenu) . '</multi>');
49
+    return ('<multi>' . join(' ', $contenu) . '</multi>');
50 50
 }
51 51
 
52 52
 function format_idiome_html($nom, $module, $args, $filtres, $prof) {
53
-	foreach ($args as $k => $v) {
54
-		$args[$k] = "$k=$v";
55
-	}
56
-	$args = (!$args ? '' : ('{' . join(',', $args) . '}'));
53
+    foreach ($args as $k => $v) {
54
+        $args[$k] = "$k=$v";
55
+    }
56
+    $args = (!$args ? '' : ('{' . join(',', $args) . '}'));
57 57
 
58
-	return ('<:' . ($module ? "$module:" : '') . $nom . $args . $filtres . ':>');
58
+    return ('<:' . ($module ? "$module:" : '') . $nom . $args . $filtres . ':>');
59 59
 }
60 60
 
61 61
 function format_champ_html($nom, $boucle, $etoile, $avant, $apres, $args, $filtres, $prof) {
62
-	$nom = '#'
63
-		. ($boucle ? ($boucle . ':') : '')
64
-		. $nom
65
-		. $etoile
66
-		. $args
67
-		. $filtres;
62
+    $nom = '#'
63
+        . ($boucle ? ($boucle . ':') : '')
64
+        . $nom
65
+        . $etoile
66
+        . $args
67
+        . $filtres;
68 68
 
69
-	// Determiner si c'est un champ etendu,
69
+    // Determiner si c'est un champ etendu,
70 70
 
71
-	$s = ($avant or $apres or $filtres
72
-		or (strpos($args, '(#') !== false));
71
+    $s = ($avant or $apres or $filtres
72
+        or (strpos($args, '(#') !== false));
73 73
 
74
-	return ($s ? "[$avant($nom)$apres]" : $nom);
74
+    return ($s ? "[$avant($nom)$apres]" : $nom);
75 75
 }
76 76
 
77 77
 function format_critere_html($critere) {
78
-	foreach ($critere as $k => $crit) {
79
-		$crit_s = '';
80
-		foreach ($crit as $operande) {
81
-			list($type, $valeur) = $operande;
82
-			if ($type == 'champ' and $valeur[0] == '[') {
83
-				$valeur = substr($valeur, 1, -1);
84
-				if (preg_match(',^[(](#[^|]*)[)]$,sS', $valeur)) {
85
-					$valeur = substr($valeur, 1, -1);
86
-				}
87
-			}
88
-			$crit_s .= $valeur;
89
-		}
90
-		$critere[$k] = $crit_s;
91
-	}
92
-
93
-	return (!$critere ? '' : ('{' . join(',', $critere) . '}'));
78
+    foreach ($critere as $k => $crit) {
79
+        $crit_s = '';
80
+        foreach ($crit as $operande) {
81
+            list($type, $valeur) = $operande;
82
+            if ($type == 'champ' and $valeur[0] == '[') {
83
+                $valeur = substr($valeur, 1, -1);
84
+                if (preg_match(',^[(](#[^|]*)[)]$,sS', $valeur)) {
85
+                    $valeur = substr($valeur, 1, -1);
86
+                }
87
+            }
88
+            $crit_s .= $valeur;
89
+        }
90
+        $critere[$k] = $crit_s;
91
+    }
92
+
93
+    return (!$critere ? '' : ('{' . join(',', $critere) . '}'));
94 94
 }
95 95
 
96 96
 function format_liste_html($fonc, $args, $prof) {
97
-	return ((($fonc !== '') ? "|$fonc" : $fonc)
98
-		. (!$args ? '' : ('{' . join(',', $args) . '}')));
97
+    return ((($fonc !== '') ? "|$fonc" : $fonc)
98
+        . (!$args ? '' : ('{' . join(',', $args) . '}')));
99 99
 }
100 100
 
101 101
 // Concatenation sans separateur: verifier qu'on ne cree pas de faux lexemes
102 102
 function format_suite_html($args) {
103
-	for ($i = 0; $i < count($args) - 1; $i++) {
104
-		list($texte, $type) = $args[$i];
105
-		list($texte2, $type2) = $args[$i + 1];
106
-		if (!$texte or !$texte2) {
107
-			continue;
108
-		}
109
-		$c1 = substr($texte, -1);
110
-		if ($type2 !== 'texte') {
111
-			// si un texte se termine par ( et est suivi d'un champ
112
-			// ou assimiles, forcer la notation pleine
113
-			if ($c1 == '(' and substr($texte2, 0, 1) == '#') {
114
-				$args[$i + 1][0] = '[(' . $texte2 . ')]';
115
-			}
116
-		} else {
117
-			if ($type == 'texte') {
118
-				continue;
119
-			}
120
-			// si un champ ou assimiles est suivi d'un texte
121
-			// et si celui-ci commence par un caractere de champ
122
-			// forcer la notation pleine
123
-			if (
124
-				($c1 == '}' and substr(ltrim($texte2), 0, 1) == '|')
125
-				or (preg_match('/[\w\d_*]/', $c1) and preg_match('/^[\w\d_*{|]/', $texte2))
126
-			) {
127
-				$args[$i][0] = '[(' . $texte . ')]';
128
-			}
129
-		}
130
-	}
131
-
132
-	return join('', array_map(function ($arg) {
133
- return reset($arg);
134
-	}, $args));
103
+    for ($i = 0; $i < count($args) - 1; $i++) {
104
+        list($texte, $type) = $args[$i];
105
+        list($texte2, $type2) = $args[$i + 1];
106
+        if (!$texte or !$texte2) {
107
+            continue;
108
+        }
109
+        $c1 = substr($texte, -1);
110
+        if ($type2 !== 'texte') {
111
+            // si un texte se termine par ( et est suivi d'un champ
112
+            // ou assimiles, forcer la notation pleine
113
+            if ($c1 == '(' and substr($texte2, 0, 1) == '#') {
114
+                $args[$i + 1][0] = '[(' . $texte2 . ')]';
115
+            }
116
+        } else {
117
+            if ($type == 'texte') {
118
+                continue;
119
+            }
120
+            // si un champ ou assimiles est suivi d'un texte
121
+            // et si celui-ci commence par un caractere de champ
122
+            // forcer la notation pleine
123
+            if (
124
+                ($c1 == '}' and substr(ltrim($texte2), 0, 1) == '|')
125
+                or (preg_match('/[\w\d_*]/', $c1) and preg_match('/^[\w\d_*{|]/', $texte2))
126
+            ) {
127
+                $args[$i][0] = '[(' . $texte . ')]';
128
+            }
129
+        }
130
+    }
131
+
132
+    return join('', array_map(function ($arg) {
133
+    return reset($arg);
134
+    }, $args));
135 135
 }
136 136
 
137 137
 function format_texte_html($texte) {
138
-	return $texte;
138
+    return $texte;
139 139
 }
Please login to merge, or discard this patch.
ecrire/public/styliser_par_z.php 1 patch
Indentation   +319 added lines, -319 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
  * @package SPIP\Core\Public\Styliser
20 20
  **/
21 21
 if (!defined('_ECRIRE_INC_VERSION')) {
22
-	return;
22
+    return;
23 23
 }
24 24
 
25 25
 /**
@@ -29,193 +29,193 @@  discard block
 block discarded – undo
29 29
  * @return array Données modifiées du pipeline
30 30
  */
31 31
 function public_styliser_par_z_dist($flux) {
32
-	static $prefix_path = null;
33
-	static $prefix_length;
34
-	static $z_blocs;
35
-	static $apl_constant;
36
-	static $page;
37
-	static $disponible = [];
38
-	static $echafauder;
39
-	static $prepend = '';
40
-
41
-	if (!isset($prefix_path)) {
42
-		$z_blocs = z_blocs(test_espace_prive());
43
-		if (test_espace_prive()) {
44
-			$prefix_path = 'prive/squelettes/';
45
-			$prefix_length = strlen($prefix_path);
46
-			$apl_constant = '_ECRIRE_AJAX_PARALLEL_LOAD';
47
-			$page = 'exec';
48
-			$echafauder = charger_fonction('echafauder', 'prive', true);
49
-			define('_ZCORE_EXCLURE_PATH', '');
50
-		} else {
51
-			$prefix_path = '';
52
-			$prefix_length = 0;
53
-			$apl_constant = '_Z_AJAX_PARALLEL_LOAD';
54
-			$page = _SPIP_PAGE;
55
-			$echafauder = charger_fonction('echafauder', 'public', true);
56
-			define('_ZCORE_EXCLURE_PATH', '\bprive|\bsquelettes-dist' . (defined('_DIR_PLUGIN_DIST') ? '|\b' . rtrim(
57
-				_DIR_PLUGIN_DIST,
58
-				'/'
59
-			) : ''));
60
-		}
61
-		$prepend = (defined('_Z_PREPEND_PATH') ? _Z_PREPEND_PATH : '');
62
-	}
63
-	$z_contenu = reset($z_blocs); // contenu par defaut
64
-
65
-	$fond = $flux['args']['fond'];
66
-
67
-	if ($prepend or strncmp($fond, $prefix_path, $prefix_length) == 0) {
68
-		$fond = substr($fond, $prefix_length);
69
-		$squelette = $flux['data'];
70
-		$ext = $flux['args']['ext'];
71
-		// Ajax Parallel loading : ne pas calculer le bloc, mais renvoyer un js qui le loadera en ajax
72
-		if (
73
-			defined('_Z_AJAX_PARALLEL_LOAD_OK')
74
-			and $dir = explode('/', $fond)
75
-			and count($dir) == 2 // pas un sous repertoire
76
-			and $dir = reset($dir)
77
-			and in_array($dir, $z_blocs) // verifier deja qu'on est dans un bloc Z
78
-			and defined($apl_constant)
79
-			and in_array($dir, explode(',', constant($apl_constant))) // et dans un demande en APL
80
-			and $pipe = z_trouver_bloc($prefix_path . $prepend, $dir, 'z_apl', $ext) // et qui contient le squelette APL
81
-		) {
82
-			$flux['data'] = $pipe;
83
-
84
-			return $flux;
85
-		}
86
-
87
-		// surcharger aussi les squelettes venant de squelettes-dist/
88
-		if ($squelette and !z_fond_valide($squelette)) {
89
-			$squelette = '';
90
-			$echafauder = '';
91
-		}
92
-		if ($prepend) {
93
-			$squelette = substr(find_in_path($prefix_path . $prepend . "$fond.$ext"), 0, -strlen(".$ext"));
94
-			if ($squelette) {
95
-				$flux['data'] = $squelette;
96
-			}
97
-		}
98
-
99
-		// gerer les squelettes non trouves
100
-		// -> router vers les /dist.html
101
-		// ou scaffolding ou page automatique les contenus
102
-		if (!$squelette) {
103
-			// si on est sur un ?page=XX non trouve
104
-			if (
105
-				(isset($flux['args']['contexte'][$page])
106
-					and $flux['args']['contexte'][$page] == $fond)
107
-				or (isset($flux['args']['contexte']['type-page'])
108
-					and $flux['args']['contexte']['type-page'] == $fond)
109
-				or ($fond == 'sommaire'
110
-					and (!isset($flux['args']['contexte'][$page]) or !$flux['args']['contexte'][$page]))
111
-			) {
112
-				// si on est sur un ?page=XX non trouve
113
-				// se brancher sur contenu/xx si il existe
114
-				// ou si c'est un objet spip, associe a une table, utiliser le fond homonyme
115
-				if (!isset($disponible[$fond])) {
116
-					$disponible[$fond] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, $fond, $ext, $echafauder);
117
-				}
118
-
119
-				if ($disponible[$fond]) {
120
-					$flux['data'] = substr(find_in_path($prefix_path . "page.$ext"), 0, -strlen(".$ext"));
121
-				}
122
-			}
123
-
124
-			// echafaudage :
125
-			// si c'est un fond de contenu d'un objet en base
126
-			// generer un fond automatique a la volee pour les webmestres
127
-			elseif (strncmp($fond, "$z_contenu/", strlen($z_contenu) + 1) == 0) {
128
-				$type = substr($fond, strlen($z_contenu) + 1);
129
-				if (($type == 'page') and isset($flux['args']['contexte'][$page])) {
130
-					$type = $flux['args']['contexte'][$page];
131
-				}
132
-				if (!isset($disponible[$type])) {
133
-					$disponible[$type] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, $type, $ext, $echafauder);
134
-				}
135
-				if (is_string($disponible[$type])) {
136
-					$flux['data'] = $disponible[$type];
137
-				} elseif (
138
-					$echafauder
139
-					and include_spip('inc/autoriser')
140
-					and isset($GLOBALS['visiteur_session']['statut']) // performance
141
-					and autoriser('echafauder', $type)
142
-					and $is = $disponible[$type]
143
-					and is_array($is)
144
-				) {
145
-					$flux['data'] = $echafauder($type, $is[0], $is[1], $is[2], $ext);
146
-				} else {
147
-					$flux['data'] = ($disponible['404'] = z_contenu_disponible(
148
-						$prefix_path . $prepend,
149
-						$z_contenu,
150
-						'404',
151
-						$ext,
152
-						$echafauder
153
-					));
154
-				}
155
-			}
156
-
157
-			// sinon, si on demande un fond non trouve dans un des autres blocs
158
-			// et si il y a bien un contenu correspondant ou echafaudable
159
-			// se rabbatre sur le dist.html du bloc concerne
160
-			else {
161
-				if (
162
-					$dir = explode('/', $fond)
163
-					and $dir = reset($dir)
164
-					and $dir !== $z_contenu
165
-					and in_array($dir, $z_blocs)
166
-				) {
167
-					$type = substr($fond, strlen("$dir/"));
168
-					if (($type == 'page') and isset($flux['args']['contexte'][$page])) {
169
-						$type = $flux['args']['contexte'][$page];
170
-					}
171
-					if ($type !== 'page' and !isset($disponible[$type])) {
172
-						$disponible[$type] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, $type, $ext, $echafauder);
173
-					}
174
-					if ($type == 'page' or $disponible[$type]) {
175
-						$flux['data'] = z_trouver_bloc($prefix_path . $prepend, $dir, 'dist', $ext);
176
-					}
177
-				}
178
-			}
179
-			$squelette = $flux['data'];
180
-		}
181
-		// layout specifiques par type et compositions :
182
-		// body-article.html
183
-		// body-sommaire.html
184
-		// pour des raisons de perfo, les declinaisons doivent etre dans le
185
-		// meme dossier que body.html
186
-		if ($fond == 'body' and substr($squelette, -strlen($fond)) == $fond) {
187
-			if (
188
-				isset($flux['args']['contexte']['type-page'])
189
-				and (
190
-					(isset($flux['args']['contexte']['composition'])
191
-						and file_exists(($f = $squelette . '-' . $flux['args']['contexte']['type-page'] . '-' . $flux['args']['contexte']['composition']) . ".$ext"))
192
-					or
193
-					file_exists(($f = $squelette . '-' . $flux['args']['contexte']['type-page']) . ".$ext")
194
-				)
195
-			) {
196
-				$flux['data'] = $f;
197
-			}
198
-		} elseif (
199
-			$fond == 'structure'
200
-			and z_sanitize_var_zajax()
201
-			and $f = find_in_path($prefix_path . $prepend . 'ajax' . ".$ext")
202
-		) {
203
-			$flux['data'] = substr($f, 0, -strlen(".$ext"));
204
-		} // chercher le fond correspondant a la composition
205
-		elseif (
206
-			isset($flux['args']['contexte']['composition'])
207
-			and (basename($fond) == 'page' or ($squelette and substr($squelette, -strlen($fond)) == $fond))
208
-			and $dir = substr($fond, $prefix_length)
209
-			and $dir = explode('/', $dir)
210
-			and $dir = reset($dir)
211
-			and in_array($dir, $z_blocs)
212
-			and $f = find_in_path($prefix_path . $prepend . $fond . '-' . $flux['args']['contexte']['composition'] . ".$ext")
213
-		) {
214
-			$flux['data'] = substr($f, 0, -strlen(".$ext"));
215
-		}
216
-	}
217
-
218
-	return $flux;
32
+    static $prefix_path = null;
33
+    static $prefix_length;
34
+    static $z_blocs;
35
+    static $apl_constant;
36
+    static $page;
37
+    static $disponible = [];
38
+    static $echafauder;
39
+    static $prepend = '';
40
+
41
+    if (!isset($prefix_path)) {
42
+        $z_blocs = z_blocs(test_espace_prive());
43
+        if (test_espace_prive()) {
44
+            $prefix_path = 'prive/squelettes/';
45
+            $prefix_length = strlen($prefix_path);
46
+            $apl_constant = '_ECRIRE_AJAX_PARALLEL_LOAD';
47
+            $page = 'exec';
48
+            $echafauder = charger_fonction('echafauder', 'prive', true);
49
+            define('_ZCORE_EXCLURE_PATH', '');
50
+        } else {
51
+            $prefix_path = '';
52
+            $prefix_length = 0;
53
+            $apl_constant = '_Z_AJAX_PARALLEL_LOAD';
54
+            $page = _SPIP_PAGE;
55
+            $echafauder = charger_fonction('echafauder', 'public', true);
56
+            define('_ZCORE_EXCLURE_PATH', '\bprive|\bsquelettes-dist' . (defined('_DIR_PLUGIN_DIST') ? '|\b' . rtrim(
57
+                _DIR_PLUGIN_DIST,
58
+                '/'
59
+            ) : ''));
60
+        }
61
+        $prepend = (defined('_Z_PREPEND_PATH') ? _Z_PREPEND_PATH : '');
62
+    }
63
+    $z_contenu = reset($z_blocs); // contenu par defaut
64
+
65
+    $fond = $flux['args']['fond'];
66
+
67
+    if ($prepend or strncmp($fond, $prefix_path, $prefix_length) == 0) {
68
+        $fond = substr($fond, $prefix_length);
69
+        $squelette = $flux['data'];
70
+        $ext = $flux['args']['ext'];
71
+        // Ajax Parallel loading : ne pas calculer le bloc, mais renvoyer un js qui le loadera en ajax
72
+        if (
73
+            defined('_Z_AJAX_PARALLEL_LOAD_OK')
74
+            and $dir = explode('/', $fond)
75
+            and count($dir) == 2 // pas un sous repertoire
76
+            and $dir = reset($dir)
77
+            and in_array($dir, $z_blocs) // verifier deja qu'on est dans un bloc Z
78
+            and defined($apl_constant)
79
+            and in_array($dir, explode(',', constant($apl_constant))) // et dans un demande en APL
80
+            and $pipe = z_trouver_bloc($prefix_path . $prepend, $dir, 'z_apl', $ext) // et qui contient le squelette APL
81
+        ) {
82
+            $flux['data'] = $pipe;
83
+
84
+            return $flux;
85
+        }
86
+
87
+        // surcharger aussi les squelettes venant de squelettes-dist/
88
+        if ($squelette and !z_fond_valide($squelette)) {
89
+            $squelette = '';
90
+            $echafauder = '';
91
+        }
92
+        if ($prepend) {
93
+            $squelette = substr(find_in_path($prefix_path . $prepend . "$fond.$ext"), 0, -strlen(".$ext"));
94
+            if ($squelette) {
95
+                $flux['data'] = $squelette;
96
+            }
97
+        }
98
+
99
+        // gerer les squelettes non trouves
100
+        // -> router vers les /dist.html
101
+        // ou scaffolding ou page automatique les contenus
102
+        if (!$squelette) {
103
+            // si on est sur un ?page=XX non trouve
104
+            if (
105
+                (isset($flux['args']['contexte'][$page])
106
+                    and $flux['args']['contexte'][$page] == $fond)
107
+                or (isset($flux['args']['contexte']['type-page'])
108
+                    and $flux['args']['contexte']['type-page'] == $fond)
109
+                or ($fond == 'sommaire'
110
+                    and (!isset($flux['args']['contexte'][$page]) or !$flux['args']['contexte'][$page]))
111
+            ) {
112
+                // si on est sur un ?page=XX non trouve
113
+                // se brancher sur contenu/xx si il existe
114
+                // ou si c'est un objet spip, associe a une table, utiliser le fond homonyme
115
+                if (!isset($disponible[$fond])) {
116
+                    $disponible[$fond] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, $fond, $ext, $echafauder);
117
+                }
118
+
119
+                if ($disponible[$fond]) {
120
+                    $flux['data'] = substr(find_in_path($prefix_path . "page.$ext"), 0, -strlen(".$ext"));
121
+                }
122
+            }
123
+
124
+            // echafaudage :
125
+            // si c'est un fond de contenu d'un objet en base
126
+            // generer un fond automatique a la volee pour les webmestres
127
+            elseif (strncmp($fond, "$z_contenu/", strlen($z_contenu) + 1) == 0) {
128
+                $type = substr($fond, strlen($z_contenu) + 1);
129
+                if (($type == 'page') and isset($flux['args']['contexte'][$page])) {
130
+                    $type = $flux['args']['contexte'][$page];
131
+                }
132
+                if (!isset($disponible[$type])) {
133
+                    $disponible[$type] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, $type, $ext, $echafauder);
134
+                }
135
+                if (is_string($disponible[$type])) {
136
+                    $flux['data'] = $disponible[$type];
137
+                } elseif (
138
+                    $echafauder
139
+                    and include_spip('inc/autoriser')
140
+                    and isset($GLOBALS['visiteur_session']['statut']) // performance
141
+                    and autoriser('echafauder', $type)
142
+                    and $is = $disponible[$type]
143
+                    and is_array($is)
144
+                ) {
145
+                    $flux['data'] = $echafauder($type, $is[0], $is[1], $is[2], $ext);
146
+                } else {
147
+                    $flux['data'] = ($disponible['404'] = z_contenu_disponible(
148
+                        $prefix_path . $prepend,
149
+                        $z_contenu,
150
+                        '404',
151
+                        $ext,
152
+                        $echafauder
153
+                    ));
154
+                }
155
+            }
156
+
157
+            // sinon, si on demande un fond non trouve dans un des autres blocs
158
+            // et si il y a bien un contenu correspondant ou echafaudable
159
+            // se rabbatre sur le dist.html du bloc concerne
160
+            else {
161
+                if (
162
+                    $dir = explode('/', $fond)
163
+                    and $dir = reset($dir)
164
+                    and $dir !== $z_contenu
165
+                    and in_array($dir, $z_blocs)
166
+                ) {
167
+                    $type = substr($fond, strlen("$dir/"));
168
+                    if (($type == 'page') and isset($flux['args']['contexte'][$page])) {
169
+                        $type = $flux['args']['contexte'][$page];
170
+                    }
171
+                    if ($type !== 'page' and !isset($disponible[$type])) {
172
+                        $disponible[$type] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, $type, $ext, $echafauder);
173
+                    }
174
+                    if ($type == 'page' or $disponible[$type]) {
175
+                        $flux['data'] = z_trouver_bloc($prefix_path . $prepend, $dir, 'dist', $ext);
176
+                    }
177
+                }
178
+            }
179
+            $squelette = $flux['data'];
180
+        }
181
+        // layout specifiques par type et compositions :
182
+        // body-article.html
183
+        // body-sommaire.html
184
+        // pour des raisons de perfo, les declinaisons doivent etre dans le
185
+        // meme dossier que body.html
186
+        if ($fond == 'body' and substr($squelette, -strlen($fond)) == $fond) {
187
+            if (
188
+                isset($flux['args']['contexte']['type-page'])
189
+                and (
190
+                    (isset($flux['args']['contexte']['composition'])
191
+                        and file_exists(($f = $squelette . '-' . $flux['args']['contexte']['type-page'] . '-' . $flux['args']['contexte']['composition']) . ".$ext"))
192
+                    or
193
+                    file_exists(($f = $squelette . '-' . $flux['args']['contexte']['type-page']) . ".$ext")
194
+                )
195
+            ) {
196
+                $flux['data'] = $f;
197
+            }
198
+        } elseif (
199
+            $fond == 'structure'
200
+            and z_sanitize_var_zajax()
201
+            and $f = find_in_path($prefix_path . $prepend . 'ajax' . ".$ext")
202
+        ) {
203
+            $flux['data'] = substr($f, 0, -strlen(".$ext"));
204
+        } // chercher le fond correspondant a la composition
205
+        elseif (
206
+            isset($flux['args']['contexte']['composition'])
207
+            and (basename($fond) == 'page' or ($squelette and substr($squelette, -strlen($fond)) == $fond))
208
+            and $dir = substr($fond, $prefix_length)
209
+            and $dir = explode('/', $dir)
210
+            and $dir = reset($dir)
211
+            and in_array($dir, $z_blocs)
212
+            and $f = find_in_path($prefix_path . $prepend . $fond . '-' . $flux['args']['contexte']['composition'] . ".$ext")
213
+        ) {
214
+            $flux['data'] = substr($f, 0, -strlen(".$ext"));
215
+        }
216
+    }
217
+
218
+    return $flux;
219 219
 }
220 220
 
221 221
 /**
@@ -225,18 +225,18 @@  discard block
 block discarded – undo
225 225
  * @return array
226 226
  */
227 227
 function z_blocs($espace_prive = false) {
228
-	if ($espace_prive) {
229
-		return (isset($GLOBALS['z_blocs_ecrire']) ? $GLOBALS['z_blocs_ecrire'] : [
230
-			'contenu',
231
-			'navigation',
232
-			'extra',
233
-			'head',
234
-			'hierarchie',
235
-			'top'
236
-		]);
237
-	}
238
-
239
-	return (isset($GLOBALS['z_blocs']) ? $GLOBALS['z_blocs'] : ['contenu']);
228
+    if ($espace_prive) {
229
+        return (isset($GLOBALS['z_blocs_ecrire']) ? $GLOBALS['z_blocs_ecrire'] : [
230
+            'contenu',
231
+            'navigation',
232
+            'extra',
233
+            'head',
234
+            'hierarchie',
235
+            'top'
236
+        ]);
237
+    }
238
+
239
+    return (isset($GLOBALS['z_blocs']) ? $GLOBALS['z_blocs'] : ['contenu']);
240 240
 }
241 241
 
242 242
 /**
@@ -251,11 +251,11 @@  discard block
 block discarded – undo
251 251
  * @return mixed
252 252
  */
253 253
 function z_contenu_disponible($prefix_path, $z_contenu, $type, $ext, $echafauder = true) {
254
-	if ($d = z_trouver_bloc($prefix_path, $z_contenu, $type, $ext)) {
255
-		return $d;
256
-	}
254
+    if ($d = z_trouver_bloc($prefix_path, $z_contenu, $type, $ext)) {
255
+        return $d;
256
+    }
257 257
 
258
-	return $echafauder ? z_echafaudable($type) : false;
258
+    return $echafauder ? z_echafaudable($type) : false;
259 259
 }
260 260
 
261 261
 /**
@@ -269,14 +269,14 @@  discard block
 block discarded – undo
269 269
  *   `true` si on peut l'utiliser, `false` sinon.
270 270
  **/
271 271
 function z_fond_valide($squelette) {
272
-	if (
273
-		!_ZCORE_EXCLURE_PATH
274
-		or !preg_match(',(' . _ZCORE_EXCLURE_PATH . ')/,', $squelette)
275
-	) {
276
-		return true;
277
-	}
278
-
279
-	return false;
272
+    if (
273
+        !_ZCORE_EXCLURE_PATH
274
+        or !preg_match(',(' . _ZCORE_EXCLURE_PATH . ')/,', $squelette)
275
+    ) {
276
+        return true;
277
+    }
278
+
279
+    return false;
280 280
 }
281 281
 
282 282
 /**
@@ -294,14 +294,14 @@  discard block
 block discarded – undo
294 294
  * @return string
295 295
  */
296 296
 function z_trouver_bloc($prefix_path, $bloc, $fond, $ext) {
297
-	if (
298
-		(defined('_ZCORE_BLOC_PREFIX_SKEL') and $f = find_in_path("$prefix_path$bloc/$bloc.$fond.$ext") and z_fond_valide($f))
299
-		or ($f = find_in_path("$prefix_path$bloc/$fond.$ext") and z_fond_valide($f))
300
-	) {
301
-		return substr($f, 0, -strlen(".$ext"));
302
-	}
303
-
304
-	return '';
297
+    if (
298
+        (defined('_ZCORE_BLOC_PREFIX_SKEL') and $f = find_in_path("$prefix_path$bloc/$bloc.$fond.$ext") and z_fond_valide($f))
299
+        or ($f = find_in_path("$prefix_path$bloc/$fond.$ext") and z_fond_valide($f))
300
+    ) {
301
+        return substr($f, 0, -strlen(".$ext"));
302
+    }
303
+
304
+    return '';
305 305
 }
306 306
 
307 307
 /**
@@ -313,52 +313,52 @@  discard block
 block discarded – undo
313 313
  * @return bool
314 314
  */
315 315
 function z_echafaudable($type) {
316
-	static $pages = null;
317
-	static $echafaudable = [];
318
-	if (isset($echafaudable[$type])) {
319
-		return $echafaudable[$type];
320
-	}
321
-	if (preg_match(',[^\w],', $type)) {
322
-		return $echafaudable[$type] = false;
323
-	}
324
-
325
-	if (test_espace_prive()) {
326
-		if (!function_exists('trouver_objet_exec')) {
327
-			include_spip('inc/pipelines_ecrire');
328
-		}
329
-		if ($e = trouver_objet_exec($type)) {
330
-			return $echafaudable[$type] = [$e['table'], $e['table_objet_sql'], $e];
331
-		} else {
332
-			// peut etre c'est un exec=types qui liste tous les objets "type"
333
-			if (
334
-				($t = objet_type($type, false)) !== $type
335
-				and $e = trouver_objet_exec($t)
336
-			) {
337
-				return $echafaudable[$type] = [$e['table'], $e['table_objet_sql'], $t];
338
-			}
339
-		}
340
-	} else {
341
-		if (is_null($pages)) {
342
-			$pages = [];
343
-			$liste = lister_tables_objets_sql();
344
-			foreach ($liste as $t => $d) {
345
-				if ($d['page']) {
346
-					$pages[$d['page']] = [$d['table_objet'], $t];
347
-				}
348
-			}
349
-		}
350
-		if (!isset($pages[$type])) {
351
-			return $echafaudable[$type] = false;
352
-		}
353
-		if (count($pages[$type]) == 2) {
354
-			$trouver_table = charger_fonction('trouver_table', 'base');
355
-			$pages[$type][] = $trouver_table(reset($pages[$type]));
356
-		}
357
-
358
-		return $echafaudable[$type] = $pages[$type];
359
-	}
360
-
361
-	return $echafaudable[$type] = false;
316
+    static $pages = null;
317
+    static $echafaudable = [];
318
+    if (isset($echafaudable[$type])) {
319
+        return $echafaudable[$type];
320
+    }
321
+    if (preg_match(',[^\w],', $type)) {
322
+        return $echafaudable[$type] = false;
323
+    }
324
+
325
+    if (test_espace_prive()) {
326
+        if (!function_exists('trouver_objet_exec')) {
327
+            include_spip('inc/pipelines_ecrire');
328
+        }
329
+        if ($e = trouver_objet_exec($type)) {
330
+            return $echafaudable[$type] = [$e['table'], $e['table_objet_sql'], $e];
331
+        } else {
332
+            // peut etre c'est un exec=types qui liste tous les objets "type"
333
+            if (
334
+                ($t = objet_type($type, false)) !== $type
335
+                and $e = trouver_objet_exec($t)
336
+            ) {
337
+                return $echafaudable[$type] = [$e['table'], $e['table_objet_sql'], $t];
338
+            }
339
+        }
340
+    } else {
341
+        if (is_null($pages)) {
342
+            $pages = [];
343
+            $liste = lister_tables_objets_sql();
344
+            foreach ($liste as $t => $d) {
345
+                if ($d['page']) {
346
+                    $pages[$d['page']] = [$d['table_objet'], $t];
347
+                }
348
+            }
349
+        }
350
+        if (!isset($pages[$type])) {
351
+            return $echafaudable[$type] = false;
352
+        }
353
+        if (count($pages[$type]) == 2) {
354
+            $trouver_table = charger_fonction('trouver_table', 'base');
355
+            $pages[$type][] = $trouver_table(reset($pages[$type]));
356
+        }
357
+
358
+        return $echafaudable[$type] = $pages[$type];
359
+    }
360
+
361
+    return $echafaudable[$type] = false;
362 362
 }
363 363
 
364 364
 
@@ -375,46 +375,46 @@  discard block
 block discarded – undo
375 375
  * @return string
376 376
  */
377 377
 function prive_echafauder_dist($exec, $table, $table_sql, $desc_exec, $ext) {
378
-	$scaffold = '';
379
-
380
-	// page objet ou objet_edit
381
-	if (is_array($desc_exec)) {
382
-		$type = $desc_exec['type'];
383
-		$primary = $desc_exec['id_table_objet'];
384
-
385
-		if ($desc_exec['edition'] === false) {
386
-			$fond = 'objet';
387
-		} else {
388
-			$trouver_table = charger_fonction('trouver_table', 'base');
389
-			$desc = $trouver_table($table_sql);
390
-			if (isset($desc['field']['id_rubrique'])) {
391
-				$fond = 'objet_edit';
392
-			} else {
393
-				$fond = 'objet_edit.sans_rubrique';
394
-			}
395
-		}
396
-		$dir = z_blocs(test_espace_prive());
397
-		$dir = reset($dir);
398
-		$scaffold = "<INCLURE{fond=prive/echafaudage/$dir/" . $fond . ',objet=' . $type . ',id_objet=#' . strtoupper($primary) . ',env}>';
399
-	} // page objets
400
-	elseif ($type = $desc_exec and strpos($type, '/') === false) {
401
-		$dir = z_blocs(test_espace_prive());
402
-		$dir = reset($dir);
403
-		$scaffold = "<INCLURE{fond=prive/echafaudage/$dir/objets,objet=" . $type . ',env} />';
404
-	}
405
-	// morceau d'objet : on fournit le fond de sibstitution dans $desc_exec
406
-	// et objet et tire de $table
407
-	elseif ($fond = $desc_exec) {
408
-		$dir = md5(dirname($fond));
409
-		$scaffold = "<INCLURE{fond=$fond,objet=" . objet_type($table) . ',env} />';
410
-	}
411
-
412
-	$base_dir = sous_repertoire(_DIR_CACHE, 'scaffold', false);
413
-	$base_dir = sous_repertoire($base_dir, $dir, false);
414
-	$f = $base_dir . "$exec";
415
-	ecrire_fichier("$f.$ext", $scaffold);
416
-
417
-	return $f;
378
+    $scaffold = '';
379
+
380
+    // page objet ou objet_edit
381
+    if (is_array($desc_exec)) {
382
+        $type = $desc_exec['type'];
383
+        $primary = $desc_exec['id_table_objet'];
384
+
385
+        if ($desc_exec['edition'] === false) {
386
+            $fond = 'objet';
387
+        } else {
388
+            $trouver_table = charger_fonction('trouver_table', 'base');
389
+            $desc = $trouver_table($table_sql);
390
+            if (isset($desc['field']['id_rubrique'])) {
391
+                $fond = 'objet_edit';
392
+            } else {
393
+                $fond = 'objet_edit.sans_rubrique';
394
+            }
395
+        }
396
+        $dir = z_blocs(test_espace_prive());
397
+        $dir = reset($dir);
398
+        $scaffold = "<INCLURE{fond=prive/echafaudage/$dir/" . $fond . ',objet=' . $type . ',id_objet=#' . strtoupper($primary) . ',env}>';
399
+    } // page objets
400
+    elseif ($type = $desc_exec and strpos($type, '/') === false) {
401
+        $dir = z_blocs(test_espace_prive());
402
+        $dir = reset($dir);
403
+        $scaffold = "<INCLURE{fond=prive/echafaudage/$dir/objets,objet=" . $type . ',env} />';
404
+    }
405
+    // morceau d'objet : on fournit le fond de sibstitution dans $desc_exec
406
+    // et objet et tire de $table
407
+    elseif ($fond = $desc_exec) {
408
+        $dir = md5(dirname($fond));
409
+        $scaffold = "<INCLURE{fond=$fond,objet=" . objet_type($table) . ',env} />';
410
+    }
411
+
412
+    $base_dir = sous_repertoire(_DIR_CACHE, 'scaffold', false);
413
+    $base_dir = sous_repertoire($base_dir, $dir, false);
414
+    $f = $base_dir . "$exec";
415
+    ecrire_fichier("$f.$ext", $scaffold);
416
+
417
+    return $f;
418 418
 }
419 419
 
420 420
 /**
@@ -423,17 +423,17 @@  discard block
 block discarded – undo
423 423
  * @return bool|string
424 424
  */
425 425
 function z_sanitize_var_zajax() {
426
-	$z_ajax = _request('var_zajax');
427
-	if (!$z_ajax) {
428
-		return false;
429
-	}
430
-	if (
431
-		!$z_blocs = z_blocs(test_espace_prive())
432
-		or !in_array($z_ajax, $z_blocs)
433
-	) {
434
-		set_request('var_zajax'); // enlever cette demande incongrue
435
-		$z_ajax = false;
436
-	}
437
-
438
-	return $z_ajax;
426
+    $z_ajax = _request('var_zajax');
427
+    if (!$z_ajax) {
428
+        return false;
429
+    }
430
+    if (
431
+        !$z_blocs = z_blocs(test_espace_prive())
432
+        or !in_array($z_ajax, $z_blocs)
433
+    ) {
434
+        set_request('var_zajax'); // enlever cette demande incongrue
435
+        $z_ajax = false;
436
+    }
437
+
438
+    return $z_ajax;
439 439
 }
Please login to merge, or discard this patch.
ecrire/public/evaluer_page.php 1 patch
Indentation   +58 added lines, -58 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
 /**
@@ -32,67 +32,67 @@  discard block
 block discarded – undo
32 32
 
33 33
 // Cas d'une page contenant du PHP :
34 34
 if (empty($page['process_ins']) or $page['process_ins'] != 'html') {
35
-	include_spip('inc/lang');
35
+    include_spip('inc/lang');
36 36
 
37
-	// restaurer l'etat des notes avant calcul
38
-	if (
39
-		isset($page['notes'])
40
-		and $page['notes']
41
-		and $notes = charger_fonction('notes', 'inc', true)
42
-	) {
43
-		$notes($page['notes'], 'restaurer_etat');
44
-	}
45
-	ob_start();
46
-	if (strpos($page['texte'], '?xml') !== false) {
47
-		$page['texte'] = str_replace('<' . '?xml', "<\1?xml", $page['texte']);
48
-	}
37
+    // restaurer l'etat des notes avant calcul
38
+    if (
39
+        isset($page['notes'])
40
+        and $page['notes']
41
+        and $notes = charger_fonction('notes', 'inc', true)
42
+    ) {
43
+        $notes($page['notes'], 'restaurer_etat');
44
+    }
45
+    ob_start();
46
+    if (strpos($page['texte'], '?xml') !== false) {
47
+        $page['texte'] = str_replace('<' . '?xml', "<\1?xml", $page['texte']);
48
+    }
49 49
 
50
-	try {
51
-		$res = eval('?' . '>' . $page['texte']);
52
-		// error catching 5.2<=PHP<7
53
-		if (
54
-			$res === false
55
-			and function_exists('error_get_last')
56
-			and ($erreur = error_get_last())
57
-		) {
58
-			$code = $page['texte'];
59
-			$GLOBALS['numero_ligne_php'] = 1;
60
-			if (!function_exists('numerote_ligne_php')) {
61
-				function numerote_ligne_php($match) {
62
-					$GLOBALS['numero_ligne_php']++;
63
-					return "\n/*" . str_pad($GLOBALS['numero_ligne_php'], 3, '0', STR_PAD_LEFT) . '*/';
64
-				}
65
-			}
66
-			$code = '/*001*/' . preg_replace_callback(",\n,", 'numerote_ligne_php', $code);
67
-			$code = trim(highlight_string($code, true));
68
-			erreur_squelette('L' . $erreur['line'] . ': ' . $erreur['message'] . '<br />' . $code, [$page['source'],'',$erreur['file'],'',$GLOBALS['spip_lang']]);
69
-			$page['texte'] = '<!-- Erreur -->';
70
-		}
71
-		else {
72
-			$page['texte'] = ob_get_contents();
73
-		}
74
-	}
75
-	catch (Exception $e) {
76
-		$code = $page['texte'];
77
-		$GLOBALS['numero_ligne_php'] = 1;
78
-		if (!function_exists('numerote_ligne_php')) {
79
-			function numerote_ligne_php($match) {
80
-				$GLOBALS['numero_ligne_php']++;
81
-				return "\n/*" . str_pad($GLOBALS['numero_ligne_php'], 3, '0', STR_PAD_LEFT) . '*/';
82
-			}
83
-		}
84
-		$code = '/*001*/' . preg_replace_callback(",\n,", 'numerote_ligne_php', $code);
85
-		$code = trim(highlight_string($code, true));
86
-		erreur_squelette('L' . $e->getLine() . ': ' . $e->getMessage() . '<br />' . $code, [$page['source'],'',$e->getFile(),'',$GLOBALS['spip_lang']]);
87
-		$page['texte'] = '<!-- Erreur -->';
88
-	}
89
-	ob_end_clean();
50
+    try {
51
+        $res = eval('?' . '>' . $page['texte']);
52
+        // error catching 5.2<=PHP<7
53
+        if (
54
+            $res === false
55
+            and function_exists('error_get_last')
56
+            and ($erreur = error_get_last())
57
+        ) {
58
+            $code = $page['texte'];
59
+            $GLOBALS['numero_ligne_php'] = 1;
60
+            if (!function_exists('numerote_ligne_php')) {
61
+                function numerote_ligne_php($match) {
62
+                    $GLOBALS['numero_ligne_php']++;
63
+                    return "\n/*" . str_pad($GLOBALS['numero_ligne_php'], 3, '0', STR_PAD_LEFT) . '*/';
64
+                }
65
+            }
66
+            $code = '/*001*/' . preg_replace_callback(",\n,", 'numerote_ligne_php', $code);
67
+            $code = trim(highlight_string($code, true));
68
+            erreur_squelette('L' . $erreur['line'] . ': ' . $erreur['message'] . '<br />' . $code, [$page['source'],'',$erreur['file'],'',$GLOBALS['spip_lang']]);
69
+            $page['texte'] = '<!-- Erreur -->';
70
+        }
71
+        else {
72
+            $page['texte'] = ob_get_contents();
73
+        }
74
+    }
75
+    catch (Exception $e) {
76
+        $code = $page['texte'];
77
+        $GLOBALS['numero_ligne_php'] = 1;
78
+        if (!function_exists('numerote_ligne_php')) {
79
+            function numerote_ligne_php($match) {
80
+                $GLOBALS['numero_ligne_php']++;
81
+                return "\n/*" . str_pad($GLOBALS['numero_ligne_php'], 3, '0', STR_PAD_LEFT) . '*/';
82
+            }
83
+        }
84
+        $code = '/*001*/' . preg_replace_callback(",\n,", 'numerote_ligne_php', $code);
85
+        $code = trim(highlight_string($code, true));
86
+        erreur_squelette('L' . $e->getLine() . ': ' . $e->getMessage() . '<br />' . $code, [$page['source'],'',$e->getFile(),'',$GLOBALS['spip_lang']]);
87
+        $page['texte'] = '<!-- Erreur -->';
88
+    }
89
+    ob_end_clean();
90 90
 
91
-	$page['process_ins'] = 'html';
91
+    $page['process_ins'] = 'html';
92 92
 
93
-	if (strpos($page['texte'], '?xml') !== false) {
94
-		$page['texte'] = str_replace("<\1?xml", '<' . '?xml', $page['texte']);
95
-	}
93
+    if (strpos($page['texte'], '?xml') !== false) {
94
+        $page['texte'] = str_replace("<\1?xml", '<' . '?xml', $page['texte']);
95
+    }
96 96
 }
97 97
 
98 98
 page_base_href($page['texte']);
Please login to merge, or discard this patch.
ecrire/public/boucles.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
  *     Code PHP compilé de la boucle
33 33
  **/
34 34
 function boucle_DEFAUT_dist($id_boucle, &$boucles) {
35
-	return calculer_boucle($id_boucle, $boucles);
35
+    return calculer_boucle($id_boucle, $boucles);
36 36
 }
37 37
 
38 38
 
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
  *     Code PHP compilé de la boucle
52 52
  **/
53 53
 function boucle_BOUCLE_dist($id_boucle, &$boucles) {
54
-	return calculer_boucle($id_boucle, $boucles);
54
+    return calculer_boucle($id_boucle, $boucles);
55 55
 }
56 56
 
57 57
 
@@ -81,30 +81,30 @@  discard block
 block discarded – undo
81 81
  *     Code PHP compilé de la boucle
82 82
  **/
83 83
 function boucle_HIERARCHIE_dist($id_boucle, &$boucles) {
84
-	$boucle = &$boucles[$id_boucle];
85
-	$id_table = $boucle->id_table . '.id_rubrique';
84
+    $boucle = &$boucles[$id_boucle];
85
+    $id_table = $boucle->id_table . '.id_rubrique';
86 86
 
87
-	// Si la boucle mere est une boucle RUBRIQUES il faut ignorer la feuille
88
-	// sauf en presence du critere {tout} (vu par phraser_html)
89
-	// ou {id_article} qui positionne aussi le {tout}
87
+    // Si la boucle mere est une boucle RUBRIQUES il faut ignorer la feuille
88
+    // sauf en presence du critere {tout} (vu par phraser_html)
89
+    // ou {id_article} qui positionne aussi le {tout}
90 90
 
91
-	$boucle->hierarchie = 'if (!($id_rubrique = intval('
92
-		. calculer_argument_precedent($boucle->id_boucle, 'id_rubrique', $boucles)
93
-		. ")))\n\t\treturn '';\n\t"
94
-		. "include_spip('inc/rubriques');\n\t"
95
-		. '$hierarchie = calcul_hierarchie_in($id_rubrique,'
96
-		. (isset($boucle->modificateur['tout']) ? 'true' : 'false')
97
-		. ");\n\t"
98
-		. 'if (!$hierarchie) return "";' . "\n\t";
91
+    $boucle->hierarchie = 'if (!($id_rubrique = intval('
92
+        . calculer_argument_precedent($boucle->id_boucle, 'id_rubrique', $boucles)
93
+        . ")))\n\t\treturn '';\n\t"
94
+        . "include_spip('inc/rubriques');\n\t"
95
+        . '$hierarchie = calcul_hierarchie_in($id_rubrique,'
96
+        . (isset($boucle->modificateur['tout']) ? 'true' : 'false')
97
+        . ");\n\t"
98
+        . 'if (!$hierarchie) return "";' . "\n\t";
99 99
 
100
-	$boucle->where[] = ["'IN'", "'$id_table'", '"($hierarchie)"'];
100
+    $boucle->where[] = ["'IN'", "'$id_table'", '"($hierarchie)"'];
101 101
 
102
-	$order = "FIELD($id_table, \$hierarchie)";
103
-	if (!isset($boucle->default_order[0]) or $boucle->default_order[0] != ' DESC') {
104
-		$boucle->default_order[] = "\"$order\"";
105
-	} else {
106
-		$boucle->default_order[0] = "\"$order DESC\"";
107
-	}
102
+    $order = "FIELD($id_table, \$hierarchie)";
103
+    if (!isset($boucle->default_order[0]) or $boucle->default_order[0] != ' DESC') {
104
+        $boucle->default_order[] = "\"$order\"";
105
+    } else {
106
+        $boucle->default_order[0] = "\"$order DESC\"";
107
+    }
108 108
 
109
-	return calculer_boucle($id_boucle, $boucles);
109
+    return calculer_boucle($id_boucle, $boucles);
110 110
 }
Please login to merge, or discard this patch.
ecrire/maj/2021.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -19,10 +19,10 @@
 block discarded – undo
19 19
  * @package SPIP\Core\SQL\Upgrade
20 20
  **/
21 21
 if (!defined('_ECRIRE_INC_VERSION')) {
22
-	return;
22
+    return;
23 23
 }
24 24
 
25 25
 $GLOBALS['maj'][2021021800] = [
26
-	['sql_alter', "TABLE spip_auteurs CHANGE imessage imessage VARCHAR(3) DEFAULT '' NOT NULL" ],
27
-	['sql_updateq', 'spip_auteurs', ['imessage' => 'oui'], "imessage != 'non' OR imessage IS NULL" ],
26
+    ['sql_alter', "TABLE spip_auteurs CHANGE imessage imessage VARCHAR(3) DEFAULT '' NOT NULL" ],
27
+    ['sql_updateq', 'spip_auteurs', ['imessage' => 'oui'], "imessage != 'non' OR imessage IS NULL" ],
28 28
 ];
Please login to merge, or discard this patch.