Completed
Push — master ( 822703...31691f )
by cam
01:52 queued 15s
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/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/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_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.
Spacing   +67 added lines, -67 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
 		}
@@ -321,11 +321,11 @@  discard block
 block discarded – undo
321 321
 		$img = "<img src='$source' />";
322 322
 	} elseif (
323 323
 		preg_match('@^data:image/([^;]*);base64,(.*)$@isS', $source, $regs)
324
-		and $extension = _image_trouver_extension_depuis_mime('image/' . $regs[1])
324
+		and $extension = _image_trouver_extension_depuis_mime('image/'.$regs[1])
325 325
 		and in_array($extension, _image_extensions_acceptees_en_entree())
326 326
 	) {
327 327
 		# gerer img src="data:....base64"
328
-		$local = sous_repertoire(_DIR_VAR, 'image-data') . md5($regs[2]) . '.' . _image_extension_normalisee($extension);
328
+		$local = sous_repertoire(_DIR_VAR, 'image-data').md5($regs[2]).'.'._image_extension_normalisee($extension);
329 329
 		if (!file_exists($local)) {
330 330
 			ecrire_fichier($local, base64_decode($regs[2]));
331 331
 		}
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 	// les protocoles web prennent au moins 3 lettres
343 343
 	if (tester_url_absolue($source)) {
344 344
 		include_spip('inc/distant');
345
-		$fichier = _DIR_RACINE . copie_locale($source);
345
+		$fichier = _DIR_RACINE.copie_locale($source);
346 346
 		if (!$fichier) {
347 347
 			return '';
348 348
 		}
@@ -440,9 +440,9 @@  discard block
 block discarded – undo
440 440
 			// on garde la terminaison initiale car image simplement copiee
441 441
 			// et on postfixe son nom avec un md5 du path
442 442
 			$terminaison_dest = $terminaison;
443
-			$fichier_dest .= '-' . substr(md5("$identifiant"), 0, 5);
443
+			$fichier_dest .= '-'.substr(md5("$identifiant"), 0, 5);
444 444
 		} else {
445
-			$fichier_dest .= '-' . substr(md5("$identifiant-$effet"), 0, 5);
445
+			$fichier_dest .= '-'.substr(md5("$identifiant-$effet"), 0, 5);
446 446
 		}
447 447
 		$cache = sous_repertoire(_DIR_VAR, $cache);
448 448
 		$cache = sous_repertoire($cache, $effet);
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 		$fichier_dest = substr($fichier_dest, 2);
454 454
 	}
455 455
 
456
-	$fichier_dest = $cache . $fichier_dest . '.' . $terminaison_dest;
456
+	$fichier_dest = $cache.$fichier_dest.'.'.$terminaison_dest;
457 457
 
458 458
 	$GLOBALS['images_calculees'][] = $fichier_dest;
459 459
 
@@ -491,15 +491,15 @@  discard block
 block discarded – undo
491 491
 
492 492
 	if ($creer) {
493 493
 		spip_log(
494
-			'filtre image ' . ($fonction_creation ? reset($fonction_creation) : '') . "[$effet] sur $fichier",
495
-			'images' . _LOG_DEBUG
494
+			'filtre image '.($fonction_creation ? reset($fonction_creation) : '')."[$effet] sur $fichier",
495
+			'images'._LOG_DEBUG
496 496
 		);
497 497
 	}
498 498
 
499 499
 	$term_fonction = _image_trouver_extension_pertinente($fichier);
500
-	$ret['fonction_imagecreatefrom'] = '_imagecreatefrom' . $term_fonction;
500
+	$ret['fonction_imagecreatefrom'] = '_imagecreatefrom'.$term_fonction;
501 501
 	$ret['fichier'] = $fichier;
502
-	$ret['fonction_image'] = '_image_image' . $terminaison_dest;
502
+	$ret['fonction_image'] = '_image_image'.$terminaison_dest;
503 503
 	$ret['fichier_dest'] = $fichier_dest;
504 504
 	$ret['format_source'] = _image_extension_normalisee($terminaison);
505 505
 	$ret['format_dest'] = $terminaison_dest;
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
 
649 649
 	$_terminaison = _image_trouver_extension_depuis_mime($mime);
650 650
 	if ($_terminaison and $_terminaison !== $terminaison) {
651
-		spip_log("Mauvaise extension du fichier : $path . Son type mime est : $mime", 'images.' . _LOG_INFO_IMPORTANTE);
651
+		spip_log("Mauvaise extension du fichier : $path . Son type mime est : $mime", 'images.'._LOG_INFO_IMPORTANTE);
652 652
 		$terminaison = $_terminaison;
653 653
 	}
654 654
 	return $terminaison;
@@ -805,7 +805,7 @@  discard block
 block discarded – undo
805 805
 	if (!function_exists('imagepng')) {
806 806
 		return false;
807 807
 	}
808
-	$tmp = $fichier . '.tmp';
808
+	$tmp = $fichier.'.tmp';
809 809
 	$ret = imagepng($img, $tmp);
810 810
 	if (file_exists($tmp)) {
811 811
 		$taille_test = getimagesize($tmp);
@@ -840,7 +840,7 @@  discard block
 block discarded – undo
840 840
 	if (!function_exists('imagegif')) {
841 841
 		return false;
842 842
 	}
843
-	$tmp = $fichier . '.tmp';
843
+	$tmp = $fichier.'.tmp';
844 844
 	$ret = imagegif($img, $tmp);
845 845
 	if (file_exists($tmp)) {
846 846
 		$taille_test = getimagesize($tmp);
@@ -880,7 +880,7 @@  discard block
 block discarded – undo
880 880
 	if (!function_exists('imagejpeg')) {
881 881
 		return false;
882 882
 	}
883
-	$tmp = $fichier . '.tmp';
883
+	$tmp = $fichier.'.tmp';
884 884
 
885 885
 	// Enable interlancing
886 886
 	imageinterlace($img, true);
@@ -941,7 +941,7 @@  discard block
 block discarded – undo
941 941
 	if (!function_exists('imagewebp')) {
942 942
 		return false;
943 943
 	}
944
-	$tmp = $fichier . '.tmp';
944
+	$tmp = $fichier.'.tmp';
945 945
 	$ret = imagewebp($img, $tmp, $qualite);
946 946
 	if (file_exists($tmp)) {
947 947
 		$taille_test = getimagesize($tmp);
@@ -975,7 +975,7 @@  discard block
 block discarded – undo
975 975
  */
976 976
 function _image_imagesvg($img, $fichier) {
977 977
 
978
-	$tmp = $fichier . '.tmp';
978
+	$tmp = $fichier.'.tmp';
979 979
 	if (strpos($img, '<') === false) {
980 980
 		$img = supprimer_timestamp($img);
981 981
 		if (!file_exists($img)) {
@@ -1032,14 +1032,14 @@  discard block
 block discarded – undo
1032 1032
  */
1033 1033
 function _image_gd_output($img, $valeurs, $qualite = _IMG_GD_QUALITE, $fonction = null) {
1034 1034
 	if (is_null($fonction)) {
1035
-		$fonction = '_image_image' . $valeurs['format_dest'];
1035
+		$fonction = '_image_image'.$valeurs['format_dest'];
1036 1036
 	}
1037 1037
 	$ret = false;
1038 1038
 	#un flag pour reperer les images gravees
1039 1039
 	$lock = (
1040 1040
 		!statut_effacer_images_temporaires('get') // si la fonction n'a pas ete activee, on grave tout
1041 1041
 	    or
1042
-		(@file_exists($valeurs['fichier_dest']) and !@file_exists($valeurs['fichier_dest'] . '.src'))
1042
+		(@file_exists($valeurs['fichier_dest']) and !@file_exists($valeurs['fichier_dest'].'.src'))
1043 1043
 		);
1044 1044
 	if (
1045 1045
 		function_exists($fonction)
@@ -1051,7 +1051,7 @@  discard block
 block discarded – undo
1051 1051
 			// dans tous les cas mettre a jour la taille de l'image finale
1052 1052
 			[$valeurs['hauteur_dest'], $valeurs['largeur_dest']] = taille_image($valeurs['fichier_dest']);
1053 1053
 			$valeurs['date'] = @filemtime($valeurs['fichier_dest']); // pour la retrouver apres disparition
1054
-			ecrire_fichier($valeurs['fichier_dest'] . '.src', serialize($valeurs), true);
1054
+			ecrire_fichier($valeurs['fichier_dest'].'.src', serialize($valeurs), true);
1055 1055
 		}
1056 1056
 	}
1057 1057
 
@@ -1226,7 +1226,7 @@  discard block
 block discarded – undo
1226 1226
 
1227 1227
 	// attributs deprecies. Transformer en CSS
1228 1228
 	if ($espace = extraire_attribut($tag, 'hspace')) {
1229
-		$style = "margin:${espace}px;" . $style;
1229
+		$style = "margin:${espace}px;".$style;
1230 1230
 		$tag = inserer_attribut($tag, 'hspace', '');
1231 1231
 	}
1232 1232
 
@@ -1353,7 +1353,7 @@  discard block
 block discarded – undo
1353 1353
 	$image = $valeurs['fichier'];
1354 1354
 	$format = $valeurs['format_source'];
1355 1355
 	$destdir = dirname($valeurs['fichier_dest']);
1356
-	$destfile = basename($valeurs['fichier_dest'], '.' . $valeurs['format_dest']);
1356
+	$destfile = basename($valeurs['fichier_dest'], '.'.$valeurs['format_dest']);
1357 1357
 
1358 1358
 	$format_sortie = $valeurs['format_dest'];
1359 1359
 
@@ -1385,14 +1385,14 @@  discard block
 block discarded – undo
1385 1385
 
1386 1386
 	// Si l'image est de la taille demandee (ou plus petite), simplement la retourner
1387 1387
 	if ($srcWidth and $srcWidth <= $maxWidth and $srcHeight <= $maxHeight) {
1388
-		$vignette = $destination . '.' . $format;
1388
+		$vignette = $destination.'.'.$format;
1389 1389
 		@copy($image, $vignette);
1390 1390
 	}
1391 1391
 
1392 1392
 	elseif ($valeurs['format_source'] === 'svg') {
1393 1393
 		if ($svg = svg_redimensionner($valeurs['fichier'], $destWidth, $destHeight)) {
1394 1394
 			$format_sortie = 'svg';
1395
-			$vignette = $destination . '.' . $format_sortie;
1395
+			$vignette = $destination.'.'.$format_sortie;
1396 1396
 			$valeurs['fichier_dest'] = $vignette;
1397 1397
 			_image_gd_output($svg, $valeurs);
1398 1398
 		}
@@ -1404,9 +1404,9 @@  discard block
 block discarded – undo
1404 1404
 			define('_CONVERT_COMMAND', 'convert');
1405 1405
 		} // Securite : mes_options.php peut preciser le chemin absolu
1406 1406
 		if (!defined('_RESIZE_COMMAND')) {
1407
-			define('_RESIZE_COMMAND', _CONVERT_COMMAND . ' -quality ' . _IMG_CONVERT_QUALITE . ' -resize %xx%y! %src %dest');
1407
+			define('_RESIZE_COMMAND', _CONVERT_COMMAND.' -quality '._IMG_CONVERT_QUALITE.' -resize %xx%y! %src %dest');
1408 1408
 		}
1409
-		$vignette = $destination . '.' . $format_sortie;
1409
+		$vignette = $destination.'.'.$format_sortie;
1410 1410
 		$commande = str_replace(
1411 1411
 			['%x', '%y', '%src', '%dest'],
1412 1412
 			[
@@ -1422,7 +1422,7 @@  discard block
 block discarded – undo
1422 1422
 		if (!@file_exists($vignette)) {
1423 1423
 			spip_log("echec convert sur $vignette");
1424 1424
 
1425
-			return;  // echec commande
1425
+			return; // echec commande
1426 1426
 		}
1427 1427
 	}
1428 1428
 
@@ -1440,7 +1440,7 @@  discard block
 block discarded – undo
1440 1440
 		if (!$output) {
1441 1441
 			return;
1442 1442
 		}
1443
-		$vignette = $output . DIRECTORY_SEPARATOR . basename($destination) . '.' . $format_sortie;
1443
+		$vignette = $output.DIRECTORY_SEPARATOR.basename($destination).'.'.$format_sortie;
1444 1444
 
1445 1445
 		$imagick = new Imagick();
1446 1446
 		$imagick->readImage(realpath($image));
@@ -1449,7 +1449,7 @@  discard block
 block discarded – undo
1449 1449
 			$destHeight,
1450 1450
 			Imagick::FILTER_LANCZOS,
1451 1451
 			1
1452
-		);//, IMAGICK_FILTER_LANCZOS, _IMG_IMAGICK_QUALITE / 100);
1452
+		); //, IMAGICK_FILTER_LANCZOS, _IMG_IMAGICK_QUALITE / 100);
1453 1453
 		$imagick->writeImage($vignette);
1454 1454
 
1455 1455
 		if (!@file_exists($vignette)) {
@@ -1458,7 +1458,7 @@  discard block
 block discarded – undo
1458 1458
 			return;
1459 1459
 		}
1460 1460
 		// remettre le chemin relatif car c'est ce qu'attend SPIP pour la suite (en particlier action/tester)
1461
-		$vignette = $destination . '.' . $format_sortie;
1461
+		$vignette = $destination.'.'.$format_sortie;
1462 1462
 	}
1463 1463
 
1464 1464
 	// netpbm
@@ -1469,11 +1469,11 @@  discard block
 block discarded – undo
1469 1469
 		if (_PNMSCALE_COMMAND == '') {
1470 1470
 			return;
1471 1471
 		}
1472
-		$vignette = $destination . '.' . $format_sortie;
1472
+		$vignette = $destination.'.'.$format_sortie;
1473 1473
 		$pnmtojpeg_command = str_replace('pnmscale', 'pnmtojpeg', _PNMSCALE_COMMAND);
1474 1474
 		if ($format == 'jpg') {
1475 1475
 			$jpegtopnm_command = str_replace('pnmscale', 'jpegtopnm', _PNMSCALE_COMMAND);
1476
-			exec("$jpegtopnm_command $image | " . _PNMSCALE_COMMAND . " -width $destWidth | $pnmtojpeg_command > $vignette");
1476
+			exec("$jpegtopnm_command $image | "._PNMSCALE_COMMAND." -width $destWidth | $pnmtojpeg_command > $vignette");
1477 1477
 			if (!($s = @filesize($vignette))) {
1478 1478
 				spip_unlink($vignette);
1479 1479
 			}
@@ -1485,7 +1485,7 @@  discard block
 block discarded – undo
1485 1485
 		} else {
1486 1486
 			if ($format == 'gif') {
1487 1487
 				$giftopnm_command = str_replace('pnmscale', 'giftopnm', _PNMSCALE_COMMAND);
1488
-				exec("$giftopnm_command $image | " . _PNMSCALE_COMMAND . " -width $destWidth | $pnmtojpeg_command > $vignette");
1488
+				exec("$giftopnm_command $image | "._PNMSCALE_COMMAND." -width $destWidth | $pnmtojpeg_command > $vignette");
1489 1489
 				if (!($s = @filesize($vignette))) {
1490 1490
 					spip_unlink($vignette);
1491 1491
 				}
@@ -1497,7 +1497,7 @@  discard block
 block discarded – undo
1497 1497
 			} else {
1498 1498
 				if ($format == 'png') {
1499 1499
 					$pngtopnm_command = str_replace('pnmscale', 'pngtopnm', _PNMSCALE_COMMAND);
1500
-					exec("$pngtopnm_command $image | " . _PNMSCALE_COMMAND . " -width $destWidth | $pnmtojpeg_command > $vignette");
1500
+					exec("$pngtopnm_command $image | "._PNMSCALE_COMMAND." -width $destWidth | $pnmtojpeg_command > $vignette");
1501 1501
 					if (!($s = @filesize($vignette))) {
1502 1502
 						spip_unlink($vignette);
1503 1503
 					}
@@ -1519,7 +1519,7 @@  discard block
 block discarded – undo
1519 1519
 			return;
1520 1520
 		}
1521 1521
 		if (_IMG_GD_MAX_PIXELS && $srcWidth * $srcHeight > _IMG_GD_MAX_PIXELS) {
1522
-			spip_log('vignette gd1/gd2 impossible : ' . $srcWidth * $srcHeight . 'pixels');
1522
+			spip_log('vignette gd1/gd2 impossible : '.$srcWidth * $srcHeight.'pixels');
1523 1523
 
1524 1524
 			return;
1525 1525
 		}
@@ -1831,7 +1831,7 @@  discard block
 block discarded – undo
1831 1831
 		// de l'image, de facon a tromper le cache du navigateur
1832 1832
 		// quand on fait supprimer/reuploader un logo
1833 1833
 		// (pas de filemtime si SAFE MODE)
1834
-		$date = test_espace_prive() ? ('?' . $date) : '';
1834
+		$date = test_espace_prive() ? ('?'.$date) : '';
1835 1835
 
1836 1836
 		return _image_ecrire_tag($image, ['src' => "$logo$date", 'width' => $destWidth, 'height' => $destHeight]);
1837 1837
 	}
@@ -1877,7 +1877,7 @@  discard block
 block discarded – undo
1877 1877
 	public static function LittleEndian2String($number, $minbytes = 1) {
1878 1878
 		$intstring = '';
1879 1879
 		while ($number > 0) {
1880
-			$intstring = $intstring . chr($number & 255);
1880
+			$intstring = $intstring.chr($number & 255);
1881 1881
 			$number >>= 8;
1882 1882
 		}
1883 1883
 
@@ -1909,9 +1909,9 @@  discard block
 block discarded – undo
1909 1909
 					$b = $argb['blue'];
1910 1910
 
1911 1911
 					if ($bpp[$key] == 32) {
1912
-						$icXOR[$key] .= chr($b) . chr($g) . chr($r) . chr($a);
1912
+						$icXOR[$key] .= chr($b).chr($g).chr($r).chr($a);
1913 1913
 					} elseif ($bpp[$key] == 24) {
1914
-						$icXOR[$key] .= chr($b) . chr($g) . chr($r);
1914
+						$icXOR[$key] .= chr($b).chr($g).chr($r);
1915 1915
 					}
1916 1916
 
1917 1917
 					if ($a < 128) {
@@ -1938,48 +1938,48 @@  discard block
 block discarded – undo
1938 1938
 
1939 1939
 			// BITMAPINFOHEADER - 40 bytes
1940 1940
 			$BitmapInfoHeader[$key] = '';
1941
-			$BitmapInfoHeader[$key] .= "\x28\x00\x00\x00";                // DWORD  biSize;
1942
-			$BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($ImageWidths[$key], 4);    // LONG   biWidth;
1941
+			$BitmapInfoHeader[$key] .= "\x28\x00\x00\x00"; // DWORD  biSize;
1942
+			$BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($ImageWidths[$key], 4); // LONG   biWidth;
1943 1943
 			// The biHeight member specifies the combined
1944 1944
 			// height of the XOR and AND masks.
1945 1945
 			$BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($ImageHeights[$key] * 2, 4); // LONG   biHeight;
1946
-			$BitmapInfoHeader[$key] .= "\x01\x00";                    // WORD   biPlanes;
1947
-			$BitmapInfoHeader[$key] .= chr($bpp[$key]) . "\x00";              // wBitCount;
1948
-			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // DWORD  biCompression;
1949
-			$BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($biSizeImage, 4);      // DWORD  biSizeImage;
1950
-			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // LONG   biXPelsPerMeter;
1951
-			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // LONG   biYPelsPerMeter;
1952
-			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // DWORD  biClrUsed;
1953
-			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // DWORD  biClrImportant;
1946
+			$BitmapInfoHeader[$key] .= "\x01\x00"; // WORD   biPlanes;
1947
+			$BitmapInfoHeader[$key] .= chr($bpp[$key])."\x00"; // wBitCount;
1948
+			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00"; // DWORD  biCompression;
1949
+			$BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($biSizeImage, 4); // DWORD  biSizeImage;
1950
+			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00"; // LONG   biXPelsPerMeter;
1951
+			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00"; // LONG   biYPelsPerMeter;
1952
+			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00"; // DWORD  biClrUsed;
1953
+			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00"; // DWORD  biClrImportant;
1954 1954
 		}
1955 1955
 
1956 1956
 
1957
-		$icondata = "\x00\x00";                    // idReserved;   // Reserved (must be 0)
1958
-		$icondata .= "\x01\x00";                    // idType;	   // Resource Type (1 for icons)
1959
-		$icondata .= phpthumb_functions::LittleEndian2String(count($gd_image_array), 2);  // idCount;	  // How many images?
1957
+		$icondata = "\x00\x00"; // idReserved;   // Reserved (must be 0)
1958
+		$icondata .= "\x01\x00"; // idType;	   // Resource Type (1 for icons)
1959
+		$icondata .= phpthumb_functions::LittleEndian2String(count($gd_image_array), 2); // idCount;	  // How many images?
1960 1960
 
1961 1961
 		$dwImageOffset = 6 + (count($gd_image_array) * 16);
1962 1962
 		foreach ($gd_image_array as $key => $gd_image) {
1963 1963
 			// ICONDIRENTRY   idEntries[1]; // An entry for each image (idCount of 'em)
1964 1964
 
1965
-			$icondata .= chr($ImageWidths[$key]);           // bWidth;		  // Width, in pixels, of the image
1966
-			$icondata .= chr($ImageHeights[$key]);          // bHeight;		 // Height, in pixels, of the image
1967
-			$icondata .= chr($totalcolors[$key]);           // bColorCount;	 // Number of colors in image (0 if >=8bpp)
1968
-			$icondata .= "\x00";                    // bReserved;	   // Reserved ( must be 0)
1965
+			$icondata .= chr($ImageWidths[$key]); // bWidth;		  // Width, in pixels, of the image
1966
+			$icondata .= chr($ImageHeights[$key]); // bHeight;		 // Height, in pixels, of the image
1967
+			$icondata .= chr($totalcolors[$key]); // bColorCount;	 // Number of colors in image (0 if >=8bpp)
1968
+			$icondata .= "\x00"; // bReserved;	   // Reserved ( must be 0)
1969 1969
 
1970
-			$icondata .= "\x01\x00";                  // wPlanes;		 // Color Planes
1971
-			$icondata .= chr($bpp[$key]) . "\x00";            // wBitCount;	   // Bits per pixel
1970
+			$icondata .= "\x01\x00"; // wPlanes;		 // Color Planes
1971
+			$icondata .= chr($bpp[$key])."\x00"; // wBitCount;	   // Bits per pixel
1972 1972
 
1973 1973
 			$dwBytesInRes = 40 + strlen($icXOR[$key]) + strlen($icAND[$key]);
1974 1974
 			$icondata .= phpthumb_functions::LittleEndian2String(
1975 1975
 				$dwBytesInRes,
1976 1976
 				4
1977
-			);     // dwBytesInRes;	// How many bytes in this resource?
1977
+			); // dwBytesInRes;	// How many bytes in this resource?
1978 1978
 
1979 1979
 			$icondata .= phpthumb_functions::LittleEndian2String(
1980 1980
 				$dwImageOffset,
1981 1981
 				4
1982
-			);    // dwImageOffset;   // Where in the file is this image?
1982
+			); // dwImageOffset;   // Where in the file is this image?
1983 1983
 			$dwImageOffset += strlen($BitmapInfoHeader[$key]);
1984 1984
 			$dwImageOffset += strlen($icXOR[$key]);
1985 1985
 			$dwImageOffset += strlen($icAND[$key]);
Please login to merge, or discard this patch.
Indentation   +1327 added lines, -1327 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
 /**
@@ -251,11 +251,11 @@  discard block
 block discarded – undo
251 251
  *     true si il faut supprimer le fichier temporaire ; false sinon.
252 252
  */
253 253
 function statut_effacer_images_temporaires($stat) {
254
-	static $statut = false; // par defaut on grave toute les images
255
-	if ($stat === 'get') {
256
-		return $statut;
257
-	}
258
-	$statut = $stat ? true : false;
254
+    static $statut = false; // par defaut on grave toute les images
255
+    if ($stat === 'get') {
256
+        return $statut;
257
+    }
258
+    $statut = $stat ? true : false;
259 259
 }
260 260
 
261 261
 
@@ -308,243 +308,243 @@  discard block
 block discarded – undo
308 308
  *     - array : tableau décrivant de l'image
309 309
  */
310 310
 function _image_valeurs_trans($img, $effet, $forcer_format = false, $fonction_creation = null, $find_in_path = false, $support_svg = false) {
311
-	$ret = [];
312
-	$f = null;
313
-	static $images_recalcul = [];
314
-	if (strlen($img) == 0) {
315
-		return false;
316
-	}
317
-
318
-	$source = trim(extraire_attribut($img, 'src') ?? '');
319
-	if (strlen($source) < 1) {
320
-		$source = $img;
321
-		$img = "<img src='$source' />";
322
-	} elseif (
323
-		preg_match('@^data:image/([^;]*);base64,(.*)$@isS', $source, $regs)
324
-		and $extension = _image_trouver_extension_depuis_mime('image/' . $regs[1])
325
-		and in_array($extension, _image_extensions_acceptees_en_entree())
326
-	) {
327
-		# gerer img src="data:....base64"
328
-		$local = sous_repertoire(_DIR_VAR, 'image-data') . md5($regs[2]) . '.' . _image_extension_normalisee($extension);
329
-		if (!file_exists($local)) {
330
-			ecrire_fichier($local, base64_decode($regs[2]));
331
-		}
332
-		if ($sanitizer = charger_fonction($extension, 'sanitizer', true)) {
333
-			$sanitizer($local);
334
-		}
335
-		$source = $local;
336
-		$img = inserer_attribut($img, 'src', $source);
337
-		# eviter les mauvaises surprises lors de conversions de format
338
-		$img = inserer_attribut($img, 'width', '');
339
-		$img = inserer_attribut($img, 'height', '');
340
-	}
341
-
342
-	// les protocoles web prennent au moins 3 lettres
343
-	if (tester_url_absolue($source)) {
344
-		include_spip('inc/distant');
345
-		$fichier = _DIR_RACINE . copie_locale($source);
346
-		if (!$fichier) {
347
-			return '';
348
-		}
349
-		if (
350
-			$extension = _image_trouver_extension($fichier)
351
-			and $sanitizer = charger_fonction($extension, 'sanitizer', true)
352
-		) {
353
-			$sanitizer($fichier);
354
-		}
355
-	} else {
356
-		// enlever le timestamp eventuel
357
-		if (strpos($source, '?') !== false) {
358
-			$source = preg_replace(',[?][0-9]+$,', '', $source);
359
-		}
360
-		if (
361
-			strpos($source, '?') !== false
362
-			and strncmp($source, _DIR_IMG, strlen(_DIR_IMG)) == 0
363
-			and file_exists($f = preg_replace(',[?].*$,', '', $source))
364
-		) {
365
-			$source = $f;
366
-		}
367
-		$fichier = $source;
368
-	}
369
-
370
-	$terminaison_dest = '';
371
-	if ($terminaison = _image_trouver_extension($fichier)) {
372
-		$terminaison_dest = ($terminaison == 'gif') ? 'png' : $terminaison;
373
-	}
374
-
375
-	if (
376
-		$forcer_format !== false
377
-		// 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
378
-		and ($terminaison_dest !== 'svg' or $support_svg or !in_array($forcer_format, _image_extensions_acceptees_en_sortie()))
379
-	) {
380
-		$terminaison_dest = $forcer_format;
381
-	}
382
-
383
-	if (!$terminaison_dest) {
384
-		return false;
385
-	}
386
-
387
-	$nom_fichier = substr($fichier, 0, strlen($fichier) - (strlen($terminaison) + 1));
388
-	$fichier_dest = $nom_fichier;
389
-	if (
390
-		($find_in_path and $f = find_in_path($fichier) and $fichier = $f)
391
-		or @file_exists($f = $fichier)
392
-	) {
393
-		// on passe la balise img a taille image qui exraira les attributs si possible
394
-		// au lieu de faire un acces disque sur le fichier
395
-		[$ret['hauteur'], $ret['largeur']] = taille_image($find_in_path ? $f : $img);
396
-		$date_src = @filemtime($f);
397
-	} elseif (
398
-		@file_exists($f = "$fichier.src")
399
-		and lire_fichier($f, $valeurs)
400
-		and $valeurs = unserialize($valeurs)
401
-		and isset($valeurs['hauteur_dest'])
402
-		and isset($valeurs['largeur_dest'])
403
-	) {
404
-		$ret['hauteur'] = $valeurs['hauteur_dest'];
405
-		$ret['largeur'] = $valeurs['largeur_dest'];
406
-		$date_src = $valeurs['date'];
407
-	} // pas de fichier source par la
408
-	else {
409
-		return false;
410
-	}
411
-
412
-	// pas de taille mesurable
413
-	if (!($ret['hauteur'] or $ret['largeur'])) {
414
-		return false;
415
-	}
416
-
417
-	// les images calculees dependent du chemin du fichier source
418
-	// 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
419
-	// ce n'est pas totalement optimal en terme de stockage, mais chaque image est associee a un fichier .src
420
-	// qui contient la methode de reconstrucion (le filtre + les arguments d'appel) et les arguments different entre prive et public
421
-	// la mise en commun du fichier image cree donc un bug et des problemes qui necessiteraient beaucoup de complexite de code
422
-	// alors que ca concerne peu de site au final
423
-	// la release de r23632+r23633+r23634 a provoque peu de remontee de bug attestant du peu de sites impactes
424
-	$identifiant = $fichier;
425
-
426
-	// cas general :
427
-	// on a un dossier cache commun et un nom de fichier qui varie avec l'effet
428
-	// cas particulier de reduire :
429
-	// un cache par dimension, et le nom de fichier est conserve, suffixe par la dimension aussi
430
-	$cache = 'cache-gd2';
431
-	if (substr($effet, 0, 7) == 'reduire') {
432
-		[, $maxWidth, $maxHeight] = explode('-', $effet);
433
-		[$destWidth, $destHeight] = _image_ratio($ret['largeur'], $ret['hauteur'], $maxWidth, $maxHeight);
434
-		$ret['largeur_dest'] = $destWidth;
435
-		$ret['hauteur_dest'] = $destHeight;
436
-		$effet = "L{$destWidth}xH$destHeight";
437
-		$cache = 'cache-vignettes';
438
-		$fichier_dest = basename($fichier_dest);
439
-		if (($ret['largeur'] <= $maxWidth) && ($ret['hauteur'] <= $maxHeight)) {
440
-			// on garde la terminaison initiale car image simplement copiee
441
-			// et on postfixe son nom avec un md5 du path
442
-			$terminaison_dest = $terminaison;
443
-			$fichier_dest .= '-' . substr(md5("$identifiant"), 0, 5);
444
-		} else {
445
-			$fichier_dest .= '-' . substr(md5("$identifiant-$effet"), 0, 5);
446
-		}
447
-		$cache = sous_repertoire(_DIR_VAR, $cache);
448
-		$cache = sous_repertoire($cache, $effet);
449
-	} else {
450
-		$fichier_dest = md5("$identifiant-$effet");
451
-		$cache = sous_repertoire(_DIR_VAR, $cache);
452
-		$cache = sous_repertoire($cache, substr($fichier_dest, 0, 2));
453
-		$fichier_dest = substr($fichier_dest, 2);
454
-	}
455
-
456
-	$fichier_dest = $cache . $fichier_dest . '.' . $terminaison_dest;
457
-
458
-	$GLOBALS['images_calculees'][] = $fichier_dest;
459
-
460
-	$creer = true;
461
-	// si recalcul des images demande, recalculer chaque image une fois
462
-	if (defined('_VAR_IMAGES') and _VAR_IMAGES and !isset($images_recalcul[$fichier_dest])) {
463
-		$images_recalcul[$fichier_dest] = true;
464
-	} else {
465
-		if (@file_exists($f = $fichier_dest)) {
466
-			if (filemtime($f) >= $date_src) {
467
-				$creer = false;
468
-			}
469
-		} else {
470
-			if (
471
-				@file_exists($f = "$fichier_dest.src")
472
-				and lire_fichier($f, $valeurs)
473
-				and $valeurs = unserialize($valeurs)
474
-				and $valeurs['date'] >= $date_src
475
-			) {
476
-				$creer = false;
477
-			}
478
-		}
479
-	}
480
-	if ($creer) {
481
-		if (!@file_exists($fichier)) {
482
-			if (!@file_exists("$fichier.src")) {
483
-				spip_log("Image absente : $fichier");
484
-
485
-				return false;
486
-			}
487
-			# on reconstruit l'image source absente a partir de la chaine des .src
488
-			reconstruire_image_intermediaire($fichier);
489
-		}
490
-	}
491
-
492
-	if ($creer) {
493
-		spip_log(
494
-			'filtre image ' . ($fonction_creation ? reset($fonction_creation) : '') . "[$effet] sur $fichier",
495
-			'images' . _LOG_DEBUG
496
-		);
497
-	}
498
-
499
-	$term_fonction = _image_trouver_extension_pertinente($fichier);
500
-	$ret['fonction_imagecreatefrom'] = '_imagecreatefrom' . $term_fonction;
501
-	$ret['fichier'] = $fichier;
502
-	$ret['fonction_image'] = '_image_image' . $terminaison_dest;
503
-	$ret['fichier_dest'] = $fichier_dest;
504
-	$ret['format_source'] = _image_extension_normalisee($terminaison);
505
-	$ret['format_dest'] = $terminaison_dest;
506
-	$ret['date_src'] = $date_src;
507
-	$ret['creer'] = $creer;
508
-	$ret['class'] = extraire_attribut($img, 'class');
509
-	$ret['alt'] = extraire_attribut($img, 'alt');
510
-	$ret['style'] = extraire_attribut($img, 'style');
511
-	$ret['tag'] = $img;
512
-	if ($fonction_creation) {
513
-		$ret['reconstruction'] = $fonction_creation;
514
-		# ecrire ici comment creer le fichier, car il est pas sur qu'on l'ecrira reelement
515
-		# cas de image_reduire qui finalement ne reduit pas l'image source
516
-		# ca evite d'essayer de le creer au prochain hit si il n'est pas la
517
-		#ecrire_fichier($ret['fichier_dest'].'.src',serialize($ret),true);
518
-	}
519
-
520
-	$ret = pipeline('image_preparer_filtre', [
521
-			'args' => [
522
-				'img' => $img,
523
-				'effet' => $effet,
524
-				'forcer_format' => $forcer_format,
525
-				'fonction_creation' => $fonction_creation,
526
-				'find_in_path' => $find_in_path,
527
-			],
528
-			'data' => $ret
529
-		]);
530
-
531
-	// une globale pour le debug en cas de crash memoire
532
-	$GLOBALS['derniere_image_calculee'] = $ret;
533
-
534
-	// traiter le cas particulier des SVG : si le filtre n'a pas annonce explicitement qu'il savait faire, on delegue
535
-	if ($term_fonction === 'svg') {
536
-		if ($creer and !$support_svg) {
537
-			process_image_svg_identite($ret);
538
-			$ret['creer'] = false;
539
-		}
540
-	}
541
-	else {
542
-		if (!function_exists($ret['fonction_imagecreatefrom'])) {
543
-			return false;
544
-		}
545
-	}
546
-
547
-	return $ret;
311
+    $ret = [];
312
+    $f = null;
313
+    static $images_recalcul = [];
314
+    if (strlen($img) == 0) {
315
+        return false;
316
+    }
317
+
318
+    $source = trim(extraire_attribut($img, 'src') ?? '');
319
+    if (strlen($source) < 1) {
320
+        $source = $img;
321
+        $img = "<img src='$source' />";
322
+    } elseif (
323
+        preg_match('@^data:image/([^;]*);base64,(.*)$@isS', $source, $regs)
324
+        and $extension = _image_trouver_extension_depuis_mime('image/' . $regs[1])
325
+        and in_array($extension, _image_extensions_acceptees_en_entree())
326
+    ) {
327
+        # gerer img src="data:....base64"
328
+        $local = sous_repertoire(_DIR_VAR, 'image-data') . md5($regs[2]) . '.' . _image_extension_normalisee($extension);
329
+        if (!file_exists($local)) {
330
+            ecrire_fichier($local, base64_decode($regs[2]));
331
+        }
332
+        if ($sanitizer = charger_fonction($extension, 'sanitizer', true)) {
333
+            $sanitizer($local);
334
+        }
335
+        $source = $local;
336
+        $img = inserer_attribut($img, 'src', $source);
337
+        # eviter les mauvaises surprises lors de conversions de format
338
+        $img = inserer_attribut($img, 'width', '');
339
+        $img = inserer_attribut($img, 'height', '');
340
+    }
341
+
342
+    // les protocoles web prennent au moins 3 lettres
343
+    if (tester_url_absolue($source)) {
344
+        include_spip('inc/distant');
345
+        $fichier = _DIR_RACINE . copie_locale($source);
346
+        if (!$fichier) {
347
+            return '';
348
+        }
349
+        if (
350
+            $extension = _image_trouver_extension($fichier)
351
+            and $sanitizer = charger_fonction($extension, 'sanitizer', true)
352
+        ) {
353
+            $sanitizer($fichier);
354
+        }
355
+    } else {
356
+        // enlever le timestamp eventuel
357
+        if (strpos($source, '?') !== false) {
358
+            $source = preg_replace(',[?][0-9]+$,', '', $source);
359
+        }
360
+        if (
361
+            strpos($source, '?') !== false
362
+            and strncmp($source, _DIR_IMG, strlen(_DIR_IMG)) == 0
363
+            and file_exists($f = preg_replace(',[?].*$,', '', $source))
364
+        ) {
365
+            $source = $f;
366
+        }
367
+        $fichier = $source;
368
+    }
369
+
370
+    $terminaison_dest = '';
371
+    if ($terminaison = _image_trouver_extension($fichier)) {
372
+        $terminaison_dest = ($terminaison == 'gif') ? 'png' : $terminaison;
373
+    }
374
+
375
+    if (
376
+        $forcer_format !== false
377
+        // 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
378
+        and ($terminaison_dest !== 'svg' or $support_svg or !in_array($forcer_format, _image_extensions_acceptees_en_sortie()))
379
+    ) {
380
+        $terminaison_dest = $forcer_format;
381
+    }
382
+
383
+    if (!$terminaison_dest) {
384
+        return false;
385
+    }
386
+
387
+    $nom_fichier = substr($fichier, 0, strlen($fichier) - (strlen($terminaison) + 1));
388
+    $fichier_dest = $nom_fichier;
389
+    if (
390
+        ($find_in_path and $f = find_in_path($fichier) and $fichier = $f)
391
+        or @file_exists($f = $fichier)
392
+    ) {
393
+        // on passe la balise img a taille image qui exraira les attributs si possible
394
+        // au lieu de faire un acces disque sur le fichier
395
+        [$ret['hauteur'], $ret['largeur']] = taille_image($find_in_path ? $f : $img);
396
+        $date_src = @filemtime($f);
397
+    } elseif (
398
+        @file_exists($f = "$fichier.src")
399
+        and lire_fichier($f, $valeurs)
400
+        and $valeurs = unserialize($valeurs)
401
+        and isset($valeurs['hauteur_dest'])
402
+        and isset($valeurs['largeur_dest'])
403
+    ) {
404
+        $ret['hauteur'] = $valeurs['hauteur_dest'];
405
+        $ret['largeur'] = $valeurs['largeur_dest'];
406
+        $date_src = $valeurs['date'];
407
+    } // pas de fichier source par la
408
+    else {
409
+        return false;
410
+    }
411
+
412
+    // pas de taille mesurable
413
+    if (!($ret['hauteur'] or $ret['largeur'])) {
414
+        return false;
415
+    }
416
+
417
+    // les images calculees dependent du chemin du fichier source
418
+    // 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
419
+    // ce n'est pas totalement optimal en terme de stockage, mais chaque image est associee a un fichier .src
420
+    // qui contient la methode de reconstrucion (le filtre + les arguments d'appel) et les arguments different entre prive et public
421
+    // la mise en commun du fichier image cree donc un bug et des problemes qui necessiteraient beaucoup de complexite de code
422
+    // alors que ca concerne peu de site au final
423
+    // la release de r23632+r23633+r23634 a provoque peu de remontee de bug attestant du peu de sites impactes
424
+    $identifiant = $fichier;
425
+
426
+    // cas general :
427
+    // on a un dossier cache commun et un nom de fichier qui varie avec l'effet
428
+    // cas particulier de reduire :
429
+    // un cache par dimension, et le nom de fichier est conserve, suffixe par la dimension aussi
430
+    $cache = 'cache-gd2';
431
+    if (substr($effet, 0, 7) == 'reduire') {
432
+        [, $maxWidth, $maxHeight] = explode('-', $effet);
433
+        [$destWidth, $destHeight] = _image_ratio($ret['largeur'], $ret['hauteur'], $maxWidth, $maxHeight);
434
+        $ret['largeur_dest'] = $destWidth;
435
+        $ret['hauteur_dest'] = $destHeight;
436
+        $effet = "L{$destWidth}xH$destHeight";
437
+        $cache = 'cache-vignettes';
438
+        $fichier_dest = basename($fichier_dest);
439
+        if (($ret['largeur'] <= $maxWidth) && ($ret['hauteur'] <= $maxHeight)) {
440
+            // on garde la terminaison initiale car image simplement copiee
441
+            // et on postfixe son nom avec un md5 du path
442
+            $terminaison_dest = $terminaison;
443
+            $fichier_dest .= '-' . substr(md5("$identifiant"), 0, 5);
444
+        } else {
445
+            $fichier_dest .= '-' . substr(md5("$identifiant-$effet"), 0, 5);
446
+        }
447
+        $cache = sous_repertoire(_DIR_VAR, $cache);
448
+        $cache = sous_repertoire($cache, $effet);
449
+    } else {
450
+        $fichier_dest = md5("$identifiant-$effet");
451
+        $cache = sous_repertoire(_DIR_VAR, $cache);
452
+        $cache = sous_repertoire($cache, substr($fichier_dest, 0, 2));
453
+        $fichier_dest = substr($fichier_dest, 2);
454
+    }
455
+
456
+    $fichier_dest = $cache . $fichier_dest . '.' . $terminaison_dest;
457
+
458
+    $GLOBALS['images_calculees'][] = $fichier_dest;
459
+
460
+    $creer = true;
461
+    // si recalcul des images demande, recalculer chaque image une fois
462
+    if (defined('_VAR_IMAGES') and _VAR_IMAGES and !isset($images_recalcul[$fichier_dest])) {
463
+        $images_recalcul[$fichier_dest] = true;
464
+    } else {
465
+        if (@file_exists($f = $fichier_dest)) {
466
+            if (filemtime($f) >= $date_src) {
467
+                $creer = false;
468
+            }
469
+        } else {
470
+            if (
471
+                @file_exists($f = "$fichier_dest.src")
472
+                and lire_fichier($f, $valeurs)
473
+                and $valeurs = unserialize($valeurs)
474
+                and $valeurs['date'] >= $date_src
475
+            ) {
476
+                $creer = false;
477
+            }
478
+        }
479
+    }
480
+    if ($creer) {
481
+        if (!@file_exists($fichier)) {
482
+            if (!@file_exists("$fichier.src")) {
483
+                spip_log("Image absente : $fichier");
484
+
485
+                return false;
486
+            }
487
+            # on reconstruit l'image source absente a partir de la chaine des .src
488
+            reconstruire_image_intermediaire($fichier);
489
+        }
490
+    }
491
+
492
+    if ($creer) {
493
+        spip_log(
494
+            'filtre image ' . ($fonction_creation ? reset($fonction_creation) : '') . "[$effet] sur $fichier",
495
+            'images' . _LOG_DEBUG
496
+        );
497
+    }
498
+
499
+    $term_fonction = _image_trouver_extension_pertinente($fichier);
500
+    $ret['fonction_imagecreatefrom'] = '_imagecreatefrom' . $term_fonction;
501
+    $ret['fichier'] = $fichier;
502
+    $ret['fonction_image'] = '_image_image' . $terminaison_dest;
503
+    $ret['fichier_dest'] = $fichier_dest;
504
+    $ret['format_source'] = _image_extension_normalisee($terminaison);
505
+    $ret['format_dest'] = $terminaison_dest;
506
+    $ret['date_src'] = $date_src;
507
+    $ret['creer'] = $creer;
508
+    $ret['class'] = extraire_attribut($img, 'class');
509
+    $ret['alt'] = extraire_attribut($img, 'alt');
510
+    $ret['style'] = extraire_attribut($img, 'style');
511
+    $ret['tag'] = $img;
512
+    if ($fonction_creation) {
513
+        $ret['reconstruction'] = $fonction_creation;
514
+        # ecrire ici comment creer le fichier, car il est pas sur qu'on l'ecrira reelement
515
+        # cas de image_reduire qui finalement ne reduit pas l'image source
516
+        # ca evite d'essayer de le creer au prochain hit si il n'est pas la
517
+        #ecrire_fichier($ret['fichier_dest'].'.src',serialize($ret),true);
518
+    }
519
+
520
+    $ret = pipeline('image_preparer_filtre', [
521
+            'args' => [
522
+                'img' => $img,
523
+                'effet' => $effet,
524
+                'forcer_format' => $forcer_format,
525
+                'fonction_creation' => $fonction_creation,
526
+                'find_in_path' => $find_in_path,
527
+            ],
528
+            'data' => $ret
529
+        ]);
530
+
531
+    // une globale pour le debug en cas de crash memoire
532
+    $GLOBALS['derniere_image_calculee'] = $ret;
533
+
534
+    // traiter le cas particulier des SVG : si le filtre n'a pas annonce explicitement qu'il savait faire, on delegue
535
+    if ($term_fonction === 'svg') {
536
+        if ($creer and !$support_svg) {
537
+            process_image_svg_identite($ret);
538
+            $ret['creer'] = false;
539
+        }
540
+    }
541
+    else {
542
+        if (!function_exists($ret['fonction_imagecreatefrom'])) {
543
+            return false;
544
+        }
545
+    }
546
+
547
+    return $ret;
548 548
 }
549 549
 
550 550
 
@@ -553,54 +553,54 @@  discard block
 block discarded – undo
553 553
  * @return array
554 554
  */
555 555
 function _image_extensions_acceptees_en_entree() {
556
-	static $extensions = null;
557
-	if (empty($extensions)) {
558
-		$extensions = ['png', 'gif', 'jpg', 'jpeg'];
559
-		if (!empty($GLOBALS['meta']['gd_formats'])) {
560
-			// action=tester renseigne gd_formats et detecte le support de webp
561
-			$extensions = array_merge(explode(',', $GLOBALS['meta']['gd_formats']));
562
-			$extensions = array_map('trim', $extensions);
563
-			$extensions = array_filter($extensions);
564
-			if (in_array('jpg', $extensions)) { 
565
-				$extensions[] = 'jpeg';
566
-			}
567
-			$extensions = array_unique($extensions);
568
-		}
569
-		$extensions[] = 'svg'; // on le supporte toujours avec des fonctions specifiques
570
-	}
571
-
572
-	return $extensions;
556
+    static $extensions = null;
557
+    if (empty($extensions)) {
558
+        $extensions = ['png', 'gif', 'jpg', 'jpeg'];
559
+        if (!empty($GLOBALS['meta']['gd_formats'])) {
560
+            // action=tester renseigne gd_formats et detecte le support de webp
561
+            $extensions = array_merge(explode(',', $GLOBALS['meta']['gd_formats']));
562
+            $extensions = array_map('trim', $extensions);
563
+            $extensions = array_filter($extensions);
564
+            if (in_array('jpg', $extensions)) { 
565
+                $extensions[] = 'jpeg';
566
+            }
567
+            $extensions = array_unique($extensions);
568
+        }
569
+        $extensions[] = 'svg'; // on le supporte toujours avec des fonctions specifiques
570
+    }
571
+
572
+    return $extensions;
573 573
 }
574 574
 
575 575
 /**
576 576
  * @return array|string[]|null
577 577
  */
578 578
 function _image_extensions_acceptees_en_sortie() {
579
-	static $extensions = null;
580
-	if (empty($extensions)) {
581
-		$extensions = _image_extensions_acceptees_en_entree();
582
-		$extensions = array_diff($extensions, ['jpeg']);
583
-		if (in_array('gif', $extensions) and !function_exists('imagegif')) {
584
-			$extensions = array_diff($extensions, ['gif']);
585
-		}
586
-		if (in_array('webp', $extensions) and !function_exists('imagewebp')) {
587
-			$extensions = array_diff($extensions, ['webp']);
588
-		}
589
-	}
590
-
591
-	return $extensions;
579
+    static $extensions = null;
580
+    if (empty($extensions)) {
581
+        $extensions = _image_extensions_acceptees_en_entree();
582
+        $extensions = array_diff($extensions, ['jpeg']);
583
+        if (in_array('gif', $extensions) and !function_exists('imagegif')) {
584
+            $extensions = array_diff($extensions, ['gif']);
585
+        }
586
+        if (in_array('webp', $extensions) and !function_exists('imagewebp')) {
587
+            $extensions = array_diff($extensions, ['webp']);
588
+        }
589
+    }
590
+
591
+    return $extensions;
592 592
 }
593 593
 
594 594
 function _image_extension_normalisee($extension) {
595
-	$extension = strtolower($extension);
596
-	if ($extension === 'jpeg') {
597
-		$extension = 'jpg';
598
-	}
599
-	return $extension;
595
+    $extension = strtolower($extension);
596
+    if ($extension === 'jpeg') {
597
+        $extension = 'jpg';
598
+    }
599
+    return $extension;
600 600
 }
601 601
 
602 602
 function _image_extensions_conservent_transparence() {
603
-	return ['png', 'webp'];
603
+    return ['png', 'webp'];
604 604
 }
605 605
 
606 606
 
@@ -610,12 +610,12 @@  discard block
 block discarded – undo
610 610
  * @return string
611 611
  */
612 612
 function _image_trouver_extension($path) {
613
-	$preg_extensions = implode('|', _image_extensions_acceptees_en_entree());
614
-	if (preg_match(",\.($preg_extensions)($|[?]),i", $path, $regs)) {
615
-		$terminaison = strtolower($regs[1]);
616
-		return $terminaison;
617
-	}
618
-	return '';
613
+    $preg_extensions = implode('|', _image_extensions_acceptees_en_entree());
614
+    if (preg_match(",\.($preg_extensions)($|[?]),i", $path, $regs)) {
615
+        $terminaison = strtolower($regs[1]);
616
+        return $terminaison;
617
+    }
618
+    return '';
619 619
 }
620 620
 
621 621
 /**
@@ -626,33 +626,33 @@  discard block
 block discarded – undo
626 626
  * @return string Extension, dans le format attendu par les fonctions 'gd' ('jpeg' pour les .jpg par exemple)
627 627
  */
628 628
 function _image_trouver_extension_pertinente($path) {
629
-	$path = supprimer_timestamp($path);
630
-	$terminaison = _image_trouver_extension($path);
631
-	if ($terminaison == 'jpg') {
632
-		$terminaison = 'jpeg';
633
-	}
634
-
635
-	if (!file_exists($path)) {
636
-		return $terminaison;
637
-	}
638
-
639
-	if (!$info = @spip_getimagesize($path)) {
640
-		return $terminaison;
641
-	}
642
-
643
-	if (isset($info['mime'])) {
644
-		$mime = $info['mime'];
645
-	}
646
-	else {
647
-		$mime = image_type_to_mime_type($info[2]);
648
-	}
649
-
650
-	$_terminaison = _image_trouver_extension_depuis_mime($mime);
651
-	if ($_terminaison and $_terminaison !== $terminaison) {
652
-		spip_log("Mauvaise extension du fichier : $path . Son type mime est : $mime", 'images.' . _LOG_INFO_IMPORTANTE);
653
-		$terminaison = $_terminaison;
654
-	}
655
-	return $terminaison;
629
+    $path = supprimer_timestamp($path);
630
+    $terminaison = _image_trouver_extension($path);
631
+    if ($terminaison == 'jpg') {
632
+        $terminaison = 'jpeg';
633
+    }
634
+
635
+    if (!file_exists($path)) {
636
+        return $terminaison;
637
+    }
638
+
639
+    if (!$info = @spip_getimagesize($path)) {
640
+        return $terminaison;
641
+    }
642
+
643
+    if (isset($info['mime'])) {
644
+        $mime = $info['mime'];
645
+    }
646
+    else {
647
+        $mime = image_type_to_mime_type($info[2]);
648
+    }
649
+
650
+    $_terminaison = _image_trouver_extension_depuis_mime($mime);
651
+    if ($_terminaison and $_terminaison !== $terminaison) {
652
+        spip_log("Mauvaise extension du fichier : $path . Son type mime est : $mime", 'images.' . _LOG_INFO_IMPORTANTE);
653
+        $terminaison = $_terminaison;
654
+    }
655
+    return $terminaison;
656 656
 }
657 657
 
658 658
 /**
@@ -660,36 +660,36 @@  discard block
 block discarded – undo
660 660
  * @return string
661 661
  */
662 662
 function _image_trouver_extension_depuis_mime($mime) {
663
-	switch (strtolower($mime)) {
664
-		case 'image/png':
665
-		case 'image/x-png':
666
-			$terminaison = 'png';
667
-			break;
668
-
669
-		case 'image/jpg':
670
-		case 'image/jpeg':
671
-		case 'image/pjpeg':
672
-			$terminaison = 'jpeg';
673
-			break;
674
-
675
-		case 'image/gif':
676
-			$terminaison = 'gif';
677
-			break;
678
-
679
-		case 'image/webp':
680
-		case 'image/x-webp':
681
-			$terminaison = 'webp';
682
-			break;
683
-
684
-		case 'image/svg+xml':
685
-			$terminaison = 'svg';
686
-			break;
687
-
688
-		default:
689
-			$terminaison = '';
690
-	}
691
-
692
-	return $terminaison;
663
+    switch (strtolower($mime)) {
664
+        case 'image/png':
665
+        case 'image/x-png':
666
+            $terminaison = 'png';
667
+            break;
668
+
669
+        case 'image/jpg':
670
+        case 'image/jpeg':
671
+        case 'image/pjpeg':
672
+            $terminaison = 'jpeg';
673
+            break;
674
+
675
+        case 'image/gif':
676
+            $terminaison = 'gif';
677
+            break;
678
+
679
+        case 'image/webp':
680
+        case 'image/x-webp':
681
+            $terminaison = 'webp';
682
+            break;
683
+
684
+        case 'image/svg+xml':
685
+            $terminaison = 'svg';
686
+            break;
687
+
688
+        default:
689
+            $terminaison = '';
690
+    }
691
+
692
+    return $terminaison;
693 693
 }
694 694
 
695 695
 
@@ -709,18 +709,18 @@  discard block
 block discarded – undo
709 709
  *     Une ressource de type Image GD.
710 710
  */
711 711
 function _imagecreatefrom_func(string $func, string $filename) {
712
-	if (!function_exists($func)) {
713
-		spip_log("GD indisponible : $func inexistante. Traitement $filename impossible.", _LOG_CRITIQUE);
714
-		erreur_squelette("GD indisponible : $func inexistante. Traitement $filename impossible.");
715
-		return null;
716
-	}
717
-	$img = @$func($filename);
718
-	if (!$img) {
719
-		spip_log("Erreur lecture imagecreatefromjpeg $filename", _LOG_CRITIQUE);
720
-		erreur_squelette("Erreur lecture imagecreatefromjpeg $filename");
721
-		$img = imagecreate(10, 10);
722
-	}
723
-	return $img;
712
+    if (!function_exists($func)) {
713
+        spip_log("GD indisponible : $func inexistante. Traitement $filename impossible.", _LOG_CRITIQUE);
714
+        erreur_squelette("GD indisponible : $func inexistante. Traitement $filename impossible.");
715
+        return null;
716
+    }
717
+    $img = @$func($filename);
718
+    if (!$img) {
719
+        spip_log("Erreur lecture imagecreatefromjpeg $filename", _LOG_CRITIQUE);
720
+        erreur_squelette("Erreur lecture imagecreatefromjpeg $filename");
721
+        $img = imagecreate(10, 10);
722
+    }
723
+    return $img;
724 724
 }
725 725
 
726 726
 /**
@@ -736,7 +736,7 @@  discard block
 block discarded – undo
736 736
  *     Une ressource de type Image GD.
737 737
  */
738 738
 function _imagecreatefromjpeg($filename) {
739
-	return _imagecreatefrom_func('imagecreatefromjpeg', $filename);
739
+    return _imagecreatefrom_func('imagecreatefromjpeg', $filename);
740 740
 }
741 741
 
742 742
 /**
@@ -752,7 +752,7 @@  discard block
 block discarded – undo
752 752
  *     Une ressource de type Image GD.
753 753
  */
754 754
 function _imagecreatefrompng($filename) {
755
-	return _imagecreatefrom_func('imagecreatefrompng', $filename);
755
+    return _imagecreatefrom_func('imagecreatefrompng', $filename);
756 756
 }
757 757
 
758 758
 /**
@@ -768,7 +768,7 @@  discard block
 block discarded – undo
768 768
  *     Une ressource de type Image GD.
769 769
  */
770 770
 function _imagecreatefromgif($filename) {
771
-	return _imagecreatefrom_func('imagecreatefromgif', $filename);
771
+    return _imagecreatefrom_func('imagecreatefromgif', $filename);
772 772
 }
773 773
 
774 774
 
@@ -785,7 +785,7 @@  discard block
 block discarded – undo
785 785
  *     Une ressource de type Image GD.
786 786
  */
787 787
 function _imagecreatefromwebp($filename) {
788
-	return _imagecreatefrom_func('imagecreatefromwebp', $filename);
788
+    return _imagecreatefrom_func('imagecreatefromwebp', $filename);
789 789
 }
790 790
 
791 791
 /**
@@ -803,24 +803,24 @@  discard block
 block discarded – undo
803 803
  *     - true si une image est bien retournée.
804 804
  */
805 805
 function _image_imagepng($img, $fichier) {
806
-	if (!function_exists('imagepng')) {
807
-		return false;
808
-	}
809
-	$tmp = $fichier . '.tmp';
810
-	$ret = imagepng($img, $tmp);
811
-	if (file_exists($tmp)) {
812
-		$taille_test = getimagesize($tmp);
813
-		if ($taille_test[0] < 1) {
814
-			return false;
815
-		}
816
-
817
-		spip_unlink($fichier); // le fichier peut deja exister
818
-		@rename($tmp, $fichier);
819
-
820
-		return $ret;
821
-	}
822
-
823
-	return false;
806
+    if (!function_exists('imagepng')) {
807
+        return false;
808
+    }
809
+    $tmp = $fichier . '.tmp';
810
+    $ret = imagepng($img, $tmp);
811
+    if (file_exists($tmp)) {
812
+        $taille_test = getimagesize($tmp);
813
+        if ($taille_test[0] < 1) {
814
+            return false;
815
+        }
816
+
817
+        spip_unlink($fichier); // le fichier peut deja exister
818
+        @rename($tmp, $fichier);
819
+
820
+        return $ret;
821
+    }
822
+
823
+    return false;
824 824
 }
825 825
 
826 826
 /**
@@ -838,24 +838,24 @@  discard block
 block discarded – undo
838 838
  *     - true si une image est bien retournée.
839 839
  */
840 840
 function _image_imagegif($img, $fichier) {
841
-	if (!function_exists('imagegif')) {
842
-		return false;
843
-	}
844
-	$tmp = $fichier . '.tmp';
845
-	$ret = imagegif($img, $tmp);
846
-	if (file_exists($tmp)) {
847
-		$taille_test = getimagesize($tmp);
848
-		if ($taille_test[0] < 1) {
849
-			return false;
850
-		}
851
-
852
-		spip_unlink($fichier); // le fichier peut deja exister
853
-		@rename($tmp, $fichier);
854
-
855
-		return $ret;
856
-	}
857
-
858
-	return false;
841
+    if (!function_exists('imagegif')) {
842
+        return false;
843
+    }
844
+    $tmp = $fichier . '.tmp';
845
+    $ret = imagegif($img, $tmp);
846
+    if (file_exists($tmp)) {
847
+        $taille_test = getimagesize($tmp);
848
+        if ($taille_test[0] < 1) {
849
+            return false;
850
+        }
851
+
852
+        spip_unlink($fichier); // le fichier peut deja exister
853
+        @rename($tmp, $fichier);
854
+
855
+        return $ret;
856
+    }
857
+
858
+    return false;
859 859
 }
860 860
 
861 861
 /**
@@ -878,29 +878,29 @@  discard block
 block discarded – undo
878 878
  *     - true si une image est bien retournée.
879 879
  */
880 880
 function _image_imagejpg($img, $fichier, $qualite = _IMG_GD_QUALITE) {
881
-	if (!function_exists('imagejpeg')) {
882
-		return false;
883
-	}
884
-	$tmp = $fichier . '.tmp';
881
+    if (!function_exists('imagejpeg')) {
882
+        return false;
883
+    }
884
+    $tmp = $fichier . '.tmp';
885 885
 
886
-	// Enable interlancing
887
-	imageinterlace($img, true);
886
+    // Enable interlancing
887
+    imageinterlace($img, true);
888 888
 
889
-	$ret = imagejpeg($img, $tmp, $qualite);
889
+    $ret = imagejpeg($img, $tmp, $qualite);
890 890
 
891
-	if (file_exists($tmp)) {
892
-		$taille_test = getimagesize($tmp);
893
-		if ($taille_test[0] < 1) {
894
-			return false;
895
-		}
891
+    if (file_exists($tmp)) {
892
+        $taille_test = getimagesize($tmp);
893
+        if ($taille_test[0] < 1) {
894
+            return false;
895
+        }
896 896
 
897
-		spip_unlink($fichier); // le fichier peut deja exister
898
-		@rename($tmp, $fichier);
897
+        spip_unlink($fichier); // le fichier peut deja exister
898
+        @rename($tmp, $fichier);
899 899
 
900
-		return $ret;
901
-	}
900
+        return $ret;
901
+    }
902 902
 
903
-	return false;
903
+    return false;
904 904
 }
905 905
 
906 906
 /**
@@ -918,9 +918,9 @@  discard block
 block discarded – undo
918 918
  *     true si le fichier a bien été créé ; false sinon.
919 919
  */
920 920
 function _image_imageico($img, $fichier) {
921
-	$gd_image_array = [$img];
921
+    $gd_image_array = [$img];
922 922
 
923
-	return ecrire_fichier($fichier, phpthumb_functions::GD2ICOstring($gd_image_array));
923
+    return ecrire_fichier($fichier, phpthumb_functions::GD2ICOstring($gd_image_array));
924 924
 }
925 925
 
926 926
 
@@ -939,24 +939,24 @@  discard block
 block discarded – undo
939 939
  *     - true si une image est bien retournée.
940 940
  */
941 941
 function _image_imagewebp($img, $fichier, $qualite = _IMG_GD_QUALITE) {
942
-	if (!function_exists('imagewebp')) {
943
-		return false;
944
-	}
945
-	$tmp = $fichier . '.tmp';
946
-	$ret = imagewebp($img, $tmp, $qualite);
947
-	if (file_exists($tmp)) {
948
-		$taille_test = getimagesize($tmp);
949
-		if ($taille_test[0] < 1) {
950
-			return false;
951
-		}
952
-
953
-		spip_unlink($fichier); // le fichier peut deja exister
954
-		@rename($tmp, $fichier);
955
-
956
-		return $ret;
957
-	}
958
-
959
-	return false;
942
+    if (!function_exists('imagewebp')) {
943
+        return false;
944
+    }
945
+    $tmp = $fichier . '.tmp';
946
+    $ret = imagewebp($img, $tmp, $qualite);
947
+    if (file_exists($tmp)) {
948
+        $taille_test = getimagesize($tmp);
949
+        if ($taille_test[0] < 1) {
950
+            return false;
951
+        }
952
+
953
+        spip_unlink($fichier); // le fichier peut deja exister
954
+        @rename($tmp, $fichier);
955
+
956
+        return $ret;
957
+    }
958
+
959
+    return false;
960 960
 }
961 961
 
962 962
 /**
@@ -976,35 +976,35 @@  discard block
 block discarded – undo
976 976
  */
977 977
 function _image_imagesvg($img, $fichier) {
978 978
 
979
-	$tmp = $fichier . '.tmp';
980
-	if (strpos($img, '<') === false) {
981
-		$img = supprimer_timestamp($img);
982
-		if (!file_exists($img)) {
983
-			return false;
984
-		}
985
-		@copy($img, $tmp);
986
-		if (filesize($tmp) == filesize($img)) {
987
-			spip_unlink($fichier); // le fichier peut deja exister
988
-			@rename($tmp, $fichier);
989
-			return true;
990
-		}
991
-		return false;
992
-	}
993
-
994
-	file_put_contents($tmp, $img);
995
-	if (file_exists($tmp)) {
996
-		$taille_test = spip_getimagesize($tmp);
997
-		if ($taille_test[0] < 1) {
998
-			return false;
999
-		}
1000
-
1001
-		spip_unlink($fichier); // le fichier peut deja exister
1002
-		@rename($tmp, $fichier);
1003
-
1004
-		return true;
1005
-	}
1006
-
1007
-	return false;
979
+    $tmp = $fichier . '.tmp';
980
+    if (strpos($img, '<') === false) {
981
+        $img = supprimer_timestamp($img);
982
+        if (!file_exists($img)) {
983
+            return false;
984
+        }
985
+        @copy($img, $tmp);
986
+        if (filesize($tmp) == filesize($img)) {
987
+            spip_unlink($fichier); // le fichier peut deja exister
988
+            @rename($tmp, $fichier);
989
+            return true;
990
+        }
991
+        return false;
992
+    }
993
+
994
+    file_put_contents($tmp, $img);
995
+    if (file_exists($tmp)) {
996
+        $taille_test = spip_getimagesize($tmp);
997
+        if ($taille_test[0] < 1) {
998
+            return false;
999
+        }
1000
+
1001
+        spip_unlink($fichier); // le fichier peut deja exister
1002
+        @rename($tmp, $fichier);
1003
+
1004
+        return true;
1005
+    }
1006
+
1007
+    return false;
1008 1008
 }
1009 1009
 
1010 1010
 
@@ -1032,31 +1032,31 @@  discard block
 block discarded – undo
1032 1032
  *     - false sinon.
1033 1033
  */
1034 1034
 function _image_gd_output($img, $valeurs, $qualite = _IMG_GD_QUALITE, $fonction = null) {
1035
-	if (is_null($fonction)) {
1036
-		$fonction = '_image_image' . $valeurs['format_dest'];
1037
-	}
1038
-	$ret = false;
1039
-	#un flag pour reperer les images gravees
1040
-	$lock = (
1041
-		!statut_effacer_images_temporaires('get') // si la fonction n'a pas ete activee, on grave tout
1042
-	    or
1043
-		(@file_exists($valeurs['fichier_dest']) and !@file_exists($valeurs['fichier_dest'] . '.src'))
1044
-		);
1045
-	if (
1046
-		function_exists($fonction)
1047
-		&& ($ret = $fonction($img, $valeurs['fichier_dest'], $qualite)) # on a reussi a creer l'image
1048
-		&& isset($valeurs['reconstruction']) # et on sait comment la resonctruire le cas echeant
1049
-		&& !$lock
1050
-	) {
1051
-		if (@file_exists($valeurs['fichier_dest'])) {
1052
-			// dans tous les cas mettre a jour la taille de l'image finale
1053
-			[$valeurs['hauteur_dest'], $valeurs['largeur_dest']] = taille_image($valeurs['fichier_dest']);
1054
-			$valeurs['date'] = @filemtime($valeurs['fichier_dest']); // pour la retrouver apres disparition
1055
-			ecrire_fichier($valeurs['fichier_dest'] . '.src', serialize($valeurs), true);
1056
-		}
1057
-	}
1058
-
1059
-	return $ret;
1035
+    if (is_null($fonction)) {
1036
+        $fonction = '_image_image' . $valeurs['format_dest'];
1037
+    }
1038
+    $ret = false;
1039
+    #un flag pour reperer les images gravees
1040
+    $lock = (
1041
+        !statut_effacer_images_temporaires('get') // si la fonction n'a pas ete activee, on grave tout
1042
+        or
1043
+        (@file_exists($valeurs['fichier_dest']) and !@file_exists($valeurs['fichier_dest'] . '.src'))
1044
+        );
1045
+    if (
1046
+        function_exists($fonction)
1047
+        && ($ret = $fonction($img, $valeurs['fichier_dest'], $qualite)) # on a reussi a creer l'image
1048
+        && isset($valeurs['reconstruction']) # et on sait comment la resonctruire le cas echeant
1049
+        && !$lock
1050
+    ) {
1051
+        if (@file_exists($valeurs['fichier_dest'])) {
1052
+            // dans tous les cas mettre a jour la taille de l'image finale
1053
+            [$valeurs['hauteur_dest'], $valeurs['largeur_dest']] = taille_image($valeurs['fichier_dest']);
1054
+            $valeurs['date'] = @filemtime($valeurs['fichier_dest']); // pour la retrouver apres disparition
1055
+            ecrire_fichier($valeurs['fichier_dest'] . '.src', serialize($valeurs), true);
1056
+        }
1057
+    }
1058
+
1059
+    return $ret;
1060 1060
 }
1061 1061
 
1062 1062
 /**
@@ -1069,27 +1069,27 @@  discard block
 block discarded – undo
1069 1069
  *     Chemin vers le fichier manquant
1070 1070
  **/
1071 1071
 function reconstruire_image_intermediaire($fichier_manquant) {
1072
-	$reconstruire = [];
1073
-	$fichier = $fichier_manquant;
1074
-	while (
1075
-		strpos($fichier, '://') === false
1076
-		and !@file_exists($fichier)
1077
-		and lire_fichier($src = "$fichier.src", $source)
1078
-		and $valeurs = unserialize($source)
1079
-		and ($fichier = $valeurs['fichier']) # l'origine est connue (on ne verifie pas son existence, qu'importe ...)
1080
-	) {
1081
-		spip_unlink($src); // si jamais on a un timeout pendant la reconstruction, elle se fera naturellement au hit suivant
1082
-		$reconstruire[] = $valeurs['reconstruction'];
1083
-	}
1084
-	while (count($reconstruire)) {
1085
-		$r = array_pop($reconstruire);
1086
-		$fonction = $r[0];
1087
-		$args = $r[1];
1088
-		$fonction(...$args);
1089
-	}
1090
-	// cette image intermediaire est commune a plusieurs series de filtre, il faut la conserver
1091
-	// mais l'on peut nettoyer les miettes de sa creation
1092
-	ramasse_miettes($fichier_manquant);
1072
+    $reconstruire = [];
1073
+    $fichier = $fichier_manquant;
1074
+    while (
1075
+        strpos($fichier, '://') === false
1076
+        and !@file_exists($fichier)
1077
+        and lire_fichier($src = "$fichier.src", $source)
1078
+        and $valeurs = unserialize($source)
1079
+        and ($fichier = $valeurs['fichier']) # l'origine est connue (on ne verifie pas son existence, qu'importe ...)
1080
+    ) {
1081
+        spip_unlink($src); // si jamais on a un timeout pendant la reconstruction, elle se fera naturellement au hit suivant
1082
+        $reconstruire[] = $valeurs['reconstruction'];
1083
+    }
1084
+    while (count($reconstruire)) {
1085
+        $r = array_pop($reconstruire);
1086
+        $fonction = $r[0];
1087
+        $args = $r[1];
1088
+        $fonction(...$args);
1089
+    }
1090
+    // cette image intermediaire est commune a plusieurs series de filtre, il faut la conserver
1091
+    // mais l'on peut nettoyer les miettes de sa creation
1092
+    ramasse_miettes($fichier_manquant);
1093 1093
 }
1094 1094
 
1095 1095
 /**
@@ -1109,28 +1109,28 @@  discard block
 block discarded – undo
1109 1109
  *     Chemin du fichier d'image calculé
1110 1110
  **/
1111 1111
 function ramasse_miettes($fichier) {
1112
-	if (
1113
-		strpos($fichier, '://') !== false
1114
-		or !lire_fichier($src = "$fichier.src", $source)
1115
-		or !$valeurs = unserialize($source)
1116
-	) {
1117
-		return;
1118
-	}
1119
-	spip_unlink($src); # on supprime la reference a sa source pour marquer cette image comme non intermediaire
1120
-	while (
1121
-		($fichier = $valeurs['fichier']) # l'origine est connue (on ne verifie pas son existence, qu'importe ...)
1122
-		and (substr($fichier, 0, strlen(_DIR_VAR)) == _DIR_VAR) # et est dans local
1123
-		and (lire_fichier(
1124
-			$src = "$fichier.src",
1125
-			$source
1126
-		)) # le fichier a une source connue (c'est donc une image calculee intermediaire)
1127
-		and ($valeurs = unserialize($source))  # et valide
1128
-	) {
1129
-		# on efface le fichier
1130
-		spip_unlink($fichier);
1131
-		# mais laisse le .src qui permet de savoir comment reconstruire l'image si besoin
1132
-		#spip_unlink($src);
1133
-	}
1112
+    if (
1113
+        strpos($fichier, '://') !== false
1114
+        or !lire_fichier($src = "$fichier.src", $source)
1115
+        or !$valeurs = unserialize($source)
1116
+    ) {
1117
+        return;
1118
+    }
1119
+    spip_unlink($src); # on supprime la reference a sa source pour marquer cette image comme non intermediaire
1120
+    while (
1121
+        ($fichier = $valeurs['fichier']) # l'origine est connue (on ne verifie pas son existence, qu'importe ...)
1122
+        and (substr($fichier, 0, strlen(_DIR_VAR)) == _DIR_VAR) # et est dans local
1123
+        and (lire_fichier(
1124
+            $src = "$fichier.src",
1125
+            $source
1126
+        )) # le fichier a une source connue (c'est donc une image calculee intermediaire)
1127
+        and ($valeurs = unserialize($source))  # et valide
1128
+    ) {
1129
+        # on efface le fichier
1130
+        spip_unlink($fichier);
1131
+        # mais laisse le .src qui permet de savoir comment reconstruire l'image si besoin
1132
+        #spip_unlink($src);
1133
+    }
1134 1134
 }
1135 1135
 
1136 1136
 
@@ -1155,31 +1155,31 @@  discard block
 block discarded – undo
1155 1155
  *     Code HTML de l'image
1156 1156
  **/
1157 1157
 function image_graver($img) {
1158
-	// appeler le filtre post_image_filtrer qui permet de faire
1159
-	// des traitements auto a la fin d'une serie de filtres
1160
-	$img = pipeline('post_image_filtrer', $img);
1161
-
1162
-	$fichier_ori = $fichier = extraire_attribut($img, 'src');
1163
-	if (($p = strpos($fichier, '?')) !== false) {
1164
-		$fichier = substr($fichier, 0, $p);
1165
-	}
1166
-	if (strlen($fichier) < 1) {
1167
-		$fichier = $img;
1168
-	}
1169
-	# si jamais le fichier final n'a pas ete calcule car suppose temporaire
1170
-	# et qu'il ne s'agit pas d'une URL
1171
-	if (strpos($fichier, '://') === false and !@file_exists($fichier)) {
1172
-		reconstruire_image_intermediaire($fichier);
1173
-	}
1174
-	ramasse_miettes($fichier);
1175
-
1176
-	// ajouter le timestamp si besoin
1177
-	if (strpos($fichier_ori, '?') === false) {
1178
-		// on utilise str_replace pour attraper le onmouseover des logo si besoin
1179
-		$img = str_replace($fichier_ori, timestamp($fichier_ori), $img);
1180
-	}
1181
-
1182
-	return $img;
1158
+    // appeler le filtre post_image_filtrer qui permet de faire
1159
+    // des traitements auto a la fin d'une serie de filtres
1160
+    $img = pipeline('post_image_filtrer', $img);
1161
+
1162
+    $fichier_ori = $fichier = extraire_attribut($img, 'src');
1163
+    if (($p = strpos($fichier, '?')) !== false) {
1164
+        $fichier = substr($fichier, 0, $p);
1165
+    }
1166
+    if (strlen($fichier) < 1) {
1167
+        $fichier = $img;
1168
+    }
1169
+    # si jamais le fichier final n'a pas ete calcule car suppose temporaire
1170
+    # et qu'il ne s'agit pas d'une URL
1171
+    if (strpos($fichier, '://') === false and !@file_exists($fichier)) {
1172
+        reconstruire_image_intermediaire($fichier);
1173
+    }
1174
+    ramasse_miettes($fichier);
1175
+
1176
+    // ajouter le timestamp si besoin
1177
+    if (strpos($fichier_ori, '?') === false) {
1178
+        // on utilise str_replace pour attraper le onmouseover des logo si besoin
1179
+        $img = str_replace($fichier_ori, timestamp($fichier_ori), $img);
1180
+    }
1181
+
1182
+    return $img;
1183 1183
 }
1184 1184
 
1185 1185
 /**
@@ -1206,34 +1206,34 @@  discard block
 block discarded – undo
1206 1206
  *     Code html modifié de la balise.
1207 1207
  **/
1208 1208
 function _image_tag_changer_taille($tag, $width, $height, $style = false) {
1209
-	if ($style === false) {
1210
-		$style = extraire_attribut($tag, 'style');
1211
-	}
1212
-
1213
-	// enlever le width et height du style
1214
-	if ($style) {
1215
-		$style = preg_replace(',(^|;)\s*(width|height)\s*:\s*[^;]+,ims', '', $style);
1216
-	}
1217
-	if ($style and $style[0] === ';') {
1218
-		$style = substr($style, 1);
1219
-	}
1220
-
1221
-	// mettre des attributs de width et height sur les images,
1222
-	// ca accelere le rendu du navigateur
1223
-	// ca permet aux navigateurs de reserver la bonne taille
1224
-	// quand on a desactive l'affichage des images.
1225
-	$tag = inserer_attribut($tag, 'width', round($width));
1226
-	$tag = inserer_attribut($tag, 'height', round($height));
1227
-
1228
-	// attributs deprecies. Transformer en CSS
1229
-	if ($espace = extraire_attribut($tag, 'hspace')) {
1230
-		$style = "margin:${espace}px;" . $style;
1231
-		$tag = inserer_attribut($tag, 'hspace', '');
1232
-	}
1233
-
1234
-	$tag = inserer_attribut($tag, 'style', (string) $style, true, $style ? false : true);
1235
-
1236
-	return $tag;
1209
+    if ($style === false) {
1210
+        $style = extraire_attribut($tag, 'style');
1211
+    }
1212
+
1213
+    // enlever le width et height du style
1214
+    if ($style) {
1215
+        $style = preg_replace(',(^|;)\s*(width|height)\s*:\s*[^;]+,ims', '', $style);
1216
+    }
1217
+    if ($style and $style[0] === ';') {
1218
+        $style = substr($style, 1);
1219
+    }
1220
+
1221
+    // mettre des attributs de width et height sur les images,
1222
+    // ca accelere le rendu du navigateur
1223
+    // ca permet aux navigateurs de reserver la bonne taille
1224
+    // quand on a desactive l'affichage des images.
1225
+    $tag = inserer_attribut($tag, 'width', round($width));
1226
+    $tag = inserer_attribut($tag, 'height', round($height));
1227
+
1228
+    // attributs deprecies. Transformer en CSS
1229
+    if ($espace = extraire_attribut($tag, 'hspace')) {
1230
+        $style = "margin:${espace}px;" . $style;
1231
+        $tag = inserer_attribut($tag, 'hspace', '');
1232
+    }
1233
+
1234
+    $tag = inserer_attribut($tag, 'style', (string) $style, true, $style ? false : true);
1235
+
1236
+    return $tag;
1237 1237
 }
1238 1238
 
1239 1239
 
@@ -1259,72 +1259,72 @@  discard block
 block discarded – undo
1259 1259
  *     Retourne le code HTML de l'image
1260 1260
  **/
1261 1261
 function _image_ecrire_tag($valeurs, $surcharge = []) {
1262
-	$valeurs = pipeline('image_ecrire_tag_preparer', $valeurs);
1263
-
1264
-	// fermer les tags img pas bien fermes;
1265
-	$tag = str_replace('>', '/>', str_replace('/>', '>', $valeurs['tag']));
1266
-
1267
-	// le style
1268
-	$style = $valeurs['style'];
1269
-	if (isset($surcharge['style'])) {
1270
-		$style = $surcharge['style'];
1271
-		unset($surcharge['style']);
1272
-	}
1273
-
1274
-	// traiter specifiquement la largeur et la hauteur
1275
-	$width = $valeurs['largeur'];
1276
-	if (isset($surcharge['width'])) {
1277
-		$width = $surcharge['width'];
1278
-		unset($surcharge['width']);
1279
-	}
1280
-	$height = $valeurs['hauteur'];
1281
-	if (isset($surcharge['height'])) {
1282
-		$height = $surcharge['height'];
1283
-		unset($surcharge['height']);
1284
-	}
1285
-
1286
-	$tag = _image_tag_changer_taille($tag, $width, $height, $style);
1287
-	// traiter specifiquement le src qui peut etre repris dans un onmouseout
1288
-	// on remplace toute les ref a src dans le tag
1289
-	$src = extraire_attribut($tag, 'src');
1290
-	if (isset($surcharge['src'])) {
1291
-		$tag = str_replace($src, $surcharge['src'], $tag);
1292
-		// si il y a des & dans src, alors ils peuvent provenir d'un &amp
1293
-		// pas garanti comme methode, mais mieux que rien
1294
-		if (strpos($src, '&') !== false) {
1295
-			$tag = str_replace(str_replace('&', '&amp;', $src), $surcharge['src'], $tag);
1296
-		}
1297
-		$src = $surcharge['src'];
1298
-		unset($surcharge['src']);
1299
-	}
1300
-
1301
-	$class = $valeurs['class'];
1302
-	if (isset($surcharge['class'])) {
1303
-		$class = $surcharge['class'];
1304
-		unset($surcharge['class']);
1305
-	}
1306
-	if (is_scalar($class) && strlen($class)) {
1307
-		$tag = inserer_attribut($tag, 'class', $class);
1308
-	}
1309
-
1310
-	if (count($surcharge)) {
1311
-		foreach ($surcharge as $attribut => $valeur) {
1312
-			$tag = inserer_attribut($tag, $attribut, $valeur);
1313
-		}
1314
-	}
1315
-
1316
-	$tag = pipeline(
1317
-		'image_ecrire_tag_finir',
1318
-		[
1319
-			'args' => [
1320
-				'valeurs' => $valeurs,
1321
-				'surcharge' => $surcharge,
1322
-			],
1323
-			'data' => $tag
1324
-		]
1325
-	);
1326
-
1327
-	return $tag;
1262
+    $valeurs = pipeline('image_ecrire_tag_preparer', $valeurs);
1263
+
1264
+    // fermer les tags img pas bien fermes;
1265
+    $tag = str_replace('>', '/>', str_replace('/>', '>', $valeurs['tag']));
1266
+
1267
+    // le style
1268
+    $style = $valeurs['style'];
1269
+    if (isset($surcharge['style'])) {
1270
+        $style = $surcharge['style'];
1271
+        unset($surcharge['style']);
1272
+    }
1273
+
1274
+    // traiter specifiquement la largeur et la hauteur
1275
+    $width = $valeurs['largeur'];
1276
+    if (isset($surcharge['width'])) {
1277
+        $width = $surcharge['width'];
1278
+        unset($surcharge['width']);
1279
+    }
1280
+    $height = $valeurs['hauteur'];
1281
+    if (isset($surcharge['height'])) {
1282
+        $height = $surcharge['height'];
1283
+        unset($surcharge['height']);
1284
+    }
1285
+
1286
+    $tag = _image_tag_changer_taille($tag, $width, $height, $style);
1287
+    // traiter specifiquement le src qui peut etre repris dans un onmouseout
1288
+    // on remplace toute les ref a src dans le tag
1289
+    $src = extraire_attribut($tag, 'src');
1290
+    if (isset($surcharge['src'])) {
1291
+        $tag = str_replace($src, $surcharge['src'], $tag);
1292
+        // si il y a des & dans src, alors ils peuvent provenir d'un &amp
1293
+        // pas garanti comme methode, mais mieux que rien
1294
+        if (strpos($src, '&') !== false) {
1295
+            $tag = str_replace(str_replace('&', '&amp;', $src), $surcharge['src'], $tag);
1296
+        }
1297
+        $src = $surcharge['src'];
1298
+        unset($surcharge['src']);
1299
+    }
1300
+
1301
+    $class = $valeurs['class'];
1302
+    if (isset($surcharge['class'])) {
1303
+        $class = $surcharge['class'];
1304
+        unset($surcharge['class']);
1305
+    }
1306
+    if (is_scalar($class) && strlen($class)) {
1307
+        $tag = inserer_attribut($tag, 'class', $class);
1308
+    }
1309
+
1310
+    if (count($surcharge)) {
1311
+        foreach ($surcharge as $attribut => $valeur) {
1312
+            $tag = inserer_attribut($tag, $attribut, $valeur);
1313
+        }
1314
+    }
1315
+
1316
+    $tag = pipeline(
1317
+        'image_ecrire_tag_finir',
1318
+        [
1319
+            'args' => [
1320
+                'valeurs' => $valeurs,
1321
+                'surcharge' => $surcharge,
1322
+            ],
1323
+            'data' => $tag
1324
+        ]
1325
+    );
1326
+
1327
+    return $tag;
1328 1328
 }
1329 1329
 
1330 1330
 /**
@@ -1347,268 +1347,268 @@  discard block
 block discarded – undo
1347 1347
  *     Description de l'image, sinon null.
1348 1348
  **/
1349 1349
 function _image_creer_vignette($valeurs, $maxWidth, $maxHeight, $process = 'AUTO', $force = false) {
1350
-	$srcHeight = null;
1351
-	$retour = [];
1352
-	// ordre de preference des formats graphiques pour creer les vignettes
1353
-	// le premier format disponible, selon la methode demandee, est utilise
1354
-	$image = $valeurs['fichier'];
1355
-	$format = $valeurs['format_source'];
1356
-	$destdir = dirname($valeurs['fichier_dest']);
1357
-	$destfile = basename($valeurs['fichier_dest'], '.' . $valeurs['format_dest']);
1358
-
1359
-	$format_sortie = $valeurs['format_dest'];
1360
-
1361
-	if (($process == 'AUTO') and isset($GLOBALS['meta']['image_process'])) {
1362
-		$process = $GLOBALS['meta']['image_process'];
1363
-	}
1364
-
1365
-	// si le doc n'est pas une image dans un format accetpable, refuser
1366
-	if (!$force and !in_array($format, formats_image_acceptables(in_array($process, ['gd1', 'gd2'])))) {
1367
-		return;
1368
-	}
1369
-	$destination = "$destdir/$destfile";
1370
-
1371
-	// calculer la taille
1372
-	if (($srcWidth = $valeurs['largeur']) && ($srcHeight = $valeurs['hauteur'])) {
1373
-		if (!($destWidth = $valeurs['largeur_dest']) || !($destHeight = $valeurs['hauteur_dest'])) {
1374
-			[$destWidth, $destHeight] = _image_ratio($srcWidth, $srcHeight, $maxWidth, $maxHeight);
1375
-		}
1376
-	} elseif ($process == 'convert' or $process == 'imagick') {
1377
-		$destWidth = $maxWidth;
1378
-		$destHeight = $maxHeight;
1379
-	} else {
1380
-		spip_log("echec $process sur $image");
1381
-
1382
-		return;
1383
-	}
1384
-
1385
-	$vignette = '';
1386
-
1387
-	// Si l'image est de la taille demandee (ou plus petite), simplement la retourner
1388
-	if ($srcWidth and $srcWidth <= $maxWidth and $srcHeight <= $maxHeight) {
1389
-		$vignette = $destination . '.' . $format;
1390
-		@copy($image, $vignette);
1391
-	}
1392
-
1393
-	elseif ($valeurs['format_source'] === 'svg') {
1394
-		if ($svg = svg_redimensionner($valeurs['fichier'], $destWidth, $destHeight)) {
1395
-			$format_sortie = 'svg';
1396
-			$vignette = $destination . '.' . $format_sortie;
1397
-			$valeurs['fichier_dest'] = $vignette;
1398
-			_image_gd_output($svg, $valeurs);
1399
-		}
1400
-	}
1401
-
1402
-	// imagemagick en ligne de commande
1403
-	elseif ($process == 'convert') {
1404
-		if (!defined('_CONVERT_COMMAND')) {
1405
-			define('_CONVERT_COMMAND', 'convert');
1406
-		} // Securite : mes_options.php peut preciser le chemin absolu
1407
-		if (!defined('_RESIZE_COMMAND')) {
1408
-			define('_RESIZE_COMMAND', _CONVERT_COMMAND . ' -quality ' . _IMG_CONVERT_QUALITE . ' -resize %xx%y! %src %dest');
1409
-		}
1410
-		$vignette = $destination . '.' . $format_sortie;
1411
-		$commande = str_replace(
1412
-			['%x', '%y', '%src', '%dest'],
1413
-			[
1414
-				$destWidth,
1415
-				$destHeight,
1416
-				escapeshellcmd($image),
1417
-				escapeshellcmd($vignette)
1418
-			],
1419
-			_RESIZE_COMMAND
1420
-		);
1421
-		spip_log($commande);
1422
-		exec($commande);
1423
-		if (!@file_exists($vignette)) {
1424
-			spip_log("echec convert sur $vignette");
1425
-
1426
-			return;  // echec commande
1427
-		}
1428
-	}
1429
-
1430
-	// php5 imagemagick
1431
-	elseif ($process == 'imagick') {
1432
-
1433
-		if (!class_exists(\Imagick::class)) {
1434
-			spip_log('Classe Imagick absente !', _LOG_ERREUR);
1435
-
1436
-			return;
1437
-		}
1438
-
1439
-		// chemin compatible Windows
1440
-		$output = realpath(dirname($destination));
1441
-		if (!$output) {
1442
-			return;
1443
-		}
1444
-		$vignette = $output . DIRECTORY_SEPARATOR . basename($destination) . '.' . $format_sortie;
1445
-
1446
-		$imagick = new Imagick();
1447
-		$imagick->readImage(realpath($image));
1448
-		$imagick->resizeImage(
1449
-			$destWidth,
1450
-			$destHeight,
1451
-			Imagick::FILTER_LANCZOS,
1452
-			1
1453
-		);//, IMAGICK_FILTER_LANCZOS, _IMG_IMAGICK_QUALITE / 100);
1454
-		$imagick->writeImage($vignette);
1455
-
1456
-		if (!@file_exists($vignette)) {
1457
-			spip_log("echec imagick sur $vignette");
1458
-
1459
-			return;
1460
-		}
1461
-		// remettre le chemin relatif car c'est ce qu'attend SPIP pour la suite (en particlier action/tester)
1462
-		$vignette = $destination . '.' . $format_sortie;
1463
-	}
1464
-
1465
-	// netpbm
1466
-	elseif ($process == 'netpbm') {
1467
-		if (!defined('_PNMSCALE_COMMAND')) {
1468
-			define('_PNMSCALE_COMMAND', 'pnmscale');
1469
-		} // Securite : mes_options.php peut preciser le chemin absolu
1470
-		if (_PNMSCALE_COMMAND == '') {
1471
-			return;
1472
-		}
1473
-		$vignette = $destination . '.' . $format_sortie;
1474
-		$pnmtojpeg_command = str_replace('pnmscale', 'pnmtojpeg', _PNMSCALE_COMMAND);
1475
-		if ($format == 'jpg') {
1476
-			$jpegtopnm_command = str_replace('pnmscale', 'jpegtopnm', _PNMSCALE_COMMAND);
1477
-			exec("$jpegtopnm_command $image | " . _PNMSCALE_COMMAND . " -width $destWidth | $pnmtojpeg_command > $vignette");
1478
-			if (!($s = @filesize($vignette))) {
1479
-				spip_unlink($vignette);
1480
-			}
1481
-			if (!@file_exists($vignette)) {
1482
-				spip_log("echec netpbm-jpg sur $vignette");
1483
-
1484
-				return;
1485
-			}
1486
-		} else {
1487
-			if ($format == 'gif') {
1488
-				$giftopnm_command = str_replace('pnmscale', 'giftopnm', _PNMSCALE_COMMAND);
1489
-				exec("$giftopnm_command $image | " . _PNMSCALE_COMMAND . " -width $destWidth | $pnmtojpeg_command > $vignette");
1490
-				if (!($s = @filesize($vignette))) {
1491
-					spip_unlink($vignette);
1492
-				}
1493
-				if (!@file_exists($vignette)) {
1494
-					spip_log("echec netpbm-gif sur $vignette");
1495
-
1496
-					return;
1497
-				}
1498
-			} else {
1499
-				if ($format == 'png') {
1500
-					$pngtopnm_command = str_replace('pnmscale', 'pngtopnm', _PNMSCALE_COMMAND);
1501
-					exec("$pngtopnm_command $image | " . _PNMSCALE_COMMAND . " -width $destWidth | $pnmtojpeg_command > $vignette");
1502
-					if (!($s = @filesize($vignette))) {
1503
-						spip_unlink($vignette);
1504
-					}
1505
-					if (!@file_exists($vignette)) {
1506
-						spip_log("echec netpbm-png sur $vignette");
1507
-
1508
-						return;
1509
-					}
1510
-				}
1511
-			}
1512
-		}
1513
-	}
1514
-
1515
-	// gd ou gd2
1516
-	elseif ($process == 'gd1' or $process == 'gd2') {
1517
-		if (!function_exists('gd_info')) {
1518
-			spip_log('Librairie GD absente !', _LOG_ERREUR);
1519
-
1520
-			return;
1521
-		}
1522
-		if (_IMG_GD_MAX_PIXELS && $srcWidth * $srcHeight > _IMG_GD_MAX_PIXELS) {
1523
-			spip_log('vignette gd1/gd2 impossible : ' . $srcWidth * $srcHeight . 'pixels');
1524
-
1525
-			return;
1526
-		}
1527
-		$destFormat = $format_sortie;
1528
-		if (!$destFormat) {
1529
-			spip_log("pas de format pour $image");
1530
-
1531
-			return;
1532
-		}
1533
-
1534
-		$fonction_imagecreatefrom = $valeurs['fonction_imagecreatefrom'];
1535
-		if (!function_exists($fonction_imagecreatefrom)) {
1536
-			return;
1537
-		}
1538
-		$srcImage = @$fonction_imagecreatefrom($image);
1539
-		if (!$srcImage) {
1540
-			spip_log('echec gd1/gd2');
1541
-
1542
-			return;
1543
-		}
1544
-
1545
-		// Initialisation de l'image destination
1546
-		$destImage = null;
1547
-		if ($process == 'gd2' and $destFormat != 'gif') {
1548
-			$destImage = ImageCreateTrueColor($destWidth, $destHeight);
1549
-		}
1550
-		if (!$destImage) {
1551
-			$destImage = ImageCreate($destWidth, $destHeight);
1552
-		}
1553
-
1554
-		// Recopie de l'image d'origine avec adaptation de la taille
1555
-		$ok = false;
1556
-		if (($process == 'gd2') and function_exists('ImageCopyResampled')) {
1557
-			if ($format == 'gif') {
1558
-				// Si un GIF est transparent,
1559
-				// fabriquer un PNG transparent
1560
-				$transp = imagecolortransparent($srcImage);
1561
-				if ($transp > 0) {
1562
-					$destFormat = 'png';
1563
-				}
1564
-			}
1565
-			if (in_array($destFormat, _image_extensions_conservent_transparence())) {
1566
-				// Conserver la transparence
1567
-				if (function_exists('imageAntiAlias')) {
1568
-					imageAntiAlias($destImage, true);
1569
-				}
1570
-				@imagealphablending($destImage, false);
1571
-				@imagesavealpha($destImage, true);
1572
-			}
1573
-			$ok = @ImageCopyResampled($destImage, $srcImage, 0, 0, 0, 0, $destWidth, $destHeight, $srcWidth, $srcHeight);
1574
-		}
1575
-		if (!$ok) {
1576
-			$ok = ImageCopyResized($destImage, $srcImage, 0, 0, 0, 0, $destWidth, $destHeight, $srcWidth, $srcHeight);
1577
-		}
1578
-
1579
-		// Sauvegarde de l'image destination
1580
-		$valeurs['fichier_dest'] = $vignette = "$destination.$destFormat";
1581
-		$valeurs['format_dest'] = $format = $destFormat;
1582
-		_image_gd_output($destImage, $valeurs);
1583
-
1584
-		if ($srcImage) {
1585
-			ImageDestroy($srcImage);
1586
-		}
1587
-		ImageDestroy($destImage);
1588
-	}
1589
-
1590
-	if (!$vignette or !$size = @spip_getimagesize($vignette)) {
1591
-		$size = [$destWidth, $destHeight];
1592
-	}
1593
-
1594
-	// Gaffe: en safe mode, pas d'acces a la vignette,
1595
-	// donc risque de balancer "width='0'", ce qui masque l'image sous MSIE
1596
-	if ($size[0] < 1) {
1597
-		$size[0] = $destWidth;
1598
-	}
1599
-	if ($size[1] < 1) {
1600
-		$size[1] = $destHeight;
1601
-	}
1602
-
1603
-	$retour['width'] = $largeur = $size[0];
1604
-	$retour['height'] = $hauteur = $size[1];
1605
-
1606
-	$retour['fichier'] = $vignette;
1607
-	$retour['format'] = $format;
1608
-	$retour['date'] = @filemtime($vignette);
1609
-
1610
-	// renvoyer l'image
1611
-	return $retour;
1350
+    $srcHeight = null;
1351
+    $retour = [];
1352
+    // ordre de preference des formats graphiques pour creer les vignettes
1353
+    // le premier format disponible, selon la methode demandee, est utilise
1354
+    $image = $valeurs['fichier'];
1355
+    $format = $valeurs['format_source'];
1356
+    $destdir = dirname($valeurs['fichier_dest']);
1357
+    $destfile = basename($valeurs['fichier_dest'], '.' . $valeurs['format_dest']);
1358
+
1359
+    $format_sortie = $valeurs['format_dest'];
1360
+
1361
+    if (($process == 'AUTO') and isset($GLOBALS['meta']['image_process'])) {
1362
+        $process = $GLOBALS['meta']['image_process'];
1363
+    }
1364
+
1365
+    // si le doc n'est pas une image dans un format accetpable, refuser
1366
+    if (!$force and !in_array($format, formats_image_acceptables(in_array($process, ['gd1', 'gd2'])))) {
1367
+        return;
1368
+    }
1369
+    $destination = "$destdir/$destfile";
1370
+
1371
+    // calculer la taille
1372
+    if (($srcWidth = $valeurs['largeur']) && ($srcHeight = $valeurs['hauteur'])) {
1373
+        if (!($destWidth = $valeurs['largeur_dest']) || !($destHeight = $valeurs['hauteur_dest'])) {
1374
+            [$destWidth, $destHeight] = _image_ratio($srcWidth, $srcHeight, $maxWidth, $maxHeight);
1375
+        }
1376
+    } elseif ($process == 'convert' or $process == 'imagick') {
1377
+        $destWidth = $maxWidth;
1378
+        $destHeight = $maxHeight;
1379
+    } else {
1380
+        spip_log("echec $process sur $image");
1381
+
1382
+        return;
1383
+    }
1384
+
1385
+    $vignette = '';
1386
+
1387
+    // Si l'image est de la taille demandee (ou plus petite), simplement la retourner
1388
+    if ($srcWidth and $srcWidth <= $maxWidth and $srcHeight <= $maxHeight) {
1389
+        $vignette = $destination . '.' . $format;
1390
+        @copy($image, $vignette);
1391
+    }
1392
+
1393
+    elseif ($valeurs['format_source'] === 'svg') {
1394
+        if ($svg = svg_redimensionner($valeurs['fichier'], $destWidth, $destHeight)) {
1395
+            $format_sortie = 'svg';
1396
+            $vignette = $destination . '.' . $format_sortie;
1397
+            $valeurs['fichier_dest'] = $vignette;
1398
+            _image_gd_output($svg, $valeurs);
1399
+        }
1400
+    }
1401
+
1402
+    // imagemagick en ligne de commande
1403
+    elseif ($process == 'convert') {
1404
+        if (!defined('_CONVERT_COMMAND')) {
1405
+            define('_CONVERT_COMMAND', 'convert');
1406
+        } // Securite : mes_options.php peut preciser le chemin absolu
1407
+        if (!defined('_RESIZE_COMMAND')) {
1408
+            define('_RESIZE_COMMAND', _CONVERT_COMMAND . ' -quality ' . _IMG_CONVERT_QUALITE . ' -resize %xx%y! %src %dest');
1409
+        }
1410
+        $vignette = $destination . '.' . $format_sortie;
1411
+        $commande = str_replace(
1412
+            ['%x', '%y', '%src', '%dest'],
1413
+            [
1414
+                $destWidth,
1415
+                $destHeight,
1416
+                escapeshellcmd($image),
1417
+                escapeshellcmd($vignette)
1418
+            ],
1419
+            _RESIZE_COMMAND
1420
+        );
1421
+        spip_log($commande);
1422
+        exec($commande);
1423
+        if (!@file_exists($vignette)) {
1424
+            spip_log("echec convert sur $vignette");
1425
+
1426
+            return;  // echec commande
1427
+        }
1428
+    }
1429
+
1430
+    // php5 imagemagick
1431
+    elseif ($process == 'imagick') {
1432
+
1433
+        if (!class_exists(\Imagick::class)) {
1434
+            spip_log('Classe Imagick absente !', _LOG_ERREUR);
1435
+
1436
+            return;
1437
+        }
1438
+
1439
+        // chemin compatible Windows
1440
+        $output = realpath(dirname($destination));
1441
+        if (!$output) {
1442
+            return;
1443
+        }
1444
+        $vignette = $output . DIRECTORY_SEPARATOR . basename($destination) . '.' . $format_sortie;
1445
+
1446
+        $imagick = new Imagick();
1447
+        $imagick->readImage(realpath($image));
1448
+        $imagick->resizeImage(
1449
+            $destWidth,
1450
+            $destHeight,
1451
+            Imagick::FILTER_LANCZOS,
1452
+            1
1453
+        );//, IMAGICK_FILTER_LANCZOS, _IMG_IMAGICK_QUALITE / 100);
1454
+        $imagick->writeImage($vignette);
1455
+
1456
+        if (!@file_exists($vignette)) {
1457
+            spip_log("echec imagick sur $vignette");
1458
+
1459
+            return;
1460
+        }
1461
+        // remettre le chemin relatif car c'est ce qu'attend SPIP pour la suite (en particlier action/tester)
1462
+        $vignette = $destination . '.' . $format_sortie;
1463
+    }
1464
+
1465
+    // netpbm
1466
+    elseif ($process == 'netpbm') {
1467
+        if (!defined('_PNMSCALE_COMMAND')) {
1468
+            define('_PNMSCALE_COMMAND', 'pnmscale');
1469
+        } // Securite : mes_options.php peut preciser le chemin absolu
1470
+        if (_PNMSCALE_COMMAND == '') {
1471
+            return;
1472
+        }
1473
+        $vignette = $destination . '.' . $format_sortie;
1474
+        $pnmtojpeg_command = str_replace('pnmscale', 'pnmtojpeg', _PNMSCALE_COMMAND);
1475
+        if ($format == 'jpg') {
1476
+            $jpegtopnm_command = str_replace('pnmscale', 'jpegtopnm', _PNMSCALE_COMMAND);
1477
+            exec("$jpegtopnm_command $image | " . _PNMSCALE_COMMAND . " -width $destWidth | $pnmtojpeg_command > $vignette");
1478
+            if (!($s = @filesize($vignette))) {
1479
+                spip_unlink($vignette);
1480
+            }
1481
+            if (!@file_exists($vignette)) {
1482
+                spip_log("echec netpbm-jpg sur $vignette");
1483
+
1484
+                return;
1485
+            }
1486
+        } else {
1487
+            if ($format == 'gif') {
1488
+                $giftopnm_command = str_replace('pnmscale', 'giftopnm', _PNMSCALE_COMMAND);
1489
+                exec("$giftopnm_command $image | " . _PNMSCALE_COMMAND . " -width $destWidth | $pnmtojpeg_command > $vignette");
1490
+                if (!($s = @filesize($vignette))) {
1491
+                    spip_unlink($vignette);
1492
+                }
1493
+                if (!@file_exists($vignette)) {
1494
+                    spip_log("echec netpbm-gif sur $vignette");
1495
+
1496
+                    return;
1497
+                }
1498
+            } else {
1499
+                if ($format == 'png') {
1500
+                    $pngtopnm_command = str_replace('pnmscale', 'pngtopnm', _PNMSCALE_COMMAND);
1501
+                    exec("$pngtopnm_command $image | " . _PNMSCALE_COMMAND . " -width $destWidth | $pnmtojpeg_command > $vignette");
1502
+                    if (!($s = @filesize($vignette))) {
1503
+                        spip_unlink($vignette);
1504
+                    }
1505
+                    if (!@file_exists($vignette)) {
1506
+                        spip_log("echec netpbm-png sur $vignette");
1507
+
1508
+                        return;
1509
+                    }
1510
+                }
1511
+            }
1512
+        }
1513
+    }
1514
+
1515
+    // gd ou gd2
1516
+    elseif ($process == 'gd1' or $process == 'gd2') {
1517
+        if (!function_exists('gd_info')) {
1518
+            spip_log('Librairie GD absente !', _LOG_ERREUR);
1519
+
1520
+            return;
1521
+        }
1522
+        if (_IMG_GD_MAX_PIXELS && $srcWidth * $srcHeight > _IMG_GD_MAX_PIXELS) {
1523
+            spip_log('vignette gd1/gd2 impossible : ' . $srcWidth * $srcHeight . 'pixels');
1524
+
1525
+            return;
1526
+        }
1527
+        $destFormat = $format_sortie;
1528
+        if (!$destFormat) {
1529
+            spip_log("pas de format pour $image");
1530
+
1531
+            return;
1532
+        }
1533
+
1534
+        $fonction_imagecreatefrom = $valeurs['fonction_imagecreatefrom'];
1535
+        if (!function_exists($fonction_imagecreatefrom)) {
1536
+            return;
1537
+        }
1538
+        $srcImage = @$fonction_imagecreatefrom($image);
1539
+        if (!$srcImage) {
1540
+            spip_log('echec gd1/gd2');
1541
+
1542
+            return;
1543
+        }
1544
+
1545
+        // Initialisation de l'image destination
1546
+        $destImage = null;
1547
+        if ($process == 'gd2' and $destFormat != 'gif') {
1548
+            $destImage = ImageCreateTrueColor($destWidth, $destHeight);
1549
+        }
1550
+        if (!$destImage) {
1551
+            $destImage = ImageCreate($destWidth, $destHeight);
1552
+        }
1553
+
1554
+        // Recopie de l'image d'origine avec adaptation de la taille
1555
+        $ok = false;
1556
+        if (($process == 'gd2') and function_exists('ImageCopyResampled')) {
1557
+            if ($format == 'gif') {
1558
+                // Si un GIF est transparent,
1559
+                // fabriquer un PNG transparent
1560
+                $transp = imagecolortransparent($srcImage);
1561
+                if ($transp > 0) {
1562
+                    $destFormat = 'png';
1563
+                }
1564
+            }
1565
+            if (in_array($destFormat, _image_extensions_conservent_transparence())) {
1566
+                // Conserver la transparence
1567
+                if (function_exists('imageAntiAlias')) {
1568
+                    imageAntiAlias($destImage, true);
1569
+                }
1570
+                @imagealphablending($destImage, false);
1571
+                @imagesavealpha($destImage, true);
1572
+            }
1573
+            $ok = @ImageCopyResampled($destImage, $srcImage, 0, 0, 0, 0, $destWidth, $destHeight, $srcWidth, $srcHeight);
1574
+        }
1575
+        if (!$ok) {
1576
+            $ok = ImageCopyResized($destImage, $srcImage, 0, 0, 0, 0, $destWidth, $destHeight, $srcWidth, $srcHeight);
1577
+        }
1578
+
1579
+        // Sauvegarde de l'image destination
1580
+        $valeurs['fichier_dest'] = $vignette = "$destination.$destFormat";
1581
+        $valeurs['format_dest'] = $format = $destFormat;
1582
+        _image_gd_output($destImage, $valeurs);
1583
+
1584
+        if ($srcImage) {
1585
+            ImageDestroy($srcImage);
1586
+        }
1587
+        ImageDestroy($destImage);
1588
+    }
1589
+
1590
+    if (!$vignette or !$size = @spip_getimagesize($vignette)) {
1591
+        $size = [$destWidth, $destHeight];
1592
+    }
1593
+
1594
+    // Gaffe: en safe mode, pas d'acces a la vignette,
1595
+    // donc risque de balancer "width='0'", ce qui masque l'image sous MSIE
1596
+    if ($size[0] < 1) {
1597
+        $size[0] = $destWidth;
1598
+    }
1599
+    if ($size[1] < 1) {
1600
+        $size[1] = $destHeight;
1601
+    }
1602
+
1603
+    $retour['width'] = $largeur = $size[0];
1604
+    $retour['height'] = $hauteur = $size[1];
1605
+
1606
+    $retour['fichier'] = $vignette;
1607
+    $retour['format'] = $format;
1608
+    $retour['date'] = @filemtime($vignette);
1609
+
1610
+    // renvoyer l'image
1611
+    return $retour;
1612 1612
 }
1613 1613
 
1614 1614
 /**
@@ -1628,25 +1628,25 @@  discard block
 block discarded – undo
1628 1628
  * @return array Liste [ largeur, hauteur, ratio de réduction ]
1629 1629
  **/
1630 1630
 function _image_ratio(int $srcWidth, int $srcHeight, int $maxWidth, int $maxHeight): array {
1631
-	$ratioWidth = $srcWidth / $maxWidth;
1632
-	$ratioHeight = $srcHeight / $maxHeight;
1633
-
1634
-	if ($srcWidth <= $maxWidth and $srcHeight <= $maxHeight) {
1635
-		$destWidth = $srcWidth;
1636
-		$destHeight = $srcHeight;
1637
-	} elseif ($ratioWidth < $ratioHeight) {
1638
-		$destWidth = $srcWidth / $ratioHeight;
1639
-		$destHeight = $maxHeight;
1640
-	} else {
1641
-		$destWidth = $maxWidth;
1642
-		$destHeight = $srcHeight / $ratioWidth;
1643
-	}
1644
-
1645
-	return [
1646
-		intval(round($destWidth)),
1647
-		intval(round($destHeight)),
1648
-		max($ratioWidth, $ratioHeight)
1649
-	];
1631
+    $ratioWidth = $srcWidth / $maxWidth;
1632
+    $ratioHeight = $srcHeight / $maxHeight;
1633
+
1634
+    if ($srcWidth <= $maxWidth and $srcHeight <= $maxHeight) {
1635
+        $destWidth = $srcWidth;
1636
+        $destHeight = $srcHeight;
1637
+    } elseif ($ratioWidth < $ratioHeight) {
1638
+        $destWidth = $srcWidth / $ratioHeight;
1639
+        $destHeight = $maxHeight;
1640
+    } else {
1641
+        $destWidth = $maxWidth;
1642
+        $destHeight = $srcHeight / $ratioWidth;
1643
+    }
1644
+
1645
+    return [
1646
+        intval(round($destWidth)),
1647
+        intval(round($destHeight)),
1648
+        max($ratioWidth, $ratioHeight)
1649
+    ];
1650 1650
 }
1651 1651
 
1652 1652
 /**
@@ -1666,25 +1666,25 @@  discard block
 block discarded – undo
1666 1666
  * @return array Liste [ largeur, hauteur, ratio de réduction ]
1667 1667
  **/
1668 1668
 function ratio_passe_partout(int $srcWidth, int $srcHeight, int $maxWidth, int $maxHeight): array {
1669
-	$ratioWidth = $srcWidth / $maxWidth;
1670
-	$ratioHeight = $srcHeight / $maxHeight;
1671
-
1672
-	if ($srcWidth <= $maxWidth and $srcHeight <= $maxHeight) {
1673
-		$destWidth = $srcWidth;
1674
-		$destHeight = $srcHeight;
1675
-	} elseif ($ratioWidth > $ratioHeight) {
1676
-		$destWidth = $srcWidth / $ratioHeight;
1677
-		$destHeight = $maxHeight;
1678
-	} else {
1679
-		$destWidth = $maxWidth;
1680
-		$destHeight = $srcHeight / $ratioWidth;
1681
-	}
1682
-
1683
-	return [
1684
-		intval(round($destWidth)),
1685
-		intval(round($destHeight)),
1686
-		min($ratioWidth, $ratioHeight)
1687
-	];
1669
+    $ratioWidth = $srcWidth / $maxWidth;
1670
+    $ratioHeight = $srcHeight / $maxHeight;
1671
+
1672
+    if ($srcWidth <= $maxWidth and $srcHeight <= $maxHeight) {
1673
+        $destWidth = $srcWidth;
1674
+        $destHeight = $srcHeight;
1675
+    } elseif ($ratioWidth > $ratioHeight) {
1676
+        $destWidth = $srcWidth / $ratioHeight;
1677
+        $destHeight = $maxHeight;
1678
+    } else {
1679
+        $destWidth = $maxWidth;
1680
+        $destHeight = $srcHeight / $ratioWidth;
1681
+    }
1682
+
1683
+    return [
1684
+        intval(round($destWidth)),
1685
+        intval(round($destHeight)),
1686
+        min($ratioWidth, $ratioHeight)
1687
+    ];
1688 1688
 }
1689 1689
 
1690 1690
 
@@ -1697,12 +1697,12 @@  discard block
 block discarded – undo
1697 1697
  * @return string
1698 1698
  */
1699 1699
 function process_image_svg_identite($image) {
1700
-	if ($image['creer']) {
1701
-		$source = $image['fichier'];
1702
-		_image_gd_output($source, $image);
1703
-	}
1700
+    if ($image['creer']) {
1701
+        $source = $image['fichier'];
1702
+        _image_gd_output($source, $image);
1703
+    }
1704 1704
 
1705
-	return _image_ecrire_tag($image, ['src' => $image['fichier_dest']]);
1705
+    return _image_ecrire_tag($image, ['src' => $image['fichier_dest']]);
1706 1706
 }
1707 1707
 
1708 1708
 
@@ -1735,111 +1735,111 @@  discard block
 block discarded – undo
1735 1735
  *     Code HTML de la balise img produite
1736 1736
  **/
1737 1737
 function process_image_reduire($fonction, $img, $taille, $taille_y, $force, $process = 'AUTO') {
1738
-	$image = false;
1739
-	if (($process == 'AUTO') and isset($GLOBALS['meta']['image_process'])) {
1740
-		$process = $GLOBALS['meta']['image_process'];
1741
-	}
1742
-	# determiner le format de sortie
1743
-	$format_sortie = false; // le choix par defaut sera bon
1744
-	if ($process == 'netpbm') {
1745
-		$format_sortie = 'jpg';
1746
-	} elseif ($process == 'gd1' or $process == 'gd2') {
1747
-		$image = _image_valeurs_trans($img, "reduire-{$taille}-{$taille_y}", $format_sortie, $fonction, false, _SVG_SUPPORTED);
1748
-		// on verifie que l'extension choisie est bonne (en principe oui)
1749
-		$gd_formats = formats_image_acceptables(true);
1750
-		if (
1751
-			is_array($image)
1752
-			and (!in_array($image['format_dest'], $gd_formats)
1753
-				or (!in_array($image['format_dest'], _image_extensions_acceptees_en_sortie()))
1754
-			)
1755
-		) {
1756
-			if ($image['format_source'] == 'jpg') {
1757
-				$formats_sortie = ['jpg', 'png', 'gif'];
1758
-			} else // les gif sont passes en png preferentiellement pour etre homogene aux autres filtres images
1759
-			{
1760
-				$formats_sortie = ['png', 'jpg', 'gif'];
1761
-			}
1762
-			// Choisir le format destination
1763
-			// - on sauve de preference en JPEG (meilleure compression)
1764
-			// - pour le GIF : les GD recentes peuvent le lire mais pas l'ecrire
1765
-			# bug : gd_formats contient la liste des fichiers qu'on sait *lire*,
1766
-			# pas *ecrire*
1767
-			$format_sortie = '';
1768
-			foreach ($formats_sortie as $fmt) {
1769
-				if (in_array($fmt, $gd_formats) and in_array($fmt, _image_extensions_acceptees_en_sortie())) {
1770
-					$format_sortie = $fmt;
1771
-					break;
1772
-				}
1773
-			}
1774
-			$image = false;
1775
-		}
1776
-	}
1777
-
1778
-	if (!is_array($image)) {
1779
-		$image = _image_valeurs_trans($img, "reduire-{$taille}-{$taille_y}", $format_sortie, $fonction, false, _SVG_SUPPORTED);
1780
-	}
1781
-
1782
-	if (!is_array($image) or !$image['largeur'] or !$image['hauteur']) {
1783
-		spip_log("image_reduire_src:pas de version locale de $img");
1784
-		// on peut resizer en mode html si on dispose des elements
1785
-		if (
1786
-			$srcw = extraire_attribut($img, 'width')
1787
-			and $srch = extraire_attribut($img, 'height')
1788
-		) {
1789
-			[$w, $h] = _image_ratio($srcw, $srch, $taille, $taille_y);
1790
-
1791
-			return _image_tag_changer_taille($img, $w, $h);
1792
-		}
1793
-		// la on n'a pas d'infos sur l'image source... on refile le truc a css
1794
-		// sous la forme style='max-width: NNpx;'
1795
-		return inserer_attribut(
1796
-			$img,
1797
-			'style',
1798
-			"max-width: ${taille}px; max-height: ${taille_y}px"
1799
-		);
1800
-	}
1801
-
1802
-	// si l'image est plus petite que la cible retourner une copie cachee de l'image
1803
-	if (($image['largeur'] <= $taille) && ($image['hauteur'] <= $taille_y)) {
1804
-		if ($image['creer']) {
1805
-			@copy($image['fichier'], $image['fichier_dest']);
1806
-		}
1807
-
1808
-		return _image_ecrire_tag($image, ['src' => $image['fichier_dest']]);
1809
-	}
1810
-
1811
-	if ($image['creer'] == false && !$force) {
1812
-		return _image_ecrire_tag(
1813
-			$image,
1814
-			['src' => $image['fichier_dest'], 'width' => $image['largeur_dest'], 'height' => $image['hauteur_dest']]
1815
-		);
1816
-	}
1817
-
1818
-	if (in_array($image['format_source'], _image_extensions_acceptees_en_entree())) {
1819
-		$destWidth = $image['largeur_dest'];
1820
-		$destHeight = $image['hauteur_dest'];
1821
-		$logo = $image['fichier'];
1822
-		$date = $image['date_src'];
1823
-		$preview = _image_creer_vignette($image, $taille, $taille_y, $process, $force);
1824
-
1825
-		if ($preview && $preview['fichier']) {
1826
-			$logo = $preview['fichier'];
1827
-			$destWidth = $preview['width'];
1828
-			$destHeight = $preview['height'];
1829
-			$date = $preview['date'];
1830
-		}
1831
-		// dans l'espace prive mettre un timestamp sur l'adresse
1832
-		// de l'image, de facon a tromper le cache du navigateur
1833
-		// quand on fait supprimer/reuploader un logo
1834
-		// (pas de filemtime si SAFE MODE)
1835
-		$date = test_espace_prive() ? ('?' . $date) : '';
1836
-
1837
-		return _image_ecrire_tag($image, ['src' => "$logo$date", 'width' => $destWidth, 'height' => $destHeight]);
1838
-	}
1839
-	else {
1840
-		# BMP, tiff ... les redacteurs osent tout!
1841
-		return $img;
1842
-	}
1738
+    $image = false;
1739
+    if (($process == 'AUTO') and isset($GLOBALS['meta']['image_process'])) {
1740
+        $process = $GLOBALS['meta']['image_process'];
1741
+    }
1742
+    # determiner le format de sortie
1743
+    $format_sortie = false; // le choix par defaut sera bon
1744
+    if ($process == 'netpbm') {
1745
+        $format_sortie = 'jpg';
1746
+    } elseif ($process == 'gd1' or $process == 'gd2') {
1747
+        $image = _image_valeurs_trans($img, "reduire-{$taille}-{$taille_y}", $format_sortie, $fonction, false, _SVG_SUPPORTED);
1748
+        // on verifie que l'extension choisie est bonne (en principe oui)
1749
+        $gd_formats = formats_image_acceptables(true);
1750
+        if (
1751
+            is_array($image)
1752
+            and (!in_array($image['format_dest'], $gd_formats)
1753
+                or (!in_array($image['format_dest'], _image_extensions_acceptees_en_sortie()))
1754
+            )
1755
+        ) {
1756
+            if ($image['format_source'] == 'jpg') {
1757
+                $formats_sortie = ['jpg', 'png', 'gif'];
1758
+            } else // les gif sont passes en png preferentiellement pour etre homogene aux autres filtres images
1759
+            {
1760
+                $formats_sortie = ['png', 'jpg', 'gif'];
1761
+            }
1762
+            // Choisir le format destination
1763
+            // - on sauve de preference en JPEG (meilleure compression)
1764
+            // - pour le GIF : les GD recentes peuvent le lire mais pas l'ecrire
1765
+            # bug : gd_formats contient la liste des fichiers qu'on sait *lire*,
1766
+            # pas *ecrire*
1767
+            $format_sortie = '';
1768
+            foreach ($formats_sortie as $fmt) {
1769
+                if (in_array($fmt, $gd_formats) and in_array($fmt, _image_extensions_acceptees_en_sortie())) {
1770
+                    $format_sortie = $fmt;
1771
+                    break;
1772
+                }
1773
+            }
1774
+            $image = false;
1775
+        }
1776
+    }
1777
+
1778
+    if (!is_array($image)) {
1779
+        $image = _image_valeurs_trans($img, "reduire-{$taille}-{$taille_y}", $format_sortie, $fonction, false, _SVG_SUPPORTED);
1780
+    }
1781
+
1782
+    if (!is_array($image) or !$image['largeur'] or !$image['hauteur']) {
1783
+        spip_log("image_reduire_src:pas de version locale de $img");
1784
+        // on peut resizer en mode html si on dispose des elements
1785
+        if (
1786
+            $srcw = extraire_attribut($img, 'width')
1787
+            and $srch = extraire_attribut($img, 'height')
1788
+        ) {
1789
+            [$w, $h] = _image_ratio($srcw, $srch, $taille, $taille_y);
1790
+
1791
+            return _image_tag_changer_taille($img, $w, $h);
1792
+        }
1793
+        // la on n'a pas d'infos sur l'image source... on refile le truc a css
1794
+        // sous la forme style='max-width: NNpx;'
1795
+        return inserer_attribut(
1796
+            $img,
1797
+            'style',
1798
+            "max-width: ${taille}px; max-height: ${taille_y}px"
1799
+        );
1800
+    }
1801
+
1802
+    // si l'image est plus petite que la cible retourner une copie cachee de l'image
1803
+    if (($image['largeur'] <= $taille) && ($image['hauteur'] <= $taille_y)) {
1804
+        if ($image['creer']) {
1805
+            @copy($image['fichier'], $image['fichier_dest']);
1806
+        }
1807
+
1808
+        return _image_ecrire_tag($image, ['src' => $image['fichier_dest']]);
1809
+    }
1810
+
1811
+    if ($image['creer'] == false && !$force) {
1812
+        return _image_ecrire_tag(
1813
+            $image,
1814
+            ['src' => $image['fichier_dest'], 'width' => $image['largeur_dest'], 'height' => $image['hauteur_dest']]
1815
+        );
1816
+    }
1817
+
1818
+    if (in_array($image['format_source'], _image_extensions_acceptees_en_entree())) {
1819
+        $destWidth = $image['largeur_dest'];
1820
+        $destHeight = $image['hauteur_dest'];
1821
+        $logo = $image['fichier'];
1822
+        $date = $image['date_src'];
1823
+        $preview = _image_creer_vignette($image, $taille, $taille_y, $process, $force);
1824
+
1825
+        if ($preview && $preview['fichier']) {
1826
+            $logo = $preview['fichier'];
1827
+            $destWidth = $preview['width'];
1828
+            $destHeight = $preview['height'];
1829
+            $date = $preview['date'];
1830
+        }
1831
+        // dans l'espace prive mettre un timestamp sur l'adresse
1832
+        // de l'image, de facon a tromper le cache du navigateur
1833
+        // quand on fait supprimer/reuploader un logo
1834
+        // (pas de filemtime si SAFE MODE)
1835
+        $date = test_espace_prive() ? ('?' . $date) : '';
1836
+
1837
+        return _image_ecrire_tag($image, ['src' => "$logo$date", 'width' => $destWidth, 'height' => $destHeight]);
1838
+    }
1839
+    else {
1840
+        # BMP, tiff ... les redacteurs osent tout!
1841
+        return $img;
1842
+    }
1843 1843
 }
1844 1844
 
1845 1845
 /**
@@ -1853,145 +1853,145 @@  discard block
 block discarded – undo
1853 1853
  * Class phpthumb_functions
1854 1854
  */
1855 1855
 class phpthumb_functions {
1856
-	/**
1857
-	 * Retourne la couleur d'un pixel dans une image
1858
-	 *
1859
-	 * @param resource|GdImage $img
1860
-	 * @param int $x
1861
-	 * @param int $y
1862
-	 * @return array|bool
1863
-	 */
1864
-	public static function GetPixelColor(&$img, $x, $y) {
1865
-		if (is_resource($img) || (is_object($img) && $img instanceof \GdImage)) {
1866
-			return @ImageColorsForIndex($img, @ImageColorAt($img, $x, $y));
1867
-		}
1868
-		return false;
1869
-	}
1870
-
1871
-	/**
1872
-	 * Retourne un nombre dans une représentation en Little Endian
1873
-	 *
1874
-	 * @param int $number
1875
-	 * @param int $minbytes
1876
-	 * @return string
1877
-	 */
1878
-	public static function LittleEndian2String($number, $minbytes = 1) {
1879
-		$intstring = '';
1880
-		while ($number > 0) {
1881
-			$intstring = $intstring . chr($number & 255);
1882
-			$number >>= 8;
1883
-		}
1884
-
1885
-		return str_pad($intstring, $minbytes, "\x00", STR_PAD_RIGHT);
1886
-	}
1887
-
1888
-	/**
1889
-	 * Transforme une ressource GD en image au format ICO
1890
-	 *
1891
-	 * @param array $gd_image_array
1892
-	 *     Tableau de ressources d'images GD
1893
-	 * @return string
1894
-	 *     Image au format ICO
1895
-	 */
1896
-	public static function GD2ICOstring(&$gd_image_array) {
1897
-		foreach ($gd_image_array as $key => $gd_image) {
1898
-			$ImageWidths[$key] = ImageSX($gd_image);
1899
-			$ImageHeights[$key] = ImageSY($gd_image);
1900
-			$bpp[$key] = ImageIsTrueColor($gd_image) ? 32 : 24;
1901
-			$totalcolors[$key] = ImageColorsTotal($gd_image);
1902
-
1903
-			$icXOR[$key] = '';
1904
-			for ($y = $ImageHeights[$key] - 1; $y >= 0; $y--) {
1905
-				for ($x = 0; $x < $ImageWidths[$key]; $x++) {
1906
-					$argb = phpthumb_functions::GetPixelColor($gd_image, $x, $y);
1907
-					$a = round(255 * ((127 - $argb['alpha']) / 127));
1908
-					$r = $argb['red'];
1909
-					$g = $argb['green'];
1910
-					$b = $argb['blue'];
1911
-
1912
-					if ($bpp[$key] == 32) {
1913
-						$icXOR[$key] .= chr($b) . chr($g) . chr($r) . chr($a);
1914
-					} elseif ($bpp[$key] == 24) {
1915
-						$icXOR[$key] .= chr($b) . chr($g) . chr($r);
1916
-					}
1917
-
1918
-					if ($a < 128) {
1919
-						@$icANDmask[$key][$y] .= '1';
1920
-					} else {
1921
-						@$icANDmask[$key][$y] .= '0';
1922
-					}
1923
-				}
1924
-				// mask bits are 32-bit aligned per scanline
1925
-				while (strlen($icANDmask[$key][$y]) % 32) {
1926
-					$icANDmask[$key][$y] .= '0';
1927
-				}
1928
-			}
1929
-			$icAND[$key] = '';
1930
-			foreach ($icANDmask[$key] as $y => $scanlinemaskbits) {
1931
-				for ($i = 0; $i < strlen($scanlinemaskbits); $i += 8) {
1932
-					$icAND[$key] .= chr(bindec(str_pad(substr($scanlinemaskbits, $i, 8), 8, '0', STR_PAD_LEFT)));
1933
-				}
1934
-			}
1935
-		}
1936
-
1937
-		foreach ($gd_image_array as $key => $gd_image) {
1938
-			$biSizeImage = $ImageWidths[$key] * $ImageHeights[$key] * ($bpp[$key] / 8);
1939
-
1940
-			// BITMAPINFOHEADER - 40 bytes
1941
-			$BitmapInfoHeader[$key] = '';
1942
-			$BitmapInfoHeader[$key] .= "\x28\x00\x00\x00";                // DWORD  biSize;
1943
-			$BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($ImageWidths[$key], 4);    // LONG   biWidth;
1944
-			// The biHeight member specifies the combined
1945
-			// height of the XOR and AND masks.
1946
-			$BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($ImageHeights[$key] * 2, 4); // LONG   biHeight;
1947
-			$BitmapInfoHeader[$key] .= "\x01\x00";                    // WORD   biPlanes;
1948
-			$BitmapInfoHeader[$key] .= chr($bpp[$key]) . "\x00";              // wBitCount;
1949
-			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // DWORD  biCompression;
1950
-			$BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($biSizeImage, 4);      // DWORD  biSizeImage;
1951
-			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // LONG   biXPelsPerMeter;
1952
-			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // LONG   biYPelsPerMeter;
1953
-			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // DWORD  biClrUsed;
1954
-			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // DWORD  biClrImportant;
1955
-		}
1956
-
1957
-
1958
-		$icondata = "\x00\x00";                    // idReserved;   // Reserved (must be 0)
1959
-		$icondata .= "\x01\x00";                    // idType;	   // Resource Type (1 for icons)
1960
-		$icondata .= phpthumb_functions::LittleEndian2String(count($gd_image_array), 2);  // idCount;	  // How many images?
1961
-
1962
-		$dwImageOffset = 6 + (count($gd_image_array) * 16);
1963
-		foreach ($gd_image_array as $key => $gd_image) {
1964
-			// ICONDIRENTRY   idEntries[1]; // An entry for each image (idCount of 'em)
1965
-
1966
-			$icondata .= chr($ImageWidths[$key]);           // bWidth;		  // Width, in pixels, of the image
1967
-			$icondata .= chr($ImageHeights[$key]);          // bHeight;		 // Height, in pixels, of the image
1968
-			$icondata .= chr($totalcolors[$key]);           // bColorCount;	 // Number of colors in image (0 if >=8bpp)
1969
-			$icondata .= "\x00";                    // bReserved;	   // Reserved ( must be 0)
1970
-
1971
-			$icondata .= "\x01\x00";                  // wPlanes;		 // Color Planes
1972
-			$icondata .= chr($bpp[$key]) . "\x00";            // wBitCount;	   // Bits per pixel
1973
-
1974
-			$dwBytesInRes = 40 + strlen($icXOR[$key]) + strlen($icAND[$key]);
1975
-			$icondata .= phpthumb_functions::LittleEndian2String(
1976
-				$dwBytesInRes,
1977
-				4
1978
-			);     // dwBytesInRes;	// How many bytes in this resource?
1979
-
1980
-			$icondata .= phpthumb_functions::LittleEndian2String(
1981
-				$dwImageOffset,
1982
-				4
1983
-			);    // dwImageOffset;   // Where in the file is this image?
1984
-			$dwImageOffset += strlen($BitmapInfoHeader[$key]);
1985
-			$dwImageOffset += strlen($icXOR[$key]);
1986
-			$dwImageOffset += strlen($icAND[$key]);
1987
-		}
1988
-
1989
-		foreach ($gd_image_array as $key => $gd_image) {
1990
-			$icondata .= $BitmapInfoHeader[$key];
1991
-			$icondata .= $icXOR[$key];
1992
-			$icondata .= $icAND[$key];
1993
-		}
1994
-
1995
-		return $icondata;
1996
-	}
1856
+    /**
1857
+     * Retourne la couleur d'un pixel dans une image
1858
+     *
1859
+     * @param resource|GdImage $img
1860
+     * @param int $x
1861
+     * @param int $y
1862
+     * @return array|bool
1863
+     */
1864
+    public static function GetPixelColor(&$img, $x, $y) {
1865
+        if (is_resource($img) || (is_object($img) && $img instanceof \GdImage)) {
1866
+            return @ImageColorsForIndex($img, @ImageColorAt($img, $x, $y));
1867
+        }
1868
+        return false;
1869
+    }
1870
+
1871
+    /**
1872
+     * Retourne un nombre dans une représentation en Little Endian
1873
+     *
1874
+     * @param int $number
1875
+     * @param int $minbytes
1876
+     * @return string
1877
+     */
1878
+    public static function LittleEndian2String($number, $minbytes = 1) {
1879
+        $intstring = '';
1880
+        while ($number > 0) {
1881
+            $intstring = $intstring . chr($number & 255);
1882
+            $number >>= 8;
1883
+        }
1884
+
1885
+        return str_pad($intstring, $minbytes, "\x00", STR_PAD_RIGHT);
1886
+    }
1887
+
1888
+    /**
1889
+     * Transforme une ressource GD en image au format ICO
1890
+     *
1891
+     * @param array $gd_image_array
1892
+     *     Tableau de ressources d'images GD
1893
+     * @return string
1894
+     *     Image au format ICO
1895
+     */
1896
+    public static function GD2ICOstring(&$gd_image_array) {
1897
+        foreach ($gd_image_array as $key => $gd_image) {
1898
+            $ImageWidths[$key] = ImageSX($gd_image);
1899
+            $ImageHeights[$key] = ImageSY($gd_image);
1900
+            $bpp[$key] = ImageIsTrueColor($gd_image) ? 32 : 24;
1901
+            $totalcolors[$key] = ImageColorsTotal($gd_image);
1902
+
1903
+            $icXOR[$key] = '';
1904
+            for ($y = $ImageHeights[$key] - 1; $y >= 0; $y--) {
1905
+                for ($x = 0; $x < $ImageWidths[$key]; $x++) {
1906
+                    $argb = phpthumb_functions::GetPixelColor($gd_image, $x, $y);
1907
+                    $a = round(255 * ((127 - $argb['alpha']) / 127));
1908
+                    $r = $argb['red'];
1909
+                    $g = $argb['green'];
1910
+                    $b = $argb['blue'];
1911
+
1912
+                    if ($bpp[$key] == 32) {
1913
+                        $icXOR[$key] .= chr($b) . chr($g) . chr($r) . chr($a);
1914
+                    } elseif ($bpp[$key] == 24) {
1915
+                        $icXOR[$key] .= chr($b) . chr($g) . chr($r);
1916
+                    }
1917
+
1918
+                    if ($a < 128) {
1919
+                        @$icANDmask[$key][$y] .= '1';
1920
+                    } else {
1921
+                        @$icANDmask[$key][$y] .= '0';
1922
+                    }
1923
+                }
1924
+                // mask bits are 32-bit aligned per scanline
1925
+                while (strlen($icANDmask[$key][$y]) % 32) {
1926
+                    $icANDmask[$key][$y] .= '0';
1927
+                }
1928
+            }
1929
+            $icAND[$key] = '';
1930
+            foreach ($icANDmask[$key] as $y => $scanlinemaskbits) {
1931
+                for ($i = 0; $i < strlen($scanlinemaskbits); $i += 8) {
1932
+                    $icAND[$key] .= chr(bindec(str_pad(substr($scanlinemaskbits, $i, 8), 8, '0', STR_PAD_LEFT)));
1933
+                }
1934
+            }
1935
+        }
1936
+
1937
+        foreach ($gd_image_array as $key => $gd_image) {
1938
+            $biSizeImage = $ImageWidths[$key] * $ImageHeights[$key] * ($bpp[$key] / 8);
1939
+
1940
+            // BITMAPINFOHEADER - 40 bytes
1941
+            $BitmapInfoHeader[$key] = '';
1942
+            $BitmapInfoHeader[$key] .= "\x28\x00\x00\x00";                // DWORD  biSize;
1943
+            $BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($ImageWidths[$key], 4);    // LONG   biWidth;
1944
+            // The biHeight member specifies the combined
1945
+            // height of the XOR and AND masks.
1946
+            $BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($ImageHeights[$key] * 2, 4); // LONG   biHeight;
1947
+            $BitmapInfoHeader[$key] .= "\x01\x00";                    // WORD   biPlanes;
1948
+            $BitmapInfoHeader[$key] .= chr($bpp[$key]) . "\x00";              // wBitCount;
1949
+            $BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // DWORD  biCompression;
1950
+            $BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($biSizeImage, 4);      // DWORD  biSizeImage;
1951
+            $BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // LONG   biXPelsPerMeter;
1952
+            $BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // LONG   biYPelsPerMeter;
1953
+            $BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // DWORD  biClrUsed;
1954
+            $BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // DWORD  biClrImportant;
1955
+        }
1956
+
1957
+
1958
+        $icondata = "\x00\x00";                    // idReserved;   // Reserved (must be 0)
1959
+        $icondata .= "\x01\x00";                    // idType;	   // Resource Type (1 for icons)
1960
+        $icondata .= phpthumb_functions::LittleEndian2String(count($gd_image_array), 2);  // idCount;	  // How many images?
1961
+
1962
+        $dwImageOffset = 6 + (count($gd_image_array) * 16);
1963
+        foreach ($gd_image_array as $key => $gd_image) {
1964
+            // ICONDIRENTRY   idEntries[1]; // An entry for each image (idCount of 'em)
1965
+
1966
+            $icondata .= chr($ImageWidths[$key]);           // bWidth;		  // Width, in pixels, of the image
1967
+            $icondata .= chr($ImageHeights[$key]);          // bHeight;		 // Height, in pixels, of the image
1968
+            $icondata .= chr($totalcolors[$key]);           // bColorCount;	 // Number of colors in image (0 if >=8bpp)
1969
+            $icondata .= "\x00";                    // bReserved;	   // Reserved ( must be 0)
1970
+
1971
+            $icondata .= "\x01\x00";                  // wPlanes;		 // Color Planes
1972
+            $icondata .= chr($bpp[$key]) . "\x00";            // wBitCount;	   // Bits per pixel
1973
+
1974
+            $dwBytesInRes = 40 + strlen($icXOR[$key]) + strlen($icAND[$key]);
1975
+            $icondata .= phpthumb_functions::LittleEndian2String(
1976
+                $dwBytesInRes,
1977
+                4
1978
+            );     // dwBytesInRes;	// How many bytes in this resource?
1979
+
1980
+            $icondata .= phpthumb_functions::LittleEndian2String(
1981
+                $dwImageOffset,
1982
+                4
1983
+            );    // dwImageOffset;   // Where in the file is this image?
1984
+            $dwImageOffset += strlen($BitmapInfoHeader[$key]);
1985
+            $dwImageOffset += strlen($icXOR[$key]);
1986
+            $dwImageOffset += strlen($icAND[$key]);
1987
+        }
1988
+
1989
+        foreach ($gd_image_array as $key => $gd_image) {
1990
+            $icondata .= $BitmapInfoHeader[$key];
1991
+            $icondata .= $icXOR[$key];
1992
+            $icondata .= $icAND[$key];
1993
+        }
1994
+
1995
+        return $icondata;
1996
+    }
1997 1997
 }
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   +140 added lines, -140 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,32 +107,32 @@  discard block
 block discarded – undo
107 107
  *     Code HTML
108 108
  **/
109 109
 function liste_objets_bloques($exec, $contexte = [], $auteur = null): string {
110
-	$res = '';
111
-	include_spip('inc/config');
112
-	if (lire_config('articles_modif', 'non') !== 'non') {
113
-		include_spip('inc/drapeau_edition');
114
-		if (is_null($auteur)) {
115
-			$auteur = $GLOBALS['visiteur_session'];
116
-		}
117
-		if (
118
-			$en_cours = trouver_objet_exec($exec)
119
-			and $en_cours['edition']
120
-			and $type = $en_cours['type']
121
-			and ((isset($contexte[$en_cours['id_table_objet']]) and $id = $contexte[$en_cours['id_table_objet']])
122
-				or $id = _request($en_cours['id_table_objet']))
123
-		) {
124
-			// marquer le fait que l'objet est ouvert en edition par toto
125
-			// a telle date ; une alerte sera donnee aux autres redacteurs
126
-			signale_edition($id, $auteur, $type);
127
-		}
128
-
129
-		$objets_ouverts = liste_drapeau_edition($auteur['id_auteur']);
130
-		if (count($objets_ouverts)) {
131
-			$res .= recuperer_fond('prive/objets/liste/objets-en-edition', [], ['ajax' => true]);
132
-		}
133
-	}
134
-
135
-	return $res;
110
+    $res = '';
111
+    include_spip('inc/config');
112
+    if (lire_config('articles_modif', 'non') !== 'non') {
113
+        include_spip('inc/drapeau_edition');
114
+        if (is_null($auteur)) {
115
+            $auteur = $GLOBALS['visiteur_session'];
116
+        }
117
+        if (
118
+            $en_cours = trouver_objet_exec($exec)
119
+            and $en_cours['edition']
120
+            and $type = $en_cours['type']
121
+            and ((isset($contexte[$en_cours['id_table_objet']]) and $id = $contexte[$en_cours['id_table_objet']])
122
+                or $id = _request($en_cours['id_table_objet']))
123
+        ) {
124
+            // marquer le fait que l'objet est ouvert en edition par toto
125
+            // a telle date ; une alerte sera donnee aux autres redacteurs
126
+            signale_edition($id, $auteur, $type);
127
+        }
128
+
129
+        $objets_ouverts = liste_drapeau_edition($auteur['id_auteur']);
130
+        if (count($objets_ouverts)) {
131
+            $res .= recuperer_fond('prive/objets/liste/objets-en-edition', [], ['ajax' => true]);
132
+        }
133
+    }
134
+
135
+    return $res;
136 136
 }
137 137
 
138 138
 
@@ -146,20 +146,20 @@  discard block
 block discarded – undo
146 146
  * @return string Code HTML
147 147
  **/
148 148
 function fin_page() {
149
-	include_spip('inc/pipelines');
150
-	// avec &var_profile=1 on a le tableau de mesures SQL
151
-	$debug = ((_request('exec') !== 'valider_xml')
152
-		and ((_request('var_mode') == 'debug')
153
-			or (isset($GLOBALS['tableau_des_temps']) and $GLOBALS['tableau_des_temps'])
154
-			and isset($_COOKIE['spip_admin'])));
155
-	$t = '</div><div id="pied"><div class="largeur">'
156
-		. recuperer_fond('prive/squelettes/inclure/pied')
157
-		. '</div>'
158
-		. '</div></div>' // cf. div#page et div.largeur ouvertes dans conmmencer_page()
159
-		. ($debug ? erreur_squelette() : '')
160
-		. "</body></html>\n";
161
-
162
-	return f_queue($t);
149
+    include_spip('inc/pipelines');
150
+    // avec &var_profile=1 on a le tableau de mesures SQL
151
+    $debug = ((_request('exec') !== 'valider_xml')
152
+        and ((_request('var_mode') == 'debug')
153
+            or (isset($GLOBALS['tableau_des_temps']) and $GLOBALS['tableau_des_temps'])
154
+            and isset($_COOKIE['spip_admin'])));
155
+    $t = '</div><div id="pied"><div class="largeur">'
156
+        . recuperer_fond('prive/squelettes/inclure/pied')
157
+        . '</div>'
158
+        . '</div></div>' // cf. div#page et div.largeur ouvertes dans conmmencer_page()
159
+        . ($debug ? erreur_squelette() : '')
160
+        . "</body></html>\n";
161
+
162
+    return f_queue($t);
163 163
 }
164 164
 
165 165
 /**
@@ -174,22 +174,22 @@  discard block
 block discarded – undo
174 174
  * @return string Code HTML
175 175
  **/
176 176
 function html_tests_js() {
177
-	if (_SPIP_AJAX and !defined('_TESTER_NOSCRIPT')) {
178
-		// pour le pied de page (deja defini si on est validation XML)
179
-		define(
180
-			'_TESTER_NOSCRIPT',
181
-			"<noscript>\n<div style='display:none;'><img src='"
182
-			. generer_url_ecrire('test_ajax', 'js=-1')
183
-			. "' width='1' height='1' alt='' /></div></noscript>\n"
184
-		);
185
-	}
186
-
187
-	$rejouer = '';
188
-	if (defined('_SESSION_REJOUER')) {
189
-		$rejouer = (_SESSION_REJOUER === true) ? rejouer_session() : _SESSION_REJOUER;
190
-	}
191
-
192
-	return $rejouer . (defined('_TESTER_NOSCRIPT') ? _TESTER_NOSCRIPT : '');
177
+    if (_SPIP_AJAX and !defined('_TESTER_NOSCRIPT')) {
178
+        // pour le pied de page (deja defini si on est validation XML)
179
+        define(
180
+            '_TESTER_NOSCRIPT',
181
+            "<noscript>\n<div style='display:none;'><img src='"
182
+            . generer_url_ecrire('test_ajax', 'js=-1')
183
+            . "' width='1' height='1' alt='' /></div></noscript>\n"
184
+        );
185
+    }
186
+
187
+    $rejouer = '';
188
+    if (defined('_SESSION_REJOUER')) {
189
+        $rejouer = (_SESSION_REJOUER === true) ? rejouer_session() : _SESSION_REJOUER;
190
+    }
191
+
192
+    return $rejouer . (defined('_TESTER_NOSCRIPT') ? _TESTER_NOSCRIPT : '');
193 193
 }
194 194
 
195 195
 /**
@@ -199,25 +199,25 @@  discard block
 block discarded – undo
199 199
  **/
200 200
 function info_maj_spip() {
201 201
 
202
-	$maj = $GLOBALS['meta']['info_maj_spip'] ?? null;
203
-	if (!$maj) {
204
-		return '';
205
-	}
202
+    $maj = $GLOBALS['meta']['info_maj_spip'] ?? null;
203
+    if (!$maj) {
204
+        return '';
205
+    }
206 206
 
207
-	$maj = explode('|', $maj);
208
-	// c'est une ancienne notif, on a fait la maj depuis !
209
-	if ($GLOBALS['spip_version_branche'] !== reset($maj)) {
210
-		return '';
211
-	}
207
+    $maj = explode('|', $maj);
208
+    // c'est une ancienne notif, on a fait la maj depuis !
209
+    if ($GLOBALS['spip_version_branche'] !== reset($maj)) {
210
+        return '';
211
+    }
212 212
 
213
-	if (!autoriser('webmestre')) {
214
-		return '';
215
-	}
213
+    if (!autoriser('webmestre')) {
214
+        return '';
215
+    }
216 216
 
217
-	array_shift($maj);
218
-	$maj = implode('|', $maj);
217
+    array_shift($maj);
218
+    $maj = implode('|', $maj);
219 219
 
220
-	return "$maj<br />";
220
+    return "$maj<br />";
221 221
 }
222 222
 
223 223
 /**
@@ -228,47 +228,47 @@  discard block
 block discarded – undo
228 228
  **/
229 229
 function info_copyright() {
230 230
 
231
-	$version = $GLOBALS['spip_version_affichee'];
232
-
233
-	//
234
-	// Mention, le cas echeant, de la revision SVN courante
235
-	//
236
-	if ($vcs = version_vcs_courante(_DIR_RACINE, true)) {
237
-		if ($vcs['vcs'] === 'GIT') {
238
-			$url = 'https://git.spip.net/spip/spip/commit/' . $vcs['commit'];
239
-		} elseif ($vcs['vcs'] === 'SVN') {
240
-			$url = 'https://core.spip.net/projects/spip/repository/revisions/' . $vcs['commit'];
241
-		} else {
242
-			$url = '';
243
-		}
244
-		// affichage "GIT [master: abcdef]"
245
-		$commit = $vcs['commit_short'] ?? $vcs['commit'];
246
-		if ($url) {
247
-			$commit = "<a href=\"$url\" target=\"_blank\" rel=\"noopener noreferrer\">$commit</a>";
248
-		}
249
-		if ($vcs['branch']) {
250
-			$commit = $vcs['branch'] . ': ' . $commit;
251
-		}
252
-		$version .= " {$vcs['vcs']} [$commit]";
253
-	}
254
-
255
-	// et la version de l'ecran de securite
256
-	$secu = defined('_ECRAN_SECURITE')
257
-		? '<br />' . _T('ecran_securite', ['version' => _ECRAN_SECURITE])
258
-		: '';
259
-
260
-	return _T(
261
-		'info_copyright',
262
-		[
263
-			'spip' => "<b>SPIP $version</b> ",
264
-			'lien_gpl' =>
265
-				"<a href='" . generer_url_ecrire(
266
-					'aide',
267
-					'aide=licence&var_lang=' . $GLOBALS['spip_lang']
268
-				) . "' class=\"aide popin\">" . _T('info_copyright_gpl') . '</a>'
269
-		]
270
-	)
271
-	. $secu;
231
+    $version = $GLOBALS['spip_version_affichee'];
232
+
233
+    //
234
+    // Mention, le cas echeant, de la revision SVN courante
235
+    //
236
+    if ($vcs = version_vcs_courante(_DIR_RACINE, true)) {
237
+        if ($vcs['vcs'] === 'GIT') {
238
+            $url = 'https://git.spip.net/spip/spip/commit/' . $vcs['commit'];
239
+        } elseif ($vcs['vcs'] === 'SVN') {
240
+            $url = 'https://core.spip.net/projects/spip/repository/revisions/' . $vcs['commit'];
241
+        } else {
242
+            $url = '';
243
+        }
244
+        // affichage "GIT [master: abcdef]"
245
+        $commit = $vcs['commit_short'] ?? $vcs['commit'];
246
+        if ($url) {
247
+            $commit = "<a href=\"$url\" target=\"_blank\" rel=\"noopener noreferrer\">$commit</a>";
248
+        }
249
+        if ($vcs['branch']) {
250
+            $commit = $vcs['branch'] . ': ' . $commit;
251
+        }
252
+        $version .= " {$vcs['vcs']} [$commit]";
253
+    }
254
+
255
+    // et la version de l'ecran de securite
256
+    $secu = defined('_ECRAN_SECURITE')
257
+        ? '<br />' . _T('ecran_securite', ['version' => _ECRAN_SECURITE])
258
+        : '';
259
+
260
+    return _T(
261
+        'info_copyright',
262
+        [
263
+            'spip' => "<b>SPIP $version</b> ",
264
+            'lien_gpl' =>
265
+                "<a href='" . generer_url_ecrire(
266
+                    'aide',
267
+                    'aide=licence&var_lang=' . $GLOBALS['spip_lang']
268
+                ) . "' class=\"aide popin\">" . _T('info_copyright_gpl') . '</a>'
269
+        ]
270
+    )
271
+    . $secu;
272 272
 }
273 273
 
274 274
 /**
@@ -283,17 +283,17 @@  discard block
 block discarded – undo
283 283
  * @return string             Code HTML
284 284
  **/
285 285
 function formulaire_recherche($page, $complement = '') {
286
-	$recherche = _request('recherche');
287
-	$recherche_aff = entites_html($recherche);
288
-	if (!strlen($recherche)) {
289
-		$recherche_aff = _T('info_rechercher');
290
-		$onfocus = " onfocus=\"this.value='';\"";
291
-	} else {
292
-		$onfocus = '';
293
-	}
294
-
295
-	$form = '<input type="text" size="10" value="' . $recherche_aff . '" name="recherche" class="recherche" accesskey="r"' . $onfocus . ' />';
296
-	$form .= "<input type='image' src='" . chemin_image('rechercher-20.png') . "' name='submit' class='submit' alt='" . _T('info_rechercher') . "' />";
297
-
298
-	return "<div class='spip_recherche'>" . generer_form_ecrire($page, $form . $complement, " method='get'") . '</div>';
286
+    $recherche = _request('recherche');
287
+    $recherche_aff = entites_html($recherche);
288
+    if (!strlen($recherche)) {
289
+        $recherche_aff = _T('info_rechercher');
290
+        $onfocus = " onfocus=\"this.value='';\"";
291
+    } else {
292
+        $onfocus = '';
293
+    }
294
+
295
+    $form = '<input type="text" size="10" value="' . $recherche_aff . '" name="recherche" class="recherche" accesskey="r"' . $onfocus . ' />';
296
+    $form .= "<input type='image' src='" . chemin_image('rechercher-20.png') . "' name='submit' class='submit' alt='" . _T('info_rechercher') . "' />";
297
+
298
+    return "<div class='spip_recherche'>" . generer_form_ecrire($page, $form . $complement, " method='get'") . '</div>';
299 299
 }
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   +138 added lines, -138 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,88 +148,88 @@  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 (
217
-			$GLOBALS['profondeur_url'] >= (_DIR_RESTREINT ? 1 : 2)
218
-			and empty($options['all_inline'])
219
-		) {
220
-			define('_SET_HTML_BASE', true);
221
-			include_spip('public/assembler');
222
-			$GLOBALS['html'] = true;
223
-			page_base_href($html);
224
-		}
225
-		return $html;
226
-	} else {
227
-		include_spip('inc/headers');
228
-		include_spip('inc/actions');
229
-		$url = self('&', true);
230
-		foreach ($_POST as $v => $c) {
231
-			$url = parametre_url($url, $v, $c, '&');
232
-		}
233
-		ajax_retour('<div>' . $titre . redirige_formulaire($url) . '</div>', false);
234
-	}
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 (
217
+            $GLOBALS['profondeur_url'] >= (_DIR_RESTREINT ? 1 : 2)
218
+            and empty($options['all_inline'])
219
+        ) {
220
+            define('_SET_HTML_BASE', true);
221
+            include_spip('public/assembler');
222
+            $GLOBALS['html'] = true;
223
+            page_base_href($html);
224
+        }
225
+        return $html;
226
+    } else {
227
+        include_spip('inc/headers');
228
+        include_spip('inc/actions');
229
+        $url = self('&', true);
230
+        foreach ($_POST as $v => $c) {
231
+            $url = parametre_url($url, $v, $c, '&');
232
+        }
233
+        ajax_retour('<div>' . $titre . redirige_formulaire($url) . '</div>', false);
234
+    }
235 235
 }
Please login to merge, or discard this patch.
ecrire/inc/boutons.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
 			&& autoriser('onglet', "_$id")
103 103
 		) {
104 104
 			$onglets[$id] = new Bouton(
105
-				isset($infos['icone']) ? find_in_theme($infos['icone']) : '',  // icone
106
-				$infos['titre'],  // titre
105
+				isset($infos['icone']) ? find_in_theme($infos['icone']) : '', // icone
106
+				$infos['titre'], // titre
107 107
 				(isset($infos['action']) and $infos['action'])
108 108
 					? generer_url_ecrire(
109 109
 						$infos['action'],
@@ -142,5 +142,5 @@  discard block
 block discarded – undo
142 142
 		$res .= onglet(_T($onglet->libelle), $url, $exec, $ongletCourant, $onglet->icone);
143 143
 	}
144 144
 
145
-	return !$res ? '' : (debut_onglet($class) . $res . fin_onglet());
145
+	return !$res ? '' : (debut_onglet($class).$res.fin_onglet());
146 146
 }
Please login to merge, or discard this patch.
Indentation   +82 added lines, -82 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
 /**
@@ -25,51 +25,51 @@  discard block
 block discarded – undo
25 25
  * privée ou dans un de ses sous menus
26 26
  */
27 27
 class Bouton {
28
-	/** @var string L'icone à mettre dans le bouton */
29
-	public $icone;
30
-
31
-	/** @var string Le nom de l'entrée d'i18n associé */
32
-	public $libelle;
33
-
34
-	/** @var null|string L'URL de la page (null => ?exec=nom) */
35
-	public $url = null;
36
-
37
-	/** @var null|string|array Arguments supplementaires de l'URL */
38
-	public $urlArg = null;
39
-
40
-	/** @var null|string URL du javascript */
41
-	public $url2 = null;
42
-
43
-	/** @var null|string Pour ouvrir dans une fenetre a part */
44
-	public $target = null;
45
-
46
-	/** @var array Sous-barre de boutons / onglets */
47
-	public $sousmenu = [];
48
-
49
-	/**
50
-	 * Définit un bouton
51
-	 *
52
-	 * @param string $icone
53
-	 *    L'icone à mettre dans le bouton
54
-	 * @param string $libelle
55
-	 *    Le nom de l'entrée i18n associé
56
-	 * @param null|string $url
57
-	 *    L'URL de la page
58
-	 * @param null|string|array $urlArg
59
-	 *    Arguments supplémentaires de l'URL
60
-	 * @param null|string $url2
61
-	 *    URL du javascript
62
-	 * @param null|mixed $target
63
-	 *    Pour ouvrir une fenêtre à part
64
-	 */
65
-	public function __construct($icone, $libelle, $url = null, $urlArg = null, $url2 = null, $target = null) {
66
-		$this->icone = $icone;
67
-		$this->libelle = $libelle;
68
-		$this->url = $url;
69
-		$this->urlArg = $urlArg;
70
-		$this->url2 = $url2;
71
-		$this->target = $target;
72
-	}
28
+    /** @var string L'icone à mettre dans le bouton */
29
+    public $icone;
30
+
31
+    /** @var string Le nom de l'entrée d'i18n associé */
32
+    public $libelle;
33
+
34
+    /** @var null|string L'URL de la page (null => ?exec=nom) */
35
+    public $url = null;
36
+
37
+    /** @var null|string|array Arguments supplementaires de l'URL */
38
+    public $urlArg = null;
39
+
40
+    /** @var null|string URL du javascript */
41
+    public $url2 = null;
42
+
43
+    /** @var null|string Pour ouvrir dans une fenetre a part */
44
+    public $target = null;
45
+
46
+    /** @var array Sous-barre de boutons / onglets */
47
+    public $sousmenu = [];
48
+
49
+    /**
50
+     * Définit un bouton
51
+     *
52
+     * @param string $icone
53
+     *    L'icone à mettre dans le bouton
54
+     * @param string $libelle
55
+     *    Le nom de l'entrée i18n associé
56
+     * @param null|string $url
57
+     *    L'URL de la page
58
+     * @param null|string|array $urlArg
59
+     *    Arguments supplémentaires de l'URL
60
+     * @param null|string $url2
61
+     *    URL du javascript
62
+     * @param null|mixed $target
63
+     *    Pour ouvrir une fenêtre à part
64
+     */
65
+    public function __construct($icone, $libelle, $url = null, $urlArg = null, $url2 = null, $target = null) {
66
+        $this->icone = $icone;
67
+        $this->libelle = $libelle;
68
+        $this->url = $url;
69
+        $this->urlArg = $urlArg;
70
+        $this->url2 = $url2;
71
+        $this->target = $target;
72
+    }
73 73
 }
74 74
 
75 75
 
@@ -86,35 +86,35 @@  discard block
 block discarded – undo
86 86
  */
87 87
 function definir_barre_onglets($script) {
88 88
 
89
-	$onglets = [];
90
-	$liste_onglets = [];
91
-
92
-	// ajouter les onglets issus des plugin via paquet.xml
93
-	if (function_exists('onglets_plugins')) {
94
-		$liste_onglets = onglets_plugins();
95
-	}
96
-
97
-
98
-	foreach ($liste_onglets as $id => $infos) {
99
-		if (
100
-			($parent = $infos['parent'])
101
-			&& $parent == $script
102
-			&& autoriser('onglet', "_$id")
103
-		) {
104
-			$onglets[$id] = new Bouton(
105
-				isset($infos['icone']) ? find_in_theme($infos['icone']) : '',  // icone
106
-				$infos['titre'],  // titre
107
-				(isset($infos['action']) and $infos['action'])
108
-					? generer_url_ecrire(
109
-						$infos['action'],
110
-						(isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : ''
111
-					)
112
-					: null
113
-			);
114
-		}
115
-	}
116
-
117
-	return pipeline('ajouter_onglets', ['data' => $onglets, 'args' => $script]);
89
+    $onglets = [];
90
+    $liste_onglets = [];
91
+
92
+    // ajouter les onglets issus des plugin via paquet.xml
93
+    if (function_exists('onglets_plugins')) {
94
+        $liste_onglets = onglets_plugins();
95
+    }
96
+
97
+
98
+    foreach ($liste_onglets as $id => $infos) {
99
+        if (
100
+            ($parent = $infos['parent'])
101
+            && $parent == $script
102
+            && autoriser('onglet', "_$id")
103
+        ) {
104
+            $onglets[$id] = new Bouton(
105
+                isset($infos['icone']) ? find_in_theme($infos['icone']) : '',  // icone
106
+                $infos['titre'],  // titre
107
+                (isset($infos['action']) and $infos['action'])
108
+                    ? generer_url_ecrire(
109
+                        $infos['action'],
110
+                        (isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : ''
111
+                    )
112
+                    : null
113
+            );
114
+        }
115
+    }
116
+
117
+    return pipeline('ajouter_onglets', ['data' => $onglets, 'args' => $script]);
118 118
 }
119 119
 
120 120
 
@@ -133,14 +133,14 @@  discard block
 block discarded – undo
133 133
  * @return string
134 134
  */
135 135
 function barre_onglets($rubrique, $ongletCourant, $class = 'barre_onglet') {
136
-	include_spip('inc/presentation');
136
+    include_spip('inc/presentation');
137 137
 
138
-	$res = '';
138
+    $res = '';
139 139
 
140
-	foreach (definir_barre_onglets($rubrique) as $exec => $onglet) {
141
-		$url = $onglet->url ?: generer_url_ecrire($exec);
142
-		$res .= onglet(_T($onglet->libelle), $url, $exec, $ongletCourant, $onglet->icone);
143
-	}
140
+    foreach (definir_barre_onglets($rubrique) as $exec => $onglet) {
141
+        $url = $onglet->url ?: generer_url_ecrire($exec);
142
+        $res .= onglet(_T($onglet->libelle), $url, $exec, $ongletCourant, $onglet->icone);
143
+    }
144 144
 
145
-	return !$res ? '' : (debut_onglet($class) . $res . fin_onglet());
145
+    return !$res ? '' : (debut_onglet($class) . $res . fin_onglet());
146 146
 }
Please login to merge, or discard this patch.
ecrire/inc/pipelines.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 		}
66 66
 	}
67 67
 
68
-	$texte = $x . $texte;
68
+	$texte = $x.$texte;
69 69
 
70 70
 	return $texte;
71 71
 }
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	|| ($pos = 0);
180 180
 
181 181
 	if (false === strpos(substr($texte, 0, $pos), '<!-- insert_head -->')) {
182
-		$insert = "\n" . pipeline('insert_head', '<!-- f_insert_head -->') . "\n";
182
+		$insert = "\n".pipeline('insert_head', '<!-- f_insert_head -->')."\n";
183 183
 		$texte = substr_replace($texte, $insert, $pos, 0);
184 184
 	}
185 185
 
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 		}
212 212
 		$texte = substr_replace($texte, $x, $pos, 0);
213 213
 		// pas de preview en fenetre enfant
214
-		$x = "<script type='text/javascript'>const frameEl = window.frameElement;if (frameEl) {frameEl.sandbox='sandbox';window.location.href='" . addslashes($GLOBALS['meta']['adresse_site']) . "';}</script>";
214
+		$x = "<script type='text/javascript'>const frameEl = window.frameElement;if (frameEl) {frameEl.sandbox='sandbox';window.location.href='".addslashes($GLOBALS['meta']['adresse_site'])."';}</script>";
215 215
 		if (!$pos = stripos($texte, '<head') or !$pos = strpos($texte, '>', $pos)) {
216 216
 			$pos = -1;
217 217
 		}
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 
283 283
 	// inserer avant le </body> fermant si on peut, a la fin de la page sinon
284 284
 	if (($p = strpos($texte, '</body>')) !== false) {
285
-		$texte = substr($texte, 0, $p) . $code . substr($texte, $p);
285
+		$texte = substr($texte, 0, $p).$code.substr($texte, $p);
286 286
 	} else {
287 287
 		$texte .= $code;
288 288
 	}
Please login to merge, or discard this patch.
Indentation   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -16,10 +16,10 @@  discard block
 block discarded – undo
16 16
  * @package SPIP\Core\Pipelines
17 17
  **/
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 if (test_espace_prive()) {
22
-	include_spip('inc/pipelines_ecrire');
22
+    include_spip('inc/pipelines_ecrire');
23 23
 }
24 24
 
25 25
 
@@ -45,28 +45,28 @@  discard block
 block discarded – undo
45 45
  * @return string          Contenu qui sera inséré dans le head HTML
46 46
  **/
47 47
 function f_jQuery($texte) {
48
-	$x = '';
49
-	$jquery_plugins = pipeline(
50
-		'jquery_plugins',
51
-		[
52
-			'javascript/jquery.js',
53
-			'javascript/jquery.form.js',
54
-			'javascript/jquery.autosave.js',
55
-			'javascript/jquery.placeholder-label.js',
56
-			'javascript/ajaxCallback.js',
57
-			'javascript/js.cookie.js',
58
-		]
59
-	);
60
-	foreach (array_unique($jquery_plugins) as $script) {
61
-		if ($script = find_in_path(supprimer_timestamp($script))) {
62
-			$script = timestamp($script);
63
-			$x .= "\n<script src=\"$script\" type=\"text/javascript\"></script>\n";
64
-		}
65
-	}
48
+    $x = '';
49
+    $jquery_plugins = pipeline(
50
+        'jquery_plugins',
51
+        [
52
+            'javascript/jquery.js',
53
+            'javascript/jquery.form.js',
54
+            'javascript/jquery.autosave.js',
55
+            'javascript/jquery.placeholder-label.js',
56
+            'javascript/ajaxCallback.js',
57
+            'javascript/js.cookie.js',
58
+        ]
59
+    );
60
+    foreach (array_unique($jquery_plugins) as $script) {
61
+        if ($script = find_in_path(supprimer_timestamp($script))) {
62
+            $script = timestamp($script);
63
+            $x .= "\n<script src=\"$script\" type=\"text/javascript\"></script>\n";
64
+        }
65
+    }
66 66
 
67
-	$texte = $x . $texte;
67
+    $texte = $x . $texte;
68 68
 
69
-	return $texte;
69
+    return $texte;
70 70
 }
71 71
 
72 72
 
@@ -85,28 +85,28 @@  discard block
 block discarded – undo
85 85
  * @return string         Contenu de la page envoyée au navigateur
86 86
  **/
87 87
 function f_surligne($texte) {
88
-	if (!$GLOBALS['html']) {
89
-		return $texte;
90
-	}
91
-	$rech = _request('var_recherche');
92
-	if (
93
-		!$rech
94
-		and (!defined('_SURLIGNE_RECHERCHE_REFERERS')
95
-			or !_SURLIGNE_RECHERCHE_REFERERS
96
-			or !isset($_SERVER['HTTP_REFERER']))
97
-	) {
98
-		return $texte;
99
-	}
100
-	include_spip('inc/surligne');
88
+    if (!$GLOBALS['html']) {
89
+        return $texte;
90
+    }
91
+    $rech = _request('var_recherche');
92
+    if (
93
+        !$rech
94
+        and (!defined('_SURLIGNE_RECHERCHE_REFERERS')
95
+            or !_SURLIGNE_RECHERCHE_REFERERS
96
+            or !isset($_SERVER['HTTP_REFERER']))
97
+    ) {
98
+        return $texte;
99
+    }
100
+    include_spip('inc/surligne');
101 101
 
102
-	if (isset($_SERVER['HTTP_REFERER'])) {
103
-		$_SERVER['HTTP_REFERER'] = preg_replace(',[^\w\,/#&;:-]+,', ' ', $_SERVER['HTTP_REFERER']);
104
-	}
105
-	if ($rech) {
106
-		$rech = preg_replace(',[^\w\,/#&;:-]+,', ' ', $rech);
107
-	}
102
+    if (isset($_SERVER['HTTP_REFERER'])) {
103
+        $_SERVER['HTTP_REFERER'] = preg_replace(',[^\w\,/#&;:-]+,', ' ', $_SERVER['HTTP_REFERER']);
104
+    }
105
+    if ($rech) {
106
+        $rech = preg_replace(',[^\w\,/#&;:-]+,', ' ', $rech);
107
+    }
108 108
 
109
-	return surligner_mots($texte, $rech);
109
+    return surligner_mots($texte, $rech);
110 110
 }
111 111
 
112 112
 /**
@@ -123,33 +123,33 @@  discard block
 block discarded – undo
123 123
  * @return string         Contenu de la page envoyée au navigateur
124 124
  **/
125 125
 function f_tidy($texte) {
126
-	/**
127
-	 * Indentation à faire ?
128
-	 *
129
-	 * - true : actif.
130
-	 * - false par défaut.
131
-	 */
126
+    /**
127
+     * Indentation à faire ?
128
+     *
129
+     * - true : actif.
130
+     * - false par défaut.
131
+     */
132 132
 
133
-	if (
134
-		$GLOBALS['xhtml'] # tidy demande
135
-		and $GLOBALS['html'] # verifie que la page avait l'entete text/html
136
-		and strlen($texte)
137
-		and !headers_sent()
138
-	) {
139
-		# Compatibilite ascendante
140
-		if (!is_string($GLOBALS['xhtml'])) {
141
-			$GLOBALS['xhtml'] = 'tidy';
142
-		}
133
+    if (
134
+        $GLOBALS['xhtml'] # tidy demande
135
+        and $GLOBALS['html'] # verifie que la page avait l'entete text/html
136
+        and strlen($texte)
137
+        and !headers_sent()
138
+    ) {
139
+        # Compatibilite ascendante
140
+        if (!is_string($GLOBALS['xhtml'])) {
141
+            $GLOBALS['xhtml'] = 'tidy';
142
+        }
143 143
 
144
-		if (!$f = charger_fonction($GLOBALS['xhtml'], 'inc', true)) {
145
-			spip_log("tidy absent, l'indenteur SPIP le remplace");
146
-			$f = charger_fonction('sax', 'xml');
147
-		}
144
+        if (!$f = charger_fonction($GLOBALS['xhtml'], 'inc', true)) {
145
+            spip_log("tidy absent, l'indenteur SPIP le remplace");
146
+            $f = charger_fonction('sax', 'xml');
147
+        }
148 148
 
149
-		return $f($texte);
150
-	}
149
+        return $f($texte);
150
+    }
151 151
 
152
-	return $texte;
152
+    return $texte;
153 153
 }
154 154
 
155 155
 
@@ -168,21 +168,21 @@  discard block
 block discarded – undo
168 168
  * @return string         Contenu de la page envoyée au navigateur
169 169
  **/
170 170
 function f_insert_head($texte) {
171
-	if (!$GLOBALS['html']) {
172
-		return $texte;
173
-	}
174
-	include_spip('public/admin'); // pour strripos
171
+    if (!$GLOBALS['html']) {
172
+        return $texte;
173
+    }
174
+    include_spip('public/admin'); // pour strripos
175 175
 
176
-	($pos = stripos($texte, '</head>'))
177
-	|| ($pos = stripos($texte, '<body>'))
178
-	|| ($pos = 0);
176
+    ($pos = stripos($texte, '</head>'))
177
+    || ($pos = stripos($texte, '<body>'))
178
+    || ($pos = 0);
179 179
 
180
-	if (false === strpos(substr($texte, 0, $pos), '<!-- insert_head -->')) {
181
-		$insert = "\n" . pipeline('insert_head', '<!-- f_insert_head -->') . "\n";
182
-		$texte = substr_replace($texte, $insert, $pos, 0);
183
-	}
180
+    if (false === strpos(substr($texte, 0, $pos), '<!-- insert_head -->')) {
181
+        $insert = "\n" . pipeline('insert_head', '<!-- f_insert_head -->') . "\n";
182
+        $texte = substr_replace($texte, $insert, $pos, 0);
183
+    }
184 184
 
185
-	return $texte;
185
+    return $texte;
186 186
 }
187 187
 
188 188
 
@@ -198,34 +198,34 @@  discard block
 block discarded – undo
198 198
  * @return string         Contenu de la page envoyée au navigateur
199 199
  **/
200 200
 function f_admin($texte) {
201
-	if (defined('_VAR_PREVIEW') and _VAR_PREVIEW and $GLOBALS['html']) {
202
-		include_spip('inc/filtres'); // pour http_img_pack
203
-		$x = "<div class='spip-previsu' "
204
-			. http_style_background('preview-32.png', '', 32)
205
-			. '>'
206
-			. _T('previsualisation')
207
-			. '</div>';
208
-		if (!$pos = stripos($texte, '</body>')) {
209
-			$pos = strlen($texte);
210
-		}
211
-		$texte = substr_replace($texte, $x, $pos, 0);
212
-		// pas de preview en fenetre enfant
213
-		$x = "<script type='text/javascript'>const frameEl = window.frameElement;if (frameEl) {frameEl.sandbox='sandbox';window.location.href='" . addslashes($GLOBALS['meta']['adresse_site']) . "';}</script>";
214
-		if (!$pos = stripos($texte, '<head') or !$pos = strpos($texte, '>', $pos)) {
215
-			$pos = -1;
216
-		}
217
-		$texte = substr_replace($texte, $x, $pos + 1, 0);
218
-	}
201
+    if (defined('_VAR_PREVIEW') and _VAR_PREVIEW and $GLOBALS['html']) {
202
+        include_spip('inc/filtres'); // pour http_img_pack
203
+        $x = "<div class='spip-previsu' "
204
+            . http_style_background('preview-32.png', '', 32)
205
+            . '>'
206
+            . _T('previsualisation')
207
+            . '</div>';
208
+        if (!$pos = stripos($texte, '</body>')) {
209
+            $pos = strlen($texte);
210
+        }
211
+        $texte = substr_replace($texte, $x, $pos, 0);
212
+        // pas de preview en fenetre enfant
213
+        $x = "<script type='text/javascript'>const frameEl = window.frameElement;if (frameEl) {frameEl.sandbox='sandbox';window.location.href='" . addslashes($GLOBALS['meta']['adresse_site']) . "';}</script>";
214
+        if (!$pos = stripos($texte, '<head') or !$pos = strpos($texte, '>', $pos)) {
215
+            $pos = -1;
216
+        }
217
+        $texte = substr_replace($texte, $x, $pos + 1, 0);
218
+    }
219 219
 
220
-	if (isset($GLOBALS['affiche_boutons_admin']) and $GLOBALS['affiche_boutons_admin']) {
221
-		include_spip('public/admin');
222
-		$texte = affiche_boutons_admin($texte);
223
-	}
224
-	if (_request('var_mode') == 'noajax') {
225
-		$texte = preg_replace(',(class=[\'"][^\'"]*)ajax([^\'"]*[\'"]),Uims', "\\1\\2", $texte);
226
-	}
220
+    if (isset($GLOBALS['affiche_boutons_admin']) and $GLOBALS['affiche_boutons_admin']) {
221
+        include_spip('public/admin');
222
+        $texte = affiche_boutons_admin($texte);
223
+    }
224
+    if (_request('var_mode') == 'noajax') {
225
+        $texte = preg_replace(',(class=[\'"][^\'"]*)ajax([^\'"]*[\'"]),Uims', "\\1\\2", $texte);
226
+    }
227 227
 
228
-	return $texte;
228
+    return $texte;
229 229
 }
230 230
 
231 231
 /**
@@ -243,11 +243,11 @@  discard block
 block discarded – undo
243 243
  * @return array $flux  Description et contenu de l'inclusion
244 244
  **/
245 245
 function f_recuperer_fond($flux) {
246
-	if (!test_espace_prive()) {
247
-		return $flux;
248
-	}
246
+    if (!test_espace_prive()) {
247
+        return $flux;
248
+    }
249 249
 
250
-	return f_afficher_blocs_ecrire($flux);
250
+    return f_afficher_blocs_ecrire($flux);
251 251
 }
252 252
 
253 253
 /**
@@ -261,30 +261,30 @@  discard block
 block discarded – undo
261 261
  * @return string         Contenu de la page envoyée au navigateur
262 262
  */
263 263
 function f_queue($texte) {
264
-	// eviter une inclusion si rien a faire
265
-	if (
266
-		_request('action') == 'cron'
267
-		or queue_sleep_time_to_next_job() > 0
268
-		or defined('_DEBUG_BLOCK_QUEUE')
269
-	) {
270
-		return $texte;
271
-	}
264
+    // eviter une inclusion si rien a faire
265
+    if (
266
+        _request('action') == 'cron'
267
+        or queue_sleep_time_to_next_job() > 0
268
+        or defined('_DEBUG_BLOCK_QUEUE')
269
+    ) {
270
+        return $texte;
271
+    }
272 272
 
273
-	include_spip('inc/queue');
274
-	$code = queue_affichage_cron();
273
+    include_spip('inc/queue');
274
+    $code = queue_affichage_cron();
275 275
 
276
-	// si rien a afficher
277
-	// ou si on est pas dans une page html, on ne sait rien faire de mieux
278
-	if (!$code or !isset($GLOBALS['html']) or !$GLOBALS['html']) {
279
-		return $texte;
280
-	}
276
+    // si rien a afficher
277
+    // ou si on est pas dans une page html, on ne sait rien faire de mieux
278
+    if (!$code or !isset($GLOBALS['html']) or !$GLOBALS['html']) {
279
+        return $texte;
280
+    }
281 281
 
282
-	// inserer avant le </body> fermant si on peut, a la fin de la page sinon
283
-	if (($p = strpos($texte, '</body>')) !== false) {
284
-		$texte = substr($texte, 0, $p) . $code . substr($texte, $p);
285
-	} else {
286
-		$texte .= $code;
287
-	}
282
+    // inserer avant le </body> fermant si on peut, a la fin de la page sinon
283
+    if (($p = strpos($texte, '</body>')) !== false) {
284
+        $texte = substr($texte, 0, $p) . $code . substr($texte, $p);
285
+    } else {
286
+        $texte .= $code;
287
+    }
288 288
 
289
-	return $texte;
289
+    return $texte;
290 290
 }
Please login to merge, or discard this patch.
ecrire/inc/recherche_to_array.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 		$_id_table = reset($_id_table);
68 68
 	}
69 69
 
70
-	$requete['SELECT'][] = 't.' . $_id_table;
70
+	$requete['SELECT'][] = 't.'.$_id_table;
71 71
 	$a = [];
72 72
 	// Recherche fulltext
73 73
 	foreach ($champs as $champ => $poids) {
@@ -78,13 +78,13 @@  discard block
 block discarded – undo
78 78
 				$champ = "t.$champ";
79 79
 			}
80 80
 			$requete['SELECT'][] = $champ;
81
-			$a[] = $champ . ' ' . $methode . ' ' . $q;
81
+			$a[] = $champ.' '.$methode.' '.$q;
82 82
 		}
83 83
 	}
84 84
 	if ($a) {
85 85
 		$requete['WHERE'][] = join(' OR ', $a);
86 86
 	}
87
-	$requete['FROM'][] = table_objet_sql($table) . ' AS t';
87
+	$requete['FROM'][] = table_objet_sql($table).' AS t';
88 88
 
89 89
 	$results = [];
90 90
 
@@ -252,8 +252,8 @@  discard block
 block discarded – undo
252 252
 					);
253 253
 				} // cas table de liaison generique spip_xxx_yyy
254 254
 				elseif (
255
-					$t = $trouver_table($table_arrivee . '_' . $table_depart, $serveur)
256
-					or $t = $trouver_table($table_depart . '_' . $table_arrivee, $serveur)
255
+					$t = $trouver_table($table_arrivee.'_'.$table_depart, $serveur)
256
+					or $t = $trouver_table($table_depart.'_'.$table_arrivee, $serveur)
257 257
 				) {
258 258
 					$s = sql_select(
259 259
 						"$cle_depart,$cle_arrivee",
@@ -292,12 +292,12 @@  discard block
 block discarded – undo
292 292
 				}
293 293
 				if (isset($joint['champs']) and $joint['champs']) {
294 294
 					foreach ($joint['champs'] as $c => $val) {
295
-						$results[$id]['champs'][$table_liee . '.' . $c] = $val;
295
+						$results[$id]['champs'][$table_liee.'.'.$c] = $val;
296 296
 					}
297 297
 				}
298 298
 				if (isset($joint['matches']) and $joint['matches']) {
299 299
 					foreach ($joint['matches'] as $c => $val) {
300
-						$results[$id]['matches'][$table_liee . '.' . $c] = $val;
300
+						$results[$id]['matches'][$table_liee.'.'.$c] = $val;
301 301
 					}
302 302
 				}
303 303
 			}
Please login to merge, or discard this patch.
Indentation   +267 added lines, -267 removed lines patch added patch discarded remove patch
@@ -11,298 +11,298 @@
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 
18 18
 // methodes sql
19 19
 function inc_recherche_to_array_dist($recherche, $options = []) {
20 20
 
21
-	// options par defaut
22
-	$options = array_merge(
23
-		[
24
-			'score' => true,
25
-			'champs' => false,
26
-			'toutvoir' => false,
27
-			'matches' => false,
28
-			'jointures' => false
29
-		],
30
-		$options
31
-	);
21
+    // options par defaut
22
+    $options = array_merge(
23
+        [
24
+            'score' => true,
25
+            'champs' => false,
26
+            'toutvoir' => false,
27
+            'matches' => false,
28
+            'jointures' => false
29
+        ],
30
+        $options
31
+    );
32 32
 
33
-	include_spip('inc/rechercher');
34
-	include_spip('inc/autoriser');
33
+    include_spip('inc/rechercher');
34
+    include_spip('inc/autoriser');
35 35
 
36
-	$requete = [
37
-		'SELECT' => [],
38
-		'FROM' => [],
39
-		'WHERE' => [],
40
-		'GROUPBY' => [],
41
-		'ORDERBY' => [],
42
-		'LIMIT' => '',
43
-		'HAVING' => []
44
-	];
36
+    $requete = [
37
+        'SELECT' => [],
38
+        'FROM' => [],
39
+        'WHERE' => [],
40
+        'GROUPBY' => [],
41
+        'ORDERBY' => [],
42
+        'LIMIT' => '',
43
+        'HAVING' => []
44
+    ];
45 45
 
46
-	$table = sinon($options['table'], 'article');
47
-	if ($options['champs']) {
48
-		$champs = $options['champs'];
49
-	} else {
50
-		$l = liste_des_champs();
51
-		$champs = $l['article'];
52
-	}
53
-	$serveur = $options['serveur'];
46
+    $table = sinon($options['table'], 'article');
47
+    if ($options['champs']) {
48
+        $champs = $options['champs'];
49
+    } else {
50
+        $l = liste_des_champs();
51
+        $champs = $l['article'];
52
+    }
53
+    $serveur = $options['serveur'];
54 54
 
55
-	[$methode, $q, $preg] = expression_recherche($recherche, $options);
55
+    [$methode, $q, $preg] = expression_recherche($recherche, $options);
56 56
 
57
-	$jointures = $options['jointures']
58
-		? liste_des_jointures()
59
-		: [];
57
+    $jointures = $options['jointures']
58
+        ? liste_des_jointures()
59
+        : [];
60 60
 
61
-	$_id_table = id_table_objet($table);
61
+    $_id_table = id_table_objet($table);
62 62
 
63
-	// c'est un pis-aller : ca a peu de chance de marcher, mais mieux quand meme que en conservant la ','
64
-	// (aka ca marche au moins dans certains cas comme avec spip_formulaires_reponses_champs)
65
-	if (strpos($_id_table, ',') !== false) {
66
-		$_id_table = explode(',', $_id_table);
67
-		$_id_table = reset($_id_table);
68
-	}
63
+    // c'est un pis-aller : ca a peu de chance de marcher, mais mieux quand meme que en conservant la ','
64
+    // (aka ca marche au moins dans certains cas comme avec spip_formulaires_reponses_champs)
65
+    if (strpos($_id_table, ',') !== false) {
66
+        $_id_table = explode(',', $_id_table);
67
+        $_id_table = reset($_id_table);
68
+    }
69 69
 
70
-	$requete['SELECT'][] = 't.' . $_id_table;
71
-	$a = [];
72
-	// Recherche fulltext
73
-	foreach ($champs as $champ => $poids) {
74
-		if (is_array($champ)) {
75
-			spip_log('requetes imbriquees interdites');
76
-		} else {
77
-			if (strpos($champ, '.') === false) {
78
-				$champ = "t.$champ";
79
-			}
80
-			$requete['SELECT'][] = $champ;
81
-			$a[] = $champ . ' ' . $methode . ' ' . $q;
82
-		}
83
-	}
84
-	if ($a) {
85
-		$requete['WHERE'][] = join(' OR ', $a);
86
-	}
87
-	$requete['FROM'][] = table_objet_sql($table) . ' AS t';
70
+    $requete['SELECT'][] = 't.' . $_id_table;
71
+    $a = [];
72
+    // Recherche fulltext
73
+    foreach ($champs as $champ => $poids) {
74
+        if (is_array($champ)) {
75
+            spip_log('requetes imbriquees interdites');
76
+        } else {
77
+            if (strpos($champ, '.') === false) {
78
+                $champ = "t.$champ";
79
+            }
80
+            $requete['SELECT'][] = $champ;
81
+            $a[] = $champ . ' ' . $methode . ' ' . $q;
82
+        }
83
+    }
84
+    if ($a) {
85
+        $requete['WHERE'][] = join(' OR ', $a);
86
+    }
87
+    $requete['FROM'][] = table_objet_sql($table) . ' AS t';
88 88
 
89
-	$results = [];
89
+    $results = [];
90 90
 
91
-	$s = sql_select(
92
-		$requete['SELECT'],
93
-		$requete['FROM'],
94
-		$requete['WHERE'],
95
-		implode(' ', $requete['GROUPBY']),
96
-		$requete['ORDERBY'],
97
-		$requete['LIMIT'],
98
-		$requete['HAVING'],
99
-		$serveur
100
-	);
91
+    $s = sql_select(
92
+        $requete['SELECT'],
93
+        $requete['FROM'],
94
+        $requete['WHERE'],
95
+        implode(' ', $requete['GROUPBY']),
96
+        $requete['ORDERBY'],
97
+        $requete['LIMIT'],
98
+        $requete['HAVING'],
99
+        $serveur
100
+    );
101 101
 
102
-	while (
103
-		$t = sql_fetch($s, $serveur)
104
-		and (!isset($t['score']) or $t['score'] > 0)
105
-	) {
106
-		$id = intval($t[$_id_table]);
102
+    while (
103
+        $t = sql_fetch($s, $serveur)
104
+        and (!isset($t['score']) or $t['score'] > 0)
105
+    ) {
106
+        $id = intval($t[$_id_table]);
107 107
 
108
-		if (
109
-			$options['toutvoir']
110
-			or autoriser('voir', $table, $id)
111
-		) {
112
-			// indiquer les champs concernes
113
-			$champs_vus = [];
114
-			$score = 0;
115
-			$matches = [];
108
+        if (
109
+            $options['toutvoir']
110
+            or autoriser('voir', $table, $id)
111
+        ) {
112
+            // indiquer les champs concernes
113
+            $champs_vus = [];
114
+            $score = 0;
115
+            $matches = [];
116 116
 
117
-			$vu = false;
118
-			foreach ($champs as $champ => $poids) {
119
-				$champ = explode('.', $champ);
120
-				$champ = end($champ);
121
-				// translitteration_rapide uniquement si on est deja en utf-8
122
-				$value = ($GLOBALS['meta']['charset'] == 'utf-8' ? translitteration_rapide($t[$champ]) : translitteration($t[$champ]));
123
-				if (
124
-					$n =
125
-					($options['score'] || $options['matches'])
126
-						? preg_match_all($preg, $value, $regs, PREG_SET_ORDER)
127
-						: preg_match($preg, $value)
128
-				) {
129
-					$vu = true;
117
+            $vu = false;
118
+            foreach ($champs as $champ => $poids) {
119
+                $champ = explode('.', $champ);
120
+                $champ = end($champ);
121
+                // translitteration_rapide uniquement si on est deja en utf-8
122
+                $value = ($GLOBALS['meta']['charset'] == 'utf-8' ? translitteration_rapide($t[$champ]) : translitteration($t[$champ]));
123
+                if (
124
+                    $n =
125
+                    ($options['score'] || $options['matches'])
126
+                        ? preg_match_all($preg, $value, $regs, PREG_SET_ORDER)
127
+                        : preg_match($preg, $value)
128
+                ) {
129
+                    $vu = true;
130 130
 
131
-					if ($options['champs']) {
132
-						$champs_vus[$champ] = $t[$champ];
133
-					}
134
-					if ($options['score']) {
135
-						// compter les points avec un peu de discernement : on pondere par la longueur du match compte en chars
136
-						$score += $poids * strlen(implode('', array_column($regs, 0)));
137
-					}
131
+                    if ($options['champs']) {
132
+                        $champs_vus[$champ] = $t[$champ];
133
+                    }
134
+                    if ($options['score']) {
135
+                        // compter les points avec un peu de discernement : on pondere par la longueur du match compte en chars
136
+                        $score += $poids * strlen(implode('', array_column($regs, 0)));
137
+                    }
138 138
 
139
-					if ($options['matches']) {
140
-						$matches[$champ] = $regs;
141
-					}
139
+                    if ($options['matches']) {
140
+                        $matches[$champ] = $regs;
141
+                    }
142 142
 
143
-					if (
144
-						!$options['champs']
145
-						and !$options['score']
146
-						and !$options['matches']
147
-					) {
148
-						break;
149
-					}
150
-				}
151
-			}
143
+                    if (
144
+                        !$options['champs']
145
+                        and !$options['score']
146
+                        and !$options['matches']
147
+                    ) {
148
+                        break;
149
+                    }
150
+                }
151
+            }
152 152
 
153
-			if ($vu) {
154
-				if (!isset($results)) {
155
-					$results = [];
156
-				}
157
-				$results[$id] = [];
158
-				if ($champs_vus) {
159
-					$results[$id]['champs'] = $champs_vus;
160
-				}
161
-				if ($score) {
162
-					$results[$id]['score'] = $score;
163
-				}
164
-				if ($matches) {
165
-					$results[$id]['matches'] = $matches;
166
-				}
167
-			}
168
-		}
169
-	}
153
+            if ($vu) {
154
+                if (!isset($results)) {
155
+                    $results = [];
156
+                }
157
+                $results[$id] = [];
158
+                if ($champs_vus) {
159
+                    $results[$id]['champs'] = $champs_vus;
160
+                }
161
+                if ($score) {
162
+                    $results[$id]['score'] = $score;
163
+                }
164
+                if ($matches) {
165
+                    $results[$id]['matches'] = $matches;
166
+                }
167
+            }
168
+        }
169
+    }
170 170
 
171 171
 
172
-	// Gerer les donnees associees
173
-	// ici on est un peu naze : pas capables de reconstruire une jointure complexe
174
-	// on ne sait passer que par table de laison en 1 coup
175
-	if (
176
-		isset($jointures[$table])
177
-		and $joints = recherche_en_base(
178
-			$recherche,
179
-			$jointures[$table],
180
-			array_merge($options, ['jointures' => false])
181
-		)
182
-	) {
183
-		include_spip('action/editer_liens');
184
-		$trouver_table = charger_fonction('trouver_table', 'base');
185
-		$cle_depart = id_table_objet($table);
186
-		$table_depart = table_objet($table, $serveur);
187
-		$desc_depart = $trouver_table($table_depart, $serveur);
188
-		$depart_associable = objet_associable($table);
189
-		foreach ($joints as $table_liee => $ids_trouves) {
190
-			// on peut definir une fonction de recherche jointe pour regler les cas particuliers
191
-			if (
192
-				!(
193
-				$rechercher_joints = charger_fonction("rechercher_joints_${table}_${table_liee}", 'inc', true)
194
-				or $rechercher_joints = charger_fonction("rechercher_joints_objet_${table_liee}", 'inc', true)
195
-				or $rechercher_joints = charger_fonction("rechercher_joints_${table}_objet_lie", 'inc', true)
196
-				)
197
-			) {
198
-				$cle_arrivee = id_table_objet($table_liee);
199
-				$table_arrivee = table_objet($table_liee, $serveur);
200
-				$desc_arrivee = $trouver_table($table_arrivee, $serveur);
201
-				// cas simple : $cle_depart dans la table_liee
202
-				if (isset($desc_arrivee['field'][$cle_depart])) {
203
-					$s = sql_select(
204
-						"$cle_depart, $cle_arrivee",
205
-						$desc_arrivee['table_sql'],
206
-						sql_in($cle_arrivee, array_keys($ids_trouves)),
207
-						'',
208
-						'',
209
-						'',
210
-						'',
211
-						$serveur
212
-					);
213
-				} // cas simple : $cle_arrivee dans la table
214
-				elseif (isset($desc_depart['field'][$cle_arrivee])) {
215
-					$s = sql_select(
216
-						"$cle_depart, $cle_arrivee",
217
-						$desc_depart['table_sql'],
218
-						sql_in($cle_arrivee, array_keys($ids_trouves)),
219
-						'',
220
-						'',
221
-						'',
222
-						'',
223
-						$serveur
224
-					);
225
-				}
226
-				// sinon cherchons une table de liaison
227
-				// cas recherche principale article, objet lie document : passer par spip_documents_liens
228
-				elseif ($l = objet_associable($table_liee)) {
229
-					[$primary, $table_liens] = $l;
230
-					$s = sql_select(
231
-						"id_objet as $cle_depart, $primary as $cle_arrivee",
232
-						$table_liens,
233
-						["objet='$table'", sql_in($primary, array_keys($ids_trouves))],
234
-						'',
235
-						'',
236
-						'',
237
-						'',
238
-						$serveur
239
-					);
240
-				} // cas recherche principale auteur, objet lie article: passer par spip_auteurs_liens
241
-				elseif ($l = $depart_associable) {
242
-					[$primary, $table_liens] = $l;
243
-					$s = sql_select(
244
-						"$primary as $cle_depart, id_objet as $cle_arrivee",
245
-						$table_liens,
246
-						["objet='$table_liee'", sql_in('id_objet', array_keys($ids_trouves))],
247
-						'',
248
-						'',
249
-						'',
250
-						'',
251
-						$serveur
252
-					);
253
-				} // cas table de liaison generique spip_xxx_yyy
254
-				elseif (
255
-					$t = $trouver_table($table_arrivee . '_' . $table_depart, $serveur)
256
-					or $t = $trouver_table($table_depart . '_' . $table_arrivee, $serveur)
257
-				) {
258
-					$s = sql_select(
259
-						"$cle_depart,$cle_arrivee",
260
-						$t['table_sql'],
261
-						sql_in($cle_arrivee, array_keys($ids_trouves)),
262
-						'',
263
-						'',
264
-						'',
265
-						'',
266
-						$serveur
267
-					);
268
-				}
269
-			} else {
270
-				[$cle_depart, $cle_arrivee, $s] = $rechercher_joints(
271
-					$table,
272
-					$table_liee,
273
-					array_keys($ids_trouves),
274
-					$serveur
275
-				);
276
-			}
172
+    // Gerer les donnees associees
173
+    // ici on est un peu naze : pas capables de reconstruire une jointure complexe
174
+    // on ne sait passer que par table de laison en 1 coup
175
+    if (
176
+        isset($jointures[$table])
177
+        and $joints = recherche_en_base(
178
+            $recherche,
179
+            $jointures[$table],
180
+            array_merge($options, ['jointures' => false])
181
+        )
182
+    ) {
183
+        include_spip('action/editer_liens');
184
+        $trouver_table = charger_fonction('trouver_table', 'base');
185
+        $cle_depart = id_table_objet($table);
186
+        $table_depart = table_objet($table, $serveur);
187
+        $desc_depart = $trouver_table($table_depart, $serveur);
188
+        $depart_associable = objet_associable($table);
189
+        foreach ($joints as $table_liee => $ids_trouves) {
190
+            // on peut definir une fonction de recherche jointe pour regler les cas particuliers
191
+            if (
192
+                !(
193
+                $rechercher_joints = charger_fonction("rechercher_joints_${table}_${table_liee}", 'inc', true)
194
+                or $rechercher_joints = charger_fonction("rechercher_joints_objet_${table_liee}", 'inc', true)
195
+                or $rechercher_joints = charger_fonction("rechercher_joints_${table}_objet_lie", 'inc', true)
196
+                )
197
+            ) {
198
+                $cle_arrivee = id_table_objet($table_liee);
199
+                $table_arrivee = table_objet($table_liee, $serveur);
200
+                $desc_arrivee = $trouver_table($table_arrivee, $serveur);
201
+                // cas simple : $cle_depart dans la table_liee
202
+                if (isset($desc_arrivee['field'][$cle_depart])) {
203
+                    $s = sql_select(
204
+                        "$cle_depart, $cle_arrivee",
205
+                        $desc_arrivee['table_sql'],
206
+                        sql_in($cle_arrivee, array_keys($ids_trouves)),
207
+                        '',
208
+                        '',
209
+                        '',
210
+                        '',
211
+                        $serveur
212
+                    );
213
+                } // cas simple : $cle_arrivee dans la table
214
+                elseif (isset($desc_depart['field'][$cle_arrivee])) {
215
+                    $s = sql_select(
216
+                        "$cle_depart, $cle_arrivee",
217
+                        $desc_depart['table_sql'],
218
+                        sql_in($cle_arrivee, array_keys($ids_trouves)),
219
+                        '',
220
+                        '',
221
+                        '',
222
+                        '',
223
+                        $serveur
224
+                    );
225
+                }
226
+                // sinon cherchons une table de liaison
227
+                // cas recherche principale article, objet lie document : passer par spip_documents_liens
228
+                elseif ($l = objet_associable($table_liee)) {
229
+                    [$primary, $table_liens] = $l;
230
+                    $s = sql_select(
231
+                        "id_objet as $cle_depart, $primary as $cle_arrivee",
232
+                        $table_liens,
233
+                        ["objet='$table'", sql_in($primary, array_keys($ids_trouves))],
234
+                        '',
235
+                        '',
236
+                        '',
237
+                        '',
238
+                        $serveur
239
+                    );
240
+                } // cas recherche principale auteur, objet lie article: passer par spip_auteurs_liens
241
+                elseif ($l = $depart_associable) {
242
+                    [$primary, $table_liens] = $l;
243
+                    $s = sql_select(
244
+                        "$primary as $cle_depart, id_objet as $cle_arrivee",
245
+                        $table_liens,
246
+                        ["objet='$table_liee'", sql_in('id_objet', array_keys($ids_trouves))],
247
+                        '',
248
+                        '',
249
+                        '',
250
+                        '',
251
+                        $serveur
252
+                    );
253
+                } // cas table de liaison generique spip_xxx_yyy
254
+                elseif (
255
+                    $t = $trouver_table($table_arrivee . '_' . $table_depart, $serveur)
256
+                    or $t = $trouver_table($table_depart . '_' . $table_arrivee, $serveur)
257
+                ) {
258
+                    $s = sql_select(
259
+                        "$cle_depart,$cle_arrivee",
260
+                        $t['table_sql'],
261
+                        sql_in($cle_arrivee, array_keys($ids_trouves)),
262
+                        '',
263
+                        '',
264
+                        '',
265
+                        '',
266
+                        $serveur
267
+                    );
268
+                }
269
+            } else {
270
+                [$cle_depart, $cle_arrivee, $s] = $rechercher_joints(
271
+                    $table,
272
+                    $table_liee,
273
+                    array_keys($ids_trouves),
274
+                    $serveur
275
+                );
276
+            }
277 277
 
278
-			while ($t = is_array($s) ? array_shift($s) : sql_fetch($s)) {
279
-				$id = $t[$cle_depart];
280
-				$joint = $ids_trouves[$t[$cle_arrivee]];
281
-				if (!isset($results)) {
282
-					$results = [];
283
-				}
284
-				if (!isset($results[$id])) {
285
-					$results[$id] = [];
286
-				}
287
-				if (isset($joint['score']) and $joint['score']) {
288
-					if (!isset($results[$id]['score'])) {
289
-						$results[$id]['score'] = 0;
290
-					}
291
-					$results[$id]['score'] += $joint['score'];
292
-				}
293
-				if (isset($joint['champs']) and $joint['champs']) {
294
-					foreach ($joint['champs'] as $c => $val) {
295
-						$results[$id]['champs'][$table_liee . '.' . $c] = $val;
296
-					}
297
-				}
298
-				if (isset($joint['matches']) and $joint['matches']) {
299
-					foreach ($joint['matches'] as $c => $val) {
300
-						$results[$id]['matches'][$table_liee . '.' . $c] = $val;
301
-					}
302
-				}
303
-			}
304
-		}
305
-	}
278
+            while ($t = is_array($s) ? array_shift($s) : sql_fetch($s)) {
279
+                $id = $t[$cle_depart];
280
+                $joint = $ids_trouves[$t[$cle_arrivee]];
281
+                if (!isset($results)) {
282
+                    $results = [];
283
+                }
284
+                if (!isset($results[$id])) {
285
+                    $results[$id] = [];
286
+                }
287
+                if (isset($joint['score']) and $joint['score']) {
288
+                    if (!isset($results[$id]['score'])) {
289
+                        $results[$id]['score'] = 0;
290
+                    }
291
+                    $results[$id]['score'] += $joint['score'];
292
+                }
293
+                if (isset($joint['champs']) and $joint['champs']) {
294
+                    foreach ($joint['champs'] as $c => $val) {
295
+                        $results[$id]['champs'][$table_liee . '.' . $c] = $val;
296
+                    }
297
+                }
298
+                if (isset($joint['matches']) and $joint['matches']) {
299
+                    foreach ($joint['matches'] as $c => $val) {
300
+                        $results[$id]['matches'][$table_liee . '.' . $c] = $val;
301
+                    }
302
+                }
303
+            }
304
+        }
305
+    }
306 306
 
307
-	return $results;
307
+    return $results;
308 308
 }
Please login to merge, or discard this patch.