Completed
Push — master ( 46b1b0...24ea70 )
by cam
01:45
created
ecrire/inc/filtres_alertes.php 1 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.