Completed
Push — master ( 9ef159...478ba3 )
by cam
01:13
created
ecrire/inc/plonger.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
 	$res = sql_select(
36 36
 		'rub1.id_rubrique, rub1.titre, rub1.id_parent, rub1.lang, rub1.langue_choisie, rub2.id_rubrique AS id_enfant',
37 37
 		'spip_rubriques AS rub1 LEFT JOIN spip_rubriques AS rub2 ON (rub1.id_rubrique = rub2.id_parent)',
38
-		'rub1.id_parent = ' . sql_quote($id_rubrique) . '
39
-			AND rub1.id_rubrique!=' . sql_quote($exclu) . '
40
-			AND (rub2.id_rubrique IS NULL OR rub2.id_rubrique!=' . sql_quote($exclu) . ')',
38
+		'rub1.id_parent = '.sql_quote($id_rubrique).'
39
+			AND rub1.id_rubrique!=' . sql_quote($exclu).'
40
+			AND (rub2.id_rubrique IS NULL OR rub2.id_rubrique!=' . sql_quote($exclu).')',
41 41
 		'',
42 42
 		'0+rub1.titre,rub1.titre'
43 43
 	);
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 				if ($row['langue_choisie'] != 'oui') {
51 51
 					$t .= ' <small title="'
52 52
 						. traduire_nom_langue($row['lang'])
53
-						. '">[' . $row['lang'] . ']</small>';
53
+						. '">['.$row['lang'].']</small>';
54 54
 				}
55 55
 				$ordre[$row['id_rubrique']] = $t;
56 56
 			}
@@ -58,14 +58,14 @@  discard block
 block discarded – undo
58 58
 	}
59 59
 	$next = $list[$col] ?? 0;
60 60
 	if ($ordre) {
61
-		$rec = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclu&do=$do&col=" . ($col + 1));
61
+		$rec = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclu&do=$do&col=".($col + 1));
62 62
 		$info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id=");
63
-		$args = "'$idom',this,$col,'" . $GLOBALS['spip_lang_left'] . "','$info',event";
63
+		$args = "'$idom',this,$col,'".$GLOBALS['spip_lang_left']."','$info',event";
64 64
 
65 65
 		foreach ($ordre as $id => $titrebrut) {
66 66
 			$titre = supprimer_numero($titrebrut);
67 67
 
68
-			$classe1 = 'petit-item ' . ($id_rubrique ? 'petite-rubrique' : 'petit-secteur');
68
+			$classe1 = 'petit-item '.($id_rubrique ? 'petite-rubrique' : 'petit-secteur');
69 69
 			if (isset($rub[$id]['enfants'])) {
70 70
 				$classe2 = " class='rub-ouverte'";
71 71
 				$url = "\nhref='$rec&amp;id=$id'";
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 				$url = "\nhref='javascript:void(0)'";
75 75
 			}
76 76
 
77
-			$js_func = $do . '_selection_titre';
77
+			$js_func = $do.'_selection_titre';
78 78
 			$click = "\nonclick=\"changerhighlight(this.parentNode.parentNode.parentNode);\nreturn "
79 79
 				. (!is_array($list) ? ' false'
80 80
 					: "aff_selection_provisoire($id,$args)")
@@ -101,17 +101,17 @@  discard block
 block discarded – undo
101 101
 		}
102 102
 	}
103 103
 
104
-	$idom2 = $idom . '_col_' . ($col + 1);
104
+	$idom2 = $idom.'_col_'.($col + 1);
105 105
 	$left = ($col * 250);
106 106
 
107 107
 	return http_img_pack(
108 108
 		'loader.svg',
109 109
 		'',
110
-		"class='loader' style='visibility: hidden; position: absolute; " . $GLOBALS['spip_lang_left'] . ': '
110
+		"class='loader' style='visibility: hidden; position: absolute; ".$GLOBALS['spip_lang_left'].': '
111 111
 		. ($left - 30)
112 112
 		. "px; top: 2px; z-index: 2;' id='img_$idom2'"
113 113
 	)
114
-	. "<div style='width: 250px; height: 100%; overflow: auto; position: absolute; top: 0px; " . $GLOBALS['spip_lang_left'] . ': '
114
+	. "<div style='width: 250px; height: 100%; overflow: auto; position: absolute; top: 0px; ".$GLOBALS['spip_lang_left'].': '
115 115
 	. ($left - 250)
116 116
 	. "px;'>"
117 117
 	. $ret
Please login to merge, or discard this patch.
Indentation   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -11,112 +11,112 @@
 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/texte');
18 18
 
19 19
 function inc_plonger_dist($id_rubrique, $idom = '', $list = [], $col = 1, $exclu = 0, $do = 'aff') {
20 20
 
21
-	if ($list) {
22
-		$id_rubrique = $list[$col - 1];
23
-	}
21
+    if ($list) {
22
+        $id_rubrique = $list[$col - 1];
23
+    }
24 24
 
25
-	$ret = '';
25
+    $ret = '';
26 26
 
27
-	# recherche les filles et petites-filles de la rubrique donnee
28
-	# en excluant une eventuelle rubrique interdite (par exemple, lorsqu'on
29
-	# deplace une rubrique, on peut la deplacer partout a partir de la
30
-	# racine... sauf vers elle-meme ou sa propre branche)
31
-	$ordre = [];
32
-	$rub = [];
27
+    # recherche les filles et petites-filles de la rubrique donnee
28
+    # en excluant une eventuelle rubrique interdite (par exemple, lorsqu'on
29
+    # deplace une rubrique, on peut la deplacer partout a partir de la
30
+    # racine... sauf vers elle-meme ou sa propre branche)
31
+    $ordre = [];
32
+    $rub = [];
33 33
 
34
-	$res = sql_select(
35
-		'rub1.id_rubrique, rub1.titre, rub1.id_parent, rub1.lang, rub1.langue_choisie, rub2.id_rubrique AS id_enfant',
36
-		'spip_rubriques AS rub1 LEFT JOIN spip_rubriques AS rub2 ON (rub1.id_rubrique = rub2.id_parent)',
37
-		'rub1.id_parent = ' . sql_quote($id_rubrique) . '
34
+    $res = sql_select(
35
+        'rub1.id_rubrique, rub1.titre, rub1.id_parent, rub1.lang, rub1.langue_choisie, rub2.id_rubrique AS id_enfant',
36
+        'spip_rubriques AS rub1 LEFT JOIN spip_rubriques AS rub2 ON (rub1.id_rubrique = rub2.id_parent)',
37
+        'rub1.id_parent = ' . sql_quote($id_rubrique) . '
38 38
 			AND rub1.id_rubrique!=' . sql_quote($exclu) . '
39 39
 			AND (rub2.id_rubrique IS NULL OR rub2.id_rubrique!=' . sql_quote($exclu) . ')',
40
-		'',
41
-		'0+rub1.titre,rub1.titre'
42
-	);
40
+        '',
41
+        '0+rub1.titre,rub1.titre'
42
+    );
43 43
 
44
-	while ($row = sql_fetch($res)) {
45
-		if (autoriser('voir', 'rubrique', $row['id_rubrique'])) {
46
-			$rub[$row['id_rubrique']]['enfants'] = $row['id_enfant'];
47
-			if ($row['id_parent'] == $id_rubrique) {
48
-				$t = trim(typo(supprimer_numero($row['titre'])));
49
-				if ($row['langue_choisie'] != 'oui') {
50
-					$t .= ' <small title="'
51
-						. traduire_nom_langue($row['lang'])
52
-						. '">[' . $row['lang'] . ']</small>';
53
-				}
54
-				$ordre[$row['id_rubrique']] = $t;
55
-			}
56
-		}
57
-	}
58
-	$next = $list[$col] ?? 0;
59
-	if ($ordre) {
60
-		$rec = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclu&do=$do&col=" . ($col + 1));
61
-		$info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id=");
62
-		$args = "'$idom',this,$col,'" . $GLOBALS['spip_lang_left'] . "','$info',event";
44
+    while ($row = sql_fetch($res)) {
45
+        if (autoriser('voir', 'rubrique', $row['id_rubrique'])) {
46
+            $rub[$row['id_rubrique']]['enfants'] = $row['id_enfant'];
47
+            if ($row['id_parent'] == $id_rubrique) {
48
+                $t = trim(typo(supprimer_numero($row['titre'])));
49
+                if ($row['langue_choisie'] != 'oui') {
50
+                    $t .= ' <small title="'
51
+                        . traduire_nom_langue($row['lang'])
52
+                        . '">[' . $row['lang'] . ']</small>';
53
+                }
54
+                $ordre[$row['id_rubrique']] = $t;
55
+            }
56
+        }
57
+    }
58
+    $next = $list[$col] ?? 0;
59
+    if ($ordre) {
60
+        $rec = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclu&do=$do&col=" . ($col + 1));
61
+        $info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id=");
62
+        $args = "'$idom',this,$col,'" . $GLOBALS['spip_lang_left'] . "','$info',event";
63 63
 
64
-		foreach ($ordre as $id => $titrebrut) {
65
-			$titre = supprimer_numero($titrebrut);
64
+        foreach ($ordre as $id => $titrebrut) {
65
+            $titre = supprimer_numero($titrebrut);
66 66
 
67
-			$classe1 = 'petit-item ' . ($id_rubrique ? 'petite-rubrique' : 'petit-secteur');
68
-			if (isset($rub[$id]['enfants'])) {
69
-				$classe2 = " class='rub-ouverte'";
70
-				$url = "\nhref='$rec&amp;id=$id'";
71
-			} else {
72
-				$classe2 = $url = '';
73
-				$url = "\nhref='javascript:void(0)'";
74
-			}
67
+            $classe1 = 'petit-item ' . ($id_rubrique ? 'petite-rubrique' : 'petit-secteur');
68
+            if (isset($rub[$id]['enfants'])) {
69
+                $classe2 = " class='rub-ouverte'";
70
+                $url = "\nhref='$rec&amp;id=$id'";
71
+            } else {
72
+                $classe2 = $url = '';
73
+                $url = "\nhref='javascript:void(0)'";
74
+            }
75 75
 
76
-			$js_func = $do . '_selection_titre';
77
-			$click = "\nonclick=\"changerhighlight(this.parentNode.parentNode.parentNode);\nreturn "
78
-				. (!is_array($list) ? ' false'
79
-					: "aff_selection_provisoire($id,$args)")
76
+            $js_func = $do . '_selection_titre';
77
+            $click = "\nonclick=\"changerhighlight(this.parentNode.parentNode.parentNode);\nreturn "
78
+                . (!is_array($list) ? ' false'
79
+                    : "aff_selection_provisoire($id,$args)")
80 80
 # ce lien provoque la selection (directe) de la rubrique cliquee
81 81
 # et l'affichage de son titre dans le bandeau
82
-				. "\"\nondblclick=\""
83
-				. "$js_func(this."
84
-				. 'firstChild.nodeValue,'
85
-				. $id
86
-				. ",'selection_rubrique','id_parent');"
87
-				. "\nreturn aff_selection_provisoire($id,$args);"
88
-				. '"';
82
+                . "\"\nondblclick=\""
83
+                . "$js_func(this."
84
+                . 'firstChild.nodeValue,'
85
+                . $id
86
+                . ",'selection_rubrique','id_parent');"
87
+                . "\nreturn aff_selection_provisoire($id,$args);"
88
+                . '"';
89 89
 
90
-			$ret .= "<div class='"
91
-				. (($id == $next) ? 'item on' : 'item')
92
-				. "'><div class='"
93
-				. $classe1
94
-				. "'><div$classe2><a"
95
-				. $url
96
-				. $click
97
-				. '>'
98
-				. $titre
99
-				. '</a></div></div></div>';
100
-		}
101
-	}
90
+            $ret .= "<div class='"
91
+                . (($id == $next) ? 'item on' : 'item')
92
+                . "'><div class='"
93
+                . $classe1
94
+                . "'><div$classe2><a"
95
+                . $url
96
+                . $click
97
+                . '>'
98
+                . $titre
99
+                . '</a></div></div></div>';
100
+        }
101
+    }
102 102
 
103
-	$idom2 = $idom . '_col_' . ($col + 1);
104
-	$left = ($col * 250);
103
+    $idom2 = $idom . '_col_' . ($col + 1);
104
+    $left = ($col * 250);
105 105
 
106
-	return http_img_pack(
107
-		'loader.svg',
108
-		'',
109
-		"class='loader' style='visibility: hidden; position: absolute; " . $GLOBALS['spip_lang_left'] . ': '
110
-		. ($left - 30)
111
-		. "px; top: 2px; z-index: 2;' id='img_$idom2'"
112
-	)
113
-	. "<div style='width: 250px; height: 100%; overflow: auto; position: absolute; top: 0px; " . $GLOBALS['spip_lang_left'] . ': '
114
-	. ($left - 250)
115
-	. "px;'>"
116
-	. $ret
117
-	. "\n</div>\n<div id='$idom2'>"
118
-	. ($next
119
-		? inc_plonger_dist($id_rubrique, $idom, $list, $col + 1, $exclu)
120
-		: '')
121
-	. "\n</div>";
106
+    return http_img_pack(
107
+        'loader.svg',
108
+        '',
109
+        "class='loader' style='visibility: hidden; position: absolute; " . $GLOBALS['spip_lang_left'] . ': '
110
+        . ($left - 30)
111
+        . "px; top: 2px; z-index: 2;' id='img_$idom2'"
112
+    )
113
+    . "<div style='width: 250px; height: 100%; overflow: auto; position: absolute; top: 0px; " . $GLOBALS['spip_lang_left'] . ': '
114
+    . ($left - 250)
115
+    . "px;'>"
116
+    . $ret
117
+    . "\n</div>\n<div id='$idom2'>"
118
+    . ($next
119
+        ? inc_plonger_dist($id_rubrique, $idom, $list, $col + 1, $exclu)
120
+        : '')
121
+    . "\n</div>";
122 122
 }
Please login to merge, or discard this patch.
ecrire/inc/texte.php 2 patches
Indentation   +227 added lines, -227 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/texte_mini');
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
  * @return array Tablea ('','')
35 35
  */
36 36
 function definir_raccourcis_alineas() {
37
-	return ['', ''];
37
+    return ['', ''];
38 38
 }
39 39
 
40 40
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
  * @return string
48 48
  */
49 49
 function traiter_tableau($bloc) {
50
-	return $bloc;
50
+    return $bloc;
51 51
 }
52 52
 
53 53
 
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
  * @return string
62 62
  */
63 63
 function traiter_listes($texte) {
64
-	return $texte;
64
+    return $texte;
65 65
 }
66 66
 
67 67
 /**
@@ -77,16 +77,16 @@  discard block
 block discarded – undo
77 77
  */
78 78
 function traiter_raccourcis($letexte) {
79 79
 
80
-	// Appeler les fonctions de pre_traitement
81
-	$letexte = pipeline('pre_propre', $letexte);
80
+    // Appeler les fonctions de pre_traitement
81
+    $letexte = pipeline('pre_propre', $letexte);
82 82
 
83
-	// APPELER ICI UN PIPELINE traiter_raccourcis ?
84
-	// $letexte = pipeline('traiter_raccourcis', $letexte);
83
+    // APPELER ICI UN PIPELINE traiter_raccourcis ?
84
+    // $letexte = pipeline('traiter_raccourcis', $letexte);
85 85
 
86
-	// Appeler les fonctions de post-traitement
87
-	$letexte = pipeline('post_propre', $letexte);
86
+    // Appeler les fonctions de post-traitement
87
+    $letexte = pipeline('post_propre', $letexte);
88 88
 
89
-	return $letexte;
89
+    return $letexte;
90 90
 }
91 91
 
92 92
 /*************************************************************************************************************************
@@ -102,22 +102,22 @@  discard block
 block discarded – undo
102 102
  * @return string
103 103
  */
104 104
 function echappe_js($t, $class = ' class = "echappe-js"') {
105
-	foreach (['script', 'iframe'] as $tag) {
106
-		if (
107
-			stripos($t, (string) "<$tag") !== false
108
-			and preg_match_all(',<' . $tag . '.*?($|</' . $tag . '.),isS', $t, $r, PREG_SET_ORDER)
109
-		) {
110
-			foreach ($r as $regs) {
111
-				$t = str_replace(
112
-					$regs[0],
113
-					"<code$class>" . nl2br(spip_htmlspecialchars($regs[0])) . '</code>',
114
-					$t
115
-				);
116
-			}
117
-		}
118
-	}
119
-
120
-	return $t;
105
+    foreach (['script', 'iframe'] as $tag) {
106
+        if (
107
+            stripos($t, (string) "<$tag") !== false
108
+            and preg_match_all(',<' . $tag . '.*?($|</' . $tag . '.),isS', $t, $r, PREG_SET_ORDER)
109
+        ) {
110
+            foreach ($r as $regs) {
111
+                $t = str_replace(
112
+                    $regs[0],
113
+                    "<code$class>" . nl2br(spip_htmlspecialchars($regs[0])) . '</code>',
114
+                    $t
115
+                );
116
+            }
117
+        }
118
+    }
119
+
120
+    return $t;
121 121
 }
122 122
 
123 123
 
@@ -146,55 +146,55 @@  discard block
 block discarded – undo
146 146
  *     Code protégé
147 147
  **/
148 148
 function interdire_scripts($arg, $mode_filtre = null) {
149
-	// on memorise le resultat sur les arguments non triviaux
150
-	static $dejavu = [];
151
-
152
-	// Attention, si ce n'est pas une chaine, laisser intact
153
-	if (!$arg or !is_string($arg) or !strstr($arg, '<')) {
154
-		return $arg;
155
-	}
156
-
157
-	if (is_null($mode_filtre) or !in_array($mode_filtre, [-1, 0, 1])) {
158
-		$mode_filtre = $GLOBALS['filtrer_javascript'];
159
-	}
160
-
161
-	if (isset($dejavu[$mode_filtre][$arg])) {
162
-		return $dejavu[$mode_filtre][$arg];
163
-	}
164
-
165
-	// echapper les tags asp/php
166
-	$t = str_replace('<' . '%', '&lt;%', $arg);
167
-
168
-	// echapper le php
169
-	$t = str_replace('<' . '?', '&lt;?', $t);
170
-
171
-	// echapper le < script language=php >
172
-	$t = preg_replace(',<(script\b[^>]+\blanguage\b[^\w>]+php\b),UimsS', '&lt;\1', $t);
173
-
174
-	// Pour le js, trois modes : parano (-1), prive (0), ok (1)
175
-	switch ($mode_filtre) {
176
-		case 0:
177
-			if (!_DIR_RESTREINT) {
178
-				$t = echappe_js($t);
179
-			}
180
-			break;
181
-		case -1:
182
-			$t = echappe_js($t);
183
-			break;
184
-	}
185
-
186
-	// pas de <base href /> svp !
187
-	$t = preg_replace(',<(base\b),iS', '&lt;\1', $t);
188
-
189
-	// Reinserer les echappements des modeles
190
-	if (defined('_PROTEGE_JS_MODELES')) {
191
-		$t = echappe_retour($t, 'javascript' . _PROTEGE_JS_MODELES);
192
-	}
193
-	if (defined('_PROTEGE_PHP_MODELES')) {
194
-		$t = echappe_retour($t, 'php' . _PROTEGE_PHP_MODELES);
195
-	}
196
-
197
-	return $dejavu[$mode_filtre][$arg] = $t;
149
+    // on memorise le resultat sur les arguments non triviaux
150
+    static $dejavu = [];
151
+
152
+    // Attention, si ce n'est pas une chaine, laisser intact
153
+    if (!$arg or !is_string($arg) or !strstr($arg, '<')) {
154
+        return $arg;
155
+    }
156
+
157
+    if (is_null($mode_filtre) or !in_array($mode_filtre, [-1, 0, 1])) {
158
+        $mode_filtre = $GLOBALS['filtrer_javascript'];
159
+    }
160
+
161
+    if (isset($dejavu[$mode_filtre][$arg])) {
162
+        return $dejavu[$mode_filtre][$arg];
163
+    }
164
+
165
+    // echapper les tags asp/php
166
+    $t = str_replace('<' . '%', '&lt;%', $arg);
167
+
168
+    // echapper le php
169
+    $t = str_replace('<' . '?', '&lt;?', $t);
170
+
171
+    // echapper le < script language=php >
172
+    $t = preg_replace(',<(script\b[^>]+\blanguage\b[^\w>]+php\b),UimsS', '&lt;\1', $t);
173
+
174
+    // Pour le js, trois modes : parano (-1), prive (0), ok (1)
175
+    switch ($mode_filtre) {
176
+        case 0:
177
+            if (!_DIR_RESTREINT) {
178
+                $t = echappe_js($t);
179
+            }
180
+            break;
181
+        case -1:
182
+            $t = echappe_js($t);
183
+            break;
184
+    }
185
+
186
+    // pas de <base href /> svp !
187
+    $t = preg_replace(',<(base\b),iS', '&lt;\1', $t);
188
+
189
+    // Reinserer les echappements des modeles
190
+    if (defined('_PROTEGE_JS_MODELES')) {
191
+        $t = echappe_retour($t, 'javascript' . _PROTEGE_JS_MODELES);
192
+    }
193
+    if (defined('_PROTEGE_PHP_MODELES')) {
194
+        $t = echappe_retour($t, 'php' . _PROTEGE_PHP_MODELES);
195
+    }
196
+
197
+    return $dejavu[$mode_filtre][$arg] = $t;
198 198
 }
199 199
 
200 200
 
@@ -223,66 +223,66 @@  discard block
 block discarded – undo
223 223
  *     Texte transformé
224 224
  **/
225 225
 function typo($letexte, $echapper = true, $connect = null, $env = []) {
226
-	// Plus vite !
227
-	if (!$letexte) {
228
-		return $letexte;
229
-	}
230
-
231
-	// les appels directs a cette fonction depuis le php de l'espace
232
-	// prive etant historiquement ecrit sans argment $connect
233
-	// on utilise la presence de celui-ci pour distinguer les cas
234
-	// ou il faut passer interdire_script explicitement
235
-	// les appels dans les squelettes (de l'espace prive) fournissant un $connect
236
-	// ne seront pas perturbes
237
-	$interdire_script = false;
238
-	if (is_null($connect)) {
239
-		$connect = '';
240
-		$interdire_script = true;
241
-		$env['espace_prive'] = test_espace_prive();
242
-	}
243
-
244
-	// Echapper les codes <html> etc
245
-	if ($echapper) {
246
-		$letexte = echappe_html($letexte, 'TYPO');
247
-	}
248
-
249
-	//
250
-	// Installer les modeles, notamment images et documents ;
251
-	//
252
-	// NOTE : propre() ne passe pas par ici mais directement par corriger_typo
253
-	// cf. inc/lien
254
-
255
-	$letexte = traiter_modeles($mem = $letexte, false, $echapper ? 'TYPO' : '', $connect, null, $env);
256
-	if ($letexte != $mem) {
257
-		$echapper = true;
258
-	}
259
-	unset($mem);
260
-
261
-	$letexte = corriger_typo($letexte);
262
-	$letexte = echapper_faux_tags($letexte);
263
-
264
-	// reintegrer les echappements
265
-	if ($echapper) {
266
-		$letexte = echappe_retour($letexte, 'TYPO');
267
-	}
268
-
269
-	// Dans les appels directs hors squelette, securiser ici aussi
270
-	if ($interdire_script) {
271
-		$letexte = interdire_scripts($letexte);
272
-	}
273
-
274
-	// Dans l'espace prive on se mefie de tout contenu dangereux
275
-	// https://core.spip.net/issues/3371
276
-	// et aussi dans l'espace public si la globale filtrer_javascript = -1
277
-	// https://core.spip.net/issues/4166
278
-	if (
279
-		$GLOBALS['filtrer_javascript'] == -1
280
-		or (isset($env['espace_prive']) and $env['espace_prive'] and $GLOBALS['filtrer_javascript'] <= 0)
281
-	) {
282
-		$letexte = echapper_html_suspect($letexte);
283
-	}
284
-
285
-	return $letexte;
226
+    // Plus vite !
227
+    if (!$letexte) {
228
+        return $letexte;
229
+    }
230
+
231
+    // les appels directs a cette fonction depuis le php de l'espace
232
+    // prive etant historiquement ecrit sans argment $connect
233
+    // on utilise la presence de celui-ci pour distinguer les cas
234
+    // ou il faut passer interdire_script explicitement
235
+    // les appels dans les squelettes (de l'espace prive) fournissant un $connect
236
+    // ne seront pas perturbes
237
+    $interdire_script = false;
238
+    if (is_null($connect)) {
239
+        $connect = '';
240
+        $interdire_script = true;
241
+        $env['espace_prive'] = test_espace_prive();
242
+    }
243
+
244
+    // Echapper les codes <html> etc
245
+    if ($echapper) {
246
+        $letexte = echappe_html($letexte, 'TYPO');
247
+    }
248
+
249
+    //
250
+    // Installer les modeles, notamment images et documents ;
251
+    //
252
+    // NOTE : propre() ne passe pas par ici mais directement par corriger_typo
253
+    // cf. inc/lien
254
+
255
+    $letexte = traiter_modeles($mem = $letexte, false, $echapper ? 'TYPO' : '', $connect, null, $env);
256
+    if ($letexte != $mem) {
257
+        $echapper = true;
258
+    }
259
+    unset($mem);
260
+
261
+    $letexte = corriger_typo($letexte);
262
+    $letexte = echapper_faux_tags($letexte);
263
+
264
+    // reintegrer les echappements
265
+    if ($echapper) {
266
+        $letexte = echappe_retour($letexte, 'TYPO');
267
+    }
268
+
269
+    // Dans les appels directs hors squelette, securiser ici aussi
270
+    if ($interdire_script) {
271
+        $letexte = interdire_scripts($letexte);
272
+    }
273
+
274
+    // Dans l'espace prive on se mefie de tout contenu dangereux
275
+    // https://core.spip.net/issues/3371
276
+    // et aussi dans l'espace public si la globale filtrer_javascript = -1
277
+    // https://core.spip.net/issues/4166
278
+    if (
279
+        $GLOBALS['filtrer_javascript'] == -1
280
+        or (isset($env['espace_prive']) and $env['espace_prive'] and $GLOBALS['filtrer_javascript'] <= 0)
281
+    ) {
282
+        $letexte = echapper_html_suspect($letexte);
283
+    }
284
+
285
+    return $letexte;
286 286
 }
287 287
 
288 288
 // Correcteur typographique
@@ -307,57 +307,57 @@  discard block
 block discarded – undo
307 307
  */
308 308
 function corriger_typo($letexte, $lang = '') {
309 309
 
310
-	// Plus vite !
311
-	if (!$letexte) {
312
-		return $letexte;
313
-	}
314
-
315
-	$letexte = pipeline('pre_typo', $letexte);
316
-
317
-	// Caracteres de controle "illegaux"
318
-	$letexte = corriger_caracteres($letexte);
319
-
320
-	// Proteger les caracteres typographiques a l'interieur des tags html
321
-	if (preg_match_all(_TYPO_BALISE, $letexte, $regs, PREG_SET_ORDER)) {
322
-		foreach ($regs as $reg) {
323
-			$insert = $reg[0];
324
-			// hack: on transforme les caracteres a proteger en les remplacant
325
-			// par des caracteres "illegaux". (cf corriger_caracteres())
326
-			$insert = strtr($insert, _TYPO_PROTEGER, _TYPO_PROTECTEUR);
327
-			$letexte = str_replace($reg[0], $insert, $letexte);
328
-		}
329
-	}
330
-
331
-	// trouver les blocs idiomes et les traiter à part
332
-	$letexte = extraire_idiome($ei = $letexte, $lang, true);
333
-	$ei = ($ei !== $letexte);
334
-
335
-	// trouver les blocs multi et les traiter a part
336
-	$letexte = extraire_multi($em = $letexte, $lang, true);
337
-	$em = ($em !== $letexte);
338
-
339
-	// Charger & appliquer les fonctions de typographie
340
-	$typographie = charger_fonction(lang_typo($lang), 'typographie');
341
-	$letexte = $typographie($letexte);
342
-
343
-	// Les citations en une autre langue, s'il y a lieu
344
-	if ($em) {
345
-		$letexte = echappe_retour($letexte, 'multi');
346
-	}
347
-	if ($ei) {
348
-		$letexte = echappe_retour($letexte, 'idiome');
349
-	}
350
-
351
-	// Retablir les caracteres proteges
352
-	$letexte = strtr($letexte, _TYPO_PROTECTEUR, _TYPO_PROTEGER);
353
-
354
-	// pipeline
355
-	$letexte = pipeline('post_typo', $letexte);
356
-
357
-	# un message pour abs_url - on est passe en mode texte
358
-	$GLOBALS['mode_abs_url'] = 'texte';
359
-
360
-	return $letexte;
310
+    // Plus vite !
311
+    if (!$letexte) {
312
+        return $letexte;
313
+    }
314
+
315
+    $letexte = pipeline('pre_typo', $letexte);
316
+
317
+    // Caracteres de controle "illegaux"
318
+    $letexte = corriger_caracteres($letexte);
319
+
320
+    // Proteger les caracteres typographiques a l'interieur des tags html
321
+    if (preg_match_all(_TYPO_BALISE, $letexte, $regs, PREG_SET_ORDER)) {
322
+        foreach ($regs as $reg) {
323
+            $insert = $reg[0];
324
+            // hack: on transforme les caracteres a proteger en les remplacant
325
+            // par des caracteres "illegaux". (cf corriger_caracteres())
326
+            $insert = strtr($insert, _TYPO_PROTEGER, _TYPO_PROTECTEUR);
327
+            $letexte = str_replace($reg[0], $insert, $letexte);
328
+        }
329
+    }
330
+
331
+    // trouver les blocs idiomes et les traiter à part
332
+    $letexte = extraire_idiome($ei = $letexte, $lang, true);
333
+    $ei = ($ei !== $letexte);
334
+
335
+    // trouver les blocs multi et les traiter a part
336
+    $letexte = extraire_multi($em = $letexte, $lang, true);
337
+    $em = ($em !== $letexte);
338
+
339
+    // Charger & appliquer les fonctions de typographie
340
+    $typographie = charger_fonction(lang_typo($lang), 'typographie');
341
+    $letexte = $typographie($letexte);
342
+
343
+    // Les citations en une autre langue, s'il y a lieu
344
+    if ($em) {
345
+        $letexte = echappe_retour($letexte, 'multi');
346
+    }
347
+    if ($ei) {
348
+        $letexte = echappe_retour($letexte, 'idiome');
349
+    }
350
+
351
+    // Retablir les caracteres proteges
352
+    $letexte = strtr($letexte, _TYPO_PROTECTEUR, _TYPO_PROTEGER);
353
+
354
+    // pipeline
355
+    $letexte = pipeline('post_typo', $letexte);
356
+
357
+    # un message pour abs_url - on est passe en mode texte
358
+    $GLOBALS['mode_abs_url'] = 'texte';
359
+
360
+    return $letexte;
361 361
 }
362 362
 
363 363
 
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
  * @return string
374 374
  */
375 375
 function paragrapher($letexte, $forcer = true) {
376
-	return $letexte;
376
+    return $letexte;
377 377
 }
378 378
 
379 379
 /**
@@ -385,11 +385,11 @@  discard block
 block discarded – undo
385 385
  * @return string Texte
386 386
  **/
387 387
 function traiter_retours_chariots($letexte) {
388
-	$letexte = preg_replace(",\r\n?,S", "\n", $letexte);
389
-	$letexte = preg_replace(',<p[>[:space:]],iS', "\n\n\\0", $letexte);
390
-	$letexte = preg_replace(',</p[>[:space:]],iS', "\\0\n\n", $letexte);
388
+    $letexte = preg_replace(",\r\n?,S", "\n", $letexte);
389
+    $letexte = preg_replace(',<p[>[:space:]],iS', "\n\n\\0", $letexte);
390
+    $letexte = preg_replace(',</p[>[:space:]],iS', "\\0\n\n", $letexte);
391 391
 
392
-	return $letexte;
392
+    return $letexte;
393 393
 }
394 394
 
395 395
 
@@ -415,39 +415,39 @@  discard block
 block discarded – undo
415 415
  *     Texte transformé
416 416
  **/
417 417
 function propre($t, $connect = null, $env = []) {
418
-	// les appels directs a cette fonction depuis le php de l'espace
419
-	// prive etant historiquement ecrits sans argment $connect
420
-	// on utilise la presence de celui-ci pour distinguer les cas
421
-	// ou il faut passer interdire_script explicitement
422
-	// les appels dans les squelettes (de l'espace prive) fournissant un $connect
423
-	// ne seront pas perturbes
424
-	$interdire_script = false;
425
-	if (is_null($connect)) {
426
-		$connect = '';
427
-		$interdire_script = true;
428
-	}
429
-
430
-	if (!$t) {
431
-		return strval($t);
432
-	}
433
-
434
-	// Dans l'espace prive on se mefie de tout contenu dangereux
435
-	// avant echappement des balises <html>
436
-	// https://core.spip.net/issues/3371
437
-	// et aussi dans l'espace public si la globale filtrer_javascript = -1
438
-	// https://core.spip.net/issues/4166
439
-	if (
440
-		$interdire_script
441
-		or $GLOBALS['filtrer_javascript'] == -1
442
-		or (isset($env['espace_prive']) and $env['espace_prive'] and $GLOBALS['filtrer_javascript'] <= 0)
443
-		or (isset($env['wysiwyg']) and $env['wysiwyg'] and $GLOBALS['filtrer_javascript'] <= 0)
444
-	) {
445
-		$t = echapper_html_suspect($t, false);
446
-	}
447
-	$t = echappe_html($t);
448
-	$t = expanser_liens($t, $connect, $env);
449
-	$t = traiter_raccourcis($t);
450
-	$t = echappe_retour_modeles($t, $interdire_script);
451
-
452
-	return $t;
418
+    // les appels directs a cette fonction depuis le php de l'espace
419
+    // prive etant historiquement ecrits sans argment $connect
420
+    // on utilise la presence de celui-ci pour distinguer les cas
421
+    // ou il faut passer interdire_script explicitement
422
+    // les appels dans les squelettes (de l'espace prive) fournissant un $connect
423
+    // ne seront pas perturbes
424
+    $interdire_script = false;
425
+    if (is_null($connect)) {
426
+        $connect = '';
427
+        $interdire_script = true;
428
+    }
429
+
430
+    if (!$t) {
431
+        return strval($t);
432
+    }
433
+
434
+    // Dans l'espace prive on se mefie de tout contenu dangereux
435
+    // avant echappement des balises <html>
436
+    // https://core.spip.net/issues/3371
437
+    // et aussi dans l'espace public si la globale filtrer_javascript = -1
438
+    // https://core.spip.net/issues/4166
439
+    if (
440
+        $interdire_script
441
+        or $GLOBALS['filtrer_javascript'] == -1
442
+        or (isset($env['espace_prive']) and $env['espace_prive'] and $GLOBALS['filtrer_javascript'] <= 0)
443
+        or (isset($env['wysiwyg']) and $env['wysiwyg'] and $GLOBALS['filtrer_javascript'] <= 0)
444
+    ) {
445
+        $t = echapper_html_suspect($t, false);
446
+    }
447
+    $t = echappe_html($t);
448
+    $t = expanser_liens($t, $connect, $env);
449
+    $t = traiter_raccourcis($t);
450
+    $t = echappe_retour_modeles($t, $interdire_script);
451
+
452
+    return $t;
453 453
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -105,12 +105,12 @@  discard block
 block discarded – undo
105 105
 	foreach (['script', 'iframe'] as $tag) {
106 106
 		if (
107 107
 			stripos($t, (string) "<$tag") !== false
108
-			and preg_match_all(',<' . $tag . '.*?($|</' . $tag . '.),isS', $t, $r, PREG_SET_ORDER)
108
+			and preg_match_all(',<'.$tag.'.*?($|</'.$tag.'.),isS', $t, $r, PREG_SET_ORDER)
109 109
 		) {
110 110
 			foreach ($r as $regs) {
111 111
 				$t = str_replace(
112 112
 					$regs[0],
113
-					"<code$class>" . nl2br(spip_htmlspecialchars($regs[0])) . '</code>',
113
+					"<code$class>".nl2br(spip_htmlspecialchars($regs[0])).'</code>',
114 114
 					$t
115 115
 				);
116 116
 			}
@@ -163,10 +163,10 @@  discard block
 block discarded – undo
163 163
 	}
164 164
 
165 165
 	// echapper les tags asp/php
166
-	$t = str_replace('<' . '%', '&lt;%', $arg);
166
+	$t = str_replace('<'.'%', '&lt;%', $arg);
167 167
 
168 168
 	// echapper le php
169
-	$t = str_replace('<' . '?', '&lt;?', $t);
169
+	$t = str_replace('<'.'?', '&lt;?', $t);
170 170
 
171 171
 	// echapper le < script language=php >
172 172
 	$t = preg_replace(',<(script\b[^>]+\blanguage\b[^\w>]+php\b),UimsS', '&lt;\1', $t);
@@ -188,10 +188,10 @@  discard block
 block discarded – undo
188 188
 
189 189
 	// Reinserer les echappements des modeles
190 190
 	if (defined('_PROTEGE_JS_MODELES')) {
191
-		$t = echappe_retour($t, 'javascript' . _PROTEGE_JS_MODELES);
191
+		$t = echappe_retour($t, 'javascript'._PROTEGE_JS_MODELES);
192 192
 	}
193 193
 	if (defined('_PROTEGE_PHP_MODELES')) {
194
-		$t = echappe_retour($t, 'php' . _PROTEGE_PHP_MODELES);
194
+		$t = echappe_retour($t, 'php'._PROTEGE_PHP_MODELES);
195 195
 	}
196 196
 
197 197
 	return $dejavu[$mode_filtre][$arg] = $t;
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 define('_TYPO_PROTEGER', "!':;?~%-");
290 290
 define('_TYPO_PROTECTEUR', "\x1\x2\x3\x4\x5\x6\x7\x8");
291 291
 
292
-define('_TYPO_BALISE', ',</?[a-z!][^<>]*[' . preg_quote(_TYPO_PROTEGER) . '][^<>]*>,imsS');
292
+define('_TYPO_BALISE', ',</?[a-z!][^<>]*['.preg_quote(_TYPO_PROTEGER).'][^<>]*>,imsS');
293 293
 
294 294
 /**
295 295
  * Corrige la typographie
Please login to merge, or discard this patch.
ecrire/inc/filtres_alertes.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
 	$_texte = ($_texte ?: "''");
52 52
 	$_titre = ($_titre ? ", $_titre" : ', null');
53 53
 	$_class = ($_class ? ", $_class" : ', null');
54
-	$_role  = ($_role  ? ", $_role"  : ', null');
55
-	$_id    = ($_id    ? ", $_id"    : ', null');
54
+	$_role  = ($_role ? ", $_role" : ', null');
55
+	$_id    = ($_id ? ", $_id" : ', null');
56 56
 
57 57
 	$f = chercher_filtre('message_alerte');
58 58
 	$p->code = "$f($_texte$_titre$_class$_role$_id)";
@@ -90,10 +90,10 @@  discard block
 block discarded – undo
90 90
 	$_class = interprete_argument_balise(2, $p);
91 91
 	$_role  = interprete_argument_balise(3, $p);
92 92
 	$_id    = interprete_argument_balise(4, $p);
93
-	$_titre = ($_titre ? "$_titre"   : 'null');
93
+	$_titre = ($_titre ? "$_titre" : 'null');
94 94
 	$_class = ($_class ? ", $_class" : ', null');
95
-	$_role  = ($_role  ? ", $_role"  : ', null');
96
-	$_id    = ($_id    ? ", $_id"    : ', null');
95
+	$_role  = ($_role ? ", $_role" : ', null');
96
+	$_id    = ($_id ? ", $_id" : ', null');
97 97
 
98 98
 	$f = chercher_filtre('message_alerte_ouvrir');
99 99
 	$p->code = "$f($_titre$_class$_role$_id)";
@@ -163,8 +163,8 @@  discard block
 block discarded – undo
163 163
 	$message_alerte_ouvrir = chercher_filtre('message_alerte_ouvrir');
164 164
 	$message_alerte_fermer = chercher_filtre('message_alerte_fermer');
165 165
 	$message =
166
-		$message_alerte_ouvrir($titre, $class, $role, $id) .
167
-		$texte .
166
+		$message_alerte_ouvrir($titre, $class, $role, $id).
167
+		$texte.
168 168
 		$message_alerte_fermer();
169 169
 
170 170
 	return $message;
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 	];
214 214
 	$type  = array_intersect(explode(' ', $class), $types);
215 215
 	$type  = reset($type);
216
-	$class = trim(str_replace($types, '', $class) . " $type");
216
+	$class = trim(str_replace($types, '', $class)." $type");
217 217
 
218 218
 	// Classes
219 219
 	$class_racine = 'msg-alert';
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 
239 239
 	// Attributs
240 240
 	$attr_role = ($role ? "role=\"$role\"" : '');
241
-	$attr_id   = ($id   ? "id=\"$id\"" : '');
241
+	$attr_id   = ($id ? "id=\"$id\"" : '');
242 242
 	$attr_data = ($type ? "data-alert=\"$type\"" : '');
243 243
 
244 244
 	$message =
Please login to merge, or discard this patch.
Indentation   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
  **/
19 19
 
20 20
 if (!defined('_ECRIRE_INC_VERSION')) {
21
-	return;
21
+    return;
22 22
 }
23 23
 
24 24
 /**
@@ -43,22 +43,22 @@  discard block
 block discarded – undo
43 43
  *     Pile complétée par le code à générer
44 44
  */
45 45
 function balise_ALERTE_MESSAGE_dist($p) {
46
-	$_texte = interprete_argument_balise(1, $p);
47
-	$_titre = interprete_argument_balise(2, $p);
48
-	$_class = interprete_argument_balise(3, $p);
49
-	$_role  = interprete_argument_balise(4, $p);
50
-	$_id    = interprete_argument_balise(5, $p);
51
-	$_texte = ($_texte ?: "''");
52
-	$_titre = ($_titre ? ", $_titre" : ', null');
53
-	$_class = ($_class ? ", $_class" : ', null');
54
-	$_role  = ($_role  ? ", $_role"  : ', null');
55
-	$_id    = ($_id    ? ", $_id"    : ', null');
46
+    $_texte = interprete_argument_balise(1, $p);
47
+    $_titre = interprete_argument_balise(2, $p);
48
+    $_class = interprete_argument_balise(3, $p);
49
+    $_role  = interprete_argument_balise(4, $p);
50
+    $_id    = interprete_argument_balise(5, $p);
51
+    $_texte = ($_texte ?: "''");
52
+    $_titre = ($_titre ? ", $_titre" : ', null');
53
+    $_class = ($_class ? ", $_class" : ', null');
54
+    $_role  = ($_role  ? ", $_role"  : ', null');
55
+    $_id    = ($_id    ? ", $_id"    : ', null');
56 56
 
57
-	$f = chercher_filtre('message_alerte');
58
-	$p->code = "$f($_texte$_titre$_class$_role$_id)";
59
-	$p->interdire_scripts = false;
57
+    $f = chercher_filtre('message_alerte');
58
+    $p->code = "$f($_texte$_titre$_class$_role$_id)";
59
+    $p->interdire_scripts = false;
60 60
 
61
-	return $p;
61
+    return $p;
62 62
 }
63 63
 
64 64
 /**
@@ -86,20 +86,20 @@  discard block
 block discarded – undo
86 86
  *     Pile complétée par le code à générer
87 87
  */
88 88
 function balise_ALERTE_OUVRIR_dist($p) {
89
-	$_titre = interprete_argument_balise(1, $p);
90
-	$_class = interprete_argument_balise(2, $p);
91
-	$_role  = interprete_argument_balise(3, $p);
92
-	$_id    = interprete_argument_balise(4, $p);
93
-	$_titre = ($_titre ? "$_titre"   : 'null');
94
-	$_class = ($_class ? ", $_class" : ', null');
95
-	$_role  = ($_role  ? ", $_role"  : ', null');
96
-	$_id    = ($_id    ? ", $_id"    : ', null');
89
+    $_titre = interprete_argument_balise(1, $p);
90
+    $_class = interprete_argument_balise(2, $p);
91
+    $_role  = interprete_argument_balise(3, $p);
92
+    $_id    = interprete_argument_balise(4, $p);
93
+    $_titre = ($_titre ? "$_titre"   : 'null');
94
+    $_class = ($_class ? ", $_class" : ', null');
95
+    $_role  = ($_role  ? ", $_role"  : ', null');
96
+    $_id    = ($_id    ? ", $_id"    : ', null');
97 97
 
98
-	$f = chercher_filtre('message_alerte_ouvrir');
99
-	$p->code = "$f($_titre$_class$_role$_id)";
100
-	$p->interdire_scripts = false;
98
+    $f = chercher_filtre('message_alerte_ouvrir');
99
+    $p->code = "$f($_titre$_class$_role$_id)";
100
+    $p->interdire_scripts = false;
101 101
 
102
-	return $p;
102
+    return $p;
103 103
 }
104 104
 
105 105
 /**
@@ -121,11 +121,11 @@  discard block
 block discarded – undo
121 121
  *     Pile complétée par le code à générer
122 122
  */
123 123
 function balise_ALERTE_FERMER_dist($p) {
124
-	$f = chercher_filtre('message_alerte_fermer');
125
-	$p->code = "$f()";
126
-	$p->interdire_scripts = false;
124
+    $f = chercher_filtre('message_alerte_fermer');
125
+    $p->code = "$f()";
126
+    $p->interdire_scripts = false;
127 127
 
128
-	return $p;
128
+    return $p;
129 129
 }
130 130
 
131 131
 /**
@@ -160,14 +160,14 @@  discard block
 block discarded – undo
160 160
  */
161 161
 function message_alerte(string $texte, ?string $titre = null, ?string $class = null, ?string $role = null, ?string $id = null): string {
162 162
 
163
-	$message_alerte_ouvrir = chercher_filtre('message_alerte_ouvrir');
164
-	$message_alerte_fermer = chercher_filtre('message_alerte_fermer');
165
-	$message =
166
-		$message_alerte_ouvrir($titre, $class, $role, $id) .
167
-		$texte .
168
-		$message_alerte_fermer();
163
+    $message_alerte_ouvrir = chercher_filtre('message_alerte_ouvrir');
164
+    $message_alerte_fermer = chercher_filtre('message_alerte_fermer');
165
+    $message =
166
+        $message_alerte_ouvrir($titre, $class, $role, $id) .
167
+        $texte .
168
+        $message_alerte_fermer();
169 169
 
170
-	return $message;
170
+    return $message;
171 171
 }
172 172
 
173 173
 /**
@@ -198,56 +198,56 @@  discard block
 block discarded – undo
198 198
  */
199 199
 function message_alerte_ouvrir(?string $titre = null, ?string $class = null, ?string $role = null, ?string $id = null): string {
200 200
 
201
-	$prive = test_espace_prive();
201
+    $prive = test_espace_prive();
202 202
 
203
-	// Valeurs par défaut
204
-	$titre = trim($titre ?? '');
205
-	$role ??= 'alert'; // fallback uniquement si null
206
-	$class ??= 'notice'; // fallback uniquement si null
203
+    // Valeurs par défaut
204
+    $titre = trim($titre ?? '');
205
+    $role ??= 'alert'; // fallback uniquement si null
206
+    $class ??= 'notice'; // fallback uniquement si null
207 207
 
208
-	// Type d'alerte : le chercher dans les classes, nettoyer celles-ci, puis le réinjecter
209
-	$types = [
210
-		'notice',
211
-		'error',
212
-		'success',
213
-		'info',
214
-	];
215
-	$type  = array_intersect(explode(' ', $class), $types);
216
-	$type  = reset($type);
217
-	$class = trim(str_replace($types, '', $class) . " $type");
208
+    // Type d'alerte : le chercher dans les classes, nettoyer celles-ci, puis le réinjecter
209
+    $types = [
210
+        'notice',
211
+        'error',
212
+        'success',
213
+        'info',
214
+    ];
215
+    $type  = array_intersect(explode(' ', $class), $types);
216
+    $type  = reset($type);
217
+    $class = trim(str_replace($types, '', $class) . " $type");
218 218
 
219
-	// Classes
220
-	$class_racine = 'msg-alert';
221
-	$clearfix     = ($prive ? 'clearfix' : '');
222
-	$class_alerte = "$class_racine $class";
223
-	$class_texte  = "${class_racine}__text $clearfix";
224
-	$class_titre  = "${class_racine}__heading";
219
+    // Classes
220
+    $class_racine = 'msg-alert';
221
+    $clearfix     = ($prive ? 'clearfix' : '');
222
+    $class_alerte = "$class_racine $class";
223
+    $class_texte  = "${class_racine}__text $clearfix";
224
+    $class_titre  = "${class_racine}__heading";
225 225
 
226
-	// Titre : markup
227
-	$titre = trim($titre);
228
-	if (strlen($titre)) {
229
-		include_spip('inc/filtres');
230
-		// Si besoin on encapsule le titre : un h3 dans le privé, un simple div sinon.
231
-		$cherche_tag = ($prive ? '<h' : '<');
232
-		$wrap_tag    = ($prive ? '<h3>' : '<div>');
233
-		if (strpos($titre, $cherche_tag) !== 0) {
234
-			$titre = wrap($titre, $wrap_tag);
235
-		}
236
-		// puis on ajoute la classe
237
-		$titre = ajouter_class($titre, $class_titre);
238
-	}
226
+    // Titre : markup
227
+    $titre = trim($titre);
228
+    if (strlen($titre)) {
229
+        include_spip('inc/filtres');
230
+        // Si besoin on encapsule le titre : un h3 dans le privé, un simple div sinon.
231
+        $cherche_tag = ($prive ? '<h' : '<');
232
+        $wrap_tag    = ($prive ? '<h3>' : '<div>');
233
+        if (strpos($titre, $cherche_tag) !== 0) {
234
+            $titre = wrap($titre, $wrap_tag);
235
+        }
236
+        // puis on ajoute la classe
237
+        $titre = ajouter_class($titre, $class_titre);
238
+    }
239 239
 
240
-	// Attributs
241
-	$attr_role = ($role ? "role=\"$role\"" : '');
242
-	$attr_id   = ($id   ? "id=\"$id\"" : '');
243
-	$attr_data = ($type ? "data-alert=\"$type\"" : '');
240
+    // Attributs
241
+    $attr_role = ($role ? "role=\"$role\"" : '');
242
+    $attr_id   = ($id   ? "id=\"$id\"" : '');
243
+    $attr_data = ($type ? "data-alert=\"$type\"" : '');
244 244
 
245
-	$message =
246
-		"<div class=\"$class_alerte\" $attr_role $attr_id $attr_data>"
247
-			. $titre
248
-			. "<div class=\"$class_texte\">";
245
+    $message =
246
+        "<div class=\"$class_alerte\" $attr_role $attr_id $attr_data>"
247
+            . $titre
248
+            . "<div class=\"$class_texte\">";
249 249
 
250
-	return $message;
250
+    return $message;
251 251
 }
252 252
 
253 253
 /**
@@ -261,5 +261,5 @@  discard block
 block discarded – undo
261 261
  *     HTML de fin de l'alerte
262 262
  */
263 263
 function message_alerte_fermer(): string {
264
-	return '</div></div>';
264
+    return '</div></div>';
265 265
 }
Please login to merge, or discard this patch.
ecrire/inc/cvt_configurer.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	) {
39 39
 		// Pour tous les formulaires CONFIGURER, ayant une fonction charger ou pas, on teste si autorisé
40 40
 		include_spip('inc/autoriser');
41
-		if (!autoriser('configurer', '_' . substr($form, 11))) {
41
+		if (!autoriser('configurer', '_'.substr($form, 11))) {
42 42
 			return false;
43 43
 		}
44 44
 
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 		and !charger_fonction('traiter', "formulaires/$form/", true) // sans fonction traiter()
73 73
 	) {
74 74
 		$trace = cvtconf_formulaires_configurer_enregistre($form, $flux['args']['args']);
75
-		$flux['data'] = ['message_ok' => _T('config_info_enregistree') . $trace, 'editable' => true];
75
+		$flux['data'] = ['message_ok' => _T('config_info_enregistree').$trace, 'editable' => true];
76 76
 	}
77 77
 
78 78
 	return $flux;
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 		$prefixe = $valeurs['_meta_prefixe'];
147 147
 	}
148 148
 	if (isset($valeurs['_meta_stockage'])) {
149
-		$stockage = $valeurs['_meta_stockage'] . '::';
149
+		$stockage = $valeurs['_meta_stockage'].'::';
150 150
 	}
151 151
 
152 152
 	// si on indique juste une table, il faut vider les autres proprietes
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 
172 172
 	// sinon cas analyse du squelette
173 173
 	if (
174
-		$f = find_in_path($form . '.' . _EXTENSION_SQUELETTES, 'formulaires/')
174
+		$f = find_in_path($form.'.'._EXTENSION_SQUELETTES, 'formulaires/')
175 175
 		and lire_fichier($f, $contenu)
176 176
 	) {
177 177
 		for ($i = 0; $i < 2; $i++) {
@@ -228,14 +228,14 @@  discard block
 block discarded – undo
228 228
 		lire_metas($table);
229 229
 	}
230 230
 
231
-	$prefixe = ($prefixe ? $prefixe . '_' : '');
231
+	$prefixe = ($prefixe ? $prefixe.'_' : '');
232 232
 	$table = ($table) ? "/$table/" : '';
233
-	$casier = ($casier) ? rtrim($casier, '/') . '/' : ''; // slash final, sinon rien
233
+	$casier = ($casier) ? rtrim($casier, '/').'/' : ''; // slash final, sinon rien
234 234
 
235 235
 	foreach ($store as $k => $v) {
236 236
 		ecrire_config("$stockage$table$prefixe$casier$k", $v);
237 237
 		if (_request('var_mode') == 'configurer' and autoriser('webmestre')) {
238
-			$trace .= "<br />table $table : " . $prefixe . $k . " = $v;";
238
+			$trace .= "<br />table $table : ".$prefixe.$k." = $v;";
239 239
 		}
240 240
 	}
241 241
 
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 	[$table, $casier, $prefixe, $stockage] = cvtconf_definir_configurer_conteneur($form, $valeurs);
253 253
 
254 254
 	$table = ($table) ? "/$table/" : '';
255
-	$prefixe = ($prefixe ? $prefixe . '_' : '');
255
+	$prefixe = ($prefixe ? $prefixe.'_' : '');
256 256
 	if ($casier) {
257 257
 		$meta = lire_config("$stockage$table$prefixe$casier");
258 258
 		$prefixe = '';
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 
264 264
 	foreach ($valeurs as $k => $v) {
265 265
 		if (substr($k, 0, 1) !== '_') {
266
-			$valeurs[$k] = ($meta[$prefixe . $k] ?? null);
266
+			$valeurs[$k] = ($meta[$prefixe.$k] ?? null);
267 267
 		}
268 268
 	}
269 269
 }
Please login to merge, or discard this patch.
Indentation   +147 added lines, -147 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
  */
21 21
 
22 22
 if (!defined('_ECRIRE_INC_VERSION')) {
23
-	return;
23
+    return;
24 24
 }
25 25
 
26 26
 include_spip('inc/config');
@@ -32,31 +32,31 @@  discard block
 block discarded – undo
32 32
  * @return array|false
33 33
  */
34 34
 function cvtconf_formulaire_charger($flux) {
35
-	if (
36
-		$form = $flux['args']['form']
37
-		and strncmp($form, 'configurer_', 11) == 0 // un #FORMULAIRE_CONFIGURER_XXX
38
-	) {
39
-		// Pour tous les formulaires CONFIGURER, ayant une fonction charger ou pas, on teste si autorisé
40
-		include_spip('inc/autoriser');
41
-		if (!autoriser('configurer', '_' . substr($form, 11))) {
42
-			return false;
43
-		}
35
+    if (
36
+        $form = $flux['args']['form']
37
+        and strncmp($form, 'configurer_', 11) == 0 // un #FORMULAIRE_CONFIGURER_XXX
38
+    ) {
39
+        // Pour tous les formulaires CONFIGURER, ayant une fonction charger ou pas, on teste si autorisé
40
+        include_spip('inc/autoriser');
41
+        if (!autoriser('configurer', '_' . substr($form, 11))) {
42
+            return false;
43
+        }
44 44
 
45
-		// S'il n'y a pas de fonction charger(), on génère un contexte automatiquement
46
-		if (!charger_fonction('charger', "formulaires/$form/", true)) {
47
-			$flux['data'] = cvtconf_formulaires_configurer_recense($form);
48
-			$flux['data']['editable'] = true;
49
-			if (_request('var_mode') == 'configurer' and autoriser('webmestre')) {
50
-				if (!_AJAX) {
51
-					var_dump($flux['data']);
52
-				}
53
-				// reinjecter pour la trace au traitement
54
-				$flux['data']['_hidden'] = "<input type='hidden' name='var_mode' value='configurer' />";
55
-			}
56
-		}
57
-	}
45
+        // S'il n'y a pas de fonction charger(), on génère un contexte automatiquement
46
+        if (!charger_fonction('charger', "formulaires/$form/", true)) {
47
+            $flux['data'] = cvtconf_formulaires_configurer_recense($form);
48
+            $flux['data']['editable'] = true;
49
+            if (_request('var_mode') == 'configurer' and autoriser('webmestre')) {
50
+                if (!_AJAX) {
51
+                    var_dump($flux['data']);
52
+                }
53
+                // reinjecter pour la trace au traitement
54
+                $flux['data']['_hidden'] = "<input type='hidden' name='var_mode' value='configurer' />";
55
+            }
56
+        }
57
+    }
58 58
 
59
-	return $flux;
59
+    return $flux;
60 60
 }
61 61
 
62 62
 /**
@@ -66,16 +66,16 @@  discard block
 block discarded – undo
66 66
  * @return array
67 67
  */
68 68
 function cvtconf_formulaire_traiter($flux) {
69
-	if (
70
-		$form = $flux['args']['form']
71
-		and strncmp($form, 'configurer_', 11) == 0 // un #FORMULAIRE_CONFIGURER_XXX
72
-		and !charger_fonction('traiter', "formulaires/$form/", true) // sans fonction traiter()
73
-	) {
74
-		$trace = cvtconf_formulaires_configurer_enregistre($form, $flux['args']['args']);
75
-		$flux['data'] = ['message_ok' => _T('config_info_enregistree') . $trace, 'editable' => true];
76
-	}
69
+    if (
70
+        $form = $flux['args']['form']
71
+        and strncmp($form, 'configurer_', 11) == 0 // un #FORMULAIRE_CONFIGURER_XXX
72
+        and !charger_fonction('traiter', "formulaires/$form/", true) // sans fonction traiter()
73
+    ) {
74
+        $trace = cvtconf_formulaires_configurer_enregistre($form, $flux['args']['args']);
75
+        $flux['data'] = ['message_ok' => _T('config_info_enregistree') . $trace, 'editable' => true];
76
+    }
77 77
 
78
-	return $flux;
78
+    return $flux;
79 79
 }
80 80
 
81 81
 /**
@@ -91,32 +91,32 @@  discard block
 block discarded – undo
91 91
  * @return string
92 92
  */
93 93
 function cvtconf_formulaires_configurer_enregistre($form, $args) {
94
-	$valeurs = [];
95
-	// charger les valeurs
96
-	// ce qui permet de prendre en charge une fonction charger() existante
97
-	// qui prend alors la main sur l'auto detection
98
-	if ($charger_valeurs = charger_fonction('charger', "formulaires/$form/", true)) {
99
-		$valeurs = $charger_valeurs(...$args);
100
-	}
101
-	$valeurs = pipeline(
102
-		'formulaire_charger',
103
-		[
104
-			'args' => ['form' => $form, 'args' => $args, 'je_suis_poste' => false],
105
-			'data' => $valeurs
106
-		]
107
-	);
108
-	// ne pas stocker editable !
109
-	unset($valeurs['editable']);
94
+    $valeurs = [];
95
+    // charger les valeurs
96
+    // ce qui permet de prendre en charge une fonction charger() existante
97
+    // qui prend alors la main sur l'auto detection
98
+    if ($charger_valeurs = charger_fonction('charger', "formulaires/$form/", true)) {
99
+        $valeurs = $charger_valeurs(...$args);
100
+    }
101
+    $valeurs = pipeline(
102
+        'formulaire_charger',
103
+        [
104
+            'args' => ['form' => $form, 'args' => $args, 'je_suis_poste' => false],
105
+            'data' => $valeurs
106
+        ]
107
+    );
108
+    // ne pas stocker editable !
109
+    unset($valeurs['editable']);
110 110
 
111
-	// recuperer les valeurs postees
112
-	$store = [];
113
-	foreach ($valeurs as $k => $v) {
114
-		if (substr($k, 0, 1) !== '_') {
115
-			$store[$k] = _request($k);
116
-		}
117
-	}
111
+    // recuperer les valeurs postees
112
+    $store = [];
113
+    foreach ($valeurs as $k => $v) {
114
+        if (substr($k, 0, 1) !== '_') {
115
+            $store[$k] = _request($k);
116
+        }
117
+    }
118 118
 
119
-	return cvtconf_configurer_stocker($form, $valeurs, $store);
119
+    return cvtconf_configurer_stocker($form, $valeurs, $store);
120 120
 }
121 121
 
122 122
 /**
@@ -132,31 +132,31 @@  discard block
 block discarded – undo
132 132
  * @return array
133 133
  */
134 134
 function cvtconf_definir_configurer_conteneur($form, $valeurs) {
135
-	// stocker en base
136
-	// par defaut, dans un casier serialize dans spip_meta (idem CFG)
137
-	$casier = substr($form, 11);
138
-	$table = 'meta';
139
-	$prefixe = '';
140
-	$stockage = '';
135
+    // stocker en base
136
+    // par defaut, dans un casier serialize dans spip_meta (idem CFG)
137
+    $casier = substr($form, 11);
138
+    $table = 'meta';
139
+    $prefixe = '';
140
+    $stockage = '';
141 141
 
142
-	if (isset($valeurs['_meta_casier'])) {
143
-		$casier = $valeurs['_meta_casier'];
144
-	}
145
-	if (isset($valeurs['_meta_prefixe'])) {
146
-		$prefixe = $valeurs['_meta_prefixe'];
147
-	}
148
-	if (isset($valeurs['_meta_stockage'])) {
149
-		$stockage = $valeurs['_meta_stockage'] . '::';
150
-	}
142
+    if (isset($valeurs['_meta_casier'])) {
143
+        $casier = $valeurs['_meta_casier'];
144
+    }
145
+    if (isset($valeurs['_meta_prefixe'])) {
146
+        $prefixe = $valeurs['_meta_prefixe'];
147
+    }
148
+    if (isset($valeurs['_meta_stockage'])) {
149
+        $stockage = $valeurs['_meta_stockage'] . '::';
150
+    }
151 151
 
152
-	// si on indique juste une table, il faut vider les autres proprietes
153
-	// car par defaut on utilise ni casier ni prefixe dans ce cas
154
-	if (isset($valeurs['_meta_table'])) {
155
-		$table = $valeurs['_meta_table'];
156
-		$casier = ($valeurs['_meta_casier'] ?? '');
157
-	}
152
+    // si on indique juste une table, il faut vider les autres proprietes
153
+    // car par defaut on utilise ni casier ni prefixe dans ce cas
154
+    if (isset($valeurs['_meta_table'])) {
155
+        $table = $valeurs['_meta_table'];
156
+        $casier = ($valeurs['_meta_casier'] ?? '');
157
+    }
158 158
 
159
-	return [$table, $casier, $prefixe, $stockage];
159
+    return [$table, $casier, $prefixe, $stockage];
160 160
 }
161 161
 
162 162
 /**
@@ -167,48 +167,48 @@  discard block
 block discarded – undo
167 167
  * @return array
168 168
  */
169 169
 function cvtconf_formulaires_configurer_recense($form) {
170
-	$valeurs = ['editable' => ' '];
170
+    $valeurs = ['editable' => ' '];
171 171
 
172
-	// sinon cas analyse du squelette
173
-	if (
174
-		$f = find_in_path($form . '.' . _EXTENSION_SQUELETTES, 'formulaires/')
175
-		and lire_fichier($f, $contenu)
176
-	) {
177
-		for ($i = 0; $i < 2; $i++) {
178
-			// a la seconde iteration, evaluer le fond avec les valeurs deja trouvees
179
-			// permet de trouver aussi les name="#GET{truc}"
180
-			if ($i == 1) {
181
-				$contenu = recuperer_fond("formulaires/$form", $valeurs);
182
-			}
172
+    // sinon cas analyse du squelette
173
+    if (
174
+        $f = find_in_path($form . '.' . _EXTENSION_SQUELETTES, 'formulaires/')
175
+        and lire_fichier($f, $contenu)
176
+    ) {
177
+        for ($i = 0; $i < 2; $i++) {
178
+            // a la seconde iteration, evaluer le fond avec les valeurs deja trouvees
179
+            // permet de trouver aussi les name="#GET{truc}"
180
+            if ($i == 1) {
181
+                $contenu = recuperer_fond("formulaires/$form", $valeurs);
182
+            }
183 183
 
184
-			$balises = array_merge(
185
-				extraire_balises($contenu, 'input'),
186
-				extraire_balises($contenu, 'textarea'),
187
-				extraire_balises($contenu, 'select')
188
-			);
184
+            $balises = array_merge(
185
+                extraire_balises($contenu, 'input'),
186
+                extraire_balises($contenu, 'textarea'),
187
+                extraire_balises($contenu, 'select')
188
+            );
189 189
 
190
-			foreach ($balises as $b) {
191
-				if (
192
-					$n = extraire_attribut($b, 'name')
193
-					and preg_match(',^([\w\-]+)(\[\w*\])?$,', $n, $r)
194
-					and !in_array($n, ['formulaire_action', 'formulaire_action_args', 'formulaire_action_sign'])
195
-					and extraire_attribut($b, 'type') !== 'submit'
196
-				) {
197
-					$valeurs[$r[1]] = '';
198
-					// recuperer les valeurs _meta_xx qui peuvent etre fournies
199
-					// en input hidden dans le squelette
200
-					if (strncmp($r[1], '_meta_', 6) == 0) {
201
-						$valeurs[$r[1]] = extraire_attribut($b, 'value');
202
-					}
203
-				}
204
-			}
205
-		}
206
-	}
190
+            foreach ($balises as $b) {
191
+                if (
192
+                    $n = extraire_attribut($b, 'name')
193
+                    and preg_match(',^([\w\-]+)(\[\w*\])?$,', $n, $r)
194
+                    and !in_array($n, ['formulaire_action', 'formulaire_action_args', 'formulaire_action_sign'])
195
+                    and extraire_attribut($b, 'type') !== 'submit'
196
+                ) {
197
+                    $valeurs[$r[1]] = '';
198
+                    // recuperer les valeurs _meta_xx qui peuvent etre fournies
199
+                    // en input hidden dans le squelette
200
+                    if (strncmp($r[1], '_meta_', 6) == 0) {
201
+                        $valeurs[$r[1]] = extraire_attribut($b, 'value');
202
+                    }
203
+                }
204
+            }
205
+        }
206
+    }
207 207
 
208 208
 
209
-	cvtconf_configurer_lire_meta($form, $valeurs);
209
+    cvtconf_configurer_lire_meta($form, $valeurs);
210 210
 
211
-	return $valeurs;
211
+    return $valeurs;
212 212
 }
213 213
 
214 214
 /**
@@ -220,26 +220,26 @@  discard block
 block discarded – undo
220 220
  * @return string
221 221
  */
222 222
 function cvtconf_configurer_stocker($form, $valeurs, $store) {
223
-	$trace = '';
224
-	[$table, $casier, $prefixe, $stockage] = cvtconf_definir_configurer_conteneur($form, $valeurs);
225
-	// stocker en base
226
-	// par defaut, dans un casier serialize dans spip_meta (idem CFG)
227
-	if (!isset($GLOBALS[$table])) {
228
-		lire_metas($table);
229
-	}
223
+    $trace = '';
224
+    [$table, $casier, $prefixe, $stockage] = cvtconf_definir_configurer_conteneur($form, $valeurs);
225
+    // stocker en base
226
+    // par defaut, dans un casier serialize dans spip_meta (idem CFG)
227
+    if (!isset($GLOBALS[$table])) {
228
+        lire_metas($table);
229
+    }
230 230
 
231
-	$prefixe = ($prefixe ? $prefixe . '_' : '');
232
-	$table = ($table) ? "/$table/" : '';
233
-	$casier = ($casier) ? rtrim($casier, '/') . '/' : ''; // slash final, sinon rien
231
+    $prefixe = ($prefixe ? $prefixe . '_' : '');
232
+    $table = ($table) ? "/$table/" : '';
233
+    $casier = ($casier) ? rtrim($casier, '/') . '/' : ''; // slash final, sinon rien
234 234
 
235
-	foreach ($store as $k => $v) {
236
-		ecrire_config("$stockage$table$prefixe$casier$k", $v);
237
-		if (_request('var_mode') == 'configurer' and autoriser('webmestre')) {
238
-			$trace .= "<br />table $table : " . $prefixe . $k . " = $v;";
239
-		}
240
-	}
235
+    foreach ($store as $k => $v) {
236
+        ecrire_config("$stockage$table$prefixe$casier$k", $v);
237
+        if (_request('var_mode') == 'configurer' and autoriser('webmestre')) {
238
+            $trace .= "<br />table $table : " . $prefixe . $k . " = $v;";
239
+        }
240
+    }
241 241
 
242
-	return $trace;
242
+    return $trace;
243 243
 }
244 244
 
245 245
 /**
@@ -249,21 +249,21 @@  discard block
 block discarded – undo
249 249
  * @param array $valeurs
250 250
  */
251 251
 function cvtconf_configurer_lire_meta($form, &$valeurs) {
252
-	[$table, $casier, $prefixe, $stockage] = cvtconf_definir_configurer_conteneur($form, $valeurs);
252
+    [$table, $casier, $prefixe, $stockage] = cvtconf_definir_configurer_conteneur($form, $valeurs);
253 253
 
254
-	$table = ($table) ? "/$table/" : '';
255
-	$prefixe = ($prefixe ? $prefixe . '_' : '');
256
-	if ($casier) {
257
-		$meta = lire_config("$stockage$table$prefixe$casier");
258
-		$prefixe = '';
259
-	} else {
260
-		$table = rtrim($table, '/');
261
-		$meta = lire_config("$stockage$table");
262
-	}
254
+    $table = ($table) ? "/$table/" : '';
255
+    $prefixe = ($prefixe ? $prefixe . '_' : '');
256
+    if ($casier) {
257
+        $meta = lire_config("$stockage$table$prefixe$casier");
258
+        $prefixe = '';
259
+    } else {
260
+        $table = rtrim($table, '/');
261
+        $meta = lire_config("$stockage$table");
262
+    }
263 263
 
264
-	foreach ($valeurs as $k => $v) {
265
-		if (substr($k, 0, 1) !== '_') {
266
-			$valeurs[$k] = ($meta[$prefixe . $k] ?? null);
267
-		}
268
-	}
264
+    foreach ($valeurs as $k => $v) {
265
+        if (substr($k, 0, 1) !== '_') {
266
+            $valeurs[$k] = ($meta[$prefixe . $k] ?? null);
267
+        }
268
+    }
269 269
 }
Please login to merge, or discard this patch.
ecrire/inc/idna_convert.class.php 1 patch
Spacing   +43 added lines, -46 removed lines patch added patch discarded remove patch
@@ -73,16 +73,16 @@  discard block
 block discarded – undo
73 73
     protected $_lcount = 19;
74 74
     protected $_vcount = 21;
75 75
     protected $_tcount = 28;
76
-    protected $_ncount = 588;   // _vcount * _tcount
76
+    protected $_ncount = 588; // _vcount * _tcount
77 77
     protected $_scount = 11172; // _lcount * _tcount * _vcount
78 78
     protected $_error = false;
79 79
     protected static $_mb_string_overload = null;
80 80
     // See {@link set_paramter()} for details of how to change the following
81 81
     // settings from within your script / application
82
-    protected $_api_encoding = 'utf8';   // Default input charset is UTF-8
83
-    protected $_allow_overlong = false;  // Overlong UTF-8 encodings are forbidden
84
-    protected $_strict_mode = false;     // Behave strict or not
85
-    protected $_idn_version = 2003;      // Can be either 2003 (old, default) or 2008
82
+    protected $_api_encoding = 'utf8'; // Default input charset is UTF-8
83
+    protected $_allow_overlong = false; // Overlong UTF-8 encodings are forbidden
84
+    protected $_strict_mode = false; // Behave strict or not
85
+    protected $_idn_version = 2003; // Can be either 2003 (old, default) or 2008
86 86
 
87 87
     /**
88 88
      * the constructor
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
                             $this->_api_encoding = $v;
141 141
                             break;
142 142
                         default:
143
-                            $this->_error('Set Parameter: Unknown parameter ' . $v . ' for option ' . $k);
143
+                            $this->_error('Set Parameter: Unknown parameter '.$v.' for option '.$k);
144 144
                             return false;
145 145
                     }
146 146
                     break;
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
                     if (in_array($v, array('2003', '2008'))) {
155 155
                         $this->_idn_version = $v;
156 156
                     } else {
157
-                        $this->_error('Set Parameter: Unknown parameter ' . $v . ' for option ' . $k);
157
+                        $this->_error('Set Parameter: Unknown parameter '.$v.' for option '.$k);
158 158
                     }
159 159
                     break;
160 160
                 case 'encode_german_sz': // Deprecated
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
                     }
166 166
                     break;
167 167
                 default:
168
-                    $this->_error('Set Parameter: Unknown option ' . $k);
168
+                    $this->_error('Set Parameter: Unknown option '.$k);
169 169
                     return false;
170 170
             }
171 171
         }
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
                 case 'ucs4_array':
189 189
                     break;
190 190
                 default:
191
-                    $this->_error('Unknown encoding ' . $one_time_encoding);
191
+                    $this->_error('Unknown encoding '.$one_time_encoding);
192 192
                     return false;
193 193
             }
194 194
         }
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
             [$email_pref, $input] = explode('@', $input, 2);
207 207
             $arr = explode('.', $input);
208 208
             foreach ($arr as $k => $v) {
209
-                if (preg_match('!^' . preg_quote($this->_punycode_prefix, '!') . '!', $v)) {
209
+                if (preg_match('!^'.preg_quote($this->_punycode_prefix, '!').'!', $v)) {
210 210
                     $conv = $this->_decode($v);
211 211
                     if ($conv) {
212 212
                         $arr[$k] = $conv;
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
             $input = join('.', $arr);
217 217
             $arr = explode('.', $email_pref);
218 218
             foreach ($arr as $k => $v) {
219
-                if (preg_match('!^' . preg_quote($this->_punycode_prefix, '!') . '!', $v)) {
219
+                if (preg_match('!^'.preg_quote($this->_punycode_prefix, '!').'!', $v)) {
220 220
                     $conv = $this->_decode($v);
221 221
                     if ($conv) {
222 222
                         $arr[$k] = $conv;
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
                 }
225 225
             }
226 226
             $email_pref = join('.', $arr);
227
-            $return = $email_pref . '@' . $input;
227
+            $return = $email_pref.'@'.$input;
228 228
         } elseif (preg_match('![:\./]!', $input)) { // Or a complete domain name (with or without paths / parameters)
229 229
             // No no in strict mode
230 230
             if ($this->_strict_mode) {
@@ -241,13 +241,13 @@  discard block
 block discarded – undo
241 241
                     }
242 242
                 }
243 243
                 $parsed['host'] = join('.', $arr);
244
-                $return = (empty($parsed['scheme']) ? '' : $parsed['scheme'] . (strtolower($parsed['scheme']) == 'mailto' ? ':' : '://')).
245
-                        (empty($parsed['user']) ? '' : $parsed['user'] . (empty($parsed['pass']) ? '' : ':' . $parsed['pass']) . '@').
244
+                $return = (empty($parsed['scheme']) ? '' : $parsed['scheme'].(strtolower($parsed['scheme']) == 'mailto' ? ':' : '://')).
245
+                        (empty($parsed['user']) ? '' : $parsed['user'].(empty($parsed['pass']) ? '' : ':'.$parsed['pass']).'@').
246 246
                         $parsed['host'].
247
-                        (empty($parsed['port']) ? '' : ':' . $parsed['port']).
247
+                        (empty($parsed['port']) ? '' : ':'.$parsed['port']).
248 248
                         (empty($parsed['path']) ? '' : $parsed['path']).
249
-                        (empty($parsed['query']) ? '' : '?' . $parsed['query']).
250
-                        (empty($parsed['fragment']) ? '' : '#' . $parsed['fragment']);
249
+                        (empty($parsed['query']) ? '' : '?'.$parsed['query']).
250
+                        (empty($parsed['fragment']) ? '' : '#'.$parsed['fragment']);
251 251
             } else { // parse_url seems to have failed, try without it
252 252
                 $arr = explode('.', $input);
253 253
                 foreach ($arr as $k => $v) {
@@ -265,8 +265,8 @@  discard block
 block discarded – undo
265 265
         // The output is UTF-8 by default, other output formats need conversion here
266 266
         // If one time encoding is given, use this, else the objects property
267 267
         switch ($one_time_encoding ?: $this->_api_encoding) {
268
-            case 'utf8':        return $return; // break;
269
-            case 'ucs4_string': return $this->_ucs4_to_ucs4_string($this->_utf8_to_ucs4($return));  // break;
268
+            case 'utf8' : return $return; // break;
269
+            case 'ucs4_string': return $this->_ucs4_to_ucs4_string($this->_utf8_to_ucs4($return)); // break;
270 270
             case 'ucs4_array':  return $this->_utf8_to_ucs4($return); // break;
271 271
             default:            $this->_error('Unsupported output format'); return false;
272 272
         }
@@ -283,15 +283,14 @@  discard block
 block discarded – undo
283 283
         // Forcing conversion of input to UCS4 array
284 284
         // If one time encoding is given, use this, else the objects property
285 285
         switch ($one_time_encoding ?: $this->_api_encoding) {
286
-            case 'utf8':
287
-                $decoded = $this->_utf8_to_ucs4($decoded);
286
+            case 'utf8' : $decoded = $this->_utf8_to_ucs4($decoded);
288 287
                 break;
289 288
             case 'ucs4_string':
290 289
                 $decoded = $this->_ucs4_string_to_ucs4($decoded);
291 290
             case 'ucs4_array':
292 291
                 break;
293 292
             default:
294
-                $this->_error('Unsupported input format: ' . ($one_time_encoding ?: $this->_api_encoding));
293
+                $this->_error('Unsupported input format: '.($one_time_encoding ?: $this->_api_encoding));
295 294
                 return false;
296 295
         }
297 296
 
@@ -380,13 +379,13 @@  discard block
 block discarded – undo
380 379
             }
381 380
         }
382 381
         $parsed['host'] = join('.', $arr);
383
-        $return = (empty($parsed['scheme']) ? '' : $parsed['scheme'] . (strtolower($parsed['scheme']) == 'mailto' ? ':' : '://')).
384
-                (empty($parsed['user']) ? '' : $parsed['user'] . (empty($parsed['pass']) ? '' : ':' . $parsed['pass']) . '@').
382
+        $return = (empty($parsed['scheme']) ? '' : $parsed['scheme'].(strtolower($parsed['scheme']) == 'mailto' ? ':' : '://')).
383
+                (empty($parsed['user']) ? '' : $parsed['user'].(empty($parsed['pass']) ? '' : ':'.$parsed['pass']).'@').
385 384
                 $parsed['host'].
386
-                (empty($parsed['port']) ? '' : ':' . $parsed['port']).
385
+                (empty($parsed['port']) ? '' : ':'.$parsed['port']).
387 386
                 (empty($parsed['path']) ? '' : $parsed['path']).
388
-                (empty($parsed['query']) ? '' : '?' . $parsed['query']).
389
-                (empty($parsed['fragment']) ? '' : '#' . $parsed['fragment']);
387
+                (empty($parsed['query']) ? '' : '?'.$parsed['query']).
388
+                (empty($parsed['fragment']) ? '' : '#'.$parsed['fragment']);
390 389
         return $return;
391 390
     }
392 391
 
@@ -409,11 +408,11 @@  discard block
 block discarded – undo
409 408
     {
410 409
         $decoded = array();
411 410
         // find the Punycode prefix
412
-        if (!preg_match('!^' . preg_quote($this->_punycode_prefix, '!') . '!', $encoded)) {
411
+        if (!preg_match('!^'.preg_quote($this->_punycode_prefix, '!').'!', $encoded)) {
413 412
             $this->_error('This is not a punycode string');
414 413
             return false;
415 414
         }
416
-        $encode_test = preg_replace('!^' . preg_quote($this->_punycode_prefix, '!') . '!', '', $encoded);
415
+        $encode_test = preg_replace('!^'.preg_quote($this->_punycode_prefix, '!').'!', '', $encoded);
417 416
         // If nothing left after removing the prefix, it is hopeless
418 417
         if (!$encode_test) {
419 418
             $this->_error('The given encoded string was empty');
@@ -439,8 +438,7 @@  discard block
 block discarded – undo
439 438
             for ($old_idx = $idx, $w = 1, $k = $this->_base; 1; $k += $this->_base) {
440 439
                 $digit = $this->_decode_digit($encoded[$enco_idx++]);
441 440
                 $idx += $digit * $w;
442
-                $t = ($k <= $bias) ? $this->_tmin :
443
-                        (($k >= $bias + $this->_tmax) ? $this->_tmax : ($k - $bias));
441
+                $t = ($k <= $bias) ? $this->_tmin : (($k >= $bias + $this->_tmax) ? $this->_tmax : ($k - $bias));
444 442
                 if ($digit < $t) {
445 443
                     break;
446 444
                 }
@@ -513,7 +511,7 @@  discard block
 block discarded – undo
513 511
             return $encoded; // All codepoints were basic ones
514 512
         }
515 513
         // Start with the prefix; copy it to output
516
-        $encoded = $this->_punycode_prefix . $encoded;
514
+        $encoded = $this->_punycode_prefix.$encoded;
517 515
         // If we have basic code points in output, add an hyphen to the end
518 516
         if ($codecount) {
519 517
             $encoded .= '-';
@@ -540,8 +538,7 @@  discard block
 block discarded – undo
540 538
                     $delta++;
541 539
                 } elseif ($decoded[$i] == $cur_code) {
542 540
                     for ($q = $delta, $k = $this->_base; 1; $k += $this->_base) {
543
-                        $t = ($k <= $bias) ? $this->_tmin :
544
-                                (($k >= $bias + $this->_tmax) ? $this->_tmax : $k - $bias);
541
+                        $t = ($k <= $bias) ? $this->_tmin : (($k >= $bias + $this->_tmax) ? $this->_tmax : $k - $bias);
545 542
                         if ($q < $t) {
546 543
                             break;
547 544
                         }
@@ -628,12 +625,12 @@  discard block
 block discarded – undo
628 625
             }
629 626
             // Try to find prohibited input
630 627
             if (in_array($v, self::$NP['prohibit']) || in_array($v, self::$NP['general_prohibited'])) {
631
-                $this->_error('NAMEPREP: Prohibited input U+' . sprintf('%08X', $v));
628
+                $this->_error('NAMEPREP: Prohibited input U+'.sprintf('%08X', $v));
632 629
                 return false;
633 630
             }
634 631
             foreach (self::$NP['prohibit_ranges'] as $range) {
635 632
                 if ($range[0] <= $v && $v <= $range[1]) {
636
-                    $this->_error('NAMEPREP: Prohibited input U+' . sprintf('%08X', $v));
633
+                    $this->_error('NAMEPREP: Prohibited input U+'.sprintf('%08X', $v));
637 634
                     return false;
638 635
                 }
639 636
             }
@@ -871,7 +868,7 @@  discard block
 block discarded – undo
871 868
                 $output[$out_len] = $v;
872 869
                 ++$out_len;
873 870
                 if ('add' == $mode) {
874
-                    $this->_error('Conversion from UTF-8 to UCS-4 failed: malformed input at byte ' . $k);
871
+                    $this->_error('Conversion from UTF-8 to UCS-4 failed: malformed input at byte '.$k);
875 872
                     return false;
876 873
                 }
877 874
                 continue;
@@ -896,7 +893,7 @@  discard block
 block discarded – undo
896 893
                     $next_byte = 4;
897 894
                     $v = ($v - 252) << 30;
898 895
                 } else {
899
-                    $this->_error('This might be UTF-8, but I don\'t understand it at byte ' . $k);
896
+                    $this->_error('This might be UTF-8, but I don\'t understand it at byte '.$k);
900 897
                     return false;
901 898
                 }
902 899
                 if ('add' == $mode) {
@@ -909,7 +906,7 @@  discard block
 block discarded – undo
909 906
                 if (!$this->_allow_overlong && $test == 'range') {
910 907
                     $test = 'none';
911 908
                     if (($v < 0xA0 && $start_byte == 0xE0) || ($v < 0x90 && $start_byte == 0xF0) || ($v > 0x8F && $start_byte == 0xF4)) {
912
-                        $this->_error('Bogus UTF-8 character detected (out of legal range) at byte ' . $k);
909
+                        $this->_error('Bogus UTF-8 character detected (out of legal range) at byte '.$k);
913 910
                         return false;
914 911
                     }
915 912
                 }
@@ -918,7 +915,7 @@  discard block
 block discarded – undo
918 915
                     $output[($out_len - 1)] += $v;
919 916
                     --$next_byte;
920 917
                 } else {
921
-                    $this->_error('Conversion from UTF-8 to UCS-4 failed: malformed input at byte ' . $k);
918
+                    $this->_error('Conversion from UTF-8 to UCS-4 failed: malformed input at byte '.$k);
922 919
                     return false;
923 920
                 }
924 921
                 if ($next_byte < 0) {
@@ -942,13 +939,13 @@  discard block
 block discarded – undo
942 939
             if ($v < 128) { // 7bit are transferred literally
943 940
                 $output .= chr($v);
944 941
             } elseif ($v < (1 << 11)) { // 2 bytes
945
-                $output .= chr(192 + ($v >> 6)) . chr(128 + ($v & 63));
942
+                $output .= chr(192 + ($v >> 6)).chr(128 + ($v & 63));
946 943
             } elseif ($v < (1 << 16)) { // 3 bytes
947
-                $output .= chr(224 + ($v >> 12)) . chr(128 + (($v >> 6) & 63)) . chr(128 + ($v & 63));
944
+                $output .= chr(224 + ($v >> 12)).chr(128 + (($v >> 6) & 63)).chr(128 + ($v & 63));
948 945
             } elseif ($v < (1 << 21)) { // 4 bytes
949
-                $output .= chr(240 + ($v >> 18)) . chr(128 + (($v >> 12) & 63)) . chr(128 + (($v >> 6) & 63)) . chr(128 + ($v & 63));
946
+                $output .= chr(240 + ($v >> 18)).chr(128 + (($v >> 12) & 63)).chr(128 + (($v >> 6) & 63)).chr(128 + ($v & 63));
950 947
             } else {
951
-                $this->_error('Conversion from UCS-4 to UTF-8 failed: malformed input at byte ' . $k);
948
+                $this->_error('Conversion from UCS-4 to UTF-8 failed: malformed input at byte '.$k);
952 949
                 return false;
953 950
             }
954 951
         }
@@ -967,7 +964,7 @@  discard block
 block discarded – undo
967 964
         // Take array values and split output to 4 bytes per value
968 965
         // The bit mask is 255, which reads &11111111
969 966
         foreach ($input as $v) {
970
-            $output .= chr(($v >> 24) & 255) . chr(($v >> 16) & 255) . chr(($v >> 8) & 255) . chr($v & 255);
967
+            $output .= chr(($v >> 24) & 255).chr(($v >> 16) & 255).chr(($v >> 8) & 255).chr($v & 255);
971 968
         }
972 969
         return $output;
973 970
     }
@@ -997,7 +994,7 @@  discard block
 block discarded – undo
997 994
                 $out_len++;
998 995
                 $output[$out_len] = 0;
999 996
             }
1000
-            $output[$out_len] += ord($input[$i]) << (8 * (3 - ($i % 4) ) );
997
+            $output[$out_len] += ord($input[$i]) << (8 * (3 - ($i % 4)));
1001 998
         }
1002 999
         return $output;
1003 1000
     }
Please login to merge, or discard this patch.
ecrire/inc/bandeau.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 			$_id = $e['id_table_objet'];
51 51
 			if (isset($contexte[$_id]) and $id = intval($contexte[$_id])) {
52 52
 				$table = $e['table_objet_sql'];
53
-				$row = sql_fetsel('*', $table, "$_id=" . intval($id));
53
+				$row = sql_fetsel('*', $table, "$_id=".intval($id));
54 54
 				if (isset($row['id_rubrique'])) {
55 55
 					$contexte['id_rubrique'] = $row['id_rubrique'];
56 56
 					if (isset($row['id_secteur'])) {
@@ -117,8 +117,8 @@  discard block
 block discarded – undo
117 117
 				$boutons_admin[$parent]->sousmenu = array_slice($boutons_admin[$parent]->sousmenu, 0, $position)
118 118
 					+ [
119 119
 						$id => new Bouton(
120
-							($icones and !empty($infos['icone'])) ? find_in_theme($infos['icone']) : '',  // icone
121
-							$infos['titre'],  // titre
120
+							($icones and !empty($infos['icone'])) ? find_in_theme($infos['icone']) : '', // icone
121
+							$infos['titre'], // titre
122 122
 							(isset($infos['action']) and $infos['action']) ? $infos['action'] : null,
123 123
 							(isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : null
124 124
 						)
@@ -135,8 +135,8 @@  discard block
 block discarded – undo
135 135
 				$boutons_admin = array_slice($boutons_admin, 0, $position)
136 136
 					+ [
137 137
 						$id => new Bouton(
138
-							($icones and isset($infos['icone']) and $infos['icone']) ? find_in_theme($infos['icone']) : '',  // icone
139
-							$infos['titre'],  // titre
138
+							($icones and isset($infos['icone']) and $infos['icone']) ? find_in_theme($infos['icone']) : '', // icone
139
+							$infos['titre'], // titre
140 140
 							(isset($infos['action']) and $infos['action']) ? $infos['action'] : null,
141 141
 							(isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : null
142 142
 						)
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 			$libelles = $isfavoris = $favoris = [];
182 182
 			foreach ($menu->sousmenu as $key => $item) {
183 183
 				$libelles[$key] = strtolower(translitteration(_T($item->libelle)));
184
-				$isfavoris[$key] = (bool)$item->favori;
184
+				$isfavoris[$key] = (bool) $item->favori;
185 185
 				$favoris[$key] = $item->favori;
186 186
 			}
187 187
 			if ($avec_favoris) {
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 		$url = str_replace('&amp;', '&', $url);
224 224
 		while (preg_match(',[&?]([a-z_]+)=@([a-z_]+)@,i', $url, $matches)) {
225 225
 			if ($matches[2] == 'id_secteur' and !isset($contexte['id_secteur']) and isset($contexte['id_rubrique'])) {
226
-				$contexte['id_secteur'] = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($contexte['id_rubrique']));
226
+				$contexte['id_secteur'] = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique='.intval($contexte['id_rubrique']));
227 227
 			}
228 228
 			$val = _request($matches[2], $contexte);
229 229
 			$url = parametre_url($url, $matches[1], $val ?: '', '&');
Please login to merge, or discard this patch.
Indentation   +149 added lines, -149 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/boutons');
@@ -37,33 +37,33 @@  discard block
 block discarded – undo
37 37
  *     Contexte
38 38
  **/
39 39
 function definir_barre_contexte($contexte = null) {
40
-	if (is_null($contexte)) {
41
-		$contexte = $_GET;
42
-	} elseif (is_string($contexte)) {
43
-		$contexte = unserialize($contexte);
44
-	}
45
-	if (!isset($contexte['id_rubrique']) and isset($contexte['exec'])) {
46
-		if (!function_exists('trouver_objet_exec')) {
47
-			include_spip('inc/pipelines_ecrire');
48
-		}
49
-		if ($e = trouver_objet_exec($contexte['exec'])) {
50
-			$_id = $e['id_table_objet'];
51
-			if (isset($contexte[$_id]) and $id = intval($contexte[$_id])) {
52
-				$table = $e['table_objet_sql'];
53
-				$row = sql_fetsel('*', $table, "$_id=" . intval($id));
54
-				if (isset($row['id_rubrique'])) {
55
-					$contexte['id_rubrique'] = $row['id_rubrique'];
56
-					if (isset($row['id_secteur'])) {
57
-						$contexte['id_secteur'] = $row['id_secteur'];
58
-					}
59
-				} elseif (isset($row['id_groupe'])) {
60
-					// TODO supprimer ce bloc quand https://core.spip.net/issues/3844 sera réalisé
61
-					$contexte['id_groupe'] = $row['id_groupe'];
62
-				}
63
-			}
64
-		}
65
-	}
66
-	return $contexte;
40
+    if (is_null($contexte)) {
41
+        $contexte = $_GET;
42
+    } elseif (is_string($contexte)) {
43
+        $contexte = unserialize($contexte);
44
+    }
45
+    if (!isset($contexte['id_rubrique']) and isset($contexte['exec'])) {
46
+        if (!function_exists('trouver_objet_exec')) {
47
+            include_spip('inc/pipelines_ecrire');
48
+        }
49
+        if ($e = trouver_objet_exec($contexte['exec'])) {
50
+            $_id = $e['id_table_objet'];
51
+            if (isset($contexte[$_id]) and $id = intval($contexte[$_id])) {
52
+                $table = $e['table_objet_sql'];
53
+                $row = sql_fetsel('*', $table, "$_id=" . intval($id));
54
+                if (isset($row['id_rubrique'])) {
55
+                    $contexte['id_rubrique'] = $row['id_rubrique'];
56
+                    if (isset($row['id_secteur'])) {
57
+                        $contexte['id_secteur'] = $row['id_secteur'];
58
+                    }
59
+                } elseif (isset($row['id_groupe'])) {
60
+                    // TODO supprimer ce bloc quand https://core.spip.net/issues/3844 sera réalisé
61
+                    $contexte['id_groupe'] = $row['id_groupe'];
62
+                }
63
+            }
64
+        }
65
+    }
66
+    return $contexte;
67 67
 }
68 68
 
69 69
 /**
@@ -79,89 +79,89 @@  discard block
 block discarded – undo
79 79
  * @return array
80 80
  */
81 81
 function definir_barre_boutons($contexte = [], $icones = true, $autorise = true) {
82
-	include_spip('inc/autoriser');
83
-	$boutons_admin = [];
82
+    include_spip('inc/autoriser');
83
+    $boutons_admin = [];
84 84
 
85
-	// les boutons du core, issus de ecrire/paquet.xml
86
-	$liste_boutons = [];
85
+    // les boutons du core, issus de ecrire/paquet.xml
86
+    $liste_boutons = [];
87 87
 
88
-	// ajouter les boutons issus des plugin via paquet.xml
89
-	if (
90
-		function_exists('boutons_plugins')
91
-		and is_array($liste_boutons_plugins = boutons_plugins())
92
-	) {
93
-		$liste_boutons = &$liste_boutons_plugins;
94
-	}
88
+    // ajouter les boutons issus des plugin via paquet.xml
89
+    if (
90
+        function_exists('boutons_plugins')
91
+        and is_array($liste_boutons_plugins = boutons_plugins())
92
+    ) {
93
+        $liste_boutons = &$liste_boutons_plugins;
94
+    }
95 95
 
96
-	foreach ($liste_boutons as $id => $infos) {
97
-		$parent = '';
98
-		// les boutons principaux ne sont pas soumis a autorisation
99
-		if (
100
-			!isset($infos['parent'])
101
-			or !($parent = $infos['parent'])
102
-			or !$autorise
103
-			or autoriser('menu', "_$id", 0, null, ['contexte' => $contexte])
104
-		) {
105
-			if (
106
-				$parent
107
-				and $parent = preg_replace(',^bando_,', 'menu_', $parent)
108
-				and isset($boutons_admin[$parent])
109
-			) {
110
-				$position = (isset($infos['position']) and strlen($infos['position'])) ? intval($infos['position']) : count($boutons_admin[$parent]->sousmenu);
111
-				if ($position < 0) {
112
-					$position = count($boutons_admin[$parent]->sousmenu) + 1 + $position;
113
-				}
114
-				$boutons_admin[$parent]->sousmenu = array_slice($boutons_admin[$parent]->sousmenu, 0, $position)
115
-					+ [
116
-						$id => new Bouton(
117
-							($icones and !empty($infos['icone'])) ? find_in_theme($infos['icone']) : '',  // icone
118
-							$infos['titre'],  // titre
119
-							(isset($infos['action']) and $infos['action']) ? $infos['action'] : null,
120
-							(isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : null
121
-						)
122
-					]
123
-					+ array_slice($boutons_admin[$parent]->sousmenu, $position, 100);
124
-			}
125
-			if (
126
-				!$parent
127
-				// provisoire, eviter les vieux boutons
128
-				and (!in_array($id, ['forum', 'statistiques_visites']))
129
-				and (!$autorise or autoriser('menugrandeentree', "_$id", 0, null, ['contexte' => $contexte]))
130
-			) {
131
-				$position = (isset($infos['position']) and $infos['position']) ? $infos['position'] : count($boutons_admin);
132
-				$boutons_admin = array_slice($boutons_admin, 0, $position)
133
-					+ [
134
-						$id => new Bouton(
135
-							($icones and isset($infos['icone']) and $infos['icone']) ? find_in_theme($infos['icone']) : '',  // icone
136
-							$infos['titre'],  // titre
137
-							(isset($infos['action']) and $infos['action']) ? $infos['action'] : null,
138
-							(isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : null
139
-						)
140
-					]
141
-					+ array_slice($boutons_admin, $position, 100);
142
-			}
143
-		}
144
-	}
145
-	$boutons_admin = pipeline('ajouter_menus', $boutons_admin);
96
+    foreach ($liste_boutons as $id => $infos) {
97
+        $parent = '';
98
+        // les boutons principaux ne sont pas soumis a autorisation
99
+        if (
100
+            !isset($infos['parent'])
101
+            or !($parent = $infos['parent'])
102
+            or !$autorise
103
+            or autoriser('menu', "_$id", 0, null, ['contexte' => $contexte])
104
+        ) {
105
+            if (
106
+                $parent
107
+                and $parent = preg_replace(',^bando_,', 'menu_', $parent)
108
+                and isset($boutons_admin[$parent])
109
+            ) {
110
+                $position = (isset($infos['position']) and strlen($infos['position'])) ? intval($infos['position']) : count($boutons_admin[$parent]->sousmenu);
111
+                if ($position < 0) {
112
+                    $position = count($boutons_admin[$parent]->sousmenu) + 1 + $position;
113
+                }
114
+                $boutons_admin[$parent]->sousmenu = array_slice($boutons_admin[$parent]->sousmenu, 0, $position)
115
+                    + [
116
+                        $id => new Bouton(
117
+                            ($icones and !empty($infos['icone'])) ? find_in_theme($infos['icone']) : '',  // icone
118
+                            $infos['titre'],  // titre
119
+                            (isset($infos['action']) and $infos['action']) ? $infos['action'] : null,
120
+                            (isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : null
121
+                        )
122
+                    ]
123
+                    + array_slice($boutons_admin[$parent]->sousmenu, $position, 100);
124
+            }
125
+            if (
126
+                !$parent
127
+                // provisoire, eviter les vieux boutons
128
+                and (!in_array($id, ['forum', 'statistiques_visites']))
129
+                and (!$autorise or autoriser('menugrandeentree', "_$id", 0, null, ['contexte' => $contexte]))
130
+            ) {
131
+                $position = (isset($infos['position']) and $infos['position']) ? $infos['position'] : count($boutons_admin);
132
+                $boutons_admin = array_slice($boutons_admin, 0, $position)
133
+                    + [
134
+                        $id => new Bouton(
135
+                            ($icones and isset($infos['icone']) and $infos['icone']) ? find_in_theme($infos['icone']) : '',  // icone
136
+                            $infos['titre'],  // titre
137
+                            (isset($infos['action']) and $infos['action']) ? $infos['action'] : null,
138
+                            (isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : null
139
+                        )
140
+                    ]
141
+                    + array_slice($boutons_admin, $position, 100);
142
+            }
143
+        }
144
+    }
145
+    $boutons_admin = pipeline('ajouter_menus', $boutons_admin);
146 146
 
147
-	// définir les favoris et positions d’origine
148
-	if ($boutons_admin) {
149
-		$menus_favoris = obtenir_menus_favoris();
150
-		$i = 1;
151
-		foreach ($boutons_admin as $key => $menu) {
152
-			$menu->favori = table_valeur($menus_favoris, $key, false);
153
-			$menu->position = $i++;
154
-			if ($menu->sousmenu) {
155
-				$j = 1;
156
-				foreach ($menu->sousmenu as $key => $bouton) {
157
-					$bouton->favori = table_valeur($menus_favoris, $key, false);
158
-					$bouton->position = $j++;
159
-				}
160
-			}
161
-		}
162
-	}
147
+    // définir les favoris et positions d’origine
148
+    if ($boutons_admin) {
149
+        $menus_favoris = obtenir_menus_favoris();
150
+        $i = 1;
151
+        foreach ($boutons_admin as $key => $menu) {
152
+            $menu->favori = table_valeur($menus_favoris, $key, false);
153
+            $menu->position = $i++;
154
+            if ($menu->sousmenu) {
155
+                $j = 1;
156
+                foreach ($menu->sousmenu as $key => $bouton) {
157
+                    $bouton->favori = table_valeur($menus_favoris, $key, false);
158
+                    $bouton->position = $j++;
159
+                }
160
+            }
161
+        }
162
+    }
163 163
 
164
-	return $boutons_admin;
164
+    return $boutons_admin;
165 165
 }
166 166
 
167 167
 /**
@@ -173,22 +173,22 @@  discard block
 block discarded – undo
173 173
  * @return Bouton[]
174 174
  */
175 175
 function trier_boutons_enfants_par_alpha($menus, $avec_favoris = false) {
176
-	foreach ($menus as $menu) {
177
-		if ($menu->sousmenu) {
178
-			$libelles = $isfavoris = $favoris = [];
179
-			foreach ($menu->sousmenu as $key => $item) {
180
-				$libelles[$key] = strtolower(translitteration(_T($item->libelle)));
181
-				$isfavoris[$key] = (bool)$item->favori;
182
-				$favoris[$key] = $item->favori;
183
-			}
184
-			if ($avec_favoris) {
185
-				array_multisort($isfavoris, SORT_DESC, $favoris, SORT_ASC, $libelles, SORT_ASC, $menu->sousmenu);
186
-			} else {
187
-				array_multisort($libelles, SORT_ASC, $menu->sousmenu);
188
-			}
189
-		}
190
-	}
191
-	return $menus;
176
+    foreach ($menus as $menu) {
177
+        if ($menu->sousmenu) {
178
+            $libelles = $isfavoris = $favoris = [];
179
+            foreach ($menu->sousmenu as $key => $item) {
180
+                $libelles[$key] = strtolower(translitteration(_T($item->libelle)));
181
+                $isfavoris[$key] = (bool)$item->favori;
182
+                $favoris[$key] = $item->favori;
183
+            }
184
+            if ($avec_favoris) {
185
+                array_multisort($isfavoris, SORT_DESC, $favoris, SORT_ASC, $libelles, SORT_ASC, $menu->sousmenu);
186
+            } else {
187
+                array_multisort($libelles, SORT_ASC, $menu->sousmenu);
188
+            }
189
+        }
190
+    }
191
+    return $menus;
192 192
 }
193 193
 
194 194
 /**
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
  * @return Bouton[]
200 200
  */
201 201
 function trier_boutons_enfants_par_favoris_alpha($menus) {
202
-	return trier_boutons_enfants_par_alpha($menus, true);
202
+    return trier_boutons_enfants_par_alpha($menus, true);
203 203
 }
204 204
 
205 205
 
@@ -212,23 +212,23 @@  discard block
 block discarded – undo
212 212
  * @return string
213 213
  */
214 214
 function bandeau_creer_url($url, $args = '', $contexte = null) {
215
-	if (!preg_match(',[\/\?],', $url)) {
216
-		$url = generer_url_ecrire($url, $args, true);
217
-		// recuperer les parametres du contexte demande par l'url sous la forme
218
-		// &truc=@machin@
219
-		// @machin@ etant remplace par _request('machin')
220
-		$url = str_replace('&amp;', '&', $url);
221
-		while (preg_match(',[&?]([a-z_]+)=@([a-z_]+)@,i', $url, $matches)) {
222
-			if ($matches[2] == 'id_secteur' and !isset($contexte['id_secteur']) and isset($contexte['id_rubrique'])) {
223
-				$contexte['id_secteur'] = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($contexte['id_rubrique']));
224
-			}
225
-			$val = _request($matches[2], $contexte);
226
-			$url = parametre_url($url, $matches[1], $val ?: '', '&');
227
-		}
228
-		$url = str_replace('&', '&amp;', $url);
229
-	}
215
+    if (!preg_match(',[\/\?],', $url)) {
216
+        $url = generer_url_ecrire($url, $args, true);
217
+        // recuperer les parametres du contexte demande par l'url sous la forme
218
+        // &truc=@machin@
219
+        // @machin@ etant remplace par _request('machin')
220
+        $url = str_replace('&amp;', '&', $url);
221
+        while (preg_match(',[&?]([a-z_]+)=@([a-z_]+)@,i', $url, $matches)) {
222
+            if ($matches[2] == 'id_secteur' and !isset($contexte['id_secteur']) and isset($contexte['id_rubrique'])) {
223
+                $contexte['id_secteur'] = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($contexte['id_rubrique']));
224
+            }
225
+            $val = _request($matches[2], $contexte);
226
+            $url = parametre_url($url, $matches[1], $val ?: '', '&');
227
+        }
228
+        $url = str_replace('&', '&amp;', $url);
229
+    }
230 230
 
231
-	return $url;
231
+    return $url;
232 232
 }
233 233
 
234 234
 /**
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
  *     Code HTML du bandeau
239 239
  */
240 240
 function inc_bandeau_dist() {
241
-	return recuperer_fond('prive/squelettes/inclure/barre-nav', $_GET);
241
+    return recuperer_fond('prive/squelettes/inclure/barre-nav', $_GET);
242 242
 }
243 243
 
244 244
 
@@ -247,13 +247,13 @@  discard block
 block discarded – undo
247 247
  * @return array
248 248
  */
249 249
 function obtenir_menus_favoris() {
250
-	if (
251
-		isset($GLOBALS['visiteur_session']['prefs']['menus_favoris'])
252
-		and is_array($GLOBALS['visiteur_session']['prefs']['menus_favoris'])
253
-		and $GLOBALS['visiteur_session']['prefs']['menus_favoris']
254
-	) {
255
-		return $GLOBALS['visiteur_session']['prefs']['menus_favoris'];
256
-	}
257
-	$definir_menus_favoris = charger_fonction('definir_menus_favoris', 'inc');
258
-	return $definir_menus_favoris();
250
+    if (
251
+        isset($GLOBALS['visiteur_session']['prefs']['menus_favoris'])
252
+        and is_array($GLOBALS['visiteur_session']['prefs']['menus_favoris'])
253
+        and $GLOBALS['visiteur_session']['prefs']['menus_favoris']
254
+    ) {
255
+        return $GLOBALS['visiteur_session']['prefs']['menus_favoris'];
256
+    }
257
+    $definir_menus_favoris = charger_fonction('definir_menus_favoris', 'inc');
258
+    return $definir_menus_favoris();
259 259
 }
Please login to merge, or discard this patch.
ecrire/inc/filtres_images_mini.php 2 patches
Indentation   +316 added lines, -316 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
  */
19 19
 
20 20
 if (!defined('_ECRIRE_INC_VERSION')) {
21
-	return;
21
+    return;
22 22
 }
23 23
 include_spip('inc/filtres_images_lib_mini'); // par precaution
24 24
 
@@ -31,161 +31,161 @@  discard block
 block discarded – undo
31 31
  *    Le code hexadécimal de la couleur (sans le #) ou le code couleur textuel si non trouvé
32 32
  */
33 33
 function couleur_html_to_hex($couleur) {
34
-	$couleurs_html = [
35
-		'aliceblue' => 'F0F8FF',
36
-		'antiquewhite' => 'FAEBD7',
37
-		'aqua' => '00FFFF',
38
-		'aquamarine' => '7FFFD4',
39
-		'azure' => 'F0FFFF',
40
-		'beige' => 'F5F5DC',
41
-		'bisque' => 'FFE4C4',
42
-		'black' => '000000',
43
-		'blanchedalmond' => 'FFEBCD',
44
-		'blue' => '0000FF',
45
-		'blueviolet' => '8A2BE2',
46
-		'brown' => 'A52A2A',
47
-		'burlywood' => 'DEB887',
48
-		'cadetblue' => '5F9EA0',
49
-		'chartreuse' => '7FFF00',
50
-		'chocolate' => 'D2691E',
51
-		'coral' => 'FF7F50',
52
-		'cornflowerblue' => '6495ED',
53
-		'cornsilk' => 'FFF8DC',
54
-		'crimson' => 'DC143C',
55
-		'cyan' => '00FFFF',
56
-		'darkblue' => '00008B',
57
-		'darkcyan' => '008B8B',
58
-		'darkgoldenrod' => 'B8860B',
59
-		'darkgray' => 'A9A9A9',
60
-		'darkgreen' => '006400',
61
-		'darkgrey' => 'A9A9A9',
62
-		'darkkhaki' => 'BDB76B',
63
-		'darkmagenta' => '8B008B',
64
-		'darkolivegreen' => '556B2F',
65
-		'darkorange' => 'FF8C00',
66
-		'darkorchid' => '9932CC',
67
-		'darkred' => '8B0000',
68
-		'darksalmon' => 'E9967A',
69
-		'darkseagreen' => '8FBC8F',
70
-		'darkslateblue' => '483D8B',
71
-		'darkslategray' => '2F4F4F',
72
-		'darkslategrey' => '2F4F4F',
73
-		'darkturquoise' => '00CED1',
74
-		'darkviolet' => '9400D3',
75
-		'deeppink' => 'FF1493',
76
-		'deepskyblue' => '00BFFF',
77
-		'dimgray' => '696969',
78
-		'dimgrey' => '696969',
79
-		'dodgerblue' => '1E90FF',
80
-		'firebrick' => 'B22222',
81
-		'floralwhite' => 'FFFAF0',
82
-		'forestgreen' => '228B22',
83
-		'fuchsia' => 'FF00FF',
84
-		'gainsboro' => 'DCDCDC',
85
-		'ghostwhite' => 'F8F8FF',
86
-		'gold' => 'FFD700',
87
-		'goldenrod' => 'DAA520',
88
-		'gray' => '808080',
89
-		'green' => '008000',
90
-		'greenyellow' => 'ADFF2F',
91
-		'grey' => '808080',
92
-		'honeydew' => 'F0FFF0',
93
-		'hotpink' => 'FF69B4',
94
-		'indianred' => 'CD5C5C',
95
-		'indigo' => '4B0082',
96
-		'ivory' => 'FFFFF0',
97
-		'khaki' => 'F0E68C',
98
-		'lavender' => 'E6E6FA',
99
-		'lavenderblush' => 'FFF0F5',
100
-		'lawngreen' => '7CFC00',
101
-		'lemonchiffon' => 'FFFACD',
102
-		'lightblue' => 'ADD8E6',
103
-		'lightcoral' => 'F08080',
104
-		'lightcyan' => 'E0FFFF',
105
-		'lightgoldenrodyellow' => 'FAFAD2',
106
-		'lightgray' => 'D3D3D3',
107
-		'lightgreen' => '90EE90',
108
-		'lightgrey' => 'D3D3D3',
109
-		'lightpink' => 'FFB6C1',
110
-		'lightsalmon' => 'FFA07A',
111
-		'lightseagreen' => '20B2AA',
112
-		'lightskyblue' => '87CEFA',
113
-		'lightslategray' => '778899',
114
-		'lightslategrey' => '778899',
115
-		'lightsteelblue' => 'B0C4DE',
116
-		'lightyellow' => 'FFFFE0',
117
-		'lime' => '00FF00',
118
-		'limegreen' => '32CD32',
119
-		'linen' => 'FAF0E6',
120
-		'magenta' => 'FF00FF',
121
-		'maroon' => '800000',
122
-		'mediumaquamarine' => '66CDAA',
123
-		'mediumblue' => '0000CD',
124
-		'mediumorchid' => 'BA55D3',
125
-		'mediumpurple' => '9370DB',
126
-		'mediumseagreen' => '3CB371',
127
-		'mediumslateblue' => '7B68EE',
128
-		'mediumspringgreen' => '00FA9A',
129
-		'mediumturquoise' => '48D1CC',
130
-		'mediumvioletred' => 'C71585',
131
-		'midnightblue' => '191970',
132
-		'mintcream' => 'F5FFFA',
133
-		'mistyrose' => 'FFE4E1',
134
-		'moccasin' => 'FFE4B5',
135
-		'navajowhite' => 'FFDEAD',
136
-		'navy' => '000080',
137
-		'oldlace' => 'FDF5E6',
138
-		'olive' => '808000',
139
-		'olivedrab' => '6B8E23',
140
-		'orange' => 'FFA500',
141
-		'orangered' => 'FF4500',
142
-		'orchid' => 'DA70D6',
143
-		'palegoldenrod' => 'EEE8AA',
144
-		'palegreen' => '98FB98',
145
-		'paleturquoise' => 'AFEEEE',
146
-		'palevioletred' => 'DB7093',
147
-		'papayawhip' => 'FFEFD5',
148
-		'peachpuff' => 'FFDAB9',
149
-		'peru' => 'CD853F',
150
-		'pink' => 'FFC0CB',
151
-		'plum' => 'DDA0DD',
152
-		'powderblue' => 'B0E0E6',
153
-		'purple' => '800080',
154
-		'rebeccapurple' => '663399',
155
-		'red' => 'FF0000',
156
-		'rosybrown' => 'BC8F8F',
157
-		'royalblue' => '4169E1',
158
-		'saddlebrown' => '8B4513',
159
-		'salmon' => 'FA8072',
160
-		'sandybrown' => 'F4A460',
161
-		'seagreen' => '2E8B57',
162
-		'seashell' => 'FFF5EE',
163
-		'sienna' => 'A0522D',
164
-		'silver' => 'C0C0C0',
165
-		'skyblue' => '87CEEB',
166
-		'slateblue' => '6A5ACD',
167
-		'slategray' => '708090',
168
-		'slategrey' => '708090',
169
-		'snow' => 'FFFAFA',
170
-		'springgreen' => '00FF7F',
171
-		'steelblue' => '4682B4',
172
-		'tan' => 'D2B48C',
173
-		'teal' => '008080',
174
-		'thistle' => 'D8BFD8',
175
-		'tomato' => 'FF6347',
176
-		'turquoise' => '40E0D0',
177
-		'violet' => 'EE82EE',
178
-		'wheat' => 'F5DEB3',
179
-		'white' => 'FFFFFF',
180
-		'whitesmoke' => 'F5F5F5',
181
-		'yellow' => 'FFFF00',
182
-		'yellowgreen' => '9ACD32',
183
-	];
184
-	if (isset($couleurs_html[$lc = strtolower($couleur)])) {
185
-		return $couleurs_html[$lc];
186
-	}
187
-
188
-	return $couleur;
34
+    $couleurs_html = [
35
+        'aliceblue' => 'F0F8FF',
36
+        'antiquewhite' => 'FAEBD7',
37
+        'aqua' => '00FFFF',
38
+        'aquamarine' => '7FFFD4',
39
+        'azure' => 'F0FFFF',
40
+        'beige' => 'F5F5DC',
41
+        'bisque' => 'FFE4C4',
42
+        'black' => '000000',
43
+        'blanchedalmond' => 'FFEBCD',
44
+        'blue' => '0000FF',
45
+        'blueviolet' => '8A2BE2',
46
+        'brown' => 'A52A2A',
47
+        'burlywood' => 'DEB887',
48
+        'cadetblue' => '5F9EA0',
49
+        'chartreuse' => '7FFF00',
50
+        'chocolate' => 'D2691E',
51
+        'coral' => 'FF7F50',
52
+        'cornflowerblue' => '6495ED',
53
+        'cornsilk' => 'FFF8DC',
54
+        'crimson' => 'DC143C',
55
+        'cyan' => '00FFFF',
56
+        'darkblue' => '00008B',
57
+        'darkcyan' => '008B8B',
58
+        'darkgoldenrod' => 'B8860B',
59
+        'darkgray' => 'A9A9A9',
60
+        'darkgreen' => '006400',
61
+        'darkgrey' => 'A9A9A9',
62
+        'darkkhaki' => 'BDB76B',
63
+        'darkmagenta' => '8B008B',
64
+        'darkolivegreen' => '556B2F',
65
+        'darkorange' => 'FF8C00',
66
+        'darkorchid' => '9932CC',
67
+        'darkred' => '8B0000',
68
+        'darksalmon' => 'E9967A',
69
+        'darkseagreen' => '8FBC8F',
70
+        'darkslateblue' => '483D8B',
71
+        'darkslategray' => '2F4F4F',
72
+        'darkslategrey' => '2F4F4F',
73
+        'darkturquoise' => '00CED1',
74
+        'darkviolet' => '9400D3',
75
+        'deeppink' => 'FF1493',
76
+        'deepskyblue' => '00BFFF',
77
+        'dimgray' => '696969',
78
+        'dimgrey' => '696969',
79
+        'dodgerblue' => '1E90FF',
80
+        'firebrick' => 'B22222',
81
+        'floralwhite' => 'FFFAF0',
82
+        'forestgreen' => '228B22',
83
+        'fuchsia' => 'FF00FF',
84
+        'gainsboro' => 'DCDCDC',
85
+        'ghostwhite' => 'F8F8FF',
86
+        'gold' => 'FFD700',
87
+        'goldenrod' => 'DAA520',
88
+        'gray' => '808080',
89
+        'green' => '008000',
90
+        'greenyellow' => 'ADFF2F',
91
+        'grey' => '808080',
92
+        'honeydew' => 'F0FFF0',
93
+        'hotpink' => 'FF69B4',
94
+        'indianred' => 'CD5C5C',
95
+        'indigo' => '4B0082',
96
+        'ivory' => 'FFFFF0',
97
+        'khaki' => 'F0E68C',
98
+        'lavender' => 'E6E6FA',
99
+        'lavenderblush' => 'FFF0F5',
100
+        'lawngreen' => '7CFC00',
101
+        'lemonchiffon' => 'FFFACD',
102
+        'lightblue' => 'ADD8E6',
103
+        'lightcoral' => 'F08080',
104
+        'lightcyan' => 'E0FFFF',
105
+        'lightgoldenrodyellow' => 'FAFAD2',
106
+        'lightgray' => 'D3D3D3',
107
+        'lightgreen' => '90EE90',
108
+        'lightgrey' => 'D3D3D3',
109
+        'lightpink' => 'FFB6C1',
110
+        'lightsalmon' => 'FFA07A',
111
+        'lightseagreen' => '20B2AA',
112
+        'lightskyblue' => '87CEFA',
113
+        'lightslategray' => '778899',
114
+        'lightslategrey' => '778899',
115
+        'lightsteelblue' => 'B0C4DE',
116
+        'lightyellow' => 'FFFFE0',
117
+        'lime' => '00FF00',
118
+        'limegreen' => '32CD32',
119
+        'linen' => 'FAF0E6',
120
+        'magenta' => 'FF00FF',
121
+        'maroon' => '800000',
122
+        'mediumaquamarine' => '66CDAA',
123
+        'mediumblue' => '0000CD',
124
+        'mediumorchid' => 'BA55D3',
125
+        'mediumpurple' => '9370DB',
126
+        'mediumseagreen' => '3CB371',
127
+        'mediumslateblue' => '7B68EE',
128
+        'mediumspringgreen' => '00FA9A',
129
+        'mediumturquoise' => '48D1CC',
130
+        'mediumvioletred' => 'C71585',
131
+        'midnightblue' => '191970',
132
+        'mintcream' => 'F5FFFA',
133
+        'mistyrose' => 'FFE4E1',
134
+        'moccasin' => 'FFE4B5',
135
+        'navajowhite' => 'FFDEAD',
136
+        'navy' => '000080',
137
+        'oldlace' => 'FDF5E6',
138
+        'olive' => '808000',
139
+        'olivedrab' => '6B8E23',
140
+        'orange' => 'FFA500',
141
+        'orangered' => 'FF4500',
142
+        'orchid' => 'DA70D6',
143
+        'palegoldenrod' => 'EEE8AA',
144
+        'palegreen' => '98FB98',
145
+        'paleturquoise' => 'AFEEEE',
146
+        'palevioletred' => 'DB7093',
147
+        'papayawhip' => 'FFEFD5',
148
+        'peachpuff' => 'FFDAB9',
149
+        'peru' => 'CD853F',
150
+        'pink' => 'FFC0CB',
151
+        'plum' => 'DDA0DD',
152
+        'powderblue' => 'B0E0E6',
153
+        'purple' => '800080',
154
+        'rebeccapurple' => '663399',
155
+        'red' => 'FF0000',
156
+        'rosybrown' => 'BC8F8F',
157
+        'royalblue' => '4169E1',
158
+        'saddlebrown' => '8B4513',
159
+        'salmon' => 'FA8072',
160
+        'sandybrown' => 'F4A460',
161
+        'seagreen' => '2E8B57',
162
+        'seashell' => 'FFF5EE',
163
+        'sienna' => 'A0522D',
164
+        'silver' => 'C0C0C0',
165
+        'skyblue' => '87CEEB',
166
+        'slateblue' => '6A5ACD',
167
+        'slategray' => '708090',
168
+        'slategrey' => '708090',
169
+        'snow' => 'FFFAFA',
170
+        'springgreen' => '00FF7F',
171
+        'steelblue' => '4682B4',
172
+        'tan' => 'D2B48C',
173
+        'teal' => '008080',
174
+        'thistle' => 'D8BFD8',
175
+        'tomato' => 'FF6347',
176
+        'turquoise' => '40E0D0',
177
+        'violet' => 'EE82EE',
178
+        'wheat' => 'F5DEB3',
179
+        'white' => 'FFFFFF',
180
+        'whitesmoke' => 'F5F5F5',
181
+        'yellow' => 'FFFF00',
182
+        'yellowgreen' => '9ACD32',
183
+    ];
184
+    if (isset($couleurs_html[$lc = strtolower($couleur)])) {
185
+        return $couleurs_html[$lc];
186
+    }
187
+
188
+    return $couleur;
189 189
 }
190 190
 
191 191
 /**
@@ -201,16 +201,16 @@  discard block
 block discarded – undo
201 201
  * @return string Couleur tel que "hsl(200, 40%, 34%)" ou valeur formattée
202 202
  */
203 203
 function couleur_hex_to_hsl($couleur, $format = null) {
204
-	$hsl = _couleur_hex_to_hsl($couleur);
205
-	$hsl = [
206
-		'h' => round($hsl['h'] * 360),
207
-		's' => round($hsl['s'] * 100) . '%',
208
-		'l' => round($hsl['l'] * 100) . '%'
209
-	];
210
-	if ($format === null) {
211
-		return "hsl({$hsl['h']}, {$hsl['s']}, {$hsl['l']})";
212
-	}
213
-	return str_replace(array_keys($hsl), $hsl, $format);
204
+    $hsl = _couleur_hex_to_hsl($couleur);
205
+    $hsl = [
206
+        'h' => round($hsl['h'] * 360),
207
+        's' => round($hsl['s'] * 100) . '%',
208
+        'l' => round($hsl['l'] * 100) . '%'
209
+    ];
210
+    if ($format === null) {
211
+        return "hsl({$hsl['h']}, {$hsl['s']}, {$hsl['l']})";
212
+    }
213
+    return str_replace(array_keys($hsl), $hsl, $format);
214 214
 }
215 215
 
216 216
 
@@ -227,16 +227,16 @@  discard block
 block discarded – undo
227 227
  * @return string Couleur tel que "rgb(200, 40, 84)" ou valeur formattée
228 228
  */
229 229
 function couleur_hex_to_rgb($couleur, $format = null) {
230
-	$rgb = _couleur_hex_to_dec($couleur);
231
-	$rgb = [
232
-		'r' => $rgb['red'],
233
-		'g' => $rgb['green'],
234
-		'b' => $rgb['blue'],
235
-	];
236
-	if ($format === null) {
237
-		return "rgb({$rgb['r']}, {$rgb['g']}, {$rgb['b']})";
238
-	}
239
-	return str_replace(array_keys($rgb), $rgb, $format);
230
+    $rgb = _couleur_hex_to_dec($couleur);
231
+    $rgb = [
232
+        'r' => $rgb['red'],
233
+        'g' => $rgb['green'],
234
+        'b' => $rgb['blue'],
235
+    ];
236
+    if ($format === null) {
237
+        return "rgb({$rgb['r']}, {$rgb['g']}, {$rgb['b']})";
238
+    }
239
+    return str_replace(array_keys($rgb), $rgb, $format);
240 240
 }
241 241
 
242 242
 /**
@@ -252,15 +252,15 @@  discard block
 block discarded – undo
252 252
  *    Code hexadécimal de la couleur plus foncée
253 253
  */
254 254
 function couleur_foncer($couleur, $coeff = 0.5) {
255
-	$couleurs = _couleur_hex_to_dec($couleur);
255
+    $couleurs = _couleur_hex_to_dec($couleur);
256 256
 
257
-	$red = $couleurs['red'] - round(($couleurs['red']) * $coeff);
258
-	$green = $couleurs['green'] - round(($couleurs['green']) * $coeff);
259
-	$blue = $couleurs['blue'] - round(($couleurs['blue']) * $coeff);
257
+    $red = $couleurs['red'] - round(($couleurs['red']) * $coeff);
258
+    $green = $couleurs['green'] - round(($couleurs['green']) * $coeff);
259
+    $blue = $couleurs['blue'] - round(($couleurs['blue']) * $coeff);
260 260
 
261
-	$couleur = _couleur_dec_to_hex($red, $green, $blue);
261
+    $couleur = _couleur_dec_to_hex($red, $green, $blue);
262 262
 
263
-	return $couleur;
263
+    return $couleur;
264 264
 }
265 265
 
266 266
 /**
@@ -276,15 +276,15 @@  discard block
 block discarded – undo
276 276
  *    Code hexadécimal de la couleur éclaircie
277 277
  */
278 278
 function couleur_eclaircir($couleur, $coeff = 0.5) {
279
-	$couleurs = _couleur_hex_to_dec($couleur);
279
+    $couleurs = _couleur_hex_to_dec($couleur);
280 280
 
281
-	$red = $couleurs['red'] + round((255 - $couleurs['red']) * $coeff);
282
-	$green = $couleurs['green'] + round((255 - $couleurs['green']) * $coeff);
283
-	$blue = $couleurs['blue'] + round((255 - $couleurs['blue']) * $coeff);
281
+    $red = $couleurs['red'] + round((255 - $couleurs['red']) * $coeff);
282
+    $green = $couleurs['green'] + round((255 - $couleurs['green']) * $coeff);
283
+    $blue = $couleurs['blue'] + round((255 - $couleurs['blue']) * $coeff);
284 284
 
285
-	$couleur = _couleur_dec_to_hex($red, $green, $blue);
285
+    $couleur = _couleur_dec_to_hex($red, $green, $blue);
286 286
 
287
-	return $couleur;
287
+    return $couleur;
288 288
 }
289 289
 
290 290
 /**
@@ -307,28 +307,28 @@  discard block
 block discarded – undo
307 307
  *    Le tag html `<img src=... />` avec une class `filtre_inactif` ou pas
308 308
  */
309 309
 function image_select($img, $width_min = 0, $height_min = 0, $width_max = 10000, $height_max = 1000) {
310
-	if (!$img) {
311
-		return $img;
312
-	}
313
-	[$h, $l] = taille_image($img);
314
-	$select = true;
315
-	if ($l < $width_min or $l > $width_max or $h < $height_min or $h > $height_max) {
316
-		$select = false;
317
-	}
318
-
319
-	$class = extraire_attribut($img, 'class');
320
-	$p = strpos($class, 'filtre_inactif');
321
-	if (($select == false) and ($p === false)) {
322
-		$class .= ' filtre_inactif';
323
-		$img = inserer_attribut($img, 'class', $class);
324
-	}
325
-	if (($select == true) and ($p !== false)) {
326
-		// no_image_filtrer : historique, a virer
327
-		$class = preg_replace(',\s*(filtre_inactif|no_image_filtrer),', '', $class);
328
-		$img = inserer_attribut($img, 'class', $class);
329
-	}
330
-
331
-	return $img;
310
+    if (!$img) {
311
+        return $img;
312
+    }
313
+    [$h, $l] = taille_image($img);
314
+    $select = true;
315
+    if ($l < $width_min or $l > $width_max or $h < $height_min or $h > $height_max) {
316
+        $select = false;
317
+    }
318
+
319
+    $class = extraire_attribut($img, 'class');
320
+    $p = strpos($class, 'filtre_inactif');
321
+    if (($select == false) and ($p === false)) {
322
+        $class .= ' filtre_inactif';
323
+        $img = inserer_attribut($img, 'class', $class);
324
+    }
325
+    if (($select == true) and ($p !== false)) {
326
+        // no_image_filtrer : historique, a virer
327
+        $class = preg_replace(',\s*(filtre_inactif|no_image_filtrer),', '', $class);
328
+        $img = inserer_attribut($img, 'class', $class);
329
+    }
330
+
331
+    return $img;
332 332
 }
333 333
 
334 334
 /**
@@ -376,45 +376,45 @@  discard block
 block discarded – undo
376 376
  *     Code HTML de l'image ou du texte.
377 377
  **/
378 378
 function image_passe_partout(
379
-	$img,
380
-	$taille_x = -1,
381
-	$taille_y = -1,
382
-	$force = false,
383
-	$cherche_image = false,
384
-	$process = 'AUTO'
379
+    $img,
380
+    $taille_x = -1,
381
+    $taille_y = -1,
382
+    $force = false,
383
+    $cherche_image = false,
384
+    $process = 'AUTO'
385 385
 ) {
386
-	// PHP 7+ type hint
387
-	$img = (string)$img;
388
-	$taille_x = (int)$taille_x;
389
-	$taille_y = (int)$taille_y;
390
-	$force = (bool)$force;
391
-	$process = (string)$process;
392
-
393
-	if (!$img) {
394
-		return '';
395
-	}
396
-	[$hauteur, $largeur] = taille_image($img);
397
-	if ($taille_x === -1) {
398
-		$taille_x = $GLOBALS['meta']['taille_preview'] ?? 150;
399
-	}
400
-	if ($taille_y === -1) {
401
-		$taille_y = $taille_x;
402
-	}
403
-
404
-	if ($taille_x === 0 and $taille_y > 0) {
405
-		$taille_x = 1;
406
-	} # {0,300} -> c'est 300 qui compte
407
-	elseif ($taille_x > 0 and $taille_y === 0) {
408
-		$taille_y = 1;
409
-	} # {300,0} -> c'est 300 qui compte
410
-	elseif ($taille_x == 0 and $taille_y === 0) {
411
-		return '';
412
-	}
413
-
414
-	[$destWidth, $destHeight, $ratio] = ratio_passe_partout($largeur ?? 0, $hauteur ?? 0, $taille_x, $taille_y);
415
-	$fonction = ['image_passe_partout', func_get_args()];
416
-
417
-	return process_image_reduire($fonction, $img, $destWidth, $destHeight, $force, $process);
386
+    // PHP 7+ type hint
387
+    $img = (string)$img;
388
+    $taille_x = (int)$taille_x;
389
+    $taille_y = (int)$taille_y;
390
+    $force = (bool)$force;
391
+    $process = (string)$process;
392
+
393
+    if (!$img) {
394
+        return '';
395
+    }
396
+    [$hauteur, $largeur] = taille_image($img);
397
+    if ($taille_x === -1) {
398
+        $taille_x = $GLOBALS['meta']['taille_preview'] ?? 150;
399
+    }
400
+    if ($taille_y === -1) {
401
+        $taille_y = $taille_x;
402
+    }
403
+
404
+    if ($taille_x === 0 and $taille_y > 0) {
405
+        $taille_x = 1;
406
+    } # {0,300} -> c'est 300 qui compte
407
+    elseif ($taille_x > 0 and $taille_y === 0) {
408
+        $taille_y = 1;
409
+    } # {300,0} -> c'est 300 qui compte
410
+    elseif ($taille_x == 0 and $taille_y === 0) {
411
+        return '';
412
+    }
413
+
414
+    [$destWidth, $destHeight, $ratio] = ratio_passe_partout($largeur ?? 0, $hauteur ?? 0, $taille_x, $taille_y);
415
+    $fonction = ['image_passe_partout', func_get_args()];
416
+
417
+    return process_image_reduire($fonction, $img, $destWidth, $destHeight, $force, $process);
418 418
 }
419 419
 
420 420
 /**
@@ -457,44 +457,44 @@  discard block
 block discarded – undo
457 457
  *     Code HTML de l'image ou du texte.
458 458
  **/
459 459
 function image_reduire(
460
-	$img,
461
-	$taille = -1,
462
-	$taille_y = -1,
463
-	$force = false,
464
-	$cherche_image = false,
465
-	$process = 'AUTO'
460
+    $img,
461
+    $taille = -1,
462
+    $taille_y = -1,
463
+    $force = false,
464
+    $cherche_image = false,
465
+    $process = 'AUTO'
466 466
 ) {
467
-	// PHP 7+ type hint
468
-	$img = (string)$img;
469
-	$taille = (int)$taille;
470
-	$taille_y = (int)$taille_y;
471
-	$force = (bool)$force;
472
-	$process = (string)$process;
473
-
474
-	// Determiner la taille x,y maxi
475
-	// prendre le reglage de previsu par defaut
476
-	if ($taille === -1) {
477
-		$taille = (isset($GLOBALS['meta']['taille_preview']) and intval($GLOBALS['meta']['taille_preview']))
478
-			? intval($GLOBALS['meta']['taille_preview'])
479
-			: 150;
480
-	}
481
-	if ($taille_y === -1) {
482
-		$taille_y = $taille;
483
-	}
484
-
485
-	if ($taille === 0 and $taille_y > 0) {
486
-		$taille = 10000;
487
-	} # {0,300} -> c'est 300 qui compte
488
-	elseif ($taille > 0 and $taille_y === 0) {
489
-		$taille_y = 10000;
490
-	} # {300,0} -> c'est 300 qui compte
491
-	elseif ($taille == 0 and $taille_y === 0) {
492
-		return '';
493
-	}
494
-
495
-	$fonction = ['image_reduire', func_get_args()];
496
-
497
-	return process_image_reduire($fonction, $img, $taille, $taille_y, $force, $process);
467
+    // PHP 7+ type hint
468
+    $img = (string)$img;
469
+    $taille = (int)$taille;
470
+    $taille_y = (int)$taille_y;
471
+    $force = (bool)$force;
472
+    $process = (string)$process;
473
+
474
+    // Determiner la taille x,y maxi
475
+    // prendre le reglage de previsu par defaut
476
+    if ($taille === -1) {
477
+        $taille = (isset($GLOBALS['meta']['taille_preview']) and intval($GLOBALS['meta']['taille_preview']))
478
+            ? intval($GLOBALS['meta']['taille_preview'])
479
+            : 150;
480
+    }
481
+    if ($taille_y === -1) {
482
+        $taille_y = $taille;
483
+    }
484
+
485
+    if ($taille === 0 and $taille_y > 0) {
486
+        $taille = 10000;
487
+    } # {0,300} -> c'est 300 qui compte
488
+    elseif ($taille > 0 and $taille_y === 0) {
489
+        $taille_y = 10000;
490
+    } # {300,0} -> c'est 300 qui compte
491
+    elseif ($taille == 0 and $taille_y === 0) {
492
+        return '';
493
+    }
494
+
495
+    $fonction = ['image_reduire', func_get_args()];
496
+
497
+    return process_image_reduire($fonction, $img, $taille, $taille_y, $force, $process);
498 498
 }
499 499
 
500 500
 /**
@@ -505,16 +505,16 @@  discard block
 block discarded – undo
505 505
  *
506 506
  **/
507 507
 function image_recadre_avec_fallback(
508
-	$im,
509
-	$width,
510
-	$height = '-',
511
-	$position = 'focus',
512
-	$background_color = 'white'
508
+    $im,
509
+    $width,
510
+    $height = '-',
511
+    $position = 'focus',
512
+    $background_color = 'white'
513 513
 ) {
514
-	if (function_exists('image_recadre') && ($GLOBALS['meta']['image_process'] ?? '') === 'gd2') {
515
-		return image_reduire(image_recadre($im, $width . ':' . $height, '-', $position, $background_color), $width, $height);
516
-	} else { return image_passe_partout($im, $width, $height);
517
-	}
514
+    if (function_exists('image_recadre') && ($GLOBALS['meta']['image_process'] ?? '') === 'gd2') {
515
+        return image_reduire(image_recadre($im, $width . ':' . $height, '-', $position, $background_color), $width, $height);
516
+    } else { return image_passe_partout($im, $width, $height);
517
+    }
518 518
 }
519 519
 
520 520
 /**
@@ -532,25 +532,25 @@  discard block
 block discarded – undo
532 532
  *     Code HTML de l'image ou du texte.
533 533
  **/
534 534
 function image_reduire_par($img, $val = 1, $force = false) {
535
-	// PHP 7+ type hint
536
-	$img = (string)$img;
537
-	$val = (int)$val;
538
-	$force = (bool)$force;
535
+    // PHP 7+ type hint
536
+    $img = (string)$img;
537
+    $val = (int)$val;
538
+    $force = (bool)$force;
539 539
 
540
-	[$hauteur, $largeur] = taille_image($img);
540
+    [$hauteur, $largeur] = taille_image($img);
541 541
 
542
-	$l = round($largeur / $val);
543
-	$h = round($hauteur / $val);
542
+    $l = round($largeur / $val);
543
+    $h = round($hauteur / $val);
544 544
 
545
-	if ($l > $h) {
546
-		$h = 0;
547
-	} else {
548
-		$l = 0;
549
-	}
545
+    if ($l > $h) {
546
+        $h = 0;
547
+    } else {
548
+        $l = 0;
549
+    }
550 550
 
551
-	$img = image_reduire($img, $l, $h, $force);
551
+    $img = image_reduire($img, $l, $h, $force);
552 552
 
553
-	return $img;
553
+    return $img;
554 554
 }
555 555
 
556 556
 /**
@@ -573,10 +573,10 @@  discard block
 block discarded – undo
573 573
  *      Couleur en écriture hexadécimale.
574 574
 **/
575 575
 function filtre_couleur_saturation_dist($couleur, $val, $strict = false) {
576
-	if (function_exists('couleur_saturation')) {
577
-		return couleur_saturation($couleur, $val, $strict);
578
-	}
579
-	return $couleur;
576
+    if (function_exists('couleur_saturation')) {
577
+        return couleur_saturation($couleur, $val, $strict);
578
+    }
579
+    return $couleur;
580 580
 }
581 581
 
582 582
 /**
@@ -597,8 +597,8 @@  discard block
 block discarded – undo
597 597
  *      Couleur en écriture hexadécimale.
598 598
 **/
599 599
 function filtre_couleur_luminance_dist($couleur, $val) {
600
-	if (function_exists('couleur_luminance')) {
601
-		return couleur_luminance($couleur, $val);
602
-	}
603
-	return $couleur;
600
+    if (function_exists('couleur_luminance')) {
601
+        return couleur_luminance($couleur, $val);
602
+    }
603
+    return $couleur;
604 604
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -204,8 +204,8 @@  discard block
 block discarded – undo
204 204
 	$hsl = _couleur_hex_to_hsl($couleur);
205 205
 	$hsl = [
206 206
 		'h' => round($hsl['h'] * 360),
207
-		's' => round($hsl['s'] * 100) . '%',
208
-		'l' => round($hsl['l'] * 100) . '%'
207
+		's' => round($hsl['s'] * 100).'%',
208
+		'l' => round($hsl['l'] * 100).'%'
209 209
 	];
210 210
 	if ($format === null) {
211 211
 		return "hsl({$hsl['h']}, {$hsl['s']}, {$hsl['l']})";
@@ -384,11 +384,11 @@  discard block
 block discarded – undo
384 384
 	$process = 'AUTO'
385 385
 ) {
386 386
 	// PHP 7+ type hint
387
-	$img = (string)$img;
388
-	$taille_x = (int)$taille_x;
389
-	$taille_y = (int)$taille_y;
390
-	$force = (bool)$force;
391
-	$process = (string)$process;
387
+	$img = (string) $img;
388
+	$taille_x = (int) $taille_x;
389
+	$taille_y = (int) $taille_y;
390
+	$force = (bool) $force;
391
+	$process = (string) $process;
392 392
 
393 393
 	if (!$img) {
394 394
 		return '';
@@ -465,11 +465,11 @@  discard block
 block discarded – undo
465 465
 	$process = 'AUTO'
466 466
 ) {
467 467
 	// PHP 7+ type hint
468
-	$img = (string)$img;
469
-	$taille = (int)$taille;
470
-	$taille_y = (int)$taille_y;
471
-	$force = (bool)$force;
472
-	$process = (string)$process;
468
+	$img = (string) $img;
469
+	$taille = (int) $taille;
470
+	$taille_y = (int) $taille_y;
471
+	$force = (bool) $force;
472
+	$process = (string) $process;
473 473
 
474 474
 	// Determiner la taille x,y maxi
475 475
 	// prendre le reglage de previsu par defaut
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
 	$background_color = 'white'
513 513
 ) {
514 514
 	if (function_exists('image_recadre') && ($GLOBALS['meta']['image_process'] ?? '') === 'gd2') {
515
-		return image_reduire(image_recadre($im, $width . ':' . $height, '-', $position, $background_color), $width, $height);
515
+		return image_reduire(image_recadre($im, $width.':'.$height, '-', $position, $background_color), $width, $height);
516 516
 	} else { return image_passe_partout($im, $width, $height);
517 517
 	}
518 518
 }
@@ -533,9 +533,9 @@  discard block
 block discarded – undo
533 533
  **/
534 534
 function image_reduire_par($img, $val = 1, $force = false) {
535 535
 	// PHP 7+ type hint
536
-	$img = (string)$img;
537
-	$val = (int)$val;
538
-	$force = (bool)$force;
536
+	$img = (string) $img;
537
+	$val = (int) $val;
538
+	$force = (bool) $force;
539 539
 
540 540
 	[$hauteur, $largeur] = taille_image($img);
541 541
 
Please login to merge, or discard this patch.
ecrire/inc/envoyer_mail.php 3 patches
Indentation   +150 added lines, -150 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @package SPIP\Core\Mail
17 17
  **/
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 include_spip('inc/charsets');
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
  * @return string
33 33
  */
34 34
 function nettoyer_titre_email($titre) {
35
-	return str_replace("\n", ' ', nettoyer_caracteres_mail(textebrut(corriger_typo($titre))));
35
+    return str_replace("\n", ' ', nettoyer_caracteres_mail(textebrut(corriger_typo($titre))));
36 36
 }
37 37
 
38 38
 /**
@@ -48,23 +48,23 @@  discard block
 block discarded – undo
48 48
  */
49 49
 function nettoyer_caracteres_mail($t) {
50 50
 
51
-	$t = filtrer_entites($t);
51
+    $t = filtrer_entites($t);
52 52
 
53
-	if ($GLOBALS['meta']['charset'] <> 'utf-8') {
54
-		$t = str_replace(
55
-			['&#8217;', '&#8220;', '&#8221;'],
56
-			["'", '"', '"'],
57
-			$t
58
-		);
59
-	}
53
+    if ($GLOBALS['meta']['charset'] <> 'utf-8') {
54
+        $t = str_replace(
55
+            ['&#8217;', '&#8220;', '&#8221;'],
56
+            ["'", '"', '"'],
57
+            $t
58
+        );
59
+    }
60 60
 
61
-	$t = str_replace(
62
-		['&mdash;', '&endash;'],
63
-		['--', '-'],
64
-		$t
65
-	);
61
+    $t = str_replace(
62
+        ['&mdash;', '&endash;'],
63
+        ['--', '-'],
64
+        $t
65
+    );
66 66
 
67
-	return $t;
67
+    return $t;
68 68
 }
69 69
 
70 70
 /**
@@ -97,86 +97,86 @@  discard block
 block discarded – undo
97 97
  */
98 98
 function inc_envoyer_mail_dist($destinataire, $sujet, $corps, $from = '', $headers = '') {
99 99
 
100
-	if (!email_valide($destinataire)) {
101
-		return false;
102
-	}
103
-	if ($destinataire == _T('info_mail_fournisseur')) {
104
-		return false;
105
-	} // tres fort
106
-
107
-	// Fournir si possible un Message-Id: conforme au RFC1036,
108
-	// sinon SpamAssassin denoncera un MSGID_FROM_MTA_HEADER
109
-
110
-	$email_envoi = $GLOBALS['meta']['email_envoi'];
111
-	if (!email_valide($email_envoi)) {
112
-		spip_log('Meta email_envoi invalide. Le mail sera probablement vu comme spam.');
113
-		$email_envoi = $destinataire;
114
-	}
115
-
116
-	$parts = '';
117
-	if (is_array($corps)) {
118
-		$texte = $corps['texte'];
119
-		$from = ($corps['from'] ?? $from);
120
-		$headers = ($corps['headers'] ?? $headers);
121
-		if (is_array($headers)) {
122
-			$headers = implode("\n", $headers);
123
-		}
124
-		if (isset($corps['pieces_jointes']) and function_exists('mail_embarquer_pieces_jointes')) {
125
-			$parts = mail_embarquer_pieces_jointes($corps['pieces_jointes']);
126
-		}
127
-	} else {
128
-		$texte = $corps;
129
-	}
130
-
131
-	if (!$from) {
132
-		$from = $email_envoi;
133
-	}
134
-
135
-	// ceci est la RegExp NO_REAL_NAME faisant hurler SpamAssassin
136
-	if (preg_match('/^["\s]*\<?\S+\@\S+\>?\s*$/', $from)) {
137
-		$from .= ' (' . str_replace(')', '', translitteration(str_replace('@', ' at ', $from))) . ')';
138
-	}
139
-
140
-	// nettoyer les &eacute; &#8217, &emdash; etc...
141
-	// les 'cliquer ici' etc sont a eviter;  voir:
142
-	// http://mta.org.ua/spamassassin-2.55/stuff/wiki.CustomRulesets/20050914/rules/french_rules.cf
143
-	$texte = nettoyer_caracteres_mail($texte);
144
-	$sujet = nettoyer_caracteres_mail($sujet);
145
-
146
-	// encoder le sujet si possible selon la RFC
147
-	if (init_mb_string()) {
148
-		# un bug de mb_string casse mb_encode_mimeheader si l'encoding interne
149
-		# est UTF-8 et le charset iso-8859-1 (constate php5-mac ; php4.3-debian)
150
-		$charset = $GLOBALS['meta']['charset'];
151
-		mb_internal_encoding($charset);
152
-		$sujet = mb_encode_mimeheader($sujet, $charset, 'Q', "\n");
153
-		mb_internal_encoding('utf-8');
154
-	}
155
-
156
-	if (function_exists('wordwrap') && (preg_match(',multipart/mixed,', $headers) == 0)) {
157
-		$texte = wordwrap($texte);
158
-	}
159
-
160
-	[$headers, $texte] = mail_normaliser_headers($headers, $from, $destinataire, $texte, $parts);
161
-
162
-	if (_OS_SERVEUR == 'windows') {
163
-		$texte = preg_replace("@\r*\n@", "\r\n", $texte);
164
-		$headers = preg_replace("@\r*\n@", "\r\n", $headers);
165
-		$sujet = preg_replace("@\r*\n@", "\r\n", $sujet);
166
-	}
167
-
168
-	spip_log("mail $destinataire\n$sujet\n$headers", 'mails');
169
-	// mode TEST : forcer l'email
170
-	if (defined('_TEST_EMAIL_DEST')) {
171
-		if (!_TEST_EMAIL_DEST) {
172
-			return false;
173
-		} else {
174
-			$texte = "Dest : $destinataire\r\n" . $texte;
175
-			$destinataire = _TEST_EMAIL_DEST;
176
-		}
177
-	}
178
-
179
-	return @mail($destinataire, $sujet, $texte, $headers);
100
+    if (!email_valide($destinataire)) {
101
+        return false;
102
+    }
103
+    if ($destinataire == _T('info_mail_fournisseur')) {
104
+        return false;
105
+    } // tres fort
106
+
107
+    // Fournir si possible un Message-Id: conforme au RFC1036,
108
+    // sinon SpamAssassin denoncera un MSGID_FROM_MTA_HEADER
109
+
110
+    $email_envoi = $GLOBALS['meta']['email_envoi'];
111
+    if (!email_valide($email_envoi)) {
112
+        spip_log('Meta email_envoi invalide. Le mail sera probablement vu comme spam.');
113
+        $email_envoi = $destinataire;
114
+    }
115
+
116
+    $parts = '';
117
+    if (is_array($corps)) {
118
+        $texte = $corps['texte'];
119
+        $from = ($corps['from'] ?? $from);
120
+        $headers = ($corps['headers'] ?? $headers);
121
+        if (is_array($headers)) {
122
+            $headers = implode("\n", $headers);
123
+        }
124
+        if (isset($corps['pieces_jointes']) and function_exists('mail_embarquer_pieces_jointes')) {
125
+            $parts = mail_embarquer_pieces_jointes($corps['pieces_jointes']);
126
+        }
127
+    } else {
128
+        $texte = $corps;
129
+    }
130
+
131
+    if (!$from) {
132
+        $from = $email_envoi;
133
+    }
134
+
135
+    // ceci est la RegExp NO_REAL_NAME faisant hurler SpamAssassin
136
+    if (preg_match('/^["\s]*\<?\S+\@\S+\>?\s*$/', $from)) {
137
+        $from .= ' (' . str_replace(')', '', translitteration(str_replace('@', ' at ', $from))) . ')';
138
+    }
139
+
140
+    // nettoyer les &eacute; &#8217, &emdash; etc...
141
+    // les 'cliquer ici' etc sont a eviter;  voir:
142
+    // http://mta.org.ua/spamassassin-2.55/stuff/wiki.CustomRulesets/20050914/rules/french_rules.cf
143
+    $texte = nettoyer_caracteres_mail($texte);
144
+    $sujet = nettoyer_caracteres_mail($sujet);
145
+
146
+    // encoder le sujet si possible selon la RFC
147
+    if (init_mb_string()) {
148
+        # un bug de mb_string casse mb_encode_mimeheader si l'encoding interne
149
+        # est UTF-8 et le charset iso-8859-1 (constate php5-mac ; php4.3-debian)
150
+        $charset = $GLOBALS['meta']['charset'];
151
+        mb_internal_encoding($charset);
152
+        $sujet = mb_encode_mimeheader($sujet, $charset, 'Q', "\n");
153
+        mb_internal_encoding('utf-8');
154
+    }
155
+
156
+    if (function_exists('wordwrap') && (preg_match(',multipart/mixed,', $headers) == 0)) {
157
+        $texte = wordwrap($texte);
158
+    }
159
+
160
+    [$headers, $texte] = mail_normaliser_headers($headers, $from, $destinataire, $texte, $parts);
161
+
162
+    if (_OS_SERVEUR == 'windows') {
163
+        $texte = preg_replace("@\r*\n@", "\r\n", $texte);
164
+        $headers = preg_replace("@\r*\n@", "\r\n", $headers);
165
+        $sujet = preg_replace("@\r*\n@", "\r\n", $sujet);
166
+    }
167
+
168
+    spip_log("mail $destinataire\n$sujet\n$headers", 'mails');
169
+    // mode TEST : forcer l'email
170
+    if (defined('_TEST_EMAIL_DEST')) {
171
+        if (!_TEST_EMAIL_DEST) {
172
+            return false;
173
+        } else {
174
+            $texte = "Dest : $destinataire\r\n" . $texte;
175
+            $destinataire = _TEST_EMAIL_DEST;
176
+        }
177
+    }
178
+
179
+    return @mail($destinataire, $sujet, $texte, $headers);
180 180
 }
181 181
 
182 182
 /**
@@ -190,58 +190,58 @@  discard block
 block discarded – undo
190 190
  * @return array
191 191
  */
192 192
 function mail_normaliser_headers($headers, $from, $to, $texte, $parts = '') {
193
-	$charset = $GLOBALS['meta']['charset'];
194
-
195
-	// Ajouter le Content-Type et consort s'il n'y est pas deja
196
-	if (strpos($headers, 'Content-Type: ') === false) {
197
-		$type =
198
-			"Content-Type: text/plain;charset=\"$charset\";\n" .
199
-			"Content-Transfer-Encoding: 8bit\n";
200
-	} else {
201
-		$type = '';
202
-	}
203
-
204
-	// calculer un identifiant unique
205
-	// Marie Toto <[email protected]> => @toto.com
206
-	if (preg_match('/@[^\s>]+/', $from, $domain)) {
207
-		$domain = $domain[0];
208
-	}
209
-	else {
210
-		$domain = '@unknown-' . md5($from) . '.org';
211
-	}
212
-	$uniq = random_int(0, mt_getrandmax()) . '_' . md5($to . $texte) . $domain;
213
-
214
-	// Si multi-part, s'en servir comme borne ...
215
-	if ($parts) {
216
-		$texte = "--$uniq\n$type\n" . $texte . "\n";
217
-		foreach ($parts as $part) {
218
-			$n = strlen($part[1]) . ($part[0] ? "\n" : '');
219
-			$e = join("\n", $part[0]);
220
-			$texte .= "\n--$uniq\nContent-Length: $n$e\n\n" . $part[1];
221
-		}
222
-		$texte .= "\n\n--$uniq--\n";
223
-		// Si boundary n'est pas entre guillemets,
224
-		// elle est comprise mais le charset est ignoree !
225
-		$type = "Content-Type: multipart/mixed; boundary=\"$uniq\"\n";
226
-	}
227
-
228
-	// .. et s'en servir pour plaire a SpamAssassin
229
-
230
-	$mid = 'Message-Id: <' . $uniq . '>';
231
-
232
-	// indispensable pour les sites qui collent d'office From: serveur-http
233
-	// sauf si deja mis par l'envoyeur
234
-	$rep = (strpos($headers, 'Reply-To:') !== false) ? '' : "Reply-To: $from\n";
235
-
236
-	// Nettoyer les en-tetes envoyees
237
-	// Ajouter le \n final
238
-	if (strlen($headers = trim($headers))) {
239
-		$headers .= "\n";
240
-	}
241
-
242
-	// Et mentionner l'indeboulonable nomenclature ratee
243
-
244
-	$headers .= "From: $from\n$type$rep$mid\nMIME-Version: 1.0\n";
245
-
246
-	return [$headers, $texte];
193
+    $charset = $GLOBALS['meta']['charset'];
194
+
195
+    // Ajouter le Content-Type et consort s'il n'y est pas deja
196
+    if (strpos($headers, 'Content-Type: ') === false) {
197
+        $type =
198
+            "Content-Type: text/plain;charset=\"$charset\";\n" .
199
+            "Content-Transfer-Encoding: 8bit\n";
200
+    } else {
201
+        $type = '';
202
+    }
203
+
204
+    // calculer un identifiant unique
205
+    // Marie Toto <[email protected]> => @toto.com
206
+    if (preg_match('/@[^\s>]+/', $from, $domain)) {
207
+        $domain = $domain[0];
208
+    }
209
+    else {
210
+        $domain = '@unknown-' . md5($from) . '.org';
211
+    }
212
+    $uniq = random_int(0, mt_getrandmax()) . '_' . md5($to . $texte) . $domain;
213
+
214
+    // Si multi-part, s'en servir comme borne ...
215
+    if ($parts) {
216
+        $texte = "--$uniq\n$type\n" . $texte . "\n";
217
+        foreach ($parts as $part) {
218
+            $n = strlen($part[1]) . ($part[0] ? "\n" : '');
219
+            $e = join("\n", $part[0]);
220
+            $texte .= "\n--$uniq\nContent-Length: $n$e\n\n" . $part[1];
221
+        }
222
+        $texte .= "\n\n--$uniq--\n";
223
+        // Si boundary n'est pas entre guillemets,
224
+        // elle est comprise mais le charset est ignoree !
225
+        $type = "Content-Type: multipart/mixed; boundary=\"$uniq\"\n";
226
+    }
227
+
228
+    // .. et s'en servir pour plaire a SpamAssassin
229
+
230
+    $mid = 'Message-Id: <' . $uniq . '>';
231
+
232
+    // indispensable pour les sites qui collent d'office From: serveur-http
233
+    // sauf si deja mis par l'envoyeur
234
+    $rep = (strpos($headers, 'Reply-To:') !== false) ? '' : "Reply-To: $from\n";
235
+
236
+    // Nettoyer les en-tetes envoyees
237
+    // Ajouter le \n final
238
+    if (strlen($headers = trim($headers))) {
239
+        $headers .= "\n";
240
+    }
241
+
242
+    // Et mentionner l'indeboulonable nomenclature ratee
243
+
244
+    $headers .= "From: $from\n$type$rep$mid\nMIME-Version: 1.0\n";
245
+
246
+    return [$headers, $texte];
247 247
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 
135 135
 	// ceci est la RegExp NO_REAL_NAME faisant hurler SpamAssassin
136 136
 	if (preg_match('/^["\s]*\<?\S+\@\S+\>?\s*$/', $from)) {
137
-		$from .= ' (' . str_replace(')', '', translitteration(str_replace('@', ' at ', $from))) . ')';
137
+		$from .= ' ('.str_replace(')', '', translitteration(str_replace('@', ' at ', $from))).')';
138 138
 	}
139 139
 
140 140
 	// nettoyer les &eacute; &#8217, &emdash; etc...
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 		if (!_TEST_EMAIL_DEST) {
172 172
 			return false;
173 173
 		} else {
174
-			$texte = "Dest : $destinataire\r\n" . $texte;
174
+			$texte = "Dest : $destinataire\r\n".$texte;
175 175
 			$destinataire = _TEST_EMAIL_DEST;
176 176
 		}
177 177
 	}
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 	// Ajouter le Content-Type et consort s'il n'y est pas deja
196 196
 	if (strpos($headers, 'Content-Type: ') === false) {
197 197
 		$type =
198
-			"Content-Type: text/plain;charset=\"$charset\";\n" .
198
+			"Content-Type: text/plain;charset=\"$charset\";\n".
199 199
 			"Content-Transfer-Encoding: 8bit\n";
200 200
 	} else {
201 201
 		$type = '';
@@ -207,17 +207,17 @@  discard block
 block discarded – undo
207 207
 		$domain = $domain[0];
208 208
 	}
209 209
 	else {
210
-		$domain = '@unknown-' . md5($from) . '.org';
210
+		$domain = '@unknown-'.md5($from).'.org';
211 211
 	}
212
-	$uniq = random_int(0, mt_getrandmax()) . '_' . md5($to . $texte) . $domain;
212
+	$uniq = random_int(0, mt_getrandmax()).'_'.md5($to.$texte).$domain;
213 213
 
214 214
 	// Si multi-part, s'en servir comme borne ...
215 215
 	if ($parts) {
216
-		$texte = "--$uniq\n$type\n" . $texte . "\n";
216
+		$texte = "--$uniq\n$type\n".$texte."\n";
217 217
 		foreach ($parts as $part) {
218
-			$n = strlen($part[1]) . ($part[0] ? "\n" : '');
218
+			$n = strlen($part[1]).($part[0] ? "\n" : '');
219 219
 			$e = join("\n", $part[0]);
220
-			$texte .= "\n--$uniq\nContent-Length: $n$e\n\n" . $part[1];
220
+			$texte .= "\n--$uniq\nContent-Length: $n$e\n\n".$part[1];
221 221
 		}
222 222
 		$texte .= "\n\n--$uniq--\n";
223 223
 		// Si boundary n'est pas entre guillemets,
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 
228 228
 	// .. et s'en servir pour plaire a SpamAssassin
229 229
 
230
-	$mid = 'Message-Id: <' . $uniq . '>';
230
+	$mid = 'Message-Id: <'.$uniq.'>';
231 231
 
232 232
 	// indispensable pour les sites qui collent d'office From: serveur-http
233 233
 	// sauf si deja mis par l'envoyeur
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -205,8 +205,7 @@
 block discarded – undo
205 205
 	// Marie Toto <[email protected]> => @toto.com
206 206
 	if (preg_match('/@[^\s>]+/', $from, $domain)) {
207 207
 		$domain = $domain[0];
208
-	}
209
-	else {
208
+	} else {
210 209
 		$domain = '@unknown-' . md5($from) . '.org';
211 210
 	}
212 211
 	$uniq = random_int(0, mt_getrandmax()) . '_' . md5($to . $texte) . $domain;
Please login to merge, or discard this patch.
ecrire/inc/importer_csv.php 1 patch
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 include_spip('inc/charsets');
@@ -42,22 +42,22 @@  discard block
 block discarded – undo
42 42
  * @return array
43 43
  */
44 44
 function importer_csv_importcharset($texte, $definir_charset_source = false) {
45
-	// le plus frequent, en particulier avec les trucs de ms@@@
46
-	static $charset_source = 'iso-8859-1';
47
-	if ($definir_charset_source) {
48
-		if ($definir_charset_source === true) {
49
-			$charset_source = 'iso-8859-1';
50
-		} else {
51
-			$charset_source = $definir_charset_source;
52
-		}
53
-	}
54
-	// mais open-office sait faire mieux, donc mefiance !
55
-	if (is_utf8($texte)) {
56
-		$charset = 'utf-8';
57
-	} else {
58
-		$charset = $charset_source;
59
-	}
60
-	return importer_charset($texte, $charset);
45
+    // le plus frequent, en particulier avec les trucs de ms@@@
46
+    static $charset_source = 'iso-8859-1';
47
+    if ($definir_charset_source) {
48
+        if ($definir_charset_source === true) {
49
+            $charset_source = 'iso-8859-1';
50
+        } else {
51
+            $charset_source = $definir_charset_source;
52
+        }
53
+    }
54
+    // mais open-office sait faire mieux, donc mefiance !
55
+    if (is_utf8($texte)) {
56
+        $charset = 'utf-8';
57
+    } else {
58
+        $charset = $charset_source;
59
+    }
60
+    return importer_charset($texte, $charset);
61 61
 }
62 62
 
63 63
 /**
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
  * @return string
69 69
  */
70 70
 function importer_csv_nettoie_key($key) {
71
-	return translitteration($key);
71
+    return translitteration($key);
72 72
 }
73 73
 
74 74
 /**
@@ -87,77 +87,77 @@  discard block
 block discarded – undo
87 87
  */
88 88
 function inc_importer_csv_dist($file, $options = []) {
89 89
 
90
-	// support ancienne syntaxe
91
-	// inc_importer_csv_dist($file, $head = false, $delim = ',', $enclos = '"', $len = 10000, $charset_source = '')
92
-	if (!is_array($options)) {
93
-		$args = func_get_args();
94
-		$options = [];
95
-		foreach ([1 => 'head', 2 => 'delim', 3 => 'enclos', 4 => 'len', 5 => 'charset_source'] as $k => $option) {
96
-			if (!empty($args[$k])) {
97
-				$options[$option] = $args[$k];
98
-			}
99
-		}
100
-	}
90
+    // support ancienne syntaxe
91
+    // inc_importer_csv_dist($file, $head = false, $delim = ',', $enclos = '"', $len = 10000, $charset_source = '')
92
+    if (!is_array($options)) {
93
+        $args = func_get_args();
94
+        $options = [];
95
+        foreach ([1 => 'head', 2 => 'delim', 3 => 'enclos', 4 => 'len', 5 => 'charset_source'] as $k => $option) {
96
+            if (!empty($args[$k])) {
97
+                $options[$option] = $args[$k];
98
+            }
99
+        }
100
+    }
101 101
 
102
-	$default_options = [
103
-		'head' => false,
104
-		'delim' => ',',
105
-		'enclos' => '"',
106
-		'len' => 10000,
107
-		'charset_source' => '',
108
-	];
109
-	$options = array_merge($default_options, $options);
102
+    $default_options = [
103
+        'head' => false,
104
+        'delim' => ',',
105
+        'enclos' => '"',
106
+        'len' => 10000,
107
+        'charset_source' => '',
108
+    ];
109
+    $options = array_merge($default_options, $options);
110 110
 
111 111
 
112
-	$return = false;
113
-	if (
114
-		@file_exists($file)
115
-		and $handle = fopen($file, 'r')
116
-	) {
117
-		if ($options['charset_source']) {
118
-			importer_csv_importcharset('', $options['charset_source']);
119
-		}
120
-		if ($options['head']) {
121
-			$header = fgetcsv($handle, $options['len'], $options['delim'], $options['enclos']);
122
-			if ($header) {
123
-				$header = array_map('importer_csv_importcharset', $header);
124
-				$header = array_map('importer_csv_nettoie_key', $header);
125
-				$header_type = [];
126
-				foreach ($header as $heading) {
127
-					if (!isset($header_type[$heading])) {
128
-						$header_type[$heading] = 'scalar';
129
-					} else {
130
-						$header_type[$heading] = 'array';
131
-					}
132
-				}
133
-			}
134
-		}
112
+    $return = false;
113
+    if (
114
+        @file_exists($file)
115
+        and $handle = fopen($file, 'r')
116
+    ) {
117
+        if ($options['charset_source']) {
118
+            importer_csv_importcharset('', $options['charset_source']);
119
+        }
120
+        if ($options['head']) {
121
+            $header = fgetcsv($handle, $options['len'], $options['delim'], $options['enclos']);
122
+            if ($header) {
123
+                $header = array_map('importer_csv_importcharset', $header);
124
+                $header = array_map('importer_csv_nettoie_key', $header);
125
+                $header_type = [];
126
+                foreach ($header as $heading) {
127
+                    if (!isset($header_type[$heading])) {
128
+                        $header_type[$heading] = 'scalar';
129
+                    } else {
130
+                        $header_type[$heading] = 'array';
131
+                    }
132
+                }
133
+            }
134
+        }
135 135
 
136
-		while (($data = fgetcsv($handle, $options['len'], $options['delim'], $options['enclos'])) !== false) {
137
-			$data = array_map('importer_csv_importcharset', $data);
138
-			if ($options['head'] and isset($header)) {
139
-				$row = [];
140
-				foreach ($header as $key => $heading) {
141
-					if ($header_type[$heading] == 'array') {
142
-						if (!isset($row[$heading])) {
143
-							$row[$heading] = [];
144
-						}
145
-						if (isset($data[$key]) and strlen($data[$key])) {
146
-							$row[$heading][] = $data[$key];
147
-						}
148
-					} else {
149
-						$row[$heading] = $data[$key] ?? '';
150
-					}
151
-				}
152
-				$return[] = $row;
153
-			} else {
154
-				$return[] = $data;
155
-			}
156
-		}
157
-		if ($options['charset_source']) {
158
-			importer_csv_importcharset('', true);
159
-		}
160
-	}
136
+        while (($data = fgetcsv($handle, $options['len'], $options['delim'], $options['enclos'])) !== false) {
137
+            $data = array_map('importer_csv_importcharset', $data);
138
+            if ($options['head'] and isset($header)) {
139
+                $row = [];
140
+                foreach ($header as $key => $heading) {
141
+                    if ($header_type[$heading] == 'array') {
142
+                        if (!isset($row[$heading])) {
143
+                            $row[$heading] = [];
144
+                        }
145
+                        if (isset($data[$key]) and strlen($data[$key])) {
146
+                            $row[$heading][] = $data[$key];
147
+                        }
148
+                    } else {
149
+                        $row[$heading] = $data[$key] ?? '';
150
+                    }
151
+                }
152
+                $return[] = $row;
153
+            } else {
154
+                $return[] = $data;
155
+            }
156
+        }
157
+        if ($options['charset_source']) {
158
+            importer_csv_importcharset('', true);
159
+        }
160
+    }
161 161
 
162
-	return $return;
162
+    return $return;
163 163
 }
Please login to merge, or discard this patch.