Completed
Push — master ( 8ce9c8...350a8b )
by cam
01:02
created
ecrire/inc/cookie.php 2 patches
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  **/
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 
@@ -51,64 +51,64 @@  discard block
 block discarded – undo
51 51
  *     cookie sécurisé ou non ?
52 52
  **/
53 53
 function spip_setcookie($name = '', $value = '', $options = []) {
54
-	static $to_secure_list = ['spip_session'];
55
-	if (defined('_COOKIE_SECURE_LIST') && is_array(_COOKIE_SECURE_LIST)) {
56
-		$to_secure_list = array_merge($to_secure_list, _COOKIE_SECURE_LIST);
57
-	}
58
-
59
-	if (!is_array($options)) {
60
-		// anciens paramètres :
61
-		# spip_setcookie($name = '', $value = '', $expire = 0, $path = 'AUTO', $domain = '', $secure = '')
62
-		$opt = func_get_args();
63
-		$opt = array_slice($opt, 2);
64
-		$options = []; # /!\ après le func_get_args (sinon $opt[0] référence la nouvelle valeur de $options !);
65
-		if (isset($opt[0])) {
66
-			$options['expires'] = $opt[0];
67
-		}
68
-		if (isset($opt[1])) {
69
-			$options['path'] = $opt[1];
70
-		}
71
-		if (isset($opt[2])) {
72
-			$options['domain'] = $opt[2];
73
-		}
74
-		if (isset($opt[3])) {
75
-			$options['secure'] = $opt[3];
76
-		}
77
-	}
78
-
79
-	// expires
80
-	if (!isset($options['expires'])) {
81
-		$options['expires'] = 0;
82
-	}
83
-	if (!isset($options['path']) || $options['path'] === 'AUTO') {
84
-		$options['path'] = defined('_COOKIE_PATH') ? _COOKIE_PATH : preg_replace(',^\w+://[^/]*,', '', url_de_base());
85
-	}
86
-	if (empty($options['domain']) && defined('_COOKIE_DOMAIN') && _COOKIE_DOMAIN) {
87
-		$options['domain'] = _COOKIE_DOMAIN;
88
-	}
89
-	if (in_array($name, $to_secure_list)) {
90
-		if (empty($options['secure']) && defined('_COOKIE_SECURE') && _COOKIE_SECURE) {
91
-			$options['secure'] = true;
92
-		}
93
-		if (empty($options['httponly'])) {
94
-			$options['httponly'] = true;
95
-		}
96
-	}
97
-	if (empty($options['samesite'])) {
98
-		$options['samesite'] = 'Lax';
99
-	}
100
-
101
-	// in fine renommer le prefixe si besoin
102
-	if (str_starts_with($name, 'spip_')) {
103
-		$name = $GLOBALS['cookie_prefix'] . '_' . substr($name, 5);
104
-	}
105
-
106
-	#spip_log("cookie('$name', '$value', " . json_encode($options, true) . ")", "cookies");
107
-	$a = @setcookie($name, $value, $options);
108
-
109
-	spip_cookie_envoye(true);
110
-
111
-	return $a;
54
+    static $to_secure_list = ['spip_session'];
55
+    if (defined('_COOKIE_SECURE_LIST') && is_array(_COOKIE_SECURE_LIST)) {
56
+        $to_secure_list = array_merge($to_secure_list, _COOKIE_SECURE_LIST);
57
+    }
58
+
59
+    if (!is_array($options)) {
60
+        // anciens paramètres :
61
+        # spip_setcookie($name = '', $value = '', $expire = 0, $path = 'AUTO', $domain = '', $secure = '')
62
+        $opt = func_get_args();
63
+        $opt = array_slice($opt, 2);
64
+        $options = []; # /!\ après le func_get_args (sinon $opt[0] référence la nouvelle valeur de $options !);
65
+        if (isset($opt[0])) {
66
+            $options['expires'] = $opt[0];
67
+        }
68
+        if (isset($opt[1])) {
69
+            $options['path'] = $opt[1];
70
+        }
71
+        if (isset($opt[2])) {
72
+            $options['domain'] = $opt[2];
73
+        }
74
+        if (isset($opt[3])) {
75
+            $options['secure'] = $opt[3];
76
+        }
77
+    }
78
+
79
+    // expires
80
+    if (!isset($options['expires'])) {
81
+        $options['expires'] = 0;
82
+    }
83
+    if (!isset($options['path']) || $options['path'] === 'AUTO') {
84
+        $options['path'] = defined('_COOKIE_PATH') ? _COOKIE_PATH : preg_replace(',^\w+://[^/]*,', '', url_de_base());
85
+    }
86
+    if (empty($options['domain']) && defined('_COOKIE_DOMAIN') && _COOKIE_DOMAIN) {
87
+        $options['domain'] = _COOKIE_DOMAIN;
88
+    }
89
+    if (in_array($name, $to_secure_list)) {
90
+        if (empty($options['secure']) && defined('_COOKIE_SECURE') && _COOKIE_SECURE) {
91
+            $options['secure'] = true;
92
+        }
93
+        if (empty($options['httponly'])) {
94
+            $options['httponly'] = true;
95
+        }
96
+    }
97
+    if (empty($options['samesite'])) {
98
+        $options['samesite'] = 'Lax';
99
+    }
100
+
101
+    // in fine renommer le prefixe si besoin
102
+    if (str_starts_with($name, 'spip_')) {
103
+        $name = $GLOBALS['cookie_prefix'] . '_' . substr($name, 5);
104
+    }
105
+
106
+    #spip_log("cookie('$name', '$value', " . json_encode($options, true) . ")", "cookies");
107
+    $a = @setcookie($name, $value, $options);
108
+
109
+    spip_cookie_envoye(true);
110
+
111
+    return $a;
112 112
 }
113 113
 
114 114
 /**
@@ -124,12 +124,12 @@  discard block
 block discarded – undo
124 124
  * @return bool
125 125
  **/
126 126
 function spip_cookie_envoye($set = '') {
127
-	static $envoye = false;
128
-	if ($set) {
129
-		$envoye = true;
130
-	}
127
+    static $envoye = false;
128
+    if ($set) {
129
+        $envoye = true;
130
+    }
131 131
 
132
-	return $envoye;
132
+    return $envoye;
133 133
 }
134 134
 
135 135
 /**
@@ -148,21 +148,21 @@  discard block
 block discarded – undo
148 148
  *     Préfixe des cookies de SPIP
149 149
  **/
150 150
 function recuperer_cookies_spip($cookie_prefix) {
151
-	$prefix_long = strlen($cookie_prefix);
152
-
153
-	foreach (array_keys($_COOKIE) as $name) {
154
-		if (str_starts_with($name, 'spip_') && substr($name, 0, $prefix_long) != $cookie_prefix) {
155
-			unset($_COOKIE[$name]);
156
-			unset($GLOBALS[$name]);
157
-		}
158
-	}
159
-	foreach ($_COOKIE as $name => $value) {
160
-		if (substr($name, 0, $prefix_long) == $cookie_prefix) {
161
-			$spipname = preg_replace('/^' . $cookie_prefix . '_/', 'spip_', $name);
162
-			$_COOKIE[$spipname] = $value;
163
-			$GLOBALS[$spipname] = $value;
164
-		}
165
-	}
151
+    $prefix_long = strlen($cookie_prefix);
152
+
153
+    foreach (array_keys($_COOKIE) as $name) {
154
+        if (str_starts_with($name, 'spip_') && substr($name, 0, $prefix_long) != $cookie_prefix) {
155
+            unset($_COOKIE[$name]);
156
+            unset($GLOBALS[$name]);
157
+        }
158
+    }
159
+    foreach ($_COOKIE as $name => $value) {
160
+        if (substr($name, 0, $prefix_long) == $cookie_prefix) {
161
+            $spipname = preg_replace('/^' . $cookie_prefix . '_/', 'spip_', $name);
162
+            $_COOKIE[$spipname] = $value;
163
+            $GLOBALS[$spipname] = $value;
164
+        }
165
+    }
166 166
 }
167 167
 
168 168
 
@@ -181,18 +181,18 @@  discard block
 block discarded – undo
181 181
  *
182 182
  **/
183 183
 function exec_test_ajax_dist() {
184
-	switch (_request('js')) {
185
-		// on est appele par <noscript>
186
-		case -1:
187
-			spip_setcookie('spip_accepte_ajax', -1);
188
-			include_spip('inc/headers');
189
-			redirige_par_entete(chemin_image('erreur-xx.svg'));
190
-			break;
191
-
192
-		// ou par ajax
193
-		case 1:
194
-		default:
195
-			spip_setcookie('spip_accepte_ajax', 1);
196
-			break;
197
-	}
184
+    switch (_request('js')) {
185
+        // on est appele par <noscript>
186
+        case -1:
187
+            spip_setcookie('spip_accepte_ajax', -1);
188
+            include_spip('inc/headers');
189
+            redirige_par_entete(chemin_image('erreur-xx.svg'));
190
+            break;
191
+
192
+        // ou par ajax
193
+        case 1:
194
+        default:
195
+            spip_setcookie('spip_accepte_ajax', 1);
196
+            break;
197
+    }
198 198
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 
101 101
 	// in fine renommer le prefixe si besoin
102 102
 	if (str_starts_with($name, 'spip_')) {
103
-		$name = $GLOBALS['cookie_prefix'] . '_' . substr($name, 5);
103
+		$name = $GLOBALS['cookie_prefix'].'_'.substr($name, 5);
104 104
 	}
105 105
 
106 106
 	#spip_log("cookie('$name', '$value', " . json_encode($options, true) . ")", "cookies");
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 	}
159 159
 	foreach ($_COOKIE as $name => $value) {
160 160
 		if (substr($name, 0, $prefix_long) == $cookie_prefix) {
161
-			$spipname = preg_replace('/^' . $cookie_prefix . '_/', 'spip_', $name);
161
+			$spipname = preg_replace('/^'.$cookie_prefix.'_/', 'spip_', $name);
162 162
 			$_COOKIE[$spipname] = $value;
163 163
 			$GLOBALS[$spipname] = $value;
164 164
 		}
Please login to merge, or discard this patch.
ecrire/inc/selectionner.php 2 patches
Indentation   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  **/
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 include_spip('inc/filtres');
@@ -45,56 +45,56 @@  discard block
 block discarded – undo
45 45
  **/
46 46
 function inc_selectionner_dist($sel, $idom = '', $exclus = 0, $aff_racine = false, $recur = true, $do = 'aff') {
47 47
 
48
-	if ($recur) {
49
-		$recur = mini_hier($sel);
50
-	} else {
51
-		$sel = 0;
52
-	}
53
-
54
-	if ($aff_racine) {
55
-		$info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id=");
56
-		$idom3 = $idom . '_selection';
57
-
58
-		$onClick = "jQuery(this).parent().addClass('on');jQuery('#choix_parent_principal .on').removeClass('on'); aff_selection(0, '$idom3', '$info', event);return false;";
59
-
60
-		$ondbClick = strtr(
61
-			str_replace(
62
-				"'",
63
-				'&#8217;',
64
-				str_replace(
65
-					'"',
66
-					'&#34;',
67
-					textebrut(_T('info_racine_site'))
68
-				)
69
-			),
70
-			"\n\r",
71
-			'  '
72
-		);
73
-
74
-		$js_func = $do . '_selection_titre';
75
-		$ondbClick = "$js_func('$ondbClick',0,'selection_rubrique','id_parent');";
76
-
77
-		$aff_racine = "<div class='petit-item petite-racine item'>"
78
-			. "<a href='#'"
79
-			. 'onclick="'
80
-			. $onClick
81
-			. "\"\nondbclick=\""
82
-			. $ondbClick
83
-			. $onClick
84
-			. '">'
85
-			. _T('info_racine_site')
86
-			. '</a></div>';
87
-	}
88
-
89
-	$url_init = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclus&id=0&col=1&do=$do");
90
-
91
-	$plonger = charger_fonction('plonger', 'inc');
92
-	$plonger_r = $plonger($sel, $idom, $recur, 1, $exclus, $do);
93
-
94
-	// url completee par la fonction JS onkeypress_rechercher
95
-	$url = generer_url_ecrire('rechercher', "exclus=$exclus&rac=$idom&do=$do&type=");
96
-
97
-	return construire_selectionner_hierarchie($idom, $plonger_r, $aff_racine, $url, 'id_parent', $url_init);
48
+    if ($recur) {
49
+        $recur = mini_hier($sel);
50
+    } else {
51
+        $sel = 0;
52
+    }
53
+
54
+    if ($aff_racine) {
55
+        $info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id=");
56
+        $idom3 = $idom . '_selection';
57
+
58
+        $onClick = "jQuery(this).parent().addClass('on');jQuery('#choix_parent_principal .on').removeClass('on'); aff_selection(0, '$idom3', '$info', event);return false;";
59
+
60
+        $ondbClick = strtr(
61
+            str_replace(
62
+                "'",
63
+                '&#8217;',
64
+                str_replace(
65
+                    '"',
66
+                    '&#34;',
67
+                    textebrut(_T('info_racine_site'))
68
+                )
69
+            ),
70
+            "\n\r",
71
+            '  '
72
+        );
73
+
74
+        $js_func = $do . '_selection_titre';
75
+        $ondbClick = "$js_func('$ondbClick',0,'selection_rubrique','id_parent');";
76
+
77
+        $aff_racine = "<div class='petit-item petite-racine item'>"
78
+            . "<a href='#'"
79
+            . 'onclick="'
80
+            . $onClick
81
+            . "\"\nondbclick=\""
82
+            . $ondbClick
83
+            . $onClick
84
+            . '">'
85
+            . _T('info_racine_site')
86
+            . '</a></div>';
87
+    }
88
+
89
+    $url_init = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclus&id=0&col=1&do=$do");
90
+
91
+    $plonger = charger_fonction('plonger', 'inc');
92
+    $plonger_r = $plonger($sel, $idom, $recur, 1, $exclus, $do);
93
+
94
+    // url completee par la fonction JS onkeypress_rechercher
95
+    $url = generer_url_ecrire('rechercher', "exclus=$exclus&rac=$idom&do=$do&type=");
96
+
97
+    return construire_selectionner_hierarchie($idom, $plonger_r, $aff_racine, $url, 'id_parent', $url_init);
98 98
 }
99 99
 
100 100
 /**
@@ -112,58 +112,58 @@  discard block
 block discarded – undo
112 112
  **/
113 113
 function construire_selectionner_hierarchie($idom, $liste, $racine, $url, $name, $url_init = '') {
114 114
 
115
-	$idom1 = $idom . '_champ_recherche';
116
-	$idom2 = $idom . '_principal';
117
-	$idom3 = $idom . '_selection';
118
-	$idom4 = $idom . '_col_1';
119
-	$idom5 = 'img_' . $idom4;
120
-	$idom6 = $idom . '_fonc';
121
-
122
-	return "<div id='$idom'>"
123
-	. "<a id='$idom6' style='visibility: hidden;'"
124
-	. ($url_init ? "\nhref='$url_init'" : '')
125
-	. '></a>'
126
-	. "<div class='recherche_rapide_parent formulaire_recherche'>"
127
-	. http_img_pack(
128
-		'loader.svg',
129
-		'',
130
-		"class='loader' style='visibility: hidden;float:" . $GLOBALS['spip_lang_right'] . "' id='$idom5'"
131
-	)
132
-	. ''
133
-	. "<input style='width: 10em;float:" . $GLOBALS['spip_lang_right'] . ";' type='text' class='text search' id='$idom1' placeholder='" . _T('info_rechercher') . "'"
134
-	// eliminer Return car il provoque la soumission (balise unique)
135
-	// et eliminer Tab pour la navigation au clavier
136
-	// ce serait encore mieux de ne le faire que s'il y a encore plusieurs
137
-	// resultats retournes par la recherche
138
-	. "\nonkeypress=\"k=event.keyCode;if (k==13 || k==3 || k==9){return false;}\""
139
-	// lancer la recherche apres le filtrage ci-dessus sauf sur le tab (navigation au clavier)
140
-	. "\nonkeyup=\"if(event.keyCode==9){return false;};return onkey_rechercher(this.value,"
141
-	// la destination de la recherche
142
-	. "'$idom4'"
115
+    $idom1 = $idom . '_champ_recherche';
116
+    $idom2 = $idom . '_principal';
117
+    $idom3 = $idom . '_selection';
118
+    $idom4 = $idom . '_col_1';
119
+    $idom5 = 'img_' . $idom4;
120
+    $idom6 = $idom . '_fonc';
121
+
122
+    return "<div id='$idom'>"
123
+    . "<a id='$idom6' style='visibility: hidden;'"
124
+    . ($url_init ? "\nhref='$url_init'" : '')
125
+    . '></a>'
126
+    . "<div class='recherche_rapide_parent formulaire_recherche'>"
127
+    . http_img_pack(
128
+        'loader.svg',
129
+        '',
130
+        "class='loader' style='visibility: hidden;float:" . $GLOBALS['spip_lang_right'] . "' id='$idom5'"
131
+    )
132
+    . ''
133
+    . "<input style='width: 10em;float:" . $GLOBALS['spip_lang_right'] . ";' type='text' class='text search' id='$idom1' placeholder='" . _T('info_rechercher') . "'"
134
+    // eliminer Return car il provoque la soumission (balise unique)
135
+    // et eliminer Tab pour la navigation au clavier
136
+    // ce serait encore mieux de ne le faire que s'il y a encore plusieurs
137
+    // resultats retournes par la recherche
138
+    . "\nonkeypress=\"k=event.keyCode;if (k==13 || k==3 || k==9){return false;}\""
139
+    // lancer la recherche apres le filtrage ci-dessus sauf sur le tab (navigation au clavier)
140
+    . "\nonkeyup=\"if(event.keyCode==9){return false;};return onkey_rechercher(this.value,"
141
+    // la destination de la recherche
142
+    . "'$idom4'"
143 143
 #	. "this.parentNode.parentNode.parentNode.parentNode.nextSibling.firstChild.id"
144
-	. ",'"
145
-	// l'url effectuant la recherche
146
-	. $url
147
-	. "',"
148
-	// le noeud contenant un gif anime
149
-	// . "'idom5'"
150
-	. 'this.parentNode.previousSibling.firstChild'
151
-	. ",'"
152
-	// la valeur de l'attribut Name a remplir
153
-	. $name
154
-	. "','"
155
-	// noeud invisible memorisant l'URL initiale (pour re-initialisation)
156
-	. $idom6
157
-	. "')\""
158
-	. ' />'
159
-	. "\n</div>"
160
-	. ($racine ? "<div>$racine</div>" : '')
161
-	. "<div id='"
162
-	. $idom2
163
-	. "'><div id='$idom4'"
164
-	. " class=''>"
165
-	. $liste
166
-	. "</div></div>\n<div id='$idom3'></div></div>\n";
144
+    . ",'"
145
+    // l'url effectuant la recherche
146
+    . $url
147
+    . "',"
148
+    // le noeud contenant un gif anime
149
+    // . "'idom5'"
150
+    . 'this.parentNode.previousSibling.firstChild'
151
+    . ",'"
152
+    // la valeur de l'attribut Name a remplir
153
+    . $name
154
+    . "','"
155
+    // noeud invisible memorisant l'URL initiale (pour re-initialisation)
156
+    . $idom6
157
+    . "')\""
158
+    . ' />'
159
+    . "\n</div>"
160
+    . ($racine ? "<div>$racine</div>" : '')
161
+    . "<div id='"
162
+    . $idom2
163
+    . "'><div id='$idom4'"
164
+    . " class=''>"
165
+    . $liste
166
+    . "</div></div>\n<div id='$idom3'></div></div>\n";
167 167
 }
168 168
 
169 169
 /**
@@ -175,11 +175,11 @@  discard block
 block discarded – undo
175 175
  **/
176 176
 function mini_hier($id_rubrique) {
177 177
 
178
-	$liste = $id_rubrique;
179
-	$id_rubrique = (int) $id_rubrique;
180
-	while ($id_rubrique = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique = ' . $id_rubrique)) {
181
-		$liste = $id_rubrique . ",$liste";
182
-	}
178
+    $liste = $id_rubrique;
179
+    $id_rubrique = (int) $id_rubrique;
180
+    while ($id_rubrique = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique = ' . $id_rubrique)) {
181
+        $liste = $id_rubrique . ",$liste";
182
+    }
183 183
 
184
-	return explode(',', "0,$liste");
184
+    return explode(',', "0,$liste");
185 185
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 
54 54
 	if ($aff_racine) {
55 55
 		$info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id=");
56
-		$idom3 = $idom . '_selection';
56
+		$idom3 = $idom.'_selection';
57 57
 
58 58
 		$onClick = "jQuery(this).parent().addClass('on');jQuery('#choix_parent_principal .on').removeClass('on'); aff_selection(0, '$idom3', '$info', event);return false;";
59 59
 
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 			'  '
72 72
 		);
73 73
 
74
-		$js_func = $do . '_selection_titre';
74
+		$js_func = $do.'_selection_titre';
75 75
 		$ondbClick = "$js_func('$ondbClick',0,'selection_rubrique','id_parent');";
76 76
 
77 77
 		$aff_racine = "<div class='petit-item petite-racine item'>"
@@ -112,12 +112,12 @@  discard block
 block discarded – undo
112 112
  **/
113 113
 function construire_selectionner_hierarchie($idom, $liste, $racine, $url, $name, $url_init = '') {
114 114
 
115
-	$idom1 = $idom . '_champ_recherche';
116
-	$idom2 = $idom . '_principal';
117
-	$idom3 = $idom . '_selection';
118
-	$idom4 = $idom . '_col_1';
119
-	$idom5 = 'img_' . $idom4;
120
-	$idom6 = $idom . '_fonc';
115
+	$idom1 = $idom.'_champ_recherche';
116
+	$idom2 = $idom.'_principal';
117
+	$idom3 = $idom.'_selection';
118
+	$idom4 = $idom.'_col_1';
119
+	$idom5 = 'img_'.$idom4;
120
+	$idom6 = $idom.'_fonc';
121 121
 
122 122
 	return "<div id='$idom'>"
123 123
 	. "<a id='$idom6' style='visibility: hidden;'"
@@ -127,10 +127,10 @@  discard block
 block discarded – undo
127 127
 	. http_img_pack(
128 128
 		'loader.svg',
129 129
 		'',
130
-		"class='loader' style='visibility: hidden;float:" . $GLOBALS['spip_lang_right'] . "' id='$idom5'"
130
+		"class='loader' style='visibility: hidden;float:".$GLOBALS['spip_lang_right']."' id='$idom5'"
131 131
 	)
132 132
 	. ''
133
-	. "<input style='width: 10em;float:" . $GLOBALS['spip_lang_right'] . ";' type='text' class='text search' id='$idom1' placeholder='" . _T('info_rechercher') . "'"
133
+	. "<input style='width: 10em;float:".$GLOBALS['spip_lang_right'].";' type='text' class='text search' id='$idom1' placeholder='"._T('info_rechercher')."'"
134 134
 	// eliminer Return car il provoque la soumission (balise unique)
135 135
 	// et eliminer Tab pour la navigation au clavier
136 136
 	// ce serait encore mieux de ne le faire que s'il y a encore plusieurs
@@ -177,8 +177,8 @@  discard block
 block discarded – undo
177 177
 
178 178
 	$liste = $id_rubrique;
179 179
 	$id_rubrique = (int) $id_rubrique;
180
-	while ($id_rubrique = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique = ' . $id_rubrique)) {
181
-		$liste = $id_rubrique . ",$liste";
180
+	while ($id_rubrique = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique = '.$id_rubrique)) {
181
+		$liste = $id_rubrique.",$liste";
182 182
 	}
183 183
 
184 184
 	return explode(',', "0,$liste");
Please login to merge, or discard this patch.
ecrire/inc/icone_renommer.php 2 patches
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -10,71 +10,71 @@
 block discarded – undo
10 10
 \***************************************************************************/
11 11
 
12 12
 if (!defined('_ECRIRE_INC_VERSION')) {
13
-	return;
13
+    return;
14 14
 }
15 15
 
16 16
 include_spip('inc/boutons');
17 17
 include_spip('base/objets');
18 18
 
19 19
 function inc_icone_renommer_dist($fond, $fonction) {
20
-	$size = 24;
21
-	if (
22
-		preg_match('/(?:-(\d{1,3}))?([.](gif|png|svg))?$/i', $fond, $match)
23
-		&& (isset($match[0]) && $match[0] || isset($match[1]) && $match[1])
24
-	) {
25
-		if (isset($match[1]) && $match[1]) {
26
-			$size = $match[1];
27
-		}
28
-		$type = substr($fond, 0, -strlen($match[0]));
29
-		if (!isset($match[2]) || !$match[2]) {
30
-			$fond .= '.png';
31
-		}
32
-	} else {
33
-		$type = $fond;
34
-		$fond .= '.png';
35
-	}
20
+    $size = 24;
21
+    if (
22
+        preg_match('/(?:-(\d{1,3}))?([.](gif|png|svg))?$/i', $fond, $match)
23
+        && (isset($match[0]) && $match[0] || isset($match[1]) && $match[1])
24
+    ) {
25
+        if (isset($match[1]) && $match[1]) {
26
+            $size = $match[1];
27
+        }
28
+        $type = substr($fond, 0, -strlen($match[0]));
29
+        if (!isset($match[2]) || !$match[2]) {
30
+            $fond .= '.png';
31
+        }
32
+    } else {
33
+        $type = $fond;
34
+        $fond .= '.png';
35
+    }
36 36
 
37
-	$rtl = false;
38
-	if (preg_match(',[-_]rtl$,i', $type, $match)) {
39
-		$rtl = true;
40
-		$type = substr($type, 0, -strlen($match[0]));
41
-	}
37
+    $rtl = false;
38
+    if (preg_match(',[-_]rtl$,i', $type, $match)) {
39
+        $rtl = true;
40
+        $type = substr($type, 0, -strlen($match[0]));
41
+    }
42 42
 
43
-	// objet_type garde invariant tout ce qui ne commence par par id_, spip_
44
-	// et ne finit pas par un s, sauf si c'est une exception declaree
45
-	$type = objet_type($type, false);
43
+    // objet_type garde invariant tout ce qui ne commence par par id_, spip_
44
+    // et ne finit pas par un s, sauf si c'est une exception declaree
45
+    $type = objet_type($type, false);
46 46
 
47
-	$dir = 'images/';
48
-	$f = "$type-$size.png";
49
-	if ($icone = find_in_theme($dir . $f)) {
50
-		$dir = dirname($icone);
51
-		$fond = $icone;
47
+    $dir = 'images/';
48
+    $f = "$type-$size.png";
49
+    if ($icone = find_in_theme($dir . $f)) {
50
+        $dir = dirname($icone);
51
+        $fond = $icone;
52 52
 
53
-		if (
54
-			$rtl
55
-			&& ($fr = $dir . '/' . str_replace("$type-", "$type-rtl-", basename($icone)))
56
-			&& file_exists($fr)
57
-		) {
58
-			$fond = $fr;
59
-		}
53
+        if (
54
+            $rtl
55
+            && ($fr = $dir . '/' . str_replace("$type-", "$type-rtl-", basename($icone)))
56
+            && file_exists($fr)
57
+        ) {
58
+            $fond = $fr;
59
+        }
60 60
 
61
-		$action = $fonction;
62
-		if ($action == 'supprimer.gif') {
63
-			$action = 'del';
64
-		} elseif ($action == 'creer.gif') {
65
-			$action = 'new';
66
-		} elseif ($action == 'edit.gif') {
67
-			$action = 'edit';
68
-		}
61
+        $action = $fonction;
62
+        if ($action == 'supprimer.gif') {
63
+            $action = 'del';
64
+        } elseif ($action == 'creer.gif') {
65
+            $action = 'new';
66
+        } elseif ($action == 'edit.gif') {
67
+            $action = 'edit';
68
+        }
69 69
 
70
-		$fonction = '';
71
-		if (in_array($action, ['add','del', 'new', 'edit', 'config'])) {
72
-			$fonction = $action;
73
-		}
70
+        $fonction = '';
71
+        if (in_array($action, ['add','del', 'new', 'edit', 'config'])) {
72
+            $fonction = $action;
73
+        }
74 74
 
75
-		// c'est bon !
76
-		return [$fond, $fonction];
77
-	}
75
+        // c'est bon !
76
+        return [$fond, $fonction];
77
+    }
78 78
 
79
-	return [$fond, $fonction];
79
+    return [$fond, $fonction];
80 80
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -46,13 +46,13 @@  discard block
 block discarded – undo
46 46
 
47 47
 	$dir = 'images/';
48 48
 	$f = "$type-$size.png";
49
-	if ($icone = find_in_theme($dir . $f)) {
49
+	if ($icone = find_in_theme($dir.$f)) {
50 50
 		$dir = dirname($icone);
51 51
 		$fond = $icone;
52 52
 
53 53
 		if (
54 54
 			$rtl
55
-			&& ($fr = $dir . '/' . str_replace("$type-", "$type-rtl-", basename($icone)))
55
+			&& ($fr = $dir.'/'.str_replace("$type-", "$type-rtl-", basename($icone)))
56 56
 			&& file_exists($fr)
57 57
 		) {
58 58
 			$fond = $fr;
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 		}
69 69
 
70 70
 		$fonction = '';
71
-		if (in_array($action, ['add','del', 'new', 'edit', 'config'])) {
71
+		if (in_array($action, ['add', 'del', 'new', 'edit', 'config'])) {
72 72
 			$fonction = $action;
73 73
 		}
74 74
 
Please login to merge, or discard this patch.
ecrire/inc/chercher_rubrique.php 2 patches
Indentation   +189 added lines, -189 removed lines patch added patch discarded remove patch
@@ -17,16 +17,16 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 if (!defined('_SPIP_SELECT_RUBRIQUES')) {
24
-	/**
25
-	 * @var int Nombre de rubriques maximum du sélecteur de rubriques.
26
-	 * Au delà, on bascule sur un sélecteur ajax.
27
-	 * mettre 100000 pour desactiver ajax
28
-	 */
29
-	define('_SPIP_SELECT_RUBRIQUES', 20);
24
+    /**
25
+     * @var int Nombre de rubriques maximum du sélecteur de rubriques.
26
+     * Au delà, on bascule sur un sélecteur ajax.
27
+     * mettre 100000 pour desactiver ajax
28
+     */
29
+    define('_SPIP_SELECT_RUBRIQUES', 20);
30 30
 }
31 31
 
32 32
 /**
@@ -54,22 +54,22 @@  discard block
 block discarded – undo
54 54
  *     Code HTML du sélecteur
55 55
  **/
56 56
 function inc_chercher_rubrique_dist($id_rubrique, $type, $restreint, $idem = 0, $do = 'aff') {
57
-	if (sql_countsel('spip_rubriques') < 1) {
58
-		return '';
59
-	}
60
-
61
-	// Mode sans Ajax :
62
-	// - soit parce que le cookie ajax n'est pas la
63
-	// - soit parce qu'il y a peu de rubriques
64
-	if (
65
-		_SPIP_AJAX < 1
66
-		|| $type == 'breve'
67
-		|| sql_countsel('spip_rubriques') < _SPIP_SELECT_RUBRIQUES
68
-	) {
69
-		return selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem);
70
-	} else {
71
-		return selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem, $do);
72
-	}
57
+    if (sql_countsel('spip_rubriques') < 1) {
58
+        return '';
59
+    }
60
+
61
+    // Mode sans Ajax :
62
+    // - soit parce que le cookie ajax n'est pas la
63
+    // - soit parce qu'il y a peu de rubriques
64
+    if (
65
+        _SPIP_AJAX < 1
66
+        || $type == 'breve'
67
+        || sql_countsel('spip_rubriques') < _SPIP_SELECT_RUBRIQUES
68
+    ) {
69
+        return selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem);
70
+    } else {
71
+        return selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem, $do);
72
+    }
73 73
 }
74 74
 
75 75
 // compatibilite pour extensions qui utilisaient l'ancien nom
@@ -86,17 +86,17 @@  discard block
 block discarded – undo
86 86
  **/
87 87
 function style_menu_rubriques($i) {
88 88
 
89
-	$espace = '';
90
-	$style = '';
91
-	for ($count = 1; $count <= $i; $count++) {
92
-		$espace .= '&nbsp;&nbsp;&nbsp;&nbsp;';
93
-	}
94
-	if ($i == 1) {
95
-		$espace = '';
96
-	}
97
-	$class = "niveau_$i";
98
-
99
-	return [$class, $style, $espace];
89
+    $espace = '';
90
+    $style = '';
91
+    for ($count = 1; $count <= $i; $count++) {
92
+        $espace .= '&nbsp;&nbsp;&nbsp;&nbsp;';
93
+    }
94
+    if ($i == 1) {
95
+        $espace = '';
96
+    }
97
+    $class = "niveau_$i";
98
+
99
+    return [$class, $style, $espace];
100 100
 }
101 101
 
102 102
 /**
@@ -120,57 +120,57 @@  discard block
 block discarded – undo
120 120
  *     Code HTML du sélecteur
121 121
  **/
122 122
 function sous_menu_rubriques($id_rubrique, $root, $niv, &$data, &$enfants, $exclus, $restreint, $type) {
123
-	static $decalage_secteur;
124
-
125
-	// Si on a demande l'exclusion ne pas descendre dans la rubrique courante
126
-	if ($exclus > 0 && $root == $exclus) {
127
-		return '';
128
-	}
129
-
130
-	// en fonction du niveau faire un affichage plus ou moins kikoo
131
-
132
-	// selected ?
133
-	$selected = ($root == $id_rubrique) ? ' selected="selected"' : '';
134
-
135
-	// le style en fonction de la profondeur
136
-	[$class, $style, $espace] = style_menu_rubriques($niv);
137
-
138
-	$class .= ' selec_rub';
139
-
140
-	// creer l'<option> pour la rubrique $root
141
-
142
-	if (isset($data[$root])) { # pas de racine sauf pour les rubriques
143
-	$r = "<option$selected value='$root' class='$class' style='$style'>$espace"
144
-			. $data[$root]
145
-			. '</option>' . "\n";
146
-	} else {
147
-		$r = '';
148
-	}
149
-
150
-	// et le sous-menu pour ses enfants
151
-	$sous = '';
152
-	if (isset($enfants[$root])) {
153
-		foreach ($enfants[$root] as $sousrub) {
154
-			$sous .= sous_menu_rubriques(
155
-				$id_rubrique,
156
-				$sousrub,
157
-				$niv + 1,
158
-				$data,
159
-				$enfants,
160
-				$exclus,
161
-				$restreint,
162
-				$type
163
-			);
164
-		}
165
-	}
166
-
167
-	// si l'objet a deplacer est publie, verifier qu'on a acces aux rubriques
168
-	if ($restreint && $root != $id_rubrique && !autoriser('publierdans', 'rubrique', $root)) {
169
-		return $sous;
170
-	}
171
-
172
-	// et voila le travail
173
-	return $r . $sous;
123
+    static $decalage_secteur;
124
+
125
+    // Si on a demande l'exclusion ne pas descendre dans la rubrique courante
126
+    if ($exclus > 0 && $root == $exclus) {
127
+        return '';
128
+    }
129
+
130
+    // en fonction du niveau faire un affichage plus ou moins kikoo
131
+
132
+    // selected ?
133
+    $selected = ($root == $id_rubrique) ? ' selected="selected"' : '';
134
+
135
+    // le style en fonction de la profondeur
136
+    [$class, $style, $espace] = style_menu_rubriques($niv);
137
+
138
+    $class .= ' selec_rub';
139
+
140
+    // creer l'<option> pour la rubrique $root
141
+
142
+    if (isset($data[$root])) { # pas de racine sauf pour les rubriques
143
+    $r = "<option$selected value='$root' class='$class' style='$style'>$espace"
144
+            . $data[$root]
145
+            . '</option>' . "\n";
146
+    } else {
147
+        $r = '';
148
+    }
149
+
150
+    // et le sous-menu pour ses enfants
151
+    $sous = '';
152
+    if (isset($enfants[$root])) {
153
+        foreach ($enfants[$root] as $sousrub) {
154
+            $sous .= sous_menu_rubriques(
155
+                $id_rubrique,
156
+                $sousrub,
157
+                $niv + 1,
158
+                $data,
159
+                $enfants,
160
+                $exclus,
161
+                $restreint,
162
+                $type
163
+            );
164
+        }
165
+    }
166
+
167
+    // si l'objet a deplacer est publie, verifier qu'on a acces aux rubriques
168
+    if ($restreint && $root != $id_rubrique && !autoriser('publierdans', 'rubrique', $root)) {
169
+        return $sous;
170
+    }
171
+
172
+    // et voila le travail
173
+    return $r . $sous;
174 174
 }
175 175
 
176 176
 /**
@@ -191,75 +191,75 @@  discard block
 block discarded – undo
191 191
  *     Code HTML du sélecteur
192 192
  **/
193 193
 function selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem = 0) {
194
-	$enfants = [];
195
-	$data = [];
196
-	if ($type == 'rubrique' && autoriser('publierdans', 'rubrique', 0)) {
197
-		$data[0] = _T('info_racine_site');
198
-	}
199
-	# premier choix = neant
200
-	# si auteur (rubriques restreintes)
201
-	# ou si creation avec id_rubrique=0
202
-	elseif ($type == 'auteur' || !$id_rubrique) {
203
-		$data[0] = '&nbsp;';
204
-	}
205
-
206
-	//
207
-	// creer une structure contenant toute l'arborescence
208
-	//
209
-
210
-	include_spip('base/abstract_sql');
211
-	$q = sql_select(
212
-		'id_rubrique, id_parent, titre, statut, lang, langue_choisie',
213
-		'spip_rubriques',
214
-		($type == 'breve' ? ' id_parent=0 ' : ''),
215
-		'',
216
-		'0+titre,titre'
217
-	);
218
-	while ($r = sql_fetch($q)) {
219
-		if (autoriser('voir', 'rubrique', $r['id_rubrique'])) {
220
-			// titre largeur maxi a 50
221
-			$titre = couper(supprimer_tags(typo($r['titre'])) . ' ', 50);
222
-			if (
223
-				$GLOBALS['meta']['multi_rubriques'] == 'oui'
224
-				&& ($r['langue_choisie'] == 'oui' || $r['id_parent'] == 0)
225
-			) {
226
-				$titre .= ' [' . traduire_nom_langue($r['lang']) . ']';
227
-			}
228
-			$data[$r['id_rubrique']] = $titre;
229
-			$enfants[$r['id_parent']][] = $r['id_rubrique'];
230
-			if ($id_rubrique == $r['id_rubrique']) {
231
-				$id_parent = $r['id_parent'];
232
-			}
233
-		}
234
-	}
235
-
236
-	// si une seule rubrique comme choix possible,
237
-	// inutile de mettre le selecteur sur un choix vide par defaut
238
-	// sauf si le selecteur s'adresse a une rubrique puisque on peut la mettre a la racine dans ce cas
239
-	if (
240
-		count($data) == 2
241
-		&& isset($data[0])
242
-		&& !in_array($type, ['auteur', 'rubrique'])
243
-		&& !$id_rubrique
244
-	) {
245
-		unset($data[0]);
246
-	}
247
-
248
-
249
-	$opt = sous_menu_rubriques($id_rubrique, 0, 0, $data, $enfants, $idem, $restreint, $type);
250
-	$att = " id='id_parent' name='id_parent'\nclass='selecteur_parent verdana1'";
251
-
252
-	if (preg_match(',^<option[^<>]*value=.(\d*).[^<>]*>([^<]*)</option>$,', $opt, $r)) {
253
-		$r = "<input$att type='hidden' value='" . $r[1] . "' />" . $r[2];
254
-	} else {
255
-		$r = '<select' . $att . " size='1'>\n$opt</select>\n";
256
-	}
257
-
258
-	# message pour neuneus (a supprimer ?)
194
+    $enfants = [];
195
+    $data = [];
196
+    if ($type == 'rubrique' && autoriser('publierdans', 'rubrique', 0)) {
197
+        $data[0] = _T('info_racine_site');
198
+    }
199
+    # premier choix = neant
200
+    # si auteur (rubriques restreintes)
201
+    # ou si creation avec id_rubrique=0
202
+    elseif ($type == 'auteur' || !$id_rubrique) {
203
+        $data[0] = '&nbsp;';
204
+    }
205
+
206
+    //
207
+    // creer une structure contenant toute l'arborescence
208
+    //
209
+
210
+    include_spip('base/abstract_sql');
211
+    $q = sql_select(
212
+        'id_rubrique, id_parent, titre, statut, lang, langue_choisie',
213
+        'spip_rubriques',
214
+        ($type == 'breve' ? ' id_parent=0 ' : ''),
215
+        '',
216
+        '0+titre,titre'
217
+    );
218
+    while ($r = sql_fetch($q)) {
219
+        if (autoriser('voir', 'rubrique', $r['id_rubrique'])) {
220
+            // titre largeur maxi a 50
221
+            $titre = couper(supprimer_tags(typo($r['titre'])) . ' ', 50);
222
+            if (
223
+                $GLOBALS['meta']['multi_rubriques'] == 'oui'
224
+                && ($r['langue_choisie'] == 'oui' || $r['id_parent'] == 0)
225
+            ) {
226
+                $titre .= ' [' . traduire_nom_langue($r['lang']) . ']';
227
+            }
228
+            $data[$r['id_rubrique']] = $titre;
229
+            $enfants[$r['id_parent']][] = $r['id_rubrique'];
230
+            if ($id_rubrique == $r['id_rubrique']) {
231
+                $id_parent = $r['id_parent'];
232
+            }
233
+        }
234
+    }
235
+
236
+    // si une seule rubrique comme choix possible,
237
+    // inutile de mettre le selecteur sur un choix vide par defaut
238
+    // sauf si le selecteur s'adresse a une rubrique puisque on peut la mettre a la racine dans ce cas
239
+    if (
240
+        count($data) == 2
241
+        && isset($data[0])
242
+        && !in_array($type, ['auteur', 'rubrique'])
243
+        && !$id_rubrique
244
+    ) {
245
+        unset($data[0]);
246
+    }
247
+
248
+
249
+    $opt = sous_menu_rubriques($id_rubrique, 0, 0, $data, $enfants, $idem, $restreint, $type);
250
+    $att = " id='id_parent' name='id_parent'\nclass='selecteur_parent verdana1'";
251
+
252
+    if (preg_match(',^<option[^<>]*value=.(\d*).[^<>]*>([^<]*)</option>$,', $opt, $r)) {
253
+        $r = "<input$att type='hidden' value='" . $r[1] . "' />" . $r[2];
254
+    } else {
255
+        $r = '<select' . $att . " size='1'>\n$opt</select>\n";
256
+    }
257
+
258
+    # message pour neuneus (a supprimer ?)
259 259
 #	if ($type != 'auteur' AND $type != 'breve')
260 260
 #		$r .= "\n<br />"._T('texte_rappel_selection_champs');
261 261
 
262
-	return $r;
262
+    return $r;
263 263
 }
264 264
 
265 265
 /**
@@ -293,22 +293,22 @@  discard block
 block discarded – undo
293 293
  */
294 294
 function selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem = 0, $do = 'aff') {
295 295
 
296
-	if ($id_rubrique) {
297
-		$titre = sql_getfetsel('titre', 'spip_rubriques', 'id_rubrique=' . (int) $id_rubrique);
298
-	} else {
299
-		$titre = $type == 'auteur' ? '&nbsp;' : _T('info_racine_site');
300
-	}
296
+    if ($id_rubrique) {
297
+        $titre = sql_getfetsel('titre', 'spip_rubriques', 'id_rubrique=' . (int) $id_rubrique);
298
+    } else {
299
+        $titre = $type == 'auteur' ? '&nbsp;' : _T('info_racine_site');
300
+    }
301 301
 
302
-	$titre = str_replace('&amp;', '&', entites_html(textebrut(typo($titre))));
303
-	$init = " disabled='disabled' type='text' value=\"" . $titre . "\"\nstyle='width:300px;'";
302
+    $titre = str_replace('&amp;', '&', entites_html(textebrut(typo($titre))));
303
+    $init = " disabled='disabled' type='text' value=\"" . $titre . "\"\nstyle='width:300px;'";
304 304
 
305
-	$url = generer_url_ecrire('selectionner', "id=$id_rubrique&type=$type&do=$do"
306
-		. ($idem ? "&exclus=$idem" : '')
307
-		. ($restreint ? '' : '&racine=oui')
308
-		. (isset($GLOBALS['var_profile']) ? '&var_profile=1' : ''));
305
+    $url = generer_url_ecrire('selectionner', "id=$id_rubrique&type=$type&do=$do"
306
+        . ($idem ? "&exclus=$idem" : '')
307
+        . ($restreint ? '' : '&racine=oui')
308
+        . (isset($GLOBALS['var_profile']) ? '&var_profile=1' : ''));
309 309
 
310 310
 
311
-	return construire_selecteur($url, '', 'selection_rubrique', 'id_parent', $init, $id_rubrique);
311
+    return construire_selecteur($url, '', 'selection_rubrique', 'id_parent', $init, $id_rubrique);
312 312
 }
313 313
 
314 314
 /**
@@ -338,30 +338,30 @@  discard block
 block discarded – undo
338 338
  *     Code HTML du sélecteur de rubrique AJAX
339 339
  **/
340 340
 function construire_selecteur($url, $js, $idom, $name, $init = '', $id = 0) {
341
-	$icone = (str_contains($idom, 'auteur')) ? 'auteur-24.png' : 'rechercher-20.png';
342
-	// si icone de recherche on embed le svg
343
-	$balise = ($icone === 'rechercher-20.png' ? chercher_filtre('balise_svg') : chercher_filtre('balise_img'));
344
-	$img_icone = $balise(chemin_image($icone), _T('titre_image_selecteur'));
345
-
346
-	return
347
-		"<div class='rubrique_actuelle'><a href='#' class='rubrique-search' role='button' style='display:inline-flex;vertical-align:middle;' onclick=\""
348
-		. $js
349
-		. " jQuery(this).toggleClass('toggled'); "
350
-		. "return charger_node_url_si_vide('"
351
-		. $url
352
-		. "', this.parentNode.nextSibling, this.nextSibling,'',event)\" title='" . attribut_html(_T('titre_image_selecteur')) . "'>"
353
-		. $img_icone
354
-		. "</a><img src='"
355
-		. chemin_image('loader.svg')
356
-		. "' class='loader' id='img_"
357
-		. $idom
358
-		. "'\nstyle='visibility: hidden;' alt='*' />"
359
-		. "<input id='titreparent' name='titreparent' class='text'"
360
-		. $init
361
-		. ' />'
362
-		. "<input type='hidden' id='$name' name='$name' value='"
363
-		. $id
364
-		. "' /><div class='nettoyeur'></div></div><div id='"
365
-		. $idom
366
-		. "'\nstyle='display: none;'></div>";
341
+    $icone = (str_contains($idom, 'auteur')) ? 'auteur-24.png' : 'rechercher-20.png';
342
+    // si icone de recherche on embed le svg
343
+    $balise = ($icone === 'rechercher-20.png' ? chercher_filtre('balise_svg') : chercher_filtre('balise_img'));
344
+    $img_icone = $balise(chemin_image($icone), _T('titre_image_selecteur'));
345
+
346
+    return
347
+        "<div class='rubrique_actuelle'><a href='#' class='rubrique-search' role='button' style='display:inline-flex;vertical-align:middle;' onclick=\""
348
+        . $js
349
+        . " jQuery(this).toggleClass('toggled'); "
350
+        . "return charger_node_url_si_vide('"
351
+        . $url
352
+        . "', this.parentNode.nextSibling, this.nextSibling,'',event)\" title='" . attribut_html(_T('titre_image_selecteur')) . "'>"
353
+        . $img_icone
354
+        . "</a><img src='"
355
+        . chemin_image('loader.svg')
356
+        . "' class='loader' id='img_"
357
+        . $idom
358
+        . "'\nstyle='visibility: hidden;' alt='*' />"
359
+        . "<input id='titreparent' name='titreparent' class='text'"
360
+        . $init
361
+        . ' />'
362
+        . "<input type='hidden' id='$name' name='$name' value='"
363
+        . $id
364
+        . "' /><div class='nettoyeur'></div></div><div id='"
365
+        . $idom
366
+        . "'\nstyle='display: none;'></div>";
367 367
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 	if (isset($data[$root])) { # pas de racine sauf pour les rubriques
143 143
 	$r = "<option$selected value='$root' class='$class' style='$style'>$espace"
144 144
 			. $data[$root]
145
-			. '</option>' . "\n";
145
+			. '</option>'."\n";
146 146
 	} else {
147 147
 		$r = '';
148 148
 	}
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 	}
171 171
 
172 172
 	// et voila le travail
173
-	return $r . $sous;
173
+	return $r.$sous;
174 174
 }
175 175
 
176 176
 /**
@@ -218,12 +218,12 @@  discard block
 block discarded – undo
218 218
 	while ($r = sql_fetch($q)) {
219 219
 		if (autoriser('voir', 'rubrique', $r['id_rubrique'])) {
220 220
 			// titre largeur maxi a 50
221
-			$titre = couper(supprimer_tags(typo($r['titre'])) . ' ', 50);
221
+			$titre = couper(supprimer_tags(typo($r['titre'])).' ', 50);
222 222
 			if (
223 223
 				$GLOBALS['meta']['multi_rubriques'] == 'oui'
224 224
 				&& ($r['langue_choisie'] == 'oui' || $r['id_parent'] == 0)
225 225
 			) {
226
-				$titre .= ' [' . traduire_nom_langue($r['lang']) . ']';
226
+				$titre .= ' ['.traduire_nom_langue($r['lang']).']';
227 227
 			}
228 228
 			$data[$r['id_rubrique']] = $titre;
229 229
 			$enfants[$r['id_parent']][] = $r['id_rubrique'];
@@ -250,9 +250,9 @@  discard block
 block discarded – undo
250 250
 	$att = " id='id_parent' name='id_parent'\nclass='selecteur_parent verdana1'";
251 251
 
252 252
 	if (preg_match(',^<option[^<>]*value=.(\d*).[^<>]*>([^<]*)</option>$,', $opt, $r)) {
253
-		$r = "<input$att type='hidden' value='" . $r[1] . "' />" . $r[2];
253
+		$r = "<input$att type='hidden' value='".$r[1]."' />".$r[2];
254 254
 	} else {
255
-		$r = '<select' . $att . " size='1'>\n$opt</select>\n";
255
+		$r = '<select'.$att." size='1'>\n$opt</select>\n";
256 256
 	}
257 257
 
258 258
 	# message pour neuneus (a supprimer ?)
@@ -294,13 +294,13 @@  discard block
 block discarded – undo
294 294
 function selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem = 0, $do = 'aff') {
295 295
 
296 296
 	if ($id_rubrique) {
297
-		$titre = sql_getfetsel('titre', 'spip_rubriques', 'id_rubrique=' . (int) $id_rubrique);
297
+		$titre = sql_getfetsel('titre', 'spip_rubriques', 'id_rubrique='.(int) $id_rubrique);
298 298
 	} else {
299 299
 		$titre = $type == 'auteur' ? '&nbsp;' : _T('info_racine_site');
300 300
 	}
301 301
 
302 302
 	$titre = str_replace('&amp;', '&', entites_html(textebrut(typo($titre))));
303
-	$init = " disabled='disabled' type='text' value=\"" . $titre . "\"\nstyle='width:300px;'";
303
+	$init = " disabled='disabled' type='text' value=\"".$titre."\"\nstyle='width:300px;'";
304 304
 
305 305
 	$url = generer_url_ecrire('selectionner', "id=$id_rubrique&type=$type&do=$do"
306 306
 		. ($idem ? "&exclus=$idem" : '')
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
 		. " jQuery(this).toggleClass('toggled'); "
350 350
 		. "return charger_node_url_si_vide('"
351 351
 		. $url
352
-		. "', this.parentNode.nextSibling, this.nextSibling,'',event)\" title='" . attribut_html(_T('titre_image_selecteur')) . "'>"
352
+		. "', this.parentNode.nextSibling, this.nextSibling,'',event)\" title='".attribut_html(_T('titre_image_selecteur'))."'>"
353 353
 		. $img_icone
354 354
 		. "</a><img src='"
355 355
 		. chemin_image('loader.svg')
Please login to merge, or discard this patch.
ecrire/inc/completer_traduction.php 2 patches
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  **/
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 /**
@@ -28,51 +28,51 @@  discard block
 block discarded – undo
28 28
  * @return string Erreur éventuelle
29 29
  */
30 30
 function inc_completer_traduction_dist($objet, $id_objet, $id_trad) {
31
-	// dupliquer tous les liens sauf les auteurs : le nouvel auteur est celui qui traduit
32
-	// cf API editer_liens
33
-	include_spip('action/editer_liens');
34
-	objet_dupliquer_liens($objet, $id_trad, $id_objet, null, ['auteur']);
35
-	$_id_table = id_table_objet($objet);
31
+    // dupliquer tous les liens sauf les auteurs : le nouvel auteur est celui qui traduit
32
+    // cf API editer_liens
33
+    include_spip('action/editer_liens');
34
+    objet_dupliquer_liens($objet, $id_trad, $id_objet, null, ['auteur']);
35
+    $_id_table = id_table_objet($objet);
36 36
 
37
-	// recuperer le logo
38
-	$chercher_logo = charger_fonction('chercher_logo', 'inc');
39
-	include_spip('action/editer_logo');
40
-	foreach (['on', 'off'] as $etat) {
41
-		$logo = $chercher_logo($id_trad, $_id_table, $etat);
42
-		if ($logo && ($file = reset($logo))) {
43
-			logo_modifier($objet, $id_objet, $etat, $file);
44
-		}
45
-	}
37
+    // recuperer le logo
38
+    $chercher_logo = charger_fonction('chercher_logo', 'inc');
39
+    include_spip('action/editer_logo');
40
+    foreach (['on', 'off'] as $etat) {
41
+        $logo = $chercher_logo($id_trad, $_id_table, $etat);
42
+        if ($logo && ($file = reset($logo))) {
43
+            logo_modifier($objet, $id_objet, $etat, $file);
44
+        }
45
+    }
46 46
 
47
-	// dupliquer certains champs
48
-	$trouver_table = charger_fonction('trouver_table', 'base');
49
-	$desc = $trouver_table(table_objet_sql($objet));
50
-	$champs = $set = [];
47
+    // dupliquer certains champs
48
+    $trouver_table = charger_fonction('trouver_table', 'base');
49
+    $desc = $trouver_table(table_objet_sql($objet));
50
+    $champs = $set = [];
51 51
 
52
-	// un éventuel champ 'virtuel' (redirections)
53
-	if (!empty($desc['field']['virtuel'])) {
54
-		$champs[] = 'virtuel';
55
-	}
52
+    // un éventuel champ 'virtuel' (redirections)
53
+    if (!empty($desc['field']['virtuel'])) {
54
+        $champs[] = 'virtuel';
55
+    }
56 56
 
57
-	$data = sql_fetsel('*', $desc['table'], $_id_table . '=' . (int) $id_trad);
57
+    $data = sql_fetsel('*', $desc['table'], $_id_table . '=' . (int) $id_trad);
58 58
 
59
-	foreach ($champs as $c) {
60
-		$set[$c] = $data[$c];
61
-	}
59
+    foreach ($champs as $c) {
60
+        $set[$c] = $data[$c];
61
+    }
62 62
 
63
-	/*
63
+    /*
64 64
 	 * Le pipeline 'pre_edition' sera appelé avec l'action 'completer_traduction'.
65 65
 	 * Des plugins pourront ainsi compléter les champs d'un objet traduit lors d'une nouvelle traduction.
66 66
 	 */
67
-	$err = objet_modifier_champs(
68
-		$objet,
69
-		$id_objet,
70
-		[
71
-			'data' => $data,
72
-			'action' => 'completer_traduction',
73
-		],
74
-		$set
75
-	);
67
+    $err = objet_modifier_champs(
68
+        $objet,
69
+        $id_objet,
70
+        [
71
+            'data' => $data,
72
+            'action' => 'completer_traduction',
73
+        ],
74
+        $set
75
+    );
76 76
 
77
-	return $err;
77
+    return $err;
78 78
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@
 block discarded – undo
54 54
 		$champs[] = 'virtuel';
55 55
 	}
56 56
 
57
-	$data = sql_fetsel('*', $desc['table'], $_id_table . '=' . (int) $id_trad);
57
+	$data = sql_fetsel('*', $desc['table'], $_id_table.'='.(int) $id_trad);
58 58
 
59 59
 	foreach ($champs as $c) {
60 60
 		$set[$c] = $data[$c];
Please login to merge, or discard this patch.
ecrire/inc/log.php 2 patches
Indentation   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -10,101 +10,101 @@
 block discarded – undo
10 10
 \***************************************************************************/
11 11
 
12 12
 if (!defined('_ECRIRE_INC_VERSION')) {
13
-	return;
13
+    return;
14 14
 }
15 15
 
16 16
 function inc_log_dist($message, $logname = null, $logdir = null, $logsuf = null) {
17
-	static $test_repertoire = [];
18
-	static $compteur = [];
19
-	static $debugverb = ''; // pour ne pas le recalculer au reappel
20
-
21
-	if (is_null($logname) || !is_string($logname)) {
22
-		$logname = defined('_FILE_LOG') ? _FILE_LOG : 'spip';
23
-	}
24
-	if (!isset($compteur[$logname])) {
25
-		$compteur[$logname] = 0;
26
-	}
27
-	if (
28
-		$logname != 'maj'
29
-		&& defined('_MAX_LOG')
30
-		&& ($compteur[$logname]++ > _MAX_LOG || !$GLOBALS['nombre_de_logs'] || !$GLOBALS['taille_des_logs'])
31
-	) {
32
-		return;
33
-	}
34
-
35
-	// si spip_log() est appelé dans mes_options, toutes les constantes n'ont pas été définies
36
-	$logfile =
37
-		($logdir ?? (defined('_DIR_LOG') ? _DIR_LOG : _DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES))
38
-		. $logname
39
-		. ($logsuf ?? (defined('_FILE_LOG_SUFFIX') ? _FILE_LOG_SUFFIX : '.log'));
40
-
41
-	if (!isset($test_repertoire[$d = dirname($logfile)])) {
42
-		$test_repertoire[$d] = false; // eviter une recursivite en cas d'erreur de sous_repertoire
43
-		$test_repertoire[$d] = (@is_dir($d) ? true : (function_exists('sous_repertoire') ? sous_repertoire(
44
-			$d,
45
-			'',
46
-			false,
47
-			true
48
-		) : false));
49
-	}
50
-
51
-	// Si le repertoire défini n'existe pas, poser dans tmp/
52
-	if (!$test_repertoire[$d]) {
53
-		$logfile = _DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES . $logname . '.log';
54
-	}
55
-
56
-	$rotate = 0;
57
-	$pid = '(pid ' . @getmypid() . ')';
58
-
59
-	// accepter spip_log( Array )
60
-	if (!is_string($message)) {
61
-		$message = var_export($message, true);
62
-	}
63
-
64
-	if (!$debugverb && defined('_LOG_FILELINE') && _LOG_FILELINE) {
65
-		$debug = debug_backtrace();
66
-		$l = $debug[1]['line'];
67
-		$fi = $debug[1]['file'];
68
-		if (str_starts_with($fi, _ROOT_RACINE)) {
69
-			$fi = substr($fi, strlen(_ROOT_RACINE));
70
-		}
71
-		$fu = $debug[2]['function'] ?? '';
72
-		$debugverb = "$fi:L$l:$fu" . '():';
73
-	}
74
-
75
-	$m = date('Y-m-d H:i:s') . ' ' . ($GLOBALS['ip'] ?? '') . ' ' . $pid . ' '
76
-		//distinguer les logs prives et publics dans les grep
77
-		. $debugverb
78
-		. (test_espace_prive() ? ':Pri:' : ':Pub:')
79
-		. preg_replace("/\n*$/", "\n", $message);
80
-
81
-
82
-	if (
83
-		@is_readable($logfile)
84
-		&& ((!$s = @filesize($logfile)) || $s > $GLOBALS['taille_des_logs'] * 1024)
85
-	) {
86
-		$rotate = $GLOBALS['nombre_de_logs'];
87
-		$m .= "[-- rotate --]\n";
88
-	}
89
-
90
-	$f = @fopen($logfile, 'ab');
91
-	if ($f) {
92
-		fwrite($f, (defined('_LOG_BRUT') && _LOG_BRUT) ? $m : str_replace('<', '&lt;', $m));
93
-		fclose($f);
94
-	}
95
-
96
-	if (
97
-		$rotate-- > 0 && function_exists('spip_unlink')
98
-	) {
99
-		spip_unlink($logfile . '.' . $rotate);
100
-		while ($rotate--) {
101
-			@rename($logfile . ($rotate ? '.' . $rotate : ''), $logfile . '.' . ($rotate + 1));
102
-		}
103
-	}
104
-
105
-	// Dupliquer les erreurs specifiques dans le log general
106
-	if (defined('_FILE_LOG') && $logname !== _FILE_LOG) {
107
-		inc_log_dist($logname == 'maj' ? 'cf maj.log' : $message);
108
-	}
109
-	$debugverb = '';
17
+    static $test_repertoire = [];
18
+    static $compteur = [];
19
+    static $debugverb = ''; // pour ne pas le recalculer au reappel
20
+
21
+    if (is_null($logname) || !is_string($logname)) {
22
+        $logname = defined('_FILE_LOG') ? _FILE_LOG : 'spip';
23
+    }
24
+    if (!isset($compteur[$logname])) {
25
+        $compteur[$logname] = 0;
26
+    }
27
+    if (
28
+        $logname != 'maj'
29
+        && defined('_MAX_LOG')
30
+        && ($compteur[$logname]++ > _MAX_LOG || !$GLOBALS['nombre_de_logs'] || !$GLOBALS['taille_des_logs'])
31
+    ) {
32
+        return;
33
+    }
34
+
35
+    // si spip_log() est appelé dans mes_options, toutes les constantes n'ont pas été définies
36
+    $logfile =
37
+        ($logdir ?? (defined('_DIR_LOG') ? _DIR_LOG : _DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES))
38
+        . $logname
39
+        . ($logsuf ?? (defined('_FILE_LOG_SUFFIX') ? _FILE_LOG_SUFFIX : '.log'));
40
+
41
+    if (!isset($test_repertoire[$d = dirname($logfile)])) {
42
+        $test_repertoire[$d] = false; // eviter une recursivite en cas d'erreur de sous_repertoire
43
+        $test_repertoire[$d] = (@is_dir($d) ? true : (function_exists('sous_repertoire') ? sous_repertoire(
44
+            $d,
45
+            '',
46
+            false,
47
+            true
48
+        ) : false));
49
+    }
50
+
51
+    // Si le repertoire défini n'existe pas, poser dans tmp/
52
+    if (!$test_repertoire[$d]) {
53
+        $logfile = _DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES . $logname . '.log';
54
+    }
55
+
56
+    $rotate = 0;
57
+    $pid = '(pid ' . @getmypid() . ')';
58
+
59
+    // accepter spip_log( Array )
60
+    if (!is_string($message)) {
61
+        $message = var_export($message, true);
62
+    }
63
+
64
+    if (!$debugverb && defined('_LOG_FILELINE') && _LOG_FILELINE) {
65
+        $debug = debug_backtrace();
66
+        $l = $debug[1]['line'];
67
+        $fi = $debug[1]['file'];
68
+        if (str_starts_with($fi, _ROOT_RACINE)) {
69
+            $fi = substr($fi, strlen(_ROOT_RACINE));
70
+        }
71
+        $fu = $debug[2]['function'] ?? '';
72
+        $debugverb = "$fi:L$l:$fu" . '():';
73
+    }
74
+
75
+    $m = date('Y-m-d H:i:s') . ' ' . ($GLOBALS['ip'] ?? '') . ' ' . $pid . ' '
76
+        //distinguer les logs prives et publics dans les grep
77
+        . $debugverb
78
+        . (test_espace_prive() ? ':Pri:' : ':Pub:')
79
+        . preg_replace("/\n*$/", "\n", $message);
80
+
81
+
82
+    if (
83
+        @is_readable($logfile)
84
+        && ((!$s = @filesize($logfile)) || $s > $GLOBALS['taille_des_logs'] * 1024)
85
+    ) {
86
+        $rotate = $GLOBALS['nombre_de_logs'];
87
+        $m .= "[-- rotate --]\n";
88
+    }
89
+
90
+    $f = @fopen($logfile, 'ab');
91
+    if ($f) {
92
+        fwrite($f, (defined('_LOG_BRUT') && _LOG_BRUT) ? $m : str_replace('<', '&lt;', $m));
93
+        fclose($f);
94
+    }
95
+
96
+    if (
97
+        $rotate-- > 0 && function_exists('spip_unlink')
98
+    ) {
99
+        spip_unlink($logfile . '.' . $rotate);
100
+        while ($rotate--) {
101
+            @rename($logfile . ($rotate ? '.' . $rotate : ''), $logfile . '.' . ($rotate + 1));
102
+        }
103
+    }
104
+
105
+    // Dupliquer les erreurs specifiques dans le log general
106
+    if (defined('_FILE_LOG') && $logname !== _FILE_LOG) {
107
+        inc_log_dist($logname == 'maj' ? 'cf maj.log' : $message);
108
+    }
109
+    $debugverb = '';
110 110
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 
35 35
 	// si spip_log() est appelé dans mes_options, toutes les constantes n'ont pas été définies
36 36
 	$logfile =
37
-		($logdir ?? (defined('_DIR_LOG') ? _DIR_LOG : _DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES))
37
+		($logdir ?? (defined('_DIR_LOG') ? _DIR_LOG : _DIR_RACINE._NOM_TEMPORAIRES_INACCESSIBLES))
38 38
 		. $logname
39 39
 		. ($logsuf ?? (defined('_FILE_LOG_SUFFIX') ? _FILE_LOG_SUFFIX : '.log'));
40 40
 
@@ -50,11 +50,11 @@  discard block
 block discarded – undo
50 50
 
51 51
 	// Si le repertoire défini n'existe pas, poser dans tmp/
52 52
 	if (!$test_repertoire[$d]) {
53
-		$logfile = _DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES . $logname . '.log';
53
+		$logfile = _DIR_RACINE._NOM_TEMPORAIRES_INACCESSIBLES.$logname.'.log';
54 54
 	}
55 55
 
56 56
 	$rotate = 0;
57
-	$pid = '(pid ' . @getmypid() . ')';
57
+	$pid = '(pid '.@getmypid().')';
58 58
 
59 59
 	// accepter spip_log( Array )
60 60
 	if (!is_string($message)) {
@@ -69,10 +69,10 @@  discard block
 block discarded – undo
69 69
 			$fi = substr($fi, strlen(_ROOT_RACINE));
70 70
 		}
71 71
 		$fu = $debug[2]['function'] ?? '';
72
-		$debugverb = "$fi:L$l:$fu" . '():';
72
+		$debugverb = "$fi:L$l:$fu".'():';
73 73
 	}
74 74
 
75
-	$m = date('Y-m-d H:i:s') . ' ' . ($GLOBALS['ip'] ?? '') . ' ' . $pid . ' '
75
+	$m = date('Y-m-d H:i:s').' '.($GLOBALS['ip'] ?? '').' '.$pid.' '
76 76
 		//distinguer les logs prives et publics dans les grep
77 77
 		. $debugverb
78 78
 		. (test_espace_prive() ? ':Pri:' : ':Pub:')
@@ -96,9 +96,9 @@  discard block
 block discarded – undo
96 96
 	if (
97 97
 		$rotate-- > 0 && function_exists('spip_unlink')
98 98
 	) {
99
-		spip_unlink($logfile . '.' . $rotate);
99
+		spip_unlink($logfile.'.'.$rotate);
100 100
 		while ($rotate--) {
101
-			@rename($logfile . ($rotate ? '.' . $rotate : ''), $logfile . '.' . ($rotate + 1));
101
+			@rename($logfile.($rotate ? '.'.$rotate : ''), $logfile.'.'.($rotate + 1));
102 102
 		}
103 103
 	}
104 104
 
Please login to merge, or discard this patch.
ecrire/inc/svg.php 3 patches
Indentation   +429 added lines, -429 removed lines patch added patch discarded remove patch
@@ -16,13 +16,13 @@  discard block
 block discarded – undo
16 16
  **/
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 if (!defined('IMG_SVG')) {
23
-	// complete 	IMG_BMP | IMG_GIF | IMG_JPG | IMG_PNG | IMG_WBMP | IMG_XPM | IMG_WEBP
24
-	define('IMG_SVG', 128);
25
-	define('IMAGETYPE_SVG', 19);
23
+    // complete 	IMG_BMP | IMG_GIF | IMG_JPG | IMG_PNG | IMG_WBMP | IMG_XPM | IMG_WEBP
24
+    define('IMG_SVG', 128);
25
+    define('IMAGETYPE_SVG', 19);
26 26
 }
27 27
 
28 28
 /**
@@ -38,34 +38,34 @@  discard block
 block discarded – undo
38 38
  *   false si on a pas pu charger l'image
39 39
  */
40 40
 function svg_charger($fichier, $maxlen = null) {
41
-	if (str_starts_with($fichier, 'data:image/svg+xml')) {
42
-		$image = explode(';', $fichier, 2);
43
-		$image = end($image);
44
-		if (str_starts_with($image, 'base64,')) {
45
-			$image = base64_decode(substr($image, 7));
46
-		}
47
-		if (str_contains($image, '<svg')) {
48
-			return $image;
49
-		}
50
-		// encodage inconnu ou autre format d'image ?
51
-		return false;
52
-	}
53
-	// c'est peut etre deja une image svg ?
54
-	if (str_contains($fichier, '<svg')) {
55
-		return $fichier;
56
-	}
57
-	if (!file_exists($fichier)) {
58
-		$fichier  = supprimer_timestamp($fichier);
59
-		if (!file_exists($fichier)) {
60
-			return false;
61
-		}
62
-	}
63
-	$image = is_null($maxlen) ? file_get_contents($fichier) : file_get_contents($fichier, false, null, 0, $maxlen);
64
-	// est-ce bien une image svg ?
65
-	if (str_contains($image, '<svg')) {
66
-		return $image;
67
-	}
68
-	return false;
41
+    if (str_starts_with($fichier, 'data:image/svg+xml')) {
42
+        $image = explode(';', $fichier, 2);
43
+        $image = end($image);
44
+        if (str_starts_with($image, 'base64,')) {
45
+            $image = base64_decode(substr($image, 7));
46
+        }
47
+        if (str_contains($image, '<svg')) {
48
+            return $image;
49
+        }
50
+        // encodage inconnu ou autre format d'image ?
51
+        return false;
52
+    }
53
+    // c'est peut etre deja une image svg ?
54
+    if (str_contains($fichier, '<svg')) {
55
+        return $fichier;
56
+    }
57
+    if (!file_exists($fichier)) {
58
+        $fichier  = supprimer_timestamp($fichier);
59
+        if (!file_exists($fichier)) {
60
+            return false;
61
+        }
62
+    }
63
+    $image = is_null($maxlen) ? file_get_contents($fichier) : file_get_contents($fichier, false, null, 0, $maxlen);
64
+    // est-ce bien une image svg ?
65
+    if (str_contains($image, '<svg')) {
66
+        return $image;
67
+    }
68
+    return false;
69 69
 }
70 70
 
71 71
 /**
@@ -74,28 +74,28 @@  discard block
 block discarded – undo
74 74
  * @return array|bool
75 75
  */
76 76
 function svg_lire_balise_svg($fichier) {
77
-	if (!$debut_fichier = svg_charger($fichier, 4096)) {
78
-		return false;
79
-	}
80
-
81
-	if (($ps = stripos($debut_fichier, '<svg')) !== false) {
82
-		$pe = stripos($debut_fichier, '>', $ps);
83
-		$balise_svg = substr($debut_fichier, $ps, $pe - $ps + 1);
84
-
85
-		if (preg_match_all(',([\w:\-]+)=,Uims', $balise_svg, $matches)) {
86
-			if (!function_exists('extraire_attribut')) {
87
-				include_spip('inc/filtres');
88
-			}
89
-			$attributs = [];
90
-			foreach ($matches[1] as $att) {
91
-				$attributs[$att] = extraire_attribut($balise_svg, $att);
92
-			}
93
-
94
-			return [$balise_svg, $attributs];
95
-		}
96
-	}
97
-
98
-	return false;
77
+    if (!$debut_fichier = svg_charger($fichier, 4096)) {
78
+        return false;
79
+    }
80
+
81
+    if (($ps = stripos($debut_fichier, '<svg')) !== false) {
82
+        $pe = stripos($debut_fichier, '>', $ps);
83
+        $balise_svg = substr($debut_fichier, $ps, $pe - $ps + 1);
84
+
85
+        if (preg_match_all(',([\w:\-]+)=,Uims', $balise_svg, $matches)) {
86
+            if (!function_exists('extraire_attribut')) {
87
+                include_spip('inc/filtres');
88
+            }
89
+            $attributs = [];
90
+            foreach ($matches[1] as $att) {
91
+                $attributs[$att] = extraire_attribut($balise_svg, $att);
92
+            }
93
+
94
+            return [$balise_svg, $attributs];
95
+        }
96
+    }
97
+
98
+    return false;
99 99
 }
100 100
 
101 101
 /**
@@ -105,12 +105,12 @@  discard block
 block discarded – undo
105 105
  */
106 106
 function svg_lire_attributs($img) {
107 107
 
108
-	if ($svg_infos = svg_lire_balise_svg($img)) {
109
-		[$balise_svg, $attributs] = $svg_infos;
110
-		return $attributs;
111
-	}
108
+    if ($svg_infos = svg_lire_balise_svg($img)) {
109
+        [$balise_svg, $attributs] = $svg_infos;
110
+        return $attributs;
111
+    }
112 112
 
113
-	return false;
113
+    return false;
114 114
 }
115 115
 
116 116
 /**
@@ -120,19 +120,19 @@  discard block
 block discarded – undo
120 120
  * @return bool|float|int
121 121
  */
122 122
 function svg_dimension_to_pixels($dimension, $precision = 2) {
123
-	if (preg_match(',^(-?\d+(\.\d+)?)([^\d]*),i', trim($dimension), $m)) {
124
-		return match (strtolower($m[2])) {
125
-			'%' => false,
126
-			'em' => round($m[1] * 16, $precision),
127
-			'ex' => round($m[1] * 16, $precision),
128
-			'pc' => round($m[1] * 16, $precision),
129
-			'cm' => round($m[1] * 96 / 2.54, $precision),
130
-			'mm' => round($m[1] * 96 / 25.4, $precision),
131
-			'in' => round($m[1] * 96, $precision),
132
-			default => $m[1],
133
-		};
134
-	}
135
-	return false;
123
+    if (preg_match(',^(-?\d+(\.\d+)?)([^\d]*),i', trim($dimension), $m)) {
124
+        return match (strtolower($m[2])) {
125
+            '%' => false,
126
+            'em' => round($m[1] * 16, $precision),
127
+            'ex' => round($m[1] * 16, $precision),
128
+            'pc' => round($m[1] * 16, $precision),
129
+            'cm' => round($m[1] * 96 / 2.54, $precision),
130
+            'mm' => round($m[1] * 96 / 25.4, $precision),
131
+            'in' => round($m[1] * 96, $precision),
132
+            default => $m[1],
133
+        };
134
+    }
135
+    return false;
136 136
 }
137 137
 
138 138
 /**
@@ -143,14 +143,14 @@  discard block
 block discarded – undo
143 143
  * @return string
144 144
  */
145 145
 function svg_change_balise_svg($svg, $old_balise_svg, $attributs) {
146
-	$new_balise_svg = '<svg';
147
-	foreach ($attributs as $k => $v) {
148
-		$new_balise_svg .= " $k=\"" . entites_html($v) . '"';
149
-	}
150
-	$new_balise_svg .= '>';
151
-
152
-	$p = strpos($svg, $old_balise_svg);
153
-	return substr_replace($svg, $new_balise_svg, $p, strlen($old_balise_svg));
146
+    $new_balise_svg = '<svg';
147
+    foreach ($attributs as $k => $v) {
148
+        $new_balise_svg .= " $k=\"" . entites_html($v) . '"';
149
+    }
150
+    $new_balise_svg .= '>';
151
+
152
+    $p = strpos($svg, $old_balise_svg);
153
+    return substr_replace($svg, $new_balise_svg, $p, strlen($old_balise_svg));
154 154
 }
155 155
 
156 156
 /**
@@ -162,15 +162,15 @@  discard block
 block discarded – undo
162 162
  */
163 163
 function svg_insert_shapes($svg, $shapes, $start = true) {
164 164
 
165
-	if ($start === false || $start === 'end') {
166
-		$svg = str_replace('</svg>', $shapes . '</svg>', $svg);
167
-	}
168
-	else {
169
-		$p = stripos($svg, '<svg');
170
-		$p = strpos($svg, '>', $p);
171
-		$svg = substr_replace($svg, $shapes, $p + 1, 0);
172
-	}
173
-	return $svg;
165
+    if ($start === false || $start === 'end') {
166
+        $svg = str_replace('</svg>', $shapes . '</svg>', $svg);
167
+    }
168
+    else {
169
+        $p = stripos($svg, '<svg');
170
+        $p = strpos($svg, '>', $p);
171
+        $svg = substr_replace($svg, $shapes, $p + 1, 0);
172
+    }
173
+    return $svg;
174 174
 }
175 175
 
176 176
 /**
@@ -183,12 +183,12 @@  discard block
 block discarded – undo
183 183
  * @return string
184 184
  */
185 185
 function svg_clip_in_box($svg, $x, $y, $width, $height) {
186
-	$rect = "<rect x=\"$x\" y=\"$y\" width=\"$width\" height=\"$height\" />";
187
-	$id = 'clip-' . substr(md5($rect . strlen($svg)), 0, 8);
188
-	$clippath = "<clipPath id=\"$id\">$rect</clipPath>";
189
-	$g = "<g clip-path=\"url(#$id)\">";
190
-	$svg = svg_insert_shapes($svg, $clippath . $g);
191
-	return svg_insert_shapes($svg, '</g>', false);
186
+    $rect = "<rect x=\"$x\" y=\"$y\" width=\"$width\" height=\"$height\" />";
187
+    $id = 'clip-' . substr(md5($rect . strlen($svg)), 0, 8);
188
+    $clippath = "<clipPath id=\"$id\">$rect</clipPath>";
189
+    $g = "<g clip-path=\"url(#$id)\">";
190
+    $svg = svg_insert_shapes($svg, $clippath . $g);
191
+    return svg_insert_shapes($svg, '</g>', false);
192 192
 }
193 193
 
194 194
 /**
@@ -199,20 +199,20 @@  discard block
 block discarded – undo
199 199
  * @return bool|string
200 200
  */
201 201
 function svg_redimensionner($img, $new_width, $new_height) {
202
-	if (
203
-		($svg = svg_charger($img))
204
-		&& ($svg_infos = svg_lire_balise_svg($svg))
205
-	) {
206
-		[$balise_svg, $attributs] = $svg_infos;
207
-		if (!isset($attributs['viewBox'])) {
208
-			$attributs['viewBox'] = '0 0 ' . $attributs['width'] . ' ' . $attributs['height'];
209
-		}
210
-		$attributs['width'] = (string) $new_width;
211
-		$attributs['height'] = (string) $new_height;
212
-		return svg_change_balise_svg($svg, $balise_svg, $attributs);
213
-	}
214
-
215
-	return $img;
202
+    if (
203
+        ($svg = svg_charger($img))
204
+        && ($svg_infos = svg_lire_balise_svg($svg))
205
+    ) {
206
+        [$balise_svg, $attributs] = $svg_infos;
207
+        if (!isset($attributs['viewBox'])) {
208
+            $attributs['viewBox'] = '0 0 ' . $attributs['width'] . ' ' . $attributs['height'];
209
+        }
210
+        $attributs['width'] = (string) $new_width;
211
+        $attributs['height'] = (string) $new_height;
212
+        return svg_change_balise_svg($svg, $balise_svg, $attributs);
213
+    }
214
+
215
+    return $img;
216 216
 }
217 217
 
218 218
 /**
@@ -221,14 +221,14 @@  discard block
 block discarded – undo
221 221
  * @return string
222 222
  */
223 223
 function svg_couleur_to_hexa($couleur) {
224
-	if (str_starts_with($couleur, 'rgb(')) {
225
-		$c = explode(',', substr($couleur, 4));
226
-		$couleur = _couleur_dec_to_hex((int) $c[0], (int) $c[1], (int) $c[2]);
227
-	}
228
-	else {
229
-		$couleur = couleur_html_to_hex($couleur);
230
-	}
231
-	return '#' . ltrim($couleur, '#');
224
+    if (str_starts_with($couleur, 'rgb(')) {
225
+        $c = explode(',', substr($couleur, 4));
226
+        $couleur = _couleur_dec_to_hex((int) $c[0], (int) $c[1], (int) $c[2]);
227
+    }
228
+    else {
229
+        $couleur = couleur_html_to_hex($couleur);
230
+    }
231
+    return '#' . ltrim($couleur, '#');
232 232
 }
233 233
 
234 234
 /**
@@ -237,11 +237,11 @@  discard block
 block discarded – undo
237 237
  * @return array
238 238
  */
239 239
 function svg_couleur_to_rgb($couleur) {
240
-	if (str_starts_with($couleur, 'rgb(')) {
241
-		$c = explode(',', substr($couleur, 4));
242
-		return ['red' => (int) $c[0],'green' => (int) $c[1],'blue' => (int) $c[2]];
243
-	}
244
-	return _couleur_hex_to_dec($couleur);
240
+    if (str_starts_with($couleur, 'rgb(')) {
241
+        $c = explode(',', substr($couleur, 4));
242
+        return ['red' => (int) $c[0],'green' => (int) $c[1],'blue' => (int) $c[2]];
243
+    }
244
+    return _couleur_hex_to_dec($couleur);
245 245
 }
246 246
 
247 247
 
@@ -251,80 +251,80 @@  discard block
 block discarded – undo
251 251
  * @return array
252 252
  */
253 253
 function svg_getimagesize_from_attr($attributs) {
254
-	$width = 350; // default width
255
-	$height = 150; // default height
256
-
257
-	$viewBox = "0 0 $width $height";
258
-	if (isset($attributs['viewBox'])) {
259
-		$viewBox = $attributs['viewBox'];
260
-		$viewBox = preg_replace(',\s+,', ' ', $viewBox);
261
-	}
262
-	// et on la convertit en px
263
-	$viewBox = explode(' ', $viewBox);
264
-	$viewBox = array_map('svg_dimension_to_pixels', $viewBox);
265
-	if (!$viewBox[2]) {
266
-		$viewBox[2] = $width;
267
-	}
268
-	if (!$viewBox[3]) {
269
-		$viewBox[3] = $height;
270
-	}
271
-
272
-	$coeff = 1;
273
-	if (
274
-		isset($attributs['width'])
275
-		&& ($w = svg_dimension_to_pixels($attributs['width']))
276
-	) {
277
-		$width = $w;
278
-		// si on avait pas de viewBox, la construire a partir de ce width
279
-		if (empty($attributs['viewBox'])) {
280
-			$viewBox[2] = $width;
281
-			// si pas de height valide, on suppose l'image carree
282
-			$viewBox[3] = $width;
283
-		}
284
-	}
285
-	else {
286
-		// si on recupere la taille de la viewbox mais si la viewbox est petite on met un multiplicateur pour la taille finale
287
-		$width = $viewBox[2];
288
-		if ($width < 1) {
289
-			$coeff = max($coeff, 1000);
290
-		}
291
-		elseif ($width < 10) {
292
-			$coeff = max($coeff, 100);
293
-		}
294
-		elseif ($width < 100) {
295
-			$coeff = max($coeff, 10);
296
-		}
297
-	}
298
-	if (
299
-		isset($attributs['height'])
300
-		&& ($h = svg_dimension_to_pixels($attributs['height']))
301
-	) {
302
-		$height = $h;
303
-		// si on avait pas de viewBox, la construire a partir de ce height
304
-		if (empty($attributs['viewBox'])) {
305
-			$viewBox[3] = $height;
306
-		}
307
-	}
308
-	else {
309
-		$height = $viewBox[3];
310
-		if ($height < 1) {
311
-			$coeff = max($coeff, 1000);
312
-		}
313
-		elseif ($height < 10) {
314
-			$coeff = max($coeff, 100);
315
-		}
316
-		elseif ($height < 100) {
317
-			$coeff = max($coeff, 10);
318
-		}
319
-	}
320
-
321
-	// arrondir le width et height en pixel in fine
322
-	$width = round($coeff * $width);
323
-	$height = round($coeff * $height);
324
-
325
-	$viewBox = implode(' ', $viewBox);
326
-
327
-	return [$width, $height, $viewBox];
254
+    $width = 350; // default width
255
+    $height = 150; // default height
256
+
257
+    $viewBox = "0 0 $width $height";
258
+    if (isset($attributs['viewBox'])) {
259
+        $viewBox = $attributs['viewBox'];
260
+        $viewBox = preg_replace(',\s+,', ' ', $viewBox);
261
+    }
262
+    // et on la convertit en px
263
+    $viewBox = explode(' ', $viewBox);
264
+    $viewBox = array_map('svg_dimension_to_pixels', $viewBox);
265
+    if (!$viewBox[2]) {
266
+        $viewBox[2] = $width;
267
+    }
268
+    if (!$viewBox[3]) {
269
+        $viewBox[3] = $height;
270
+    }
271
+
272
+    $coeff = 1;
273
+    if (
274
+        isset($attributs['width'])
275
+        && ($w = svg_dimension_to_pixels($attributs['width']))
276
+    ) {
277
+        $width = $w;
278
+        // si on avait pas de viewBox, la construire a partir de ce width
279
+        if (empty($attributs['viewBox'])) {
280
+            $viewBox[2] = $width;
281
+            // si pas de height valide, on suppose l'image carree
282
+            $viewBox[3] = $width;
283
+        }
284
+    }
285
+    else {
286
+        // si on recupere la taille de la viewbox mais si la viewbox est petite on met un multiplicateur pour la taille finale
287
+        $width = $viewBox[2];
288
+        if ($width < 1) {
289
+            $coeff = max($coeff, 1000);
290
+        }
291
+        elseif ($width < 10) {
292
+            $coeff = max($coeff, 100);
293
+        }
294
+        elseif ($width < 100) {
295
+            $coeff = max($coeff, 10);
296
+        }
297
+    }
298
+    if (
299
+        isset($attributs['height'])
300
+        && ($h = svg_dimension_to_pixels($attributs['height']))
301
+    ) {
302
+        $height = $h;
303
+        // si on avait pas de viewBox, la construire a partir de ce height
304
+        if (empty($attributs['viewBox'])) {
305
+            $viewBox[3] = $height;
306
+        }
307
+    }
308
+    else {
309
+        $height = $viewBox[3];
310
+        if ($height < 1) {
311
+            $coeff = max($coeff, 1000);
312
+        }
313
+        elseif ($height < 10) {
314
+            $coeff = max($coeff, 100);
315
+        }
316
+        elseif ($height < 100) {
317
+            $coeff = max($coeff, 10);
318
+        }
319
+    }
320
+
321
+    // arrondir le width et height en pixel in fine
322
+    $width = round($coeff * $width);
323
+    $height = round($coeff * $height);
324
+
325
+    $viewBox = implode(' ', $viewBox);
326
+
327
+    return [$width, $height, $viewBox];
328 328
 }
329 329
 
330 330
 /**
@@ -340,23 +340,23 @@  discard block
 block discarded – undo
340 340
  * @return string
341 341
  */
342 342
 function svg_force_viewBox_px($img, $force_width_and_height = false) {
343
-	if (
344
-		($svg = svg_charger($img))
345
-		&& ($svg_infos = svg_lire_balise_svg($svg))
346
-	) {
347
-		[$balise_svg, $attributs] = $svg_infos;
348
-
349
-		[$width, $height, $viewBox] = svg_getimagesize_from_attr($attributs);
350
-
351
-		if ($force_width_and_height) {
352
-			$attributs['width'] = $width;
353
-			$attributs['height'] = $height;
354
-		}
355
-
356
-		$attributs['viewBox'] = $viewBox;
357
-		return svg_change_balise_svg($svg, $balise_svg, $attributs);
358
-	}
359
-	return $img;
343
+    if (
344
+        ($svg = svg_charger($img))
345
+        && ($svg_infos = svg_lire_balise_svg($svg))
346
+    ) {
347
+        [$balise_svg, $attributs] = $svg_infos;
348
+
349
+        [$width, $height, $viewBox] = svg_getimagesize_from_attr($attributs);
350
+
351
+        if ($force_width_and_height) {
352
+            $attributs['width'] = $width;
353
+            $attributs['height'] = $height;
354
+        }
355
+
356
+        $attributs['viewBox'] = $viewBox;
357
+        return svg_change_balise_svg($svg, $balise_svg, $attributs);
358
+    }
359
+    return $img;
360 360
 }
361 361
 
362 362
 /**
@@ -365,13 +365,13 @@  discard block
 block discarded – undo
365 365
  * @return array|mixed
366 366
  */
367 367
 function svg_extract_couleurs($img) {
368
-	if (
369
-		($svg = svg_charger($img))
370
-		&& preg_match_all('/(#[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f])|(rgb\([\s\d]+,[\s\d]+,[\s\d]+\))|(#[0-9a-f][0-9a-f][0-9a-f])/imS', $svg, $matches)
371
-	) {
372
-		return $matches[0];
373
-	}
374
-	return [];
368
+    if (
369
+        ($svg = svg_charger($img))
370
+        && preg_match_all('/(#[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f])|(rgb\([\s\d]+,[\s\d]+,[\s\d]+\))|(#[0-9a-f][0-9a-f][0-9a-f])/imS', $svg, $matches)
371
+    ) {
372
+        return $matches[0];
373
+    }
374
+    return [];
375 375
 }
376 376
 
377 377
 /**
@@ -382,58 +382,58 @@  discard block
 block discarded – undo
382 382
  * @return bool|string
383 383
  */
384 384
 function svg_recadrer($img, $new_width, $new_height, $offset_width, $offset_height, $background_color = '') {
385
-	if (
386
-		($svg = svg_force_viewBox_px($img))
387
-		&& ($svg_infos = svg_lire_balise_svg($svg))
388
-	) {
389
-		[$balise_svg, $attributs] = $svg_infos;
390
-		$viewBox = explode(' ', $attributs['viewBox']);
391
-
392
-		$viewport_w = $new_width;
393
-		$viewport_h = $new_height;
394
-		$viewport_ox = $offset_width;
395
-		$viewport_oy = $offset_height;
396
-
397
-		// si on a un width/height qui rescale, il faut rescaler
398
-		if (
399
-			isset($attributs['width'])
400
-			&& ($w = svg_dimension_to_pixels($attributs['width']))
401
-			&& isset($attributs['height'])
402
-			&& ($h = svg_dimension_to_pixels($attributs['height']))
403
-		) {
404
-			$xscale = $viewBox[2] / $w;
405
-			$viewport_w = round($viewport_w * $xscale, 2);
406
-			$viewport_ox = round($viewport_ox * $xscale, 2);
407
-			$yscale = $viewBox[3] / $h;
408
-			$viewport_h = round($viewport_h * $yscale, 2);
409
-			$viewport_oy = round($viewport_oy * $yscale, 2);
410
-		}
411
-
412
-		if ($viewport_w > $viewBox[2] || $viewport_h > $viewBox[3]) {
413
-			$svg = svg_clip_in_box($svg, $viewBox[0], $viewBox[1], $viewBox[2], $viewBox[3]);
414
-		}
415
-
416
-		// maintenant on redefinit la viewBox
417
-		$viewBox[0] += $viewport_ox;
418
-		$viewBox[1] += $viewport_oy;
419
-		$viewBox[2] = $viewport_w;
420
-		$viewBox[3] = $viewport_h;
421
-
422
-		$attributs['viewBox'] = implode(' ', $viewBox);
423
-		$attributs['width'] = (string) $new_width;
424
-		$attributs['height'] = (string) $new_height;
425
-
426
-		$svg = svg_change_balise_svg($svg, $balise_svg, $attributs);
427
-
428
-		// ajouter un background
429
-		if ($background_color && $background_color !== 'transparent') {
430
-			$svg = svg_ajouter_background($svg, $background_color);
431
-		}
432
-
433
-		return $svg;
434
-	}
435
-
436
-	return $img;
385
+    if (
386
+        ($svg = svg_force_viewBox_px($img))
387
+        && ($svg_infos = svg_lire_balise_svg($svg))
388
+    ) {
389
+        [$balise_svg, $attributs] = $svg_infos;
390
+        $viewBox = explode(' ', $attributs['viewBox']);
391
+
392
+        $viewport_w = $new_width;
393
+        $viewport_h = $new_height;
394
+        $viewport_ox = $offset_width;
395
+        $viewport_oy = $offset_height;
396
+
397
+        // si on a un width/height qui rescale, il faut rescaler
398
+        if (
399
+            isset($attributs['width'])
400
+            && ($w = svg_dimension_to_pixels($attributs['width']))
401
+            && isset($attributs['height'])
402
+            && ($h = svg_dimension_to_pixels($attributs['height']))
403
+        ) {
404
+            $xscale = $viewBox[2] / $w;
405
+            $viewport_w = round($viewport_w * $xscale, 2);
406
+            $viewport_ox = round($viewport_ox * $xscale, 2);
407
+            $yscale = $viewBox[3] / $h;
408
+            $viewport_h = round($viewport_h * $yscale, 2);
409
+            $viewport_oy = round($viewport_oy * $yscale, 2);
410
+        }
411
+
412
+        if ($viewport_w > $viewBox[2] || $viewport_h > $viewBox[3]) {
413
+            $svg = svg_clip_in_box($svg, $viewBox[0], $viewBox[1], $viewBox[2], $viewBox[3]);
414
+        }
415
+
416
+        // maintenant on redefinit la viewBox
417
+        $viewBox[0] += $viewport_ox;
418
+        $viewBox[1] += $viewport_oy;
419
+        $viewBox[2] = $viewport_w;
420
+        $viewBox[3] = $viewport_h;
421
+
422
+        $attributs['viewBox'] = implode(' ', $viewBox);
423
+        $attributs['width'] = (string) $new_width;
424
+        $attributs['height'] = (string) $new_height;
425
+
426
+        $svg = svg_change_balise_svg($svg, $balise_svg, $attributs);
427
+
428
+        // ajouter un background
429
+        if ($background_color && $background_color !== 'transparent') {
430
+            $svg = svg_ajouter_background($svg, $background_color);
431
+        }
432
+
433
+        return $svg;
434
+    }
435
+
436
+    return $img;
437 437
 }
438 438
 
439 439
 /**
@@ -443,26 +443,26 @@  discard block
 block discarded – undo
443 443
  * @return bool|string
444 444
  */
445 445
 function svg_ajouter_background($img, $background_color) {
446
-	if (
447
-		($svg = svg_charger($img))
448
-		&& ($svg_infos = svg_lire_balise_svg($svg))
449
-	) {
450
-		if ($background_color && $background_color !== 'transparent') {
451
-			[$balise_svg, $attributs] = $svg_infos;
452
-
453
-			$background_color = svg_couleur_to_hexa($background_color);
454
-			if (isset($attributs['viewBox'])) {
455
-				$viewBox = explode(' ', $attributs['viewBox']);
456
-				$rect = '<rect x="' . $viewBox[0] . '" y="' . $viewBox[1] . '" width="' . $viewBox[2] . '" height="' . $viewBox[3] . "\" fill=\"$background_color\"/>";
457
-			}
458
-			else {
459
-				$rect = "<rect width=\"100%\" height=\"100%\" fill=\"$background_color\"/>";
460
-			}
461
-			$svg = svg_insert_shapes($svg, $rect);
462
-		}
463
-		return $svg;
464
-	}
465
-	return $img;
446
+    if (
447
+        ($svg = svg_charger($img))
448
+        && ($svg_infos = svg_lire_balise_svg($svg))
449
+    ) {
450
+        if ($background_color && $background_color !== 'transparent') {
451
+            [$balise_svg, $attributs] = $svg_infos;
452
+
453
+            $background_color = svg_couleur_to_hexa($background_color);
454
+            if (isset($attributs['viewBox'])) {
455
+                $viewBox = explode(' ', $attributs['viewBox']);
456
+                $rect = '<rect x="' . $viewBox[0] . '" y="' . $viewBox[1] . '" width="' . $viewBox[2] . '" height="' . $viewBox[3] . "\" fill=\"$background_color\"/>";
457
+            }
458
+            else {
459
+                $rect = "<rect width=\"100%\" height=\"100%\" fill=\"$background_color\"/>";
460
+            }
461
+            $svg = svg_insert_shapes($svg, $rect);
462
+        }
463
+        return $svg;
464
+    }
465
+    return $img;
466 466
 }
467 467
 
468 468
 
@@ -473,26 +473,26 @@  discard block
 block discarded – undo
473 473
  * @return bool|string
474 474
  */
475 475
 function svg_ajouter_voile($img, $background_color, $opacity) {
476
-	if (
477
-		($svg = svg_charger($img))
478
-		&& ($svg_infos = svg_lire_balise_svg($svg))
479
-	) {
480
-		if ($background_color && $background_color !== 'transparent') {
481
-			[$balise_svg, $attributs] = $svg_infos;
482
-
483
-			$background_color = svg_couleur_to_hexa($background_color);
484
-			if (isset($attributs['viewBox'])) {
485
-				$viewBox = explode(' ', $attributs['viewBox']);
486
-				$rect = '<rect x="' . $viewBox[0] . '" y="' . $viewBox[1] . '" width="' . $viewBox[2] . '" height="' . $viewBox[3] . "\" fill=\"$background_color\" opacity=\"$opacity\"/>";
487
-			}
488
-			else {
489
-				$rect = "<rect width=\"100%\" height=\"100%\" fill=\"$background_color\"/>";
490
-			}
491
-			$svg = svg_insert_shapes($svg, $rect, false);
492
-		}
493
-		return $svg;
494
-	}
495
-	return $img;
476
+    if (
477
+        ($svg = svg_charger($img))
478
+        && ($svg_infos = svg_lire_balise_svg($svg))
479
+    ) {
480
+        if ($background_color && $background_color !== 'transparent') {
481
+            [$balise_svg, $attributs] = $svg_infos;
482
+
483
+            $background_color = svg_couleur_to_hexa($background_color);
484
+            if (isset($attributs['viewBox'])) {
485
+                $viewBox = explode(' ', $attributs['viewBox']);
486
+                $rect = '<rect x="' . $viewBox[0] . '" y="' . $viewBox[1] . '" width="' . $viewBox[2] . '" height="' . $viewBox[3] . "\" fill=\"$background_color\" opacity=\"$opacity\"/>";
487
+            }
488
+            else {
489
+                $rect = "<rect width=\"100%\" height=\"100%\" fill=\"$background_color\"/>";
490
+            }
491
+            $svg = svg_insert_shapes($svg, $rect, false);
492
+        }
493
+        return $svg;
494
+    }
495
+    return $img;
496 496
 }
497 497
 
498 498
 
@@ -503,27 +503,27 @@  discard block
 block discarded – undo
503 503
  * @return bool|string
504 504
  */
505 505
 function svg_transformer($img, $attributs) {
506
-	if (
507
-		($svg = svg_charger($img))
508
-		&& ($svg_infos = svg_lire_balise_svg($svg))
509
-	) {
510
-		if ($attributs) {
511
-			[$balise_svg, ] = $svg_infos;
512
-			$g = '<g';
513
-			foreach ($attributs as $k => $v) {
514
-				if (strlen($v)) {
515
-					$g .= " $k=\"" . attribut_html($v) . '"';
516
-				}
517
-			}
518
-			if (strlen($g) > 2) {
519
-				$g .= '>';
520
-				$svg = svg_insert_shapes($svg, $g);
521
-				$svg = svg_insert_shapes($svg, '</g>', false);
522
-			}
523
-		}
524
-		return $svg;
525
-	}
526
-	return $img;
506
+    if (
507
+        ($svg = svg_charger($img))
508
+        && ($svg_infos = svg_lire_balise_svg($svg))
509
+    ) {
510
+        if ($attributs) {
511
+            [$balise_svg, ] = $svg_infos;
512
+            $g = '<g';
513
+            foreach ($attributs as $k => $v) {
514
+                if (strlen($v)) {
515
+                    $g .= " $k=\"" . attribut_html($v) . '"';
516
+                }
517
+            }
518
+            if (strlen($g) > 2) {
519
+                $g .= '>';
520
+                $svg = svg_insert_shapes($svg, $g);
521
+                $svg = svg_insert_shapes($svg, '</g>', false);
522
+            }
523
+        }
524
+        return $svg;
525
+    }
526
+    return $img;
527 527
 }
528 528
 
529 529
 /**
@@ -534,21 +534,21 @@  discard block
 block discarded – undo
534 534
  * @return bool|string
535 535
  */
536 536
 function svg_apply_filter($img, $filter_def) {
537
-	if (
538
-		($svg = svg_charger($img))
539
-		&& ($svg_infos = svg_lire_balise_svg($svg))
540
-	) {
541
-		if ($filter_def) {
542
-			[$balise_svg, ] = $svg_infos;
543
-			$filter_id = 'filter-' . substr(md5($filter_def . strlen($svg)), 0, 8);
544
-			$filter = "<defs><filter id=\"$filter_id\">$filter_def</filter></defs>";
545
-			$g = "<g filter=\"url(#$filter_id)\">";
546
-			$svg = svg_insert_shapes($svg, $filter . $g);
547
-			$svg = svg_insert_shapes($svg, '</g>', false);
548
-		}
549
-		return $svg;
550
-	}
551
-	return $img;
537
+    if (
538
+        ($svg = svg_charger($img))
539
+        && ($svg_infos = svg_lire_balise_svg($svg))
540
+    ) {
541
+        if ($filter_def) {
542
+            [$balise_svg, ] = $svg_infos;
543
+            $filter_id = 'filter-' . substr(md5($filter_def . strlen($svg)), 0, 8);
544
+            $filter = "<defs><filter id=\"$filter_id\">$filter_def</filter></defs>";
545
+            $g = "<g filter=\"url(#$filter_id)\">";
546
+            $svg = svg_insert_shapes($svg, $filter . $g);
547
+            $svg = svg_insert_shapes($svg, '</g>', false);
548
+        }
549
+        return $svg;
550
+    }
551
+    return $img;
552 552
 }
553 553
 
554 554
 /**
@@ -558,8 +558,8 @@  discard block
 block discarded – undo
558 558
  * @return string
559 559
  */
560 560
 function svg_filter_blur($img, $blur_width) {
561
-	$blur_width = (int) $blur_width;
562
-	return svg_apply_filter($img, "<feGaussianBlur stdDeviation=\"$blur_width\"/>");
561
+    $blur_width = (int) $blur_width;
562
+    return svg_apply_filter($img, "<feGaussianBlur stdDeviation=\"$blur_width\"/>");
563 563
 }
564 564
 
565 565
 /**
@@ -569,10 +569,10 @@  discard block
 block discarded – undo
569 569
  * @return bool|string
570 570
  */
571 571
 function svg_filter_grayscale($img, $intensity) {
572
-	$value = round(1.0 - $intensity, 2);
573
-	//$filter = "<feColorMatrix type=\"matrix\" values=\"0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\"/>";
574
-	$filter = "<feColorMatrix type=\"saturate\" values=\"$value\"/>";
575
-	return svg_apply_filter($img, $filter);
572
+    $value = round(1.0 - $intensity, 2);
573
+    //$filter = "<feColorMatrix type=\"matrix\" values=\"0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\"/>";
574
+    $filter = "<feColorMatrix type=\"saturate\" values=\"$value\"/>";
575
+    return svg_apply_filter($img, $filter);
576 576
 }
577 577
 
578 578
 /**
@@ -582,8 +582,8 @@  discard block
 block discarded – undo
582 582
  * @return bool|string
583 583
  */
584 584
 function svg_filter_sepia($img, $intensity) {
585
-	$filter = '<feColorMatrix type="matrix" values="0.30 0.30 0.30 0.0 0 0.25 0.25 0.25 0.0 0 0.20 0.20 0.20 0.0 0 0.00 0.00 0.00 1 0"/>';
586
-	return svg_apply_filter($img, $filter);
585
+    $filter = '<feColorMatrix type="matrix" values="0.30 0.30 0.30 0.0 0 0.25 0.25 0.25 0.0 0 0.20 0.20 0.20 0.0 0 0.00 0.00 0.00 1 0"/>';
586
+    return svg_apply_filter($img, $filter);
587 587
 }
588 588
 
589 589
 /**
@@ -593,30 +593,30 @@  discard block
 block discarded – undo
593 593
  * @return bool|string
594 594
  */
595 595
 function svg_flip($img, $HorV) {
596
-	if (
597
-		($svg = svg_force_viewBox_px($img))
598
-		&& ($svg_infos = svg_lire_balise_svg($svg))
599
-	) {
600
-		[$balise_svg, $atts] = $svg_infos;
601
-		$viewBox = explode(' ', $atts['viewBox']);
602
-
603
-		if (!in_array($HorV, ['h', 'H'])) {
604
-			$transform = 'scale(-1,1)';
605
-
606
-			$x = (int) $viewBox[0] + (int) ($viewBox[2] / 2);
607
-			$mx = -$x;
608
-			$transform = "translate($x, 0) $transform translate($mx, 0)";
609
-		}
610
-		else {
611
-			$transform = 'scale(1,-1)';
612
-
613
-			$y = (int) $viewBox[1] + (int) ($viewBox[3] / 2);
614
-			$my = -$y;
615
-			$transform = "translate(0, $y) $transform translate(0, $my)";
616
-		}
617
-		return svg_transformer($svg, ['transform' => $transform]);
618
-	}
619
-	return $img;
596
+    if (
597
+        ($svg = svg_force_viewBox_px($img))
598
+        && ($svg_infos = svg_lire_balise_svg($svg))
599
+    ) {
600
+        [$balise_svg, $atts] = $svg_infos;
601
+        $viewBox = explode(' ', $atts['viewBox']);
602
+
603
+        if (!in_array($HorV, ['h', 'H'])) {
604
+            $transform = 'scale(-1,1)';
605
+
606
+            $x = (int) $viewBox[0] + (int) ($viewBox[2] / 2);
607
+            $mx = -$x;
608
+            $transform = "translate($x, 0) $transform translate($mx, 0)";
609
+        }
610
+        else {
611
+            $transform = 'scale(1,-1)';
612
+
613
+            $y = (int) $viewBox[1] + (int) ($viewBox[3] / 2);
614
+            $my = -$y;
615
+            $transform = "translate(0, $y) $transform translate(0, $my)";
616
+        }
617
+        return svg_transformer($svg, ['transform' => $transform]);
618
+    }
619
+    return $img;
620 620
 }
621 621
 
622 622
 /**
@@ -630,19 +630,19 @@  discard block
 block discarded – undo
630 630
  * @return bool|string
631 631
  */
632 632
 function svg_rotate($img, $angle, $center_x, $center_y) {
633
-	if (
634
-		($svg = svg_force_viewBox_px($img))
635
-		&& ($svg_infos = svg_lire_balise_svg($svg))
636
-	) {
637
-		[$balise_svg, $atts] = $svg_infos;
638
-		$viewBox = explode(' ', $atts['viewBox']);
639
-
640
-		$center_x = round($viewBox[0] + $center_x * $viewBox[2]);
641
-		$center_y = round($viewBox[1] + $center_y * $viewBox[3]);
642
-
643
-		return svg_transformer($svg, ['transform' => "rotate($angle $center_x $center_y)"]);
644
-	}
645
-	return $img;
633
+    if (
634
+        ($svg = svg_force_viewBox_px($img))
635
+        && ($svg_infos = svg_lire_balise_svg($svg))
636
+    ) {
637
+        [$balise_svg, $atts] = $svg_infos;
638
+        $viewBox = explode(' ', $atts['viewBox']);
639
+
640
+        $center_x = round($viewBox[0] + $center_x * $viewBox[2]);
641
+        $center_y = round($viewBox[1] + $center_y * $viewBox[3]);
642
+
643
+        return svg_transformer($svg, ['transform' => "rotate($angle $center_x $center_y)"]);
644
+    }
645
+    return $img;
646 646
 }
647 647
 
648 648
 /**
@@ -654,40 +654,40 @@  discard block
 block discarded – undo
654 654
  * @return bool|mixed|string
655 655
  */
656 656
 function svg_filtrer_couleurs($img, $callback_filter) {
657
-	if (
658
-		($svg = svg_force_viewBox_px($img))
659
-		&& ($colors = svg_extract_couleurs($svg))
660
-	) {
661
-		$colors = array_unique($colors);
662
-
663
-		$short = [];
664
-		$long = [];
665
-		while (count($colors)) {
666
-			$c = array_shift($colors);
667
-			if (strlen($c) == 4) {
668
-				$short[] = $c;
669
-			}
670
-			else {
671
-				$long[] = $c;
672
-			}
673
-		}
674
-
675
-		$colors = [...$long, ...$short];
676
-		$new_colors = [];
677
-		$colors = array_flip($colors);
678
-		foreach ($colors as $c => $k) {
679
-			$colors[$c] = "@@@COLOR$$k$@@@";
680
-		}
681
-
682
-
683
-		foreach ($colors as $original => $replace) {
684
-			$new = svg_couleur_to_hexa($original);
685
-			$new_colors[$replace] = $callback_filter($new);
686
-		}
687
-
688
-		$svg = str_replace(array_keys($colors), array_values($colors), $svg);
689
-
690
-		return str_replace(array_keys($new_colors), array_values($new_colors), $svg);
691
-	}
692
-	return $img;
657
+    if (
658
+        ($svg = svg_force_viewBox_px($img))
659
+        && ($colors = svg_extract_couleurs($svg))
660
+    ) {
661
+        $colors = array_unique($colors);
662
+
663
+        $short = [];
664
+        $long = [];
665
+        while (count($colors)) {
666
+            $c = array_shift($colors);
667
+            if (strlen($c) == 4) {
668
+                $short[] = $c;
669
+            }
670
+            else {
671
+                $long[] = $c;
672
+            }
673
+        }
674
+
675
+        $colors = [...$long, ...$short];
676
+        $new_colors = [];
677
+        $colors = array_flip($colors);
678
+        foreach ($colors as $c => $k) {
679
+            $colors[$c] = "@@@COLOR$$k$@@@";
680
+        }
681
+
682
+
683
+        foreach ($colors as $original => $replace) {
684
+            $new = svg_couleur_to_hexa($original);
685
+            $new_colors[$replace] = $callback_filter($new);
686
+        }
687
+
688
+        $svg = str_replace(array_keys($colors), array_values($colors), $svg);
689
+
690
+        return str_replace(array_keys($new_colors), array_values($new_colors), $svg);
691
+    }
692
+    return $img;
693 693
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 		return $fichier;
56 56
 	}
57 57
 	if (!file_exists($fichier)) {
58
-		$fichier  = supprimer_timestamp($fichier);
58
+		$fichier = supprimer_timestamp($fichier);
59 59
 		if (!file_exists($fichier)) {
60 60
 			return false;
61 61
 		}
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 function svg_change_balise_svg($svg, $old_balise_svg, $attributs) {
146 146
 	$new_balise_svg = '<svg';
147 147
 	foreach ($attributs as $k => $v) {
148
-		$new_balise_svg .= " $k=\"" . entites_html($v) . '"';
148
+		$new_balise_svg .= " $k=\"".entites_html($v).'"';
149 149
 	}
150 150
 	$new_balise_svg .= '>';
151 151
 
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 function svg_insert_shapes($svg, $shapes, $start = true) {
164 164
 
165 165
 	if ($start === false || $start === 'end') {
166
-		$svg = str_replace('</svg>', $shapes . '</svg>', $svg);
166
+		$svg = str_replace('</svg>', $shapes.'</svg>', $svg);
167 167
 	}
168 168
 	else {
169 169
 		$p = stripos($svg, '<svg');
@@ -184,10 +184,10 @@  discard block
 block discarded – undo
184 184
  */
185 185
 function svg_clip_in_box($svg, $x, $y, $width, $height) {
186 186
 	$rect = "<rect x=\"$x\" y=\"$y\" width=\"$width\" height=\"$height\" />";
187
-	$id = 'clip-' . substr(md5($rect . strlen($svg)), 0, 8);
187
+	$id = 'clip-'.substr(md5($rect.strlen($svg)), 0, 8);
188 188
 	$clippath = "<clipPath id=\"$id\">$rect</clipPath>";
189 189
 	$g = "<g clip-path=\"url(#$id)\">";
190
-	$svg = svg_insert_shapes($svg, $clippath . $g);
190
+	$svg = svg_insert_shapes($svg, $clippath.$g);
191 191
 	return svg_insert_shapes($svg, '</g>', false);
192 192
 }
193 193
 
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 	) {
206 206
 		[$balise_svg, $attributs] = $svg_infos;
207 207
 		if (!isset($attributs['viewBox'])) {
208
-			$attributs['viewBox'] = '0 0 ' . $attributs['width'] . ' ' . $attributs['height'];
208
+			$attributs['viewBox'] = '0 0 '.$attributs['width'].' '.$attributs['height'];
209 209
 		}
210 210
 		$attributs['width'] = (string) $new_width;
211 211
 		$attributs['height'] = (string) $new_height;
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 	else {
229 229
 		$couleur = couleur_html_to_hex($couleur);
230 230
 	}
231
-	return '#' . ltrim($couleur, '#');
231
+	return '#'.ltrim($couleur, '#');
232 232
 }
233 233
 
234 234
 /**
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 function svg_couleur_to_rgb($couleur) {
240 240
 	if (str_starts_with($couleur, 'rgb(')) {
241 241
 		$c = explode(',', substr($couleur, 4));
242
-		return ['red' => (int) $c[0],'green' => (int) $c[1],'blue' => (int) $c[2]];
242
+		return ['red' => (int) $c[0], 'green' => (int) $c[1], 'blue' => (int) $c[2]];
243 243
 	}
244 244
 	return _couleur_hex_to_dec($couleur);
245 245
 }
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 			$background_color = svg_couleur_to_hexa($background_color);
454 454
 			if (isset($attributs['viewBox'])) {
455 455
 				$viewBox = explode(' ', $attributs['viewBox']);
456
-				$rect = '<rect x="' . $viewBox[0] . '" y="' . $viewBox[1] . '" width="' . $viewBox[2] . '" height="' . $viewBox[3] . "\" fill=\"$background_color\"/>";
456
+				$rect = '<rect x="'.$viewBox[0].'" y="'.$viewBox[1].'" width="'.$viewBox[2].'" height="'.$viewBox[3]."\" fill=\"$background_color\"/>";
457 457
 			}
458 458
 			else {
459 459
 				$rect = "<rect width=\"100%\" height=\"100%\" fill=\"$background_color\"/>";
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
 			$background_color = svg_couleur_to_hexa($background_color);
484 484
 			if (isset($attributs['viewBox'])) {
485 485
 				$viewBox = explode(' ', $attributs['viewBox']);
486
-				$rect = '<rect x="' . $viewBox[0] . '" y="' . $viewBox[1] . '" width="' . $viewBox[2] . '" height="' . $viewBox[3] . "\" fill=\"$background_color\" opacity=\"$opacity\"/>";
486
+				$rect = '<rect x="'.$viewBox[0].'" y="'.$viewBox[1].'" width="'.$viewBox[2].'" height="'.$viewBox[3]."\" fill=\"$background_color\" opacity=\"$opacity\"/>";
487 487
 			}
488 488
 			else {
489 489
 				$rect = "<rect width=\"100%\" height=\"100%\" fill=\"$background_color\"/>";
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
 			$g = '<g';
513 513
 			foreach ($attributs as $k => $v) {
514 514
 				if (strlen($v)) {
515
-					$g .= " $k=\"" . attribut_html($v) . '"';
515
+					$g .= " $k=\"".attribut_html($v).'"';
516 516
 				}
517 517
 			}
518 518
 			if (strlen($g) > 2) {
@@ -540,10 +540,10 @@  discard block
 block discarded – undo
540 540
 	) {
541 541
 		if ($filter_def) {
542 542
 			[$balise_svg, ] = $svg_infos;
543
-			$filter_id = 'filter-' . substr(md5($filter_def . strlen($svg)), 0, 8);
543
+			$filter_id = 'filter-'.substr(md5($filter_def.strlen($svg)), 0, 8);
544 544
 			$filter = "<defs><filter id=\"$filter_id\">$filter_def</filter></defs>";
545 545
 			$g = "<g filter=\"url(#$filter_id)\">";
546
-			$svg = svg_insert_shapes($svg, $filter . $g);
546
+			$svg = svg_insert_shapes($svg, $filter.$g);
547 547
 			$svg = svg_insert_shapes($svg, '</g>', false);
548 548
 		}
549 549
 		return $svg;
Please login to merge, or discard this patch.
Braces   +12 added lines, -24 removed lines patch added patch discarded remove patch
@@ -164,8 +164,7 @@  discard block
 block discarded – undo
164 164
 
165 165
 	if ($start === false || $start === 'end') {
166 166
 		$svg = str_replace('</svg>', $shapes . '</svg>', $svg);
167
-	}
168
-	else {
167
+	} else {
169 168
 		$p = stripos($svg, '<svg');
170 169
 		$p = strpos($svg, '>', $p);
171 170
 		$svg = substr_replace($svg, $shapes, $p + 1, 0);
@@ -224,8 +223,7 @@  discard block
 block discarded – undo
224 223
 	if (str_starts_with($couleur, 'rgb(')) {
225 224
 		$c = explode(',', substr($couleur, 4));
226 225
 		$couleur = _couleur_dec_to_hex((int) $c[0], (int) $c[1], (int) $c[2]);
227
-	}
228
-	else {
226
+	} else {
229 227
 		$couleur = couleur_html_to_hex($couleur);
230 228
 	}
231 229
 	return '#' . ltrim($couleur, '#');
@@ -281,17 +279,14 @@  discard block
 block discarded – undo
281 279
 			// si pas de height valide, on suppose l'image carree
282 280
 			$viewBox[3] = $width;
283 281
 		}
284
-	}
285
-	else {
282
+	} else {
286 283
 		// si on recupere la taille de la viewbox mais si la viewbox est petite on met un multiplicateur pour la taille finale
287 284
 		$width = $viewBox[2];
288 285
 		if ($width < 1) {
289 286
 			$coeff = max($coeff, 1000);
290
-		}
291
-		elseif ($width < 10) {
287
+		} elseif ($width < 10) {
292 288
 			$coeff = max($coeff, 100);
293
-		}
294
-		elseif ($width < 100) {
289
+		} elseif ($width < 100) {
295 290
 			$coeff = max($coeff, 10);
296 291
 		}
297 292
 	}
@@ -304,16 +299,13 @@  discard block
 block discarded – undo
304 299
 		if (empty($attributs['viewBox'])) {
305 300
 			$viewBox[3] = $height;
306 301
 		}
307
-	}
308
-	else {
302
+	} else {
309 303
 		$height = $viewBox[3];
310 304
 		if ($height < 1) {
311 305
 			$coeff = max($coeff, 1000);
312
-		}
313
-		elseif ($height < 10) {
306
+		} elseif ($height < 10) {
314 307
 			$coeff = max($coeff, 100);
315
-		}
316
-		elseif ($height < 100) {
308
+		} elseif ($height < 100) {
317 309
 			$coeff = max($coeff, 10);
318 310
 		}
319 311
 	}
@@ -454,8 +446,7 @@  discard block
 block discarded – undo
454 446
 			if (isset($attributs['viewBox'])) {
455 447
 				$viewBox = explode(' ', $attributs['viewBox']);
456 448
 				$rect = '<rect x="' . $viewBox[0] . '" y="' . $viewBox[1] . '" width="' . $viewBox[2] . '" height="' . $viewBox[3] . "\" fill=\"$background_color\"/>";
457
-			}
458
-			else {
449
+			} else {
459 450
 				$rect = "<rect width=\"100%\" height=\"100%\" fill=\"$background_color\"/>";
460 451
 			}
461 452
 			$svg = svg_insert_shapes($svg, $rect);
@@ -484,8 +475,7 @@  discard block
 block discarded – undo
484 475
 			if (isset($attributs['viewBox'])) {
485 476
 				$viewBox = explode(' ', $attributs['viewBox']);
486 477
 				$rect = '<rect x="' . $viewBox[0] . '" y="' . $viewBox[1] . '" width="' . $viewBox[2] . '" height="' . $viewBox[3] . "\" fill=\"$background_color\" opacity=\"$opacity\"/>";
487
-			}
488
-			else {
478
+			} else {
489 479
 				$rect = "<rect width=\"100%\" height=\"100%\" fill=\"$background_color\"/>";
490 480
 			}
491 481
 			$svg = svg_insert_shapes($svg, $rect, false);
@@ -606,8 +596,7 @@  discard block
 block discarded – undo
606 596
 			$x = (int) $viewBox[0] + (int) ($viewBox[2] / 2);
607 597
 			$mx = -$x;
608 598
 			$transform = "translate($x, 0) $transform translate($mx, 0)";
609
-		}
610
-		else {
599
+		} else {
611 600
 			$transform = 'scale(1,-1)';
612 601
 
613 602
 			$y = (int) $viewBox[1] + (int) ($viewBox[3] / 2);
@@ -666,8 +655,7 @@  discard block
 block discarded – undo
666 655
 			$c = array_shift($colors);
667 656
 			if (strlen($c) == 4) {
668 657
 				$short[] = $c;
669
-			}
670
-			else {
658
+			} else {
671 659
 				$long[] = $c;
672 660
 			}
673 661
 		}
Please login to merge, or discard this patch.
ecrire/src/Afficher/Minipage/AbstractPage.php 2 patches
Indentation   +236 added lines, -236 removed lines patch added patch discarded remove patch
@@ -15,265 +15,265 @@
 block discarded – undo
15 15
  * Présentation des pages simplifiées
16 16
  **/
17 17
 abstract class AbstractPage {
18
-	public const TYPE = '';
18
+    public const TYPE = '';
19 19
 
20
-	public function __construct() {
21
-		include_fichiers_fonctions();
22
-		include_spip('inc/headers');
23
-		include_spip('inc/texte'); //inclue inc/lang et inc/filtres
24
-		include_spip('inc/filtres_images_mini');
25
-	}
20
+    public function __construct() {
21
+        include_fichiers_fonctions();
22
+        include_spip('inc/headers');
23
+        include_spip('inc/texte'); //inclue inc/lang et inc/filtres
24
+        include_spip('inc/filtres_images_mini');
25
+    }
26 26
 
27
-	/**
28
-	 * Retourne le début d'une page HTML minimale
29
-	 *
30
-	 * Le contenu de CSS minimales (reset.css, clear.css, minipage.css) est inséré
31
-	 * dans une balise script inline (compactée si possible)
32
-	 *
33
-	 * @param array $options
34
-	 *   string $lang : forcer la langue utilisateur
35
-	 *   string $page_title : titre éventuel de la page (nom du site par défaut)
36
-	 *   string $couleur_fond : pour la couleur dominante de la page (par défaut on reprend le réglage de la page de login)
37
-	 *   bool $all_inline : inliner les CSS pour envoyer toute la page en 1 hit
38
-	 *   string $doctype
39
-	 *   string $charset
40
-	 *   string $onload
41
-	 *   array $css_files : ajouter des fichiers css
42
-	 *   string $css : ajouter du CSS inline
43
-	 *   string $head : contenu à ajouter à la fin <head> (pour inclusion de JS ou JS inline...)
44
-	 * @return string
45
-	 *    Code HTML
46
-	 *
47
-	 * @uses html_lang_attributes()
48
-	 * @uses minifier() si le plugin compresseur est présent
49
-	 * @uses url_absolue_css()
50
-	 *
51
-	 * @uses utiliser_langue_visiteur()
52
-	 * @uses http_no_cache()
53
-	 */
54
-	protected function ouvreBody($options = []) {
55
-		$h = null;
56
-		$s = null;
57
-		$l = null;
58
-		if (empty($options['lang'])) {
59
-			// on se limite sur une langue de $GLOBALS['meta']['langues_multilingue'] car on est dans le public
60
-			utiliser_langue_visiteur($GLOBALS['meta']['langues_multilingue'] ?? null);
61
-		} else {
62
-			changer_langue($options['lang']);
63
-		}
64
-		http_no_cache();
27
+    /**
28
+     * Retourne le début d'une page HTML minimale
29
+     *
30
+     * Le contenu de CSS minimales (reset.css, clear.css, minipage.css) est inséré
31
+     * dans une balise script inline (compactée si possible)
32
+     *
33
+     * @param array $options
34
+     *   string $lang : forcer la langue utilisateur
35
+     *   string $page_title : titre éventuel de la page (nom du site par défaut)
36
+     *   string $couleur_fond : pour la couleur dominante de la page (par défaut on reprend le réglage de la page de login)
37
+     *   bool $all_inline : inliner les CSS pour envoyer toute la page en 1 hit
38
+     *   string $doctype
39
+     *   string $charset
40
+     *   string $onload
41
+     *   array $css_files : ajouter des fichiers css
42
+     *   string $css : ajouter du CSS inline
43
+     *   string $head : contenu à ajouter à la fin <head> (pour inclusion de JS ou JS inline...)
44
+     * @return string
45
+     *    Code HTML
46
+     *
47
+     * @uses html_lang_attributes()
48
+     * @uses minifier() si le plugin compresseur est présent
49
+     * @uses url_absolue_css()
50
+     *
51
+     * @uses utiliser_langue_visiteur()
52
+     * @uses http_no_cache()
53
+     */
54
+    protected function ouvreBody($options = []) {
55
+        $h = null;
56
+        $s = null;
57
+        $l = null;
58
+        if (empty($options['lang'])) {
59
+            // on se limite sur une langue de $GLOBALS['meta']['langues_multilingue'] car on est dans le public
60
+            utiliser_langue_visiteur($GLOBALS['meta']['langues_multilingue'] ?? null);
61
+        } else {
62
+            changer_langue($options['lang']);
63
+        }
64
+        http_no_cache();
65 65
 
66
-		$page_title = ($options['page_title'] ?? $GLOBALS['meta']['nom_site']);
67
-		$doctype = ($options['doctype'] ?? '<!DOCTYPE html>');
68
-		$doctype = trim($doctype) . "\n";
69
-		$charset = ($options['charset'] ?? 'utf-8');
70
-		$all_inline = ($options['all_inline'] ?? true);
71
-		$onLoad = ($options['onLoad'] ?? '');
72
-		if ($onLoad) {
73
-			$onLoad = ' onload="' . attribut_html($onLoad) . '"';
74
-		}
66
+        $page_title = ($options['page_title'] ?? $GLOBALS['meta']['nom_site']);
67
+        $doctype = ($options['doctype'] ?? '<!DOCTYPE html>');
68
+        $doctype = trim($doctype) . "\n";
69
+        $charset = ($options['charset'] ?? 'utf-8');
70
+        $all_inline = ($options['all_inline'] ?? true);
71
+        $onLoad = ($options['onLoad'] ?? '');
72
+        if ($onLoad) {
73
+            $onLoad = ' onload="' . attribut_html($onLoad) . '"';
74
+        }
75 75
 
76
-		# envoyer le charset
77
-		if (!headers_sent()) {
78
-			header('Content-Type: text/html; charset=' . $charset);
79
-		}
76
+        # envoyer le charset
77
+        if (!headers_sent()) {
78
+            header('Content-Type: text/html; charset=' . $charset);
79
+        }
80 80
 
81
-		$css = '';
81
+        $css = '';
82 82
 
83
-		if (function_exists('couleur_hex_to_hsl')) {
84
-			$couleur_fond = empty($options['couleur_fond'])
85
-				? lire_config('couleur_login', '#db1762')
86
-				: $options['couleur_fond'];
87
-			$h = couleur_hex_to_hsl($couleur_fond, 'h');
88
-			$s = couleur_hex_to_hsl($couleur_fond, 's');
89
-			$l = couleur_hex_to_hsl($couleur_fond, 'l');
90
-		}
83
+        if (function_exists('couleur_hex_to_hsl')) {
84
+            $couleur_fond = empty($options['couleur_fond'])
85
+                ? lire_config('couleur_login', '#db1762')
86
+                : $options['couleur_fond'];
87
+            $h = couleur_hex_to_hsl($couleur_fond, 'h');
88
+            $s = couleur_hex_to_hsl($couleur_fond, 's');
89
+            $l = couleur_hex_to_hsl($couleur_fond, 'l');
90
+        }
91 91
 
92
-		$inline = ':root {'
93
-			. "--minipage-color-theme--h: $h;"
94
-			. "--minipage-color-theme--s: $s;"
95
-			. "--minipage-color-theme--l: $l;}";
96
-		$vars = file_get_contents(find_in_theme('minipage.vars.css'));
97
-		$inline .= "\n" . trim($vars);
98
-		if (function_exists('minifier')) {
99
-			$inline = minifier($inline, 'css');
100
-		}
101
-		$files = [
102
-			find_in_theme('reset.css'),
103
-			find_in_theme('clear.css'),
104
-			find_in_theme('minipage.css'),
105
-		];
106
-		if (!empty($options['css_files'])) {
107
-			foreach ($options['css_files'] as $css_file) {
108
-				$files[] = $css_file;
109
-			}
110
-		}
111
-		if ($all_inline) {
112
-			// inliner les CSS (optimisation de la page minipage qui passe en un seul hit a la demande)
113
-			foreach ($files as $name) {
114
-				$file = direction_css($name);
115
-				if (function_exists('minifier')) {
116
-					$file = minifier($file);
117
-				} else {
118
-					$file = url_absolue_css($file); // precaution
119
-				}
120
-				$css .= file_get_contents($file);
121
-			}
122
-			$css = "$inline\n$css";
123
-			if (!empty($options['css'])) {
124
-				$css .= "\n" . $options['css'];
125
-			}
126
-			$css = "<style type='text/css'>$css</style>";
127
-		} else {
128
-			$css = "<style type='text/css'>$inline</style>";
129
-			foreach ($files as $name) {
130
-				$file = timestamp(direction_css($name));
131
-				$css .= "<link rel='stylesheet' href='" . attribut_html($file) . "' type='text/css' />\n";
132
-			}
133
-			if (!empty($options['css'])) {
134
-				$css .= "<style type='text/css'>" . $options['css'] . '</style>';
135
-			}
136
-		}
92
+        $inline = ':root {'
93
+            . "--minipage-color-theme--h: $h;"
94
+            . "--minipage-color-theme--s: $s;"
95
+            . "--minipage-color-theme--l: $l;}";
96
+        $vars = file_get_contents(find_in_theme('minipage.vars.css'));
97
+        $inline .= "\n" . trim($vars);
98
+        if (function_exists('minifier')) {
99
+            $inline = minifier($inline, 'css');
100
+        }
101
+        $files = [
102
+            find_in_theme('reset.css'),
103
+            find_in_theme('clear.css'),
104
+            find_in_theme('minipage.css'),
105
+        ];
106
+        if (!empty($options['css_files'])) {
107
+            foreach ($options['css_files'] as $css_file) {
108
+                $files[] = $css_file;
109
+            }
110
+        }
111
+        if ($all_inline) {
112
+            // inliner les CSS (optimisation de la page minipage qui passe en un seul hit a la demande)
113
+            foreach ($files as $name) {
114
+                $file = direction_css($name);
115
+                if (function_exists('minifier')) {
116
+                    $file = minifier($file);
117
+                } else {
118
+                    $file = url_absolue_css($file); // precaution
119
+                }
120
+                $css .= file_get_contents($file);
121
+            }
122
+            $css = "$inline\n$css";
123
+            if (!empty($options['css'])) {
124
+                $css .= "\n" . $options['css'];
125
+            }
126
+            $css = "<style type='text/css'>$css</style>";
127
+        } else {
128
+            $css = "<style type='text/css'>$inline</style>";
129
+            foreach ($files as $name) {
130
+                $file = timestamp(direction_css($name));
131
+                $css .= "<link rel='stylesheet' href='" . attribut_html($file) . "' type='text/css' />\n";
132
+            }
133
+            if (!empty($options['css'])) {
134
+                $css .= "<style type='text/css'>" . $options['css'] . '</style>';
135
+            }
136
+        }
137 137
 
138
-		return $doctype .
139
-			html_lang_attributes() .
140
-			"<head>\n" .
141
-			'<title>' .
142
-			textebrut($page_title) .
143
-			"</title>\n" .
144
-			"<meta name=\"viewport\" content=\"width=device-width\" />\n" .
145
-			$css .
146
-			(empty($options['head']) ? '' : $options['head']) .
147
-			"</head>\n" .
148
-			"<body{$onLoad} class=\"minipage" . ($this::TYPE ? ' minipage--' . $this::TYPE : '') . "\">\n" .
149
-			"\t<div class=\"minipage-bloc\">\n";
150
-	}
138
+        return $doctype .
139
+            html_lang_attributes() .
140
+            "<head>\n" .
141
+            '<title>' .
142
+            textebrut($page_title) .
143
+            "</title>\n" .
144
+            "<meta name=\"viewport\" content=\"width=device-width\" />\n" .
145
+            $css .
146
+            (empty($options['head']) ? '' : $options['head']) .
147
+            "</head>\n" .
148
+            "<body{$onLoad} class=\"minipage" . ($this::TYPE ? ' minipage--' . $this::TYPE : '') . "\">\n" .
149
+            "\t<div class=\"minipage-bloc\">\n";
150
+    }
151 151
 
152
-	/**
153
-	 * Ouvre le corps : affiche le header avec un éventuel titre + ouvre le div corps
154
-	 * @param $options
155
-	 * @return string
156
-	 */
157
-	protected function ouvreCorps($options = []) {
158
-		$url_site = url_de_base();
159
-		$header = "<header>\n" .
160
-			'<h1><a href="' . attribut_html($url_site) . '">' . interdire_scripts($GLOBALS['meta']['nom_site'] ?? '') . "</a></h1>\n";
152
+    /**
153
+     * Ouvre le corps : affiche le header avec un éventuel titre + ouvre le div corps
154
+     * @param $options
155
+     * @return string
156
+     */
157
+    protected function ouvreCorps($options = []) {
158
+        $url_site = url_de_base();
159
+        $header = "<header>\n" .
160
+            '<h1><a href="' . attribut_html($url_site) . '">' . interdire_scripts($GLOBALS['meta']['nom_site'] ?? '') . "</a></h1>\n";
161 161
 
162
-		$titre = ($options['titre'] ?? '');
163
-		if ($titre) {
164
-			$header .= '<h2>' . interdire_scripts($titre) . '</h2>';
165
-		}
166
-		$header .= '</header>';
162
+        $titre = ($options['titre'] ?? '');
163
+        if ($titre) {
164
+            $header .= '<h2>' . interdire_scripts($titre) . '</h2>';
165
+        }
166
+        $header .= '</header>';
167 167
 
168
-		return $header . "<div class='corps'>\n";
169
-	}
168
+        return $header . "<div class='corps'>\n";
169
+    }
170 170
 
171
-	/**
172
-	 * Ferme le corps : affiche le footer par défaut ou custom et ferme le div corps
173
-	 * @param $options
174
-	 * @return string
175
-	 */
176
-	protected function fermeCorps($options = []) {
177
-		$url_site = url_de_base();
171
+    /**
172
+     * Ferme le corps : affiche le footer par défaut ou custom et ferme le div corps
173
+     * @param $options
174
+     * @return string
175
+     */
176
+    protected function fermeCorps($options = []) {
177
+        $url_site = url_de_base();
178 178
 
179
-		if (isset($options['footer'])) {
180
-			$footer = $options['footer'];
181
-		} else {
182
-			$footer = '<a href="' . attribut_html($url_site) . '">' . _T('retour') . "</a>\n";
183
-		}
184
-		if (!empty($footer)) {
185
-			$footer = "<footer>\n{$footer}</footer>";
186
-		}
179
+        if (isset($options['footer'])) {
180
+            $footer = $options['footer'];
181
+        } else {
182
+            $footer = '<a href="' . attribut_html($url_site) . '">' . _T('retour') . "</a>\n";
183
+        }
184
+        if (!empty($footer)) {
185
+            $footer = "<footer>\n{$footer}</footer>";
186
+        }
187 187
 
188
-		return "</div>\n" . $footer;
189
-	}
188
+        return "</div>\n" . $footer;
189
+    }
190 190
 
191 191
 
192
-	/**
193
-	 * Retourne la fin d'une page HTML minimale
194
-	 *
195
-	 * @return string Code HTML
196
-	 */
197
-	protected function fermeBody() {
198
-		return "\n\t</div>\n</body>\n</html>";
199
-	}
192
+    /**
193
+     * Retourne la fin d'une page HTML minimale
194
+     *
195
+     * @return string Code HTML
196
+     */
197
+    protected function fermeBody() {
198
+        return "\n\t</div>\n</body>\n</html>";
199
+    }
200 200
 
201 201
 
202
-	/**
203
-	 * Retourne une page HTML contenant, dans une présentation minimale,
204
-	 * le contenu transmis dans `$corps`.
205
-	 *
206
-	 * Appelée pour afficher un message ou une demande de confirmation simple et rapide
207
-	 *
208
-	 * @param string $corps
209
-	 *   Corps de la page
210
-	 * @param array $options
211
-	 * @return string
212
-	 *   HTML de la page
213
-	 * @see  ouvreBody()
214
-	 * @see  ouvreCorps()
215
-	 *   string $titre : Titre à l'affichage (différent de $page_title)
216
-	 *   int $status : status de la page
217
-	 *   string $footer : pied de la box en remplacement du bouton retour par défaut
218
-	 * @uses ouvreBody()
219
-	 * @uses ouvreCorps()
220
-	 * @uses fermeCorps()
221
-	 * @uses fermeBody()
222
-	 *
223
-	 */
224
-	public function page($corps, $options = []) {
202
+    /**
203
+     * Retourne une page HTML contenant, dans une présentation minimale,
204
+     * le contenu transmis dans `$corps`.
205
+     *
206
+     * Appelée pour afficher un message ou une demande de confirmation simple et rapide
207
+     *
208
+     * @param string $corps
209
+     *   Corps de la page
210
+     * @param array $options
211
+     * @return string
212
+     *   HTML de la page
213
+     * @see  ouvreBody()
214
+     * @see  ouvreCorps()
215
+     *   string $titre : Titre à l'affichage (différent de $page_title)
216
+     *   int $status : status de la page
217
+     *   string $footer : pied de la box en remplacement du bouton retour par défaut
218
+     * @uses ouvreBody()
219
+     * @uses ouvreCorps()
220
+     * @uses fermeCorps()
221
+     * @uses fermeBody()
222
+     *
223
+     */
224
+    public function page($corps, $options = []) {
225 225
 
226
-		// par securite
227
-		if (!defined('_AJAX')) {
228
-			define('_AJAX', false);
229
-		}
226
+        // par securite
227
+        if (!defined('_AJAX')) {
228
+            define('_AJAX', false);
229
+        }
230 230
 
231
-		$status = ((int) ($options['status'] ?? 200)) ?: 200;
231
+        $status = ((int) ($options['status'] ?? 200)) ?: 200;
232 232
 
233
-		http_response_code($status);
233
+        http_response_code($status);
234 234
 
235
-		$html = $this->ouvreBody($options)
236
-			. $this->ouvreCorps($options)
237
-			. $corps
238
-			. $this->fermeCorps($options)
239
-			. $this->fermeBody();
235
+        $html = $this->ouvreBody($options)
236
+            . $this->ouvreCorps($options)
237
+            . $corps
238
+            . $this->fermeCorps($options)
239
+            . $this->fermeBody();
240 240
 
241
-		if (
242
-			$GLOBALS['profondeur_url'] >= (_DIR_RESTREINT ? 1 : 2)
243
-			&& empty($options['all_inline'])
244
-		) {
245
-			define('_SET_HTML_BASE', true);
246
-			include_spip('public/assembler');
247
-			$GLOBALS['html'] = true;
248
-			page_base_href($html);
249
-		}
250
-		return $html;
251
-	}
241
+        if (
242
+            $GLOBALS['profondeur_url'] >= (_DIR_RESTREINT ? 1 : 2)
243
+            && empty($options['all_inline'])
244
+        ) {
245
+            define('_SET_HTML_BASE', true);
246
+            include_spip('public/assembler');
247
+            $GLOBALS['html'] = true;
248
+            page_base_href($html);
249
+        }
250
+        return $html;
251
+    }
252 252
 
253
-	/**
254
-	 * Fonction helper pour les erreurs
255
-	 * @param ?string $message_erreur
256
-	 * @param array $options
257
-	 * @see page()
258
-	 * @return string
259
-	 *
260
-	 */
261
-	public function pageErreur($message_erreur = null, $options = []) {
253
+    /**
254
+     * Fonction helper pour les erreurs
255
+     * @param ?string $message_erreur
256
+     * @param array $options
257
+     * @see page()
258
+     * @return string
259
+     *
260
+     */
261
+    public function pageErreur($message_erreur = null, $options = []) {
262 262
 
263
-		if (empty($message_erreur)) {
264
-			if (empty($options['lang'])) {
265
-				utiliser_langue_visiteur();
266
-			} else {
267
-				changer_langue($options['lang']);
268
-			}
269
-			$message_erreur = _T('info_acces_interdit');
270
-		}
271
-		$corps = "<div class='msg-alert error'>"
272
-			. $message_erreur
273
-			. '</div>';
274
-		if (empty($options['status'])) {
275
-			$options['status'] = 403;
276
-		}
277
-		return $this->page($corps, $options);
278
-	}
263
+        if (empty($message_erreur)) {
264
+            if (empty($options['lang'])) {
265
+                utiliser_langue_visiteur();
266
+            } else {
267
+                changer_langue($options['lang']);
268
+            }
269
+            $message_erreur = _T('info_acces_interdit');
270
+        }
271
+        $corps = "<div class='msg-alert error'>"
272
+            . $message_erreur
273
+            . '</div>';
274
+        if (empty($options['status'])) {
275
+            $options['status'] = 403;
276
+        }
277
+        return $this->page($corps, $options);
278
+    }
279 279
 }
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -65,17 +65,17 @@  discard block
 block discarded – undo
65 65
 
66 66
 		$page_title = ($options['page_title'] ?? $GLOBALS['meta']['nom_site']);
67 67
 		$doctype = ($options['doctype'] ?? '<!DOCTYPE html>');
68
-		$doctype = trim($doctype) . "\n";
68
+		$doctype = trim($doctype)."\n";
69 69
 		$charset = ($options['charset'] ?? 'utf-8');
70 70
 		$all_inline = ($options['all_inline'] ?? true);
71 71
 		$onLoad = ($options['onLoad'] ?? '');
72 72
 		if ($onLoad) {
73
-			$onLoad = ' onload="' . attribut_html($onLoad) . '"';
73
+			$onLoad = ' onload="'.attribut_html($onLoad).'"';
74 74
 		}
75 75
 
76 76
 		# envoyer le charset
77 77
 		if (!headers_sent()) {
78
-			header('Content-Type: text/html; charset=' . $charset);
78
+			header('Content-Type: text/html; charset='.$charset);
79 79
 		}
80 80
 
81 81
 		$css = '';
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 			. "--minipage-color-theme--s: $s;"
95 95
 			. "--minipage-color-theme--l: $l;}";
96 96
 		$vars = file_get_contents(find_in_theme('minipage.vars.css'));
97
-		$inline .= "\n" . trim($vars);
97
+		$inline .= "\n".trim($vars);
98 98
 		if (function_exists('minifier')) {
99 99
 			$inline = minifier($inline, 'css');
100 100
 		}
@@ -121,31 +121,31 @@  discard block
 block discarded – undo
121 121
 			}
122 122
 			$css = "$inline\n$css";
123 123
 			if (!empty($options['css'])) {
124
-				$css .= "\n" . $options['css'];
124
+				$css .= "\n".$options['css'];
125 125
 			}
126 126
 			$css = "<style type='text/css'>$css</style>";
127 127
 		} else {
128 128
 			$css = "<style type='text/css'>$inline</style>";
129 129
 			foreach ($files as $name) {
130 130
 				$file = timestamp(direction_css($name));
131
-				$css .= "<link rel='stylesheet' href='" . attribut_html($file) . "' type='text/css' />\n";
131
+				$css .= "<link rel='stylesheet' href='".attribut_html($file)."' type='text/css' />\n";
132 132
 			}
133 133
 			if (!empty($options['css'])) {
134
-				$css .= "<style type='text/css'>" . $options['css'] . '</style>';
134
+				$css .= "<style type='text/css'>".$options['css'].'</style>';
135 135
 			}
136 136
 		}
137 137
 
138
-		return $doctype .
139
-			html_lang_attributes() .
140
-			"<head>\n" .
141
-			'<title>' .
142
-			textebrut($page_title) .
143
-			"</title>\n" .
144
-			"<meta name=\"viewport\" content=\"width=device-width\" />\n" .
145
-			$css .
146
-			(empty($options['head']) ? '' : $options['head']) .
147
-			"</head>\n" .
148
-			"<body{$onLoad} class=\"minipage" . ($this::TYPE ? ' minipage--' . $this::TYPE : '') . "\">\n" .
138
+		return $doctype.
139
+			html_lang_attributes().
140
+			"<head>\n".
141
+			'<title>'.
142
+			textebrut($page_title).
143
+			"</title>\n".
144
+			"<meta name=\"viewport\" content=\"width=device-width\" />\n".
145
+			$css.
146
+			(empty($options['head']) ? '' : $options['head']).
147
+			"</head>\n".
148
+			"<body{$onLoad} class=\"minipage".($this::TYPE ? ' minipage--'.$this::TYPE : '')."\">\n".
149 149
 			"\t<div class=\"minipage-bloc\">\n";
150 150
 	}
151 151
 
@@ -156,16 +156,16 @@  discard block
 block discarded – undo
156 156
 	 */
157 157
 	protected function ouvreCorps($options = []) {
158 158
 		$url_site = url_de_base();
159
-		$header = "<header>\n" .
160
-			'<h1><a href="' . attribut_html($url_site) . '">' . interdire_scripts($GLOBALS['meta']['nom_site'] ?? '') . "</a></h1>\n";
159
+		$header = "<header>\n".
160
+			'<h1><a href="'.attribut_html($url_site).'">'.interdire_scripts($GLOBALS['meta']['nom_site'] ?? '')."</a></h1>\n";
161 161
 
162 162
 		$titre = ($options['titre'] ?? '');
163 163
 		if ($titre) {
164
-			$header .= '<h2>' . interdire_scripts($titre) . '</h2>';
164
+			$header .= '<h2>'.interdire_scripts($titre).'</h2>';
165 165
 		}
166 166
 		$header .= '</header>';
167 167
 
168
-		return $header . "<div class='corps'>\n";
168
+		return $header."<div class='corps'>\n";
169 169
 	}
170 170
 
171 171
 	/**
@@ -179,13 +179,13 @@  discard block
 block discarded – undo
179 179
 		if (isset($options['footer'])) {
180 180
 			$footer = $options['footer'];
181 181
 		} else {
182
-			$footer = '<a href="' . attribut_html($url_site) . '">' . _T('retour') . "</a>\n";
182
+			$footer = '<a href="'.attribut_html($url_site).'">'._T('retour')."</a>\n";
183 183
 		}
184 184
 		if (!empty($footer)) {
185 185
 			$footer = "<footer>\n{$footer}</footer>";
186 186
 		}
187 187
 
188
-		return "</div>\n" . $footer;
188
+		return "</div>\n".$footer;
189 189
 	}
190 190
 
191 191
 
Please login to merge, or discard this patch.
ecrire/src/Afficher/Minipage/Installation.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -15,22 +15,22 @@
 block discarded – undo
15 15
  * Présentation des pages simplifiées pour installer SPIP
16 16
  **/
17 17
 class Installation extends Admin {
18
-	public const TYPE = 'installation';
18
+    public const TYPE = 'installation';
19 19
 
20
-	protected function setOptions(array $options) {
21
-		$options['titre'] ??= '';
22
-		if (!$options['titre'] || $options['titre'] === 'AUTO') {
23
-			$options['titre'] = _T('info_installation_systeme_publication');
24
-		}
25
-		$options = parent::setOptions($options);
26
-		$options['couleur_fond'] = '#a1124d';
27
-		$options['css_files'][] = find_in_theme('installation.css');
28
-		$options['footer'] = '';
29
-		return $options;
30
-	}
20
+    protected function setOptions(array $options) {
21
+        $options['titre'] ??= '';
22
+        if (!$options['titre'] || $options['titre'] === 'AUTO') {
23
+            $options['titre'] = _T('info_installation_systeme_publication');
24
+        }
25
+        $options = parent::setOptions($options);
26
+        $options['couleur_fond'] = '#a1124d';
27
+        $options['css_files'][] = find_in_theme('installation.css');
28
+        $options['footer'] = '';
29
+        return $options;
30
+    }
31 31
 
32
-	public function page($corps = '', $options = []) {
33
-		$options['titre'] ??= 'AUTO';
34
-		return parent::page($corps, $options);
35
-	}
32
+    public function page($corps = '', $options = []) {
33
+        $options['titre'] ??= 'AUTO';
34
+        return parent::page($corps, $options);
35
+    }
36 36
 }
Please login to merge, or discard this patch.