Completed
Push — master ( 5d4b0b...2986c5 )
by cam
01:06
created
ecrire/inc/pipelines.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 		}
66 66
 	}
67 67
 
68
-	$texte = $x . $texte;
68
+	$texte = $x.$texte;
69 69
 
70 70
 	return $texte;
71 71
 }
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	|| ($pos = 0);
180 180
 
181 181
 	if (false === strpos(substr($texte, 0, $pos), '<!-- insert_head -->')) {
182
-		$insert = "\n" . pipeline('insert_head', '<!-- f_insert_head -->') . "\n";
182
+		$insert = "\n".pipeline('insert_head', '<!-- f_insert_head -->')."\n";
183 183
 		$texte = substr_replace($texte, $insert, $pos, 0);
184 184
 	}
185 185
 
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 		}
212 212
 		$texte = substr_replace($texte, $x, $pos, 0);
213 213
 		// pas de preview en fenetre enfant
214
-		$x = "<script type='text/javascript'>const frameEl = window.frameElement;if (frameEl) {frameEl.sandbox='sandbox';window.location.href='" . addslashes($GLOBALS['meta']['adresse_site']) . "';}</script>";
214
+		$x = "<script type='text/javascript'>const frameEl = window.frameElement;if (frameEl) {frameEl.sandbox='sandbox';window.location.href='".addslashes($GLOBALS['meta']['adresse_site'])."';}</script>";
215 215
 		if (!$pos = stripos($texte, '<head') or !$pos = strpos($texte, '>', $pos)) {
216 216
 			$pos = -1;
217 217
 		}
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 
283 283
 	// inserer avant le </body> fermant si on peut, a la fin de la page sinon
284 284
 	if (($p = strpos($texte, '</body>')) !== false) {
285
-		$texte = substr($texte, 0, $p) . $code . substr($texte, $p);
285
+		$texte = substr($texte, 0, $p).$code.substr($texte, $p);
286 286
 	} else {
287 287
 		$texte .= $code;
288 288
 	}
Please login to merge, or discard this patch.
Indentation   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -16,10 +16,10 @@  discard block
 block discarded – undo
16 16
  * @package SPIP\Core\Pipelines
17 17
  **/
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 if (test_espace_prive()) {
22
-	include_spip('inc/pipelines_ecrire');
22
+    include_spip('inc/pipelines_ecrire');
23 23
 }
24 24
 
25 25
 
@@ -45,28 +45,28 @@  discard block
 block discarded – undo
45 45
  * @return string          Contenu qui sera inséré dans le head HTML
46 46
  **/
47 47
 function f_jQuery($texte) {
48
-	$x = '';
49
-	$jquery_plugins = pipeline(
50
-		'jquery_plugins',
51
-		[
52
-			'javascript/jquery.js',
53
-			'javascript/jquery.form.js',
54
-			'javascript/jquery.autosave.js',
55
-			'javascript/jquery.placeholder-label.js',
56
-			'javascript/ajaxCallback.js',
57
-			'javascript/js.cookie.js',
58
-		]
59
-	);
60
-	foreach (array_unique($jquery_plugins) as $script) {
61
-		if ($script = find_in_path(supprimer_timestamp($script))) {
62
-			$script = timestamp($script);
63
-			$x .= "\n<script src=\"$script\" type=\"text/javascript\"></script>\n";
64
-		}
65
-	}
48
+    $x = '';
49
+    $jquery_plugins = pipeline(
50
+        'jquery_plugins',
51
+        [
52
+            'javascript/jquery.js',
53
+            'javascript/jquery.form.js',
54
+            'javascript/jquery.autosave.js',
55
+            'javascript/jquery.placeholder-label.js',
56
+            'javascript/ajaxCallback.js',
57
+            'javascript/js.cookie.js',
58
+        ]
59
+    );
60
+    foreach (array_unique($jquery_plugins) as $script) {
61
+        if ($script = find_in_path(supprimer_timestamp($script))) {
62
+            $script = timestamp($script);
63
+            $x .= "\n<script src=\"$script\" type=\"text/javascript\"></script>\n";
64
+        }
65
+    }
66 66
 
67
-	$texte = $x . $texte;
67
+    $texte = $x . $texte;
68 68
 
69
-	return $texte;
69
+    return $texte;
70 70
 }
71 71
 
72 72
 
@@ -85,28 +85,28 @@  discard block
 block discarded – undo
85 85
  * @return string         Contenu de la page envoyée au navigateur
86 86
  **/
87 87
 function f_surligne($texte) {
88
-	if (!$GLOBALS['html']) {
89
-		return $texte;
90
-	}
91
-	$rech = _request('var_recherche');
92
-	if (
93
-		!$rech
94
-		and (!defined('_SURLIGNE_RECHERCHE_REFERERS')
95
-			or !_SURLIGNE_RECHERCHE_REFERERS
96
-			or !isset($_SERVER['HTTP_REFERER']))
97
-	) {
98
-		return $texte;
99
-	}
100
-	include_spip('inc/surligne');
88
+    if (!$GLOBALS['html']) {
89
+        return $texte;
90
+    }
91
+    $rech = _request('var_recherche');
92
+    if (
93
+        !$rech
94
+        and (!defined('_SURLIGNE_RECHERCHE_REFERERS')
95
+            or !_SURLIGNE_RECHERCHE_REFERERS
96
+            or !isset($_SERVER['HTTP_REFERER']))
97
+    ) {
98
+        return $texte;
99
+    }
100
+    include_spip('inc/surligne');
101 101
 
102
-	if (isset($_SERVER['HTTP_REFERER'])) {
103
-		$_SERVER['HTTP_REFERER'] = preg_replace(',[^\w\,/#&;:-]+,', ' ', $_SERVER['HTTP_REFERER']);
104
-	}
105
-	if ($rech) {
106
-		$rech = preg_replace(',[^\w\,/#&;:-]+,', ' ', $rech);
107
-	}
102
+    if (isset($_SERVER['HTTP_REFERER'])) {
103
+        $_SERVER['HTTP_REFERER'] = preg_replace(',[^\w\,/#&;:-]+,', ' ', $_SERVER['HTTP_REFERER']);
104
+    }
105
+    if ($rech) {
106
+        $rech = preg_replace(',[^\w\,/#&;:-]+,', ' ', $rech);
107
+    }
108 108
 
109
-	return surligner_mots($texte, $rech);
109
+    return surligner_mots($texte, $rech);
110 110
 }
111 111
 
112 112
 /**
@@ -123,33 +123,33 @@  discard block
 block discarded – undo
123 123
  * @return string         Contenu de la page envoyée au navigateur
124 124
  **/
125 125
 function f_tidy($texte) {
126
-	/**
127
-	 * Indentation à faire ?
128
-	 *
129
-	 * - true : actif.
130
-	 * - false par défaut.
131
-	 */
126
+    /**
127
+     * Indentation à faire ?
128
+     *
129
+     * - true : actif.
130
+     * - false par défaut.
131
+     */
132 132
 
133
-	if (
134
-		$GLOBALS['xhtml'] # tidy demande
135
-		and $GLOBALS['html'] # verifie que la page avait l'entete text/html
136
-		and strlen($texte)
137
-		and !headers_sent()
138
-	) {
139
-		# Compatibilite ascendante
140
-		if (!is_string($GLOBALS['xhtml'])) {
141
-			$GLOBALS['xhtml'] = 'tidy';
142
-		}
133
+    if (
134
+        $GLOBALS['xhtml'] # tidy demande
135
+        and $GLOBALS['html'] # verifie que la page avait l'entete text/html
136
+        and strlen($texte)
137
+        and !headers_sent()
138
+    ) {
139
+        # Compatibilite ascendante
140
+        if (!is_string($GLOBALS['xhtml'])) {
141
+            $GLOBALS['xhtml'] = 'tidy';
142
+        }
143 143
 
144
-		if (!$f = charger_fonction($GLOBALS['xhtml'], 'inc', true)) {
145
-			spip_log("tidy absent, l'indenteur SPIP le remplace");
146
-			$f = charger_fonction('sax', 'xml');
147
-		}
144
+        if (!$f = charger_fonction($GLOBALS['xhtml'], 'inc', true)) {
145
+            spip_log("tidy absent, l'indenteur SPIP le remplace");
146
+            $f = charger_fonction('sax', 'xml');
147
+        }
148 148
 
149
-		return $f($texte);
150
-	}
149
+        return $f($texte);
150
+    }
151 151
 
152
-	return $texte;
152
+    return $texte;
153 153
 }
154 154
 
155 155
 
@@ -168,21 +168,21 @@  discard block
 block discarded – undo
168 168
  * @return string         Contenu de la page envoyée au navigateur
169 169
  **/
170 170
 function f_insert_head($texte) {
171
-	if (!$GLOBALS['html']) {
172
-		return $texte;
173
-	}
174
-	include_spip('public/admin'); // pour strripos
171
+    if (!$GLOBALS['html']) {
172
+        return $texte;
173
+    }
174
+    include_spip('public/admin'); // pour strripos
175 175
 
176
-	($pos = stripos($texte, '</head>'))
177
-	|| ($pos = stripos($texte, '<body>'))
178
-	|| ($pos = 0);
176
+    ($pos = stripos($texte, '</head>'))
177
+    || ($pos = stripos($texte, '<body>'))
178
+    || ($pos = 0);
179 179
 
180
-	if (false === strpos(substr($texte, 0, $pos), '<!-- insert_head -->')) {
181
-		$insert = "\n" . pipeline('insert_head', '<!-- f_insert_head -->') . "\n";
182
-		$texte = substr_replace($texte, $insert, $pos, 0);
183
-	}
180
+    if (false === strpos(substr($texte, 0, $pos), '<!-- insert_head -->')) {
181
+        $insert = "\n" . pipeline('insert_head', '<!-- f_insert_head -->') . "\n";
182
+        $texte = substr_replace($texte, $insert, $pos, 0);
183
+    }
184 184
 
185
-	return $texte;
185
+    return $texte;
186 186
 }
187 187
 
188 188
 
@@ -198,34 +198,34 @@  discard block
 block discarded – undo
198 198
  * @return string         Contenu de la page envoyée au navigateur
199 199
  **/
200 200
 function f_admin($texte) {
201
-	if (defined('_VAR_PREVIEW') and _VAR_PREVIEW and $GLOBALS['html']) {
202
-		include_spip('inc/filtres'); // pour http_img_pack
203
-		$x = "<div class='spip-previsu' "
204
-			. http_style_background('preview-32.png', '', 32)
205
-			. '>'
206
-			. _T('previsualisation')
207
-			. '</div>';
208
-		if (!$pos = stripos($texte, '</body>')) {
209
-			$pos = strlen($texte);
210
-		}
211
-		$texte = substr_replace($texte, $x, $pos, 0);
212
-		// pas de preview en fenetre enfant
213
-		$x = "<script type='text/javascript'>const frameEl = window.frameElement;if (frameEl) {frameEl.sandbox='sandbox';window.location.href='" . addslashes($GLOBALS['meta']['adresse_site']) . "';}</script>";
214
-		if (!$pos = stripos($texte, '<head') or !$pos = strpos($texte, '>', $pos)) {
215
-			$pos = -1;
216
-		}
217
-		$texte = substr_replace($texte, $x, $pos + 1, 0);
218
-	}
201
+    if (defined('_VAR_PREVIEW') and _VAR_PREVIEW and $GLOBALS['html']) {
202
+        include_spip('inc/filtres'); // pour http_img_pack
203
+        $x = "<div class='spip-previsu' "
204
+            . http_style_background('preview-32.png', '', 32)
205
+            . '>'
206
+            . _T('previsualisation')
207
+            . '</div>';
208
+        if (!$pos = stripos($texte, '</body>')) {
209
+            $pos = strlen($texte);
210
+        }
211
+        $texte = substr_replace($texte, $x, $pos, 0);
212
+        // pas de preview en fenetre enfant
213
+        $x = "<script type='text/javascript'>const frameEl = window.frameElement;if (frameEl) {frameEl.sandbox='sandbox';window.location.href='" . addslashes($GLOBALS['meta']['adresse_site']) . "';}</script>";
214
+        if (!$pos = stripos($texte, '<head') or !$pos = strpos($texte, '>', $pos)) {
215
+            $pos = -1;
216
+        }
217
+        $texte = substr_replace($texte, $x, $pos + 1, 0);
218
+    }
219 219
 
220
-	if (isset($GLOBALS['affiche_boutons_admin']) and $GLOBALS['affiche_boutons_admin']) {
221
-		include_spip('public/admin');
222
-		$texte = affiche_boutons_admin($texte);
223
-	}
224
-	if (_request('var_mode') == 'noajax') {
225
-		$texte = preg_replace(',(class=[\'"][^\'"]*)ajax([^\'"]*[\'"]),Uims', "\\1\\2", $texte);
226
-	}
220
+    if (isset($GLOBALS['affiche_boutons_admin']) and $GLOBALS['affiche_boutons_admin']) {
221
+        include_spip('public/admin');
222
+        $texte = affiche_boutons_admin($texte);
223
+    }
224
+    if (_request('var_mode') == 'noajax') {
225
+        $texte = preg_replace(',(class=[\'"][^\'"]*)ajax([^\'"]*[\'"]),Uims', "\\1\\2", $texte);
226
+    }
227 227
 
228
-	return $texte;
228
+    return $texte;
229 229
 }
230 230
 
231 231
 /**
@@ -243,11 +243,11 @@  discard block
 block discarded – undo
243 243
  * @return array $flux  Description et contenu de l'inclusion
244 244
  **/
245 245
 function f_recuperer_fond($flux) {
246
-	if (!test_espace_prive()) {
247
-		return $flux;
248
-	}
246
+    if (!test_espace_prive()) {
247
+        return $flux;
248
+    }
249 249
 
250
-	return f_afficher_blocs_ecrire($flux);
250
+    return f_afficher_blocs_ecrire($flux);
251 251
 }
252 252
 
253 253
 /**
@@ -261,30 +261,30 @@  discard block
 block discarded – undo
261 261
  * @return string         Contenu de la page envoyée au navigateur
262 262
  */
263 263
 function f_queue($texte) {
264
-	// eviter une inclusion si rien a faire
265
-	if (
266
-		_request('action') == 'cron'
267
-		or queue_sleep_time_to_next_job() > 0
268
-		or defined('_DEBUG_BLOCK_QUEUE')
269
-	) {
270
-		return $texte;
271
-	}
264
+    // eviter une inclusion si rien a faire
265
+    if (
266
+        _request('action') == 'cron'
267
+        or queue_sleep_time_to_next_job() > 0
268
+        or defined('_DEBUG_BLOCK_QUEUE')
269
+    ) {
270
+        return $texte;
271
+    }
272 272
 
273
-	include_spip('inc/queue');
274
-	$code = queue_affichage_cron();
273
+    include_spip('inc/queue');
274
+    $code = queue_affichage_cron();
275 275
 
276
-	// si rien a afficher
277
-	// ou si on est pas dans une page html, on ne sait rien faire de mieux
278
-	if (!$code or !isset($GLOBALS['html']) or !$GLOBALS['html']) {
279
-		return $texte;
280
-	}
276
+    // si rien a afficher
277
+    // ou si on est pas dans une page html, on ne sait rien faire de mieux
278
+    if (!$code or !isset($GLOBALS['html']) or !$GLOBALS['html']) {
279
+        return $texte;
280
+    }
281 281
 
282
-	// inserer avant le </body> fermant si on peut, a la fin de la page sinon
283
-	if (($p = strpos($texte, '</body>')) !== false) {
284
-		$texte = substr($texte, 0, $p) . $code . substr($texte, $p);
285
-	} else {
286
-		$texte .= $code;
287
-	}
282
+    // inserer avant le </body> fermant si on peut, a la fin de la page sinon
283
+    if (($p = strpos($texte, '</body>')) !== false) {
284
+        $texte = substr($texte, 0, $p) . $code . substr($texte, $p);
285
+    } else {
286
+        $texte .= $code;
287
+    }
288 288
 
289
-	return $texte;
289
+    return $texte;
290 290
 }
Please login to merge, or discard this patch.
ecrire/inc/recherche_to_array.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 		$_id_table = reset($_id_table);
68 68
 	}
69 69
 
70
-	$requete['SELECT'][] = 't.' . $_id_table;
70
+	$requete['SELECT'][] = 't.'.$_id_table;
71 71
 	$a = [];
72 72
 	// Recherche fulltext
73 73
 	foreach ($champs as $champ => $poids) {
@@ -78,13 +78,13 @@  discard block
 block discarded – undo
78 78
 				$champ = "t.$champ";
79 79
 			}
80 80
 			$requete['SELECT'][] = $champ;
81
-			$a[] = $champ . ' ' . $methode . ' ' . $q;
81
+			$a[] = $champ.' '.$methode.' '.$q;
82 82
 		}
83 83
 	}
84 84
 	if ($a) {
85 85
 		$requete['WHERE'][] = join(' OR ', $a);
86 86
 	}
87
-	$requete['FROM'][] = table_objet_sql($table) . ' AS t';
87
+	$requete['FROM'][] = table_objet_sql($table).' AS t';
88 88
 
89 89
 	$results = [];
90 90
 
@@ -252,8 +252,8 @@  discard block
 block discarded – undo
252 252
 					);
253 253
 				} // cas table de liaison generique spip_xxx_yyy
254 254
 				elseif (
255
-					$t = $trouver_table($table_arrivee . '_' . $table_depart, $serveur)
256
-					or $t = $trouver_table($table_depart . '_' . $table_arrivee, $serveur)
255
+					$t = $trouver_table($table_arrivee.'_'.$table_depart, $serveur)
256
+					or $t = $trouver_table($table_depart.'_'.$table_arrivee, $serveur)
257 257
 				) {
258 258
 					$s = sql_select(
259 259
 						"$cle_depart,$cle_arrivee",
@@ -292,12 +292,12 @@  discard block
 block discarded – undo
292 292
 				}
293 293
 				if (isset($joint['champs']) and $joint['champs']) {
294 294
 					foreach ($joint['champs'] as $c => $val) {
295
-						$results[$id]['champs'][$table_liee . '.' . $c] = $val;
295
+						$results[$id]['champs'][$table_liee.'.'.$c] = $val;
296 296
 					}
297 297
 				}
298 298
 				if (isset($joint['matches']) and $joint['matches']) {
299 299
 					foreach ($joint['matches'] as $c => $val) {
300
-						$results[$id]['matches'][$table_liee . '.' . $c] = $val;
300
+						$results[$id]['matches'][$table_liee.'.'.$c] = $val;
301 301
 					}
302 302
 				}
303 303
 			}
Please login to merge, or discard this patch.
Indentation   +267 added lines, -267 removed lines patch added patch discarded remove patch
@@ -11,298 +11,298 @@
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 
18 18
 // methodes sql
19 19
 function inc_recherche_to_array_dist($recherche, $options = []) {
20 20
 
21
-	// options par defaut
22
-	$options = array_merge(
23
-		[
24
-			'score' => true,
25
-			'champs' => false,
26
-			'toutvoir' => false,
27
-			'matches' => false,
28
-			'jointures' => false
29
-		],
30
-		$options
31
-	);
21
+    // options par defaut
22
+    $options = array_merge(
23
+        [
24
+            'score' => true,
25
+            'champs' => false,
26
+            'toutvoir' => false,
27
+            'matches' => false,
28
+            'jointures' => false
29
+        ],
30
+        $options
31
+    );
32 32
 
33
-	include_spip('inc/rechercher');
34
-	include_spip('inc/autoriser');
33
+    include_spip('inc/rechercher');
34
+    include_spip('inc/autoriser');
35 35
 
36
-	$requete = [
37
-		'SELECT' => [],
38
-		'FROM' => [],
39
-		'WHERE' => [],
40
-		'GROUPBY' => [],
41
-		'ORDERBY' => [],
42
-		'LIMIT' => '',
43
-		'HAVING' => []
44
-	];
36
+    $requete = [
37
+        'SELECT' => [],
38
+        'FROM' => [],
39
+        'WHERE' => [],
40
+        'GROUPBY' => [],
41
+        'ORDERBY' => [],
42
+        'LIMIT' => '',
43
+        'HAVING' => []
44
+    ];
45 45
 
46
-	$table = sinon($options['table'], 'article');
47
-	if ($options['champs']) {
48
-		$champs = $options['champs'];
49
-	} else {
50
-		$l = liste_des_champs();
51
-		$champs = $l['article'];
52
-	}
53
-	$serveur = $options['serveur'];
46
+    $table = sinon($options['table'], 'article');
47
+    if ($options['champs']) {
48
+        $champs = $options['champs'];
49
+    } else {
50
+        $l = liste_des_champs();
51
+        $champs = $l['article'];
52
+    }
53
+    $serveur = $options['serveur'];
54 54
 
55
-	[$methode, $q, $preg] = expression_recherche($recherche, $options);
55
+    [$methode, $q, $preg] = expression_recherche($recherche, $options);
56 56
 
57
-	$jointures = $options['jointures']
58
-		? liste_des_jointures()
59
-		: [];
57
+    $jointures = $options['jointures']
58
+        ? liste_des_jointures()
59
+        : [];
60 60
 
61
-	$_id_table = id_table_objet($table);
61
+    $_id_table = id_table_objet($table);
62 62
 
63
-	// c'est un pis-aller : ca a peu de chance de marcher, mais mieux quand meme que en conservant la ','
64
-	// (aka ca marche au moins dans certains cas comme avec spip_formulaires_reponses_champs)
65
-	if (strpos($_id_table, ',') !== false) {
66
-		$_id_table = explode(',', $_id_table);
67
-		$_id_table = reset($_id_table);
68
-	}
63
+    // c'est un pis-aller : ca a peu de chance de marcher, mais mieux quand meme que en conservant la ','
64
+    // (aka ca marche au moins dans certains cas comme avec spip_formulaires_reponses_champs)
65
+    if (strpos($_id_table, ',') !== false) {
66
+        $_id_table = explode(',', $_id_table);
67
+        $_id_table = reset($_id_table);
68
+    }
69 69
 
70
-	$requete['SELECT'][] = 't.' . $_id_table;
71
-	$a = [];
72
-	// Recherche fulltext
73
-	foreach ($champs as $champ => $poids) {
74
-		if (is_array($champ)) {
75
-			spip_log('requetes imbriquees interdites');
76
-		} else {
77
-			if (strpos($champ, '.') === false) {
78
-				$champ = "t.$champ";
79
-			}
80
-			$requete['SELECT'][] = $champ;
81
-			$a[] = $champ . ' ' . $methode . ' ' . $q;
82
-		}
83
-	}
84
-	if ($a) {
85
-		$requete['WHERE'][] = join(' OR ', $a);
86
-	}
87
-	$requete['FROM'][] = table_objet_sql($table) . ' AS t';
70
+    $requete['SELECT'][] = 't.' . $_id_table;
71
+    $a = [];
72
+    // Recherche fulltext
73
+    foreach ($champs as $champ => $poids) {
74
+        if (is_array($champ)) {
75
+            spip_log('requetes imbriquees interdites');
76
+        } else {
77
+            if (strpos($champ, '.') === false) {
78
+                $champ = "t.$champ";
79
+            }
80
+            $requete['SELECT'][] = $champ;
81
+            $a[] = $champ . ' ' . $methode . ' ' . $q;
82
+        }
83
+    }
84
+    if ($a) {
85
+        $requete['WHERE'][] = join(' OR ', $a);
86
+    }
87
+    $requete['FROM'][] = table_objet_sql($table) . ' AS t';
88 88
 
89
-	$results = [];
89
+    $results = [];
90 90
 
91
-	$s = sql_select(
92
-		$requete['SELECT'],
93
-		$requete['FROM'],
94
-		$requete['WHERE'],
95
-		implode(' ', $requete['GROUPBY']),
96
-		$requete['ORDERBY'],
97
-		$requete['LIMIT'],
98
-		$requete['HAVING'],
99
-		$serveur
100
-	);
91
+    $s = sql_select(
92
+        $requete['SELECT'],
93
+        $requete['FROM'],
94
+        $requete['WHERE'],
95
+        implode(' ', $requete['GROUPBY']),
96
+        $requete['ORDERBY'],
97
+        $requete['LIMIT'],
98
+        $requete['HAVING'],
99
+        $serveur
100
+    );
101 101
 
102
-	while (
103
-		$t = sql_fetch($s, $serveur)
104
-		and (!isset($t['score']) or $t['score'] > 0)
105
-	) {
106
-		$id = intval($t[$_id_table]);
102
+    while (
103
+        $t = sql_fetch($s, $serveur)
104
+        and (!isset($t['score']) or $t['score'] > 0)
105
+    ) {
106
+        $id = intval($t[$_id_table]);
107 107
 
108
-		if (
109
-			$options['toutvoir']
110
-			or autoriser('voir', $table, $id)
111
-		) {
112
-			// indiquer les champs concernes
113
-			$champs_vus = [];
114
-			$score = 0;
115
-			$matches = [];
108
+        if (
109
+            $options['toutvoir']
110
+            or autoriser('voir', $table, $id)
111
+        ) {
112
+            // indiquer les champs concernes
113
+            $champs_vus = [];
114
+            $score = 0;
115
+            $matches = [];
116 116
 
117
-			$vu = false;
118
-			foreach ($champs as $champ => $poids) {
119
-				$champ = explode('.', $champ);
120
-				$champ = end($champ);
121
-				// translitteration_rapide uniquement si on est deja en utf-8
122
-				$value = ($GLOBALS['meta']['charset'] == 'utf-8' ? translitteration_rapide($t[$champ]) : translitteration($t[$champ]));
123
-				if (
124
-					$n =
125
-					($options['score'] || $options['matches'])
126
-						? preg_match_all($preg, $value, $regs, PREG_SET_ORDER)
127
-						: preg_match($preg, $value)
128
-				) {
129
-					$vu = true;
117
+            $vu = false;
118
+            foreach ($champs as $champ => $poids) {
119
+                $champ = explode('.', $champ);
120
+                $champ = end($champ);
121
+                // translitteration_rapide uniquement si on est deja en utf-8
122
+                $value = ($GLOBALS['meta']['charset'] == 'utf-8' ? translitteration_rapide($t[$champ]) : translitteration($t[$champ]));
123
+                if (
124
+                    $n =
125
+                    ($options['score'] || $options['matches'])
126
+                        ? preg_match_all($preg, $value, $regs, PREG_SET_ORDER)
127
+                        : preg_match($preg, $value)
128
+                ) {
129
+                    $vu = true;
130 130
 
131
-					if ($options['champs']) {
132
-						$champs_vus[$champ] = $t[$champ];
133
-					}
134
-					if ($options['score']) {
135
-						// compter les points avec un peu de discernement : on pondere par la longueur du match compte en chars
136
-						$score += $poids * strlen(implode('', array_column($regs, 0)));
137
-					}
131
+                    if ($options['champs']) {
132
+                        $champs_vus[$champ] = $t[$champ];
133
+                    }
134
+                    if ($options['score']) {
135
+                        // compter les points avec un peu de discernement : on pondere par la longueur du match compte en chars
136
+                        $score += $poids * strlen(implode('', array_column($regs, 0)));
137
+                    }
138 138
 
139
-					if ($options['matches']) {
140
-						$matches[$champ] = $regs;
141
-					}
139
+                    if ($options['matches']) {
140
+                        $matches[$champ] = $regs;
141
+                    }
142 142
 
143
-					if (
144
-						!$options['champs']
145
-						and !$options['score']
146
-						and !$options['matches']
147
-					) {
148
-						break;
149
-					}
150
-				}
151
-			}
143
+                    if (
144
+                        !$options['champs']
145
+                        and !$options['score']
146
+                        and !$options['matches']
147
+                    ) {
148
+                        break;
149
+                    }
150
+                }
151
+            }
152 152
 
153
-			if ($vu) {
154
-				if (!isset($results)) {
155
-					$results = [];
156
-				}
157
-				$results[$id] = [];
158
-				if ($champs_vus) {
159
-					$results[$id]['champs'] = $champs_vus;
160
-				}
161
-				if ($score) {
162
-					$results[$id]['score'] = $score;
163
-				}
164
-				if ($matches) {
165
-					$results[$id]['matches'] = $matches;
166
-				}
167
-			}
168
-		}
169
-	}
153
+            if ($vu) {
154
+                if (!isset($results)) {
155
+                    $results = [];
156
+                }
157
+                $results[$id] = [];
158
+                if ($champs_vus) {
159
+                    $results[$id]['champs'] = $champs_vus;
160
+                }
161
+                if ($score) {
162
+                    $results[$id]['score'] = $score;
163
+                }
164
+                if ($matches) {
165
+                    $results[$id]['matches'] = $matches;
166
+                }
167
+            }
168
+        }
169
+    }
170 170
 
171 171
 
172
-	// Gerer les donnees associees
173
-	// ici on est un peu naze : pas capables de reconstruire une jointure complexe
174
-	// on ne sait passer que par table de laison en 1 coup
175
-	if (
176
-		isset($jointures[$table])
177
-		and $joints = recherche_en_base(
178
-			$recherche,
179
-			$jointures[$table],
180
-			array_merge($options, ['jointures' => false])
181
-		)
182
-	) {
183
-		include_spip('action/editer_liens');
184
-		$trouver_table = charger_fonction('trouver_table', 'base');
185
-		$cle_depart = id_table_objet($table);
186
-		$table_depart = table_objet($table, $serveur);
187
-		$desc_depart = $trouver_table($table_depart, $serveur);
188
-		$depart_associable = objet_associable($table);
189
-		foreach ($joints as $table_liee => $ids_trouves) {
190
-			// on peut definir une fonction de recherche jointe pour regler les cas particuliers
191
-			if (
192
-				!(
193
-				$rechercher_joints = charger_fonction("rechercher_joints_${table}_${table_liee}", 'inc', true)
194
-				or $rechercher_joints = charger_fonction("rechercher_joints_objet_${table_liee}", 'inc', true)
195
-				or $rechercher_joints = charger_fonction("rechercher_joints_${table}_objet_lie", 'inc', true)
196
-				)
197
-			) {
198
-				$cle_arrivee = id_table_objet($table_liee);
199
-				$table_arrivee = table_objet($table_liee, $serveur);
200
-				$desc_arrivee = $trouver_table($table_arrivee, $serveur);
201
-				// cas simple : $cle_depart dans la table_liee
202
-				if (isset($desc_arrivee['field'][$cle_depart])) {
203
-					$s = sql_select(
204
-						"$cle_depart, $cle_arrivee",
205
-						$desc_arrivee['table_sql'],
206
-						sql_in($cle_arrivee, array_keys($ids_trouves)),
207
-						'',
208
-						'',
209
-						'',
210
-						'',
211
-						$serveur
212
-					);
213
-				} // cas simple : $cle_arrivee dans la table
214
-				elseif (isset($desc_depart['field'][$cle_arrivee])) {
215
-					$s = sql_select(
216
-						"$cle_depart, $cle_arrivee",
217
-						$desc_depart['table_sql'],
218
-						sql_in($cle_arrivee, array_keys($ids_trouves)),
219
-						'',
220
-						'',
221
-						'',
222
-						'',
223
-						$serveur
224
-					);
225
-				}
226
-				// sinon cherchons une table de liaison
227
-				// cas recherche principale article, objet lie document : passer par spip_documents_liens
228
-				elseif ($l = objet_associable($table_liee)) {
229
-					[$primary, $table_liens] = $l;
230
-					$s = sql_select(
231
-						"id_objet as $cle_depart, $primary as $cle_arrivee",
232
-						$table_liens,
233
-						["objet='$table'", sql_in($primary, array_keys($ids_trouves))],
234
-						'',
235
-						'',
236
-						'',
237
-						'',
238
-						$serveur
239
-					);
240
-				} // cas recherche principale auteur, objet lie article: passer par spip_auteurs_liens
241
-				elseif ($l = $depart_associable) {
242
-					[$primary, $table_liens] = $l;
243
-					$s = sql_select(
244
-						"$primary as $cle_depart, id_objet as $cle_arrivee",
245
-						$table_liens,
246
-						["objet='$table_liee'", sql_in('id_objet', array_keys($ids_trouves))],
247
-						'',
248
-						'',
249
-						'',
250
-						'',
251
-						$serveur
252
-					);
253
-				} // cas table de liaison generique spip_xxx_yyy
254
-				elseif (
255
-					$t = $trouver_table($table_arrivee . '_' . $table_depart, $serveur)
256
-					or $t = $trouver_table($table_depart . '_' . $table_arrivee, $serveur)
257
-				) {
258
-					$s = sql_select(
259
-						"$cle_depart,$cle_arrivee",
260
-						$t['table_sql'],
261
-						sql_in($cle_arrivee, array_keys($ids_trouves)),
262
-						'',
263
-						'',
264
-						'',
265
-						'',
266
-						$serveur
267
-					);
268
-				}
269
-			} else {
270
-				[$cle_depart, $cle_arrivee, $s] = $rechercher_joints(
271
-					$table,
272
-					$table_liee,
273
-					array_keys($ids_trouves),
274
-					$serveur
275
-				);
276
-			}
172
+    // Gerer les donnees associees
173
+    // ici on est un peu naze : pas capables de reconstruire une jointure complexe
174
+    // on ne sait passer que par table de laison en 1 coup
175
+    if (
176
+        isset($jointures[$table])
177
+        and $joints = recherche_en_base(
178
+            $recherche,
179
+            $jointures[$table],
180
+            array_merge($options, ['jointures' => false])
181
+        )
182
+    ) {
183
+        include_spip('action/editer_liens');
184
+        $trouver_table = charger_fonction('trouver_table', 'base');
185
+        $cle_depart = id_table_objet($table);
186
+        $table_depart = table_objet($table, $serveur);
187
+        $desc_depart = $trouver_table($table_depart, $serveur);
188
+        $depart_associable = objet_associable($table);
189
+        foreach ($joints as $table_liee => $ids_trouves) {
190
+            // on peut definir une fonction de recherche jointe pour regler les cas particuliers
191
+            if (
192
+                !(
193
+                $rechercher_joints = charger_fonction("rechercher_joints_${table}_${table_liee}", 'inc', true)
194
+                or $rechercher_joints = charger_fonction("rechercher_joints_objet_${table_liee}", 'inc', true)
195
+                or $rechercher_joints = charger_fonction("rechercher_joints_${table}_objet_lie", 'inc', true)
196
+                )
197
+            ) {
198
+                $cle_arrivee = id_table_objet($table_liee);
199
+                $table_arrivee = table_objet($table_liee, $serveur);
200
+                $desc_arrivee = $trouver_table($table_arrivee, $serveur);
201
+                // cas simple : $cle_depart dans la table_liee
202
+                if (isset($desc_arrivee['field'][$cle_depart])) {
203
+                    $s = sql_select(
204
+                        "$cle_depart, $cle_arrivee",
205
+                        $desc_arrivee['table_sql'],
206
+                        sql_in($cle_arrivee, array_keys($ids_trouves)),
207
+                        '',
208
+                        '',
209
+                        '',
210
+                        '',
211
+                        $serveur
212
+                    );
213
+                } // cas simple : $cle_arrivee dans la table
214
+                elseif (isset($desc_depart['field'][$cle_arrivee])) {
215
+                    $s = sql_select(
216
+                        "$cle_depart, $cle_arrivee",
217
+                        $desc_depart['table_sql'],
218
+                        sql_in($cle_arrivee, array_keys($ids_trouves)),
219
+                        '',
220
+                        '',
221
+                        '',
222
+                        '',
223
+                        $serveur
224
+                    );
225
+                }
226
+                // sinon cherchons une table de liaison
227
+                // cas recherche principale article, objet lie document : passer par spip_documents_liens
228
+                elseif ($l = objet_associable($table_liee)) {
229
+                    [$primary, $table_liens] = $l;
230
+                    $s = sql_select(
231
+                        "id_objet as $cle_depart, $primary as $cle_arrivee",
232
+                        $table_liens,
233
+                        ["objet='$table'", sql_in($primary, array_keys($ids_trouves))],
234
+                        '',
235
+                        '',
236
+                        '',
237
+                        '',
238
+                        $serveur
239
+                    );
240
+                } // cas recherche principale auteur, objet lie article: passer par spip_auteurs_liens
241
+                elseif ($l = $depart_associable) {
242
+                    [$primary, $table_liens] = $l;
243
+                    $s = sql_select(
244
+                        "$primary as $cle_depart, id_objet as $cle_arrivee",
245
+                        $table_liens,
246
+                        ["objet='$table_liee'", sql_in('id_objet', array_keys($ids_trouves))],
247
+                        '',
248
+                        '',
249
+                        '',
250
+                        '',
251
+                        $serveur
252
+                    );
253
+                } // cas table de liaison generique spip_xxx_yyy
254
+                elseif (
255
+                    $t = $trouver_table($table_arrivee . '_' . $table_depart, $serveur)
256
+                    or $t = $trouver_table($table_depart . '_' . $table_arrivee, $serveur)
257
+                ) {
258
+                    $s = sql_select(
259
+                        "$cle_depart,$cle_arrivee",
260
+                        $t['table_sql'],
261
+                        sql_in($cle_arrivee, array_keys($ids_trouves)),
262
+                        '',
263
+                        '',
264
+                        '',
265
+                        '',
266
+                        $serveur
267
+                    );
268
+                }
269
+            } else {
270
+                [$cle_depart, $cle_arrivee, $s] = $rechercher_joints(
271
+                    $table,
272
+                    $table_liee,
273
+                    array_keys($ids_trouves),
274
+                    $serveur
275
+                );
276
+            }
277 277
 
278
-			while ($t = is_array($s) ? array_shift($s) : sql_fetch($s)) {
279
-				$id = $t[$cle_depart];
280
-				$joint = $ids_trouves[$t[$cle_arrivee]];
281
-				if (!isset($results)) {
282
-					$results = [];
283
-				}
284
-				if (!isset($results[$id])) {
285
-					$results[$id] = [];
286
-				}
287
-				if (isset($joint['score']) and $joint['score']) {
288
-					if (!isset($results[$id]['score'])) {
289
-						$results[$id]['score'] = 0;
290
-					}
291
-					$results[$id]['score'] += $joint['score'];
292
-				}
293
-				if (isset($joint['champs']) and $joint['champs']) {
294
-					foreach ($joint['champs'] as $c => $val) {
295
-						$results[$id]['champs'][$table_liee . '.' . $c] = $val;
296
-					}
297
-				}
298
-				if (isset($joint['matches']) and $joint['matches']) {
299
-					foreach ($joint['matches'] as $c => $val) {
300
-						$results[$id]['matches'][$table_liee . '.' . $c] = $val;
301
-					}
302
-				}
303
-			}
304
-		}
305
-	}
278
+            while ($t = is_array($s) ? array_shift($s) : sql_fetch($s)) {
279
+                $id = $t[$cle_depart];
280
+                $joint = $ids_trouves[$t[$cle_arrivee]];
281
+                if (!isset($results)) {
282
+                    $results = [];
283
+                }
284
+                if (!isset($results[$id])) {
285
+                    $results[$id] = [];
286
+                }
287
+                if (isset($joint['score']) and $joint['score']) {
288
+                    if (!isset($results[$id]['score'])) {
289
+                        $results[$id]['score'] = 0;
290
+                    }
291
+                    $results[$id]['score'] += $joint['score'];
292
+                }
293
+                if (isset($joint['champs']) and $joint['champs']) {
294
+                    foreach ($joint['champs'] as $c => $val) {
295
+                        $results[$id]['champs'][$table_liee . '.' . $c] = $val;
296
+                    }
297
+                }
298
+                if (isset($joint['matches']) and $joint['matches']) {
299
+                    foreach ($joint['matches'] as $c => $val) {
300
+                        $results[$id]['matches'][$table_liee . '.' . $c] = $val;
301
+                    }
302
+                }
303
+            }
304
+        }
305
+    }
306 306
 
307
-	return $results;
307
+    return $results;
308 308
 }
Please login to merge, or discard this patch.
ecrire/inc/icone_renommer.php 2 patches
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -11,71 +11,71 @@
 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/boutons');
18 18
 include_spip('base/objets');
19 19
 
20 20
 function inc_icone_renommer_dist($fond, $fonction) {
21
-	$size = 24;
22
-	if (
23
-		preg_match('/(?:-([0-9]{1,3}))?([.](gif|png|svg))?$/i', $fond, $match)
24
-		and ((isset($match[0]) and $match[0]) or (isset($match[1]) and $match[1]))
25
-	) {
26
-		if (isset($match[1]) and $match[1]) {
27
-			$size = $match[1];
28
-		}
29
-		$type = substr($fond, 0, -strlen($match[0]));
30
-		if (!isset($match[2]) or !$match[2]) {
31
-			$fond .= '.png';
32
-		}
33
-	} else {
34
-		$type = $fond;
35
-		$fond .= '.png';
36
-	}
21
+    $size = 24;
22
+    if (
23
+        preg_match('/(?:-([0-9]{1,3}))?([.](gif|png|svg))?$/i', $fond, $match)
24
+        and ((isset($match[0]) and $match[0]) or (isset($match[1]) and $match[1]))
25
+    ) {
26
+        if (isset($match[1]) and $match[1]) {
27
+            $size = $match[1];
28
+        }
29
+        $type = substr($fond, 0, -strlen($match[0]));
30
+        if (!isset($match[2]) or !$match[2]) {
31
+            $fond .= '.png';
32
+        }
33
+    } else {
34
+        $type = $fond;
35
+        $fond .= '.png';
36
+    }
37 37
 
38
-	$rtl = false;
39
-	if (preg_match(',[-_]rtl$,i', $type, $match)) {
40
-		$rtl = true;
41
-		$type = substr($type, 0, -strlen($match[0]));
42
-	}
38
+    $rtl = false;
39
+    if (preg_match(',[-_]rtl$,i', $type, $match)) {
40
+        $rtl = true;
41
+        $type = substr($type, 0, -strlen($match[0]));
42
+    }
43 43
 
44
-	// objet_type garde invariant tout ce qui ne commence par par id_, spip_
45
-	// et ne finit pas par un s, sauf si c'est une exception declaree
46
-	$type = objet_type($type, false);
44
+    // objet_type garde invariant tout ce qui ne commence par par id_, spip_
45
+    // et ne finit pas par un s, sauf si c'est une exception declaree
46
+    $type = objet_type($type, false);
47 47
 
48
-	$dir = 'images/';
49
-	$f = "$type-$size.png";
50
-	if ($icone = find_in_theme($dir . $f)) {
51
-		$dir = dirname($icone);
52
-		$fond = $icone;
48
+    $dir = 'images/';
49
+    $f = "$type-$size.png";
50
+    if ($icone = find_in_theme($dir . $f)) {
51
+        $dir = dirname($icone);
52
+        $fond = $icone;
53 53
 
54
-		if (
55
-			$rtl
56
-			and $fr = $dir . '/' . str_replace("$type-", "$type-rtl-", basename($icone))
57
-			and file_exists($fr)
58
-		) {
59
-			$fond = $fr;
60
-		}
54
+        if (
55
+            $rtl
56
+            and $fr = $dir . '/' . str_replace("$type-", "$type-rtl-", basename($icone))
57
+            and file_exists($fr)
58
+        ) {
59
+            $fond = $fr;
60
+        }
61 61
 
62
-		$action = $fonction;
63
-		if ($action == 'supprimer.gif') {
64
-			$action = 'del';
65
-		} elseif ($action == 'creer.gif') {
66
-			$action = 'new';
67
-		} elseif ($action == 'edit.gif') {
68
-			$action = 'edit';
69
-		}
62
+        $action = $fonction;
63
+        if ($action == 'supprimer.gif') {
64
+            $action = 'del';
65
+        } elseif ($action == 'creer.gif') {
66
+            $action = 'new';
67
+        } elseif ($action == 'edit.gif') {
68
+            $action = 'edit';
69
+        }
70 70
 
71
-		$fonction = '';
72
-		if (in_array($action, ['add','del', 'new', 'edit', 'config'])) {
73
-			$fonction = $action;
74
-		}
71
+        $fonction = '';
72
+        if (in_array($action, ['add','del', 'new', 'edit', 'config'])) {
73
+            $fonction = $action;
74
+        }
75 75
 
76
-		// c'est bon !
77
-		return [$fond, $fonction];
78
-	}
76
+        // c'est bon !
77
+        return [$fond, $fonction];
78
+    }
79 79
 
80
-	return [$fond, $fonction];
80
+    return [$fond, $fonction];
81 81
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -47,13 +47,13 @@  discard block
 block discarded – undo
47 47
 
48 48
 	$dir = 'images/';
49 49
 	$f = "$type-$size.png";
50
-	if ($icone = find_in_theme($dir . $f)) {
50
+	if ($icone = find_in_theme($dir.$f)) {
51 51
 		$dir = dirname($icone);
52 52
 		$fond = $icone;
53 53
 
54 54
 		if (
55 55
 			$rtl
56
-			and $fr = $dir . '/' . str_replace("$type-", "$type-rtl-", basename($icone))
56
+			and $fr = $dir.'/'.str_replace("$type-", "$type-rtl-", basename($icone))
57 57
 			and file_exists($fr)
58 58
 		) {
59 59
 			$fond = $fr;
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 		}
70 70
 
71 71
 		$fonction = '';
72
-		if (in_array($action, ['add','del', 'new', 'edit', 'config'])) {
72
+		if (in_array($action, ['add', 'del', 'new', 'edit', 'config'])) {
73 73
 			$fonction = $action;
74 74
 		}
75 75
 
Please login to merge, or discard this patch.
ecrire/inc/prepare_recherche.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -82,12 +82,12 @@  discard block
 block discarded – undo
82 82
 	$where_resultat_recent = sql_date_proche('maj', (0 - ($delai_fraicheur + 100)), ' SECOND');
83 83
 	if (!isset($cache[$serveur][$table][$recherche])) {
84 84
 		$hash_serv = ($serveur ? substr(md5($serveur), 0, 16) : '');
85
-		$hash = substr(md5($recherche . $table), 0, 16);
86
-		$where = "(resultats.recherche='$hash' AND resultats.table_objet=" . sql_quote($table) . " AND resultats.serveur='$hash_serv')";
85
+		$hash = substr(md5($recherche.$table), 0, 16);
86
+		$where = "(resultats.recherche='$hash' AND resultats.table_objet=".sql_quote($table)." AND resultats.serveur='$hash_serv')";
87 87
 		$row = sql_fetsel(
88 88
 			'recherche',
89 89
 			'spip_resultats AS resultats',
90
-			$where . " AND $where_resultat_recent",
90
+			$where." AND $where_resultat_recent",
91 91
 			'',
92 92
 			'',
93 93
 			'0,1'
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 		}
197 197
 
198 198
 		foreach ($listes_ids as $p => $ids) {
199
-			$select .= "+$p*(" .
199
+			$select .= "+$p*(".
200 200
 				sql_in("$table.$primary", $ids, '', $serveur)
201 201
 				. ') ';
202 202
 		}
Please login to merge, or discard this patch.
Indentation   +142 added lines, -142 removed lines patch added patch discarded remove patch
@@ -17,12 +17,12 @@  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
 include_spip('inc/rechercher');
24 24
 if (!defined('_DELAI_CACHE_resultats')) {
25
-	define('_DELAI_CACHE_resultats', 600);
25
+    define('_DELAI_CACHE_resultats', 600);
26 26
 }
27 27
 
28 28
 /**
@@ -49,129 +49,129 @@  discard block
 block discarded – undo
49 49
  * @return array
50 50
  */
51 51
 function inc_prepare_recherche_dist(
52
-	$recherche,
53
-	$table = 'articles',
54
-	$cond = false,
55
-	$serveur = '',
56
-	$modificateurs = [],
57
-	$primary = ''
52
+    $recherche,
53
+    $table = 'articles',
54
+    $cond = false,
55
+    $serveur = '',
56
+    $modificateurs = [],
57
+    $primary = ''
58 58
 ) {
59
-	$where = null;
60
-	$rows = null;
61
-	static $cache = [];
62
-	$delai_fraicheur = min(
63
-		\_DELAI_CACHE_resultats,
64
-		time() - ($GLOBALS['meta']['derniere_modif'] ?? 0)
65
-	);
66
-
67
-	// si recherche n'est pas dans le contexte, on va prendre en globals
68
-	// ca permet de faire des inclure simple.
69
-	if (!isset($recherche) and isset($GLOBALS['recherche'])) {
70
-		$recherche = $GLOBALS['recherche'];
71
-	}
72
-
73
-	// traiter le cas {recherche?}
74
-	if ($cond and !strlen($recherche)) {
75
-		return [
76
-			'0 as points' /* as points */, /* where */
77
-			''
78
-		];
79
-	}
80
-
81
-
82
-	$rechercher = false;
83
-
84
-	$where_resultat_recent = sql_date_proche('maj', (0 - ($delai_fraicheur + 100)), ' SECOND');
85
-	if (!isset($cache[$serveur][$table][$recherche])) {
86
-		$hash_serv = ($serveur ? substr(md5($serveur), 0, 16) : '');
87
-		$hash = substr(md5($recherche . $table), 0, 16);
88
-		$where = "(resultats.recherche='$hash' AND resultats.table_objet=" . sql_quote($table) . " AND resultats.serveur='$hash_serv')";
89
-		$row = sql_fetsel(
90
-			'recherche',
91
-			'spip_resultats AS resultats',
92
-			$where . " AND $where_resultat_recent",
93
-			'',
94
-			'',
95
-			'0,1'
96
-		);
97
-		if (
98
-			!$row
99
-			or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')
100
-		) {
101
-			$rechercher = true;
102
-		}
103
-	}
104
-
105
-	// si on n'a pas encore traite les donnees dans une boucle precedente
106
-	if ($rechercher) {
107
-		//$tables = liste_des_champs();
108
-		$x = objet_type($table);
109
-		$points = recherche_en_base(
110
-			$recherche,
111
-			$x,
112
-			[
113
-				'score' => true,
114
-				'toutvoir' => true,
115
-				'jointures' => true
116
-			],
117
-			$serveur
118
-		);
119
-		// pas de résultat, pas de point
120
-		$points = $points[$x] ?? [];
121
-
122
-		// permettre aux plugins de modifier le resultat
123
-		$points = pipeline('prepare_recherche', [
124
-			'args' => [
125
-				'type' => $x,
126
-				'recherche' => $recherche,
127
-				'serveur' => $serveur,
128
-				'modificateurs' => $modificateurs
129
-			],
130
-			'data' => $points
131
-		]);
132
-
133
-		// supprimer les anciens resultats de cette recherche
134
-		// et les resultats trop vieux avec une marge
135
-		// pas de AS resultats dans un delete (mysql)
136
-		$whered = str_replace(
137
-			['resultats.recherche', 'resultats.table_objet', 'resultats.serveur'],
138
-			['recherche', 'table_objet', 'serveur'],
139
-			$where
140
-		);
141
-
142
-		sql_delete(
143
-			'spip_resultats',
144
-			"NOT($where_resultat_recent) OR ($whered)"
145
-		);
146
-
147
-		// inserer les resultats dans la table de cache des resultats
148
-		if (is_countable($points) ? count($points) : 0) {
149
-			$tab_couples = [];
150
-			foreach ($points as $id => $p) {
151
-				$tab_couples[] = [
152
-					'recherche' => $hash,
153
-					'id' => $id,
154
-					'points' => $p['score'],
155
-					'table_objet' => $table,
156
-					'serveur' => $hash_serv,
157
-				];
158
-			}
159
-			sql_insertq_multi('spip_resultats', $tab_couples, []);
160
-		}
161
-	}
162
-
163
-	if (!isset($cache[$serveur][$table][$recherche])) {
164
-		if (!$serveur) {
165
-			$cache[$serveur][$table][$recherche] = ['resultats.points AS points', $where];
166
-		} else {
167
-			if (sql_countsel('spip_resultats as resultats', $where)) {
168
-				$rows = sql_allfetsel('resultats.id,resultats.points', 'spip_resultats as resultats', $where);
169
-			}
170
-			$cache[$serveur][$table][$recherche] = generer_select_where_explicites($table, $primary, $rows, $serveur);
171
-		}
172
-	}
173
-
174
-	return $cache[$serveur][$table][$recherche];
59
+    $where = null;
60
+    $rows = null;
61
+    static $cache = [];
62
+    $delai_fraicheur = min(
63
+        \_DELAI_CACHE_resultats,
64
+        time() - ($GLOBALS['meta']['derniere_modif'] ?? 0)
65
+    );
66
+
67
+    // si recherche n'est pas dans le contexte, on va prendre en globals
68
+    // ca permet de faire des inclure simple.
69
+    if (!isset($recherche) and isset($GLOBALS['recherche'])) {
70
+        $recherche = $GLOBALS['recherche'];
71
+    }
72
+
73
+    // traiter le cas {recherche?}
74
+    if ($cond and !strlen($recherche)) {
75
+        return [
76
+            '0 as points' /* as points */, /* where */
77
+            ''
78
+        ];
79
+    }
80
+
81
+
82
+    $rechercher = false;
83
+
84
+    $where_resultat_recent = sql_date_proche('maj', (0 - ($delai_fraicheur + 100)), ' SECOND');
85
+    if (!isset($cache[$serveur][$table][$recherche])) {
86
+        $hash_serv = ($serveur ? substr(md5($serveur), 0, 16) : '');
87
+        $hash = substr(md5($recherche . $table), 0, 16);
88
+        $where = "(resultats.recherche='$hash' AND resultats.table_objet=" . sql_quote($table) . " AND resultats.serveur='$hash_serv')";
89
+        $row = sql_fetsel(
90
+            'recherche',
91
+            'spip_resultats AS resultats',
92
+            $where . " AND $where_resultat_recent",
93
+            '',
94
+            '',
95
+            '0,1'
96
+        );
97
+        if (
98
+            !$row
99
+            or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')
100
+        ) {
101
+            $rechercher = true;
102
+        }
103
+    }
104
+
105
+    // si on n'a pas encore traite les donnees dans une boucle precedente
106
+    if ($rechercher) {
107
+        //$tables = liste_des_champs();
108
+        $x = objet_type($table);
109
+        $points = recherche_en_base(
110
+            $recherche,
111
+            $x,
112
+            [
113
+                'score' => true,
114
+                'toutvoir' => true,
115
+                'jointures' => true
116
+            ],
117
+            $serveur
118
+        );
119
+        // pas de résultat, pas de point
120
+        $points = $points[$x] ?? [];
121
+
122
+        // permettre aux plugins de modifier le resultat
123
+        $points = pipeline('prepare_recherche', [
124
+            'args' => [
125
+                'type' => $x,
126
+                'recherche' => $recherche,
127
+                'serveur' => $serveur,
128
+                'modificateurs' => $modificateurs
129
+            ],
130
+            'data' => $points
131
+        ]);
132
+
133
+        // supprimer les anciens resultats de cette recherche
134
+        // et les resultats trop vieux avec une marge
135
+        // pas de AS resultats dans un delete (mysql)
136
+        $whered = str_replace(
137
+            ['resultats.recherche', 'resultats.table_objet', 'resultats.serveur'],
138
+            ['recherche', 'table_objet', 'serveur'],
139
+            $where
140
+        );
141
+
142
+        sql_delete(
143
+            'spip_resultats',
144
+            "NOT($where_resultat_recent) OR ($whered)"
145
+        );
146
+
147
+        // inserer les resultats dans la table de cache des resultats
148
+        if (is_countable($points) ? count($points) : 0) {
149
+            $tab_couples = [];
150
+            foreach ($points as $id => $p) {
151
+                $tab_couples[] = [
152
+                    'recherche' => $hash,
153
+                    'id' => $id,
154
+                    'points' => $p['score'],
155
+                    'table_objet' => $table,
156
+                    'serveur' => $hash_serv,
157
+                ];
158
+            }
159
+            sql_insertq_multi('spip_resultats', $tab_couples, []);
160
+        }
161
+    }
162
+
163
+    if (!isset($cache[$serveur][$table][$recherche])) {
164
+        if (!$serveur) {
165
+            $cache[$serveur][$table][$recherche] = ['resultats.points AS points', $where];
166
+        } else {
167
+            if (sql_countsel('spip_resultats as resultats', $where)) {
168
+                $rows = sql_allfetsel('resultats.id,resultats.points', 'spip_resultats as resultats', $where);
169
+            }
170
+            $cache[$serveur][$table][$recherche] = generer_select_where_explicites($table, $primary, $rows, $serveur);
171
+        }
172
+    }
173
+
174
+    return $cache[$serveur][$table][$recherche];
175 175
 }
176 176
 
177 177
 
@@ -187,22 +187,22 @@  discard block
 block discarded – undo
187 187
  * @return array
188 188
  */
189 189
 function generer_select_where_explicites($table, $primary, $rows, $serveur) {
190
-	# calculer le {id_article IN()} et le {... as points}
191
-	if (!count($rows)) {
192
-		return ["''", '0=1'];
193
-	} else {
194
-		$listes_ids = [];
195
-		$select = '0';
196
-		foreach ($rows as $r) {
197
-			$listes_ids[$r['points']][] = $r['id'];
198
-		}
199
-
200
-		foreach ($listes_ids as $p => $ids) {
201
-			$select .= "+$p*(" .
202
-				sql_in("$table.$primary", $ids, '', $serveur)
203
-				. ') ';
204
-		}
205
-
206
-		return ["$select AS points ", sql_in("$table.$primary", array_map('reset', $rows), '', $serveur)];
207
-	}
190
+    # calculer le {id_article IN()} et le {... as points}
191
+    if (!count($rows)) {
192
+        return ["''", '0=1'];
193
+    } else {
194
+        $listes_ids = [];
195
+        $select = '0';
196
+        foreach ($rows as $r) {
197
+            $listes_ids[$r['points']][] = $r['id'];
198
+        }
199
+
200
+        foreach ($listes_ids as $p => $ids) {
201
+            $select .= "+$p*(" .
202
+                sql_in("$table.$primary", $ids, '', $serveur)
203
+                . ') ';
204
+        }
205
+
206
+        return ["$select AS points ", sql_in("$table.$primary", array_map('reset', $rows), '', $serveur)];
207
+    }
208 208
 }
Please login to merge, or discard this patch.
ecrire/inc/exporter_csv.php 3 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -173,8 +173,7 @@
 block discarded – undo
173 173
 	// sinon on ecrit directement sur stdout
174 174
 	if ($options['envoyer'] and $options['envoyer'] !== 'attachment') {
175 175
 		$fichier = 'php://output';
176
-	}
177
-	else {
176
+	} else {
178 177
 	$fichier = sous_repertoire(_DIR_CACHE, 'export') . $filename;
179 178
 	}
180 179
 
Please login to merge, or discard this patch.
Indentation   +114 added lines, -114 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
 include_spip('inc/charsets');
@@ -32,13 +32,13 @@  discard block
 block discarded – undo
32 32
  * @return string
33 33
  */
34 34
 function exporter_csv_champ($champ) {
35
-	#$champ = str_replace("\r", "\n", $champ);
36
-	#$champ = preg_replace(",[\n]+,ms", "\n", $champ);
37
-	#$champ = str_replace("\n", ", ", $champ);
38
-	$champ = preg_replace(',[\s]+,ms', ' ', $champ);
39
-	$champ = str_replace('"', '""', $champ);
35
+    #$champ = str_replace("\r", "\n", $champ);
36
+    #$champ = preg_replace(",[\n]+,ms", "\n", $champ);
37
+    #$champ = str_replace("\n", ", ", $champ);
38
+    $champ = preg_replace(',[\s]+,ms', ' ', $champ);
39
+    $champ = str_replace('"', '""', $champ);
40 40
 
41
-	return '"' . $champ . '"';
41
+    return '"' . $champ . '"';
42 42
 }
43 43
 
44 44
 /**
@@ -55,15 +55,15 @@  discard block
 block discarded – undo
55 55
  * @return string
56 56
  */
57 57
 function exporter_csv_ligne_numerotee($nb, $ligne, $delim = ',', $importer_charset = null, ?callable $callback = null) {
58
-	if ($callback) {
59
-		$ligne = $callback($nb, $ligne, $delim, $importer_charset);
60
-	}
61
-	$output = join($delim, array_map('exporter_csv_champ', $ligne)) . "\r\n";
62
-	if ($importer_charset) {
63
-		$output = str_replace('’', '\'', $output);
64
-		$output = unicode2charset(html2unicode(charset2unicode($output)), $importer_charset);
65
-	}
66
-	return $output;
58
+    if ($callback) {
59
+        $ligne = $callback($nb, $ligne, $delim, $importer_charset);
60
+    }
61
+    $output = join($delim, array_map('exporter_csv_champ', $ligne)) . "\r\n";
62
+    if ($importer_charset) {
63
+        $output = str_replace('’', '\'', $output);
64
+        $output = unicode2charset(html2unicode(charset2unicode($output)), $importer_charset);
65
+    }
66
+    return $output;
67 67
 }
68 68
 
69 69
 /**
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
  * @return string
76 76
  */
77 77
 function exporter_csv_ligne($ligne, $delim = ',', $importer_charset = null) {
78
-	return exporter_csv_ligne_numerotee(null, $ligne, $delim, $importer_charset);
78
+    return exporter_csv_ligne_numerotee(null, $ligne, $delim, $importer_charset);
79 79
 }
80 80
 
81 81
 /**
@@ -101,101 +101,101 @@  discard block
 block discarded – undo
101 101
  */
102 102
 function inc_exporter_csv_dist($titre, $resource, $options = []) {
103 103
 
104
-	// support ancienne syntaxe
105
-	// inc_exporter_csv_dist($titre, $resource, $delim = ', ', $entetes = null, $envoyer = true)
106
-	if (is_string($options)) {
107
-		$args = func_get_args();
108
-		$options = [];
109
-		foreach ([2 => 'delim', 3 => 'entetes', 4 => 'envoyer'] as $k => $option) {
110
-			if (!empty($args[$k])) {
111
-				$options[$option] = $args[$k];
112
-			}
113
-		}
114
-	}
115
-
116
-	$default_options = [
117
-		'delim' => ', ',
118
-		'entetes' => null,
119
-		'envoyer' => true,
120
-		'charset' => null,
121
-		'callback' => null,
122
-	];
123
-	$options = array_merge($default_options, $options);
124
-
125
-	$filename = preg_replace(',[^-_\w]+,', '_', translitteration(textebrut(typo($titre))));
126
-
127
-	if ($options['delim'] == 'TAB') {
128
-		$options['delim'] = "\t";
129
-	}
130
-	if (!in_array($options['delim'], [',', ';', "\t"])) {
131
-		$options['delim'] = ',';
132
-	}
133
-
134
-	$charset = $GLOBALS['meta']['charset'];
135
-	$importer_charset = null;
136
-	if ($options['delim'] == ',') {
137
-		$extension = 'csv';
138
-	} else {
139
-		$extension = 'xls';
140
-		# Excel n'accepte pas l'utf-8 ni les entites html... on transcode tout ce qu'on peut
141
-		$charset = 'iso-8859-1';
142
-	}
143
-	// mais si une option charset est explicite, elle a la priorite
144
-	if (!empty($options['charset'])) {
145
-		$charset = $options['charset'];
146
-	}
147
-
148
-	$importer_charset = (($charset === $GLOBALS['meta']['charset']) ? null : $charset);
149
-
150
-	$filename = "$filename.$extension";
151
-
152
-	$output = '';
153
-	$nb = 0;
154
-	if (!empty($options['entetes']) and is_array($options['entetes'])) {
155
-		$output = exporter_csv_ligne_numerotee($nb, $options['entetes'], $options['delim'], $importer_charset, $options['callback']);
156
-	}
157
-	// les donnees commencent toujours a la ligne 1, qu'il y ait ou non des entetes
158
-	$nb++;
159
-
160
-	if ($options['envoyer']) {
161
-		$disposition = ($options['envoyer'] === 'attachment' ? 'attachment' : 'inline');
162
-		header("Content-Type: text/comma-separated-values; charset=$charset");
163
-		header("Content-Disposition: $disposition; filename=$filename");
164
-
165
-		// Vider tous les tampons
166
-		$level = @ob_get_level();
167
-		while ($level--) {
168
-			@ob_end_flush();
169
-		}
170
-	}
171
-
172
-	// si envoyer=='attachment' on passe par un fichier temporaire
173
-	// sinon on ecrit directement sur stdout
174
-	if ($options['envoyer'] and $options['envoyer'] !== 'attachment') {
175
-		$fichier = 'php://output';
176
-	}
177
-	else {
178
-	$fichier = sous_repertoire(_DIR_CACHE, 'export') . $filename;
179
-	}
180
-
181
-	$fp = fopen($fichier, 'w');
182
-	$length = fwrite($fp, $output);
183
-
184
-	while ($row = is_array($resource) ? array_shift($resource) : sql_fetch($resource)) {
185
-		$output = exporter_csv_ligne_numerotee($nb, $row, $options['delim'], $importer_charset, $options['callback']);
186
-		$length += fwrite($fp, $output);
187
-		$nb++;
188
-	}
189
-	fclose($fp);
190
-
191
-	if ($options['envoyer']) {
192
-		if ($options['envoyer'] === 'attachment') {
193
-			header("Content-Length: $length");
194
-			readfile($fichier);
195
-		}
196
-		// si on a envoye inline, c'est deja tout bon
197
-		exit;
198
-	}
199
-
200
-	return $fichier;
104
+    // support ancienne syntaxe
105
+    // inc_exporter_csv_dist($titre, $resource, $delim = ', ', $entetes = null, $envoyer = true)
106
+    if (is_string($options)) {
107
+        $args = func_get_args();
108
+        $options = [];
109
+        foreach ([2 => 'delim', 3 => 'entetes', 4 => 'envoyer'] as $k => $option) {
110
+            if (!empty($args[$k])) {
111
+                $options[$option] = $args[$k];
112
+            }
113
+        }
114
+    }
115
+
116
+    $default_options = [
117
+        'delim' => ', ',
118
+        'entetes' => null,
119
+        'envoyer' => true,
120
+        'charset' => null,
121
+        'callback' => null,
122
+    ];
123
+    $options = array_merge($default_options, $options);
124
+
125
+    $filename = preg_replace(',[^-_\w]+,', '_', translitteration(textebrut(typo($titre))));
126
+
127
+    if ($options['delim'] == 'TAB') {
128
+        $options['delim'] = "\t";
129
+    }
130
+    if (!in_array($options['delim'], [',', ';', "\t"])) {
131
+        $options['delim'] = ',';
132
+    }
133
+
134
+    $charset = $GLOBALS['meta']['charset'];
135
+    $importer_charset = null;
136
+    if ($options['delim'] == ',') {
137
+        $extension = 'csv';
138
+    } else {
139
+        $extension = 'xls';
140
+        # Excel n'accepte pas l'utf-8 ni les entites html... on transcode tout ce qu'on peut
141
+        $charset = 'iso-8859-1';
142
+    }
143
+    // mais si une option charset est explicite, elle a la priorite
144
+    if (!empty($options['charset'])) {
145
+        $charset = $options['charset'];
146
+    }
147
+
148
+    $importer_charset = (($charset === $GLOBALS['meta']['charset']) ? null : $charset);
149
+
150
+    $filename = "$filename.$extension";
151
+
152
+    $output = '';
153
+    $nb = 0;
154
+    if (!empty($options['entetes']) and is_array($options['entetes'])) {
155
+        $output = exporter_csv_ligne_numerotee($nb, $options['entetes'], $options['delim'], $importer_charset, $options['callback']);
156
+    }
157
+    // les donnees commencent toujours a la ligne 1, qu'il y ait ou non des entetes
158
+    $nb++;
159
+
160
+    if ($options['envoyer']) {
161
+        $disposition = ($options['envoyer'] === 'attachment' ? 'attachment' : 'inline');
162
+        header("Content-Type: text/comma-separated-values; charset=$charset");
163
+        header("Content-Disposition: $disposition; filename=$filename");
164
+
165
+        // Vider tous les tampons
166
+        $level = @ob_get_level();
167
+        while ($level--) {
168
+            @ob_end_flush();
169
+        }
170
+    }
171
+
172
+    // si envoyer=='attachment' on passe par un fichier temporaire
173
+    // sinon on ecrit directement sur stdout
174
+    if ($options['envoyer'] and $options['envoyer'] !== 'attachment') {
175
+        $fichier = 'php://output';
176
+    }
177
+    else {
178
+    $fichier = sous_repertoire(_DIR_CACHE, 'export') . $filename;
179
+    }
180
+
181
+    $fp = fopen($fichier, 'w');
182
+    $length = fwrite($fp, $output);
183
+
184
+    while ($row = is_array($resource) ? array_shift($resource) : sql_fetch($resource)) {
185
+        $output = exporter_csv_ligne_numerotee($nb, $row, $options['delim'], $importer_charset, $options['callback']);
186
+        $length += fwrite($fp, $output);
187
+        $nb++;
188
+    }
189
+    fclose($fp);
190
+
191
+    if ($options['envoyer']) {
192
+        if ($options['envoyer'] === 'attachment') {
193
+            header("Content-Length: $length");
194
+            readfile($fichier);
195
+        }
196
+        // si on a envoye inline, c'est deja tout bon
197
+        exit;
198
+    }
199
+
200
+    return $fichier;
201 201
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	$champ = preg_replace(',[\s]+,ms', ' ', $champ);
39 39
 	$champ = str_replace('"', '""', $champ);
40 40
 
41
-	return '"' . $champ . '"';
41
+	return '"'.$champ.'"';
42 42
 }
43 43
 
44 44
 /**
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	if ($callback) {
59 59
 		$ligne = $callback($nb, $ligne, $delim, $importer_charset);
60 60
 	}
61
-	$output = join($delim, array_map('exporter_csv_champ', $ligne)) . "\r\n";
61
+	$output = join($delim, array_map('exporter_csv_champ', $ligne))."\r\n";
62 62
 	if ($importer_charset) {
63 63
 		$output = str_replace('’', '\'', $output);
64 64
 		$output = unicode2charset(html2unicode(charset2unicode($output)), $importer_charset);
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 		$fichier = 'php://output';
176 176
 	}
177 177
 	else {
178
-	$fichier = sous_repertoire(_DIR_CACHE, 'export') . $filename;
178
+	$fichier = sous_repertoire(_DIR_CACHE, 'export').$filename;
179 179
 	}
180 180
 
181 181
 	$fp = fopen($fichier, 'w');
Please login to merge, or discard this patch.
ecrire/inc/svg.php 3 patches
Braces   +13 added lines, -26 removed lines patch added patch discarded remove patch
@@ -63,8 +63,7 @@  discard block
 block discarded – undo
63 63
 	}
64 64
 	if (is_null($maxlen)) {
65 65
 		$image = file_get_contents($fichier);
66
-	}
67
-	else {
66
+	} else {
68 67
 		$image = file_get_contents($fichier, false, null, 0, $maxlen);
69 68
 	}
70 69
 	// est-ce bien une image svg ?
@@ -190,8 +189,7 @@  discard block
 block discarded – undo
190 189
 
191 190
 	if ($start === false or $start === 'end') {
192 191
 		$svg = str_replace('</svg>', $shapes . '</svg>', $svg);
193
-	}
194
-	else {
192
+	} else {
195 193
 		$p = stripos($svg, '<svg');
196 194
 		$p = strpos($svg, '>', $p);
197 195
 		$svg = substr_replace($svg, $shapes, $p + 1, 0);
@@ -253,8 +251,7 @@  discard block
 block discarded – undo
253 251
 	if (strpos($couleur, 'rgb(') === 0) {
254 252
 		$c = explode(',', substr($couleur, 4));
255 253
 		$couleur = _couleur_dec_to_hex(intval($c[0]), intval($c[1]), intval($c[2]));
256
-	}
257
-	else {
254
+	} else {
258 255
 		$couleur = couleur_html_to_hex($couleur);
259 256
 	}
260 257
 	$couleur = '#' . ltrim($couleur, '#');
@@ -305,17 +302,14 @@  discard block
 block discarded – undo
305 302
 		and $w = svg_dimension_to_pixels($attributs['width'])
306 303
 	) {
307 304
 		$width = $w;
308
-	}
309
-	else {
305
+	} else {
310 306
 		// si on recupere la taille de la viewbox mais si la viewbox est petite on met un multiplicateur pour la taille finale
311 307
 		$width = $viewBox[2];
312 308
 		if ($width < 1) {
313 309
 			$coeff = max($coeff, 1000);
314
-		}
315
-		elseif ($width < 10) {
310
+		} elseif ($width < 10) {
316 311
 			$coeff = max($coeff, 100);
317
-		}
318
-		elseif ($width < 100) {
312
+		} elseif ($width < 100) {
319 313
 			$coeff = max($coeff, 10);
320 314
 		}
321 315
 	}
@@ -324,16 +318,13 @@  discard block
 block discarded – undo
324 318
 		and $h = svg_dimension_to_pixels($attributs['height'])
325 319
 	) {
326 320
 		$height = $h;
327
-	}
328
-	else {
321
+	} else {
329 322
 		$height = $viewBox[3];
330 323
 		if ($height < 1) {
331 324
 			$coeff = max($coeff, 1000);
332
-		}
333
-		elseif ($height < 10) {
325
+		} elseif ($height < 10) {
334 326
 			$coeff = max($coeff, 100);
335
-		}
336
-		elseif ($height < 100) {
327
+		} elseif ($height < 100) {
337 328
 			$coeff = max($coeff, 10);
338 329
 		}
339 330
 	}
@@ -475,8 +466,7 @@  discard block
 block discarded – undo
475 466
 			if (isset($attributs['viewBox'])) {
476 467
 				$viewBox = explode(' ', $attributs['viewBox']);
477 468
 				$rect = '<rect x="' . $viewBox[0] . '" y="' . $viewBox[1] . '" width="' . $viewBox[2] . '" height="' . $viewBox[3] . "\" fill=\"$background_color\"/>";
478
-			}
479
-			else {
469
+			} else {
480 470
 				$rect = "<rect width=\"100%\" height=\"100%\" fill=\"$background_color\"/>";
481 471
 			}
482 472
 			$svg = svg_insert_shapes($svg, $rect);
@@ -505,8 +495,7 @@  discard block
 block discarded – undo
505 495
 			if (isset($attributs['viewBox'])) {
506 496
 				$viewBox = explode(' ', $attributs['viewBox']);
507 497
 				$rect = '<rect x="' . $viewBox[0] . '" y="' . $viewBox[1] . '" width="' . $viewBox[2] . '" height="' . $viewBox[3] . "\" fill=\"$background_color\" opacity=\"$opacity\"/>";
508
-			}
509
-			else {
498
+			} else {
510 499
 				$rect = "<rect width=\"100%\" height=\"100%\" fill=\"$background_color\"/>";
511 500
 			}
512 501
 			$svg = svg_insert_shapes($svg, $rect, false);
@@ -627,8 +616,7 @@  discard block
 block discarded – undo
627 616
 			$x = intval($viewBox[0]) + intval($viewBox[2] / 2);
628 617
 			$mx = -$x;
629 618
 			$transform = "translate($x, 0) $transform translate($mx, 0)";
630
-		}
631
-		else {
619
+		} else {
632 620
 			$transform = 'scale(1,-1)';
633 621
 
634 622
 			$y = intval($viewBox[1]) + intval($viewBox[3] / 2);
@@ -689,8 +677,7 @@  discard block
 block discarded – undo
689 677
 			$c = array_shift($colors);
690 678
 			if (strlen($c) == 4) {
691 679
 				$short[] = $c;
692
-			}
693
-			else {
680
+			} else {
694 681
 				$long[] = $c;
695 682
 			}
696 683
 		}
Please login to merge, or discard this patch.
Indentation   +448 added lines, -448 removed lines patch added patch discarded remove patch
@@ -17,13 +17,13 @@  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
 if (!defined('IMG_SVG')) {
24
-	// complete 	IMG_BMP | IMG_GIF | IMG_JPG | IMG_PNG | IMG_WBMP | IMG_XPM | IMG_WEBP
25
-	define('IMG_SVG', 128);
26
-	define('IMAGETYPE_SVG', 19);
24
+    // complete 	IMG_BMP | IMG_GIF | IMG_JPG | IMG_PNG | IMG_WBMP | IMG_XPM | IMG_WEBP
25
+    define('IMG_SVG', 128);
26
+    define('IMAGETYPE_SVG', 19);
27 27
 }
28 28
 
29 29
 /**
@@ -39,39 +39,39 @@  discard block
 block discarded – undo
39 39
  *   false si on a pas pu charger l'image
40 40
  */
41 41
 function svg_charger($fichier, $maxlen = null) {
42
-	if (strpos($fichier, 'data:image/svg+xml') === 0) {
43
-		$image = explode(';', $fichier, 2);
44
-		$image = end($image);
45
-		if (strpos($image, 'base64,') === 0) {
46
-			$image = base64_decode(substr($image, 7));
47
-		}
48
-		if (strpos($image, '<svg') !== false) {
49
-			return $image;
50
-		}
51
-		// encodage inconnu ou autre format d'image ?
52
-		return false;
53
-	}
54
-	// c'est peut etre deja une image svg ?
55
-	if (strpos($fichier, '<svg') !== false) {
56
-		return $fichier;
57
-	}
58
-	if (!file_exists($fichier)) {
59
-		$fichier  = supprimer_timestamp($fichier);
60
-		if (!file_exists($fichier)) {
61
-			return false;
62
-		}
63
-	}
64
-	if (is_null($maxlen)) {
65
-		$image = file_get_contents($fichier);
66
-	}
67
-	else {
68
-		$image = file_get_contents($fichier, false, null, 0, $maxlen);
69
-	}
70
-	// est-ce bien une image svg ?
71
-	if (strpos($image, '<svg') !== false) {
72
-		return $image;
73
-	}
74
-	return false;
42
+    if (strpos($fichier, 'data:image/svg+xml') === 0) {
43
+        $image = explode(';', $fichier, 2);
44
+        $image = end($image);
45
+        if (strpos($image, 'base64,') === 0) {
46
+            $image = base64_decode(substr($image, 7));
47
+        }
48
+        if (strpos($image, '<svg') !== false) {
49
+            return $image;
50
+        }
51
+        // encodage inconnu ou autre format d'image ?
52
+        return false;
53
+    }
54
+    // c'est peut etre deja une image svg ?
55
+    if (strpos($fichier, '<svg') !== false) {
56
+        return $fichier;
57
+    }
58
+    if (!file_exists($fichier)) {
59
+        $fichier  = supprimer_timestamp($fichier);
60
+        if (!file_exists($fichier)) {
61
+            return false;
62
+        }
63
+    }
64
+    if (is_null($maxlen)) {
65
+        $image = file_get_contents($fichier);
66
+    }
67
+    else {
68
+        $image = file_get_contents($fichier, false, null, 0, $maxlen);
69
+    }
70
+    // est-ce bien une image svg ?
71
+    if (strpos($image, '<svg') !== false) {
72
+        return $image;
73
+    }
74
+    return false;
75 75
 }
76 76
 
77 77
 /**
@@ -80,28 +80,28 @@  discard block
 block discarded – undo
80 80
  * @return array|bool
81 81
  */
82 82
 function svg_lire_balise_svg($fichier) {
83
-	if (!$debut_fichier = svg_charger($fichier, 4096)) {
84
-		return false;
85
-	}
86
-
87
-	if (($ps = stripos($debut_fichier, '<svg')) !== false) {
88
-		$pe = stripos($debut_fichier, '>', $ps);
89
-		$balise_svg = substr($debut_fichier, $ps, $pe - $ps + 1);
90
-
91
-		if (preg_match_all(',([\w:\-]+)=,Uims', $balise_svg, $matches)) {
92
-			if (!function_exists('extraire_attribut')) {
93
-				include_spip('inc/filtres');
94
-			}
95
-			$attributs = [];
96
-			foreach ($matches[1] as $att) {
97
-				$attributs[$att] = extraire_attribut($balise_svg, $att);
98
-			}
99
-
100
-			return [$balise_svg, $attributs];
101
-		}
102
-	}
103
-
104
-	return false;
83
+    if (!$debut_fichier = svg_charger($fichier, 4096)) {
84
+        return false;
85
+    }
86
+
87
+    if (($ps = stripos($debut_fichier, '<svg')) !== false) {
88
+        $pe = stripos($debut_fichier, '>', $ps);
89
+        $balise_svg = substr($debut_fichier, $ps, $pe - $ps + 1);
90
+
91
+        if (preg_match_all(',([\w:\-]+)=,Uims', $balise_svg, $matches)) {
92
+            if (!function_exists('extraire_attribut')) {
93
+                include_spip('inc/filtres');
94
+            }
95
+            $attributs = [];
96
+            foreach ($matches[1] as $att) {
97
+                $attributs[$att] = extraire_attribut($balise_svg, $att);
98
+            }
99
+
100
+            return [$balise_svg, $attributs];
101
+        }
102
+    }
103
+
104
+    return false;
105 105
 }
106 106
 
107 107
 /**
@@ -111,12 +111,12 @@  discard block
 block discarded – undo
111 111
  */
112 112
 function svg_lire_attributs($img) {
113 113
 
114
-	if ($svg_infos = svg_lire_balise_svg($img)) {
115
-		[$balise_svg, $attributs] = $svg_infos;
116
-		return $attributs;
117
-	}
114
+    if ($svg_infos = svg_lire_balise_svg($img)) {
115
+        [$balise_svg, $attributs] = $svg_infos;
116
+        return $attributs;
117
+    }
118 118
 
119
-	return false;
119
+    return false;
120 120
 }
121 121
 
122 122
 /**
@@ -126,38 +126,38 @@  discard block
 block discarded – undo
126 126
  * @return bool|float|int
127 127
  */
128 128
 function svg_dimension_to_pixels($dimension, $precision = 2) {
129
-	if (preg_match(',^(-?\d+(\.\d+)?)([^\d]*),i', trim($dimension), $m)) {
130
-		switch (strtolower($m[2])) {
131
-			case '%':
132
-				// on ne sait pas faire :(
133
-				return false;
134
-				break;
135
-			case 'em':
136
-				return round($m[1] * 16, $precision); // 16px font-size par defaut
137
-				break;
138
-			case 'ex':
139
-				return round($m[1] * 16, $precision); // 16px font-size par defaut
140
-				break;
141
-			case 'pc':
142
-				return round($m[1] * 16, $precision); // 1/6 inch = 96px/6 in CSS
143
-				break;
144
-			case 'cm':
145
-				return round($m[1] * 96 / 2.54, $precision); // 96px / 2.54cm;
146
-				break;
147
-			case 'mm':
148
-				return round($m[1] * 96 / 25.4, $precision); // 96px / 25.4mm;
149
-				break;
150
-			case 'in':
151
-				return round($m[1] * 96, $precision); // 1 inch = 96px in CSS
152
-				break;
153
-			case 'px':
154
-			case 'pt':
155
-			default:
156
-				return $m[1];
157
-				break;
158
-		}
159
-	}
160
-	return false;
129
+    if (preg_match(',^(-?\d+(\.\d+)?)([^\d]*),i', trim($dimension), $m)) {
130
+        switch (strtolower($m[2])) {
131
+            case '%':
132
+                // on ne sait pas faire :(
133
+                return false;
134
+                break;
135
+            case 'em':
136
+                return round($m[1] * 16, $precision); // 16px font-size par defaut
137
+                break;
138
+            case 'ex':
139
+                return round($m[1] * 16, $precision); // 16px font-size par defaut
140
+                break;
141
+            case 'pc':
142
+                return round($m[1] * 16, $precision); // 1/6 inch = 96px/6 in CSS
143
+                break;
144
+            case 'cm':
145
+                return round($m[1] * 96 / 2.54, $precision); // 96px / 2.54cm;
146
+                break;
147
+            case 'mm':
148
+                return round($m[1] * 96 / 25.4, $precision); // 96px / 25.4mm;
149
+                break;
150
+            case 'in':
151
+                return round($m[1] * 96, $precision); // 1 inch = 96px in CSS
152
+                break;
153
+            case 'px':
154
+            case 'pt':
155
+            default:
156
+                return $m[1];
157
+                break;
158
+        }
159
+    }
160
+    return false;
161 161
 }
162 162
 
163 163
 /**
@@ -168,15 +168,15 @@  discard block
 block discarded – undo
168 168
  * @return string
169 169
  */
170 170
 function svg_change_balise_svg($svg, $old_balise_svg, $attributs) {
171
-	$new_balise_svg = '<svg';
172
-	foreach ($attributs as $k => $v) {
173
-		$new_balise_svg .= " $k=\"" . entites_html($v) . '"';
174
-	}
175
-	$new_balise_svg .= '>';
176
-
177
-	$p = strpos($svg, $old_balise_svg);
178
-	$svg = substr_replace($svg, $new_balise_svg, $p, strlen($old_balise_svg));
179
-	return $svg;
171
+    $new_balise_svg = '<svg';
172
+    foreach ($attributs as $k => $v) {
173
+        $new_balise_svg .= " $k=\"" . entites_html($v) . '"';
174
+    }
175
+    $new_balise_svg .= '>';
176
+
177
+    $p = strpos($svg, $old_balise_svg);
178
+    $svg = substr_replace($svg, $new_balise_svg, $p, strlen($old_balise_svg));
179
+    return $svg;
180 180
 }
181 181
 
182 182
 /**
@@ -188,15 +188,15 @@  discard block
 block discarded – undo
188 188
  */
189 189
 function svg_insert_shapes($svg, $shapes, $start = true) {
190 190
 
191
-	if ($start === false or $start === 'end') {
192
-		$svg = str_replace('</svg>', $shapes . '</svg>', $svg);
193
-	}
194
-	else {
195
-		$p = stripos($svg, '<svg');
196
-		$p = strpos($svg, '>', $p);
197
-		$svg = substr_replace($svg, $shapes, $p + 1, 0);
198
-	}
199
-	return $svg;
191
+    if ($start === false or $start === 'end') {
192
+        $svg = str_replace('</svg>', $shapes . '</svg>', $svg);
193
+    }
194
+    else {
195
+        $p = stripos($svg, '<svg');
196
+        $p = strpos($svg, '>', $p);
197
+        $svg = substr_replace($svg, $shapes, $p + 1, 0);
198
+    }
199
+    return $svg;
200 200
 }
201 201
 
202 202
 /**
@@ -209,13 +209,13 @@  discard block
 block discarded – undo
209 209
  * @return string
210 210
  */
211 211
 function svg_clip_in_box($svg, $x, $y, $width, $height) {
212
-	$rect = "<rect x=\"$x\" y=\"$y\" width=\"$width\" height=\"$height\" />";
213
-	$id = 'clip-' . substr(md5($rect . strlen($svg)), 0, 8);
214
-	$clippath = "<clipPath id=\"$id\">$rect</clipPath>";
215
-	$g = "<g clip-path=\"url(#$id)\">";
216
-	$svg = svg_insert_shapes($svg, $clippath . $g);
217
-	$svg = svg_insert_shapes($svg, '</g>', false);
218
-	return $svg;
212
+    $rect = "<rect x=\"$x\" y=\"$y\" width=\"$width\" height=\"$height\" />";
213
+    $id = 'clip-' . substr(md5($rect . strlen($svg)), 0, 8);
214
+    $clippath = "<clipPath id=\"$id\">$rect</clipPath>";
215
+    $g = "<g clip-path=\"url(#$id)\">";
216
+    $svg = svg_insert_shapes($svg, $clippath . $g);
217
+    $svg = svg_insert_shapes($svg, '</g>', false);
218
+    return $svg;
219 219
 }
220 220
 
221 221
 /**
@@ -226,22 +226,22 @@  discard block
 block discarded – undo
226 226
  * @return bool|string
227 227
  */
228 228
 function svg_redimensionner($img, $new_width, $new_height) {
229
-	if (
230
-		$svg = svg_charger($img)
231
-		and $svg_infos = svg_lire_balise_svg($svg)
232
-	) {
233
-		[$balise_svg, $attributs] = $svg_infos;
234
-		if (!isset($attributs['viewBox'])) {
235
-			$attributs['viewBox'] = '0 0 ' . $attributs['width'] . ' ' . $attributs['height'];
236
-		}
237
-		$attributs['width'] = strval($new_width);
238
-		$attributs['height'] = strval($new_height);
239
-
240
-		$svg = svg_change_balise_svg($svg, $balise_svg, $attributs);
241
-		return $svg;
242
-	}
243
-
244
-	return $img;
229
+    if (
230
+        $svg = svg_charger($img)
231
+        and $svg_infos = svg_lire_balise_svg($svg)
232
+    ) {
233
+        [$balise_svg, $attributs] = $svg_infos;
234
+        if (!isset($attributs['viewBox'])) {
235
+            $attributs['viewBox'] = '0 0 ' . $attributs['width'] . ' ' . $attributs['height'];
236
+        }
237
+        $attributs['width'] = strval($new_width);
238
+        $attributs['height'] = strval($new_height);
239
+
240
+        $svg = svg_change_balise_svg($svg, $balise_svg, $attributs);
241
+        return $svg;
242
+    }
243
+
244
+    return $img;
245 245
 }
246 246
 
247 247
 /**
@@ -250,15 +250,15 @@  discard block
 block discarded – undo
250 250
  * @return string
251 251
  */
252 252
 function svg_couleur_to_hexa($couleur) {
253
-	if (strpos($couleur, 'rgb(') === 0) {
254
-		$c = explode(',', substr($couleur, 4));
255
-		$couleur = _couleur_dec_to_hex(intval($c[0]), intval($c[1]), intval($c[2]));
256
-	}
257
-	else {
258
-		$couleur = couleur_html_to_hex($couleur);
259
-	}
260
-	$couleur = '#' . ltrim($couleur, '#');
261
-	return $couleur;
253
+    if (strpos($couleur, 'rgb(') === 0) {
254
+        $c = explode(',', substr($couleur, 4));
255
+        $couleur = _couleur_dec_to_hex(intval($c[0]), intval($c[1]), intval($c[2]));
256
+    }
257
+    else {
258
+        $couleur = couleur_html_to_hex($couleur);
259
+    }
260
+    $couleur = '#' . ltrim($couleur, '#');
261
+    return $couleur;
262 262
 }
263 263
 
264 264
 /**
@@ -267,11 +267,11 @@  discard block
 block discarded – undo
267 267
  * @return array
268 268
  */
269 269
 function svg_couleur_to_rgb($couleur) {
270
-	if (strpos($couleur, 'rgb(') === 0) {
271
-		$c = explode(',', substr($couleur, 4));
272
-		return ['red' => intval($c[0]),'green' => intval($c[1]),'blue' => intval($c[2])];
273
-	}
274
-	return _couleur_hex_to_dec($couleur);
270
+    if (strpos($couleur, 'rgb(') === 0) {
271
+        $c = explode(',', substr($couleur, 4));
272
+        return ['red' => intval($c[0]),'green' => intval($c[1]),'blue' => intval($c[2])];
273
+    }
274
+    return _couleur_hex_to_dec($couleur);
275 275
 }
276 276
 
277 277
 
@@ -281,70 +281,70 @@  discard block
 block discarded – undo
281 281
  * @return array
282 282
  */
283 283
 function svg_getimagesize_from_attr($attributs) {
284
-	$width = 350; // default width
285
-	$height = 150; // default height
286
-
287
-	$viewBox = "0 0 $width $height";
288
-	if (isset($attributs['viewBox'])) {
289
-		$viewBox = $attributs['viewBox'];
290
-		$viewBox = preg_replace(',\s+,', ' ', $viewBox);
291
-	}
292
-	// et on la convertit en px
293
-	$viewBox = explode(' ', $viewBox);
294
-	$viewBox = array_map('svg_dimension_to_pixels', $viewBox);
295
-	if (!$viewBox[2]) {
296
-		$viewBox[2] = $width;
297
-	}
298
-	if (!$viewBox[3]) {
299
-		$viewBox[3] = $height;
300
-	}
301
-
302
-	$coeff = 1;
303
-	if (
304
-		isset($attributs['width'])
305
-		and $w = svg_dimension_to_pixels($attributs['width'])
306
-	) {
307
-		$width = $w;
308
-	}
309
-	else {
310
-		// si on recupere la taille de la viewbox mais si la viewbox est petite on met un multiplicateur pour la taille finale
311
-		$width = $viewBox[2];
312
-		if ($width < 1) {
313
-			$coeff = max($coeff, 1000);
314
-		}
315
-		elseif ($width < 10) {
316
-			$coeff = max($coeff, 100);
317
-		}
318
-		elseif ($width < 100) {
319
-			$coeff = max($coeff, 10);
320
-		}
321
-	}
322
-	if (
323
-		isset($attributs['height'])
324
-		and $h = svg_dimension_to_pixels($attributs['height'])
325
-	) {
326
-		$height = $h;
327
-	}
328
-	else {
329
-		$height = $viewBox[3];
330
-		if ($height < 1) {
331
-			$coeff = max($coeff, 1000);
332
-		}
333
-		elseif ($height < 10) {
334
-			$coeff = max($coeff, 100);
335
-		}
336
-		elseif ($height < 100) {
337
-			$coeff = max($coeff, 10);
338
-		}
339
-	}
340
-
341
-	// arrondir le width et height en pixel in fine
342
-	$width = round($coeff * $width);
343
-	$height = round($coeff * $height);
344
-
345
-	$viewBox = implode(' ', $viewBox);
346
-
347
-	return [$width, $height, $viewBox];
284
+    $width = 350; // default width
285
+    $height = 150; // default height
286
+
287
+    $viewBox = "0 0 $width $height";
288
+    if (isset($attributs['viewBox'])) {
289
+        $viewBox = $attributs['viewBox'];
290
+        $viewBox = preg_replace(',\s+,', ' ', $viewBox);
291
+    }
292
+    // et on la convertit en px
293
+    $viewBox = explode(' ', $viewBox);
294
+    $viewBox = array_map('svg_dimension_to_pixels', $viewBox);
295
+    if (!$viewBox[2]) {
296
+        $viewBox[2] = $width;
297
+    }
298
+    if (!$viewBox[3]) {
299
+        $viewBox[3] = $height;
300
+    }
301
+
302
+    $coeff = 1;
303
+    if (
304
+        isset($attributs['width'])
305
+        and $w = svg_dimension_to_pixels($attributs['width'])
306
+    ) {
307
+        $width = $w;
308
+    }
309
+    else {
310
+        // si on recupere la taille de la viewbox mais si la viewbox est petite on met un multiplicateur pour la taille finale
311
+        $width = $viewBox[2];
312
+        if ($width < 1) {
313
+            $coeff = max($coeff, 1000);
314
+        }
315
+        elseif ($width < 10) {
316
+            $coeff = max($coeff, 100);
317
+        }
318
+        elseif ($width < 100) {
319
+            $coeff = max($coeff, 10);
320
+        }
321
+    }
322
+    if (
323
+        isset($attributs['height'])
324
+        and $h = svg_dimension_to_pixels($attributs['height'])
325
+    ) {
326
+        $height = $h;
327
+    }
328
+    else {
329
+        $height = $viewBox[3];
330
+        if ($height < 1) {
331
+            $coeff = max($coeff, 1000);
332
+        }
333
+        elseif ($height < 10) {
334
+            $coeff = max($coeff, 100);
335
+        }
336
+        elseif ($height < 100) {
337
+            $coeff = max($coeff, 10);
338
+        }
339
+    }
340
+
341
+    // arrondir le width et height en pixel in fine
342
+    $width = round($coeff * $width);
343
+    $height = round($coeff * $height);
344
+
345
+    $viewBox = implode(' ', $viewBox);
346
+
347
+    return [$width, $height, $viewBox];
348 348
 }
349 349
 
350 350
 /**
@@ -360,25 +360,25 @@  discard block
 block discarded – undo
360 360
  * @return string
361 361
  */
362 362
 function svg_force_viewBox_px($img, $force_width_and_height = false) {
363
-	if (
364
-		$svg = svg_charger($img)
365
-		and $svg_infos = svg_lire_balise_svg($svg)
366
-	) {
367
-		[$balise_svg, $attributs] = $svg_infos;
363
+    if (
364
+        $svg = svg_charger($img)
365
+        and $svg_infos = svg_lire_balise_svg($svg)
366
+    ) {
367
+        [$balise_svg, $attributs] = $svg_infos;
368 368
 
369
-		[$width, $height, $viewBox] = svg_getimagesize_from_attr($attributs);
369
+        [$width, $height, $viewBox] = svg_getimagesize_from_attr($attributs);
370 370
 
371
-		if ($force_width_and_height) {
372
-			$attributs['width'] = $width;
373
-			$attributs['height'] = $height;
374
-		}
371
+        if ($force_width_and_height) {
372
+            $attributs['width'] = $width;
373
+            $attributs['height'] = $height;
374
+        }
375 375
 
376
-		$attributs['viewBox'] = $viewBox;
376
+        $attributs['viewBox'] = $viewBox;
377 377
 
378
-		$svg = svg_change_balise_svg($svg, $balise_svg, $attributs);
379
-		return $svg;
380
-	}
381
-	return $img;
378
+        $svg = svg_change_balise_svg($svg, $balise_svg, $attributs);
379
+        return $svg;
380
+    }
381
+    return $img;
382 382
 }
383 383
 
384 384
 /**
@@ -387,12 +387,12 @@  discard block
 block discarded – undo
387 387
  * @return array|mixed
388 388
  */
389 389
 function svg_extract_couleurs($img) {
390
-	if ($svg = svg_charger($img)) {
391
-		if (preg_match_all('/(#[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f])|(rgb\([\s\d]+,[\s\d]+,[\s\d]+\))|(#[0-9a-f][0-9a-f][0-9a-f])/imS', $svg, $matches)) {
392
-			return $matches[0];
393
-		}
394
-	}
395
-	return [];
390
+    if ($svg = svg_charger($img)) {
391
+        if (preg_match_all('/(#[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f])|(rgb\([\s\d]+,[\s\d]+,[\s\d]+\))|(#[0-9a-f][0-9a-f][0-9a-f])/imS', $svg, $matches)) {
392
+            return $matches[0];
393
+        }
394
+    }
395
+    return [];
396 396
 }
397 397
 
398 398
 /**
@@ -403,58 +403,58 @@  discard block
 block discarded – undo
403 403
  * @return bool|string
404 404
  */
405 405
 function svg_recadrer($img, $new_width, $new_height, $offset_width, $offset_height, $background_color = '') {
406
-	if (
407
-		$svg = svg_force_viewBox_px($img)
408
-		and $svg_infos = svg_lire_balise_svg($svg)
409
-	) {
410
-		[$balise_svg, $attributs] = $svg_infos;
411
-		$viewBox = explode(' ', $attributs['viewBox']);
412
-
413
-		$viewport_w = $new_width;
414
-		$viewport_h = $new_height;
415
-		$viewport_ox = $offset_width;
416
-		$viewport_oy = $offset_height;
417
-
418
-		// si on a un width/height qui rescale, il faut rescaler
419
-		if (
420
-			isset($attributs['width'])
421
-			and $w = svg_dimension_to_pixels($attributs['width'])
422
-			and isset($attributs['height'])
423
-			and $h = svg_dimension_to_pixels($attributs['height'])
424
-		) {
425
-			$xscale = $viewBox[2] / $w;
426
-			$viewport_w = round($viewport_w * $xscale, 2);
427
-			$viewport_ox = round($viewport_ox * $xscale, 2);
428
-			$yscale = $viewBox[3] / $h;
429
-			$viewport_h = round($viewport_h * $yscale, 2);
430
-			$viewport_oy = round($viewport_oy * $yscale, 2);
431
-		}
432
-
433
-		if ($viewport_w > $viewBox[2] or $viewport_h > $viewBox[3]) {
434
-			$svg = svg_clip_in_box($svg, $viewBox[0], $viewBox[1], $viewBox[2], $viewBox[3]);
435
-		}
436
-
437
-		// maintenant on redefinit la viewBox
438
-		$viewBox[0] += $viewport_ox;
439
-		$viewBox[1] += $viewport_oy;
440
-		$viewBox[2] = $viewport_w;
441
-		$viewBox[3] = $viewport_h;
442
-
443
-		$attributs['viewBox'] = implode(' ', $viewBox);
444
-		$attributs['width'] = strval($new_width);
445
-		$attributs['height'] = strval($new_height);
446
-
447
-		$svg = svg_change_balise_svg($svg, $balise_svg, $attributs);
448
-
449
-		// ajouter un background
450
-		if ($background_color and $background_color !== 'transparent') {
451
-			$svg = svg_ajouter_background($svg, $background_color);
452
-		}
453
-
454
-		return $svg;
455
-	}
456
-
457
-	return $img;
406
+    if (
407
+        $svg = svg_force_viewBox_px($img)
408
+        and $svg_infos = svg_lire_balise_svg($svg)
409
+    ) {
410
+        [$balise_svg, $attributs] = $svg_infos;
411
+        $viewBox = explode(' ', $attributs['viewBox']);
412
+
413
+        $viewport_w = $new_width;
414
+        $viewport_h = $new_height;
415
+        $viewport_ox = $offset_width;
416
+        $viewport_oy = $offset_height;
417
+
418
+        // si on a un width/height qui rescale, il faut rescaler
419
+        if (
420
+            isset($attributs['width'])
421
+            and $w = svg_dimension_to_pixels($attributs['width'])
422
+            and isset($attributs['height'])
423
+            and $h = svg_dimension_to_pixels($attributs['height'])
424
+        ) {
425
+            $xscale = $viewBox[2] / $w;
426
+            $viewport_w = round($viewport_w * $xscale, 2);
427
+            $viewport_ox = round($viewport_ox * $xscale, 2);
428
+            $yscale = $viewBox[3] / $h;
429
+            $viewport_h = round($viewport_h * $yscale, 2);
430
+            $viewport_oy = round($viewport_oy * $yscale, 2);
431
+        }
432
+
433
+        if ($viewport_w > $viewBox[2] or $viewport_h > $viewBox[3]) {
434
+            $svg = svg_clip_in_box($svg, $viewBox[0], $viewBox[1], $viewBox[2], $viewBox[3]);
435
+        }
436
+
437
+        // maintenant on redefinit la viewBox
438
+        $viewBox[0] += $viewport_ox;
439
+        $viewBox[1] += $viewport_oy;
440
+        $viewBox[2] = $viewport_w;
441
+        $viewBox[3] = $viewport_h;
442
+
443
+        $attributs['viewBox'] = implode(' ', $viewBox);
444
+        $attributs['width'] = strval($new_width);
445
+        $attributs['height'] = strval($new_height);
446
+
447
+        $svg = svg_change_balise_svg($svg, $balise_svg, $attributs);
448
+
449
+        // ajouter un background
450
+        if ($background_color and $background_color !== 'transparent') {
451
+            $svg = svg_ajouter_background($svg, $background_color);
452
+        }
453
+
454
+        return $svg;
455
+    }
456
+
457
+    return $img;
458 458
 }
459 459
 
460 460
 /**
@@ -464,26 +464,26 @@  discard block
 block discarded – undo
464 464
  * @return bool|string
465 465
  */
466 466
 function svg_ajouter_background($img, $background_color) {
467
-	if (
468
-		$svg = svg_charger($img)
469
-		and $svg_infos = svg_lire_balise_svg($svg)
470
-	) {
471
-		if ($background_color and $background_color !== 'transparent') {
472
-			[$balise_svg, $attributs] = $svg_infos;
473
-
474
-			$background_color = svg_couleur_to_hexa($background_color);
475
-			if (isset($attributs['viewBox'])) {
476
-				$viewBox = explode(' ', $attributs['viewBox']);
477
-				$rect = '<rect x="' . $viewBox[0] . '" y="' . $viewBox[1] . '" width="' . $viewBox[2] . '" height="' . $viewBox[3] . "\" fill=\"$background_color\"/>";
478
-			}
479
-			else {
480
-				$rect = "<rect width=\"100%\" height=\"100%\" fill=\"$background_color\"/>";
481
-			}
482
-			$svg = svg_insert_shapes($svg, $rect);
483
-		}
484
-		return $svg;
485
-	}
486
-	return $img;
467
+    if (
468
+        $svg = svg_charger($img)
469
+        and $svg_infos = svg_lire_balise_svg($svg)
470
+    ) {
471
+        if ($background_color and $background_color !== 'transparent') {
472
+            [$balise_svg, $attributs] = $svg_infos;
473
+
474
+            $background_color = svg_couleur_to_hexa($background_color);
475
+            if (isset($attributs['viewBox'])) {
476
+                $viewBox = explode(' ', $attributs['viewBox']);
477
+                $rect = '<rect x="' . $viewBox[0] . '" y="' . $viewBox[1] . '" width="' . $viewBox[2] . '" height="' . $viewBox[3] . "\" fill=\"$background_color\"/>";
478
+            }
479
+            else {
480
+                $rect = "<rect width=\"100%\" height=\"100%\" fill=\"$background_color\"/>";
481
+            }
482
+            $svg = svg_insert_shapes($svg, $rect);
483
+        }
484
+        return $svg;
485
+    }
486
+    return $img;
487 487
 }
488 488
 
489 489
 
@@ -494,26 +494,26 @@  discard block
 block discarded – undo
494 494
  * @return bool|string
495 495
  */
496 496
 function svg_ajouter_voile($img, $background_color, $opacity) {
497
-	if (
498
-		$svg = svg_charger($img)
499
-		and $svg_infos = svg_lire_balise_svg($svg)
500
-	) {
501
-		if ($background_color and $background_color !== 'transparent') {
502
-			[$balise_svg, $attributs] = $svg_infos;
503
-
504
-			$background_color = svg_couleur_to_hexa($background_color);
505
-			if (isset($attributs['viewBox'])) {
506
-				$viewBox = explode(' ', $attributs['viewBox']);
507
-				$rect = '<rect x="' . $viewBox[0] . '" y="' . $viewBox[1] . '" width="' . $viewBox[2] . '" height="' . $viewBox[3] . "\" fill=\"$background_color\" opacity=\"$opacity\"/>";
508
-			}
509
-			else {
510
-				$rect = "<rect width=\"100%\" height=\"100%\" fill=\"$background_color\"/>";
511
-			}
512
-			$svg = svg_insert_shapes($svg, $rect, false);
513
-		}
514
-		return $svg;
515
-	}
516
-	return $img;
497
+    if (
498
+        $svg = svg_charger($img)
499
+        and $svg_infos = svg_lire_balise_svg($svg)
500
+    ) {
501
+        if ($background_color and $background_color !== 'transparent') {
502
+            [$balise_svg, $attributs] = $svg_infos;
503
+
504
+            $background_color = svg_couleur_to_hexa($background_color);
505
+            if (isset($attributs['viewBox'])) {
506
+                $viewBox = explode(' ', $attributs['viewBox']);
507
+                $rect = '<rect x="' . $viewBox[0] . '" y="' . $viewBox[1] . '" width="' . $viewBox[2] . '" height="' . $viewBox[3] . "\" fill=\"$background_color\" opacity=\"$opacity\"/>";
508
+            }
509
+            else {
510
+                $rect = "<rect width=\"100%\" height=\"100%\" fill=\"$background_color\"/>";
511
+            }
512
+            $svg = svg_insert_shapes($svg, $rect, false);
513
+        }
514
+        return $svg;
515
+    }
516
+    return $img;
517 517
 }
518 518
 
519 519
 
@@ -524,27 +524,27 @@  discard block
 block discarded – undo
524 524
  * @return bool|string
525 525
  */
526 526
 function svg_transformer($img, $attributs) {
527
-	if (
528
-		$svg = svg_charger($img)
529
-		and $svg_infos = svg_lire_balise_svg($svg)
530
-	) {
531
-		if ($attributs) {
532
-			[$balise_svg, ] = $svg_infos;
533
-			$g = '<g';
534
-			foreach ($attributs as $k => $v) {
535
-				if (strlen($v)) {
536
-					$g .= " $k=\"" . attribut_html($v) . '"';
537
-				}
538
-			}
539
-			if (strlen($g) > 2) {
540
-				$g .= '>';
541
-				$svg = svg_insert_shapes($svg, $g);
542
-				$svg = svg_insert_shapes($svg, '</g>', false);
543
-			}
544
-		}
545
-		return $svg;
546
-	}
547
-	return $img;
527
+    if (
528
+        $svg = svg_charger($img)
529
+        and $svg_infos = svg_lire_balise_svg($svg)
530
+    ) {
531
+        if ($attributs) {
532
+            [$balise_svg, ] = $svg_infos;
533
+            $g = '<g';
534
+            foreach ($attributs as $k => $v) {
535
+                if (strlen($v)) {
536
+                    $g .= " $k=\"" . attribut_html($v) . '"';
537
+                }
538
+            }
539
+            if (strlen($g) > 2) {
540
+                $g .= '>';
541
+                $svg = svg_insert_shapes($svg, $g);
542
+                $svg = svg_insert_shapes($svg, '</g>', false);
543
+            }
544
+        }
545
+        return $svg;
546
+    }
547
+    return $img;
548 548
 }
549 549
 
550 550
 /**
@@ -555,21 +555,21 @@  discard block
 block discarded – undo
555 555
  * @return bool|string
556 556
  */
557 557
 function svg_apply_filter($img, $filter_def) {
558
-	if (
559
-		$svg = svg_charger($img)
560
-		and $svg_infos = svg_lire_balise_svg($svg)
561
-	) {
562
-		if ($filter_def) {
563
-			[$balise_svg, ] = $svg_infos;
564
-			$filter_id = 'filter-' . substr(md5($filter_def . strlen($svg)), 0, 8);
565
-			$filter = "<defs><filter id=\"$filter_id\">$filter_def</filter></defs>";
566
-			$g = "<g filter=\"url(#$filter_id)\">";
567
-			$svg = svg_insert_shapes($svg, $filter . $g);
568
-			$svg = svg_insert_shapes($svg, '</g>', false);
569
-		}
570
-		return $svg;
571
-	}
572
-	return $img;
558
+    if (
559
+        $svg = svg_charger($img)
560
+        and $svg_infos = svg_lire_balise_svg($svg)
561
+    ) {
562
+        if ($filter_def) {
563
+            [$balise_svg, ] = $svg_infos;
564
+            $filter_id = 'filter-' . substr(md5($filter_def . strlen($svg)), 0, 8);
565
+            $filter = "<defs><filter id=\"$filter_id\">$filter_def</filter></defs>";
566
+            $g = "<g filter=\"url(#$filter_id)\">";
567
+            $svg = svg_insert_shapes($svg, $filter . $g);
568
+            $svg = svg_insert_shapes($svg, '</g>', false);
569
+        }
570
+        return $svg;
571
+    }
572
+    return $img;
573 573
 }
574 574
 
575 575
 /**
@@ -579,8 +579,8 @@  discard block
 block discarded – undo
579 579
  * @return string
580 580
  */
581 581
 function svg_filter_blur($img, $blur_width) {
582
-	$blur_width = intval($blur_width);
583
-	return svg_apply_filter($img, "<feGaussianBlur stdDeviation=\"$blur_width\"/>");
582
+    $blur_width = intval($blur_width);
583
+    return svg_apply_filter($img, "<feGaussianBlur stdDeviation=\"$blur_width\"/>");
584 584
 }
585 585
 
586 586
 /**
@@ -590,10 +590,10 @@  discard block
 block discarded – undo
590 590
  * @return bool|string
591 591
  */
592 592
 function svg_filter_grayscale($img, $intensity) {
593
-	$value = round(1.0 - $intensity, 2);
594
-	//$filter = "<feColorMatrix type=\"matrix\" values=\"0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\"/>";
595
-	$filter = "<feColorMatrix type=\"saturate\" values=\"$value\"/>";
596
-	return svg_apply_filter($img, $filter);
593
+    $value = round(1.0 - $intensity, 2);
594
+    //$filter = "<feColorMatrix type=\"matrix\" values=\"0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\"/>";
595
+    $filter = "<feColorMatrix type=\"saturate\" values=\"$value\"/>";
596
+    return svg_apply_filter($img, $filter);
597 597
 }
598 598
 
599 599
 /**
@@ -603,8 +603,8 @@  discard block
 block discarded – undo
603 603
  * @return bool|string
604 604
  */
605 605
 function svg_filter_sepia($img, $intensity) {
606
-	$filter = '<feColorMatrix type="matrix" values="0.30 0.30 0.30 0.0 0 0.25 0.25 0.25 0.0 0 0.20 0.20 0.20 0.0 0 0.00 0.00 0.00 1 0"/>';
607
-	return svg_apply_filter($img, $filter);
606
+    $filter = '<feColorMatrix type="matrix" values="0.30 0.30 0.30 0.0 0 0.25 0.25 0.25 0.0 0 0.20 0.20 0.20 0.0 0 0.00 0.00 0.00 1 0"/>';
607
+    return svg_apply_filter($img, $filter);
608 608
 }
609 609
 
610 610
 /**
@@ -614,31 +614,31 @@  discard block
 block discarded – undo
614 614
  * @return bool|string
615 615
  */
616 616
 function svg_flip($img, $HorV) {
617
-	if (
618
-		$svg = svg_force_viewBox_px($img)
619
-		and $svg_infos = svg_lire_balise_svg($svg)
620
-	) {
621
-		[$balise_svg, $atts] = $svg_infos;
622
-		$viewBox = explode(' ', $atts['viewBox']);
623
-
624
-		if (!in_array($HorV, ['h', 'H'])) {
625
-			$transform = 'scale(-1,1)';
626
-
627
-			$x = intval($viewBox[0]) + intval($viewBox[2] / 2);
628
-			$mx = -$x;
629
-			$transform = "translate($x, 0) $transform translate($mx, 0)";
630
-		}
631
-		else {
632
-			$transform = 'scale(1,-1)';
633
-
634
-			$y = intval($viewBox[1]) + intval($viewBox[3] / 2);
635
-			$my = -$y;
636
-			$transform = "translate(0, $y) $transform translate(0, $my)";
637
-		}
638
-		$svg = svg_transformer($svg, ['transform' => $transform]);
639
-		return $svg;
640
-	}
641
-	return $img;
617
+    if (
618
+        $svg = svg_force_viewBox_px($img)
619
+        and $svg_infos = svg_lire_balise_svg($svg)
620
+    ) {
621
+        [$balise_svg, $atts] = $svg_infos;
622
+        $viewBox = explode(' ', $atts['viewBox']);
623
+
624
+        if (!in_array($HorV, ['h', 'H'])) {
625
+            $transform = 'scale(-1,1)';
626
+
627
+            $x = intval($viewBox[0]) + intval($viewBox[2] / 2);
628
+            $mx = -$x;
629
+            $transform = "translate($x, 0) $transform translate($mx, 0)";
630
+        }
631
+        else {
632
+            $transform = 'scale(1,-1)';
633
+
634
+            $y = intval($viewBox[1]) + intval($viewBox[3] / 2);
635
+            $my = -$y;
636
+            $transform = "translate(0, $y) $transform translate(0, $my)";
637
+        }
638
+        $svg = svg_transformer($svg, ['transform' => $transform]);
639
+        return $svg;
640
+    }
641
+    return $img;
642 642
 }
643 643
 
644 644
 /**
@@ -652,20 +652,20 @@  discard block
 block discarded – undo
652 652
  * @return bool|string
653 653
  */
654 654
 function svg_rotate($img, $angle, $center_x, $center_y) {
655
-	if (
656
-		$svg = svg_force_viewBox_px($img)
657
-		and $svg_infos = svg_lire_balise_svg($svg)
658
-	) {
659
-		[$balise_svg, $atts] = $svg_infos;
660
-		$viewBox = explode(' ', $atts['viewBox']);
661
-
662
-		$center_x = round($viewBox[0] + $center_x * $viewBox[2]);
663
-		$center_y = round($viewBox[1] + $center_y * $viewBox[3]);
664
-		$svg = svg_transformer($svg, ['transform' => "rotate($angle $center_x $center_y)"]);
665
-
666
-		return $svg;
667
-	}
668
-	return $img;
655
+    if (
656
+        $svg = svg_force_viewBox_px($img)
657
+        and $svg_infos = svg_lire_balise_svg($svg)
658
+    ) {
659
+        [$balise_svg, $atts] = $svg_infos;
660
+        $viewBox = explode(' ', $atts['viewBox']);
661
+
662
+        $center_x = round($viewBox[0] + $center_x * $viewBox[2]);
663
+        $center_y = round($viewBox[1] + $center_y * $viewBox[3]);
664
+        $svg = svg_transformer($svg, ['transform' => "rotate($angle $center_x $center_y)"]);
665
+
666
+        return $svg;
667
+    }
668
+    return $img;
669 669
 }
670 670
 
671 671
 /**
@@ -677,41 +677,41 @@  discard block
 block discarded – undo
677 677
  * @return bool|mixed|string
678 678
  */
679 679
 function svg_filtrer_couleurs($img, $callback_filter) {
680
-	if (
681
-		$svg = svg_force_viewBox_px($img)
682
-		and $colors = svg_extract_couleurs($svg)
683
-	) {
684
-		$colors = array_unique($colors);
685
-
686
-		$short = [];
687
-		$long = [];
688
-		while (count($colors)) {
689
-			$c = array_shift($colors);
690
-			if (strlen($c) == 4) {
691
-				$short[] = $c;
692
-			}
693
-			else {
694
-				$long[] = $c;
695
-			}
696
-		}
697
-
698
-		$colors = [...$long, ...$short];
699
-		$new_colors = [];
700
-		$colors = array_flip($colors);
701
-		foreach ($colors as $c => $k) {
702
-			$colors[$c] = "@@@COLOR$$k$@@@";
703
-		}
704
-
705
-
706
-		foreach ($colors as $original => $replace) {
707
-			$new = svg_couleur_to_hexa($original);
708
-			$new_colors[$replace] = $callback_filter($new);
709
-		}
710
-
711
-		$svg = str_replace(array_keys($colors), array_values($colors), $svg);
712
-		$svg = str_replace(array_keys($new_colors), array_values($new_colors), $svg);
713
-
714
-		return $svg;
715
-	}
716
-	return $img;
680
+    if (
681
+        $svg = svg_force_viewBox_px($img)
682
+        and $colors = svg_extract_couleurs($svg)
683
+    ) {
684
+        $colors = array_unique($colors);
685
+
686
+        $short = [];
687
+        $long = [];
688
+        while (count($colors)) {
689
+            $c = array_shift($colors);
690
+            if (strlen($c) == 4) {
691
+                $short[] = $c;
692
+            }
693
+            else {
694
+                $long[] = $c;
695
+            }
696
+        }
697
+
698
+        $colors = [...$long, ...$short];
699
+        $new_colors = [];
700
+        $colors = array_flip($colors);
701
+        foreach ($colors as $c => $k) {
702
+            $colors[$c] = "@@@COLOR$$k$@@@";
703
+        }
704
+
705
+
706
+        foreach ($colors as $original => $replace) {
707
+            $new = svg_couleur_to_hexa($original);
708
+            $new_colors[$replace] = $callback_filter($new);
709
+        }
710
+
711
+        $svg = str_replace(array_keys($colors), array_values($colors), $svg);
712
+        $svg = str_replace(array_keys($new_colors), array_values($new_colors), $svg);
713
+
714
+        return $svg;
715
+    }
716
+    return $img;
717 717
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 		return $fichier;
57 57
 	}
58 58
 	if (!file_exists($fichier)) {
59
-		$fichier  = supprimer_timestamp($fichier);
59
+		$fichier = supprimer_timestamp($fichier);
60 60
 		if (!file_exists($fichier)) {
61 61
 			return false;
62 62
 		}
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 function svg_change_balise_svg($svg, $old_balise_svg, $attributs) {
171 171
 	$new_balise_svg = '<svg';
172 172
 	foreach ($attributs as $k => $v) {
173
-		$new_balise_svg .= " $k=\"" . entites_html($v) . '"';
173
+		$new_balise_svg .= " $k=\"".entites_html($v).'"';
174 174
 	}
175 175
 	$new_balise_svg .= '>';
176 176
 
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 function svg_insert_shapes($svg, $shapes, $start = true) {
190 190
 
191 191
 	if ($start === false or $start === 'end') {
192
-		$svg = str_replace('</svg>', $shapes . '</svg>', $svg);
192
+		$svg = str_replace('</svg>', $shapes.'</svg>', $svg);
193 193
 	}
194 194
 	else {
195 195
 		$p = stripos($svg, '<svg');
@@ -210,10 +210,10 @@  discard block
 block discarded – undo
210 210
  */
211 211
 function svg_clip_in_box($svg, $x, $y, $width, $height) {
212 212
 	$rect = "<rect x=\"$x\" y=\"$y\" width=\"$width\" height=\"$height\" />";
213
-	$id = 'clip-' . substr(md5($rect . strlen($svg)), 0, 8);
213
+	$id = 'clip-'.substr(md5($rect.strlen($svg)), 0, 8);
214 214
 	$clippath = "<clipPath id=\"$id\">$rect</clipPath>";
215 215
 	$g = "<g clip-path=\"url(#$id)\">";
216
-	$svg = svg_insert_shapes($svg, $clippath . $g);
216
+	$svg = svg_insert_shapes($svg, $clippath.$g);
217 217
 	$svg = svg_insert_shapes($svg, '</g>', false);
218 218
 	return $svg;
219 219
 }
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 	) {
233 233
 		[$balise_svg, $attributs] = $svg_infos;
234 234
 		if (!isset($attributs['viewBox'])) {
235
-			$attributs['viewBox'] = '0 0 ' . $attributs['width'] . ' ' . $attributs['height'];
235
+			$attributs['viewBox'] = '0 0 '.$attributs['width'].' '.$attributs['height'];
236 236
 		}
237 237
 		$attributs['width'] = strval($new_width);
238 238
 		$attributs['height'] = strval($new_height);
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 	else {
258 258
 		$couleur = couleur_html_to_hex($couleur);
259 259
 	}
260
-	$couleur = '#' . ltrim($couleur, '#');
260
+	$couleur = '#'.ltrim($couleur, '#');
261 261
 	return $couleur;
262 262
 }
263 263
 
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 function svg_couleur_to_rgb($couleur) {
270 270
 	if (strpos($couleur, 'rgb(') === 0) {
271 271
 		$c = explode(',', substr($couleur, 4));
272
-		return ['red' => intval($c[0]),'green' => intval($c[1]),'blue' => intval($c[2])];
272
+		return ['red' => intval($c[0]), 'green' => intval($c[1]), 'blue' => intval($c[2])];
273 273
 	}
274 274
 	return _couleur_hex_to_dec($couleur);
275 275
 }
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
 			$background_color = svg_couleur_to_hexa($background_color);
475 475
 			if (isset($attributs['viewBox'])) {
476 476
 				$viewBox = explode(' ', $attributs['viewBox']);
477
-				$rect = '<rect x="' . $viewBox[0] . '" y="' . $viewBox[1] . '" width="' . $viewBox[2] . '" height="' . $viewBox[3] . "\" fill=\"$background_color\"/>";
477
+				$rect = '<rect x="'.$viewBox[0].'" y="'.$viewBox[1].'" width="'.$viewBox[2].'" height="'.$viewBox[3]."\" fill=\"$background_color\"/>";
478 478
 			}
479 479
 			else {
480 480
 				$rect = "<rect width=\"100%\" height=\"100%\" fill=\"$background_color\"/>";
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
 			$background_color = svg_couleur_to_hexa($background_color);
505 505
 			if (isset($attributs['viewBox'])) {
506 506
 				$viewBox = explode(' ', $attributs['viewBox']);
507
-				$rect = '<rect x="' . $viewBox[0] . '" y="' . $viewBox[1] . '" width="' . $viewBox[2] . '" height="' . $viewBox[3] . "\" fill=\"$background_color\" opacity=\"$opacity\"/>";
507
+				$rect = '<rect x="'.$viewBox[0].'" y="'.$viewBox[1].'" width="'.$viewBox[2].'" height="'.$viewBox[3]."\" fill=\"$background_color\" opacity=\"$opacity\"/>";
508 508
 			}
509 509
 			else {
510 510
 				$rect = "<rect width=\"100%\" height=\"100%\" fill=\"$background_color\"/>";
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
 			$g = '<g';
534 534
 			foreach ($attributs as $k => $v) {
535 535
 				if (strlen($v)) {
536
-					$g .= " $k=\"" . attribut_html($v) . '"';
536
+					$g .= " $k=\"".attribut_html($v).'"';
537 537
 				}
538 538
 			}
539 539
 			if (strlen($g) > 2) {
@@ -561,10 +561,10 @@  discard block
 block discarded – undo
561 561
 	) {
562 562
 		if ($filter_def) {
563 563
 			[$balise_svg, ] = $svg_infos;
564
-			$filter_id = 'filter-' . substr(md5($filter_def . strlen($svg)), 0, 8);
564
+			$filter_id = 'filter-'.substr(md5($filter_def.strlen($svg)), 0, 8);
565 565
 			$filter = "<defs><filter id=\"$filter_id\">$filter_def</filter></defs>";
566 566
 			$g = "<g filter=\"url(#$filter_id)\">";
567
-			$svg = svg_insert_shapes($svg, $filter . $g);
567
+			$svg = svg_insert_shapes($svg, $filter.$g);
568 568
 			$svg = svg_insert_shapes($svg, '</g>', false);
569 569
 		}
570 570
 		return $svg;
Please login to merge, or discard this patch.
ecrire/inc/lister_objets.php 2 patches
Indentation   +21 added lines, -21 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
 
@@ -40,29 +40,29 @@  discard block
 block discarded – undo
40 40
  *     Code HTML de la liste
41 41
  */
42 42
 function inc_lister_objets_dist($vue, $contexte = [], $force = false) {
43
-	$res = ''; // debug
44
-	if (!is_array($contexte)) {
45
-		return _L('$contexte doit etre un tableau dans inc/lister_objets');
46
-	}
43
+    $res = ''; // debug
44
+    if (!is_array($contexte)) {
45
+        return _L('$contexte doit etre un tableau dans inc/lister_objets');
46
+    }
47 47
 
48
-	$fond = "prive/objets/liste/$vue";
49
-	if (!find_in_path($fond . '.' . _EXTENSION_SQUELETTES)) {
50
-		// traiter les cas particuliers
51
-		include_spip('base/connect_sql');
52
-		$vue = table_objet($vue);
53
-		$fond = "prive/objets/liste/$vue";
54
-		if (!find_in_path($fond . '.' . _EXTENSION_SQUELETTES)) {
55
-			return _L("vue $vue introuvable pour lister les objets");
56
-		}
57
-	}
48
+    $fond = "prive/objets/liste/$vue";
49
+    if (!find_in_path($fond . '.' . _EXTENSION_SQUELETTES)) {
50
+        // traiter les cas particuliers
51
+        include_spip('base/connect_sql');
52
+        $vue = table_objet($vue);
53
+        $fond = "prive/objets/liste/$vue";
54
+        if (!find_in_path($fond . '.' . _EXTENSION_SQUELETTES)) {
55
+            return _L("vue $vue introuvable pour lister les objets");
56
+        }
57
+    }
58 58
 
59 59
 
60
-	$contexte['sinon'] = ($force ? $contexte['titre'] : '');
60
+    $contexte['sinon'] = ($force ? $contexte['titre'] : '');
61 61
 
62
-	$res = recuperer_fond($fond, $contexte, ['ajax' => true]);
63
-	if (_request('var_liste')) {
64
-		echo var_export($contexte, true);
65
-	}
62
+    $res = recuperer_fond($fond, $contexte, ['ajax' => true]);
63
+    if (_request('var_liste')) {
64
+        echo var_export($contexte, true);
65
+    }
66 66
 
67
-	return $res;
67
+    return $res;
68 68
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -46,12 +46,12 @@
 block discarded – undo
46 46
 	}
47 47
 
48 48
 	$fond = "prive/objets/liste/$vue";
49
-	if (!find_in_path($fond . '.' . _EXTENSION_SQUELETTES)) {
49
+	if (!find_in_path($fond.'.'._EXTENSION_SQUELETTES)) {
50 50
 		// traiter les cas particuliers
51 51
 		include_spip('base/connect_sql');
52 52
 		$vue = table_objet($vue);
53 53
 		$fond = "prive/objets/liste/$vue";
54
-		if (!find_in_path($fond . '.' . _EXTENSION_SQUELETTES)) {
54
+		if (!find_in_path($fond.'.'._EXTENSION_SQUELETTES)) {
55 55
 			return _L("vue $vue introuvable pour lister les objets");
56 56
 		}
57 57
 	}
Please login to merge, or discard this patch.
ecrire/inc/pipelines_ecrire.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 
94 94
 		$titre = '<title>['
95 95
 			. $nom_site_spip
96
-			. '] ' . $match
96
+			. '] '.$match
97 97
 			. '</title>';
98 98
 
99 99
 		$texte = substr_replace($texte, $titre, $p + 6, 0);
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 			$flux['data']['texte'] = pipeline(
156 156
 				'affiche_droite',
157 157
 				['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']]
158
-			) . liste_objets_bloques(
158
+			).liste_objets_bloques(
159 159
 				$exec,
160 160
 				$flux['args']['contexte']
161 161
 			);
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 				$flux['data']['texte'] = str_replace('<!--affiche_milieu-->', recuperer_fond(
191 191
 					'prive/objets/editer/traductions',
192 192
 					['objet' => $objet, 'id_objet' => $id, 'espace_prive' => 1]
193
-				) . '<!--affiche_milieu-->', $flux['data']['texte']);
193
+				).'<!--affiche_milieu-->', $flux['data']['texte']);
194 194
 				$flux['data']['texte'] = pipeline('afficher_fiche_objet', [
195 195
 					'args' => [
196 196
 						'contexte' => $flux['args']['contexte'],
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 		$full_marqueur = "$ouvrir$marqueur$fermer";
259 259
 
260 260
 		// Le marqueur est absent : on l'ajoute avant l'élément indiqué
261
-		if ($marqueur_pos  === false) {
261
+		if ($marqueur_pos === false) {
262 262
 			$texte = preg_replace(
263 263
 				",$inserer_avant,",
264 264
 				"$full_marqueur\\0",
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 		}
306 306
 	}
307 307
 	if ($res) {
308
-		$flux['data'] = $res . $flux['data'];
308
+		$flux['data'] = $res.$flux['data'];
309 309
 	}
310 310
 
311 311
 	return $flux;
Please login to merge, or discard this patch.
Indentation   +225 added lines, -225 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @package SPIP\Core\Pipelines
17 17
  **/
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 
@@ -35,36 +35,36 @@  discard block
 block discarded – undo
35 35
  * @return string          Contenu complété des scripts javascripts, dont jQuery
36 36
  **/
37 37
 function f_jQuery_prive($texte) {
38
-	$x = '';
39
-	$jquery_plugins = pipeline(
40
-		'jquery_plugins',
41
-		[
42
-			'prive/javascript/jquery.js',
43
-			'prive/javascript/jquery.form.js',
44
-			'prive/javascript/jquery.autosave.js',
45
-			'prive/javascript/jquery.placeholder-label.js',
46
-			'prive/javascript/ajaxCallback.js',
47
-			'prive/javascript/js.cookie.js',
48
-			'prive/javascript/spip_barre.js',
49
-		]
50
-	);
51
-	foreach (array_unique($jquery_plugins) as $script) {
52
-		if ($script = find_in_path(supprimer_timestamp($script))) {
53
-			$script = timestamp($script);
54
-			$x .= "\n<script src=\"$script\" type=\"text/javascript\"></script>\n";
55
-		}
56
-	}
57
-	// inserer avant le premier script externe ou a la fin
58
-	if (
59
-		preg_match(',<script[^><]*src=,', $texte, $match)
60
-		and $p = strpos($texte, (string) $match[0])
61
-	) {
62
-		$texte = substr_replace($texte, $x, $p, 0);
63
-	} else {
64
-		$texte .= $x;
65
-	}
38
+    $x = '';
39
+    $jquery_plugins = pipeline(
40
+        'jquery_plugins',
41
+        [
42
+            'prive/javascript/jquery.js',
43
+            'prive/javascript/jquery.form.js',
44
+            'prive/javascript/jquery.autosave.js',
45
+            'prive/javascript/jquery.placeholder-label.js',
46
+            'prive/javascript/ajaxCallback.js',
47
+            'prive/javascript/js.cookie.js',
48
+            'prive/javascript/spip_barre.js',
49
+        ]
50
+    );
51
+    foreach (array_unique($jquery_plugins) as $script) {
52
+        if ($script = find_in_path(supprimer_timestamp($script))) {
53
+            $script = timestamp($script);
54
+            $x .= "\n<script src=\"$script\" type=\"text/javascript\"></script>\n";
55
+        }
56
+    }
57
+    // inserer avant le premier script externe ou a la fin
58
+    if (
59
+        preg_match(',<script[^><]*src=,', $texte, $match)
60
+        and $p = strpos($texte, (string) $match[0])
61
+    ) {
62
+        $texte = substr_replace($texte, $x, $p, 0);
63
+    } else {
64
+        $texte .= $x;
65
+    }
66 66
 
67
-	return $texte;
67
+    return $texte;
68 68
 }
69 69
 
70 70
 
@@ -77,42 +77,42 @@  discard block
 block discarded – undo
77 77
  * @return string
78 78
  */
79 79
 function affichage_final_prive_title_auto($texte) {
80
-	if (
81
-		strpos($texte, '<title>') === false
82
-		and
83
-		(preg_match(',<h1[^>]*>(.+)</h1>,Uims', $texte, $match)
84
-			or preg_match(',<h[23][^>]*>(.+)</h[23]>,Uims', $texte, $match))
85
-		and $match = textebrut(trim($match[1]))
86
-		and ($p = strpos($texte, '<head>')) !== false
87
-	) {
88
-		if (!$nom_site_spip = textebrut(typo($GLOBALS['meta']['nom_site']))) {
89
-			$nom_site_spip = _T('info_mon_site_spip');
90
-		}
80
+    if (
81
+        strpos($texte, '<title>') === false
82
+        and
83
+        (preg_match(',<h1[^>]*>(.+)</h1>,Uims', $texte, $match)
84
+            or preg_match(',<h[23][^>]*>(.+)</h[23]>,Uims', $texte, $match))
85
+        and $match = textebrut(trim($match[1]))
86
+        and ($p = strpos($texte, '<head>')) !== false
87
+    ) {
88
+        if (!$nom_site_spip = textebrut(typo($GLOBALS['meta']['nom_site']))) {
89
+            $nom_site_spip = _T('info_mon_site_spip');
90
+        }
91 91
 
92
-		$titre = '<title>['
93
-			. $nom_site_spip
94
-			. '] ' . $match
95
-			. '</title>';
92
+        $titre = '<title>['
93
+            . $nom_site_spip
94
+            . '] ' . $match
95
+            . '</title>';
96 96
 
97
-		$texte = substr_replace($texte, $titre, $p + 6, 0);
98
-	}
97
+        $texte = substr_replace($texte, $titre, $p + 6, 0);
98
+    }
99 99
 
100
-	return $texte;
100
+    return $texte;
101 101
 }
102 102
 
103 103
 
104 104
 // Fonction standard pour le pipeline 'boite_infos'
105 105
 function f_boite_infos($flux) {
106
-	$args = $flux['args'];
107
-	$type = $args['type'];
108
-	unset($args['row']);
109
-	if (!trouver_fond($type, 'prive/objets/infos/')) {
110
-		$type = 'objet';
111
-	}
112
-	$args['espace_prive'] = 1;
113
-	$flux['data'] .= recuperer_fond("prive/objets/infos/$type", $args);
106
+    $args = $flux['args'];
107
+    $type = $args['type'];
108
+    unset($args['row']);
109
+    if (!trouver_fond($type, 'prive/objets/infos/')) {
110
+        $type = 'objet';
111
+    }
112
+    $args['espace_prive'] = 1;
113
+    $flux['data'] .= recuperer_fond("prive/objets/infos/$type", $args);
114 114
 
115
-	return $flux;
115
+    return $flux;
116 116
 }
117 117
 
118 118
 
@@ -131,97 +131,97 @@  discard block
 block discarded – undo
131 131
  * @return array Données du pipeline
132 132
  */
133 133
 function f_afficher_blocs_ecrire($flux) {
134
-	static $o = [];
135
-	if (is_string($fond = $flux['args']['fond'])) {
136
-		$exec = $flux['args']['contexte']['exec'] ?? _request('exec');
137
-		if (!isset($o[$exec])) {
138
-			$o[$exec] = trouver_objet_exec($exec);
139
-		}
140
-		// cas particulier
141
-		if ($exec == 'infos_perso') {
142
-			$flux['args']['contexte']['id_auteur'] = $GLOBALS['visiteur_session']['id_auteur'];
143
-		}
144
-		$typepage = ($flux['args']['contexte']['type-page'] ?? $exec);
145
-		if ($fond == "prive/squelettes/navigation/$typepage") {
146
-			$flux['data']['texte'] = pipeline(
147
-				'affiche_gauche',
148
-				['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']]
149
-			);
150
-		} elseif ($fond == "prive/squelettes/extra/$typepage") {
151
-			include_spip('inc/presentation_mini');
152
-			$flux['data']['texte'] = pipeline(
153
-				'affiche_droite',
154
-				['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']]
155
-			) . liste_objets_bloques(
156
-				$exec,
157
-				$flux['args']['contexte']
158
-			);
159
-		} elseif ($fond == "prive/squelettes/hierarchie/$typepage" and $o[$exec]) {
160
-			// id non defini sur les formulaire de nouveaux objets
161
-			$id = isset($flux['args']['contexte'][$o[$exec]['id_table_objet']]) ? intval($flux['args']['contexte'][$o[$exec]['id_table_objet']]) : 0;
162
-			$flux['data']['texte'] = pipeline(
163
-				'affiche_hierarchie',
164
-				['args' => ['objet' => $o[$exec]['type'], 'id_objet' => $id], 'data' => $flux['data']['texte']]
165
-			);
166
-		} elseif ($fond == "prive/squelettes/contenu/$typepage") {
167
-			// Préparation du marqueur affiche_milieu
168
-			// Si c'est la page d'un objet pas en édition, on l'encapsule dans un div
169
-			$est_page_objet = !empty($o[$exec]['type']);
170
-			$est_en_edition = (isset($o[$exec]['edition']) and $o[$exec]['edition'] === true);
171
-			$encapsuler_milieu = ($est_page_objet and !$est_en_edition);
172
-			$flux['data']['texte'] = afficher_blocs_ecrire_preparer_marqueur(
173
-				$flux['data']['texte'],
174
-				'<!--affiche_milieu-->',
175
-				'<div id=["\']wysiwyg',
176
-				$encapsuler_milieu ? '<div class="affiche_milieu">' : '',
177
-				$encapsuler_milieu ? '</div>' : ''
178
-			);
179
-			if (
180
-				$o[$exec]
181
-				and $objet = $o[$exec]['type']
182
-				and $o[$exec]['edition'] == false
183
-				and isset($flux['args']['contexte'][$o[$exec]['id_table_objet']])
184
-				and $id = intval($flux['args']['contexte'][$o[$exec]['id_table_objet']])
185
-			) {
186
-				// inserer le formulaire de traduction
187
-				$flux['data']['texte'] = str_replace('<!--affiche_milieu-->', recuperer_fond(
188
-					'prive/objets/editer/traductions',
189
-					['objet' => $objet, 'id_objet' => $id, 'espace_prive' => 1]
190
-				) . '<!--affiche_milieu-->', $flux['data']['texte']);
191
-				$flux['data']['texte'] = pipeline('afficher_fiche_objet', [
192
-					'args' => [
193
-						'contexte' => $flux['args']['contexte'],
194
-						'type' => $objet,
195
-						'id' => $id
196
-					],
197
-					'data' => $flux['data']['texte']
198
-				]);
199
-			}
200
-			$flux['data']['texte'] = pipeline(
201
-				'affiche_milieu',
202
-				['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']]
203
-			);
204
-		} elseif ($fond == 'prive/squelettes/inclure/pied') {
205
-			$flux['data']['texte'] = pipeline(
206
-				'affiche_pied',
207
-				['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']]
208
-			);
209
-		} elseif (
210
-			strncmp($fond, 'prive/objets/contenu/', 21) == 0
211
-			and $objet = basename($fond)
212
-			and $objet == substr($fond, 21)
213
-			and isset($o[$objet])
214
-			and $o[$objet]
215
-		) {
216
-			$id = intval($flux['args']['contexte'][$o[$exec]['id_table_objet']]);
217
-			$flux['data']['texte'] = pipeline('afficher_contenu_objet', [
218
-				'args' => ['type' => $objet, 'id_objet' => $id, 'contexte' => $flux['args']['contexte']],
219
-				'data' => $flux['data']['texte']
220
-			]);
221
-		}
222
-	}
134
+    static $o = [];
135
+    if (is_string($fond = $flux['args']['fond'])) {
136
+        $exec = $flux['args']['contexte']['exec'] ?? _request('exec');
137
+        if (!isset($o[$exec])) {
138
+            $o[$exec] = trouver_objet_exec($exec);
139
+        }
140
+        // cas particulier
141
+        if ($exec == 'infos_perso') {
142
+            $flux['args']['contexte']['id_auteur'] = $GLOBALS['visiteur_session']['id_auteur'];
143
+        }
144
+        $typepage = ($flux['args']['contexte']['type-page'] ?? $exec);
145
+        if ($fond == "prive/squelettes/navigation/$typepage") {
146
+            $flux['data']['texte'] = pipeline(
147
+                'affiche_gauche',
148
+                ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']]
149
+            );
150
+        } elseif ($fond == "prive/squelettes/extra/$typepage") {
151
+            include_spip('inc/presentation_mini');
152
+            $flux['data']['texte'] = pipeline(
153
+                'affiche_droite',
154
+                ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']]
155
+            ) . liste_objets_bloques(
156
+                $exec,
157
+                $flux['args']['contexte']
158
+            );
159
+        } elseif ($fond == "prive/squelettes/hierarchie/$typepage" and $o[$exec]) {
160
+            // id non defini sur les formulaire de nouveaux objets
161
+            $id = isset($flux['args']['contexte'][$o[$exec]['id_table_objet']]) ? intval($flux['args']['contexte'][$o[$exec]['id_table_objet']]) : 0;
162
+            $flux['data']['texte'] = pipeline(
163
+                'affiche_hierarchie',
164
+                ['args' => ['objet' => $o[$exec]['type'], 'id_objet' => $id], 'data' => $flux['data']['texte']]
165
+            );
166
+        } elseif ($fond == "prive/squelettes/contenu/$typepage") {
167
+            // Préparation du marqueur affiche_milieu
168
+            // Si c'est la page d'un objet pas en édition, on l'encapsule dans un div
169
+            $est_page_objet = !empty($o[$exec]['type']);
170
+            $est_en_edition = (isset($o[$exec]['edition']) and $o[$exec]['edition'] === true);
171
+            $encapsuler_milieu = ($est_page_objet and !$est_en_edition);
172
+            $flux['data']['texte'] = afficher_blocs_ecrire_preparer_marqueur(
173
+                $flux['data']['texte'],
174
+                '<!--affiche_milieu-->',
175
+                '<div id=["\']wysiwyg',
176
+                $encapsuler_milieu ? '<div class="affiche_milieu">' : '',
177
+                $encapsuler_milieu ? '</div>' : ''
178
+            );
179
+            if (
180
+                $o[$exec]
181
+                and $objet = $o[$exec]['type']
182
+                and $o[$exec]['edition'] == false
183
+                and isset($flux['args']['contexte'][$o[$exec]['id_table_objet']])
184
+                and $id = intval($flux['args']['contexte'][$o[$exec]['id_table_objet']])
185
+            ) {
186
+                // inserer le formulaire de traduction
187
+                $flux['data']['texte'] = str_replace('<!--affiche_milieu-->', recuperer_fond(
188
+                    'prive/objets/editer/traductions',
189
+                    ['objet' => $objet, 'id_objet' => $id, 'espace_prive' => 1]
190
+                ) . '<!--affiche_milieu-->', $flux['data']['texte']);
191
+                $flux['data']['texte'] = pipeline('afficher_fiche_objet', [
192
+                    'args' => [
193
+                        'contexte' => $flux['args']['contexte'],
194
+                        'type' => $objet,
195
+                        'id' => $id
196
+                    ],
197
+                    'data' => $flux['data']['texte']
198
+                ]);
199
+            }
200
+            $flux['data']['texte'] = pipeline(
201
+                'affiche_milieu',
202
+                ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']]
203
+            );
204
+        } elseif ($fond == 'prive/squelettes/inclure/pied') {
205
+            $flux['data']['texte'] = pipeline(
206
+                'affiche_pied',
207
+                ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']]
208
+            );
209
+        } elseif (
210
+            strncmp($fond, 'prive/objets/contenu/', 21) == 0
211
+            and $objet = basename($fond)
212
+            and $objet == substr($fond, 21)
213
+            and isset($o[$objet])
214
+            and $o[$objet]
215
+        ) {
216
+            $id = intval($flux['args']['contexte'][$o[$exec]['id_table_objet']]);
217
+            $flux['data']['texte'] = pipeline('afficher_contenu_objet', [
218
+                'args' => ['type' => $objet, 'id_objet' => $id, 'contexte' => $flux['args']['contexte']],
219
+                'data' => $flux['data']['texte']
220
+            ]);
221
+        }
222
+    }
223 223
 
224
-	return $flux;
224
+    return $flux;
225 225
 }
226 226
 
227 227
 /**
@@ -249,36 +249,36 @@  discard block
 block discarded – undo
249 249
  */
250 250
 function afficher_blocs_ecrire_preparer_marqueur(?string $texte, string $marqueur, string $inserer_avant, string $ouvrir = '', string $fermer = ''): ?string {
251 251
 
252
-	if ($texte) {
253
-		$encapsuler = (($ouvrir and $fermer) ? true : false);
254
-		$marqueur_pos = strpos($texte, $marqueur);
255
-		$full_marqueur = "$ouvrir$marqueur$fermer";
252
+    if ($texte) {
253
+        $encapsuler = (($ouvrir and $fermer) ? true : false);
254
+        $marqueur_pos = strpos($texte, $marqueur);
255
+        $full_marqueur = "$ouvrir$marqueur$fermer";
256 256
 
257
-		// Le marqueur est absent : on l'ajoute avant l'élément indiqué
258
-		if ($marqueur_pos  === false) {
259
-			$texte = preg_replace(
260
-				",$inserer_avant,",
261
-				"$full_marqueur\\0",
262
-				$texte
263
-			);
264
-		// Le marqueur est présent mais pas encapsulé : on ajoute les balises ouvrantes et fermantes.
265
-		// Pour vérifier, on prend le texte précédent et on regarde si ça correspond à la balise ouvrante.
266
-		// Il ne faut donc aucun espace blanc en trop.
267
-		} elseif (
268
-			$marqueur_pos !== false
269
-			and $encapsuler
270
-			and substr($texte, $marqueur_pos - strlen($ouvrir), strlen($ouvrir)) !== $ouvrir
271
-		) {
272
-			$texte = substr_replace(
273
-				$texte,
274
-				$full_marqueur,
275
-				$marqueur_pos,
276
-				strlen($marqueur)
277
-			);
278
-		}
279
-	}
257
+        // Le marqueur est absent : on l'ajoute avant l'élément indiqué
258
+        if ($marqueur_pos  === false) {
259
+            $texte = preg_replace(
260
+                ",$inserer_avant,",
261
+                "$full_marqueur\\0",
262
+                $texte
263
+            );
264
+        // Le marqueur est présent mais pas encapsulé : on ajoute les balises ouvrantes et fermantes.
265
+        // Pour vérifier, on prend le texte précédent et on regarde si ça correspond à la balise ouvrante.
266
+        // Il ne faut donc aucun espace blanc en trop.
267
+        } elseif (
268
+            $marqueur_pos !== false
269
+            and $encapsuler
270
+            and substr($texte, $marqueur_pos - strlen($ouvrir), strlen($ouvrir)) !== $ouvrir
271
+        ) {
272
+            $texte = substr_replace(
273
+                $texte,
274
+                $full_marqueur,
275
+                $marqueur_pos,
276
+                strlen($marqueur)
277
+            );
278
+        }
279
+    }
280 280
 
281
-	return $texte;
281
+    return $texte;
282 282
 }
283 283
 
284 284
 /**
@@ -289,23 +289,23 @@  discard block
 block discarded – undo
289 289
  * @return string
290 290
  */
291 291
 function f_queue_affiche_milieu($flux) {
292
-	$args = $flux['args'];
293
-	$res = '';
294
-	foreach ($args as $key => $arg) {
295
-		if (preg_match(',^id_,', $key) and is_numeric($arg) and $arg = intval($arg)) {
296
-			$objet = preg_replace(',^id_,', '', $key);
297
-			$res .= recuperer_fond(
298
-				'modeles/object_jobs_list',
299
-				['id_objet' => $arg, 'objet' => $objet, 'espace_prive' => 1],
300
-				['ajax' => true]
301
-			);
302
-		}
303
-	}
304
-	if ($res) {
305
-		$flux['data'] = $res . $flux['data'];
306
-	}
292
+    $args = $flux['args'];
293
+    $res = '';
294
+    foreach ($args as $key => $arg) {
295
+        if (preg_match(',^id_,', $key) and is_numeric($arg) and $arg = intval($arg)) {
296
+            $objet = preg_replace(',^id_,', '', $key);
297
+            $res .= recuperer_fond(
298
+                'modeles/object_jobs_list',
299
+                ['id_objet' => $arg, 'objet' => $objet, 'espace_prive' => 1],
300
+                ['ajax' => true]
301
+            );
302
+        }
303
+    }
304
+    if ($res) {
305
+        $flux['data'] = $res . $flux['data'];
306
+    }
307 307
 
308
-	return $flux;
308
+    return $flux;
309 309
 }
310 310
 
311 311
 /**
@@ -319,39 +319,39 @@  discard block
 block discarded – undo
319 319
  * @return array|bool
320 320
  */
321 321
 function trouver_objet_exec(?string $exec) {
322
-	static $objet_exec = [];
323
-	if (!$exec) {
324
-		return false;
325
-	}
326
-	// cas particulier
327
-	if ($exec === 'infos_perso') {
328
-		$exec = 'auteur';
329
-		set_request('id_auteur', $GLOBALS['visiteur_session']['id_auteur']);
330
-	}
331
-	if (!isset($objet_exec[$exec])) {
332
-		$objet_exec[$exec] = false;
333
-		$infos = lister_tables_objets_sql();
334
-		foreach ($infos as $t => $info) {
335
-			if ($exec === $info['url_edit'] and $info['editable']) {
336
-				return $objet_exec[$exec] = [
337
-					'edition' => $exec == $info['url_voir'] ? '' : true,
338
-					'table_objet_sql' => $t,
339
-					'table' => $info['table_objet'],
340
-					'type' => $info['type'],
341
-					'id_table_objet' => id_table_objet($info['type'])
342
-				];
343
-			}
344
-			if ($exec === $info['url_voir']) {
345
-				return $objet_exec[$exec] = [
346
-					'edition' => false,
347
-					'table_objet_sql' => $t,
348
-					'table' => $info['table_objet'],
349
-					'type' => $info['type'],
350
-					'id_table_objet' => id_table_objet($info['type'])
351
-				];
352
-			}
353
-		}
354
-	}
322
+    static $objet_exec = [];
323
+    if (!$exec) {
324
+        return false;
325
+    }
326
+    // cas particulier
327
+    if ($exec === 'infos_perso') {
328
+        $exec = 'auteur';
329
+        set_request('id_auteur', $GLOBALS['visiteur_session']['id_auteur']);
330
+    }
331
+    if (!isset($objet_exec[$exec])) {
332
+        $objet_exec[$exec] = false;
333
+        $infos = lister_tables_objets_sql();
334
+        foreach ($infos as $t => $info) {
335
+            if ($exec === $info['url_edit'] and $info['editable']) {
336
+                return $objet_exec[$exec] = [
337
+                    'edition' => $exec == $info['url_voir'] ? '' : true,
338
+                    'table_objet_sql' => $t,
339
+                    'table' => $info['table_objet'],
340
+                    'type' => $info['type'],
341
+                    'id_table_objet' => id_table_objet($info['type'])
342
+                ];
343
+            }
344
+            if ($exec === $info['url_voir']) {
345
+                return $objet_exec[$exec] = [
346
+                    'edition' => false,
347
+                    'table_objet_sql' => $t,
348
+                    'table' => $info['table_objet'],
349
+                    'type' => $info['type'],
350
+                    'id_table_objet' => id_table_objet($info['type'])
351
+                ];
352
+            }
353
+        }
354
+    }
355 355
 
356
-	return $objet_exec[$exec];
356
+    return $objet_exec[$exec];
357 357
 }
Please login to merge, or discard this patch.
ecrire/inc/informer.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	include_spip('inc/texte');
22 22
 	$titre = $descriptif = '';
23 23
 	if ($type == 'rubrique') {
24
-		$row = sql_fetsel('titre, descriptif', 'spip_rubriques', 'id_rubrique = ' . intval($id));
24
+		$row = sql_fetsel('titre, descriptif', 'spip_rubriques', 'id_rubrique = '.intval($id));
25 25
 		if ($row) {
26 26
 			$titre = typo($row['titre']);
27 27
 			$descriptif = propre($row['descriptif']);
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 				include_spip('inc/filtres_images_mini');
40 40
 				$res = image_reduire("<img src='$fid' alt='' />", 100, 48);
41 41
 				if ($res) {
42
-					$res = "<div class='informer__media' style='float: " . $GLOBALS['spip_lang_right'] . '; margin-' . $GLOBALS['spip_lang_right'] . ": -5px; margin-top: -5px;'>$res</div>";
42
+					$res = "<div class='informer__media' style='float: ".$GLOBALS['spip_lang_right'].'; margin-'.$GLOBALS['spip_lang_right'].": -5px; margin-top: -5px;'>$res</div>";
43 43
 				}
44 44
 			}
45 45
 		}
@@ -61,21 +61,21 @@  discard block
 block discarded – undo
61 61
 		'  '
62 62
 	);
63 63
 
64
-	$js_func = $do . '_selection_titre';
64
+	$js_func = $do.'_selection_titre';
65 65
 
66 66
 	return "<div style='display: none;'>"
67
-	. "<input type='text' id='" . $rac . "_sel' value='$id' />"
68
-	. "<input type='text' id='" . $rac . "_sel2' value=\""
67
+	. "<input type='text' id='".$rac."_sel' value='$id' />"
68
+	. "<input type='text' id='".$rac."_sel2' value=\""
69 69
 	. entites_html($titre)
70 70
 	. '" />'
71 71
 	. '</div>'
72 72
 	. "<div class='informer' style='padding: 5px; border-top: 0px;'>"
73 73
 	. '<div class="informer__item">'
74 74
 	. (!$res ? '' : $res)
75
-	. "<p class='informer__titre'><b>" . safehtml($titre) . '</b></p>'
76
-	. (!$descriptif ? '' : "<div class='informer__descriptif'>" . safehtml($descriptif) . '</div>')
75
+	. "<p class='informer__titre'><b>".safehtml($titre).'</b></p>'
76
+	. (!$descriptif ? '' : "<div class='informer__descriptif'>".safehtml($descriptif).'</div>')
77 77
 	. '</div>'
78
-	. "<div class='informer__action' style='clear:both; text-align: " . $GLOBALS['spip_lang_right'] . ";'>"
78
+	. "<div class='informer__action' style='clear:both; text-align: ".$GLOBALS['spip_lang_right'].";'>"
79 79
 	. "<input type='submit' class='fondo btn submit' value='"
80 80
 	. _T('bouton_choisir')
81 81
 	. "'\nonclick=\"$js_func('$titre',$id,'selection_rubrique','id_parent'); return false;\" />"
Please login to merge, or discard this patch.
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -11,73 +11,73 @@
 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 information d'une rubrique selectionnee dans le mini navigateur
18 18
 
19 19
 function inc_informer_dist($id, $col, $exclus, $rac, $type, $do = 'aff') {
20
-	include_spip('inc/texte');
21
-	$titre = $descriptif = '';
22
-	if ($type == 'rubrique') {
23
-		$row = sql_fetsel('titre, descriptif', 'spip_rubriques', 'id_rubrique = ' . intval($id));
24
-		if ($row) {
25
-			$titre = typo($row['titre']);
26
-			$descriptif = propre($row['descriptif']);
27
-		} else {
28
-			$titre = _T('info_racine_site');
29
-		}
30
-	}
20
+    include_spip('inc/texte');
21
+    $titre = $descriptif = '';
22
+    if ($type == 'rubrique') {
23
+        $row = sql_fetsel('titre, descriptif', 'spip_rubriques', 'id_rubrique = ' . intval($id));
24
+        if ($row) {
25
+            $titre = typo($row['titre']);
26
+            $descriptif = propre($row['descriptif']);
27
+        } else {
28
+            $titre = _T('info_racine_site');
29
+        }
30
+    }
31 31
 
32
-	$res = '';
33
-	if ($type == 'rubrique' and $GLOBALS['spip_display'] != 1 and isset($GLOBALS['meta']['image_process'])) {
34
-		if ($GLOBALS['meta']['image_process'] != 'non') {
35
-			$chercher_logo = charger_fonction('chercher_logo', 'inc');
36
-			if ($res = $chercher_logo($id, 'id_rubrique', 'on')) {
37
-				[$fid, $dir, $nom, $format] = $res;
38
-				include_spip('inc/filtres_images_mini');
39
-				$res = image_reduire("<img src='$fid' alt='' />", 100, 48);
40
-				if ($res) {
41
-					$res = "<div class='informer__media' style='float: " . $GLOBALS['spip_lang_right'] . '; margin-' . $GLOBALS['spip_lang_right'] . ": -5px; margin-top: -5px;'>$res</div>";
42
-				}
43
-			}
44
-		}
45
-	}
32
+    $res = '';
33
+    if ($type == 'rubrique' and $GLOBALS['spip_display'] != 1 and isset($GLOBALS['meta']['image_process'])) {
34
+        if ($GLOBALS['meta']['image_process'] != 'non') {
35
+            $chercher_logo = charger_fonction('chercher_logo', 'inc');
36
+            if ($res = $chercher_logo($id, 'id_rubrique', 'on')) {
37
+                [$fid, $dir, $nom, $format] = $res;
38
+                include_spip('inc/filtres_images_mini');
39
+                $res = image_reduire("<img src='$fid' alt='' />", 100, 48);
40
+                if ($res) {
41
+                    $res = "<div class='informer__media' style='float: " . $GLOBALS['spip_lang_right'] . '; margin-' . $GLOBALS['spip_lang_right'] . ": -5px; margin-top: -5px;'>$res</div>";
42
+                }
43
+            }
44
+        }
45
+    }
46 46
 
47
-	$rac = spip_htmlentities($rac, ENT_QUOTES);
48
-	$do = spip_htmlentities($do, ENT_QUOTES);
49
-	$id = intval($id);
47
+    $rac = spip_htmlentities($rac, ENT_QUOTES);
48
+    $do = spip_htmlentities($do, ENT_QUOTES);
49
+    $id = intval($id);
50 50
 
51 51
 # ce lien provoque la selection (directe) de la rubrique cliquee
52 52
 # et l'affichage de son titre dans le bandeau
53
-	$titre = strtr(
54
-		str_replace(
55
-			"'",
56
-			'&#8217;',
57
-			str_replace('"', '&#34;', textebrut($titre))
58
-		),
59
-		"\n\r",
60
-		'  '
61
-	);
53
+    $titre = strtr(
54
+        str_replace(
55
+            "'",
56
+            '&#8217;',
57
+            str_replace('"', '&#34;', textebrut($titre))
58
+        ),
59
+        "\n\r",
60
+        '  '
61
+    );
62 62
 
63
-	$js_func = $do . '_selection_titre';
63
+    $js_func = $do . '_selection_titre';
64 64
 
65
-	return "<div style='display: none;'>"
66
-	. "<input type='text' id='" . $rac . "_sel' value='$id' />"
67
-	. "<input type='text' id='" . $rac . "_sel2' value=\""
68
-	. entites_html($titre)
69
-	. '" />'
70
-	. '</div>'
71
-	. "<div class='informer' style='padding: 5px; border-top: 0px;'>"
72
-	. '<div class="informer__item">'
73
-	. (!$res ? '' : $res)
74
-	. "<p class='informer__titre'><b>" . safehtml($titre) . '</b></p>'
75
-	. (!$descriptif ? '' : "<div class='informer__descriptif'>" . safehtml($descriptif) . '</div>')
76
-	. '</div>'
77
-	. "<div class='informer__action' style='clear:both; text-align: " . $GLOBALS['spip_lang_right'] . ";'>"
78
-	. "<input type='submit' class='fondo btn submit' value='"
79
-	. _T('bouton_choisir')
80
-	. "'\nonclick=\"$js_func('$titre',$id,'selection_rubrique','id_parent'); return false;\" />"
81
-	. '</div>'
82
-	. '</div>';
65
+    return "<div style='display: none;'>"
66
+    . "<input type='text' id='" . $rac . "_sel' value='$id' />"
67
+    . "<input type='text' id='" . $rac . "_sel2' value=\""
68
+    . entites_html($titre)
69
+    . '" />'
70
+    . '</div>'
71
+    . "<div class='informer' style='padding: 5px; border-top: 0px;'>"
72
+    . '<div class="informer__item">'
73
+    . (!$res ? '' : $res)
74
+    . "<p class='informer__titre'><b>" . safehtml($titre) . '</b></p>'
75
+    . (!$descriptif ? '' : "<div class='informer__descriptif'>" . safehtml($descriptif) . '</div>')
76
+    . '</div>'
77
+    . "<div class='informer__action' style='clear:both; text-align: " . $GLOBALS['spip_lang_right'] . ";'>"
78
+    . "<input type='submit' class='fondo btn submit' value='"
79
+    . _T('bouton_choisir')
80
+    . "'\nonclick=\"$js_func('$titre',$id,'selection_rubrique','id_parent'); return false;\" />"
81
+    . '</div>'
82
+    . '</div>';
83 83
 }
Please login to merge, or discard this patch.