Completed
Push — master ( db1666...a9bd83 )
by cam
01:35
created
ecrire/inc/plugin.php 3 patches
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -561,11 +561,9 @@  discard block
 block discarded – undo
561 561
 		if (!isset($msg[$p])) {
562 562
 			if (isset($resume['erreur']) and $resume['erreur']) {
563 563
 				$msg[$p] = [$resume['erreur']];
564
-			}
565
-			elseif (!plugin_version_compatible($k['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) {
564
+			} elseif (!plugin_version_compatible($k['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) {
566 565
 				$msg[$p] = [plugin_message_incompatibilite($k['compatibilite'], $GLOBALS['spip_version_branche'], 'SPIP', 'necessite')];
567
-			}
568
-			elseif (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) {
566
+			} elseif (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) {
569 567
 				$msg[$p] = plugin_necessite($k['utilise'], $liste, 'utilise');
570 568
 			}
571 569
 		} else {
@@ -954,8 +952,7 @@  discard block
 block discarded – undo
954 952
 					if (is_dir(constant($dir_type) . $plug . '/squelettes/')) {
955 953
 						$chemins['public'][] = "_DIR_PLUGIN_{$prefix}.'squelettes/'";
956 954
 					}
957
-				}
958
-				else {
955
+				} else {
959 956
 					foreach ($info['chemin'] as $chemin) {
960 957
 						if (
961 958
 							!isset($chemin['version']) or plugin_version_compatible(
@@ -1425,8 +1422,7 @@  discard block
 block discarded – undo
1425 1422
 						echo "\n" . ($ok ? 'OK  ' : '/!\ ') . textebrut($titre) . "\n",
1426 1423
 						  $trace,
1427 1424
 						  "\n";
1428
-					}
1429
-					else {
1425
+					} else {
1430 1426
 						include_spip('inc/filtres_boites');
1431 1427
 						echo "<div class='install-plugins svp_retour'>"
1432 1428
 							. boite_ouvrir($titre, ($ok ? 'success' : 'error'))
@@ -1463,8 +1459,7 @@  discard block
 block discarded – undo
1463 1459
 	if (file_exists($nom)) {
1464 1460
 		if (substr($nom, -4) == '.php') {
1465 1461
 			$fichier_tmp = substr($nom, 0, -4) . '.tmp.php';
1466
-		}
1467
-		else {
1462
+		} else {
1468 1463
 			$fichier_tmp = $nom . '.tmp';
1469 1464
 		}
1470 1465
 		file_put_contents($fichier_tmp, $contenu);
Please login to merge, or discard this patch.
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 
23 23
 /** l'adresse du repertoire de telechargement et de decompactage des plugins */
24 24
 if (!defined('_DIR_PLUGINS_AUTO')) {
25
-	define('_DIR_PLUGINS_AUTO', _DIR_PLUGINS . 'auto/');
25
+	define('_DIR_PLUGINS_AUTO', _DIR_PLUGINS.'auto/');
26 26
 }
27 27
 
28 28
 #include_spip('inc/texte'); // ????? Appelle public/parametrer trop tot avant la reconstruction du chemin des plugins.
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 				if ($dir) {
374 374
 					$dir .= '/';
375 375
 				}
376
-				$dir .= 'procure:' . $procure['nom'];
376
+				$dir .= 'procure:'.$procure['nom'];
377 377
 
378 378
 				$procure['etat'] = '?';
379 379
 				$procure['dir_type'] = $resume['dir_type'];
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
 		$plug = $resume['dir'];
558 558
 		$k = $infos[$dir_type][$plug];
559 559
 
560
-		$plug = constant($dir_type) . $plug;
560
+		$plug = constant($dir_type).$plug;
561 561
 		if (!isset($msg[$p])) {
562 562
 			if (isset($resume['erreur']) and $resume['erreur']) {
563 563
 				$msg[$p] = [$resume['erreur']];
@@ -600,10 +600,10 @@  discard block
 block discarded – undo
600 600
 		$list = $raw ? [] : $GLOBALS['meta']['plugin_erreur_activation'];
601 601
 	} elseif (!$raw) {
602 602
 		foreach ($list as $plug => $msg) {
603
-			$list[$plug] = '<li>' . _T('plugin_impossible_activer', ['plugin' => $plug])
604
-				. '<ul><li>' . implode('</li><li>', $msg) . '</li></ul></li>';
603
+			$list[$plug] = '<li>'._T('plugin_impossible_activer', ['plugin' => $plug])
604
+				. '<ul><li>'.implode('</li><li>', $msg).'</li></ul></li>';
605 605
 		}
606
-		$list = '<ul>' . join("\n", $list) . '</ul>';
606
+		$list = '<ul>'.join("\n", $list).'</ul>';
607 607
 	}
608 608
 	if ($raz) {
609 609
 		effacer_meta('plugin_erreur_activation');
@@ -717,13 +717,13 @@  discard block
 block discarded – undo
717 717
 			if ($minimum_inclus and spip_version_compare($version, $minimum, '<')) {
718 718
 				return _T("plugin_${balise}_${type}", [
719 719
 					'plugin' => $nom,
720
-					'version' => ' &ge; ' . $minimum
720
+					'version' => ' &ge; '.$minimum
721 721
 				]);
722 722
 			}
723 723
 			if (!$minimum_inclus and spip_version_compare($version, $minimum, '<=')) {
724 724
 				return _T("plugin_${balise}_${type}", [
725 725
 					'plugin' => $nom,
726
-					'version' => ' &gt; ' . $minimum
726
+					'version' => ' &gt; '.$minimum
727 727
 				]);
728 728
 			}
729 729
 		}
@@ -732,13 +732,13 @@  discard block
 block discarded – undo
732 732
 			if ($maximum_inclus and spip_version_compare($version, $maximum, '>')) {
733 733
 				return _T("plugin_${balise}_${type}", [
734 734
 					'plugin' => $nom,
735
-					'version' => ' &le; ' . $maximum
735
+					'version' => ' &le; '.$maximum
736 736
 				]);
737 737
 			}
738 738
 			if (!$maximum_inclus and spip_version_compare($version, $maximum, '>=')) {
739 739
 				return _T("plugin_${balise}_plugin", [
740 740
 					'plugin' => $nom,
741
-					'version' => ' &lt; ' . $maximum
741
+					'version' => ' &lt; '.$maximum
742 742
 				]);
743 743
 			}
744 744
 		}
@@ -757,7 +757,7 @@  discard block
 block discarded – undo
757 757
 		include_spip('inc/charger_plugin');
758 758
 		$url = '<br />'	. bouton_telechargement_plugin($url, 'lib');
759 759
 	}*/
760
-	return _T('plugin_necessite_lib', ['lib' => $lib]) . " <a href='$url'>$url</a>";
760
+	return _T('plugin_necessite_lib', ['lib' => $lib])." <a href='$url'>$url</a>";
761 761
 }
762 762
 
763 763
 
@@ -857,7 +857,7 @@  discard block
 block discarded – undo
857 857
 	foreach ($plugin_valides as $p => $resume) {
858 858
 		// Les headers ne doivent pas indiquer les versions des extensions PHP, ni la version PHP
859 859
 		if (0 !== strpos($p, 'PHP:') and $p !== 'PHP') {
860
-			$header[] = $p . ($resume['version'] ? '(' . $resume['version'] . ')' : '');
860
+			$header[] = $p.($resume['version'] ? '('.$resume['version'].')' : '');
861 861
 		}
862 862
 		if ($resume['dir']) {
863 863
 			foreach ($infos[$resume['dir_type']][$resume['dir']]['lib'] as $l) {
@@ -882,11 +882,11 @@  discard block
 block discarded – undo
882 882
 	$header = strtolower(implode(',', $header));
883 883
 	if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) {
884 884
 		ecrire_fichier(
885
-			_DIR_VAR . 'config.txt',
886
-			(defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : 'Composed-By: SPIP') . ' ' . $GLOBALS['spip_version_affichee'] . ' @ www.spip.net + ' . $header
885
+			_DIR_VAR.'config.txt',
886
+			(defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : 'Composed-By: SPIP').' '.$GLOBALS['spip_version_affichee'].' @ www.spip.net + '.$header
887 887
 		);
888 888
 	} else {
889
-		@unlink(_DIR_VAR . 'config.txt');
889
+		@unlink(_DIR_VAR.'config.txt');
890 890
 	}
891 891
 	// generer charger_plugins_chemin.php
892 892
 	plugins_precompile_chemin($plugin_valides, $ordre);
@@ -940,7 +940,7 @@  discard block
 block discarded – undo
940 940
 			// definir le plugin, donc le path avant l'include du fichier options
941 941
 			// permet de faire des include_spip pour attraper un inc_ du plugin
942 942
 
943
-			$dir = $dir_type . ".'" . $plug . "/'";
943
+			$dir = $dir_type.".'".$plug."/'";
944 944
 
945 945
 			$prefix = strtoupper(preg_replace(',\W,', '_', $info['prefix']));
946 946
 			if (
@@ -951,7 +951,7 @@  discard block
 block discarded – undo
951 951
 				if (!$info['chemin']) {
952 952
 					$chemins['public'][] = "_DIR_PLUGIN_$prefix";
953 953
 					$chemins['prive'][] = "_DIR_PLUGIN_$prefix";
954
-					if (is_dir(constant($dir_type) . $plug . '/squelettes/')) {
954
+					if (is_dir(constant($dir_type).$plug.'/squelettes/')) {
955 955
 						$chemins['public'][] = "_DIR_PLUGIN_{$prefix}.'squelettes/'";
956 956
 					}
957 957
 				}
@@ -972,13 +972,13 @@  discard block
 block discarded – undo
972 972
 								$dir = '';
973 973
 							}
974 974
 							if (strlen($dir)) {
975
-								$dir = rtrim($dir, '/') . '/';
975
+								$dir = rtrim($dir, '/').'/';
976 976
 							}
977 977
 							if (!isset($chemin['type']) or $chemin['type'] == 'public') {
978
-								$chemins['public'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : '');
978
+								$chemins['public'][] = "_DIR_PLUGIN_$prefix".(strlen($dir) ? ".'$dir'" : '');
979 979
 							}
980 980
 							if (!isset($chemin['type']) or $chemin['type'] == 'prive') {
981
-								$chemins['prive'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : '');
981
+								$chemins['prive'][] = "_DIR_PLUGIN_$prefix".(strlen($dir) ? ".'$dir'" : '');
982 982
 							}
983 983
 						}
984 984
 					}
@@ -987,11 +987,11 @@  discard block
 block discarded – undo
987 987
 		}
988 988
 	}
989 989
 	if (count($chemins['public']) or count($chemins['prive'])) {
990
-		$contenu .= 'if (_DIR_RESTREINT) _chemin([' . implode(
990
+		$contenu .= 'if (_DIR_RESTREINT) _chemin(['.implode(
991 991
 			',',
992 992
 			array_reverse($chemins['public'])
993
-		) . "]);\n"
994
-			. 'else _chemin([' . implode(',', array_reverse($chemins['prive'])) . "]);\n";
993
+		)."]);\n"
994
+			. 'else _chemin(['.implode(',', array_reverse($chemins['prive']))."]);\n";
995 995
 	}
996 996
 
997 997
 	ecrire_fichier_php(_CACHE_PLUGINS_PATH, $contenu);
@@ -1040,7 +1040,7 @@  discard block
 block discarded – undo
1040 1040
 					and strpos($dir, ':') === false // exclure le cas des procure:
1041 1041
 					and file_exists("$dir$plug/paquet.xml") // uniquement pour les paquet.xml
1042 1042
 				) {
1043
-					if (is_readable("$dir$plug/" . ($file = $info['prefix'] . '_' . $charge . '.php'))) {
1043
+					if (is_readable("$dir$plug/".($file = $info['prefix'].'_'.$charge.'.php'))) {
1044 1044
 						$info[$charge] = [$file];
1045 1045
 					}
1046 1046
 				}
@@ -1057,7 +1057,7 @@  discard block
 block discarded – undo
1057 1057
 						) {
1058 1058
 							unset($info[$charge][$k]);
1059 1059
 						} else {
1060
-							$_file = $root_dir_type . ".'$plug/$file'";
1060
+							$_file = $root_dir_type.".'$plug/$file'";
1061 1061
 							$contenu[$charge] .= "include_once_check($_file);\n";
1062 1062
 						}
1063 1063
 					}
@@ -1067,7 +1067,7 @@  discard block
 block discarded – undo
1067 1067
 		}
1068 1068
 	}
1069 1069
 
1070
-	$contenu['options'] = "define('_PLUGINS_HASH','" . md5($sign) . "');\n" . $contenu['options'];
1070
+	$contenu['options'] = "define('_PLUGINS_HASH','".md5($sign)."');\n".$contenu['options'];
1071 1071
 	$contenu['fonctions'] .= plugin_ongletbouton('boutons_plugins', $boutons)
1072 1072
 		. plugin_ongletbouton('onglets_plugins', $onglets);
1073 1073
 
@@ -1102,12 +1102,12 @@  discard block
 block discarded – undo
1102 1102
 		define("_UPDATED_$nom", $val);
1103 1103
 		define("_UPDATED_md5_$nom", $md5);
1104 1104
 	}
1105
-	$val = "unserialize('" . str_replace("'", "\'", $val) . "')";
1105
+	$val = "unserialize('".str_replace("'", "\'", $val)."')";
1106 1106
 
1107 1107
 	return
1108 1108
 		"if (!function_exists('$nom')) {\n"
1109 1109
 		. "function $nom(){return defined('_UPDATED_$nom')?unserialize(_UPDATED_$nom):$val;}\n"
1110
-		. "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'" . $md5 . "';}\n"
1110
+		. "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'".$md5."';}\n"
1111 1111
 		. "}\n";
1112 1112
 }
1113 1113
 
@@ -1130,7 +1130,7 @@  discard block
 block discarded – undo
1130 1130
 	if (@is_readable(_CACHE_PLUGINS_OPT)) {
1131 1131
 		include_once(_CACHE_PLUGINS_OPT);
1132 1132
 	} else {
1133
-		spip_log('pipelines desactives: impossible de produire ' . _CACHE_PLUGINS_OPT);
1133
+		spip_log('pipelines desactives: impossible de produire '._CACHE_PLUGINS_OPT);
1134 1134
 	}
1135 1135
 }
1136 1136
 
@@ -1167,7 +1167,7 @@  discard block
 block discarded – undo
1167 1167
 			$dir_type = $plugin_valides[$p]['dir_type'];
1168 1168
 			$root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type);
1169 1169
 			$plug = $plugin_valides[$p]['dir'];
1170
-			$prefix = (($info['prefix'] == 'spip') ? '' : $info['prefix'] . '_');
1170
+			$prefix = (($info['prefix'] == 'spip') ? '' : $info['prefix'].'_');
1171 1171
 			if (isset($info['pipeline']) and is_array($info['pipeline'])) {
1172 1172
 				foreach ($info['pipeline'] as $pipe) {
1173 1173
 					$nom = $pipe['nom'];
@@ -1201,7 +1201,7 @@  discard block
 block discarded – undo
1201 1201
 						}
1202 1202
 						if (isset($pipe['inclure'])) {
1203 1203
 							$GLOBALS['spip_matrice']["$prefix$action"] =
1204
-								"$root_dir_type:$plug/" . $pipe['inclure'];
1204
+								"$root_dir_type:$plug/".$pipe['inclure'];
1205 1205
 						}
1206 1206
 					}
1207 1207
 				}
@@ -1211,7 +1211,7 @@  discard block
 block discarded – undo
1211 1211
 					$prepend_code['taches_generales_cron'] = '';
1212 1212
 				}
1213 1213
 				foreach ($info['genie'] as $genie) {
1214
-					$nom = $prefix . $genie['nom'];
1214
+					$nom = $prefix.$genie['nom'];
1215 1215
 					$periode = max(60, intval($genie['periode']));
1216 1216
 					if (charger_fonction($nom, 'genie', true)) {
1217 1217
 						$prepend_code['taches_generales_cron'] .= "\$val['$nom'] = $periode;\n";
@@ -1229,13 +1229,13 @@  discard block
 block discarded – undo
1229 1229
 				}
1230 1230
 				foreach ($info['style'] as $style) {
1231 1231
 					if (isset($style['path']) and $style['path']) {
1232
-						$code = "if (\$f=timestamp(direction_css(find_in_path('" . addslashes($style['path']) . "')))) ";
1232
+						$code = "if (\$f=timestamp(direction_css(find_in_path('".addslashes($style['path'])."')))) ";
1233 1233
 					} else {
1234
-						$code = "if (\$f='" . addslashes($style['url']) . "') ";
1234
+						$code = "if (\$f='".addslashes($style['url'])."') ";
1235 1235
 					}
1236 1236
 					$code .= "\$val .= '<link rel=\"stylesheet\" href=\"'.\$f.'\" type=\"text/css\"";
1237 1237
 					if (isset($style['media']) and strlen($style['media'])) {
1238
-						$code .= ' media="' . addslashes($style['media']) . '"';
1238
+						$code .= ' media="'.addslashes($style['media']).'"';
1239 1239
 					}
1240 1240
 					$code .= "/>';\n";
1241 1241
 					if ($style['type'] != 'prive') {
@@ -1255,9 +1255,9 @@  discard block
 block discarded – undo
1255 1255
 			if (isset($info['script']) and is_countable($info['script']) ? count($info['script']) : 0) {
1256 1256
 				foreach ($info['script'] as $script) {
1257 1257
 					if (isset($script['path']) and $script['path']) {
1258
-						$code = "if (\$f=timestamp(find_in_path('" . addslashes($script['path']) . "'))) ";
1258
+						$code = "if (\$f=timestamp(find_in_path('".addslashes($script['path'])."'))) ";
1259 1259
 					} else {
1260
-						$code = "if (\$f='" . addslashes($script['url']) . "') ";
1260
+						$code = "if (\$f='".addslashes($script['url'])."') ";
1261 1261
 					}
1262 1262
 					$code .= "\$val .= '<script src=\"'.\$f.'\" type=\"text/javascript\"></script>';\n";
1263 1263
 					if ($script['type'] != 'prive') {
@@ -1320,10 +1320,10 @@  discard block
 block discarded – undo
1320 1320
 		unset($GLOBALS['spip_pipeline']['all']);
1321 1321
 		$all_pipes = trim(array_shift($a));
1322 1322
 		if ($all_pipes) {
1323
-			$all_pipes = '|' . ltrim($all_pipes, '|');
1323
+			$all_pipes = '|'.ltrim($all_pipes, '|');
1324 1324
 		}
1325 1325
 		if (count($a)) {
1326
-			$all_pipes_end = '||' . array_shift($a);
1326
+			$all_pipes_end = '||'.array_shift($a);
1327 1327
 		}
1328 1328
 	}
1329 1329
 	$content = '';
@@ -1340,7 +1340,7 @@  discard block
 block discarded – undo
1340 1340
 		// Eclater le pipeline en filtres et appliquer chaque filtre
1341 1341
 		foreach ($pipe as $fonc) {
1342 1342
 			$fonc = trim($fonc);
1343
-			$s_call .= '$val = minipipe(\'' . $fonc . '\', $val);' . "\n";
1343
+			$s_call .= '$val = minipipe(\''.$fonc.'\', $val);'."\n";
1344 1344
 			if (isset($GLOBALS['spip_matrice'][$fonc])) {
1345 1345
 				$file = $GLOBALS['spip_matrice'][$fonc];
1346 1346
 				$file = "'$file'";
@@ -1351,7 +1351,7 @@  discard block
 block discarded – undo
1351 1351
 					if (defined($root_dir)) {
1352 1352
 						$dir = $root_dir;
1353 1353
 					}
1354
-					$file = str_replace($regs[0], "'." . $dir . ".'", $file);
1354
+					$file = str_replace($regs[0], "'.".$dir.".'", $file);
1355 1355
 					$file = str_replace("''.", '', $file);
1356 1356
 					$file = str_replace(constant($dir), '', $file);
1357 1357
 				}
@@ -1364,7 +1364,7 @@  discard block
 block discarded – undo
1364 1364
 		$content .= "// Pipeline $action \n"
1365 1365
 			. "function execute_pipeline_$action(&\$val){\n"
1366 1366
 			. $s_inc
1367
-			. ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action]) . "\n" : '')
1367
+			. ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action])."\n" : '')
1368 1368
 			. $s_call
1369 1369
 			. "return \$val;\n}\n";
1370 1370
 	}
@@ -1420,9 +1420,9 @@  discard block
 block discarded – undo
1420 1420
 					$result = ($ok ? ((isset($infos['upgrade']) && $infos['upgrade']) ? _T('plugin_info_upgrade_ok') : _T('plugin_info_install_ok')) : _T('avis_operation_echec'));
1421 1421
 					if (_IS_CLI) {
1422 1422
 						include_spip('inc/filtres');
1423
-						$trace = ltrim(textebrut($trace) . "\n" . $result);
1424
-						$trace = '    ' . str_replace("\n", "\n    ", $trace);
1425
-						echo "\n" . ($ok ? 'OK  ' : '/!\ ') . textebrut($titre) . "\n",
1423
+						$trace = ltrim(textebrut($trace)."\n".$result);
1424
+						$trace = '    '.str_replace("\n", "\n    ", $trace);
1425
+						echo "\n".($ok ? 'OK  ' : '/!\ ').textebrut($titre)."\n",
1426 1426
 						  $trace,
1427 1427
 						  "\n";
1428 1428
 					}
@@ -1457,15 +1457,15 @@  discard block
 block discarded – undo
1457 1457
 		$GLOBALS['fichier_php_compile_recent'] = 0;
1458 1458
 	}
1459 1459
 
1460
-	$contenu = '<' . '?php' . "\n" . $comment . "\nif (defined('_ECRIRE_INC_VERSION')) {\n" . $contenu . "}\n?" . '>';
1460
+	$contenu = '<'.'?php'."\n".$comment."\nif (defined('_ECRIRE_INC_VERSION')) {\n".$contenu."}\n?".'>';
1461 1461
 	// si un fichier existe deja on verifie que son contenu change avant de l'ecraser
1462 1462
 	// si pas de modif on ne touche pas au fichier initial
1463 1463
 	if (file_exists($nom)) {
1464 1464
 		if (substr($nom, -4) == '.php') {
1465
-			$fichier_tmp = substr($nom, 0, -4) . '.tmp.php';
1465
+			$fichier_tmp = substr($nom, 0, -4).'.tmp.php';
1466 1466
 		}
1467 1467
 		else {
1468
-			$fichier_tmp = $nom . '.tmp';
1468
+			$fichier_tmp = $nom.'.tmp';
1469 1469
 		}
1470 1470
 		file_put_contents($fichier_tmp, $contenu);
1471 1471
 		if (md5_file($nom) == md5_file($fichier_tmp)) {
Please login to merge, or discard this patch.
Indentation   +984 added lines, -984 removed lines patch added patch discarded remove patch
@@ -17,12 +17,12 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 /** l'adresse du repertoire de telechargement et de decompactage des plugins */
24 24
 if (!defined('_DIR_PLUGINS_AUTO')) {
25
-	define('_DIR_PLUGINS_AUTO', _DIR_PLUGINS . 'auto/');
25
+    define('_DIR_PLUGINS_AUTO', _DIR_PLUGINS . 'auto/');
26 26
 }
27 27
 
28 28
 #include_spip('inc/texte'); // ????? Appelle public/parametrer trop tot avant la reconstruction du chemin des plugins.
@@ -47,27 +47,27 @@  discard block
 block discarded – undo
47 47
  * @return array
48 48
 **/
49 49
 function liste_plugin_files($dir_plugins = null) {
50
-	static $plugin_files = [];
51
-	if (is_null($dir_plugins)) {
52
-		$dir_plugins = _DIR_PLUGINS;
53
-	}
54
-	if (
55
-		!isset($plugin_files[$dir_plugins])
56
-		or (is_countable($plugin_files[$dir_plugins]) ? count($plugin_files[$dir_plugins]) : 0) == 0
57
-	) {
58
-		$plugin_files[$dir_plugins] = [];
59
-		foreach (fast_find_plugin_dirs($dir_plugins) as $plugin) {
60
-			$plugin_files[$dir_plugins][] = substr($plugin, strlen($dir_plugins));
61
-		}
62
-
63
-		sort($plugin_files[$dir_plugins]);
64
-		// et on lit le XML de tous les plugins pour le mettre en cache
65
-		// et en profiter pour nettoyer ceux qui n'existent plus du cache
66
-		$get_infos = charger_fonction('get_infos', 'plugins');
67
-		$get_infos($plugin_files[$dir_plugins], false, $dir_plugins, true);
68
-	}
69
-
70
-	return $plugin_files[$dir_plugins];
50
+    static $plugin_files = [];
51
+    if (is_null($dir_plugins)) {
52
+        $dir_plugins = _DIR_PLUGINS;
53
+    }
54
+    if (
55
+        !isset($plugin_files[$dir_plugins])
56
+        or (is_countable($plugin_files[$dir_plugins]) ? count($plugin_files[$dir_plugins]) : 0) == 0
57
+    ) {
58
+        $plugin_files[$dir_plugins] = [];
59
+        foreach (fast_find_plugin_dirs($dir_plugins) as $plugin) {
60
+            $plugin_files[$dir_plugins][] = substr($plugin, strlen($dir_plugins));
61
+        }
62
+
63
+        sort($plugin_files[$dir_plugins]);
64
+        // et on lit le XML de tous les plugins pour le mettre en cache
65
+        // et en profiter pour nettoyer ceux qui n'existent plus du cache
66
+        $get_infos = charger_fonction('get_infos', 'plugins');
67
+        $get_infos($plugin_files[$dir_plugins], false, $dir_plugins, true);
68
+    }
69
+
70
+    return $plugin_files[$dir_plugins];
71 71
 }
72 72
 
73 73
 /**
@@ -83,45 +83,45 @@  discard block
 block discarded – undo
83 83
  *     Liste complète des répeertoires
84 84
 **/
85 85
 function fast_find_plugin_dirs($dir, $max_prof = 100) {
86
-	$fichiers = [];
87
-	// revenir au repertoire racine si on a recu dossier/truc
88
-	// pour regarder dossier/truc/ ne pas oublier le / final
89
-	$dir = preg_replace(',/[^/]*$,', '', $dir);
90
-	if ($dir == '') {
91
-		$dir = '.';
92
-	}
93
-
94
-	if (!is_dir($dir)) {
95
-		return $fichiers;
96
-	}
97
-	if (is_plugin_dir($dir, '')) {
98
-		$fichiers[] = $dir;
99
-
100
-		return $fichiers;
101
-	}
102
-	if ($max_prof <= 0) {
103
-		return $fichiers;
104
-	}
105
-
106
-	$subdirs = [];
107
-	if (@is_dir($dir) and is_readable($dir) and $d = opendir($dir)) {
108
-		while (($f = readdir($d)) !== false) {
109
-			if (
110
-				$f[0] != '.' # ignorer . .. .svn etc
111
-				and $f != 'CVS'
112
-				and is_dir($f = "$dir/$f")
113
-			) {
114
-				$subdirs[] = $f;
115
-			}
116
-		}
117
-		closedir($d);
118
-	}
119
-
120
-	foreach ($subdirs as $d) {
121
-		$fichiers = array_merge($fichiers, fast_find_plugin_dirs("$d/", $max_prof - 1));
122
-	}
123
-
124
-	return $fichiers;
86
+    $fichiers = [];
87
+    // revenir au repertoire racine si on a recu dossier/truc
88
+    // pour regarder dossier/truc/ ne pas oublier le / final
89
+    $dir = preg_replace(',/[^/]*$,', '', $dir);
90
+    if ($dir == '') {
91
+        $dir = '.';
92
+    }
93
+
94
+    if (!is_dir($dir)) {
95
+        return $fichiers;
96
+    }
97
+    if (is_plugin_dir($dir, '')) {
98
+        $fichiers[] = $dir;
99
+
100
+        return $fichiers;
101
+    }
102
+    if ($max_prof <= 0) {
103
+        return $fichiers;
104
+    }
105
+
106
+    $subdirs = [];
107
+    if (@is_dir($dir) and is_readable($dir) and $d = opendir($dir)) {
108
+        while (($f = readdir($d)) !== false) {
109
+            if (
110
+                $f[0] != '.' # ignorer . .. .svn etc
111
+                and $f != 'CVS'
112
+                and is_dir($f = "$dir/$f")
113
+            ) {
114
+                $subdirs[] = $f;
115
+            }
116
+        }
117
+        closedir($d);
118
+    }
119
+
120
+    foreach ($subdirs as $d) {
121
+        $fichiers = array_merge($fichiers, fast_find_plugin_dirs("$d/", $max_prof - 1));
122
+    }
123
+
124
+    return $fichiers;
125 125
 }
126 126
 
127 127
 /**
@@ -142,27 +142,27 @@  discard block
 block discarded – undo
142 142
 **/
143 143
 function is_plugin_dir($dir, $dir_plugins = null) {
144 144
 
145
-	if (is_array($dir)) {
146
-		foreach ($dir as $k => $d) {
147
-			if (!is_plugin_dir($d, $dir_plugins)) {
148
-				unset($dir[$k]);
149
-			}
150
-		}
151
-
152
-		return $dir;
153
-	}
154
-	if (is_null($dir_plugins)) {
155
-		$dir_plugins = _DIR_PLUGINS;
156
-	}
157
-	$search = ["$dir_plugins$dir/paquet.xml"];
158
-
159
-	foreach ($search as $s) {
160
-		if (file_exists($s)) {
161
-			return $dir;
162
-		}
163
-	}
164
-
165
-	return '';
145
+    if (is_array($dir)) {
146
+        foreach ($dir as $k => $d) {
147
+            if (!is_plugin_dir($d, $dir_plugins)) {
148
+                unset($dir[$k]);
149
+            }
150
+        }
151
+
152
+        return $dir;
153
+    }
154
+    if (is_null($dir_plugins)) {
155
+        $dir_plugins = _DIR_PLUGINS;
156
+    }
157
+    $search = ["$dir_plugins$dir/paquet.xml"];
158
+
159
+    foreach ($search as $s) {
160
+        if (file_exists($s)) {
161
+            return $dir;
162
+        }
163
+    }
164
+
165
+    return '';
166 166
 }
167 167
 
168 168
 /** Regexp d'extraction des informations d'un intervalle de compatibilité */
@@ -189,51 +189,51 @@  discard block
 block discarded – undo
189 189
  **/
190 190
 function plugin_version_compatible($intervalle, $version, $avec_quoi = '') {
191 191
 
192
-	if (!strlen($intervalle)) {
193
-		return true;
194
-	}
195
-	if (!preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) {
196
-		return false;
197
-	}
198
-	// Extraction des bornes et traitement de * pour la borne sup :
199
-	// -- on autorise uniquement les ecritures 3.0.*, 3.*
200
-	$minimum = $regs[1];
201
-	$maximum = $regs[2];
202
-
203
-	//  si une version SPIP de compatibilité a été définie (dans
204
-	//  mes_options.php, sous la forme : define('_DEV_VERSION_SPIP_COMPAT', '3.1.0');
205
-	//  on l'utilise (phase de dev, de test...) mais *que* en cas de comparaison
206
-	//  avec la version de SPIP (ne nuit donc pas aux tests de necessite
207
-	//  entre plugins)
208
-	if (defined('_DEV_VERSION_SPIP_COMPAT') and $avec_quoi == 'spip' and $version !== _DEV_VERSION_SPIP_COMPAT) {
209
-		if (plugin_version_compatible($intervalle, _DEV_VERSION_SPIP_COMPAT, $avec_quoi)) {
210
-			return true;
211
-		}
212
-		// si pas de compatibilite avec _DEV_VERSION_SPIP_COMPAT, on essaye quand meme avec la vrai version
213
-		// cas du plugin qui n'est compatible qu'avec cette nouvelle version
214
-	}
215
-
216
-	$minimum_inc = $intervalle[0] == '[';
217
-	$maximum_inc = substr($intervalle, -1) == ']';
218
-
219
-	if (strlen($minimum)) {
220
-		if ($minimum_inc and spip_version_compare($version, $minimum, '<')) {
221
-			return false;
222
-		}
223
-		if (!$minimum_inc and spip_version_compare($version, $minimum, '<=')) {
224
-			return false;
225
-		}
226
-	}
227
-	if (strlen($maximum)) {
228
-		if ($maximum_inc and spip_version_compare($version, $maximum, '>')) {
229
-			return false;
230
-		}
231
-		if (!$maximum_inc and spip_version_compare($version, $maximum, '>=')) {
232
-			return false;
233
-		}
234
-	}
235
-
236
-	return true;
192
+    if (!strlen($intervalle)) {
193
+        return true;
194
+    }
195
+    if (!preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) {
196
+        return false;
197
+    }
198
+    // Extraction des bornes et traitement de * pour la borne sup :
199
+    // -- on autorise uniquement les ecritures 3.0.*, 3.*
200
+    $minimum = $regs[1];
201
+    $maximum = $regs[2];
202
+
203
+    //  si une version SPIP de compatibilité a été définie (dans
204
+    //  mes_options.php, sous la forme : define('_DEV_VERSION_SPIP_COMPAT', '3.1.0');
205
+    //  on l'utilise (phase de dev, de test...) mais *que* en cas de comparaison
206
+    //  avec la version de SPIP (ne nuit donc pas aux tests de necessite
207
+    //  entre plugins)
208
+    if (defined('_DEV_VERSION_SPIP_COMPAT') and $avec_quoi == 'spip' and $version !== _DEV_VERSION_SPIP_COMPAT) {
209
+        if (plugin_version_compatible($intervalle, _DEV_VERSION_SPIP_COMPAT, $avec_quoi)) {
210
+            return true;
211
+        }
212
+        // si pas de compatibilite avec _DEV_VERSION_SPIP_COMPAT, on essaye quand meme avec la vrai version
213
+        // cas du plugin qui n'est compatible qu'avec cette nouvelle version
214
+    }
215
+
216
+    $minimum_inc = $intervalle[0] == '[';
217
+    $maximum_inc = substr($intervalle, -1) == ']';
218
+
219
+    if (strlen($minimum)) {
220
+        if ($minimum_inc and spip_version_compare($version, $minimum, '<')) {
221
+            return false;
222
+        }
223
+        if (!$minimum_inc and spip_version_compare($version, $minimum, '<=')) {
224
+            return false;
225
+        }
226
+    }
227
+    if (strlen($maximum)) {
228
+        if ($maximum_inc and spip_version_compare($version, $maximum, '>')) {
229
+            return false;
230
+        }
231
+        if (!$maximum_inc and spip_version_compare($version, $maximum, '>=')) {
232
+            return false;
233
+        }
234
+    }
235
+
236
+    return true;
237 237
 }
238 238
 
239 239
 /**
@@ -250,62 +250,62 @@  discard block
 block discarded – undo
250 250
  * @return array
251 251
  */
252 252
 function liste_plugin_valides($liste_plug, $force = false) {
253
-	$liste_ext = liste_plugin_files(_DIR_PLUGINS_DIST);
254
-	$get_infos = charger_fonction('get_infos', 'plugins');
255
-	$infos = [
256
-		// lister les extensions qui sont automatiquement actives
257
-		'_DIR_PLUGINS_DIST' => $get_infos($liste_ext, $force, _DIR_PLUGINS_DIST),
258
-		'_DIR_PLUGINS' => $get_infos($liste_plug, $force, _DIR_PLUGINS)
259
-	];
260
-
261
-	// creer une premiere liste non ordonnee mais qui ne retient
262
-	// que les plugins valides, et dans leur derniere version en cas de doublon
263
-	$infos['_DIR_RESTREINT'][''] = $get_infos('./', $force, _DIR_RESTREINT);
264
-	$infos['_DIR_RESTREINT']['SPIP']['version'] = $GLOBALS['spip_version_branche'];
265
-	$infos['_DIR_RESTREINT']['SPIP']['chemin'] = [];
266
-	$liste_non_classee = [
267
-		'SPIP' => [
268
-			'nom' => 'SPIP',
269
-			'etat' => 'stable',
270
-			'version' => $GLOBALS['spip_version_branche'],
271
-			'dir_type' => '_DIR_RESTREINT',
272
-			'dir' => '',
273
-		]
274
-	];
275
-
276
-	$invalides = [];
277
-	foreach ($liste_ext as $plug) {
278
-		if (isset($infos['_DIR_PLUGINS_DIST'][$plug])) {
279
-			plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_DIST');
280
-		}
281
-	}
282
-	foreach ($liste_plug as $plug) {
283
-		if (isset($infos['_DIR_PLUGINS'][$plug])) {
284
-			$r = plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS');
285
-			if (is_array($r)) {
286
-				$invalides = array_merge($invalides, $r);
287
-			}
288
-		}
289
-	}
290
-
291
-	if (defined('_DIR_PLUGINS_SUPPL') and _DIR_PLUGINS_SUPPL) {
292
-		$infos['_DIR_PLUGINS_SUPPL'] = $get_infos($liste_plug, false, _DIR_PLUGINS_SUPPL);
293
-		foreach ($liste_plug as $plug) {
294
-			if (isset($infos['_DIR_PLUGINS_SUPPL'][$plug])) {
295
-				$r = plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_SUPPL');
296
-				if (is_array($r)) {
297
-					$invalides = array_merge($invalides, $r);
298
-				}
299
-			}
300
-		}
301
-	}
302
-
303
-	plugin_fixer_procure($liste_non_classee, $infos);
304
-
305
-	// les plugins qui sont dans $liste_non_classee ne sont pas invalides (on a trouve un autre version valide)
306
-	$invalides = array_diff_key($invalides, $liste_non_classee);
307
-
308
-	return [$infos, $liste_non_classee, $invalides];
253
+    $liste_ext = liste_plugin_files(_DIR_PLUGINS_DIST);
254
+    $get_infos = charger_fonction('get_infos', 'plugins');
255
+    $infos = [
256
+        // lister les extensions qui sont automatiquement actives
257
+        '_DIR_PLUGINS_DIST' => $get_infos($liste_ext, $force, _DIR_PLUGINS_DIST),
258
+        '_DIR_PLUGINS' => $get_infos($liste_plug, $force, _DIR_PLUGINS)
259
+    ];
260
+
261
+    // creer une premiere liste non ordonnee mais qui ne retient
262
+    // que les plugins valides, et dans leur derniere version en cas de doublon
263
+    $infos['_DIR_RESTREINT'][''] = $get_infos('./', $force, _DIR_RESTREINT);
264
+    $infos['_DIR_RESTREINT']['SPIP']['version'] = $GLOBALS['spip_version_branche'];
265
+    $infos['_DIR_RESTREINT']['SPIP']['chemin'] = [];
266
+    $liste_non_classee = [
267
+        'SPIP' => [
268
+            'nom' => 'SPIP',
269
+            'etat' => 'stable',
270
+            'version' => $GLOBALS['spip_version_branche'],
271
+            'dir_type' => '_DIR_RESTREINT',
272
+            'dir' => '',
273
+        ]
274
+    ];
275
+
276
+    $invalides = [];
277
+    foreach ($liste_ext as $plug) {
278
+        if (isset($infos['_DIR_PLUGINS_DIST'][$plug])) {
279
+            plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_DIST');
280
+        }
281
+    }
282
+    foreach ($liste_plug as $plug) {
283
+        if (isset($infos['_DIR_PLUGINS'][$plug])) {
284
+            $r = plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS');
285
+            if (is_array($r)) {
286
+                $invalides = array_merge($invalides, $r);
287
+            }
288
+        }
289
+    }
290
+
291
+    if (defined('_DIR_PLUGINS_SUPPL') and _DIR_PLUGINS_SUPPL) {
292
+        $infos['_DIR_PLUGINS_SUPPL'] = $get_infos($liste_plug, false, _DIR_PLUGINS_SUPPL);
293
+        foreach ($liste_plug as $plug) {
294
+            if (isset($infos['_DIR_PLUGINS_SUPPL'][$plug])) {
295
+                $r = plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_SUPPL');
296
+                if (is_array($r)) {
297
+                    $invalides = array_merge($invalides, $r);
298
+                }
299
+            }
300
+        }
301
+    }
302
+
303
+    plugin_fixer_procure($liste_non_classee, $infos);
304
+
305
+    // les plugins qui sont dans $liste_non_classee ne sont pas invalides (on a trouve un autre version valide)
306
+    $invalides = array_diff_key($invalides, $liste_non_classee);
307
+
308
+    return [$infos, $liste_non_classee, $invalides];
309 309
 }
310 310
 
311 311
 /**
@@ -325,38 +325,38 @@  discard block
 block discarded – undo
325 325
  *   array description short si on ne le retient pas (pour memorisation dans une table des erreurs)
326 326
  */
327 327
 function plugin_valide_resume(&$liste, $plug, $infos, $dir_type) {
328
-	$i = $infos[$dir_type][$plug];
329
-	// minimum syndical pour afficher si le xml avait des erreurs éventuelles
330
-	$short_desc = [
331
-		'dir' => $plug,
332
-		'dir_type' => $dir_type
333
-	];
334
-	if (empty($i['prefix'])) {
335
-		// erreur xml ? mais sans connaissance du prefix, on retourne le chemin…
336
-		$short_desc['erreur'] = $i['erreur'] ?? ['?'];
337
-		return [$plug => $short_desc];
338
-	}
339
-
340
-	$p = strtoupper($i['prefix']);
341
-	$short_desc['nom'] = $i['nom'];
342
-	$short_desc['etat'] = $i['etat'];
343
-	$short_desc['version'] = $i['version'];
344
-
345
-	if (isset($i['erreur']) and $i['erreur']) {
346
-		$short_desc['erreur'] = $i['erreur'];
347
-		return [$p => $short_desc];
348
-	}
349
-	if (!plugin_version_compatible($i['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) {
350
-		return [$p => $short_desc];
351
-	}
352
-	if (
353
-		!isset($liste[$p])
354
-		or spip_version_compare($i['version'], $liste[$p]['version'], '>')
355
-	) {
356
-		$liste[$p] = $short_desc;
357
-	}
358
-	// ok le plugin etait deja dans la liste ou on a choisi une version plus recente
359
-	return $p;
328
+    $i = $infos[$dir_type][$plug];
329
+    // minimum syndical pour afficher si le xml avait des erreurs éventuelles
330
+    $short_desc = [
331
+        'dir' => $plug,
332
+        'dir_type' => $dir_type
333
+    ];
334
+    if (empty($i['prefix'])) {
335
+        // erreur xml ? mais sans connaissance du prefix, on retourne le chemin…
336
+        $short_desc['erreur'] = $i['erreur'] ?? ['?'];
337
+        return [$plug => $short_desc];
338
+    }
339
+
340
+    $p = strtoupper($i['prefix']);
341
+    $short_desc['nom'] = $i['nom'];
342
+    $short_desc['etat'] = $i['etat'];
343
+    $short_desc['version'] = $i['version'];
344
+
345
+    if (isset($i['erreur']) and $i['erreur']) {
346
+        $short_desc['erreur'] = $i['erreur'];
347
+        return [$p => $short_desc];
348
+    }
349
+    if (!plugin_version_compatible($i['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) {
350
+        return [$p => $short_desc];
351
+    }
352
+    if (
353
+        !isset($liste[$p])
354
+        or spip_version_compare($i['version'], $liste[$p]['version'], '>')
355
+    ) {
356
+        $liste[$p] = $short_desc;
357
+    }
358
+    // ok le plugin etait deja dans la liste ou on a choisi une version plus recente
359
+    return $p;
360 360
 }
361 361
 
362 362
 /**
@@ -372,47 +372,47 @@  discard block
 block discarded – undo
372 372
  * @param array $infos
373 373
  */
374 374
 function plugin_fixer_procure(&$liste, &$infos) {
375
-	foreach ($liste as $p => $resume) {
376
-		$i = $infos[$resume['dir_type']][$resume['dir']];
377
-		if (isset($i['procure']) and $i['procure']) {
378
-			foreach ($i['procure'] as $procure) {
379
-				$p = strtoupper($procure['nom']);
380
-				$dir = $resume['dir'];
381
-				if ($dir) {
382
-					$dir .= '/';
383
-				}
384
-				$dir .= 'procure:' . $procure['nom'];
385
-
386
-				$procure['etat'] = '?';
387
-				$procure['dir_type'] = $resume['dir_type'];
388
-				$procure['dir'] = $dir;
389
-
390
-				// si ce plugin n'est pas deja procure, ou dans une version plus ancienne
391
-				// on ajoute cette version a la liste
392
-				if (
393
-					!isset($liste[$p])
394
-					or spip_version_compare($procure['version'], $liste[$p]['version'], '>')
395
-				) {
396
-					$liste[$p] = $procure;
397
-
398
-					// on fournit une information minimale pour ne pas perturber la compilation
399
-					$infos[$resume['dir_type']][$dir] = [
400
-						'prefix' => $procure['nom'],
401
-						'nom' => $procure['nom'],
402
-						'etat' => $procure['etat'],
403
-						'version' => $procure['version'],
404
-						'chemin' => [],
405
-						'necessite' => [],
406
-						'utilise' => [],
407
-						'lib' => [],
408
-						'menu' => [],
409
-						'onglet' => [],
410
-						'procure' => [],
411
-					];
412
-				}
413
-			}
414
-		}
415
-	}
375
+    foreach ($liste as $p => $resume) {
376
+        $i = $infos[$resume['dir_type']][$resume['dir']];
377
+        if (isset($i['procure']) and $i['procure']) {
378
+            foreach ($i['procure'] as $procure) {
379
+                $p = strtoupper($procure['nom']);
380
+                $dir = $resume['dir'];
381
+                if ($dir) {
382
+                    $dir .= '/';
383
+                }
384
+                $dir .= 'procure:' . $procure['nom'];
385
+
386
+                $procure['etat'] = '?';
387
+                $procure['dir_type'] = $resume['dir_type'];
388
+                $procure['dir'] = $dir;
389
+
390
+                // si ce plugin n'est pas deja procure, ou dans une version plus ancienne
391
+                // on ajoute cette version a la liste
392
+                if (
393
+                    !isset($liste[$p])
394
+                    or spip_version_compare($procure['version'], $liste[$p]['version'], '>')
395
+                ) {
396
+                    $liste[$p] = $procure;
397
+
398
+                    // on fournit une information minimale pour ne pas perturber la compilation
399
+                    $infos[$resume['dir_type']][$dir] = [
400
+                        'prefix' => $procure['nom'],
401
+                        'nom' => $procure['nom'],
402
+                        'etat' => $procure['etat'],
403
+                        'version' => $procure['version'],
404
+                        'chemin' => [],
405
+                        'necessite' => [],
406
+                        'utilise' => [],
407
+                        'lib' => [],
408
+                        'menu' => [],
409
+                        'onglet' => [],
410
+                        'procure' => [],
411
+                    ];
412
+                }
413
+            }
414
+        }
415
+    }
416 416
 }
417 417
 
418 418
 /**
@@ -426,20 +426,20 @@  discard block
 block discarded – undo
426 426
  * @return array
427 427
  */
428 428
 function liste_chemin_plugin($liste, $dir_plugins = _DIR_PLUGINS) {
429
-	foreach ($liste as $prefix => $infos) {
430
-		if (
431
-			!$dir_plugins
432
-			or (
433
-				defined($infos['dir_type'])
434
-				and constant($infos['dir_type']) == $dir_plugins)
435
-		) {
436
-			$liste[$prefix] = $infos['dir'];
437
-		} else {
438
-			unset($liste[$prefix]);
439
-		}
440
-	}
441
-
442
-	return $liste;
429
+    foreach ($liste as $prefix => $infos) {
430
+        if (
431
+            !$dir_plugins
432
+            or (
433
+                defined($infos['dir_type'])
434
+                and constant($infos['dir_type']) == $dir_plugins)
435
+        ) {
436
+            $liste[$prefix] = $infos['dir'];
437
+        } else {
438
+            unset($liste[$prefix]);
439
+        }
440
+    }
441
+
442
+    return $liste;
443 443
 }
444 444
 
445 445
 /**
@@ -454,9 +454,9 @@  discard block
 block discarded – undo
454 454
  * @return array
455 455
  */
456 456
 function liste_chemin_plugin_actifs($dir_plugins = _DIR_PLUGINS) {
457
-	include_spip('plugins/installer');
457
+    include_spip('plugins/installer');
458 458
 
459
-	return liste_chemin_plugin(liste_plugin_actifs(), $dir_plugins);
459
+    return liste_chemin_plugin(liste_plugin_actifs(), $dir_plugins);
460 460
 }
461 461
 
462 462
 /**
@@ -487,54 +487,54 @@  discard block
 block discarded – undo
487 487
  *                qui n'ont pas satisfait leurs dépendances
488 488
 **/
489 489
 function plugin_trier($infos, $liste_non_classee) {
490
-	$toute_la_liste = $liste_non_classee;
491
-	$liste = $ordre = [];
492
-	$count = 0;
493
-
494
-	while ($c = count($liste_non_classee) and $c != $count) { // tant qu'il reste des plugins a classer, et qu'on ne stagne pas
495
-		#echo "tour::";var_dump($liste_non_classee);
496
-		$count = $c;
497
-		foreach ($liste_non_classee as $p => $resume) {
498
-			$plug = $resume['dir'];
499
-			$dir_type = $resume['dir_type'];
500
-			$info1 = $infos[$dir_type][$plug];
501
-			// si des plugins sont necessaires,
502
-			// on ne peut inserer qu'apres eux
503
-			foreach ($info1['necessite'] as $need) {
504
-				$nom = strtoupper($need['nom']);
505
-				$compat = $need['compatibilite'] ?? '';
506
-				if (!isset($liste[$nom]) or !plugin_version_compatible($compat, $liste[$nom]['version'])) {
507
-					$info1 = false;
508
-					break;
509
-				}
510
-			}
511
-			if (!$info1) {
512
-				continue;
513
-			}
514
-			// idem si des plugins sont utiles,
515
-			// sauf si ils sont de toute facon absents de la liste
516
-			foreach ($info1['utilise'] as $need) {
517
-				$nom = strtoupper($need['nom']);
518
-				$compat = $need['compatibilite'] ?? '';
519
-				if (isset($toute_la_liste[$nom])) {
520
-					if (
521
-						!isset($liste[$nom]) or
522
-						!plugin_version_compatible($compat, $liste[$nom]['version'])
523
-					) {
524
-						$info1 = false;
525
-						break;
526
-					}
527
-				}
528
-			}
529
-			if ($info1) {
530
-				$ordre[$p] = $info1;
531
-				$liste[$p] = $liste_non_classee[$p];
532
-				unset($liste_non_classee[$p]);
533
-			}
534
-		}
535
-	}
536
-
537
-	return [$liste, $ordre, $liste_non_classee];
490
+    $toute_la_liste = $liste_non_classee;
491
+    $liste = $ordre = [];
492
+    $count = 0;
493
+
494
+    while ($c = count($liste_non_classee) and $c != $count) { // tant qu'il reste des plugins a classer, et qu'on ne stagne pas
495
+        #echo "tour::";var_dump($liste_non_classee);
496
+        $count = $c;
497
+        foreach ($liste_non_classee as $p => $resume) {
498
+            $plug = $resume['dir'];
499
+            $dir_type = $resume['dir_type'];
500
+            $info1 = $infos[$dir_type][$plug];
501
+            // si des plugins sont necessaires,
502
+            // on ne peut inserer qu'apres eux
503
+            foreach ($info1['necessite'] as $need) {
504
+                $nom = strtoupper($need['nom']);
505
+                $compat = $need['compatibilite'] ?? '';
506
+                if (!isset($liste[$nom]) or !plugin_version_compatible($compat, $liste[$nom]['version'])) {
507
+                    $info1 = false;
508
+                    break;
509
+                }
510
+            }
511
+            if (!$info1) {
512
+                continue;
513
+            }
514
+            // idem si des plugins sont utiles,
515
+            // sauf si ils sont de toute facon absents de la liste
516
+            foreach ($info1['utilise'] as $need) {
517
+                $nom = strtoupper($need['nom']);
518
+                $compat = $need['compatibilite'] ?? '';
519
+                if (isset($toute_la_liste[$nom])) {
520
+                    if (
521
+                        !isset($liste[$nom]) or
522
+                        !plugin_version_compatible($compat, $liste[$nom]['version'])
523
+                    ) {
524
+                        $info1 = false;
525
+                        break;
526
+                    }
527
+                }
528
+            }
529
+            if ($info1) {
530
+                $ordre[$p] = $info1;
531
+                $liste[$p] = $liste_non_classee[$p];
532
+                unset($liste_non_classee[$p]);
533
+            }
534
+        }
535
+    }
536
+
537
+    return [$liste, $ordre, $liste_non_classee];
538 538
 }
539 539
 
540 540
 /**
@@ -551,40 +551,40 @@  discard block
 block discarded – undo
551 551
  *     Répertoire (plugins, plugins-dist, ...) => Couples (prefixes => infos completes) des plugins qu'ils contiennent
552 552
 **/
553 553
 function plugins_erreurs($liste_non_classee, $liste, $infos, $msg = []) {
554
-	static $erreurs = [];
555
-
556
-	if (!is_array($liste)) {
557
-		$liste = [];
558
-	}
559
-
560
-	// les plugins en erreur ne sont pas actifs ; ils ne doivent pas être dans la liste
561
-	$liste = array_diff_key($liste, $liste_non_classee);
562
-
563
-	foreach ($liste_non_classee as $p => $resume) {
564
-		$dir_type = $resume['dir_type'];
565
-		$plug = $resume['dir'];
566
-		$k = $infos[$dir_type][$plug];
567
-
568
-		$plug = constant($dir_type) . $plug;
569
-		if (!isset($msg[$p])) {
570
-			if (isset($resume['erreur']) and $resume['erreur']) {
571
-				$msg[$p] = [$resume['erreur']];
572
-			}
573
-			elseif (!plugin_version_compatible($k['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) {
574
-				$msg[$p] = [plugin_message_incompatibilite($k['compatibilite'], $GLOBALS['spip_version_branche'], 'SPIP', 'necessite')];
575
-			}
576
-			elseif (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) {
577
-				$msg[$p] = plugin_necessite($k['utilise'], $liste, 'utilise');
578
-			}
579
-		} else {
580
-			foreach ($msg[$p] as $c => $l) {
581
-				$msg[$p][$c] = plugin_controler_lib($l['nom'], $l['lien']);
582
-			}
583
-		}
584
-		$erreurs[$plug] = $msg[$p];
585
-	}
586
-
587
-	ecrire_meta('plugin_erreur_activation', serialize($erreurs));
554
+    static $erreurs = [];
555
+
556
+    if (!is_array($liste)) {
557
+        $liste = [];
558
+    }
559
+
560
+    // les plugins en erreur ne sont pas actifs ; ils ne doivent pas être dans la liste
561
+    $liste = array_diff_key($liste, $liste_non_classee);
562
+
563
+    foreach ($liste_non_classee as $p => $resume) {
564
+        $dir_type = $resume['dir_type'];
565
+        $plug = $resume['dir'];
566
+        $k = $infos[$dir_type][$plug];
567
+
568
+        $plug = constant($dir_type) . $plug;
569
+        if (!isset($msg[$p])) {
570
+            if (isset($resume['erreur']) and $resume['erreur']) {
571
+                $msg[$p] = [$resume['erreur']];
572
+            }
573
+            elseif (!plugin_version_compatible($k['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) {
574
+                $msg[$p] = [plugin_message_incompatibilite($k['compatibilite'], $GLOBALS['spip_version_branche'], 'SPIP', 'necessite')];
575
+            }
576
+            elseif (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) {
577
+                $msg[$p] = plugin_necessite($k['utilise'], $liste, 'utilise');
578
+            }
579
+        } else {
580
+            foreach ($msg[$p] as $c => $l) {
581
+                $msg[$p][$c] = plugin_controler_lib($l['nom'], $l['lien']);
582
+            }
583
+        }
584
+        $erreurs[$plug] = $msg[$p];
585
+    }
586
+
587
+    ecrire_meta('plugin_erreur_activation', serialize($erreurs));
588 588
 }
589 589
 
590 590
 /**
@@ -599,25 +599,25 @@  discard block
 block discarded – undo
599 599
  *     - Liste des erreurs ou code HTML des erreurs
600 600
 **/
601 601
 function plugin_donne_erreurs($raw = false, $raz = true) {
602
-	if (!isset($GLOBALS['meta']['plugin_erreur_activation'])) {
603
-		return $raw ? [] : '';
604
-	}
605
-	$list = @unserialize($GLOBALS['meta']['plugin_erreur_activation']);
606
-	// Compat ancienne version
607
-	if (!$list) {
608
-		$list = $raw ? [] : $GLOBALS['meta']['plugin_erreur_activation'];
609
-	} elseif (!$raw) {
610
-		foreach ($list as $plug => $msg) {
611
-			$list[$plug] = '<li>' . _T('plugin_impossible_activer', ['plugin' => $plug])
612
-				. '<ul><li>' . implode('</li><li>', $msg) . '</li></ul></li>';
613
-		}
614
-		$list = '<ul>' . join("\n", $list) . '</ul>';
615
-	}
616
-	if ($raz) {
617
-		effacer_meta('plugin_erreur_activation');
618
-	}
619
-
620
-	return $list;
602
+    if (!isset($GLOBALS['meta']['plugin_erreur_activation'])) {
603
+        return $raw ? [] : '';
604
+    }
605
+    $list = @unserialize($GLOBALS['meta']['plugin_erreur_activation']);
606
+    // Compat ancienne version
607
+    if (!$list) {
608
+        $list = $raw ? [] : $GLOBALS['meta']['plugin_erreur_activation'];
609
+    } elseif (!$raw) {
610
+        foreach ($list as $plug => $msg) {
611
+            $list[$plug] = '<li>' . _T('plugin_impossible_activer', ['plugin' => $plug])
612
+                . '<ul><li>' . implode('</li><li>', $msg) . '</li></ul></li>';
613
+        }
614
+        $list = '<ul>' . join("\n", $list) . '</ul>';
615
+    }
616
+    if ($raz) {
617
+        effacer_meta('plugin_erreur_activation');
618
+    }
619
+
620
+    return $list;
621 621
 }
622 622
 
623 623
 /**
@@ -637,21 +637,21 @@  discard block
 block discarded – undo
637 637
  *
638 638
  **/
639 639
 function plugin_necessite($n, $liste, $balise = 'necessite') {
640
-	$msg = [];
641
-	foreach ($n as $need) {
642
-		$id = strtoupper($need['nom']);
643
-		$r = plugin_controler_necessite(
644
-			$liste,
645
-			$id,
646
-			$need['compatibilite'] ?? '',
647
-			$balise
648
-		);
649
-		if ($r) {
650
-			$msg[] = $r;
651
-		}
652
-	}
653
-
654
-	return $msg;
640
+    $msg = [];
641
+    foreach ($n as $need) {
642
+        $id = strtoupper($need['nom']);
643
+        $r = plugin_controler_necessite(
644
+            $liste,
645
+            $id,
646
+            $need['compatibilite'] ?? '',
647
+            $balise
648
+        );
649
+        if ($r) {
650
+            $msg[] = $r;
651
+        }
652
+    }
653
+
654
+    return $msg;
655 655
 }
656 656
 
657 657
 /**
@@ -673,19 +673,19 @@  discard block
 block discarded – undo
673 673
  *    Message d'erreur lorsque la dépendance est absente.
674 674
  **/
675 675
 function plugin_controler_necessite($liste, $nom, $intervalle, $balise) {
676
-	if (isset($liste[$nom]) and plugin_version_compatible($intervalle, $liste[$nom]['version'])) {
677
-		return '';
678
-	}
679
-	// Si l'on a un <utilise="plugin non actif" />, ne pas renvoyer d'erreur
680
-	if ($balise === 'utilise' and !isset($liste[$nom])) {
681
-		return '';
682
-	}
683
-	return plugin_message_incompatibilite(
684
-		$intervalle,
685
-		(isset($liste[$nom]) ? $liste[$nom]['version'] : ''),
686
-		$nom,
687
-		$balise
688
-	);
676
+    if (isset($liste[$nom]) and plugin_version_compatible($intervalle, $liste[$nom]['version'])) {
677
+        return '';
678
+    }
679
+    // Si l'on a un <utilise="plugin non actif" />, ne pas renvoyer d'erreur
680
+    if ($balise === 'utilise' and !isset($liste[$nom])) {
681
+        return '';
682
+    }
683
+    return plugin_message_incompatibilite(
684
+        $intervalle,
685
+        (isset($liste[$nom]) ? $liste[$nom]['version'] : ''),
686
+        $nom,
687
+        $balise
688
+    );
689 689
 }
690 690
 
691 691
 /**
@@ -702,70 +702,70 @@  discard block
 block discarded – undo
702 702
  */
703 703
 function plugin_message_incompatibilite($intervalle, $version, $nom, $balise) {
704 704
 
705
-	// prendre en compte les erreurs de dépendances à PHP
706
-	// ou à une extension PHP avec des messages d'erreurs dédiés.
707
-	$type = 'plugin';
708
-	if ($nom === 'SPIP') {
709
-		$type = 'spip';
710
-	} elseif ($nom === 'PHP') {
711
-		$type = 'php';
712
-	} elseif (strncmp($nom, 'PHP:', 4) === 0) {
713
-		$type = 'extension_php';
714
-		[, $nom] = explode(':', $nom, 2);
715
-	}
716
-
717
-	if (preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) {
718
-		$minimum = $regs[1];
719
-		$maximum = $regs[2];
720
-
721
-		$minimum_inclus = $intervalle[0] == '[';
722
-		$maximum_inclus = substr($intervalle, -1) == ']';
723
-
724
-		if (strlen($minimum)) {
725
-			if ($minimum_inclus and spip_version_compare($version, $minimum, '<')) {
726
-				return _T("plugin_${balise}_${type}", [
727
-					'plugin' => $nom,
728
-					'version' => ' &ge; ' . $minimum
729
-				]);
730
-			}
731
-			if (!$minimum_inclus and spip_version_compare($version, $minimum, '<=')) {
732
-				return _T("plugin_${balise}_${type}", [
733
-					'plugin' => $nom,
734
-					'version' => ' &gt; ' . $minimum
735
-				]);
736
-			}
737
-		}
738
-
739
-		if (strlen($maximum)) {
740
-			if ($maximum_inclus and spip_version_compare($version, $maximum, '>')) {
741
-				return _T("plugin_${balise}_${type}", [
742
-					'plugin' => $nom,
743
-					'version' => ' &le; ' . $maximum
744
-				]);
745
-			}
746
-			if (!$maximum_inclus and spip_version_compare($version, $maximum, '>=')) {
747
-				return _T("plugin_${balise}_plugin", [
748
-					'plugin' => $nom,
749
-					'version' => ' &lt; ' . $maximum
750
-				]);
751
-			}
752
-		}
753
-	}
754
-
755
-	// note : il ne peut pas y avoir d'erreur sur
756
-	// - un 'utilise' sans version.
757
-	// - un 'php' sans version.
758
-	return _T("plugin_necessite_${type}_sans_version", ['plugin' => $nom]);
705
+    // prendre en compte les erreurs de dépendances à PHP
706
+    // ou à une extension PHP avec des messages d'erreurs dédiés.
707
+    $type = 'plugin';
708
+    if ($nom === 'SPIP') {
709
+        $type = 'spip';
710
+    } elseif ($nom === 'PHP') {
711
+        $type = 'php';
712
+    } elseif (strncmp($nom, 'PHP:', 4) === 0) {
713
+        $type = 'extension_php';
714
+        [, $nom] = explode(':', $nom, 2);
715
+    }
716
+
717
+    if (preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) {
718
+        $minimum = $regs[1];
719
+        $maximum = $regs[2];
720
+
721
+        $minimum_inclus = $intervalle[0] == '[';
722
+        $maximum_inclus = substr($intervalle, -1) == ']';
723
+
724
+        if (strlen($minimum)) {
725
+            if ($minimum_inclus and spip_version_compare($version, $minimum, '<')) {
726
+                return _T("plugin_${balise}_${type}", [
727
+                    'plugin' => $nom,
728
+                    'version' => ' &ge; ' . $minimum
729
+                ]);
730
+            }
731
+            if (!$minimum_inclus and spip_version_compare($version, $minimum, '<=')) {
732
+                return _T("plugin_${balise}_${type}", [
733
+                    'plugin' => $nom,
734
+                    'version' => ' &gt; ' . $minimum
735
+                ]);
736
+            }
737
+        }
738
+
739
+        if (strlen($maximum)) {
740
+            if ($maximum_inclus and spip_version_compare($version, $maximum, '>')) {
741
+                return _T("plugin_${balise}_${type}", [
742
+                    'plugin' => $nom,
743
+                    'version' => ' &le; ' . $maximum
744
+                ]);
745
+            }
746
+            if (!$maximum_inclus and spip_version_compare($version, $maximum, '>=')) {
747
+                return _T("plugin_${balise}_plugin", [
748
+                    'plugin' => $nom,
749
+                    'version' => ' &lt; ' . $maximum
750
+                ]);
751
+            }
752
+        }
753
+    }
754
+
755
+    // note : il ne peut pas y avoir d'erreur sur
756
+    // - un 'utilise' sans version.
757
+    // - un 'php' sans version.
758
+    return _T("plugin_necessite_${type}_sans_version", ['plugin' => $nom]);
759 759
 }
760 760
 
761 761
 
762 762
 function plugin_controler_lib($lib, $url) {
763
-	/* Feature sortie du core, voir STP
763
+    /* Feature sortie du core, voir STP
764 764
 	 * if ($url) {
765 765
 		include_spip('inc/charger_plugin');
766 766
 		$url = '<br />'	. bouton_telechargement_plugin($url, 'lib');
767 767
 	}*/
768
-	return _T('plugin_necessite_lib', ['lib' => $lib]) . " <a href='$url'>$url</a>";
768
+    return _T('plugin_necessite_lib', ['lib' => $lib]) . " <a href='$url'>$url</a>";
769 769
 }
770 770
 
771 771
 
@@ -780,7 +780,7 @@  discard block
 block discarded – undo
780 780
  *     true si il y a eu des modifications sur la liste des plugins actifs, false sinon
781 781
  **/
782 782
 function actualise_plugins_actifs($pipe_recherche = false) {
783
-	return ecrire_plugin_actifs('', $pipe_recherche, 'force');
783
+    return ecrire_plugin_actifs('', $pipe_recherche, 'force');
784 784
 }
785 785
 
786 786
 
@@ -807,116 +807,116 @@  discard block
 block discarded – undo
807 807
  **/
808 808
 function ecrire_plugin_actifs($plugin, $pipe_recherche = false, $operation = 'raz') {
809 809
 
810
-	// creer le repertoire cache/ si necessaire ! (installation notamment)
811
-	$cache = sous_repertoire(_DIR_CACHE, '', false, true);
812
-
813
-	// Si on n'a ni cache accessible, ni connexion SQL, on ne peut pas faire grand chose encore.
814
-	if (!$cache and !spip_connect()) {
815
-		return false;
816
-	}
817
-
818
-	if ($operation != 'raz') {
819
-		$plugin_valides = liste_chemin_plugin_actifs();
820
-		$plugin_valides = is_plugin_dir($plugin_valides);
821
-		if (defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) {
822
-			$plugin_valides_supp = liste_chemin_plugin_actifs(_DIR_PLUGINS_SUPPL);
823
-			$plugin_valides_supp = is_plugin_dir($plugin_valides_supp, _DIR_PLUGINS_SUPPL);
824
-			$plugin_valides = array_merge($plugin_valides, $plugin_valides_supp);
825
-		}
826
-		// si des plugins sont en attentes (coches mais impossible a activer)
827
-		// on les reinjecte ici
828
-		if (
829
-			isset($GLOBALS['meta']['plugin_attente'])
830
-			and $a = unserialize($GLOBALS['meta']['plugin_attente'])
831
-		) {
832
-			$plugin_valides = $plugin_valides + liste_chemin_plugin($a);
833
-		}
834
-
835
-		if ($operation == 'ajoute') {
836
-			$plugin = array_merge($plugin_valides, $plugin);
837
-		} elseif ($operation == 'enleve') {
838
-			$plugin = array_diff($plugin_valides, $plugin);
839
-		} else {
840
-			$plugin = $plugin_valides;
841
-		}
842
-	}
843
-	$actifs_avant = $GLOBALS['meta']['plugin'] ?? '';
844
-
845
-	// si une fonction de gestion de dependances existe, l'appeler ici
846
-	if ($ajouter_dependances = charger_fonction('ajouter_dependances', 'plugins', true)) {
847
-		$plugin = $ajouter_dependances($plugin);
848
-	}
849
-
850
-	// recharger le xml des plugins a activer
851
-	// on force le reload ici, meme si le fichier xml n'a pas change
852
-	// pour ne pas rater l'ajout ou la suppression d'un fichier fonctions/options/administrations
853
-	// pourra etre evite quand on ne supportera plus les plugin.xml
854
-	// en deplacant la detection de ces fichiers dans la compilation ci dessous
855
-	[$infos, $liste, $invalides] = liste_plugin_valides($plugin, true);
856
-	// trouver l'ordre d'activation
857
-	[$plugin_valides, $ordre, $reste] = plugin_trier($infos, $liste);
858
-	if ($invalides or $reste) {
859
-		plugins_erreurs(array_merge($invalides, $reste), $liste, $infos);
860
-	}
861
-
862
-	// Ignorer les plugins necessitant une lib absente
863
-	// et preparer la meta d'entete Http
864
-	$err = $msg = $header = [];
865
-	foreach ($plugin_valides as $p => $resume) {
866
-		// Les headers ne doivent pas indiquer les versions des extensions PHP, ni la version PHP
867
-		if (0 !== strpos($p, 'PHP:') and $p !== 'PHP') {
868
-			$header[] = $p . ($resume['version'] ? '(' . $resume['version'] . ')' : '');
869
-		}
870
-		if ($resume['dir']) {
871
-			foreach ($infos[$resume['dir_type']][$resume['dir']]['lib'] as $l) {
872
-				if (!find_in_path($l['nom'], 'lib/')) {
873
-					$err[$p] = $resume;
874
-					$msg[$p][] = $l;
875
-					unset($plugin_valides[$p]);
876
-				}
877
-			}
878
-		}
879
-	}
880
-	if ($err) {
881
-		plugins_erreurs($err, '', $infos, $msg);
882
-	}
883
-
884
-	if (isset($GLOBALS['meta']['message_crash_plugins'])) {
885
-		effacer_meta('message_crash_plugins');
886
-	}
887
-	ecrire_meta('plugin', serialize($plugin_valides));
888
-	$liste = array_diff_key($liste, $plugin_valides);
889
-	ecrire_meta('plugin_attente', serialize($liste));
890
-	$header = strtolower(implode(',', $header));
891
-	if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) {
892
-		ecrire_fichier(
893
-			_DIR_VAR . 'config.txt',
894
-			(defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : 'Composed-By: SPIP') . ' ' . $GLOBALS['spip_version_affichee'] . ' @ www.spip.net + ' . $header
895
-		);
896
-	} else {
897
-		@unlink(_DIR_VAR . 'config.txt');
898
-	}
899
-	// generer charger_plugins_chemin.php
900
-	plugins_precompile_chemin($plugin_valides, $ordre);
901
-	// generer les fichiers
902
-	// - charger_plugins_options.php
903
-	// - charger_plugins_fonctions.php
904
-	plugins_precompile_xxxtions($plugin_valides, $ordre);
905
-	// charger les chemins des plugins et les fichiers d'options
906
-	// (qui peuvent déclarer / utiliser des pipelines, ajouter d'autres chemins)
907
-	plugins_amorcer_plugins_actifs();
908
-	// mise a jour de la matrice des pipelines
909
-	$prepend_code = pipeline_matrice_precompile($plugin_valides, $ordre, $pipe_recherche);
910
-	// generer le fichier _CACHE_PIPELINE
911
-	pipeline_precompile($prepend_code);
912
-
913
-	if (spip_connect()) {
914
-		// lancer et initialiser les nouveaux crons !
915
-		include_spip('inc/genie');
916
-		genie_queue_watch_dist();
917
-	}
918
-
919
-	return ($GLOBALS['meta']['plugin'] != $actifs_avant);
810
+    // creer le repertoire cache/ si necessaire ! (installation notamment)
811
+    $cache = sous_repertoire(_DIR_CACHE, '', false, true);
812
+
813
+    // Si on n'a ni cache accessible, ni connexion SQL, on ne peut pas faire grand chose encore.
814
+    if (!$cache and !spip_connect()) {
815
+        return false;
816
+    }
817
+
818
+    if ($operation != 'raz') {
819
+        $plugin_valides = liste_chemin_plugin_actifs();
820
+        $plugin_valides = is_plugin_dir($plugin_valides);
821
+        if (defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) {
822
+            $plugin_valides_supp = liste_chemin_plugin_actifs(_DIR_PLUGINS_SUPPL);
823
+            $plugin_valides_supp = is_plugin_dir($plugin_valides_supp, _DIR_PLUGINS_SUPPL);
824
+            $plugin_valides = array_merge($plugin_valides, $plugin_valides_supp);
825
+        }
826
+        // si des plugins sont en attentes (coches mais impossible a activer)
827
+        // on les reinjecte ici
828
+        if (
829
+            isset($GLOBALS['meta']['plugin_attente'])
830
+            and $a = unserialize($GLOBALS['meta']['plugin_attente'])
831
+        ) {
832
+            $plugin_valides = $plugin_valides + liste_chemin_plugin($a);
833
+        }
834
+
835
+        if ($operation == 'ajoute') {
836
+            $plugin = array_merge($plugin_valides, $plugin);
837
+        } elseif ($operation == 'enleve') {
838
+            $plugin = array_diff($plugin_valides, $plugin);
839
+        } else {
840
+            $plugin = $plugin_valides;
841
+        }
842
+    }
843
+    $actifs_avant = $GLOBALS['meta']['plugin'] ?? '';
844
+
845
+    // si une fonction de gestion de dependances existe, l'appeler ici
846
+    if ($ajouter_dependances = charger_fonction('ajouter_dependances', 'plugins', true)) {
847
+        $plugin = $ajouter_dependances($plugin);
848
+    }
849
+
850
+    // recharger le xml des plugins a activer
851
+    // on force le reload ici, meme si le fichier xml n'a pas change
852
+    // pour ne pas rater l'ajout ou la suppression d'un fichier fonctions/options/administrations
853
+    // pourra etre evite quand on ne supportera plus les plugin.xml
854
+    // en deplacant la detection de ces fichiers dans la compilation ci dessous
855
+    [$infos, $liste, $invalides] = liste_plugin_valides($plugin, true);
856
+    // trouver l'ordre d'activation
857
+    [$plugin_valides, $ordre, $reste] = plugin_trier($infos, $liste);
858
+    if ($invalides or $reste) {
859
+        plugins_erreurs(array_merge($invalides, $reste), $liste, $infos);
860
+    }
861
+
862
+    // Ignorer les plugins necessitant une lib absente
863
+    // et preparer la meta d'entete Http
864
+    $err = $msg = $header = [];
865
+    foreach ($plugin_valides as $p => $resume) {
866
+        // Les headers ne doivent pas indiquer les versions des extensions PHP, ni la version PHP
867
+        if (0 !== strpos($p, 'PHP:') and $p !== 'PHP') {
868
+            $header[] = $p . ($resume['version'] ? '(' . $resume['version'] . ')' : '');
869
+        }
870
+        if ($resume['dir']) {
871
+            foreach ($infos[$resume['dir_type']][$resume['dir']]['lib'] as $l) {
872
+                if (!find_in_path($l['nom'], 'lib/')) {
873
+                    $err[$p] = $resume;
874
+                    $msg[$p][] = $l;
875
+                    unset($plugin_valides[$p]);
876
+                }
877
+            }
878
+        }
879
+    }
880
+    if ($err) {
881
+        plugins_erreurs($err, '', $infos, $msg);
882
+    }
883
+
884
+    if (isset($GLOBALS['meta']['message_crash_plugins'])) {
885
+        effacer_meta('message_crash_plugins');
886
+    }
887
+    ecrire_meta('plugin', serialize($plugin_valides));
888
+    $liste = array_diff_key($liste, $plugin_valides);
889
+    ecrire_meta('plugin_attente', serialize($liste));
890
+    $header = strtolower(implode(',', $header));
891
+    if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) {
892
+        ecrire_fichier(
893
+            _DIR_VAR . 'config.txt',
894
+            (defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : 'Composed-By: SPIP') . ' ' . $GLOBALS['spip_version_affichee'] . ' @ www.spip.net + ' . $header
895
+        );
896
+    } else {
897
+        @unlink(_DIR_VAR . 'config.txt');
898
+    }
899
+    // generer charger_plugins_chemin.php
900
+    plugins_precompile_chemin($plugin_valides, $ordre);
901
+    // generer les fichiers
902
+    // - charger_plugins_options.php
903
+    // - charger_plugins_fonctions.php
904
+    plugins_precompile_xxxtions($plugin_valides, $ordre);
905
+    // charger les chemins des plugins et les fichiers d'options
906
+    // (qui peuvent déclarer / utiliser des pipelines, ajouter d'autres chemins)
907
+    plugins_amorcer_plugins_actifs();
908
+    // mise a jour de la matrice des pipelines
909
+    $prepend_code = pipeline_matrice_precompile($plugin_valides, $ordre, $pipe_recherche);
910
+    // generer le fichier _CACHE_PIPELINE
911
+    pipeline_precompile($prepend_code);
912
+
913
+    if (spip_connect()) {
914
+        // lancer et initialiser les nouveaux crons !
915
+        include_spip('inc/genie');
916
+        genie_queue_watch_dist();
917
+    }
918
+
919
+    return ($GLOBALS['meta']['plugin'] != $actifs_avant);
920 920
 }
921 921
 
922 922
 /**
@@ -935,74 +935,74 @@  discard block
 block discarded – undo
935 935
  *     Couples (prefixe => infos complètes) des plugins qui seront actifs, dans l'ordre de leurs dépendances
936 936
 **/
937 937
 function plugins_precompile_chemin($plugin_valides, $ordre) {
938
-	$chemins = [
939
-		'public' => [],
940
-		'prive' => []
941
-	];
942
-	$contenu = '';
943
-	foreach ($ordre as $p => $info) {
944
-		// $ordre peur contenir des plugins en attente et non valides pour ce hit
945
-		if (isset($plugin_valides[$p])) {
946
-			$dir_type = $plugin_valides[$p]['dir_type'];
947
-			$plug = $plugin_valides[$p]['dir'];
948
-			// definir le plugin, donc le path avant l'include du fichier options
949
-			// permet de faire des include_spip pour attraper un inc_ du plugin
950
-
951
-			$dir = $dir_type . ".'" . $plug . "/'";
952
-
953
-			$prefix = strtoupper(preg_replace(',\W,', '_', $info['prefix']));
954
-			if (
955
-				$prefix !== 'SPIP'
956
-				and strpos($dir, ':') === false // exclure le cas des procure:
957
-			) {
958
-				$contenu .= "define('_DIR_PLUGIN_$prefix',$dir);\n";
959
-				if (!$info['chemin']) {
960
-					$chemins['public'][] = "_DIR_PLUGIN_$prefix";
961
-					$chemins['prive'][] = "_DIR_PLUGIN_$prefix";
962
-					if (is_dir(constant($dir_type) . $plug . '/squelettes/')) {
963
-						$chemins['public'][] = "_DIR_PLUGIN_{$prefix}.'squelettes/'";
964
-					}
965
-				}
966
-				else {
967
-					foreach ($info['chemin'] as $chemin) {
968
-						if (
969
-							!isset($chemin['version']) or plugin_version_compatible(
970
-								$chemin['version'],
971
-								$GLOBALS['spip_version_branche'],
972
-								'spip'
973
-							)
974
-						) {
975
-							$dir = $chemin['path'];
976
-							if (strlen($dir) and $dir[0] == '/') {
977
-								$dir = substr($dir, 1);
978
-							}
979
-							if (strlen($dir) and $dir == './') {
980
-								$dir = '';
981
-							}
982
-							if (strlen($dir)) {
983
-								$dir = rtrim($dir, '/') . '/';
984
-							}
985
-							if (!isset($chemin['type']) or $chemin['type'] == 'public') {
986
-								$chemins['public'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : '');
987
-							}
988
-							if (!isset($chemin['type']) or $chemin['type'] == 'prive') {
989
-								$chemins['prive'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : '');
990
-							}
991
-						}
992
-					}
993
-				}
994
-			}
995
-		}
996
-	}
997
-	if (count($chemins['public']) or count($chemins['prive'])) {
998
-		$contenu .= 'if (_DIR_RESTREINT) _chemin([' . implode(
999
-			',',
1000
-			array_reverse($chemins['public'])
1001
-		) . "]);\n"
1002
-			. 'else _chemin([' . implode(',', array_reverse($chemins['prive'])) . "]);\n";
1003
-	}
1004
-
1005
-	ecrire_fichier_php(_CACHE_PLUGINS_PATH, $contenu);
938
+    $chemins = [
939
+        'public' => [],
940
+        'prive' => []
941
+    ];
942
+    $contenu = '';
943
+    foreach ($ordre as $p => $info) {
944
+        // $ordre peur contenir des plugins en attente et non valides pour ce hit
945
+        if (isset($plugin_valides[$p])) {
946
+            $dir_type = $plugin_valides[$p]['dir_type'];
947
+            $plug = $plugin_valides[$p]['dir'];
948
+            // definir le plugin, donc le path avant l'include du fichier options
949
+            // permet de faire des include_spip pour attraper un inc_ du plugin
950
+
951
+            $dir = $dir_type . ".'" . $plug . "/'";
952
+
953
+            $prefix = strtoupper(preg_replace(',\W,', '_', $info['prefix']));
954
+            if (
955
+                $prefix !== 'SPIP'
956
+                and strpos($dir, ':') === false // exclure le cas des procure:
957
+            ) {
958
+                $contenu .= "define('_DIR_PLUGIN_$prefix',$dir);\n";
959
+                if (!$info['chemin']) {
960
+                    $chemins['public'][] = "_DIR_PLUGIN_$prefix";
961
+                    $chemins['prive'][] = "_DIR_PLUGIN_$prefix";
962
+                    if (is_dir(constant($dir_type) . $plug . '/squelettes/')) {
963
+                        $chemins['public'][] = "_DIR_PLUGIN_{$prefix}.'squelettes/'";
964
+                    }
965
+                }
966
+                else {
967
+                    foreach ($info['chemin'] as $chemin) {
968
+                        if (
969
+                            !isset($chemin['version']) or plugin_version_compatible(
970
+                                $chemin['version'],
971
+                                $GLOBALS['spip_version_branche'],
972
+                                'spip'
973
+                            )
974
+                        ) {
975
+                            $dir = $chemin['path'];
976
+                            if (strlen($dir) and $dir[0] == '/') {
977
+                                $dir = substr($dir, 1);
978
+                            }
979
+                            if (strlen($dir) and $dir == './') {
980
+                                $dir = '';
981
+                            }
982
+                            if (strlen($dir)) {
983
+                                $dir = rtrim($dir, '/') . '/';
984
+                            }
985
+                            if (!isset($chemin['type']) or $chemin['type'] == 'public') {
986
+                                $chemins['public'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : '');
987
+                            }
988
+                            if (!isset($chemin['type']) or $chemin['type'] == 'prive') {
989
+                                $chemins['prive'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : '');
990
+                            }
991
+                        }
992
+                    }
993
+                }
994
+            }
995
+        }
996
+    }
997
+    if (count($chemins['public']) or count($chemins['prive'])) {
998
+        $contenu .= 'if (_DIR_RESTREINT) _chemin([' . implode(
999
+            ',',
1000
+            array_reverse($chemins['public'])
1001
+        ) . "]);\n"
1002
+            . 'else _chemin([' . implode(',', array_reverse($chemins['prive'])) . "]);\n";
1003
+    }
1004
+
1005
+    ecrire_fichier_php(_CACHE_PLUGINS_PATH, $contenu);
1006 1006
 }
1007 1007
 
1008 1008
 /**
@@ -1020,67 +1020,67 @@  discard block
 block discarded – undo
1020 1020
  *     Couples (prefixe => infos complètes) des plugins qui seront actifs, dans l'ordre de leurs dépendances
1021 1021
 **/
1022 1022
 function plugins_precompile_xxxtions($plugin_valides, $ordre) {
1023
-	$contenu = ['options' => '', 'fonctions' => ''];
1024
-	$boutons = [];
1025
-	$onglets = [];
1026
-	$sign = '';
1027
-
1028
-	foreach ($ordre as $p => $info) {
1029
-		// $ordre peur contenir des plugins en attente et non valides pour ce hit
1030
-		if (isset($plugin_valides[$p])) {
1031
-			$dir_type = $plugin_valides[$p]['dir_type'];
1032
-			$plug = $plugin_valides[$p]['dir'];
1033
-			$dir = constant($dir_type);
1034
-			$root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type);
1035
-			if ($info['menu']) {
1036
-				$boutons = array_merge($boutons, $info['menu']);
1037
-			}
1038
-			if ($info['onglet']) {
1039
-				$onglets = array_merge($onglets, $info['onglet']);
1040
-			}
1041
-			foreach ($contenu as $charge => $v) {
1042
-				// si pas declare/detecte a la lecture du paquet.xml,
1043
-				// detecer a nouveau ici puisque son ajout ne provoque pas une modif du paquet.xml
1044
-				// donc ni sa relecture, ni sa detection
1045
-				if (
1046
-					!isset($info[$charge])
1047
-					and $dir // exclure le cas du plugin "SPIP"
1048
-					and strpos($dir, ':') === false // exclure le cas des procure:
1049
-					and file_exists("$dir$plug/paquet.xml") // uniquement pour les paquet.xml
1050
-				) {
1051
-					if (is_readable("$dir$plug/" . ($file = $info['prefix'] . '_' . $charge . '.php'))) {
1052
-						$info[$charge] = [$file];
1053
-					}
1054
-				}
1055
-				if (isset($info[$charge])) {
1056
-					$files = $info[$charge];
1057
-					foreach ($files as $k => $file) {
1058
-						// on genere un if file_exists devant chaque include
1059
-						// pour pouvoir garder le meme niveau d'erreur general
1060
-						$file = trim($file);
1061
-						if (
1062
-							!is_readable("$dir$plug/$file")
1063
-							// uniquement pour les paquet.xml
1064
-							and file_exists("$dir$plug/paquet.xml")
1065
-						) {
1066
-							unset($info[$charge][$k]);
1067
-						} else {
1068
-							$_file = $root_dir_type . ".'$plug/$file'";
1069
-							$contenu[$charge] .= "include_once_check($_file);\n";
1070
-						}
1071
-					}
1072
-				}
1073
-			}
1074
-			$sign .= md5(serialize($info));
1075
-		}
1076
-	}
1077
-
1078
-	$contenu['options'] = "define('_PLUGINS_HASH','" . md5($sign) . "');\n" . $contenu['options'];
1079
-	$contenu['fonctions'] .= plugin_ongletbouton('boutons_plugins', $boutons)
1080
-		. plugin_ongletbouton('onglets_plugins', $onglets);
1081
-
1082
-	ecrire_fichier_php(_CACHE_PLUGINS_OPT, $contenu['options']);
1083
-	ecrire_fichier_php(_CACHE_PLUGINS_FCT, $contenu['fonctions']);
1023
+    $contenu = ['options' => '', 'fonctions' => ''];
1024
+    $boutons = [];
1025
+    $onglets = [];
1026
+    $sign = '';
1027
+
1028
+    foreach ($ordre as $p => $info) {
1029
+        // $ordre peur contenir des plugins en attente et non valides pour ce hit
1030
+        if (isset($plugin_valides[$p])) {
1031
+            $dir_type = $plugin_valides[$p]['dir_type'];
1032
+            $plug = $plugin_valides[$p]['dir'];
1033
+            $dir = constant($dir_type);
1034
+            $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type);
1035
+            if ($info['menu']) {
1036
+                $boutons = array_merge($boutons, $info['menu']);
1037
+            }
1038
+            if ($info['onglet']) {
1039
+                $onglets = array_merge($onglets, $info['onglet']);
1040
+            }
1041
+            foreach ($contenu as $charge => $v) {
1042
+                // si pas declare/detecte a la lecture du paquet.xml,
1043
+                // detecer a nouveau ici puisque son ajout ne provoque pas une modif du paquet.xml
1044
+                // donc ni sa relecture, ni sa detection
1045
+                if (
1046
+                    !isset($info[$charge])
1047
+                    and $dir // exclure le cas du plugin "SPIP"
1048
+                    and strpos($dir, ':') === false // exclure le cas des procure:
1049
+                    and file_exists("$dir$plug/paquet.xml") // uniquement pour les paquet.xml
1050
+                ) {
1051
+                    if (is_readable("$dir$plug/" . ($file = $info['prefix'] . '_' . $charge . '.php'))) {
1052
+                        $info[$charge] = [$file];
1053
+                    }
1054
+                }
1055
+                if (isset($info[$charge])) {
1056
+                    $files = $info[$charge];
1057
+                    foreach ($files as $k => $file) {
1058
+                        // on genere un if file_exists devant chaque include
1059
+                        // pour pouvoir garder le meme niveau d'erreur general
1060
+                        $file = trim($file);
1061
+                        if (
1062
+                            !is_readable("$dir$plug/$file")
1063
+                            // uniquement pour les paquet.xml
1064
+                            and file_exists("$dir$plug/paquet.xml")
1065
+                        ) {
1066
+                            unset($info[$charge][$k]);
1067
+                        } else {
1068
+                            $_file = $root_dir_type . ".'$plug/$file'";
1069
+                            $contenu[$charge] .= "include_once_check($_file);\n";
1070
+                        }
1071
+                    }
1072
+                }
1073
+            }
1074
+            $sign .= md5(serialize($info));
1075
+        }
1076
+    }
1077
+
1078
+    $contenu['options'] = "define('_PLUGINS_HASH','" . md5($sign) . "');\n" . $contenu['options'];
1079
+    $contenu['fonctions'] .= plugin_ongletbouton('boutons_plugins', $boutons)
1080
+        . plugin_ongletbouton('onglets_plugins', $onglets);
1081
+
1082
+    ecrire_fichier_php(_CACHE_PLUGINS_OPT, $contenu['options']);
1083
+    ecrire_fichier_php(_CACHE_PLUGINS_FCT, $contenu['fonctions']);
1084 1084
 }
1085 1085
 
1086 1086
 /**
@@ -1099,24 +1099,24 @@  discard block
 block discarded – undo
1099 1099
  * @return string Code php
1100 1100
  */
1101 1101
 function plugin_ongletbouton($nom, $val) {
1102
-	if (!$val) {
1103
-		$val = [];
1104
-	}
1105
-
1106
-	$val = serialize($val);
1107
-	$md5 = md5($val);
1108
-
1109
-	if (!defined("_UPDATED_$nom")) {
1110
-		define("_UPDATED_$nom", $val);
1111
-		define("_UPDATED_md5_$nom", $md5);
1112
-	}
1113
-	$val = "unserialize('" . str_replace("'", "\'", $val) . "')";
1114
-
1115
-	return
1116
-		"if (!function_exists('$nom')) {\n"
1117
-		. "function $nom(){return defined('_UPDATED_$nom')?unserialize(_UPDATED_$nom):$val;}\n"
1118
-		. "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'" . $md5 . "';}\n"
1119
-		. "}\n";
1102
+    if (!$val) {
1103
+        $val = [];
1104
+    }
1105
+
1106
+    $val = serialize($val);
1107
+    $md5 = md5($val);
1108
+
1109
+    if (!defined("_UPDATED_$nom")) {
1110
+        define("_UPDATED_$nom", $val);
1111
+        define("_UPDATED_md5_$nom", $md5);
1112
+    }
1113
+    $val = "unserialize('" . str_replace("'", "\'", $val) . "')";
1114
+
1115
+    return
1116
+        "if (!function_exists('$nom')) {\n"
1117
+        . "function $nom(){return defined('_UPDATED_$nom')?unserialize(_UPDATED_$nom):$val;}\n"
1118
+        . "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'" . $md5 . "';}\n"
1119
+        . "}\n";
1120 1120
 }
1121 1121
 
1122 1122
 /**
@@ -1131,15 +1131,15 @@  discard block
 block discarded – undo
1131 1131
 **/
1132 1132
 function plugins_amorcer_plugins_actifs() {
1133 1133
 
1134
-	if (@is_readable(_CACHE_PLUGINS_PATH)) {
1135
-		include_once(_CACHE_PLUGINS_PATH);
1136
-	}
1134
+    if (@is_readable(_CACHE_PLUGINS_PATH)) {
1135
+        include_once(_CACHE_PLUGINS_PATH);
1136
+    }
1137 1137
 
1138
-	if (@is_readable(_CACHE_PLUGINS_OPT)) {
1139
-		include_once(_CACHE_PLUGINS_OPT);
1140
-	} else {
1141
-		spip_log('pipelines desactives: impossible de produire ' . _CACHE_PLUGINS_OPT);
1142
-	}
1138
+    if (@is_readable(_CACHE_PLUGINS_OPT)) {
1139
+        include_once(_CACHE_PLUGINS_OPT);
1140
+    } else {
1141
+        spip_log('pipelines desactives: impossible de produire ' . _CACHE_PLUGINS_OPT);
1142
+    }
1143 1143
 }
1144 1144
 
1145 1145
 /**
@@ -1162,140 +1162,140 @@  discard block
 block discarded – undo
1162 1162
  *     Couples (nom du pipeline => Code PHP à insérer au début du pipeline)
1163 1163
 **/
1164 1164
 function pipeline_matrice_precompile($plugin_valides, $ordre, $pipe_recherche) {
1165
-	static $liste_pipe_manquants = [];
1166
-	if (($pipe_recherche) && (!in_array($pipe_recherche, $liste_pipe_manquants))) {
1167
-		$liste_pipe_manquants[] = $pipe_recherche;
1168
-	}
1169
-
1170
-	$prepend_code = [];
1171
-
1172
-	foreach ($ordre as $p => $info) {
1173
-		// $ordre peur contenir des plugins en attente et non valides pour ce hit
1174
-		if (isset($plugin_valides[$p])) {
1175
-			$dir_type = $plugin_valides[$p]['dir_type'];
1176
-			$root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type);
1177
-			$plug = $plugin_valides[$p]['dir'];
1178
-			$prefix = (($info['prefix'] == 'spip') ? '' : $info['prefix'] . '_');
1179
-			if (isset($info['pipeline']) and is_array($info['pipeline'])) {
1180
-				foreach ($info['pipeline'] as $pipe) {
1181
-					$nom = $pipe['nom'];
1182
-					if (isset($pipe['action'])) {
1183
-						$action = $pipe['action'];
1184
-					} else {
1185
-						$action = $nom;
1186
-					}
1187
-					$nomlower = strtolower($nom);
1188
-					if (
1189
-						$nomlower != $nom
1190
-						and isset($GLOBALS['spip_pipeline'][$nom])
1191
-						and !isset($GLOBALS['spip_pipeline'][$nomlower])
1192
-					) {
1193
-						$GLOBALS['spip_pipeline'][$nomlower] = $GLOBALS['spip_pipeline'][$nom];
1194
-						unset($GLOBALS['spip_pipeline'][$nom]);
1195
-					}
1196
-					$nom = $nomlower;
1197
-					// une action vide est une declaration qui ne doit pas etre compilee !
1198
-					if (!isset($GLOBALS['spip_pipeline'][$nom])) { // creer le pipeline eventuel
1199
-					$GLOBALS['spip_pipeline'][$nom] = '';
1200
-					}
1201
-					if ($action) {
1202
-						if (strpos($GLOBALS['spip_pipeline'][$nom], (string) "|$prefix$action") === false) {
1203
-							$GLOBALS['spip_pipeline'][$nom] = preg_replace(
1204
-								',(\|\||$),',
1205
-								"|$prefix$action\\1",
1206
-								$GLOBALS['spip_pipeline'][$nom],
1207
-								1
1208
-							);
1209
-						}
1210
-						if (isset($pipe['inclure'])) {
1211
-							$GLOBALS['spip_matrice']["$prefix$action"] =
1212
-								"$root_dir_type:$plug/" . $pipe['inclure'];
1213
-						}
1214
-					}
1215
-				}
1216
-			}
1217
-			if (isset($info['genie']) and is_countable($info['genie']) ? count($info['genie']) : 0) {
1218
-				if (!isset($prepend_code['taches_generales_cron'])) {
1219
-					$prepend_code['taches_generales_cron'] = '';
1220
-				}
1221
-				foreach ($info['genie'] as $genie) {
1222
-					$nom = $prefix . $genie['nom'];
1223
-					$periode = max(60, intval($genie['periode']));
1224
-					if (charger_fonction($nom, 'genie', true)) {
1225
-						$prepend_code['taches_generales_cron'] .= "\$val['$nom'] = $periode;\n";
1226
-					} else {
1227
-						spip_log("Fonction genie_$nom introuvable", _LOG_ERREUR);
1228
-					}
1229
-				}
1230
-			}
1231
-			if (isset($info['style']) and is_countable($info['style']) ? count($info['style']) : 0) {
1232
-				if (!isset($prepend_code['insert_head_css'])) {
1233
-					$prepend_code['insert_head_css'] = '';
1234
-				}
1235
-				if (!isset($prepend_code['header_prive_css'])) {
1236
-					$prepend_code['header_prive_css'] = '';
1237
-				}
1238
-				foreach ($info['style'] as $style) {
1239
-					if (isset($style['path']) and $style['path']) {
1240
-						$code = "if (\$f=timestamp(direction_css(find_in_path('" . addslashes($style['path']) . "')))) ";
1241
-					} else {
1242
-						$code = "if (\$f='" . addslashes($style['url']) . "') ";
1243
-					}
1244
-					$code .= "\$val .= '<link rel=\"stylesheet\" href=\"'.\$f.'\" type=\"text/css\"";
1245
-					if (isset($style['media']) and strlen($style['media'])) {
1246
-						$code .= ' media="' . addslashes($style['media']) . '"';
1247
-					}
1248
-					$code .= "/>';\n";
1249
-					if ($style['type'] != 'prive') {
1250
-						$prepend_code['insert_head_css'] .= $code;
1251
-					}
1252
-					if ($style['type'] != 'public') {
1253
-						$prepend_code['header_prive_css'] .= $code;
1254
-					}
1255
-				}
1256
-			}
1257
-			if (!isset($prepend_code['insert_head'])) {
1258
-				$prepend_code['insert_head'] = '';
1259
-			}
1260
-			if (!isset($prepend_code['header_prive'])) {
1261
-				$prepend_code['header_prive'] = '';
1262
-			}
1263
-			if (isset($info['script']) and is_countable($info['script']) ? count($info['script']) : 0) {
1264
-				foreach ($info['script'] as $script) {
1265
-					if (isset($script['path']) and $script['path']) {
1266
-						$code = "if (\$f=timestamp(find_in_path('" . addslashes($script['path']) . "'))) ";
1267
-					} else {
1268
-						$code = "if (\$f='" . addslashes($script['url']) . "') ";
1269
-					}
1270
-					$code .= "\$val .= '<script src=\"'.\$f.'\" type=\"text/javascript\"></script>';\n";
1271
-					if ($script['type'] != 'prive') {
1272
-						$prepend_code['insert_head'] .= $code;
1273
-					}
1274
-					if ($script['type'] != 'public') {
1275
-						$prepend_code['header_prive'] .= $code;
1276
-					}
1277
-				}
1278
-			}
1279
-		}
1280
-	}
1281
-
1282
-	$prepend_code['insert_head'] =
1283
-		"include_once_check(_DIR_RESTREINT . 'inc/pipelines.php');\n"
1284
-		. "\$val = minipipe('f_jQuery', \$val);\n"
1285
-		. $prepend_code['insert_head'];
1286
-	$prepend_code['header_prive'] =
1287
-		"include_once_check(_DIR_RESTREINT . 'inc/pipelines_ecrire.php');\n"
1288
-		. "\$val = minipipe('f_jQuery_prive', \$val);\n"
1289
-		. $prepend_code['header_prive'];
1290
-
1291
-	// on ajoute les pipe qui ont ete recenses manquants
1292
-	foreach ($liste_pipe_manquants as $add_pipe) {
1293
-		if (!isset($GLOBALS['spip_pipeline'][$add_pipe])) {
1294
-			$GLOBALS['spip_pipeline'][$add_pipe] = '';
1295
-		}
1296
-	}
1297
-
1298
-	return $prepend_code;
1165
+    static $liste_pipe_manquants = [];
1166
+    if (($pipe_recherche) && (!in_array($pipe_recherche, $liste_pipe_manquants))) {
1167
+        $liste_pipe_manquants[] = $pipe_recherche;
1168
+    }
1169
+
1170
+    $prepend_code = [];
1171
+
1172
+    foreach ($ordre as $p => $info) {
1173
+        // $ordre peur contenir des plugins en attente et non valides pour ce hit
1174
+        if (isset($plugin_valides[$p])) {
1175
+            $dir_type = $plugin_valides[$p]['dir_type'];
1176
+            $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type);
1177
+            $plug = $plugin_valides[$p]['dir'];
1178
+            $prefix = (($info['prefix'] == 'spip') ? '' : $info['prefix'] . '_');
1179
+            if (isset($info['pipeline']) and is_array($info['pipeline'])) {
1180
+                foreach ($info['pipeline'] as $pipe) {
1181
+                    $nom = $pipe['nom'];
1182
+                    if (isset($pipe['action'])) {
1183
+                        $action = $pipe['action'];
1184
+                    } else {
1185
+                        $action = $nom;
1186
+                    }
1187
+                    $nomlower = strtolower($nom);
1188
+                    if (
1189
+                        $nomlower != $nom
1190
+                        and isset($GLOBALS['spip_pipeline'][$nom])
1191
+                        and !isset($GLOBALS['spip_pipeline'][$nomlower])
1192
+                    ) {
1193
+                        $GLOBALS['spip_pipeline'][$nomlower] = $GLOBALS['spip_pipeline'][$nom];
1194
+                        unset($GLOBALS['spip_pipeline'][$nom]);
1195
+                    }
1196
+                    $nom = $nomlower;
1197
+                    // une action vide est une declaration qui ne doit pas etre compilee !
1198
+                    if (!isset($GLOBALS['spip_pipeline'][$nom])) { // creer le pipeline eventuel
1199
+                    $GLOBALS['spip_pipeline'][$nom] = '';
1200
+                    }
1201
+                    if ($action) {
1202
+                        if (strpos($GLOBALS['spip_pipeline'][$nom], (string) "|$prefix$action") === false) {
1203
+                            $GLOBALS['spip_pipeline'][$nom] = preg_replace(
1204
+                                ',(\|\||$),',
1205
+                                "|$prefix$action\\1",
1206
+                                $GLOBALS['spip_pipeline'][$nom],
1207
+                                1
1208
+                            );
1209
+                        }
1210
+                        if (isset($pipe['inclure'])) {
1211
+                            $GLOBALS['spip_matrice']["$prefix$action"] =
1212
+                                "$root_dir_type:$plug/" . $pipe['inclure'];
1213
+                        }
1214
+                    }
1215
+                }
1216
+            }
1217
+            if (isset($info['genie']) and is_countable($info['genie']) ? count($info['genie']) : 0) {
1218
+                if (!isset($prepend_code['taches_generales_cron'])) {
1219
+                    $prepend_code['taches_generales_cron'] = '';
1220
+                }
1221
+                foreach ($info['genie'] as $genie) {
1222
+                    $nom = $prefix . $genie['nom'];
1223
+                    $periode = max(60, intval($genie['periode']));
1224
+                    if (charger_fonction($nom, 'genie', true)) {
1225
+                        $prepend_code['taches_generales_cron'] .= "\$val['$nom'] = $periode;\n";
1226
+                    } else {
1227
+                        spip_log("Fonction genie_$nom introuvable", _LOG_ERREUR);
1228
+                    }
1229
+                }
1230
+            }
1231
+            if (isset($info['style']) and is_countable($info['style']) ? count($info['style']) : 0) {
1232
+                if (!isset($prepend_code['insert_head_css'])) {
1233
+                    $prepend_code['insert_head_css'] = '';
1234
+                }
1235
+                if (!isset($prepend_code['header_prive_css'])) {
1236
+                    $prepend_code['header_prive_css'] = '';
1237
+                }
1238
+                foreach ($info['style'] as $style) {
1239
+                    if (isset($style['path']) and $style['path']) {
1240
+                        $code = "if (\$f=timestamp(direction_css(find_in_path('" . addslashes($style['path']) . "')))) ";
1241
+                    } else {
1242
+                        $code = "if (\$f='" . addslashes($style['url']) . "') ";
1243
+                    }
1244
+                    $code .= "\$val .= '<link rel=\"stylesheet\" href=\"'.\$f.'\" type=\"text/css\"";
1245
+                    if (isset($style['media']) and strlen($style['media'])) {
1246
+                        $code .= ' media="' . addslashes($style['media']) . '"';
1247
+                    }
1248
+                    $code .= "/>';\n";
1249
+                    if ($style['type'] != 'prive') {
1250
+                        $prepend_code['insert_head_css'] .= $code;
1251
+                    }
1252
+                    if ($style['type'] != 'public') {
1253
+                        $prepend_code['header_prive_css'] .= $code;
1254
+                    }
1255
+                }
1256
+            }
1257
+            if (!isset($prepend_code['insert_head'])) {
1258
+                $prepend_code['insert_head'] = '';
1259
+            }
1260
+            if (!isset($prepend_code['header_prive'])) {
1261
+                $prepend_code['header_prive'] = '';
1262
+            }
1263
+            if (isset($info['script']) and is_countable($info['script']) ? count($info['script']) : 0) {
1264
+                foreach ($info['script'] as $script) {
1265
+                    if (isset($script['path']) and $script['path']) {
1266
+                        $code = "if (\$f=timestamp(find_in_path('" . addslashes($script['path']) . "'))) ";
1267
+                    } else {
1268
+                        $code = "if (\$f='" . addslashes($script['url']) . "') ";
1269
+                    }
1270
+                    $code .= "\$val .= '<script src=\"'.\$f.'\" type=\"text/javascript\"></script>';\n";
1271
+                    if ($script['type'] != 'prive') {
1272
+                        $prepend_code['insert_head'] .= $code;
1273
+                    }
1274
+                    if ($script['type'] != 'public') {
1275
+                        $prepend_code['header_prive'] .= $code;
1276
+                    }
1277
+                }
1278
+            }
1279
+        }
1280
+    }
1281
+
1282
+    $prepend_code['insert_head'] =
1283
+        "include_once_check(_DIR_RESTREINT . 'inc/pipelines.php');\n"
1284
+        . "\$val = minipipe('f_jQuery', \$val);\n"
1285
+        . $prepend_code['insert_head'];
1286
+    $prepend_code['header_prive'] =
1287
+        "include_once_check(_DIR_RESTREINT . 'inc/pipelines_ecrire.php');\n"
1288
+        . "\$val = minipipe('f_jQuery_prive', \$val);\n"
1289
+        . $prepend_code['header_prive'];
1290
+
1291
+    // on ajoute les pipe qui ont ete recenses manquants
1292
+    foreach ($liste_pipe_manquants as $add_pipe) {
1293
+        if (!isset($GLOBALS['spip_pipeline'][$add_pipe])) {
1294
+            $GLOBALS['spip_pipeline'][$add_pipe] = '';
1295
+        }
1296
+    }
1297
+
1298
+    return $prepend_code;
1299 1299
 }
1300 1300
 
1301 1301
 /**
@@ -1322,62 +1322,62 @@  discard block
 block discarded – undo
1322 1322
 **/
1323 1323
 function pipeline_precompile($prepend_code = []) {
1324 1324
 
1325
-	$all_pipes = $all_pipes_end = '';
1326
-	if (!empty($GLOBALS['spip_pipeline']['all'])) {
1327
-		$a = explode('||', $GLOBALS['spip_pipeline']['all'], 2);
1328
-		unset($GLOBALS['spip_pipeline']['all']);
1329
-		$all_pipes = trim(array_shift($a));
1330
-		if ($all_pipes) {
1331
-			$all_pipes = '|' . ltrim($all_pipes, '|');
1332
-		}
1333
-		if (count($a)) {
1334
-			$all_pipes_end = '||' . array_shift($a);
1335
-		}
1336
-	}
1337
-	$content = '';
1338
-	foreach ($GLOBALS['spip_pipeline'] as $action => $pipeline) {
1339
-		$s_inc = '';
1340
-		$s_call = '';
1341
-		if ($all_pipes) {
1342
-			$pipeline = preg_replace(',(\|\||$),', "$all_pipes\\1", $pipeline, 1);
1343
-		}
1344
-		if ($all_pipes_end) {
1345
-			$pipeline .= $all_pipes_end;
1346
-		}
1347
-		$pipe = array_filter(explode('|', $pipeline));
1348
-		// Eclater le pipeline en filtres et appliquer chaque filtre
1349
-		foreach ($pipe as $fonc) {
1350
-			$fonc = trim($fonc);
1351
-			$s_call .= '$val = minipipe(\'' . $fonc . '\', $val);' . "\n";
1352
-			if (isset($GLOBALS['spip_matrice'][$fonc])) {
1353
-				$file = $GLOBALS['spip_matrice'][$fonc];
1354
-				$file = "'$file'";
1355
-				// si un _DIR_XXX: est dans la chaine, on extrait la constante
1356
-				if (preg_match(',(_(DIR|ROOT)_[A-Z_]+):,Ums', $file, $regs)) {
1357
-					$dir = $regs[1];
1358
-					$root_dir = str_replace('_DIR_', '_ROOT_', $dir);
1359
-					if (defined($root_dir)) {
1360
-						$dir = $root_dir;
1361
-					}
1362
-					$file = str_replace($regs[0], "'." . $dir . ".'", $file);
1363
-					$file = str_replace("''.", '', $file);
1364
-					$file = str_replace(constant($dir), '', $file);
1365
-				}
1366
-				$s_inc .= "include_once_check($file);\n";
1367
-			}
1368
-		}
1369
-		if (strlen($s_inc)) {
1370
-			$s_inc = "static \$inc=null;\nif (!\$inc){\n$s_inc\$inc=true;\n}\n";
1371
-		}
1372
-		$content .= "// Pipeline $action \n"
1373
-			. "function execute_pipeline_$action(&\$val){\n"
1374
-			. $s_inc
1375
-			. ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action]) . "\n" : '')
1376
-			. $s_call
1377
-			. "return \$val;\n}\n";
1378
-	}
1379
-	ecrire_fichier_php(_CACHE_PIPELINES, $content);
1380
-	clear_path_cache();
1325
+    $all_pipes = $all_pipes_end = '';
1326
+    if (!empty($GLOBALS['spip_pipeline']['all'])) {
1327
+        $a = explode('||', $GLOBALS['spip_pipeline']['all'], 2);
1328
+        unset($GLOBALS['spip_pipeline']['all']);
1329
+        $all_pipes = trim(array_shift($a));
1330
+        if ($all_pipes) {
1331
+            $all_pipes = '|' . ltrim($all_pipes, '|');
1332
+        }
1333
+        if (count($a)) {
1334
+            $all_pipes_end = '||' . array_shift($a);
1335
+        }
1336
+    }
1337
+    $content = '';
1338
+    foreach ($GLOBALS['spip_pipeline'] as $action => $pipeline) {
1339
+        $s_inc = '';
1340
+        $s_call = '';
1341
+        if ($all_pipes) {
1342
+            $pipeline = preg_replace(',(\|\||$),', "$all_pipes\\1", $pipeline, 1);
1343
+        }
1344
+        if ($all_pipes_end) {
1345
+            $pipeline .= $all_pipes_end;
1346
+        }
1347
+        $pipe = array_filter(explode('|', $pipeline));
1348
+        // Eclater le pipeline en filtres et appliquer chaque filtre
1349
+        foreach ($pipe as $fonc) {
1350
+            $fonc = trim($fonc);
1351
+            $s_call .= '$val = minipipe(\'' . $fonc . '\', $val);' . "\n";
1352
+            if (isset($GLOBALS['spip_matrice'][$fonc])) {
1353
+                $file = $GLOBALS['spip_matrice'][$fonc];
1354
+                $file = "'$file'";
1355
+                // si un _DIR_XXX: est dans la chaine, on extrait la constante
1356
+                if (preg_match(',(_(DIR|ROOT)_[A-Z_]+):,Ums', $file, $regs)) {
1357
+                    $dir = $regs[1];
1358
+                    $root_dir = str_replace('_DIR_', '_ROOT_', $dir);
1359
+                    if (defined($root_dir)) {
1360
+                        $dir = $root_dir;
1361
+                    }
1362
+                    $file = str_replace($regs[0], "'." . $dir . ".'", $file);
1363
+                    $file = str_replace("''.", '', $file);
1364
+                    $file = str_replace(constant($dir), '', $file);
1365
+                }
1366
+                $s_inc .= "include_once_check($file);\n";
1367
+            }
1368
+        }
1369
+        if (strlen($s_inc)) {
1370
+            $s_inc = "static \$inc=null;\nif (!\$inc){\n$s_inc\$inc=true;\n}\n";
1371
+        }
1372
+        $content .= "// Pipeline $action \n"
1373
+            . "function execute_pipeline_$action(&\$val){\n"
1374
+            . $s_inc
1375
+            . ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action]) . "\n" : '')
1376
+            . $s_call
1377
+            . "return \$val;\n}\n";
1378
+    }
1379
+    ecrire_fichier_php(_CACHE_PIPELINES, $content);
1380
+    clear_path_cache();
1381 1381
 }
1382 1382
 
1383 1383
 
@@ -1390,12 +1390,12 @@  discard block
 block discarded – undo
1390 1390
  *     true si le plugin est actif, false sinon
1391 1391
 **/
1392 1392
 function plugin_est_installe($plug_path) {
1393
-	$plugin_installes = isset($GLOBALS['meta']['plugin_installes']) ? unserialize($GLOBALS['meta']['plugin_installes']) : [];
1394
-	if (!$plugin_installes) {
1395
-		return false;
1396
-	}
1393
+    $plugin_installes = isset($GLOBALS['meta']['plugin_installes']) ? unserialize($GLOBALS['meta']['plugin_installes']) : [];
1394
+    if (!$plugin_installes) {
1395
+        return false;
1396
+    }
1397 1397
 
1398
-	return in_array($plug_path, $plugin_installes);
1398
+    return in_array($plug_path, $plugin_installes);
1399 1399
 }
1400 1400
 
1401 1401
 
@@ -1408,46 +1408,46 @@  discard block
 block discarded – undo
1408 1408
  * @uses plugins_installer_dist()
1409 1409
  **/
1410 1410
 function plugin_installes_meta() {
1411
-	if (isset($GLOBALS['fichier_php_compile_recent'])) {
1412
-		// attendre eventuellement l'invalidation du cache opcode
1413
-		spip_attend_invalidation_opcode_cache($GLOBALS['fichier_php_compile_recent']);
1414
-	}
1415
-
1416
-	$installer_plugins = charger_fonction('installer', 'plugins');
1417
-	$meta_plug_installes = [];
1418
-	foreach (unserialize($GLOBALS['meta']['plugin']) as $prefix => $resume) {
1419
-		if ($plug = $resume['dir']) {
1420
-			$infos = $installer_plugins($plug, 'install', $resume['dir_type']);
1421
-			if ($infos) {
1422
-				if (!is_array($infos) or $infos['install_test'][0]) {
1423
-					$meta_plug_installes[] = $plug;
1424
-				}
1425
-				if (is_array($infos)) {
1426
-					[$ok, $trace] = $infos['install_test'];
1427
-					$titre = _T('plugin_titre_installation', ['plugin' => typo($infos['nom'])]);
1428
-					$result = ($ok ? ((isset($infos['upgrade']) && $infos['upgrade']) ? _T('plugin_info_upgrade_ok') : _T('plugin_info_install_ok')) : _T('avis_operation_echec'));
1429
-					if (_IS_CLI) {
1430
-						include_spip('inc/filtres');
1431
-						$trace = ltrim(textebrut($trace) . "\n" . $result);
1432
-						$trace = '    ' . str_replace("\n", "\n    ", $trace);
1433
-						echo "\n" . ($ok ? 'OK  ' : '/!\ ') . textebrut($titre) . "\n",
1434
-						  $trace,
1435
-						  "\n";
1436
-					}
1437
-					else {
1438
-						include_spip('inc/filtres_boites');
1439
-						echo "<div class='install-plugins svp_retour'>"
1440
-							. boite_ouvrir($titre, ($ok ? 'success' : 'error'))
1441
-							. $trace
1442
-							. "<div class='result'>$result</div>"
1443
-							. boite_fermer()
1444
-							. '</div>';
1445
-					}
1446
-				}
1447
-			}
1448
-		}
1449
-	}
1450
-	ecrire_meta('plugin_installes', serialize($meta_plug_installes), 'non');
1411
+    if (isset($GLOBALS['fichier_php_compile_recent'])) {
1412
+        // attendre eventuellement l'invalidation du cache opcode
1413
+        spip_attend_invalidation_opcode_cache($GLOBALS['fichier_php_compile_recent']);
1414
+    }
1415
+
1416
+    $installer_plugins = charger_fonction('installer', 'plugins');
1417
+    $meta_plug_installes = [];
1418
+    foreach (unserialize($GLOBALS['meta']['plugin']) as $prefix => $resume) {
1419
+        if ($plug = $resume['dir']) {
1420
+            $infos = $installer_plugins($plug, 'install', $resume['dir_type']);
1421
+            if ($infos) {
1422
+                if (!is_array($infos) or $infos['install_test'][0]) {
1423
+                    $meta_plug_installes[] = $plug;
1424
+                }
1425
+                if (is_array($infos)) {
1426
+                    [$ok, $trace] = $infos['install_test'];
1427
+                    $titre = _T('plugin_titre_installation', ['plugin' => typo($infos['nom'])]);
1428
+                    $result = ($ok ? ((isset($infos['upgrade']) && $infos['upgrade']) ? _T('plugin_info_upgrade_ok') : _T('plugin_info_install_ok')) : _T('avis_operation_echec'));
1429
+                    if (_IS_CLI) {
1430
+                        include_spip('inc/filtres');
1431
+                        $trace = ltrim(textebrut($trace) . "\n" . $result);
1432
+                        $trace = '    ' . str_replace("\n", "\n    ", $trace);
1433
+                        echo "\n" . ($ok ? 'OK  ' : '/!\ ') . textebrut($titre) . "\n",
1434
+                            $trace,
1435
+                            "\n";
1436
+                    }
1437
+                    else {
1438
+                        include_spip('inc/filtres_boites');
1439
+                        echo "<div class='install-plugins svp_retour'>"
1440
+                            . boite_ouvrir($titre, ($ok ? 'success' : 'error'))
1441
+                            . $trace
1442
+                            . "<div class='result'>$result</div>"
1443
+                            . boite_fermer()
1444
+                            . '</div>';
1445
+                    }
1446
+                }
1447
+            }
1448
+        }
1449
+    }
1450
+    ecrire_meta('plugin_installes', serialize($meta_plug_installes), 'non');
1451 1451
 }
1452 1452
 
1453 1453
 /**
@@ -1461,29 +1461,29 @@  discard block
 block discarded – undo
1461 1461
  *     Commentaire : code écrit en tout début de fichier, après la balise PHP ouvrante
1462 1462
 **/
1463 1463
 function ecrire_fichier_php($nom, $contenu, $comment = '') {
1464
-	if (!isset($GLOBALS['fichier_php_compile_recent'])) {
1465
-		$GLOBALS['fichier_php_compile_recent'] = 0;
1466
-	}
1467
-
1468
-	$contenu = '<' . '?php' . "\n" . $comment . "\nif (defined('_ECRIRE_INC_VERSION')) {\n" . $contenu . "}\n?" . '>';
1469
-	// si un fichier existe deja on verifie que son contenu change avant de l'ecraser
1470
-	// si pas de modif on ne touche pas au fichier initial
1471
-	if (file_exists($nom)) {
1472
-		if (substr($nom, -4) == '.php') {
1473
-			$fichier_tmp = substr($nom, 0, -4) . '.tmp.php';
1474
-		}
1475
-		else {
1476
-			$fichier_tmp = $nom . '.tmp';
1477
-		}
1478
-		file_put_contents($fichier_tmp, $contenu);
1479
-		if (md5_file($nom) == md5_file($fichier_tmp)) {
1480
-			$GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom));
1481
-			@unlink($fichier_tmp);
1482
-			return;
1483
-		}
1484
-		@unlink($fichier_tmp);
1485
-	}
1486
-	ecrire_fichier($nom, $contenu);
1487
-	$GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom));
1488
-	spip_clear_opcode_cache(realpath($nom));
1464
+    if (!isset($GLOBALS['fichier_php_compile_recent'])) {
1465
+        $GLOBALS['fichier_php_compile_recent'] = 0;
1466
+    }
1467
+
1468
+    $contenu = '<' . '?php' . "\n" . $comment . "\nif (defined('_ECRIRE_INC_VERSION')) {\n" . $contenu . "}\n?" . '>';
1469
+    // si un fichier existe deja on verifie que son contenu change avant de l'ecraser
1470
+    // si pas de modif on ne touche pas au fichier initial
1471
+    if (file_exists($nom)) {
1472
+        if (substr($nom, -4) == '.php') {
1473
+            $fichier_tmp = substr($nom, 0, -4) . '.tmp.php';
1474
+        }
1475
+        else {
1476
+            $fichier_tmp = $nom . '.tmp';
1477
+        }
1478
+        file_put_contents($fichier_tmp, $contenu);
1479
+        if (md5_file($nom) == md5_file($fichier_tmp)) {
1480
+            $GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom));
1481
+            @unlink($fichier_tmp);
1482
+            return;
1483
+        }
1484
+        @unlink($fichier_tmp);
1485
+    }
1486
+    ecrire_fichier($nom, $contenu);
1487
+    $GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom));
1488
+    spip_clear_opcode_cache(realpath($nom));
1489 1489
 }
Please login to merge, or discard this patch.
ecrire/inc/filtres_mime.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 	static $t1 = ['&', '<', '>'];
121 121
 	static $t2 = ['&amp;', '&lt;', '&gt;'];
122 122
 
123
-	return '<pre>' . str_replace($t1, $t2, $t) . '</pre>';
123
+	return '<pre>'.str_replace($t1, $t2, $t).'</pre>';
124 124
 }
125 125
 
126 126
 /**
@@ -140,12 +140,12 @@  discard block
 block discarded – undo
140 140
 	foreach ($lignes as &$l) {
141 141
 		$l = join('|', $l);
142 142
 	}
143
-	$corps = join("\n", $lignes) . "\n";
144
-	$corps = $caption .
145
-		"\n|{{" .
146
-		join('}}|{{', $entete) .
147
-		'}}|' .
148
-		"\n|" .
143
+	$corps = join("\n", $lignes)."\n";
144
+	$corps = $caption.
145
+		"\n|{{".
146
+		join('}}|{{', $entete).
147
+		'}}|'.
148
+		"\n|".
149 149
 		str_replace("\n", "|\n|", $corps);
150 150
 	include_spip('inc/texte');
151 151
 
@@ -187,9 +187,9 @@  discard block
 block discarded – undo
187 187
 		}
188 188
 	}
189 189
 	// Pourquoi SafeHtml transforme-t-il en texte les scripts dans Body ?
190
-	$t = safehtml(preg_replace(',<script' . '.*?</script>,is', '', $t));
190
+	$t = safehtml(preg_replace(',<script'.'.*?</script>,is', '', $t));
191 191
 
192
-	return (!$style ? '' : "\n<style>" . $style . '</style>') . $t;
192
+	return (!$style ? '' : "\n<style>".$style.'</style>').$t;
193 193
 }
194 194
 
195 195
 /**
Please login to merge, or discard this patch.
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
  **/
23 23
 
24 24
 if (!defined('_ECRIRE_INC_VERSION')) {
25
-	return;
25
+    return;
26 26
 }
27 27
 include_spip('inc/filtres');
28 28
 
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
  * @return string Rien.
40 40
  **/
41 41
 function filtre_image_dist($t) {
42
-	return '';
42
+    return '';
43 43
 }
44 44
 
45 45
 /**
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
  * @return string Rien.
53 53
  **/
54 54
 function filtre_audio_dist($t) {
55
-	return '';
55
+    return '';
56 56
 }
57 57
 
58 58
 /**
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
  * @return string Rien.
66 66
  **/
67 67
 function filtre_video_dist($t) {
68
-	return '';
68
+    return '';
69 69
 }
70 70
 
71 71
 /**
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
  * @return string Rien.
79 79
  **/
80 80
 function filtre_application_dist($t) {
81
-	return '';
81
+    return '';
82 82
 }
83 83
 
84 84
 /**
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
  * @return string Rien.
92 92
  **/
93 93
 function filtre_message_dist($t) {
94
-	return '';
94
+    return '';
95 95
 }
96 96
 
97 97
 /**
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
  * @return string Rien.
105 105
  **/
106 106
 function filtre_multipart_dist($t) {
107
-	return '';
107
+    return '';
108 108
 }
109 109
 
110 110
 /**
@@ -117,10 +117,10 @@  discard block
 block discarded – undo
117 117
  * @return string Contenu échappé.
118 118
  **/
119 119
 function filtre_text_dist($t) {
120
-	static $t1 = ['&', '<', '>'];
121
-	static $t2 = ['&amp;', '&lt;', '&gt;'];
120
+    static $t1 = ['&', '<', '>'];
121
+    static $t2 = ['&amp;', '&lt;', '&gt;'];
122 122
 
123
-	return '<pre>' . str_replace($t1, $t2, $t) . '</pre>';
123
+    return '<pre>' . str_replace($t1, $t2, $t) . '</pre>';
124 124
 }
125 125
 
126 126
 /**
@@ -135,21 +135,21 @@  discard block
 block discarded – undo
135 135
  *     Tableau (formaté en SPIP)
136 136
  **/
137 137
 function filtre_text_csv_dist($t) {
138
-	include_spip('inc/csv');
139
-	[$entete, $lignes, $caption] = analyse_csv($t);
140
-	foreach ($lignes as &$l) {
141
-		$l = join('|', $l);
142
-	}
143
-	$corps = join("\n", $lignes) . "\n";
144
-	$corps = $caption .
145
-		"\n|{{" .
146
-		join('}}|{{', $entete) .
147
-		'}}|' .
148
-		"\n|" .
149
-		str_replace("\n", "|\n|", $corps);
150
-	include_spip('inc/texte');
151
-
152
-	return propre($corps);
138
+    include_spip('inc/csv');
139
+    [$entete, $lignes, $caption] = analyse_csv($t);
140
+    foreach ($lignes as &$l) {
141
+        $l = join('|', $l);
142
+    }
143
+    $corps = join("\n", $lignes) . "\n";
144
+    $corps = $caption .
145
+        "\n|{{" .
146
+        join('}}|{{', $entete) .
147
+        '}}|' .
148
+        "\n|" .
149
+        str_replace("\n", "|\n|", $corps);
150
+    include_spip('inc/texte');
151
+
152
+    return propre($corps);
153 153
 }
154 154
 
155 155
 /**
@@ -163,33 +163,33 @@  discard block
 block discarded – undo
163 163
  * @return string Code html sécurisé ou texte échappé
164 164
  **/
165 165
 function filtre_text_html_dist($t) {
166
-	if (!preg_match(',^(.*?)<body[^>]*>(.*)</body>,is', $t, $r)) {
167
-		return appliquer_filtre($t, 'text/plain');
168
-	}
169
-
170
-	[, $h, $t] = $r;
171
-
172
-	$style = '';
173
-	// recuperer les styles internes
174
-	if (preg_match_all(',<style>(.*?)</style>,is', $h, $r, PREG_PATTERN_ORDER)) {
175
-		$style = join("\n", $r[1]);
176
-	}
177
-	// ... et externes
178
-
179
-	include_spip('inc/distant');
180
-	if (preg_match_all(',<link[^>]+type=.text/css[^>]*>,is', $h, $r, PREG_PATTERN_ORDER)) {
181
-		foreach ($r[0] as $l) {
182
-			preg_match("/href='([^']*)'/", str_replace('"', "'", $l), $m);
183
-			$page = recuperer_url($m[1]);
184
-			$page = $page['page'] ?? '';
185
-			$style .= "\n/* $l */\n"
186
-				. str_replace('<', '', $page);
187
-		}
188
-	}
189
-	// Pourquoi SafeHtml transforme-t-il en texte les scripts dans Body ?
190
-	$t = safehtml(preg_replace(',<script' . '.*?</script>,is', '', $t));
191
-
192
-	return (!$style ? '' : "\n<style>" . $style . '</style>') . $t;
166
+    if (!preg_match(',^(.*?)<body[^>]*>(.*)</body>,is', $t, $r)) {
167
+        return appliquer_filtre($t, 'text/plain');
168
+    }
169
+
170
+    [, $h, $t] = $r;
171
+
172
+    $style = '';
173
+    // recuperer les styles internes
174
+    if (preg_match_all(',<style>(.*?)</style>,is', $h, $r, PREG_PATTERN_ORDER)) {
175
+        $style = join("\n", $r[1]);
176
+    }
177
+    // ... et externes
178
+
179
+    include_spip('inc/distant');
180
+    if (preg_match_all(',<link[^>]+type=.text/css[^>]*>,is', $h, $r, PREG_PATTERN_ORDER)) {
181
+        foreach ($r[0] as $l) {
182
+            preg_match("/href='([^']*)'/", str_replace('"', "'", $l), $m);
183
+            $page = recuperer_url($m[1]);
184
+            $page = $page['page'] ?? '';
185
+            $style .= "\n/* $l */\n"
186
+                . str_replace('<', '', $page);
187
+        }
188
+    }
189
+    // Pourquoi SafeHtml transforme-t-il en texte les scripts dans Body ?
190
+    $t = safehtml(preg_replace(',<script' . '.*?</script>,is', '', $t));
191
+
192
+    return (!$style ? '' : "\n<style>" . $style . '</style>') . $t;
193 193
 }
194 194
 
195 195
 /**
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
  * @return string Code HTML des balises `<param>`
203 203
  **/
204 204
 function filtre_audio_x_pn_realaudio($id) {
205
-	return "
205
+    return "
206 206
 	<param name='controls' value='PositionSlider' />
207 207
 	<param name='controls' value='ImageWindow' />
208 208
 	<param name='controls' value='PlayButton' />
Please login to merge, or discard this patch.
ecrire/inc/definir_menus_favoris.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -20,21 +20,21 @@
 block discarded – undo
20 20
  * Retourne la liste des menus favoris par défaut ainsi que leur rang
21 21
  */
22 22
 function inc_definir_menus_favoris_dist() {
23
-	$liste = [
23
+    $liste = [
24 24
 
25
-		// Menu Édition,
26
-		'auteurs' => 1,
27
-		'rubriques' => 2,
28
-		'articles' => 3,
25
+        // Menu Édition,
26
+        'auteurs' => 1,
27
+        'rubriques' => 2,
28
+        'articles' => 3,
29 29
 
30
-		// Menu Maintenance
31
-		'admin_vider' => 1,
30
+        // Menu Maintenance
31
+        'admin_vider' => 1,
32 32
 
33
-		// Menu Configurations
34
-		'configurer_identite' => 1,
35
-		'admin_plugin' => 2,
33
+        // Menu Configurations
34
+        'configurer_identite' => 1,
35
+        'admin_plugin' => 2,
36 36
 
37
-	];
37
+    ];
38 38
 
39
-	return $liste;
39
+    return $liste;
40 40
 }
Please login to merge, or discard this patch.
ecrire/inc/filtres_dates.php 3 patches
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 function extraire_date($texte) {
39 39
 	// format = 2001-08
40 40
 	if (preg_match(',([1-2][0-9]{3})[^0-9]*(1[0-2]|0?[1-9]),', $texte, $regs)) {
41
-		return $regs[1] . '-' . sprintf('%02d', $regs[2]) . '-01';
41
+		return $regs[1].'-'.sprintf('%02d', $regs[2]).'-01';
42 42
 	}
43 43
 }
44 44
 
@@ -68,11 +68,11 @@  discard block
 block discarded – undo
68 68
 		}
69 69
 		if (preg_match('#^([12][0-9]{3})([-/]00)?( [-0-9:]+)?$#', $date, $regs)) {
70 70
 			$regs = array_pad($regs, 4, null); // eviter notice php
71
-			$date = $regs[1] . '-00-00' . $regs[3];
71
+			$date = $regs[1].'-00-00'.$regs[3];
72 72
 		} else {
73 73
 			if (preg_match('#^([12][0-9]{3}[-/][01]?[0-9])([-/]00)?( [-0-9:]+)?$#', $date, $regs)) {
74 74
 				$regs = array_pad($regs, 4, null); // eviter notice php
75
-				$date = preg_replace('@/@', '-', $regs[1]) . '-00' . $regs[3];
75
+				$date = preg_replace('@/@', '-', $regs[1]).'-00'.$regs[3];
76 76
 			} else {
77 77
 				$date = date('Y-m-d H:i:s', strtotime($date));
78 78
 			}
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 function vider_date($letexte, $verif_format_date = false) {
99 99
 	if (
100 100
 		!$verif_format_date
101
-		or (in_array(strlen($letexte), [10,19]) and
101
+		or (in_array(strlen($letexte), [10, 19]) and
102 102
 			  preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}(\s[0-9]{2}:[0-9]{2}:[0-9]{2})?$/', $letexte))
103 103
 	) {
104 104
 		if (strncmp('0000-00-00', $letexte, 10) == 0) {
@@ -381,17 +381,17 @@  discard block
 block discarded – undo
381 381
 	if ($decal > 3600 * 24 * 30) {
382 382
 		$mois = floor($decal / (3600 * 24 * 30));
383 383
 		if ($mois < 2) {
384
-			$delai = "$mois " . _T('date_un_mois');
384
+			$delai = "$mois "._T('date_un_mois');
385 385
 		} else {
386
-			$delai = "$mois " . _T('date_mois');
386
+			$delai = "$mois "._T('date_mois');
387 387
 		}
388 388
 	} else {
389 389
 		if ($decal > 3600 * 24 * 7) {
390 390
 			$semaines = floor($decal / (3600 * 24 * 7));
391 391
 			if ($semaines < 2) {
392
-				$delai = "$semaines " . _T('date_une_semaine');
392
+				$delai = "$semaines "._T('date_une_semaine');
393 393
 			} else {
394
-				$delai = "$semaines " . _T('date_semaines');
394
+				$delai = "$semaines "._T('date_semaines');
395 395
 			}
396 396
 		} else {
397 397
 			if ($decal > 3600 * 24) {
@@ -399,30 +399,30 @@  discard block
 block discarded – undo
399 399
 				if ($jours < 2) {
400 400
 					return $il_y_a == 'date_dans' ? _T('date_demain') : _T('date_hier');
401 401
 				} else {
402
-					$delai = "$jours " . _T('date_jours');
402
+					$delai = "$jours "._T('date_jours');
403 403
 				}
404 404
 			} else {
405 405
 				if ($decal >= 3600) {
406 406
 					$heures = floor($decal / 3600);
407 407
 					if ($heures < 2) {
408
-						$delai = "$heures " . _T('date_une_heure');
408
+						$delai = "$heures "._T('date_une_heure');
409 409
 					} else {
410
-						$delai = "$heures " . _T('date_heures');
410
+						$delai = "$heures "._T('date_heures');
411 411
 					}
412 412
 				} else {
413 413
 					if ($decal >= 60) {
414 414
 						$minutes = floor($decal / 60);
415 415
 						if ($minutes < 2) {
416
-							$delai = "$minutes " . _T('date_une_minute');
416
+							$delai = "$minutes "._T('date_une_minute');
417 417
 						} else {
418
-							$delai = "$minutes " . _T('date_minutes');
418
+							$delai = "$minutes "._T('date_minutes');
419 419
 						}
420 420
 					} else {
421 421
 						$secondes = ceil($decal);
422 422
 						if ($secondes < 2) {
423
-							$delai = "$secondes " . _T('date_une_seconde');
423
+							$delai = "$secondes "._T('date_une_seconde');
424 424
 						} else {
425
-							$delai = "$secondes " . _T('date_secondes');
425
+							$delai = "$secondes "._T('date_secondes');
426 426
 						}
427 427
 					}
428 428
 				}
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
 		$njour = 0;
518 518
 	} else {
519 519
 		$njour = intval($jour);
520
-		if ($jourth = _T('date_jnum' . $jour)) {
520
+		if ($jourth = _T('date_jnum'.$jour)) {
521 521
 			$jour = $jourth;
522 522
 		}
523 523
 	}
@@ -525,10 +525,10 @@  discard block
 block discarded – undo
525 525
 	$mois = intval($mois);
526 526
 	if ($mois > 0 and $mois < 13) {
527 527
 		/* Traiter le cas "abbr" pour les noms de mois */
528
-		$param = ((isset($options['param']) and $options['param'] === 'abbr') ? '_' . $options['param'] : '');
529
-		$nommois = _T('date_mois_' . $mois . $param);
528
+		$param = ((isset($options['param']) and $options['param'] === 'abbr') ? '_'.$options['param'] : '');
529
+		$nommois = _T('date_mois_'.$mois.$param);
530 530
 		if ($jour) {
531
-			$jourmois = _T('date_de_mois_' . $mois, ['j' => $jour, 'nommois' => $nommois]);
531
+			$jourmois = _T('date_de_mois_'.$mois, ['j' => $jour, 'nommois' => $nommois]);
532 532
 		} else {
533 533
 			$jourmois = $nommois;
534 534
 		}
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
 	}
539 539
 
540 540
 	if ($annee < 0) {
541
-		$annee = -$annee . ' ' . _T('date_avant_jc');
541
+		$annee = -$annee.' '._T('date_avant_jc');
542 542
 		$avjc = true;
543 543
 	} else {
544 544
 		$avjc = false;
@@ -564,11 +564,11 @@  discard block
 block discarded – undo
564 564
 				}
565 565
 			}
566 566
 			if ($vue == 'saison') {
567
-				return $saison ? _T('date_saison_' . $saison) : '';
567
+				return $saison ? _T('date_saison_'.$saison) : '';
568 568
 			} else {
569 569
 				return $saison ? trim(_T(
570 570
 					'date_fmt_saison_annee',
571
-					['saison' => _T('date_saison_' . $saison), 'annee' => $annee]
571
+					['saison' => _T('date_saison_'.$saison), 'annee' => $annee]
572 572
 				)) : '';
573 573
 			}
574 574
 
@@ -645,9 +645,9 @@  discard block
 block discarded – undo
645 645
 			}
646 646
 			$nom = mktime(1, 1, 1, $mois, $njour, $annee);
647 647
 			$nom = 1 + date('w', $nom);
648
-			$param = ((isset($options['param']) and $options['param']) ? '_' . $options['param'] : '');
648
+			$param = ((isset($options['param']) and $options['param']) ? '_'.$options['param'] : '');
649 649
 
650
-			return _T('date_jour_' . $nom . $param);
650
+			return _T('date_jour_'.$nom.$param);
651 651
 
652 652
 		case 'mois_annee':
653 653
 			if ($avjc) {
@@ -1042,8 +1042,8 @@  discard block
 block discarded – undo
1042 1042
 
1043 1043
 	$dtstart = $dtend = $dtabbr = '';
1044 1044
 	if (strpos($forme, 'hcal') !== false) {
1045
-		$dtstart = "<abbr class='dtstart' title='" . date_iso($date_debut) . "'>";
1046
-		$dtend = "<abbr class='dtend' title='" . date_iso($date_fin) . "'>";
1045
+		$dtstart = "<abbr class='dtstart' title='".date_iso($date_debut)."'>";
1046
+		$dtend = "<abbr class='dtend' title='".date_iso($date_fin)."'>";
1047 1047
 		$dtabbr = '</abbr>';
1048 1048
 	}
1049 1049
 
@@ -1091,7 +1091,7 @@  discard block
 block discarded – undo
1091 1091
 			}
1092 1092
 		} else {
1093 1093
 			if ($dtabbr && $dtstart) {
1094
-				$s = $dtstart . spip_ucfirst($s) . $dtabbr;
1094
+				$s = $dtstart.spip_ucfirst($s).$dtabbr;
1095 1095
 			} else {
1096 1096
 				$s = spip_ucfirst($s);
1097 1097
 			}
@@ -1114,8 +1114,8 @@  discard block
 block discarded – undo
1114 1114
 				$date_debut = _T('date_fmt_jour_heure', ['jour' => $date_debut, 'heure' => $hd]);
1115 1115
 				$date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]);
1116 1116
 			}
1117
-			$date_debut = $dtstart . $date_debut . $dtabbr;
1118
-			$date_fin = $dtend . $date_fin . $dtabbr;
1117
+			$date_debut = $dtstart.$date_debut.$dtabbr;
1118
+			$date_fin = $dtend.$date_fin.$dtabbr;
1119 1119
 
1120 1120
 			$s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]);
1121 1121
 		} else {
@@ -1132,8 +1132,8 @@  discard block
 block discarded – undo
1132 1132
 				$date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]);
1133 1133
 			}
1134 1134
 
1135
-			$date_debut = $dtstart . $date_debut . $dtabbr;
1136
-			$date_fin = $dtend . $date_fin . $dtabbr;
1135
+			$date_debut = $dtstart.$date_debut.$dtabbr;
1136
+			$date_fin = $dtend.$date_fin.$dtabbr;
1137 1137
 			$s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]);
1138 1138
 		}
1139 1139
 	}
@@ -1237,7 +1237,7 @@  discard block
 block discarded – undo
1237 1237
 		$d = date('Y-m-d');
1238 1238
 	}
1239 1239
 
1240
-	return substr($d, 0, 4) . substr($d, 5, 2) . substr($d, 8, 2);
1240
+	return substr($d, 0, 4).substr($d, 5, 2).substr($d, 8, 2);
1241 1241
 }
1242 1242
 
1243 1243
 /**
@@ -1257,7 +1257,7 @@  discard block
 block discarded – undo
1257 1257
 		$d = date('Y-m-d');
1258 1258
 	}
1259 1259
 
1260
-	return substr($d, 0, 4) . substr($d, 5, 2);
1260
+	return substr($d, 0, 4).substr($d, 5, 2);
1261 1261
 }
1262 1262
 
1263 1263
 /**
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -212,8 +212,7 @@
 block discarded – undo
212 212
 function heures_minutes($numdate, $forme = '') {
213 213
 	if ($forme != 'abbr') {
214 214
 		return _T('date_fmt_heures_minutes', ['h' => heures($numdate), 'm' => minutes($numdate)]);
215
-	}
216
-	else {
215
+	} else {
217 216
 		return _T('date_fmt_heures_minutes_court', ['h' => heures($numdate), 'm' => minutes($numdate)]);
218 217
 	}
219 218
 }
Please login to merge, or discard this patch.
Indentation   +577 added lines, -577 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @package SPIP\Core\Filtres
17 17
  **/
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 
@@ -36,10 +36,10 @@  discard block
 block discarded – undo
36 36
  *    Date au format SQL tel que `2008-04-01`
37 37
  **/
38 38
 function extraire_date($texte) {
39
-	// format = 2001-08
40
-	if (preg_match(',([1-2][0-9]{3})[^0-9]*(1[0-2]|0?[1-9]),', $texte, $regs)) {
41
-		return $regs[1] . '-' . sprintf('%02d', $regs[2]) . '-01';
42
-	}
39
+    // format = 2001-08
40
+    if (preg_match(',([1-2][0-9]{3})[^0-9]*(1[0-2]|0?[1-9]),', $texte, $regs)) {
41
+        return $regs[1] . '-' . sprintf('%02d', $regs[2]) . '-01';
42
+    }
43 43
 }
44 44
 
45 45
 
@@ -61,29 +61,29 @@  discard block
 block discarded – undo
61 61
  *     - une chaîne vide si la date est considérée nulle
62 62
  **/
63 63
 function normaliser_date($date, $forcer_jour = false) {
64
-	$date = vider_date($date);
65
-	if ($date) {
66
-		if (preg_match('/^[0-9]{8,10}$/', $date)) {
67
-			$date = date('Y-m-d H:i:s', $date);
68
-		}
69
-		if (preg_match('#^([12][0-9]{3})([-/]00)?( [-0-9:]+)?$#', $date, $regs)) {
70
-			$regs = array_pad($regs, 4, null); // eviter notice php
71
-			$date = $regs[1] . '-00-00' . $regs[3];
72
-		} else {
73
-			if (preg_match('#^([12][0-9]{3}[-/][01]?[0-9])([-/]00)?( [-0-9:]+)?$#', $date, $regs)) {
74
-				$regs = array_pad($regs, 4, null); // eviter notice php
75
-				$date = preg_replace('@/@', '-', $regs[1]) . '-00' . $regs[3];
76
-			} else {
77
-				$date = date('Y-m-d H:i:s', strtotime($date));
78
-			}
79
-		}
80
-
81
-		if ($forcer_jour) {
82
-			$date = str_replace('-00', '-01', $date);
83
-		}
84
-	}
85
-
86
-	return $date;
64
+    $date = vider_date($date);
65
+    if ($date) {
66
+        if (preg_match('/^[0-9]{8,10}$/', $date)) {
67
+            $date = date('Y-m-d H:i:s', $date);
68
+        }
69
+        if (preg_match('#^([12][0-9]{3})([-/]00)?( [-0-9:]+)?$#', $date, $regs)) {
70
+            $regs = array_pad($regs, 4, null); // eviter notice php
71
+            $date = $regs[1] . '-00-00' . $regs[3];
72
+        } else {
73
+            if (preg_match('#^([12][0-9]{3}[-/][01]?[0-9])([-/]00)?( [-0-9:]+)?$#', $date, $regs)) {
74
+                $regs = array_pad($regs, 4, null); // eviter notice php
75
+                $date = preg_replace('@/@', '-', $regs[1]) . '-00' . $regs[3];
76
+            } else {
77
+                $date = date('Y-m-d H:i:s', strtotime($date));
78
+            }
79
+        }
80
+
81
+        if ($forcer_jour) {
82
+            $date = str_replace('-00', '-01', $date);
83
+        }
84
+    }
85
+
86
+    return $date;
87 87
 }
88 88
 
89 89
 /**
@@ -96,22 +96,22 @@  discard block
 block discarded – undo
96 96
  *     - Une chaine vide
97 97
  **/
98 98
 function vider_date($letexte, $verif_format_date = false) {
99
-	if (
100
-		!$verif_format_date
101
-		or (in_array(strlen($letexte), [10,19]) and
102
-			  preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}(\s[0-9]{2}:[0-9]{2}:[0-9]{2})?$/', $letexte))
103
-	) {
104
-		if (strncmp('0000-00-00', $letexte, 10) == 0) {
105
-			return '';
106
-		}
107
-		if (strncmp('0001-01-01', $letexte, 10) == 0) {
108
-			return '';
109
-		}
110
-		if (strncmp('1970-01-01', $letexte, 10) == 0) {
111
-			return '';
112
-		}  // eviter le bug GMT-1
113
-	}
114
-	return $letexte;
99
+    if (
100
+        !$verif_format_date
101
+        or (in_array(strlen($letexte), [10,19]) and
102
+              preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}(\s[0-9]{2}:[0-9]{2}:[0-9]{2})?$/', $letexte))
103
+    ) {
104
+        if (strncmp('0000-00-00', $letexte, 10) == 0) {
105
+            return '';
106
+        }
107
+        if (strncmp('0001-01-01', $letexte, 10) == 0) {
108
+            return '';
109
+        }
110
+        if (strncmp('1970-01-01', $letexte, 10) == 0) {
111
+            return '';
112
+        }  // eviter le bug GMT-1
113
+    }
114
+    return $letexte;
115 115
 }
116 116
 
117 117
 /**
@@ -127,14 +127,14 @@  discard block
 block discarded – undo
127 127
  **/
128 128
 function recup_heure($date) {
129 129
 
130
-	static $d = [0, 0, 0];
131
-	if (!preg_match('#([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $date, $r)) {
132
-		return $d;
133
-	}
130
+    static $d = [0, 0, 0];
131
+    if (!preg_match('#([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $date, $r)) {
132
+        return $d;
133
+    }
134 134
 
135
-	array_shift($r);
135
+    array_shift($r);
136 136
 
137
-	return $r;
137
+    return $r;
138 138
 }
139 139
 
140 140
 /**
@@ -148,13 +148,13 @@  discard block
 block discarded – undo
148 148
  * @return int heures, sinon 0
149 149
  **/
150 150
 function heures($numdate) {
151
-	$heures = null;
152
-	$date_array = recup_heure($numdate);
153
-	if ($date_array) {
154
-		[$heures, $minutes, $secondes] = $date_array;
155
-	}
151
+    $heures = null;
152
+    $date_array = recup_heure($numdate);
153
+    if ($date_array) {
154
+        [$heures, $minutes, $secondes] = $date_array;
155
+    }
156 156
 
157
-	return $heures;
157
+    return $heures;
158 158
 }
159 159
 
160 160
 /**
@@ -168,13 +168,13 @@  discard block
 block discarded – undo
168 168
  * @return int minutes, sinon 0
169 169
  **/
170 170
 function minutes($numdate) {
171
-	$minutes = null;
172
-	$date_array = recup_heure($numdate);
173
-	if ($date_array) {
174
-		[$heures, $minutes, $secondes] = $date_array;
175
-	}
171
+    $minutes = null;
172
+    $date_array = recup_heure($numdate);
173
+    if ($date_array) {
174
+        [$heures, $minutes, $secondes] = $date_array;
175
+    }
176 176
 
177
-	return $minutes;
177
+    return $minutes;
178 178
 }
179 179
 
180 180
 /**
@@ -188,13 +188,13 @@  discard block
 block discarded – undo
188 188
  * @return int secondes, sinon 0
189 189
  **/
190 190
 function secondes($numdate) {
191
-	$secondes = null;
192
-	$date_array = recup_heure($numdate);
193
-	if ($date_array) {
194
-		[$heures, $minutes, $secondes] = $date_array;
195
-	}
191
+    $secondes = null;
192
+    $date_array = recup_heure($numdate);
193
+    if ($date_array) {
194
+        [$heures, $minutes, $secondes] = $date_array;
195
+    }
196 196
 
197
-	return $secondes;
197
+    return $secondes;
198 198
 }
199 199
 
200 200
 /**
@@ -213,12 +213,12 @@  discard block
 block discarded – undo
213 213
  * @return string L'heure formatée dans la langue en cours.
214 214
  **/
215 215
 function heures_minutes($numdate, $forme = '') {
216
-	if ($forme != 'abbr') {
217
-		return _T('date_fmt_heures_minutes', ['h' => heures($numdate), 'm' => minutes($numdate)]);
218
-	}
219
-	else {
220
-		return _T('date_fmt_heures_minutes_court', ['h' => heures($numdate), 'm' => minutes($numdate)]);
221
-	}
216
+    if ($forme != 'abbr') {
217
+        return _T('date_fmt_heures_minutes', ['h' => heures($numdate), 'm' => minutes($numdate)]);
218
+    }
219
+    else {
220
+        return _T('date_fmt_heures_minutes_court', ['h' => heures($numdate), 'm' => minutes($numdate)]);
221
+    }
222 222
 }
223 223
 
224 224
 /**
@@ -243,56 +243,56 @@  discard block
 block discarded – undo
243 243
  * @return array [année, mois, jour, heures, minutes, secondes]
244 244
  **/
245 245
 function recup_date($numdate, $forcer_jour = true) {
246
-	if (!$numdate) {
247
-		return '';
248
-	}
249
-	$heures = $minutes = $secondes = 0;
250
-	if (preg_match('#([0-9]{1,2})/([0-9]{1,2})/([0-9]{4}|[0-9]{1,2})#', $numdate, $regs)) {
251
-		$jour = $regs[1];
252
-		$mois = $regs[2];
253
-		$annee = $regs[3];
254
-		if ($annee < 90) {
255
-			$annee = 2000 + $annee;
256
-		} elseif ($annee < 100) {
257
-			$annee = 1900 + $annee;
258
-		}
259
-		[$heures, $minutes, $secondes] = recup_heure($numdate);
260
-	} elseif (preg_match('#([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})#', $numdate, $regs)) {
261
-		$annee = $regs[1];
262
-		$mois = $regs[2];
263
-		$jour = $regs[3];
264
-		[$heures, $minutes, $secondes] = recup_heure($numdate);
265
-	} elseif (preg_match('#([0-9]{4})-([0-9]{2})#', $numdate, $regs)) {
266
-		$annee = $regs[1];
267
-		$mois = $regs[2];
268
-		$jour = '';
269
-		[$heures, $minutes, $secondes] = recup_heure($numdate);
270
-	} elseif (preg_match('#^([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#', $numdate, $regs)) {
271
-		$annee = $regs[1];
272
-		$mois = $regs[2];
273
-		$jour = $regs[3];
274
-		$heures = $regs[4];
275
-		$minutes = $regs[5];
276
-		$secondes = $regs[6];
277
-	} else {
278
-		$annee = $mois = $jour = '';
279
-	}
280
-	if ($annee > 4000) {
281
-		$annee -= 9000;
282
-	}
283
-	if (strlen($jour) and substr($jour, 0, 1) == '0') {
284
-		$jour = substr($jour, 1);
285
-	}
286
-
287
-	if ($forcer_jour and $jour == '0') {
288
-		$jour = '1';
289
-	}
290
-	if ($forcer_jour and $mois == '0') {
291
-		$mois = '1';
292
-	}
293
-	if ($annee or $mois or $jour or $heures or $minutes or $secondes) {
294
-		return [$annee, $mois, $jour, $heures, $minutes, $secondes];
295
-	}
246
+    if (!$numdate) {
247
+        return '';
248
+    }
249
+    $heures = $minutes = $secondes = 0;
250
+    if (preg_match('#([0-9]{1,2})/([0-9]{1,2})/([0-9]{4}|[0-9]{1,2})#', $numdate, $regs)) {
251
+        $jour = $regs[1];
252
+        $mois = $regs[2];
253
+        $annee = $regs[3];
254
+        if ($annee < 90) {
255
+            $annee = 2000 + $annee;
256
+        } elseif ($annee < 100) {
257
+            $annee = 1900 + $annee;
258
+        }
259
+        [$heures, $minutes, $secondes] = recup_heure($numdate);
260
+    } elseif (preg_match('#([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})#', $numdate, $regs)) {
261
+        $annee = $regs[1];
262
+        $mois = $regs[2];
263
+        $jour = $regs[3];
264
+        [$heures, $minutes, $secondes] = recup_heure($numdate);
265
+    } elseif (preg_match('#([0-9]{4})-([0-9]{2})#', $numdate, $regs)) {
266
+        $annee = $regs[1];
267
+        $mois = $regs[2];
268
+        $jour = '';
269
+        [$heures, $minutes, $secondes] = recup_heure($numdate);
270
+    } elseif (preg_match('#^([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#', $numdate, $regs)) {
271
+        $annee = $regs[1];
272
+        $mois = $regs[2];
273
+        $jour = $regs[3];
274
+        $heures = $regs[4];
275
+        $minutes = $regs[5];
276
+        $secondes = $regs[6];
277
+    } else {
278
+        $annee = $mois = $jour = '';
279
+    }
280
+    if ($annee > 4000) {
281
+        $annee -= 9000;
282
+    }
283
+    if (strlen($jour) and substr($jour, 0, 1) == '0') {
284
+        $jour = substr($jour, 1);
285
+    }
286
+
287
+    if ($forcer_jour and $jour == '0') {
288
+        $jour = '1';
289
+    }
290
+    if ($forcer_jour and $mois == '0') {
291
+        $mois = '1';
292
+    }
293
+    if ($annee or $mois or $jour or $heures or $minutes or $secondes) {
294
+        return [$annee, $mois, $jour, $heures, $minutes, $secondes];
295
+    }
296 296
 }
297 297
 
298 298
 /**
@@ -319,10 +319,10 @@  discard block
 block discarded – undo
319 319
  *     La date relative ou complète
320 320
  **/
321 321
 function date_interface($date, $decalage_maxi = 43200 /* 12*3600 */) {
322
-	return sinon(
323
-		date_relative($date, $decalage_maxi),
324
-		affdate_heure($date)
325
-	);
322
+    return sinon(
323
+        date_relative($date, $decalage_maxi),
324
+        affdate_heure($date)
325
+    );
326 326
 }
327 327
 
328 328
 /**
@@ -355,85 +355,85 @@  discard block
 block discarded – undo
355 355
  **/
356 356
 function date_relative($date, $decalage_maxi = 0, $ref_date = null) {
357 357
 
358
-	if (is_null($ref_date)) {
359
-		$ref_time = time();
360
-	} else {
361
-		$ref_time = strtotime($ref_date);
362
-	}
363
-
364
-	if (!$date) {
365
-		return;
366
-	}
367
-	$decal = date('U', $ref_time) - date('U', strtotime($date));
368
-
369
-	if ($decalage_maxi and ($decal > $decalage_maxi or $decal < 0)) {
370
-		return '';
371
-	}
372
-
373
-	if ($decal < 0) {
374
-		$il_y_a = 'date_dans';
375
-		$decal = -1 * $decal;
376
-	} else {
377
-		$il_y_a = 'date_il_y_a';
378
-	}
379
-
380
-	if ($decal > 3600 * 24 * 30 * 6) {
381
-		return affdate_court($date);
382
-	}
383
-
384
-	if ($decal > 3600 * 24 * 30) {
385
-		$mois = floor($decal / (3600 * 24 * 30));
386
-		if ($mois < 2) {
387
-			$delai = "$mois " . _T('date_un_mois');
388
-		} else {
389
-			$delai = "$mois " . _T('date_mois');
390
-		}
391
-	} else {
392
-		if ($decal > 3600 * 24 * 7) {
393
-			$semaines = floor($decal / (3600 * 24 * 7));
394
-			if ($semaines < 2) {
395
-				$delai = "$semaines " . _T('date_une_semaine');
396
-			} else {
397
-				$delai = "$semaines " . _T('date_semaines');
398
-			}
399
-		} else {
400
-			if ($decal > 3600 * 24) {
401
-				$jours = floor($decal / (3600 * 24));
402
-				if ($jours < 2) {
403
-					return $il_y_a == 'date_dans' ? _T('date_demain') : _T('date_hier');
404
-				} else {
405
-					$delai = "$jours " . _T('date_jours');
406
-				}
407
-			} else {
408
-				if ($decal >= 3600) {
409
-					$heures = floor($decal / 3600);
410
-					if ($heures < 2) {
411
-						$delai = "$heures " . _T('date_une_heure');
412
-					} else {
413
-						$delai = "$heures " . _T('date_heures');
414
-					}
415
-				} else {
416
-					if ($decal >= 60) {
417
-						$minutes = floor($decal / 60);
418
-						if ($minutes < 2) {
419
-							$delai = "$minutes " . _T('date_une_minute');
420
-						} else {
421
-							$delai = "$minutes " . _T('date_minutes');
422
-						}
423
-					} else {
424
-						$secondes = ceil($decal);
425
-						if ($secondes < 2) {
426
-							$delai = "$secondes " . _T('date_une_seconde');
427
-						} else {
428
-							$delai = "$secondes " . _T('date_secondes');
429
-						}
430
-					}
431
-				}
432
-			}
433
-		}
434
-	}
435
-
436
-	return _T($il_y_a, ['delai' => $delai]);
358
+    if (is_null($ref_date)) {
359
+        $ref_time = time();
360
+    } else {
361
+        $ref_time = strtotime($ref_date);
362
+    }
363
+
364
+    if (!$date) {
365
+        return;
366
+    }
367
+    $decal = date('U', $ref_time) - date('U', strtotime($date));
368
+
369
+    if ($decalage_maxi and ($decal > $decalage_maxi or $decal < 0)) {
370
+        return '';
371
+    }
372
+
373
+    if ($decal < 0) {
374
+        $il_y_a = 'date_dans';
375
+        $decal = -1 * $decal;
376
+    } else {
377
+        $il_y_a = 'date_il_y_a';
378
+    }
379
+
380
+    if ($decal > 3600 * 24 * 30 * 6) {
381
+        return affdate_court($date);
382
+    }
383
+
384
+    if ($decal > 3600 * 24 * 30) {
385
+        $mois = floor($decal / (3600 * 24 * 30));
386
+        if ($mois < 2) {
387
+            $delai = "$mois " . _T('date_un_mois');
388
+        } else {
389
+            $delai = "$mois " . _T('date_mois');
390
+        }
391
+    } else {
392
+        if ($decal > 3600 * 24 * 7) {
393
+            $semaines = floor($decal / (3600 * 24 * 7));
394
+            if ($semaines < 2) {
395
+                $delai = "$semaines " . _T('date_une_semaine');
396
+            } else {
397
+                $delai = "$semaines " . _T('date_semaines');
398
+            }
399
+        } else {
400
+            if ($decal > 3600 * 24) {
401
+                $jours = floor($decal / (3600 * 24));
402
+                if ($jours < 2) {
403
+                    return $il_y_a == 'date_dans' ? _T('date_demain') : _T('date_hier');
404
+                } else {
405
+                    $delai = "$jours " . _T('date_jours');
406
+                }
407
+            } else {
408
+                if ($decal >= 3600) {
409
+                    $heures = floor($decal / 3600);
410
+                    if ($heures < 2) {
411
+                        $delai = "$heures " . _T('date_une_heure');
412
+                    } else {
413
+                        $delai = "$heures " . _T('date_heures');
414
+                    }
415
+                } else {
416
+                    if ($decal >= 60) {
417
+                        $minutes = floor($decal / 60);
418
+                        if ($minutes < 2) {
419
+                            $delai = "$minutes " . _T('date_une_minute');
420
+                        } else {
421
+                            $delai = "$minutes " . _T('date_minutes');
422
+                        }
423
+                    } else {
424
+                        $secondes = ceil($decal);
425
+                        if ($secondes < 2) {
426
+                            $delai = "$secondes " . _T('date_une_seconde');
427
+                        } else {
428
+                            $delai = "$secondes " . _T('date_secondes');
429
+                        }
430
+                    }
431
+                }
432
+            }
433
+        }
434
+    }
435
+
436
+    return _T($il_y_a, ['delai' => $delai]);
437 437
 }
438 438
 
439 439
 
@@ -459,32 +459,32 @@  discard block
 block discarded – undo
459 459
  **/
460 460
 function date_relativecourt($date, $decalage_maxi = 0) {
461 461
 
462
-	if (!$date) {
463
-		return;
464
-	}
465
-	$decal = date('U', strtotime(date('Y-m-d')) - strtotime(date('Y-m-d', strtotime($date))));
466
-
467
-	if ($decalage_maxi and ($decal > $decalage_maxi or $decal < 0)) {
468
-		return '';
469
-	}
470
-
471
-	if ($decal < -24 * 3600) {
472
-		$retour = date_relative($date, $decalage_maxi);
473
-	} elseif ($decal < 0) {
474
-		$retour = _T('date_demain');
475
-	} else {
476
-		if ($decal < (3600 * 24)) {
477
-			$retour = _T('date_aujourdhui');
478
-		} else {
479
-			if ($decal < (3600 * 24 * 2)) {
480
-				$retour = _T('date_hier');
481
-			} else {
482
-				$retour = date_relative($date, $decalage_maxi);
483
-			}
484
-		}
485
-	}
486
-
487
-	return $retour;
462
+    if (!$date) {
463
+        return;
464
+    }
465
+    $decal = date('U', strtotime(date('Y-m-d')) - strtotime(date('Y-m-d', strtotime($date))));
466
+
467
+    if ($decalage_maxi and ($decal > $decalage_maxi or $decal < 0)) {
468
+        return '';
469
+    }
470
+
471
+    if ($decal < -24 * 3600) {
472
+        $retour = date_relative($date, $decalage_maxi);
473
+    } elseif ($decal < 0) {
474
+        $retour = _T('date_demain');
475
+    } else {
476
+        if ($decal < (3600 * 24)) {
477
+            $retour = _T('date_aujourdhui');
478
+        } else {
479
+            if ($decal < (3600 * 24 * 2)) {
480
+                $retour = _T('date_hier');
481
+            } else {
482
+                $retour = date_relative($date, $decalage_maxi);
483
+            }
484
+        }
485
+    }
486
+
487
+    return $retour;
488 488
 }
489 489
 
490 490
 /**
@@ -503,174 +503,174 @@  discard block
 block discarded – undo
503 503
  * @return mixed|string
504 504
  */
505 505
 function affdate_base($numdate, $vue, $options = []) {
506
-	if (is_string($options)) {
507
-		$options = ['param' => $options];
508
-	}
509
-	$date_array = recup_date($numdate, false);
510
-	if (!$date_array) {
511
-		return;
512
-	}
513
-	[$annee, $mois, $jour, $heures, $minutes, $secondes] = $date_array;
514
-
515
-	// 1er, 21st, etc.
516
-	$journum = $jour;
517
-
518
-	if ($jour == 0) {
519
-		$jour = '';
520
-		$njour = 0;
521
-	} else {
522
-		$njour = intval($jour);
523
-		if ($jourth = _T('date_jnum' . $jour)) {
524
-			$jour = $jourth;
525
-		}
526
-	}
527
-
528
-	$mois = intval($mois);
529
-	if ($mois > 0 and $mois < 13) {
530
-		/* Traiter le cas "abbr" pour les noms de mois */
531
-		$param = ((isset($options['param']) and $options['param'] === 'abbr') ? '_' . $options['param'] : '');
532
-		$nommois = _T('date_mois_' . $mois . $param);
533
-		if ($jour) {
534
-			$jourmois = _T('date_de_mois_' . $mois, ['j' => $jour, 'nommois' => $nommois]);
535
-		} else {
536
-			$jourmois = $nommois;
537
-		}
538
-	} else {
539
-		$nommois = '';
540
-		$jourmois = '';
541
-	}
542
-
543
-	if ($annee < 0) {
544
-		$annee = -$annee . ' ' . _T('date_avant_jc');
545
-		$avjc = true;
546
-	} else {
547
-		$avjc = false;
548
-	}
549
-
550
-	switch ($vue) {
551
-		case 'saison':
552
-		case 'saison_annee':
553
-			$saison = '';
554
-			if ($mois > 0) {
555
-				$saison = ($options['param'] == 'sud') ? 3 : 1;
556
-				if (($mois == 3 and $jour >= 21) or $mois > 3) {
557
-					$saison = ($options['param'] == 'sud') ? 4 : 2;
558
-				}
559
-				if (($mois == 6 and $jour >= 21) or $mois > 6) {
560
-					$saison = ($options['param'] == 'sud') ? 1 : 3;
561
-				}
562
-				if (($mois == 9 and $jour >= 21) or $mois > 9) {
563
-					$saison = ($options['param'] == 'sud') ? 2 : 4;
564
-				}
565
-				if (($mois == 12 and $jour >= 21) or $mois > 12) {
566
-					$saison = ($options['param'] == 'sud') ? 3 : 1;
567
-				}
568
-			}
569
-			if ($vue == 'saison') {
570
-				return $saison ? _T('date_saison_' . $saison) : '';
571
-			} else {
572
-				return $saison ? trim(_T(
573
-					'date_fmt_saison_annee',
574
-					['saison' => _T('date_saison_' . $saison), 'annee' => $annee]
575
-				)) : '';
576
-			}
577
-
578
-		case 'court':
579
-			if ($avjc) {
580
-				return $annee;
581
-			}
582
-			$a = ((isset($options['annee_courante']) and $options['annee_courante']) ? $options['annee_courante'] : date('Y'));
583
-			if ($annee < ($a - 100) or $annee > ($a + 100)) {
584
-				return $annee;
585
-			}
586
-			if ($annee != $a) {
587
-				return _T(
588
-					'date_fmt_mois_annee',
589
-					['mois' => $mois, 'nommois' => spip_ucfirst($nommois), 'annee' => $annee]
590
-				);
591
-			}
592
-
593
-			return _T(
594
-				'date_fmt_jour_mois',
595
-				['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee]
596
-			);
597
-
598
-		case 'jourcourt':
599
-			if ($avjc) {
600
-				return $annee;
601
-			}
602
-			$a = ((isset($options['annee_courante']) and $options['annee_courante']) ? $options['annee_courante'] : date('Y'));
603
-			if ($annee < ($a - 100) or $annee > ($a + 100)) {
604
-				return $annee;
605
-			}
606
-			if ($annee != $a) {
607
-				return _T(
608
-					'date_fmt_jour_mois_annee',
609
-					['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee]
610
-				);
611
-			}
612
-
613
-			return _T(
614
-				'date_fmt_jour_mois',
615
-				['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee]
616
-			);
617
-
618
-		case 'entier':
619
-			if ($avjc) {
620
-				return $annee;
621
-			}
622
-			if ($jour) {
623
-				return _T(
624
-					'date_fmt_jour_mois_annee',
625
-					['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee]
626
-				);
627
-			} elseif ($mois) {
628
-				return trim(_T('date_fmt_mois_annee', ['mois' => $mois, 'nommois' => $nommois, 'annee' => $annee]));
629
-			} else {
630
-				return $annee;
631
-			}
632
-
633
-		case 'nom_mois':
634
-			return $nommois;
635
-
636
-		case 'mois':
637
-			return sprintf('%02s', $mois);
638
-
639
-		case 'jour':
640
-			return $jour;
641
-
642
-		case 'journum':
643
-			return $journum;
644
-
645
-		case 'nom_jour':
646
-			if (!$mois or !$njour) {
647
-				return '';
648
-			}
649
-			$nom = mktime(1, 1, 1, $mois, $njour, $annee);
650
-			$nom = 1 + date('w', $nom);
651
-			$param = ((isset($options['param']) and $options['param']) ? '_' . $options['param'] : '');
652
-
653
-			return _T('date_jour_' . $nom . $param);
654
-
655
-		case 'mois_annee':
656
-			if ($avjc) {
657
-				return $annee;
658
-			}
659
-
660
-			return trim(_T('date_fmt_mois_annee', ['mois' => $mois, 'nommois' => $nommois, 'annee' => $annee]));
661
-
662
-		case 'annee':
663
-			return $annee;
664
-
665
-		// Cas d'une vue non definie : retomber sur le format
666
-		// de date propose par http://www.php.net/date
667
-		default:
668
-			[$annee, $mois, $jour, $heures, $minutes, $secondes] = $date_array;
669
-			if (!$time = mktime($heures, $minutes, $secondes, $mois, (int) $jour, $annee)) {
670
-				$time = strtotime($numdate);
671
-			}
672
-			return date($vue, $time);
673
-	}
506
+    if (is_string($options)) {
507
+        $options = ['param' => $options];
508
+    }
509
+    $date_array = recup_date($numdate, false);
510
+    if (!$date_array) {
511
+        return;
512
+    }
513
+    [$annee, $mois, $jour, $heures, $minutes, $secondes] = $date_array;
514
+
515
+    // 1er, 21st, etc.
516
+    $journum = $jour;
517
+
518
+    if ($jour == 0) {
519
+        $jour = '';
520
+        $njour = 0;
521
+    } else {
522
+        $njour = intval($jour);
523
+        if ($jourth = _T('date_jnum' . $jour)) {
524
+            $jour = $jourth;
525
+        }
526
+    }
527
+
528
+    $mois = intval($mois);
529
+    if ($mois > 0 and $mois < 13) {
530
+        /* Traiter le cas "abbr" pour les noms de mois */
531
+        $param = ((isset($options['param']) and $options['param'] === 'abbr') ? '_' . $options['param'] : '');
532
+        $nommois = _T('date_mois_' . $mois . $param);
533
+        if ($jour) {
534
+            $jourmois = _T('date_de_mois_' . $mois, ['j' => $jour, 'nommois' => $nommois]);
535
+        } else {
536
+            $jourmois = $nommois;
537
+        }
538
+    } else {
539
+        $nommois = '';
540
+        $jourmois = '';
541
+    }
542
+
543
+    if ($annee < 0) {
544
+        $annee = -$annee . ' ' . _T('date_avant_jc');
545
+        $avjc = true;
546
+    } else {
547
+        $avjc = false;
548
+    }
549
+
550
+    switch ($vue) {
551
+        case 'saison':
552
+        case 'saison_annee':
553
+            $saison = '';
554
+            if ($mois > 0) {
555
+                $saison = ($options['param'] == 'sud') ? 3 : 1;
556
+                if (($mois == 3 and $jour >= 21) or $mois > 3) {
557
+                    $saison = ($options['param'] == 'sud') ? 4 : 2;
558
+                }
559
+                if (($mois == 6 and $jour >= 21) or $mois > 6) {
560
+                    $saison = ($options['param'] == 'sud') ? 1 : 3;
561
+                }
562
+                if (($mois == 9 and $jour >= 21) or $mois > 9) {
563
+                    $saison = ($options['param'] == 'sud') ? 2 : 4;
564
+                }
565
+                if (($mois == 12 and $jour >= 21) or $mois > 12) {
566
+                    $saison = ($options['param'] == 'sud') ? 3 : 1;
567
+                }
568
+            }
569
+            if ($vue == 'saison') {
570
+                return $saison ? _T('date_saison_' . $saison) : '';
571
+            } else {
572
+                return $saison ? trim(_T(
573
+                    'date_fmt_saison_annee',
574
+                    ['saison' => _T('date_saison_' . $saison), 'annee' => $annee]
575
+                )) : '';
576
+            }
577
+
578
+        case 'court':
579
+            if ($avjc) {
580
+                return $annee;
581
+            }
582
+            $a = ((isset($options['annee_courante']) and $options['annee_courante']) ? $options['annee_courante'] : date('Y'));
583
+            if ($annee < ($a - 100) or $annee > ($a + 100)) {
584
+                return $annee;
585
+            }
586
+            if ($annee != $a) {
587
+                return _T(
588
+                    'date_fmt_mois_annee',
589
+                    ['mois' => $mois, 'nommois' => spip_ucfirst($nommois), 'annee' => $annee]
590
+                );
591
+            }
592
+
593
+            return _T(
594
+                'date_fmt_jour_mois',
595
+                ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee]
596
+            );
597
+
598
+        case 'jourcourt':
599
+            if ($avjc) {
600
+                return $annee;
601
+            }
602
+            $a = ((isset($options['annee_courante']) and $options['annee_courante']) ? $options['annee_courante'] : date('Y'));
603
+            if ($annee < ($a - 100) or $annee > ($a + 100)) {
604
+                return $annee;
605
+            }
606
+            if ($annee != $a) {
607
+                return _T(
608
+                    'date_fmt_jour_mois_annee',
609
+                    ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee]
610
+                );
611
+            }
612
+
613
+            return _T(
614
+                'date_fmt_jour_mois',
615
+                ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee]
616
+            );
617
+
618
+        case 'entier':
619
+            if ($avjc) {
620
+                return $annee;
621
+            }
622
+            if ($jour) {
623
+                return _T(
624
+                    'date_fmt_jour_mois_annee',
625
+                    ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee]
626
+                );
627
+            } elseif ($mois) {
628
+                return trim(_T('date_fmt_mois_annee', ['mois' => $mois, 'nommois' => $nommois, 'annee' => $annee]));
629
+            } else {
630
+                return $annee;
631
+            }
632
+
633
+        case 'nom_mois':
634
+            return $nommois;
635
+
636
+        case 'mois':
637
+            return sprintf('%02s', $mois);
638
+
639
+        case 'jour':
640
+            return $jour;
641
+
642
+        case 'journum':
643
+            return $journum;
644
+
645
+        case 'nom_jour':
646
+            if (!$mois or !$njour) {
647
+                return '';
648
+            }
649
+            $nom = mktime(1, 1, 1, $mois, $njour, $annee);
650
+            $nom = 1 + date('w', $nom);
651
+            $param = ((isset($options['param']) and $options['param']) ? '_' . $options['param'] : '');
652
+
653
+            return _T('date_jour_' . $nom . $param);
654
+
655
+        case 'mois_annee':
656
+            if ($avjc) {
657
+                return $annee;
658
+            }
659
+
660
+            return trim(_T('date_fmt_mois_annee', ['mois' => $mois, 'nommois' => $nommois, 'annee' => $annee]));
661
+
662
+        case 'annee':
663
+            return $annee;
664
+
665
+        // Cas d'une vue non definie : retomber sur le format
666
+        // de date propose par http://www.php.net/date
667
+        default:
668
+            [$annee, $mois, $jour, $heures, $minutes, $secondes] = $date_array;
669
+            if (!$time = mktime($heures, $minutes, $secondes, $mois, (int) $jour, $annee)) {
670
+                $time = strtotime($numdate);
671
+            }
672
+            return date($vue, $time);
673
+    }
674 674
 }
675 675
 
676 676
 
@@ -697,11 +697,11 @@  discard block
 block discarded – undo
697 697
  *     Nom du jour
698 698
  **/
699 699
 function nom_jour($numdate, $forme = '') {
700
-	if (!($forme == 'abbr' or $forme == 'initiale')) {
701
-		$forme = '';
702
-	}
700
+    if (!($forme == 'abbr' or $forme == 'initiale')) {
701
+        $forme = '';
702
+    }
703 703
 
704
-	return affdate_base($numdate, 'nom_jour', $forme);
704
+    return affdate_base($numdate, 'nom_jour', $forme);
705 705
 }
706 706
 
707 707
 /**
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
  *     Numéro du jour
724 724
  **/
725 725
 function jour($numdate) {
726
-	return affdate_base($numdate, 'jour');
726
+    return affdate_base($numdate, 'jour');
727 727
 }
728 728
 
729 729
 /**
@@ -741,7 +741,7 @@  discard block
 block discarded – undo
741 741
  *     Numéro du jour
742 742
  **/
743 743
 function journum($numdate) {
744
-	return affdate_base($numdate, 'journum');
744
+    return affdate_base($numdate, 'journum');
745 745
 }
746 746
 
747 747
 /**
@@ -759,7 +759,7 @@  discard block
 block discarded – undo
759 759
  *     Numéro du mois (sur 2 chiffres)
760 760
  **/
761 761
 function mois($numdate) {
762
-	return affdate_base($numdate, 'mois');
762
+    return affdate_base($numdate, 'mois');
763 763
 }
764 764
 
765 765
 /**
@@ -783,11 +783,11 @@  discard block
 block discarded – undo
783 783
  *     Nom du mois
784 784
  **/
785 785
 function nom_mois($numdate, $forme = '') {
786
-	if (!($forme == 'abbr')) {
787
-		$forme = '';
788
-	}
786
+    if (!($forme == 'abbr')) {
787
+        $forme = '';
788
+    }
789 789
 
790
-	return affdate_base($numdate, 'nom_mois', $forme);
790
+    return affdate_base($numdate, 'nom_mois', $forme);
791 791
 }
792 792
 
793 793
 /**
@@ -805,7 +805,7 @@  discard block
 block discarded – undo
805 805
  *     Année (sur 4 chiffres)
806 806
  **/
807 807
 function annee($numdate) {
808
-	return affdate_base($numdate, 'annee');
808
+    return affdate_base($numdate, 'annee');
809 809
 }
810 810
 
811 811
 
@@ -835,11 +835,11 @@  discard block
 block discarded – undo
835 835
  *     La date formatée
836 836
  **/
837 837
 function saison($numdate, $hemisphere = 'nord') {
838
-	if ($hemisphere != 'sud') {
839
-		$hemisphere = 'nord';
840
-	}
838
+    if ($hemisphere != 'sud') {
839
+        $hemisphere = 'nord';
840
+    }
841 841
 
842
-	return affdate_base($numdate, 'saison', $hemisphere);
842
+    return affdate_base($numdate, 'saison', $hemisphere);
843 843
 }
844 844
 
845 845
 
@@ -868,11 +868,11 @@  discard block
 block discarded – undo
868 868
  *     La date formatée
869 869
  **/
870 870
 function saison_annee($numdate, $hemisphere = 'nord') {
871
-	if ($hemisphere != 'sud') {
872
-		$hemisphere = 'nord';
873
-	}
871
+    if ($hemisphere != 'sud') {
872
+        $hemisphere = 'nord';
873
+    }
874 874
 
875
-	return affdate_base($numdate, 'saison_annee', $hemisphere);
875
+    return affdate_base($numdate, 'saison_annee', $hemisphere);
876 876
 }
877 877
 
878 878
 /**
@@ -900,7 +900,7 @@  discard block
 block discarded – undo
900 900
  *     La date formatée
901 901
  **/
902 902
 function affdate($numdate, $format = 'entier') {
903
-	return affdate_base($numdate, $format);
903
+    return affdate_base($numdate, $format);
904 904
 }
905 905
 
906 906
 
@@ -927,7 +927,7 @@  discard block
 block discarded – undo
927 927
  *     La date formatée
928 928
  **/
929 929
 function affdate_court($numdate, $annee_courante = null) {
930
-	return affdate_base($numdate, 'court', ['annee_courante' => $annee_courante]);
930
+    return affdate_base($numdate, 'court', ['annee_courante' => $annee_courante]);
931 931
 }
932 932
 
933 933
 
@@ -954,7 +954,7 @@  discard block
 block discarded – undo
954 954
  *     La date formatée
955 955
  **/
956 956
 function affdate_jourcourt($numdate, $annee_courante = null) {
957
-	return affdate_base($numdate, 'jourcourt', ['annee_courante' => $annee_courante]);
957
+    return affdate_base($numdate, 'jourcourt', ['annee_courante' => $annee_courante]);
958 958
 }
959 959
 
960 960
 /**
@@ -972,7 +972,7 @@  discard block
 block discarded – undo
972 972
  *     La date formatée
973 973
  **/
974 974
 function affdate_mois_annee($numdate) {
975
-	return affdate_base($numdate, 'mois_annee');
975
+    return affdate_base($numdate, 'mois_annee');
976 976
 }
977 977
 
978 978
 /**
@@ -990,16 +990,16 @@  discard block
 block discarded – undo
990 990
  *     La date formatée
991 991
  **/
992 992
 function affdate_heure($numdate) {
993
-	$date_array = recup_date($numdate);
994
-	if (!$date_array) {
995
-		return;
996
-	}
997
-	[$annee, $mois, $jour, $heures, $minutes, $sec] = $date_array;
998
-
999
-	return _T('date_fmt_jour_heure', [
1000
-		'jour' => affdate($numdate),
1001
-		'heure' => _T('date_fmt_heures_minutes', ['h' => $heures, 'm' => $minutes])
1002
-	]);
993
+    $date_array = recup_date($numdate);
994
+    if (!$date_array) {
995
+        return;
996
+    }
997
+    [$annee, $mois, $jour, $heures, $minutes, $sec] = $date_array;
998
+
999
+    return _T('date_fmt_jour_heure', [
1000
+        'jour' => affdate($numdate),
1001
+        'heure' => _T('date_fmt_heures_minutes', ['h' => $heures, 'm' => $minutes])
1002
+    ]);
1003 1003
 }
1004 1004
 
1005 1005
 /**
@@ -1031,117 +1031,117 @@  discard block
 block discarded – undo
1031 1031
  *     Texte de la date
1032 1032
  */
1033 1033
 function affdate_debut_fin($date_debut, $date_fin, $horaire = 'oui', $forme = '') {
1034
-	$abbr = $jour = '';
1035
-	$affdate = 'affdate_jourcourt';
1036
-	if (strpos($forme, 'abbr') !== false) {
1037
-		$abbr = 'abbr';
1038
-	}
1039
-	if (strpos($forme, 'annee') !== false) {
1040
-		$affdate = 'affdate';
1041
-	}
1042
-	if (strpos($forme, 'jour') !== false) {
1043
-		$jour = 'jour';
1044
-	}
1045
-
1046
-	$dtstart = $dtend = $dtabbr = '';
1047
-	if (strpos($forme, 'hcal') !== false) {
1048
-		$dtstart = "<abbr class='dtstart' title='" . date_iso($date_debut) . "'>";
1049
-		$dtend = "<abbr class='dtend' title='" . date_iso($date_fin) . "'>";
1050
-		$dtabbr = '</abbr>';
1051
-	}
1052
-
1053
-	$date_debut = strtotime($date_debut);
1054
-	$date_fin = strtotime($date_fin);
1055
-	$d = date('Y-m-d', $date_debut);
1056
-	$f = date('Y-m-d', $date_fin);
1057
-	$h = ($horaire === 'oui' or $horaire === true);
1058
-	$hd = _T('date_fmt_heures_minutes_court', ['h' => date('H', $date_debut), 'm' => date('i', $date_debut)]);
1059
-	$hf = _T('date_fmt_heures_minutes_court', ['h' => date('H', $date_fin), 'm' => date('i', $date_fin)]);
1060
-
1061
-	if ($d == $f) { // meme jour
1062
-		$nomjour = nom_jour($d, $abbr);
1063
-		$s = $affdate($d);
1064
-		$s = _T('date_fmt_jour', ['nomjour' => $nomjour, 'jour' => $s]);
1065
-		if ($h) {
1066
-			if ($hd == $hf) {
1067
-				// Lundi 20 fevrier a 18h25
1068
-				$s = spip_ucfirst(_T('date_fmt_jour_heure', ['jour' => $s, 'heure' => $hd]));
1069
-				$s = "$dtstart$s$dtabbr";
1070
-			} else {
1071
-				// Le <abbr...>lundi 20 fevrier de 18h00</abbr> a <abbr...>20h00</abbr>
1072
-				if ($dtabbr && $dtstart && $dtend) {
1073
-					$s = _T(
1074
-						'date_fmt_jour_heure_debut_fin_abbr',
1075
-						[
1076
-						'jour' => spip_ucfirst($s),
1077
-						'heure_debut' => $hd,
1078
-						'heure_fin' => $hf,
1079
-						'dtstart' => $dtstart,
1080
-						'dtend' => $dtend,
1081
-						'dtabbr' => $dtabbr
1082
-						],
1083
-						[
1084
-							'sanitize' => false
1085
-						]
1086
-					);
1087
-				} // Le lundi 20 fevrier de 18h00 a 20h00
1088
-				else {
1089
-					$s = spip_ucfirst(_T(
1090
-						'date_fmt_jour_heure_debut_fin',
1091
-						['jour' => $s, 'heure_debut' => $hd, 'heure_fin' => $hf]
1092
-					));
1093
-				}
1094
-			}
1095
-		} else {
1096
-			if ($dtabbr && $dtstart) {
1097
-				$s = $dtstart . spip_ucfirst($s) . $dtabbr;
1098
-			} else {
1099
-				$s = spip_ucfirst($s);
1100
-			}
1101
-		}
1102
-	} else {
1103
-		if ((date('Y-m', $date_debut)) == date('Y-m', $date_fin)) { // meme annee et mois, jours differents
1104
-			if (!$h) {
1105
-				$date_debut = jour($d);
1106
-			} else {
1107
-				$date_debut = affdate_jourcourt($d, date('Y', $date_fin));
1108
-			}
1109
-			$date_fin = $affdate($f);
1110
-			if ($jour) {
1111
-				$nomjour_debut = nom_jour($d, $abbr);
1112
-				$date_debut = _T('date_fmt_jour', ['nomjour' => $nomjour_debut, 'jour' => $date_debut]);
1113
-				$nomjour_fin = nom_jour($f, $abbr);
1114
-				$date_fin = _T('date_fmt_jour', ['nomjour' => $nomjour_fin, 'jour' => $date_fin]);
1115
-			}
1116
-			if ($h) {
1117
-				$date_debut = _T('date_fmt_jour_heure', ['jour' => $date_debut, 'heure' => $hd]);
1118
-				$date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]);
1119
-			}
1120
-			$date_debut = $dtstart . $date_debut . $dtabbr;
1121
-			$date_fin = $dtend . $date_fin . $dtabbr;
1122
-
1123
-			$s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]);
1124
-		} else {
1125
-			$date_debut = affdate_jourcourt($d, date('Y', $date_fin));
1126
-			$date_fin = $affdate($f);
1127
-			if ($jour) {
1128
-				$nomjour_debut = nom_jour($d, $abbr);
1129
-				$date_debut = _T('date_fmt_jour', ['nomjour' => $nomjour_debut, 'jour' => $date_debut]);
1130
-				$nomjour_fin = nom_jour($f, $abbr);
1131
-				$date_fin = _T('date_fmt_jour', ['nomjour' => $nomjour_fin, 'jour' => $date_fin]);
1132
-			}
1133
-			if ($h) {
1134
-				$date_debut = _T('date_fmt_jour_heure', ['jour' => $date_debut, 'heure' => $hd]);
1135
-				$date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]);
1136
-			}
1137
-
1138
-			$date_debut = $dtstart . $date_debut . $dtabbr;
1139
-			$date_fin = $dtend . $date_fin . $dtabbr;
1140
-			$s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]);
1141
-		}
1142
-	}
1143
-
1144
-	return $s;
1034
+    $abbr = $jour = '';
1035
+    $affdate = 'affdate_jourcourt';
1036
+    if (strpos($forme, 'abbr') !== false) {
1037
+        $abbr = 'abbr';
1038
+    }
1039
+    if (strpos($forme, 'annee') !== false) {
1040
+        $affdate = 'affdate';
1041
+    }
1042
+    if (strpos($forme, 'jour') !== false) {
1043
+        $jour = 'jour';
1044
+    }
1045
+
1046
+    $dtstart = $dtend = $dtabbr = '';
1047
+    if (strpos($forme, 'hcal') !== false) {
1048
+        $dtstart = "<abbr class='dtstart' title='" . date_iso($date_debut) . "'>";
1049
+        $dtend = "<abbr class='dtend' title='" . date_iso($date_fin) . "'>";
1050
+        $dtabbr = '</abbr>';
1051
+    }
1052
+
1053
+    $date_debut = strtotime($date_debut);
1054
+    $date_fin = strtotime($date_fin);
1055
+    $d = date('Y-m-d', $date_debut);
1056
+    $f = date('Y-m-d', $date_fin);
1057
+    $h = ($horaire === 'oui' or $horaire === true);
1058
+    $hd = _T('date_fmt_heures_minutes_court', ['h' => date('H', $date_debut), 'm' => date('i', $date_debut)]);
1059
+    $hf = _T('date_fmt_heures_minutes_court', ['h' => date('H', $date_fin), 'm' => date('i', $date_fin)]);
1060
+
1061
+    if ($d == $f) { // meme jour
1062
+        $nomjour = nom_jour($d, $abbr);
1063
+        $s = $affdate($d);
1064
+        $s = _T('date_fmt_jour', ['nomjour' => $nomjour, 'jour' => $s]);
1065
+        if ($h) {
1066
+            if ($hd == $hf) {
1067
+                // Lundi 20 fevrier a 18h25
1068
+                $s = spip_ucfirst(_T('date_fmt_jour_heure', ['jour' => $s, 'heure' => $hd]));
1069
+                $s = "$dtstart$s$dtabbr";
1070
+            } else {
1071
+                // Le <abbr...>lundi 20 fevrier de 18h00</abbr> a <abbr...>20h00</abbr>
1072
+                if ($dtabbr && $dtstart && $dtend) {
1073
+                    $s = _T(
1074
+                        'date_fmt_jour_heure_debut_fin_abbr',
1075
+                        [
1076
+                        'jour' => spip_ucfirst($s),
1077
+                        'heure_debut' => $hd,
1078
+                        'heure_fin' => $hf,
1079
+                        'dtstart' => $dtstart,
1080
+                        'dtend' => $dtend,
1081
+                        'dtabbr' => $dtabbr
1082
+                        ],
1083
+                        [
1084
+                            'sanitize' => false
1085
+                        ]
1086
+                    );
1087
+                } // Le lundi 20 fevrier de 18h00 a 20h00
1088
+                else {
1089
+                    $s = spip_ucfirst(_T(
1090
+                        'date_fmt_jour_heure_debut_fin',
1091
+                        ['jour' => $s, 'heure_debut' => $hd, 'heure_fin' => $hf]
1092
+                    ));
1093
+                }
1094
+            }
1095
+        } else {
1096
+            if ($dtabbr && $dtstart) {
1097
+                $s = $dtstart . spip_ucfirst($s) . $dtabbr;
1098
+            } else {
1099
+                $s = spip_ucfirst($s);
1100
+            }
1101
+        }
1102
+    } else {
1103
+        if ((date('Y-m', $date_debut)) == date('Y-m', $date_fin)) { // meme annee et mois, jours differents
1104
+            if (!$h) {
1105
+                $date_debut = jour($d);
1106
+            } else {
1107
+                $date_debut = affdate_jourcourt($d, date('Y', $date_fin));
1108
+            }
1109
+            $date_fin = $affdate($f);
1110
+            if ($jour) {
1111
+                $nomjour_debut = nom_jour($d, $abbr);
1112
+                $date_debut = _T('date_fmt_jour', ['nomjour' => $nomjour_debut, 'jour' => $date_debut]);
1113
+                $nomjour_fin = nom_jour($f, $abbr);
1114
+                $date_fin = _T('date_fmt_jour', ['nomjour' => $nomjour_fin, 'jour' => $date_fin]);
1115
+            }
1116
+            if ($h) {
1117
+                $date_debut = _T('date_fmt_jour_heure', ['jour' => $date_debut, 'heure' => $hd]);
1118
+                $date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]);
1119
+            }
1120
+            $date_debut = $dtstart . $date_debut . $dtabbr;
1121
+            $date_fin = $dtend . $date_fin . $dtabbr;
1122
+
1123
+            $s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]);
1124
+        } else {
1125
+            $date_debut = affdate_jourcourt($d, date('Y', $date_fin));
1126
+            $date_fin = $affdate($f);
1127
+            if ($jour) {
1128
+                $nomjour_debut = nom_jour($d, $abbr);
1129
+                $date_debut = _T('date_fmt_jour', ['nomjour' => $nomjour_debut, 'jour' => $date_debut]);
1130
+                $nomjour_fin = nom_jour($f, $abbr);
1131
+                $date_fin = _T('date_fmt_jour', ['nomjour' => $nomjour_fin, 'jour' => $date_fin]);
1132
+            }
1133
+            if ($h) {
1134
+                $date_debut = _T('date_fmt_jour_heure', ['jour' => $date_debut, 'heure' => $hd]);
1135
+                $date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]);
1136
+            }
1137
+
1138
+            $date_debut = $dtstart . $date_debut . $dtabbr;
1139
+            $date_fin = $dtend . $date_fin . $dtabbr;
1140
+            $s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]);
1141
+        }
1142
+    }
1143
+
1144
+    return $s;
1145 1145
 }
1146 1146
 
1147 1147
 /**
@@ -1162,10 +1162,10 @@  discard block
 block discarded – undo
1162 1162
  *     Date au format ical
1163 1163
  **/
1164 1164
 function date_ical($date, $addminutes = 0) {
1165
-	[$heures, $minutes, $secondes] = recup_heure($date);
1166
-	[$annee, $mois, $jour] = recup_date($date);
1165
+    [$heures, $minutes, $secondes] = recup_heure($date);
1166
+    [$annee, $mois, $jour] = recup_date($date);
1167 1167
 
1168
-	return gmdate('Ymd\THis\Z', mktime($heures, $minutes + $addminutes, $secondes, $mois, $jour, $annee));
1168
+    return gmdate('Ymd\THis\Z', mktime($heures, $minutes + $addminutes, $secondes, $mois, $jour, $annee));
1169 1169
 }
1170 1170
 
1171 1171
 
@@ -1189,11 +1189,11 @@  discard block
 block discarded – undo
1189 1189
  *     La date formatée
1190 1190
  **/
1191 1191
 function date_iso($date_heure) {
1192
-	[$annee, $mois, $jour] = recup_date($date_heure);
1193
-	[$heures, $minutes, $secondes] = recup_heure($date_heure);
1194
-	$time = @mktime($heures, $minutes, $secondes, $mois, $jour, $annee);
1192
+    [$annee, $mois, $jour] = recup_date($date_heure);
1193
+    [$heures, $minutes, $secondes] = recup_heure($date_heure);
1194
+    $time = @mktime($heures, $minutes, $secondes, $mois, $jour, $annee);
1195 1195
 
1196
-	return gmdate('Y-m-d\TH:i:s\Z', $time);
1196
+    return gmdate('Y-m-d\TH:i:s\Z', $time);
1197 1197
 }
1198 1198
 
1199 1199
 /**
@@ -1216,11 +1216,11 @@  discard block
 block discarded – undo
1216 1216
  *     La date formatée
1217 1217
  **/
1218 1218
 function date_822($date_heure) {
1219
-	[$annee, $mois, $jour] = recup_date($date_heure);
1220
-	[$heures, $minutes, $secondes] = recup_heure($date_heure);
1221
-	$time = mktime($heures, $minutes, $secondes, $mois, $jour, $annee);
1219
+    [$annee, $mois, $jour] = recup_date($date_heure);
1220
+    [$heures, $minutes, $secondes] = recup_heure($date_heure);
1221
+    $time = mktime($heures, $minutes, $secondes, $mois, $jour, $annee);
1222 1222
 
1223
-	return date('r', $time);
1223
+    return date('r', $time);
1224 1224
 }
1225 1225
 
1226 1226
 /**
@@ -1236,11 +1236,11 @@  discard block
 block discarded – undo
1236 1236
  *     Date au format `Ymd`
1237 1237
  **/
1238 1238
 function date_anneemoisjour($d) {
1239
-	if (!$d) {
1240
-		$d = date('Y-m-d');
1241
-	}
1239
+    if (!$d) {
1240
+        $d = date('Y-m-d');
1241
+    }
1242 1242
 
1243
-	return substr($d, 0, 4) . substr($d, 5, 2) . substr($d, 8, 2);
1243
+    return substr($d, 0, 4) . substr($d, 5, 2) . substr($d, 8, 2);
1244 1244
 }
1245 1245
 
1246 1246
 /**
@@ -1256,11 +1256,11 @@  discard block
 block discarded – undo
1256 1256
  *     Date au format `Ym`
1257 1257
  **/
1258 1258
 function date_anneemois($d) {
1259
-	if (!$d) {
1260
-		$d = date('Y-m-d');
1261
-	}
1259
+    if (!$d) {
1260
+        $d = date('Y-m-d');
1261
+    }
1262 1262
 
1263
-	return substr($d, 0, 4) . substr($d, 5, 2);
1263
+    return substr($d, 0, 4) . substr($d, 5, 2);
1264 1264
 }
1265 1265
 
1266 1266
 /**
@@ -1276,13 +1276,13 @@  discard block
 block discarded – undo
1276 1276
  *     Date au lundi de la même semaine au format `Ymd`
1277 1277
  **/
1278 1278
 function date_debut_semaine($annee, $mois, $jour) {
1279
-	$w_day = date('w', mktime(0, 0, 0, $mois, $jour, $annee));
1280
-	if ($w_day == 0) {
1281
-		$w_day = 7;
1282
-	} // Gaffe: le dimanche est zero
1283
-	$debut = $jour - $w_day + 1;
1279
+    $w_day = date('w', mktime(0, 0, 0, $mois, $jour, $annee));
1280
+    if ($w_day == 0) {
1281
+        $w_day = 7;
1282
+    } // Gaffe: le dimanche est zero
1283
+    $debut = $jour - $w_day + 1;
1284 1284
 
1285
-	return date('Ymd', mktime(0, 0, 0, $mois, $debut, $annee));
1285
+    return date('Ymd', mktime(0, 0, 0, $mois, $debut, $annee));
1286 1286
 }
1287 1287
 
1288 1288
 /**
@@ -1298,11 +1298,11 @@  discard block
 block discarded – undo
1298 1298
  *     Date au dimanche de la même semaine au format `Ymd`
1299 1299
  **/
1300 1300
 function date_fin_semaine($annee, $mois, $jour) {
1301
-	$w_day = date('w', mktime(0, 0, 0, $mois, $jour, $annee));
1302
-	if ($w_day == 0) {
1303
-		$w_day = 7;
1304
-	} // Gaffe: le dimanche est zero
1305
-	$debut = $jour - $w_day + 1;
1301
+    $w_day = date('w', mktime(0, 0, 0, $mois, $jour, $annee));
1302
+    if ($w_day == 0) {
1303
+        $w_day = 7;
1304
+    } // Gaffe: le dimanche est zero
1305
+    $debut = $jour - $w_day + 1;
1306 1306
 
1307
-	return date('Ymd', mktime(0, 0, 0, $mois, $debut + 6, $annee));
1307
+    return date('Ymd', mktime(0, 0, 0, $mois, $debut + 6, $annee));
1308 1308
 }
Please login to merge, or discard this patch.
ecrire/inc/puce_statut.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -416,7 +416,7 @@
 block discarded – undo
416 416
 	$h = generer_action_auteur('instituer_objet', "$type-$id-$statut");
417 417
 	$t = supprimer_tags($titre);
418 418
 
419
-	return "<a href=\"#\" data-puce-id=\"$id\" data-puce-type=\"$type\" data-puce-decal=\"$n\" data-puce-action=\"$h\" title=\"$t\"$act>" . http_img_pack($img, $t) . '</a>';
419
+	return "<a href=\"#\" data-puce-id=\"$id\" data-puce-type=\"$type\" data-puce-decal=\"$n\" data-puce-action=\"$h\" title=\"$t\"$act>".http_img_pack($img, $t).'</a>';
420 420
 }
421 421
 
422 422
 // compat
Please login to merge, or discard this patch.
Indentation   +236 added lines, -236 removed lines patch added patch discarded remove patch
@@ -18,18 +18,18 @@  discard block
 block discarded – undo
18 18
  **/
19 19
 
20 20
 if (!defined('_ECRIRE_INC_VERSION')) {
21
-	return;
21
+    return;
22 22
 }
23 23
 
24 24
 if (!defined('_ACTIVER_PUCE_RAPIDE')) {
25
-	/**
26
-	 * Activer le changement rapide de statut sur les listes d'objets ?
27
-	 *
28
-	 * Peut ralentir un site sur des listes très longues.
29
-	 *
30
-	 * @var bool
31
-	 **/
32
-	define('_ACTIVER_PUCE_RAPIDE', true);
25
+    /**
26
+     * Activer le changement rapide de statut sur les listes d'objets ?
27
+     *
28
+     * Peut ralentir un site sur des listes très longues.
29
+     *
30
+     * @var bool
31
+     **/
32
+    define('_ACTIVER_PUCE_RAPIDE', true);
33 33
 }
34 34
 
35 35
 /**
@@ -57,31 +57,31 @@  discard block
 block discarded – undo
57 57
  *     Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent)
58 58
  */
59 59
 function inc_puce_statut_dist(
60
-	$id_objet,
61
-	$statut,
62
-	$id_parent,
63
-	$type,
64
-	$ajax = false,
65
-	$menu_rapide = _ACTIVER_PUCE_RAPIDE
60
+    $id_objet,
61
+    $statut,
62
+    $id_parent,
63
+    $type,
64
+    $ajax = false,
65
+    $menu_rapide = _ACTIVER_PUCE_RAPIDE
66 66
 ) {
67
-	static $f_puce_statut = [];
68
-	$type = objet_type($type);
69
-	// cas prioritaire : fonction perso, qui permet aussi de gerer les cas historiques
70
-	if (!isset($f_puce_statut[$type]) or is_null($f_puce_statut[$type])) {
71
-		$f_puce_statut[$type] = charger_fonction($type, 'puce_statut', true);
72
-	}
73
-	if ($f_puce_statut[$type]) {
74
-		return $f_puce_statut[$type]($id_objet, $statut, $id_parent, $type, $ajax, $menu_rapide);
75
-	}
76
-
77
-	// si statut_image trouve quelque chose (et '' est quelque chose)
78
-	// composer une puce, avec si possible changement rapide
79
-	elseif (!is_null($puce = puce_statut_changement_rapide($id_objet, $statut, $id_parent, $type, $ajax, $menu_rapide))) {
80
-		return $puce;
81
-	} // sinon fausse puce avec le type de l'image
82
-	else {
83
-		return http_img_pack("$type-16.png", '');
84
-	}
67
+    static $f_puce_statut = [];
68
+    $type = objet_type($type);
69
+    // cas prioritaire : fonction perso, qui permet aussi de gerer les cas historiques
70
+    if (!isset($f_puce_statut[$type]) or is_null($f_puce_statut[$type])) {
71
+        $f_puce_statut[$type] = charger_fonction($type, 'puce_statut', true);
72
+    }
73
+    if ($f_puce_statut[$type]) {
74
+        return $f_puce_statut[$type]($id_objet, $statut, $id_parent, $type, $ajax, $menu_rapide);
75
+    }
76
+
77
+    // si statut_image trouve quelque chose (et '' est quelque chose)
78
+    // composer une puce, avec si possible changement rapide
79
+    elseif (!is_null($puce = puce_statut_changement_rapide($id_objet, $statut, $id_parent, $type, $ajax, $menu_rapide))) {
80
+        return $puce;
81
+    } // sinon fausse puce avec le type de l'image
82
+    else {
83
+        return http_img_pack("$type-16.png", '');
84
+    }
85 85
 }
86 86
 
87 87
 /**
@@ -110,41 +110,41 @@  discard block
 block discarded – undo
110 110
  *   null si pas capable de déterminer l'image
111 111
  */
112 112
 function statut_image($objet, $statut) {
113
-	$src = null;
114
-	$table = table_objet_sql($objet);
115
-	$desc = lister_tables_objets_sql($table);
116
-	if (isset($desc['statut_images'])) {
117
-		// si une declaration statut_images
118
-		// mais rien pour le statut demande, ne rien afficher
119
-		$src = '';
120
-		if (isset($desc['statut_images'][$statut])) {
121
-			$src = $desc['statut_images'][$statut];
122
-		} // sinon image par defaut ?
123
-		elseif (isset($desc['statut_images'][0])) {
124
-			$src = $desc['statut_images'][0];
125
-		}
126
-	} else {
127
-		switch ($statut) {
128
-			case 'prepa':
129
-				$src = 'puce-preparer-xx.svg?12px';
130
-				break;
131
-			case 'prop':
132
-				$src = 'puce-proposer-xx.svg?12px';
133
-				break;
134
-			case 'publie':
135
-				$src = 'puce-publier-xx.svg?12px';
136
-				break;
137
-			case 'refuse':
138
-				$src = 'puce-refuser-xx.svg?12px';
139
-				break;
140
-			case 'poubelle':
141
-			case 'poub':
142
-				$src = 'puce-supprimer-xx.svg?12px';
143
-				break;
144
-		}
145
-	}
146
-
147
-	return $src;
113
+    $src = null;
114
+    $table = table_objet_sql($objet);
115
+    $desc = lister_tables_objets_sql($table);
116
+    if (isset($desc['statut_images'])) {
117
+        // si une declaration statut_images
118
+        // mais rien pour le statut demande, ne rien afficher
119
+        $src = '';
120
+        if (isset($desc['statut_images'][$statut])) {
121
+            $src = $desc['statut_images'][$statut];
122
+        } // sinon image par defaut ?
123
+        elseif (isset($desc['statut_images'][0])) {
124
+            $src = $desc['statut_images'][0];
125
+        }
126
+    } else {
127
+        switch ($statut) {
128
+            case 'prepa':
129
+                $src = 'puce-preparer-xx.svg?12px';
130
+                break;
131
+            case 'prop':
132
+                $src = 'puce-proposer-xx.svg?12px';
133
+                break;
134
+            case 'publie':
135
+                $src = 'puce-publier-xx.svg?12px';
136
+                break;
137
+            case 'refuse':
138
+                $src = 'puce-refuser-xx.svg?12px';
139
+                break;
140
+            case 'poubelle':
141
+            case 'poub':
142
+                $src = 'puce-supprimer-xx.svg?12px';
143
+                break;
144
+        }
145
+    }
146
+
147
+    return $src;
148 148
 }
149 149
 
150 150
 /**
@@ -172,40 +172,40 @@  discard block
 block discarded – undo
172 172
  * @return string
173 173
  */
174 174
 function statut_titre($objet, $statut) {
175
-	$titre = '';
176
-	$table = table_objet_sql($objet);
177
-	$desc = lister_tables_objets_sql($table);
178
-	if (isset($desc['statut_titres'])) {
179
-		// si une declaration statut_titres
180
-		// mais rien pour le statut demande, ne rien afficher
181
-		if (isset($desc['statut_titres'][$statut])) {
182
-			$titre = $desc['statut_titres'][$statut];
183
-		} // sinon image par defaut ?
184
-		elseif (isset($desc['statut_titres'][0])) {
185
-			$titre = $desc['statut_titres'][0];
186
-		}
187
-	} else {
188
-		switch ($statut) {
189
-			case 'prepa':
190
-				$titre = 'texte_statut_en_cours_redaction';
191
-				break;
192
-			case 'prop':
193
-				$titre = 'texte_statut_propose_evaluation';
194
-				break;
195
-			case 'publie':
196
-				$titre = 'texte_statut_publie';
197
-				break;
198
-			case 'refuse':
199
-				$titre = 'texte_statut_refuse';
200
-				break;
201
-			case 'poubelle':
202
-			case 'poub':
203
-				$titre = 'texte_statut_poubelle';
204
-				break;
205
-		}
206
-	}
207
-
208
-	return $titre ? _T($titre) : '';
175
+    $titre = '';
176
+    $table = table_objet_sql($objet);
177
+    $desc = lister_tables_objets_sql($table);
178
+    if (isset($desc['statut_titres'])) {
179
+        // si une declaration statut_titres
180
+        // mais rien pour le statut demande, ne rien afficher
181
+        if (isset($desc['statut_titres'][$statut])) {
182
+            $titre = $desc['statut_titres'][$statut];
183
+        } // sinon image par defaut ?
184
+        elseif (isset($desc['statut_titres'][0])) {
185
+            $titre = $desc['statut_titres'][0];
186
+        }
187
+    } else {
188
+        switch ($statut) {
189
+            case 'prepa':
190
+                $titre = 'texte_statut_en_cours_redaction';
191
+                break;
192
+            case 'prop':
193
+                $titre = 'texte_statut_propose_evaluation';
194
+                break;
195
+            case 'publie':
196
+                $titre = 'texte_statut_publie';
197
+                break;
198
+            case 'refuse':
199
+                $titre = 'texte_statut_refuse';
200
+                break;
201
+            case 'poubelle':
202
+            case 'poub':
203
+                $titre = 'texte_statut_poubelle';
204
+                break;
205
+        }
206
+    }
207
+
208
+    return $titre ? _T($titre) : '';
209 209
 }
210 210
 
211 211
 
@@ -225,37 +225,37 @@  discard block
 block discarded – undo
225 225
  * @return string
226 226
  */
227 227
 function statut_texte_instituer($objet, $statut) {
228
-	$texte = '';
229
-	$table = table_objet_sql($objet);
230
-	$desc = lister_tables_objets_sql($table);
231
-	if (isset($desc['statut_textes_instituer'])) {
232
-		// si une declaration statut_titres
233
-		// mais rien pour le statut demande, ne rien afficher
234
-		if (isset($desc['statut_textes_instituer'][$statut])) {
235
-			$texte = $desc['statut_textes_instituer'][$statut];
236
-		}
237
-	} else {
238
-		switch ($statut) {
239
-			case 'prepa':
240
-				$texte = 'texte_statut_en_cours_redaction';
241
-				break;
242
-			case 'prop':
243
-				$texte = 'texte_statut_propose_evaluation';
244
-				break;
245
-			case 'publie':
246
-				$texte = 'texte_statut_publie';
247
-				break;
248
-			case 'refuse':
249
-				$texte = 'texte_statut_refuse';
250
-				break;
251
-			case 'poubelle':
252
-			case 'poub':
253
-				$texte = 'texte_statut_poubelle';
254
-				break;
255
-		}
256
-	}
257
-
258
-	return $texte ? _T($texte) : '';
228
+    $texte = '';
229
+    $table = table_objet_sql($objet);
230
+    $desc = lister_tables_objets_sql($table);
231
+    if (isset($desc['statut_textes_instituer'])) {
232
+        // si une declaration statut_titres
233
+        // mais rien pour le statut demande, ne rien afficher
234
+        if (isset($desc['statut_textes_instituer'][$statut])) {
235
+            $texte = $desc['statut_textes_instituer'][$statut];
236
+        }
237
+    } else {
238
+        switch ($statut) {
239
+            case 'prepa':
240
+                $texte = 'texte_statut_en_cours_redaction';
241
+                break;
242
+            case 'prop':
243
+                $texte = 'texte_statut_propose_evaluation';
244
+                break;
245
+            case 'publie':
246
+                $texte = 'texte_statut_publie';
247
+                break;
248
+            case 'refuse':
249
+                $texte = 'texte_statut_refuse';
250
+                break;
251
+            case 'poubelle':
252
+            case 'poub':
253
+                $texte = 'texte_statut_poubelle';
254
+                break;
255
+        }
256
+    }
257
+
258
+    return $texte ? _T($texte) : '';
259 259
 }
260 260
 
261 261
 
@@ -275,16 +275,16 @@  discard block
 block discarded – undo
275 275
  * @return string
276 276
  */
277 277
 function puce_statut_auteur_dist($id, $statut, $id_parent, $type, $ajax = '', $menu_rapide = _ACTIVER_PUCE_RAPIDE) {
278
-	$img = statut_image('auteur', $statut);
279
-	if (!$img) {
280
-		return '';
281
-	}
282
-	$alt = statut_titre('auteur', $statut);
278
+    $img = statut_image('auteur', $statut);
279
+    if (!$img) {
280
+        return '';
281
+    }
282
+    $alt = statut_titre('auteur', $statut);
283 283
 
284
-	$fond = '';
285
-	$titre = '';
284
+    $fond = '';
285
+    $titre = '';
286 286
 
287
-	/*
287
+    /*
288 288
 	if ($type != 'auteur') {
289 289
 	  $img2 = chemin_image('del-16.png');
290 290
 	  $titre = _T('titre_image_redacteur');
@@ -294,12 +294,12 @@  discard block
 block discarded – undo
294 294
 	}
295 295
 	*/
296 296
 
297
-	return http_img_pack($img, $alt, $fond, $alt);
297
+    return http_img_pack($img, $alt, $fond, $alt);
298 298
 }
299 299
 
300 300
 
301 301
 function puce_statut_rubrique_dist($id, $statut, $id_rubrique, $type, $ajax = '', $menu_rapide = _ACTIVER_PUCE_RAPIDE) {
302
-	return http_img_pack('rubrique-16.png', '');
302
+    return http_img_pack('rubrique-16.png', '');
303 303
 }
304 304
 
305 305
 /**
@@ -323,110 +323,110 @@  discard block
 block discarded – undo
323 323
  *     Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent)
324 324
  **/
325 325
 function puce_statut_changement_rapide(
326
-	$id,
327
-	$statut,
328
-	$id_rubrique,
329
-	$type = 'article',
330
-	$ajax = false,
331
-	$menu_rapide = _ACTIVER_PUCE_RAPIDE
326
+    $id,
327
+    $statut,
328
+    $id_rubrique,
329
+    $type = 'article',
330
+    $ajax = false,
331
+    $menu_rapide = _ACTIVER_PUCE_RAPIDE
332 332
 ) {
333
-	$src = statut_image($type, $statut);
334
-	if (!$src) {
335
-		return $src;
336
-	}
337
-
338
-	if (
339
-		!$id
340
-		or !_SPIP_AJAX
341
-		or !$menu_rapide
342
-	) {
343
-		$ajax_node = '';
344
-	} else {
345
-		$ajax_node = " class='imgstatut$type$id'";
346
-	}
347
-
348
-
349
-	$t = statut_titre($type, $statut);
350
-	$inser_puce = http_img_pack($src, $t, $ajax_node, $t);
351
-
352
-	if (!$ajax_node) {
353
-		return $inser_puce;
354
-	}
355
-
356
-	$table = table_objet_sql($type);
357
-	$desc = lister_tables_objets_sql($table);
358
-	if (!isset($desc['statut_textes_instituer'])) {
359
-		return $inser_puce;
360
-	}
361
-
362
-	if (!function_exists('autoriser')) {
363
-		include_spip('inc/autoriser');
364
-	}
365
-
366
-	// cas ou l'on a un parent connu (devrait disparaitre au profit du second cas plus generique)
367
-	if ($id_rubrique) {
368
-		if (!autoriser('publierdans', 'rubrique', $id_rubrique)) {
369
-			return $inser_puce;
370
-		}
371
-	} // si pas d'id_rubrique fourni, tester directement instituer type avec le statut publie
372
-	else {
373
-		if (!autoriser('instituer', $type, $id, null, ['statut' => 'publie'])) {
374
-			return $inser_puce;
375
-		}
376
-	}
377
-
378
-	$coord = array_flip(array_keys($desc['statut_textes_instituer']));
379
-	if (!isset($coord[$statut])) {
380
-		return $inser_puce;
381
-	}
382
-
383
-	$unit = 18/*widh de img*/ + 0/*padding*/
384
-	;
385
-	$margin = 0; /* marge a gauche + droite */
386
-	$zero = 0 /*border*/ + $margin / 2 + 0 /*padding*/
387
-	;
388
-	$clip = $zero + ($unit * $coord[$statut]);
389
-
390
-	if ($ajax) {
391
-		$width = $unit * (is_countable($desc['statut_textes_instituer']) ? count($desc['statut_textes_instituer']) : 0) + $margin;
392
-		$out = "<span class='puce_objet_fixe $type'>"
393
-			. $inser_puce
394
-			. '</span>'
395
-			. "<span class='puce_objet_popup $type statutdecal$type$id' style='width:{$width}px;margin-left:-{$clip}px;'>";
396
-		$i = 0;
397
-		foreach ($desc['statut_textes_instituer'] as $s => $t) {
398
-			$out .= afficher_script_statut($id, $type, -$zero - $i++ * $unit, statut_image($type, $s), $s, _T($t));
399
-		}
400
-		$out .= '</span>';
401
-
402
-		return $out;
403
-	} else {
404
-		$nom = 'puce_statut_';
405
-		$action = generer_url_ecrire('puce_statut', '', true);
406
-		$lang_dir = lang_dir(lang_typo());
407
-
408
-		return "<span class='puce_objet $type' id='$nom$type$id' dir='$lang_dir' data-puce-nom='$nom' data-puce-type='$type' data-puce-id='$id' data-puce-action='$action'>"
409
-		. $inser_puce
410
-		. '</span>';
411
-	}
333
+    $src = statut_image($type, $statut);
334
+    if (!$src) {
335
+        return $src;
336
+    }
337
+
338
+    if (
339
+        !$id
340
+        or !_SPIP_AJAX
341
+        or !$menu_rapide
342
+    ) {
343
+        $ajax_node = '';
344
+    } else {
345
+        $ajax_node = " class='imgstatut$type$id'";
346
+    }
347
+
348
+
349
+    $t = statut_titre($type, $statut);
350
+    $inser_puce = http_img_pack($src, $t, $ajax_node, $t);
351
+
352
+    if (!$ajax_node) {
353
+        return $inser_puce;
354
+    }
355
+
356
+    $table = table_objet_sql($type);
357
+    $desc = lister_tables_objets_sql($table);
358
+    if (!isset($desc['statut_textes_instituer'])) {
359
+        return $inser_puce;
360
+    }
361
+
362
+    if (!function_exists('autoriser')) {
363
+        include_spip('inc/autoriser');
364
+    }
365
+
366
+    // cas ou l'on a un parent connu (devrait disparaitre au profit du second cas plus generique)
367
+    if ($id_rubrique) {
368
+        if (!autoriser('publierdans', 'rubrique', $id_rubrique)) {
369
+            return $inser_puce;
370
+        }
371
+    } // si pas d'id_rubrique fourni, tester directement instituer type avec le statut publie
372
+    else {
373
+        if (!autoriser('instituer', $type, $id, null, ['statut' => 'publie'])) {
374
+            return $inser_puce;
375
+        }
376
+    }
377
+
378
+    $coord = array_flip(array_keys($desc['statut_textes_instituer']));
379
+    if (!isset($coord[$statut])) {
380
+        return $inser_puce;
381
+    }
382
+
383
+    $unit = 18/*widh de img*/ + 0/*padding*/
384
+    ;
385
+    $margin = 0; /* marge a gauche + droite */
386
+    $zero = 0 /*border*/ + $margin / 2 + 0 /*padding*/
387
+    ;
388
+    $clip = $zero + ($unit * $coord[$statut]);
389
+
390
+    if ($ajax) {
391
+        $width = $unit * (is_countable($desc['statut_textes_instituer']) ? count($desc['statut_textes_instituer']) : 0) + $margin;
392
+        $out = "<span class='puce_objet_fixe $type'>"
393
+            . $inser_puce
394
+            . '</span>'
395
+            . "<span class='puce_objet_popup $type statutdecal$type$id' style='width:{$width}px;margin-left:-{$clip}px;'>";
396
+        $i = 0;
397
+        foreach ($desc['statut_textes_instituer'] as $s => $t) {
398
+            $out .= afficher_script_statut($id, $type, -$zero - $i++ * $unit, statut_image($type, $s), $s, _T($t));
399
+        }
400
+        $out .= '</span>';
401
+
402
+        return $out;
403
+    } else {
404
+        $nom = 'puce_statut_';
405
+        $action = generer_url_ecrire('puce_statut', '', true);
406
+        $lang_dir = lang_dir(lang_typo());
407
+
408
+        return "<span class='puce_objet $type' id='$nom$type$id' dir='$lang_dir' data-puce-nom='$nom' data-puce-type='$type' data-puce-id='$id' data-puce-action='$action'>"
409
+        . $inser_puce
410
+        . '</span>';
411
+    }
412 412
 }
413 413
 
414 414
 
415 415
 function afficher_script_statut($id, $type, $n, $img, $statut, $titre, $act = '') {
416
-	$h = generer_action_auteur('instituer_objet', "$type-$id-$statut");
417
-	$t = supprimer_tags($titre);
416
+    $h = generer_action_auteur('instituer_objet', "$type-$id-$statut");
417
+    $t = supprimer_tags($titre);
418 418
 
419
-	return "<a href=\"#\" data-puce-id=\"$id\" data-puce-type=\"$type\" data-puce-decal=\"$n\" data-puce-action=\"$h\" title=\"$t\"$act>" . http_img_pack($img, $t) . '</a>';
419
+    return "<a href=\"#\" data-puce-id=\"$id\" data-puce-type=\"$type\" data-puce-decal=\"$n\" data-puce-action=\"$h\" title=\"$t\"$act>" . http_img_pack($img, $t) . '</a>';
420 420
 }
421 421
 
422 422
 // compat
423 423
 // La couleur du statut
424 424
 
425 425
 function puce_statut($statut, $atts = '') {
426
-	$src = statut_image('article', $statut);
427
-	if (!$src) {
428
-		return '';
429
-	}
426
+    $src = statut_image('article', $statut);
427
+    if (!$src) {
428
+        return '';
429
+    }
430 430
 
431
-	return http_img_pack($src, statut_titre('article', $statut), $atts);
431
+    return http_img_pack($src, statut_titre('article', $statut), $atts);
432 432
 }
Please login to merge, or discard this patch.
ecrire/inc/filtres_mini.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -45,10 +45,10 @@  discard block
 block discarded – undo
45 45
 	}
46 46
 
47 47
 	if ($query) {
48
-		$url .= '?' . $query;
48
+		$url .= '?'.$query;
49 49
 	}
50 50
 
51
-	return '/' . preg_replace(',^/,S', '', $url);
51
+	return '/'.preg_replace(',^/,S', '', $url);
52 52
 }
53 53
 
54 54
 
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	if (preg_match(';^((?:[a-z]{3,33}:)?//.*?)(/.*)?$;iS', $lien, $r)) {
76 76
 		$r = array_pad($r, 3, null);
77 77
 
78
-		return $r[1] . resolve_path($r[2]);
78
+		return $r[1].resolve_path($r[2]);
79 79
 	}
80 80
 
81 81
 	# L'url site spip est un lien absolu aussi
@@ -96,13 +96,13 @@  discard block
 block discarded – undo
96 96
 	}
97 97
 	switch (substr($lien, 0, 1)) {
98 98
 		case '/':
99
-			return $debut . resolve_path($lien);
99
+			return $debut.resolve_path($lien);
100 100
 		case '#':
101
-			return $debut . resolve_path($dir . $mot . $get . $lien);
101
+			return $debut.resolve_path($dir.$mot.$get.$lien);
102 102
 		case '':
103
-			return $debut . resolve_path($dir . $mot . $get . $hash);
103
+			return $debut.resolve_path($dir.$mot.$get.$hash);
104 104
 		default:
105
-			return $debut . resolve_path($dir . $lien);
105
+			return $debut.resolve_path($dir.$lien);
106 106
 	}
107 107
 }
108 108
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 		return '';
131 131
 	}
132 132
 	if (!$base) {
133
-		$base = url_de_base() . (_DIR_RACINE ? _DIR_RESTREINT_ABS : '');
133
+		$base = url_de_base().(_DIR_RACINE ? _DIR_RESTREINT_ABS : '');
134 134
 	}
135 135
 
136 136
 	return suivre_lien($base, $url);
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
  * @param array $protocoles_autorises
154 154
  * @return bool
155 155
  */
156
-function protocole_verifier($url_absolue, $protocoles_autorises = ['http','https']) {
156
+function protocole_verifier($url_absolue, $protocoles_autorises = ['http', 'https']) {
157 157
 
158 158
 	if (preg_match(';^([a-z]{3,7})://;i', $url_absolue, $m)) {
159 159
 		$protocole = $m[1];
Please login to merge, or discard this patch.
Indentation   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 
@@ -35,20 +35,20 @@  discard block
 block discarded – undo
35 35
  * @return string URL nettoyée
36 36
  **/
37 37
 function resolve_path($url) {
38
-	[$url, $query] = array_pad(explode('?', $url, 2), 2, null);
39
-	while (
40
-		preg_match(',/\.?/,', $url, $regs)    # supprime // et /./
41
-		or preg_match(',/[^/]*/\.\./,S', $url, $regs)  # supprime /toto/../
42
-		or preg_match(',^/\.\./,S', $url, $regs) # supprime les /../ du haut
43
-	) {
44
-		$url = str_replace($regs[0], '/', $url);
45
-	}
38
+    [$url, $query] = array_pad(explode('?', $url, 2), 2, null);
39
+    while (
40
+        preg_match(',/\.?/,', $url, $regs)    # supprime // et /./
41
+        or preg_match(',/[^/]*/\.\./,S', $url, $regs)  # supprime /toto/../
42
+        or preg_match(',^/\.\./,S', $url, $regs) # supprime les /../ du haut
43
+    ) {
44
+        $url = str_replace($regs[0], '/', $url);
45
+    }
46 46
 
47
-	if ($query) {
48
-		$url .= '?' . $query;
49
-	}
47
+    if ($query) {
48
+        $url .= '?' . $query;
49
+    }
50 50
 
51
-	return '/' . preg_replace(',^/,S', '', $url);
51
+    return '/' . preg_replace(',^/,S', '', $url);
52 52
 }
53 53
 
54 54
 
@@ -69,44 +69,44 @@  discard block
 block discarded – undo
69 69
  **/
70 70
 function suivre_lien($url, $lien) {
71 71
 
72
-	$mot = null;
73
-	$get = null;
74
-	$hash = null;
75
-	if (preg_match(',^(mailto|javascript|data|tel|callto|file|ftp):,iS', $lien)) {
76
-		return $lien;
77
-	}
78
-	if (preg_match(';^((?:[a-z]{3,33}:)?//.*?)(/.*)?$;iS', $lien, $r)) {
79
-		$r = array_pad($r, 3, null);
72
+    $mot = null;
73
+    $get = null;
74
+    $hash = null;
75
+    if (preg_match(',^(mailto|javascript|data|tel|callto|file|ftp):,iS', $lien)) {
76
+        return $lien;
77
+    }
78
+    if (preg_match(';^((?:[a-z]{3,33}:)?//.*?)(/.*)?$;iS', $lien, $r)) {
79
+        $r = array_pad($r, 3, null);
80 80
 
81
-		return $r[1] . resolve_path($r[2]);
82
-	}
81
+        return $r[1] . resolve_path($r[2]);
82
+    }
83 83
 
84
-	# L'url site spip est un lien absolu aussi
85
-	if (isset($GLOBALS['meta']['adresse_site']) and $lien == $GLOBALS['meta']['adresse_site']) {
86
-		return $lien;
87
-	}
84
+    # L'url site spip est un lien absolu aussi
85
+    if (isset($GLOBALS['meta']['adresse_site']) and $lien == $GLOBALS['meta']['adresse_site']) {
86
+        return $lien;
87
+    }
88 88
 
89
-	# lien relatif, il faut verifier l'url de base
90
-	# commencer par virer la chaine de get de l'url de base
91
-	$dir = '/';
92
-	$debut = '';
93
-	if (preg_match(';^((?:[a-z]{3,7}:)?//[^/]+)(/.*?/?)?([^/#?]*)([?][^#]*)?(#.*)?$;S', $url, $regs)) {
94
-		$debut = $regs[1];
95
-		$dir = !strlen($regs[2]) ? '/' : $regs[2];
96
-		$mot = $regs[3];
97
-		$get = $regs[4] ?? '';
98
-		$hash = $regs[5] ?? '';
99
-	}
100
-	switch (substr($lien, 0, 1)) {
101
-		case '/':
102
-			return $debut . resolve_path($lien);
103
-		case '#':
104
-			return $debut . resolve_path($dir . $mot . $get . $lien);
105
-		case '':
106
-			return $debut . resolve_path($dir . $mot . $get . $hash);
107
-		default:
108
-			return $debut . resolve_path($dir . $lien);
109
-	}
89
+    # lien relatif, il faut verifier l'url de base
90
+    # commencer par virer la chaine de get de l'url de base
91
+    $dir = '/';
92
+    $debut = '';
93
+    if (preg_match(';^((?:[a-z]{3,7}:)?//[^/]+)(/.*?/?)?([^/#?]*)([?][^#]*)?(#.*)?$;S', $url, $regs)) {
94
+        $debut = $regs[1];
95
+        $dir = !strlen($regs[2]) ? '/' : $regs[2];
96
+        $mot = $regs[3];
97
+        $get = $regs[4] ?? '';
98
+        $hash = $regs[5] ?? '';
99
+    }
100
+    switch (substr($lien, 0, 1)) {
101
+        case '/':
102
+            return $debut . resolve_path($lien);
103
+        case '#':
104
+            return $debut . resolve_path($dir . $mot . $get . $lien);
105
+        case '':
106
+            return $debut . resolve_path($dir . $mot . $get . $hash);
107
+        default:
108
+            return $debut . resolve_path($dir . $lien);
109
+    }
110 110
 }
111 111
 
112 112
 
@@ -129,14 +129,14 @@  discard block
 block discarded – undo
129 129
  * @return string Texte ou URL (en absolus)
130 130
  **/
131 131
 function url_absolue($url, $base = '') {
132
-	if (strlen($url = trim($url)) == 0) {
133
-		return '';
134
-	}
135
-	if (!$base) {
136
-		$base = url_de_base() . (_DIR_RACINE ? _DIR_RESTREINT_ABS : '');
137
-	}
132
+    if (strlen($url = trim($url)) == 0) {
133
+        return '';
134
+    }
135
+    if (!$base) {
136
+        $base = url_de_base() . (_DIR_RACINE ? _DIR_RESTREINT_ABS : '');
137
+    }
138 138
 
139
-	return suivre_lien($base, $url);
139
+    return suivre_lien($base, $url);
140 140
 }
141 141
 
142 142
 /**
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
  * @return string
148 148
  */
149 149
 function protocole_implicite($url_absolue) {
150
-	return preg_replace(';^[a-z]{3,7}://;i', '//', $url_absolue);
150
+    return preg_replace(';^[a-z]{3,7}://;i', '//', $url_absolue);
151 151
 }
152 152
 
153 153
 /**
@@ -158,16 +158,16 @@  discard block
 block discarded – undo
158 158
  */
159 159
 function protocole_verifier($url_absolue, $protocoles_autorises = ['http','https']) {
160 160
 
161
-	if (preg_match(';^([a-z]{3,7})://;i', $url_absolue, $m)) {
162
-		$protocole = $m[1];
163
-		if (
164
-			in_array($protocole, $protocoles_autorises)
165
-			or in_array(strtolower($protocole), array_map('strtolower', $protocoles_autorises))
166
-		) {
167
-			return true;
168
-		}
169
-	}
170
-	return false;
161
+    if (preg_match(';^([a-z]{3,7})://;i', $url_absolue, $m)) {
162
+        $protocole = $m[1];
163
+        if (
164
+            in_array($protocole, $protocoles_autorises)
165
+            or in_array(strtolower($protocole), array_map('strtolower', $protocoles_autorises))
166
+        ) {
167
+            return true;
168
+        }
169
+    }
170
+    return false;
171 171
 }
172 172
 
173 173
 /**
@@ -184,27 +184,27 @@  discard block
 block discarded – undo
184 184
  * @return string Texte avec des URLs absolues
185 185
  **/
186 186
 function liens_absolus($texte, $base = '') {
187
-	if (preg_match_all(',(<(a|link|image|img|script)\s[^<>]*(href|src)=[^<>]*>),imsS', $texte, $liens, PREG_SET_ORDER)) {
188
-		if (!function_exists('extraire_attribut')) {
189
-			include_spip('inc/filtres');
190
-		}
191
-		foreach ($liens as $lien) {
192
-			foreach (['href', 'src'] as $attr) {
193
-				$href = extraire_attribut($lien[0], $attr);
194
-				if (strlen($href) > 0) {
195
-					if (!preg_match(';^((?:[a-z]{3,7}:)?//);iS', $href)) {
196
-						$abs = url_absolue($href, $base);
197
-						if (rtrim($href, '/') !== rtrim($abs, '/') and !preg_match('/^#/', $href)) {
198
-							$texte_lien = inserer_attribut($lien[0], $attr, $abs);
199
-							$texte = str_replace($lien[0], $texte_lien, $texte);
200
-						}
201
-					}
202
-				}
203
-			}
204
-		}
205
-	}
187
+    if (preg_match_all(',(<(a|link|image|img|script)\s[^<>]*(href|src)=[^<>]*>),imsS', $texte, $liens, PREG_SET_ORDER)) {
188
+        if (!function_exists('extraire_attribut')) {
189
+            include_spip('inc/filtres');
190
+        }
191
+        foreach ($liens as $lien) {
192
+            foreach (['href', 'src'] as $attr) {
193
+                $href = extraire_attribut($lien[0], $attr);
194
+                if (strlen($href) > 0) {
195
+                    if (!preg_match(';^((?:[a-z]{3,7}:)?//);iS', $href)) {
196
+                        $abs = url_absolue($href, $base);
197
+                        if (rtrim($href, '/') !== rtrim($abs, '/') and !preg_match('/^#/', $href)) {
198
+                            $texte_lien = inserer_attribut($lien[0], $attr, $abs);
199
+                            $texte = str_replace($lien[0], $texte_lien, $texte);
200
+                        }
201
+                    }
202
+                }
203
+            }
204
+        }
205
+    }
206 206
 
207
-	return $texte;
207
+    return $texte;
208 208
 }
209 209
 
210 210
 
@@ -220,11 +220,11 @@  discard block
 block discarded – undo
220 220
  * @return string Texte ou URL (en absolus)
221 221
  **/
222 222
 function abs_url($texte, $base = '') {
223
-	if ($GLOBALS['mode_abs_url'] == 'url') {
224
-		return url_absolue($texte, $base);
225
-	} else {
226
-		return liens_absolus($texte, $base);
227
-	}
223
+    if ($GLOBALS['mode_abs_url'] == 'url') {
224
+        return url_absolue($texte, $base);
225
+    } else {
226
+        return liens_absolus($texte, $base);
227
+    }
228 228
 }
229 229
 
230 230
 /**
@@ -237,11 +237,11 @@  discard block
 block discarded – undo
237 237
  * @return string
238 238
  */
239 239
 function spip_htmlspecialchars($string, $flags = null, $encoding = 'UTF-8', $double_encode = true) {
240
-	if (is_null($flags)) {
241
-		$flags = ENT_COMPAT | ENT_HTML401;
242
-	}
240
+    if (is_null($flags)) {
241
+        $flags = ENT_COMPAT | ENT_HTML401;
242
+    }
243 243
 
244
-	return htmlspecialchars($string, $flags, $encoding, $double_encode);
244
+    return htmlspecialchars($string, $flags, $encoding, $double_encode);
245 245
 }
246 246
 
247 247
 /**
@@ -254,9 +254,9 @@  discard block
 block discarded – undo
254 254
  * @return string
255 255
  */
256 256
 function spip_htmlentities($string, $flags = null, $encoding = 'UTF-8', $double_encode = true) {
257
-	if (is_null($flags)) {
258
-		$flags = ENT_COMPAT | ENT_HTML401;
259
-	}
257
+    if (is_null($flags)) {
258
+        $flags = ENT_COMPAT | ENT_HTML401;
259
+    }
260 260
 
261
-	return htmlentities($string, $flags, $encoding, $double_encode);
261
+    return htmlentities($string, $flags, $encoding, $double_encode);
262 262
 }
Please login to merge, or discard this patch.
ecrire/inc/filtres_images_lib_mini.php 3 patches
Braces   +4 added lines, -9 removed lines patch added patch discarded remove patch
@@ -524,8 +524,7 @@  discard block
 block discarded – undo
524 524
 			process_image_svg_identite($ret);
525 525
 			$ret['creer'] = false;
526 526
 		}
527
-	}
528
-	else {
527
+	} else {
529 528
 		if (!function_exists($ret['fonction_imagecreatefrom'])) {
530 529
 			return false;
531 530
 		}
@@ -628,8 +627,7 @@  discard block
 block discarded – undo
628 627
 
629 628
 	if (isset($info['mime'])) {
630 629
 		$mime = $info['mime'];
631
-	}
632
-	else {
630
+	} else {
633 631
 		$mime = image_type_to_mime_type($info[2]);
634 632
 	}
635 633
 
@@ -1408,9 +1406,7 @@  discard block
 block discarded – undo
1408 1406
 	if ($srcWidth and $srcWidth <= $maxWidth and $srcHeight <= $maxHeight) {
1409 1407
 		$vignette = $destination . '.' . $format;
1410 1408
 		@copy($image, $vignette);
1411
-	}
1412
-
1413
-	elseif ($valeurs['format_source'] === 'svg') {
1409
+	} elseif ($valeurs['format_source'] === 'svg') {
1414 1410
 		if ($svg = svg_redimensionner($valeurs['fichier'], $destWidth, $destHeight)) {
1415 1411
 			$format_sortie = 'svg';
1416 1412
 			$vignette = $destination . '.' . $format_sortie;
@@ -1846,8 +1842,7 @@  discard block
 block discarded – undo
1846 1842
 		$date = test_espace_prive() ? ('?' . $date) : '';
1847 1843
 
1848 1844
 		return _image_ecrire_tag($image, ['src' => "$logo$date", 'width' => $destWidth, 'height' => $destHeight]);
1849
-	}
1850
-	else {
1845
+	} else {
1851 1846
 		# BMP, tiff ... les redacteurs osent tout!
1852 1847
 		return $img;
1853 1848
 	}
Please login to merge, or discard this patch.
Indentation   +1351 added lines, -1351 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
  */
19 19
 
20 20
 if (!defined('_ECRIRE_INC_VERSION')) {
21
-	return;
21
+    return;
22 22
 }
23 23
 include_spip('inc/filtres'); // par precaution
24 24
 include_spip('inc/filtres_images_mini'); // par precaution
@@ -38,21 +38,21 @@  discard block
 block discarded – undo
38 38
  *     Le code de la couleur en hexadécimal.
39 39
  */
40 40
 function _couleur_dec_to_hex($red, $green, $blue) {
41
-	$red = dechex($red);
42
-	$green = dechex($green);
43
-	$blue = dechex($blue);
44
-
45
-	if (strlen($red) == 1) {
46
-		$red = '0' . $red;
47
-	}
48
-	if (strlen($green) == 1) {
49
-		$green = '0' . $green;
50
-	}
51
-	if (strlen($blue) == 1) {
52
-		$blue = '0' . $blue;
53
-	}
54
-
55
-	return "$red$green$blue";
41
+    $red = dechex($red);
42
+    $green = dechex($green);
43
+    $blue = dechex($blue);
44
+
45
+    if (strlen($red) == 1) {
46
+        $red = '0' . $red;
47
+    }
48
+    if (strlen($green) == 1) {
49
+        $green = '0' . $green;
50
+    }
51
+    if (strlen($blue) == 1) {
52
+        $blue = '0' . $blue;
53
+    }
54
+
55
+    return "$red$green$blue";
56 56
 }
57 57
 
58 58
 /**
@@ -64,17 +64,17 @@  discard block
 block discarded – undo
64 64
  *     Un tableau des 3 éléments : rouge, vert, bleu.
65 65
  */
66 66
 function _couleur_hex_to_dec($couleur) {
67
-	$couleur = couleur_html_to_hex($couleur);
68
-	$couleur = ltrim($couleur, '#');
69
-	if (strlen($couleur) === 3) {
70
-		$couleur = $couleur[0] . $couleur[0] . $couleur[1] . $couleur[1] . $couleur[2] . $couleur[2];
71
-	}
72
-	$retour = [];
73
-	$retour['red'] = hexdec(substr($couleur, 0, 2));
74
-	$retour['green'] = hexdec(substr($couleur, 2, 2));
75
-	$retour['blue'] = hexdec(substr($couleur, 4, 2));
76
-
77
-	return $retour;
67
+    $couleur = couleur_html_to_hex($couleur);
68
+    $couleur = ltrim($couleur, '#');
69
+    if (strlen($couleur) === 3) {
70
+        $couleur = $couleur[0] . $couleur[0] . $couleur[1] . $couleur[1] . $couleur[2] . $couleur[2];
71
+    }
72
+    $retour = [];
73
+    $retour['red'] = hexdec(substr($couleur, 0, 2));
74
+    $retour['green'] = hexdec(substr($couleur, 2, 2));
75
+    $retour['blue'] = hexdec(substr($couleur, 4, 2));
76
+
77
+    return $retour;
78 78
 }
79 79
 
80 80
 
@@ -91,8 +91,8 @@  discard block
 block discarded – undo
91 91
  *     Le code de la couleur en hexadécimal.
92 92
  */
93 93
 function _couleur_hsl_to_hex($hue, $saturation, $lightness) {
94
-	$rgb = _couleur_hsl_to_rgb($hue, $saturation, $lightness);
95
-	return _couleur_dec_to_hex($rgb['r'], $rgb['g'], $rgb['b']);
94
+    $rgb = _couleur_hsl_to_rgb($hue, $saturation, $lightness);
95
+    return _couleur_dec_to_hex($rgb['r'], $rgb['g'], $rgb['b']);
96 96
 }
97 97
 
98 98
 /**
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
  *     Un tableau des 3 éléments : teinte, saturation, luminosité.
105 105
  */
106 106
 function _couleur_hex_to_hsl($couleur) {
107
-	$rgb = _couleur_hex_to_dec($couleur);
108
-	return _couleur_rgb_to_hsl($rgb['red'], $rgb['green'], $rgb['blue']);
107
+    $rgb = _couleur_hex_to_dec($couleur);
108
+    return _couleur_rgb_to_hsl($rgb['red'], $rgb['green'], $rgb['blue']);
109 109
 }
110 110
 
111 111
 /**
@@ -120,59 +120,59 @@  discard block
 block discarded – undo
120 120
  * @return array
121 121
  */
122 122
 function _couleur_rgb_to_hsl($R, $G, $B) {
123
-	$H = null;
124
-	$var_R = ($R / 255); // Where RGB values = 0 ÷ 255
125
-	$var_G = ($G / 255);
126
-	$var_B = ($B / 255);
127
-
128
-	$var_Min = min($var_R, $var_G, $var_B);   //Min. value of RGB
129
-	$var_Max = max($var_R, $var_G, $var_B);   //Max. value of RGB
130
-	$del_Max = $var_Max - $var_Min;           //Delta RGB value
131
-
132
-	$L = ($var_Max + $var_Min) / 2;
133
-
134
-	if ($del_Max == 0) {
135
-		//This is a gray, no chroma...
136
-		$H = 0; //HSL results = 0 ÷ 1
137
-		$S = 0;
138
-	} else {
139
-		// Chromatic data...
140
-		if ($L < 0.5) {
141
-			$S = $del_Max / ($var_Max + $var_Min);
142
-		} else {
143
-			$S = $del_Max / (2 - $var_Max - $var_Min);
144
-		}
145
-
146
-		$del_R = ((($var_Max - $var_R) / 6) + ($del_Max / 2)) / $del_Max;
147
-		$del_G = ((($var_Max - $var_G) / 6) + ($del_Max / 2)) / $del_Max;
148
-		$del_B = ((($var_Max - $var_B) / 6) + ($del_Max / 2)) / $del_Max;
149
-
150
-		if ($var_R == $var_Max) {
151
-			$H = $del_B - $del_G;
152
-		} else {
153
-			if ($var_G == $var_Max) {
154
-				$H = (1 / 3) + $del_R - $del_B;
155
-			} else {
156
-				if ($var_B == $var_Max) {
157
-					$H = (2 / 3) + $del_G - $del_R;
158
-				}
159
-			}
160
-		}
161
-
162
-		if ($H < 0) {
163
-			$H += 1;
164
-		}
165
-		if ($H > 1) {
166
-			$H -= 1;
167
-		}
168
-	}
169
-
170
-	$ret = [];
171
-	$ret['h'] = $H;
172
-	$ret['s'] = $S;
173
-	$ret['l'] = $L;
174
-
175
-	return $ret;
123
+    $H = null;
124
+    $var_R = ($R / 255); // Where RGB values = 0 ÷ 255
125
+    $var_G = ($G / 255);
126
+    $var_B = ($B / 255);
127
+
128
+    $var_Min = min($var_R, $var_G, $var_B);   //Min. value of RGB
129
+    $var_Max = max($var_R, $var_G, $var_B);   //Max. value of RGB
130
+    $del_Max = $var_Max - $var_Min;           //Delta RGB value
131
+
132
+    $L = ($var_Max + $var_Min) / 2;
133
+
134
+    if ($del_Max == 0) {
135
+        //This is a gray, no chroma...
136
+        $H = 0; //HSL results = 0 ÷ 1
137
+        $S = 0;
138
+    } else {
139
+        // Chromatic data...
140
+        if ($L < 0.5) {
141
+            $S = $del_Max / ($var_Max + $var_Min);
142
+        } else {
143
+            $S = $del_Max / (2 - $var_Max - $var_Min);
144
+        }
145
+
146
+        $del_R = ((($var_Max - $var_R) / 6) + ($del_Max / 2)) / $del_Max;
147
+        $del_G = ((($var_Max - $var_G) / 6) + ($del_Max / 2)) / $del_Max;
148
+        $del_B = ((($var_Max - $var_B) / 6) + ($del_Max / 2)) / $del_Max;
149
+
150
+        if ($var_R == $var_Max) {
151
+            $H = $del_B - $del_G;
152
+        } else {
153
+            if ($var_G == $var_Max) {
154
+                $H = (1 / 3) + $del_R - $del_B;
155
+            } else {
156
+                if ($var_B == $var_Max) {
157
+                    $H = (2 / 3) + $del_G - $del_R;
158
+                }
159
+            }
160
+        }
161
+
162
+        if ($H < 0) {
163
+            $H += 1;
164
+        }
165
+        if ($H > 1) {
166
+            $H -= 1;
167
+        }
168
+    }
169
+
170
+    $ret = [];
171
+    $ret['h'] = $H;
172
+    $ret['s'] = $S;
173
+    $ret['l'] = $L;
174
+
175
+    return $ret;
176 176
 }
177 177
 
178 178
 
@@ -188,52 +188,52 @@  discard block
 block discarded – undo
188 188
  * @return array
189 189
  */
190 190
 function _couleur_hsl_to_rgb($H, $S, $L) {
191
-	// helper
192
-	$hue_2_rgb = function ($v1, $v2, $vH) {
193
-		if ($vH < 0) {
194
-			$vH += 1;
195
-		}
196
-		if ($vH > 1) {
197
-			$vH -= 1;
198
-		}
199
-		if ((6 * $vH) < 1) {
200
-			return ($v1 + ($v2 - $v1) * 6 * $vH);
201
-		}
202
-		if ((2 * $vH) < 1) {
203
-			return ($v2);
204
-		}
205
-		if ((3 * $vH) < 2) {
206
-			return ($v1 + ($v2 - $v1) * ((2 / 3) - $vH) * 6);
207
-		}
208
-
209
-		return ($v1);
210
-	};
211
-
212
-	if ($S == 0) {
213
-		// HSV values = 0 -> 1
214
-		$R = $L * 255;
215
-		$G = $L * 255;
216
-		$B = $L * 255;
217
-	} else {
218
-		if ($L < 0.5) {
219
-			$var_2 = $L * (1 + $S);
220
-		} else {
221
-			$var_2 = ($L + $S) - ($S * $L);
222
-		}
223
-
224
-		$var_1 = 2 * $L - $var_2;
225
-
226
-		$R = 255 * $hue_2_rgb($var_1, $var_2, $H + (1 / 3));
227
-		$G = 255 * $hue_2_rgb($var_1, $var_2, $H);
228
-		$B = 255 * $hue_2_rgb($var_1, $var_2, $H - (1 / 3));
229
-	}
230
-
231
-	$ret = [];
232
-	$ret['r'] = floor($R);
233
-	$ret['g'] = floor($G);
234
-	$ret['b'] = floor($B);
235
-
236
-	return $ret;
191
+    // helper
192
+    $hue_2_rgb = function ($v1, $v2, $vH) {
193
+        if ($vH < 0) {
194
+            $vH += 1;
195
+        }
196
+        if ($vH > 1) {
197
+            $vH -= 1;
198
+        }
199
+        if ((6 * $vH) < 1) {
200
+            return ($v1 + ($v2 - $v1) * 6 * $vH);
201
+        }
202
+        if ((2 * $vH) < 1) {
203
+            return ($v2);
204
+        }
205
+        if ((3 * $vH) < 2) {
206
+            return ($v1 + ($v2 - $v1) * ((2 / 3) - $vH) * 6);
207
+        }
208
+
209
+        return ($v1);
210
+    };
211
+
212
+    if ($S == 0) {
213
+        // HSV values = 0 -> 1
214
+        $R = $L * 255;
215
+        $G = $L * 255;
216
+        $B = $L * 255;
217
+    } else {
218
+        if ($L < 0.5) {
219
+            $var_2 = $L * (1 + $S);
220
+        } else {
221
+            $var_2 = ($L + $S) - ($S * $L);
222
+        }
223
+
224
+        $var_1 = 2 * $L - $var_2;
225
+
226
+        $R = 255 * $hue_2_rgb($var_1, $var_2, $H + (1 / 3));
227
+        $G = 255 * $hue_2_rgb($var_1, $var_2, $H);
228
+        $B = 255 * $hue_2_rgb($var_1, $var_2, $H - (1 / 3));
229
+    }
230
+
231
+    $ret = [];
232
+    $ret['r'] = floor($R);
233
+    $ret['g'] = floor($G);
234
+    $ret['b'] = floor($B);
235
+
236
+    return $ret;
237 237
 }
238 238
 
239 239
 /**
@@ -250,11 +250,11 @@  discard block
 block discarded – undo
250 250
  *     true si il faut supprimer le fichier temporaire ; false sinon.
251 251
  */
252 252
 function statut_effacer_images_temporaires($stat) {
253
-	static $statut = false; // par defaut on grave toute les images
254
-	if ($stat === 'get') {
255
-		return $statut;
256
-	}
257
-	$statut = $stat ? true : false;
253
+    static $statut = false; // par defaut on grave toute les images
254
+    if ($stat === 'get') {
255
+        return $statut;
256
+    }
257
+    $statut = $stat ? true : false;
258 258
 }
259 259
 
260 260
 
@@ -307,243 +307,243 @@  discard block
 block discarded – undo
307 307
  *     - array : tableau décrivant de l'image
308 308
  */
309 309
 function _image_valeurs_trans($img, $effet, $forcer_format = false, $fonction_creation = null, $find_in_path = false, $support_svg = false) {
310
-	$ret = [];
311
-	$f = null;
312
-	static $images_recalcul = [];
313
-	if (strlen($img) == 0) {
314
-		return false;
315
-	}
316
-
317
-	$source = trim(extraire_attribut($img, 'src') ?? '');
318
-	if (strlen($source) < 1) {
319
-		$source = $img;
320
-		$img = "<img src='$source' />";
321
-	} elseif (
322
-		preg_match('@^data:image/([^;]*);base64,(.*)$@isS', $source, $regs)
323
-		and $extension = _image_trouver_extension_depuis_mime('image/' . $regs[1])
324
-		and in_array($extension, _image_extensions_acceptees_en_entree())
325
-	) {
326
-		# gerer img src="data:....base64"
327
-		$local = sous_repertoire(_DIR_VAR, 'image-data') . md5($regs[2]) . '.' . _image_extension_normalisee($extension);
328
-		if (!file_exists($local)) {
329
-			ecrire_fichier($local, base64_decode($regs[2]));
330
-		}
331
-		if ($sanitizer = charger_fonction($extension, 'sanitizer', true)) {
332
-			$sanitizer($local);
333
-		}
334
-		$source = $local;
335
-		$img = inserer_attribut($img, 'src', $source);
336
-		# eviter les mauvaises surprises lors de conversions de format
337
-		$img = inserer_attribut($img, 'width', '');
338
-		$img = inserer_attribut($img, 'height', '');
339
-	}
340
-
341
-	// les protocoles web prennent au moins 3 lettres
342
-	if (tester_url_absolue($source)) {
343
-		include_spip('inc/distant');
344
-		$fichier = _DIR_RACINE . copie_locale($source);
345
-		if (!$fichier) {
346
-			return '';
347
-		}
348
-		if (
349
-			$extension = _image_trouver_extension($fichier)
350
-			and $sanitizer = charger_fonction($extension, 'sanitizer', true)
351
-		) {
352
-			$sanitizer($fichier);
353
-		}
354
-	} else {
355
-		// enlever le timestamp eventuel
356
-		if (strpos($source, '?') !== false) {
357
-			$source = preg_replace(',[?][0-9]+$,', '', $source);
358
-		}
359
-		if (
360
-			strpos($source, '?') !== false
361
-			and strncmp($source, _DIR_IMG, strlen(_DIR_IMG)) == 0
362
-			and file_exists($f = preg_replace(',[?].*$,', '', $source))
363
-		) {
364
-			$source = $f;
365
-		}
366
-		$fichier = $source;
367
-	}
368
-
369
-	$terminaison_dest = '';
370
-	if ($terminaison = _image_trouver_extension($fichier)) {
371
-		$terminaison_dest = ($terminaison == 'gif') ? 'png' : $terminaison;
372
-	}
373
-
374
-	if (
375
-		$forcer_format !== false
376
-		// ignorer forcer_format si on a une image svg, que le filtre appelant ne supporte pas SVG, et que le forcage est un autre format image
377
-		and ($terminaison_dest !== 'svg' or $support_svg or !in_array($forcer_format, _image_extensions_acceptees_en_sortie()))
378
-	) {
379
-		$terminaison_dest = $forcer_format;
380
-	}
381
-
382
-	if (!$terminaison_dest) {
383
-		return false;
384
-	}
385
-
386
-	$nom_fichier = substr($fichier, 0, strlen($fichier) - (strlen($terminaison) + 1));
387
-	$fichier_dest = $nom_fichier;
388
-	if (
389
-		($find_in_path and $f = find_in_path($fichier) and $fichier = $f)
390
-		or @file_exists($f = $fichier)
391
-	) {
392
-		// on passe la balise img a taille image qui exraira les attributs si possible
393
-		// au lieu de faire un acces disque sur le fichier
394
-		[$ret['hauteur'], $ret['largeur']] = taille_image($find_in_path ? $f : $img);
395
-		$date_src = @filemtime($f);
396
-	} elseif (
397
-		@file_exists($f = "$fichier.src")
398
-		and lire_fichier($f, $valeurs)
399
-		and $valeurs = unserialize($valeurs)
400
-		and isset($valeurs['hauteur_dest'])
401
-		and isset($valeurs['largeur_dest'])
402
-	) {
403
-		$ret['hauteur'] = $valeurs['hauteur_dest'];
404
-		$ret['largeur'] = $valeurs['largeur_dest'];
405
-		$date_src = $valeurs['date'];
406
-	} // pas de fichier source par la
407
-	else {
408
-		return false;
409
-	}
410
-
411
-	// pas de taille mesurable
412
-	if (!($ret['hauteur'] or $ret['largeur'])) {
413
-		return false;
414
-	}
415
-
416
-	// les images calculees dependent du chemin du fichier source
417
-	// pour une meme image source et un meme filtre on aboutira a 2 fichiers selon si l'appel est dans le public ou dans le prive
418
-	// ce n'est pas totalement optimal en terme de stockage, mais chaque image est associee a un fichier .src
419
-	// qui contient la methode de reconstrucion (le filtre + les arguments d'appel) et les arguments different entre prive et public
420
-	// la mise en commun du fichier image cree donc un bug et des problemes qui necessiteraient beaucoup de complexite de code
421
-	// alors que ca concerne peu de site au final
422
-	// la release de r23632+r23633+r23634 a provoque peu de remontee de bug attestant du peu de sites impactes
423
-	$identifiant = $fichier;
424
-
425
-	// cas general :
426
-	// on a un dossier cache commun et un nom de fichier qui varie avec l'effet
427
-	// cas particulier de reduire :
428
-	// un cache par dimension, et le nom de fichier est conserve, suffixe par la dimension aussi
429
-	$cache = 'cache-gd2';
430
-	if (substr($effet, 0, 7) == 'reduire') {
431
-		[, $maxWidth, $maxHeight] = explode('-', $effet);
432
-		[$destWidth, $destHeight] = _image_ratio($ret['largeur'], $ret['hauteur'], $maxWidth, $maxHeight);
433
-		$ret['largeur_dest'] = $destWidth;
434
-		$ret['hauteur_dest'] = $destHeight;
435
-		$effet = "L{$destWidth}xH$destHeight";
436
-		$cache = 'cache-vignettes';
437
-		$fichier_dest = basename($fichier_dest);
438
-		if (($ret['largeur'] <= $maxWidth) && ($ret['hauteur'] <= $maxHeight)) {
439
-			// on garde la terminaison initiale car image simplement copiee
440
-			// et on postfixe son nom avec un md5 du path
441
-			$terminaison_dest = $terminaison;
442
-			$fichier_dest .= '-' . substr(md5("$identifiant"), 0, 5);
443
-		} else {
444
-			$fichier_dest .= '-' . substr(md5("$identifiant-$effet"), 0, 5);
445
-		}
446
-		$cache = sous_repertoire(_DIR_VAR, $cache);
447
-		$cache = sous_repertoire($cache, $effet);
448
-	} else {
449
-		$fichier_dest = md5("$identifiant-$effet");
450
-		$cache = sous_repertoire(_DIR_VAR, $cache);
451
-		$cache = sous_repertoire($cache, substr($fichier_dest, 0, 2));
452
-		$fichier_dest = substr($fichier_dest, 2);
453
-	}
454
-
455
-	$fichier_dest = $cache . $fichier_dest . '.' . $terminaison_dest;
456
-
457
-	$GLOBALS['images_calculees'][] = $fichier_dest;
458
-
459
-	$creer = true;
460
-	// si recalcul des images demande, recalculer chaque image une fois
461
-	if (defined('_VAR_IMAGES') and _VAR_IMAGES and !isset($images_recalcul[$fichier_dest])) {
462
-		$images_recalcul[$fichier_dest] = true;
463
-	} else {
464
-		if (@file_exists($f = $fichier_dest)) {
465
-			if (filemtime($f) >= $date_src) {
466
-				$creer = false;
467
-			}
468
-		} else {
469
-			if (
470
-				@file_exists($f = "$fichier_dest.src")
471
-				and lire_fichier($f, $valeurs)
472
-				and $valeurs = unserialize($valeurs)
473
-				and $valeurs['date'] >= $date_src
474
-			) {
475
-				$creer = false;
476
-			}
477
-		}
478
-	}
479
-	if ($creer) {
480
-		if (!@file_exists($fichier)) {
481
-			if (!@file_exists("$fichier.src")) {
482
-				spip_log("Image absente : $fichier");
483
-
484
-				return false;
485
-			}
486
-			# on reconstruit l'image source absente a partir de la chaine des .src
487
-			reconstruire_image_intermediaire($fichier);
488
-		}
489
-	}
490
-
491
-	if ($creer) {
492
-		spip_log(
493
-			'filtre image ' . ($fonction_creation ? reset($fonction_creation) : '') . "[$effet] sur $fichier",
494
-			'images' . _LOG_DEBUG
495
-		);
496
-	}
497
-
498
-	$term_fonction = _image_trouver_extension_pertinente($fichier);
499
-	$ret['fonction_imagecreatefrom'] = '_imagecreatefrom' . $term_fonction;
500
-	$ret['fichier'] = $fichier;
501
-	$ret['fonction_image'] = '_image_image' . $terminaison_dest;
502
-	$ret['fichier_dest'] = $fichier_dest;
503
-	$ret['format_source'] = _image_extension_normalisee($terminaison);
504
-	$ret['format_dest'] = $terminaison_dest;
505
-	$ret['date_src'] = $date_src;
506
-	$ret['creer'] = $creer;
507
-	$ret['class'] = extraire_attribut($img, 'class');
508
-	$ret['alt'] = extraire_attribut($img, 'alt');
509
-	$ret['style'] = extraire_attribut($img, 'style');
510
-	$ret['tag'] = $img;
511
-	if ($fonction_creation) {
512
-		$ret['reconstruction'] = $fonction_creation;
513
-		# ecrire ici comment creer le fichier, car il est pas sur qu'on l'ecrira reelement
514
-		# cas de image_reduire qui finalement ne reduit pas l'image source
515
-		# ca evite d'essayer de le creer au prochain hit si il n'est pas la
516
-		#ecrire_fichier($ret['fichier_dest'].'.src',serialize($ret),true);
517
-	}
518
-
519
-	$ret = pipeline('image_preparer_filtre', [
520
-			'args' => [
521
-				'img' => $img,
522
-				'effet' => $effet,
523
-				'forcer_format' => $forcer_format,
524
-				'fonction_creation' => $fonction_creation,
525
-				'find_in_path' => $find_in_path,
526
-			],
527
-			'data' => $ret
528
-		]);
529
-
530
-	// une globale pour le debug en cas de crash memoire
531
-	$GLOBALS['derniere_image_calculee'] = $ret;
532
-
533
-	// traiter le cas particulier des SVG : si le filtre n'a pas annonce explicitement qu'il savait faire, on delegue
534
-	if ($term_fonction === 'svg') {
535
-		if ($creer and !$support_svg) {
536
-			process_image_svg_identite($ret);
537
-			$ret['creer'] = false;
538
-		}
539
-	}
540
-	else {
541
-		if (!function_exists($ret['fonction_imagecreatefrom'])) {
542
-			return false;
543
-		}
544
-	}
545
-
546
-	return $ret;
310
+    $ret = [];
311
+    $f = null;
312
+    static $images_recalcul = [];
313
+    if (strlen($img) == 0) {
314
+        return false;
315
+    }
316
+
317
+    $source = trim(extraire_attribut($img, 'src') ?? '');
318
+    if (strlen($source) < 1) {
319
+        $source = $img;
320
+        $img = "<img src='$source' />";
321
+    } elseif (
322
+        preg_match('@^data:image/([^;]*);base64,(.*)$@isS', $source, $regs)
323
+        and $extension = _image_trouver_extension_depuis_mime('image/' . $regs[1])
324
+        and in_array($extension, _image_extensions_acceptees_en_entree())
325
+    ) {
326
+        # gerer img src="data:....base64"
327
+        $local = sous_repertoire(_DIR_VAR, 'image-data') . md5($regs[2]) . '.' . _image_extension_normalisee($extension);
328
+        if (!file_exists($local)) {
329
+            ecrire_fichier($local, base64_decode($regs[2]));
330
+        }
331
+        if ($sanitizer = charger_fonction($extension, 'sanitizer', true)) {
332
+            $sanitizer($local);
333
+        }
334
+        $source = $local;
335
+        $img = inserer_attribut($img, 'src', $source);
336
+        # eviter les mauvaises surprises lors de conversions de format
337
+        $img = inserer_attribut($img, 'width', '');
338
+        $img = inserer_attribut($img, 'height', '');
339
+    }
340
+
341
+    // les protocoles web prennent au moins 3 lettres
342
+    if (tester_url_absolue($source)) {
343
+        include_spip('inc/distant');
344
+        $fichier = _DIR_RACINE . copie_locale($source);
345
+        if (!$fichier) {
346
+            return '';
347
+        }
348
+        if (
349
+            $extension = _image_trouver_extension($fichier)
350
+            and $sanitizer = charger_fonction($extension, 'sanitizer', true)
351
+        ) {
352
+            $sanitizer($fichier);
353
+        }
354
+    } else {
355
+        // enlever le timestamp eventuel
356
+        if (strpos($source, '?') !== false) {
357
+            $source = preg_replace(',[?][0-9]+$,', '', $source);
358
+        }
359
+        if (
360
+            strpos($source, '?') !== false
361
+            and strncmp($source, _DIR_IMG, strlen(_DIR_IMG)) == 0
362
+            and file_exists($f = preg_replace(',[?].*$,', '', $source))
363
+        ) {
364
+            $source = $f;
365
+        }
366
+        $fichier = $source;
367
+    }
368
+
369
+    $terminaison_dest = '';
370
+    if ($terminaison = _image_trouver_extension($fichier)) {
371
+        $terminaison_dest = ($terminaison == 'gif') ? 'png' : $terminaison;
372
+    }
373
+
374
+    if (
375
+        $forcer_format !== false
376
+        // ignorer forcer_format si on a une image svg, que le filtre appelant ne supporte pas SVG, et que le forcage est un autre format image
377
+        and ($terminaison_dest !== 'svg' or $support_svg or !in_array($forcer_format, _image_extensions_acceptees_en_sortie()))
378
+    ) {
379
+        $terminaison_dest = $forcer_format;
380
+    }
381
+
382
+    if (!$terminaison_dest) {
383
+        return false;
384
+    }
385
+
386
+    $nom_fichier = substr($fichier, 0, strlen($fichier) - (strlen($terminaison) + 1));
387
+    $fichier_dest = $nom_fichier;
388
+    if (
389
+        ($find_in_path and $f = find_in_path($fichier) and $fichier = $f)
390
+        or @file_exists($f = $fichier)
391
+    ) {
392
+        // on passe la balise img a taille image qui exraira les attributs si possible
393
+        // au lieu de faire un acces disque sur le fichier
394
+        [$ret['hauteur'], $ret['largeur']] = taille_image($find_in_path ? $f : $img);
395
+        $date_src = @filemtime($f);
396
+    } elseif (
397
+        @file_exists($f = "$fichier.src")
398
+        and lire_fichier($f, $valeurs)
399
+        and $valeurs = unserialize($valeurs)
400
+        and isset($valeurs['hauteur_dest'])
401
+        and isset($valeurs['largeur_dest'])
402
+    ) {
403
+        $ret['hauteur'] = $valeurs['hauteur_dest'];
404
+        $ret['largeur'] = $valeurs['largeur_dest'];
405
+        $date_src = $valeurs['date'];
406
+    } // pas de fichier source par la
407
+    else {
408
+        return false;
409
+    }
410
+
411
+    // pas de taille mesurable
412
+    if (!($ret['hauteur'] or $ret['largeur'])) {
413
+        return false;
414
+    }
415
+
416
+    // les images calculees dependent du chemin du fichier source
417
+    // pour une meme image source et un meme filtre on aboutira a 2 fichiers selon si l'appel est dans le public ou dans le prive
418
+    // ce n'est pas totalement optimal en terme de stockage, mais chaque image est associee a un fichier .src
419
+    // qui contient la methode de reconstrucion (le filtre + les arguments d'appel) et les arguments different entre prive et public
420
+    // la mise en commun du fichier image cree donc un bug et des problemes qui necessiteraient beaucoup de complexite de code
421
+    // alors que ca concerne peu de site au final
422
+    // la release de r23632+r23633+r23634 a provoque peu de remontee de bug attestant du peu de sites impactes
423
+    $identifiant = $fichier;
424
+
425
+    // cas general :
426
+    // on a un dossier cache commun et un nom de fichier qui varie avec l'effet
427
+    // cas particulier de reduire :
428
+    // un cache par dimension, et le nom de fichier est conserve, suffixe par la dimension aussi
429
+    $cache = 'cache-gd2';
430
+    if (substr($effet, 0, 7) == 'reduire') {
431
+        [, $maxWidth, $maxHeight] = explode('-', $effet);
432
+        [$destWidth, $destHeight] = _image_ratio($ret['largeur'], $ret['hauteur'], $maxWidth, $maxHeight);
433
+        $ret['largeur_dest'] = $destWidth;
434
+        $ret['hauteur_dest'] = $destHeight;
435
+        $effet = "L{$destWidth}xH$destHeight";
436
+        $cache = 'cache-vignettes';
437
+        $fichier_dest = basename($fichier_dest);
438
+        if (($ret['largeur'] <= $maxWidth) && ($ret['hauteur'] <= $maxHeight)) {
439
+            // on garde la terminaison initiale car image simplement copiee
440
+            // et on postfixe son nom avec un md5 du path
441
+            $terminaison_dest = $terminaison;
442
+            $fichier_dest .= '-' . substr(md5("$identifiant"), 0, 5);
443
+        } else {
444
+            $fichier_dest .= '-' . substr(md5("$identifiant-$effet"), 0, 5);
445
+        }
446
+        $cache = sous_repertoire(_DIR_VAR, $cache);
447
+        $cache = sous_repertoire($cache, $effet);
448
+    } else {
449
+        $fichier_dest = md5("$identifiant-$effet");
450
+        $cache = sous_repertoire(_DIR_VAR, $cache);
451
+        $cache = sous_repertoire($cache, substr($fichier_dest, 0, 2));
452
+        $fichier_dest = substr($fichier_dest, 2);
453
+    }
454
+
455
+    $fichier_dest = $cache . $fichier_dest . '.' . $terminaison_dest;
456
+
457
+    $GLOBALS['images_calculees'][] = $fichier_dest;
458
+
459
+    $creer = true;
460
+    // si recalcul des images demande, recalculer chaque image une fois
461
+    if (defined('_VAR_IMAGES') and _VAR_IMAGES and !isset($images_recalcul[$fichier_dest])) {
462
+        $images_recalcul[$fichier_dest] = true;
463
+    } else {
464
+        if (@file_exists($f = $fichier_dest)) {
465
+            if (filemtime($f) >= $date_src) {
466
+                $creer = false;
467
+            }
468
+        } else {
469
+            if (
470
+                @file_exists($f = "$fichier_dest.src")
471
+                and lire_fichier($f, $valeurs)
472
+                and $valeurs = unserialize($valeurs)
473
+                and $valeurs['date'] >= $date_src
474
+            ) {
475
+                $creer = false;
476
+            }
477
+        }
478
+    }
479
+    if ($creer) {
480
+        if (!@file_exists($fichier)) {
481
+            if (!@file_exists("$fichier.src")) {
482
+                spip_log("Image absente : $fichier");
483
+
484
+                return false;
485
+            }
486
+            # on reconstruit l'image source absente a partir de la chaine des .src
487
+            reconstruire_image_intermediaire($fichier);
488
+        }
489
+    }
490
+
491
+    if ($creer) {
492
+        spip_log(
493
+            'filtre image ' . ($fonction_creation ? reset($fonction_creation) : '') . "[$effet] sur $fichier",
494
+            'images' . _LOG_DEBUG
495
+        );
496
+    }
497
+
498
+    $term_fonction = _image_trouver_extension_pertinente($fichier);
499
+    $ret['fonction_imagecreatefrom'] = '_imagecreatefrom' . $term_fonction;
500
+    $ret['fichier'] = $fichier;
501
+    $ret['fonction_image'] = '_image_image' . $terminaison_dest;
502
+    $ret['fichier_dest'] = $fichier_dest;
503
+    $ret['format_source'] = _image_extension_normalisee($terminaison);
504
+    $ret['format_dest'] = $terminaison_dest;
505
+    $ret['date_src'] = $date_src;
506
+    $ret['creer'] = $creer;
507
+    $ret['class'] = extraire_attribut($img, 'class');
508
+    $ret['alt'] = extraire_attribut($img, 'alt');
509
+    $ret['style'] = extraire_attribut($img, 'style');
510
+    $ret['tag'] = $img;
511
+    if ($fonction_creation) {
512
+        $ret['reconstruction'] = $fonction_creation;
513
+        # ecrire ici comment creer le fichier, car il est pas sur qu'on l'ecrira reelement
514
+        # cas de image_reduire qui finalement ne reduit pas l'image source
515
+        # ca evite d'essayer de le creer au prochain hit si il n'est pas la
516
+        #ecrire_fichier($ret['fichier_dest'].'.src',serialize($ret),true);
517
+    }
518
+
519
+    $ret = pipeline('image_preparer_filtre', [
520
+            'args' => [
521
+                'img' => $img,
522
+                'effet' => $effet,
523
+                'forcer_format' => $forcer_format,
524
+                'fonction_creation' => $fonction_creation,
525
+                'find_in_path' => $find_in_path,
526
+            ],
527
+            'data' => $ret
528
+        ]);
529
+
530
+    // une globale pour le debug en cas de crash memoire
531
+    $GLOBALS['derniere_image_calculee'] = $ret;
532
+
533
+    // traiter le cas particulier des SVG : si le filtre n'a pas annonce explicitement qu'il savait faire, on delegue
534
+    if ($term_fonction === 'svg') {
535
+        if ($creer and !$support_svg) {
536
+            process_image_svg_identite($ret);
537
+            $ret['creer'] = false;
538
+        }
539
+    }
540
+    else {
541
+        if (!function_exists($ret['fonction_imagecreatefrom'])) {
542
+            return false;
543
+        }
544
+    }
545
+
546
+    return $ret;
547 547
 }
548 548
 
549 549
 
@@ -552,53 +552,53 @@  discard block
 block discarded – undo
552 552
  * @return array
553 553
  */
554 554
 function _image_extensions_acceptees_en_entree() {
555
-	static $extensions = null;
556
-	if (empty($extensions)) {
557
-		$extensions = ['png', 'gif', 'jpg', 'jpeg'];
558
-		if (!empty($GLOBALS['meta']['gd_formats'])) {
559
-			// action=tester renseigne gd_formats et detecte le support de webp
560
-			$extensions = array_merge(explode(',', $GLOBALS['meta']['gd_formats']));
561
-			$extensions = array_map('trim', $extensions);
562
-			$extensions = array_filter($extensions);
563
-			$extensions = array_unique($extensions);
564
-			if (in_array('jpg', $extensions)) { $extensions[] = 'jpeg';
565
-			}
566
-		}
567
-		$extensions[] = 'svg'; // on le supporte toujours avec des fonctions specifiques
568
-	}
569
-
570
-	return $extensions;
555
+    static $extensions = null;
556
+    if (empty($extensions)) {
557
+        $extensions = ['png', 'gif', 'jpg', 'jpeg'];
558
+        if (!empty($GLOBALS['meta']['gd_formats'])) {
559
+            // action=tester renseigne gd_formats et detecte le support de webp
560
+            $extensions = array_merge(explode(',', $GLOBALS['meta']['gd_formats']));
561
+            $extensions = array_map('trim', $extensions);
562
+            $extensions = array_filter($extensions);
563
+            $extensions = array_unique($extensions);
564
+            if (in_array('jpg', $extensions)) { $extensions[] = 'jpeg';
565
+            }
566
+        }
567
+        $extensions[] = 'svg'; // on le supporte toujours avec des fonctions specifiques
568
+    }
569
+
570
+    return $extensions;
571 571
 }
572 572
 
573 573
 /**
574 574
  * @return array|string[]|null
575 575
  */
576 576
 function _image_extensions_acceptees_en_sortie() {
577
-	static $extensions = null;
578
-	if (empty($extensions)) {
579
-		$extensions = _image_extensions_acceptees_en_entree();
580
-		$extensions = array_diff($extensions, ['jpeg']);
581
-		if (in_array('gif', $extensions) and !function_exists('imagegif')) {
582
-			$extensions = array_diff($extensions, ['gif']);
583
-		}
584
-		if (in_array('webp', $extensions) and !function_exists('imagewebp')) {
585
-			$extensions = array_diff($extensions, ['webp']);
586
-		}
587
-	}
588
-
589
-	return $extensions;
577
+    static $extensions = null;
578
+    if (empty($extensions)) {
579
+        $extensions = _image_extensions_acceptees_en_entree();
580
+        $extensions = array_diff($extensions, ['jpeg']);
581
+        if (in_array('gif', $extensions) and !function_exists('imagegif')) {
582
+            $extensions = array_diff($extensions, ['gif']);
583
+        }
584
+        if (in_array('webp', $extensions) and !function_exists('imagewebp')) {
585
+            $extensions = array_diff($extensions, ['webp']);
586
+        }
587
+    }
588
+
589
+    return $extensions;
590 590
 }
591 591
 
592 592
 function _image_extension_normalisee($extension) {
593
-	$extension = strtolower($extension);
594
-	if ($extension === 'jpeg') {
595
-		$extension = 'jpg';
596
-	}
597
-	return $extension;
593
+    $extension = strtolower($extension);
594
+    if ($extension === 'jpeg') {
595
+        $extension = 'jpg';
596
+    }
597
+    return $extension;
598 598
 }
599 599
 
600 600
 function _image_extensions_conservent_transparence() {
601
-	return ['png', 'webp'];
601
+    return ['png', 'webp'];
602 602
 }
603 603
 
604 604
 
@@ -608,12 +608,12 @@  discard block
 block discarded – undo
608 608
  * @return string
609 609
  */
610 610
 function _image_trouver_extension($path) {
611
-	$preg_extensions = implode('|', _image_extensions_acceptees_en_entree());
612
-	if (preg_match(",\.($preg_extensions)($|[?]),i", $path, $regs)) {
613
-		$terminaison = strtolower($regs[1]);
614
-		return $terminaison;
615
-	}
616
-	return '';
611
+    $preg_extensions = implode('|', _image_extensions_acceptees_en_entree());
612
+    if (preg_match(",\.($preg_extensions)($|[?]),i", $path, $regs)) {
613
+        $terminaison = strtolower($regs[1]);
614
+        return $terminaison;
615
+    }
616
+    return '';
617 617
 }
618 618
 
619 619
 /**
@@ -624,33 +624,33 @@  discard block
 block discarded – undo
624 624
  * @return string Extension, dans le format attendu par les fonctions 'gd' ('jpeg' pour les .jpg par exemple)
625 625
  */
626 626
 function _image_trouver_extension_pertinente($path) {
627
-	$path = supprimer_timestamp($path);
628
-	$terminaison = _image_trouver_extension($path);
629
-	if ($terminaison == 'jpg') {
630
-		$terminaison = 'jpeg';
631
-	}
632
-
633
-	if (!file_exists($path)) {
634
-		return $terminaison;
635
-	}
636
-
637
-	if (!$info = @spip_getimagesize($path)) {
638
-		return $terminaison;
639
-	}
640
-
641
-	if (isset($info['mime'])) {
642
-		$mime = $info['mime'];
643
-	}
644
-	else {
645
-		$mime = image_type_to_mime_type($info[2]);
646
-	}
647
-
648
-	$_terminaison = _image_trouver_extension_depuis_mime($mime);
649
-	if ($_terminaison and $_terminaison !== $terminaison) {
650
-		spip_log("Mauvaise extension du fichier : $path . Son type mime est : $mime", 'images.' . _LOG_INFO_IMPORTANTE);
651
-		$terminaison = $_terminaison;
652
-	}
653
-	return $terminaison;
627
+    $path = supprimer_timestamp($path);
628
+    $terminaison = _image_trouver_extension($path);
629
+    if ($terminaison == 'jpg') {
630
+        $terminaison = 'jpeg';
631
+    }
632
+
633
+    if (!file_exists($path)) {
634
+        return $terminaison;
635
+    }
636
+
637
+    if (!$info = @spip_getimagesize($path)) {
638
+        return $terminaison;
639
+    }
640
+
641
+    if (isset($info['mime'])) {
642
+        $mime = $info['mime'];
643
+    }
644
+    else {
645
+        $mime = image_type_to_mime_type($info[2]);
646
+    }
647
+
648
+    $_terminaison = _image_trouver_extension_depuis_mime($mime);
649
+    if ($_terminaison and $_terminaison !== $terminaison) {
650
+        spip_log("Mauvaise extension du fichier : $path . Son type mime est : $mime", 'images.' . _LOG_INFO_IMPORTANTE);
651
+        $terminaison = $_terminaison;
652
+    }
653
+    return $terminaison;
654 654
 }
655 655
 
656 656
 /**
@@ -658,36 +658,36 @@  discard block
 block discarded – undo
658 658
  * @return string
659 659
  */
660 660
 function _image_trouver_extension_depuis_mime($mime) {
661
-	switch (strtolower($mime)) {
662
-		case 'image/png':
663
-		case 'image/x-png':
664
-			$terminaison = 'png';
665
-			break;
666
-
667
-		case 'image/jpg':
668
-		case 'image/jpeg':
669
-		case 'image/pjpeg':
670
-			$terminaison = 'jpeg';
671
-			break;
672
-
673
-		case 'image/gif':
674
-			$terminaison = 'gif';
675
-			break;
676
-
677
-		case 'image/webp':
678
-		case 'image/x-webp':
679
-			$terminaison = 'webp';
680
-			break;
681
-
682
-		case 'image/svg+xml':
683
-			$terminaison = 'svg';
684
-			break;
685
-
686
-		default:
687
-			$terminaison = '';
688
-	}
689
-
690
-	return $terminaison;
661
+    switch (strtolower($mime)) {
662
+        case 'image/png':
663
+        case 'image/x-png':
664
+            $terminaison = 'png';
665
+            break;
666
+
667
+        case 'image/jpg':
668
+        case 'image/jpeg':
669
+        case 'image/pjpeg':
670
+            $terminaison = 'jpeg';
671
+            break;
672
+
673
+        case 'image/gif':
674
+            $terminaison = 'gif';
675
+            break;
676
+
677
+        case 'image/webp':
678
+        case 'image/x-webp':
679
+            $terminaison = 'webp';
680
+            break;
681
+
682
+        case 'image/svg+xml':
683
+            $terminaison = 'svg';
684
+            break;
685
+
686
+        default:
687
+            $terminaison = '';
688
+    }
689
+
690
+    return $terminaison;
691 691
 }
692 692
 
693 693
 
@@ -707,18 +707,18 @@  discard block
 block discarded – undo
707 707
  *     Une ressource de type Image GD.
708 708
  */
709 709
 function _imagecreatefrom_func(string $func, string $filename) {
710
-	if (!function_exists($func)) {
711
-		spip_log("GD indisponible : $func inexistante. Traitement $filename impossible.", _LOG_CRITIQUE);
712
-		erreur_squelette("GD indisponible : $func inexistante. Traitement $filename impossible.");
713
-		return null;
714
-	}
715
-	$img = @$func($filename);
716
-	if (!$img) {
717
-		spip_log("Erreur lecture imagecreatefromjpeg $filename", _LOG_CRITIQUE);
718
-		erreur_squelette("Erreur lecture imagecreatefromjpeg $filename");
719
-		$img = imagecreate(10, 10);
720
-	}
721
-	return $img;
710
+    if (!function_exists($func)) {
711
+        spip_log("GD indisponible : $func inexistante. Traitement $filename impossible.", _LOG_CRITIQUE);
712
+        erreur_squelette("GD indisponible : $func inexistante. Traitement $filename impossible.");
713
+        return null;
714
+    }
715
+    $img = @$func($filename);
716
+    if (!$img) {
717
+        spip_log("Erreur lecture imagecreatefromjpeg $filename", _LOG_CRITIQUE);
718
+        erreur_squelette("Erreur lecture imagecreatefromjpeg $filename");
719
+        $img = imagecreate(10, 10);
720
+    }
721
+    return $img;
722 722
 }
723 723
 
724 724
 /**
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
  *     Une ressource de type Image GD.
735 735
  */
736 736
 function _imagecreatefromjpeg($filename) {
737
-	return _imagecreatefrom_func('imagecreatefromjpeg', $filename);
737
+    return _imagecreatefrom_func('imagecreatefromjpeg', $filename);
738 738
 }
739 739
 
740 740
 /**
@@ -750,7 +750,7 @@  discard block
 block discarded – undo
750 750
  *     Une ressource de type Image GD.
751 751
  */
752 752
 function _imagecreatefrompng($filename) {
753
-	return _imagecreatefrom_func('imagecreatefrompng', $filename);
753
+    return _imagecreatefrom_func('imagecreatefrompng', $filename);
754 754
 }
755 755
 
756 756
 /**
@@ -766,7 +766,7 @@  discard block
 block discarded – undo
766 766
  *     Une ressource de type Image GD.
767 767
  */
768 768
 function _imagecreatefromgif($filename) {
769
-	return _imagecreatefrom_func('imagecreatefromgif', $filename);
769
+    return _imagecreatefrom_func('imagecreatefromgif', $filename);
770 770
 }
771 771
 
772 772
 
@@ -783,7 +783,7 @@  discard block
 block discarded – undo
783 783
  *     Une ressource de type Image GD.
784 784
  */
785 785
 function _imagecreatefromwebp($filename) {
786
-	return _imagecreatefrom_func('imagecreatefromwebp', $filename);
786
+    return _imagecreatefrom_func('imagecreatefromwebp', $filename);
787 787
 }
788 788
 
789 789
 /**
@@ -801,24 +801,24 @@  discard block
 block discarded – undo
801 801
  *     - true si une image est bien retournée.
802 802
  */
803 803
 function _image_imagepng($img, $fichier) {
804
-	if (!function_exists('imagepng')) {
805
-		return false;
806
-	}
807
-	$tmp = $fichier . '.tmp';
808
-	$ret = imagepng($img, $tmp);
809
-	if (file_exists($tmp)) {
810
-		$taille_test = getimagesize($tmp);
811
-		if ($taille_test[0] < 1) {
812
-			return false;
813
-		}
814
-
815
-		spip_unlink($fichier); // le fichier peut deja exister
816
-		@rename($tmp, $fichier);
817
-
818
-		return $ret;
819
-	}
820
-
821
-	return false;
804
+    if (!function_exists('imagepng')) {
805
+        return false;
806
+    }
807
+    $tmp = $fichier . '.tmp';
808
+    $ret = imagepng($img, $tmp);
809
+    if (file_exists($tmp)) {
810
+        $taille_test = getimagesize($tmp);
811
+        if ($taille_test[0] < 1) {
812
+            return false;
813
+        }
814
+
815
+        spip_unlink($fichier); // le fichier peut deja exister
816
+        @rename($tmp, $fichier);
817
+
818
+        return $ret;
819
+    }
820
+
821
+    return false;
822 822
 }
823 823
 
824 824
 /**
@@ -836,24 +836,24 @@  discard block
 block discarded – undo
836 836
  *     - true si une image est bien retournée.
837 837
  */
838 838
 function _image_imagegif($img, $fichier) {
839
-	if (!function_exists('imagegif')) {
840
-		return false;
841
-	}
842
-	$tmp = $fichier . '.tmp';
843
-	$ret = imagegif($img, $tmp);
844
-	if (file_exists($tmp)) {
845
-		$taille_test = getimagesize($tmp);
846
-		if ($taille_test[0] < 1) {
847
-			return false;
848
-		}
849
-
850
-		spip_unlink($fichier); // le fichier peut deja exister
851
-		@rename($tmp, $fichier);
852
-
853
-		return $ret;
854
-	}
855
-
856
-	return false;
839
+    if (!function_exists('imagegif')) {
840
+        return false;
841
+    }
842
+    $tmp = $fichier . '.tmp';
843
+    $ret = imagegif($img, $tmp);
844
+    if (file_exists($tmp)) {
845
+        $taille_test = getimagesize($tmp);
846
+        if ($taille_test[0] < 1) {
847
+            return false;
848
+        }
849
+
850
+        spip_unlink($fichier); // le fichier peut deja exister
851
+        @rename($tmp, $fichier);
852
+
853
+        return $ret;
854
+    }
855
+
856
+    return false;
857 857
 }
858 858
 
859 859
 /**
@@ -876,29 +876,29 @@  discard block
 block discarded – undo
876 876
  *     - true si une image est bien retournée.
877 877
  */
878 878
 function _image_imagejpg($img, $fichier, $qualite = _IMG_GD_QUALITE) {
879
-	if (!function_exists('imagejpeg')) {
880
-		return false;
881
-	}
882
-	$tmp = $fichier . '.tmp';
879
+    if (!function_exists('imagejpeg')) {
880
+        return false;
881
+    }
882
+    $tmp = $fichier . '.tmp';
883 883
 
884
-	// Enable interlancing
885
-	imageinterlace($img, true);
884
+    // Enable interlancing
885
+    imageinterlace($img, true);
886 886
 
887
-	$ret = imagejpeg($img, $tmp, $qualite);
887
+    $ret = imagejpeg($img, $tmp, $qualite);
888 888
 
889
-	if (file_exists($tmp)) {
890
-		$taille_test = getimagesize($tmp);
891
-		if ($taille_test[0] < 1) {
892
-			return false;
893
-		}
889
+    if (file_exists($tmp)) {
890
+        $taille_test = getimagesize($tmp);
891
+        if ($taille_test[0] < 1) {
892
+            return false;
893
+        }
894 894
 
895
-		spip_unlink($fichier); // le fichier peut deja exister
896
-		@rename($tmp, $fichier);
895
+        spip_unlink($fichier); // le fichier peut deja exister
896
+        @rename($tmp, $fichier);
897 897
 
898
-		return $ret;
899
-	}
898
+        return $ret;
899
+    }
900 900
 
901
-	return false;
901
+    return false;
902 902
 }
903 903
 
904 904
 /**
@@ -916,9 +916,9 @@  discard block
 block discarded – undo
916 916
  *     true si le fichier a bien été créé ; false sinon.
917 917
  */
918 918
 function _image_imageico($img, $fichier) {
919
-	$gd_image_array = [$img];
919
+    $gd_image_array = [$img];
920 920
 
921
-	return ecrire_fichier($fichier, phpthumb_functions::GD2ICOstring($gd_image_array));
921
+    return ecrire_fichier($fichier, phpthumb_functions::GD2ICOstring($gd_image_array));
922 922
 }
923 923
 
924 924
 
@@ -937,24 +937,24 @@  discard block
 block discarded – undo
937 937
  *     - true si une image est bien retournée.
938 938
  */
939 939
 function _image_imagewebp($img, $fichier, $qualite = _IMG_GD_QUALITE) {
940
-	if (!function_exists('imagewebp')) {
941
-		return false;
942
-	}
943
-	$tmp = $fichier . '.tmp';
944
-	$ret = imagewebp($img, $tmp, $qualite);
945
-	if (file_exists($tmp)) {
946
-		$taille_test = getimagesize($tmp);
947
-		if ($taille_test[0] < 1) {
948
-			return false;
949
-		}
950
-
951
-		spip_unlink($fichier); // le fichier peut deja exister
952
-		@rename($tmp, $fichier);
953
-
954
-		return $ret;
955
-	}
956
-
957
-	return false;
940
+    if (!function_exists('imagewebp')) {
941
+        return false;
942
+    }
943
+    $tmp = $fichier . '.tmp';
944
+    $ret = imagewebp($img, $tmp, $qualite);
945
+    if (file_exists($tmp)) {
946
+        $taille_test = getimagesize($tmp);
947
+        if ($taille_test[0] < 1) {
948
+            return false;
949
+        }
950
+
951
+        spip_unlink($fichier); // le fichier peut deja exister
952
+        @rename($tmp, $fichier);
953
+
954
+        return $ret;
955
+    }
956
+
957
+    return false;
958 958
 }
959 959
 
960 960
 /**
@@ -974,35 +974,35 @@  discard block
 block discarded – undo
974 974
  */
975 975
 function _image_imagesvg($img, $fichier) {
976 976
 
977
-	$tmp = $fichier . '.tmp';
978
-	if (strpos($img, '<') === false) {
979
-		$img = supprimer_timestamp($img);
980
-		if (!file_exists($img)) {
981
-			return false;
982
-		}
983
-		@copy($img, $tmp);
984
-		if (filesize($tmp) == filesize($img)) {
985
-			spip_unlink($fichier); // le fichier peut deja exister
986
-			@rename($tmp, $fichier);
987
-			return true;
988
-		}
989
-		return false;
990
-	}
991
-
992
-	file_put_contents($tmp, $img);
993
-	if (file_exists($tmp)) {
994
-		$taille_test = spip_getimagesize($tmp);
995
-		if ($taille_test[0] < 1) {
996
-			return false;
997
-		}
998
-
999
-		spip_unlink($fichier); // le fichier peut deja exister
1000
-		@rename($tmp, $fichier);
1001
-
1002
-		return true;
1003
-	}
1004
-
1005
-	return false;
977
+    $tmp = $fichier . '.tmp';
978
+    if (strpos($img, '<') === false) {
979
+        $img = supprimer_timestamp($img);
980
+        if (!file_exists($img)) {
981
+            return false;
982
+        }
983
+        @copy($img, $tmp);
984
+        if (filesize($tmp) == filesize($img)) {
985
+            spip_unlink($fichier); // le fichier peut deja exister
986
+            @rename($tmp, $fichier);
987
+            return true;
988
+        }
989
+        return false;
990
+    }
991
+
992
+    file_put_contents($tmp, $img);
993
+    if (file_exists($tmp)) {
994
+        $taille_test = spip_getimagesize($tmp);
995
+        if ($taille_test[0] < 1) {
996
+            return false;
997
+        }
998
+
999
+        spip_unlink($fichier); // le fichier peut deja exister
1000
+        @rename($tmp, $fichier);
1001
+
1002
+        return true;
1003
+    }
1004
+
1005
+    return false;
1006 1006
 }
1007 1007
 
1008 1008
 
@@ -1030,29 +1030,29 @@  discard block
 block discarded – undo
1030 1030
  *     - false sinon.
1031 1031
  */
1032 1032
 function _image_gd_output($img, $valeurs, $qualite = _IMG_GD_QUALITE, $fonction = null) {
1033
-	if (is_null($fonction)) {
1034
-		$fonction = '_image_image' . $valeurs['format_dest'];
1035
-	}
1036
-	$ret = false;
1037
-	#un flag pour reperer les images gravees
1038
-	$lock =
1039
-		!statut_effacer_images_temporaires('get') // si la fonction n'a pas ete activee, on grave tout
1040
-	or (@file_exists($valeurs['fichier_dest']) and !@file_exists($valeurs['fichier_dest'] . '.src'));
1041
-	if (
1042
-		function_exists($fonction)
1043
-		&& ($ret = $fonction($img, $valeurs['fichier_dest'], $qualite)) # on a reussi a creer l'image
1044
-		&& isset($valeurs['reconstruction']) # et on sait comment la resonctruire le cas echeant
1045
-		&& !$lock
1046
-	) {
1047
-		if (@file_exists($valeurs['fichier_dest'])) {
1048
-			// dans tous les cas mettre a jour la taille de l'image finale
1049
-			[$valeurs['hauteur_dest'], $valeurs['largeur_dest']] = taille_image($valeurs['fichier_dest']);
1050
-			$valeurs['date'] = @filemtime($valeurs['fichier_dest']); // pour la retrouver apres disparition
1051
-			ecrire_fichier($valeurs['fichier_dest'] . '.src', serialize($valeurs), true);
1052
-		}
1053
-	}
1054
-
1055
-	return $ret;
1033
+    if (is_null($fonction)) {
1034
+        $fonction = '_image_image' . $valeurs['format_dest'];
1035
+    }
1036
+    $ret = false;
1037
+    #un flag pour reperer les images gravees
1038
+    $lock =
1039
+        !statut_effacer_images_temporaires('get') // si la fonction n'a pas ete activee, on grave tout
1040
+    or (@file_exists($valeurs['fichier_dest']) and !@file_exists($valeurs['fichier_dest'] . '.src'));
1041
+    if (
1042
+        function_exists($fonction)
1043
+        && ($ret = $fonction($img, $valeurs['fichier_dest'], $qualite)) # on a reussi a creer l'image
1044
+        && isset($valeurs['reconstruction']) # et on sait comment la resonctruire le cas echeant
1045
+        && !$lock
1046
+    ) {
1047
+        if (@file_exists($valeurs['fichier_dest'])) {
1048
+            // dans tous les cas mettre a jour la taille de l'image finale
1049
+            [$valeurs['hauteur_dest'], $valeurs['largeur_dest']] = taille_image($valeurs['fichier_dest']);
1050
+            $valeurs['date'] = @filemtime($valeurs['fichier_dest']); // pour la retrouver apres disparition
1051
+            ecrire_fichier($valeurs['fichier_dest'] . '.src', serialize($valeurs), true);
1052
+        }
1053
+    }
1054
+
1055
+    return $ret;
1056 1056
 }
1057 1057
 
1058 1058
 /**
@@ -1065,27 +1065,27 @@  discard block
 block discarded – undo
1065 1065
  *     Chemin vers le fichier manquant
1066 1066
  **/
1067 1067
 function reconstruire_image_intermediaire($fichier_manquant) {
1068
-	$reconstruire = [];
1069
-	$fichier = $fichier_manquant;
1070
-	while (
1071
-		strpos($fichier, '://') === false
1072
-		and !@file_exists($fichier)
1073
-		and lire_fichier($src = "$fichier.src", $source)
1074
-		and $valeurs = unserialize($source)
1075
-		and ($fichier = $valeurs['fichier']) # l'origine est connue (on ne verifie pas son existence, qu'importe ...)
1076
-	) {
1077
-		spip_unlink($src); // si jamais on a un timeout pendant la reconstruction, elle se fera naturellement au hit suivant
1078
-		$reconstruire[] = $valeurs['reconstruction'];
1079
-	}
1080
-	while (count($reconstruire)) {
1081
-		$r = array_pop($reconstruire);
1082
-		$fonction = $r[0];
1083
-		$args = $r[1];
1084
-		call_user_func_array($fonction, $args);
1085
-	}
1086
-	// cette image intermediaire est commune a plusieurs series de filtre, il faut la conserver
1087
-	// mais l'on peut nettoyer les miettes de sa creation
1088
-	ramasse_miettes($fichier_manquant);
1068
+    $reconstruire = [];
1069
+    $fichier = $fichier_manquant;
1070
+    while (
1071
+        strpos($fichier, '://') === false
1072
+        and !@file_exists($fichier)
1073
+        and lire_fichier($src = "$fichier.src", $source)
1074
+        and $valeurs = unserialize($source)
1075
+        and ($fichier = $valeurs['fichier']) # l'origine est connue (on ne verifie pas son existence, qu'importe ...)
1076
+    ) {
1077
+        spip_unlink($src); // si jamais on a un timeout pendant la reconstruction, elle se fera naturellement au hit suivant
1078
+        $reconstruire[] = $valeurs['reconstruction'];
1079
+    }
1080
+    while (count($reconstruire)) {
1081
+        $r = array_pop($reconstruire);
1082
+        $fonction = $r[0];
1083
+        $args = $r[1];
1084
+        call_user_func_array($fonction, $args);
1085
+    }
1086
+    // cette image intermediaire est commune a plusieurs series de filtre, il faut la conserver
1087
+    // mais l'on peut nettoyer les miettes de sa creation
1088
+    ramasse_miettes($fichier_manquant);
1089 1089
 }
1090 1090
 
1091 1091
 /**
@@ -1105,28 +1105,28 @@  discard block
 block discarded – undo
1105 1105
  *     Chemin du fichier d'image calculé
1106 1106
  **/
1107 1107
 function ramasse_miettes($fichier) {
1108
-	if (
1109
-		strpos($fichier, '://') !== false
1110
-		or !lire_fichier($src = "$fichier.src", $source)
1111
-		or !$valeurs = unserialize($source)
1112
-	) {
1113
-		return;
1114
-	}
1115
-	spip_unlink($src); # on supprime la reference a sa source pour marquer cette image comme non intermediaire
1116
-	while (
1117
-		($fichier = $valeurs['fichier']) # l'origine est connue (on ne verifie pas son existence, qu'importe ...)
1118
-		and (substr($fichier, 0, strlen(_DIR_VAR)) == _DIR_VAR) # et est dans local
1119
-		and (lire_fichier(
1120
-			$src = "$fichier.src",
1121
-			$source
1122
-		)) # le fichier a une source connue (c'est donc une image calculee intermediaire)
1123
-		and ($valeurs = unserialize($source))  # et valide
1124
-	) {
1125
-		# on efface le fichier
1126
-		spip_unlink($fichier);
1127
-		# mais laisse le .src qui permet de savoir comment reconstruire l'image si besoin
1128
-		#spip_unlink($src);
1129
-	}
1108
+    if (
1109
+        strpos($fichier, '://') !== false
1110
+        or !lire_fichier($src = "$fichier.src", $source)
1111
+        or !$valeurs = unserialize($source)
1112
+    ) {
1113
+        return;
1114
+    }
1115
+    spip_unlink($src); # on supprime la reference a sa source pour marquer cette image comme non intermediaire
1116
+    while (
1117
+        ($fichier = $valeurs['fichier']) # l'origine est connue (on ne verifie pas son existence, qu'importe ...)
1118
+        and (substr($fichier, 0, strlen(_DIR_VAR)) == _DIR_VAR) # et est dans local
1119
+        and (lire_fichier(
1120
+            $src = "$fichier.src",
1121
+            $source
1122
+        )) # le fichier a une source connue (c'est donc une image calculee intermediaire)
1123
+        and ($valeurs = unserialize($source))  # et valide
1124
+    ) {
1125
+        # on efface le fichier
1126
+        spip_unlink($fichier);
1127
+        # mais laisse le .src qui permet de savoir comment reconstruire l'image si besoin
1128
+        #spip_unlink($src);
1129
+    }
1130 1130
 }
1131 1131
 
1132 1132
 
@@ -1151,71 +1151,71 @@  discard block
 block discarded – undo
1151 1151
  *     Code HTML de l'image
1152 1152
  **/
1153 1153
 function image_graver($img) {
1154
-	// appeler le filtre post_image_filtrer qui permet de faire
1155
-	// des traitements auto a la fin d'une serie de filtres
1156
-	$img = pipeline('post_image_filtrer', $img);
1157
-
1158
-	$fichier_ori = $fichier = extraire_attribut($img, 'src');
1159
-	if (($p = strpos($fichier, '?')) !== false) {
1160
-		$fichier = substr($fichier, 0, $p);
1161
-	}
1162
-	if (strlen($fichier) < 1) {
1163
-		$fichier = $img;
1164
-	}
1165
-	# si jamais le fichier final n'a pas ete calcule car suppose temporaire
1166
-	# et qu'il ne s'agit pas d'une URL
1167
-	if (strpos($fichier, '://') === false and !@file_exists($fichier)) {
1168
-		reconstruire_image_intermediaire($fichier);
1169
-	}
1170
-	ramasse_miettes($fichier);
1171
-
1172
-	// ajouter le timestamp si besoin
1173
-	if (strpos($fichier_ori, '?') === false) {
1174
-		// on utilise str_replace pour attraper le onmouseover des logo si besoin
1175
-		$img = str_replace($fichier_ori, timestamp($fichier_ori), $img);
1176
-	}
1177
-
1178
-	return $img;
1154
+    // appeler le filtre post_image_filtrer qui permet de faire
1155
+    // des traitements auto a la fin d'une serie de filtres
1156
+    $img = pipeline('post_image_filtrer', $img);
1157
+
1158
+    $fichier_ori = $fichier = extraire_attribut($img, 'src');
1159
+    if (($p = strpos($fichier, '?')) !== false) {
1160
+        $fichier = substr($fichier, 0, $p);
1161
+    }
1162
+    if (strlen($fichier) < 1) {
1163
+        $fichier = $img;
1164
+    }
1165
+    # si jamais le fichier final n'a pas ete calcule car suppose temporaire
1166
+    # et qu'il ne s'agit pas d'une URL
1167
+    if (strpos($fichier, '://') === false and !@file_exists($fichier)) {
1168
+        reconstruire_image_intermediaire($fichier);
1169
+    }
1170
+    ramasse_miettes($fichier);
1171
+
1172
+    // ajouter le timestamp si besoin
1173
+    if (strpos($fichier_ori, '?') === false) {
1174
+        // on utilise str_replace pour attraper le onmouseover des logo si besoin
1175
+        $img = str_replace($fichier_ori, timestamp($fichier_ori), $img);
1176
+    }
1177
+
1178
+    return $img;
1179 1179
 }
1180 1180
 
1181 1181
 
1182 1182
 if (!function_exists('imagepalettetotruecolor')) {
1183
-	/**
1184
-	 * Transforme une image à palette indexée (256 couleurs max) en "vraies" couleurs RGB
1185
-	 *
1186
-	 * @note Pour compatibilité avec PHP < 5.5
1187
-	 *
1188
-	 * @link http://php.net/manual/fr/function.imagepalettetotruecolor.php
1189
-	 *
1190
-	 * @param ressource $img
1191
-	 * @return bool
1192
-	 *     - true si l'image est déjà en vrai RGB ou peut être transformée
1193
-	 *     - false si la transformation ne peut être faite.
1194
-	 **/
1195
-	function imagepalettetotruecolor(&$img) {
1196
-		if (!$img or !function_exists('imagecreatetruecolor')) {
1197
-			return false;
1198
-		} elseif (!imageistruecolor($img)) {
1199
-			$w = imagesx($img);
1200
-			$h = imagesy($img);
1201
-			$img1 = imagecreatetruecolor($w, $h);
1202
-			//Conserver la transparence si possible
1203
-			if (function_exists('ImageCopyResampled')) {
1204
-				if (function_exists('imageAntiAlias')) {
1205
-					imageAntiAlias($img1, true);
1206
-				}
1207
-				@imagealphablending($img1, false);
1208
-				@imagesavealpha($img1, true);
1209
-				@ImageCopyResampled($img1, $img, 0, 0, 0, 0, $w, $h, $w, $h);
1210
-			} else {
1211
-				imagecopy($img1, $img, 0, 0, 0, 0, $w, $h);
1212
-			}
1213
-
1214
-			$img = $img1;
1215
-		}
1216
-
1217
-		return true;
1218
-	}
1183
+    /**
1184
+     * Transforme une image à palette indexée (256 couleurs max) en "vraies" couleurs RGB
1185
+     *
1186
+     * @note Pour compatibilité avec PHP < 5.5
1187
+     *
1188
+     * @link http://php.net/manual/fr/function.imagepalettetotruecolor.php
1189
+     *
1190
+     * @param ressource $img
1191
+     * @return bool
1192
+     *     - true si l'image est déjà en vrai RGB ou peut être transformée
1193
+     *     - false si la transformation ne peut être faite.
1194
+     **/
1195
+    function imagepalettetotruecolor(&$img) {
1196
+        if (!$img or !function_exists('imagecreatetruecolor')) {
1197
+            return false;
1198
+        } elseif (!imageistruecolor($img)) {
1199
+            $w = imagesx($img);
1200
+            $h = imagesy($img);
1201
+            $img1 = imagecreatetruecolor($w, $h);
1202
+            //Conserver la transparence si possible
1203
+            if (function_exists('ImageCopyResampled')) {
1204
+                if (function_exists('imageAntiAlias')) {
1205
+                    imageAntiAlias($img1, true);
1206
+                }
1207
+                @imagealphablending($img1, false);
1208
+                @imagesavealpha($img1, true);
1209
+                @ImageCopyResampled($img1, $img, 0, 0, 0, 0, $w, $h, $w, $h);
1210
+            } else {
1211
+                imagecopy($img1, $img, 0, 0, 0, 0, $w, $h);
1212
+            }
1213
+
1214
+            $img = $img1;
1215
+        }
1216
+
1217
+        return true;
1218
+    }
1219 1219
 }
1220 1220
 
1221 1221
 /**
@@ -1242,34 +1242,34 @@  discard block
 block discarded – undo
1242 1242
  *     Code html modifié de la balise.
1243 1243
  **/
1244 1244
 function _image_tag_changer_taille($tag, $width, $height, $style = false) {
1245
-	if ($style === false) {
1246
-		$style = extraire_attribut($tag, 'style');
1247
-	}
1248
-
1249
-	// enlever le width et height du style
1250
-	if ($style) {
1251
-		$style = preg_replace(',(^|;)\s*(width|height)\s*:\s*[^;]+,ims', '', $style);
1252
-	}
1253
-	if ($style and $style[0] === ';') {
1254
-		$style = substr($style, 1);
1255
-	}
1256
-
1257
-	// mettre des attributs de width et height sur les images,
1258
-	// ca accelere le rendu du navigateur
1259
-	// ca permet aux navigateurs de reserver la bonne taille
1260
-	// quand on a desactive l'affichage des images.
1261
-	$tag = inserer_attribut($tag, 'width', round($width));
1262
-	$tag = inserer_attribut($tag, 'height', round($height));
1263
-
1264
-	// attributs deprecies. Transformer en CSS
1265
-	if ($espace = extraire_attribut($tag, 'hspace')) {
1266
-		$style = "margin:${espace}px;" . $style;
1267
-		$tag = inserer_attribut($tag, 'hspace', '');
1268
-	}
1269
-
1270
-	$tag = inserer_attribut($tag, 'style', (string) $style, true, $style ? false : true);
1271
-
1272
-	return $tag;
1245
+    if ($style === false) {
1246
+        $style = extraire_attribut($tag, 'style');
1247
+    }
1248
+
1249
+    // enlever le width et height du style
1250
+    if ($style) {
1251
+        $style = preg_replace(',(^|;)\s*(width|height)\s*:\s*[^;]+,ims', '', $style);
1252
+    }
1253
+    if ($style and $style[0] === ';') {
1254
+        $style = substr($style, 1);
1255
+    }
1256
+
1257
+    // mettre des attributs de width et height sur les images,
1258
+    // ca accelere le rendu du navigateur
1259
+    // ca permet aux navigateurs de reserver la bonne taille
1260
+    // quand on a desactive l'affichage des images.
1261
+    $tag = inserer_attribut($tag, 'width', round($width));
1262
+    $tag = inserer_attribut($tag, 'height', round($height));
1263
+
1264
+    // attributs deprecies. Transformer en CSS
1265
+    if ($espace = extraire_attribut($tag, 'hspace')) {
1266
+        $style = "margin:${espace}px;" . $style;
1267
+        $tag = inserer_attribut($tag, 'hspace', '');
1268
+    }
1269
+
1270
+    $tag = inserer_attribut($tag, 'style', (string) $style, true, $style ? false : true);
1271
+
1272
+    return $tag;
1273 1273
 }
1274 1274
 
1275 1275
 
@@ -1295,72 +1295,72 @@  discard block
 block discarded – undo
1295 1295
  *     Retourne le code HTML de l'image
1296 1296
  **/
1297 1297
 function _image_ecrire_tag($valeurs, $surcharge = []) {
1298
-	$valeurs = pipeline('image_ecrire_tag_preparer', $valeurs);
1299
-
1300
-	// fermer les tags img pas bien fermes;
1301
-	$tag = str_replace('>', '/>', str_replace('/>', '>', $valeurs['tag']));
1302
-
1303
-	// le style
1304
-	$style = $valeurs['style'];
1305
-	if (isset($surcharge['style'])) {
1306
-		$style = $surcharge['style'];
1307
-		unset($surcharge['style']);
1308
-	}
1309
-
1310
-	// traiter specifiquement la largeur et la hauteur
1311
-	$width = $valeurs['largeur'];
1312
-	if (isset($surcharge['width'])) {
1313
-		$width = $surcharge['width'];
1314
-		unset($surcharge['width']);
1315
-	}
1316
-	$height = $valeurs['hauteur'];
1317
-	if (isset($surcharge['height'])) {
1318
-		$height = $surcharge['height'];
1319
-		unset($surcharge['height']);
1320
-	}
1321
-
1322
-	$tag = _image_tag_changer_taille($tag, $width, $height, $style);
1323
-	// traiter specifiquement le src qui peut etre repris dans un onmouseout
1324
-	// on remplace toute les ref a src dans le tag
1325
-	$src = extraire_attribut($tag, 'src');
1326
-	if (isset($surcharge['src'])) {
1327
-		$tag = str_replace($src, $surcharge['src'], $tag);
1328
-		// si il y a des & dans src, alors ils peuvent provenir d'un &amp
1329
-		// pas garanti comme methode, mais mieux que rien
1330
-		if (strpos($src, '&') !== false) {
1331
-			$tag = str_replace(str_replace('&', '&amp;', $src), $surcharge['src'], $tag);
1332
-		}
1333
-		$src = $surcharge['src'];
1334
-		unset($surcharge['src']);
1335
-	}
1336
-
1337
-	$class = $valeurs['class'];
1338
-	if (isset($surcharge['class'])) {
1339
-		$class = $surcharge['class'];
1340
-		unset($surcharge['class']);
1341
-	}
1342
-	if (is_scalar($class) && strlen($class)) {
1343
-		$tag = inserer_attribut($tag, 'class', $class);
1344
-	}
1345
-
1346
-	if (count($surcharge)) {
1347
-		foreach ($surcharge as $attribut => $valeur) {
1348
-			$tag = inserer_attribut($tag, $attribut, $valeur);
1349
-		}
1350
-	}
1351
-
1352
-	$tag = pipeline(
1353
-		'image_ecrire_tag_finir',
1354
-		[
1355
-			'args' => [
1356
-				'valeurs' => $valeurs,
1357
-				'surcharge' => $surcharge,
1358
-			],
1359
-			'data' => $tag
1360
-		]
1361
-	);
1362
-
1363
-	return $tag;
1298
+    $valeurs = pipeline('image_ecrire_tag_preparer', $valeurs);
1299
+
1300
+    // fermer les tags img pas bien fermes;
1301
+    $tag = str_replace('>', '/>', str_replace('/>', '>', $valeurs['tag']));
1302
+
1303
+    // le style
1304
+    $style = $valeurs['style'];
1305
+    if (isset($surcharge['style'])) {
1306
+        $style = $surcharge['style'];
1307
+        unset($surcharge['style']);
1308
+    }
1309
+
1310
+    // traiter specifiquement la largeur et la hauteur
1311
+    $width = $valeurs['largeur'];
1312
+    if (isset($surcharge['width'])) {
1313
+        $width = $surcharge['width'];
1314
+        unset($surcharge['width']);
1315
+    }
1316
+    $height = $valeurs['hauteur'];
1317
+    if (isset($surcharge['height'])) {
1318
+        $height = $surcharge['height'];
1319
+        unset($surcharge['height']);
1320
+    }
1321
+
1322
+    $tag = _image_tag_changer_taille($tag, $width, $height, $style);
1323
+    // traiter specifiquement le src qui peut etre repris dans un onmouseout
1324
+    // on remplace toute les ref a src dans le tag
1325
+    $src = extraire_attribut($tag, 'src');
1326
+    if (isset($surcharge['src'])) {
1327
+        $tag = str_replace($src, $surcharge['src'], $tag);
1328
+        // si il y a des & dans src, alors ils peuvent provenir d'un &amp
1329
+        // pas garanti comme methode, mais mieux que rien
1330
+        if (strpos($src, '&') !== false) {
1331
+            $tag = str_replace(str_replace('&', '&amp;', $src), $surcharge['src'], $tag);
1332
+        }
1333
+        $src = $surcharge['src'];
1334
+        unset($surcharge['src']);
1335
+    }
1336
+
1337
+    $class = $valeurs['class'];
1338
+    if (isset($surcharge['class'])) {
1339
+        $class = $surcharge['class'];
1340
+        unset($surcharge['class']);
1341
+    }
1342
+    if (is_scalar($class) && strlen($class)) {
1343
+        $tag = inserer_attribut($tag, 'class', $class);
1344
+    }
1345
+
1346
+    if (count($surcharge)) {
1347
+        foreach ($surcharge as $attribut => $valeur) {
1348
+            $tag = inserer_attribut($tag, $attribut, $valeur);
1349
+        }
1350
+    }
1351
+
1352
+    $tag = pipeline(
1353
+        'image_ecrire_tag_finir',
1354
+        [
1355
+            'args' => [
1356
+                'valeurs' => $valeurs,
1357
+                'surcharge' => $surcharge,
1358
+            ],
1359
+            'data' => $tag
1360
+        ]
1361
+    );
1362
+
1363
+    return $tag;
1364 1364
 }
1365 1365
 
1366 1366
 /**
@@ -1383,259 +1383,259 @@  discard block
 block discarded – undo
1383 1383
  *     Description de l'image, sinon null.
1384 1384
  **/
1385 1385
 function _image_creer_vignette($valeurs, $maxWidth, $maxHeight, $process = 'AUTO', $force = false) {
1386
-	$srcHeight = null;
1387
-	$retour = [];
1388
-	// ordre de preference des formats graphiques pour creer les vignettes
1389
-	// le premier format disponible, selon la methode demandee, est utilise
1390
-	$image = $valeurs['fichier'];
1391
-	$format = $valeurs['format_source'];
1392
-	$destdir = dirname($valeurs['fichier_dest']);
1393
-	$destfile = basename($valeurs['fichier_dest'], '.' . $valeurs['format_dest']);
1394
-
1395
-	$format_sortie = $valeurs['format_dest'];
1396
-
1397
-	if (($process == 'AUTO') and isset($GLOBALS['meta']['image_process'])) {
1398
-		$process = $GLOBALS['meta']['image_process'];
1399
-	}
1400
-
1401
-	// si le doc n'est pas une image dans un format accetpable, refuser
1402
-	if (!$force and !in_array($format, formats_image_acceptables(in_array($process, ['gd1', 'gd2'])))) {
1403
-		return;
1404
-	}
1405
-	$destination = "$destdir/$destfile";
1406
-
1407
-	// calculer la taille
1408
-	if (($srcWidth = $valeurs['largeur']) && ($srcHeight = $valeurs['hauteur'])) {
1409
-		if (!($destWidth = $valeurs['largeur_dest']) || !($destHeight = $valeurs['hauteur_dest'])) {
1410
-			[$destWidth, $destHeight] = _image_ratio($srcWidth, $srcHeight, $maxWidth, $maxHeight);
1411
-		}
1412
-	} elseif ($process == 'convert' or $process == 'imagick') {
1413
-		$destWidth = $maxWidth;
1414
-		$destHeight = $maxHeight;
1415
-	} else {
1416
-		spip_log("echec $process sur $image");
1417
-
1418
-		return;
1419
-	}
1420
-
1421
-	$vignette = '';
1422
-
1423
-	// Si l'image est de la taille demandee (ou plus petite), simplement la retourner
1424
-	if ($srcWidth and $srcWidth <= $maxWidth and $srcHeight <= $maxHeight) {
1425
-		$vignette = $destination . '.' . $format;
1426
-		@copy($image, $vignette);
1427
-	}
1428
-
1429
-	elseif ($valeurs['format_source'] === 'svg') {
1430
-		if ($svg = svg_redimensionner($valeurs['fichier'], $destWidth, $destHeight)) {
1431
-			$format_sortie = 'svg';
1432
-			$vignette = $destination . '.' . $format_sortie;
1433
-			$valeurs['fichier_dest'] = $vignette;
1434
-			_image_gd_output($svg, $valeurs);
1435
-		}
1436
-	}
1437
-
1438
-	// imagemagick en ligne de commande
1439
-	elseif ($process == 'convert') {
1440
-		if (!defined('_CONVERT_COMMAND')) {
1441
-			define('_CONVERT_COMMAND', 'convert');
1442
-		} // Securite : mes_options.php peut preciser le chemin absolu
1443
-		if (!defined('_RESIZE_COMMAND')) {
1444
-			define('_RESIZE_COMMAND', _CONVERT_COMMAND . ' -quality ' . _IMG_CONVERT_QUALITE . ' -resize %xx%y! %src %dest');
1445
-		}
1446
-		$vignette = $destination . '.' . $format_sortie;
1447
-		$commande = str_replace(
1448
-			['%x', '%y', '%src', '%dest'],
1449
-			[
1450
-				$destWidth,
1451
-				$destHeight,
1452
-				escapeshellcmd($image),
1453
-				escapeshellcmd($vignette)
1454
-			],
1455
-			_RESIZE_COMMAND
1456
-		);
1457
-		spip_log($commande);
1458
-		exec($commande);
1459
-		if (!@file_exists($vignette)) {
1460
-			spip_log("echec convert sur $vignette");
1461
-
1462
-			return;  // echec commande
1463
-		}
1464
-	}
1465
-
1466
-	// php5 imagemagick
1467
-	elseif ($process == 'imagick') {
1468
-		$vignette = "$destination." . $format_sortie;
1469
-
1470
-		if (!class_exists(\Imagick::class)) {
1471
-			spip_log('Classe Imagick absente !', _LOG_ERREUR);
1472
-
1473
-			return;
1474
-		}
1475
-		$imagick = new Imagick();
1476
-		$imagick->readImage($image);
1477
-		$imagick->resizeImage(
1478
-			$destWidth,
1479
-			$destHeight,
1480
-			Imagick::FILTER_LANCZOS,
1481
-			1
1482
-		);//, IMAGICK_FILTER_LANCZOS, _IMG_IMAGICK_QUALITE / 100);
1483
-		$imagick->writeImage($vignette);
1484
-
1485
-		if (!@file_exists($vignette)) {
1486
-			spip_log("echec imagick sur $vignette");
1487
-
1488
-			return;
1489
-		}
1490
-	}
1491
-
1492
-	// netpbm
1493
-	elseif ($process == 'netpbm') {
1494
-		if (!defined('_PNMSCALE_COMMAND')) {
1495
-			define('_PNMSCALE_COMMAND', 'pnmscale');
1496
-		} // Securite : mes_options.php peut preciser le chemin absolu
1497
-		if (_PNMSCALE_COMMAND == '') {
1498
-			return;
1499
-		}
1500
-		$vignette = $destination . '.' . $format_sortie;
1501
-		$pnmtojpeg_command = str_replace('pnmscale', 'pnmtojpeg', _PNMSCALE_COMMAND);
1502
-		if ($format == 'jpg') {
1503
-			$jpegtopnm_command = str_replace('pnmscale', 'jpegtopnm', _PNMSCALE_COMMAND);
1504
-			exec("$jpegtopnm_command $image | " . _PNMSCALE_COMMAND . " -width $destWidth | $pnmtojpeg_command > $vignette");
1505
-			if (!($s = @filesize($vignette))) {
1506
-				spip_unlink($vignette);
1507
-			}
1508
-			if (!@file_exists($vignette)) {
1509
-				spip_log("echec netpbm-jpg sur $vignette");
1510
-
1511
-				return;
1512
-			}
1513
-		} else {
1514
-			if ($format == 'gif') {
1515
-				$giftopnm_command = str_replace('pnmscale', 'giftopnm', _PNMSCALE_COMMAND);
1516
-				exec("$giftopnm_command $image | " . _PNMSCALE_COMMAND . " -width $destWidth | $pnmtojpeg_command > $vignette");
1517
-				if (!($s = @filesize($vignette))) {
1518
-					spip_unlink($vignette);
1519
-				}
1520
-				if (!@file_exists($vignette)) {
1521
-					spip_log("echec netpbm-gif sur $vignette");
1522
-
1523
-					return;
1524
-				}
1525
-			} else {
1526
-				if ($format == 'png') {
1527
-					$pngtopnm_command = str_replace('pnmscale', 'pngtopnm', _PNMSCALE_COMMAND);
1528
-					exec("$pngtopnm_command $image | " . _PNMSCALE_COMMAND . " -width $destWidth | $pnmtojpeg_command > $vignette");
1529
-					if (!($s = @filesize($vignette))) {
1530
-						spip_unlink($vignette);
1531
-					}
1532
-					if (!@file_exists($vignette)) {
1533
-						spip_log("echec netpbm-png sur $vignette");
1534
-
1535
-						return;
1536
-					}
1537
-				}
1538
-			}
1539
-		}
1540
-	}
1541
-
1542
-	// gd ou gd2
1543
-	elseif ($process == 'gd1' or $process == 'gd2') {
1544
-		if (!function_exists('gd_info')) {
1545
-			spip_log('Librairie GD absente !', _LOG_ERREUR);
1546
-
1547
-			return;
1548
-		}
1549
-		if (_IMG_GD_MAX_PIXELS && $srcWidth * $srcHeight > _IMG_GD_MAX_PIXELS) {
1550
-			spip_log('vignette gd1/gd2 impossible : ' . $srcWidth * $srcHeight . 'pixels');
1551
-
1552
-			return;
1553
-		}
1554
-		$destFormat = $format_sortie;
1555
-		if (!$destFormat) {
1556
-			spip_log("pas de format pour $image");
1557
-
1558
-			return;
1559
-		}
1560
-
1561
-		$fonction_imagecreatefrom = $valeurs['fonction_imagecreatefrom'];
1562
-		if (!function_exists($fonction_imagecreatefrom)) {
1563
-			return '';
1564
-		}
1565
-		$srcImage = @$fonction_imagecreatefrom($image);
1566
-		if (!$srcImage) {
1567
-			spip_log('echec gd1/gd2');
1568
-
1569
-			return;
1570
-		}
1571
-
1572
-		// Initialisation de l'image destination
1573
-		$destImage = null;
1574
-		if ($process == 'gd2' and $destFormat != 'gif') {
1575
-			$destImage = ImageCreateTrueColor($destWidth, $destHeight);
1576
-		}
1577
-		if (!$destImage) {
1578
-			$destImage = ImageCreate($destWidth, $destHeight);
1579
-		}
1580
-
1581
-		// Recopie de l'image d'origine avec adaptation de la taille
1582
-		$ok = false;
1583
-		if (($process == 'gd2') and function_exists('ImageCopyResampled')) {
1584
-			if ($format == 'gif') {
1585
-				// Si un GIF est transparent,
1586
-				// fabriquer un PNG transparent
1587
-				$transp = imagecolortransparent($srcImage);
1588
-				if ($transp > 0) {
1589
-					$destFormat = 'png';
1590
-				}
1591
-			}
1592
-			if (in_array($destFormat, _image_extensions_conservent_transparence())) {
1593
-				// Conserver la transparence
1594
-				if (function_exists('imageAntiAlias')) {
1595
-					imageAntiAlias($destImage, true);
1596
-				}
1597
-				@imagealphablending($destImage, false);
1598
-				@imagesavealpha($destImage, true);
1599
-			}
1600
-			$ok = @ImageCopyResampled($destImage, $srcImage, 0, 0, 0, 0, $destWidth, $destHeight, $srcWidth, $srcHeight);
1601
-		}
1602
-		if (!$ok) {
1603
-			$ok = ImageCopyResized($destImage, $srcImage, 0, 0, 0, 0, $destWidth, $destHeight, $srcWidth, $srcHeight);
1604
-		}
1605
-
1606
-		// Sauvegarde de l'image destination
1607
-		$valeurs['fichier_dest'] = $vignette = "$destination.$destFormat";
1608
-		$valeurs['format_dest'] = $format = $destFormat;
1609
-		_image_gd_output($destImage, $valeurs);
1610
-
1611
-		if ($srcImage) {
1612
-			ImageDestroy($srcImage);
1613
-		}
1614
-		ImageDestroy($destImage);
1615
-	}
1616
-
1617
-	if (!$vignette or !$size = @spip_getimagesize($vignette)) {
1618
-		$size = [$destWidth, $destHeight];
1619
-	}
1620
-
1621
-	// Gaffe: en safe mode, pas d'acces a la vignette,
1622
-	// donc risque de balancer "width='0'", ce qui masque l'image sous MSIE
1623
-	if ($size[0] < 1) {
1624
-		$size[0] = $destWidth;
1625
-	}
1626
-	if ($size[1] < 1) {
1627
-		$size[1] = $destHeight;
1628
-	}
1629
-
1630
-	$retour['width'] = $largeur = $size[0];
1631
-	$retour['height'] = $hauteur = $size[1];
1632
-
1633
-	$retour['fichier'] = $vignette;
1634
-	$retour['format'] = $format;
1635
-	$retour['date'] = @filemtime($vignette);
1636
-
1637
-	// renvoyer l'image
1638
-	return $retour;
1386
+    $srcHeight = null;
1387
+    $retour = [];
1388
+    // ordre de preference des formats graphiques pour creer les vignettes
1389
+    // le premier format disponible, selon la methode demandee, est utilise
1390
+    $image = $valeurs['fichier'];
1391
+    $format = $valeurs['format_source'];
1392
+    $destdir = dirname($valeurs['fichier_dest']);
1393
+    $destfile = basename($valeurs['fichier_dest'], '.' . $valeurs['format_dest']);
1394
+
1395
+    $format_sortie = $valeurs['format_dest'];
1396
+
1397
+    if (($process == 'AUTO') and isset($GLOBALS['meta']['image_process'])) {
1398
+        $process = $GLOBALS['meta']['image_process'];
1399
+    }
1400
+
1401
+    // si le doc n'est pas une image dans un format accetpable, refuser
1402
+    if (!$force and !in_array($format, formats_image_acceptables(in_array($process, ['gd1', 'gd2'])))) {
1403
+        return;
1404
+    }
1405
+    $destination = "$destdir/$destfile";
1406
+
1407
+    // calculer la taille
1408
+    if (($srcWidth = $valeurs['largeur']) && ($srcHeight = $valeurs['hauteur'])) {
1409
+        if (!($destWidth = $valeurs['largeur_dest']) || !($destHeight = $valeurs['hauteur_dest'])) {
1410
+            [$destWidth, $destHeight] = _image_ratio($srcWidth, $srcHeight, $maxWidth, $maxHeight);
1411
+        }
1412
+    } elseif ($process == 'convert' or $process == 'imagick') {
1413
+        $destWidth = $maxWidth;
1414
+        $destHeight = $maxHeight;
1415
+    } else {
1416
+        spip_log("echec $process sur $image");
1417
+
1418
+        return;
1419
+    }
1420
+
1421
+    $vignette = '';
1422
+
1423
+    // Si l'image est de la taille demandee (ou plus petite), simplement la retourner
1424
+    if ($srcWidth and $srcWidth <= $maxWidth and $srcHeight <= $maxHeight) {
1425
+        $vignette = $destination . '.' . $format;
1426
+        @copy($image, $vignette);
1427
+    }
1428
+
1429
+    elseif ($valeurs['format_source'] === 'svg') {
1430
+        if ($svg = svg_redimensionner($valeurs['fichier'], $destWidth, $destHeight)) {
1431
+            $format_sortie = 'svg';
1432
+            $vignette = $destination . '.' . $format_sortie;
1433
+            $valeurs['fichier_dest'] = $vignette;
1434
+            _image_gd_output($svg, $valeurs);
1435
+        }
1436
+    }
1437
+
1438
+    // imagemagick en ligne de commande
1439
+    elseif ($process == 'convert') {
1440
+        if (!defined('_CONVERT_COMMAND')) {
1441
+            define('_CONVERT_COMMAND', 'convert');
1442
+        } // Securite : mes_options.php peut preciser le chemin absolu
1443
+        if (!defined('_RESIZE_COMMAND')) {
1444
+            define('_RESIZE_COMMAND', _CONVERT_COMMAND . ' -quality ' . _IMG_CONVERT_QUALITE . ' -resize %xx%y! %src %dest');
1445
+        }
1446
+        $vignette = $destination . '.' . $format_sortie;
1447
+        $commande = str_replace(
1448
+            ['%x', '%y', '%src', '%dest'],
1449
+            [
1450
+                $destWidth,
1451
+                $destHeight,
1452
+                escapeshellcmd($image),
1453
+                escapeshellcmd($vignette)
1454
+            ],
1455
+            _RESIZE_COMMAND
1456
+        );
1457
+        spip_log($commande);
1458
+        exec($commande);
1459
+        if (!@file_exists($vignette)) {
1460
+            spip_log("echec convert sur $vignette");
1461
+
1462
+            return;  // echec commande
1463
+        }
1464
+    }
1465
+
1466
+    // php5 imagemagick
1467
+    elseif ($process == 'imagick') {
1468
+        $vignette = "$destination." . $format_sortie;
1469
+
1470
+        if (!class_exists(\Imagick::class)) {
1471
+            spip_log('Classe Imagick absente !', _LOG_ERREUR);
1472
+
1473
+            return;
1474
+        }
1475
+        $imagick = new Imagick();
1476
+        $imagick->readImage($image);
1477
+        $imagick->resizeImage(
1478
+            $destWidth,
1479
+            $destHeight,
1480
+            Imagick::FILTER_LANCZOS,
1481
+            1
1482
+        );//, IMAGICK_FILTER_LANCZOS, _IMG_IMAGICK_QUALITE / 100);
1483
+        $imagick->writeImage($vignette);
1484
+
1485
+        if (!@file_exists($vignette)) {
1486
+            spip_log("echec imagick sur $vignette");
1487
+
1488
+            return;
1489
+        }
1490
+    }
1491
+
1492
+    // netpbm
1493
+    elseif ($process == 'netpbm') {
1494
+        if (!defined('_PNMSCALE_COMMAND')) {
1495
+            define('_PNMSCALE_COMMAND', 'pnmscale');
1496
+        } // Securite : mes_options.php peut preciser le chemin absolu
1497
+        if (_PNMSCALE_COMMAND == '') {
1498
+            return;
1499
+        }
1500
+        $vignette = $destination . '.' . $format_sortie;
1501
+        $pnmtojpeg_command = str_replace('pnmscale', 'pnmtojpeg', _PNMSCALE_COMMAND);
1502
+        if ($format == 'jpg') {
1503
+            $jpegtopnm_command = str_replace('pnmscale', 'jpegtopnm', _PNMSCALE_COMMAND);
1504
+            exec("$jpegtopnm_command $image | " . _PNMSCALE_COMMAND . " -width $destWidth | $pnmtojpeg_command > $vignette");
1505
+            if (!($s = @filesize($vignette))) {
1506
+                spip_unlink($vignette);
1507
+            }
1508
+            if (!@file_exists($vignette)) {
1509
+                spip_log("echec netpbm-jpg sur $vignette");
1510
+
1511
+                return;
1512
+            }
1513
+        } else {
1514
+            if ($format == 'gif') {
1515
+                $giftopnm_command = str_replace('pnmscale', 'giftopnm', _PNMSCALE_COMMAND);
1516
+                exec("$giftopnm_command $image | " . _PNMSCALE_COMMAND . " -width $destWidth | $pnmtojpeg_command > $vignette");
1517
+                if (!($s = @filesize($vignette))) {
1518
+                    spip_unlink($vignette);
1519
+                }
1520
+                if (!@file_exists($vignette)) {
1521
+                    spip_log("echec netpbm-gif sur $vignette");
1522
+
1523
+                    return;
1524
+                }
1525
+            } else {
1526
+                if ($format == 'png') {
1527
+                    $pngtopnm_command = str_replace('pnmscale', 'pngtopnm', _PNMSCALE_COMMAND);
1528
+                    exec("$pngtopnm_command $image | " . _PNMSCALE_COMMAND . " -width $destWidth | $pnmtojpeg_command > $vignette");
1529
+                    if (!($s = @filesize($vignette))) {
1530
+                        spip_unlink($vignette);
1531
+                    }
1532
+                    if (!@file_exists($vignette)) {
1533
+                        spip_log("echec netpbm-png sur $vignette");
1534
+
1535
+                        return;
1536
+                    }
1537
+                }
1538
+            }
1539
+        }
1540
+    }
1541
+
1542
+    // gd ou gd2
1543
+    elseif ($process == 'gd1' or $process == 'gd2') {
1544
+        if (!function_exists('gd_info')) {
1545
+            spip_log('Librairie GD absente !', _LOG_ERREUR);
1546
+
1547
+            return;
1548
+        }
1549
+        if (_IMG_GD_MAX_PIXELS && $srcWidth * $srcHeight > _IMG_GD_MAX_PIXELS) {
1550
+            spip_log('vignette gd1/gd2 impossible : ' . $srcWidth * $srcHeight . 'pixels');
1551
+
1552
+            return;
1553
+        }
1554
+        $destFormat = $format_sortie;
1555
+        if (!$destFormat) {
1556
+            spip_log("pas de format pour $image");
1557
+
1558
+            return;
1559
+        }
1560
+
1561
+        $fonction_imagecreatefrom = $valeurs['fonction_imagecreatefrom'];
1562
+        if (!function_exists($fonction_imagecreatefrom)) {
1563
+            return '';
1564
+        }
1565
+        $srcImage = @$fonction_imagecreatefrom($image);
1566
+        if (!$srcImage) {
1567
+            spip_log('echec gd1/gd2');
1568
+
1569
+            return;
1570
+        }
1571
+
1572
+        // Initialisation de l'image destination
1573
+        $destImage = null;
1574
+        if ($process == 'gd2' and $destFormat != 'gif') {
1575
+            $destImage = ImageCreateTrueColor($destWidth, $destHeight);
1576
+        }
1577
+        if (!$destImage) {
1578
+            $destImage = ImageCreate($destWidth, $destHeight);
1579
+        }
1580
+
1581
+        // Recopie de l'image d'origine avec adaptation de la taille
1582
+        $ok = false;
1583
+        if (($process == 'gd2') and function_exists('ImageCopyResampled')) {
1584
+            if ($format == 'gif') {
1585
+                // Si un GIF est transparent,
1586
+                // fabriquer un PNG transparent
1587
+                $transp = imagecolortransparent($srcImage);
1588
+                if ($transp > 0) {
1589
+                    $destFormat = 'png';
1590
+                }
1591
+            }
1592
+            if (in_array($destFormat, _image_extensions_conservent_transparence())) {
1593
+                // Conserver la transparence
1594
+                if (function_exists('imageAntiAlias')) {
1595
+                    imageAntiAlias($destImage, true);
1596
+                }
1597
+                @imagealphablending($destImage, false);
1598
+                @imagesavealpha($destImage, true);
1599
+            }
1600
+            $ok = @ImageCopyResampled($destImage, $srcImage, 0, 0, 0, 0, $destWidth, $destHeight, $srcWidth, $srcHeight);
1601
+        }
1602
+        if (!$ok) {
1603
+            $ok = ImageCopyResized($destImage, $srcImage, 0, 0, 0, 0, $destWidth, $destHeight, $srcWidth, $srcHeight);
1604
+        }
1605
+
1606
+        // Sauvegarde de l'image destination
1607
+        $valeurs['fichier_dest'] = $vignette = "$destination.$destFormat";
1608
+        $valeurs['format_dest'] = $format = $destFormat;
1609
+        _image_gd_output($destImage, $valeurs);
1610
+
1611
+        if ($srcImage) {
1612
+            ImageDestroy($srcImage);
1613
+        }
1614
+        ImageDestroy($destImage);
1615
+    }
1616
+
1617
+    if (!$vignette or !$size = @spip_getimagesize($vignette)) {
1618
+        $size = [$destWidth, $destHeight];
1619
+    }
1620
+
1621
+    // Gaffe: en safe mode, pas d'acces a la vignette,
1622
+    // donc risque de balancer "width='0'", ce qui masque l'image sous MSIE
1623
+    if ($size[0] < 1) {
1624
+        $size[0] = $destWidth;
1625
+    }
1626
+    if ($size[1] < 1) {
1627
+        $size[1] = $destHeight;
1628
+    }
1629
+
1630
+    $retour['width'] = $largeur = $size[0];
1631
+    $retour['height'] = $hauteur = $size[1];
1632
+
1633
+    $retour['fichier'] = $vignette;
1634
+    $retour['format'] = $format;
1635
+    $retour['date'] = @filemtime($vignette);
1636
+
1637
+    // renvoyer l'image
1638
+    return $retour;
1639 1639
 }
1640 1640
 
1641 1641
 /**
@@ -1655,25 +1655,25 @@  discard block
 block discarded – undo
1655 1655
  * @return array Liste [ largeur, hauteur, ratio de réduction ]
1656 1656
  **/
1657 1657
 function _image_ratio(int $srcWidth, int $srcHeight, int $maxWidth, int $maxHeight): array {
1658
-	$ratioWidth = $srcWidth / $maxWidth;
1659
-	$ratioHeight = $srcHeight / $maxHeight;
1660
-
1661
-	if ($srcWidth <= $maxWidth and $srcHeight <= $maxHeight) {
1662
-		$destWidth = $srcWidth;
1663
-		$destHeight = $srcHeight;
1664
-	} elseif ($ratioWidth < $ratioHeight) {
1665
-		$destWidth = $srcWidth / $ratioHeight;
1666
-		$destHeight = $maxHeight;
1667
-	} else {
1668
-		$destWidth = $maxWidth;
1669
-		$destHeight = $srcHeight / $ratioWidth;
1670
-	}
1671
-
1672
-	return [
1673
-		intval(round($destWidth)),
1674
-		intval(round($destHeight)),
1675
-		max($ratioWidth, $ratioHeight)
1676
-	];
1658
+    $ratioWidth = $srcWidth / $maxWidth;
1659
+    $ratioHeight = $srcHeight / $maxHeight;
1660
+
1661
+    if ($srcWidth <= $maxWidth and $srcHeight <= $maxHeight) {
1662
+        $destWidth = $srcWidth;
1663
+        $destHeight = $srcHeight;
1664
+    } elseif ($ratioWidth < $ratioHeight) {
1665
+        $destWidth = $srcWidth / $ratioHeight;
1666
+        $destHeight = $maxHeight;
1667
+    } else {
1668
+        $destWidth = $maxWidth;
1669
+        $destHeight = $srcHeight / $ratioWidth;
1670
+    }
1671
+
1672
+    return [
1673
+        intval(round($destWidth)),
1674
+        intval(round($destHeight)),
1675
+        max($ratioWidth, $ratioHeight)
1676
+    ];
1677 1677
 }
1678 1678
 
1679 1679
 /**
@@ -1693,25 +1693,25 @@  discard block
 block discarded – undo
1693 1693
  * @return array Liste [ largeur, hauteur, ratio de réduction ]
1694 1694
  **/
1695 1695
 function ratio_passe_partout(int $srcWidth, int $srcHeight, int $maxWidth, int $maxHeight): array {
1696
-	$ratioWidth = $srcWidth / $maxWidth;
1697
-	$ratioHeight = $srcHeight / $maxHeight;
1698
-
1699
-	if ($srcWidth <= $maxWidth and $srcHeight <= $maxHeight) {
1700
-		$destWidth = $srcWidth;
1701
-		$destHeight = $srcHeight;
1702
-	} elseif ($ratioWidth > $ratioHeight) {
1703
-		$destWidth = $srcWidth / $ratioHeight;
1704
-		$destHeight = $maxHeight;
1705
-	} else {
1706
-		$destWidth = $maxWidth;
1707
-		$destHeight = $srcHeight / $ratioWidth;
1708
-	}
1709
-
1710
-	return [
1711
-		intval(round($destWidth)),
1712
-		intval(round($destHeight)),
1713
-		min($ratioWidth, $ratioHeight)
1714
-	];
1696
+    $ratioWidth = $srcWidth / $maxWidth;
1697
+    $ratioHeight = $srcHeight / $maxHeight;
1698
+
1699
+    if ($srcWidth <= $maxWidth and $srcHeight <= $maxHeight) {
1700
+        $destWidth = $srcWidth;
1701
+        $destHeight = $srcHeight;
1702
+    } elseif ($ratioWidth > $ratioHeight) {
1703
+        $destWidth = $srcWidth / $ratioHeight;
1704
+        $destHeight = $maxHeight;
1705
+    } else {
1706
+        $destWidth = $maxWidth;
1707
+        $destHeight = $srcHeight / $ratioWidth;
1708
+    }
1709
+
1710
+    return [
1711
+        intval(round($destWidth)),
1712
+        intval(round($destHeight)),
1713
+        min($ratioWidth, $ratioHeight)
1714
+    ];
1715 1715
 }
1716 1716
 
1717 1717
 
@@ -1724,12 +1724,12 @@  discard block
 block discarded – undo
1724 1724
  * @return string
1725 1725
  */
1726 1726
 function process_image_svg_identite($image) {
1727
-	if ($image['creer']) {
1728
-		$source = $image['fichier'];
1729
-		_image_gd_output($source, $image);
1730
-	}
1727
+    if ($image['creer']) {
1728
+        $source = $image['fichier'];
1729
+        _image_gd_output($source, $image);
1730
+    }
1731 1731
 
1732
-	return _image_ecrire_tag($image, ['src' => $image['fichier_dest']]);
1732
+    return _image_ecrire_tag($image, ['src' => $image['fichier_dest']]);
1733 1733
 }
1734 1734
 
1735 1735
 
@@ -1762,111 +1762,111 @@  discard block
 block discarded – undo
1762 1762
  *     Code HTML de la balise img produite
1763 1763
  **/
1764 1764
 function process_image_reduire($fonction, $img, $taille, $taille_y, $force, $process = 'AUTO') {
1765
-	$image = false;
1766
-	if (($process == 'AUTO') and isset($GLOBALS['meta']['image_process'])) {
1767
-		$process = $GLOBALS['meta']['image_process'];
1768
-	}
1769
-	# determiner le format de sortie
1770
-	$format_sortie = false; // le choix par defaut sera bon
1771
-	if ($process == 'netpbm') {
1772
-		$format_sortie = 'jpg';
1773
-	} elseif ($process == 'gd1' or $process == 'gd2') {
1774
-		$image = _image_valeurs_trans($img, "reduire-{$taille}-{$taille_y}", $format_sortie, $fonction, false, _SVG_SUPPORTED);
1775
-		// on verifie que l'extension choisie est bonne (en principe oui)
1776
-		$gd_formats = formats_image_acceptables(true);
1777
-		if (
1778
-			is_array($image)
1779
-			and (!in_array($image['format_dest'], $gd_formats)
1780
-				or (!in_array($image['format_dest'], _image_extensions_acceptees_en_sortie()))
1781
-			)
1782
-		) {
1783
-			if ($image['format_source'] == 'jpg') {
1784
-				$formats_sortie = ['jpg', 'png', 'gif'];
1785
-			} else // les gif sont passes en png preferentiellement pour etre homogene aux autres filtres images
1786
-			{
1787
-				$formats_sortie = ['png', 'jpg', 'gif'];
1788
-			}
1789
-			// Choisir le format destination
1790
-			// - on sauve de preference en JPEG (meilleure compression)
1791
-			// - pour le GIF : les GD recentes peuvent le lire mais pas l'ecrire
1792
-			# bug : gd_formats contient la liste des fichiers qu'on sait *lire*,
1793
-			# pas *ecrire*
1794
-			$format_sortie = '';
1795
-			foreach ($formats_sortie as $fmt) {
1796
-				if (in_array($fmt, $gd_formats) and in_array($fmt, _image_extensions_acceptees_en_sortie())) {
1797
-					$format_sortie = $fmt;
1798
-					break;
1799
-				}
1800
-			}
1801
-			$image = false;
1802
-		}
1803
-	}
1804
-
1805
-	if (!is_array($image)) {
1806
-		$image = _image_valeurs_trans($img, "reduire-{$taille}-{$taille_y}", $format_sortie, $fonction, false, _SVG_SUPPORTED);
1807
-	}
1808
-
1809
-	if (!is_array($image) or !$image['largeur'] or !$image['hauteur']) {
1810
-		spip_log("image_reduire_src:pas de version locale de $img");
1811
-		// on peut resizer en mode html si on dispose des elements
1812
-		if (
1813
-			$srcw = extraire_attribut($img, 'width')
1814
-			and $srch = extraire_attribut($img, 'height')
1815
-		) {
1816
-			[$w, $h] = _image_ratio($srcw, $srch, $taille, $taille_y);
1817
-
1818
-			return _image_tag_changer_taille($img, $w, $h);
1819
-		}
1820
-		// la on n'a pas d'infos sur l'image source... on refile le truc a css
1821
-		// sous la forme style='max-width: NNpx;'
1822
-		return inserer_attribut(
1823
-			$img,
1824
-			'style',
1825
-			"max-width: ${taille}px; max-height: ${taille_y}px"
1826
-		);
1827
-	}
1828
-
1829
-	// si l'image est plus petite que la cible retourner une copie cachee de l'image
1830
-	if (($image['largeur'] <= $taille) && ($image['hauteur'] <= $taille_y)) {
1831
-		if ($image['creer']) {
1832
-			@copy($image['fichier'], $image['fichier_dest']);
1833
-		}
1834
-
1835
-		return _image_ecrire_tag($image, ['src' => $image['fichier_dest']]);
1836
-	}
1837
-
1838
-	if ($image['creer'] == false && !$force) {
1839
-		return _image_ecrire_tag(
1840
-			$image,
1841
-			['src' => $image['fichier_dest'], 'width' => $image['largeur_dest'], 'height' => $image['hauteur_dest']]
1842
-		);
1843
-	}
1844
-
1845
-	if (in_array($image['format_source'], _image_extensions_acceptees_en_entree())) {
1846
-		$destWidth = $image['largeur_dest'];
1847
-		$destHeight = $image['hauteur_dest'];
1848
-		$logo = $image['fichier'];
1849
-		$date = $image['date_src'];
1850
-		$preview = _image_creer_vignette($image, $taille, $taille_y, $process, $force);
1851
-
1852
-		if ($preview && $preview['fichier']) {
1853
-			$logo = $preview['fichier'];
1854
-			$destWidth = $preview['width'];
1855
-			$destHeight = $preview['height'];
1856
-			$date = $preview['date'];
1857
-		}
1858
-		// dans l'espace prive mettre un timestamp sur l'adresse
1859
-		// de l'image, de facon a tromper le cache du navigateur
1860
-		// quand on fait supprimer/reuploader un logo
1861
-		// (pas de filemtime si SAFE MODE)
1862
-		$date = test_espace_prive() ? ('?' . $date) : '';
1863
-
1864
-		return _image_ecrire_tag($image, ['src' => "$logo$date", 'width' => $destWidth, 'height' => $destHeight]);
1865
-	}
1866
-	else {
1867
-		# BMP, tiff ... les redacteurs osent tout!
1868
-		return $img;
1869
-	}
1765
+    $image = false;
1766
+    if (($process == 'AUTO') and isset($GLOBALS['meta']['image_process'])) {
1767
+        $process = $GLOBALS['meta']['image_process'];
1768
+    }
1769
+    # determiner le format de sortie
1770
+    $format_sortie = false; // le choix par defaut sera bon
1771
+    if ($process == 'netpbm') {
1772
+        $format_sortie = 'jpg';
1773
+    } elseif ($process == 'gd1' or $process == 'gd2') {
1774
+        $image = _image_valeurs_trans($img, "reduire-{$taille}-{$taille_y}", $format_sortie, $fonction, false, _SVG_SUPPORTED);
1775
+        // on verifie que l'extension choisie est bonne (en principe oui)
1776
+        $gd_formats = formats_image_acceptables(true);
1777
+        if (
1778
+            is_array($image)
1779
+            and (!in_array($image['format_dest'], $gd_formats)
1780
+                or (!in_array($image['format_dest'], _image_extensions_acceptees_en_sortie()))
1781
+            )
1782
+        ) {
1783
+            if ($image['format_source'] == 'jpg') {
1784
+                $formats_sortie = ['jpg', 'png', 'gif'];
1785
+            } else // les gif sont passes en png preferentiellement pour etre homogene aux autres filtres images
1786
+            {
1787
+                $formats_sortie = ['png', 'jpg', 'gif'];
1788
+            }
1789
+            // Choisir le format destination
1790
+            // - on sauve de preference en JPEG (meilleure compression)
1791
+            // - pour le GIF : les GD recentes peuvent le lire mais pas l'ecrire
1792
+            # bug : gd_formats contient la liste des fichiers qu'on sait *lire*,
1793
+            # pas *ecrire*
1794
+            $format_sortie = '';
1795
+            foreach ($formats_sortie as $fmt) {
1796
+                if (in_array($fmt, $gd_formats) and in_array($fmt, _image_extensions_acceptees_en_sortie())) {
1797
+                    $format_sortie = $fmt;
1798
+                    break;
1799
+                }
1800
+            }
1801
+            $image = false;
1802
+        }
1803
+    }
1804
+
1805
+    if (!is_array($image)) {
1806
+        $image = _image_valeurs_trans($img, "reduire-{$taille}-{$taille_y}", $format_sortie, $fonction, false, _SVG_SUPPORTED);
1807
+    }
1808
+
1809
+    if (!is_array($image) or !$image['largeur'] or !$image['hauteur']) {
1810
+        spip_log("image_reduire_src:pas de version locale de $img");
1811
+        // on peut resizer en mode html si on dispose des elements
1812
+        if (
1813
+            $srcw = extraire_attribut($img, 'width')
1814
+            and $srch = extraire_attribut($img, 'height')
1815
+        ) {
1816
+            [$w, $h] = _image_ratio($srcw, $srch, $taille, $taille_y);
1817
+
1818
+            return _image_tag_changer_taille($img, $w, $h);
1819
+        }
1820
+        // la on n'a pas d'infos sur l'image source... on refile le truc a css
1821
+        // sous la forme style='max-width: NNpx;'
1822
+        return inserer_attribut(
1823
+            $img,
1824
+            'style',
1825
+            "max-width: ${taille}px; max-height: ${taille_y}px"
1826
+        );
1827
+    }
1828
+
1829
+    // si l'image est plus petite que la cible retourner une copie cachee de l'image
1830
+    if (($image['largeur'] <= $taille) && ($image['hauteur'] <= $taille_y)) {
1831
+        if ($image['creer']) {
1832
+            @copy($image['fichier'], $image['fichier_dest']);
1833
+        }
1834
+
1835
+        return _image_ecrire_tag($image, ['src' => $image['fichier_dest']]);
1836
+    }
1837
+
1838
+    if ($image['creer'] == false && !$force) {
1839
+        return _image_ecrire_tag(
1840
+            $image,
1841
+            ['src' => $image['fichier_dest'], 'width' => $image['largeur_dest'], 'height' => $image['hauteur_dest']]
1842
+        );
1843
+    }
1844
+
1845
+    if (in_array($image['format_source'], _image_extensions_acceptees_en_entree())) {
1846
+        $destWidth = $image['largeur_dest'];
1847
+        $destHeight = $image['hauteur_dest'];
1848
+        $logo = $image['fichier'];
1849
+        $date = $image['date_src'];
1850
+        $preview = _image_creer_vignette($image, $taille, $taille_y, $process, $force);
1851
+
1852
+        if ($preview && $preview['fichier']) {
1853
+            $logo = $preview['fichier'];
1854
+            $destWidth = $preview['width'];
1855
+            $destHeight = $preview['height'];
1856
+            $date = $preview['date'];
1857
+        }
1858
+        // dans l'espace prive mettre un timestamp sur l'adresse
1859
+        // de l'image, de facon a tromper le cache du navigateur
1860
+        // quand on fait supprimer/reuploader un logo
1861
+        // (pas de filemtime si SAFE MODE)
1862
+        $date = test_espace_prive() ? ('?' . $date) : '';
1863
+
1864
+        return _image_ecrire_tag($image, ['src' => "$logo$date", 'width' => $destWidth, 'height' => $destHeight]);
1865
+    }
1866
+    else {
1867
+        # BMP, tiff ... les redacteurs osent tout!
1868
+        return $img;
1869
+    }
1870 1870
 }
1871 1871
 
1872 1872
 /**
@@ -1881,145 +1881,145 @@  discard block
 block discarded – undo
1881 1881
  */
1882 1882
 class phpthumb_functions {
1883 1883
 
1884
-	/**
1885
-	 * Retourne la couleur d'un pixel dans une image
1886
-	 *
1887
-	 * @param ressource $img
1888
-	 * @param int $x
1889
-	 * @param int $y
1890
-	 * @return array|bool
1891
-	 */
1892
-	public static function GetPixelColor(&$img, $x, $y) {
1893
-		if (is_resource($img) || (is_object($img) && $img instanceof \GdImage)) {
1894
-			return @ImageColorsForIndex($img, @ImageColorAt($img, $x, $y));
1895
-		}
1896
-		return false;
1897
-	}
1898
-
1899
-	/**
1900
-	 * Retourne un nombre dans une représentation en Little Endian
1901
-	 *
1902
-	 * @param int $number
1903
-	 * @param int $minbytes
1904
-	 * @return string
1905
-	 */
1906
-	public static function LittleEndian2String($number, $minbytes = 1) {
1907
-		$intstring = '';
1908
-		while ($number > 0) {
1909
-			$intstring = $intstring . chr($number & 255);
1910
-			$number >>= 8;
1911
-		}
1912
-
1913
-		return str_pad($intstring, $minbytes, "\x00", STR_PAD_RIGHT);
1914
-	}
1915
-
1916
-	/**
1917
-	 * Transforme une ressource GD en image au format ICO
1918
-	 *
1919
-	 * @param array $gd_image_array
1920
-	 *     Tableau de ressources d'images GD
1921
-	 * @return string
1922
-	 *     Image au format ICO
1923
-	 */
1924
-	public static function GD2ICOstring(&$gd_image_array) {
1925
-		foreach ($gd_image_array as $key => $gd_image) {
1926
-			$ImageWidths[$key] = ImageSX($gd_image);
1927
-			$ImageHeights[$key] = ImageSY($gd_image);
1928
-			$bpp[$key] = ImageIsTrueColor($gd_image) ? 32 : 24;
1929
-			$totalcolors[$key] = ImageColorsTotal($gd_image);
1930
-
1931
-			$icXOR[$key] = '';
1932
-			for ($y = $ImageHeights[$key] - 1; $y >= 0; $y--) {
1933
-				for ($x = 0; $x < $ImageWidths[$key]; $x++) {
1934
-					$argb = phpthumb_functions::GetPixelColor($gd_image, $x, $y);
1935
-					$a = round(255 * ((127 - $argb['alpha']) / 127));
1936
-					$r = $argb['red'];
1937
-					$g = $argb['green'];
1938
-					$b = $argb['blue'];
1939
-
1940
-					if ($bpp[$key] == 32) {
1941
-						$icXOR[$key] .= chr($b) . chr($g) . chr($r) . chr($a);
1942
-					} elseif ($bpp[$key] == 24) {
1943
-						$icXOR[$key] .= chr($b) . chr($g) . chr($r);
1944
-					}
1945
-
1946
-					if ($a < 128) {
1947
-						@$icANDmask[$key][$y] .= '1';
1948
-					} else {
1949
-						@$icANDmask[$key][$y] .= '0';
1950
-					}
1951
-				}
1952
-				// mask bits are 32-bit aligned per scanline
1953
-				while (strlen($icANDmask[$key][$y]) % 32) {
1954
-					$icANDmask[$key][$y] .= '0';
1955
-				}
1956
-			}
1957
-			$icAND[$key] = '';
1958
-			foreach ($icANDmask[$key] as $y => $scanlinemaskbits) {
1959
-				for ($i = 0; $i < strlen($scanlinemaskbits); $i += 8) {
1960
-					$icAND[$key] .= chr(bindec(str_pad(substr($scanlinemaskbits, $i, 8), 8, '0', STR_PAD_LEFT)));
1961
-				}
1962
-			}
1963
-		}
1964
-
1965
-		foreach ($gd_image_array as $key => $gd_image) {
1966
-			$biSizeImage = $ImageWidths[$key] * $ImageHeights[$key] * ($bpp[$key] / 8);
1967
-
1968
-			// BITMAPINFOHEADER - 40 bytes
1969
-			$BitmapInfoHeader[$key] = '';
1970
-			$BitmapInfoHeader[$key] .= "\x28\x00\x00\x00";                // DWORD  biSize;
1971
-			$BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($ImageWidths[$key], 4);    // LONG   biWidth;
1972
-			// The biHeight member specifies the combined
1973
-			// height of the XOR and AND masks.
1974
-			$BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($ImageHeights[$key] * 2, 4); // LONG   biHeight;
1975
-			$BitmapInfoHeader[$key] .= "\x01\x00";                    // WORD   biPlanes;
1976
-			$BitmapInfoHeader[$key] .= chr($bpp[$key]) . "\x00";              // wBitCount;
1977
-			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // DWORD  biCompression;
1978
-			$BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($biSizeImage, 4);      // DWORD  biSizeImage;
1979
-			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // LONG   biXPelsPerMeter;
1980
-			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // LONG   biYPelsPerMeter;
1981
-			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // DWORD  biClrUsed;
1982
-			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // DWORD  biClrImportant;
1983
-		}
1984
-
1985
-
1986
-		$icondata = "\x00\x00";                    // idReserved;   // Reserved (must be 0)
1987
-		$icondata .= "\x01\x00";                    // idType;	   // Resource Type (1 for icons)
1988
-		$icondata .= phpthumb_functions::LittleEndian2String(count($gd_image_array), 2);  // idCount;	  // How many images?
1989
-
1990
-		$dwImageOffset = 6 + (count($gd_image_array) * 16);
1991
-		foreach ($gd_image_array as $key => $gd_image) {
1992
-			// ICONDIRENTRY   idEntries[1]; // An entry for each image (idCount of 'em)
1993
-
1994
-			$icondata .= chr($ImageWidths[$key]);           // bWidth;		  // Width, in pixels, of the image
1995
-			$icondata .= chr($ImageHeights[$key]);          // bHeight;		 // Height, in pixels, of the image
1996
-			$icondata .= chr($totalcolors[$key]);           // bColorCount;	 // Number of colors in image (0 if >=8bpp)
1997
-			$icondata .= "\x00";                    // bReserved;	   // Reserved ( must be 0)
1998
-
1999
-			$icondata .= "\x01\x00";                  // wPlanes;		 // Color Planes
2000
-			$icondata .= chr($bpp[$key]) . "\x00";            // wBitCount;	   // Bits per pixel
2001
-
2002
-			$dwBytesInRes = 40 + strlen($icXOR[$key]) + strlen($icAND[$key]);
2003
-			$icondata .= phpthumb_functions::LittleEndian2String(
2004
-				$dwBytesInRes,
2005
-				4
2006
-			);     // dwBytesInRes;	// How many bytes in this resource?
2007
-
2008
-			$icondata .= phpthumb_functions::LittleEndian2String(
2009
-				$dwImageOffset,
2010
-				4
2011
-			);    // dwImageOffset;   // Where in the file is this image?
2012
-			$dwImageOffset += strlen($BitmapInfoHeader[$key]);
2013
-			$dwImageOffset += strlen($icXOR[$key]);
2014
-			$dwImageOffset += strlen($icAND[$key]);
2015
-		}
2016
-
2017
-		foreach ($gd_image_array as $key => $gd_image) {
2018
-			$icondata .= $BitmapInfoHeader[$key];
2019
-			$icondata .= $icXOR[$key];
2020
-			$icondata .= $icAND[$key];
2021
-		}
2022
-
2023
-		return $icondata;
2024
-	}
1884
+    /**
1885
+     * Retourne la couleur d'un pixel dans une image
1886
+     *
1887
+     * @param ressource $img
1888
+     * @param int $x
1889
+     * @param int $y
1890
+     * @return array|bool
1891
+     */
1892
+    public static function GetPixelColor(&$img, $x, $y) {
1893
+        if (is_resource($img) || (is_object($img) && $img instanceof \GdImage)) {
1894
+            return @ImageColorsForIndex($img, @ImageColorAt($img, $x, $y));
1895
+        }
1896
+        return false;
1897
+    }
1898
+
1899
+    /**
1900
+     * Retourne un nombre dans une représentation en Little Endian
1901
+     *
1902
+     * @param int $number
1903
+     * @param int $minbytes
1904
+     * @return string
1905
+     */
1906
+    public static function LittleEndian2String($number, $minbytes = 1) {
1907
+        $intstring = '';
1908
+        while ($number > 0) {
1909
+            $intstring = $intstring . chr($number & 255);
1910
+            $number >>= 8;
1911
+        }
1912
+
1913
+        return str_pad($intstring, $minbytes, "\x00", STR_PAD_RIGHT);
1914
+    }
1915
+
1916
+    /**
1917
+     * Transforme une ressource GD en image au format ICO
1918
+     *
1919
+     * @param array $gd_image_array
1920
+     *     Tableau de ressources d'images GD
1921
+     * @return string
1922
+     *     Image au format ICO
1923
+     */
1924
+    public static function GD2ICOstring(&$gd_image_array) {
1925
+        foreach ($gd_image_array as $key => $gd_image) {
1926
+            $ImageWidths[$key] = ImageSX($gd_image);
1927
+            $ImageHeights[$key] = ImageSY($gd_image);
1928
+            $bpp[$key] = ImageIsTrueColor($gd_image) ? 32 : 24;
1929
+            $totalcolors[$key] = ImageColorsTotal($gd_image);
1930
+
1931
+            $icXOR[$key] = '';
1932
+            for ($y = $ImageHeights[$key] - 1; $y >= 0; $y--) {
1933
+                for ($x = 0; $x < $ImageWidths[$key]; $x++) {
1934
+                    $argb = phpthumb_functions::GetPixelColor($gd_image, $x, $y);
1935
+                    $a = round(255 * ((127 - $argb['alpha']) / 127));
1936
+                    $r = $argb['red'];
1937
+                    $g = $argb['green'];
1938
+                    $b = $argb['blue'];
1939
+
1940
+                    if ($bpp[$key] == 32) {
1941
+                        $icXOR[$key] .= chr($b) . chr($g) . chr($r) . chr($a);
1942
+                    } elseif ($bpp[$key] == 24) {
1943
+                        $icXOR[$key] .= chr($b) . chr($g) . chr($r);
1944
+                    }
1945
+
1946
+                    if ($a < 128) {
1947
+                        @$icANDmask[$key][$y] .= '1';
1948
+                    } else {
1949
+                        @$icANDmask[$key][$y] .= '0';
1950
+                    }
1951
+                }
1952
+                // mask bits are 32-bit aligned per scanline
1953
+                while (strlen($icANDmask[$key][$y]) % 32) {
1954
+                    $icANDmask[$key][$y] .= '0';
1955
+                }
1956
+            }
1957
+            $icAND[$key] = '';
1958
+            foreach ($icANDmask[$key] as $y => $scanlinemaskbits) {
1959
+                for ($i = 0; $i < strlen($scanlinemaskbits); $i += 8) {
1960
+                    $icAND[$key] .= chr(bindec(str_pad(substr($scanlinemaskbits, $i, 8), 8, '0', STR_PAD_LEFT)));
1961
+                }
1962
+            }
1963
+        }
1964
+
1965
+        foreach ($gd_image_array as $key => $gd_image) {
1966
+            $biSizeImage = $ImageWidths[$key] * $ImageHeights[$key] * ($bpp[$key] / 8);
1967
+
1968
+            // BITMAPINFOHEADER - 40 bytes
1969
+            $BitmapInfoHeader[$key] = '';
1970
+            $BitmapInfoHeader[$key] .= "\x28\x00\x00\x00";                // DWORD  biSize;
1971
+            $BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($ImageWidths[$key], 4);    // LONG   biWidth;
1972
+            // The biHeight member specifies the combined
1973
+            // height of the XOR and AND masks.
1974
+            $BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($ImageHeights[$key] * 2, 4); // LONG   biHeight;
1975
+            $BitmapInfoHeader[$key] .= "\x01\x00";                    // WORD   biPlanes;
1976
+            $BitmapInfoHeader[$key] .= chr($bpp[$key]) . "\x00";              // wBitCount;
1977
+            $BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // DWORD  biCompression;
1978
+            $BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($biSizeImage, 4);      // DWORD  biSizeImage;
1979
+            $BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // LONG   biXPelsPerMeter;
1980
+            $BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // LONG   biYPelsPerMeter;
1981
+            $BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // DWORD  biClrUsed;
1982
+            $BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // DWORD  biClrImportant;
1983
+        }
1984
+
1985
+
1986
+        $icondata = "\x00\x00";                    // idReserved;   // Reserved (must be 0)
1987
+        $icondata .= "\x01\x00";                    // idType;	   // Resource Type (1 for icons)
1988
+        $icondata .= phpthumb_functions::LittleEndian2String(count($gd_image_array), 2);  // idCount;	  // How many images?
1989
+
1990
+        $dwImageOffset = 6 + (count($gd_image_array) * 16);
1991
+        foreach ($gd_image_array as $key => $gd_image) {
1992
+            // ICONDIRENTRY   idEntries[1]; // An entry for each image (idCount of 'em)
1993
+
1994
+            $icondata .= chr($ImageWidths[$key]);           // bWidth;		  // Width, in pixels, of the image
1995
+            $icondata .= chr($ImageHeights[$key]);          // bHeight;		 // Height, in pixels, of the image
1996
+            $icondata .= chr($totalcolors[$key]);           // bColorCount;	 // Number of colors in image (0 if >=8bpp)
1997
+            $icondata .= "\x00";                    // bReserved;	   // Reserved ( must be 0)
1998
+
1999
+            $icondata .= "\x01\x00";                  // wPlanes;		 // Color Planes
2000
+            $icondata .= chr($bpp[$key]) . "\x00";            // wBitCount;	   // Bits per pixel
2001
+
2002
+            $dwBytesInRes = 40 + strlen($icXOR[$key]) + strlen($icAND[$key]);
2003
+            $icondata .= phpthumb_functions::LittleEndian2String(
2004
+                $dwBytesInRes,
2005
+                4
2006
+            );     // dwBytesInRes;	// How many bytes in this resource?
2007
+
2008
+            $icondata .= phpthumb_functions::LittleEndian2String(
2009
+                $dwImageOffset,
2010
+                4
2011
+            );    // dwImageOffset;   // Where in the file is this image?
2012
+            $dwImageOffset += strlen($BitmapInfoHeader[$key]);
2013
+            $dwImageOffset += strlen($icXOR[$key]);
2014
+            $dwImageOffset += strlen($icAND[$key]);
2015
+        }
2016
+
2017
+        foreach ($gd_image_array as $key => $gd_image) {
2018
+            $icondata .= $BitmapInfoHeader[$key];
2019
+            $icondata .= $icXOR[$key];
2020
+            $icondata .= $icAND[$key];
2021
+        }
2022
+
2023
+        return $icondata;
2024
+    }
2025 2025
 }
Please login to merge, or discard this patch.
Spacing   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -43,13 +43,13 @@  discard block
 block discarded – undo
43 43
 	$blue = dechex($blue);
44 44
 
45 45
 	if (strlen($red) == 1) {
46
-		$red = '0' . $red;
46
+		$red = '0'.$red;
47 47
 	}
48 48
 	if (strlen($green) == 1) {
49
-		$green = '0' . $green;
49
+		$green = '0'.$green;
50 50
 	}
51 51
 	if (strlen($blue) == 1) {
52
-		$blue = '0' . $blue;
52
+		$blue = '0'.$blue;
53 53
 	}
54 54
 
55 55
 	return "$red$green$blue";
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	$couleur = couleur_html_to_hex($couleur);
68 68
 	$couleur = ltrim($couleur, '#');
69 69
 	if (strlen($couleur) === 3) {
70
-		$couleur = $couleur[0] . $couleur[0] . $couleur[1] . $couleur[1] . $couleur[2] . $couleur[2];
70
+		$couleur = $couleur[0].$couleur[0].$couleur[1].$couleur[1].$couleur[2].$couleur[2];
71 71
 	}
72 72
 	$retour = [];
73 73
 	$retour['red'] = hexdec(substr($couleur, 0, 2));
@@ -125,9 +125,9 @@  discard block
 block discarded – undo
125 125
 	$var_G = ($G / 255);
126 126
 	$var_B = ($B / 255);
127 127
 
128
-	$var_Min = min($var_R, $var_G, $var_B);   //Min. value of RGB
129
-	$var_Max = max($var_R, $var_G, $var_B);   //Max. value of RGB
130
-	$del_Max = $var_Max - $var_Min;           //Delta RGB value
128
+	$var_Min = min($var_R, $var_G, $var_B); //Min. value of RGB
129
+	$var_Max = max($var_R, $var_G, $var_B); //Max. value of RGB
130
+	$del_Max = $var_Max - $var_Min; //Delta RGB value
131 131
 
132 132
 	$L = ($var_Max + $var_Min) / 2;
133 133
 
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
  */
190 190
 function _couleur_hsl_to_rgb($H, $S, $L) {
191 191
 	// helper
192
-	$hue_2_rgb = function ($v1, $v2, $vH) {
192
+	$hue_2_rgb = function($v1, $v2, $vH) {
193 193
 		if ($vH < 0) {
194 194
 			$vH += 1;
195 195
 		}
@@ -320,11 +320,11 @@  discard block
 block discarded – undo
320 320
 		$img = "<img src='$source' />";
321 321
 	} elseif (
322 322
 		preg_match('@^data:image/([^;]*);base64,(.*)$@isS', $source, $regs)
323
-		and $extension = _image_trouver_extension_depuis_mime('image/' . $regs[1])
323
+		and $extension = _image_trouver_extension_depuis_mime('image/'.$regs[1])
324 324
 		and in_array($extension, _image_extensions_acceptees_en_entree())
325 325
 	) {
326 326
 		# gerer img src="data:....base64"
327
-		$local = sous_repertoire(_DIR_VAR, 'image-data') . md5($regs[2]) . '.' . _image_extension_normalisee($extension);
327
+		$local = sous_repertoire(_DIR_VAR, 'image-data').md5($regs[2]).'.'._image_extension_normalisee($extension);
328 328
 		if (!file_exists($local)) {
329 329
 			ecrire_fichier($local, base64_decode($regs[2]));
330 330
 		}
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
 	// les protocoles web prennent au moins 3 lettres
342 342
 	if (tester_url_absolue($source)) {
343 343
 		include_spip('inc/distant');
344
-		$fichier = _DIR_RACINE . copie_locale($source);
344
+		$fichier = _DIR_RACINE.copie_locale($source);
345 345
 		if (!$fichier) {
346 346
 			return '';
347 347
 		}
@@ -439,9 +439,9 @@  discard block
 block discarded – undo
439 439
 			// on garde la terminaison initiale car image simplement copiee
440 440
 			// et on postfixe son nom avec un md5 du path
441 441
 			$terminaison_dest = $terminaison;
442
-			$fichier_dest .= '-' . substr(md5("$identifiant"), 0, 5);
442
+			$fichier_dest .= '-'.substr(md5("$identifiant"), 0, 5);
443 443
 		} else {
444
-			$fichier_dest .= '-' . substr(md5("$identifiant-$effet"), 0, 5);
444
+			$fichier_dest .= '-'.substr(md5("$identifiant-$effet"), 0, 5);
445 445
 		}
446 446
 		$cache = sous_repertoire(_DIR_VAR, $cache);
447 447
 		$cache = sous_repertoire($cache, $effet);
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
 		$fichier_dest = substr($fichier_dest, 2);
453 453
 	}
454 454
 
455
-	$fichier_dest = $cache . $fichier_dest . '.' . $terminaison_dest;
455
+	$fichier_dest = $cache.$fichier_dest.'.'.$terminaison_dest;
456 456
 
457 457
 	$GLOBALS['images_calculees'][] = $fichier_dest;
458 458
 
@@ -490,15 +490,15 @@  discard block
 block discarded – undo
490 490
 
491 491
 	if ($creer) {
492 492
 		spip_log(
493
-			'filtre image ' . ($fonction_creation ? reset($fonction_creation) : '') . "[$effet] sur $fichier",
494
-			'images' . _LOG_DEBUG
493
+			'filtre image '.($fonction_creation ? reset($fonction_creation) : '')."[$effet] sur $fichier",
494
+			'images'._LOG_DEBUG
495 495
 		);
496 496
 	}
497 497
 
498 498
 	$term_fonction = _image_trouver_extension_pertinente($fichier);
499
-	$ret['fonction_imagecreatefrom'] = '_imagecreatefrom' . $term_fonction;
499
+	$ret['fonction_imagecreatefrom'] = '_imagecreatefrom'.$term_fonction;
500 500
 	$ret['fichier'] = $fichier;
501
-	$ret['fonction_image'] = '_image_image' . $terminaison_dest;
501
+	$ret['fonction_image'] = '_image_image'.$terminaison_dest;
502 502
 	$ret['fichier_dest'] = $fichier_dest;
503 503
 	$ret['format_source'] = _image_extension_normalisee($terminaison);
504 504
 	$ret['format_dest'] = $terminaison_dest;
@@ -647,7 +647,7 @@  discard block
 block discarded – undo
647 647
 
648 648
 	$_terminaison = _image_trouver_extension_depuis_mime($mime);
649 649
 	if ($_terminaison and $_terminaison !== $terminaison) {
650
-		spip_log("Mauvaise extension du fichier : $path . Son type mime est : $mime", 'images.' . _LOG_INFO_IMPORTANTE);
650
+		spip_log("Mauvaise extension du fichier : $path . Son type mime est : $mime", 'images.'._LOG_INFO_IMPORTANTE);
651 651
 		$terminaison = $_terminaison;
652 652
 	}
653 653
 	return $terminaison;
@@ -804,7 +804,7 @@  discard block
 block discarded – undo
804 804
 	if (!function_exists('imagepng')) {
805 805
 		return false;
806 806
 	}
807
-	$tmp = $fichier . '.tmp';
807
+	$tmp = $fichier.'.tmp';
808 808
 	$ret = imagepng($img, $tmp);
809 809
 	if (file_exists($tmp)) {
810 810
 		$taille_test = getimagesize($tmp);
@@ -839,7 +839,7 @@  discard block
 block discarded – undo
839 839
 	if (!function_exists('imagegif')) {
840 840
 		return false;
841 841
 	}
842
-	$tmp = $fichier . '.tmp';
842
+	$tmp = $fichier.'.tmp';
843 843
 	$ret = imagegif($img, $tmp);
844 844
 	if (file_exists($tmp)) {
845 845
 		$taille_test = getimagesize($tmp);
@@ -879,7 +879,7 @@  discard block
 block discarded – undo
879 879
 	if (!function_exists('imagejpeg')) {
880 880
 		return false;
881 881
 	}
882
-	$tmp = $fichier . '.tmp';
882
+	$tmp = $fichier.'.tmp';
883 883
 
884 884
 	// Enable interlancing
885 885
 	imageinterlace($img, true);
@@ -940,7 +940,7 @@  discard block
 block discarded – undo
940 940
 	if (!function_exists('imagewebp')) {
941 941
 		return false;
942 942
 	}
943
-	$tmp = $fichier . '.tmp';
943
+	$tmp = $fichier.'.tmp';
944 944
 	$ret = imagewebp($img, $tmp, $qualite);
945 945
 	if (file_exists($tmp)) {
946 946
 		$taille_test = getimagesize($tmp);
@@ -974,7 +974,7 @@  discard block
 block discarded – undo
974 974
  */
975 975
 function _image_imagesvg($img, $fichier) {
976 976
 
977
-	$tmp = $fichier . '.tmp';
977
+	$tmp = $fichier.'.tmp';
978 978
 	if (strpos($img, '<') === false) {
979 979
 		$img = supprimer_timestamp($img);
980 980
 		if (!file_exists($img)) {
@@ -1031,13 +1031,13 @@  discard block
 block discarded – undo
1031 1031
  */
1032 1032
 function _image_gd_output($img, $valeurs, $qualite = _IMG_GD_QUALITE, $fonction = null) {
1033 1033
 	if (is_null($fonction)) {
1034
-		$fonction = '_image_image' . $valeurs['format_dest'];
1034
+		$fonction = '_image_image'.$valeurs['format_dest'];
1035 1035
 	}
1036 1036
 	$ret = false;
1037 1037
 	#un flag pour reperer les images gravees
1038 1038
 	$lock =
1039 1039
 		!statut_effacer_images_temporaires('get') // si la fonction n'a pas ete activee, on grave tout
1040
-	or (@file_exists($valeurs['fichier_dest']) and !@file_exists($valeurs['fichier_dest'] . '.src'));
1040
+	or (@file_exists($valeurs['fichier_dest']) and !@file_exists($valeurs['fichier_dest'].'.src'));
1041 1041
 	if (
1042 1042
 		function_exists($fonction)
1043 1043
 		&& ($ret = $fonction($img, $valeurs['fichier_dest'], $qualite)) # on a reussi a creer l'image
@@ -1048,7 +1048,7 @@  discard block
 block discarded – undo
1048 1048
 			// dans tous les cas mettre a jour la taille de l'image finale
1049 1049
 			[$valeurs['hauteur_dest'], $valeurs['largeur_dest']] = taille_image($valeurs['fichier_dest']);
1050 1050
 			$valeurs['date'] = @filemtime($valeurs['fichier_dest']); // pour la retrouver apres disparition
1051
-			ecrire_fichier($valeurs['fichier_dest'] . '.src', serialize($valeurs), true);
1051
+			ecrire_fichier($valeurs['fichier_dest'].'.src', serialize($valeurs), true);
1052 1052
 		}
1053 1053
 	}
1054 1054
 
@@ -1263,7 +1263,7 @@  discard block
 block discarded – undo
1263 1263
 
1264 1264
 	// attributs deprecies. Transformer en CSS
1265 1265
 	if ($espace = extraire_attribut($tag, 'hspace')) {
1266
-		$style = "margin:${espace}px;" . $style;
1266
+		$style = "margin:${espace}px;".$style;
1267 1267
 		$tag = inserer_attribut($tag, 'hspace', '');
1268 1268
 	}
1269 1269
 
@@ -1390,7 +1390,7 @@  discard block
 block discarded – undo
1390 1390
 	$image = $valeurs['fichier'];
1391 1391
 	$format = $valeurs['format_source'];
1392 1392
 	$destdir = dirname($valeurs['fichier_dest']);
1393
-	$destfile = basename($valeurs['fichier_dest'], '.' . $valeurs['format_dest']);
1393
+	$destfile = basename($valeurs['fichier_dest'], '.'.$valeurs['format_dest']);
1394 1394
 
1395 1395
 	$format_sortie = $valeurs['format_dest'];
1396 1396
 
@@ -1422,14 +1422,14 @@  discard block
 block discarded – undo
1422 1422
 
1423 1423
 	// Si l'image est de la taille demandee (ou plus petite), simplement la retourner
1424 1424
 	if ($srcWidth and $srcWidth <= $maxWidth and $srcHeight <= $maxHeight) {
1425
-		$vignette = $destination . '.' . $format;
1425
+		$vignette = $destination.'.'.$format;
1426 1426
 		@copy($image, $vignette);
1427 1427
 	}
1428 1428
 
1429 1429
 	elseif ($valeurs['format_source'] === 'svg') {
1430 1430
 		if ($svg = svg_redimensionner($valeurs['fichier'], $destWidth, $destHeight)) {
1431 1431
 			$format_sortie = 'svg';
1432
-			$vignette = $destination . '.' . $format_sortie;
1432
+			$vignette = $destination.'.'.$format_sortie;
1433 1433
 			$valeurs['fichier_dest'] = $vignette;
1434 1434
 			_image_gd_output($svg, $valeurs);
1435 1435
 		}
@@ -1441,9 +1441,9 @@  discard block
 block discarded – undo
1441 1441
 			define('_CONVERT_COMMAND', 'convert');
1442 1442
 		} // Securite : mes_options.php peut preciser le chemin absolu
1443 1443
 		if (!defined('_RESIZE_COMMAND')) {
1444
-			define('_RESIZE_COMMAND', _CONVERT_COMMAND . ' -quality ' . _IMG_CONVERT_QUALITE . ' -resize %xx%y! %src %dest');
1444
+			define('_RESIZE_COMMAND', _CONVERT_COMMAND.' -quality '._IMG_CONVERT_QUALITE.' -resize %xx%y! %src %dest');
1445 1445
 		}
1446
-		$vignette = $destination . '.' . $format_sortie;
1446
+		$vignette = $destination.'.'.$format_sortie;
1447 1447
 		$commande = str_replace(
1448 1448
 			['%x', '%y', '%src', '%dest'],
1449 1449
 			[
@@ -1459,13 +1459,13 @@  discard block
 block discarded – undo
1459 1459
 		if (!@file_exists($vignette)) {
1460 1460
 			spip_log("echec convert sur $vignette");
1461 1461
 
1462
-			return;  // echec commande
1462
+			return; // echec commande
1463 1463
 		}
1464 1464
 	}
1465 1465
 
1466 1466
 	// php5 imagemagick
1467 1467
 	elseif ($process == 'imagick') {
1468
-		$vignette = "$destination." . $format_sortie;
1468
+		$vignette = "$destination.".$format_sortie;
1469 1469
 
1470 1470
 		if (!class_exists(\Imagick::class)) {
1471 1471
 			spip_log('Classe Imagick absente !', _LOG_ERREUR);
@@ -1479,7 +1479,7 @@  discard block
 block discarded – undo
1479 1479
 			$destHeight,
1480 1480
 			Imagick::FILTER_LANCZOS,
1481 1481
 			1
1482
-		);//, IMAGICK_FILTER_LANCZOS, _IMG_IMAGICK_QUALITE / 100);
1482
+		); //, IMAGICK_FILTER_LANCZOS, _IMG_IMAGICK_QUALITE / 100);
1483 1483
 		$imagick->writeImage($vignette);
1484 1484
 
1485 1485
 		if (!@file_exists($vignette)) {
@@ -1497,11 +1497,11 @@  discard block
 block discarded – undo
1497 1497
 		if (_PNMSCALE_COMMAND == '') {
1498 1498
 			return;
1499 1499
 		}
1500
-		$vignette = $destination . '.' . $format_sortie;
1500
+		$vignette = $destination.'.'.$format_sortie;
1501 1501
 		$pnmtojpeg_command = str_replace('pnmscale', 'pnmtojpeg', _PNMSCALE_COMMAND);
1502 1502
 		if ($format == 'jpg') {
1503 1503
 			$jpegtopnm_command = str_replace('pnmscale', 'jpegtopnm', _PNMSCALE_COMMAND);
1504
-			exec("$jpegtopnm_command $image | " . _PNMSCALE_COMMAND . " -width $destWidth | $pnmtojpeg_command > $vignette");
1504
+			exec("$jpegtopnm_command $image | "._PNMSCALE_COMMAND." -width $destWidth | $pnmtojpeg_command > $vignette");
1505 1505
 			if (!($s = @filesize($vignette))) {
1506 1506
 				spip_unlink($vignette);
1507 1507
 			}
@@ -1513,7 +1513,7 @@  discard block
 block discarded – undo
1513 1513
 		} else {
1514 1514
 			if ($format == 'gif') {
1515 1515
 				$giftopnm_command = str_replace('pnmscale', 'giftopnm', _PNMSCALE_COMMAND);
1516
-				exec("$giftopnm_command $image | " . _PNMSCALE_COMMAND . " -width $destWidth | $pnmtojpeg_command > $vignette");
1516
+				exec("$giftopnm_command $image | "._PNMSCALE_COMMAND." -width $destWidth | $pnmtojpeg_command > $vignette");
1517 1517
 				if (!($s = @filesize($vignette))) {
1518 1518
 					spip_unlink($vignette);
1519 1519
 				}
@@ -1525,7 +1525,7 @@  discard block
 block discarded – undo
1525 1525
 			} else {
1526 1526
 				if ($format == 'png') {
1527 1527
 					$pngtopnm_command = str_replace('pnmscale', 'pngtopnm', _PNMSCALE_COMMAND);
1528
-					exec("$pngtopnm_command $image | " . _PNMSCALE_COMMAND . " -width $destWidth | $pnmtojpeg_command > $vignette");
1528
+					exec("$pngtopnm_command $image | "._PNMSCALE_COMMAND." -width $destWidth | $pnmtojpeg_command > $vignette");
1529 1529
 					if (!($s = @filesize($vignette))) {
1530 1530
 						spip_unlink($vignette);
1531 1531
 					}
@@ -1547,7 +1547,7 @@  discard block
 block discarded – undo
1547 1547
 			return;
1548 1548
 		}
1549 1549
 		if (_IMG_GD_MAX_PIXELS && $srcWidth * $srcHeight > _IMG_GD_MAX_PIXELS) {
1550
-			spip_log('vignette gd1/gd2 impossible : ' . $srcWidth * $srcHeight . 'pixels');
1550
+			spip_log('vignette gd1/gd2 impossible : '.$srcWidth * $srcHeight.'pixels');
1551 1551
 
1552 1552
 			return;
1553 1553
 		}
@@ -1859,7 +1859,7 @@  discard block
 block discarded – undo
1859 1859
 		// de l'image, de facon a tromper le cache du navigateur
1860 1860
 		// quand on fait supprimer/reuploader un logo
1861 1861
 		// (pas de filemtime si SAFE MODE)
1862
-		$date = test_espace_prive() ? ('?' . $date) : '';
1862
+		$date = test_espace_prive() ? ('?'.$date) : '';
1863 1863
 
1864 1864
 		return _image_ecrire_tag($image, ['src' => "$logo$date", 'width' => $destWidth, 'height' => $destHeight]);
1865 1865
 	}
@@ -1906,7 +1906,7 @@  discard block
 block discarded – undo
1906 1906
 	public static function LittleEndian2String($number, $minbytes = 1) {
1907 1907
 		$intstring = '';
1908 1908
 		while ($number > 0) {
1909
-			$intstring = $intstring . chr($number & 255);
1909
+			$intstring = $intstring.chr($number & 255);
1910 1910
 			$number >>= 8;
1911 1911
 		}
1912 1912
 
@@ -1938,9 +1938,9 @@  discard block
 block discarded – undo
1938 1938
 					$b = $argb['blue'];
1939 1939
 
1940 1940
 					if ($bpp[$key] == 32) {
1941
-						$icXOR[$key] .= chr($b) . chr($g) . chr($r) . chr($a);
1941
+						$icXOR[$key] .= chr($b).chr($g).chr($r).chr($a);
1942 1942
 					} elseif ($bpp[$key] == 24) {
1943
-						$icXOR[$key] .= chr($b) . chr($g) . chr($r);
1943
+						$icXOR[$key] .= chr($b).chr($g).chr($r);
1944 1944
 					}
1945 1945
 
1946 1946
 					if ($a < 128) {
@@ -1967,48 +1967,48 @@  discard block
 block discarded – undo
1967 1967
 
1968 1968
 			// BITMAPINFOHEADER - 40 bytes
1969 1969
 			$BitmapInfoHeader[$key] = '';
1970
-			$BitmapInfoHeader[$key] .= "\x28\x00\x00\x00";                // DWORD  biSize;
1971
-			$BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($ImageWidths[$key], 4);    // LONG   biWidth;
1970
+			$BitmapInfoHeader[$key] .= "\x28\x00\x00\x00"; // DWORD  biSize;
1971
+			$BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($ImageWidths[$key], 4); // LONG   biWidth;
1972 1972
 			// The biHeight member specifies the combined
1973 1973
 			// height of the XOR and AND masks.
1974 1974
 			$BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($ImageHeights[$key] * 2, 4); // LONG   biHeight;
1975
-			$BitmapInfoHeader[$key] .= "\x01\x00";                    // WORD   biPlanes;
1976
-			$BitmapInfoHeader[$key] .= chr($bpp[$key]) . "\x00";              // wBitCount;
1977
-			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // DWORD  biCompression;
1978
-			$BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($biSizeImage, 4);      // DWORD  biSizeImage;
1979
-			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // LONG   biXPelsPerMeter;
1980
-			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // LONG   biYPelsPerMeter;
1981
-			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // DWORD  biClrUsed;
1982
-			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // DWORD  biClrImportant;
1975
+			$BitmapInfoHeader[$key] .= "\x01\x00"; // WORD   biPlanes;
1976
+			$BitmapInfoHeader[$key] .= chr($bpp[$key])."\x00"; // wBitCount;
1977
+			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00"; // DWORD  biCompression;
1978
+			$BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($biSizeImage, 4); // DWORD  biSizeImage;
1979
+			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00"; // LONG   biXPelsPerMeter;
1980
+			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00"; // LONG   biYPelsPerMeter;
1981
+			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00"; // DWORD  biClrUsed;
1982
+			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00"; // DWORD  biClrImportant;
1983 1983
 		}
1984 1984
 
1985 1985
 
1986
-		$icondata = "\x00\x00";                    // idReserved;   // Reserved (must be 0)
1987
-		$icondata .= "\x01\x00";                    // idType;	   // Resource Type (1 for icons)
1988
-		$icondata .= phpthumb_functions::LittleEndian2String(count($gd_image_array), 2);  // idCount;	  // How many images?
1986
+		$icondata = "\x00\x00"; // idReserved;   // Reserved (must be 0)
1987
+		$icondata .= "\x01\x00"; // idType;	   // Resource Type (1 for icons)
1988
+		$icondata .= phpthumb_functions::LittleEndian2String(count($gd_image_array), 2); // idCount;	  // How many images?
1989 1989
 
1990 1990
 		$dwImageOffset = 6 + (count($gd_image_array) * 16);
1991 1991
 		foreach ($gd_image_array as $key => $gd_image) {
1992 1992
 			// ICONDIRENTRY   idEntries[1]; // An entry for each image (idCount of 'em)
1993 1993
 
1994
-			$icondata .= chr($ImageWidths[$key]);           // bWidth;		  // Width, in pixels, of the image
1995
-			$icondata .= chr($ImageHeights[$key]);          // bHeight;		 // Height, in pixels, of the image
1996
-			$icondata .= chr($totalcolors[$key]);           // bColorCount;	 // Number of colors in image (0 if >=8bpp)
1997
-			$icondata .= "\x00";                    // bReserved;	   // Reserved ( must be 0)
1994
+			$icondata .= chr($ImageWidths[$key]); // bWidth;		  // Width, in pixels, of the image
1995
+			$icondata .= chr($ImageHeights[$key]); // bHeight;		 // Height, in pixels, of the image
1996
+			$icondata .= chr($totalcolors[$key]); // bColorCount;	 // Number of colors in image (0 if >=8bpp)
1997
+			$icondata .= "\x00"; // bReserved;	   // Reserved ( must be 0)
1998 1998
 
1999
-			$icondata .= "\x01\x00";                  // wPlanes;		 // Color Planes
2000
-			$icondata .= chr($bpp[$key]) . "\x00";            // wBitCount;	   // Bits per pixel
1999
+			$icondata .= "\x01\x00"; // wPlanes;		 // Color Planes
2000
+			$icondata .= chr($bpp[$key])."\x00"; // wBitCount;	   // Bits per pixel
2001 2001
 
2002 2002
 			$dwBytesInRes = 40 + strlen($icXOR[$key]) + strlen($icAND[$key]);
2003 2003
 			$icondata .= phpthumb_functions::LittleEndian2String(
2004 2004
 				$dwBytesInRes,
2005 2005
 				4
2006
-			);     // dwBytesInRes;	// How many bytes in this resource?
2006
+			); // dwBytesInRes;	// How many bytes in this resource?
2007 2007
 
2008 2008
 			$icondata .= phpthumb_functions::LittleEndian2String(
2009 2009
 				$dwImageOffset,
2010 2010
 				4
2011
-			);    // dwImageOffset;   // Where in the file is this image?
2011
+			); // dwImageOffset;   // Where in the file is this image?
2012 2012
 			$dwImageOffset += strlen($BitmapInfoHeader[$key]);
2013 2013
 			$dwImageOffset += strlen($icXOR[$key]);
2014 2014
 			$dwImageOffset += strlen($icAND[$key]);
Please login to merge, or discard this patch.
ecrire/inc/presentation_mini.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 		$rejouer = (_SESSION_REJOUER === true) ? rejouer_session() : _SESSION_REJOUER;
189 189
 	}
190 190
 
191
-	return $rejouer . (defined('_TESTER_NOSCRIPT') ? _TESTER_NOSCRIPT : '');
191
+	return $rejouer.(defined('_TESTER_NOSCRIPT') ? _TESTER_NOSCRIPT : '');
192 192
 }
193 193
 
194 194
 /**
@@ -234,9 +234,9 @@  discard block
 block discarded – undo
234 234
 	//
235 235
 	if ($vcs = version_vcs_courante(_DIR_RACINE, true)) {
236 236
 		if ($vcs['vcs'] === 'GIT') {
237
-			$url = 'https://git.spip.net/spip/spip/commit/' . $vcs['commit'];
237
+			$url = 'https://git.spip.net/spip/spip/commit/'.$vcs['commit'];
238 238
 		} elseif ($vcs['vcs'] === 'SVN') {
239
-			$url = 'https://core.spip.net/projects/spip/repository/revisions/' . $vcs['commit'];
239
+			$url = 'https://core.spip.net/projects/spip/repository/revisions/'.$vcs['commit'];
240 240
 		} else {
241 241
 			$url = '';
242 242
 		}
@@ -246,14 +246,14 @@  discard block
 block discarded – undo
246 246
 			$commit = "<a href=\"$url\" target=\"_blank\" rel=\"noopener noreferrer\">$commit</a>";
247 247
 		}
248 248
 		if ($vcs['branch']) {
249
-			$commit = $vcs['branch'] . ': ' . $commit;
249
+			$commit = $vcs['branch'].': '.$commit;
250 250
 		}
251 251
 		$version .= " {$vcs['vcs']} [$commit]";
252 252
 	}
253 253
 
254 254
 	// et la version de l'ecran de securite
255 255
 	$secu = defined('_ECRAN_SECURITE')
256
-		? '<br />' . _T('ecran_securite', ['version' => _ECRAN_SECURITE])
256
+		? '<br />'._T('ecran_securite', ['version' => _ECRAN_SECURITE])
257 257
 		: '';
258 258
 
259 259
 	return _T(
@@ -261,10 +261,10 @@  discard block
 block discarded – undo
261 261
 		[
262 262
 			'spip' => "<b>SPIP $version</b> ",
263 263
 			'lien_gpl' =>
264
-				"<a href='" . generer_url_ecrire(
264
+				"<a href='".generer_url_ecrire(
265 265
 					'aide',
266
-					'aide=licence&var_lang=' . $GLOBALS['spip_lang']
267
-				) . "' class=\"aide popin\">" . _T('info_copyright_gpl') . '</a>'
266
+					'aide=licence&var_lang='.$GLOBALS['spip_lang']
267
+				)."' class=\"aide popin\">"._T('info_copyright_gpl').'</a>'
268 268
 		]
269 269
 	)
270 270
 	. $secu;
@@ -291,8 +291,8 @@  discard block
 block discarded – undo
291 291
 		$onfocus = '';
292 292
 	}
293 293
 
294
-	$form = '<input type="text" size="10" value="' . $recherche_aff . '" name="recherche" class="recherche" accesskey="r"' . $onfocus . ' />';
295
-	$form .= "<input type='image' src='" . chemin_image('rechercher-20.png') . "' name='submit' class='submit' alt='" . _T('info_rechercher') . "' />";
294
+	$form = '<input type="text" size="10" value="'.$recherche_aff.'" name="recherche" class="recherche" accesskey="r"'.$onfocus.' />';
295
+	$form .= "<input type='image' src='".chemin_image('rechercher-20.png')."' name='submit' class='submit' alt='"._T('info_rechercher')."' />";
296 296
 
297
-	return "<div class='spip_recherche'>" . generer_form_ecrire($page, $form . $complement, " method='get'") . '</div>';
297
+	return "<div class='spip_recherche'>".generer_form_ecrire($page, $form.$complement, " method='get'").'</div>';
298 298
 }
Please login to merge, or discard this patch.
Indentation   +139 added lines, -139 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @package SPIP\Core\Affichage
17 17
  **/
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 /**
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  * @return string Code HTML
26 26
  */
27 27
 function debut_grand_cadre() {
28
- return "\n<div class = 'table_page'>\n";
28
+    return "\n<div class = 'table_page'>\n";
29 29
 }
30 30
 
31 31
 /**
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
  * @return string Code HTML
35 35
  */
36 36
 function fin_grand_cadre() {
37
- return "\n</div>";
37
+    return "\n</div>";
38 38
 }
39 39
 
40 40
 // Debut de la colonne de gauche
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
  * @return string Code HTML
50 50
  */
51 51
 function debut_gauche() {
52
-	return "<div id = 'conteneur' class = ''>\n<div id = 'navigation' class = 'lat' role = 'contentinfo'>\n";
52
+    return "<div id = 'conteneur' class = ''>\n<div id = 'navigation' class = 'lat' role = 'contentinfo'>\n";
53 53
 }
54 54
 
55 55
 /**
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
  * @return string Code HTML
59 59
  */
60 60
 function fin_gauche() {
61
- return "</div></div><br class = 'nettoyeur' />";
61
+    return "</div></div><br class = 'nettoyeur' />";
62 62
 }
63 63
 
64 64
 /**
@@ -67,13 +67,13 @@  discard block
 block discarded – undo
67 67
  * @return string Code HTML
68 68
  */
69 69
 function creer_colonne_droite() {
70
-	static $deja_colonne_droite;
71
-	if ($deja_colonne_droite) {
72
-		return '';
73
-	}
74
-	$deja_colonne_droite = true;
70
+    static $deja_colonne_droite;
71
+    if ($deja_colonne_droite) {
72
+        return '';
73
+    }
74
+    $deja_colonne_droite = true;
75 75
 
76
-	return "\n</div><div id='extra' class='lat' role='complementary'>";
76
+    return "\n</div><div id='extra' class='lat' role='complementary'>";
77 77
 }
78 78
 
79 79
 /**
@@ -82,10 +82,10 @@  discard block
 block discarded – undo
82 82
  * @return string Code HTML
83 83
  */
84 84
 function debut_droite() {
85
-	return liste_objets_bloques(_request('exec'))
86
-	. creer_colonne_droite()
87
-	. '</div>'
88
-	. "\n<div id='contenu'>";
85
+    return liste_objets_bloques(_request('exec'))
86
+    . creer_colonne_droite()
87
+    . '</div>'
88
+    . "\n<div id='contenu'>";
89 89
 }
90 90
 
91 91
 /**
@@ -107,31 +107,31 @@  discard block
 block discarded – undo
107 107
  *     Code HTML
108 108
  **/
109 109
 function liste_objets_bloques($exec, $contexte = [], $auteur = null) {
110
-	$res = '';
111
-	if ($GLOBALS['meta']['articles_modif'] != 'non') {
112
-		include_spip('inc/drapeau_edition');
113
-		if (is_null($auteur)) {
114
-			$auteur = $GLOBALS['visiteur_session'];
115
-		}
116
-		if (
117
-			$en_cours = trouver_objet_exec($exec)
118
-			and $en_cours['edition']
119
-			and $type = $en_cours['type']
120
-			and ((isset($contexte[$en_cours['id_table_objet']]) and $id = $contexte[$en_cours['id_table_objet']])
121
-				or $id = _request($en_cours['id_table_objet']))
122
-		) {
123
-			// marquer le fait que l'objet est ouvert en edition par toto
124
-			// a telle date ; une alerte sera donnee aux autres redacteurs
125
-			signale_edition($id, $auteur, $type);
126
-		}
127
-
128
-		$objets_ouverts = liste_drapeau_edition($auteur['id_auteur']);
129
-		if (count($objets_ouverts)) {
130
-			$res .= recuperer_fond('prive/objets/liste/objets-en-edition', [], ['ajax' => true]);
131
-		}
132
-	}
133
-
134
-	return $res;
110
+    $res = '';
111
+    if ($GLOBALS['meta']['articles_modif'] != 'non') {
112
+        include_spip('inc/drapeau_edition');
113
+        if (is_null($auteur)) {
114
+            $auteur = $GLOBALS['visiteur_session'];
115
+        }
116
+        if (
117
+            $en_cours = trouver_objet_exec($exec)
118
+            and $en_cours['edition']
119
+            and $type = $en_cours['type']
120
+            and ((isset($contexte[$en_cours['id_table_objet']]) and $id = $contexte[$en_cours['id_table_objet']])
121
+                or $id = _request($en_cours['id_table_objet']))
122
+        ) {
123
+            // marquer le fait que l'objet est ouvert en edition par toto
124
+            // a telle date ; une alerte sera donnee aux autres redacteurs
125
+            signale_edition($id, $auteur, $type);
126
+        }
127
+
128
+        $objets_ouverts = liste_drapeau_edition($auteur['id_auteur']);
129
+        if (count($objets_ouverts)) {
130
+            $res .= recuperer_fond('prive/objets/liste/objets-en-edition', [], ['ajax' => true]);
131
+        }
132
+    }
133
+
134
+    return $res;
135 135
 }
136 136
 
137 137
 
@@ -145,20 +145,20 @@  discard block
 block discarded – undo
145 145
  * @return string Code HTML
146 146
  **/
147 147
 function fin_page() {
148
-	include_spip('inc/pipelines');
149
-	// avec &var_profile=1 on a le tableau de mesures SQL
150
-	$debug = ((_request('exec') !== 'valider_xml')
151
-		and ((_request('var_mode') == 'debug')
152
-			or (isset($GLOBALS['tableau_des_temps']) and $GLOBALS['tableau_des_temps'])
153
-			and isset($_COOKIE['spip_admin'])));
154
-	$t = '</div><div id="pied"><div class="largeur">'
155
-		. recuperer_fond('prive/squelettes/inclure/pied')
156
-		. '</div>'
157
-		. '</div></div>' // cf. div#page et div.largeur ouvertes dans conmmencer_page()
158
-		. ($debug ? erreur_squelette() : '')
159
-		. "</body></html>\n";
160
-
161
-	return f_queue($t);
148
+    include_spip('inc/pipelines');
149
+    // avec &var_profile=1 on a le tableau de mesures SQL
150
+    $debug = ((_request('exec') !== 'valider_xml')
151
+        and ((_request('var_mode') == 'debug')
152
+            or (isset($GLOBALS['tableau_des_temps']) and $GLOBALS['tableau_des_temps'])
153
+            and isset($_COOKIE['spip_admin'])));
154
+    $t = '</div><div id="pied"><div class="largeur">'
155
+        . recuperer_fond('prive/squelettes/inclure/pied')
156
+        . '</div>'
157
+        . '</div></div>' // cf. div#page et div.largeur ouvertes dans conmmencer_page()
158
+        . ($debug ? erreur_squelette() : '')
159
+        . "</body></html>\n";
160
+
161
+    return f_queue($t);
162 162
 }
163 163
 
164 164
 /**
@@ -173,22 +173,22 @@  discard block
 block discarded – undo
173 173
  * @return string Code HTML
174 174
  **/
175 175
 function html_tests_js() {
176
-	if (_SPIP_AJAX and !defined('_TESTER_NOSCRIPT')) {
177
-		// pour le pied de page (deja defini si on est validation XML)
178
-		define(
179
-			'_TESTER_NOSCRIPT',
180
-			"<noscript>\n<div style='display:none;'><img src='"
181
-			. generer_url_ecrire('test_ajax', 'js=-1')
182
-			. "' width='1' height='1' alt='' /></div></noscript>\n"
183
-		);
184
-	}
185
-
186
-	$rejouer = '';
187
-	if (defined('_SESSION_REJOUER')) {
188
-		$rejouer = (_SESSION_REJOUER === true) ? rejouer_session() : _SESSION_REJOUER;
189
-	}
190
-
191
-	return $rejouer . (defined('_TESTER_NOSCRIPT') ? _TESTER_NOSCRIPT : '');
176
+    if (_SPIP_AJAX and !defined('_TESTER_NOSCRIPT')) {
177
+        // pour le pied de page (deja defini si on est validation XML)
178
+        define(
179
+            '_TESTER_NOSCRIPT',
180
+            "<noscript>\n<div style='display:none;'><img src='"
181
+            . generer_url_ecrire('test_ajax', 'js=-1')
182
+            . "' width='1' height='1' alt='' /></div></noscript>\n"
183
+        );
184
+    }
185
+
186
+    $rejouer = '';
187
+    if (defined('_SESSION_REJOUER')) {
188
+        $rejouer = (_SESSION_REJOUER === true) ? rejouer_session() : _SESSION_REJOUER;
189
+    }
190
+
191
+    return $rejouer . (defined('_TESTER_NOSCRIPT') ? _TESTER_NOSCRIPT : '');
192 192
 }
193 193
 
194 194
 /**
@@ -198,25 +198,25 @@  discard block
 block discarded – undo
198 198
  **/
199 199
 function info_maj_spip() {
200 200
 
201
-	$maj = $GLOBALS['meta']['info_maj_spip'] ?? null;
202
-	if (!$maj) {
203
-		return '';
204
-	}
201
+    $maj = $GLOBALS['meta']['info_maj_spip'] ?? null;
202
+    if (!$maj) {
203
+        return '';
204
+    }
205 205
 
206
-	$maj = explode('|', $maj);
207
-	// c'est une ancienne notif, on a fait la maj depuis !
208
-	if ($GLOBALS['spip_version_branche'] !== reset($maj)) {
209
-		return '';
210
-	}
206
+    $maj = explode('|', $maj);
207
+    // c'est une ancienne notif, on a fait la maj depuis !
208
+    if ($GLOBALS['spip_version_branche'] !== reset($maj)) {
209
+        return '';
210
+    }
211 211
 
212
-	if (!autoriser('webmestre')) {
213
-		return '';
214
-	}
212
+    if (!autoriser('webmestre')) {
213
+        return '';
214
+    }
215 215
 
216
-	array_shift($maj);
217
-	$maj = implode('|', $maj);
216
+    array_shift($maj);
217
+    $maj = implode('|', $maj);
218 218
 
219
-	return "$maj<br />";
219
+    return "$maj<br />";
220 220
 }
221 221
 
222 222
 /**
@@ -227,47 +227,47 @@  discard block
 block discarded – undo
227 227
  **/
228 228
 function info_copyright() {
229 229
 
230
-	$version = $GLOBALS['spip_version_affichee'];
231
-
232
-	//
233
-	// Mention, le cas echeant, de la revision SVN courante
234
-	//
235
-	if ($vcs = version_vcs_courante(_DIR_RACINE, true)) {
236
-		if ($vcs['vcs'] === 'GIT') {
237
-			$url = 'https://git.spip.net/spip/spip/commit/' . $vcs['commit'];
238
-		} elseif ($vcs['vcs'] === 'SVN') {
239
-			$url = 'https://core.spip.net/projects/spip/repository/revisions/' . $vcs['commit'];
240
-		} else {
241
-			$url = '';
242
-		}
243
-		// affichage "GIT [master: abcdef]"
244
-		$commit = $vcs['commit_short'] ?? $vcs['commit'];
245
-		if ($url) {
246
-			$commit = "<a href=\"$url\" target=\"_blank\" rel=\"noopener noreferrer\">$commit</a>";
247
-		}
248
-		if ($vcs['branch']) {
249
-			$commit = $vcs['branch'] . ': ' . $commit;
250
-		}
251
-		$version .= " {$vcs['vcs']} [$commit]";
252
-	}
253
-
254
-	// et la version de l'ecran de securite
255
-	$secu = defined('_ECRAN_SECURITE')
256
-		? '<br />' . _T('ecran_securite', ['version' => _ECRAN_SECURITE])
257
-		: '';
258
-
259
-	return _T(
260
-		'info_copyright',
261
-		[
262
-			'spip' => "<b>SPIP $version</b> ",
263
-			'lien_gpl' =>
264
-				"<a href='" . generer_url_ecrire(
265
-					'aide',
266
-					'aide=licence&var_lang=' . $GLOBALS['spip_lang']
267
-				) . "' class=\"aide popin\">" . _T('info_copyright_gpl') . '</a>'
268
-		]
269
-	)
270
-	. $secu;
230
+    $version = $GLOBALS['spip_version_affichee'];
231
+
232
+    //
233
+    // Mention, le cas echeant, de la revision SVN courante
234
+    //
235
+    if ($vcs = version_vcs_courante(_DIR_RACINE, true)) {
236
+        if ($vcs['vcs'] === 'GIT') {
237
+            $url = 'https://git.spip.net/spip/spip/commit/' . $vcs['commit'];
238
+        } elseif ($vcs['vcs'] === 'SVN') {
239
+            $url = 'https://core.spip.net/projects/spip/repository/revisions/' . $vcs['commit'];
240
+        } else {
241
+            $url = '';
242
+        }
243
+        // affichage "GIT [master: abcdef]"
244
+        $commit = $vcs['commit_short'] ?? $vcs['commit'];
245
+        if ($url) {
246
+            $commit = "<a href=\"$url\" target=\"_blank\" rel=\"noopener noreferrer\">$commit</a>";
247
+        }
248
+        if ($vcs['branch']) {
249
+            $commit = $vcs['branch'] . ': ' . $commit;
250
+        }
251
+        $version .= " {$vcs['vcs']} [$commit]";
252
+    }
253
+
254
+    // et la version de l'ecran de securite
255
+    $secu = defined('_ECRAN_SECURITE')
256
+        ? '<br />' . _T('ecran_securite', ['version' => _ECRAN_SECURITE])
257
+        : '';
258
+
259
+    return _T(
260
+        'info_copyright',
261
+        [
262
+            'spip' => "<b>SPIP $version</b> ",
263
+            'lien_gpl' =>
264
+                "<a href='" . generer_url_ecrire(
265
+                    'aide',
266
+                    'aide=licence&var_lang=' . $GLOBALS['spip_lang']
267
+                ) . "' class=\"aide popin\">" . _T('info_copyright_gpl') . '</a>'
268
+        ]
269
+    )
270
+    . $secu;
271 271
 }
272 272
 
273 273
 /**
@@ -282,17 +282,17 @@  discard block
 block discarded – undo
282 282
  * @return string             Code HTML
283 283
  **/
284 284
 function formulaire_recherche($page, $complement = '') {
285
-	$recherche = _request('recherche');
286
-	$recherche_aff = entites_html($recherche);
287
-	if (!strlen($recherche)) {
288
-		$recherche_aff = _T('info_rechercher');
289
-		$onfocus = " onfocus=\"this.value='';\"";
290
-	} else {
291
-		$onfocus = '';
292
-	}
293
-
294
-	$form = '<input type="text" size="10" value="' . $recherche_aff . '" name="recherche" class="recherche" accesskey="r"' . $onfocus . ' />';
295
-	$form .= "<input type='image' src='" . chemin_image('rechercher-20.png') . "' name='submit' class='submit' alt='" . _T('info_rechercher') . "' />";
296
-
297
-	return "<div class='spip_recherche'>" . generer_form_ecrire($page, $form . $complement, " method='get'") . '</div>';
285
+    $recherche = _request('recherche');
286
+    $recherche_aff = entites_html($recherche);
287
+    if (!strlen($recherche)) {
288
+        $recherche_aff = _T('info_rechercher');
289
+        $onfocus = " onfocus=\"this.value='';\"";
290
+    } else {
291
+        $onfocus = '';
292
+    }
293
+
294
+    $form = '<input type="text" size="10" value="' . $recherche_aff . '" name="recherche" class="recherche" accesskey="r"' . $onfocus . ' />';
295
+    $form .= "<input type='image' src='" . chemin_image('rechercher-20.png') . "' name='submit' class='submit' alt='" . _T('info_rechercher') . "' />";
296
+
297
+    return "<div class='spip_recherche'>" . generer_form_ecrire($page, $form . $complement, " method='get'") . '</div>';
298 298
 }
Please login to merge, or discard this patch.
ecrire/inc/minipres.php 3 patches
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -193,11 +193,9 @@
 block discarded – undo
193 193
 
194 194
 		if ($statut and test_espace_prive()) {
195 195
 			$corps = bouton_action(_T('public:accueil_site'), generer_url_ecrire('accueil'));
196
-		}
197
-		elseif (!empty($_COOKIE['spip_admin'])) {
196
+		} elseif (!empty($_COOKIE['spip_admin'])) {
198 197
 			$corps = bouton_action(_T('public:lien_connecter'), generer_url_public('login'));
199
-		}
200
-		else {
198
+		} else {
201 199
 			$corps = bouton_action(_T('public:accueil_site'), $GLOBALS['meta']['adresse_site']);
202 200
 		}
203 201
 		$corps = "<div class='boutons'>$corps</div>";
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 			lire_fichier($file, $c);
75 75
 			$css .= $c;
76 76
 		}
77
-		$css = "<style type='text/css'>" . $css . '</style>';
77
+		$css = "<style type='text/css'>".$css.'</style>';
78 78
 	} else {
79 79
 		foreach ($files as $name) {
80 80
 			$file = direction_css(find_in_theme($name));
@@ -87,19 +87,19 @@  discard block
 block discarded – undo
87 87
 		define('_DOCTYPE_ECRIRE', '');
88 88
 	}
89 89
 
90
-	return _DOCTYPE_ECRIRE .
91
-	html_lang_attributes() .
92
-	"<head>\n" .
93
-	'<title>' .
94
-	textebrut($titre) .
95
-	"</title>\n" .
96
-	"<meta name='viewport' content='width=device-width' />\n" .
97
-	$css .
90
+	return _DOCTYPE_ECRIRE.
91
+	html_lang_attributes().
92
+	"<head>\n".
93
+	'<title>'.
94
+	textebrut($titre).
95
+	"</title>\n".
96
+	"<meta name='viewport' content='width=device-width' />\n".
97
+	$css.
98 98
 	'</head>
99
-<body' . $onLoad . " class='minipres'>
99
+<body' . $onLoad." class='minipres'>
100 100
 	<div id='minipres'>
101 101
 	<h1>" .
102
-	$titre .
102
+	$titre.
103 103
 	"</h1>
104 104
 	<div>\n";
105 105
 }
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 
183 183
 		$titre = ($titre == 'install')
184 184
 			? _T('avis_espace_interdit')
185
-			: $titre . '&nbsp;: ' . _T('info_acces_interdit');
185
+			: $titre.'&nbsp;: '._T('info_acces_interdit');
186 186
 
187 187
 		$statut = $GLOBALS['visiteur_session']['statut'] ?? '';
188 188
 		$nom = $GLOBALS['visiteur_session']['nom'] ?? '';
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 			$corps = bouton_action(_T('public:accueil_site'), $GLOBALS['meta']['adresse_site']);
202 202
 		}
203 203
 		$corps = "<div class='boutons'>$corps</div>";
204
-		spip_log($nom . " $titre " . $_SERVER['REQUEST_URI']);
204
+		spip_log($nom." $titre ".$_SERVER['REQUEST_URI']);
205 205
 	}
206 206
 
207 207
 	if (!_AJAX) {
@@ -219,6 +219,6 @@  discard block
 block discarded – undo
219 219
 		foreach ($_POST as $v => $c) {
220 220
 			$url = parametre_url($url, $v, $c, '&');
221 221
 		}
222
-		ajax_retour('<div>' . $titre . redirige_formulaire($url) . '</div>', false);
222
+		ajax_retour('<div>'.$titre.redirige_formulaire($url).'</div>', false);
223 223
 	}
224 224
 }
Please login to merge, or discard this patch.
Indentation   +136 added lines, -136 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @package SPIP\Core\Minipres
17 17
  **/
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 include_spip('inc/headers');
@@ -46,61 +46,61 @@  discard block
 block discarded – undo
46 46
  */
47 47
 function install_debut_html($titre = 'AUTO', $onLoad = '', $all_inline = false) {
48 48
 
49
-	utiliser_langue_visiteur();
50
-
51
-	http_no_cache();
52
-
53
-	if ($titre == 'AUTO') {
54
-		$titre = _T('info_installation_systeme_publication');
55
-	}
56
-
57
-	# le charset est en utf-8, pour recuperer le nom comme il faut
58
-	# lors de l'installation
59
-	if (!headers_sent()) {
60
-		header('Content-Type: text/html; charset=utf-8');
61
-	}
62
-
63
-	$css = '';
64
-	$files = ['reset.css', 'clear.css', 'minipres.css'];
65
-	if ($all_inline) {
66
-		// inliner les CSS (optimisation de la page minipres qui passe en un seul hit a la demande)
67
-		foreach ($files as $name) {
68
-			$file = direction_css(find_in_theme($name));
69
-			if (function_exists('minifier')) {
70
-				$file = minifier($file);
71
-			} else {
72
-				$file = url_absolue_css($file); // precaution
73
-			}
74
-			lire_fichier($file, $c);
75
-			$css .= $c;
76
-		}
77
-		$css = "<style type='text/css'>" . $css . '</style>';
78
-	} else {
79
-		foreach ($files as $name) {
80
-			$file = direction_css(find_in_theme($name));
81
-			$css .= "<link rel='stylesheet' href='$file' type='text/css' />\n";
82
-		}
83
-	}
84
-
85
-	// au cas ou minipres() est appele avant spip_initialisation_suite()
86
-	if (!defined('_DOCTYPE_ECRIRE')) {
87
-		define('_DOCTYPE_ECRIRE', '');
88
-	}
89
-
90
-	return _DOCTYPE_ECRIRE .
91
-	html_lang_attributes() .
92
-	"<head>\n" .
93
-	'<title>' .
94
-	textebrut($titre) .
95
-	"</title>\n" .
96
-	"<meta name='viewport' content='width=device-width' />\n" .
97
-	$css .
98
-	'</head>
49
+    utiliser_langue_visiteur();
50
+
51
+    http_no_cache();
52
+
53
+    if ($titre == 'AUTO') {
54
+        $titre = _T('info_installation_systeme_publication');
55
+    }
56
+
57
+    # le charset est en utf-8, pour recuperer le nom comme il faut
58
+    # lors de l'installation
59
+    if (!headers_sent()) {
60
+        header('Content-Type: text/html; charset=utf-8');
61
+    }
62
+
63
+    $css = '';
64
+    $files = ['reset.css', 'clear.css', 'minipres.css'];
65
+    if ($all_inline) {
66
+        // inliner les CSS (optimisation de la page minipres qui passe en un seul hit a la demande)
67
+        foreach ($files as $name) {
68
+            $file = direction_css(find_in_theme($name));
69
+            if (function_exists('minifier')) {
70
+                $file = minifier($file);
71
+            } else {
72
+                $file = url_absolue_css($file); // precaution
73
+            }
74
+            lire_fichier($file, $c);
75
+            $css .= $c;
76
+        }
77
+        $css = "<style type='text/css'>" . $css . '</style>';
78
+    } else {
79
+        foreach ($files as $name) {
80
+            $file = direction_css(find_in_theme($name));
81
+            $css .= "<link rel='stylesheet' href='$file' type='text/css' />\n";
82
+        }
83
+    }
84
+
85
+    // au cas ou minipres() est appele avant spip_initialisation_suite()
86
+    if (!defined('_DOCTYPE_ECRIRE')) {
87
+        define('_DOCTYPE_ECRIRE', '');
88
+    }
89
+
90
+    return _DOCTYPE_ECRIRE .
91
+    html_lang_attributes() .
92
+    "<head>\n" .
93
+    '<title>' .
94
+    textebrut($titre) .
95
+    "</title>\n" .
96
+    "<meta name='viewport' content='width=device-width' />\n" .
97
+    $css .
98
+    '</head>
99 99
 <body' . $onLoad . " class='minipres'>
100 100
 	<div id='minipres'>
101 101
 	<h1>" .
102
-	$titre .
103
-	"</h1>
102
+    $titre .
103
+    "</h1>
104 104
 	<div>\n";
105 105
 }
106 106
 
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
  * @return string Code HTML
111 111
  */
112 112
 function install_fin_html() {
113
-	return "\n\t</div>\n\t</div>\n</body>\n</html>";
113
+    return "\n\t</div>\n\t</div>\n</body>\n</html>";
114 114
 }
115 115
 
116 116
 
@@ -148,86 +148,86 @@  discard block
 block discarded – undo
148 148
  */
149 149
 function minipres($titre = '', $corps = '', $options = []) {
150 150
 
151
-	// compat signature old
152
-	// minipres($titre='', $corps="", $onload='', $all_inline = false)
153
-	$args = func_get_args();
154
-	if (isset($args[2]) and is_string($args[2])) {
155
-		$options = ['onload' => $args[2]];
156
-	}
157
-	if (isset($args[3])) {
158
-		$options['all_inline'] = $args[3];
159
-	}
160
-
161
-	$options = array_merge([
162
-		'onload' => '',
163
-		'all_inline' => false,
164
-	], $options);
165
-
166
-	if (!defined('_AJAX')) {
167
-		define('_AJAX', false);
168
-	} // par securite
169
-	if (!$titre) {
170
-		if (!isset($options['status'])) {
171
-			$options['status'] = 403;
172
-		}
173
-		if (
174
-			!$titre = _request('action')
175
-			and !$titre = _request('exec')
176
-			and !$titre = _request('page')
177
-		) {
178
-			$titre = '?';
179
-		}
180
-
181
-		$titre = spip_htmlspecialchars($titre);
182
-
183
-		$titre = ($titre == 'install')
184
-			? _T('avis_espace_interdit')
185
-			: $titre . '&nbsp;: ' . _T('info_acces_interdit');
186
-
187
-		$statut = $GLOBALS['visiteur_session']['statut'] ?? '';
188
-		$nom = $GLOBALS['visiteur_session']['nom'] ?? '';
189
-
190
-		if ($statut != '0minirezo') {
191
-			$titre = _T('info_acces_interdit');
192
-		}
193
-
194
-		if ($statut and test_espace_prive()) {
195
-			$corps = bouton_action(_T('public:accueil_site'), generer_url_ecrire('accueil'));
196
-		}
197
-		elseif (!empty($_COOKIE['spip_admin'])) {
198
-			$corps = bouton_action(_T('public:lien_connecter'), generer_url_public('login'));
199
-		}
200
-		else {
201
-			$corps = bouton_action(_T('public:accueil_site'), $GLOBALS['meta']['adresse_site']);
202
-		}
203
-		$corps = "<div class='boutons'>$corps</div>";
204
-		spip_log($nom . " $titre " . $_SERVER['REQUEST_URI']);
205
-	}
206
-
207
-	if (!_AJAX) {
208
-		if (isset($options['status'])) {
209
-			http_response_code($options['status']);
210
-		}
211
-
212
-		$html = install_debut_html($titre, $options['onload'], $options['all_inline'])
213
-				. $corps
214
-				. install_fin_html();
215
-
216
-		if ($GLOBALS['profondeur_url'] >= (_DIR_RESTREINT ? 1 : 2)
217
-		  and empty($options['all_inline'])) {
218
-			define('_SET_HTML_BASE', true);
219
-			include_spip('public/assembler');
220
-			$GLOBALS['html'] = true;
221
-			page_base_href($html);
222
-		}
223
-		return $html;
224
-	} else {
225
-		include_spip('inc/headers');
226
-		include_spip('inc/actions');
227
-		$url = self('&', true);
228
-		foreach ($_POST as $v => $c) {
229
-			$url = parametre_url($url, $v, $c, '&');
230
-		}
231
-		ajax_retour('<div>' . $titre . redirige_formulaire($url) . '</div>', false);
232
-	}
151
+    // compat signature old
152
+    // minipres($titre='', $corps="", $onload='', $all_inline = false)
153
+    $args = func_get_args();
154
+    if (isset($args[2]) and is_string($args[2])) {
155
+        $options = ['onload' => $args[2]];
156
+    }
157
+    if (isset($args[3])) {
158
+        $options['all_inline'] = $args[3];
159
+    }
160
+
161
+    $options = array_merge([
162
+        'onload' => '',
163
+        'all_inline' => false,
164
+    ], $options);
165
+
166
+    if (!defined('_AJAX')) {
167
+        define('_AJAX', false);
168
+    } // par securite
169
+    if (!$titre) {
170
+        if (!isset($options['status'])) {
171
+            $options['status'] = 403;
172
+        }
173
+        if (
174
+            !$titre = _request('action')
175
+            and !$titre = _request('exec')
176
+            and !$titre = _request('page')
177
+        ) {
178
+            $titre = '?';
179
+        }
180
+
181
+        $titre = spip_htmlspecialchars($titre);
182
+
183
+        $titre = ($titre == 'install')
184
+            ? _T('avis_espace_interdit')
185
+            : $titre . '&nbsp;: ' . _T('info_acces_interdit');
186
+
187
+        $statut = $GLOBALS['visiteur_session']['statut'] ?? '';
188
+        $nom = $GLOBALS['visiteur_session']['nom'] ?? '';
189
+
190
+        if ($statut != '0minirezo') {
191
+            $titre = _T('info_acces_interdit');
192
+        }
193
+
194
+        if ($statut and test_espace_prive()) {
195
+            $corps = bouton_action(_T('public:accueil_site'), generer_url_ecrire('accueil'));
196
+        }
197
+        elseif (!empty($_COOKIE['spip_admin'])) {
198
+            $corps = bouton_action(_T('public:lien_connecter'), generer_url_public('login'));
199
+        }
200
+        else {
201
+            $corps = bouton_action(_T('public:accueil_site'), $GLOBALS['meta']['adresse_site']);
202
+        }
203
+        $corps = "<div class='boutons'>$corps</div>";
204
+        spip_log($nom . " $titre " . $_SERVER['REQUEST_URI']);
205
+    }
206
+
207
+    if (!_AJAX) {
208
+        if (isset($options['status'])) {
209
+            http_response_code($options['status']);
210
+        }
211
+
212
+        $html = install_debut_html($titre, $options['onload'], $options['all_inline'])
213
+                . $corps
214
+                . install_fin_html();
215
+
216
+        if ($GLOBALS['profondeur_url'] >= (_DIR_RESTREINT ? 1 : 2)
217
+          and empty($options['all_inline'])) {
218
+            define('_SET_HTML_BASE', true);
219
+            include_spip('public/assembler');
220
+            $GLOBALS['html'] = true;
221
+            page_base_href($html);
222
+        }
223
+        return $html;
224
+    } else {
225
+        include_spip('inc/headers');
226
+        include_spip('inc/actions');
227
+        $url = self('&', true);
228
+        foreach ($_POST as $v => $c) {
229
+            $url = parametre_url($url, $v, $c, '&');
230
+        }
231
+        ajax_retour('<div>' . $titre . redirige_formulaire($url) . '</div>', false);
232
+    }
233 233
 }
Please login to merge, or discard this patch.