Completed
Pull Request — master (#40)
by
unknown
04:13
created
ecrire/inc/filtres.php 4 patches
Doc Comments   +12 added lines, -9 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
  *
70 70
  * @param string $fonc
71 71
  *     Nom du filtre
72
- * @param null $default
72
+ * @param string $default
73 73
  *     Nom du filtre appliqué par défaut si celui demandé n'est pas trouvé
74 74
  * @return string
75 75
  *     Fonction PHP correspondante du filtre demandé
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
  *
117 117
  * @see filtrer() Assez proche
118 118
  *
119
- * @param mixed $arg
119
+ * @param string $arg
120 120
  *     Texte (le plus souvent) sur lequel appliquer le filtre
121 121
  * @param string $filtre
122 122
  *     Nom du filtre à appliquer
@@ -673,7 +673,7 @@  discard block
 block discarded – undo
673 673
  *   corriger toutes les `&xx;` en `&xx;`
674 674
  * @param bool $quote
675 675
  *   Échapper aussi les simples quotes en `'`
676
- * @return mixed|string
676
+ * @return string
677 677
  */
678 678
 function entites_html($texte, $tout = false, $quote = true) {
679 679
 	if (!is_string($texte) or !$texte
@@ -1310,7 +1310,7 @@  discard block
 block discarded – undo
1310 1310
  *
1311 1311
  * @param mixed $texte
1312 1312
  *     Contenu de reference a tester
1313
- * @param mixed $sinon
1313
+ * @param string|null $sinon
1314 1314
  *     Contenu a retourner si le contenu de reference est vide
1315 1315
  * @return mixed
1316 1316
  *     Retourne $texte, sinon $sinon.
@@ -1568,7 +1568,7 @@  discard block
 block discarded – undo
1568 1568
  * @param string $letexte
1569 1569
  * @param string $lang
1570 1570
  *     Langue à retrouver (si vide, utilise la langue en cours).
1571
- * @param array $options Options {
1571
+ * @param boolean $options Options {
1572 1572
  * @type bool $echappe_span
1573 1573
  *         True pour échapper les balises span (false par défaut)
1574 1574
  * @type string $lang_defaut
@@ -1658,7 +1658,7 @@  discard block
 block discarded – undo
1658 1658
  * @param string $letexte
1659 1659
  * @param string $lang
1660 1660
  *     Langue à retrouver (si vide, utilise la langue en cours).
1661
- * @param array $options Options {
1661
+ * @param boolean $options Options {
1662 1662
  * @type bool $echappe_span
1663 1663
  *         True pour échapper les balises span (false par défaut)
1664 1664
  * @type string $lang_defaut
@@ -2042,6 +2042,9 @@  discard block
 block discarded – undo
2042 2042
 // Quelques fonctions de calcul arithmetique
2043 2043
 //
2044 2044
 function floatstr($a) { return str_replace(',','.',(string)floatval($a)); }
2045
+/**
2046
+ * @param string $f
2047
+ */
2045 2048
 function strize($f, $a, $b) { return floatstr($f(floatstr($a),floatstr($b))); }
2046 2049
 
2047 2050
 /**
@@ -2184,7 +2187,7 @@  discard block
 block discarded – undo
2184 2187
  *
2185 2188
  * @param string $adresses
2186 2189
  *      Adresse ou liste d'adresse
2187
- * @return bool|string
2190
+ * @return false|string
2188 2191
  *      - false si pas conforme,
2189 2192
  *      - la normalisation de la dernière adresse donnée sinon
2190 2193
  **/
@@ -2518,7 +2521,7 @@  discard block
 block discarded – undo
2518 2521
  * @param int $a
2519 2522
  * @param int $b
2520 2523
  * @param int $c
2521
- * @return int
2524
+ * @return double
2522 2525
  *      Retourne `$a*$b/$c`
2523 2526
  **/
2524 2527
 function regledetrois($a, $b, $c) {
@@ -4551,7 +4554,7 @@  discard block
 block discarded – undo
4551 4554
  *     Nombre d'éléments
4552 4555
  * @param string $objet
4553 4556
  *     Objet
4554
- * @return mixed|string
4557
+ * @return string
4555 4558
  *     Texte traduit du comptage, tel que '3 articles'
4556 4559
  */
4557 4560
 function objet_afficher_nb($nb, $objet) {
Please login to merge, or discard this patch.
Spacing   +130 added lines, -130 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 
93 93
 		return $f;
94 94
 	}
95
-	foreach (array('filtre_' . $fonc, 'filtre_' . $fonc . '_dist', $fonc) as $f) {
95
+	foreach (array('filtre_'.$fonc, 'filtre_'.$fonc.'_dist', $fonc) as $f) {
96 96
 		trouver_filtre_matrice($f); // charge des fichiers spécifiques éventuels
97 97
 		// fonction ou name\space\fonction
98 98
 		if (is_callable($f)) {
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 function spip_version() {
160 160
 	$version = $GLOBALS['spip_version_affichee'];
161 161
 	if ($svn_revision = version_svn_courante(_DIR_RACINE)) {
162
-		$version .= ($svn_revision < 0 ? ' SVN' : '') . ' [' . abs($svn_revision) . ']';
162
+		$version .= ($svn_revision < 0 ? ' SVN' : '').' ['.abs($svn_revision).']';
163 163
 	}
164 164
 
165 165
 	return $version;
@@ -186,15 +186,15 @@  discard block
 block discarded – undo
186 186
 	}
187 187
 
188 188
 	// version installee par paquet ZIP
189
-	if (lire_fichier($dir . '/svn.revision', $c)
189
+	if (lire_fichier($dir.'/svn.revision', $c)
190 190
 		and preg_match(',Revision: (\d+),', $c, $d)
191 191
 	) {
192 192
 		return intval($d[1]);
193 193
 	}
194 194
 
195 195
 	// version installee par SVN
196
-	if (file_exists($dir . '/.svn/wc.db') && class_exists('SQLite3')) {
197
-		$db = new SQLite3($dir . '/.svn/wc.db');
196
+	if (file_exists($dir.'/.svn/wc.db') && class_exists('SQLite3')) {
197
+		$db = new SQLite3($dir.'/.svn/wc.db');
198 198
 		$result = $db->query('SELECT changed_revision FROM nodes WHERE local_relpath = "" LIMIT 1');
199 199
 		if ($result) {
200 200
 			$row = $result->fetchArray();
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 				return -$row['changed_revision'];
203 203
 			}
204 204
 		}
205
-	} else if (lire_fichier($dir . '/.svn/entries', $c)
205
+	} else if (lire_fichier($dir.'/.svn/entries', $c)
206 206
 		and (
207 207
 			(preg_match_all(
208 208
 					',committed-rev="([0-9]+)",', $c, $r1, PREG_PATTERN_ORDER)
@@ -222,11 +222,11 @@  discard block
 block discarded – undo
222 222
 
223 223
 // La matrice est necessaire pour ne filtrer _que_ des fonctions definies dans filtres_images
224 224
 // et laisser passer les fonctions personnelles baptisees image_...
225
-$GLOBALS['spip_matrice']['image_graver'] = true;//'inc/filtres_images_mini.php';
226
-$GLOBALS['spip_matrice']['image_select'] = true;//'inc/filtres_images_mini.php';
227
-$GLOBALS['spip_matrice']['image_reduire'] = true;//'inc/filtres_images_mini.php';
228
-$GLOBALS['spip_matrice']['image_reduire_par'] = true;//'inc/filtres_images_mini.php';
229
-$GLOBALS['spip_matrice']['image_passe_partout'] = true;//'inc/filtres_images_mini.php';
225
+$GLOBALS['spip_matrice']['image_graver'] = true; //'inc/filtres_images_mini.php';
226
+$GLOBALS['spip_matrice']['image_select'] = true; //'inc/filtres_images_mini.php';
227
+$GLOBALS['spip_matrice']['image_reduire'] = true; //'inc/filtres_images_mini.php';
228
+$GLOBALS['spip_matrice']['image_reduire_par'] = true; //'inc/filtres_images_mini.php';
229
+$GLOBALS['spip_matrice']['image_passe_partout'] = true; //'inc/filtres_images_mini.php';
230 230
 
231 231
 $GLOBALS['spip_matrice']['couleur_html_to_hex'] = 'inc/filtres_images_mini.php';
232 232
 $GLOBALS['spip_matrice']['couleur_foncer'] = 'inc/filtres_images_mini.php';
@@ -372,8 +372,8 @@  discard block
 block discarded – undo
372 372
  */
373 373
 function filtre_debug($val, $key = null) {
374 374
 	$debug = (
375
-		is_null($key) ? '' : (var_export($key, true) . " = ")
376
-		) . var_export($val, true);
375
+		is_null($key) ? '' : (var_export($key, true)." = ")
376
+		).var_export($val, true);
377 377
 
378 378
 	include_spip('inc/autoriser');
379 379
 	if (autoriser('webmestre')) {
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 						if (preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)) {
462 462
 							$srcover = $match[1];
463 463
 							array_shift($args);
464
-							array_unshift($args, "<img src='" . $match[1] . "' />");
464
+							array_unshift($args, "<img src='".$match[1]."' />");
465 465
 							$srcover_filter = call_user_func_array($filtre, $args);
466 466
 							$srcover_filter = extraire_attribut($srcover_filter, 'src');
467 467
 							$reduit = str_replace($srcover, $srcover_filter, $reduit);
@@ -811,7 +811,7 @@  discard block
 block discarded – undo
811 811
 	// " -> &quot; et tout ce genre de choses
812 812
 	$u = $GLOBALS['meta']['pcre_u'];
813 813
 	$texte = str_replace("&nbsp;", " ", $texte);
814
-	$texte = preg_replace('/\s{2,}/S' . $u, " ", $texte);
814
+	$texte = preg_replace('/\s{2,}/S'.$u, " ", $texte);
815 815
 	// ne pas echapper les sinqle quotes car certains outils de syndication gerent mal
816 816
 	$texte = entites_html($texte, false, false);
817 817
 	// mais bien echapper les double quotes !
@@ -871,7 +871,7 @@  discard block
 block discarded – undo
871 871
  **/
872 872
 function supprimer_numero($texte) {
873 873
 	return preg_replace(
874
-		",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
874
+		",^[[:space:]]*([0-9]+)([.)]|".chr(194).'?'.chr(176).")[[:space:]]+,S",
875 875
 		"", $texte);
876 876
 }
877 877
 
@@ -896,7 +896,7 @@  discard block
 block discarded – undo
896 896
  **/
897 897
 function recuperer_numero($texte) {
898 898
 	if (preg_match(
899
-		",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
899
+		",^[[:space:]]*([0-9]+)([.)]|".chr(194).'?'.chr(176).")[[:space:]]+,S",
900 900
 		$texte, $regs)) {
901 901
 		return strval($regs[1]);
902 902
 	} else {
@@ -981,8 +981,8 @@  discard block
 block discarded – undo
981 981
  **/
982 982
 function textebrut($texte) {
983 983
 	$u = $GLOBALS['meta']['pcre_u'];
984
-	$texte = preg_replace('/\s+/S' . $u, " ", $texte);
985
-	$texte = preg_replace("/<(p|br)( [^>]*)?" . ">/iS", "\n\n", $texte);
984
+	$texte = preg_replace('/\s+/S'.$u, " ", $texte);
985
+	$texte = preg_replace("/<(p|br)( [^>]*)?".">/iS", "\n\n", $texte);
986 986
 	$texte = preg_replace("/^\n+/", "", $texte);
987 987
 	$texte = preg_replace("/\n+$/", "", $texte);
988 988
 	$texte = preg_replace("/\n +/", "\n", $texte);
@@ -1010,7 +1010,7 @@  discard block
 block discarded – undo
1010 1010
 	if (preg_match_all(",(<a\s+[^>]*https?://[^>]*class=[\"']spip_(out|url)\b[^>]+>),imsS",
1011 1011
 		$texte, $liens, PREG_PATTERN_ORDER)) {
1012 1012
 		foreach ($liens[0] as $a) {
1013
-			$rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel');
1013
+			$rel = 'noopener noreferrer '.extraire_attribut($a, 'rel');
1014 1014
 			$ablank = inserer_attribut($a, 'rel', $rel);
1015 1015
 			$ablank = inserer_attribut($ablank, 'target', '_blank');
1016 1016
 			$texte = str_replace($a, $ablank, $texte);
@@ -1035,7 +1035,7 @@  discard block
 block discarded – undo
1035 1035
 		foreach ($regs[0] as $a) {
1036 1036
 			$rel = extraire_attribut($a, "rel");
1037 1037
 			if (strpos($rel, "nofollow") === false) {
1038
-				$rel = "nofollow" . ($rel ? " $rel" : "");
1038
+				$rel = "nofollow".($rel ? " $rel" : "");
1039 1039
 				$anofollow = inserer_attribut($a, "rel", $rel);
1040 1040
 				$texte = str_replace($a, $anofollow, $texte);
1041 1041
 			}
@@ -1064,7 +1064,7 @@  discard block
 block discarded – undo
1064 1064
 	$u = $GLOBALS['meta']['pcre_u'];
1065 1065
 	$texte = preg_replace("@</p>@iS", "\n", $texte);
1066 1066
 	$texte = preg_replace("@<p\b.*>@UiS", "<br />", $texte);
1067
-	$texte = preg_replace("@^\s*<br />@S" . $u, "", $texte);
1067
+	$texte = preg_replace("@^\s*<br />@S".$u, "", $texte);
1068 1068
 
1069 1069
 	return $texte;
1070 1070
 }
@@ -1094,7 +1094,7 @@  discard block
 block discarded – undo
1094 1094
 		return $texte;
1095 1095
 	}
1096 1096
 	include_spip('inc/texte');
1097
-	$tag = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $texte) ?
1097
+	$tag = preg_match(',</?('._BALISES_BLOCS.')[>[:space:]],iS', $texte) ?
1098 1098
 		'div' : 'span';
1099 1099
 
1100 1100
 	return "<$tag style='word-wrap:break-word;'>$texte</$tag>";
@@ -1203,7 +1203,7 @@  discard block
 block discarded – undo
1203 1203
 function attribut_html($texte, $textebrut = true) {
1204 1204
 	$u = $GLOBALS['meta']['pcre_u'];
1205 1205
 	if ($textebrut) {
1206
-		$texte = preg_replace(array(",\n,", ",\s(?=\s),msS" . $u), array(" ", ""), textebrut($texte));
1206
+		$texte = preg_replace(array(",\n,", ",\s(?=\s),msS".$u), array(" ", ""), textebrut($texte));
1207 1207
 	}
1208 1208
 	$texte = texte_backend($texte);
1209 1209
 	$texte = str_replace(array("'", '"'), array('&#039;', '&#034;'), $texte);
@@ -1232,7 +1232,7 @@  discard block
 block discarded – undo
1232 1232
 	# un message pour abs_url
1233 1233
 	$GLOBALS['mode_abs_url'] = 'url';
1234 1234
 	$url = trim($url);
1235
-	$r = ",^(?:" . _PROTOCOLES_STD . '):?/?/?$,iS';
1235
+	$r = ",^(?:"._PROTOCOLES_STD.'):?/?/?$,iS';
1236 1236
 
1237 1237
 	return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url);
1238 1238
 }
@@ -1434,14 +1434,14 @@  discard block
 block discarded – undo
1434 1434
 	if (strpos($texte, "<") !== false) {
1435 1435
 		include_spip('inc/lien');
1436 1436
 		if (defined('_PREG_MODELE')) {
1437
-			$preg_modeles = "@" . _PREG_MODELE . "@imsS";
1437
+			$preg_modeles = "@"._PREG_MODELE."@imsS";
1438 1438
 			$texte = echappe_html($texte, '', true, $preg_modeles);
1439 1439
 		}
1440 1440
 	}
1441 1441
 
1442 1442
 	$debut = '';
1443 1443
 	$suite = $texte;
1444
-	while ($t = strpos('-' . $suite, "\n", 1)) {
1444
+	while ($t = strpos('-'.$suite, "\n", 1)) {
1445 1445
 		$debut .= substr($suite, 0, $t - 1);
1446 1446
 		$suite = substr($suite, $t);
1447 1447
 		$car = substr($suite, 0, 1);
@@ -1458,11 +1458,11 @@  discard block
 block discarded – undo
1458 1458
 			$suite = substr($suite, strlen($regs[0]));
1459 1459
 		}
1460 1460
 	}
1461
-	$texte = $debut . $suite;
1461
+	$texte = $debut.$suite;
1462 1462
 
1463 1463
 	$texte = echappe_retour($texte);
1464 1464
 
1465
-	return $texte . $fin;
1465
+	return $texte.$fin;
1466 1466
 }
1467 1467
 
1468 1468
 
@@ -1523,7 +1523,7 @@  discard block
 block discarded – undo
1523 1523
 		}
1524 1524
 
1525 1525
 		foreach ($regs as $reg) {
1526
-			$cle = ($reg[1] ? $reg[1] . ':' : '') . $reg[2];
1526
+			$cle = ($reg[1] ? $reg[1].':' : '').$reg[2];
1527 1527
 			$desc = $traduire($cle, $lang, true);
1528 1528
 			$l = $desc->langue;
1529 1529
 			// si pas de traduction, on laissera l'écriture de l'idiome entier dans le texte.
@@ -1636,7 +1636,7 @@  discard block
 block discarded – undo
1636 1636
 					// il ne faut pas echapper en div si propre produit un seul paragraphe
1637 1637
 					include_spip('inc/texte');
1638 1638
 					$trad_propre = preg_replace(",(^<p[^>]*>|</p>$),Uims", "", propre($trad));
1639
-					$mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $trad_propre) ? 'div' : 'span';
1639
+					$mode = preg_match(',</?('._BALISES_BLOCS.')[>[:space:]],iS', $trad_propre) ? 'div' : 'span';
1640 1640
 					$trad = code_echappement($trad, 'multi', false, $mode);
1641 1641
 					$trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
1642 1642
 					if (lang_dir($l) !== lang_dir($lang)) {
@@ -1829,7 +1829,7 @@  discard block
 block discarded – undo
1829 1829
 	if (is_array($balise)) {
1830 1830
 		array_walk(
1831 1831
 			$balise,
1832
-			function(&$a, $key, $t){
1832
+			function(&$a, $key, $t) {
1833 1833
 				$a = extraire_attribut($a, $t);
1834 1834
 			},
1835 1835
 			$attribut
@@ -1916,14 +1916,14 @@  discard block
 block discarded – undo
1916 1916
 
1917 1917
 	if ($old !== null) {
1918 1918
 		// Remplacer l'ancien attribut du meme nom
1919
-		$balise = $r[1] . $insert . $r[5];
1919
+		$balise = $r[1].$insert.$r[5];
1920 1920
 	} else {
1921 1921
 		// preferer une balise " />" (comme <img />)
1922 1922
 		if (preg_match(',/>,', $balise)) {
1923
-			$balise = preg_replace(",\s?/>,S", $insert . " />", $balise, 1);
1923
+			$balise = preg_replace(",\s?/>,S", $insert." />", $balise, 1);
1924 1924
 		} // sinon une balise <a ...> ... </a>
1925 1925
 		else {
1926
-			$balise = preg_replace(",\s?>,S", $insert . ">", $balise, 1);
1926
+			$balise = preg_replace(",\s?>,S", $insert.">", $balise, 1);
1927 1927
 		}
1928 1928
 	}
1929 1929
 
@@ -1965,8 +1965,8 @@  discard block
 block discarded – undo
1965 1965
 //
1966 1966
 // Quelques fonctions de calcul arithmetique
1967 1967
 //
1968
-function floatstr($a) { return str_replace(',','.',(string)floatval($a)); }
1969
-function strize($f, $a, $b) { return floatstr($f(floatstr($a),floatstr($b))); }
1968
+function floatstr($a) { return str_replace(',', '.', (string) floatval($a)); }
1969
+function strize($f, $a, $b) { return floatstr($f(floatstr($a), floatstr($b))); }
1970 1970
 
1971 1971
 /**
1972 1972
  * Additionne 2 nombres
@@ -1986,7 +1986,7 @@  discard block
 block discarded – undo
1986 1986
 function plus($a, $b) {
1987 1987
 	return $a + $b;
1988 1988
 }
1989
-function strplus($a, $b) {return strize('plus', $a, $b);}
1989
+function strplus($a, $b) {return strize('plus', $a, $b); }
1990 1990
 /**
1991 1991
  * Soustrait 2 nombres
1992 1992
  *
@@ -2005,7 +2005,7 @@  discard block
 block discarded – undo
2005 2005
 function moins($a, $b) {
2006 2006
 	return $a - $b;
2007 2007
 }
2008
-function strmoins($a, $b) {return strize('moins', $a, $b);}
2008
+function strmoins($a, $b) {return strize('moins', $a, $b); }
2009 2009
 
2010 2010
 /**
2011 2011
  * Multiplie 2 nombres
@@ -2026,7 +2026,7 @@  discard block
 block discarded – undo
2026 2026
 function mult($a, $b) {
2027 2027
 	return $a * $b;
2028 2028
 }
2029
-function strmult($a, $b) {return strize('mult', $a, $b);}
2029
+function strmult($a, $b) {return strize('mult', $a, $b); }
2030 2030
 
2031 2031
 /**
2032 2032
  * Divise 2 nombres
@@ -2047,7 +2047,7 @@  discard block
 block discarded – undo
2047 2047
 function div($a, $b) {
2048 2048
 	return $b ? $a / $b : 0;
2049 2049
 }
2050
-function strdiv($a, $b) {return strize('div', $a, $b);}
2050
+function strdiv($a, $b) {return strize('div', $a, $b); }
2051 2051
 
2052 2052
 /**
2053 2053
  * Retourne le modulo 2 nombres
@@ -2088,13 +2088,13 @@  discard block
 block discarded – undo
2088 2088
 	if (!defined('_TAGS_NOM_AUTEUR')) {
2089 2089
 		define('_TAGS_NOM_AUTEUR', '');
2090 2090
 	}
2091
-	$tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR));
2091
+	$tags_acceptes = array_unique(explode(',', 'multi,'._TAGS_NOM_AUTEUR));
2092 2092
 	foreach ($tags_acceptes as $tag) {
2093 2093
 		if (strlen($tag)) {
2094
-			$remp1[] = '<' . trim($tag) . '>';
2095
-			$remp1[] = '</' . trim($tag) . '>';
2096
-			$remp2[] = '\x60' . trim($tag) . '\x61';
2097
-			$remp2[] = '\x60/' . trim($tag) . '\x61';
2094
+			$remp1[] = '<'.trim($tag).'>';
2095
+			$remp1[] = '</'.trim($tag).'>';
2096
+			$remp2[] = '\x60'.trim($tag).'\x61';
2097
+			$remp2[] = '\x60/'.trim($tag).'\x61';
2098 2098
 		}
2099 2099
 	}
2100 2100
 	$v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom)));
@@ -2157,7 +2157,7 @@  discard block
 block discarded – undo
2157 2157
 			$s[] = preg_replace(',>[^<]+</a>,S',
2158 2158
 				'>'
2159 2159
 				. http_img_pack('attachment-16.png', $t,
2160
-					'title="' . attribut_html($t) . '"')
2160
+					'title="'.attribut_html($t).'"')
2161 2161
 				. '</a>', $tag);
2162 2162
 		}
2163 2163
 	}
@@ -2218,10 +2218,10 @@  discard block
 block discarded – undo
2218 2218
 	$fichier = basename($url);
2219 2219
 
2220 2220
 	return '<a rel="enclosure"'
2221
-	. ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '')
2222
-	. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2223
-	. ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '')
2224
-	. '>' . $fichier . '</a>';
2221
+	. ($url ? ' href="'.spip_htmlspecialchars($url).'"' : '')
2222
+	. ($type ? ' type="'.spip_htmlspecialchars($type).'"' : '')
2223
+	. ($length ? ' title="'.spip_htmlspecialchars($length).'"' : '')
2224
+	. '>'.$fichier.'</a>';
2225 2225
 }
2226 2226
 
2227 2227
 /**
@@ -2249,9 +2249,9 @@  discard block
 block discarded – undo
2249 2249
 			} # vieux data
2250 2250
 			$fichier = basename($url);
2251 2251
 			$enclosures[] = '<enclosure'
2252
-				. ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '')
2253
-				. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2254
-				. ($length ? ' length="' . $length . '"' : '')
2252
+				. ($url ? ' url="'.spip_htmlspecialchars($url).'"' : '')
2253
+				. ($type ? ' type="'.spip_htmlspecialchars($type).'"' : '')
2254
+				. ($length ? ' length="'.$length.'"' : '')
2255 2255
 				. ' />';
2256 2256
 		}
2257 2257
 	}
@@ -2277,7 +2277,7 @@  discard block
 block discarded – undo
2277 2277
 		if (extraire_attribut($e, rel) == 'tag') {
2278 2278
 			$subjects .= '<dc:subject>'
2279 2279
 				. texte_backend(textebrut($e))
2280
-				. '</dc:subject>' . "\n";
2280
+				. '</dc:subject>'."\n";
2281 2281
 		}
2282 2282
 	}
2283 2283
 
@@ -2313,7 +2313,7 @@  discard block
 block discarded – undo
2313 2313
 	if (is_array($texte)) {
2314 2314
 		array_walk(
2315 2315
 			$texte,
2316
-			function(&$a, $key, $t){
2316
+			function(&$a, $key, $t) {
2317 2317
 				$a = extraire_balise($a, $t);
2318 2318
 			},
2319 2319
 			$tag
@@ -2357,7 +2357,7 @@  discard block
 block discarded – undo
2357 2357
 	if (is_array($texte)) {
2358 2358
 		array_walk(
2359 2359
 			$texte,
2360
-			function(&$a, $key, $t){
2360
+			function(&$a, $key, $t) {
2361 2361
 				$a = extraire_balises($a, $t);
2362 2362
 			},
2363 2363
 			$tag
@@ -2483,7 +2483,7 @@  discard block
 block discarded – undo
2483 2483
 		if ($fond != '404') {
2484 2484
 			$contexte = array_shift($p);
2485 2485
 			$contexte['page'] = $fond;
2486
-			$action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action);
2486
+			$action = preg_replace('/([?]'.preg_quote($fond).'[^&=]*[0-9]+)(&|$)/', '?&', $action);
2487 2487
 		}
2488 2488
 	}
2489 2489
 	// defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url
@@ -2538,9 +2538,9 @@  discard block
 block discarded – undo
2538 2538
 			. '"'
2539 2539
 			. (is_null($val)
2540 2540
 				? ''
2541
-				: ' value="' . entites_html($val) . '"'
2541
+				: ' value="'.entites_html($val).'"'
2542 2542
 			)
2543
-			. ' type="hidden"' . "\n/>";
2543
+			. ' type="hidden"'."\n/>";
2544 2544
 	}
2545 2545
 
2546 2546
 	return join("", $hidden);
@@ -2703,12 +2703,12 @@  discard block
 block discarded – undo
2703 2703
 	if ($pas < 1) {
2704 2704
 		return '';
2705 2705
 	}
2706
-	$ancre = 'pagination' . $nom; // #pagination_articles
2707
-	$debut = 'debut' . $nom; // 'debut_articles'
2706
+	$ancre = 'pagination'.$nom; // #pagination_articles
2707
+	$debut = 'debut'.$nom; // 'debut_articles'
2708 2708
 
2709 2709
 	// n'afficher l'ancre qu'une fois
2710 2710
 	if (!isset($ancres[$ancre])) {
2711
-		$bloc_ancre = $ancres[$ancre] = "<a name='" . $ancre . "' id='" . $ancre . "'></a>";
2711
+		$bloc_ancre = $ancres[$ancre] = "<a name='".$ancre."' id='".$ancre."'></a>";
2712 2712
 	} else {
2713 2713
 		$bloc_ancre = '';
2714 2714
 	}
@@ -2738,7 +2738,7 @@  discard block
 block discarded – undo
2738 2738
 	}
2739 2739
 
2740 2740
 	if ($modele) {
2741
-		$modele = '_' . $modele;
2741
+		$modele = '_'.$modele;
2742 2742
 	}
2743 2743
 
2744 2744
 	return recuperer_fond("modeles/pagination$modele", $pagination, array('trim' => true), $connect);
@@ -2763,7 +2763,7 @@  discard block
 block discarded – undo
2763 2763
 	return preg_replace_callback(
2764 2764
 		",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims",
2765 2765
 		function($x) use ($path) {
2766
-			return "url('" . suivre_lien($path, $x[1]) . "')";
2766
+			return "url('".suivre_lien($path, $x[1])."')";
2767 2767
 		},
2768 2768
 		$contenu
2769 2769
 	);
@@ -2825,14 +2825,14 @@  discard block
 block discarded – undo
2825 2825
 	) {
2826 2826
 		$distant = true;
2827 2827
 		$cssf = parse_url($css);
2828
-		$cssf = $cssf['path'] . ($cssf['query'] ? "?" . $cssf['query'] : "");
2828
+		$cssf = $cssf['path'].($cssf['query'] ? "?".$cssf['query'] : "");
2829 2829
 		$cssf = preg_replace(',[?:&=],', "_", $cssf);
2830 2830
 	} else {
2831 2831
 		$distant = false;
2832 2832
 		$cssf = $css;
2833 2833
 		// 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi
2834 2834
 		//propose (rien a faire dans ce cas)
2835
-		$f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css);
2835
+		$f = preg_replace(',(_rtl)?\.css$,i', '_'.$ndir.'.css', $css);
2836 2836
 		if (@file_exists($f)) {
2837 2837
 			return $f;
2838 2838
 		}
@@ -2842,7 +2842,7 @@  discard block
 block discarded – undo
2842 2842
 	$dir_var = sous_repertoire(_DIR_VAR, 'cache-css');
2843 2843
 	$f = $dir_var
2844 2844
 		. preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf)
2845
-		. '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css';
2845
+		. '.'.substr(md5($cssf), 0, 4).'_'.$ndir.'.css';
2846 2846
 
2847 2847
 	// la css peut etre distante (url absolue !)
2848 2848
 	if ($distant) {
@@ -2887,8 +2887,8 @@  discard block
 block discarded – undo
2887 2887
 		} // si la css_direction commence par $dir_var on la fait passer pour une absolue
2888 2888
 		elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) {
2889 2889
 			$css_direction = substr($css_direction, strlen($dir_var));
2890
-			$src_faux_abs["/@@@@@@/" . $css_direction] = $css_direction;
2891
-			$css_direction = "/@@@@@@/" . $css_direction;
2890
+			$src_faux_abs["/@@@@@@/".$css_direction] = $css_direction;
2891
+			$css_direction = "/@@@@@@/".$css_direction;
2892 2892
 		}
2893 2893
 		$src[] = $regs[0][$k];
2894 2894
 		$src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]);
@@ -2937,7 +2937,7 @@  discard block
 block discarded – undo
2937 2937
 
2938 2938
 	$f = basename($css, '.css');
2939 2939
 	$f = sous_repertoire(_DIR_VAR, 'cache-css')
2940
-		. preg_replace(",(.*?)(_rtl|_ltr)?$,", "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f)
2940
+		. preg_replace(",(.*?)(_rtl|_ltr)?$,", "\\1-urlabs-".substr(md5("$css-urlabs"), 0, 4)."\\2", $f)
2941 2941
 		. '.css';
2942 2942
 
2943 2943
 	if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) {
@@ -2946,7 +2946,7 @@  discard block
 block discarded – undo
2946 2946
 
2947 2947
 	if ($url_absolue_css == $css) {
2948 2948
 		if (strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0
2949
-			or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu)
2949
+			or !lire_fichier(_DIR_RACINE.substr($css, $l), $contenu)
2950 2950
 		) {
2951 2951
 			include_spip('inc/distant');
2952 2952
 			if (!$contenu = recuperer_page($css)) {
@@ -3056,7 +3056,7 @@  discard block
 block discarded – undo
3056 3056
 	$expression = str_replace("\/", "/", $expression);
3057 3057
 	$expression = str_replace("/", "\/", $expression);
3058 3058
 
3059
-	if (preg_match('/' . $expression . '/' . $modif, $texte, $r)) {
3059
+	if (preg_match('/'.$expression.'/'.$modif, $texte, $r)) {
3060 3060
 		if (isset($r[$capte])) {
3061 3061
 			return $r[$capte];
3062 3062
 		} else {
@@ -3094,7 +3094,7 @@  discard block
 block discarded – undo
3094 3094
 	$expression = str_replace("\/", "/", $expression);
3095 3095
 	$expression = str_replace("/", "\/", $expression);
3096 3096
 
3097
-	return preg_replace('/' . $expression . '/' . $modif, $replace, $texte);
3097
+	return preg_replace('/'.$expression.'/'.$modif, $replace, $texte);
3098 3098
 }
3099 3099
 
3100 3100
 
@@ -3113,7 +3113,7 @@  discard block
 block discarded – undo
3113 3113
 function traiter_doublons_documents(&$doublons, $letexte) {
3114 3114
 
3115 3115
 	// Verifier dans le texte & les notes (pas beau, helas)
3116
-	$t = $letexte . $GLOBALS['les_notes'];
3116
+	$t = $letexte.$GLOBALS['les_notes'];
3117 3117
 
3118 3118
 	if (strstr($t, 'spip_document_') // evite le preg_match_all si inutile
3119 3119
 		and preg_match_all(
@@ -3123,7 +3123,7 @@  discard block
 block discarded – undo
3123 3123
 		if (!isset($doublons['documents'])) {
3124 3124
 			$doublons['documents'] = "";
3125 3125
 		}
3126
-		$doublons['documents'] .= "," . join(',', $matches[1]);
3126
+		$doublons['documents'] .= ",".join(',', $matches[1]);
3127 3127
 	}
3128 3128
 
3129 3129
 	return $letexte;
@@ -3180,7 +3180,7 @@  discard block
 block discarded – undo
3180 3180
 	if ($env) {
3181 3181
 		foreach ($env as $i => $j) {
3182 3182
 			if (is_string($j) and !in_array($i, $ignore_params)) {
3183
-				$texte .= "<param name='" . $i . "'\n\tvalue='" . $j . "' />";
3183
+				$texte .= "<param name='".$i."'\n\tvalue='".$j."' />";
3184 3184
 			}
3185 3185
 		}
3186 3186
 	}
@@ -3219,7 +3219,7 @@  discard block
 block discarded – undo
3219 3219
 	if ($env) {
3220 3220
 		foreach ($env as $i => $j) {
3221 3221
 			if (is_string($j) and !in_array($i, $ignore_params)) {
3222
-				$texte .= $i . "='" . $j . "' ";
3222
+				$texte .= $i."='".$j."' ";
3223 3223
 			}
3224 3224
 		}
3225 3225
 	}
@@ -3315,12 +3315,12 @@  discard block
 block discarded – undo
3315 3315
 				return "";
3316 3316
 			}
3317 3317
 		}
3318
-		$atts .= " width='" . $largeur . "' height='" . $hauteur . "'";
3318
+		$atts .= " width='".$largeur."' height='".$hauteur."'";
3319 3319
 	}
3320 3320
 
3321
-	return "<img src='$img' alt='" . attribut_html($alt ? $alt : $title) . "'"
3322
-	. ($title ? ' title="' . attribut_html($title) . '"' : '')
3323
-	. " " . ltrim($atts)
3321
+	return "<img src='$img' alt='".attribut_html($alt ? $alt : $title)."'"
3322
+	. ($title ? ' title="'.attribut_html($title).'"' : '')
3323
+	. " ".ltrim($atts)
3324 3324
 	. " />";
3325 3325
 }
3326 3326
 
@@ -3332,7 +3332,7 @@  discard block
 block discarded – undo
3332 3332
  * @return string
3333 3333
  */
3334 3334
 function http_style_background($img, $att = '') {
3335
-	return " style='background" . ($att ? "" : "-image") . ": url(\"" . chemin_image($img) . "\")" . ($att ? (' ' . $att) : '') . ";'";
3335
+	return " style='background".($att ? "" : "-image").": url(\"".chemin_image($img)."\")".($att ? (' '.$att) : '').";'";
3336 3336
 }
3337 3337
 
3338 3338
 /**
@@ -3347,7 +3347,7 @@  discard block
 block discarded – undo
3347 3347
  *     Code HTML de la balise IMG
3348 3348
  */
3349 3349
 function filtre_balise_img_dist($img, $alt = "", $class = "") {
3350
-	return http_img_pack($img, $alt, $class ? " class='" . attribut_html($class) . "'" : '', '',
3350
+	return http_img_pack($img, $alt, $class ? " class='".attribut_html($class)."'" : '', '',
3351 3351
 		array('chemin_image' => false, 'utiliser_suffixe_size' => false));
3352 3352
 }
3353 3353
 
@@ -3379,11 +3379,11 @@  discard block
 block discarded – undo
3379 3379
 	if ($class) {
3380 3380
 		$balise_svg = inserer_attribut($balise_svg, 'class', $class);
3381 3381
 	}
3382
-	if ($alt){
3382
+	if ($alt) {
3383 3383
 		$balise_svg = inserer_attribut($balise_svg, 'role', 'img');
3384
-		$id = "img-svg-title-" . substr(md5("$file:$svg:$alt"),0,4);
3384
+		$id = "img-svg-title-".substr(md5("$file:$svg:$alt"), 0, 4);
3385 3385
 		$balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id);
3386
-		$title = "<title id=\"$id\">" . entites_html($alt)."</title>\n";
3386
+		$title = "<title id=\"$id\">".entites_html($alt)."</title>\n";
3387 3387
 		$balise_svg .= $title;
3388 3388
 	}
3389 3389
 	else {
@@ -3417,7 +3417,7 @@  discard block
 block discarded – undo
3417 3417
 	$texte = '';
3418 3418
 	if (is_array($tableau)) {
3419 3419
 		foreach ($tableau as $k => $v) {
3420
-			$res = recuperer_fond('modeles/' . $modele,
3420
+			$res = recuperer_fond('modeles/'.$modele,
3421 3421
 				array_merge(array('cle' => $k), (is_array($v) ? $v : array('valeur' => $v)))
3422 3422
 			);
3423 3423
 			$texte .= $res;
@@ -3594,7 +3594,7 @@  discard block
 block discarded – undo
3594 3594
 	}
3595 3595
 
3596 3596
 	$c = serialize($c);
3597
-	$cle = calculer_cle_action($form . $c);
3597
+	$cle = calculer_cle_action($form.$c);
3598 3598
 	$c = "$cle:$c";
3599 3599
 
3600 3600
 	// on ne stocke pas les contextes dans des fichiers caches
@@ -3644,15 +3644,15 @@  discard block
 block discarded – undo
3644 3644
 	}
3645 3645
 	// toujours encoder l'url source dans le bloc ajax
3646 3646
 	$r = self();
3647
-	$r = ' data-origin="' . $r . '"';
3647
+	$r = ' data-origin="'.$r.'"';
3648 3648
 	$class = 'ajaxbloc';
3649 3649
 	if ($ajaxid and is_string($ajaxid)) {
3650 3650
 		// ajaxid est normalement conforme a un nom de classe css
3651 3651
 		// on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution
3652
-		$class .= ' ajax-id-' . entites_html($ajaxid);
3652
+		$class .= ' ajax-id-'.entites_html($ajaxid);
3653 3653
 	}
3654 3654
 
3655
-	return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
3655
+	return "<div class='$class' "."data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
3656 3656
 }
3657 3657
 
3658 3658
 /**
@@ -3691,11 +3691,11 @@  discard block
 block discarded – undo
3691 3691
 	// extraire la signature en debut de contexte
3692 3692
 	// et la verifier avant de deserializer
3693 3693
 	// format : signature:donneesserializees
3694
-	if ($p = strpos($c,":")){
3695
-		$cle = substr($c,0,$p);
3696
-		$c = substr($c,$p+1);
3694
+	if ($p = strpos($c, ":")) {
3695
+		$cle = substr($c, 0, $p);
3696
+		$c = substr($c, $p + 1);
3697 3697
 
3698
-		if ($cle == calculer_cle_action($form . $c)) {
3698
+		if ($cle == calculer_cle_action($form.$c)) {
3699 3699
 			$env = @unserialize($c);
3700 3700
 			return $env;
3701 3701
 		}
@@ -3796,9 +3796,9 @@  discard block
 block discarded – undo
3796 3796
 	} else {
3797 3797
 		$bal = 'a';
3798 3798
 		$att = "href='$url'"
3799
-			. ($title ? " title='" . attribut_html($title) . "'" : '')
3800
-			. ($class ? " class='" . attribut_html($class) . "'" : '')
3801
-			. ($rel ? " rel='" . attribut_html($rel) . "'" : '')
3799
+			. ($title ? " title='".attribut_html($title)."'" : '')
3800
+			. ($class ? " class='".attribut_html($class)."'" : '')
3801
+			. ($rel ? " rel='".attribut_html($rel)."'" : '')
3802 3802
 			. $evt;
3803 3803
 	}
3804 3804
 	if ($libelle === null) {
@@ -3872,7 +3872,7 @@  discard block
 block discarded – undo
3872 3872
 	}
3873 3873
 
3874 3874
 	// ajouter le type d'objet dans la class de l'icone
3875
-	$class .= " " . substr(basename($fond), 0, -4);
3875
+	$class .= " ".substr(basename($fond), 0, -4);
3876 3876
 
3877 3877
 	$alt = attribut_html($texte);
3878 3878
 	$title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ?
@@ -3897,7 +3897,7 @@  discard block
 block discarded – undo
3897 3897
 	if ($fonction) {
3898 3898
 		// 2 images pour composer l'icone : le fond (article) en background,
3899 3899
 		// la fonction (new) en image
3900
-		$icone = http_img_pack($fonction, $alt, "width='$size' height='$size'\n" .
3900
+		$icone = http_img_pack($fonction, $alt, "width='$size' height='$size'\n".
3901 3901
 			http_style_background($fond));
3902 3902
 	} else {
3903 3903
 		$icone = http_img_pack($fond, $alt, "width='$size' height='$size'");
@@ -4131,13 +4131,13 @@  discard block
 block discarded – undo
4131 4131
 	$res = "";
4132 4132
 	foreach ($boutons as $page => $detail) {
4133 4133
 		if ($detail->icone and strlen(trim($detail->icone))) {
4134
-			$res .= "\n.navigation_avec_icones #bando1_$page {background-image:url(" . $detail->icone . ");}";
4134
+			$res .= "\n.navigation_avec_icones #bando1_$page {background-image:url(".$detail->icone.");}";
4135 4135
 		}
4136 4136
 		$selecteur = (in_array($page, array('outils_rapides', 'outils_collaboratifs')) ? "" : ".navigation_avec_icones ");
4137 4137
 		if (is_array($detail->sousmenu)) {
4138 4138
 			foreach ($detail->sousmenu as $souspage => $sousdetail) {
4139 4139
 				if ($sousdetail->icone and strlen(trim($sousdetail->icone))) {
4140
-					$res .= "\n$selecteur.bando2_$souspage {background-image:url(" . $sousdetail->icone . ");}";
4140
+					$res .= "\n$selecteur.bando2_$souspage {background-image:url(".$sousdetail->icone.");}";
4141 4141
 				}
4142 4142
 			}
4143 4143
 		}
@@ -4163,17 +4163,17 @@  discard block
 block discarded – undo
4163 4163
  */
4164 4164
 function bouton_action($libelle, $url, $class = "", $confirm = "", $title = "", $callback = "") {
4165 4165
 	if ($confirm) {
4166
-		$confirm = "confirm(\"" . attribut_html($confirm) . "\")";
4166
+		$confirm = "confirm(\"".attribut_html($confirm)."\")";
4167 4167
 		if ($callback) {
4168 4168
 			$callback = "$confirm?($callback):false";
4169 4169
 		} else {
4170 4170
 			$callback = $confirm;
4171 4171
 		}
4172 4172
 	}
4173
-	$onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : "";
4173
+	$onclick = $callback ? " onclick='return ".addcslashes($callback, "'")."'" : "";
4174 4174
 	$title = $title ? " title='$title'" : "";
4175 4175
 
4176
-	return "<form class='bouton_action_post $class' method='post' action='$url'><div>" . form_hidden($url)
4176
+	return "<form class='bouton_action_post $class' method='post' action='$url'><div>".form_hidden($url)
4177 4177
 	. "<button type='submit' class='submit'$title$onclick>$libelle</button></div></form>";
4178 4178
 }
4179 4179
 
@@ -4312,14 +4312,14 @@  discard block
 block discarded – undo
4312 4312
 		$champ_titre = "";
4313 4313
 		if ($demande_titre) {
4314 4314
 			// si pas de titre declare mais champ titre, il sera peuple par le select *
4315
-			$champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : '';
4315
+			$champ_titre = (!empty($desc['titre'])) ? ', '.$desc['titre'] : '';
4316 4316
 		}
4317 4317
 		include_spip('base/abstract_sql');
4318 4318
 		include_spip('base/connect_sql');
4319 4319
 		$objets[$type_objet][$id_objet] = sql_fetsel(
4320
-			'*' . $champ_titre,
4320
+			'*'.$champ_titre,
4321 4321
 			$desc['table_sql'],
4322
-			id_table_objet($type_objet) . ' = ' . intval($id_objet)
4322
+			id_table_objet($type_objet).' = '.intval($id_objet)
4323 4323
 		);
4324 4324
 	}
4325 4325
 
@@ -4389,7 +4389,7 @@  discard block
 block discarded – undo
4389 4389
 		return $texte;
4390 4390
 	}
4391 4391
 
4392
-	$traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement);
4392
+	$traitement = str_replace('%s', "'".texte_script($texte)."'", $traitement);
4393 4393
 
4394 4394
 	// Fournir $connect et $Pile[0] au traitement si besoin
4395 4395
 	$Pile = array(0 => $env);
@@ -4423,7 +4423,7 @@  discard block
 block discarded – undo
4423 4423
 	}
4424 4424
 	$url = generer_url_entite($id_objet, $objet, '', '', $connect);
4425 4425
 
4426
-	return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . "</a>";
4426
+	return "<a href='$url' class='$objet'>".couper($titre, $longueur)."</a>";
4427 4427
 }
4428 4428
 
4429 4429
 
@@ -4442,10 +4442,10 @@  discard block
 block discarded – undo
4442 4442
 function wrap($texte, $wrap) {
4443 4443
 	$balises = extraire_balises($wrap);
4444 4444
 	if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) {
4445
-		$texte = $wrap . $texte;
4445
+		$texte = $wrap.$texte;
4446 4446
 		$regs = array_reverse($regs[1]);
4447
-		$wrap = "</" . implode("></", $regs) . ">";
4448
-		$texte = $texte . $wrap;
4447
+		$wrap = "</".implode("></", $regs).">";
4448
+		$texte = $texte.$wrap;
4449 4449
 	}
4450 4450
 
4451 4451
 	return $texte;
@@ -4476,7 +4476,7 @@  discard block
 block discarded – undo
4476 4476
 
4477 4477
 	// caster $u en array si besoin
4478 4478
 	if (is_object($u)) {
4479
-		$u = (array)$u;
4479
+		$u = (array) $u;
4480 4480
 	}
4481 4481
 
4482 4482
 	if (is_array($u)) {
@@ -4497,7 +4497,7 @@  discard block
 block discarded – undo
4497 4497
 		// sinon on passe a la ligne et on indente
4498 4498
 		$i_str = str_pad("", $indent, " ");
4499 4499
 		foreach ($u as $k => $v) {
4500
-			$out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2);
4500
+			$out .= $join.$i_str."$k: ".filtre_print_dist($v, $join, $indent + 2);
4501 4501
 		}
4502 4502
 
4503 4503
 		return $out;
@@ -4550,7 +4550,7 @@  discard block
 block discarded – undo
4550 4550
  * @return string
4551 4551
  */
4552 4552
 function objet_icone($objet, $taille = 24) {
4553
-	$icone = objet_info($objet, 'icone_objet') . "-" . $taille . ".png";
4553
+	$icone = objet_info($objet, 'icone_objet')."-".$taille.".png";
4554 4554
 	$icone = chemin_image($icone);
4555 4555
 	$balise_img = charger_filtre('balise_img');
4556 4556
 
@@ -4574,12 +4574,12 @@  discard block
 block discarded – undo
4574 4574
  * @param array $options
4575 4575
  * @return string
4576 4576
  */
4577
-function objet_T($objet, $chaine, $args = array(), $options = array()){
4578
-	$chaine = explode(':',$chaine);
4579
-	if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, array('force'=>false)))) {
4577
+function objet_T($objet, $chaine, $args = array(), $options = array()) {
4578
+	$chaine = explode(':', $chaine);
4579
+	if ($t = _T($objet.':'.end($chaine), $args, array_merge($options, array('force'=>false)))) {
4580 4580
 		return $t;
4581 4581
 	}
4582
-	$chaine = implode(':',$chaine);
4582
+	$chaine = implode(':', $chaine);
4583 4583
 	return _T($chaine, $args, $options);
4584 4584
 }
4585 4585
 
@@ -4639,11 +4639,11 @@  discard block
 block discarded – undo
4639 4639
 	$cache = recuperer_fond($fond, $contexte, $options, $connect);
4640 4640
 
4641 4641
 	// calculer le nom de la css
4642
-	$dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension);
4642
+	$dir_var = sous_repertoire(_DIR_VAR, 'cache-'.$extension);
4643 4643
 	$nom_safe = preg_replace(",\W,", '_', str_replace('.', '_', $fond));
4644 4644
 	$contexte_implicite = calculer_contexte_implicite();
4645
-	$filename = $dir_var . $extension . "dyn-$nom_safe-"
4646
-		. substr(md5($fond . serialize($contexte_implicite) . serialize($contexte) . $connect), 0, 8)
4645
+	$filename = $dir_var.$extension."dyn-$nom_safe-"
4646
+		. substr(md5($fond.serialize($contexte_implicite).serialize($contexte).$connect), 0, 8)
4647 4647
 		. ".$extension";
4648 4648
 
4649 4649
 	// mettre a jour le fichier si il n'existe pas
@@ -4651,8 +4651,8 @@  discard block
 block discarded – undo
4651 4651
 	// le dernier fichier produit est toujours suffixe par .last
4652 4652
 	// et recopie sur le fichier cible uniquement si il change
4653 4653
 	if (!file_exists($filename)
4654
-		or !file_exists($filename . ".last")
4655
-		or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . ".last") < $cache['lastmodified'])
4654
+		or !file_exists($filename.".last")
4655
+		or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename.".last") < $cache['lastmodified'])
4656 4656
 		or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')
4657 4657
 	) {
4658 4658
 		$contenu = $cache['texte'];
@@ -4671,15 +4671,15 @@  discard block
 block discarded – undo
4671 4671
 			}
4672 4672
 			// pas de date dans le commentaire car sinon ca invalide le md5 et force la maj
4673 4673
 			// mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non
4674
-			$comment .= "}\n   md5:" . md5($contenu) . " */\n";
4674
+			$comment .= "}\n   md5:".md5($contenu)." */\n";
4675 4675
 		}
4676 4676
 		// et ecrire le fichier
4677
-		ecrire_fichier($filename . ".last", $comment . $contenu);
4677
+		ecrire_fichier($filename.".last", $comment.$contenu);
4678 4678
 		// regarder si on recopie
4679 4679
 		if (!file_exists($filename)
4680
-			or md5_file($filename) !== md5_file($filename . ".last")
4680
+			or md5_file($filename) !== md5_file($filename.".last")
4681 4681
 		) {
4682
-			@copy($filename . ".last", $filename);
4682
+			@copy($filename.".last", $filename);
4683 4683
 			clearstatcache(true, $filename); // eviter que PHP ne reserve le vieux timestamp
4684 4684
 		}
4685 4685
 	}
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -3385,8 +3385,7 @@
 block discarded – undo
3385 3385
 		$balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id);
3386 3386
 		$title = "<title id=\"$id\">" . entites_html($alt)."</title>\n";
3387 3387
 		$balise_svg .= $title;
3388
-	}
3389
-	else {
3388
+	} else {
3390 3389
 		$balise_svg = inserer_attribut($balise_svg, 'aria-hidden', 'true');
3391 3390
 	}
3392 3391
 	$svg = str_replace($balise_svg_source, $balise_svg, $svg);
Please login to merge, or discard this patch.
Indentation   +1979 added lines, -1979 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @package SPIP\Core\Filtres
17 17
  **/
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 include_spip('inc/charsets');
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
  * @return string Fonction PHP correspondante du filtre
43 43
  */
44 44
 function charger_filtre($fonc, $default = 'filtre_identite_dist') {
45
-	include_spip('public/parametrer'); // inclure les fichiers fonctions
46
-	return chercher_filtre($fonc, $default);
45
+    include_spip('public/parametrer'); // inclure les fichiers fonctions
46
+    return chercher_filtre($fonc, $default);
47 47
 }
48 48
 
49 49
 /**
@@ -75,36 +75,36 @@  discard block
 block discarded – undo
75 75
  *     Fonction PHP correspondante du filtre demandé
76 76
  */
77 77
 function chercher_filtre($fonc, $default = null) {
78
-	if (!$fonc) {
79
-		return $default;
80
-	}
81
-	// Cas des types mime, sans confondre avec les appels de fonction de classe
82
-	// Foo::Bar
83
-	// qui peuvent etre avec un namespace : space\Foo::Bar
84
-	if (preg_match(',^[\w]+/,', $fonc)) {
85
-		$nom = preg_replace(',\W,', '_', $fonc);
86
-		$f = chercher_filtre($nom);
87
-		// cas du sous-type MIME sans filtre associe, passer au type:
88
-		// si filtre_text_plain pas defini, passe a filtre_text
89
-		if (!$f and $nom !== $fonc) {
90
-			$f = chercher_filtre(preg_replace(',\W.*$,', '', $fonc));
91
-		}
92
-
93
-		return $f;
94
-	}
95
-	foreach (array('filtre_' . $fonc, 'filtre_' . $fonc . '_dist', $fonc) as $f) {
96
-		trouver_filtre_matrice($f); // charge des fichiers spécifiques éventuels
97
-		// fonction ou name\space\fonction
98
-		if (is_callable($f)) {
99
-			return $f;
100
-		}
101
-		// méthode statique d'une classe Classe::methode ou name\space\Classe::methode
102
-		elseif (false === strpos($f, '::') and is_callable(array($f))) {
103
-			return $f;
104
-		}
105
-	}
106
-
107
-	return $default;
78
+    if (!$fonc) {
79
+        return $default;
80
+    }
81
+    // Cas des types mime, sans confondre avec les appels de fonction de classe
82
+    // Foo::Bar
83
+    // qui peuvent etre avec un namespace : space\Foo::Bar
84
+    if (preg_match(',^[\w]+/,', $fonc)) {
85
+        $nom = preg_replace(',\W,', '_', $fonc);
86
+        $f = chercher_filtre($nom);
87
+        // cas du sous-type MIME sans filtre associe, passer au type:
88
+        // si filtre_text_plain pas defini, passe a filtre_text
89
+        if (!$f and $nom !== $fonc) {
90
+            $f = chercher_filtre(preg_replace(',\W.*$,', '', $fonc));
91
+        }
92
+
93
+        return $f;
94
+    }
95
+    foreach (array('filtre_' . $fonc, 'filtre_' . $fonc . '_dist', $fonc) as $f) {
96
+        trouver_filtre_matrice($f); // charge des fichiers spécifiques éventuels
97
+        // fonction ou name\space\fonction
98
+        if (is_callable($f)) {
99
+            return $f;
100
+        }
101
+        // méthode statique d'une classe Classe::methode ou name\space\Classe::methode
102
+        elseif (false === strpos($f, '::') and is_callable(array($f))) {
103
+            return $f;
104
+        }
105
+    }
106
+
107
+    return $default;
108 108
 }
109 109
 
110 110
 /**
@@ -128,20 +128,20 @@  discard block
 block discarded – undo
128 128
  *     Chaîne vide sinon (filtre introuvable).
129 129
  **/
130 130
 function appliquer_filtre($arg, $filtre, $force = null) {
131
-	$f = chercher_filtre($filtre);
132
-	if (!$f) {
133
-		if (!$force) {
134
-			return '';
135
-		} else {
136
-			return $arg;
137
-		}
138
-	}
131
+    $f = chercher_filtre($filtre);
132
+    if (!$f) {
133
+        if (!$force) {
134
+            return '';
135
+        } else {
136
+            return $arg;
137
+        }
138
+    }
139 139
 
140
-	$args = func_get_args();
141
-	array_shift($args); // enlever $arg
142
-	array_shift($args); // enlever $filtre
143
-	array_unshift($args, $arg); // remettre $arg
144
-	return call_user_func_array($f, $args);
140
+    $args = func_get_args();
141
+    array_shift($args); // enlever $arg
142
+    array_shift($args); // enlever $filtre
143
+    array_unshift($args, $arg); // remettre $arg
144
+    return call_user_func_array($f, $args);
145 145
 }
146 146
 
147 147
 /**
@@ -157,12 +157,12 @@  discard block
 block discarded – undo
157 157
  *     Version de SPIP
158 158
  **/
159 159
 function spip_version() {
160
-	$version = $GLOBALS['spip_version_affichee'];
161
-	if ($svn_revision = version_svn_courante(_DIR_RACINE)) {
162
-		$version .= ($svn_revision < 0 ? ' SVN' : '') . ' [' . abs($svn_revision) . ']';
163
-	}
160
+    $version = $GLOBALS['spip_version_affichee'];
161
+    if ($svn_revision = version_svn_courante(_DIR_RACINE)) {
162
+        $version .= ($svn_revision < 0 ? ' SVN' : '') . ' [' . abs($svn_revision) . ']';
163
+    }
164 164
 
165
-	return $version;
165
+    return $version;
166 166
 }
167 167
 
168 168
 
@@ -181,43 +181,43 @@  discard block
 block discarded – undo
181 181
  *
182 182
  **/
183 183
 function version_svn_courante($dir) {
184
-	if (!$dir) {
185
-		$dir = '.';
186
-	}
187
-
188
-	// version installee par paquet ZIP
189
-	if (lire_fichier($dir . '/svn.revision', $c)
190
-		and preg_match(',Revision: (\d+),', $c, $d)
191
-	) {
192
-		return intval($d[1]);
193
-	}
194
-
195
-	// version installee par SVN
196
-	if (file_exists($dir . '/.svn/wc.db') && class_exists('SQLite3')) {
197
-		$db = new SQLite3($dir . '/.svn/wc.db');
198
-		$result = $db->query('SELECT changed_revision FROM nodes WHERE local_relpath = "" LIMIT 1');
199
-		if ($result) {
200
-			$row = $result->fetchArray();
201
-			if ($row['changed_revision'] != "") {
202
-				return -$row['changed_revision'];
203
-			}
204
-		}
205
-	} else if (lire_fichier($dir . '/.svn/entries', $c)
206
-		and (
207
-			(preg_match_all(
208
-					',committed-rev="([0-9]+)",', $c, $r1, PREG_PATTERN_ORDER)
209
-				and $v = max($r1[1])
210
-			)
211
-			or
212
-			(preg_match(',^\d.*dir[\r\n]+(\d+),ms', $c, $r1) # svn >= 1.4
213
-				and $v = $r1[1]
214
-			))
215
-	) {
216
-		return -$v;
217
-	}
218
-
219
-	// Bug ou paquet fait main
220
-	return 0;
184
+    if (!$dir) {
185
+        $dir = '.';
186
+    }
187
+
188
+    // version installee par paquet ZIP
189
+    if (lire_fichier($dir . '/svn.revision', $c)
190
+        and preg_match(',Revision: (\d+),', $c, $d)
191
+    ) {
192
+        return intval($d[1]);
193
+    }
194
+
195
+    // version installee par SVN
196
+    if (file_exists($dir . '/.svn/wc.db') && class_exists('SQLite3')) {
197
+        $db = new SQLite3($dir . '/.svn/wc.db');
198
+        $result = $db->query('SELECT changed_revision FROM nodes WHERE local_relpath = "" LIMIT 1');
199
+        if ($result) {
200
+            $row = $result->fetchArray();
201
+            if ($row['changed_revision'] != "") {
202
+                return -$row['changed_revision'];
203
+            }
204
+        }
205
+    } else if (lire_fichier($dir . '/.svn/entries', $c)
206
+        and (
207
+            (preg_match_all(
208
+                    ',committed-rev="([0-9]+)",', $c, $r1, PREG_PATTERN_ORDER)
209
+                and $v = max($r1[1])
210
+            )
211
+            or
212
+            (preg_match(',^\d.*dir[\r\n]+(\d+),ms', $c, $r1) # svn >= 1.4
213
+                and $v = $r1[1]
214
+            ))
215
+    ) {
216
+        return -$v;
217
+    }
218
+
219
+    // Bug ou paquet fait main
220
+    return 0;
221 221
 }
222 222
 
223 223
 // La matrice est necessaire pour ne filtrer _que_ des fonctions definies dans filtres_images
@@ -261,18 +261,18 @@  discard block
 block discarded – undo
261 261
  *     Code HTML retourné par le filtre
262 262
  **/
263 263
 function filtrer($filtre) {
264
-	$tous = func_get_args();
265
-	if (trouver_filtre_matrice($filtre) and substr($filtre, 0, 6) == 'image_') {
266
-		return image_filtrer($tous);
267
-	} elseif ($f = chercher_filtre($filtre)) {
268
-		array_shift($tous);
269
-		return call_user_func_array($f, $tous);
270
-	} else {
271
-		// le filtre n'existe pas, on provoque une erreur
272
-		$msg = array('zbug_erreur_filtre', array('filtre' => texte_script($filtre)));
273
-		erreur_squelette($msg);
274
-		return '';
275
-	}
264
+    $tous = func_get_args();
265
+    if (trouver_filtre_matrice($filtre) and substr($filtre, 0, 6) == 'image_') {
266
+        return image_filtrer($tous);
267
+    } elseif ($f = chercher_filtre($filtre)) {
268
+        array_shift($tous);
269
+        return call_user_func_array($f, $tous);
270
+    } else {
271
+        // le filtre n'existe pas, on provoque une erreur
272
+        $msg = array('zbug_erreur_filtre', array('filtre' => texte_script($filtre)));
273
+        erreur_squelette($msg);
274
+        return '';
275
+    }
276 276
 }
277 277
 
278 278
 /**
@@ -289,11 +289,11 @@  discard block
 block discarded – undo
289 289
  * @return bool true si on trouve le filtre dans la matrice, false sinon.
290 290
  */
291 291
 function trouver_filtre_matrice($filtre) {
292
-	if (isset($GLOBALS['spip_matrice'][$filtre]) and is_string($f = $GLOBALS['spip_matrice'][$filtre])) {
293
-		find_in_path($f, '', true);
294
-		$GLOBALS['spip_matrice'][$filtre] = true;
295
-	}
296
-	return !empty($GLOBALS['spip_matrice'][$filtre]);
292
+    if (isset($GLOBALS['spip_matrice'][$filtre]) and is_string($f = $GLOBALS['spip_matrice'][$filtre])) {
293
+        find_in_path($f, '', true);
294
+        $GLOBALS['spip_matrice'][$filtre] = true;
295
+    }
296
+    return !empty($GLOBALS['spip_matrice'][$filtre]);
297 297
 }
298 298
 
299 299
 
@@ -321,8 +321,8 @@  discard block
 block discarded – undo
321 321
  * @return mixed
322 322
  */
323 323
 function filtre_set(&$Pile, $val, $key, $continue = null) {
324
-	$Pile['vars'][$key] = $val;
325
-	return $continue ? $val : '';
324
+    $Pile['vars'][$key] = $val;
325
+    return $continue ? $val : '';
326 326
 }
327 327
 
328 328
 /**
@@ -348,8 +348,8 @@  discard block
 block discarded – undo
348 348
  * @return string|mixed Retourne `$val` si `$continue` présent, sinon ''.
349 349
  */
350 350
 function filtre_setenv(&$Pile, $val, $key, $continue = null) {
351
-	$Pile[0][$key] = $val;
352
-	return $continue ? $val : '';
351
+    $Pile[0][$key] = $val;
352
+    return $continue ? $val : '';
353 353
 }
354 354
 
355 355
 /**
@@ -371,18 +371,18 @@  discard block
 block discarded – undo
371 371
  * @return mixed Retourne la valeur (sans la modifier).
372 372
  */
373 373
 function filtre_debug($val, $key = null) {
374
-	$debug = (
375
-		is_null($key) ? '' : (var_export($key, true) . " = ")
376
-		) . var_export($val, true);
374
+    $debug = (
375
+        is_null($key) ? '' : (var_export($key, true) . " = ")
376
+        ) . var_export($val, true);
377 377
 
378
-	include_spip('inc/autoriser');
379
-	if (autoriser('webmestre')) {
380
-		echo "<div class='spip_debug'>\n", $debug, "</div>\n";
381
-	}
378
+    include_spip('inc/autoriser');
379
+    if (autoriser('webmestre')) {
380
+        echo "<div class='spip_debug'>\n", $debug, "</div>\n";
381
+    }
382 382
 
383
-	spip_log($debug, 'debug');
383
+    spip_log($debug, 'debug');
384 384
 
385
-	return $val;
385
+    return $val;
386 386
 }
387 387
 
388 388
 
@@ -410,71 +410,71 @@  discard block
 block discarded – undo
410 410
  *     Texte qui a reçu les filtres
411 411
  **/
412 412
 function image_filtrer($args) {
413
-	$filtre = array_shift($args); # enlever $filtre
414
-	$texte = array_shift($args);
415
-	if (!strlen($texte)) {
416
-		return;
417
-	}
418
-	find_in_path('filtres_images_mini.php', 'inc/', true);
419
-	statut_effacer_images_temporaires(true); // activer la suppression des images temporaires car le compilo finit la chaine par un image_graver
420
-	// Cas du nom de fichier local
421
-	if (strpos(substr($texte, strlen(_DIR_RACINE)), '..') === false
422
-		and !preg_match(',^/|[<>]|\s,S', $texte)
423
-		and (
424
-			file_exists(preg_replace(',[?].*$,', '', $texte))
425
-			or tester_url_absolue($texte)
426
-		)
427
-	) {
428
-		array_unshift($args, "<img src='$texte' />");
429
-		$res = call_user_func_array($filtre, $args);
430
-		statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
431
-		return $res;
432
-	}
433
-
434
-	// Cas general : trier toutes les images, avec eventuellement leur <span>
435
-	if (preg_match_all(
436
-		',(<([a-z]+) [^<>]*spip_documents[^<>]*>)?\s*(<img\s.*>),UimsS',
437
-		$texte, $tags, PREG_SET_ORDER)) {
438
-		foreach ($tags as $tag) {
439
-			$class = extraire_attribut($tag[3], 'class');
440
-			if (!$class or
441
-				(strpos($class, 'filtre_inactif') === false
442
-					// compat historique a virer en 3.2
443
-					and strpos($class, 'no_image_filtrer') === false)
444
-			) {
445
-				array_unshift($args, $tag[3]);
446
-				if ($reduit = call_user_func_array($filtre, $args)) {
447
-					// En cas de span spip_documents, modifier le style=...width:
448
-					if ($tag[1]) {
449
-						$w = extraire_attribut($reduit, 'width');
450
-						if (!$w and preg_match(",width:\s*(\d+)px,S", extraire_attribut($reduit, 'style'), $regs)) {
451
-							$w = $regs[1];
452
-						}
453
-						if ($w and ($style = extraire_attribut($tag[1], 'style'))) {
454
-							$style = preg_replace(",width:\s*\d+px,S", "width:${w}px", $style);
455
-							$replace = inserer_attribut($tag[1], 'style', $style);
456
-							$texte = str_replace($tag[1], $replace, $texte);
457
-						}
458
-					}
459
-					// traiter aussi un eventuel mouseover
460
-					if ($mouseover = extraire_attribut($reduit, 'onmouseover')) {
461
-						if (preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)) {
462
-							$srcover = $match[1];
463
-							array_shift($args);
464
-							array_unshift($args, "<img src='" . $match[1] . "' />");
465
-							$srcover_filter = call_user_func_array($filtre, $args);
466
-							$srcover_filter = extraire_attribut($srcover_filter, 'src');
467
-							$reduit = str_replace($srcover, $srcover_filter, $reduit);
468
-						}
469
-					}
470
-					$texte = str_replace($tag[3], $reduit, $texte);
471
-				}
472
-				array_shift($args);
473
-			}
474
-		}
475
-	}
476
-	statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
477
-	return $texte;
413
+    $filtre = array_shift($args); # enlever $filtre
414
+    $texte = array_shift($args);
415
+    if (!strlen($texte)) {
416
+        return;
417
+    }
418
+    find_in_path('filtres_images_mini.php', 'inc/', true);
419
+    statut_effacer_images_temporaires(true); // activer la suppression des images temporaires car le compilo finit la chaine par un image_graver
420
+    // Cas du nom de fichier local
421
+    if (strpos(substr($texte, strlen(_DIR_RACINE)), '..') === false
422
+        and !preg_match(',^/|[<>]|\s,S', $texte)
423
+        and (
424
+            file_exists(preg_replace(',[?].*$,', '', $texte))
425
+            or tester_url_absolue($texte)
426
+        )
427
+    ) {
428
+        array_unshift($args, "<img src='$texte' />");
429
+        $res = call_user_func_array($filtre, $args);
430
+        statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
431
+        return $res;
432
+    }
433
+
434
+    // Cas general : trier toutes les images, avec eventuellement leur <span>
435
+    if (preg_match_all(
436
+        ',(<([a-z]+) [^<>]*spip_documents[^<>]*>)?\s*(<img\s.*>),UimsS',
437
+        $texte, $tags, PREG_SET_ORDER)) {
438
+        foreach ($tags as $tag) {
439
+            $class = extraire_attribut($tag[3], 'class');
440
+            if (!$class or
441
+                (strpos($class, 'filtre_inactif') === false
442
+                    // compat historique a virer en 3.2
443
+                    and strpos($class, 'no_image_filtrer') === false)
444
+            ) {
445
+                array_unshift($args, $tag[3]);
446
+                if ($reduit = call_user_func_array($filtre, $args)) {
447
+                    // En cas de span spip_documents, modifier le style=...width:
448
+                    if ($tag[1]) {
449
+                        $w = extraire_attribut($reduit, 'width');
450
+                        if (!$w and preg_match(",width:\s*(\d+)px,S", extraire_attribut($reduit, 'style'), $regs)) {
451
+                            $w = $regs[1];
452
+                        }
453
+                        if ($w and ($style = extraire_attribut($tag[1], 'style'))) {
454
+                            $style = preg_replace(",width:\s*\d+px,S", "width:${w}px", $style);
455
+                            $replace = inserer_attribut($tag[1], 'style', $style);
456
+                            $texte = str_replace($tag[1], $replace, $texte);
457
+                        }
458
+                    }
459
+                    // traiter aussi un eventuel mouseover
460
+                    if ($mouseover = extraire_attribut($reduit, 'onmouseover')) {
461
+                        if (preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)) {
462
+                            $srcover = $match[1];
463
+                            array_shift($args);
464
+                            array_unshift($args, "<img src='" . $match[1] . "' />");
465
+                            $srcover_filter = call_user_func_array($filtre, $args);
466
+                            $srcover_filter = extraire_attribut($srcover_filter, 'src');
467
+                            $reduit = str_replace($srcover, $srcover_filter, $reduit);
468
+                        }
469
+                    }
470
+                    $texte = str_replace($tag[3], $reduit, $texte);
471
+                }
472
+                array_shift($args);
473
+            }
474
+        }
475
+    }
476
+    statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
477
+    return $texte;
478 478
 }
479 479
 
480 480
 /**
@@ -489,65 +489,65 @@  discard block
 block discarded – undo
489 489
  **/
490 490
 function taille_image($img) {
491 491
 
492
-	static $largeur_img = array(), $hauteur_img = array();
493
-	$srcWidth = 0;
494
-	$srcHeight = 0;
495
-
496
-	$src = extraire_attribut($img, 'src');
497
-
498
-	if (!$src) {
499
-		$src = $img;
500
-	} else {
501
-		$srcWidth = extraire_attribut($img, 'width');
502
-		$srcHeight = extraire_attribut($img, 'height');
503
-	}
504
-
505
-	// ne jamais operer directement sur une image distante pour des raisons de perfo
506
-	// la copie locale a toutes les chances d'etre la ou de resservir
507
-	if (tester_url_absolue($src)) {
508
-		include_spip('inc/distant');
509
-		$fichier = copie_locale($src);
510
-		$src = $fichier ? _DIR_RACINE . $fichier : $src;
511
-	}
512
-	if (($p = strpos($src, '?')) !== false) {
513
-		$src = substr($src, 0, $p);
514
-	}
515
-
516
-	$srcsize = false;
517
-	if (isset($largeur_img[$src])) {
518
-		$srcWidth = $largeur_img[$src];
519
-	}
520
-	if (isset($hauteur_img[$src])) {
521
-		$srcHeight = $hauteur_img[$src];
522
-	}
523
-	if (!$srcWidth or !$srcHeight) {
524
-
525
-		if (file_exists($src)
526
-			and $srcsize = spip_getimagesize($src)
527
-		) {
528
-			if (!$srcWidth) {
529
-				$largeur_img[$src] = $srcWidth = $srcsize[0];
530
-			}
531
-			if (!$srcHeight) {
532
-				$hauteur_img[$src] = $srcHeight = $srcsize[1];
533
-			}
534
-		}
535
-		// $src peut etre une reference a une image temporaire dont a n'a que le log .src
536
-		// on s'y refere, l'image sera reconstruite en temps utile si necessaire
537
-		elseif (@file_exists($f = "$src.src")
538
-			and lire_fichier($f, $valeurs)
539
-			and $valeurs = unserialize($valeurs)
540
-		) {
541
-			if (!$srcWidth) {
542
-				$largeur_img[$src] = $srcWidth = $valeurs["largeur_dest"];
543
-			}
544
-			if (!$srcHeight) {
545
-				$hauteur_img[$src] = $srcHeight = $valeurs["hauteur_dest"];
546
-			}
547
-		}
548
-	}
549
-
550
-	return array($srcHeight, $srcWidth);
492
+    static $largeur_img = array(), $hauteur_img = array();
493
+    $srcWidth = 0;
494
+    $srcHeight = 0;
495
+
496
+    $src = extraire_attribut($img, 'src');
497
+
498
+    if (!$src) {
499
+        $src = $img;
500
+    } else {
501
+        $srcWidth = extraire_attribut($img, 'width');
502
+        $srcHeight = extraire_attribut($img, 'height');
503
+    }
504
+
505
+    // ne jamais operer directement sur une image distante pour des raisons de perfo
506
+    // la copie locale a toutes les chances d'etre la ou de resservir
507
+    if (tester_url_absolue($src)) {
508
+        include_spip('inc/distant');
509
+        $fichier = copie_locale($src);
510
+        $src = $fichier ? _DIR_RACINE . $fichier : $src;
511
+    }
512
+    if (($p = strpos($src, '?')) !== false) {
513
+        $src = substr($src, 0, $p);
514
+    }
515
+
516
+    $srcsize = false;
517
+    if (isset($largeur_img[$src])) {
518
+        $srcWidth = $largeur_img[$src];
519
+    }
520
+    if (isset($hauteur_img[$src])) {
521
+        $srcHeight = $hauteur_img[$src];
522
+    }
523
+    if (!$srcWidth or !$srcHeight) {
524
+
525
+        if (file_exists($src)
526
+            and $srcsize = spip_getimagesize($src)
527
+        ) {
528
+            if (!$srcWidth) {
529
+                $largeur_img[$src] = $srcWidth = $srcsize[0];
530
+            }
531
+            if (!$srcHeight) {
532
+                $hauteur_img[$src] = $srcHeight = $srcsize[1];
533
+            }
534
+        }
535
+        // $src peut etre une reference a une image temporaire dont a n'a que le log .src
536
+        // on s'y refere, l'image sera reconstruite en temps utile si necessaire
537
+        elseif (@file_exists($f = "$src.src")
538
+            and lire_fichier($f, $valeurs)
539
+            and $valeurs = unserialize($valeurs)
540
+        ) {
541
+            if (!$srcWidth) {
542
+                $largeur_img[$src] = $srcWidth = $valeurs["largeur_dest"];
543
+            }
544
+            if (!$srcHeight) {
545
+                $hauteur_img[$src] = $srcHeight = $valeurs["hauteur_dest"];
546
+            }
547
+        }
548
+    }
549
+
550
+    return array($srcHeight, $srcWidth);
551 551
 }
552 552
 
553 553
 
@@ -565,12 +565,12 @@  discard block
 block discarded – undo
565 565
  *     Largeur en pixels, NULL ou 0 si aucune image.
566 566
  **/
567 567
 function largeur($img) {
568
-	if (!$img) {
569
-		return;
570
-	}
571
-	list($h, $l) = taille_image($img);
568
+    if (!$img) {
569
+        return;
570
+    }
571
+    list($h, $l) = taille_image($img);
572 572
 
573
-	return $l;
573
+    return $l;
574 574
 }
575 575
 
576 576
 /**
@@ -587,12 +587,12 @@  discard block
 block discarded – undo
587 587
  *     Hauteur en pixels, NULL ou 0 si aucune image.
588 588
  **/
589 589
 function hauteur($img) {
590
-	if (!$img) {
591
-		return;
592
-	}
593
-	list($h, $l) = taille_image($img);
590
+    if (!$img) {
591
+        return;
592
+    }
593
+    list($h, $l) = taille_image($img);
594 594
 
595
-	return $h;
595
+    return $h;
596 596
 }
597 597
 
598 598
 
@@ -612,11 +612,11 @@  discard block
 block discarded – undo
612 612
  * @return string
613 613
  **/
614 614
 function corriger_entites_html($texte) {
615
-	if (strpos($texte, '&amp;') === false) {
616
-		return $texte;
617
-	}
615
+    if (strpos($texte, '&amp;') === false) {
616
+        return $texte;
617
+    }
618 618
 
619
-	return preg_replace(',&amp;(#[0-9][0-9][0-9]+;|amp;),iS', '&\1', $texte);
619
+    return preg_replace(',&amp;(#[0-9][0-9][0-9]+;|amp;),iS', '&\1', $texte);
620 620
 }
621 621
 
622 622
 /**
@@ -631,11 +631,11 @@  discard block
 block discarded – undo
631 631
  * @return string
632 632
  **/
633 633
 function corriger_toutes_entites_html($texte) {
634
-	if (strpos($texte, '&amp;') === false) {
635
-		return $texte;
636
-	}
634
+    if (strpos($texte, '&amp;') === false) {
635
+        return $texte;
636
+    }
637 637
 
638
-	return preg_replace(',&amp;(#?[a-z0-9]+;),iS', '&\1', $texte);
638
+    return preg_replace(',&amp;(#?[a-z0-9]+;),iS', '&\1', $texte);
639 639
 }
640 640
 
641 641
 /**
@@ -645,7 +645,7 @@  discard block
 block discarded – undo
645 645
  * @return string
646 646
  **/
647 647
 function proteger_amp($texte) {
648
-	return str_replace('&', '&amp;', $texte);
648
+    return str_replace('&', '&amp;', $texte);
649 649
 }
650 650
 
651 651
 
@@ -676,20 +676,20 @@  discard block
 block discarded – undo
676 676
  * @return mixed|string
677 677
  */
678 678
 function entites_html($texte, $tout = false, $quote = true) {
679
-	if (!is_string($texte) or !$texte
680
-		or strpbrk($texte, "&\"'<>") == false
681
-	) {
682
-		return $texte;
683
-	}
684
-	include_spip('inc/texte');
685
-	$flags = ($quote ? ENT_QUOTES : ENT_NOQUOTES);
686
-	$flags |= ENT_HTML401;
687
-	$texte = spip_htmlspecialchars(echappe_retour(echappe_html($texte, '', true), '', 'proteger_amp'), $flags);
688
-	if ($tout) {
689
-		return corriger_toutes_entites_html($texte);
690
-	} else {
691
-		return corriger_entites_html($texte);
692
-	}
679
+    if (!is_string($texte) or !$texte
680
+        or strpbrk($texte, "&\"'<>") == false
681
+    ) {
682
+        return $texte;
683
+    }
684
+    include_spip('inc/texte');
685
+    $flags = ($quote ? ENT_QUOTES : ENT_NOQUOTES);
686
+    $flags |= ENT_HTML401;
687
+    $texte = spip_htmlspecialchars(echappe_retour(echappe_html($texte, '', true), '', 'proteger_amp'), $flags);
688
+    if ($tout) {
689
+        return corriger_toutes_entites_html($texte);
690
+    } else {
691
+        return corriger_entites_html($texte);
692
+    }
693 693
 }
694 694
 
695 695
 /**
@@ -708,37 +708,37 @@  discard block
 block discarded – undo
708 708
  *     Texte converti
709 709
  **/
710 710
 function filtrer_entites($texte) {
711
-	if (strpos($texte, '&') === false) {
712
-		return $texte;
713
-	}
714
-	// filtrer
715
-	$texte = html2unicode($texte);
716
-	// remettre le tout dans le charset cible
717
-	$texte = unicode2charset($texte);
718
-	// cas particulier des " et ' qu'il faut filtrer aussi
719
-	// (on le faisait deja avec un &quot;)
720
-	if (strpos($texte, "&#") !== false) {
721
-		$texte = str_replace(array("&#039;", "&#39;", "&#034;", "&#34;"), array("'", "'", '"', '"'), $texte);
722
-	}
711
+    if (strpos($texte, '&') === false) {
712
+        return $texte;
713
+    }
714
+    // filtrer
715
+    $texte = html2unicode($texte);
716
+    // remettre le tout dans le charset cible
717
+    $texte = unicode2charset($texte);
718
+    // cas particulier des " et ' qu'il faut filtrer aussi
719
+    // (on le faisait deja avec un &quot;)
720
+    if (strpos($texte, "&#") !== false) {
721
+        $texte = str_replace(array("&#039;", "&#39;", "&#034;", "&#34;"), array("'", "'", '"', '"'), $texte);
722
+    }
723 723
 
724
-	return $texte;
724
+    return $texte;
725 725
 }
726 726
 
727 727
 
728 728
 if (!function_exists('filtre_filtrer_entites_dist')) {
729
-	/**
730
-	 * Version sécurisée de filtrer_entites
731
-	 * 
732
-	 * @uses interdire_scripts()
733
-	 * @uses filtrer_entites()
734
-	 * 
735
-	 * @param string $t
736
-	 * @return string
737
-	 */
738
-	function filtre_filtrer_entites_dist($t) {
739
-		include_spip('inc/texte');
740
-		return interdire_scripts(filtrer_entites($t));
741
-	}
729
+    /**
730
+     * Version sécurisée de filtrer_entites
731
+     * 
732
+     * @uses interdire_scripts()
733
+     * @uses filtrer_entites()
734
+     * 
735
+     * @param string $t
736
+     * @return string
737
+     */
738
+    function filtre_filtrer_entites_dist($t) {
739
+        include_spip('inc/texte');
740
+        return interdire_scripts(filtrer_entites($t));
741
+    }
742 742
 }
743 743
 
744 744
 
@@ -753,18 +753,18 @@  discard block
 block discarded – undo
753 753
  * @return string|array
754 754
  **/
755 755
 function supprimer_caracteres_illegaux($texte) {
756
-	static $from = "\x0\x1\x2\x3\x4\x5\x6\x7\x8\xB\xC\xE\xF\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F";
757
-	static $to = null;
756
+    static $from = "\x0\x1\x2\x3\x4\x5\x6\x7\x8\xB\xC\xE\xF\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F";
757
+    static $to = null;
758 758
 
759
-	if (is_array($texte)) {
760
-		return array_map('supprimer_caracteres_illegaux', $texte);
761
-	}
759
+    if (is_array($texte)) {
760
+        return array_map('supprimer_caracteres_illegaux', $texte);
761
+    }
762 762
 
763
-	if (!$to) {
764
-		$to = str_repeat('-', strlen($from));
765
-	}
763
+    if (!$to) {
764
+        $to = str_repeat('-', strlen($from));
765
+    }
766 766
 
767
-	return strtr($texte, $from, $to);
767
+    return strtr($texte, $from, $to);
768 768
 }
769 769
 
770 770
 /**
@@ -776,10 +776,10 @@  discard block
 block discarded – undo
776 776
  * @return string|array
777 777
  **/
778 778
 function corriger_caracteres($texte) {
779
-	$texte = corriger_caracteres_windows($texte);
780
-	$texte = supprimer_caracteres_illegaux($texte);
779
+    $texte = corriger_caracteres_windows($texte);
780
+    $texte = supprimer_caracteres_illegaux($texte);
781 781
 
782
-	return $texte;
782
+    return $texte;
783 783
 }
784 784
 
785 785
 /**
@@ -797,40 +797,40 @@  discard block
 block discarded – undo
797 797
  */
798 798
 function texte_backend($texte) {
799 799
 
800
-	static $apostrophe = array("&#8217;", "'"); # n'allouer qu'une fois
800
+    static $apostrophe = array("&#8217;", "'"); # n'allouer qu'une fois
801 801
 
802
-	// si on a des liens ou des images, les passer en absolu
803
-	$texte = liens_absolus($texte);
802
+    // si on a des liens ou des images, les passer en absolu
803
+    $texte = liens_absolus($texte);
804 804
 
805
-	// echapper les tags &gt; &lt;
806
-	$texte = preg_replace(',&(gt|lt);,S', '&amp;\1;', $texte);
805
+    // echapper les tags &gt; &lt;
806
+    $texte = preg_replace(',&(gt|lt);,S', '&amp;\1;', $texte);
807 807
 
808
-	// importer les &eacute;
809
-	$texte = filtrer_entites($texte);
808
+    // importer les &eacute;
809
+    $texte = filtrer_entites($texte);
810 810
 
811
-	// " -> &quot; et tout ce genre de choses
812
-	$u = $GLOBALS['meta']['pcre_u'];
813
-	$texte = str_replace("&nbsp;", " ", $texte);
814
-	$texte = preg_replace('/\s{2,}/S' . $u, " ", $texte);
815
-	// ne pas echapper les sinqle quotes car certains outils de syndication gerent mal
816
-	$texte = entites_html($texte, false, false);
817
-	// mais bien echapper les double quotes !
818
-	$texte = str_replace('"', '&#034;', $texte);
811
+    // " -> &quot; et tout ce genre de choses
812
+    $u = $GLOBALS['meta']['pcre_u'];
813
+    $texte = str_replace("&nbsp;", " ", $texte);
814
+    $texte = preg_replace('/\s{2,}/S' . $u, " ", $texte);
815
+    // ne pas echapper les sinqle quotes car certains outils de syndication gerent mal
816
+    $texte = entites_html($texte, false, false);
817
+    // mais bien echapper les double quotes !
818
+    $texte = str_replace('"', '&#034;', $texte);
819 819
 
820
-	// verifier le charset
821
-	$texte = charset2unicode($texte);
820
+    // verifier le charset
821
+    $texte = charset2unicode($texte);
822 822
 
823
-	// Caracteres problematiques en iso-latin 1
824
-	if (isset($GLOBALS['meta']['charset']) and $GLOBALS['meta']['charset'] == 'iso-8859-1') {
825
-		$texte = str_replace(chr(156), '&#156;', $texte);
826
-		$texte = str_replace(chr(140), '&#140;', $texte);
827
-		$texte = str_replace(chr(159), '&#159;', $texte);
828
-	}
823
+    // Caracteres problematiques en iso-latin 1
824
+    if (isset($GLOBALS['meta']['charset']) and $GLOBALS['meta']['charset'] == 'iso-8859-1') {
825
+        $texte = str_replace(chr(156), '&#156;', $texte);
826
+        $texte = str_replace(chr(140), '&#140;', $texte);
827
+        $texte = str_replace(chr(159), '&#159;', $texte);
828
+    }
829 829
 
830
-	// l'apostrophe curly pose probleme a certains lecteure de RSS
831
-	// et le caractere apostrophe alourdit les squelettes avec PHP
832
-	// ==> on les remplace par l'entite HTML
833
-	return str_replace($apostrophe, "'", $texte);
830
+    // l'apostrophe curly pose probleme a certains lecteure de RSS
831
+    // et le caractere apostrophe alourdit les squelettes avec PHP
832
+    // ==> on les remplace par l'entite HTML
833
+    return str_replace($apostrophe, "'", $texte);
834 834
 }
835 835
 
836 836
 /**
@@ -847,7 +847,7 @@  discard block
 block discarded – undo
847 847
  *     Texte encodé et quote pour XML
848 848
  */
849 849
 function texte_backendq($texte) {
850
-	return addslashes(texte_backend($texte));
850
+    return addslashes(texte_backend($texte));
851 851
 }
852 852
 
853 853
 
@@ -870,9 +870,9 @@  discard block
 block discarded – undo
870 870
  *     Numéro de titre, sinon chaîne vide
871 871
  **/
872 872
 function supprimer_numero($texte) {
873
-	return preg_replace(
874
-		",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
875
-		"", $texte);
873
+    return preg_replace(
874
+        ",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
875
+        "", $texte);
876 876
 }
877 877
 
878 878
 /**
@@ -895,13 +895,13 @@  discard block
 block discarded – undo
895 895
  *     Numéro de titre, sinon chaîne vide
896 896
  **/
897 897
 function recuperer_numero($texte) {
898
-	if (preg_match(
899
-		",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
900
-		$texte, $regs)) {
901
-		return strval($regs[1]);
902
-	} else {
903
-		return '';
904
-	}
898
+    if (preg_match(
899
+        ",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
900
+        $texte, $regs)) {
901
+        return strval($regs[1]);
902
+    } else {
903
+        return '';
904
+    }
905 905
 }
906 906
 
907 907
 /**
@@ -928,13 +928,13 @@  discard block
 block discarded – undo
928 928
  *     Texte converti
929 929
  **/
930 930
 function supprimer_tags($texte, $rempl = "") {
931
-	$texte = preg_replace(",<(!--|\w|/|!\[endif|!\[if)[^>]*>,US", $rempl, $texte);
932
-	// ne pas oublier un < final non ferme car coupe
933
-	$texte = preg_replace(",<(!--|\w|/).*$,US", $rempl, $texte);
934
-	// mais qui peut aussi etre un simple signe plus petit que
935
-	$texte = str_replace('<', '&lt;', $texte);
931
+    $texte = preg_replace(",<(!--|\w|/|!\[endif|!\[if)[^>]*>,US", $rempl, $texte);
932
+    // ne pas oublier un < final non ferme car coupe
933
+    $texte = preg_replace(",<(!--|\w|/).*$,US", $rempl, $texte);
934
+    // mais qui peut aussi etre un simple signe plus petit que
935
+    $texte = str_replace('<', '&lt;', $texte);
936 936
 
937
-	return $texte;
937
+    return $texte;
938 938
 }
939 939
 
940 940
 /**
@@ -957,9 +957,9 @@  discard block
 block discarded – undo
957 957
  *     Texte converti
958 958
  **/
959 959
 function echapper_tags($texte, $rempl = "") {
960
-	$texte = preg_replace("/<([^>]*)>/", "&lt;\\1&gt;", $texte);
960
+    $texte = preg_replace("/<([^>]*)>/", "&lt;\\1&gt;", $texte);
961 961
 
962
-	return $texte;
962
+    return $texte;
963 963
 }
964 964
 
965 965
 /**
@@ -980,18 +980,18 @@  discard block
 block discarded – undo
980 980
  *     Texte converti
981 981
  **/
982 982
 function textebrut($texte) {
983
-	$u = $GLOBALS['meta']['pcre_u'];
984
-	$texte = preg_replace('/\s+/S' . $u, " ", $texte);
985
-	$texte = preg_replace("/<(p|br)( [^>]*)?" . ">/iS", "\n\n", $texte);
986
-	$texte = preg_replace("/^\n+/", "", $texte);
987
-	$texte = preg_replace("/\n+$/", "", $texte);
988
-	$texte = preg_replace("/\n +/", "\n", $texte);
989
-	$texte = supprimer_tags($texte);
990
-	$texte = preg_replace("/(&nbsp;| )+/S", " ", $texte);
991
-	// nettoyer l'apostrophe curly qui pose probleme a certains rss-readers, lecteurs de mail...
992
-	$texte = str_replace("&#8217;", "'", $texte);
983
+    $u = $GLOBALS['meta']['pcre_u'];
984
+    $texte = preg_replace('/\s+/S' . $u, " ", $texte);
985
+    $texte = preg_replace("/<(p|br)( [^>]*)?" . ">/iS", "\n\n", $texte);
986
+    $texte = preg_replace("/^\n+/", "", $texte);
987
+    $texte = preg_replace("/\n+$/", "", $texte);
988
+    $texte = preg_replace("/\n +/", "\n", $texte);
989
+    $texte = supprimer_tags($texte);
990
+    $texte = preg_replace("/(&nbsp;| )+/S", " ", $texte);
991
+    // nettoyer l'apostrophe curly qui pose probleme a certains rss-readers, lecteurs de mail...
992
+    $texte = str_replace("&#8217;", "'", $texte);
993 993
 
994
-	return $texte;
994
+    return $texte;
995 995
 }
996 996
 
997 997
 
@@ -1007,17 +1007,17 @@  discard block
 block discarded – undo
1007 1007
  *     Texte avec liens ouvrants
1008 1008
  **/
1009 1009
 function liens_ouvrants($texte) {
1010
-	if (preg_match_all(",(<a\s+[^>]*https?://[^>]*class=[\"']spip_(out|url)\b[^>]+>),imsS",
1011
-		$texte, $liens, PREG_PATTERN_ORDER)) {
1012
-		foreach ($liens[0] as $a) {
1013
-			$rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel');
1014
-			$ablank = inserer_attribut($a, 'rel', $rel);
1015
-			$ablank = inserer_attribut($ablank, 'target', '_blank');
1016
-			$texte = str_replace($a, $ablank, $texte);
1017
-		}
1018
-	}
1010
+    if (preg_match_all(",(<a\s+[^>]*https?://[^>]*class=[\"']spip_(out|url)\b[^>]+>),imsS",
1011
+        $texte, $liens, PREG_PATTERN_ORDER)) {
1012
+        foreach ($liens[0] as $a) {
1013
+            $rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel');
1014
+            $ablank = inserer_attribut($a, 'rel', $rel);
1015
+            $ablank = inserer_attribut($ablank, 'target', '_blank');
1016
+            $texte = str_replace($a, $ablank, $texte);
1017
+        }
1018
+    }
1019 1019
 
1020
-	return $texte;
1020
+    return $texte;
1021 1021
 }
1022 1022
 
1023 1023
 /**
@@ -1027,22 +1027,22 @@  discard block
 block discarded – undo
1027 1027
  * @return string
1028 1028
  */
1029 1029
 function liens_nofollow($texte) {
1030
-	if (stripos($texte, "<a") === false) {
1031
-		return $texte;
1032
-	}
1030
+    if (stripos($texte, "<a") === false) {
1031
+        return $texte;
1032
+    }
1033 1033
 
1034
-	if (preg_match_all(",<a\b[^>]*>,UimsS", $texte, $regs, PREG_PATTERN_ORDER)) {
1035
-		foreach ($regs[0] as $a) {
1036
-			$rel = extraire_attribut($a, "rel");
1037
-			if (strpos($rel, "nofollow") === false) {
1038
-				$rel = "nofollow" . ($rel ? " $rel" : "");
1039
-				$anofollow = inserer_attribut($a, "rel", $rel);
1040
-				$texte = str_replace($a, $anofollow, $texte);
1041
-			}
1042
-		}
1043
-	}
1034
+    if (preg_match_all(",<a\b[^>]*>,UimsS", $texte, $regs, PREG_PATTERN_ORDER)) {
1035
+        foreach ($regs[0] as $a) {
1036
+            $rel = extraire_attribut($a, "rel");
1037
+            if (strpos($rel, "nofollow") === false) {
1038
+                $rel = "nofollow" . ($rel ? " $rel" : "");
1039
+                $anofollow = inserer_attribut($a, "rel", $rel);
1040
+                $texte = str_replace($a, $anofollow, $texte);
1041
+            }
1042
+        }
1043
+    }
1044 1044
 
1045
-	return $texte;
1045
+    return $texte;
1046 1046
 }
1047 1047
 
1048 1048
 /**
@@ -1061,12 +1061,12 @@  discard block
 block discarded – undo
1061 1061
  *     Texte sans paraghaphes
1062 1062
  **/
1063 1063
 function PtoBR($texte) {
1064
-	$u = $GLOBALS['meta']['pcre_u'];
1065
-	$texte = preg_replace("@</p>@iS", "\n", $texte);
1066
-	$texte = preg_replace("@<p\b.*>@UiS", "<br />", $texte);
1067
-	$texte = preg_replace("@^\s*<br />@S" . $u, "", $texte);
1064
+    $u = $GLOBALS['meta']['pcre_u'];
1065
+    $texte = preg_replace("@</p>@iS", "\n", $texte);
1066
+    $texte = preg_replace("@<p\b.*>@UiS", "<br />", $texte);
1067
+    $texte = preg_replace("@^\s*<br />@S" . $u, "", $texte);
1068 1068
 
1069
-	return $texte;
1069
+    return $texte;
1070 1070
 }
1071 1071
 
1072 1072
 
@@ -1090,14 +1090,14 @@  discard block
 block discarded – undo
1090 1090
  * @return string Texte encadré du style CSS
1091 1091
  */
1092 1092
 function lignes_longues($texte) {
1093
-	if (!strlen(trim($texte))) {
1094
-		return $texte;
1095
-	}
1096
-	include_spip('inc/texte');
1097
-	$tag = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $texte) ?
1098
-		'div' : 'span';
1093
+    if (!strlen(trim($texte))) {
1094
+        return $texte;
1095
+    }
1096
+    include_spip('inc/texte');
1097
+    $tag = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $texte) ?
1098
+        'div' : 'span';
1099 1099
 
1100
-	return "<$tag style='word-wrap:break-word;'>$texte</$tag>";
1100
+    return "<$tag style='word-wrap:break-word;'>$texte</$tag>";
1101 1101
 }
1102 1102
 
1103 1103
 /**
@@ -1116,30 +1116,30 @@  discard block
 block discarded – undo
1116 1116
  * @return string Texte en majuscule
1117 1117
  */
1118 1118
 function majuscules($texte) {
1119
-	if (!strlen($texte)) {
1120
-		return '';
1121
-	}
1119
+    if (!strlen($texte)) {
1120
+        return '';
1121
+    }
1122 1122
 
1123
-	// Cas du turc
1124
-	if ($GLOBALS['spip_lang'] == 'tr') {
1125
-		# remplacer hors des tags et des entites
1126
-		if (preg_match_all(',<[^<>]+>|&[^;]+;,S', $texte, $regs, PREG_SET_ORDER)) {
1127
-			foreach ($regs as $n => $match) {
1128
-				$texte = str_replace($match[0], "@@SPIP_TURC$n@@", $texte);
1129
-			}
1130
-		}
1123
+    // Cas du turc
1124
+    if ($GLOBALS['spip_lang'] == 'tr') {
1125
+        # remplacer hors des tags et des entites
1126
+        if (preg_match_all(',<[^<>]+>|&[^;]+;,S', $texte, $regs, PREG_SET_ORDER)) {
1127
+            foreach ($regs as $n => $match) {
1128
+                $texte = str_replace($match[0], "@@SPIP_TURC$n@@", $texte);
1129
+            }
1130
+        }
1131 1131
 
1132
-		$texte = str_replace('i', '&#304;', $texte);
1132
+        $texte = str_replace('i', '&#304;', $texte);
1133 1133
 
1134
-		if ($regs) {
1135
-			foreach ($regs as $n => $match) {
1136
-				$texte = str_replace("@@SPIP_TURC$n@@", $match[0], $texte);
1137
-			}
1138
-		}
1139
-	}
1134
+        if ($regs) {
1135
+            foreach ($regs as $n => $match) {
1136
+                $texte = str_replace("@@SPIP_TURC$n@@", $match[0], $texte);
1137
+            }
1138
+        }
1139
+    }
1140 1140
 
1141
-	// Cas general
1142
-	return "<span style='text-transform: uppercase;'>$texte</span>";
1141
+    // Cas general
1142
+    return "<span style='text-transform: uppercase;'>$texte</span>";
1143 1143
 }
1144 1144
 
1145 1145
 /**
@@ -1157,29 +1157,29 @@  discard block
 block discarded – undo
1157 1157
  * @return string
1158 1158
  **/
1159 1159
 function taille_en_octets($taille) {
1160
-	if (!defined('_KILOBYTE')) {
1161
-		/**
1162
-		 * Définit le nombre d'octets dans un Kilobyte
1163
-		 *
1164
-		 * @var int
1165
-		 **/
1166
-		define('_KILOBYTE', 1024);
1167
-	}
1160
+    if (!defined('_KILOBYTE')) {
1161
+        /**
1162
+         * Définit le nombre d'octets dans un Kilobyte
1163
+         *
1164
+         * @var int
1165
+         **/
1166
+        define('_KILOBYTE', 1024);
1167
+    }
1168 1168
 
1169
-	if ($taille < 1) {
1170
-		return '';
1171
-	}
1172
-	if ($taille < _KILOBYTE) {
1173
-		$taille = _T('taille_octets', array('taille' => $taille));
1174
-	} elseif ($taille < _KILOBYTE * _KILOBYTE) {
1175
-		$taille = _T('taille_ko', array('taille' => round($taille / _KILOBYTE, 1)));
1176
-	} elseif ($taille < _KILOBYTE * _KILOBYTE * _KILOBYTE) {
1177
-		$taille = _T('taille_mo', array('taille' => round($taille / _KILOBYTE / _KILOBYTE, 1)));
1178
-	} else {
1179
-		$taille = _T('taille_go', array('taille' => round($taille / _KILOBYTE / _KILOBYTE / _KILOBYTE, 2)));
1180
-	}
1169
+    if ($taille < 1) {
1170
+        return '';
1171
+    }
1172
+    if ($taille < _KILOBYTE) {
1173
+        $taille = _T('taille_octets', array('taille' => $taille));
1174
+    } elseif ($taille < _KILOBYTE * _KILOBYTE) {
1175
+        $taille = _T('taille_ko', array('taille' => round($taille / _KILOBYTE, 1)));
1176
+    } elseif ($taille < _KILOBYTE * _KILOBYTE * _KILOBYTE) {
1177
+        $taille = _T('taille_mo', array('taille' => round($taille / _KILOBYTE / _KILOBYTE, 1)));
1178
+    } else {
1179
+        $taille = _T('taille_go', array('taille' => round($taille / _KILOBYTE / _KILOBYTE / _KILOBYTE, 2)));
1180
+    }
1181 1181
 
1182
-	return $taille;
1182
+    return $taille;
1183 1183
 }
1184 1184
 
1185 1185
 
@@ -1201,15 +1201,15 @@  discard block
 block discarded – undo
1201 1201
  *     Texte prêt pour être utilisé en attribut HTML
1202 1202
  **/
1203 1203
 function attribut_html($texte, $textebrut = true) {
1204
-	$u = $GLOBALS['meta']['pcre_u'];
1205
-	if ($textebrut) {
1206
-		$texte = preg_replace(array(",\n,", ",\s(?=\s),msS" . $u), array(" ", ""), textebrut($texte));
1207
-	}
1208
-	$texte = texte_backend($texte);
1209
-	$texte = str_replace(array("'", '"'), array('&#039;', '&#034;'), $texte);
1204
+    $u = $GLOBALS['meta']['pcre_u'];
1205
+    if ($textebrut) {
1206
+        $texte = preg_replace(array(",\n,", ",\s(?=\s),msS" . $u), array(" ", ""), textebrut($texte));
1207
+    }
1208
+    $texte = texte_backend($texte);
1209
+    $texte = str_replace(array("'", '"'), array('&#039;', '&#034;'), $texte);
1210 1210
 
1211
-	return preg_replace(array("/&(amp;|#38;)/", "/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,5};)/"), array("&", "&#38;"),
1212
-		$texte);
1211
+    return preg_replace(array("/&(amp;|#38;)/", "/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,5};)/"), array("&", "&#38;"),
1212
+        $texte);
1213 1213
 }
1214 1214
 
1215 1215
 
@@ -1229,12 +1229,12 @@  discard block
 block discarded – undo
1229 1229
  *     URL ou chaîne vide
1230 1230
  **/
1231 1231
 function vider_url($url, $entites = true) {
1232
-	# un message pour abs_url
1233
-	$GLOBALS['mode_abs_url'] = 'url';
1234
-	$url = trim($url);
1235
-	$r = ",^(?:" . _PROTOCOLES_STD . '):?/?/?$,iS';
1232
+    # un message pour abs_url
1233
+    $GLOBALS['mode_abs_url'] = 'url';
1234
+    $url = trim($url);
1235
+    $r = ",^(?:" . _PROTOCOLES_STD . '):?/?/?$,iS';
1236 1236
 
1237
-	return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url);
1237
+    return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url);
1238 1238
 }
1239 1239
 
1240 1240
 
@@ -1249,10 +1249,10 @@  discard block
 block discarded – undo
1249 1249
  * @return string Adresse email maquillée
1250 1250
  **/
1251 1251
 function antispam($texte) {
1252
-	include_spip('inc/acces');
1253
-	$masque = creer_pass_aleatoire(3);
1252
+    include_spip('inc/acces');
1253
+    $masque = creer_pass_aleatoire(3);
1254 1254
 
1255
-	return preg_replace("/@/", " $masque ", $texte);
1255
+    return preg_replace("/@/", " $masque ", $texte);
1256 1256
 }
1257 1257
 
1258 1258
 /**
@@ -1284,12 +1284,12 @@  discard block
 block discarded – undo
1284 1284
  *     True si on a le droit d'accès, false sinon.
1285 1285
  **/
1286 1286
 function securiser_acces($id_auteur, $cle, $dir, $op = '', $args = '') {
1287
-	include_spip('inc/acces');
1288
-	if ($op) {
1289
-		$dir .= " $op $args";
1290
-	}
1287
+    include_spip('inc/acces');
1288
+    if ($op) {
1289
+        $dir .= " $op $args";
1290
+    }
1291 1291
 
1292
-	return verifier_low_sec($id_auteur, $cle, $dir);
1292
+    return verifier_low_sec($id_auteur, $cle, $dir);
1293 1293
 }
1294 1294
 
1295 1295
 /**
@@ -1314,11 +1314,11 @@  discard block
 block discarded – undo
1314 1314
  *     Retourne $texte, sinon $sinon.
1315 1315
  **/
1316 1316
 function sinon($texte, $sinon = '') {
1317
-	if ($texte or (!is_array($texte) and strlen($texte))) {
1318
-		return $texte;
1319
-	} else {
1320
-		return $sinon;
1321
-	}
1317
+    if ($texte or (!is_array($texte) and strlen($texte))) {
1318
+        return $texte;
1319
+    } else {
1320
+        return $sinon;
1321
+    }
1322 1322
 }
1323 1323
 
1324 1324
 /**
@@ -1342,7 +1342,7 @@  discard block
 block discarded – undo
1342 1342
  * @return mixed
1343 1343
  **/
1344 1344
 function choixsivide($a, $vide, $pasvide) {
1345
-	return $a ? $pasvide : $vide;
1345
+    return $a ? $pasvide : $vide;
1346 1346
 }
1347 1347
 
1348 1348
 /**
@@ -1366,7 +1366,7 @@  discard block
 block discarded – undo
1366 1366
  * @return mixed
1367 1367
  **/
1368 1368
 function choixsiegal($a1, $a2, $v, $f) {
1369
-	return ($a1 == $a2) ? $v : $f;
1369
+    return ($a1 == $a2) ? $v : $f;
1370 1370
 }
1371 1371
 
1372 1372
 //
@@ -1385,13 +1385,13 @@  discard block
 block discarded – undo
1385 1385
  * @return string
1386 1386
  **/
1387 1387
 function filtrer_ical($texte) {
1388
-	#include_spip('inc/charsets');
1389
-	$texte = html2unicode($texte);
1390
-	$texte = unicode2charset(charset2unicode($texte, $GLOBALS['meta']['charset'], 1), 'utf-8');
1391
-	$texte = preg_replace("/\n/", " ", $texte);
1392
-	$texte = preg_replace("/,/", "\,", $texte);
1388
+    #include_spip('inc/charsets');
1389
+    $texte = html2unicode($texte);
1390
+    $texte = unicode2charset(charset2unicode($texte, $GLOBALS['meta']['charset'], 1), 'utf-8');
1391
+    $texte = preg_replace("/\n/", " ", $texte);
1392
+    $texte = preg_replace("/,/", "\,", $texte);
1393 1393
 
1394
-	return $texte;
1394
+    return $texte;
1395 1395
 }
1396 1396
 
1397 1397
 
@@ -1416,53 +1416,53 @@  discard block
 block discarded – undo
1416 1416
  * @return string
1417 1417
  **/
1418 1418
 function post_autobr($texte, $delim = "\n_ ") {
1419
-	if (!function_exists('echappe_html')) {
1420
-		include_spip('inc/texte_mini');
1421
-	}
1422
-	$texte = str_replace("\r\n", "\r", $texte);
1423
-	$texte = str_replace("\r", "\n", $texte);
1424
-
1425
-	if (preg_match(",\n+$,", $texte, $fin)) {
1426
-		$texte = substr($texte, 0, -strlen($fin = $fin[0]));
1427
-	} else {
1428
-		$fin = '';
1429
-	}
1430
-
1431
-	$texte = echappe_html($texte, '', true);
1432
-
1433
-	// echapper les modeles
1434
-	if (strpos($texte, "<") !== false) {
1435
-		include_spip('inc/lien');
1436
-		if (defined('_PREG_MODELE')) {
1437
-			$preg_modeles = "@" . _PREG_MODELE . "@imsS";
1438
-			$texte = echappe_html($texte, '', true, $preg_modeles);
1439
-		}
1440
-	}
1441
-
1442
-	$debut = '';
1443
-	$suite = $texte;
1444
-	while ($t = strpos('-' . $suite, "\n", 1)) {
1445
-		$debut .= substr($suite, 0, $t - 1);
1446
-		$suite = substr($suite, $t);
1447
-		$car = substr($suite, 0, 1);
1448
-		if (($car <> '-') and ($car <> '_') and ($car <> "\n") and ($car <> "|") and ($car <> "}")
1449
-			and !preg_match(',^\s*(\n|</?(quote|div|dl|dt|dd)|$),S', ($suite))
1450
-			and !preg_match(',</?(quote|div|dl|dt|dd)> *$,iS', $debut)
1451
-		) {
1452
-			$debut .= $delim;
1453
-		} else {
1454
-			$debut .= "\n";
1455
-		}
1456
-		if (preg_match(",^\n+,", $suite, $regs)) {
1457
-			$debut .= $regs[0];
1458
-			$suite = substr($suite, strlen($regs[0]));
1459
-		}
1460
-	}
1461
-	$texte = $debut . $suite;
1462
-
1463
-	$texte = echappe_retour($texte);
1464
-
1465
-	return $texte . $fin;
1419
+    if (!function_exists('echappe_html')) {
1420
+        include_spip('inc/texte_mini');
1421
+    }
1422
+    $texte = str_replace("\r\n", "\r", $texte);
1423
+    $texte = str_replace("\r", "\n", $texte);
1424
+
1425
+    if (preg_match(",\n+$,", $texte, $fin)) {
1426
+        $texte = substr($texte, 0, -strlen($fin = $fin[0]));
1427
+    } else {
1428
+        $fin = '';
1429
+    }
1430
+
1431
+    $texte = echappe_html($texte, '', true);
1432
+
1433
+    // echapper les modeles
1434
+    if (strpos($texte, "<") !== false) {
1435
+        include_spip('inc/lien');
1436
+        if (defined('_PREG_MODELE')) {
1437
+            $preg_modeles = "@" . _PREG_MODELE . "@imsS";
1438
+            $texte = echappe_html($texte, '', true, $preg_modeles);
1439
+        }
1440
+    }
1441
+
1442
+    $debut = '';
1443
+    $suite = $texte;
1444
+    while ($t = strpos('-' . $suite, "\n", 1)) {
1445
+        $debut .= substr($suite, 0, $t - 1);
1446
+        $suite = substr($suite, $t);
1447
+        $car = substr($suite, 0, 1);
1448
+        if (($car <> '-') and ($car <> '_') and ($car <> "\n") and ($car <> "|") and ($car <> "}")
1449
+            and !preg_match(',^\s*(\n|</?(quote|div|dl|dt|dd)|$),S', ($suite))
1450
+            and !preg_match(',</?(quote|div|dl|dt|dd)> *$,iS', $debut)
1451
+        ) {
1452
+            $debut .= $delim;
1453
+        } else {
1454
+            $debut .= "\n";
1455
+        }
1456
+        if (preg_match(",^\n+,", $suite, $regs)) {
1457
+            $debut .= $regs[0];
1458
+            $suite = substr($suite, strlen($regs[0]));
1459
+        }
1460
+    }
1461
+    $texte = $debut . $suite;
1462
+
1463
+    $texte = echappe_retour($texte);
1464
+
1465
+    return $texte . $fin;
1466 1466
 }
1467 1467
 
1468 1468
 
@@ -1503,46 +1503,46 @@  discard block
 block discarded – undo
1503 1503
  * @return string
1504 1504
  **/
1505 1505
 function extraire_idiome($letexte, $lang = null, $options = array()) {
1506
-	static $traduire = false;
1507
-	if ($letexte
1508
-		and preg_match_all(_EXTRAIRE_IDIOME, $letexte, $regs, PREG_SET_ORDER)
1509
-	) {
1510
-		if (!$traduire) {
1511
-			$traduire = charger_fonction('traduire', 'inc');
1512
-			include_spip('inc/lang');
1513
-		}
1514
-		if (!$lang) {
1515
-			$lang = $GLOBALS['spip_lang'];
1516
-		}
1517
-		// Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1518
-		if (is_bool($options)) {
1519
-			$options = array('echappe_span' => $options);
1520
-		}
1521
-		if (!isset($options['echappe_span'])) {
1522
-			$options = array_merge($options, array('echappe_span' => false));
1523
-		}
1524
-
1525
-		foreach ($regs as $reg) {
1526
-			$cle = ($reg[1] ? $reg[1] . ':' : '') . $reg[2];
1527
-			$desc = $traduire($cle, $lang, true);
1528
-			$l = $desc->langue;
1529
-			// si pas de traduction, on laissera l'écriture de l'idiome entier dans le texte.
1530
-			if (strlen($desc->texte)) {
1531
-				$trad = code_echappement($desc->texte, 'idiome', false);
1532
-				if ($l !== $lang) {
1533
-					$trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
1534
-				}
1535
-				if (lang_dir($l) !== lang_dir($lang)) {
1536
-					$trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l)));
1537
-				}
1538
-				if (!$options['echappe_span']) {
1539
-					$trad = echappe_retour($trad, 'idiome');
1540
-				}
1541
-				$letexte = str_replace($reg[0], $trad, $letexte);
1542
-			}
1543
-		}
1544
-	}
1545
-	return $letexte;
1506
+    static $traduire = false;
1507
+    if ($letexte
1508
+        and preg_match_all(_EXTRAIRE_IDIOME, $letexte, $regs, PREG_SET_ORDER)
1509
+    ) {
1510
+        if (!$traduire) {
1511
+            $traduire = charger_fonction('traduire', 'inc');
1512
+            include_spip('inc/lang');
1513
+        }
1514
+        if (!$lang) {
1515
+            $lang = $GLOBALS['spip_lang'];
1516
+        }
1517
+        // Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1518
+        if (is_bool($options)) {
1519
+            $options = array('echappe_span' => $options);
1520
+        }
1521
+        if (!isset($options['echappe_span'])) {
1522
+            $options = array_merge($options, array('echappe_span' => false));
1523
+        }
1524
+
1525
+        foreach ($regs as $reg) {
1526
+            $cle = ($reg[1] ? $reg[1] . ':' : '') . $reg[2];
1527
+            $desc = $traduire($cle, $lang, true);
1528
+            $l = $desc->langue;
1529
+            // si pas de traduction, on laissera l'écriture de l'idiome entier dans le texte.
1530
+            if (strlen($desc->texte)) {
1531
+                $trad = code_echappement($desc->texte, 'idiome', false);
1532
+                if ($l !== $lang) {
1533
+                    $trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
1534
+                }
1535
+                if (lang_dir($l) !== lang_dir($lang)) {
1536
+                    $trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l)));
1537
+                }
1538
+                if (!$options['echappe_span']) {
1539
+                    $trad = echappe_retour($trad, 'idiome');
1540
+                }
1541
+                $letexte = str_replace($reg[0], $trad, $letexte);
1542
+            }
1543
+        }
1544
+    }
1545
+    return $letexte;
1546 1546
 }
1547 1547
 
1548 1548
 /**
@@ -1594,64 +1594,64 @@  discard block
 block discarded – undo
1594 1594
  **/
1595 1595
 function extraire_multi($letexte, $lang = null, $options = array()) {
1596 1596
 
1597
-	if ($letexte
1598
-		and preg_match_all(_EXTRAIRE_MULTI, $letexte, $regs, PREG_SET_ORDER)
1599
-	) {
1600
-		if (!$lang) {
1601
-			$lang = $GLOBALS['spip_lang'];
1602
-		}
1603
-
1604
-		// Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1605
-		if (is_bool($options)) {
1606
-			$options = array('echappe_span' => $options, 'lang_defaut' => _LANGUE_PAR_DEFAUT);
1607
-		}
1608
-		if (!isset($options['echappe_span'])) {
1609
-			$options = array_merge($options, array('echappe_span' => false));
1610
-		}
1611
-		if (!isset($options['lang_defaut'])) {
1612
-			$options = array_merge($options, array('lang_defaut' => _LANGUE_PAR_DEFAUT));
1613
-		}
1614
-
1615
-		include_spip('inc/lang');
1616
-		foreach ($regs as $reg) {
1617
-			// chercher la version de la langue courante
1618
-			$trads = extraire_trads($reg[1]);
1619
-			if ($l = approcher_langue($trads, $lang)) {
1620
-				$trad = $trads[$l];
1621
-			} else {
1622
-				if ($options['lang_defaut'] == 'aucune') {
1623
-					$trad = '';
1624
-				} else {
1625
-					// langue absente, prendre le fr ou une langue précisée (meme comportement que inc/traduire.php)
1626
-					// ou la premiere dispo
1627
-					// mais typographier le texte selon les regles de celle-ci
1628
-					// Attention aux blocs multi sur plusieurs lignes
1629
-					if (!$l = approcher_langue($trads, $options['lang_defaut'])) {
1630
-						$l = key($trads);
1631
-					}
1632
-					$trad = $trads[$l];
1633
-					$typographie = charger_fonction(lang_typo($l), 'typographie');
1634
-					$trad = $typographie($trad);
1635
-					// Tester si on echappe en span ou en div
1636
-					// il ne faut pas echapper en div si propre produit un seul paragraphe
1637
-					include_spip('inc/texte');
1638
-					$trad_propre = preg_replace(",(^<p[^>]*>|</p>$),Uims", "", propre($trad));
1639
-					$mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $trad_propre) ? 'div' : 'span';
1640
-					$trad = code_echappement($trad, 'multi', false, $mode);
1641
-					$trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
1642
-					if (lang_dir($l) !== lang_dir($lang)) {
1643
-						$trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l)));
1644
-					}
1645
-					if (!$options['echappe_span']) {
1646
-						$trad = echappe_retour($trad, 'multi');
1647
-					}
1648
-				}
1649
-			}
1650
-			$letexte = str_replace($reg[0], $trad, $letexte);
1651
-		}
1652
-	}
1653
-
1654
-	return $letexte;
1597
+    if ($letexte
1598
+        and preg_match_all(_EXTRAIRE_MULTI, $letexte, $regs, PREG_SET_ORDER)
1599
+    ) {
1600
+        if (!$lang) {
1601
+            $lang = $GLOBALS['spip_lang'];
1602
+        }
1603
+
1604
+        // Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1605
+        if (is_bool($options)) {
1606
+            $options = array('echappe_span' => $options, 'lang_defaut' => _LANGUE_PAR_DEFAUT);
1607
+        }
1608
+        if (!isset($options['echappe_span'])) {
1609
+            $options = array_merge($options, array('echappe_span' => false));
1610
+        }
1611
+        if (!isset($options['lang_defaut'])) {
1612
+            $options = array_merge($options, array('lang_defaut' => _LANGUE_PAR_DEFAUT));
1613
+        }
1614
+
1615
+        include_spip('inc/lang');
1616
+        foreach ($regs as $reg) {
1617
+            // chercher la version de la langue courante
1618
+            $trads = extraire_trads($reg[1]);
1619
+            if ($l = approcher_langue($trads, $lang)) {
1620
+                $trad = $trads[$l];
1621
+            } else {
1622
+                if ($options['lang_defaut'] == 'aucune') {
1623
+                    $trad = '';
1624
+                } else {
1625
+                    // langue absente, prendre le fr ou une langue précisée (meme comportement que inc/traduire.php)
1626
+                    // ou la premiere dispo
1627
+                    // mais typographier le texte selon les regles de celle-ci
1628
+                    // Attention aux blocs multi sur plusieurs lignes
1629
+                    if (!$l = approcher_langue($trads, $options['lang_defaut'])) {
1630
+                        $l = key($trads);
1631
+                    }
1632
+                    $trad = $trads[$l];
1633
+                    $typographie = charger_fonction(lang_typo($l), 'typographie');
1634
+                    $trad = $typographie($trad);
1635
+                    // Tester si on echappe en span ou en div
1636
+                    // il ne faut pas echapper en div si propre produit un seul paragraphe
1637
+                    include_spip('inc/texte');
1638
+                    $trad_propre = preg_replace(",(^<p[^>]*>|</p>$),Uims", "", propre($trad));
1639
+                    $mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $trad_propre) ? 'div' : 'span';
1640
+                    $trad = code_echappement($trad, 'multi', false, $mode);
1641
+                    $trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
1642
+                    if (lang_dir($l) !== lang_dir($lang)) {
1643
+                        $trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l)));
1644
+                    }
1645
+                    if (!$options['echappe_span']) {
1646
+                        $trad = echappe_retour($trad, 'multi');
1647
+                    }
1648
+                }
1649
+            }
1650
+            $letexte = str_replace($reg[0], $trad, $letexte);
1651
+        }
1652
+    }
1653
+
1654
+    return $letexte;
1655 1655
 }
1656 1656
 
1657 1657
 /**
@@ -1667,20 +1667,20 @@  discard block
 block discarded – undo
1667 1667
  *     Peut retourner un code de langue vide, lorsqu'un texte par défaut est indiqué.
1668 1668
  **/
1669 1669
 function extraire_trads($bloc) {
1670
-	$lang = '';
1670
+    $lang = '';
1671 1671
 // ce reg fait planter l'analyse multi s'il y a de l'{italique} dans le champ
1672 1672
 //	while (preg_match("/^(.*?)[{\[]([a-z_]+)[}\]]/siS", $bloc, $regs)) {
1673
-	while (preg_match("/^(.*?)[\[]([a-z_]+)[\]]/siS", $bloc, $regs)) {
1674
-		$texte = trim($regs[1]);
1675
-		if ($texte or $lang) {
1676
-			$trads[$lang] = $texte;
1677
-		}
1678
-		$bloc = substr($bloc, strlen($regs[0]));
1679
-		$lang = $regs[2];
1680
-	}
1681
-	$trads[$lang] = $bloc;
1673
+    while (preg_match("/^(.*?)[\[]([a-z_]+)[\]]/siS", $bloc, $regs)) {
1674
+        $texte = trim($regs[1]);
1675
+        if ($texte or $lang) {
1676
+            $trads[$lang] = $texte;
1677
+        }
1678
+        $bloc = substr($bloc, strlen($regs[0]));
1679
+        $lang = $regs[2];
1680
+    }
1681
+    $trads[$lang] = $bloc;
1682 1682
 
1683
-	return $trads;
1683
+    return $trads;
1684 1684
 }
1685 1685
 
1686 1686
 
@@ -1691,7 +1691,7 @@  discard block
 block discarded – undo
1691 1691
  * @return string L'initiale en majuscule
1692 1692
  */
1693 1693
 function filtre_initiale($nom) {
1694
-	return spip_substr(trim(strtoupper(extraire_multi($nom))), 0, 1);
1694
+    return spip_substr(trim(strtoupper(extraire_multi($nom))), 0, 1);
1695 1695
 }
1696 1696
 
1697 1697
 
@@ -1736,33 +1736,33 @@  discard block
 block discarded – undo
1736 1736
  *      - null (interne) : si on empile
1737 1737
  **/
1738 1738
 function unique($donnee, $famille = '', $cpt = false) {
1739
-	static $mem = array();
1740
-	// permettre de vider la pile et de la restaurer
1741
-	// pour le calcul de introduction...
1742
-	if ($famille == '_spip_raz_') {
1743
-		$tmp = $mem;
1744
-		$mem = array();
1745
-
1746
-		return $tmp;
1747
-	} elseif ($famille == '_spip_set_') {
1748
-		$mem = $donnee;
1749
-
1750
-		return;
1751
-	}
1752
-	// eviter une notice
1753
-	if (!isset($mem[$famille])) {
1754
-		$mem[$famille] = array();
1755
-	}
1756
-	if ($cpt) {
1757
-		return count($mem[$famille]);
1758
-	}
1759
-	// eviter une notice
1760
-	if (!isset($mem[$famille][$donnee])) {
1761
-		$mem[$famille][$donnee] = 0;
1762
-	}
1763
-	if (!($mem[$famille][$donnee]++)) {
1764
-		return $donnee;
1765
-	}
1739
+    static $mem = array();
1740
+    // permettre de vider la pile et de la restaurer
1741
+    // pour le calcul de introduction...
1742
+    if ($famille == '_spip_raz_') {
1743
+        $tmp = $mem;
1744
+        $mem = array();
1745
+
1746
+        return $tmp;
1747
+    } elseif ($famille == '_spip_set_') {
1748
+        $mem = $donnee;
1749
+
1750
+        return;
1751
+    }
1752
+    // eviter une notice
1753
+    if (!isset($mem[$famille])) {
1754
+        $mem[$famille] = array();
1755
+    }
1756
+    if ($cpt) {
1757
+        return count($mem[$famille]);
1758
+    }
1759
+    // eviter une notice
1760
+    if (!isset($mem[$famille][$donnee])) {
1761
+        $mem[$famille][$donnee] = 0;
1762
+    }
1763
+    if (!($mem[$famille][$donnee]++)) {
1764
+        return $donnee;
1765
+    }
1766 1766
 }
1767 1767
 
1768 1768
 
@@ -1790,18 +1790,18 @@  discard block
 block discarded – undo
1790 1790
  *     Une des valeurs en fonction du compteur.
1791 1791
  **/
1792 1792
 function alterner($i) {
1793
-	// recuperer les arguments (attention fonctions un peu space)
1794
-	$num = func_num_args();
1795
-	$args = func_get_args();
1793
+    // recuperer les arguments (attention fonctions un peu space)
1794
+    $num = func_num_args();
1795
+    $args = func_get_args();
1796 1796
 
1797
-	if ($num == 2 && is_array($args[1])) {
1798
-		$args = $args[1];
1799
-		array_unshift($args, '');
1800
-		$num = count($args);
1801
-	}
1797
+    if ($num == 2 && is_array($args[1])) {
1798
+        $args = $args[1];
1799
+        array_unshift($args, '');
1800
+        $num = count($args);
1801
+    }
1802 1802
 
1803
-	// renvoyer le i-ieme argument, modulo le nombre d'arguments
1804
-	return $args[(intval($i) - 1) % ($num - 1) + 1];
1803
+    // renvoyer le i-ieme argument, modulo le nombre d'arguments
1804
+    return $args[(intval($i) - 1) % ($num - 1) + 1];
1805 1805
 }
1806 1806
 
1807 1807
 
@@ -1826,46 +1826,46 @@  discard block
 block discarded – undo
1826 1826
  *     - Tableau complet (si 2e argument)
1827 1827
  **/
1828 1828
 function extraire_attribut($balise, $attribut, $complet = false) {
1829
-	if (is_array($balise)) {
1830
-		array_walk(
1831
-			$balise,
1832
-			function(&$a, $key, $t){
1833
-				$a = extraire_attribut($a, $t);
1834
-			},
1835
-			$attribut
1836
-		);
1837
-
1838
-		return $balise;
1839
-	}
1840
-	if (preg_match(
1841
-		',(^.*?<(?:(?>\s*)(?>[\w:.-]+)(?>(?:=(?:"[^"]*"|\'[^\']*\'|[^\'"]\S*))?))*?)(\s+'
1842
-		. $attribut
1843
-		. '(?:=\s*("[^"]*"|\'[^\']*\'|[^\'"]\S*))?)()((?:[\s/][^>]*)?>.*),isS',
1844
-
1845
-		$balise, $r)) {
1846
-		if (isset($r[3][0]) and ($r[3][0] == '"' || $r[3][0] == "'")) {
1847
-			$r[4] = substr($r[3], 1, -1);
1848
-			$r[3] = $r[3][0];
1849
-		} elseif ($r[3] !== '') {
1850
-			$r[4] = $r[3];
1851
-			$r[3] = '';
1852
-		} else {
1853
-			$r[4] = trim($r[2]);
1854
-		}
1855
-		$att = $r[4];
1856
-		if (strpos($att, "&#") !== false) {
1857
-			$att = str_replace(array("&#039;", "&#39;", "&#034;", "&#34;"), array("'", "'", '"', '"'), $att);
1858
-		}
1859
-		$att = filtrer_entites($att);
1860
-	} else {
1861
-		$att = null;
1862
-	}
1863
-
1864
-	if ($complet) {
1865
-		return array($att, $r);
1866
-	} else {
1867
-		return $att;
1868
-	}
1829
+    if (is_array($balise)) {
1830
+        array_walk(
1831
+            $balise,
1832
+            function(&$a, $key, $t){
1833
+                $a = extraire_attribut($a, $t);
1834
+            },
1835
+            $attribut
1836
+        );
1837
+
1838
+        return $balise;
1839
+    }
1840
+    if (preg_match(
1841
+        ',(^.*?<(?:(?>\s*)(?>[\w:.-]+)(?>(?:=(?:"[^"]*"|\'[^\']*\'|[^\'"]\S*))?))*?)(\s+'
1842
+        . $attribut
1843
+        . '(?:=\s*("[^"]*"|\'[^\']*\'|[^\'"]\S*))?)()((?:[\s/][^>]*)?>.*),isS',
1844
+
1845
+        $balise, $r)) {
1846
+        if (isset($r[3][0]) and ($r[3][0] == '"' || $r[3][0] == "'")) {
1847
+            $r[4] = substr($r[3], 1, -1);
1848
+            $r[3] = $r[3][0];
1849
+        } elseif ($r[3] !== '') {
1850
+            $r[4] = $r[3];
1851
+            $r[3] = '';
1852
+        } else {
1853
+            $r[4] = trim($r[2]);
1854
+        }
1855
+        $att = $r[4];
1856
+        if (strpos($att, "&#") !== false) {
1857
+            $att = str_replace(array("&#039;", "&#39;", "&#034;", "&#34;"), array("'", "'", '"', '"'), $att);
1858
+        }
1859
+        $att = filtrer_entites($att);
1860
+    } else {
1861
+        $att = null;
1862
+    }
1863
+
1864
+    if ($complet) {
1865
+        return array($att, $r);
1866
+    } else {
1867
+        return $att;
1868
+    }
1869 1869
 }
1870 1870
 
1871 1871
 /**
@@ -1897,37 +1897,37 @@  discard block
 block discarded – undo
1897 1897
  *     Code html modifié
1898 1898
  **/
1899 1899
 function inserer_attribut($balise, $attribut, $val, $proteger = true, $vider = false) {
1900
-	// preparer l'attribut
1901
-	// supprimer les &nbsp; etc mais pas les balises html
1902
-	// qui ont un sens dans un attribut value d'un input
1903
-	if ($proteger) {
1904
-		$val = attribut_html($val, false);
1905
-	}
1906
-
1907
-	// echapper les ' pour eviter tout bug
1908
-	$val = str_replace("'", "&#039;", $val);
1909
-	if ($vider and strlen($val) == 0) {
1910
-		$insert = '';
1911
-	} else {
1912
-		$insert = " $attribut='$val'";
1913
-	}
1914
-
1915
-	list($old, $r) = extraire_attribut($balise, $attribut, true);
1916
-
1917
-	if ($old !== null) {
1918
-		// Remplacer l'ancien attribut du meme nom
1919
-		$balise = $r[1] . $insert . $r[5];
1920
-	} else {
1921
-		// preferer une balise " />" (comme <img />)
1922
-		if (preg_match(',/>,', $balise)) {
1923
-			$balise = preg_replace(",\s?/>,S", $insert . " />", $balise, 1);
1924
-		} // sinon une balise <a ...> ... </a>
1925
-		else {
1926
-			$balise = preg_replace(",\s?>,S", $insert . ">", $balise, 1);
1927
-		}
1928
-	}
1929
-
1930
-	return $balise;
1900
+    // preparer l'attribut
1901
+    // supprimer les &nbsp; etc mais pas les balises html
1902
+    // qui ont un sens dans un attribut value d'un input
1903
+    if ($proteger) {
1904
+        $val = attribut_html($val, false);
1905
+    }
1906
+
1907
+    // echapper les ' pour eviter tout bug
1908
+    $val = str_replace("'", "&#039;", $val);
1909
+    if ($vider and strlen($val) == 0) {
1910
+        $insert = '';
1911
+    } else {
1912
+        $insert = " $attribut='$val'";
1913
+    }
1914
+
1915
+    list($old, $r) = extraire_attribut($balise, $attribut, true);
1916
+
1917
+    if ($old !== null) {
1918
+        // Remplacer l'ancien attribut du meme nom
1919
+        $balise = $r[1] . $insert . $r[5];
1920
+    } else {
1921
+        // preferer une balise " />" (comme <img />)
1922
+        if (preg_match(',/>,', $balise)) {
1923
+            $balise = preg_replace(",\s?/>,S", $insert . " />", $balise, 1);
1924
+        } // sinon une balise <a ...> ... </a>
1925
+        else {
1926
+            $balise = preg_replace(",\s?>,S", $insert . ">", $balise, 1);
1927
+        }
1928
+    }
1929
+
1930
+    return $balise;
1931 1931
 }
1932 1932
 
1933 1933
 /**
@@ -1945,7 +1945,7 @@  discard block
 block discarded – undo
1945 1945
  * @return string Code HTML sans l'attribut
1946 1946
  **/
1947 1947
 function vider_attribut($balise, $attribut) {
1948
-	return inserer_attribut($balise, $attribut, '', false, true);
1948
+    return inserer_attribut($balise, $attribut, '', false, true);
1949 1949
 }
1950 1950
 
1951 1951
 
@@ -1957,9 +1957,9 @@  discard block
 block discarded – undo
1957 1957
  * @return string
1958 1958
  */
1959 1959
 function tester_config($id, $mode = '') {
1960
-	include_spip('action/inscrire_auteur');
1960
+    include_spip('action/inscrire_auteur');
1961 1961
 
1962
-	return tester_statut_inscription($mode, $id);
1962
+    return tester_statut_inscription($mode, $id);
1963 1963
 }
1964 1964
 
1965 1965
 //
@@ -1984,7 +1984,7 @@  discard block
 block discarded – undo
1984 1984
  * @return int $a+$b
1985 1985
  **/
1986 1986
 function plus($a, $b) {
1987
-	return $a + $b;
1987
+    return $a + $b;
1988 1988
 }
1989 1989
 function strplus($a, $b) {return strize('plus', $a, $b);}
1990 1990
 /**
@@ -2003,7 +2003,7 @@  discard block
 block discarded – undo
2003 2003
  * @return int $a-$b
2004 2004
  **/
2005 2005
 function moins($a, $b) {
2006
-	return $a - $b;
2006
+    return $a - $b;
2007 2007
 }
2008 2008
 function strmoins($a, $b) {return strize('moins', $a, $b);}
2009 2009
 
@@ -2024,7 +2024,7 @@  discard block
 block discarded – undo
2024 2024
  * @return int $a*$b
2025 2025
  **/
2026 2026
 function mult($a, $b) {
2027
-	return $a * $b;
2027
+    return $a * $b;
2028 2028
 }
2029 2029
 function strmult($a, $b) {return strize('mult', $a, $b);}
2030 2030
 
@@ -2045,7 +2045,7 @@  discard block
 block discarded – undo
2045 2045
  * @return int $a/$b (ou 0 si $b est nul)
2046 2046
  **/
2047 2047
 function div($a, $b) {
2048
-	return $b ? $a / $b : 0;
2048
+    return $b ? $a / $b : 0;
2049 2049
 }
2050 2050
 function strdiv($a, $b) {return strize('div', $a, $b);}
2051 2051
 
@@ -2067,7 +2067,7 @@  discard block
 block discarded – undo
2067 2067
  * @return int ($nb % $mod) + $add
2068 2068
  **/
2069 2069
 function modulo($nb, $mod, $add = 0) {
2070
-	return ($mod ? $nb % $mod : 0) + $add;
2070
+    return ($mod ? $nb % $mod : 0) + $add;
2071 2071
 }
2072 2072
 
2073 2073
 
@@ -2082,24 +2082,24 @@  discard block
 block discarded – undo
2082 2082
  *      - true sinon
2083 2083
  **/
2084 2084
 function nom_acceptable($nom) {
2085
-	if (!is_string($nom)) {
2086
-		return false;
2087
-	}
2088
-	if (!defined('_TAGS_NOM_AUTEUR')) {
2089
-		define('_TAGS_NOM_AUTEUR', '');
2090
-	}
2091
-	$tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR));
2092
-	foreach ($tags_acceptes as $tag) {
2093
-		if (strlen($tag)) {
2094
-			$remp1[] = '<' . trim($tag) . '>';
2095
-			$remp1[] = '</' . trim($tag) . '>';
2096
-			$remp2[] = '\x60' . trim($tag) . '\x61';
2097
-			$remp2[] = '\x60/' . trim($tag) . '\x61';
2098
-		}
2099
-	}
2100
-	$v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom)));
2085
+    if (!is_string($nom)) {
2086
+        return false;
2087
+    }
2088
+    if (!defined('_TAGS_NOM_AUTEUR')) {
2089
+        define('_TAGS_NOM_AUTEUR', '');
2090
+    }
2091
+    $tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR));
2092
+    foreach ($tags_acceptes as $tag) {
2093
+        if (strlen($tag)) {
2094
+            $remp1[] = '<' . trim($tag) . '>';
2095
+            $remp1[] = '</' . trim($tag) . '>';
2096
+            $remp2[] = '\x60' . trim($tag) . '\x61';
2097
+            $remp2[] = '\x60/' . trim($tag) . '\x61';
2098
+        }
2099
+    }
2100
+    $v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom)));
2101 2101
 
2102
-	return str_replace('&lt;', '<', $v_nom) == $nom;
2102
+    return str_replace('&lt;', '<', $v_nom) == $nom;
2103 2103
 }
2104 2104
 
2105 2105
 
@@ -2113,29 +2113,29 @@  discard block
 block discarded – undo
2113 2113
  *      - la normalisation de la dernière adresse donnée sinon
2114 2114
  **/
2115 2115
 function email_valide($adresses) {
2116
-	// eviter d'injecter n'importe quoi dans preg_match
2117
-	if (!is_string($adresses)) {
2118
-		return false;
2119
-	}
2116
+    // eviter d'injecter n'importe quoi dans preg_match
2117
+    if (!is_string($adresses)) {
2118
+        return false;
2119
+    }
2120 2120
 
2121
-	// Si c'est un spammeur autant arreter tout de suite
2122
-	if (preg_match(",[\n\r].*(MIME|multipart|Content-),i", $adresses)) {
2123
-		spip_log("Tentative d'injection de mail : $adresses");
2121
+    // Si c'est un spammeur autant arreter tout de suite
2122
+    if (preg_match(",[\n\r].*(MIME|multipart|Content-),i", $adresses)) {
2123
+        spip_log("Tentative d'injection de mail : $adresses");
2124 2124
 
2125
-		return false;
2126
-	}
2125
+        return false;
2126
+    }
2127 2127
 
2128
-	foreach (explode(',', $adresses) as $v) {
2129
-		// nettoyer certains formats
2130
-		// "Marie Toto <[email protected]>"
2131
-		$adresse = trim(preg_replace(",^[^<>\"]*<([^<>\"]+)>$,i", "\\1", $v));
2132
-		// RFC 822
2133
-		if (!preg_match('#^[^()<>@,;:\\"/[:space:]]+(@([-_0-9a-z]+\.)*[-_0-9a-z]+)$#i', $adresse)) {
2134
-			return false;
2135
-		}
2136
-	}
2128
+    foreach (explode(',', $adresses) as $v) {
2129
+        // nettoyer certains formats
2130
+        // "Marie Toto <[email protected]>"
2131
+        $adresse = trim(preg_replace(",^[^<>\"]*<([^<>\"]+)>$,i", "\\1", $v));
2132
+        // RFC 822
2133
+        if (!preg_match('#^[^()<>@,;:\\"/[:space:]]+(@([-_0-9a-z]+\.)*[-_0-9a-z]+)$#i', $adresse)) {
2134
+            return false;
2135
+        }
2136
+    }
2137 2137
 
2138
-	return $adresse;
2138
+    return $adresse;
2139 2139
 }
2140 2140
 
2141 2141
 /**
@@ -2149,20 +2149,20 @@  discard block
 block discarded – undo
2149 2149
  * @return string Texte
2150 2150
  **/
2151 2151
 function afficher_enclosures($tags) {
2152
-	$s = array();
2153
-	foreach (extraire_balises($tags, 'a') as $tag) {
2154
-		if (extraire_attribut($tag, 'rel') == 'enclosure'
2155
-			and $t = extraire_attribut($tag, 'href')
2156
-		) {
2157
-			$s[] = preg_replace(',>[^<]+</a>,S',
2158
-				'>'
2159
-				. http_img_pack('attachment-16.png', $t,
2160
-					'title="' . attribut_html($t) . '"')
2161
-				. '</a>', $tag);
2162
-		}
2163
-	}
2152
+    $s = array();
2153
+    foreach (extraire_balises($tags, 'a') as $tag) {
2154
+        if (extraire_attribut($tag, 'rel') == 'enclosure'
2155
+            and $t = extraire_attribut($tag, 'href')
2156
+        ) {
2157
+            $s[] = preg_replace(',>[^<]+</a>,S',
2158
+                '>'
2159
+                . http_img_pack('attachment-16.png', $t,
2160
+                    'title="' . attribut_html($t) . '"')
2161
+                . '</a>', $tag);
2162
+        }
2163
+    }
2164 2164
 
2165
-	return join('&nbsp;', $s);
2165
+    return join('&nbsp;', $s);
2166 2166
 }
2167 2167
 
2168 2168
 /**
@@ -2177,15 +2177,15 @@  discard block
 block discarded – undo
2177 2177
  * @return string Liens trouvés
2178 2178
  **/
2179 2179
 function afficher_tags($tags, $rels = 'tag,directory') {
2180
-	$s = array();
2181
-	foreach (extraire_balises($tags, 'a') as $tag) {
2182
-		$rel = extraire_attribut($tag, 'rel');
2183
-		if (strstr(",$rels,", ",$rel,")) {
2184
-			$s[] = $tag;
2185
-		}
2186
-	}
2180
+    $s = array();
2181
+    foreach (extraire_balises($tags, 'a') as $tag) {
2182
+        $rel = extraire_attribut($tag, 'rel');
2183
+        if (strstr(",$rels,", ",$rel,")) {
2184
+            $s[] = $tag;
2185
+        }
2186
+    }
2187 2187
 
2188
-	return join(', ', $s);
2188
+    return join(', ', $s);
2189 2189
 }
2190 2190
 
2191 2191
 
@@ -2207,21 +2207,21 @@  discard block
 block discarded – undo
2207 2207
  * @return string Tag HTML `<a>` avec microformat.
2208 2208
  **/
2209 2209
 function enclosure2microformat($e) {
2210
-	if (!$url = filtrer_entites(extraire_attribut($e, 'url'))) {
2211
-		$url = filtrer_entites(extraire_attribut($e, 'href'));
2212
-	}
2213
-	$type = extraire_attribut($e, 'type');
2214
-	if (!$length = extraire_attribut($e, 'length')) {
2215
-		# <media:content : longeur dans fileSize. On tente.
2216
-		$length = extraire_attribut($e, 'fileSize');
2217
-	}
2218
-	$fichier = basename($url);
2210
+    if (!$url = filtrer_entites(extraire_attribut($e, 'url'))) {
2211
+        $url = filtrer_entites(extraire_attribut($e, 'href'));
2212
+    }
2213
+    $type = extraire_attribut($e, 'type');
2214
+    if (!$length = extraire_attribut($e, 'length')) {
2215
+        # <media:content : longeur dans fileSize. On tente.
2216
+        $length = extraire_attribut($e, 'fileSize');
2217
+    }
2218
+    $fichier = basename($url);
2219 2219
 
2220
-	return '<a rel="enclosure"'
2221
-	. ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '')
2222
-	. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2223
-	. ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '')
2224
-	. '>' . $fichier . '</a>';
2220
+    return '<a rel="enclosure"'
2221
+    . ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '')
2222
+    . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2223
+    . ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '')
2224
+    . '>' . $fichier . '</a>';
2225 2225
 }
2226 2226
 
2227 2227
 /**
@@ -2239,24 +2239,24 @@  discard block
 block discarded – undo
2239 2239
  * @return string Tags RSS `<enclosure>`.
2240 2240
  **/
2241 2241
 function microformat2enclosure($tags) {
2242
-	$enclosures = array();
2243
-	foreach (extraire_balises($tags, 'a') as $e) {
2244
-		if (extraire_attribut($e, 'rel') == 'enclosure') {
2245
-			$url = filtrer_entites(extraire_attribut($e, 'href'));
2246
-			$type = extraire_attribut($e, 'type');
2247
-			if (!$length = intval(extraire_attribut($e, 'title'))) {
2248
-				$length = intval(extraire_attribut($e, 'length'));
2249
-			} # vieux data
2250
-			$fichier = basename($url);
2251
-			$enclosures[] = '<enclosure'
2252
-				. ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '')
2253
-				. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2254
-				. ($length ? ' length="' . $length . '"' : '')
2255
-				. ' />';
2256
-		}
2257
-	}
2242
+    $enclosures = array();
2243
+    foreach (extraire_balises($tags, 'a') as $e) {
2244
+        if (extraire_attribut($e, 'rel') == 'enclosure') {
2245
+            $url = filtrer_entites(extraire_attribut($e, 'href'));
2246
+            $type = extraire_attribut($e, 'type');
2247
+            if (!$length = intval(extraire_attribut($e, 'title'))) {
2248
+                $length = intval(extraire_attribut($e, 'length'));
2249
+            } # vieux data
2250
+            $fichier = basename($url);
2251
+            $enclosures[] = '<enclosure'
2252
+                . ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '')
2253
+                . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2254
+                . ($length ? ' length="' . $length . '"' : '')
2255
+                . ' />';
2256
+        }
2257
+    }
2258 2258
 
2259
-	return join("\n", $enclosures);
2259
+    return join("\n", $enclosures);
2260 2260
 }
2261 2261
 
2262 2262
 
@@ -2272,16 +2272,16 @@  discard block
 block discarded – undo
2272 2272
  * @return string Tags RSS Atom `<dc:subject>`.
2273 2273
  **/
2274 2274
 function tags2dcsubject($tags) {
2275
-	$subjects = '';
2276
-	foreach (extraire_balises($tags, 'a') as $e) {
2277
-		if (extraire_attribut($e, rel) == 'tag') {
2278
-			$subjects .= '<dc:subject>'
2279
-				. texte_backend(textebrut($e))
2280
-				. '</dc:subject>' . "\n";
2281
-		}
2282
-	}
2275
+    $subjects = '';
2276
+    foreach (extraire_balises($tags, 'a') as $e) {
2277
+        if (extraire_attribut($e, rel) == 'tag') {
2278
+            $subjects .= '<dc:subject>'
2279
+                . texte_backend(textebrut($e))
2280
+                . '</dc:subject>' . "\n";
2281
+        }
2282
+    }
2283 2283
 
2284
-	return $subjects;
2284
+    return $subjects;
2285 2285
 }
2286 2286
 
2287 2287
 /**
@@ -2310,23 +2310,23 @@  discard block
 block discarded – undo
2310 2310
  *     - Tableau de résultats, si tableau en entrée.
2311 2311
  **/
2312 2312
 function extraire_balise($texte, $tag = 'a') {
2313
-	if (is_array($texte)) {
2314
-		array_walk(
2315
-			$texte,
2316
-			function(&$a, $key, $t){
2317
-				$a = extraire_balise($a, $t);
2318
-			},
2319
-			$tag
2320
-		);
2313
+    if (is_array($texte)) {
2314
+        array_walk(
2315
+            $texte,
2316
+            function(&$a, $key, $t){
2317
+                $a = extraire_balise($a, $t);
2318
+            },
2319
+            $tag
2320
+        );
2321 2321
 
2322
-		return $texte;
2323
-	}
2322
+        return $texte;
2323
+    }
2324 2324
 
2325
-	if (preg_match(
2326
-		",<$tag\b[^>]*(/>|>.*</$tag\b[^>]*>|>),UimsS",
2327
-		$texte, $regs)) {
2328
-		return $regs[0];
2329
-	}
2325
+    if (preg_match(
2326
+        ",<$tag\b[^>]*(/>|>.*</$tag\b[^>]*>|>),UimsS",
2327
+        $texte, $regs)) {
2328
+        return $regs[0];
2329
+    }
2330 2330
 }
2331 2331
 
2332 2332
 /**
@@ -2354,25 +2354,25 @@  discard block
 block discarded – undo
2354 2354
  *     - Tableau de résultats, si tableau en entrée.
2355 2355
  **/
2356 2356
 function extraire_balises($texte, $tag = 'a') {
2357
-	if (is_array($texte)) {
2358
-		array_walk(
2359
-			$texte,
2360
-			function(&$a, $key, $t){
2361
-				$a = extraire_balises($a, $t);
2362
-			},
2363
-			$tag
2364
-		);
2357
+    if (is_array($texte)) {
2358
+        array_walk(
2359
+            $texte,
2360
+            function(&$a, $key, $t){
2361
+                $a = extraire_balises($a, $t);
2362
+            },
2363
+            $tag
2364
+        );
2365 2365
 
2366
-		return $texte;
2367
-	}
2366
+        return $texte;
2367
+    }
2368 2368
 
2369
-	if (preg_match_all(
2370
-		",<${tag}\b[^>]*(/>|>.*</${tag}\b[^>]*>|>),UimsS",
2371
-		$texte, $regs, PREG_PATTERN_ORDER)) {
2372
-		return $regs[0];
2373
-	} else {
2374
-		return array();
2375
-	}
2369
+    if (preg_match_all(
2370
+        ",<${tag}\b[^>]*(/>|>.*</${tag}\b[^>]*>|>),UimsS",
2371
+        $texte, $regs, PREG_PATTERN_ORDER)) {
2372
+        return $regs[0];
2373
+    } else {
2374
+        return array();
2375
+    }
2376 2376
 }
2377 2377
 
2378 2378
 /**
@@ -2401,11 +2401,11 @@  discard block
 block discarded – undo
2401 2401
  *     - `$def` si on n'a pas transmis de tableau
2402 2402
  **/
2403 2403
 function in_any($val, $vals, $def = '') {
2404
-	if (!is_array($vals) and $v = unserialize($vals)) {
2405
-		$vals = $v;
2406
-	}
2404
+    if (!is_array($vals) and $v = unserialize($vals)) {
2405
+        $vals = $v;
2406
+    }
2407 2407
 
2408
-	return (!is_array($vals) ? $def : (in_array($val, $vals) ? ' ' : ''));
2408
+    return (!is_array($vals) ? $def : (in_array($val, $vals) ? ' ' : ''));
2409 2409
 }
2410 2410
 
2411 2411
 
@@ -2426,12 +2426,12 @@  discard block
 block discarded – undo
2426 2426
  *     Résultat du calcul
2427 2427
  **/
2428 2428
 function valeur_numerique($expr) {
2429
-	$a = 0;
2430
-	if (preg_match(',^[0-9]+(\s*[+*-]\s*[0-9]+)*$,S', trim($expr))) {
2431
-		eval("\$a = $expr;");
2432
-	}
2429
+    $a = 0;
2430
+    if (preg_match(',^[0-9]+(\s*[+*-]\s*[0-9]+)*$,S', trim($expr))) {
2431
+        eval("\$a = $expr;");
2432
+    }
2433 2433
 
2434
-	return intval($a);
2434
+    return intval($a);
2435 2435
 }
2436 2436
 
2437 2437
 /**
@@ -2450,7 +2450,7 @@  discard block
 block discarded – undo
2450 2450
  *      Retourne `$a*$b/$c`
2451 2451
  **/
2452 2452
 function regledetrois($a, $b, $c) {
2453
-	return round($a * $b / $c);
2453
+    return round($a * $b / $c);
2454 2454
 }
2455 2455
 
2456 2456
 
@@ -2474,76 +2474,76 @@  discard block
 block discarded – undo
2474 2474
  **/
2475 2475
 function form_hidden($action) {
2476 2476
 
2477
-	$contexte = array();
2478
-	include_spip('inc/urls');
2479
-	if ($p = urls_decoder_url($action, '')
2480
-		and reset($p)
2481
-	) {
2482
-		$fond = array_shift($p);
2483
-		if ($fond != '404') {
2484
-			$contexte = array_shift($p);
2485
-			$contexte['page'] = $fond;
2486
-			$action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action);
2487
-		}
2488
-	}
2489
-	// defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url
2490
-	if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) {
2491
-		unset($contexte['type']);
2492
-	}
2493
-	if (defined('_DEFINIR_CONTEXTE_TYPE_PAGE') and _DEFINIR_CONTEXTE_TYPE_PAGE) {
2494
-		unset($contexte['type-page']);
2495
-	}
2496
-
2497
-	// on va remplir un tableau de valeurs en prenant bien soin de ne pas
2498
-	// ecraser les elements de la forme mots[]=1&mots[]=2
2499
-	$values = array();
2500
-
2501
-	// d'abord avec celles de l'url
2502
-	if (false !== ($p = strpos($action, '?'))) {
2503
-		foreach (preg_split('/&(amp;)?/S', substr($action, $p + 1)) as $c) {
2504
-			$c = explode('=', $c, 2);
2505
-			$var = array_shift($c);
2506
-			$val = array_shift($c);
2507
-			if ($var) {
2508
-				$val = rawurldecode($val);
2509
-				$var = rawurldecode($var); // decoder les [] eventuels
2510
-				if (preg_match(',\[\]$,S', $var)) {
2511
-					$values[] = array($var, $val);
2512
-				} else {
2513
-					if (!isset($values[$var])) {
2514
-						$values[$var] = array($var, $val);
2515
-					}
2516
-				}
2517
-			}
2518
-		}
2519
-	}
2520
-
2521
-	// ensuite avec celles du contexte, sans doublonner !
2522
-	foreach ($contexte as $var => $val) {
2523
-		if (preg_match(',\[\]$,S', $var)) {
2524
-			$values[] = array($var, $val);
2525
-		} else {
2526
-			if (!isset($values[$var])) {
2527
-				$values[$var] = array($var, $val);
2528
-			}
2529
-		}
2530
-	}
2531
-
2532
-	// puis on rassemble le tout
2533
-	$hidden = array();
2534
-	foreach ($values as $value) {
2535
-		list($var, $val) = $value;
2536
-		$hidden[] = '<input name="'
2537
-			. entites_html($var)
2538
-			. '"'
2539
-			. (is_null($val)
2540
-				? ''
2541
-				: ' value="' . entites_html($val) . '"'
2542
-			)
2543
-			. ' type="hidden"' . "\n/>";
2544
-	}
2545
-
2546
-	return join("", $hidden);
2477
+    $contexte = array();
2478
+    include_spip('inc/urls');
2479
+    if ($p = urls_decoder_url($action, '')
2480
+        and reset($p)
2481
+    ) {
2482
+        $fond = array_shift($p);
2483
+        if ($fond != '404') {
2484
+            $contexte = array_shift($p);
2485
+            $contexte['page'] = $fond;
2486
+            $action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action);
2487
+        }
2488
+    }
2489
+    // defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url
2490
+    if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) {
2491
+        unset($contexte['type']);
2492
+    }
2493
+    if (defined('_DEFINIR_CONTEXTE_TYPE_PAGE') and _DEFINIR_CONTEXTE_TYPE_PAGE) {
2494
+        unset($contexte['type-page']);
2495
+    }
2496
+
2497
+    // on va remplir un tableau de valeurs en prenant bien soin de ne pas
2498
+    // ecraser les elements de la forme mots[]=1&mots[]=2
2499
+    $values = array();
2500
+
2501
+    // d'abord avec celles de l'url
2502
+    if (false !== ($p = strpos($action, '?'))) {
2503
+        foreach (preg_split('/&(amp;)?/S', substr($action, $p + 1)) as $c) {
2504
+            $c = explode('=', $c, 2);
2505
+            $var = array_shift($c);
2506
+            $val = array_shift($c);
2507
+            if ($var) {
2508
+                $val = rawurldecode($val);
2509
+                $var = rawurldecode($var); // decoder les [] eventuels
2510
+                if (preg_match(',\[\]$,S', $var)) {
2511
+                    $values[] = array($var, $val);
2512
+                } else {
2513
+                    if (!isset($values[$var])) {
2514
+                        $values[$var] = array($var, $val);
2515
+                    }
2516
+                }
2517
+            }
2518
+        }
2519
+    }
2520
+
2521
+    // ensuite avec celles du contexte, sans doublonner !
2522
+    foreach ($contexte as $var => $val) {
2523
+        if (preg_match(',\[\]$,S', $var)) {
2524
+            $values[] = array($var, $val);
2525
+        } else {
2526
+            if (!isset($values[$var])) {
2527
+                $values[$var] = array($var, $val);
2528
+            }
2529
+        }
2530
+    }
2531
+
2532
+    // puis on rassemble le tout
2533
+    $hidden = array();
2534
+    foreach ($values as $value) {
2535
+        list($var, $val) = $value;
2536
+        $hidden[] = '<input name="'
2537
+            . entites_html($var)
2538
+            . '"'
2539
+            . (is_null($val)
2540
+                ? ''
2541
+                : ' value="' . entites_html($val) . '"'
2542
+            )
2543
+            . ' type="hidden"' . "\n/>";
2544
+    }
2545
+
2546
+    return join("", $hidden);
2547 2547
 }
2548 2548
 
2549 2549
 /**
@@ -2561,15 +2561,15 @@  discard block
 block discarded – undo
2561 2561
  *     Liste (première page, dernière page).
2562 2562
  **/
2563 2563
 function filtre_bornes_pagination_dist($courante, $nombre, $max = 10) {
2564
-	if ($max <= 0 or $max >= $nombre) {
2565
-		return array(1, $nombre);
2566
-	}
2564
+    if ($max <= 0 or $max >= $nombre) {
2565
+        return array(1, $nombre);
2566
+    }
2567 2567
 
2568
-	$premiere = max(1, $courante - floor(($max - 1) / 2));
2569
-	$derniere = min($nombre, $premiere + $max - 2);
2570
-	$premiere = $derniere == $nombre ? $derniere - $max + 1 : $premiere;
2568
+    $premiere = max(1, $courante - floor(($max - 1) / 2));
2569
+    $derniere = min($nombre, $premiere + $max - 2);
2570
+    $premiere = $derniere == $nombre ? $derniere - $max + 1 : $premiere;
2571 2571
 
2572
-	return array($premiere, $derniere);
2572
+    return array($premiere, $derniere);
2573 2573
 }
2574 2574
 
2575 2575
 
@@ -2591,7 +2591,7 @@  discard block
 block discarded – undo
2591 2591
  *    - la première valeur du tableau sinon.
2592 2592
  **/
2593 2593
 function filtre_reset($array) {
2594
-	return !is_array($array) ? null : reset($array);
2594
+    return !is_array($array) ? null : reset($array);
2595 2595
 }
2596 2596
 
2597 2597
 /**
@@ -2612,7 +2612,7 @@  discard block
 block discarded – undo
2612 2612
  *    - la dernière valeur du tableau sinon.
2613 2613
  **/
2614 2614
 function filtre_end($array) {
2615
-	return !is_array($array) ? null : end($array);
2615
+    return !is_array($array) ? null : end($array);
2616 2616
 }
2617 2617
 
2618 2618
 /**
@@ -2632,11 +2632,11 @@  discard block
 block discarded – undo
2632 2632
  *
2633 2633
  **/
2634 2634
 function filtre_push($array, $val) {
2635
-	if (!is_array($array) or !array_push($array, $val)) {
2636
-		return '';
2637
-	}
2635
+    if (!is_array($array) or !array_push($array, $val)) {
2636
+        return '';
2637
+    }
2638 2638
 
2639
-	return $array;
2639
+    return $array;
2640 2640
 }
2641 2641
 
2642 2642
 /**
@@ -2655,7 +2655,7 @@  discard block
 block discarded – undo
2655 2655
  *     - `true` si la valeur existe dans le tableau, `false` sinon.
2656 2656
  **/
2657 2657
 function filtre_find($array, $val) {
2658
-	return (is_array($array) and in_array($val, $array));
2658
+    return (is_array($array) and in_array($val, $array));
2659 2659
 }
2660 2660
 
2661 2661
 
@@ -2690,58 +2690,58 @@  discard block
 block discarded – undo
2690 2690
  *     Code HTML de la pagination
2691 2691
  **/
2692 2692
 function filtre_pagination_dist(
2693
-	$total,
2694
-	$nom,
2695
-	$position,
2696
-	$pas,
2697
-	$liste = true,
2698
-	$modele = '',
2699
-	$connect = '',
2700
-	$env = array()
2693
+    $total,
2694
+    $nom,
2695
+    $position,
2696
+    $pas,
2697
+    $liste = true,
2698
+    $modele = '',
2699
+    $connect = '',
2700
+    $env = array()
2701 2701
 ) {
2702
-	static $ancres = array();
2703
-	if ($pas < 1) {
2704
-		return '';
2705
-	}
2706
-	$ancre = 'pagination' . $nom; // #pagination_articles
2707
-	$debut = 'debut' . $nom; // 'debut_articles'
2708
-
2709
-	// n'afficher l'ancre qu'une fois
2710
-	if (!isset($ancres[$ancre])) {
2711
-		$bloc_ancre = $ancres[$ancre] = "<a name='" . $ancre . "' id='" . $ancre . "'></a>";
2712
-	} else {
2713
-		$bloc_ancre = '';
2714
-	}
2715
-	// liste = false : on ne veut que l'ancre
2716
-	if (!$liste) {
2717
-		return $ancres[$ancre];
2718
-	}
2719
-
2720
-	$pagination = array(
2721
-		'debut' => $debut,
2722
-		'url' => parametre_url(self(), 'fragment', ''), // nettoyer l'id ahah eventuel
2723
-		'total' => $total,
2724
-		'position' => intval($position),
2725
-		'pas' => $pas,
2726
-		'nombre_pages' => floor(($total - 1) / $pas) + 1,
2727
-		'page_courante' => floor(intval($position) / $pas) + 1,
2728
-		'ancre' => $ancre,
2729
-		'bloc_ancre' => $bloc_ancre
2730
-	);
2731
-	if (is_array($env)) {
2732
-		$pagination = array_merge($env, $pagination);
2733
-	}
2734
-
2735
-	// Pas de pagination
2736
-	if ($pagination['nombre_pages'] <= 1) {
2737
-		return '';
2738
-	}
2739
-
2740
-	if ($modele) {
2741
-		$modele = '_' . $modele;
2742
-	}
2743
-
2744
-	return recuperer_fond("modeles/pagination$modele", $pagination, array('trim' => true), $connect);
2702
+    static $ancres = array();
2703
+    if ($pas < 1) {
2704
+        return '';
2705
+    }
2706
+    $ancre = 'pagination' . $nom; // #pagination_articles
2707
+    $debut = 'debut' . $nom; // 'debut_articles'
2708
+
2709
+    // n'afficher l'ancre qu'une fois
2710
+    if (!isset($ancres[$ancre])) {
2711
+        $bloc_ancre = $ancres[$ancre] = "<a name='" . $ancre . "' id='" . $ancre . "'></a>";
2712
+    } else {
2713
+        $bloc_ancre = '';
2714
+    }
2715
+    // liste = false : on ne veut que l'ancre
2716
+    if (!$liste) {
2717
+        return $ancres[$ancre];
2718
+    }
2719
+
2720
+    $pagination = array(
2721
+        'debut' => $debut,
2722
+        'url' => parametre_url(self(), 'fragment', ''), // nettoyer l'id ahah eventuel
2723
+        'total' => $total,
2724
+        'position' => intval($position),
2725
+        'pas' => $pas,
2726
+        'nombre_pages' => floor(($total - 1) / $pas) + 1,
2727
+        'page_courante' => floor(intval($position) / $pas) + 1,
2728
+        'ancre' => $ancre,
2729
+        'bloc_ancre' => $bloc_ancre
2730
+    );
2731
+    if (is_array($env)) {
2732
+        $pagination = array_merge($env, $pagination);
2733
+    }
2734
+
2735
+    // Pas de pagination
2736
+    if ($pagination['nombre_pages'] <= 1) {
2737
+        return '';
2738
+    }
2739
+
2740
+    if ($modele) {
2741
+        $modele = '_' . $modele;
2742
+    }
2743
+
2744
+    return recuperer_fond("modeles/pagination$modele", $pagination, array('trim' => true), $connect);
2745 2745
 }
2746 2746
 
2747 2747
 
@@ -2758,15 +2758,15 @@  discard block
 block discarded – undo
2758 2758
  *     Contenu avec urls en absolus
2759 2759
  **/
2760 2760
 function urls_absolues_css($contenu, $source) {
2761
-	$path = suivre_lien(url_absolue($source), './');
2761
+    $path = suivre_lien(url_absolue($source), './');
2762 2762
 
2763
-	return preg_replace_callback(
2764
-		",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims",
2765
-		function($x) use ($path) {
2766
-			return "url('" . suivre_lien($path, $x[1]) . "')";
2767
-		},
2768
-		$contenu
2769
-	);
2763
+    return preg_replace_callback(
2764
+        ",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims",
2765
+        function($x) use ($path) {
2766
+            return "url('" . suivre_lien($path, $x[1]) . "')";
2767
+        },
2768
+        $contenu
2769
+    );
2770 2770
 }
2771 2771
 
2772 2772
 
@@ -2795,118 +2795,118 @@  discard block
 block discarded – undo
2795 2795
  *     Chemin du fichier CSS inversé
2796 2796
  **/
2797 2797
 function direction_css($css, $voulue = '') {
2798
-	if (!preg_match(',(_rtl)?\.css$,i', $css, $r)) {
2799
-		return $css;
2800
-	}
2801
-
2802
-	// si on a precise le sens voulu en argument, le prendre en compte
2803
-	if ($voulue = strtolower($voulue)) {
2804
-		if ($voulue != 'rtl' and $voulue != 'ltr') {
2805
-			$voulue = lang_dir($voulue);
2806
-		}
2807
-	} else {
2808
-		$voulue = lang_dir();
2809
-	}
2810
-
2811
-	$r = count($r) > 1;
2812
-	$right = $r ? 'left' : 'right'; // 'right' de la css lue en entree
2813
-	$dir = $r ? 'rtl' : 'ltr';
2814
-	$ndir = $r ? 'ltr' : 'rtl';
2815
-
2816
-	if ($voulue == $dir) {
2817
-		return $css;
2818
-	}
2819
-
2820
-	if (
2821
-		// url absolue
2822
-		preg_match(",^https?:,i", $css)
2823
-		// ou qui contient un ?
2824
-		or (($p = strpos($css, '?')) !== false)
2825
-	) {
2826
-		$distant = true;
2827
-		$cssf = parse_url($css);
2828
-		$cssf = $cssf['path'] . ($cssf['query'] ? "?" . $cssf['query'] : "");
2829
-		$cssf = preg_replace(',[?:&=],', "_", $cssf);
2830
-	} else {
2831
-		$distant = false;
2832
-		$cssf = $css;
2833
-		// 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi
2834
-		//propose (rien a faire dans ce cas)
2835
-		$f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css);
2836
-		if (@file_exists($f)) {
2837
-			return $f;
2838
-		}
2839
-	}
2840
-
2841
-	// 2.
2842
-	$dir_var = sous_repertoire(_DIR_VAR, 'cache-css');
2843
-	$f = $dir_var
2844
-		. preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf)
2845
-		. '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css';
2846
-
2847
-	// la css peut etre distante (url absolue !)
2848
-	if ($distant) {
2849
-		include_spip('inc/distant');
2850
-		$res = recuperer_url($css);
2851
-		if (!$res or !$contenu = $res['page']) {
2852
-			return $css;
2853
-		}
2854
-	} else {
2855
-		if ((@filemtime($f) > @filemtime($css))
2856
-			and (_VAR_MODE != 'recalcul')
2857
-		) {
2858
-			return $f;
2859
-		}
2860
-		if (!lire_fichier($css, $contenu)) {
2861
-			return $css;
2862
-		}
2863
-	}
2864
-
2865
-
2866
-	// Inverser la direction gauche-droite en utilisant CSSTidy qui gere aussi les shorthands
2867
-	include_spip("lib/csstidy/class.csstidy");
2868
-	$parser = new csstidy();
2869
-	$parser->set_cfg('optimise_shorthands', 0);
2870
-	$parser->set_cfg('reverse_left_and_right', true);
2871
-	$parser->parse($contenu);
2872
-
2873
-	$contenu = $parser->print->plain();
2874
-
2875
-
2876
-	// reperer les @import auxquels il faut propager le direction_css
2877
-	preg_match_all(",\@import\s*url\s*\(\s*['\"]?([^'\"/][^:]*)['\"]?\s*\),Uims", $contenu, $regs);
2878
-	$src = array();
2879
-	$src_direction_css = array();
2880
-	$src_faux_abs = array();
2881
-	$d = dirname($css);
2882
-	foreach ($regs[1] as $k => $import_css) {
2883
-		$css_direction = direction_css("$d/$import_css", $voulue);
2884
-		// si la css_direction est dans le meme path que la css d'origine, on tronque le path, elle sera passee en absolue
2885
-		if (substr($css_direction, 0, strlen($d) + 1) == "$d/") {
2886
-			$css_direction = substr($css_direction, strlen($d) + 1);
2887
-		} // si la css_direction commence par $dir_var on la fait passer pour une absolue
2888
-		elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) {
2889
-			$css_direction = substr($css_direction, strlen($dir_var));
2890
-			$src_faux_abs["/@@@@@@/" . $css_direction] = $css_direction;
2891
-			$css_direction = "/@@@@@@/" . $css_direction;
2892
-		}
2893
-		$src[] = $regs[0][$k];
2894
-		$src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]);
2895
-	}
2896
-	$contenu = str_replace($src, $src_direction_css, $contenu);
2897
-
2898
-	$contenu = urls_absolues_css($contenu, $css);
2899
-
2900
-	// virer les fausses url absolues que l'on a mis dans les import
2901
-	if (count($src_faux_abs)) {
2902
-		$contenu = str_replace(array_keys($src_faux_abs), $src_faux_abs, $contenu);
2903
-	}
2904
-
2905
-	if (!ecrire_fichier($f, $contenu)) {
2906
-		return $css;
2907
-	}
2908
-
2909
-	return $f;
2798
+    if (!preg_match(',(_rtl)?\.css$,i', $css, $r)) {
2799
+        return $css;
2800
+    }
2801
+
2802
+    // si on a precise le sens voulu en argument, le prendre en compte
2803
+    if ($voulue = strtolower($voulue)) {
2804
+        if ($voulue != 'rtl' and $voulue != 'ltr') {
2805
+            $voulue = lang_dir($voulue);
2806
+        }
2807
+    } else {
2808
+        $voulue = lang_dir();
2809
+    }
2810
+
2811
+    $r = count($r) > 1;
2812
+    $right = $r ? 'left' : 'right'; // 'right' de la css lue en entree
2813
+    $dir = $r ? 'rtl' : 'ltr';
2814
+    $ndir = $r ? 'ltr' : 'rtl';
2815
+
2816
+    if ($voulue == $dir) {
2817
+        return $css;
2818
+    }
2819
+
2820
+    if (
2821
+        // url absolue
2822
+        preg_match(",^https?:,i", $css)
2823
+        // ou qui contient un ?
2824
+        or (($p = strpos($css, '?')) !== false)
2825
+    ) {
2826
+        $distant = true;
2827
+        $cssf = parse_url($css);
2828
+        $cssf = $cssf['path'] . ($cssf['query'] ? "?" . $cssf['query'] : "");
2829
+        $cssf = preg_replace(',[?:&=],', "_", $cssf);
2830
+    } else {
2831
+        $distant = false;
2832
+        $cssf = $css;
2833
+        // 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi
2834
+        //propose (rien a faire dans ce cas)
2835
+        $f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css);
2836
+        if (@file_exists($f)) {
2837
+            return $f;
2838
+        }
2839
+    }
2840
+
2841
+    // 2.
2842
+    $dir_var = sous_repertoire(_DIR_VAR, 'cache-css');
2843
+    $f = $dir_var
2844
+        . preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf)
2845
+        . '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css';
2846
+
2847
+    // la css peut etre distante (url absolue !)
2848
+    if ($distant) {
2849
+        include_spip('inc/distant');
2850
+        $res = recuperer_url($css);
2851
+        if (!$res or !$contenu = $res['page']) {
2852
+            return $css;
2853
+        }
2854
+    } else {
2855
+        if ((@filemtime($f) > @filemtime($css))
2856
+            and (_VAR_MODE != 'recalcul')
2857
+        ) {
2858
+            return $f;
2859
+        }
2860
+        if (!lire_fichier($css, $contenu)) {
2861
+            return $css;
2862
+        }
2863
+    }
2864
+
2865
+
2866
+    // Inverser la direction gauche-droite en utilisant CSSTidy qui gere aussi les shorthands
2867
+    include_spip("lib/csstidy/class.csstidy");
2868
+    $parser = new csstidy();
2869
+    $parser->set_cfg('optimise_shorthands', 0);
2870
+    $parser->set_cfg('reverse_left_and_right', true);
2871
+    $parser->parse($contenu);
2872
+
2873
+    $contenu = $parser->print->plain();
2874
+
2875
+
2876
+    // reperer les @import auxquels il faut propager le direction_css
2877
+    preg_match_all(",\@import\s*url\s*\(\s*['\"]?([^'\"/][^:]*)['\"]?\s*\),Uims", $contenu, $regs);
2878
+    $src = array();
2879
+    $src_direction_css = array();
2880
+    $src_faux_abs = array();
2881
+    $d = dirname($css);
2882
+    foreach ($regs[1] as $k => $import_css) {
2883
+        $css_direction = direction_css("$d/$import_css", $voulue);
2884
+        // si la css_direction est dans le meme path que la css d'origine, on tronque le path, elle sera passee en absolue
2885
+        if (substr($css_direction, 0, strlen($d) + 1) == "$d/") {
2886
+            $css_direction = substr($css_direction, strlen($d) + 1);
2887
+        } // si la css_direction commence par $dir_var on la fait passer pour une absolue
2888
+        elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) {
2889
+            $css_direction = substr($css_direction, strlen($dir_var));
2890
+            $src_faux_abs["/@@@@@@/" . $css_direction] = $css_direction;
2891
+            $css_direction = "/@@@@@@/" . $css_direction;
2892
+        }
2893
+        $src[] = $regs[0][$k];
2894
+        $src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]);
2895
+    }
2896
+    $contenu = str_replace($src, $src_direction_css, $contenu);
2897
+
2898
+    $contenu = urls_absolues_css($contenu, $css);
2899
+
2900
+    // virer les fausses url absolues que l'on a mis dans les import
2901
+    if (count($src_faux_abs)) {
2902
+        $contenu = str_replace(array_keys($src_faux_abs), $src_faux_abs, $contenu);
2903
+    }
2904
+
2905
+    if (!ecrire_fichier($f, $contenu)) {
2906
+        return $css;
2907
+    }
2908
+
2909
+    return $f;
2910 2910
 }
2911 2911
 
2912 2912
 
@@ -2929,43 +2929,43 @@  discard block
 block discarded – undo
2929 2929
  *     - Chemin ou URL du fichier CSS source sinon.
2930 2930
  **/
2931 2931
 function url_absolue_css($css) {
2932
-	if (!preg_match(',\.css$,i', $css, $r)) {
2933
-		return $css;
2934
-	}
2932
+    if (!preg_match(',\.css$,i', $css, $r)) {
2933
+        return $css;
2934
+    }
2935 2935
 
2936
-	$url_absolue_css = url_absolue($css);
2936
+    $url_absolue_css = url_absolue($css);
2937 2937
 
2938
-	$f = basename($css, '.css');
2939
-	$f = sous_repertoire(_DIR_VAR, 'cache-css')
2940
-		. preg_replace(",(.*?)(_rtl|_ltr)?$,", "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f)
2941
-		. '.css';
2938
+    $f = basename($css, '.css');
2939
+    $f = sous_repertoire(_DIR_VAR, 'cache-css')
2940
+        . preg_replace(",(.*?)(_rtl|_ltr)?$,", "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f)
2941
+        . '.css';
2942 2942
 
2943
-	if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) {
2944
-		return $f;
2945
-	}
2943
+    if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) {
2944
+        return $f;
2945
+    }
2946 2946
 
2947
-	if ($url_absolue_css == $css) {
2948
-		if (strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0
2949
-			or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu)
2950
-		) {
2951
-			include_spip('inc/distant');
2952
-			if (!$contenu = recuperer_page($css)) {
2953
-				return $css;
2954
-			}
2955
-		}
2956
-	} elseif (!lire_fichier($css, $contenu)) {
2957
-		return $css;
2958
-	}
2947
+    if ($url_absolue_css == $css) {
2948
+        if (strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0
2949
+            or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu)
2950
+        ) {
2951
+            include_spip('inc/distant');
2952
+            if (!$contenu = recuperer_page($css)) {
2953
+                return $css;
2954
+            }
2955
+        }
2956
+    } elseif (!lire_fichier($css, $contenu)) {
2957
+        return $css;
2958
+    }
2959 2959
 
2960
-	// passer les url relatives a la css d'origine en url absolues
2961
-	$contenu = urls_absolues_css($contenu, $css);
2960
+    // passer les url relatives a la css d'origine en url absolues
2961
+    $contenu = urls_absolues_css($contenu, $css);
2962 2962
 
2963
-	// ecrire la css
2964
-	if (!ecrire_fichier($f, $contenu)) {
2965
-		return $css;
2966
-	}
2963
+    // ecrire la css
2964
+    if (!ecrire_fichier($f, $contenu)) {
2965
+        return $css;
2966
+    }
2967 2967
 
2968
-	return $f;
2968
+    return $f;
2969 2969
 }
2970 2970
 
2971 2971
 
@@ -2999,24 +2999,24 @@  discard block
 block discarded – undo
2999 2999
  *     Valeur trouvée ou valeur par défaut.
3000 3000
  **/
3001 3001
 function table_valeur($table, $cle, $defaut = '', $conserver_null = false) {
3002
-	foreach (explode('/', $cle) as $k) {
3002
+    foreach (explode('/', $cle) as $k) {
3003 3003
 
3004
-		$table = is_string($table) ? @unserialize($table) : $table;
3004
+        $table = is_string($table) ? @unserialize($table) : $table;
3005 3005
 
3006
-		if (is_object($table)) {
3007
-			$table = (($k !== "") and isset($table->$k)) ? $table->$k : $defaut;
3008
-		} elseif (is_array($table)) {
3009
-			if ($conserver_null) {
3010
-				$table = array_key_exists($k, $table) ? $table[$k] : $defaut;
3011
-			} else {
3012
-				$table = isset($table[$k]) ? $table[$k] : $defaut;
3013
-			}
3014
-		} else {
3015
-			$table = $defaut;
3016
-		}
3017
-	}
3006
+        if (is_object($table)) {
3007
+            $table = (($k !== "") and isset($table->$k)) ? $table->$k : $defaut;
3008
+        } elseif (is_array($table)) {
3009
+            if ($conserver_null) {
3010
+                $table = array_key_exists($k, $table) ? $table[$k] : $defaut;
3011
+            } else {
3012
+                $table = isset($table[$k]) ? $table[$k] : $defaut;
3013
+            }
3014
+        } else {
3015
+            $table = $defaut;
3016
+        }
3017
+    }
3018 3018
 
3019
-	return $table;
3019
+    return $table;
3020 3020
 }
3021 3021
 
3022 3022
 /**
@@ -3049,22 +3049,22 @@  discard block
 block discarded – undo
3049 3049
  *     - string : expression trouvée.
3050 3050
  **/
3051 3051
 function match($texte, $expression, $modif = "UimsS", $capte = 0) {
3052
-	if (intval($modif) and $capte == 0) {
3053
-		$capte = $modif;
3054
-		$modif = "UimsS";
3055
-	}
3056
-	$expression = str_replace("\/", "/", $expression);
3057
-	$expression = str_replace("/", "\/", $expression);
3052
+    if (intval($modif) and $capte == 0) {
3053
+        $capte = $modif;
3054
+        $modif = "UimsS";
3055
+    }
3056
+    $expression = str_replace("\/", "/", $expression);
3057
+    $expression = str_replace("/", "\/", $expression);
3058 3058
 
3059
-	if (preg_match('/' . $expression . '/' . $modif, $texte, $r)) {
3060
-		if (isset($r[$capte])) {
3061
-			return $r[$capte];
3062
-		} else {
3063
-			return true;
3064
-		}
3065
-	}
3059
+    if (preg_match('/' . $expression . '/' . $modif, $texte, $r)) {
3060
+        if (isset($r[$capte])) {
3061
+            return $r[$capte];
3062
+        } else {
3063
+            return true;
3064
+        }
3065
+    }
3066 3066
 
3067
-	return false;
3067
+    return false;
3068 3068
 }
3069 3069
 
3070 3070
 
@@ -3091,10 +3091,10 @@  discard block
 block discarded – undo
3091 3091
  *     Texte
3092 3092
  **/
3093 3093
 function replace($texte, $expression, $replace = '', $modif = "UimsS") {
3094
-	$expression = str_replace("\/", "/", $expression);
3095
-	$expression = str_replace("/", "\/", $expression);
3094
+    $expression = str_replace("\/", "/", $expression);
3095
+    $expression = str_replace("/", "\/", $expression);
3096 3096
 
3097
-	return preg_replace('/' . $expression . '/' . $modif, $replace, $texte);
3097
+    return preg_replace('/' . $expression . '/' . $modif, $replace, $texte);
3098 3098
 }
3099 3099
 
3100 3100
 
@@ -3112,21 +3112,21 @@  discard block
 block discarded – undo
3112 3112
  **/
3113 3113
 function traiter_doublons_documents(&$doublons, $letexte) {
3114 3114
 
3115
-	// Verifier dans le texte & les notes (pas beau, helas)
3116
-	$t = $letexte . $GLOBALS['les_notes'];
3115
+    // Verifier dans le texte & les notes (pas beau, helas)
3116
+    $t = $letexte . $GLOBALS['les_notes'];
3117 3117
 
3118
-	if (strstr($t, 'spip_document_') // evite le preg_match_all si inutile
3119
-		and preg_match_all(
3120
-			',<[^>]+\sclass=["\']spip_document_([0-9]+)[\s"\'],imsS',
3121
-			$t, $matches, PREG_PATTERN_ORDER)
3122
-	) {
3123
-		if (!isset($doublons['documents'])) {
3124
-			$doublons['documents'] = "";
3125
-		}
3126
-		$doublons['documents'] .= "," . join(',', $matches[1]);
3127
-	}
3118
+    if (strstr($t, 'spip_document_') // evite le preg_match_all si inutile
3119
+        and preg_match_all(
3120
+            ',<[^>]+\sclass=["\']spip_document_([0-9]+)[\s"\'],imsS',
3121
+            $t, $matches, PREG_PATTERN_ORDER)
3122
+    ) {
3123
+        if (!isset($doublons['documents'])) {
3124
+            $doublons['documents'] = "";
3125
+        }
3126
+        $doublons['documents'] .= "," . join(',', $matches[1]);
3127
+    }
3128 3128
 
3129
-	return $letexte;
3129
+    return $letexte;
3130 3130
 }
3131 3131
 
3132 3132
 /**
@@ -3140,7 +3140,7 @@  discard block
 block discarded – undo
3140 3140
  * @return string Chaîne vide
3141 3141
  **/
3142 3142
 function vide($texte) {
3143
-	return "";
3143
+    return "";
3144 3144
 }
3145 3145
 
3146 3146
 //
@@ -3169,23 +3169,23 @@  discard block
 block discarded – undo
3169 3169
  *      Code HTML résultant
3170 3170
  **/
3171 3171
 function env_to_params($env, $ignore_params = array()) {
3172
-	$ignore_params = array_merge(
3173
-		array('id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'),
3174
-		$ignore_params
3175
-	);
3176
-	if (!is_array($env)) {
3177
-		$env = unserialize($env);
3178
-	}
3179
-	$texte = "";
3180
-	if ($env) {
3181
-		foreach ($env as $i => $j) {
3182
-			if (is_string($j) and !in_array($i, $ignore_params)) {
3183
-				$texte .= "<param name='" . $i . "'\n\tvalue='" . $j . "' />";
3184
-			}
3185
-		}
3186
-	}
3187
-
3188
-	return $texte;
3172
+    $ignore_params = array_merge(
3173
+        array('id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'),
3174
+        $ignore_params
3175
+    );
3176
+    if (!is_array($env)) {
3177
+        $env = unserialize($env);
3178
+    }
3179
+    $texte = "";
3180
+    if ($env) {
3181
+        foreach ($env as $i => $j) {
3182
+            if (is_string($j) and !in_array($i, $ignore_params)) {
3183
+                $texte .= "<param name='" . $i . "'\n\tvalue='" . $j . "' />";
3184
+            }
3185
+        }
3186
+    }
3187
+
3188
+    return $texte;
3189 3189
 }
3190 3190
 
3191 3191
 /**
@@ -3208,23 +3208,23 @@  discard block
 block discarded – undo
3208 3208
  *      Code HTML résultant
3209 3209
  **/
3210 3210
 function env_to_attributs($env, $ignore_params = array()) {
3211
-	$ignore_params = array_merge(
3212
-		array('id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'),
3213
-		$ignore_params
3214
-	);
3215
-	if (!is_array($env)) {
3216
-		$env = unserialize($env);
3217
-	}
3218
-	$texte = "";
3219
-	if ($env) {
3220
-		foreach ($env as $i => $j) {
3221
-			if (is_string($j) and !in_array($i, $ignore_params)) {
3222
-				$texte .= $i . "='" . $j . "' ";
3223
-			}
3224
-		}
3225
-	}
3211
+    $ignore_params = array_merge(
3212
+        array('id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'),
3213
+        $ignore_params
3214
+    );
3215
+    if (!is_array($env)) {
3216
+        $env = unserialize($env);
3217
+    }
3218
+    $texte = "";
3219
+    if ($env) {
3220
+        foreach ($env as $i => $j) {
3221
+            if (is_string($j) and !in_array($i, $ignore_params)) {
3222
+                $texte .= $i . "='" . $j . "' ";
3223
+            }
3224
+        }
3225
+    }
3226 3226
 
3227
-	return $texte;
3227
+    return $texte;
3228 3228
 }
3229 3229
 
3230 3230
 
@@ -3241,9 +3241,9 @@  discard block
 block discarded – undo
3241 3241
  * @return string Chaînes concaténés
3242 3242
  **/
3243 3243
 function concat() {
3244
-	$args = func_get_args();
3244
+    $args = func_get_args();
3245 3245
 
3246
-	return join('', $args);
3246
+    return join('', $args);
3247 3247
 }
3248 3248
 
3249 3249
 
@@ -3263,23 +3263,23 @@  discard block
 block discarded – undo
3263 3263
  *     Contenu du ou des fichiers, concaténé
3264 3264
  **/
3265 3265
 function charge_scripts($files, $script = true) {
3266
-	$flux = "";
3267
-	foreach (is_array($files) ? $files : explode("|", $files) as $file) {
3268
-		if (!is_string($file)) {
3269
-			continue;
3270
-		}
3271
-		if ($script) {
3272
-			$file = preg_match(",^\w+$,", $file) ? "javascript/$file.js" : '';
3273
-		}
3274
-		if ($file) {
3275
-			$path = find_in_path($file);
3276
-			if ($path) {
3277
-				$flux .= spip_file_get_contents($path);
3278
-			}
3279
-		}
3280
-	}
3266
+    $flux = "";
3267
+    foreach (is_array($files) ? $files : explode("|", $files) as $file) {
3268
+        if (!is_string($file)) {
3269
+            continue;
3270
+        }
3271
+        if ($script) {
3272
+            $file = preg_match(",^\w+$,", $file) ? "javascript/$file.js" : '';
3273
+        }
3274
+        if ($file) {
3275
+            $path = find_in_path($file);
3276
+            if ($path) {
3277
+                $flux .= spip_file_get_contents($path);
3278
+            }
3279
+        }
3280
+    }
3281 3281
 
3282
-	return $flux;
3282
+    return $flux;
3283 3283
 }
3284 3284
 
3285 3285
 
@@ -3299,29 +3299,29 @@  discard block
 block discarded – undo
3299 3299
  * @return string
3300 3300
  */
3301 3301
 function http_img_pack($img, $alt, $atts = '', $title = '', $options = array()) {
3302
-	if (!isset($options['chemin_image']) or $options['chemin_image'] == true) {
3303
-		$img = chemin_image($img);
3304
-	}
3305
-	if (stripos($atts, 'width') === false) {
3306
-		// utiliser directement l'info de taille presente dans le nom
3307
-		if ((!isset($options['utiliser_suffixe_size']) or $options['utiliser_suffixe_size'] == true)
3308
-			and preg_match(',-([0-9]+)[.](png|gif)$,', $img, $regs)
3309
-		) {
3310
-			$largeur = $hauteur = intval($regs[1]);
3311
-		} else {
3312
-			$taille = taille_image($img);
3313
-			list($hauteur, $largeur) = $taille;
3314
-			if (!$hauteur or !$largeur) {
3315
-				return "";
3316
-			}
3317
-		}
3318
-		$atts .= " width='" . $largeur . "' height='" . $hauteur . "'";
3319
-	}
3320
-
3321
-	return "<img src='$img' alt='" . attribut_html($alt ? $alt : $title) . "'"
3322
-	. ($title ? ' title="' . attribut_html($title) . '"' : '')
3323
-	. " " . ltrim($atts)
3324
-	. " />";
3302
+    if (!isset($options['chemin_image']) or $options['chemin_image'] == true) {
3303
+        $img = chemin_image($img);
3304
+    }
3305
+    if (stripos($atts, 'width') === false) {
3306
+        // utiliser directement l'info de taille presente dans le nom
3307
+        if ((!isset($options['utiliser_suffixe_size']) or $options['utiliser_suffixe_size'] == true)
3308
+            and preg_match(',-([0-9]+)[.](png|gif)$,', $img, $regs)
3309
+        ) {
3310
+            $largeur = $hauteur = intval($regs[1]);
3311
+        } else {
3312
+            $taille = taille_image($img);
3313
+            list($hauteur, $largeur) = $taille;
3314
+            if (!$hauteur or !$largeur) {
3315
+                return "";
3316
+            }
3317
+        }
3318
+        $atts .= " width='" . $largeur . "' height='" . $hauteur . "'";
3319
+    }
3320
+
3321
+    return "<img src='$img' alt='" . attribut_html($alt ? $alt : $title) . "'"
3322
+    . ($title ? ' title="' . attribut_html($title) . '"' : '')
3323
+    . " " . ltrim($atts)
3324
+    . " />";
3325 3325
 }
3326 3326
 
3327 3327
 /**
@@ -3332,7 +3332,7 @@  discard block
 block discarded – undo
3332 3332
  * @return string
3333 3333
  */
3334 3334
 function http_style_background($img, $att = '') {
3335
-	return " style='background" . ($att ? "" : "-image") . ": url(\"" . chemin_image($img) . "\")" . ($att ? (' ' . $att) : '') . ";'";
3335
+    return " style='background" . ($att ? "" : "-image") . ": url(\"" . chemin_image($img) . "\")" . ($att ? (' ' . $att) : '') . ";'";
3336 3336
 }
3337 3337
 
3338 3338
 /**
@@ -3347,8 +3347,8 @@  discard block
 block discarded – undo
3347 3347
  *     Code HTML de la balise IMG
3348 3348
  */
3349 3349
 function filtre_balise_img_dist($img, $alt = "", $class = "") {
3350
-	return http_img_pack($img, $alt, $class ? " class='" . attribut_html($class) . "'" : '', '',
3351
-		array('chemin_image' => false, 'utiliser_suffixe_size' => false));
3350
+    return http_img_pack($img, $alt, $class ? " class='" . attribut_html($class) . "'" : '', '',
3351
+        array('chemin_image' => false, 'utiliser_suffixe_size' => false));
3352 3352
 }
3353 3353
 
3354 3354
 
@@ -3364,34 +3364,34 @@  discard block
 block discarded – undo
3364 3364
  * @return string
3365 3365
  */
3366 3366
 function filtre_balise_svg_dist($img, $alt = "", $class = "") {
3367
-	if (!$file = find_in_path($img)
3368
-	  or !$svg = file_get_contents($file)) {
3369
-		return '';
3370
-	}
3371
-
3372
-	if (!preg_match(",<svg\b[^>]*>,UimsS", $svg, $match)) {
3373
-		return '';
3374
-	}
3375
-	$balise_svg = $match[0];
3376
-	$balise_svg_source = $balise_svg;
3377
-	// IE est toujours mon ami
3378
-	$balise_svg = inserer_attribut($balise_svg, 'focusable', 'false');
3379
-	if ($class) {
3380
-		$balise_svg = inserer_attribut($balise_svg, 'class', $class);
3381
-	}
3382
-	if ($alt){
3383
-		$balise_svg = inserer_attribut($balise_svg, 'role', 'img');
3384
-		$id = "img-svg-title-" . substr(md5("$file:$svg:$alt"),0,4);
3385
-		$balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id);
3386
-		$title = "<title id=\"$id\">" . entites_html($alt)."</title>\n";
3387
-		$balise_svg .= $title;
3388
-	}
3389
-	else {
3390
-		$balise_svg = inserer_attribut($balise_svg, 'aria-hidden', 'true');
3391
-	}
3392
-	$svg = str_replace($balise_svg_source, $balise_svg, $svg);
3393
-
3394
-	return $svg;
3367
+    if (!$file = find_in_path($img)
3368
+      or !$svg = file_get_contents($file)) {
3369
+        return '';
3370
+    }
3371
+
3372
+    if (!preg_match(",<svg\b[^>]*>,UimsS", $svg, $match)) {
3373
+        return '';
3374
+    }
3375
+    $balise_svg = $match[0];
3376
+    $balise_svg_source = $balise_svg;
3377
+    // IE est toujours mon ami
3378
+    $balise_svg = inserer_attribut($balise_svg, 'focusable', 'false');
3379
+    if ($class) {
3380
+        $balise_svg = inserer_attribut($balise_svg, 'class', $class);
3381
+    }
3382
+    if ($alt){
3383
+        $balise_svg = inserer_attribut($balise_svg, 'role', 'img');
3384
+        $id = "img-svg-title-" . substr(md5("$file:$svg:$alt"),0,4);
3385
+        $balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id);
3386
+        $title = "<title id=\"$id\">" . entites_html($alt)."</title>\n";
3387
+        $balise_svg .= $title;
3388
+    }
3389
+    else {
3390
+        $balise_svg = inserer_attribut($balise_svg, 'aria-hidden', 'true');
3391
+    }
3392
+    $svg = str_replace($balise_svg_source, $balise_svg, $svg);
3393
+
3394
+    return $svg;
3395 3395
 }
3396 3396
 
3397 3397
 
@@ -3414,17 +3414,17 @@  discard block
 block discarded – undo
3414 3414
  *     Code HTML résultant
3415 3415
  **/
3416 3416
 function filtre_foreach_dist($tableau, $modele = 'foreach') {
3417
-	$texte = '';
3418
-	if (is_array($tableau)) {
3419
-		foreach ($tableau as $k => $v) {
3420
-			$res = recuperer_fond('modeles/' . $modele,
3421
-				array_merge(array('cle' => $k), (is_array($v) ? $v : array('valeur' => $v)))
3422
-			);
3423
-			$texte .= $res;
3424
-		}
3425
-	}
3417
+    $texte = '';
3418
+    if (is_array($tableau)) {
3419
+        foreach ($tableau as $k => $v) {
3420
+            $res = recuperer_fond('modeles/' . $modele,
3421
+                array_merge(array('cle' => $k), (is_array($v) ? $v : array('valeur' => $v)))
3422
+            );
3423
+            $texte .= $res;
3424
+        }
3425
+    }
3426 3426
 
3427
-	return $texte;
3427
+    return $texte;
3428 3428
 }
3429 3429
 
3430 3430
 
@@ -3449,37 +3449,37 @@  discard block
 block discarded – undo
3449 3449
  *         - tout : retourne toutes les informations du plugin actif
3450 3450
  **/
3451 3451
 function filtre_info_plugin_dist($plugin, $type_info, $reload = false) {
3452
-	include_spip('inc/plugin');
3453
-	$plugin = strtoupper($plugin);
3454
-	$plugins_actifs = liste_plugin_actifs();
3455
-
3456
-	if (!$plugin) {
3457
-		return serialize(array_keys($plugins_actifs));
3458
-	} elseif (empty($plugins_actifs[$plugin]) and !$reload) {
3459
-		return '';
3460
-	} elseif (($type_info == 'est_actif') and !$reload) {
3461
-		return $plugins_actifs[$plugin] ? 1 : 0;
3462
-	} elseif (isset($plugins_actifs[$plugin][$type_info]) and !$reload) {
3463
-		return $plugins_actifs[$plugin][$type_info];
3464
-	} else {
3465
-		$get_infos = charger_fonction('get_infos', 'plugins');
3466
-		// On prend en compte les extensions
3467
-		if (!is_dir($plugins_actifs[$plugin]['dir_type'])) {
3468
-			$dir_plugins = constant($plugins_actifs[$plugin]['dir_type']);
3469
-		} else {
3470
-			$dir_plugins = $plugins_actifs[$plugin]['dir_type'];
3471
-		}
3472
-		if (!$infos = $get_infos($plugins_actifs[$plugin]['dir'], $reload, $dir_plugins)) {
3473
-			return '';
3474
-		}
3475
-		if ($type_info == 'tout') {
3476
-			return $infos;
3477
-		} elseif ($type_info == 'est_actif') {
3478
-			return $infos ? 1 : 0;
3479
-		} else {
3480
-			return strval($infos[$type_info]);
3481
-		}
3482
-	}
3452
+    include_spip('inc/plugin');
3453
+    $plugin = strtoupper($plugin);
3454
+    $plugins_actifs = liste_plugin_actifs();
3455
+
3456
+    if (!$plugin) {
3457
+        return serialize(array_keys($plugins_actifs));
3458
+    } elseif (empty($plugins_actifs[$plugin]) and !$reload) {
3459
+        return '';
3460
+    } elseif (($type_info == 'est_actif') and !$reload) {
3461
+        return $plugins_actifs[$plugin] ? 1 : 0;
3462
+    } elseif (isset($plugins_actifs[$plugin][$type_info]) and !$reload) {
3463
+        return $plugins_actifs[$plugin][$type_info];
3464
+    } else {
3465
+        $get_infos = charger_fonction('get_infos', 'plugins');
3466
+        // On prend en compte les extensions
3467
+        if (!is_dir($plugins_actifs[$plugin]['dir_type'])) {
3468
+            $dir_plugins = constant($plugins_actifs[$plugin]['dir_type']);
3469
+        } else {
3470
+            $dir_plugins = $plugins_actifs[$plugin]['dir_type'];
3471
+        }
3472
+        if (!$infos = $get_infos($plugins_actifs[$plugin]['dir'], $reload, $dir_plugins)) {
3473
+            return '';
3474
+        }
3475
+        if ($type_info == 'tout') {
3476
+            return $infos;
3477
+        } elseif ($type_info == 'est_actif') {
3478
+            return $infos ? 1 : 0;
3479
+        } else {
3480
+            return strval($infos[$type_info]);
3481
+        }
3482
+    }
3483 3483
 }
3484 3484
 
3485 3485
 
@@ -3506,9 +3506,9 @@  discard block
 block discarded – undo
3506 3506
  *     Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent)
3507 3507
  */
3508 3508
 function puce_changement_statut($id_objet, $statut, $id_rubrique, $type, $ajax = false) {
3509
-	$puce_statut = charger_fonction('puce_statut', 'inc');
3509
+    $puce_statut = charger_fonction('puce_statut', 'inc');
3510 3510
 
3511
-	return $puce_statut($id_objet, $statut, $id_rubrique, $type, $ajax);
3511
+    return $puce_statut($id_objet, $statut, $id_rubrique, $type, $ajax);
3512 3512
 }
3513 3513
 
3514 3514
 
@@ -3538,13 +3538,13 @@  discard block
 block discarded – undo
3538 3538
  *     Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent)
3539 3539
  */
3540 3540
 function filtre_puce_statut_dist($statut, $objet, $id_objet = 0, $id_parent = 0) {
3541
-	static $puce_statut = null;
3542
-	if (!$puce_statut) {
3543
-		$puce_statut = charger_fonction('puce_statut', 'inc');
3544
-	}
3541
+    static $puce_statut = null;
3542
+    if (!$puce_statut) {
3543
+        $puce_statut = charger_fonction('puce_statut', 'inc');
3544
+    }
3545 3545
 
3546
-	return $puce_statut($id_objet, $statut, $id_parent, $objet, false,
3547
-		objet_info($objet, 'editable') ? _ACTIVER_PUCE_RAPIDE : false);
3546
+    return $puce_statut($id_objet, $statut, $id_parent, $objet, false,
3547
+        objet_info($objet, 'editable') ? _ACTIVER_PUCE_RAPIDE : false);
3548 3548
 }
3549 3549
 
3550 3550
 
@@ -3571,88 +3571,88 @@  discard block
 block discarded – undo
3571 3571
  *   hash du contexte
3572 3572
  */
3573 3573
 function encoder_contexte_ajax($c, $form = '', $emboite = null, $ajaxid = '') {
3574
-	if (is_string($c)
3575
-		and @unserialize($c) !== false
3576
-	) {
3577
-		$c = unserialize($c);
3578
-	}
3579
-
3580
-	// supprimer les parametres debut_x
3581
-	// pour que la pagination ajax ne soit pas plantee
3582
-	// si on charge la page &debut_x=1 : car alors en cliquant sur l'item 0,
3583
-	// le debut_x=0 n'existe pas, et on resterait sur 1
3584
-	if (is_array($c)) {
3585
-		foreach ($c as $k => $v) {
3586
-			if (strpos($k, 'debut_') === 0) {
3587
-				unset($c[$k]);
3588
-			}
3589
-		}
3590
-	}
3591
-
3592
-	if (!function_exists('calculer_cle_action')) {
3593
-		include_spip("inc/securiser_action");
3594
-	}
3595
-
3596
-	$c = serialize($c);
3597
-	$cle = calculer_cle_action($form . $c);
3598
-	$c = "$cle:$c";
3599
-
3600
-	// on ne stocke pas les contextes dans des fichiers caches
3601
-	// par defaut, sauf si cette configuration a ete forcee
3602
-	// OU que la longueur de l''argument generee est plus long
3603
-	// que ce que telere Suhosin.
3604
-	$cache_contextes_ajax = (defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX);
3605
-	if (!$cache_contextes_ajax) {
3606
-		$env = $c;
3607
-		if (function_exists('gzdeflate') && function_exists('gzinflate')) {
3608
-			$env = gzdeflate($env);
3609
-			// http://core.spip.net/issues/2667 | https://bugs.php.net/bug.php?id=61287
3610
-			if ((PHP_VERSION_ID == 50400) and !@gzinflate($env)) {
3611
-				$cache_contextes_ajax = true;
3612
-				spip_log("Contextes AJAX forces en fichiers ! Erreur PHP 5.4.0", _LOG_AVERTISSEMENT);
3613
-			}
3614
-		}
3615
-		$env = _xor($env);
3616
-		$env = base64_encode($env);
3617
-		// tester Suhosin et la valeur maximale des variables en GET...
3618
-		if ($max_len = @ini_get('suhosin.get.max_value_length')
3619
-			and $max_len < ($len = strlen($env))
3620
-		) {
3621
-			$cache_contextes_ajax = true;
3622
-			spip_log("Contextes AJAX forces en fichiers !"
3623
-				. " Cela arrive lorsque la valeur du contexte"
3624
-				. " depasse la longueur maximale autorisee par Suhosin"
3625
-				. " ($max_len) dans 'suhosin.get.max_value_length'. Ici : $len."
3626
-				. " Vous devriez modifier les parametres de Suhosin"
3627
-				. " pour accepter au moins 1024 caracteres.", _LOG_AVERTISSEMENT);
3628
-		}
3629
-	}
3630
-
3631
-	if ($cache_contextes_ajax) {
3632
-		$dir = sous_repertoire(_DIR_CACHE, 'contextes');
3633
-		// stocker les contextes sur disque et ne passer qu'un hash dans l'url
3634
-		$md5 = md5($c);
3635
-		ecrire_fichier("$dir/c$md5", $c);
3636
-		$env = $md5;
3637
-	}
3638
-
3639
-	if ($emboite === null) {
3640
-		return $env;
3641
-	}
3642
-	if (!trim($emboite)) {
3643
-		return "";
3644
-	}
3645
-	// toujours encoder l'url source dans le bloc ajax
3646
-	$r = self();
3647
-	$r = ' data-origin="' . $r . '"';
3648
-	$class = 'ajaxbloc';
3649
-	if ($ajaxid and is_string($ajaxid)) {
3650
-		// ajaxid est normalement conforme a un nom de classe css
3651
-		// on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution
3652
-		$class .= ' ajax-id-' . entites_html($ajaxid);
3653
-	}
3654
-
3655
-	return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
3574
+    if (is_string($c)
3575
+        and @unserialize($c) !== false
3576
+    ) {
3577
+        $c = unserialize($c);
3578
+    }
3579
+
3580
+    // supprimer les parametres debut_x
3581
+    // pour que la pagination ajax ne soit pas plantee
3582
+    // si on charge la page &debut_x=1 : car alors en cliquant sur l'item 0,
3583
+    // le debut_x=0 n'existe pas, et on resterait sur 1
3584
+    if (is_array($c)) {
3585
+        foreach ($c as $k => $v) {
3586
+            if (strpos($k, 'debut_') === 0) {
3587
+                unset($c[$k]);
3588
+            }
3589
+        }
3590
+    }
3591
+
3592
+    if (!function_exists('calculer_cle_action')) {
3593
+        include_spip("inc/securiser_action");
3594
+    }
3595
+
3596
+    $c = serialize($c);
3597
+    $cle = calculer_cle_action($form . $c);
3598
+    $c = "$cle:$c";
3599
+
3600
+    // on ne stocke pas les contextes dans des fichiers caches
3601
+    // par defaut, sauf si cette configuration a ete forcee
3602
+    // OU que la longueur de l''argument generee est plus long
3603
+    // que ce que telere Suhosin.
3604
+    $cache_contextes_ajax = (defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX);
3605
+    if (!$cache_contextes_ajax) {
3606
+        $env = $c;
3607
+        if (function_exists('gzdeflate') && function_exists('gzinflate')) {
3608
+            $env = gzdeflate($env);
3609
+            // http://core.spip.net/issues/2667 | https://bugs.php.net/bug.php?id=61287
3610
+            if ((PHP_VERSION_ID == 50400) and !@gzinflate($env)) {
3611
+                $cache_contextes_ajax = true;
3612
+                spip_log("Contextes AJAX forces en fichiers ! Erreur PHP 5.4.0", _LOG_AVERTISSEMENT);
3613
+            }
3614
+        }
3615
+        $env = _xor($env);
3616
+        $env = base64_encode($env);
3617
+        // tester Suhosin et la valeur maximale des variables en GET...
3618
+        if ($max_len = @ini_get('suhosin.get.max_value_length')
3619
+            and $max_len < ($len = strlen($env))
3620
+        ) {
3621
+            $cache_contextes_ajax = true;
3622
+            spip_log("Contextes AJAX forces en fichiers !"
3623
+                . " Cela arrive lorsque la valeur du contexte"
3624
+                . " depasse la longueur maximale autorisee par Suhosin"
3625
+                . " ($max_len) dans 'suhosin.get.max_value_length'. Ici : $len."
3626
+                . " Vous devriez modifier les parametres de Suhosin"
3627
+                . " pour accepter au moins 1024 caracteres.", _LOG_AVERTISSEMENT);
3628
+        }
3629
+    }
3630
+
3631
+    if ($cache_contextes_ajax) {
3632
+        $dir = sous_repertoire(_DIR_CACHE, 'contextes');
3633
+        // stocker les contextes sur disque et ne passer qu'un hash dans l'url
3634
+        $md5 = md5($c);
3635
+        ecrire_fichier("$dir/c$md5", $c);
3636
+        $env = $md5;
3637
+    }
3638
+
3639
+    if ($emboite === null) {
3640
+        return $env;
3641
+    }
3642
+    if (!trim($emboite)) {
3643
+        return "";
3644
+    }
3645
+    // toujours encoder l'url source dans le bloc ajax
3646
+    $r = self();
3647
+    $r = ' data-origin="' . $r . '"';
3648
+    $class = 'ajaxbloc';
3649
+    if ($ajaxid and is_string($ajaxid)) {
3650
+        // ajaxid est normalement conforme a un nom de classe css
3651
+        // on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution
3652
+        $class .= ' ajax-id-' . entites_html($ajaxid);
3653
+    }
3654
+
3655
+    return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
3656 3656
 }
3657 3657
 
3658 3658
 /**
@@ -3672,36 +3672,36 @@  discard block
 block discarded – undo
3672 3672
  *   - false : erreur de décodage
3673 3673
  */
3674 3674
 function decoder_contexte_ajax($c, $form = '') {
3675
-	if (!function_exists('calculer_cle_action')) {
3676
-		include_spip("inc/securiser_action");
3677
-	}
3678
-	if (((defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX) or strlen($c) == 32)
3679
-		and $dir = sous_repertoire(_DIR_CACHE, 'contextes')
3680
-		and lire_fichier("$dir/c$c", $contexte)
3681
-	) {
3682
-		$c = $contexte;
3683
-	} else {
3684
-		$c = @base64_decode($c);
3685
-		$c = _xor($c);
3686
-		if (function_exists('gzdeflate') && function_exists('gzinflate')) {
3687
-			$c = @gzinflate($c);
3688
-		}
3689
-	}
3690
-
3691
-	// extraire la signature en debut de contexte
3692
-	// et la verifier avant de deserializer
3693
-	// format : signature:donneesserializees
3694
-	if ($p = strpos($c,":")){
3695
-		$cle = substr($c,0,$p);
3696
-		$c = substr($c,$p+1);
3697
-
3698
-		if ($cle == calculer_cle_action($form . $c)) {
3699
-			$env = @unserialize($c);
3700
-			return $env;
3701
-		}
3702
-	}
3703
-
3704
-	return false;
3675
+    if (!function_exists('calculer_cle_action')) {
3676
+        include_spip("inc/securiser_action");
3677
+    }
3678
+    if (((defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX) or strlen($c) == 32)
3679
+        and $dir = sous_repertoire(_DIR_CACHE, 'contextes')
3680
+        and lire_fichier("$dir/c$c", $contexte)
3681
+    ) {
3682
+        $c = $contexte;
3683
+    } else {
3684
+        $c = @base64_decode($c);
3685
+        $c = _xor($c);
3686
+        if (function_exists('gzdeflate') && function_exists('gzinflate')) {
3687
+            $c = @gzinflate($c);
3688
+        }
3689
+    }
3690
+
3691
+    // extraire la signature en debut de contexte
3692
+    // et la verifier avant de deserializer
3693
+    // format : signature:donneesserializees
3694
+    if ($p = strpos($c,":")){
3695
+        $cle = substr($c,0,$p);
3696
+        $c = substr($c,$p+1);
3697
+
3698
+        if ($cle == calculer_cle_action($form . $c)) {
3699
+            $env = @unserialize($c);
3700
+            return $env;
3701
+        }
3702
+    }
3703
+
3704
+    return false;
3705 3705
 }
3706 3706
 
3707 3707
 
@@ -3719,20 +3719,20 @@  discard block
 block discarded – undo
3719 3719
  *    Message décrypté ou encrypté
3720 3720
  **/
3721 3721
 function _xor($message, $key = null) {
3722
-	if (is_null($key)) {
3723
-		if (!function_exists('calculer_cle_action')) {
3724
-			include_spip("inc/securiser_action");
3725
-		}
3726
-		$key = pack("H*", calculer_cle_action('_xor'));
3727
-	}
3722
+    if (is_null($key)) {
3723
+        if (!function_exists('calculer_cle_action')) {
3724
+            include_spip("inc/securiser_action");
3725
+        }
3726
+        $key = pack("H*", calculer_cle_action('_xor'));
3727
+    }
3728 3728
 
3729
-	$keylen = strlen($key);
3730
-	$messagelen = strlen($message);
3731
-	for ($i = 0; $i < $messagelen; $i++) {
3732
-		$message[$i] = ~($message[$i] ^ $key[$i % $keylen]);
3733
-	}
3729
+    $keylen = strlen($key);
3730
+    $messagelen = strlen($message);
3731
+    for ($i = 0; $i < $messagelen; $i++) {
3732
+        $message[$i] = ~($message[$i] ^ $key[$i % $keylen]);
3733
+    }
3734 3734
 
3735
-	return $message;
3735
+    return $message;
3736 3736
 }
3737 3737
 
3738 3738
 /**
@@ -3790,22 +3790,22 @@  discard block
 block discarded – undo
3790 3790
  *   Code HTML
3791 3791
  */
3792 3792
 function lien_ou_expose($url, $libelle = null, $on = false, $class = "", $title = "", $rel = "", $evt = '') {
3793
-	if ($on) {
3794
-		$bal = "strong";
3795
-		$att = "class='on'";
3796
-	} else {
3797
-		$bal = 'a';
3798
-		$att = "href='$url'"
3799
-			. ($title ? " title='" . attribut_html($title) . "'" : '')
3800
-			. ($class ? " class='" . attribut_html($class) . "'" : '')
3801
-			. ($rel ? " rel='" . attribut_html($rel) . "'" : '')
3802
-			. $evt;
3803
-	}
3804
-	if ($libelle === null) {
3805
-		$libelle = $url;
3806
-	}
3793
+    if ($on) {
3794
+        $bal = "strong";
3795
+        $att = "class='on'";
3796
+    } else {
3797
+        $bal = 'a';
3798
+        $att = "href='$url'"
3799
+            . ($title ? " title='" . attribut_html($title) . "'" : '')
3800
+            . ($class ? " class='" . attribut_html($class) . "'" : '')
3801
+            . ($rel ? " rel='" . attribut_html($rel) . "'" : '')
3802
+            . $evt;
3803
+    }
3804
+    if ($libelle === null) {
3805
+        $libelle = $url;
3806
+    }
3807 3807
 
3808
-	return "<$bal $att>$libelle</$bal>";
3808
+    return "<$bal $att>$libelle</$bal>";
3809 3809
 }
3810 3810
 
3811 3811
 
@@ -3822,18 +3822,18 @@  discard block
 block discarded – undo
3822 3822
  * @return string : la chaine de langue finale en utilisant la fonction _T()
3823 3823
  */
3824 3824
 function singulier_ou_pluriel($nb, $chaine_un, $chaine_plusieurs, $var = 'nb', $vars = array()) {
3825
-	if (!$nb = intval($nb)) {
3826
-		return "";
3827
-	}
3828
-	if (!is_array($vars)) {
3829
-		return "";
3830
-	}
3831
-	$vars[$var] = $nb;
3832
-	if ($nb > 1) {
3833
-		return _T($chaine_plusieurs, $vars);
3834
-	} else {
3835
-		return _T($chaine_un, $vars);
3836
-	}
3825
+    if (!$nb = intval($nb)) {
3826
+        return "";
3827
+    }
3828
+    if (!is_array($vars)) {
3829
+        return "";
3830
+    }
3831
+    $vars[$var] = $nb;
3832
+    if ($nb > 1) {
3833
+        return _T($chaine_plusieurs, $vars);
3834
+    } else {
3835
+        return _T($chaine_un, $vars);
3836
+    }
3837 3837
 }
3838 3838
 
3839 3839
 
@@ -3858,60 +3858,60 @@  discard block
 block discarded – undo
3858 3858
  * @return string
3859 3859
  */
3860 3860
 function prepare_icone_base($type, $lien, $texte, $fond, $fonction = "", $class = "", $javascript = "") {
3861
-	if (in_array($fonction, array("del", "supprimer.gif"))) {
3862
-		$class .= ' danger';
3863
-	} elseif ($fonction == "rien.gif") {
3864
-		$fonction = "";
3865
-	} elseif ($fonction == "delsafe") {
3866
-		$fonction = "del";
3867
-	}
3868
-
3869
-	// remappage des icone : article-24.png+new => article-new-24.png
3870
-	if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) {
3871
-		list($fond, $fonction) = $icone_renommer($fond, $fonction);
3872
-	}
3873
-
3874
-	// ajouter le type d'objet dans la class de l'icone
3875
-	$class .= " " . substr(basename($fond), 0, -4);
3876
-
3877
-	$alt = attribut_html($texte);
3878
-	$title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ?
3879
-
3880
-	$ajax = "";
3881
-	if (strpos($class, "ajax") !== false) {
3882
-		$ajax = "ajax";
3883
-		if (strpos($class, "preload") !== false) {
3884
-			$ajax .= " preload";
3885
-		}
3886
-		if (strpos($class, "nocache") !== false) {
3887
-			$ajax .= " nocache";
3888
-		}
3889
-		$ajax = " class='$ajax'";
3890
-	}
3891
-
3892
-	$size = 24;
3893
-	if (preg_match("/-([0-9]{1,3})[.](gif|png)$/i", $fond, $match)) {
3894
-		$size = $match[1];
3895
-	}
3896
-
3897
-	if ($fonction) {
3898
-		// 2 images pour composer l'icone : le fond (article) en background,
3899
-		// la fonction (new) en image
3900
-		$icone = http_img_pack($fonction, $alt, "width='$size' height='$size'\n" .
3901
-			http_style_background($fond));
3902
-	} else {
3903
-		$icone = http_img_pack($fond, $alt, "width='$size' height='$size'");
3904
-	}
3905
-
3906
-	if ($type == 'lien') {
3907
-		return "<span class='icone s$size $class'>"
3908
-		. "<a href='$lien'$title$ajax$javascript>"
3909
-		. $icone
3910
-		. "<b>$texte</b>"
3911
-		. "</a></span>\n";
3912
-	} else {
3913
-		return bouton_action("$icone<b>$texte</b>", $lien, "icone s$size $class", $javascript, $alt);
3914
-	}
3861
+    if (in_array($fonction, array("del", "supprimer.gif"))) {
3862
+        $class .= ' danger';
3863
+    } elseif ($fonction == "rien.gif") {
3864
+        $fonction = "";
3865
+    } elseif ($fonction == "delsafe") {
3866
+        $fonction = "del";
3867
+    }
3868
+
3869
+    // remappage des icone : article-24.png+new => article-new-24.png
3870
+    if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) {
3871
+        list($fond, $fonction) = $icone_renommer($fond, $fonction);
3872
+    }
3873
+
3874
+    // ajouter le type d'objet dans la class de l'icone
3875
+    $class .= " " . substr(basename($fond), 0, -4);
3876
+
3877
+    $alt = attribut_html($texte);
3878
+    $title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ?
3879
+
3880
+    $ajax = "";
3881
+    if (strpos($class, "ajax") !== false) {
3882
+        $ajax = "ajax";
3883
+        if (strpos($class, "preload") !== false) {
3884
+            $ajax .= " preload";
3885
+        }
3886
+        if (strpos($class, "nocache") !== false) {
3887
+            $ajax .= " nocache";
3888
+        }
3889
+        $ajax = " class='$ajax'";
3890
+    }
3891
+
3892
+    $size = 24;
3893
+    if (preg_match("/-([0-9]{1,3})[.](gif|png)$/i", $fond, $match)) {
3894
+        $size = $match[1];
3895
+    }
3896
+
3897
+    if ($fonction) {
3898
+        // 2 images pour composer l'icone : le fond (article) en background,
3899
+        // la fonction (new) en image
3900
+        $icone = http_img_pack($fonction, $alt, "width='$size' height='$size'\n" .
3901
+            http_style_background($fond));
3902
+    } else {
3903
+        $icone = http_img_pack($fond, $alt, "width='$size' height='$size'");
3904
+    }
3905
+
3906
+    if ($type == 'lien') {
3907
+        return "<span class='icone s$size $class'>"
3908
+        . "<a href='$lien'$title$ajax$javascript>"
3909
+        . $icone
3910
+        . "<b>$texte</b>"
3911
+        . "</a></span>\n";
3912
+    } else {
3913
+        return bouton_action("$icone<b>$texte</b>", $lien, "icone s$size $class", $javascript, $alt);
3914
+    }
3915 3915
 }
3916 3916
 
3917 3917
 /**
@@ -3935,7 +3935,7 @@  discard block
 block discarded – undo
3935 3935
  *     Code HTML du lien
3936 3936
  **/
3937 3937
 function icone_base($lien, $texte, $fond, $fonction = "", $class = "", $javascript = "") {
3938
-	return prepare_icone_base('lien', $lien, $texte, $fond, $fonction, $class, $javascript);
3938
+    return prepare_icone_base('lien', $lien, $texte, $fond, $fonction, $class, $javascript);
3939 3939
 }
3940 3940
 
3941 3941
 /**
@@ -3970,7 +3970,7 @@  discard block
 block discarded – undo
3970 3970
  *     Code HTML du lien
3971 3971
  **/
3972 3972
 function filtre_icone_verticale_dist($lien, $texte, $fond, $fonction = "", $class = "", $javascript = "") {
3973
-	return icone_base($lien, $texte, $fond, $fonction, "verticale $class", $javascript);
3973
+    return icone_base($lien, $texte, $fond, $fonction, "verticale $class", $javascript);
3974 3974
 }
3975 3975
 
3976 3976
 /**
@@ -4015,7 +4015,7 @@  discard block
 block discarded – undo
4015 4015
  *     Code HTML du lien
4016 4016
  **/
4017 4017
 function filtre_icone_horizontale_dist($lien, $texte, $fond, $fonction = "", $class = "", $javascript = "") {
4018
-	return icone_base($lien, $texte, $fond, $fonction, "horizontale $class", $javascript);
4018
+    return icone_base($lien, $texte, $fond, $fonction, "horizontale $class", $javascript);
4019 4019
 }
4020 4020
 
4021 4021
 /**
@@ -4046,7 +4046,7 @@  discard block
 block discarded – undo
4046 4046
  *     Code HTML du lien
4047 4047
  **/
4048 4048
 function filtre_bouton_action_horizontal_dist($lien, $texte, $fond, $fonction = "", $class = "", $confirm = "") {
4049
-	return prepare_icone_base('bouton', $lien, $texte, $fond, $fonction, "horizontale $class", $confirm);
4049
+    return prepare_icone_base('bouton', $lien, $texte, $fond, $fonction, "horizontale $class", $confirm);
4050 4050
 }
4051 4051
 
4052 4052
 /**
@@ -4076,7 +4076,7 @@  discard block
 block discarded – undo
4076 4076
  *     Code HTML du lien
4077 4077
  */
4078 4078
 function filtre_icone_dist($lien, $texte, $fond, $align = "", $fonction = "", $class = "", $javascript = "") {
4079
-	return icone_base($lien, $texte, $fond, $fonction, "verticale $align $class", $javascript);
4079
+    return icone_base($lien, $texte, $fond, $fonction, "verticale $align $class", $javascript);
4080 4080
 }
4081 4081
 
4082 4082
 
@@ -4124,26 +4124,26 @@  discard block
 block discarded – undo
4124 4124
  * @return string Code CSS
4125 4125
  */
4126 4126
 function bando_images_background() {
4127
-	include_spip('inc/bandeau');
4128
-	// recuperer tous les boutons et leurs images
4129
-	$boutons = definir_barre_boutons(definir_barre_contexte(), true, false);
4127
+    include_spip('inc/bandeau');
4128
+    // recuperer tous les boutons et leurs images
4129
+    $boutons = definir_barre_boutons(definir_barre_contexte(), true, false);
4130 4130
 
4131
-	$res = "";
4132
-	foreach ($boutons as $page => $detail) {
4133
-		if ($detail->icone and strlen(trim($detail->icone))) {
4134
-			$res .= "\n.navigation_avec_icones #bando1_$page {background-image:url(" . $detail->icone . ");}";
4135
-		}
4136
-		$selecteur = (in_array($page, array('outils_rapides', 'outils_collaboratifs')) ? "" : ".navigation_avec_icones ");
4137
-		if (is_array($detail->sousmenu)) {
4138
-			foreach ($detail->sousmenu as $souspage => $sousdetail) {
4139
-				if ($sousdetail->icone and strlen(trim($sousdetail->icone))) {
4140
-					$res .= "\n$selecteur.bando2_$souspage {background-image:url(" . $sousdetail->icone . ");}";
4141
-				}
4142
-			}
4143
-		}
4144
-	}
4131
+    $res = "";
4132
+    foreach ($boutons as $page => $detail) {
4133
+        if ($detail->icone and strlen(trim($detail->icone))) {
4134
+            $res .= "\n.navigation_avec_icones #bando1_$page {background-image:url(" . $detail->icone . ");}";
4135
+        }
4136
+        $selecteur = (in_array($page, array('outils_rapides', 'outils_collaboratifs')) ? "" : ".navigation_avec_icones ");
4137
+        if (is_array($detail->sousmenu)) {
4138
+            foreach ($detail->sousmenu as $souspage => $sousdetail) {
4139
+                if ($sousdetail->icone and strlen(trim($sousdetail->icone))) {
4140
+                    $res .= "\n$selecteur.bando2_$souspage {background-image:url(" . $sousdetail->icone . ");}";
4141
+                }
4142
+            }
4143
+        }
4144
+    }
4145 4145
 
4146
-	return $res;
4146
+    return $res;
4147 4147
 }
4148 4148
 
4149 4149
 /**
@@ -4162,19 +4162,19 @@  discard block
 block discarded – undo
4162 4162
  * @return string
4163 4163
  */
4164 4164
 function bouton_action($libelle, $url, $class = "", $confirm = "", $title = "", $callback = "") {
4165
-	if ($confirm) {
4166
-		$confirm = "confirm(\"" . attribut_html($confirm) . "\")";
4167
-		if ($callback) {
4168
-			$callback = "$confirm?($callback):false";
4169
-		} else {
4170
-			$callback = $confirm;
4171
-		}
4172
-	}
4173
-	$onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : "";
4174
-	$title = $title ? " title='$title'" : "";
4165
+    if ($confirm) {
4166
+        $confirm = "confirm(\"" . attribut_html($confirm) . "\")";
4167
+        if ($callback) {
4168
+            $callback = "$confirm?($callback):false";
4169
+        } else {
4170
+            $callback = $confirm;
4171
+        }
4172
+    }
4173
+    $onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : "";
4174
+    $title = $title ? " title='$title'" : "";
4175 4175
 
4176
-	return "<form class='bouton_action_post $class' method='post' action='$url'><div>" . form_hidden($url)
4177
-	. "<button type='submit' class='submit'$title$onclick>$libelle</button></div></form>";
4176
+    return "<form class='bouton_action_post $class' method='post' action='$url'><div>" . form_hidden($url)
4177
+    . "<button type='submit' class='submit'$title$onclick>$libelle</button></div></form>";
4178 4178
 }
4179 4179
 
4180 4180
 
@@ -4186,7 +4186,7 @@  discard block
 block discarded – undo
4186 4186
  * @return string
4187 4187
  */
4188 4188
 function tri_protege_champ($t) {
4189
-	return preg_replace(',[^\s\w.+],', '', $t);
4189
+    return preg_replace(',[^\s\w.+],', '', $t);
4190 4190
 }
4191 4191
 
4192 4192
 /**
@@ -4199,34 +4199,34 @@  discard block
 block discarded – undo
4199 4199
  * @return string
4200 4200
  */
4201 4201
 function tri_champ_order($t, $from = null) {
4202
-	if (strncmp($t, 'multi ', 6) == 0) {
4203
-		return "multi";
4204
-	}
4205
-
4206
-	$champ = $t;
4207
-
4208
-	if (strncmp($t, 'num ', 4) == 0) {
4209
-		$champ = substr($t, 4);
4210
-	}
4211
-	// enlever les autres espaces non evacues par tri_protege_champ
4212
-	$champ = preg_replace(',\s,', '', $champ);
4213
-
4214
-	if (is_array($from)) {
4215
-		$trouver_table = charger_fonction('trouver_table', 'base');
4216
-		foreach ($from as $idt => $table_sql) {
4217
-			if ($desc = $trouver_table($table_sql)
4218
-				and isset($desc['field'][$champ])
4219
-			) {
4220
-				$champ = "$idt.$champ";
4221
-				break;
4222
-			}
4223
-		}
4224
-	}
4225
-	if (strncmp($t, 'num ', 4) == 0) {
4226
-		return "0+$champ";
4227
-	} else {
4228
-		return $champ;
4229
-	}
4202
+    if (strncmp($t, 'multi ', 6) == 0) {
4203
+        return "multi";
4204
+    }
4205
+
4206
+    $champ = $t;
4207
+
4208
+    if (strncmp($t, 'num ', 4) == 0) {
4209
+        $champ = substr($t, 4);
4210
+    }
4211
+    // enlever les autres espaces non evacues par tri_protege_champ
4212
+    $champ = preg_replace(',\s,', '', $champ);
4213
+
4214
+    if (is_array($from)) {
4215
+        $trouver_table = charger_fonction('trouver_table', 'base');
4216
+        foreach ($from as $idt => $table_sql) {
4217
+            if ($desc = $trouver_table($table_sql)
4218
+                and isset($desc['field'][$champ])
4219
+            ) {
4220
+                $champ = "$idt.$champ";
4221
+                break;
4222
+            }
4223
+        }
4224
+    }
4225
+    if (strncmp($t, 'num ', 4) == 0) {
4226
+        return "0+$champ";
4227
+    } else {
4228
+        return $champ;
4229
+    }
4230 4230
 }
4231 4231
 
4232 4232
 /**
@@ -4240,18 +4240,18 @@  discard block
 block discarded – undo
4240 4240
  * @return string
4241 4241
  */
4242 4242
 function tri_champ_select($t) {
4243
-	if (strncmp($t, 'multi ', 6) == 0) {
4244
-		$t = substr($t, 6);
4245
-		$t = preg_replace(',\s,', '', $t);
4246
-		$t = sql_multi($t, $GLOBALS['spip_lang']);
4243
+    if (strncmp($t, 'multi ', 6) == 0) {
4244
+        $t = substr($t, 6);
4245
+        $t = preg_replace(',\s,', '', $t);
4246
+        $t = sql_multi($t, $GLOBALS['spip_lang']);
4247 4247
 
4248
-		return $t;
4249
-	}
4250
-	if (trim($t) == 'hasard') {
4251
-		return 'rand() AS hasard';
4252
-	}
4248
+        return $t;
4249
+    }
4250
+    if (trim($t) == 'hasard') {
4251
+        return 'rand() AS hasard';
4252
+    }
4253 4253
 
4254
-	return "''";
4254
+    return "''";
4255 4255
 }
4256 4256
 
4257 4257
 
@@ -4273,78 +4273,78 @@  discard block
 block discarded – undo
4273 4273
  * @return string
4274 4274
  */
4275 4275
 function generer_info_entite($id_objet, $type_objet, $info, $etoile = "") {
4276
-	static $trouver_table = null;
4277
-	static $objets;
4278
-
4279
-	// On verifie qu'on a tout ce qu'il faut
4280
-	$id_objet = intval($id_objet);
4281
-	if (!($id_objet and $type_objet and $info)) {
4282
-		return '';
4283
-	}
4284
-
4285
-	// si on a deja note que l'objet n'existe pas, ne pas aller plus loin
4286
-	if (isset($objets[$type_objet]) and $objets[$type_objet] === false) {
4287
-		return '';
4288
-	}
4289
-
4290
-	// Si on demande l'url, on retourne direct la fonction
4291
-	if ($info == 'url') {
4292
-		return generer_url_entite($id_objet, $type_objet);
4293
-	}
4294
-
4295
-	// Sinon on va tout chercher dans la table et on garde en memoire
4296
-	$demande_titre = ($info == 'titre');
4297
-
4298
-	// On ne fait la requete que si on a pas deja l'objet ou si on demande le titre mais qu'on ne l'a pas encore
4299
-	if (!isset($objets[$type_objet][$id_objet])
4300
-		or
4301
-		($demande_titre and !isset($objets[$type_objet][$id_objet]['titre']))
4302
-	) {
4303
-		if (!$trouver_table) {
4304
-			$trouver_table = charger_fonction('trouver_table', 'base');
4305
-		}
4306
-		$desc = $trouver_table(table_objet_sql($type_objet));
4307
-		if (!$desc) {
4308
-			return $objets[$type_objet] = false;
4309
-		}
4310
-
4311
-		// Si on demande le titre, on le gere en interne
4312
-		$champ_titre = "";
4313
-		if ($demande_titre) {
4314
-			// si pas de titre declare mais champ titre, il sera peuple par le select *
4315
-			$champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : '';
4316
-		}
4317
-		include_spip('base/abstract_sql');
4318
-		include_spip('base/connect_sql');
4319
-		$objets[$type_objet][$id_objet] = sql_fetsel(
4320
-			'*' . $champ_titre,
4321
-			$desc['table_sql'],
4322
-			id_table_objet($type_objet) . ' = ' . intval($id_objet)
4323
-		);
4324
-	}
4325
-
4326
-	// Si la fonction generer_TRUC_TYPE existe, on l'utilise pour formater $info_generee
4327
-	if ($generer = charger_fonction("generer_${info}_${type_objet}", '', true)) {
4328
-		$info_generee = $generer($id_objet, $objets[$type_objet][$id_objet]);
4329
-	} // Si la fonction generer_TRUC_entite existe, on l'utilise pour formater $info_generee
4330
-	else {
4331
-		if ($generer = charger_fonction("generer_${info}_entite", '', true)) {
4332
-			$info_generee = $generer($id_objet, $type_objet, $objets[$type_objet][$id_objet]);
4333
-		} // Sinon on prend directement le champ SQL tel quel
4334
-		else {
4335
-			$info_generee = (isset($objets[$type_objet][$id_objet][$info]) ? $objets[$type_objet][$id_objet][$info] : '');
4336
-		}
4337
-	}
4338
-
4339
-	// On va ensuite appliquer les traitements automatiques si besoin
4340
-	if (!$etoile) {
4341
-		// FIXME: on fournit un ENV minimum avec id et type et connect=''
4342
-		// mais ce fonctionnement est a ameliorer !
4343
-		$info_generee = appliquer_traitement_champ($info_generee, $info, table_objet($type_objet),
4344
-			array('id_objet' => $id_objet, 'objet' => $type_objet, ''));
4345
-	}
4346
-
4347
-	return $info_generee;
4276
+    static $trouver_table = null;
4277
+    static $objets;
4278
+
4279
+    // On verifie qu'on a tout ce qu'il faut
4280
+    $id_objet = intval($id_objet);
4281
+    if (!($id_objet and $type_objet and $info)) {
4282
+        return '';
4283
+    }
4284
+
4285
+    // si on a deja note que l'objet n'existe pas, ne pas aller plus loin
4286
+    if (isset($objets[$type_objet]) and $objets[$type_objet] === false) {
4287
+        return '';
4288
+    }
4289
+
4290
+    // Si on demande l'url, on retourne direct la fonction
4291
+    if ($info == 'url') {
4292
+        return generer_url_entite($id_objet, $type_objet);
4293
+    }
4294
+
4295
+    // Sinon on va tout chercher dans la table et on garde en memoire
4296
+    $demande_titre = ($info == 'titre');
4297
+
4298
+    // On ne fait la requete que si on a pas deja l'objet ou si on demande le titre mais qu'on ne l'a pas encore
4299
+    if (!isset($objets[$type_objet][$id_objet])
4300
+        or
4301
+        ($demande_titre and !isset($objets[$type_objet][$id_objet]['titre']))
4302
+    ) {
4303
+        if (!$trouver_table) {
4304
+            $trouver_table = charger_fonction('trouver_table', 'base');
4305
+        }
4306
+        $desc = $trouver_table(table_objet_sql($type_objet));
4307
+        if (!$desc) {
4308
+            return $objets[$type_objet] = false;
4309
+        }
4310
+
4311
+        // Si on demande le titre, on le gere en interne
4312
+        $champ_titre = "";
4313
+        if ($demande_titre) {
4314
+            // si pas de titre declare mais champ titre, il sera peuple par le select *
4315
+            $champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : '';
4316
+        }
4317
+        include_spip('base/abstract_sql');
4318
+        include_spip('base/connect_sql');
4319
+        $objets[$type_objet][$id_objet] = sql_fetsel(
4320
+            '*' . $champ_titre,
4321
+            $desc['table_sql'],
4322
+            id_table_objet($type_objet) . ' = ' . intval($id_objet)
4323
+        );
4324
+    }
4325
+
4326
+    // Si la fonction generer_TRUC_TYPE existe, on l'utilise pour formater $info_generee
4327
+    if ($generer = charger_fonction("generer_${info}_${type_objet}", '', true)) {
4328
+        $info_generee = $generer($id_objet, $objets[$type_objet][$id_objet]);
4329
+    } // Si la fonction generer_TRUC_entite existe, on l'utilise pour formater $info_generee
4330
+    else {
4331
+        if ($generer = charger_fonction("generer_${info}_entite", '', true)) {
4332
+            $info_generee = $generer($id_objet, $type_objet, $objets[$type_objet][$id_objet]);
4333
+        } // Sinon on prend directement le champ SQL tel quel
4334
+        else {
4335
+            $info_generee = (isset($objets[$type_objet][$id_objet][$info]) ? $objets[$type_objet][$id_objet][$info] : '');
4336
+        }
4337
+    }
4338
+
4339
+    // On va ensuite appliquer les traitements automatiques si besoin
4340
+    if (!$etoile) {
4341
+        // FIXME: on fournit un ENV minimum avec id et type et connect=''
4342
+        // mais ce fonctionnement est a ameliorer !
4343
+        $info_generee = appliquer_traitement_champ($info_generee, $info, table_objet($type_objet),
4344
+            array('id_objet' => $id_objet, 'objet' => $type_objet, ''));
4345
+    }
4346
+
4347
+    return $info_generee;
4348 4348
 }
4349 4349
 
4350 4350
 /**
@@ -4358,44 +4358,44 @@  discard block
 block discarded – undo
4358 4358
  * @return string
4359 4359
  */
4360 4360
 function appliquer_traitement_champ($texte, $champ, $table_objet = '', $env = array(), $connect = '') {
4361
-	if (!$champ) {
4362
-		return $texte;
4363
-	}
4361
+    if (!$champ) {
4362
+        return $texte;
4363
+    }
4364 4364
 	
4365
-	// On charge toujours les filtres de texte car la majorité des traitements les utilisent
4366
-	// et il ne faut pas partir du principe que c'est déjà chargé (form ajax, etc)
4367
-	include_spip('inc/texte');
4365
+    // On charge toujours les filtres de texte car la majorité des traitements les utilisent
4366
+    // et il ne faut pas partir du principe que c'est déjà chargé (form ajax, etc)
4367
+    include_spip('inc/texte');
4368 4368
 	
4369
-	$champ = strtoupper($champ);
4370
-	$traitements = isset($GLOBALS['table_des_traitements'][$champ]) ? $GLOBALS['table_des_traitements'][$champ] : false;
4371
-	if (!$traitements or !is_array($traitements)) {
4372
-		return $texte;
4373
-	}
4369
+    $champ = strtoupper($champ);
4370
+    $traitements = isset($GLOBALS['table_des_traitements'][$champ]) ? $GLOBALS['table_des_traitements'][$champ] : false;
4371
+    if (!$traitements or !is_array($traitements)) {
4372
+        return $texte;
4373
+    }
4374 4374
 
4375
-	$traitement = '';
4376
-	if ($table_objet and (!isset($traitements[0]) or count($traitements) > 1)) {
4377
-		// necessaire pour prendre en charge les vieux appels avec un table_objet_sql en 3e arg
4378
-		$table_objet = table_objet($table_objet);
4379
-		if (isset($traitements[$table_objet])) {
4380
-			$traitement = $traitements[$table_objet];
4381
-		}
4382
-	}
4383
-	if (!$traitement and isset($traitements[0])) {
4384
-		$traitement = $traitements[0];
4385
-	}
4386
-	// (sinon prendre le premier de la liste par defaut ?)
4375
+    $traitement = '';
4376
+    if ($table_objet and (!isset($traitements[0]) or count($traitements) > 1)) {
4377
+        // necessaire pour prendre en charge les vieux appels avec un table_objet_sql en 3e arg
4378
+        $table_objet = table_objet($table_objet);
4379
+        if (isset($traitements[$table_objet])) {
4380
+            $traitement = $traitements[$table_objet];
4381
+        }
4382
+    }
4383
+    if (!$traitement and isset($traitements[0])) {
4384
+        $traitement = $traitements[0];
4385
+    }
4386
+    // (sinon prendre le premier de la liste par defaut ?)
4387 4387
 
4388
-	if (!$traitement) {
4389
-		return $texte;
4390
-	}
4388
+    if (!$traitement) {
4389
+        return $texte;
4390
+    }
4391 4391
 
4392
-	$traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement);
4392
+    $traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement);
4393 4393
 
4394
-	// Fournir $connect et $Pile[0] au traitement si besoin
4395
-	$Pile = array(0 => $env);
4396
-	eval("\$texte = $traitement;");
4394
+    // Fournir $connect et $Pile[0] au traitement si besoin
4395
+    $Pile = array(0 => $env);
4396
+    eval("\$texte = $traitement;");
4397 4397
 
4398
-	return $texte;
4398
+    return $texte;
4399 4399
 }
4400 4400
 
4401 4401
 
@@ -4409,21 +4409,21 @@  discard block
 block discarded – undo
4409 4409
  * @return string
4410 4410
  */
4411 4411
 function generer_lien_entite($id_objet, $objet, $longueur = 80, $connect = null) {
4412
-	include_spip('inc/liens');
4413
-	$titre = traiter_raccourci_titre($id_objet, $objet, $connect);
4414
-	// lorsque l'objet n'est plus declare (plugin desactive par exemple)
4415
-	// le raccourcis n'est plus valide
4416
-	$titre = isset($titre['titre']) ? typo($titre['titre']) : '';
4417
-	// on essaye avec generer_info_entite ?
4418
-	if (!strlen($titre) and !$connect) {
4419
-		$titre = generer_info_entite($id_objet, $objet, 'titre');
4420
-	}
4421
-	if (!strlen($titre)) {
4422
-		$titre = _T('info_sans_titre');
4423
-	}
4424
-	$url = generer_url_entite($id_objet, $objet, '', '', $connect);
4412
+    include_spip('inc/liens');
4413
+    $titre = traiter_raccourci_titre($id_objet, $objet, $connect);
4414
+    // lorsque l'objet n'est plus declare (plugin desactive par exemple)
4415
+    // le raccourcis n'est plus valide
4416
+    $titre = isset($titre['titre']) ? typo($titre['titre']) : '';
4417
+    // on essaye avec generer_info_entite ?
4418
+    if (!strlen($titre) and !$connect) {
4419
+        $titre = generer_info_entite($id_objet, $objet, 'titre');
4420
+    }
4421
+    if (!strlen($titre)) {
4422
+        $titre = _T('info_sans_titre');
4423
+    }
4424
+    $url = generer_url_entite($id_objet, $objet, '', '', $connect);
4425 4425
 
4426
-	return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . "</a>";
4426
+    return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . "</a>";
4427 4427
 }
4428 4428
 
4429 4429
 
@@ -4440,15 +4440,15 @@  discard block
 block discarded – undo
4440 4440
  * @return string
4441 4441
  */
4442 4442
 function wrap($texte, $wrap) {
4443
-	$balises = extraire_balises($wrap);
4444
-	if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) {
4445
-		$texte = $wrap . $texte;
4446
-		$regs = array_reverse($regs[1]);
4447
-		$wrap = "</" . implode("></", $regs) . ">";
4448
-		$texte = $texte . $wrap;
4449
-	}
4443
+    $balises = extraire_balises($wrap);
4444
+    if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) {
4445
+        $texte = $wrap . $texte;
4446
+        $regs = array_reverse($regs[1]);
4447
+        $wrap = "</" . implode("></", $regs) . ">";
4448
+        $texte = $texte . $wrap;
4449
+    }
4450 4450
 
4451
-	return $texte;
4451
+    return $texte;
4452 4452
 }
4453 4453
 
4454 4454
 
@@ -4468,43 +4468,43 @@  discard block
 block discarded – undo
4468 4468
  * @return array|mixed|string
4469 4469
  */
4470 4470
 function filtre_print_dist($u, $join = "<br />", $indent = 0) {
4471
-	if (is_string($u)) {
4472
-		$u = typo($u);
4471
+    if (is_string($u)) {
4472
+        $u = typo($u);
4473 4473
 
4474
-		return $u;
4475
-	}
4474
+        return $u;
4475
+    }
4476 4476
 
4477
-	// caster $u en array si besoin
4478
-	if (is_object($u)) {
4479
-		$u = (array)$u;
4480
-	}
4477
+    // caster $u en array si besoin
4478
+    if (is_object($u)) {
4479
+        $u = (array)$u;
4480
+    }
4481 4481
 
4482
-	if (is_array($u)) {
4483
-		$out = "";
4484
-		// toutes les cles sont numeriques ?
4485
-		// et aucun enfant n'est un tableau
4486
-		// liste simple separee par des virgules
4487
-		$numeric_keys = array_map('is_numeric', array_keys($u));
4488
-		$array_values = array_map('is_array', $u);
4489
-		$object_values = array_map('is_object', $u);
4490
-		if (array_sum($numeric_keys) == count($numeric_keys)
4491
-			and !array_sum($array_values)
4492
-			and !array_sum($object_values)
4493
-		) {
4494
-			return join(", ", array_map('filtre_print_dist', $u));
4495
-		}
4482
+    if (is_array($u)) {
4483
+        $out = "";
4484
+        // toutes les cles sont numeriques ?
4485
+        // et aucun enfant n'est un tableau
4486
+        // liste simple separee par des virgules
4487
+        $numeric_keys = array_map('is_numeric', array_keys($u));
4488
+        $array_values = array_map('is_array', $u);
4489
+        $object_values = array_map('is_object', $u);
4490
+        if (array_sum($numeric_keys) == count($numeric_keys)
4491
+            and !array_sum($array_values)
4492
+            and !array_sum($object_values)
4493
+        ) {
4494
+            return join(", ", array_map('filtre_print_dist', $u));
4495
+        }
4496 4496
 
4497
-		// sinon on passe a la ligne et on indente
4498
-		$i_str = str_pad("", $indent, " ");
4499
-		foreach ($u as $k => $v) {
4500
-			$out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2);
4501
-		}
4497
+        // sinon on passe a la ligne et on indente
4498
+        $i_str = str_pad("", $indent, " ");
4499
+        foreach ($u as $k => $v) {
4500
+            $out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2);
4501
+        }
4502 4502
 
4503
-		return $out;
4504
-	}
4503
+        return $out;
4504
+    }
4505 4505
 
4506
-	// on sait pas quoi faire...
4507
-	return $u;
4506
+    // on sait pas quoi faire...
4507
+    return $u;
4508 4508
 }
4509 4509
 
4510 4510
 
@@ -4517,10 +4517,10 @@  discard block
 block discarded – undo
4517 4517
  * @return string
4518 4518
  */
4519 4519
 function objet_info($objet, $info) {
4520
-	$table = table_objet_sql($objet);
4521
-	$infos = lister_tables_objets_sql($table);
4520
+    $table = table_objet_sql($objet);
4521
+    $infos = lister_tables_objets_sql($table);
4522 4522
 
4523
-	return (isset($infos[$info]) ? $infos[$info] : '');
4523
+    return (isset($infos[$info]) ? $infos[$info] : '');
4524 4524
 }
4525 4525
 
4526 4526
 /**
@@ -4535,11 +4535,11 @@  discard block
 block discarded – undo
4535 4535
  *     Texte traduit du comptage, tel que '3 articles'
4536 4536
  */
4537 4537
 function objet_afficher_nb($nb, $objet) {
4538
-	if (!$nb) {
4539
-		return _T(objet_info($objet, 'info_aucun_objet'));
4540
-	} else {
4541
-		return _T(objet_info($objet, $nb == 1 ? 'info_1_objet' : 'info_nb_objets'), array('nb' => $nb));
4542
-	}
4538
+    if (!$nb) {
4539
+        return _T(objet_info($objet, 'info_aucun_objet'));
4540
+    } else {
4541
+        return _T(objet_info($objet, $nb == 1 ? 'info_1_objet' : 'info_nb_objets'), array('nb' => $nb));
4542
+    }
4543 4543
 }
4544 4544
 
4545 4545
 /**
@@ -4550,11 +4550,11 @@  discard block
 block discarded – undo
4550 4550
  * @return string
4551 4551
  */
4552 4552
 function objet_icone($objet, $taille = 24) {
4553
-	$icone = objet_info($objet, 'icone_objet') . "-" . $taille . ".png";
4554
-	$icone = chemin_image($icone);
4555
-	$balise_img = charger_filtre('balise_img');
4553
+    $icone = objet_info($objet, 'icone_objet') . "-" . $taille . ".png";
4554
+    $icone = chemin_image($icone);
4555
+    $balise_img = charger_filtre('balise_img');
4556 4556
 
4557
-	return $icone ? $balise_img($icone, _T(objet_info($objet, 'texte_objet'))) : '';
4557
+    return $icone ? $balise_img($icone, _T(objet_info($objet, 'texte_objet'))) : '';
4558 4558
 }
4559 4559
 
4560 4560
 /**
@@ -4575,12 +4575,12 @@  discard block
 block discarded – undo
4575 4575
  * @return string
4576 4576
  */
4577 4577
 function objet_T($objet, $chaine, $args = array(), $options = array()){
4578
-	$chaine = explode(':',$chaine);
4579
-	if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, array('force'=>false)))) {
4580
-		return $t;
4581
-	}
4582
-	$chaine = implode(':',$chaine);
4583
-	return _T($chaine, $args, $options);
4578
+    $chaine = explode(':',$chaine);
4579
+    if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, array('force'=>false)))) {
4580
+        return $t;
4581
+    }
4582
+    $chaine = implode(':',$chaine);
4583
+    return _T($chaine, $args, $options);
4584 4584
 }
4585 4585
 
4586 4586
 /**
@@ -4594,17 +4594,17 @@  discard block
 block discarded – undo
4594 4594
  * @return string      Code HTML
4595 4595
  */
4596 4596
 function insert_head_css_conditionnel($flux) {
4597
-	if (strpos($flux, '<!-- insert_head_css -->') === false
4598
-		and $p = strpos($flux, '<!-- insert_head -->')
4599
-	) {
4600
-		// plutot avant le premier js externe (jquery) pour etre non bloquant
4601
-		if ($p1 = stripos($flux, '<script src=') and $p1 < $p) {
4602
-			$p = $p1;
4603
-		}
4604
-		$flux = substr_replace($flux, pipeline('insert_head_css', '<!-- insert_head_css -->'), $p, 0);
4605
-	}
4597
+    if (strpos($flux, '<!-- insert_head_css -->') === false
4598
+        and $p = strpos($flux, '<!-- insert_head -->')
4599
+    ) {
4600
+        // plutot avant le premier js externe (jquery) pour etre non bloquant
4601
+        if ($p1 = stripos($flux, '<script src=') and $p1 < $p) {
4602
+            $p = $p1;
4603
+        }
4604
+        $flux = substr_replace($flux, pipeline('insert_head_css', '<!-- insert_head_css -->'), $p, 0);
4605
+    }
4606 4606
 
4607
-	return $flux;
4607
+    return $flux;
4608 4608
 }
4609 4609
 
4610 4610
 /**
@@ -4625,66 +4625,66 @@  discard block
 block discarded – undo
4625 4625
  * @return string
4626 4626
  */
4627 4627
 function produire_fond_statique($fond, $contexte = array(), $options = array(), $connect = '') {
4628
-	if (isset($contexte['format'])) {
4629
-		$extension = $contexte['format'];
4630
-		unset($contexte['format']);
4631
-	} else {
4632
-		$extension = "html";
4633
-		if (preg_match(',[.](css|js|json)$,', $fond, $m)) {
4634
-			$extension = $m[1];
4635
-		}
4636
-	}
4637
-	// recuperer le contenu produit par le squelette
4638
-	$options['raw'] = true;
4639
-	$cache = recuperer_fond($fond, $contexte, $options, $connect);
4640
-
4641
-	// calculer le nom de la css
4642
-	$dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension);
4643
-	$nom_safe = preg_replace(",\W,", '_', str_replace('.', '_', $fond));
4644
-	$contexte_implicite = calculer_contexte_implicite();
4645
-	$filename = $dir_var . $extension . "dyn-$nom_safe-"
4646
-		. substr(md5($fond . serialize($contexte_implicite) . serialize($contexte) . $connect), 0, 8)
4647
-		. ".$extension";
4648
-
4649
-	// mettre a jour le fichier si il n'existe pas
4650
-	// ou trop ancien
4651
-	// le dernier fichier produit est toujours suffixe par .last
4652
-	// et recopie sur le fichier cible uniquement si il change
4653
-	if (!file_exists($filename)
4654
-		or !file_exists($filename . ".last")
4655
-		or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . ".last") < $cache['lastmodified'])
4656
-		or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')
4657
-	) {
4658
-		$contenu = $cache['texte'];
4659
-		// passer les urls en absolu si c'est une css
4660
-		if ($extension == "css") {
4661
-			$contenu = urls_absolues_css($contenu,
4662
-				test_espace_prive() ? generer_url_ecrire('accueil') : generer_url_public($fond));
4663
-		}
4664
-
4665
-		$comment = '';
4666
-		// ne pas insérer de commentaire si c'est du json
4667
-		if ($extension != "json") {
4668
-			$comment = "/* #PRODUIRE{fond=$fond";
4669
-			foreach ($contexte as $k => $v) {
4670
-				$comment .= ",$k=$v";
4671
-			}
4672
-			// pas de date dans le commentaire car sinon ca invalide le md5 et force la maj
4673
-			// mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non
4674
-			$comment .= "}\n   md5:" . md5($contenu) . " */\n";
4675
-		}
4676
-		// et ecrire le fichier
4677
-		ecrire_fichier($filename . ".last", $comment . $contenu);
4678
-		// regarder si on recopie
4679
-		if (!file_exists($filename)
4680
-			or md5_file($filename) !== md5_file($filename . ".last")
4681
-		) {
4682
-			@copy($filename . ".last", $filename);
4683
-			clearstatcache(true, $filename); // eviter que PHP ne reserve le vieux timestamp
4684
-		}
4685
-	}
4686
-
4687
-	return timestamp($filename);
4628
+    if (isset($contexte['format'])) {
4629
+        $extension = $contexte['format'];
4630
+        unset($contexte['format']);
4631
+    } else {
4632
+        $extension = "html";
4633
+        if (preg_match(',[.](css|js|json)$,', $fond, $m)) {
4634
+            $extension = $m[1];
4635
+        }
4636
+    }
4637
+    // recuperer le contenu produit par le squelette
4638
+    $options['raw'] = true;
4639
+    $cache = recuperer_fond($fond, $contexte, $options, $connect);
4640
+
4641
+    // calculer le nom de la css
4642
+    $dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension);
4643
+    $nom_safe = preg_replace(",\W,", '_', str_replace('.', '_', $fond));
4644
+    $contexte_implicite = calculer_contexte_implicite();
4645
+    $filename = $dir_var . $extension . "dyn-$nom_safe-"
4646
+        . substr(md5($fond . serialize($contexte_implicite) . serialize($contexte) . $connect), 0, 8)
4647
+        . ".$extension";
4648
+
4649
+    // mettre a jour le fichier si il n'existe pas
4650
+    // ou trop ancien
4651
+    // le dernier fichier produit est toujours suffixe par .last
4652
+    // et recopie sur le fichier cible uniquement si il change
4653
+    if (!file_exists($filename)
4654
+        or !file_exists($filename . ".last")
4655
+        or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . ".last") < $cache['lastmodified'])
4656
+        or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')
4657
+    ) {
4658
+        $contenu = $cache['texte'];
4659
+        // passer les urls en absolu si c'est une css
4660
+        if ($extension == "css") {
4661
+            $contenu = urls_absolues_css($contenu,
4662
+                test_espace_prive() ? generer_url_ecrire('accueil') : generer_url_public($fond));
4663
+        }
4664
+
4665
+        $comment = '';
4666
+        // ne pas insérer de commentaire si c'est du json
4667
+        if ($extension != "json") {
4668
+            $comment = "/* #PRODUIRE{fond=$fond";
4669
+            foreach ($contexte as $k => $v) {
4670
+                $comment .= ",$k=$v";
4671
+            }
4672
+            // pas de date dans le commentaire car sinon ca invalide le md5 et force la maj
4673
+            // mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non
4674
+            $comment .= "}\n   md5:" . md5($contenu) . " */\n";
4675
+        }
4676
+        // et ecrire le fichier
4677
+        ecrire_fichier($filename . ".last", $comment . $contenu);
4678
+        // regarder si on recopie
4679
+        if (!file_exists($filename)
4680
+            or md5_file($filename) !== md5_file($filename . ".last")
4681
+        ) {
4682
+            @copy($filename . ".last", $filename);
4683
+            clearstatcache(true, $filename); // eviter que PHP ne reserve le vieux timestamp
4684
+        }
4685
+    }
4686
+
4687
+    return timestamp($filename);
4688 4688
 }
4689 4689
 
4690 4690
 /**
@@ -4697,14 +4697,14 @@  discard block
 block discarded – undo
4697 4697
  *    $fichier auquel on a ajouté le timestamp
4698 4698
  */
4699 4699
 function timestamp($fichier) {
4700
-	if (!$fichier
4701
-		or !file_exists($fichier)
4702
-		or !$m = filemtime($fichier)
4703
-	) {
4704
-		return $fichier;
4705
-	}
4700
+    if (!$fichier
4701
+        or !file_exists($fichier)
4702
+        or !$m = filemtime($fichier)
4703
+    ) {
4704
+        return $fichier;
4705
+    }
4706 4706
 
4707
-	return "$fichier?$m";
4707
+    return "$fichier?$m";
4708 4708
 }
4709 4709
 
4710 4710
 /**
@@ -4714,11 +4714,11 @@  discard block
 block discarded – undo
4714 4714
  * @return string
4715 4715
  */
4716 4716
 function supprimer_timestamp($url) {
4717
-	if (strpos($url, "?") === false) {
4718
-		return $url;
4719
-	}
4717
+    if (strpos($url, "?") === false) {
4718
+        return $url;
4719
+    }
4720 4720
 
4721
-	return preg_replace(",\?[[:digit:]]+$,", "", $url);
4721
+    return preg_replace(",\?[[:digit:]]+$,", "", $url);
4722 4722
 }
4723 4723
 
4724 4724
 /**
@@ -4733,9 +4733,9 @@  discard block
 block discarded – undo
4733 4733
  * @return string
4734 4734
  */
4735 4735
 function filtre_nettoyer_titre_email_dist($titre) {
4736
-	include_spip('inc/envoyer_mail');
4736
+    include_spip('inc/envoyer_mail');
4737 4737
 
4738
-	return nettoyer_titre_email($titre);
4738
+    return nettoyer_titre_email($titre);
4739 4739
 }
4740 4740
 
4741 4741
 /**
@@ -4757,19 +4757,19 @@  discard block
 block discarded – undo
4757 4757
  * @return string
4758 4758
  */
4759 4759
 function filtre_chercher_rubrique_dist(
4760
-	$titre,
4761
-	$id_objet,
4762
-	$id_parent,
4763
-	$objet,
4764
-	$id_secteur,
4765
-	$restreint,
4766
-	$actionable = false,
4767
-	$retour_sans_cadre = false
4760
+    $titre,
4761
+    $id_objet,
4762
+    $id_parent,
4763
+    $objet,
4764
+    $id_secteur,
4765
+    $restreint,
4766
+    $actionable = false,
4767
+    $retour_sans_cadre = false
4768 4768
 ) {
4769
-	include_spip('inc/filtres_ecrire');
4769
+    include_spip('inc/filtres_ecrire');
4770 4770
 
4771
-	return chercher_rubrique($titre, $id_objet, $id_parent, $objet, $id_secteur, $restreint, $actionable,
4772
-		$retour_sans_cadre);
4771
+    return chercher_rubrique($titre, $id_objet, $id_parent, $objet, $id_secteur, $restreint, $actionable,
4772
+        $retour_sans_cadre);
4773 4773
 }
4774 4774
 
4775 4775
 /**
@@ -4798,56 +4798,56 @@  discard block
 block discarded – undo
4798 4798
  *     Chaîne vide si l'accès est autorisé
4799 4799
  */
4800 4800
 function sinon_interdire_acces($ok = false, $url = '', $statut = 0, $message = null) {
4801
-	if ($ok) {
4802
-		return '';
4803
-	}
4804
-
4805
-	// Vider tous les tampons
4806
-	$level = @ob_get_level();
4807
-	while ($level--) {
4808
-		@ob_end_clean();
4809
-	}
4810
-
4811
-	include_spip('inc/headers');
4812
-
4813
-	// S'il y a une URL, on redirige (si pas de statut, la fonction mettra 302 par défaut)
4814
-	if ($url) {
4815
-		redirige_par_entete($url, '', $statut);
4816
-	}
4817
-
4818
-	// ecriture simplifiee avec message en 3eme argument (= statut 403)
4819
-	if (!is_numeric($statut) and is_null($message)) {
4820
-		$message = $statut;
4821
-		$statut = 0;
4822
-	}
4823
-	if (!$message) {
4824
-		$message = '';
4825
-	}
4826
-	$statut = intval($statut);
4827
-
4828
-	// Si on est dans l'espace privé, on génère du 403 Forbidden par defaut ou du 404
4829
-	if (test_espace_prive()) {
4830
-		if (!$statut or !in_array($statut, array(404, 403))) {
4831
-			$statut = 403;
4832
-		}
4833
-		http_status(403);
4834
-		$echec = charger_fonction('403', 'exec');
4835
-		$echec($message);
4836
-	} else {
4837
-		// Sinon dans l'espace public on redirige vers une 404 par défaut, car elle toujours présente normalement
4838
-		if (!$statut) {
4839
-			$statut = 404;
4840
-		}
4841
-		// Dans tous les cas on modifie l'entité avec ce qui est demandé
4842
-		http_status($statut);
4843
-		// Si le statut est une erreur et qu'il n'y a pas de redirection on va chercher le squelette du même nom
4844
-		if ($statut >= 400) {
4845
-			echo recuperer_fond("$statut", array('erreur' => $message));
4846
-		}
4847
-	}
4848
-
4849
-
4850
-	exit;
4801
+    if ($ok) {
4802
+        return '';
4803
+    }
4804
+
4805
+    // Vider tous les tampons
4806
+    $level = @ob_get_level();
4807
+    while ($level--) {
4808
+        @ob_end_clean();
4809
+    }
4810
+
4811
+    include_spip('inc/headers');
4812
+
4813
+    // S'il y a une URL, on redirige (si pas de statut, la fonction mettra 302 par défaut)
4814
+    if ($url) {
4815
+        redirige_par_entete($url, '', $statut);
4816
+    }
4817
+
4818
+    // ecriture simplifiee avec message en 3eme argument (= statut 403)
4819
+    if (!is_numeric($statut) and is_null($message)) {
4820
+        $message = $statut;
4821
+        $statut = 0;
4822
+    }
4823
+    if (!$message) {
4824
+        $message = '';
4825
+    }
4826
+    $statut = intval($statut);
4827
+
4828
+    // Si on est dans l'espace privé, on génère du 403 Forbidden par defaut ou du 404
4829
+    if (test_espace_prive()) {
4830
+        if (!$statut or !in_array($statut, array(404, 403))) {
4831
+            $statut = 403;
4832
+        }
4833
+        http_status(403);
4834
+        $echec = charger_fonction('403', 'exec');
4835
+        $echec($message);
4836
+    } else {
4837
+        // Sinon dans l'espace public on redirige vers une 404 par défaut, car elle toujours présente normalement
4838
+        if (!$statut) {
4839
+            $statut = 404;
4840
+        }
4841
+        // Dans tous les cas on modifie l'entité avec ce qui est demandé
4842
+        http_status($statut);
4843
+        // Si le statut est une erreur et qu'il n'y a pas de redirection on va chercher le squelette du même nom
4844
+        if ($statut >= 400) {
4845
+            echo recuperer_fond("$statut", array('erreur' => $message));
4846
+        }
4847
+    }
4848
+
4849
+
4850
+    exit;
4851 4851
 }
4852 4852
 
4853 4853
 /**
@@ -4858,9 +4858,9 @@  discard block
 block discarded – undo
4858 4858
  * @return string
4859 4859
  */
4860 4860
 function filtre_compacte_dist($source, $format = null) {
4861
-	if (function_exists('compacte')) {
4862
-		return compacte($source, $format);
4863
-	}
4861
+    if (function_exists('compacte')) {
4862
+        return compacte($source, $format);
4863
+    }
4864 4864
 
4865
-	return $source;
4865
+    return $source;
4866 4866
 }
Please login to merge, or discard this patch.
ecrire/inc/install.php 3 patches
Doc Comments   +18 added lines patch added patch discarded remove patch
@@ -234,6 +234,9 @@  discard block
 block discarded – undo
234 234
 
235 235
 
236 236
 // http://code.spip.net/@info_etape
237
+/**
238
+ * @param string $titre
239
+ */
237 240
 function info_etape($titre, $complement = '') {
238 241
 	return "<h2>" . $titre . "</h2>\n" .
239 242
 	($complement ? "" . $complement . "\n" : '');
@@ -259,6 +262,11 @@  discard block
 block discarded – undo
259 262
 }
260 263
 
261 264
 // http://code.spip.net/@info_progression_etape
265
+/**
266
+ * @param integer $en_cours
267
+ * @param string $phase
268
+ * @param string $dir
269
+ */
262 270
 function info_progression_etape($en_cours, $phase, $dir, $erreur = false) {
263 271
 	//$en_cours = _request('etape')?_request('etape'):"";
264 272
 	$liste = find_all_in_path($dir, $phase . '(([0-9])+|fin)[.]php$');
@@ -315,6 +323,9 @@  discard block
 block discarded – undo
315 323
 
316 324
 
317 325
 // http://code.spip.net/@fieldset
326
+/**
327
+ * @param string $legend
328
+ */
318 329
 function fieldset($legend, $champs = array(), $apres = '', $avant = '') {
319 330
 	return "<fieldset>\n" .
320 331
 	$avant .
@@ -382,6 +393,10 @@  discard block
 block discarded – undo
382 393
 }
383 394
 
384 395
 // http://code.spip.net/@install_connexion_form
396
+/**
397
+ * @param string[] $pass
398
+ * @param integer $etape
399
+ */
385 400
 function install_connexion_form($db, $login, $pass, $predef, $hidden, $etape, $jquery = true) {
386 401
 	$server_db = (is_string($predef[0])) ? $predef[0] : '';
387 402
 
@@ -549,6 +564,9 @@  discard block
 block discarded – undo
549 564
 	return array($checked, $bases);
550 565
 }
551 566
 
567
+/**
568
+ * @param string[] $hidden
569
+ */
552 570
 function install_propager($hidden) {
553 571
 	$res = '';
554 572
 	foreach ($hidden as $k) {
Please login to merge, or discard this patch.
Indentation   +354 added lines, -354 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
 
@@ -43,12 +43,12 @@  discard block
 block discarded – undo
43 43
  * @return void
44 44
  **/
45 45
 function install_fichier_connexion($nom, $texte) {
46
-	$texte = "<" . "?php\n"
47
-		. "if (!defined(\"_ECRIRE_INC_VERSION\")) return;\n"
48
-		. $texte
49
-		. "?" . ">";
46
+    $texte = "<" . "?php\n"
47
+        . "if (!defined(\"_ECRIRE_INC_VERSION\")) return;\n"
48
+        . $texte
49
+        . "?" . ">";
50 50
 
51
-	ecrire_fichier($nom, $texte);
51
+    ecrire_fichier($nom, $texte);
52 52
 }
53 53
 
54 54
 
@@ -77,20 +77,20 @@  discard block
 block discarded – undo
77 77
  *
78 78
  **/
79 79
 function install_connexion($adr, $port, $login, $pass, $base, $type, $pref, $ldap = '', $charset = '') {
80
-	$adr = addcslashes($adr, "'\\");
81
-	$port = addcslashes($port, "'\\");
82
-	$login = addcslashes($login, "'\\");
83
-	$pass = addcslashes($pass, "'\\");
84
-	$base = addcslashes($base, "'\\");
85
-	$type = addcslashes($type, "'\\");
86
-	$pref = addcslashes($pref, "'\\");
87
-	$ldap = addcslashes($ldap, "'\\");
88
-	$charset = addcslashes($charset, "'\\");
89
-
90
-	return "\$GLOBALS['spip_connect_version'] = 0.8;\n"
91
-	. "spip_connect_db("
92
-	. "'$adr','$port','$login','$pass','$base'"
93
-	. ",'$type', '$pref','$ldap','$charset');\n";
80
+    $adr = addcslashes($adr, "'\\");
81
+    $port = addcslashes($port, "'\\");
82
+    $login = addcslashes($login, "'\\");
83
+    $pass = addcslashes($pass, "'\\");
84
+    $base = addcslashes($base, "'\\");
85
+    $type = addcslashes($type, "'\\");
86
+    $pref = addcslashes($pref, "'\\");
87
+    $ldap = addcslashes($ldap, "'\\");
88
+    $charset = addcslashes($charset, "'\\");
89
+
90
+    return "\$GLOBALS['spip_connect_version'] = 0.8;\n"
91
+    . "spip_connect_db("
92
+    . "'$adr','$port','$login','$pass','$base'"
93
+    . ",'$type', '$pref','$ldap','$charset');\n";
94 94
 }
95 95
 
96 96
 
@@ -106,26 +106,26 @@  discard block
 block discarded – undo
106 106
  *     Tableau des informations sur la connexion
107 107
  **/
108 108
 function analyse_fichier_connection($file) {
109
-	$s = @join('', file($file));
110
-	if (preg_match("#mysql_connect\([\"'](.*)[\"'],[\"'](.*)[\"'],[\"'](.*)[\"']\)#", $s, $regs)) {
111
-		array_shift($regs);
112
-
113
-		return $regs;
114
-	} else {
115
-		$ar = '\s*\'([^\']*)\'';
116
-		$r = '\s*,' . $ar;
117
-		$r = "#spip_connect_db[(]$ar$r$r$r$r(?:$r(?:$r(?:$r(?:$r)?)?)?)?#";
118
-		if (preg_match($r, $s, $regs)) {
119
-			$regs[2] = $regs[1] . (!$regs[2] ? '' : ":" . $regs[2] . ";");
120
-			array_shift($regs);
121
-			array_shift($regs);
122
-
123
-			return $regs;
124
-		}
125
-	}
126
-	spip_log("$file n'est pas un fichier de connexion");
127
-
128
-	return array();
109
+    $s = @join('', file($file));
110
+    if (preg_match("#mysql_connect\([\"'](.*)[\"'],[\"'](.*)[\"'],[\"'](.*)[\"']\)#", $s, $regs)) {
111
+        array_shift($regs);
112
+
113
+        return $regs;
114
+    } else {
115
+        $ar = '\s*\'([^\']*)\'';
116
+        $r = '\s*,' . $ar;
117
+        $r = "#spip_connect_db[(]$ar$r$r$r$r(?:$r(?:$r(?:$r(?:$r)?)?)?)?#";
118
+        if (preg_match($r, $s, $regs)) {
119
+            $regs[2] = $regs[1] . (!$regs[2] ? '' : ":" . $regs[2] . ";");
120
+            array_shift($regs);
121
+            array_shift($regs);
122
+
123
+            return $regs;
124
+        }
125
+    }
126
+    spip_log("$file n'est pas un fichier de connexion");
127
+
128
+    return array();
129 129
 }
130 130
 
131 131
 /**
@@ -142,21 +142,21 @@  discard block
 block discarded – undo
142 142
  *     Liste des noms de connecteurs
143 143
  **/
144 144
 function bases_referencees($exclu = '') {
145
-	$tables = array();
146
-	foreach (preg_files(_DIR_CONNECT, '.php$') as $f) {
147
-		if ($f != $exclu and analyse_fichier_connection($f)) {
148
-			$tables[] = basename($f, '.php');
149
-		}
150
-	}
151
-
152
-	return $tables;
145
+    $tables = array();
146
+    foreach (preg_files(_DIR_CONNECT, '.php$') as $f) {
147
+        if ($f != $exclu and analyse_fichier_connection($f)) {
148
+            $tables[] = basename($f, '.php');
149
+        }
150
+    }
151
+
152
+    return $tables;
153 153
 }
154 154
 
155 155
 
156 156
 function install_mode_appel($server_db, $tout = true) {
157
-	return ($server_db != 'mysql') ? ''
158
-		: (($tout ? test_rappel_nom_base_mysql($server_db) : '')
159
-			. test_sql_mode_mysql($server_db));
157
+    return ($server_db != 'mysql') ? ''
158
+        : (($tout ? test_rappel_nom_base_mysql($server_db) : '')
159
+            . test_sql_mode_mysql($server_db));
160 160
 }
161 161
 
162 162
 //
@@ -164,52 +164,52 @@  discard block
 block discarded – undo
164 164
 // (sert a l'etape 1 de l'installation)
165 165
 // http://code.spip.net/@tester_compatibilite_hebergement
166 166
 function tester_compatibilite_hebergement() {
167
-	$err = array();
168
-
169
-	$p = phpversion();
170
-	if (version_compare($p, _PHP_MIN, '<')) {
171
-		$err[] = _T('install_php_version', array('version' => $p, 'minimum' => _PHP_MIN));
172
-	}
173
-
174
-	// Si on n'a pas la bonne version de PHP, c'est la fin
175
-	if ($err) {
176
-		die("<div class='error'>"
177
-			. "<h3>" . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>"
178
-			. "<li><strong>{$err[0]}</strong></li>\n</ul></div>");
179
-	}
180
-
181
-	// Il faut une base de donnees tout de meme ...
182
-	$serveurs = install_select_serveur();
183
-	if (!$serveurs) {
184
-		$err[] = _T('install_extension_php_obligatoire')
185
-			. " <a href='http://www.php.net/mysql'>MYSQL</a>"
186
-			. "| <a href='http://www.php.net/pgsql'>PostgreSQL</a>"
187
-			. "| <a href='http://www.php.net/sqlite'>SQLite</a>";
188
-	}
189
-
190
-	// et il faut preg
191
-	if (!function_exists('preg_match_all')) {
192
-		$err[] = _T('install_extension_php_obligatoire')
193
-			. " <a href='http://se.php.net/pcre'>PCRE</a>";
194
-	}
195
-
196
-	// et surtout pas ce mbstring.overload
197
-	if ($a = @ini_get('mbstring.func_overload')) {
198
-		$err[] = _T('install_extension_mbstring')
199
-			. "mbstring.func_overload=$a - <a href='http://www.php.net/mb_string'>mb_string</a>.<br /><small>";
200
-	}
201
-
202
-	if ($err) {
203
-		echo "<div class='error'>"
204
-			. "<h3>" . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>";
205
-		foreach ($err as $e) {
206
-			echo "<li><strong>$e</strong></li>\n";
207
-		}
208
-
209
-		# a priori ici on pourrait die(), mais il faut laisser la possibilite
210
-		# de forcer malgre tout (pour tester, ou si bug de detection)
211
-		echo "</ul></div>\n";
212
-	}
167
+    $err = array();
168
+
169
+    $p = phpversion();
170
+    if (version_compare($p, _PHP_MIN, '<')) {
171
+        $err[] = _T('install_php_version', array('version' => $p, 'minimum' => _PHP_MIN));
172
+    }
173
+
174
+    // Si on n'a pas la bonne version de PHP, c'est la fin
175
+    if ($err) {
176
+        die("<div class='error'>"
177
+            . "<h3>" . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>"
178
+            . "<li><strong>{$err[0]}</strong></li>\n</ul></div>");
179
+    }
180
+
181
+    // Il faut une base de donnees tout de meme ...
182
+    $serveurs = install_select_serveur();
183
+    if (!$serveurs) {
184
+        $err[] = _T('install_extension_php_obligatoire')
185
+            . " <a href='http://www.php.net/mysql'>MYSQL</a>"
186
+            . "| <a href='http://www.php.net/pgsql'>PostgreSQL</a>"
187
+            . "| <a href='http://www.php.net/sqlite'>SQLite</a>";
188
+    }
189
+
190
+    // et il faut preg
191
+    if (!function_exists('preg_match_all')) {
192
+        $err[] = _T('install_extension_php_obligatoire')
193
+            . " <a href='http://se.php.net/pcre'>PCRE</a>";
194
+    }
195
+
196
+    // et surtout pas ce mbstring.overload
197
+    if ($a = @ini_get('mbstring.func_overload')) {
198
+        $err[] = _T('install_extension_mbstring')
199
+            . "mbstring.func_overload=$a - <a href='http://www.php.net/mb_string'>mb_string</a>.<br /><small>";
200
+    }
201
+
202
+    if ($err) {
203
+        echo "<div class='error'>"
204
+            . "<h3>" . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>";
205
+        foreach ($err as $e) {
206
+            echo "<li><strong>$e</strong></li>\n";
207
+        }
208
+
209
+        # a priori ici on pourrait die(), mais il faut laisser la possibilite
210
+        # de forcer malgre tout (pour tester, ou si bug de detection)
211
+        echo "</ul></div>\n";
212
+    }
213 213
 }
214 214
 
215 215
 
@@ -219,24 +219,24 @@  discard block
 block discarded – undo
219 219
  * @note superflu ??
220 220
  */
221 221
 function login_hebergeur() {
222
-	$base_hebergeur = 'localhost'; # par defaut
222
+    $base_hebergeur = 'localhost'; # par defaut
223 223
 
224
-	// Free
225
-	if (preg_match(',(.*)\.free\.fr$,', $_SERVER['SERVER_NAME'], $regs)) {
226
-		$base_hebergeur = 'sql.free.fr';
227
-		$login_hebergeur = $regs[1];
228
-	} else {
229
-		$login_hebergeur = '';
230
-	}
224
+    // Free
225
+    if (preg_match(',(.*)\.free\.fr$,', $_SERVER['SERVER_NAME'], $regs)) {
226
+        $base_hebergeur = 'sql.free.fr';
227
+        $login_hebergeur = $regs[1];
228
+    } else {
229
+        $login_hebergeur = '';
230
+    }
231 231
 
232
-	return array($base_hebergeur, $login_hebergeur);
232
+    return array($base_hebergeur, $login_hebergeur);
233 233
 }
234 234
 
235 235
 
236 236
 // http://code.spip.net/@info_etape
237 237
 function info_etape($titre, $complement = '') {
238
-	return "<h2>" . $titre . "</h2>\n" .
239
-	($complement ? "" . $complement . "\n" : '');
238
+    return "<h2>" . $titre . "</h2>\n" .
239
+    ($complement ? "" . $complement . "\n" : '');
240 240
 }
241 241
 
242 242
 /**
@@ -246,155 +246,155 @@  discard block
 block discarded – undo
246 246
  * @return string Code HTML du bouton
247 247
  **/
248 248
 function bouton_suivant($code = '') {
249
-	if ($code == '') {
250
-		$code = _T('bouton_suivant');
251
-	}
252
-	static $suivant = 0;
253
-	$id = 'suivant' . (($suivant > 0) ? strval($suivant) : '');
254
-	$suivant += 1;
255
-
256
-	return "\n<p class='boutons suivant'><input id='" . $id . "' type='submit'\nvalue=\"" .
257
-	$code .
258
-	" >>\" /></p>\n";
249
+    if ($code == '') {
250
+        $code = _T('bouton_suivant');
251
+    }
252
+    static $suivant = 0;
253
+    $id = 'suivant' . (($suivant > 0) ? strval($suivant) : '');
254
+    $suivant += 1;
255
+
256
+    return "\n<p class='boutons suivant'><input id='" . $id . "' type='submit'\nvalue=\"" .
257
+    $code .
258
+    " >>\" /></p>\n";
259 259
 }
260 260
 
261 261
 // http://code.spip.net/@info_progression_etape
262 262
 function info_progression_etape($en_cours, $phase, $dir, $erreur = false) {
263
-	//$en_cours = _request('etape')?_request('etape'):"";
264
-	$liste = find_all_in_path($dir, $phase . '(([0-9])+|fin)[.]php$');
265
-	$debut = 1;
266
-	$etat = "ok";
267
-	$last = count($liste);
263
+    //$en_cours = _request('etape')?_request('etape'):"";
264
+    $liste = find_all_in_path($dir, $phase . '(([0-9])+|fin)[.]php$');
265
+    $debut = 1;
266
+    $etat = "ok";
267
+    $last = count($liste);
268 268
 //	$texte_etat = array('ok'=>'OK','encours'=>_T('en_cours'),'todo'=>_T('todo'));
269 269
 
270
-	$intitule_etat["etape_"][1] = typo(_T('info_connexion_base_donnee'));
271
-	$intitule_etat["etape_"][2] = typo(_T('menu_aide_installation_choix_base'));
272
-	$intitule_etat["etape_"][3] = typo(_T('info_informations_personnelles'));
273
-	$intitule_etat["etape_"][4] = typo(_T('info_derniere_etape'));
270
+    $intitule_etat["etape_"][1] = typo(_T('info_connexion_base_donnee'));
271
+    $intitule_etat["etape_"][2] = typo(_T('menu_aide_installation_choix_base'));
272
+    $intitule_etat["etape_"][3] = typo(_T('info_informations_personnelles'));
273
+    $intitule_etat["etape_"][4] = typo(_T('info_derniere_etape'));
274 274
 
275
-	$intitule_etat["etape_ldap"][1] = typo(_T('titre_connexion_ldap'));
276
-	$intitule_etat["etape_ldap"][2] = typo(_T('titre_connexion_ldap'));
277
-	$intitule_etat["etape_ldap"][3] = typo(_T('info_chemin_acces_1'));
278
-	$intitule_etat["etape_ldap"][4] = typo(_T('info_reglage_ldap'));
279
-	$intitule_etat["etape_ldap"][5] = typo(_T('info_ldap_ok'));
275
+    $intitule_etat["etape_ldap"][1] = typo(_T('titre_connexion_ldap'));
276
+    $intitule_etat["etape_ldap"][2] = typo(_T('titre_connexion_ldap'));
277
+    $intitule_etat["etape_ldap"][3] = typo(_T('info_chemin_acces_1'));
278
+    $intitule_etat["etape_ldap"][4] = typo(_T('info_reglage_ldap'));
279
+    $intitule_etat["etape_ldap"][5] = typo(_T('info_ldap_ok'));
280 280
 
281 281
 //	$aff_etapes = "<span id='etapes'>";
282 282
 
283
-	$aff_etapes = "<ul id='infos_etapes' class='infos_$phase$en_cours'>";
284
-
285
-	foreach ($liste as $etape => $fichier) {
286
-		if ($debut < $last) {
287
-			if ($debut == $en_cours && $erreur) {
288
-				$class = "on erreur";
289
-			} else {
290
-				if ($debut == $en_cours) {
291
-					$class = "on";
292
-				} else {
293
-					if ($debut > $en_cours) {
294
-						$class = "prochains";
295
-					} else {
296
-						$class = "valides";
297
-					}
298
-				}
299
-			}
300
-
301
-			$aff_etapes .= "<li class='$class'><div class='fond'>";
302
-			$aff_etapes .= ($debut == $en_cours) ? "<strong>" : '';
303
-			$aff_etapes .= "<em>" . _T('etape') . " </em><span class='numero_etape'>$debut</span><em>&nbsp;: </em>";
304
-			$aff_etapes .= $intitule_etat["$phase"][$debut];
305
-			$aff_etapes .= ($debut == $en_cours) ? "</strong>" : '';
306
-			$aff_etapes .= "</div></li>";
307
-		}
308
-		$debut++;
309
-	}
310
-	$aff_etapes .= "</ul>";
311
-	$aff_etapes .= "<br class='nettoyeur' />\n";
312
-
313
-	return $aff_etapes;
283
+    $aff_etapes = "<ul id='infos_etapes' class='infos_$phase$en_cours'>";
284
+
285
+    foreach ($liste as $etape => $fichier) {
286
+        if ($debut < $last) {
287
+            if ($debut == $en_cours && $erreur) {
288
+                $class = "on erreur";
289
+            } else {
290
+                if ($debut == $en_cours) {
291
+                    $class = "on";
292
+                } else {
293
+                    if ($debut > $en_cours) {
294
+                        $class = "prochains";
295
+                    } else {
296
+                        $class = "valides";
297
+                    }
298
+                }
299
+            }
300
+
301
+            $aff_etapes .= "<li class='$class'><div class='fond'>";
302
+            $aff_etapes .= ($debut == $en_cours) ? "<strong>" : '';
303
+            $aff_etapes .= "<em>" . _T('etape') . " </em><span class='numero_etape'>$debut</span><em>&nbsp;: </em>";
304
+            $aff_etapes .= $intitule_etat["$phase"][$debut];
305
+            $aff_etapes .= ($debut == $en_cours) ? "</strong>" : '';
306
+            $aff_etapes .= "</div></li>";
307
+        }
308
+        $debut++;
309
+    }
310
+    $aff_etapes .= "</ul>";
311
+    $aff_etapes .= "<br class='nettoyeur' />\n";
312
+
313
+    return $aff_etapes;
314 314
 }
315 315
 
316 316
 
317 317
 // http://code.spip.net/@fieldset
318 318
 function fieldset($legend, $champs = array(), $apres = '', $avant = '') {
319
-	return "<fieldset>\n" .
320
-	$avant .
321
-	($legend ? "<legend>" . $legend . "</legend>\n" : '') .
322
-	fieldset_champs($champs) .
323
-	$apres .
324
-	"</fieldset>\n";
319
+    return "<fieldset>\n" .
320
+    $avant .
321
+    ($legend ? "<legend>" . $legend . "</legend>\n" : '') .
322
+    fieldset_champs($champs) .
323
+    $apres .
324
+    "</fieldset>\n";
325 325
 }
326 326
 
327 327
 function fieldset_champs($champs = array()) {
328
-	$fieldset = '';
329
-	foreach ($champs as $nom => $contenu) {
330
-		$type = isset($contenu['hidden']) ? 'hidden' : (preg_match(',^pass,', $nom) ? 'password' : 'text');
331
-		$class = isset($contenu['hidden']) ? '' : "class='formo' size='40' ";
332
-		if (isset($contenu['alternatives'])) {
333
-			$fieldset .= $contenu['label'] . "\n";
334
-			foreach ($contenu['alternatives'] as $valeur => $label) {
335
-				$fieldset .= "<input type='radio' name='" . $nom .
336
-					"' id='$nom-$valeur' value='$valeur'"
337
-					. (($valeur == $contenu['valeur']) ? "\nchecked='checked'" : '')
338
-					. "/>\n";
339
-				$fieldset .= "<label for='$nom-$valeur'>" . $label . "</label>\n";
340
-			}
341
-			$fieldset .= "<br />\n";
342
-		} else {
343
-			$fieldset .= "<label for='" . $nom . "'>" . $contenu['label'] . "</label>\n";
344
-			$fieldset .= "<input " . $class . "type='" . $type . "' id='" . $nom . "' name='" . $nom . "'\nvalue='" . $contenu['valeur'] . "'"
345
-				. (preg_match(',^(pass|login),', $nom) ? " autocomplete='off'" : '')
346
-				. ((isset($contenu['required']) and $contenu['required']) ? " required='required'" : "")
347
-				. " />\n";
348
-		}
349
-	}
350
-
351
-	return $fieldset;
328
+    $fieldset = '';
329
+    foreach ($champs as $nom => $contenu) {
330
+        $type = isset($contenu['hidden']) ? 'hidden' : (preg_match(',^pass,', $nom) ? 'password' : 'text');
331
+        $class = isset($contenu['hidden']) ? '' : "class='formo' size='40' ";
332
+        if (isset($contenu['alternatives'])) {
333
+            $fieldset .= $contenu['label'] . "\n";
334
+            foreach ($contenu['alternatives'] as $valeur => $label) {
335
+                $fieldset .= "<input type='radio' name='" . $nom .
336
+                    "' id='$nom-$valeur' value='$valeur'"
337
+                    . (($valeur == $contenu['valeur']) ? "\nchecked='checked'" : '')
338
+                    . "/>\n";
339
+                $fieldset .= "<label for='$nom-$valeur'>" . $label . "</label>\n";
340
+            }
341
+            $fieldset .= "<br />\n";
342
+        } else {
343
+            $fieldset .= "<label for='" . $nom . "'>" . $contenu['label'] . "</label>\n";
344
+            $fieldset .= "<input " . $class . "type='" . $type . "' id='" . $nom . "' name='" . $nom . "'\nvalue='" . $contenu['valeur'] . "'"
345
+                . (preg_match(',^(pass|login),', $nom) ? " autocomplete='off'" : '')
346
+                . ((isset($contenu['required']) and $contenu['required']) ? " required='required'" : "")
347
+                . " />\n";
348
+        }
349
+    }
350
+
351
+    return $fieldset;
352 352
 }
353 353
 
354 354
 function install_select_serveur() {
355
-	$options = array();
356
-	$dir = _DIR_RESTREINT . 'req/';
357
-	$d = opendir($dir);
358
-	if (!$d) {
359
-		return array();
360
-	}
361
-	while (($f = readdir($d)) !== false) {
362
-		if ((preg_match('/^(.*)[.]php$/', $f, $s))
363
-			and is_readable($f = $dir . $f)
364
-		) {
365
-			require_once($f);
366
-			$s = $s[1];
367
-			$v = 'spip_versions_' . $s;
368
-			if (function_exists($v) and $v()) {
369
-				$titre = _T("install_select_type_$s");
370
-				// proposer mysql par defaut si dispo
371
-				$checked = ($s == 'mysql' ? " checked='checked'" : "");
372
-				$options[$s] = "<li><input type='radio' id='$s' value='$s' name='server_db'$checked>"
373
-					. "<label for='$s'>" . ($titre ? $titre : $s) . "</label></li>";
374
-			} else {
375
-				spip_log("$s: portage indisponible");
376
-			}
377
-		}
378
-	}
379
-	sort($options);
380
-
381
-	return $options;
355
+    $options = array();
356
+    $dir = _DIR_RESTREINT . 'req/';
357
+    $d = opendir($dir);
358
+    if (!$d) {
359
+        return array();
360
+    }
361
+    while (($f = readdir($d)) !== false) {
362
+        if ((preg_match('/^(.*)[.]php$/', $f, $s))
363
+            and is_readable($f = $dir . $f)
364
+        ) {
365
+            require_once($f);
366
+            $s = $s[1];
367
+            $v = 'spip_versions_' . $s;
368
+            if (function_exists($v) and $v()) {
369
+                $titre = _T("install_select_type_$s");
370
+                // proposer mysql par defaut si dispo
371
+                $checked = ($s == 'mysql' ? " checked='checked'" : "");
372
+                $options[$s] = "<li><input type='radio' id='$s' value='$s' name='server_db'$checked>"
373
+                    . "<label for='$s'>" . ($titre ? $titre : $s) . "</label></li>";
374
+            } else {
375
+                spip_log("$s: portage indisponible");
376
+            }
377
+        }
378
+    }
379
+    sort($options);
380
+
381
+    return $options;
382 382
 }
383 383
 
384 384
 // http://code.spip.net/@install_connexion_form
385 385
 function install_connexion_form($db, $login, $pass, $predef, $hidden, $etape, $jquery = true) {
386
-	$server_db = (is_string($predef[0])) ? $predef[0] : '';
387
-
388
-	return generer_form_ecrire('install', (
389
-		"\n<input type='hidden' name='etape' value='$etape' />"
390
-		. $hidden
391
-		. (_request('echec') ?
392
-			("<p><b>" . _T('avis_connexion_echec_1') .
393
-				"</b></p><p>" . _T('avis_connexion_echec_2') . "</p><p style='font-size: small;'>" . _T('avis_connexion_echec_3') . "</p>")
394
-			: "")
395
-
396
-		. ($jquery ? http_script('', 'jquery.js') : '')
397
-		. http_script('
386
+    $server_db = (is_string($predef[0])) ? $predef[0] : '';
387
+
388
+    return generer_form_ecrire('install', (
389
+        "\n<input type='hidden' name='etape' value='$etape' />"
390
+        . $hidden
391
+        . (_request('echec') ?
392
+            ("<p><b>" . _T('avis_connexion_echec_1') .
393
+                "</b></p><p>" . _T('avis_connexion_echec_2') . "</p><p style='font-size: small;'>" . _T('avis_connexion_echec_3') . "</p>")
394
+            : "")
395
+
396
+        . ($jquery ? http_script('', 'jquery.js') : '')
397
+        . http_script('
398 398
 		jQuery(function($) {
399 399
 			$("input[type=hidden][name=server_db]").each(function(){
400 400
 				if ($(this).attr("value").match("sqlite*")){
@@ -417,67 +417,67 @@  discard block
 block discarded – undo
417 417
 			});
418 418
 		});')
419 419
 
420
-		. ($server_db
421
-			? '<input type="hidden" name="server_db" value="' . $server_db . '" />'
422
-			. (($predef[0])
423
-				? ('<h3>' . _T('install_serveur_hebergeur') . '</h3>')
424
-				: '')
425
-			: ('<fieldset><legend>'
426
-				. _T('install_select_type_db')
427
-				. "</legend>"
428
-				. '<p class="explication">'
429
-				. _T('install_types_db_connus')
430
-				// Passer l'avertissement SQLIte en  commentaire, on pourra facilement le supprimer par la suite sans changer les traductions.
431
-				// . "<br /><small>(". _T('install_types_db_connus_avertissement') .')</small>'
432
-				. '</p>'
433
-				. "\n<div class='p'>\n<ul>\n"
434
-				. join("\n", install_select_serveur())
435
-				. "\n</ul>\n</div></fieldset>")
436
-		)
437
-		. '<div id="install_adresse_base_hebergeur">'
438
-		. '<p>' . _T('texte_connexion_mysql') . '</p>'
439
-		. ($predef[1]
440
-			? '<h3>' . _T('install_adresse_base_hebergeur') . '</h3>'
441
-			: fieldset(_T('entree_base_donnee_1'),
442
-				array(
443
-					'adresse_db' => array(
444
-						'label' => $db[1],
445
-						'valeur' => $db[0]
446
-					),
447
-				)
448
-			)
449
-		)
450
-		. '</div>'
451
-
452
-		. '<div id="install_login_base_hebergeur">'
453
-		. ($predef[2]
454
-			? '<h3>' . _T('install_login_base_hebergeur') . '</h3>'
455
-			: fieldset(_T('entree_login_connexion_1'),
456
-				array(
457
-					'login_db' => array(
458
-						'label' => $login[1],
459
-						'valeur' => $login[0]
460
-					),
461
-				)
462
-			)
463
-		)
464
-		. '</div>'
465
-
466
-		. '<div id="install_pass_base_hebergeur">'
467
-		. ($predef[3]
468
-			? '<h3>' . _T('install_pass_base_hebergeur') . '</h3>'
469
-			: fieldset(_T('entree_mot_passe_1'),
470
-				array(
471
-					'pass_db' => array(
472
-						'label' => $pass[1],
473
-						'valeur' => $pass[0]
474
-					),
475
-				)
476
-			)
477
-		)
478
-		. '</div>'
479
-
480
-		. bouton_suivant()));
420
+        . ($server_db
421
+            ? '<input type="hidden" name="server_db" value="' . $server_db . '" />'
422
+            . (($predef[0])
423
+                ? ('<h3>' . _T('install_serveur_hebergeur') . '</h3>')
424
+                : '')
425
+            : ('<fieldset><legend>'
426
+                . _T('install_select_type_db')
427
+                . "</legend>"
428
+                . '<p class="explication">'
429
+                . _T('install_types_db_connus')
430
+                // Passer l'avertissement SQLIte en  commentaire, on pourra facilement le supprimer par la suite sans changer les traductions.
431
+                // . "<br /><small>(". _T('install_types_db_connus_avertissement') .')</small>'
432
+                . '</p>'
433
+                . "\n<div class='p'>\n<ul>\n"
434
+                . join("\n", install_select_serveur())
435
+                . "\n</ul>\n</div></fieldset>")
436
+        )
437
+        . '<div id="install_adresse_base_hebergeur">'
438
+        . '<p>' . _T('texte_connexion_mysql') . '</p>'
439
+        . ($predef[1]
440
+            ? '<h3>' . _T('install_adresse_base_hebergeur') . '</h3>'
441
+            : fieldset(_T('entree_base_donnee_1'),
442
+                array(
443
+                    'adresse_db' => array(
444
+                        'label' => $db[1],
445
+                        'valeur' => $db[0]
446
+                    ),
447
+                )
448
+            )
449
+        )
450
+        . '</div>'
451
+
452
+        . '<div id="install_login_base_hebergeur">'
453
+        . ($predef[2]
454
+            ? '<h3>' . _T('install_login_base_hebergeur') . '</h3>'
455
+            : fieldset(_T('entree_login_connexion_1'),
456
+                array(
457
+                    'login_db' => array(
458
+                        'label' => $login[1],
459
+                        'valeur' => $login[0]
460
+                    ),
461
+                )
462
+            )
463
+        )
464
+        . '</div>'
465
+
466
+        . '<div id="install_pass_base_hebergeur">'
467
+        . ($predef[3]
468
+            ? '<h3>' . _T('install_pass_base_hebergeur') . '</h3>'
469
+            : fieldset(_T('entree_mot_passe_1'),
470
+                array(
471
+                    'pass_db' => array(
472
+                        'label' => $pass[1],
473
+                        'valeur' => $pass[0]
474
+                    ),
475
+                )
476
+            )
477
+        )
478
+        . '</div>'
479
+
480
+        . bouton_suivant()));
481 481
 
482 482
 }
483 483
 
@@ -486,75 +486,75 @@  discard block
 block discarded – undo
486 486
 
487 487
 // http://code.spip.net/@predef_ou_cache
488 488
 function predef_ou_cache($adresse_db, $login_db, $pass_db, $server_db) {
489
-	return ((defined('_INSTALL_HOST_DB'))
490
-		? ''
491
-		: "\n<input type='hidden' name='adresse_db'  value=\"" . spip_htmlspecialchars($adresse_db) . "\" />"
492
-	)
493
-	. ((defined('_INSTALL_USER_DB'))
494
-		? ''
495
-		: "\n<input type='hidden' name='login_db' value=\"" . spip_htmlspecialchars($login_db) . "\" />"
496
-	)
497
-	. ((defined('_INSTALL_PASS_DB'))
498
-		? ''
499
-		: "\n<input type='hidden' name='pass_db' value=\"" . spip_htmlspecialchars($pass_db) . "\" />"
500
-	)
501
-
502
-	. ((defined('_INSTALL_SERVER_DB'))
503
-		? ''
504
-		: "\n<input type='hidden' name='server_db' value=\"" . spip_htmlspecialchars($server_db) . "\" />"
505
-	);
489
+    return ((defined('_INSTALL_HOST_DB'))
490
+        ? ''
491
+        : "\n<input type='hidden' name='adresse_db'  value=\"" . spip_htmlspecialchars($adresse_db) . "\" />"
492
+    )
493
+    . ((defined('_INSTALL_USER_DB'))
494
+        ? ''
495
+        : "\n<input type='hidden' name='login_db' value=\"" . spip_htmlspecialchars($login_db) . "\" />"
496
+    )
497
+    . ((defined('_INSTALL_PASS_DB'))
498
+        ? ''
499
+        : "\n<input type='hidden' name='pass_db' value=\"" . spip_htmlspecialchars($pass_db) . "\" />"
500
+    )
501
+
502
+    . ((defined('_INSTALL_SERVER_DB'))
503
+        ? ''
504
+        : "\n<input type='hidden' name='server_db' value=\"" . spip_htmlspecialchars($server_db) . "\" />"
505
+    );
506 506
 }
507 507
 
508 508
 // presentation des bases existantes
509 509
 
510 510
 // http://code.spip.net/@install_etape_liste_bases
511 511
 function install_etape_liste_bases($server_db, $login_db, $disabled = array()) {
512
-	$bases = $checked = array();
513
-	$noms = sql_listdbs($server_db);
514
-	if (!$noms) {
515
-		return '';
516
-	}
517
-
518
-	foreach ($noms as $nom) {
519
-		$id = spip_htmlspecialchars($nom);
520
-		$dis = in_array($nom, $disabled) ? " disabled='disabled'" : '';
521
-		$base = " name=\"choix_db\" value=\""
522
-			. $nom
523
-			. '"'
524
-			. $dis
525
-			. " type='radio' id='$id'";
526
-		$label = "<label for='$id'>"
527
-			. ($dis ? "<i>$nom</i>" : $nom)
528
-			. "</label>";
529
-
530
-		if (!$checked and !$dis and
531
-			(($nom == $login_db) or
532
-				($GLOBALS['table_prefix'] == $nom))
533
-		) {
534
-			$checked = "<input$base checked='checked' />\n$label";
535
-		} else {
536
-			$bases[] = "<input$base />\n$label";
537
-		}
538
-	}
539
-
540
-	if (!$bases && !$checked) {
541
-		return false;
542
-	}
543
-
544
-	if ($checked) {
545
-		array_unshift($bases, $checked);
546
-		$checked = true;
547
-	}
548
-
549
-	return array($checked, $bases);
512
+    $bases = $checked = array();
513
+    $noms = sql_listdbs($server_db);
514
+    if (!$noms) {
515
+        return '';
516
+    }
517
+
518
+    foreach ($noms as $nom) {
519
+        $id = spip_htmlspecialchars($nom);
520
+        $dis = in_array($nom, $disabled) ? " disabled='disabled'" : '';
521
+        $base = " name=\"choix_db\" value=\""
522
+            . $nom
523
+            . '"'
524
+            . $dis
525
+            . " type='radio' id='$id'";
526
+        $label = "<label for='$id'>"
527
+            . ($dis ? "<i>$nom</i>" : $nom)
528
+            . "</label>";
529
+
530
+        if (!$checked and !$dis and
531
+            (($nom == $login_db) or
532
+                ($GLOBALS['table_prefix'] == $nom))
533
+        ) {
534
+            $checked = "<input$base checked='checked' />\n$label";
535
+        } else {
536
+            $bases[] = "<input$base />\n$label";
537
+        }
538
+    }
539
+
540
+    if (!$bases && !$checked) {
541
+        return false;
542
+    }
543
+
544
+    if ($checked) {
545
+        array_unshift($bases, $checked);
546
+        $checked = true;
547
+    }
548
+
549
+    return array($checked, $bases);
550 550
 }
551 551
 
552 552
 function install_propager($hidden) {
553
-	$res = '';
554
-	foreach ($hidden as $k) {
555
-		$v = spip_htmlentities(_request($k));
556
-		$res .= "<input type='hidden' name='$k' value='$v' />";
557
-	}
553
+    $res = '';
554
+    foreach ($hidden as $k) {
555
+        $v = spip_htmlentities(_request($k));
556
+        $res .= "<input type='hidden' name='$k' value='$v' />";
557
+    }
558 558
 
559
-	return $res;
559
+    return $res;
560 560
 }
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -43,10 +43,10 @@  discard block
 block discarded – undo
43 43
  * @return void
44 44
  **/
45 45
 function install_fichier_connexion($nom, $texte) {
46
-	$texte = "<" . "?php\n"
46
+	$texte = "<"."?php\n"
47 47
 		. "if (!defined(\"_ECRIRE_INC_VERSION\")) return;\n"
48 48
 		. $texte
49
-		. "?" . ">";
49
+		. "?".">";
50 50
 
51 51
 	ecrire_fichier($nom, $texte);
52 52
 }
@@ -113,10 +113,10 @@  discard block
 block discarded – undo
113 113
 		return $regs;
114 114
 	} else {
115 115
 		$ar = '\s*\'([^\']*)\'';
116
-		$r = '\s*,' . $ar;
116
+		$r = '\s*,'.$ar;
117 117
 		$r = "#spip_connect_db[(]$ar$r$r$r$r(?:$r(?:$r(?:$r(?:$r)?)?)?)?#";
118 118
 		if (preg_match($r, $s, $regs)) {
119
-			$regs[2] = $regs[1] . (!$regs[2] ? '' : ":" . $regs[2] . ";");
119
+			$regs[2] = $regs[1].(!$regs[2] ? '' : ":".$regs[2].";");
120 120
 			array_shift($regs);
121 121
 			array_shift($regs);
122 122
 
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 	// Si on n'a pas la bonne version de PHP, c'est la fin
175 175
 	if ($err) {
176 176
 		die("<div class='error'>"
177
-			. "<h3>" . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>"
177
+			. "<h3>"._T('avis_attention').'</h3><p>'._T('install_echec_annonce')."</p><ul class='spip'>"
178 178
 			. "<li><strong>{$err[0]}</strong></li>\n</ul></div>");
179 179
 	}
180 180
 
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 
202 202
 	if ($err) {
203 203
 		echo "<div class='error'>"
204
-			. "<h3>" . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>";
204
+			. "<h3>"._T('avis_attention').'</h3><p>'._T('install_echec_annonce')."</p><ul class='spip'>";
205 205
 		foreach ($err as $e) {
206 206
 			echo "<li><strong>$e</strong></li>\n";
207 207
 		}
@@ -235,8 +235,8 @@  discard block
 block discarded – undo
235 235
 
236 236
 // http://code.spip.net/@info_etape
237 237
 function info_etape($titre, $complement = '') {
238
-	return "<h2>" . $titre . "</h2>\n" .
239
-	($complement ? "" . $complement . "\n" : '');
238
+	return "<h2>".$titre."</h2>\n".
239
+	($complement ? "".$complement."\n" : '');
240 240
 }
241 241
 
242 242
 /**
@@ -250,18 +250,18 @@  discard block
 block discarded – undo
250 250
 		$code = _T('bouton_suivant');
251 251
 	}
252 252
 	static $suivant = 0;
253
-	$id = 'suivant' . (($suivant > 0) ? strval($suivant) : '');
253
+	$id = 'suivant'.(($suivant > 0) ? strval($suivant) : '');
254 254
 	$suivant += 1;
255 255
 
256
-	return "\n<p class='boutons suivant'><input id='" . $id . "' type='submit'\nvalue=\"" .
257
-	$code .
256
+	return "\n<p class='boutons suivant'><input id='".$id."' type='submit'\nvalue=\"".
257
+	$code.
258 258
 	" >>\" /></p>\n";
259 259
 }
260 260
 
261 261
 // http://code.spip.net/@info_progression_etape
262 262
 function info_progression_etape($en_cours, $phase, $dir, $erreur = false) {
263 263
 	//$en_cours = _request('etape')?_request('etape'):"";
264
-	$liste = find_all_in_path($dir, $phase . '(([0-9])+|fin)[.]php$');
264
+	$liste = find_all_in_path($dir, $phase.'(([0-9])+|fin)[.]php$');
265 265
 	$debut = 1;
266 266
 	$etat = "ok";
267 267
 	$last = count($liste);
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 
301 301
 			$aff_etapes .= "<li class='$class'><div class='fond'>";
302 302
 			$aff_etapes .= ($debut == $en_cours) ? "<strong>" : '';
303
-			$aff_etapes .= "<em>" . _T('etape') . " </em><span class='numero_etape'>$debut</span><em>&nbsp;: </em>";
303
+			$aff_etapes .= "<em>"._T('etape')." </em><span class='numero_etape'>$debut</span><em>&nbsp;: </em>";
304 304
 			$aff_etapes .= $intitule_etat["$phase"][$debut];
305 305
 			$aff_etapes .= ($debut == $en_cours) ? "</strong>" : '';
306 306
 			$aff_etapes .= "</div></li>";
@@ -316,11 +316,11 @@  discard block
 block discarded – undo
316 316
 
317 317
 // http://code.spip.net/@fieldset
318 318
 function fieldset($legend, $champs = array(), $apres = '', $avant = '') {
319
-	return "<fieldset>\n" .
320
-	$avant .
321
-	($legend ? "<legend>" . $legend . "</legend>\n" : '') .
322
-	fieldset_champs($champs) .
323
-	$apres .
319
+	return "<fieldset>\n".
320
+	$avant.
321
+	($legend ? "<legend>".$legend."</legend>\n" : '').
322
+	fieldset_champs($champs).
323
+	$apres.
324 324
 	"</fieldset>\n";
325 325
 }
326 326
 
@@ -330,18 +330,18 @@  discard block
 block discarded – undo
330 330
 		$type = isset($contenu['hidden']) ? 'hidden' : (preg_match(',^pass,', $nom) ? 'password' : 'text');
331 331
 		$class = isset($contenu['hidden']) ? '' : "class='formo' size='40' ";
332 332
 		if (isset($contenu['alternatives'])) {
333
-			$fieldset .= $contenu['label'] . "\n";
333
+			$fieldset .= $contenu['label']."\n";
334 334
 			foreach ($contenu['alternatives'] as $valeur => $label) {
335
-				$fieldset .= "<input type='radio' name='" . $nom .
335
+				$fieldset .= "<input type='radio' name='".$nom.
336 336
 					"' id='$nom-$valeur' value='$valeur'"
337 337
 					. (($valeur == $contenu['valeur']) ? "\nchecked='checked'" : '')
338 338
 					. "/>\n";
339
-				$fieldset .= "<label for='$nom-$valeur'>" . $label . "</label>\n";
339
+				$fieldset .= "<label for='$nom-$valeur'>".$label."</label>\n";
340 340
 			}
341 341
 			$fieldset .= "<br />\n";
342 342
 		} else {
343
-			$fieldset .= "<label for='" . $nom . "'>" . $contenu['label'] . "</label>\n";
344
-			$fieldset .= "<input " . $class . "type='" . $type . "' id='" . $nom . "' name='" . $nom . "'\nvalue='" . $contenu['valeur'] . "'"
343
+			$fieldset .= "<label for='".$nom."'>".$contenu['label']."</label>\n";
344
+			$fieldset .= "<input ".$class."type='".$type."' id='".$nom."' name='".$nom."'\nvalue='".$contenu['valeur']."'"
345 345
 				. (preg_match(',^(pass|login),', $nom) ? " autocomplete='off'" : '')
346 346
 				. ((isset($contenu['required']) and $contenu['required']) ? " required='required'" : "")
347 347
 				. " />\n";
@@ -353,24 +353,24 @@  discard block
 block discarded – undo
353 353
 
354 354
 function install_select_serveur() {
355 355
 	$options = array();
356
-	$dir = _DIR_RESTREINT . 'req/';
356
+	$dir = _DIR_RESTREINT.'req/';
357 357
 	$d = opendir($dir);
358 358
 	if (!$d) {
359 359
 		return array();
360 360
 	}
361 361
 	while (($f = readdir($d)) !== false) {
362 362
 		if ((preg_match('/^(.*)[.]php$/', $f, $s))
363
-			and is_readable($f = $dir . $f)
363
+			and is_readable($f = $dir.$f)
364 364
 		) {
365 365
 			require_once($f);
366 366
 			$s = $s[1];
367
-			$v = 'spip_versions_' . $s;
367
+			$v = 'spip_versions_'.$s;
368 368
 			if (function_exists($v) and $v()) {
369 369
 				$titre = _T("install_select_type_$s");
370 370
 				// proposer mysql par defaut si dispo
371 371
 				$checked = ($s == 'mysql' ? " checked='checked'" : "");
372 372
 				$options[$s] = "<li><input type='radio' id='$s' value='$s' name='server_db'$checked>"
373
-					. "<label for='$s'>" . ($titre ? $titre : $s) . "</label></li>";
373
+					. "<label for='$s'>".($titre ? $titre : $s)."</label></li>";
374 374
 			} else {
375 375
 				spip_log("$s: portage indisponible");
376 376
 			}
@@ -389,8 +389,8 @@  discard block
 block discarded – undo
389 389
 		"\n<input type='hidden' name='etape' value='$etape' />"
390 390
 		. $hidden
391 391
 		. (_request('echec') ?
392
-			("<p><b>" . _T('avis_connexion_echec_1') .
393
-				"</b></p><p>" . _T('avis_connexion_echec_2') . "</p><p style='font-size: small;'>" . _T('avis_connexion_echec_3') . "</p>")
392
+			("<p><b>"._T('avis_connexion_echec_1').
393
+				"</b></p><p>"._T('avis_connexion_echec_2')."</p><p style='font-size: small;'>"._T('avis_connexion_echec_3')."</p>")
394 394
 			: "")
395 395
 
396 396
 		. ($jquery ? http_script('', 'jquery.js') : '')
@@ -418,9 +418,9 @@  discard block
 block discarded – undo
418 418
 		});')
419 419
 
420 420
 		. ($server_db
421
-			? '<input type="hidden" name="server_db" value="' . $server_db . '" />'
421
+			? '<input type="hidden" name="server_db" value="'.$server_db.'" />'
422 422
 			. (($predef[0])
423
-				? ('<h3>' . _T('install_serveur_hebergeur') . '</h3>')
423
+				? ('<h3>'._T('install_serveur_hebergeur').'</h3>')
424 424
 				: '')
425 425
 			: ('<fieldset><legend>'
426 426
 				. _T('install_select_type_db')
@@ -435,9 +435,9 @@  discard block
 block discarded – undo
435 435
 				. "\n</ul>\n</div></fieldset>")
436 436
 		)
437 437
 		. '<div id="install_adresse_base_hebergeur">'
438
-		. '<p>' . _T('texte_connexion_mysql') . '</p>'
438
+		. '<p>'._T('texte_connexion_mysql').'</p>'
439 439
 		. ($predef[1]
440
-			? '<h3>' . _T('install_adresse_base_hebergeur') . '</h3>'
440
+			? '<h3>'._T('install_adresse_base_hebergeur').'</h3>'
441 441
 			: fieldset(_T('entree_base_donnee_1'),
442 442
 				array(
443 443
 					'adresse_db' => array(
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 
452 452
 		. '<div id="install_login_base_hebergeur">'
453 453
 		. ($predef[2]
454
-			? '<h3>' . _T('install_login_base_hebergeur') . '</h3>'
454
+			? '<h3>'._T('install_login_base_hebergeur').'</h3>'
455 455
 			: fieldset(_T('entree_login_connexion_1'),
456 456
 				array(
457 457
 					'login_db' => array(
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
 
466 466
 		. '<div id="install_pass_base_hebergeur">'
467 467
 		. ($predef[3]
468
-			? '<h3>' . _T('install_pass_base_hebergeur') . '</h3>'
468
+			? '<h3>'._T('install_pass_base_hebergeur').'</h3>'
469 469
 			: fieldset(_T('entree_mot_passe_1'),
470 470
 				array(
471 471
 					'pass_db' => array(
@@ -488,20 +488,20 @@  discard block
 block discarded – undo
488 488
 function predef_ou_cache($adresse_db, $login_db, $pass_db, $server_db) {
489 489
 	return ((defined('_INSTALL_HOST_DB'))
490 490
 		? ''
491
-		: "\n<input type='hidden' name='adresse_db'  value=\"" . spip_htmlspecialchars($adresse_db) . "\" />"
491
+		: "\n<input type='hidden' name='adresse_db'  value=\"".spip_htmlspecialchars($adresse_db)."\" />"
492 492
 	)
493 493
 	. ((defined('_INSTALL_USER_DB'))
494 494
 		? ''
495
-		: "\n<input type='hidden' name='login_db' value=\"" . spip_htmlspecialchars($login_db) . "\" />"
495
+		: "\n<input type='hidden' name='login_db' value=\"".spip_htmlspecialchars($login_db)."\" />"
496 496
 	)
497 497
 	. ((defined('_INSTALL_PASS_DB'))
498 498
 		? ''
499
-		: "\n<input type='hidden' name='pass_db' value=\"" . spip_htmlspecialchars($pass_db) . "\" />"
499
+		: "\n<input type='hidden' name='pass_db' value=\"".spip_htmlspecialchars($pass_db)."\" />"
500 500
 	)
501 501
 
502 502
 	. ((defined('_INSTALL_SERVER_DB'))
503 503
 		? ''
504
-		: "\n<input type='hidden' name='server_db' value=\"" . spip_htmlspecialchars($server_db) . "\" />"
504
+		: "\n<input type='hidden' name='server_db' value=\"".spip_htmlspecialchars($server_db)."\" />"
505 505
 	);
506 506
 }
507 507
 
Please login to merge, or discard this patch.
ecrire/inc/math.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -21,6 +21,9 @@
 block discarded – undo
21 21
 //
22 22
 
23 23
 // http://code.spip.net/@image_math
24
+/**
25
+ * @param string $tex
26
+ */
24 27
 function produire_image_math($tex) {
25 28
 
26 29
 	switch ($GLOBALS['traiter_math']) {
Please login to merge, or discard this patch.
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 
14 14
 //
15 15
 if (!defined('_ECRIRE_INC_VERSION')) {
16
-	return;
16
+    return;
17 17
 }
18 18
 
19 19
 //
@@ -23,56 +23,56 @@  discard block
 block discarded – undo
23 23
 // http://code.spip.net/@image_math
24 24
 function produire_image_math($tex) {
25 25
 
26
-	switch ($GLOBALS['traiter_math']) {
27
-		// Attention: mathml desactiv'e pour l'instant
28
-		case 'mathml':
29
-			$ext = '.xhtml';
30
-			$server = $GLOBALS['mathml_server'];
31
-			break;
32
-		case 'tex':
33
-			$ext = '.png';
34
-			$server = $GLOBALS['tex_server'];
35
-			break;
36
-		default:
37
-			return $tex;
38
-	}
39
-
40
-	// Regarder dans le repertoire local des images TeX et blocs MathML
41
-	if (!@is_dir($dir_tex = _DIR_VAR . 'cache-TeX/')) {
42
-		@mkdir($dir_tex, _SPIP_CHMOD);
43
-	}
44
-	$fichier = $dir_tex . md5(trim($tex)) . $ext;
45
-
46
-
47
-	if (!@file_exists($fichier)) {
48
-		// Aller chercher l'image sur le serveur
49
-		if ($server) {
50
-			spip_log($url = $server . '?' . rawurlencode($tex));
51
-			include_spip('inc/distant');
52
-			recuperer_page($url, $fichier);
53
-		}
54
-	}
55
-
56
-
57
-	// Composer la reponse selon presence ou non de l'image
58
-	$tex = entites_html($tex);
59
-	if (@file_exists($fichier)) {
60
-
61
-		// MathML
62
-		if ($GLOBALS['traiter_math'] == 'mathml') {
63
-			return join(file("$fichier"), "");
64
-		} // TeX
65
-		else {
66
-			list(, , , $size) = @spip_getimagesize($fichier);
67
-			$alt = "alt=\"$tex\" title=\"$tex\"";
68
-
69
-			return "<img src=\"$fichier\" style=\"vertical-align:middle;\" $size $alt />";
70
-		}
71
-
72
-	} else // pas de fichier
73
-	{
74
-		return "<tt><span class='spip_code' dir='ltr'>$tex</span></tt>";
75
-	}
26
+    switch ($GLOBALS['traiter_math']) {
27
+        // Attention: mathml desactiv'e pour l'instant
28
+        case 'mathml':
29
+            $ext = '.xhtml';
30
+            $server = $GLOBALS['mathml_server'];
31
+            break;
32
+        case 'tex':
33
+            $ext = '.png';
34
+            $server = $GLOBALS['tex_server'];
35
+            break;
36
+        default:
37
+            return $tex;
38
+    }
39
+
40
+    // Regarder dans le repertoire local des images TeX et blocs MathML
41
+    if (!@is_dir($dir_tex = _DIR_VAR . 'cache-TeX/')) {
42
+        @mkdir($dir_tex, _SPIP_CHMOD);
43
+    }
44
+    $fichier = $dir_tex . md5(trim($tex)) . $ext;
45
+
46
+
47
+    if (!@file_exists($fichier)) {
48
+        // Aller chercher l'image sur le serveur
49
+        if ($server) {
50
+            spip_log($url = $server . '?' . rawurlencode($tex));
51
+            include_spip('inc/distant');
52
+            recuperer_page($url, $fichier);
53
+        }
54
+    }
55
+
56
+
57
+    // Composer la reponse selon presence ou non de l'image
58
+    $tex = entites_html($tex);
59
+    if (@file_exists($fichier)) {
60
+
61
+        // MathML
62
+        if ($GLOBALS['traiter_math'] == 'mathml') {
63
+            return join(file("$fichier"), "");
64
+        } // TeX
65
+        else {
66
+            list(, , , $size) = @spip_getimagesize($fichier);
67
+            $alt = "alt=\"$tex\" title=\"$tex\"";
68
+
69
+            return "<img src=\"$fichier\" style=\"vertical-align:middle;\" $size $alt />";
70
+        }
71
+
72
+    } else // pas de fichier
73
+    {
74
+        return "<tt><span class='spip_code' dir='ltr'>$tex</span></tt>";
75
+    }
76 76
 
77 77
 }
78 78
 
@@ -108,46 +108,46 @@  discard block
 block discarded – undo
108 108
  */
109 109
 function traiter_math($letexte, $source = '', $defaire_amp = false) {
110 110
 
111
-	$texte_a_voir = $letexte;
112
-	while (($debut = strpos($texte_a_voir, "<math>")) !== false) {
113
-		if (!$fin = strpos($texte_a_voir, "</math>")) {
114
-			$fin = strlen($texte_a_voir);
115
-		}
116
-
117
-		$texte_debut = substr($texte_a_voir, 0, $debut);
118
-		$texte_milieu = substr($texte_a_voir,
119
-			$debut + strlen("<math>"), $fin - $debut - strlen("<math>"));
120
-		$texte_fin = substr($texte_a_voir,
121
-			$fin + strlen("</math>"), strlen($texte_a_voir));
122
-
123
-		// Les doubles $$x^2$$ en mode 'div'
124
-		while ((preg_match(",[$][$]([^$]+)[$][$],", $texte_milieu, $regs))) {
125
-			$expression = $regs[1];
126
-			if ($defaire_amp) {
127
-				$expression = str_replace('&amp;', '&', $expression);
128
-			}
129
-			$echap = "\n<p class=\"spip\" style=\"text-align: center;\">" . produire_image_math($expression) . "</p>\n";
130
-			$pos = strpos($texte_milieu, $regs[0]);
131
-			$texte_milieu = substr($texte_milieu, 0, $pos)
132
-				. code_echappement($echap, $source)
133
-				. substr($texte_milieu, $pos + strlen($regs[0]));
134
-		}
135
-
136
-		// Les simples $x^2$ en mode 'span'
137
-		while ((preg_match(",[$]([^$]+)[$],", $texte_milieu, $regs))) {
138
-			$expression = $regs[1];
139
-			if ($defaire_amp) {
140
-				$expression = str_replace('&amp;', '&', $expression);
141
-			}
142
-			$echap = produire_image_math($expression);
143
-			$pos = strpos($texte_milieu, $regs[0]);
144
-			$texte_milieu = substr($texte_milieu, 0, $pos)
145
-				. code_echappement($echap, $source)
146
-				. substr($texte_milieu, $pos + strlen($regs[0]));
147
-		}
148
-
149
-		$texte_a_voir = $texte_debut . $texte_milieu . $texte_fin;
150
-	}
151
-
152
-	return $texte_a_voir;
111
+    $texte_a_voir = $letexte;
112
+    while (($debut = strpos($texte_a_voir, "<math>")) !== false) {
113
+        if (!$fin = strpos($texte_a_voir, "</math>")) {
114
+            $fin = strlen($texte_a_voir);
115
+        }
116
+
117
+        $texte_debut = substr($texte_a_voir, 0, $debut);
118
+        $texte_milieu = substr($texte_a_voir,
119
+            $debut + strlen("<math>"), $fin - $debut - strlen("<math>"));
120
+        $texte_fin = substr($texte_a_voir,
121
+            $fin + strlen("</math>"), strlen($texte_a_voir));
122
+
123
+        // Les doubles $$x^2$$ en mode 'div'
124
+        while ((preg_match(",[$][$]([^$]+)[$][$],", $texte_milieu, $regs))) {
125
+            $expression = $regs[1];
126
+            if ($defaire_amp) {
127
+                $expression = str_replace('&amp;', '&', $expression);
128
+            }
129
+            $echap = "\n<p class=\"spip\" style=\"text-align: center;\">" . produire_image_math($expression) . "</p>\n";
130
+            $pos = strpos($texte_milieu, $regs[0]);
131
+            $texte_milieu = substr($texte_milieu, 0, $pos)
132
+                . code_echappement($echap, $source)
133
+                . substr($texte_milieu, $pos + strlen($regs[0]));
134
+        }
135
+
136
+        // Les simples $x^2$ en mode 'span'
137
+        while ((preg_match(",[$]([^$]+)[$],", $texte_milieu, $regs))) {
138
+            $expression = $regs[1];
139
+            if ($defaire_amp) {
140
+                $expression = str_replace('&amp;', '&', $expression);
141
+            }
142
+            $echap = produire_image_math($expression);
143
+            $pos = strpos($texte_milieu, $regs[0]);
144
+            $texte_milieu = substr($texte_milieu, 0, $pos)
145
+                . code_echappement($echap, $source)
146
+                . substr($texte_milieu, $pos + strlen($regs[0]));
147
+        }
148
+
149
+        $texte_a_voir = $texte_debut . $texte_milieu . $texte_fin;
150
+    }
151
+
152
+    return $texte_a_voir;
153 153
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -38,16 +38,16 @@  discard block
 block discarded – undo
38 38
 	}
39 39
 
40 40
 	// Regarder dans le repertoire local des images TeX et blocs MathML
41
-	if (!@is_dir($dir_tex = _DIR_VAR . 'cache-TeX/')) {
41
+	if (!@is_dir($dir_tex = _DIR_VAR.'cache-TeX/')) {
42 42
 		@mkdir($dir_tex, _SPIP_CHMOD);
43 43
 	}
44
-	$fichier = $dir_tex . md5(trim($tex)) . $ext;
44
+	$fichier = $dir_tex.md5(trim($tex)).$ext;
45 45
 
46 46
 
47 47
 	if (!@file_exists($fichier)) {
48 48
 		// Aller chercher l'image sur le serveur
49 49
 		if ($server) {
50
-			spip_log($url = $server . '?' . rawurlencode($tex));
50
+			spip_log($url = $server.'?'.rawurlencode($tex));
51 51
 			include_spip('inc/distant');
52 52
 			recuperer_page($url, $fichier);
53 53
 		}
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 			return join(file("$fichier"), "");
64 64
 		} // TeX
65 65
 		else {
66
-			list(, , , $size) = @spip_getimagesize($fichier);
66
+			list(,,, $size) = @spip_getimagesize($fichier);
67 67
 			$alt = "alt=\"$tex\" title=\"$tex\"";
68 68
 
69 69
 			return "<img src=\"$fichier\" style=\"vertical-align:middle;\" $size $alt />";
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 			if ($defaire_amp) {
127 127
 				$expression = str_replace('&amp;', '&', $expression);
128 128
 			}
129
-			$echap = "\n<p class=\"spip\" style=\"text-align: center;\">" . produire_image_math($expression) . "</p>\n";
129
+			$echap = "\n<p class=\"spip\" style=\"text-align: center;\">".produire_image_math($expression)."</p>\n";
130 130
 			$pos = strpos($texte_milieu, $regs[0]);
131 131
 			$texte_milieu = substr($texte_milieu, 0, $pos)
132 132
 				. code_echappement($echap, $source)
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 				. substr($texte_milieu, $pos + strlen($regs[0]));
147 147
 		}
148 148
 
149
-		$texte_a_voir = $texte_debut . $texte_milieu . $texte_fin;
149
+		$texte_a_voir = $texte_debut.$texte_milieu.$texte_fin;
150 150
 	}
151 151
 
152 152
 	return $texte_a_voir;
Please login to merge, or discard this patch.
ecrire/inc/plugin.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -623,11 +623,11 @@
 block discarded – undo
623 623
  * 
624 624
  * @param $liste
625 625
  *    Liste de description des plugins
626
- * @param $nom
626
+ * @param string $nom
627 627
  *    Le plugin donc on cherche la presence
628 628
  * @param $intervalle
629 629
  *    L'éventuelle intervalle de compatibilité de la dépendance. ex: [1.1.0;]
630
- * @param $balise
630
+ * @param string $balise
631 631
  *    Permet de définir si on teste un utilise ou un nécessite
632 632
  * @return string.
633 633
  *    Vide si ok,
Please login to merge, or discard this patch.
Spacing   +43 added lines, -43 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.
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
 				if ($dir) {
371 371
 					$dir .= "/";
372 372
 				}
373
-				$dir .= "procure:" . $procure['nom'];
373
+				$dir .= "procure:".$procure['nom'];
374 374
 
375 375
 				$procure['etat'] = '?';
376 376
 				$procure['dir_type'] = $resume['dir_type'];
@@ -551,7 +551,7 @@  discard block
 block discarded – undo
551 551
 		$plug = $resume['dir'];
552 552
 		$k = $infos[$dir_type][$plug];
553 553
 
554
-		$plug = constant($dir_type) . $plug;
554
+		$plug = constant($dir_type).$plug;
555 555
 		if (!isset($msg[$p])) {
556 556
 			if (isset($resume['erreur']) and $resume['erreur']) {
557 557
 				$msg[$p] = array($resume['erreur']);
@@ -594,10 +594,10 @@  discard block
 block discarded – undo
594 594
 		$list = $raw ? array() : $GLOBALS['meta']['plugin_erreur_activation'];
595 595
 	} elseif (!$raw) {
596 596
 		foreach ($list as $plug => $msg) {
597
-			$list[$plug] = "<li>" . _T('plugin_impossible_activer', array('plugin' => $plug))
598
-				. "<ul><li>" . implode("</li><li>", $msg) . "</li></ul></li>";
597
+			$list[$plug] = "<li>"._T('plugin_impossible_activer', array('plugin' => $plug))
598
+				. "<ul><li>".implode("</li><li>", $msg)."</li></ul></li>";
599 599
 		}
600
-		$list = "<ul>" . join("\n", $list) . "</ul>";
600
+		$list = "<ul>".join("\n", $list)."</ul>";
601 601
 	}
602 602
 	if ($raz) {
603 603
 		effacer_meta('plugin_erreur_activation');
@@ -708,13 +708,13 @@  discard block
 block discarded – undo
708 708
 			if ($minimum_inclus and spip_version_compare($version, $minimum, '<')) {
709 709
 				return _T("plugin_${balise}_${type}", array(
710 710
 					'plugin' => $nom,
711
-					'version' => ' &ge; ' . $minimum
711
+					'version' => ' &ge; '.$minimum
712 712
 				));
713 713
 			}
714 714
 			if (!$minimum_inclus and spip_version_compare($version, $minimum, '<=')) {
715 715
 				return _T("plugin_${balise}_${type}", array(
716 716
 					'plugin' => $nom,
717
-					'version' => ' &gt; ' . $minimum
717
+					'version' => ' &gt; '.$minimum
718 718
 				));
719 719
 			}
720 720
 		}
@@ -723,13 +723,13 @@  discard block
 block discarded – undo
723 723
 			if ($maximum_inclus and spip_version_compare($version, $maximum, '>')) {
724 724
 				return _T("plugin_${balise}_${type}", array(
725 725
 					'plugin' => $nom,
726
-					'version' => ' &le; ' . $maximum
726
+					'version' => ' &le; '.$maximum
727 727
 				));
728 728
 			}
729 729
 			if (!$maximum_inclus and spip_version_compare($version, $maximum, '>=')) {
730 730
 				return _T("plugin_${balise}_plugin", array(
731 731
 					'plugin' => $nom,
732
-					'version' => ' &lt; ' . $maximum
732
+					'version' => ' &lt; '.$maximum
733 733
 				));
734 734
 			}
735 735
 		}
@@ -748,7 +748,7 @@  discard block
 block discarded – undo
748 748
 		include_spip('inc/charger_plugin');
749 749
 		$url = '<br />'	. bouton_telechargement_plugin($url, 'lib');
750 750
 	}*/
751
-	return _T('plugin_necessite_lib', array('lib' => $lib)) . " <a href='$url'>$url</a>";
751
+	return _T('plugin_necessite_lib', array('lib' => $lib))." <a href='$url'>$url</a>";
752 752
 }
753 753
 
754 754
 
@@ -847,7 +847,7 @@  discard block
 block discarded – undo
847 847
 	foreach ($plugin_valides as $p => $resume) {
848 848
 		// Les headers ne doivent pas indiquer les versions des extensions PHP, ni la version PHP
849 849
 		if (0 !== strpos($p, 'PHP:') and $p !== 'PHP') {
850
-			$header[] = $p . ($resume['version'] ? "(" . $resume['version'] . ")" : "");
850
+			$header[] = $p.($resume['version'] ? "(".$resume['version'].")" : "");
851 851
 		}
852 852
 		if ($resume['dir']) {
853 853
 			foreach ($infos[$resume['dir_type']][$resume['dir']]['lib'] as $l) {
@@ -871,10 +871,10 @@  discard block
 block discarded – undo
871 871
 	ecrire_meta('plugin_attente', serialize($liste));
872 872
 	$header = strtolower(implode(",", $header));
873 873
 	if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) {
874
-		ecrire_fichier(_DIR_VAR . "config.txt",
875
-			(defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : "Composed-By: SPIP") . ' ' . $GLOBALS['spip_version_affichee'] . " @ www.spip.net + " . $header);
874
+		ecrire_fichier(_DIR_VAR."config.txt",
875
+			(defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : "Composed-By: SPIP").' '.$GLOBALS['spip_version_affichee']." @ www.spip.net + ".$header);
876 876
 	} else {
877
-		@unlink(_DIR_VAR . "config.txt");
877
+		@unlink(_DIR_VAR."config.txt");
878 878
 	}
879 879
 	// generer charger_plugins_chemin.php
880 880
 	plugins_precompile_chemin($plugin_valides, $ordre);
@@ -925,7 +925,7 @@  discard block
 block discarded – undo
925 925
 			// definir le plugin, donc le path avant l'include du fichier options
926 926
 			// permet de faire des include_spip pour attraper un inc_ du plugin
927 927
 
928
-			$dir = $dir_type . ".'" . $plug . "/'";
928
+			$dir = $dir_type.".'".$plug."/'";
929 929
 
930 930
 			$prefix = strtoupper(preg_replace(',\W,', '_', $info['prefix']));
931 931
 			if (
@@ -945,13 +945,13 @@  discard block
 block discarded – undo
945 945
 							$dir = '';
946 946
 						}
947 947
 						if (strlen($dir)) {
948
-							$dir = rtrim($dir, '/') . '/';
948
+							$dir = rtrim($dir, '/').'/';
949 949
 						}
950 950
 						if (!isset($chemin['type']) or $chemin['type'] == 'public') {
951
-							$chemins['public'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : "");
951
+							$chemins['public'][] = "_DIR_PLUGIN_$prefix".(strlen($dir) ? ".'$dir'" : "");
952 952
 						}
953 953
 						if (!isset($chemin['type']) or $chemin['type'] == 'prive') {
954
-							$chemins['prive'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : "");
954
+							$chemins['prive'][] = "_DIR_PLUGIN_$prefix".(strlen($dir) ? ".'$dir'" : "");
955 955
 						}
956 956
 					}
957 957
 				}
@@ -959,9 +959,9 @@  discard block
 block discarded – undo
959 959
 		}
960 960
 	}
961 961
 	if (count($chemins)) {
962
-		$contenu .= "if (_DIR_RESTREINT) _chemin(implode(':',array(" . implode(',',
963
-				array_reverse($chemins['public'])) . ")));\n"
964
-			. "else _chemin(implode(':',array(" . implode(',', array_reverse($chemins['prive'])) . ")));\n";
962
+		$contenu .= "if (_DIR_RESTREINT) _chemin(implode(':',array(".implode(',',
963
+				array_reverse($chemins['public'])).")));\n"
964
+			. "else _chemin(implode(':',array(".implode(',', array_reverse($chemins['prive'])).")));\n";
965 965
 	}
966 966
 
967 967
 	ecrire_fichier_php(_CACHE_PLUGINS_PATH, $contenu);
@@ -1009,7 +1009,7 @@  discard block
 block discarded – undo
1009 1009
 					and strpos($dir, ":") === false // exclure le cas des procure:
1010 1010
 					and file_exists("$dir$plug/paquet.xml") // uniquement pour les paquet.xml
1011 1011
 				) {
1012
-					if (is_readable("$dir$plug/" . ($file = $info['prefix'] . "_" . $charge . ".php"))) {
1012
+					if (is_readable("$dir$plug/".($file = $info['prefix']."_".$charge.".php"))) {
1013 1013
 						$info[$charge] = array($file);
1014 1014
 					}
1015 1015
 				}
@@ -1025,7 +1025,7 @@  discard block
 block discarded – undo
1025 1025
 						) {
1026 1026
 							unset($info[$charge][$k]);
1027 1027
 						} else {
1028
-							$_file = $root_dir_type . ".'$plug/$file'";
1028
+							$_file = $root_dir_type.".'$plug/$file'";
1029 1029
 							$contenu[$charge] .= "include_once_check($_file);\n";
1030 1030
 						}
1031 1031
 					}
@@ -1035,7 +1035,7 @@  discard block
 block discarded – undo
1035 1035
 		}
1036 1036
 	}
1037 1037
 
1038
-	$contenu['options'] = "define('_PLUGINS_HASH','" . md5($sign) . "');\n" . $contenu['options'];
1038
+	$contenu['options'] = "define('_PLUGINS_HASH','".md5($sign)."');\n".$contenu['options'];
1039 1039
 	$contenu['fonctions'] .= plugin_ongletbouton("boutons_plugins", $boutons)
1040 1040
 		. plugin_ongletbouton("onglets_plugins", $onglets);
1041 1041
 
@@ -1070,12 +1070,12 @@  discard block
 block discarded – undo
1070 1070
 		define("_UPDATED_$nom", $val);
1071 1071
 		define("_UPDATED_md5_$nom", $md5);
1072 1072
 	}
1073
-	$val = "unserialize('" . str_replace("'", "\'", $val) . "')";
1073
+	$val = "unserialize('".str_replace("'", "\'", $val)."')";
1074 1074
 
1075 1075
 	return
1076 1076
 		"if (!function_exists('$nom')) {\n"
1077 1077
 		. "function $nom(){return defined('_UPDATED_$nom')?unserialize(_UPDATED_$nom):$val;}\n"
1078
-		. "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'" . $md5 . "';}\n"
1078
+		. "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'".$md5."';}\n"
1079 1079
 		. "}\n";
1080 1080
 }
1081 1081
 
@@ -1098,7 +1098,7 @@  discard block
 block discarded – undo
1098 1098
 	if (@is_readable(_CACHE_PLUGINS_OPT)) {
1099 1099
 		include_once(_CACHE_PLUGINS_OPT);
1100 1100
 	} else {
1101
-		spip_log("pipelines desactives: impossible de produire " . _CACHE_PLUGINS_OPT);
1101
+		spip_log("pipelines desactives: impossible de produire "._CACHE_PLUGINS_OPT);
1102 1102
 	}
1103 1103
 }
1104 1104
 
@@ -1135,7 +1135,7 @@  discard block
 block discarded – undo
1135 1135
 			$dir_type = $plugin_valides[$p]['dir_type'];
1136 1136
 			$root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type);
1137 1137
 			$plug = $plugin_valides[$p]['dir'];
1138
-			$prefix = (($info['prefix'] == "spip") ? "" : $info['prefix'] . "_");
1138
+			$prefix = (($info['prefix'] == "spip") ? "" : $info['prefix']."_");
1139 1139
 			if (isset($info['pipeline']) and is_array($info['pipeline'])) {
1140 1140
 				foreach ($info['pipeline'] as $pipe) {
1141 1141
 					$nom = $pipe['nom'];
@@ -1165,7 +1165,7 @@  discard block
 block discarded – undo
1165 1165
 						}
1166 1166
 						if (isset($pipe['inclure'])) {
1167 1167
 							$GLOBALS['spip_matrice']["$prefix$action"] =
1168
-								"$root_dir_type:$plug/" . $pipe['inclure'];
1168
+								"$root_dir_type:$plug/".$pipe['inclure'];
1169 1169
 						}
1170 1170
 					}
1171 1171
 				}
@@ -1175,7 +1175,7 @@  discard block
 block discarded – undo
1175 1175
 					$prepend_code['taches_generales_cron'] = "";
1176 1176
 				}
1177 1177
 				foreach ($info['genie'] as $genie) {
1178
-					$nom = $prefix . $genie['nom'];
1178
+					$nom = $prefix.$genie['nom'];
1179 1179
 					$periode = max(60, intval($genie['periode']));
1180 1180
 					if (charger_fonction($nom, "genie", true)) {
1181 1181
 						$prepend_code['taches_generales_cron'] .= "\$val['$nom'] = $periode;\n";
@@ -1193,13 +1193,13 @@  discard block
 block discarded – undo
1193 1193
 				}
1194 1194
 				foreach ($info['style'] as $style) {
1195 1195
 					if (isset($style['path']) and $style['path']) {
1196
-						$code = "if (\$f=timestamp(direction_css(find_in_path('" . addslashes($style['path']) . "')))) ";
1196
+						$code = "if (\$f=timestamp(direction_css(find_in_path('".addslashes($style['path'])."')))) ";
1197 1197
 					} else {
1198
-						$code = "if (\$f='" . addslashes($style['url']) . "') ";
1198
+						$code = "if (\$f='".addslashes($style['url'])."') ";
1199 1199
 					}
1200 1200
 					$code .= "\$val .= '<link rel=\"stylesheet\" href=\"'.\$f.'\" type=\"text/css\"";
1201 1201
 					if (isset($style['media']) and strlen($style['media'])) {
1202
-						$code .= " media=\"" . addslashes($style['media']) . "\"";
1202
+						$code .= " media=\"".addslashes($style['media'])."\"";
1203 1203
 					}
1204 1204
 					$code .= "/>';\n";
1205 1205
 					if ($style['type'] != 'prive') {
@@ -1219,9 +1219,9 @@  discard block
 block discarded – undo
1219 1219
 			if (isset($info['script']) and count($info['script'])) {
1220 1220
 				foreach ($info['script'] as $script) {
1221 1221
 					if (isset($script['path']) and $script['path']) {
1222
-						$code = "if (\$f=timestamp(find_in_path('" . addslashes($script['path']) . "'))) ";
1222
+						$code = "if (\$f=timestamp(find_in_path('".addslashes($script['path'])."'))) ";
1223 1223
 					} else {
1224
-						$code = "if (\$f='" . addslashes($script['url']) . "') ";
1224
+						$code = "if (\$f='".addslashes($script['url'])."') ";
1225 1225
 					}
1226 1226
 					$code .= "\$val .= '<script src=\"'.\$f.'\" type=\"text/javascript\"></script>';\n";
1227 1227
 					if ($script['type'] != 'prive') {
@@ -1286,7 +1286,7 @@  discard block
 block discarded – undo
1286 1286
 		// Eclater le pipeline en filtres et appliquer chaque filtre
1287 1287
 		foreach ($pipe as $fonc) {
1288 1288
 			$fonc = trim($fonc);
1289
-			$s_call .= '$val = minipipe(\'' . $fonc . '\', $val);' . "\n";
1289
+			$s_call .= '$val = minipipe(\''.$fonc.'\', $val);'."\n";
1290 1290
 			if (isset($GLOBALS['spip_matrice'][$fonc])) {
1291 1291
 				$file = $GLOBALS['spip_matrice'][$fonc];
1292 1292
 				$file = "'$file'";
@@ -1297,7 +1297,7 @@  discard block
 block discarded – undo
1297 1297
 					if (defined($root_dir)) {
1298 1298
 						$dir = $root_dir;
1299 1299
 					}
1300
-					$file = str_replace($regs[0], "'." . $dir . ".'", $file);
1300
+					$file = str_replace($regs[0], "'.".$dir.".'", $file);
1301 1301
 					$file = str_replace("''.", "", $file);
1302 1302
 					$file = str_replace(constant($dir), '', $file);
1303 1303
 				}
@@ -1310,7 +1310,7 @@  discard block
 block discarded – undo
1310 1310
 		$content .= "// Pipeline $action \n"
1311 1311
 			. "function execute_pipeline_$action(&\$val){\n"
1312 1312
 			. $s_inc
1313
-			. ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action]) . "\n" : '')
1313
+			. ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action])."\n" : '')
1314 1314
 			. $s_call
1315 1315
 			. "return \$val;\n}\n";
1316 1316
 	}
@@ -1394,18 +1394,18 @@  discard block
 block discarded – undo
1394 1394
 		$GLOBALS['fichier_php_compile_recent'] = 0;
1395 1395
 	}
1396 1396
 
1397
-	$contenu = '<' . '?php' . "\n" . $comment . "\nif (defined('_ECRIRE_INC_VERSION')) {\n" . $contenu . "}\n?" . '>';
1397
+	$contenu = '<'.'?php'."\n".$comment."\nif (defined('_ECRIRE_INC_VERSION')) {\n".$contenu."}\n?".'>';
1398 1398
 	// si un fichier existe deja on verifie que son contenu change avant de l'ecraser
1399 1399
 	// si pas de modif on ne touche pas au fichier initial
1400 1400
 	if (file_exists($nom)) {
1401 1401
 		if (substr($nom, -4) == '.php') {
1402
-			$fichier_tmp = substr($nom, 0, -4) . '.tmp.php';
1402
+			$fichier_tmp = substr($nom, 0, -4).'.tmp.php';
1403 1403
 		}
1404 1404
 		else {
1405
-			$fichier_tmp = $nom . '.tmp';
1405
+			$fichier_tmp = $nom.'.tmp';
1406 1406
 		}
1407 1407
 		file_put_contents($fichier_tmp, $contenu);
1408
-		if(md5_file($nom) == md5_file($fichier_tmp)) {
1408
+		if (md5_file($nom) == md5_file($fichier_tmp)) {
1409 1409
 			$GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom));
1410 1410
 			@unlink($fichier_tmp);
1411 1411
 			return;
Please login to merge, or discard this patch.
Braces   +6 added lines, -7 removed lines patch added patch discarded remove patch
@@ -555,11 +555,9 @@  discard block
 block discarded – undo
555 555
 		if (!isset($msg[$p])) {
556 556
 			if (isset($resume['erreur']) and $resume['erreur']) {
557 557
 				$msg[$p] = array($resume['erreur']);
558
-			}
559
-			elseif (!plugin_version_compatible($k['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) {
558
+			} elseif (!plugin_version_compatible($k['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) {
560 559
 				$msg[$p] = array(plugin_message_incompatibilite($k['compatibilite'], $GLOBALS['spip_version_branche'], 'SPIP', 'necessite'));
561
-			}
562
-			elseif (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) {
560
+			} elseif (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) {
563 561
 				$msg[$p] = plugin_necessite($k['utilise'], $liste, 'utilise');
564 562
 			}
565 563
 		} else {
@@ -1154,10 +1152,12 @@  discard block
 block discarded – undo
1154 1152
 					}
1155 1153
 					$nom = $nomlower;
1156 1154
 					// une action vide est une declaration qui ne doit pas etre compilee !
1157
-					if (!isset($GLOBALS['spip_pipeline'][$nom])) // creer le pipeline eventuel
1155
+					if (!isset($GLOBALS['spip_pipeline'][$nom])) {
1156
+					    // creer le pipeline eventuel
1158 1157
 					{
1159 1158
 						$GLOBALS['spip_pipeline'][$nom] = "";
1160 1159
 					}
1160
+					}
1161 1161
 					if ($action) {
1162 1162
 						if (strpos($GLOBALS['spip_pipeline'][$nom], "|$prefix$action") === false) {
1163 1163
 							$GLOBALS['spip_pipeline'][$nom] = preg_replace(",(\|\||$),", "|$prefix$action\\1",
@@ -1400,8 +1400,7 @@  discard block
 block discarded – undo
1400 1400
 	if (file_exists($nom)) {
1401 1401
 		if (substr($nom, -4) == '.php') {
1402 1402
 			$fichier_tmp = substr($nom, 0, -4) . '.tmp.php';
1403
-		}
1404
-		else {
1403
+		} else {
1405 1404
 			$fichier_tmp = $nom . '.tmp';
1406 1405
 		}
1407 1406
 		file_put_contents($fichier_tmp, $contenu);
Please login to merge, or discard this patch.
Indentation   +913 added lines, -913 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,26 +47,26 @@  discard block
 block discarded – undo
47 47
  * @return array
48 48
 **/
49 49
 function liste_plugin_files($dir_plugins = null) {
50
-	static $plugin_files = array();
51
-	if (is_null($dir_plugins)) {
52
-		$dir_plugins = _DIR_PLUGINS;
53
-	}
54
-	if (!isset($plugin_files[$dir_plugins])
55
-		or count($plugin_files[$dir_plugins]) == 0
56
-	) {
57
-		$plugin_files[$dir_plugins] = array();
58
-		foreach (fast_find_plugin_dirs($dir_plugins) as $plugin) {
59
-			$plugin_files[$dir_plugins][] = substr($plugin, strlen($dir_plugins));
60
-		}
61
-
62
-		sort($plugin_files[$dir_plugins]);
63
-		// et on lit le XML de tous les plugins pour le mettre en cache
64
-		// et en profiter pour nettoyer ceux qui n'existent plus du cache
65
-		$get_infos = charger_fonction('get_infos', 'plugins');
66
-		$get_infos($plugin_files[$dir_plugins], false, $dir_plugins, true);
67
-	}
68
-
69
-	return $plugin_files[$dir_plugins];
50
+    static $plugin_files = array();
51
+    if (is_null($dir_plugins)) {
52
+        $dir_plugins = _DIR_PLUGINS;
53
+    }
54
+    if (!isset($plugin_files[$dir_plugins])
55
+        or count($plugin_files[$dir_plugins]) == 0
56
+    ) {
57
+        $plugin_files[$dir_plugins] = array();
58
+        foreach (fast_find_plugin_dirs($dir_plugins) as $plugin) {
59
+            $plugin_files[$dir_plugins][] = substr($plugin, strlen($dir_plugins));
60
+        }
61
+
62
+        sort($plugin_files[$dir_plugins]);
63
+        // et on lit le XML de tous les plugins pour le mettre en cache
64
+        // et en profiter pour nettoyer ceux qui n'existent plus du cache
65
+        $get_infos = charger_fonction('get_infos', 'plugins');
66
+        $get_infos($plugin_files[$dir_plugins], false, $dir_plugins, true);
67
+    }
68
+
69
+    return $plugin_files[$dir_plugins];
70 70
 }
71 71
 
72 72
 /**
@@ -82,44 +82,44 @@  discard block
 block discarded – undo
82 82
  *     Liste complète des répeertoires
83 83
 **/
84 84
 function fast_find_plugin_dirs($dir, $max_prof = 100) {
85
-	$fichiers = array();
86
-	// revenir au repertoire racine si on a recu dossier/truc
87
-	// pour regarder dossier/truc/ ne pas oublier le / final
88
-	$dir = preg_replace(',/[^/]*$,', '', $dir);
89
-	if ($dir == '') {
90
-		$dir = '.';
91
-	}
92
-
93
-	if (!is_dir($dir)) {
94
-		return $fichiers;
95
-	}
96
-	if (is_plugin_dir($dir, '')) {
97
-		$fichiers[] = $dir;
98
-
99
-		return $fichiers;
100
-	}
101
-	if ($max_prof <= 0) {
102
-		return $fichiers;
103
-	}
104
-
105
-	$subdirs = array();
106
-	if (@is_dir($dir) and is_readable($dir) and $d = opendir($dir)) {
107
-		while (($f = readdir($d)) !== false) {
108
-			if ($f[0] != '.' # ignorer . .. .svn etc
109
-				and $f != 'CVS'
110
-				and is_dir($f = "$dir/$f")
111
-			) {
112
-				$subdirs[] = $f;
113
-			}
114
-		}
115
-		closedir($d);
116
-	}
117
-
118
-	foreach ($subdirs as $d) {
119
-		$fichiers = array_merge($fichiers, fast_find_plugin_dirs("$d/", $max_prof - 1));
120
-	}
121
-
122
-	return $fichiers;
85
+    $fichiers = array();
86
+    // revenir au repertoire racine si on a recu dossier/truc
87
+    // pour regarder dossier/truc/ ne pas oublier le / final
88
+    $dir = preg_replace(',/[^/]*$,', '', $dir);
89
+    if ($dir == '') {
90
+        $dir = '.';
91
+    }
92
+
93
+    if (!is_dir($dir)) {
94
+        return $fichiers;
95
+    }
96
+    if (is_plugin_dir($dir, '')) {
97
+        $fichiers[] = $dir;
98
+
99
+        return $fichiers;
100
+    }
101
+    if ($max_prof <= 0) {
102
+        return $fichiers;
103
+    }
104
+
105
+    $subdirs = array();
106
+    if (@is_dir($dir) and is_readable($dir) and $d = opendir($dir)) {
107
+        while (($f = readdir($d)) !== false) {
108
+            if ($f[0] != '.' # ignorer . .. .svn etc
109
+                and $f != 'CVS'
110
+                and is_dir($f = "$dir/$f")
111
+            ) {
112
+                $subdirs[] = $f;
113
+            }
114
+        }
115
+        closedir($d);
116
+    }
117
+
118
+    foreach ($subdirs as $d) {
119
+        $fichiers = array_merge($fichiers, fast_find_plugin_dirs("$d/", $max_prof - 1));
120
+    }
121
+
122
+    return $fichiers;
123 123
 }
124 124
 
125 125
 /**
@@ -140,27 +140,27 @@  discard block
 block discarded – undo
140 140
 **/
141 141
 function is_plugin_dir($dir, $dir_plugins = null) {
142 142
 
143
-	if (is_array($dir)) {
144
-		foreach ($dir as $k => $d) {
145
-			if (!is_plugin_dir($d, $dir_plugins)) {
146
-				unset($dir[$k]);
147
-			}
148
-		}
149
-
150
-		return $dir;
151
-	}
152
-	if (is_null($dir_plugins)) {
153
-		$dir_plugins = _DIR_PLUGINS;
154
-	}
155
-	$search = array("$dir_plugins$dir/paquet.xml");
156
-
157
-	foreach ($search as $s) {
158
-		if (file_exists($s)) {
159
-			return $dir;
160
-		}
161
-	}
162
-
163
-	return '';
143
+    if (is_array($dir)) {
144
+        foreach ($dir as $k => $d) {
145
+            if (!is_plugin_dir($d, $dir_plugins)) {
146
+                unset($dir[$k]);
147
+            }
148
+        }
149
+
150
+        return $dir;
151
+    }
152
+    if (is_null($dir_plugins)) {
153
+        $dir_plugins = _DIR_PLUGINS;
154
+    }
155
+    $search = array("$dir_plugins$dir/paquet.xml");
156
+
157
+    foreach ($search as $s) {
158
+        if (file_exists($s)) {
159
+            return $dir;
160
+        }
161
+    }
162
+
163
+    return '';
164 164
 }
165 165
 
166 166
 /** Regexp d'extraction des informations d'un intervalle de compatibilité */
@@ -187,51 +187,51 @@  discard block
 block discarded – undo
187 187
  **/
188 188
 function plugin_version_compatible($intervalle, $version, $avec_quoi = '') {
189 189
 
190
-	if (!strlen($intervalle)) {
191
-		return true;
192
-	}
193
-	if (!preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) {
194
-		return false;
195
-	}
196
-	// Extraction des bornes et traitement de * pour la borne sup :
197
-	// -- on autorise uniquement les ecritures 3.0.*, 3.*
198
-	$minimum = $regs[1];
199
-	$maximum = $regs[2];
200
-
201
-	//  si une version SPIP de compatibilité a été définie (dans
202
-	//  mes_options.php, sous la forme : define('_DEV_VERSION_SPIP_COMPAT', '3.1.0');
203
-	//  on l'utilise (phase de dev, de test...) mais *que* en cas de comparaison
204
-	//  avec la version de SPIP (ne nuit donc pas aux tests de necessite
205
-	//  entre plugins)
206
-	if (defined('_DEV_VERSION_SPIP_COMPAT') and $avec_quoi == 'spip' and $version !== _DEV_VERSION_SPIP_COMPAT) {
207
-		if (plugin_version_compatible($intervalle, _DEV_VERSION_SPIP_COMPAT, $avec_quoi)) {
208
-			return true;
209
-		}
210
-		// si pas de compatibilite avec _DEV_VERSION_SPIP_COMPAT, on essaye quand meme avec la vrai version
211
-		// cas du plugin qui n'est compatible qu'avec cette nouvelle version
212
-	}
213
-
214
-	$minimum_inc = $intervalle{0} == "[";
215
-	$maximum_inc = substr($intervalle, -1) == "]";
216
-
217
-	if (strlen($minimum)) {
218
-		if ($minimum_inc and spip_version_compare($version, $minimum, '<')) {
219
-			return false;
220
-		}
221
-		if (!$minimum_inc and spip_version_compare($version, $minimum, '<=')) {
222
-			return false;
223
-		}
224
-	}
225
-	if (strlen($maximum)) {
226
-		if ($maximum_inc and spip_version_compare($version, $maximum, '>')) {
227
-			return false;
228
-		}
229
-		if (!$maximum_inc and spip_version_compare($version, $maximum, '>=')) {
230
-			return false;
231
-		}
232
-	}
233
-
234
-	return true;
190
+    if (!strlen($intervalle)) {
191
+        return true;
192
+    }
193
+    if (!preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) {
194
+        return false;
195
+    }
196
+    // Extraction des bornes et traitement de * pour la borne sup :
197
+    // -- on autorise uniquement les ecritures 3.0.*, 3.*
198
+    $minimum = $regs[1];
199
+    $maximum = $regs[2];
200
+
201
+    //  si une version SPIP de compatibilité a été définie (dans
202
+    //  mes_options.php, sous la forme : define('_DEV_VERSION_SPIP_COMPAT', '3.1.0');
203
+    //  on l'utilise (phase de dev, de test...) mais *que* en cas de comparaison
204
+    //  avec la version de SPIP (ne nuit donc pas aux tests de necessite
205
+    //  entre plugins)
206
+    if (defined('_DEV_VERSION_SPIP_COMPAT') and $avec_quoi == 'spip' and $version !== _DEV_VERSION_SPIP_COMPAT) {
207
+        if (plugin_version_compatible($intervalle, _DEV_VERSION_SPIP_COMPAT, $avec_quoi)) {
208
+            return true;
209
+        }
210
+        // si pas de compatibilite avec _DEV_VERSION_SPIP_COMPAT, on essaye quand meme avec la vrai version
211
+        // cas du plugin qui n'est compatible qu'avec cette nouvelle version
212
+    }
213
+
214
+    $minimum_inc = $intervalle{0} == "[";
215
+    $maximum_inc = substr($intervalle, -1) == "]";
216
+
217
+    if (strlen($minimum)) {
218
+        if ($minimum_inc and spip_version_compare($version, $minimum, '<')) {
219
+            return false;
220
+        }
221
+        if (!$minimum_inc and spip_version_compare($version, $minimum, '<=')) {
222
+            return false;
223
+        }
224
+    }
225
+    if (strlen($maximum)) {
226
+        if ($maximum_inc and spip_version_compare($version, $maximum, '>')) {
227
+            return false;
228
+        }
229
+        if (!$maximum_inc and spip_version_compare($version, $maximum, '>=')) {
230
+            return false;
231
+        }
232
+    }
233
+
234
+    return true;
235 235
 }
236 236
 
237 237
 /**
@@ -248,62 +248,62 @@  discard block
 block discarded – undo
248 248
  * @return array
249 249
  */
250 250
 function liste_plugin_valides($liste_plug, $force = false) {
251
-	$liste_ext = liste_plugin_files(_DIR_PLUGINS_DIST);
252
-	$get_infos = charger_fonction('get_infos', 'plugins');
253
-	$infos = array(
254
-		// lister les extensions qui sont automatiquement actives
255
-		'_DIR_PLUGINS_DIST' => $get_infos($liste_ext, $force, _DIR_PLUGINS_DIST),
256
-		'_DIR_PLUGINS' => $get_infos($liste_plug, $force, _DIR_PLUGINS)
257
-	);
258
-
259
-	// creer une premiere liste non ordonnee mais qui ne retient
260
-	// que les plugins valides, et dans leur derniere version en cas de doublon
261
-	$infos['_DIR_RESTREINT'][''] = $get_infos('./', $force, _DIR_RESTREINT);
262
-	$infos['_DIR_RESTREINT']['SPIP']['version'] = $GLOBALS['spip_version_branche'];
263
-	$infos['_DIR_RESTREINT']['SPIP']['chemin'] = array();
264
-	$liste_non_classee = array(
265
-		'SPIP' => array(
266
-			'nom' => 'SPIP',
267
-			'etat' => 'stable',
268
-			'version' => $GLOBALS['spip_version_branche'],
269
-			'dir_type' => '_DIR_RESTREINT',
270
-			'dir' => '',
271
-		)
272
-	);
273
-
274
-	$invalides = array();
275
-	foreach ($liste_ext as $plug) {
276
-		if (isset($infos['_DIR_PLUGINS_DIST'][$plug])) {
277
-			plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_DIST');
278
-		}
279
-	}
280
-	foreach ($liste_plug as $plug) {
281
-		if (isset($infos['_DIR_PLUGINS'][$plug])) {
282
-			$r = plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS');
283
-			if (is_array($r)) {
284
-				$invalides = array_merge($invalides, $r);
285
-			}
286
-		}
287
-	}
288
-
289
-	if (defined('_DIR_PLUGINS_SUPPL') and _DIR_PLUGINS_SUPPL) {
290
-		$infos['_DIR_PLUGINS_SUPPL'] = $get_infos($liste_plug, false, _DIR_PLUGINS_SUPPL);
291
-		foreach ($liste_plug as $plug) {
292
-			if (isset($infos['_DIR_PLUGINS_SUPPL'][$plug])) {
293
-				$r = plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_SUPPL');
294
-				if (is_array($r)) {
295
-					$invalides = array_merge($invalides, $r);
296
-				}
297
-			}
298
-		}
299
-	}
300
-
301
-	plugin_fixer_procure($liste_non_classee, $infos);
302
-
303
-	// les plugins qui sont dans $liste_non_classee ne sont pas invalides (on a trouve un autre version valide)
304
-	$invalides = array_diff_key($invalides, $liste_non_classee);
305
-
306
-	return array($infos, $liste_non_classee, $invalides);
251
+    $liste_ext = liste_plugin_files(_DIR_PLUGINS_DIST);
252
+    $get_infos = charger_fonction('get_infos', 'plugins');
253
+    $infos = array(
254
+        // lister les extensions qui sont automatiquement actives
255
+        '_DIR_PLUGINS_DIST' => $get_infos($liste_ext, $force, _DIR_PLUGINS_DIST),
256
+        '_DIR_PLUGINS' => $get_infos($liste_plug, $force, _DIR_PLUGINS)
257
+    );
258
+
259
+    // creer une premiere liste non ordonnee mais qui ne retient
260
+    // que les plugins valides, et dans leur derniere version en cas de doublon
261
+    $infos['_DIR_RESTREINT'][''] = $get_infos('./', $force, _DIR_RESTREINT);
262
+    $infos['_DIR_RESTREINT']['SPIP']['version'] = $GLOBALS['spip_version_branche'];
263
+    $infos['_DIR_RESTREINT']['SPIP']['chemin'] = array();
264
+    $liste_non_classee = array(
265
+        'SPIP' => array(
266
+            'nom' => 'SPIP',
267
+            'etat' => 'stable',
268
+            'version' => $GLOBALS['spip_version_branche'],
269
+            'dir_type' => '_DIR_RESTREINT',
270
+            'dir' => '',
271
+        )
272
+    );
273
+
274
+    $invalides = array();
275
+    foreach ($liste_ext as $plug) {
276
+        if (isset($infos['_DIR_PLUGINS_DIST'][$plug])) {
277
+            plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_DIST');
278
+        }
279
+    }
280
+    foreach ($liste_plug as $plug) {
281
+        if (isset($infos['_DIR_PLUGINS'][$plug])) {
282
+            $r = plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS');
283
+            if (is_array($r)) {
284
+                $invalides = array_merge($invalides, $r);
285
+            }
286
+        }
287
+    }
288
+
289
+    if (defined('_DIR_PLUGINS_SUPPL') and _DIR_PLUGINS_SUPPL) {
290
+        $infos['_DIR_PLUGINS_SUPPL'] = $get_infos($liste_plug, false, _DIR_PLUGINS_SUPPL);
291
+        foreach ($liste_plug as $plug) {
292
+            if (isset($infos['_DIR_PLUGINS_SUPPL'][$plug])) {
293
+                $r = plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_SUPPL');
294
+                if (is_array($r)) {
295
+                    $invalides = array_merge($invalides, $r);
296
+                }
297
+            }
298
+        }
299
+    }
300
+
301
+    plugin_fixer_procure($liste_non_classee, $infos);
302
+
303
+    // les plugins qui sont dans $liste_non_classee ne sont pas invalides (on a trouve un autre version valide)
304
+    $invalides = array_diff_key($invalides, $liste_non_classee);
305
+
306
+    return array($infos, $liste_non_classee, $invalides);
307 307
 }
308 308
 
309 309
 /**
@@ -323,29 +323,29 @@  discard block
 block discarded – undo
323 323
  *   array description short si on ne le retient pas (pour memorisation dans une table des erreurs)
324 324
  */
325 325
 function plugin_valide_resume(&$liste, $plug, $infos, $dir_type) {
326
-	$i = $infos[$dir_type][$plug];
327
-	$p = strtoupper($i['prefix']);
328
-	$short_desc = array(
329
-		'nom' => $i['nom'],
330
-		'etat' => $i['etat'],
331
-		'version' => $i['version'],
332
-		'dir' => $plug,
333
-		'dir_type' => $dir_type
334
-	);
335
-	if (isset($i['erreur']) and $i['erreur']) {
336
-		$short_desc['erreur'] = $i['erreur'];
337
-		return array($p=>$short_desc);
338
-	}
339
-	if (!plugin_version_compatible($i['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) {
340
-		return array($p=>$short_desc);
341
-	}
342
-	if (!isset($liste[$p])
343
-		or spip_version_compare($i['version'], $liste[$p]['version'], '>')
344
-	) {
345
-		$liste[$p] = $short_desc;
346
-	}
347
-	// ok le plugin etait deja dans la liste ou on a choisi une version plus recente
348
-	return $p;
326
+    $i = $infos[$dir_type][$plug];
327
+    $p = strtoupper($i['prefix']);
328
+    $short_desc = array(
329
+        'nom' => $i['nom'],
330
+        'etat' => $i['etat'],
331
+        'version' => $i['version'],
332
+        'dir' => $plug,
333
+        'dir_type' => $dir_type
334
+    );
335
+    if (isset($i['erreur']) and $i['erreur']) {
336
+        $short_desc['erreur'] = $i['erreur'];
337
+        return array($p=>$short_desc);
338
+    }
339
+    if (!plugin_version_compatible($i['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) {
340
+        return array($p=>$short_desc);
341
+    }
342
+    if (!isset($liste[$p])
343
+        or spip_version_compare($i['version'], $liste[$p]['version'], '>')
344
+    ) {
345
+        $liste[$p] = $short_desc;
346
+    }
347
+    // ok le plugin etait deja dans la liste ou on a choisi une version plus recente
348
+    return $p;
349 349
 }
350 350
 
351 351
 /**
@@ -361,46 +361,46 @@  discard block
 block discarded – undo
361 361
  * @param array $infos
362 362
  */
363 363
 function plugin_fixer_procure(&$liste, &$infos) {
364
-	foreach ($liste as $p => $resume) {
365
-		$i = $infos[$resume['dir_type']][$resume['dir']];
366
-		if (isset($i['procure']) and $i['procure']) {
367
-			foreach ($i['procure'] as $procure) {
368
-				$p = strtoupper($procure['nom']);
369
-				$dir = $resume['dir'];
370
-				if ($dir) {
371
-					$dir .= "/";
372
-				}
373
-				$dir .= "procure:" . $procure['nom'];
374
-
375
-				$procure['etat'] = '?';
376
-				$procure['dir_type'] = $resume['dir_type'];
377
-				$procure['dir'] = $dir;
378
-
379
-				// si ce plugin n'est pas deja procure, ou dans une version plus ancienne
380
-				// on ajoute cette version a la liste
381
-				if (!isset($liste[$p])
382
-					or spip_version_compare($procure['version'], $liste[$p]['version'], '>')
383
-				) {
384
-					$liste[$p] = $procure;
385
-
386
-					// on fournit une information minimale pour ne pas perturber la compilation
387
-					$infos[$resume['dir_type']][$dir] = array(
388
-						'prefix' => $procure['nom'],
389
-						'nom' => $procure['nom'],
390
-						'etat' => $procure['etat'],
391
-						'version' => $procure['version'],
392
-						'chemin' => array(),
393
-						'necessite' => array(),
394
-						'utilise' => array(),
395
-						'lib' => array(),
396
-						'menu' => array(),
397
-						'onglet' => array(),
398
-						'procure' => array(),
399
-					);
400
-				}
401
-			}
402
-		}
403
-	}
364
+    foreach ($liste as $p => $resume) {
365
+        $i = $infos[$resume['dir_type']][$resume['dir']];
366
+        if (isset($i['procure']) and $i['procure']) {
367
+            foreach ($i['procure'] as $procure) {
368
+                $p = strtoupper($procure['nom']);
369
+                $dir = $resume['dir'];
370
+                if ($dir) {
371
+                    $dir .= "/";
372
+                }
373
+                $dir .= "procure:" . $procure['nom'];
374
+
375
+                $procure['etat'] = '?';
376
+                $procure['dir_type'] = $resume['dir_type'];
377
+                $procure['dir'] = $dir;
378
+
379
+                // si ce plugin n'est pas deja procure, ou dans une version plus ancienne
380
+                // on ajoute cette version a la liste
381
+                if (!isset($liste[$p])
382
+                    or spip_version_compare($procure['version'], $liste[$p]['version'], '>')
383
+                ) {
384
+                    $liste[$p] = $procure;
385
+
386
+                    // on fournit une information minimale pour ne pas perturber la compilation
387
+                    $infos[$resume['dir_type']][$dir] = array(
388
+                        'prefix' => $procure['nom'],
389
+                        'nom' => $procure['nom'],
390
+                        'etat' => $procure['etat'],
391
+                        'version' => $procure['version'],
392
+                        'chemin' => array(),
393
+                        'necessite' => array(),
394
+                        'utilise' => array(),
395
+                        'lib' => array(),
396
+                        'menu' => array(),
397
+                        'onglet' => array(),
398
+                        'procure' => array(),
399
+                    );
400
+                }
401
+            }
402
+        }
403
+    }
404 404
 }
405 405
 
406 406
 /**
@@ -414,19 +414,19 @@  discard block
 block discarded – undo
414 414
  * @return array
415 415
  */
416 416
 function liste_chemin_plugin($liste, $dir_plugins = _DIR_PLUGINS) {
417
-	foreach ($liste as $prefix => $infos) {
418
-		if (!$dir_plugins
419
-			or (
420
-				defined($infos['dir_type'])
421
-				and constant($infos['dir_type']) == $dir_plugins)
422
-		) {
423
-			$liste[$prefix] = $infos['dir'];
424
-		} else {
425
-			unset($liste[$prefix]);
426
-		}
427
-	}
428
-
429
-	return $liste;
417
+    foreach ($liste as $prefix => $infos) {
418
+        if (!$dir_plugins
419
+            or (
420
+                defined($infos['dir_type'])
421
+                and constant($infos['dir_type']) == $dir_plugins)
422
+        ) {
423
+            $liste[$prefix] = $infos['dir'];
424
+        } else {
425
+            unset($liste[$prefix]);
426
+        }
427
+    }
428
+
429
+    return $liste;
430 430
 }
431 431
 
432 432
 /**
@@ -441,9 +441,9 @@  discard block
 block discarded – undo
441 441
  * @return array
442 442
  */
443 443
 function liste_chemin_plugin_actifs($dir_plugins = _DIR_PLUGINS) {
444
-	include_spip('plugins/installer');
444
+    include_spip('plugins/installer');
445 445
 
446
-	return liste_chemin_plugin(liste_plugin_actifs(), $dir_plugins);
446
+    return liste_chemin_plugin(liste_plugin_actifs(), $dir_plugins);
447 447
 }
448 448
 
449 449
 /**
@@ -474,53 +474,53 @@  discard block
 block discarded – undo
474 474
  *                qui n'ont pas satisfait leurs dépendances
475 475
 **/
476 476
 function plugin_trier($infos, $liste_non_classee) {
477
-	$toute_la_liste = $liste_non_classee;
478
-	$liste = $ordre = array();
479
-	$count = 0;
480
-
481
-	while ($c = count($liste_non_classee) and $c != $count) { // tant qu'il reste des plugins a classer, et qu'on ne stagne pas
482
-		#echo "tour::";var_dump($liste_non_classee);
483
-		$count = $c;
484
-		foreach ($liste_non_classee as $p => $resume) {
485
-			$plug = $resume['dir'];
486
-			$dir_type = $resume['dir_type'];
487
-			$info1 = $infos[$dir_type][$plug];
488
-			// si des plugins sont necessaires,
489
-			// on ne peut inserer qu'apres eux
490
-			foreach ($info1['necessite'] as $need) {
491
-				$nom = strtoupper($need['nom']);
492
-				$compat = isset($need['compatibilite']) ? $need['compatibilite'] : '';
493
-				if (!isset($liste[$nom]) or !plugin_version_compatible($compat, $liste[$nom]['version'])) {
494
-					$info1 = false;
495
-					break;
496
-				}
497
-			}
498
-			if (!$info1) {
499
-				continue;
500
-			}
501
-			// idem si des plugins sont utiles,
502
-			// sauf si ils sont de toute facon absents de la liste
503
-			foreach ($info1['utilise'] as $need) {
504
-				$nom = strtoupper($need['nom']);
505
-				$compat = isset($need['compatibilite']) ? $need['compatibilite'] : '';
506
-				if (isset($toute_la_liste[$nom])) {
507
-					if (!isset($liste[$nom]) or
508
-						!plugin_version_compatible($compat, $liste[$nom]['version'])
509
-					) {
510
-						$info1 = false;
511
-						break;
512
-					}
513
-				}
514
-			}
515
-			if ($info1) {
516
-				$ordre[$p] = $info1;
517
-				$liste[$p] = $liste_non_classee[$p];
518
-				unset($liste_non_classee[$p]);
519
-			}
520
-		}
521
-	}
522
-
523
-	return array($liste, $ordre, $liste_non_classee);
477
+    $toute_la_liste = $liste_non_classee;
478
+    $liste = $ordre = array();
479
+    $count = 0;
480
+
481
+    while ($c = count($liste_non_classee) and $c != $count) { // tant qu'il reste des plugins a classer, et qu'on ne stagne pas
482
+        #echo "tour::";var_dump($liste_non_classee);
483
+        $count = $c;
484
+        foreach ($liste_non_classee as $p => $resume) {
485
+            $plug = $resume['dir'];
486
+            $dir_type = $resume['dir_type'];
487
+            $info1 = $infos[$dir_type][$plug];
488
+            // si des plugins sont necessaires,
489
+            // on ne peut inserer qu'apres eux
490
+            foreach ($info1['necessite'] as $need) {
491
+                $nom = strtoupper($need['nom']);
492
+                $compat = isset($need['compatibilite']) ? $need['compatibilite'] : '';
493
+                if (!isset($liste[$nom]) or !plugin_version_compatible($compat, $liste[$nom]['version'])) {
494
+                    $info1 = false;
495
+                    break;
496
+                }
497
+            }
498
+            if (!$info1) {
499
+                continue;
500
+            }
501
+            // idem si des plugins sont utiles,
502
+            // sauf si ils sont de toute facon absents de la liste
503
+            foreach ($info1['utilise'] as $need) {
504
+                $nom = strtoupper($need['nom']);
505
+                $compat = isset($need['compatibilite']) ? $need['compatibilite'] : '';
506
+                if (isset($toute_la_liste[$nom])) {
507
+                    if (!isset($liste[$nom]) or
508
+                        !plugin_version_compatible($compat, $liste[$nom]['version'])
509
+                    ) {
510
+                        $info1 = false;
511
+                        break;
512
+                    }
513
+                }
514
+            }
515
+            if ($info1) {
516
+                $ordre[$p] = $info1;
517
+                $liste[$p] = $liste_non_classee[$p];
518
+                unset($liste_non_classee[$p]);
519
+            }
520
+        }
521
+    }
522
+
523
+    return array($liste, $ordre, $liste_non_classee);
524 524
 }
525 525
 
526 526
 /**
@@ -537,40 +537,40 @@  discard block
 block discarded – undo
537 537
  *     Répertoire (plugins, plugins-dist, ...) => Couples (prefixes => infos completes) des plugins qu'ils contiennent
538 538
 **/
539 539
 function plugins_erreurs($liste_non_classee, $liste, $infos, $msg = array()) {
540
-	static $erreurs = array();
541
-
542
-	if (!is_array($liste)) {
543
-		$liste = array();
544
-	}
545
-
546
-	// les plugins en erreur ne sont pas actifs ; ils ne doivent pas être dans la liste
547
-	$liste = array_diff_key($liste, $liste_non_classee);
548
-
549
-	foreach ($liste_non_classee as $p => $resume) {
550
-		$dir_type = $resume['dir_type'];
551
-		$plug = $resume['dir'];
552
-		$k = $infos[$dir_type][$plug];
553
-
554
-		$plug = constant($dir_type) . $plug;
555
-		if (!isset($msg[$p])) {
556
-			if (isset($resume['erreur']) and $resume['erreur']) {
557
-				$msg[$p] = array($resume['erreur']);
558
-			}
559
-			elseif (!plugin_version_compatible($k['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) {
560
-				$msg[$p] = array(plugin_message_incompatibilite($k['compatibilite'], $GLOBALS['spip_version_branche'], 'SPIP', 'necessite'));
561
-			}
562
-			elseif (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) {
563
-				$msg[$p] = plugin_necessite($k['utilise'], $liste, 'utilise');
564
-			}
565
-		} else {
566
-			foreach ($msg[$p] as $c => $l) {
567
-				$msg[$p][$c] = plugin_controler_lib($l['nom'], $l['lien']);
568
-			}
569
-		}
570
-		$erreurs[$plug] = $msg[$p];
571
-	}
572
-
573
-	ecrire_meta('plugin_erreur_activation', serialize($erreurs));
540
+    static $erreurs = array();
541
+
542
+    if (!is_array($liste)) {
543
+        $liste = array();
544
+    }
545
+
546
+    // les plugins en erreur ne sont pas actifs ; ils ne doivent pas être dans la liste
547
+    $liste = array_diff_key($liste, $liste_non_classee);
548
+
549
+    foreach ($liste_non_classee as $p => $resume) {
550
+        $dir_type = $resume['dir_type'];
551
+        $plug = $resume['dir'];
552
+        $k = $infos[$dir_type][$plug];
553
+
554
+        $plug = constant($dir_type) . $plug;
555
+        if (!isset($msg[$p])) {
556
+            if (isset($resume['erreur']) and $resume['erreur']) {
557
+                $msg[$p] = array($resume['erreur']);
558
+            }
559
+            elseif (!plugin_version_compatible($k['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) {
560
+                $msg[$p] = array(plugin_message_incompatibilite($k['compatibilite'], $GLOBALS['spip_version_branche'], 'SPIP', 'necessite'));
561
+            }
562
+            elseif (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) {
563
+                $msg[$p] = plugin_necessite($k['utilise'], $liste, 'utilise');
564
+            }
565
+        } else {
566
+            foreach ($msg[$p] as $c => $l) {
567
+                $msg[$p][$c] = plugin_controler_lib($l['nom'], $l['lien']);
568
+            }
569
+        }
570
+        $erreurs[$plug] = $msg[$p];
571
+    }
572
+
573
+    ecrire_meta('plugin_erreur_activation', serialize($erreurs));
574 574
 }
575 575
 
576 576
 /**
@@ -585,25 +585,25 @@  discard block
 block discarded – undo
585 585
  *     - Liste des erreurs ou code HTML des erreurs
586 586
 **/
587 587
 function plugin_donne_erreurs($raw = false, $raz = true) {
588
-	if (!isset($GLOBALS['meta']['plugin_erreur_activation'])) {
589
-		return $raw ? array() : '';
590
-	}
591
-	$list = @unserialize($GLOBALS['meta']['plugin_erreur_activation']);
592
-	// Compat ancienne version
593
-	if (!$list) {
594
-		$list = $raw ? array() : $GLOBALS['meta']['plugin_erreur_activation'];
595
-	} elseif (!$raw) {
596
-		foreach ($list as $plug => $msg) {
597
-			$list[$plug] = "<li>" . _T('plugin_impossible_activer', array('plugin' => $plug))
598
-				. "<ul><li>" . implode("</li><li>", $msg) . "</li></ul></li>";
599
-		}
600
-		$list = "<ul>" . join("\n", $list) . "</ul>";
601
-	}
602
-	if ($raz) {
603
-		effacer_meta('plugin_erreur_activation');
604
-	}
605
-
606
-	return $list;
588
+    if (!isset($GLOBALS['meta']['plugin_erreur_activation'])) {
589
+        return $raw ? array() : '';
590
+    }
591
+    $list = @unserialize($GLOBALS['meta']['plugin_erreur_activation']);
592
+    // Compat ancienne version
593
+    if (!$list) {
594
+        $list = $raw ? array() : $GLOBALS['meta']['plugin_erreur_activation'];
595
+    } elseif (!$raw) {
596
+        foreach ($list as $plug => $msg) {
597
+            $list[$plug] = "<li>" . _T('plugin_impossible_activer', array('plugin' => $plug))
598
+                . "<ul><li>" . implode("</li><li>", $msg) . "</li></ul></li>";
599
+        }
600
+        $list = "<ul>" . join("\n", $list) . "</ul>";
601
+    }
602
+    if ($raz) {
603
+        effacer_meta('plugin_erreur_activation');
604
+    }
605
+
606
+    return $list;
607 607
 }
608 608
 
609 609
 /**
@@ -623,21 +623,21 @@  discard block
 block discarded – undo
623 623
  *
624 624
  **/
625 625
 function plugin_necessite($n, $liste, $balise = 'necessite') {
626
-	$msg = array();
627
-	foreach ($n as $need) {
628
-		$id = strtoupper($need['nom']);
629
-		$r = plugin_controler_necessite(
630
-			$liste, 
631
-			$id, 
632
-			isset($need['compatibilite']) ? $need['compatibilite'] : '', 
633
-			$balise
634
-		);
635
-		if ($r) {
636
-			$msg[] = $r;
637
-		}
638
-	}
639
-
640
-	return $msg;
626
+    $msg = array();
627
+    foreach ($n as $need) {
628
+        $id = strtoupper($need['nom']);
629
+        $r = plugin_controler_necessite(
630
+            $liste, 
631
+            $id, 
632
+            isset($need['compatibilite']) ? $need['compatibilite'] : '', 
633
+            $balise
634
+        );
635
+        if ($r) {
636
+            $msg[] = $r;
637
+        }
638
+    }
639
+
640
+    return $msg;
641 641
 }
642 642
 
643 643
 /**
@@ -659,16 +659,16 @@  discard block
 block discarded – undo
659 659
  *    Message d'erreur lorsque la dépendance est absente.
660 660
  **/
661 661
 function plugin_controler_necessite($liste, $nom, $intervalle, $balise) {
662
-	if (isset($liste[$nom]) and plugin_version_compatible($intervalle, $liste[$nom]['version'])) {
663
-		return '';
664
-	}
665
-
666
-	return plugin_message_incompatibilite(
667
-		$intervalle, 
668
-		(isset($liste[$nom]) ? $liste[$nom]['version'] : ""), 
669
-		$nom, 
670
-		$balise
671
-	);
662
+    if (isset($liste[$nom]) and plugin_version_compatible($intervalle, $liste[$nom]['version'])) {
663
+        return '';
664
+    }
665
+
666
+    return plugin_message_incompatibilite(
667
+        $intervalle, 
668
+        (isset($liste[$nom]) ? $liste[$nom]['version'] : ""), 
669
+        $nom, 
670
+        $balise
671
+    );
672 672
 }
673 673
 
674 674
 /**
@@ -685,70 +685,70 @@  discard block
 block discarded – undo
685 685
  */
686 686
 function plugin_message_incompatibilite($intervalle, $version, $nom, $balise) {
687 687
 
688
-	// prendre en compte les erreurs de dépendances à PHP
689
-	// ou à une extension PHP avec des messages d'erreurs dédiés.
690
-	$type = 'plugin';
691
-	if ($nom === 'SPIP') {
692
-		$type = 'spip';
693
-	} elseif ($nom === 'PHP') {
694
-		$type = 'php';
695
-	} elseif (strncmp($nom, 'PHP:', 4) === 0) {
696
-		$type = 'extension_php';
697
-		list(,$nom) = explode(':', $nom, 2);
698
-	}
699
-
700
-	if (preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) {
701
-		$minimum = $regs[1];
702
-		$maximum = $regs[2];
703
-
704
-		$minimum_inclus = $intervalle{0} == "[";
705
-		$maximum_inclus = substr($intervalle, -1) == "]";
706
-
707
-		if (strlen($minimum)) {
708
-			if ($minimum_inclus and spip_version_compare($version, $minimum, '<')) {
709
-				return _T("plugin_${balise}_${type}", array(
710
-					'plugin' => $nom,
711
-					'version' => ' &ge; ' . $minimum
712
-				));
713
-			}
714
-			if (!$minimum_inclus and spip_version_compare($version, $minimum, '<=')) {
715
-				return _T("plugin_${balise}_${type}", array(
716
-					'plugin' => $nom,
717
-					'version' => ' &gt; ' . $minimum
718
-				));
719
-			}
720
-		}
721
-
722
-		if (strlen($maximum)) {
723
-			if ($maximum_inclus and spip_version_compare($version, $maximum, '>')) {
724
-				return _T("plugin_${balise}_${type}", array(
725
-					'plugin' => $nom,
726
-					'version' => ' &le; ' . $maximum
727
-				));
728
-			}
729
-			if (!$maximum_inclus and spip_version_compare($version, $maximum, '>=')) {
730
-				return _T("plugin_${balise}_plugin", array(
731
-					'plugin' => $nom,
732
-					'version' => ' &lt; ' . $maximum
733
-				));
734
-			}
735
-		}
736
-	}
737
-
738
-	// note : il ne peut pas y avoir d'erreur sur
739
-	// - un 'utilise' sans version.
740
-	// - un 'php' sans version.
741
-	return _T("plugin_necessite_${type}_sans_version", array('plugin' => $nom));
688
+    // prendre en compte les erreurs de dépendances à PHP
689
+    // ou à une extension PHP avec des messages d'erreurs dédiés.
690
+    $type = 'plugin';
691
+    if ($nom === 'SPIP') {
692
+        $type = 'spip';
693
+    } elseif ($nom === 'PHP') {
694
+        $type = 'php';
695
+    } elseif (strncmp($nom, 'PHP:', 4) === 0) {
696
+        $type = 'extension_php';
697
+        list(,$nom) = explode(':', $nom, 2);
698
+    }
699
+
700
+    if (preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) {
701
+        $minimum = $regs[1];
702
+        $maximum = $regs[2];
703
+
704
+        $minimum_inclus = $intervalle{0} == "[";
705
+        $maximum_inclus = substr($intervalle, -1) == "]";
706
+
707
+        if (strlen($minimum)) {
708
+            if ($minimum_inclus and spip_version_compare($version, $minimum, '<')) {
709
+                return _T("plugin_${balise}_${type}", array(
710
+                    'plugin' => $nom,
711
+                    'version' => ' &ge; ' . $minimum
712
+                ));
713
+            }
714
+            if (!$minimum_inclus and spip_version_compare($version, $minimum, '<=')) {
715
+                return _T("plugin_${balise}_${type}", array(
716
+                    'plugin' => $nom,
717
+                    'version' => ' &gt; ' . $minimum
718
+                ));
719
+            }
720
+        }
721
+
722
+        if (strlen($maximum)) {
723
+            if ($maximum_inclus and spip_version_compare($version, $maximum, '>')) {
724
+                return _T("plugin_${balise}_${type}", array(
725
+                    'plugin' => $nom,
726
+                    'version' => ' &le; ' . $maximum
727
+                ));
728
+            }
729
+            if (!$maximum_inclus and spip_version_compare($version, $maximum, '>=')) {
730
+                return _T("plugin_${balise}_plugin", array(
731
+                    'plugin' => $nom,
732
+                    'version' => ' &lt; ' . $maximum
733
+                ));
734
+            }
735
+        }
736
+    }
737
+
738
+    // note : il ne peut pas y avoir d'erreur sur
739
+    // - un 'utilise' sans version.
740
+    // - un 'php' sans version.
741
+    return _T("plugin_necessite_${type}_sans_version", array('plugin' => $nom));
742 742
 }
743 743
 
744 744
 
745 745
 function plugin_controler_lib($lib, $url) {
746
-	/* Feature sortie du core, voir STP
746
+    /* Feature sortie du core, voir STP
747 747
 	 * if ($url) {
748 748
 		include_spip('inc/charger_plugin');
749 749
 		$url = '<br />'	. bouton_telechargement_plugin($url, 'lib');
750 750
 	}*/
751
-	return _T('plugin_necessite_lib', array('lib' => $lib)) . " <a href='$url'>$url</a>";
751
+    return _T('plugin_necessite_lib', array('lib' => $lib)) . " <a href='$url'>$url</a>";
752 752
 }
753 753
 
754 754
 
@@ -763,7 +763,7 @@  discard block
 block discarded – undo
763 763
  *     true si il y a eu des modifications sur la liste des plugins actifs, false sinon
764 764
  **/
765 765
 function actualise_plugins_actifs($pipe_recherche = false) {
766
-	return ecrire_plugin_actifs('', $pipe_recherche, 'force');
766
+    return ecrire_plugin_actifs('', $pipe_recherche, 'force');
767 767
 }
768 768
 
769 769
 
@@ -790,113 +790,113 @@  discard block
 block discarded – undo
790 790
  **/
791 791
 function ecrire_plugin_actifs($plugin, $pipe_recherche = false, $operation = 'raz') {
792 792
 
793
-	// creer le repertoire cache/ si necessaire ! (installation notamment)
794
-	$cache = sous_repertoire(_DIR_CACHE, '', false, true);
795
-
796
-	// Si on n'a ni cache accessible, ni connexion SQL, on ne peut pas faire grand chose encore.
797
-	if (!$cache and !spip_connect()) {
798
-		return false;
799
-	}
800
-
801
-	if ($operation != 'raz') {
802
-		$plugin_valides = liste_chemin_plugin_actifs();
803
-		$plugin_valides = is_plugin_dir($plugin_valides);
804
-		if (defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) {
805
-			$plugin_valides_supp = liste_chemin_plugin_actifs(_DIR_PLUGINS_SUPPL);
806
-			$plugin_valides_supp = is_plugin_dir($plugin_valides_supp, _DIR_PLUGINS_SUPPL);
807
-			$plugin_valides = array_merge($plugin_valides, $plugin_valides_supp);
808
-		}
809
-		// si des plugins sont en attentes (coches mais impossible a activer)
810
-		// on les reinjecte ici
811
-		if (isset($GLOBALS['meta']['plugin_attente'])
812
-			and $a = unserialize($GLOBALS['meta']['plugin_attente'])
813
-		) {
814
-			$plugin_valides = $plugin_valides + liste_chemin_plugin($a);
815
-		}
816
-
817
-		if ($operation == 'ajoute') {
818
-			$plugin = array_merge($plugin_valides, $plugin);
819
-		} elseif ($operation == 'enleve') {
820
-			$plugin = array_diff($plugin_valides, $plugin);
821
-		} else {
822
-			$plugin = $plugin_valides;
823
-		}
824
-	}
825
-	$actifs_avant = isset($GLOBALS['meta']['plugin']) ? $GLOBALS['meta']['plugin'] : '';
826
-
827
-	// si une fonction de gestion de dependances existe, l'appeler ici
828
-	if ($ajouter_dependances = charger_fonction("ajouter_dependances", "plugins", true)) {
829
-		$plugin = $ajouter_dependances($plugin);
830
-	}
831
-
832
-	// recharger le xml des plugins a activer
833
-	// on force le reload ici, meme si le fichier xml n'a pas change
834
-	// pour ne pas rater l'ajout ou la suppression d'un fichier fonctions/options/administrations
835
-	// pourra etre evite quand on ne supportera plus les plugin.xml
836
-	// en deplacant la detection de ces fichiers dans la compilation ci dessous
837
-	list($infos, $liste, $invalides) = liste_plugin_valides($plugin, true);
838
-	// trouver l'ordre d'activation
839
-	list($plugin_valides, $ordre, $reste) = plugin_trier($infos, $liste);
840
-	if ($invalides or $reste) {
841
-		plugins_erreurs(array_merge($invalides, $reste), $liste, $infos);
842
-	}
843
-
844
-	// Ignorer les plugins necessitant une lib absente
845
-	// et preparer la meta d'entete Http
846
-	$err = $msg = $header = array();
847
-	foreach ($plugin_valides as $p => $resume) {
848
-		// Les headers ne doivent pas indiquer les versions des extensions PHP, ni la version PHP
849
-		if (0 !== strpos($p, 'PHP:') and $p !== 'PHP') {
850
-			$header[] = $p . ($resume['version'] ? "(" . $resume['version'] . ")" : "");
851
-		}
852
-		if ($resume['dir']) {
853
-			foreach ($infos[$resume['dir_type']][$resume['dir']]['lib'] as $l) {
854
-				if (!find_in_path($l['nom'], 'lib/')) {
855
-					$err[$p] = $resume;
856
-					$msg[$p][] = $l;
857
-					unset($plugin_valides[$p]);
858
-				}
859
-			}
860
-		}
861
-	}
862
-	if ($err) {
863
-		plugins_erreurs($err, '', $infos, $msg);
864
-	}
865
-
866
-	if (isset($GLOBALS['meta']['message_crash_plugins'])) {
867
-		effacer_meta('message_crash_plugins');
868
-	}
869
-	ecrire_meta('plugin', serialize($plugin_valides));
870
-	$liste = array_diff_key($liste, $plugin_valides);
871
-	ecrire_meta('plugin_attente', serialize($liste));
872
-	$header = strtolower(implode(",", $header));
873
-	if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) {
874
-		ecrire_fichier(_DIR_VAR . "config.txt",
875
-			(defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : "Composed-By: SPIP") . ' ' . $GLOBALS['spip_version_affichee'] . " @ www.spip.net + " . $header);
876
-	} else {
877
-		@unlink(_DIR_VAR . "config.txt");
878
-	}
879
-	// generer charger_plugins_chemin.php
880
-	plugins_precompile_chemin($plugin_valides, $ordre);
881
-	// generer les fichiers
882
-	// - charger_plugins_options.php
883
-	// - charger_plugins_fonctions.php
884
-	plugins_precompile_xxxtions($plugin_valides, $ordre);
885
-	// charger les chemins des plugins et les fichiers d'options 
886
-	// (qui peuvent déclarer / utiliser des pipelines, ajouter d'autres chemins)
887
-	plugins_amorcer_plugins_actifs();
888
-	// mise a jour de la matrice des pipelines
889
-	$prepend_code = pipeline_matrice_precompile($plugin_valides, $ordre, $pipe_recherche);
890
-	// generer le fichier _CACHE_PIPELINE
891
-	pipeline_precompile($prepend_code);
892
-
893
-	if (spip_connect()) {
894
-		// lancer et initialiser les nouveaux crons !
895
-		include_spip('inc/genie');
896
-		genie_queue_watch_dist();
897
-	}
898
-
899
-	return ($GLOBALS['meta']['plugin'] != $actifs_avant);
793
+    // creer le repertoire cache/ si necessaire ! (installation notamment)
794
+    $cache = sous_repertoire(_DIR_CACHE, '', false, true);
795
+
796
+    // Si on n'a ni cache accessible, ni connexion SQL, on ne peut pas faire grand chose encore.
797
+    if (!$cache and !spip_connect()) {
798
+        return false;
799
+    }
800
+
801
+    if ($operation != 'raz') {
802
+        $plugin_valides = liste_chemin_plugin_actifs();
803
+        $plugin_valides = is_plugin_dir($plugin_valides);
804
+        if (defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) {
805
+            $plugin_valides_supp = liste_chemin_plugin_actifs(_DIR_PLUGINS_SUPPL);
806
+            $plugin_valides_supp = is_plugin_dir($plugin_valides_supp, _DIR_PLUGINS_SUPPL);
807
+            $plugin_valides = array_merge($plugin_valides, $plugin_valides_supp);
808
+        }
809
+        // si des plugins sont en attentes (coches mais impossible a activer)
810
+        // on les reinjecte ici
811
+        if (isset($GLOBALS['meta']['plugin_attente'])
812
+            and $a = unserialize($GLOBALS['meta']['plugin_attente'])
813
+        ) {
814
+            $plugin_valides = $plugin_valides + liste_chemin_plugin($a);
815
+        }
816
+
817
+        if ($operation == 'ajoute') {
818
+            $plugin = array_merge($plugin_valides, $plugin);
819
+        } elseif ($operation == 'enleve') {
820
+            $plugin = array_diff($plugin_valides, $plugin);
821
+        } else {
822
+            $plugin = $plugin_valides;
823
+        }
824
+    }
825
+    $actifs_avant = isset($GLOBALS['meta']['plugin']) ? $GLOBALS['meta']['plugin'] : '';
826
+
827
+    // si une fonction de gestion de dependances existe, l'appeler ici
828
+    if ($ajouter_dependances = charger_fonction("ajouter_dependances", "plugins", true)) {
829
+        $plugin = $ajouter_dependances($plugin);
830
+    }
831
+
832
+    // recharger le xml des plugins a activer
833
+    // on force le reload ici, meme si le fichier xml n'a pas change
834
+    // pour ne pas rater l'ajout ou la suppression d'un fichier fonctions/options/administrations
835
+    // pourra etre evite quand on ne supportera plus les plugin.xml
836
+    // en deplacant la detection de ces fichiers dans la compilation ci dessous
837
+    list($infos, $liste, $invalides) = liste_plugin_valides($plugin, true);
838
+    // trouver l'ordre d'activation
839
+    list($plugin_valides, $ordre, $reste) = plugin_trier($infos, $liste);
840
+    if ($invalides or $reste) {
841
+        plugins_erreurs(array_merge($invalides, $reste), $liste, $infos);
842
+    }
843
+
844
+    // Ignorer les plugins necessitant une lib absente
845
+    // et preparer la meta d'entete Http
846
+    $err = $msg = $header = array();
847
+    foreach ($plugin_valides as $p => $resume) {
848
+        // Les headers ne doivent pas indiquer les versions des extensions PHP, ni la version PHP
849
+        if (0 !== strpos($p, 'PHP:') and $p !== 'PHP') {
850
+            $header[] = $p . ($resume['version'] ? "(" . $resume['version'] . ")" : "");
851
+        }
852
+        if ($resume['dir']) {
853
+            foreach ($infos[$resume['dir_type']][$resume['dir']]['lib'] as $l) {
854
+                if (!find_in_path($l['nom'], 'lib/')) {
855
+                    $err[$p] = $resume;
856
+                    $msg[$p][] = $l;
857
+                    unset($plugin_valides[$p]);
858
+                }
859
+            }
860
+        }
861
+    }
862
+    if ($err) {
863
+        plugins_erreurs($err, '', $infos, $msg);
864
+    }
865
+
866
+    if (isset($GLOBALS['meta']['message_crash_plugins'])) {
867
+        effacer_meta('message_crash_plugins');
868
+    }
869
+    ecrire_meta('plugin', serialize($plugin_valides));
870
+    $liste = array_diff_key($liste, $plugin_valides);
871
+    ecrire_meta('plugin_attente', serialize($liste));
872
+    $header = strtolower(implode(",", $header));
873
+    if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) {
874
+        ecrire_fichier(_DIR_VAR . "config.txt",
875
+            (defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : "Composed-By: SPIP") . ' ' . $GLOBALS['spip_version_affichee'] . " @ www.spip.net + " . $header);
876
+    } else {
877
+        @unlink(_DIR_VAR . "config.txt");
878
+    }
879
+    // generer charger_plugins_chemin.php
880
+    plugins_precompile_chemin($plugin_valides, $ordre);
881
+    // generer les fichiers
882
+    // - charger_plugins_options.php
883
+    // - charger_plugins_fonctions.php
884
+    plugins_precompile_xxxtions($plugin_valides, $ordre);
885
+    // charger les chemins des plugins et les fichiers d'options 
886
+    // (qui peuvent déclarer / utiliser des pipelines, ajouter d'autres chemins)
887
+    plugins_amorcer_plugins_actifs();
888
+    // mise a jour de la matrice des pipelines
889
+    $prepend_code = pipeline_matrice_precompile($plugin_valides, $ordre, $pipe_recherche);
890
+    // generer le fichier _CACHE_PIPELINE
891
+    pipeline_precompile($prepend_code);
892
+
893
+    if (spip_connect()) {
894
+        // lancer et initialiser les nouveaux crons !
895
+        include_spip('inc/genie');
896
+        genie_queue_watch_dist();
897
+    }
898
+
899
+    return ($GLOBALS['meta']['plugin'] != $actifs_avant);
900 900
 }
901 901
 
902 902
 /**
@@ -915,56 +915,56 @@  discard block
 block discarded – undo
915 915
  *     Couples (prefixe => infos complètes) des plugins qui seront actifs, dans l'ordre de leurs dépendances
916 916
 **/
917 917
 function plugins_precompile_chemin($plugin_valides, $ordre) {
918
-	$chemins = array();
919
-	$contenu = "";
920
-	foreach ($ordre as $p => $info) {
921
-		// $ordre peur contenir des plugins en attente et non valides pour ce hit
922
-		if (isset($plugin_valides[$p])) {
923
-			$dir_type = $plugin_valides[$p]['dir_type'];
924
-			$plug = $plugin_valides[$p]['dir'];
925
-			// definir le plugin, donc le path avant l'include du fichier options
926
-			// permet de faire des include_spip pour attraper un inc_ du plugin
927
-
928
-			$dir = $dir_type . ".'" . $plug . "/'";
929
-
930
-			$prefix = strtoupper(preg_replace(',\W,', '_', $info['prefix']));
931
-			if (
932
-				$prefix !== "SPIP"
933
-				and strpos($dir, ":") === false // exclure le cas des procure:
934
-			) {
935
-				$contenu .= "define('_DIR_PLUGIN_$prefix',$dir);\n";
936
-				foreach ($info['chemin'] as $chemin) {
937
-					if (!isset($chemin['version']) or plugin_version_compatible($chemin['version'],
938
-							$GLOBALS['spip_version_branche'], 'spip')
939
-					) {
940
-						$dir = $chemin['path'];
941
-						if (strlen($dir) and $dir{0} == "/") {
942
-							$dir = substr($dir, 1);
943
-						}
944
-						if (strlen($dir) and $dir == "./") {
945
-							$dir = '';
946
-						}
947
-						if (strlen($dir)) {
948
-							$dir = rtrim($dir, '/') . '/';
949
-						}
950
-						if (!isset($chemin['type']) or $chemin['type'] == 'public') {
951
-							$chemins['public'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : "");
952
-						}
953
-						if (!isset($chemin['type']) or $chemin['type'] == 'prive') {
954
-							$chemins['prive'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : "");
955
-						}
956
-					}
957
-				}
958
-			}
959
-		}
960
-	}
961
-	if (count($chemins)) {
962
-		$contenu .= "if (_DIR_RESTREINT) _chemin(implode(':',array(" . implode(',',
963
-				array_reverse($chemins['public'])) . ")));\n"
964
-			. "else _chemin(implode(':',array(" . implode(',', array_reverse($chemins['prive'])) . ")));\n";
965
-	}
966
-
967
-	ecrire_fichier_php(_CACHE_PLUGINS_PATH, $contenu);
918
+    $chemins = array();
919
+    $contenu = "";
920
+    foreach ($ordre as $p => $info) {
921
+        // $ordre peur contenir des plugins en attente et non valides pour ce hit
922
+        if (isset($plugin_valides[$p])) {
923
+            $dir_type = $plugin_valides[$p]['dir_type'];
924
+            $plug = $plugin_valides[$p]['dir'];
925
+            // definir le plugin, donc le path avant l'include du fichier options
926
+            // permet de faire des include_spip pour attraper un inc_ du plugin
927
+
928
+            $dir = $dir_type . ".'" . $plug . "/'";
929
+
930
+            $prefix = strtoupper(preg_replace(',\W,', '_', $info['prefix']));
931
+            if (
932
+                $prefix !== "SPIP"
933
+                and strpos($dir, ":") === false // exclure le cas des procure:
934
+            ) {
935
+                $contenu .= "define('_DIR_PLUGIN_$prefix',$dir);\n";
936
+                foreach ($info['chemin'] as $chemin) {
937
+                    if (!isset($chemin['version']) or plugin_version_compatible($chemin['version'],
938
+                            $GLOBALS['spip_version_branche'], 'spip')
939
+                    ) {
940
+                        $dir = $chemin['path'];
941
+                        if (strlen($dir) and $dir{0} == "/") {
942
+                            $dir = substr($dir, 1);
943
+                        }
944
+                        if (strlen($dir) and $dir == "./") {
945
+                            $dir = '';
946
+                        }
947
+                        if (strlen($dir)) {
948
+                            $dir = rtrim($dir, '/') . '/';
949
+                        }
950
+                        if (!isset($chemin['type']) or $chemin['type'] == 'public') {
951
+                            $chemins['public'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : "");
952
+                        }
953
+                        if (!isset($chemin['type']) or $chemin['type'] == 'prive') {
954
+                            $chemins['prive'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : "");
955
+                        }
956
+                    }
957
+                }
958
+            }
959
+        }
960
+    }
961
+    if (count($chemins)) {
962
+        $contenu .= "if (_DIR_RESTREINT) _chemin(implode(':',array(" . implode(',',
963
+                array_reverse($chemins['public'])) . ")));\n"
964
+            . "else _chemin(implode(':',array(" . implode(',', array_reverse($chemins['prive'])) . ")));\n";
965
+    }
966
+
967
+    ecrire_fichier_php(_CACHE_PLUGINS_PATH, $contenu);
968 968
 }
969 969
 
970 970
 /**
@@ -982,65 +982,65 @@  discard block
 block discarded – undo
982 982
  *     Couples (prefixe => infos complètes) des plugins qui seront actifs, dans l'ordre de leurs dépendances
983 983
 **/
984 984
 function plugins_precompile_xxxtions($plugin_valides, $ordre) {
985
-	$contenu = array('options' => '', 'fonctions' => '');
986
-	$boutons = array();
987
-	$onglets = array();
988
-	$sign = "";
989
-
990
-	foreach ($ordre as $p => $info) {
991
-		// $ordre peur contenir des plugins en attente et non valides pour ce hit
992
-		if (isset($plugin_valides[$p])) {
993
-			$dir_type = $plugin_valides[$p]['dir_type'];
994
-			$plug = $plugin_valides[$p]['dir'];
995
-			$dir = constant($dir_type);
996
-			$root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type);
997
-			if ($info['menu']) {
998
-				$boutons = array_merge($boutons, $info['menu']);
999
-			}
1000
-			if ($info['onglet']) {
1001
-				$onglets = array_merge($onglets, $info['onglet']);
1002
-			}
1003
-			foreach ($contenu as $charge => $v) {
1004
-				// si pas declare/detecte a la lecture du paquet.xml,
1005
-				// detecer a nouveau ici puisque son ajout ne provoque pas une modif du paquet.xml
1006
-				// donc ni sa relecture, ni sa detection
1007
-				if (!isset($info[$charge])
1008
-					and $dir // exclure le cas du plugin "SPIP"
1009
-					and strpos($dir, ":") === false // exclure le cas des procure:
1010
-					and file_exists("$dir$plug/paquet.xml") // uniquement pour les paquet.xml
1011
-				) {
1012
-					if (is_readable("$dir$plug/" . ($file = $info['prefix'] . "_" . $charge . ".php"))) {
1013
-						$info[$charge] = array($file);
1014
-					}
1015
-				}
1016
-				if (isset($info[$charge])) {
1017
-					$files = $info[$charge];
1018
-					foreach ($files as $k => $file) {
1019
-						// on genere un if file_exists devant chaque include
1020
-						// pour pouvoir garder le meme niveau d'erreur general
1021
-						$file = trim($file);
1022
-						if (!is_readable("$dir$plug/$file")
1023
-							// uniquement pour les paquet.xml
1024
-							and file_exists("$dir$plug/paquet.xml")
1025
-						) {
1026
-							unset($info[$charge][$k]);
1027
-						} else {
1028
-							$_file = $root_dir_type . ".'$plug/$file'";
1029
-							$contenu[$charge] .= "include_once_check($_file);\n";
1030
-						}
1031
-					}
1032
-				}
1033
-			}
1034
-			$sign .= md5(serialize($info));
1035
-		}
1036
-	}
1037
-
1038
-	$contenu['options'] = "define('_PLUGINS_HASH','" . md5($sign) . "');\n" . $contenu['options'];
1039
-	$contenu['fonctions'] .= plugin_ongletbouton("boutons_plugins", $boutons)
1040
-		. plugin_ongletbouton("onglets_plugins", $onglets);
1041
-
1042
-	ecrire_fichier_php(_CACHE_PLUGINS_OPT, $contenu['options']);
1043
-	ecrire_fichier_php(_CACHE_PLUGINS_FCT, $contenu['fonctions']);
985
+    $contenu = array('options' => '', 'fonctions' => '');
986
+    $boutons = array();
987
+    $onglets = array();
988
+    $sign = "";
989
+
990
+    foreach ($ordre as $p => $info) {
991
+        // $ordre peur contenir des plugins en attente et non valides pour ce hit
992
+        if (isset($plugin_valides[$p])) {
993
+            $dir_type = $plugin_valides[$p]['dir_type'];
994
+            $plug = $plugin_valides[$p]['dir'];
995
+            $dir = constant($dir_type);
996
+            $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type);
997
+            if ($info['menu']) {
998
+                $boutons = array_merge($boutons, $info['menu']);
999
+            }
1000
+            if ($info['onglet']) {
1001
+                $onglets = array_merge($onglets, $info['onglet']);
1002
+            }
1003
+            foreach ($contenu as $charge => $v) {
1004
+                // si pas declare/detecte a la lecture du paquet.xml,
1005
+                // detecer a nouveau ici puisque son ajout ne provoque pas une modif du paquet.xml
1006
+                // donc ni sa relecture, ni sa detection
1007
+                if (!isset($info[$charge])
1008
+                    and $dir // exclure le cas du plugin "SPIP"
1009
+                    and strpos($dir, ":") === false // exclure le cas des procure:
1010
+                    and file_exists("$dir$plug/paquet.xml") // uniquement pour les paquet.xml
1011
+                ) {
1012
+                    if (is_readable("$dir$plug/" . ($file = $info['prefix'] . "_" . $charge . ".php"))) {
1013
+                        $info[$charge] = array($file);
1014
+                    }
1015
+                }
1016
+                if (isset($info[$charge])) {
1017
+                    $files = $info[$charge];
1018
+                    foreach ($files as $k => $file) {
1019
+                        // on genere un if file_exists devant chaque include
1020
+                        // pour pouvoir garder le meme niveau d'erreur general
1021
+                        $file = trim($file);
1022
+                        if (!is_readable("$dir$plug/$file")
1023
+                            // uniquement pour les paquet.xml
1024
+                            and file_exists("$dir$plug/paquet.xml")
1025
+                        ) {
1026
+                            unset($info[$charge][$k]);
1027
+                        } else {
1028
+                            $_file = $root_dir_type . ".'$plug/$file'";
1029
+                            $contenu[$charge] .= "include_once_check($_file);\n";
1030
+                        }
1031
+                    }
1032
+                }
1033
+            }
1034
+            $sign .= md5(serialize($info));
1035
+        }
1036
+    }
1037
+
1038
+    $contenu['options'] = "define('_PLUGINS_HASH','" . md5($sign) . "');\n" . $contenu['options'];
1039
+    $contenu['fonctions'] .= plugin_ongletbouton("boutons_plugins", $boutons)
1040
+        . plugin_ongletbouton("onglets_plugins", $onglets);
1041
+
1042
+    ecrire_fichier_php(_CACHE_PLUGINS_OPT, $contenu['options']);
1043
+    ecrire_fichier_php(_CACHE_PLUGINS_FCT, $contenu['fonctions']);
1044 1044
 }
1045 1045
 
1046 1046
 /**
@@ -1059,24 +1059,24 @@  discard block
 block discarded – undo
1059 1059
  * @return string Code php
1060 1060
  */
1061 1061
 function plugin_ongletbouton($nom, $val) {
1062
-	if (!$val) {
1063
-		$val = array();
1064
-	}
1065
-
1066
-	$val = serialize($val);
1067
-	$md5 = md5($val);
1068
-
1069
-	if (!defined("_UPDATED_$nom")) {
1070
-		define("_UPDATED_$nom", $val);
1071
-		define("_UPDATED_md5_$nom", $md5);
1072
-	}
1073
-	$val = "unserialize('" . str_replace("'", "\'", $val) . "')";
1074
-
1075
-	return
1076
-		"if (!function_exists('$nom')) {\n"
1077
-		. "function $nom(){return defined('_UPDATED_$nom')?unserialize(_UPDATED_$nom):$val;}\n"
1078
-		. "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'" . $md5 . "';}\n"
1079
-		. "}\n";
1062
+    if (!$val) {
1063
+        $val = array();
1064
+    }
1065
+
1066
+    $val = serialize($val);
1067
+    $md5 = md5($val);
1068
+
1069
+    if (!defined("_UPDATED_$nom")) {
1070
+        define("_UPDATED_$nom", $val);
1071
+        define("_UPDATED_md5_$nom", $md5);
1072
+    }
1073
+    $val = "unserialize('" . str_replace("'", "\'", $val) . "')";
1074
+
1075
+    return
1076
+        "if (!function_exists('$nom')) {\n"
1077
+        . "function $nom(){return defined('_UPDATED_$nom')?unserialize(_UPDATED_$nom):$val;}\n"
1078
+        . "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'" . $md5 . "';}\n"
1079
+        . "}\n";
1080 1080
 }
1081 1081
 
1082 1082
 /**
@@ -1091,15 +1091,15 @@  discard block
 block discarded – undo
1091 1091
 **/
1092 1092
 function plugins_amorcer_plugins_actifs() {
1093 1093
 
1094
-	if (@is_readable(_CACHE_PLUGINS_PATH)) {
1095
-		include_once(_CACHE_PLUGINS_PATH);
1096
-	} 
1094
+    if (@is_readable(_CACHE_PLUGINS_PATH)) {
1095
+        include_once(_CACHE_PLUGINS_PATH);
1096
+    } 
1097 1097
 
1098
-	if (@is_readable(_CACHE_PLUGINS_OPT)) {
1099
-		include_once(_CACHE_PLUGINS_OPT);
1100
-	} else {
1101
-		spip_log("pipelines desactives: impossible de produire " . _CACHE_PLUGINS_OPT);
1102
-	}
1098
+    if (@is_readable(_CACHE_PLUGINS_OPT)) {
1099
+        include_once(_CACHE_PLUGINS_OPT);
1100
+    } else {
1101
+        spip_log("pipelines desactives: impossible de produire " . _CACHE_PLUGINS_OPT);
1102
+    }
1103 1103
 }
1104 1104
 
1105 1105
 /**
@@ -1122,136 +1122,136 @@  discard block
 block discarded – undo
1122 1122
  *     Couples (nom du pipeline => Code PHP à insérer au début du pipeline)
1123 1123
 **/
1124 1124
 function pipeline_matrice_precompile($plugin_valides, $ordre, $pipe_recherche) {
1125
-	static $liste_pipe_manquants = array();
1126
-	if (($pipe_recherche) && (!in_array($pipe_recherche, $liste_pipe_manquants))) {
1127
-		$liste_pipe_manquants[] = $pipe_recherche;
1128
-	}
1129
-
1130
-	$prepend_code = array();
1131
-
1132
-	foreach ($ordre as $p => $info) {
1133
-		// $ordre peur contenir des plugins en attente et non valides pour ce hit
1134
-		if (isset($plugin_valides[$p])) {
1135
-			$dir_type = $plugin_valides[$p]['dir_type'];
1136
-			$root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type);
1137
-			$plug = $plugin_valides[$p]['dir'];
1138
-			$prefix = (($info['prefix'] == "spip") ? "" : $info['prefix'] . "_");
1139
-			if (isset($info['pipeline']) and is_array($info['pipeline'])) {
1140
-				foreach ($info['pipeline'] as $pipe) {
1141
-					$nom = $pipe['nom'];
1142
-					if (isset($pipe['action'])) {
1143
-						$action = $pipe['action'];
1144
-					} else {
1145
-						$action = $nom;
1146
-					}
1147
-					$nomlower = strtolower($nom);
1148
-					if ($nomlower != $nom
1149
-						and isset($GLOBALS['spip_pipeline'][$nom])
1150
-						and !isset($GLOBALS['spip_pipeline'][$nomlower])
1151
-					) {
1152
-						$GLOBALS['spip_pipeline'][$nomlower] = $GLOBALS['spip_pipeline'][$nom];
1153
-						unset($GLOBALS['spip_pipeline'][$nom]);
1154
-					}
1155
-					$nom = $nomlower;
1156
-					// une action vide est une declaration qui ne doit pas etre compilee !
1157
-					if (!isset($GLOBALS['spip_pipeline'][$nom])) // creer le pipeline eventuel
1158
-					{
1159
-						$GLOBALS['spip_pipeline'][$nom] = "";
1160
-					}
1161
-					if ($action) {
1162
-						if (strpos($GLOBALS['spip_pipeline'][$nom], "|$prefix$action") === false) {
1163
-							$GLOBALS['spip_pipeline'][$nom] = preg_replace(",(\|\||$),", "|$prefix$action\\1",
1164
-								$GLOBALS['spip_pipeline'][$nom], 1);
1165
-						}
1166
-						if (isset($pipe['inclure'])) {
1167
-							$GLOBALS['spip_matrice']["$prefix$action"] =
1168
-								"$root_dir_type:$plug/" . $pipe['inclure'];
1169
-						}
1170
-					}
1171
-				}
1172
-			}
1173
-			if (isset($info['genie']) and count($info['genie'])) {
1174
-				if (!isset($prepend_code['taches_generales_cron'])) {
1175
-					$prepend_code['taches_generales_cron'] = "";
1176
-				}
1177
-				foreach ($info['genie'] as $genie) {
1178
-					$nom = $prefix . $genie['nom'];
1179
-					$periode = max(60, intval($genie['periode']));
1180
-					if (charger_fonction($nom, "genie", true)) {
1181
-						$prepend_code['taches_generales_cron'] .= "\$val['$nom'] = $periode;\n";
1182
-					} else {
1183
-						spip_log("Fonction genie_$nom introuvable", _LOG_ERREUR);
1184
-					}
1185
-				}
1186
-			}
1187
-			if (isset($info['style']) and count($info['style'])) {
1188
-				if (!isset($prepend_code['insert_head_css'])) {
1189
-					$prepend_code['insert_head_css'] = "";
1190
-				}
1191
-				if (!isset($prepend_code['header_prive_css'])) {
1192
-					$prepend_code['header_prive_css'] = "";
1193
-				}
1194
-				foreach ($info['style'] as $style) {
1195
-					if (isset($style['path']) and $style['path']) {
1196
-						$code = "if (\$f=timestamp(direction_css(find_in_path('" . addslashes($style['path']) . "')))) ";
1197
-					} else {
1198
-						$code = "if (\$f='" . addslashes($style['url']) . "') ";
1199
-					}
1200
-					$code .= "\$val .= '<link rel=\"stylesheet\" href=\"'.\$f.'\" type=\"text/css\"";
1201
-					if (isset($style['media']) and strlen($style['media'])) {
1202
-						$code .= " media=\"" . addslashes($style['media']) . "\"";
1203
-					}
1204
-					$code .= "/>';\n";
1205
-					if ($style['type'] != 'prive') {
1206
-						$prepend_code['insert_head_css'] .= $code;
1207
-					}
1208
-					if ($style['type'] != 'public') {
1209
-						$prepend_code['header_prive_css'] .= $code;
1210
-					}
1211
-				}
1212
-			}
1213
-			if (!isset($prepend_code['insert_head'])) {
1214
-				$prepend_code['insert_head'] = "";
1215
-			}
1216
-			if (!isset($prepend_code['header_prive'])) {
1217
-				$prepend_code['header_prive'] = "";
1218
-			}
1219
-			if (isset($info['script']) and count($info['script'])) {
1220
-				foreach ($info['script'] as $script) {
1221
-					if (isset($script['path']) and $script['path']) {
1222
-						$code = "if (\$f=timestamp(find_in_path('" . addslashes($script['path']) . "'))) ";
1223
-					} else {
1224
-						$code = "if (\$f='" . addslashes($script['url']) . "') ";
1225
-					}
1226
-					$code .= "\$val .= '<script src=\"'.\$f.'\" type=\"text/javascript\"></script>';\n";
1227
-					if ($script['type'] != 'prive') {
1228
-						$prepend_code['insert_head'] .= $code;
1229
-					}
1230
-					if ($script['type'] != 'public') {
1231
-						$prepend_code['header_prive'] .= $code;
1232
-					}
1233
-				}
1234
-			}
1235
-		}
1236
-	}
1237
-
1238
-	$prepend_code['insert_head'] =
1239
-		"include_once_check(_DIR_RESTREINT . 'inc/pipelines.php');\n"
1240
-		. "\$val = minipipe('f_jQuery', \$val);\n"
1241
-		. $prepend_code['insert_head'];
1242
-	$prepend_code['header_prive'] =
1243
-		"include_once_check(_DIR_RESTREINT . 'inc/pipelines_ecrire.php');\n"
1244
-		. "\$val = minipipe('f_jQuery_prive', \$val);\n"
1245
-		. $prepend_code['header_prive'];
1246
-
1247
-	// on ajoute les pipe qui ont ete recenses manquants
1248
-	foreach ($liste_pipe_manquants as $add_pipe) {
1249
-		if (!isset($GLOBALS['spip_pipeline'][$add_pipe])) {
1250
-			$GLOBALS['spip_pipeline'][$add_pipe] = '';
1251
-		}
1252
-	}
1253
-
1254
-	return $prepend_code;
1125
+    static $liste_pipe_manquants = array();
1126
+    if (($pipe_recherche) && (!in_array($pipe_recherche, $liste_pipe_manquants))) {
1127
+        $liste_pipe_manquants[] = $pipe_recherche;
1128
+    }
1129
+
1130
+    $prepend_code = array();
1131
+
1132
+    foreach ($ordre as $p => $info) {
1133
+        // $ordre peur contenir des plugins en attente et non valides pour ce hit
1134
+        if (isset($plugin_valides[$p])) {
1135
+            $dir_type = $plugin_valides[$p]['dir_type'];
1136
+            $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type);
1137
+            $plug = $plugin_valides[$p]['dir'];
1138
+            $prefix = (($info['prefix'] == "spip") ? "" : $info['prefix'] . "_");
1139
+            if (isset($info['pipeline']) and is_array($info['pipeline'])) {
1140
+                foreach ($info['pipeline'] as $pipe) {
1141
+                    $nom = $pipe['nom'];
1142
+                    if (isset($pipe['action'])) {
1143
+                        $action = $pipe['action'];
1144
+                    } else {
1145
+                        $action = $nom;
1146
+                    }
1147
+                    $nomlower = strtolower($nom);
1148
+                    if ($nomlower != $nom
1149
+                        and isset($GLOBALS['spip_pipeline'][$nom])
1150
+                        and !isset($GLOBALS['spip_pipeline'][$nomlower])
1151
+                    ) {
1152
+                        $GLOBALS['spip_pipeline'][$nomlower] = $GLOBALS['spip_pipeline'][$nom];
1153
+                        unset($GLOBALS['spip_pipeline'][$nom]);
1154
+                    }
1155
+                    $nom = $nomlower;
1156
+                    // une action vide est une declaration qui ne doit pas etre compilee !
1157
+                    if (!isset($GLOBALS['spip_pipeline'][$nom])) // creer le pipeline eventuel
1158
+                    {
1159
+                        $GLOBALS['spip_pipeline'][$nom] = "";
1160
+                    }
1161
+                    if ($action) {
1162
+                        if (strpos($GLOBALS['spip_pipeline'][$nom], "|$prefix$action") === false) {
1163
+                            $GLOBALS['spip_pipeline'][$nom] = preg_replace(",(\|\||$),", "|$prefix$action\\1",
1164
+                                $GLOBALS['spip_pipeline'][$nom], 1);
1165
+                        }
1166
+                        if (isset($pipe['inclure'])) {
1167
+                            $GLOBALS['spip_matrice']["$prefix$action"] =
1168
+                                "$root_dir_type:$plug/" . $pipe['inclure'];
1169
+                        }
1170
+                    }
1171
+                }
1172
+            }
1173
+            if (isset($info['genie']) and count($info['genie'])) {
1174
+                if (!isset($prepend_code['taches_generales_cron'])) {
1175
+                    $prepend_code['taches_generales_cron'] = "";
1176
+                }
1177
+                foreach ($info['genie'] as $genie) {
1178
+                    $nom = $prefix . $genie['nom'];
1179
+                    $periode = max(60, intval($genie['periode']));
1180
+                    if (charger_fonction($nom, "genie", true)) {
1181
+                        $prepend_code['taches_generales_cron'] .= "\$val['$nom'] = $periode;\n";
1182
+                    } else {
1183
+                        spip_log("Fonction genie_$nom introuvable", _LOG_ERREUR);
1184
+                    }
1185
+                }
1186
+            }
1187
+            if (isset($info['style']) and count($info['style'])) {
1188
+                if (!isset($prepend_code['insert_head_css'])) {
1189
+                    $prepend_code['insert_head_css'] = "";
1190
+                }
1191
+                if (!isset($prepend_code['header_prive_css'])) {
1192
+                    $prepend_code['header_prive_css'] = "";
1193
+                }
1194
+                foreach ($info['style'] as $style) {
1195
+                    if (isset($style['path']) and $style['path']) {
1196
+                        $code = "if (\$f=timestamp(direction_css(find_in_path('" . addslashes($style['path']) . "')))) ";
1197
+                    } else {
1198
+                        $code = "if (\$f='" . addslashes($style['url']) . "') ";
1199
+                    }
1200
+                    $code .= "\$val .= '<link rel=\"stylesheet\" href=\"'.\$f.'\" type=\"text/css\"";
1201
+                    if (isset($style['media']) and strlen($style['media'])) {
1202
+                        $code .= " media=\"" . addslashes($style['media']) . "\"";
1203
+                    }
1204
+                    $code .= "/>';\n";
1205
+                    if ($style['type'] != 'prive') {
1206
+                        $prepend_code['insert_head_css'] .= $code;
1207
+                    }
1208
+                    if ($style['type'] != 'public') {
1209
+                        $prepend_code['header_prive_css'] .= $code;
1210
+                    }
1211
+                }
1212
+            }
1213
+            if (!isset($prepend_code['insert_head'])) {
1214
+                $prepend_code['insert_head'] = "";
1215
+            }
1216
+            if (!isset($prepend_code['header_prive'])) {
1217
+                $prepend_code['header_prive'] = "";
1218
+            }
1219
+            if (isset($info['script']) and count($info['script'])) {
1220
+                foreach ($info['script'] as $script) {
1221
+                    if (isset($script['path']) and $script['path']) {
1222
+                        $code = "if (\$f=timestamp(find_in_path('" . addslashes($script['path']) . "'))) ";
1223
+                    } else {
1224
+                        $code = "if (\$f='" . addslashes($script['url']) . "') ";
1225
+                    }
1226
+                    $code .= "\$val .= '<script src=\"'.\$f.'\" type=\"text/javascript\"></script>';\n";
1227
+                    if ($script['type'] != 'prive') {
1228
+                        $prepend_code['insert_head'] .= $code;
1229
+                    }
1230
+                    if ($script['type'] != 'public') {
1231
+                        $prepend_code['header_prive'] .= $code;
1232
+                    }
1233
+                }
1234
+            }
1235
+        }
1236
+    }
1237
+
1238
+    $prepend_code['insert_head'] =
1239
+        "include_once_check(_DIR_RESTREINT . 'inc/pipelines.php');\n"
1240
+        . "\$val = minipipe('f_jQuery', \$val);\n"
1241
+        . $prepend_code['insert_head'];
1242
+    $prepend_code['header_prive'] =
1243
+        "include_once_check(_DIR_RESTREINT . 'inc/pipelines_ecrire.php');\n"
1244
+        . "\$val = minipipe('f_jQuery_prive', \$val);\n"
1245
+        . $prepend_code['header_prive'];
1246
+
1247
+    // on ajoute les pipe qui ont ete recenses manquants
1248
+    foreach ($liste_pipe_manquants as $add_pipe) {
1249
+        if (!isset($GLOBALS['spip_pipeline'][$add_pipe])) {
1250
+            $GLOBALS['spip_pipeline'][$add_pipe] = '';
1251
+        }
1252
+    }
1253
+
1254
+    return $prepend_code;
1255 1255
 }
1256 1256
 
1257 1257
 /**
@@ -1278,44 +1278,44 @@  discard block
 block discarded – undo
1278 1278
 **/
1279 1279
 function pipeline_precompile($prepend_code = array()) {
1280 1280
 
1281
-	$content = "";
1282
-	foreach ($GLOBALS['spip_pipeline'] as $action => $pipeline) {
1283
-		$s_inc = "";
1284
-		$s_call = "";
1285
-		$pipe = array_filter(explode('|', $pipeline));
1286
-		// Eclater le pipeline en filtres et appliquer chaque filtre
1287
-		foreach ($pipe as $fonc) {
1288
-			$fonc = trim($fonc);
1289
-			$s_call .= '$val = minipipe(\'' . $fonc . '\', $val);' . "\n";
1290
-			if (isset($GLOBALS['spip_matrice'][$fonc])) {
1291
-				$file = $GLOBALS['spip_matrice'][$fonc];
1292
-				$file = "'$file'";
1293
-				// si un _DIR_XXX: est dans la chaine, on extrait la constante
1294
-				if (preg_match(",(_(DIR|ROOT)_[A-Z_]+):,Ums", $file, $regs)) {
1295
-					$dir = $regs[1];
1296
-					$root_dir = str_replace('_DIR_', '_ROOT_', $dir);
1297
-					if (defined($root_dir)) {
1298
-						$dir = $root_dir;
1299
-					}
1300
-					$file = str_replace($regs[0], "'." . $dir . ".'", $file);
1301
-					$file = str_replace("''.", "", $file);
1302
-					$file = str_replace(constant($dir), '', $file);
1303
-				}
1304
-				$s_inc .= "include_once_check($file);\n";
1305
-			}
1306
-		}
1307
-		if (strlen($s_inc)) {
1308
-			$s_inc = "static \$inc=null;\nif (!\$inc){\n$s_inc\$inc=true;\n}\n";
1309
-		}
1310
-		$content .= "// Pipeline $action \n"
1311
-			. "function execute_pipeline_$action(&\$val){\n"
1312
-			. $s_inc
1313
-			. ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action]) . "\n" : '')
1314
-			. $s_call
1315
-			. "return \$val;\n}\n";
1316
-	}
1317
-	ecrire_fichier_php(_CACHE_PIPELINES, $content);
1318
-	clear_path_cache();
1281
+    $content = "";
1282
+    foreach ($GLOBALS['spip_pipeline'] as $action => $pipeline) {
1283
+        $s_inc = "";
1284
+        $s_call = "";
1285
+        $pipe = array_filter(explode('|', $pipeline));
1286
+        // Eclater le pipeline en filtres et appliquer chaque filtre
1287
+        foreach ($pipe as $fonc) {
1288
+            $fonc = trim($fonc);
1289
+            $s_call .= '$val = minipipe(\'' . $fonc . '\', $val);' . "\n";
1290
+            if (isset($GLOBALS['spip_matrice'][$fonc])) {
1291
+                $file = $GLOBALS['spip_matrice'][$fonc];
1292
+                $file = "'$file'";
1293
+                // si un _DIR_XXX: est dans la chaine, on extrait la constante
1294
+                if (preg_match(",(_(DIR|ROOT)_[A-Z_]+):,Ums", $file, $regs)) {
1295
+                    $dir = $regs[1];
1296
+                    $root_dir = str_replace('_DIR_', '_ROOT_', $dir);
1297
+                    if (defined($root_dir)) {
1298
+                        $dir = $root_dir;
1299
+                    }
1300
+                    $file = str_replace($regs[0], "'." . $dir . ".'", $file);
1301
+                    $file = str_replace("''.", "", $file);
1302
+                    $file = str_replace(constant($dir), '', $file);
1303
+                }
1304
+                $s_inc .= "include_once_check($file);\n";
1305
+            }
1306
+        }
1307
+        if (strlen($s_inc)) {
1308
+            $s_inc = "static \$inc=null;\nif (!\$inc){\n$s_inc\$inc=true;\n}\n";
1309
+        }
1310
+        $content .= "// Pipeline $action \n"
1311
+            . "function execute_pipeline_$action(&\$val){\n"
1312
+            . $s_inc
1313
+            . ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action]) . "\n" : '')
1314
+            . $s_call
1315
+            . "return \$val;\n}\n";
1316
+    }
1317
+    ecrire_fichier_php(_CACHE_PIPELINES, $content);
1318
+    clear_path_cache();
1319 1319
 }
1320 1320
 
1321 1321
 
@@ -1328,12 +1328,12 @@  discard block
 block discarded – undo
1328 1328
  *     true si le plugin est actif, false sinon
1329 1329
 **/
1330 1330
 function plugin_est_installe($plug_path) {
1331
-	$plugin_installes = isset($GLOBALS['meta']['plugin_installes']) ? unserialize($GLOBALS['meta']['plugin_installes']) : array();
1332
-	if (!$plugin_installes) {
1333
-		return false;
1334
-	}
1331
+    $plugin_installes = isset($GLOBALS['meta']['plugin_installes']) ? unserialize($GLOBALS['meta']['plugin_installes']) : array();
1332
+    if (!$plugin_installes) {
1333
+        return false;
1334
+    }
1335 1335
 
1336
-	return in_array($plug_path, $plugin_installes);
1336
+    return in_array($plug_path, $plugin_installes);
1337 1337
 }
1338 1338
 
1339 1339
 
@@ -1346,37 +1346,37 @@  discard block
 block discarded – undo
1346 1346
  * @uses plugins_installer_dist()
1347 1347
  **/
1348 1348
 function plugin_installes_meta() {
1349
-	if (isset($GLOBALS['fichier_php_compile_recent'])) {
1350
-		// attendre eventuellement l'invalidation du cache opcode
1351
-		spip_attend_invalidation_opcode_cache($GLOBALS['fichier_php_compile_recent']);
1352
-	}
1353
-
1354
-	$installer_plugins = charger_fonction('installer', 'plugins');
1355
-	$meta_plug_installes = array();
1356
-	foreach (unserialize($GLOBALS['meta']['plugin']) as $prefix => $resume) {
1357
-		if ($plug = $resume['dir']) {
1358
-			$infos = $installer_plugins($plug, 'install', $resume['dir_type']);
1359
-			if ($infos) {
1360
-				if (!is_array($infos) or $infos['install_test'][0]) {
1361
-					$meta_plug_installes[] = $plug;
1362
-				}
1363
-				if (is_array($infos)) {
1364
-					list($ok, $trace) = $infos['install_test'];
1365
-					include_spip('inc/filtres_boites');
1366
-					echo "<div class='install-plugins svp_retour'>"
1367
-						. boite_ouvrir(_T('plugin_titre_installation', array('plugin' => typo($infos['nom']))),
1368
-							($ok ? 'success' : 'error'))
1369
-						. $trace
1370
-						. "<div class='result'>"
1371
-						. ($ok ? ((isset($infos['upgrade']) && $infos['upgrade']) ? _T("plugin_info_upgrade_ok") : _T("plugin_info_install_ok")) : _T("avis_operation_echec"))
1372
-						. "</div>"
1373
-						. boite_fermer()
1374
-						. "</div>";
1375
-				}
1376
-			}
1377
-		}
1378
-	}
1379
-	ecrire_meta('plugin_installes', serialize($meta_plug_installes), 'non');
1349
+    if (isset($GLOBALS['fichier_php_compile_recent'])) {
1350
+        // attendre eventuellement l'invalidation du cache opcode
1351
+        spip_attend_invalidation_opcode_cache($GLOBALS['fichier_php_compile_recent']);
1352
+    }
1353
+
1354
+    $installer_plugins = charger_fonction('installer', 'plugins');
1355
+    $meta_plug_installes = array();
1356
+    foreach (unserialize($GLOBALS['meta']['plugin']) as $prefix => $resume) {
1357
+        if ($plug = $resume['dir']) {
1358
+            $infos = $installer_plugins($plug, 'install', $resume['dir_type']);
1359
+            if ($infos) {
1360
+                if (!is_array($infos) or $infos['install_test'][0]) {
1361
+                    $meta_plug_installes[] = $plug;
1362
+                }
1363
+                if (is_array($infos)) {
1364
+                    list($ok, $trace) = $infos['install_test'];
1365
+                    include_spip('inc/filtres_boites');
1366
+                    echo "<div class='install-plugins svp_retour'>"
1367
+                        . boite_ouvrir(_T('plugin_titre_installation', array('plugin' => typo($infos['nom']))),
1368
+                            ($ok ? 'success' : 'error'))
1369
+                        . $trace
1370
+                        . "<div class='result'>"
1371
+                        . ($ok ? ((isset($infos['upgrade']) && $infos['upgrade']) ? _T("plugin_info_upgrade_ok") : _T("plugin_info_install_ok")) : _T("avis_operation_echec"))
1372
+                        . "</div>"
1373
+                        . boite_fermer()
1374
+                        . "</div>";
1375
+                }
1376
+            }
1377
+        }
1378
+    }
1379
+    ecrire_meta('plugin_installes', serialize($meta_plug_installes), 'non');
1380 1380
 }
1381 1381
 
1382 1382
 /**
@@ -1390,29 +1390,29 @@  discard block
 block discarded – undo
1390 1390
  *     Commentaire : code écrit en tout début de fichier, après la balise PHP ouvrante
1391 1391
 **/
1392 1392
 function ecrire_fichier_php($nom, $contenu, $comment = '') {
1393
-	if (!isset($GLOBALS['fichier_php_compile_recent'])) {
1394
-		$GLOBALS['fichier_php_compile_recent'] = 0;
1395
-	}
1396
-
1397
-	$contenu = '<' . '?php' . "\n" . $comment . "\nif (defined('_ECRIRE_INC_VERSION')) {\n" . $contenu . "}\n?" . '>';
1398
-	// si un fichier existe deja on verifie que son contenu change avant de l'ecraser
1399
-	// si pas de modif on ne touche pas au fichier initial
1400
-	if (file_exists($nom)) {
1401
-		if (substr($nom, -4) == '.php') {
1402
-			$fichier_tmp = substr($nom, 0, -4) . '.tmp.php';
1403
-		}
1404
-		else {
1405
-			$fichier_tmp = $nom . '.tmp';
1406
-		}
1407
-		file_put_contents($fichier_tmp, $contenu);
1408
-		if(md5_file($nom) == md5_file($fichier_tmp)) {
1409
-			$GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom));
1410
-			@unlink($fichier_tmp);
1411
-			return;
1412
-		}
1413
-		@unlink($fichier_tmp);
1414
-	}
1415
-	ecrire_fichier($nom, $contenu);
1416
-	$GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom));
1417
-	spip_clear_opcode_cache(realpath($nom));
1393
+    if (!isset($GLOBALS['fichier_php_compile_recent'])) {
1394
+        $GLOBALS['fichier_php_compile_recent'] = 0;
1395
+    }
1396
+
1397
+    $contenu = '<' . '?php' . "\n" . $comment . "\nif (defined('_ECRIRE_INC_VERSION')) {\n" . $contenu . "}\n?" . '>';
1398
+    // si un fichier existe deja on verifie que son contenu change avant de l'ecraser
1399
+    // si pas de modif on ne touche pas au fichier initial
1400
+    if (file_exists($nom)) {
1401
+        if (substr($nom, -4) == '.php') {
1402
+            $fichier_tmp = substr($nom, 0, -4) . '.tmp.php';
1403
+        }
1404
+        else {
1405
+            $fichier_tmp = $nom . '.tmp';
1406
+        }
1407
+        file_put_contents($fichier_tmp, $contenu);
1408
+        if(md5_file($nom) == md5_file($fichier_tmp)) {
1409
+            $GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom));
1410
+            @unlink($fichier_tmp);
1411
+            return;
1412
+        }
1413
+        @unlink($fichier_tmp);
1414
+    }
1415
+    ecrire_fichier($nom, $contenu);
1416
+    $GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom));
1417
+    spip_clear_opcode_cache(realpath($nom));
1418 1418
 }
Please login to merge, or discard this patch.
ecrire/inc/prepare_recherche.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -165,7 +165,7 @@
 block discarded – undo
165 165
  * @param string $primary
166 166
  * @param array $rows
167 167
  * @param string $serveur
168
- * @return array
168
+ * @return string[]
169 169
  */
170 170
 function generer_select_where_explicites($table, $primary, $rows, $serveur) {
171 171
 	# calculer le {id_article IN()} et le {... as points}
Please login to merge, or discard this patch.
Indentation   +123 added lines, -123 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
 include_spip('inc/rechercher');
24 24
 if (!defined('_DELAI_CACHE_resultats')) {
25
-	define('_DELAI_CACHE_resultats', 600);
25
+    define('_DELAI_CACHE_resultats', 600);
26 26
 }
27 27
 
28 28
 /**
@@ -49,110 +49,110 @@  discard block
 block discarded – undo
49 49
  * @return array
50 50
  */
51 51
 function inc_prepare_recherche_dist(
52
-	$recherche,
53
-	$table = 'articles',
54
-	$cond = false,
55
-	$serveur = '',
56
-	$modificateurs = array(),
57
-	$primary = ''
52
+    $recherche,
53
+    $table = 'articles',
54
+    $cond = false,
55
+    $serveur = '',
56
+    $modificateurs = array(),
57
+    $primary = ''
58 58
 ) {
59
-	static $cache = array();
60
-	$delai_fraicheur = min(_DELAI_CACHE_resultats,
61
-		time() - (isset($GLOBALS['meta']['derniere_modif']) ? $GLOBALS['meta']['derniere_modif'] : 0));
62
-
63
-	// si recherche n'est pas dans le contexte, on va prendre en globals
64
-	// ca permet de faire des inclure simple.
65
-	if (!isset($recherche) and isset($GLOBALS['recherche'])) {
66
-		$recherche = $GLOBALS['recherche'];
67
-	}
68
-
69
-	// traiter le cas {recherche?}
70
-	if ($cond and !strlen($recherche)) {
71
-		return array(
72
-			"0 as points" /* as points */, /* where */
73
-			''
74
-		);
75
-	}
76
-
77
-
78
-	$rechercher = false;
79
-
80
-	if (!isset($cache[$serveur][$table][$recherche])) {
81
-		$hash_serv = ($serveur ? substr(md5($serveur), 0, 16) : '');
82
-		$hash = substr(md5($recherche . $table), 0, 16);
83
-		$where = "(resultats.recherche='$hash' AND resultats.table_objet=" . sql_quote($table) . " AND resultats.serveur='$hash_serv')";
84
-		$row = sql_fetsel('UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(resultats.maj) AS fraicheur', 'spip_resultats AS resultats',
85
-			$where, '', 'fraicheur DESC', '0,1');
86
-		if (!$row
87
-			or ($row['fraicheur'] > $delai_fraicheur)
88
-			or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')
89
-		) {
90
-			$rechercher = true;
91
-		}
92
-	}
93
-
94
-	// si on n'a pas encore traite les donnees dans une boucle precedente
95
-	if ($rechercher) {
96
-		//$tables = liste_des_champs();
97
-		$x = objet_type($table);
98
-		$points = recherche_en_base($recherche,
99
-			$x,
100
-			array(
101
-				'score' => true,
102
-				'toutvoir' => true,
103
-				'jointures' => true
104
-			),
105
-			$serveur);
106
-		// pas de résultat, pas de point
107
-		$points = isset($points[$x]) ? $points[$x] : array();
108
-
109
-		// permettre aux plugins de modifier le resultat
110
-		$points = pipeline('prepare_recherche', array(
111
-			'args' => array(
112
-				'type' => $x,
113
-				'recherche' => $recherche,
114
-				'serveur' => $serveur,
115
-				'modificateurs' => $modificateurs
116
-			),
117
-			'data' => $points
118
-		));
119
-
120
-		// supprimer les anciens resultats de cette recherche
121
-		// et les resultats trop vieux avec une marge
122
-		// pas de AS resultats dans un delete (mysql)
123
-		$whered = str_replace(array("resultats.recherche", "resultats.table_objet", "resultats.serveur"),
124
-			array("recherche", "table_objet", "serveur"), $where);
125
-		sql_delete('spip_resultats',
126
-			'NOT(' . sql_date_proche('maj', (0 - ($delai_fraicheur + 100)), " SECOND") . ") OR ($whered)");
127
-
128
-		// inserer les resultats dans la table de cache des resultats
129
-		if (count($points)) {
130
-			$tab_couples = array();
131
-			foreach ($points as $id => $p) {
132
-				$tab_couples[] = array(
133
-					'recherche' => $hash,
134
-					'id' => $id,
135
-					'points' => $p['score'],
136
-					'table_objet' => $table,
137
-					'serveur' => $hash_serv,
138
-				);
139
-			}
140
-			sql_insertq_multi('spip_resultats', $tab_couples, array());
141
-		}
142
-	}
143
-
144
-	if (!isset($cache[$serveur][$table][$recherche])) {
145
-		if (!$serveur) {
146
-			$cache[$serveur][$table][$recherche] = array("resultats.points AS points", $where);
147
-		} else {
148
-			if (sql_countsel('spip_resultats as resultats', $where)) {
149
-				$rows = sql_allfetsel('resultats.id,resultats.points', 'spip_resultats as resultats', $where);
150
-			}
151
-			$cache[$serveur][$table][$recherche] = generer_select_where_explicites($table, $primary, $rows, $serveur);
152
-		}
153
-	}
154
-
155
-	return $cache[$serveur][$table][$recherche];
59
+    static $cache = array();
60
+    $delai_fraicheur = min(_DELAI_CACHE_resultats,
61
+        time() - (isset($GLOBALS['meta']['derniere_modif']) ? $GLOBALS['meta']['derniere_modif'] : 0));
62
+
63
+    // si recherche n'est pas dans le contexte, on va prendre en globals
64
+    // ca permet de faire des inclure simple.
65
+    if (!isset($recherche) and isset($GLOBALS['recherche'])) {
66
+        $recherche = $GLOBALS['recherche'];
67
+    }
68
+
69
+    // traiter le cas {recherche?}
70
+    if ($cond and !strlen($recherche)) {
71
+        return array(
72
+            "0 as points" /* as points */, /* where */
73
+            ''
74
+        );
75
+    }
76
+
77
+
78
+    $rechercher = false;
79
+
80
+    if (!isset($cache[$serveur][$table][$recherche])) {
81
+        $hash_serv = ($serveur ? substr(md5($serveur), 0, 16) : '');
82
+        $hash = substr(md5($recherche . $table), 0, 16);
83
+        $where = "(resultats.recherche='$hash' AND resultats.table_objet=" . sql_quote($table) . " AND resultats.serveur='$hash_serv')";
84
+        $row = sql_fetsel('UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(resultats.maj) AS fraicheur', 'spip_resultats AS resultats',
85
+            $where, '', 'fraicheur DESC', '0,1');
86
+        if (!$row
87
+            or ($row['fraicheur'] > $delai_fraicheur)
88
+            or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')
89
+        ) {
90
+            $rechercher = true;
91
+        }
92
+    }
93
+
94
+    // si on n'a pas encore traite les donnees dans une boucle precedente
95
+    if ($rechercher) {
96
+        //$tables = liste_des_champs();
97
+        $x = objet_type($table);
98
+        $points = recherche_en_base($recherche,
99
+            $x,
100
+            array(
101
+                'score' => true,
102
+                'toutvoir' => true,
103
+                'jointures' => true
104
+            ),
105
+            $serveur);
106
+        // pas de résultat, pas de point
107
+        $points = isset($points[$x]) ? $points[$x] : array();
108
+
109
+        // permettre aux plugins de modifier le resultat
110
+        $points = pipeline('prepare_recherche', array(
111
+            'args' => array(
112
+                'type' => $x,
113
+                'recherche' => $recherche,
114
+                'serveur' => $serveur,
115
+                'modificateurs' => $modificateurs
116
+            ),
117
+            'data' => $points
118
+        ));
119
+
120
+        // supprimer les anciens resultats de cette recherche
121
+        // et les resultats trop vieux avec une marge
122
+        // pas de AS resultats dans un delete (mysql)
123
+        $whered = str_replace(array("resultats.recherche", "resultats.table_objet", "resultats.serveur"),
124
+            array("recherche", "table_objet", "serveur"), $where);
125
+        sql_delete('spip_resultats',
126
+            'NOT(' . sql_date_proche('maj', (0 - ($delai_fraicheur + 100)), " SECOND") . ") OR ($whered)");
127
+
128
+        // inserer les resultats dans la table de cache des resultats
129
+        if (count($points)) {
130
+            $tab_couples = array();
131
+            foreach ($points as $id => $p) {
132
+                $tab_couples[] = array(
133
+                    'recherche' => $hash,
134
+                    'id' => $id,
135
+                    'points' => $p['score'],
136
+                    'table_objet' => $table,
137
+                    'serveur' => $hash_serv,
138
+                );
139
+            }
140
+            sql_insertq_multi('spip_resultats', $tab_couples, array());
141
+        }
142
+    }
143
+
144
+    if (!isset($cache[$serveur][$table][$recherche])) {
145
+        if (!$serveur) {
146
+            $cache[$serveur][$table][$recherche] = array("resultats.points AS points", $where);
147
+        } else {
148
+            if (sql_countsel('spip_resultats as resultats', $where)) {
149
+                $rows = sql_allfetsel('resultats.id,resultats.points', 'spip_resultats as resultats', $where);
150
+            }
151
+            $cache[$serveur][$table][$recherche] = generer_select_where_explicites($table, $primary, $rows, $serveur);
152
+        }
153
+    }
154
+
155
+    return $cache[$serveur][$table][$recherche];
156 156
 }
157 157
 
158 158
 
@@ -168,22 +168,22 @@  discard block
 block discarded – undo
168 168
  * @return array
169 169
  */
170 170
 function generer_select_where_explicites($table, $primary, $rows, $serveur) {
171
-	# calculer le {id_article IN()} et le {... as points}
172
-	if (!count($rows)) {
173
-		return array("''", "0=1");
174
-	} else {
175
-		$listes_ids = array();
176
-		$select = '0';
177
-		foreach ($rows as $r) {
178
-			$listes_ids[$r['points']][] = $r['id'];
179
-		}
180
-
181
-		foreach ($listes_ids as $p => $ids) {
182
-			$select .= "+$p*(" .
183
-				sql_in("$table.$primary", $ids, '', $serveur)
184
-				. ") ";
185
-		}
186
-
187
-		return array("$select AS points ", sql_in("$table.$primary", array_map('reset', $rows), '', $serveur));
188
-	}
171
+    # calculer le {id_article IN()} et le {... as points}
172
+    if (!count($rows)) {
173
+        return array("''", "0=1");
174
+    } else {
175
+        $listes_ids = array();
176
+        $select = '0';
177
+        foreach ($rows as $r) {
178
+            $listes_ids[$r['points']][] = $r['id'];
179
+        }
180
+
181
+        foreach ($listes_ids as $p => $ids) {
182
+            $select .= "+$p*(" .
183
+                sql_in("$table.$primary", $ids, '', $serveur)
184
+                . ") ";
185
+        }
186
+
187
+        return array("$select AS points ", sql_in("$table.$primary", array_map('reset', $rows), '', $serveur));
188
+    }
189 189
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
 
80 80
 	if (!isset($cache[$serveur][$table][$recherche])) {
81 81
 		$hash_serv = ($serveur ? substr(md5($serveur), 0, 16) : '');
82
-		$hash = substr(md5($recherche . $table), 0, 16);
83
-		$where = "(resultats.recherche='$hash' AND resultats.table_objet=" . sql_quote($table) . " AND resultats.serveur='$hash_serv')";
82
+		$hash = substr(md5($recherche.$table), 0, 16);
83
+		$where = "(resultats.recherche='$hash' AND resultats.table_objet=".sql_quote($table)." AND resultats.serveur='$hash_serv')";
84 84
 		$row = sql_fetsel('UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(resultats.maj) AS fraicheur', 'spip_resultats AS resultats',
85 85
 			$where, '', 'fraicheur DESC', '0,1');
86 86
 		if (!$row
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 		$whered = str_replace(array("resultats.recherche", "resultats.table_objet", "resultats.serveur"),
124 124
 			array("recherche", "table_objet", "serveur"), $where);
125 125
 		sql_delete('spip_resultats',
126
-			'NOT(' . sql_date_proche('maj', (0 - ($delai_fraicheur + 100)), " SECOND") . ") OR ($whered)");
126
+			'NOT('.sql_date_proche('maj', (0 - ($delai_fraicheur + 100)), " SECOND").") OR ($whered)");
127 127
 
128 128
 		// inserer les resultats dans la table de cache des resultats
129 129
 		if (count($points)) {
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 		}
180 180
 
181 181
 		foreach ($listes_ids as $p => $ids) {
182
-			$select .= "+$p*(" .
182
+			$select .= "+$p*(".
183 183
 				sql_in("$table.$primary", $ids, '', $serveur)
184 184
 				. ") ";
185 185
 		}
Please login to merge, or discard this patch.
ecrire/inc/presentation.php 3 patches
Doc Comments   +7 added lines patch added patch discarded remove patch
@@ -30,6 +30,9 @@  discard block
 block discarded – undo
30 30
 include_spip('inc/filtres_boites');
31 31
 
32 32
 // http://code.spip.net/@debut_cadre
33
+/**
34
+ * @param string $style
35
+ */
33 36
 function debut_cadre($style, $icone = "", $fonction = "", $titre = "", $id = "", $class = "", $padding = true) {
34 37
 	$style_mapping = array(
35 38
 		'r' => 'simple',
@@ -183,6 +186,10 @@  discard block
 block discarded – undo
183 186
 function fin_onglet() { return "</ul></div>\n"; }
184 187
 
185 188
 // http://code.spip.net/@onglet
189
+/**
190
+ * @param string $texte
191
+ * @param string $onglet
192
+ */
186 193
 function onglet($texte, $lien, $onglet_ref, $onglet, $icone = "") {
187 194
 	return "<li>"
188 195
 	. ($icone ? http_img_pack($icone, '', " class='cadre-icone'") : '')
Please login to merge, or discard this patch.
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @package SPIP\Core\Presentation
17 17
  **/
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 include_spip('inc/presentation_mini');
@@ -31,44 +31,44 @@  discard block
 block discarded – undo
31 31
 
32 32
 // http://code.spip.net/@debut_cadre
33 33
 function debut_cadre($style, $icone = "", $fonction = "", $titre = "", $id = "", $class = "", $padding = true) {
34
-	$style_mapping = array(
35
-		'r' => 'simple',
36
-		'e' => 'raccourcis',
37
-		'couleur' => 'basic highlight',
38
-		'couleur-foncee' => 'basic highlight',
39
-		'trait-couleur' => 'important',
40
-		'alerte' => 'notice',
41
-		'info' => 'info',
42
-		'sous_rub' => 'simple sous-rub'
43
-	);
44
-	$style_titre_mapping = array('couleur' => 'topper', 'trait-couleur' => 'section');
45
-	$c = isset($style_mapping[$style]) ? $style_mapping[$style] : 'simple';
46
-	$class = $c . ($class ? " $class" : "");
47
-	if (!$padding) {
48
-		$class .= ($class ? " " : "") . "no-padding";
49
-	}
50
-
51
-	//($id?"id='$id' ":"")
52
-	if (strlen($icone) > 1) {
53
-		if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) {
54
-			list($fond, $fonction) = $icone_renommer($icone, $fonction);
55
-		}
56
-		$size = 24;
57
-		if (preg_match("/-([0-9]{1,3})[.](gif|png)$/i", $fond, $match)) {
58
-			$size = $match[1];
59
-		}
60
-		if ($fonction) {
61
-			// 2 images pour composer l'icone : le fond (article) en background,
62
-			// la fonction (new) en image
63
-			$icone = http_img_pack($fonction, "", "class='cadre-icone' width='$size' height='$size'\n" .
64
-				http_style_background($fond, "no-repeat center center"));
65
-		} else {
66
-			$icone = http_img_pack($fond, "", "class='cadre-icone' width='$size' height='$size'");
67
-		}
68
-		$titre = $icone . $titre;
69
-	}
70
-
71
-	return boite_ouvrir($titre, $class, isset($style_titre_mapping[$style]) ? $style_titre_mapping[$style] : '', $id);
34
+    $style_mapping = array(
35
+        'r' => 'simple',
36
+        'e' => 'raccourcis',
37
+        'couleur' => 'basic highlight',
38
+        'couleur-foncee' => 'basic highlight',
39
+        'trait-couleur' => 'important',
40
+        'alerte' => 'notice',
41
+        'info' => 'info',
42
+        'sous_rub' => 'simple sous-rub'
43
+    );
44
+    $style_titre_mapping = array('couleur' => 'topper', 'trait-couleur' => 'section');
45
+    $c = isset($style_mapping[$style]) ? $style_mapping[$style] : 'simple';
46
+    $class = $c . ($class ? " $class" : "");
47
+    if (!$padding) {
48
+        $class .= ($class ? " " : "") . "no-padding";
49
+    }
50
+
51
+    //($id?"id='$id' ":"")
52
+    if (strlen($icone) > 1) {
53
+        if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) {
54
+            list($fond, $fonction) = $icone_renommer($icone, $fonction);
55
+        }
56
+        $size = 24;
57
+        if (preg_match("/-([0-9]{1,3})[.](gif|png)$/i", $fond, $match)) {
58
+            $size = $match[1];
59
+        }
60
+        if ($fonction) {
61
+            // 2 images pour composer l'icone : le fond (article) en background,
62
+            // la fonction (new) en image
63
+            $icone = http_img_pack($fonction, "", "class='cadre-icone' width='$size' height='$size'\n" .
64
+                http_style_background($fond, "no-repeat center center"));
65
+        } else {
66
+            $icone = http_img_pack($fond, "", "class='cadre-icone' width='$size' height='$size'");
67
+        }
68
+        $titre = $icone . $titre;
69
+    }
70
+
71
+    return boite_ouvrir($titre, $class, isset($style_titre_mapping[$style]) ? $style_titre_mapping[$style] : '', $id);
72 72
 }
73 73
 
74 74
 // http://code.spip.net/@fin_cadre
@@ -76,66 +76,66 @@  discard block
 block discarded – undo
76 76
 
77 77
 
78 78
 function debut_cadre_relief(
79
-	$icone = '',
80
-	$dummy = '',
81
-	$fonction = '',
82
-	$titre = '',
83
-	$id = "",
84
-	$class = ""
79
+    $icone = '',
80
+    $dummy = '',
81
+    $fonction = '',
82
+    $titre = '',
83
+    $id = "",
84
+    $class = ""
85 85
 ) {
86
-	return debut_cadre('r', $icone, $fonction, $titre, $id, $class);
86
+    return debut_cadre('r', $icone, $fonction, $titre, $id, $class);
87 87
 }
88 88
 
89 89
 function fin_cadre_relief() { return fin_cadre('r'); }
90 90
 
91 91
 function debut_cadre_enfonce(
92
-	$icone = '',
93
-	$dummy = '',
94
-	$fonction = '',
95
-	$titre = '',
96
-	$id = "",
97
-	$class = ""
92
+    $icone = '',
93
+    $dummy = '',
94
+    $fonction = '',
95
+    $titre = '',
96
+    $id = "",
97
+    $class = ""
98 98
 ) {
99
-	return debut_cadre('e', $icone, $fonction, $titre, $id, $class);
99
+    return debut_cadre('e', $icone, $fonction, $titre, $id, $class);
100 100
 }
101 101
 
102 102
 function fin_cadre_enfonce() { return fin_cadre('e'); }
103 103
 
104 104
 function debut_cadre_sous_rub(
105
-	$icone = '',
106
-	$dummy = '',
107
-	$fonction = '',
108
-	$titre = '',
109
-	$id = "",
110
-	$class = ""
105
+    $icone = '',
106
+    $dummy = '',
107
+    $fonction = '',
108
+    $titre = '',
109
+    $id = "",
110
+    $class = ""
111 111
 ) {
112
-	return debut_cadre('sous_rub', $icone, $fonction, $titre, $id, $class);
112
+    return debut_cadre('sous_rub', $icone, $fonction, $titre, $id, $class);
113 113
 }
114 114
 
115 115
 function fin_cadre_sous_rub() { return fin_cadre('sous_rub'); }
116 116
 
117 117
 function debut_cadre_couleur(
118
-	$icone = '',
119
-	$dummy = '',
120
-	$fonction = '',
121
-	$titre = '',
122
-	$id = "",
123
-	$class = ""
118
+    $icone = '',
119
+    $dummy = '',
120
+    $fonction = '',
121
+    $titre = '',
122
+    $id = "",
123
+    $class = ""
124 124
 ) {
125
-	return debut_cadre('couleur', $icone, $fonction, $titre, $id, $class);
125
+    return debut_cadre('couleur', $icone, $fonction, $titre, $id, $class);
126 126
 }
127 127
 
128 128
 function fin_cadre_couleur() { return fin_cadre('couleur'); }
129 129
 
130 130
 function debut_cadre_trait_couleur(
131
-	$icone = '',
132
-	$dummy = '',
133
-	$fonction = '',
134
-	$titre = '',
135
-	$id = "",
136
-	$class = ""
131
+    $icone = '',
132
+    $dummy = '',
133
+    $fonction = '',
134
+    $titre = '',
135
+    $id = "",
136
+    $class = ""
137 137
 ) {
138
-	return debut_cadre('trait-couleur', $icone, $fonction, $titre, $id, $class);
138
+    return debut_cadre('trait-couleur', $icone, $fonction, $titre, $id, $class);
139 139
 }
140 140
 
141 141
 function fin_cadre_trait_couleur() { return fin_cadre('trait-couleur'); }
@@ -156,18 +156,18 @@  discard block
 block discarded – undo
156 156
  * @return string Code PHP.
157 157
  **/
158 158
 function gros_titre(
159
-	$titre,
160
-	$ze_logo = ''
159
+    $titre,
160
+    $ze_logo = ''
161 161
 ) {
162
-	return "<h1 class = 'grostitre'>" . $ze_logo . ' ' . typo($titre) . "</h1>\n";
162
+    return "<h1 class = 'grostitre'>" . $ze_logo . ' ' . typo($titre) . "</h1>\n";
163 163
 }
164 164
 
165 165
 // La boite des raccourcis
166 166
 // Se place a droite si l'ecran est en mode panoramique.
167 167
 // http://code.spip.net/@bloc_des_raccourcis
168 168
 function bloc_des_raccourcis($bloc) {
169
-	return creer_colonne_droite()
170
-	. boite_ouvrir(_T('titre_cadre_raccourcis'), 'raccourcis') . $bloc . boite_fermer();
169
+    return creer_colonne_droite()
170
+    . boite_ouvrir(_T('titre_cadre_raccourcis'), 'raccourcis') . $bloc . boite_fermer();
171 171
 }
172 172
 
173 173
 //
@@ -184,10 +184,10 @@  discard block
 block discarded – undo
184 184
 
185 185
 // http://code.spip.net/@onglet
186 186
 function onglet($texte, $lien, $onglet_ref, $onglet, $icone = "") {
187
-	return "<li>"
188
-	. ($icone ? http_img_pack($icone, '', " class='cadre-icone'") : '')
189
-	. lien_ou_expose($lien, $texte, $onglet == $onglet_ref)
190
-	. "</li>";
187
+    return "<li>"
188
+    . ($icone ? http_img_pack($icone, '', " class='cadre-icone'") : '')
189
+    . lien_ou_expose($lien, $texte, $onglet == $onglet_ref)
190
+    . "</li>";
191 191
 }
192 192
 
193 193
 /**
@@ -219,14 +219,14 @@  discard block
 block discarded – undo
219 219
  *     Code HTML du lien
220 220
  **/
221 221
 function icone_verticale($texte, $lien, $fond, $fonction = "", $align = "", $javascript = "") {
222
-	// cas d'ajax_action_auteur: faut defaire le boulot
223
-	// (il faudrait fusionner avec le cas $javascript)
224
-	if (preg_match(",^<a\shref='([^']*)'([^>]*)>(.*)</a>$,i", $lien, $r)) {
225
-		list($x, $lien, $atts, $texte) = $r;
226
-		$javascript .= $atts;
227
-	}
228
-
229
-	return icone_base($lien, $texte, $fond, $fonction, "verticale $align", $javascript);
222
+    // cas d'ajax_action_auteur: faut defaire le boulot
223
+    // (il faudrait fusionner avec le cas $javascript)
224
+    if (preg_match(",^<a\shref='([^']*)'([^>]*)>(.*)</a>$,i", $lien, $r)) {
225
+        list($x, $lien, $atts, $texte) = $r;
226
+        $javascript .= $atts;
227
+    }
228
+
229
+    return icone_base($lien, $texte, $fond, $fonction, "verticale $align", $javascript);
230 230
 }
231 231
 
232 232
 /**
@@ -251,15 +251,15 @@  discard block
 block discarded – undo
251 251
  *     Code HTML du lien
252 252
  **/
253 253
 function icone_horizontale($texte, $lien, $fond, $fonction = "", $dummy = "", $javascript = "") {
254
-	$retour = '';
255
-	// cas d'ajax_action_auteur: faut defaire le boulot
256
-	// (il faudrait fusionner avec le cas $javascript)
257
-	if (preg_match(",^<a\shref='([^']*)'([^>]*)>(.*)</a>$,i", $lien, $r)) {
258
-		list($x, $lien, $atts, $texte) = $r;
259
-		$javascript .= $atts;
260
-	}
254
+    $retour = '';
255
+    // cas d'ajax_action_auteur: faut defaire le boulot
256
+    // (il faudrait fusionner avec le cas $javascript)
257
+    if (preg_match(",^<a\shref='([^']*)'([^>]*)>(.*)</a>$,i", $lien, $r)) {
258
+        list($x, $lien, $atts, $texte) = $r;
259
+        $javascript .= $atts;
260
+    }
261 261
 
262
-	$retour = icone_base($lien, $texte, $fond, $fonction, "horizontale", $javascript);
262
+    $retour = icone_base($lien, $texte, $fond, $fonction, "horizontale", $javascript);
263 263
 
264
-	return $retour;
264
+    return $retour;
265 265
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -43,9 +43,9 @@  discard block
 block discarded – undo
43 43
 	);
44 44
 	$style_titre_mapping = array('couleur' => 'topper', 'trait-couleur' => 'section');
45 45
 	$c = isset($style_mapping[$style]) ? $style_mapping[$style] : 'simple';
46
-	$class = $c . ($class ? " $class" : "");
46
+	$class = $c.($class ? " $class" : "");
47 47
 	if (!$padding) {
48
-		$class .= ($class ? " " : "") . "no-padding";
48
+		$class .= ($class ? " " : "")."no-padding";
49 49
 	}
50 50
 
51 51
 	//($id?"id='$id' ":"")
@@ -60,12 +60,12 @@  discard block
 block discarded – undo
60 60
 		if ($fonction) {
61 61
 			// 2 images pour composer l'icone : le fond (article) en background,
62 62
 			// la fonction (new) en image
63
-			$icone = http_img_pack($fonction, "", "class='cadre-icone' width='$size' height='$size'\n" .
63
+			$icone = http_img_pack($fonction, "", "class='cadre-icone' width='$size' height='$size'\n".
64 64
 				http_style_background($fond, "no-repeat center center"));
65 65
 		} else {
66 66
 			$icone = http_img_pack($fond, "", "class='cadre-icone' width='$size' height='$size'");
67 67
 		}
68
-		$titre = $icone . $titre;
68
+		$titre = $icone.$titre;
69 69
 	}
70 70
 
71 71
 	return boite_ouvrir($titre, $class, isset($style_titre_mapping[$style]) ? $style_titre_mapping[$style] : '', $id);
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 	$titre,
160 160
 	$ze_logo = ''
161 161
 ) {
162
-	return "<h1 class = 'grostitre'>" . $ze_logo . ' ' . typo($titre) . "</h1>\n";
162
+	return "<h1 class = 'grostitre'>".$ze_logo.' '.typo($titre)."</h1>\n";
163 163
 }
164 164
 
165 165
 // La boite des raccourcis
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 // http://code.spip.net/@bloc_des_raccourcis
168 168
 function bloc_des_raccourcis($bloc) {
169 169
 	return creer_colonne_droite()
170
-	. boite_ouvrir(_T('titre_cadre_raccourcis'), 'raccourcis') . $bloc . boite_fermer();
170
+	. boite_ouvrir(_T('titre_cadre_raccourcis'), 'raccourcis').$bloc.boite_fermer();
171 171
 }
172 172
 
173 173
 //
Please login to merge, or discard this patch.
ecrire/inc/puce_statut.php 3 patches
Doc Comments   +7 added lines patch added patch discarded remove patch
@@ -415,6 +415,13 @@
 block discarded – undo
415 415
 }
416 416
 
417 417
 
418
+/**
419
+ * @param integer $id
420
+ * @param string $type
421
+ * @param double $n
422
+ * @param string|null $img
423
+ * @param string $titre
424
+ */
418 425
 function afficher_script_statut($id, $type, $n, $img, $statut, $titre, $act = '') {
419 426
 	$h = generer_action_auteur("instituer_objet", "$type-$id-$statut");
420 427
 	$h = "selec_statut('$id', '$type', $n, jQuery('img',this).attr('src'), '$h');return false;";
Please login to merge, or discard this patch.
Indentation   +240 added lines, -240 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 = array();
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 = array();
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-8.png';
130
-				break;
131
-			case 'prop':
132
-				$src = 'puce-proposer-8.png';
133
-				break;
134
-			case 'publie':
135
-				$src = 'puce-publier-8.png';
136
-				break;
137
-			case 'refuse':
138
-				$src = 'puce-refuser-8.png';
139
-				break;
140
-			case 'poubelle':
141
-			case 'poub':
142
-				$src = 'puce-supprimer-8.png';
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-8.png';
130
+                break;
131
+            case 'prop':
132
+                $src = 'puce-proposer-8.png';
133
+                break;
134
+            case 'publie':
135
+                $src = 'puce-publier-8.png';
136
+                break;
137
+            case 'refuse':
138
+                $src = 'puce-refuser-8.png';
139
+                break;
140
+            case 'poubelle':
141
+            case 'poub':
142
+                $src = 'puce-supprimer-8.png';
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,114 +323,114 @@  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 (!$id
339
-		or !_SPIP_AJAX
340
-		or !$menu_rapide
341
-	) {
342
-		$ajax_node = '';
343
-	} else {
344
-		$ajax_node = " class='imgstatut$type$id'";
345
-	}
346
-
347
-
348
-	$t = statut_titre($type, $statut);
349
-	$inser_puce = http_img_pack($src, $t, $ajax_node, $t);
350
-
351
-	if (!$ajax_node) {
352
-		return $inser_puce;
353
-	}
354
-
355
-	$table = table_objet_sql($type);
356
-	$desc = lister_tables_objets_sql($table);
357
-	if (!isset($desc['statut_textes_instituer'])) {
358
-		return $inser_puce;
359
-	}
360
-
361
-	if (!function_exists('autoriser')) {
362
-		include_spip('inc/autoriser');
363
-	}
364
-
365
-	// cas ou l'on a un parent connu (devrait disparaitre au profit du second cas plus generique)
366
-	if ($id_rubrique) {
367
-		if (!autoriser('publierdans', 'rubrique', $id_rubrique)) {
368
-			return $inser_puce;
369
-		}
370
-	} // si pas d'id_rubrique fourni, tester directement instituer type avec le statut publie
371
-	else {
372
-		if (!autoriser('instituer', $type, $id, null, array('statut' => 'publie'))) {
373
-			return $inser_puce;
374
-		}
375
-	}
376
-
377
-	$coord = array_flip(array_keys($desc['statut_textes_instituer']));
378
-	if (!isset($coord[$statut])) {
379
-		return $inser_puce;
380
-	}
381
-
382
-	$unit = 8/*widh de img*/ + 4/*padding*/
383
-	;
384
-	$margin = 4; /* marge a gauche + droite */
385
-	$zero = 1 /*border*/ + $margin / 2 + 2 /*padding*/
386
-	;
387
-	$clip = $zero + ($unit * $coord[$statut]);
388
-
389
-	if ($ajax) {
390
-		$width = $unit * count($desc['statut_textes_instituer']) + $margin;
391
-		$out = "<span class='puce_objet_fixe $type'>"
392
-			. $inser_puce
393
-			. "</span>"
394
-			. "<span class='puce_objet_popup $type statutdecal$type$id' style='width:{$width}px;margin-left:-{$clip}px;'>";
395
-		$i = 0;
396
-		foreach ($desc['statut_textes_instituer'] as $s => $t) {
397
-			$out .= afficher_script_statut($id, $type, -$zero - $i++ * $unit, statut_image($type, $s), $s, _T($t));
398
-		}
399
-		$out .= "</span>";
400
-
401
-		return $out;
402
-	} else {
403
-
404
-		$nom = "puce_statut_";
405
-		$action = generer_url_ecrire('puce_statut', "", true);
406
-		$action = "if (!this.puce_loaded) { this.puce_loaded = true; prepare_selec_statut(this, '$nom', '$type', '$id', '$action'); }";
407
-		$over = " onmouseover=\"$action\"";
408
-
409
-		$lang_dir = lang_dir(lang_typo());
410
-
411
-		return "<span class='puce_objet $type' id='$nom$type$id' dir='$lang_dir'$over>"
412
-		. $inser_puce
413
-		. '</span>';
414
-	}
333
+    $src = statut_image($type, $statut);
334
+    if (!$src) {
335
+        return $src;
336
+    }
337
+
338
+    if (!$id
339
+        or !_SPIP_AJAX
340
+        or !$menu_rapide
341
+    ) {
342
+        $ajax_node = '';
343
+    } else {
344
+        $ajax_node = " class='imgstatut$type$id'";
345
+    }
346
+
347
+
348
+    $t = statut_titre($type, $statut);
349
+    $inser_puce = http_img_pack($src, $t, $ajax_node, $t);
350
+
351
+    if (!$ajax_node) {
352
+        return $inser_puce;
353
+    }
354
+
355
+    $table = table_objet_sql($type);
356
+    $desc = lister_tables_objets_sql($table);
357
+    if (!isset($desc['statut_textes_instituer'])) {
358
+        return $inser_puce;
359
+    }
360
+
361
+    if (!function_exists('autoriser')) {
362
+        include_spip('inc/autoriser');
363
+    }
364
+
365
+    // cas ou l'on a un parent connu (devrait disparaitre au profit du second cas plus generique)
366
+    if ($id_rubrique) {
367
+        if (!autoriser('publierdans', 'rubrique', $id_rubrique)) {
368
+            return $inser_puce;
369
+        }
370
+    } // si pas d'id_rubrique fourni, tester directement instituer type avec le statut publie
371
+    else {
372
+        if (!autoriser('instituer', $type, $id, null, array('statut' => 'publie'))) {
373
+            return $inser_puce;
374
+        }
375
+    }
376
+
377
+    $coord = array_flip(array_keys($desc['statut_textes_instituer']));
378
+    if (!isset($coord[$statut])) {
379
+        return $inser_puce;
380
+    }
381
+
382
+    $unit = 8/*widh de img*/ + 4/*padding*/
383
+    ;
384
+    $margin = 4; /* marge a gauche + droite */
385
+    $zero = 1 /*border*/ + $margin / 2 + 2 /*padding*/
386
+    ;
387
+    $clip = $zero + ($unit * $coord[$statut]);
388
+
389
+    if ($ajax) {
390
+        $width = $unit * count($desc['statut_textes_instituer']) + $margin;
391
+        $out = "<span class='puce_objet_fixe $type'>"
392
+            . $inser_puce
393
+            . "</span>"
394
+            . "<span class='puce_objet_popup $type statutdecal$type$id' style='width:{$width}px;margin-left:-{$clip}px;'>";
395
+        $i = 0;
396
+        foreach ($desc['statut_textes_instituer'] as $s => $t) {
397
+            $out .= afficher_script_statut($id, $type, -$zero - $i++ * $unit, statut_image($type, $s), $s, _T($t));
398
+        }
399
+        $out .= "</span>";
400
+
401
+        return $out;
402
+    } else {
403
+
404
+        $nom = "puce_statut_";
405
+        $action = generer_url_ecrire('puce_statut', "", true);
406
+        $action = "if (!this.puce_loaded) { this.puce_loaded = true; prepare_selec_statut(this, '$nom', '$type', '$id', '$action'); }";
407
+        $over = " onmouseover=\"$action\"";
408
+
409
+        $lang_dir = lang_dir(lang_typo());
410
+
411
+        return "<span class='puce_objet $type' id='$nom$type$id' dir='$lang_dir'$over>"
412
+        . $inser_puce
413
+        . '</span>';
414
+    }
415 415
 }
416 416
 
417 417
 
418 418
 function afficher_script_statut($id, $type, $n, $img, $statut, $titre, $act = '') {
419
-	$h = generer_action_auteur("instituer_objet", "$type-$id-$statut");
420
-	$h = "selec_statut('$id', '$type', $n, jQuery('img',this).attr('src'), '$h');return false;";
421
-	$t = supprimer_tags($titre);
419
+    $h = generer_action_auteur("instituer_objet", "$type-$id-$statut");
420
+    $h = "selec_statut('$id', '$type', $n, jQuery('img',this).attr('src'), '$h');return false;";
421
+    $t = supprimer_tags($titre);
422 422
 
423
-	return "<a href=\"#\" onclick=\"$h\" title=\"$t\"$act>" . http_img_pack($img, $t) . "</a>";
423
+    return "<a href=\"#\" onclick=\"$h\" title=\"$t\"$act>" . http_img_pack($img, $t) . "</a>";
424 424
 }
425 425
 
426 426
 // compat
427 427
 // La couleur du statut
428 428
 
429 429
 function puce_statut($statut, $atts = '') {
430
-	$src = statut_image('article', $statut);
431
-	if (!$src) {
432
-		return '';
433
-	}
430
+    $src = statut_image('article', $statut);
431
+    if (!$src) {
432
+        return '';
433
+    }
434 434
 
435
-	return http_img_pack($src, statut_titre('article', $statut), $atts);
435
+    return http_img_pack($src, statut_titre('article', $statut), $atts);
436 436
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -420,7 +420,7 @@
 block discarded – undo
420 420
 	$h = "selec_statut('$id', '$type', $n, jQuery('img',this).attr('src'), '$h');return false;";
421 421
 	$t = supprimer_tags($titre);
422 422
 
423
-	return "<a href=\"#\" onclick=\"$h\" title=\"$t\"$act>" . http_img_pack($img, $t) . "</a>";
423
+	return "<a href=\"#\" onclick=\"$h\" title=\"$t\"$act>".http_img_pack($img, $t)."</a>";
424 424
 }
425 425
 
426 426
 // compat
Please login to merge, or discard this patch.
ecrire/inc/rubriques.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
  *     Ancien statut de la rubrique
51 51
  * @param bool $postdate
52 52
  *     true pour recalculer aussi la date du prochain article post-daté
53
- * @return bool
53
+ * @return boolean|null
54 54
  *     true si le statut change effectivement
55 55
  **/
56 56
 function calculer_rubriques_if($id_rubrique, $modifs, $statut_ancien = '', $postdate = false) {
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
  * de la rubrique parente lorsque langue_choisie est différent de oui,
425 425
  * et les corrige.
426 426
  *
427
- * @return bool
427
+ * @return boolean|string
428 428
  *     true si un changement a eu lieu
429 429
  **/
430 430
 function calculer_langues_rubriques_etape() {
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -78,10 +78,12 @@
 block discarded – undo
78 78
 		}
79 79
 	}
80 80
 
81
-	if ($neuf) // Sauver la date de la derniere mise a jour (pour menu_rubriques)
81
+	if ($neuf) {
82
+	    // Sauver la date de la derniere mise a jour (pour menu_rubriques)
82 83
 	{
83 84
 		ecrire_meta("date_calcul_rubriques", date("U"));
84 85
 	}
86
+	}
85 87
 
86 88
 	$langues = calculer_langues_utilisees();
87 89
 	ecrire_meta('langues_utilisees', $langues);
Please login to merge, or discard this patch.
Indentation   +496 added lines, -496 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
 
@@ -54,37 +54,37 @@  discard block
 block discarded – undo
54 54
  *     true si le statut change effectivement
55 55
  **/
56 56
 function calculer_rubriques_if($id_rubrique, $modifs, $statut_ancien = '', $postdate = false) {
57
-	$neuf = false;
58
-	if ($statut_ancien == 'publie') {
59
-		if (isset($modifs['statut'])
60
-			or isset($modifs['id_rubrique'])
61
-			or ($postdate and strtotime($postdate) > time())
62
-		) {
63
-			$neuf |= depublier_branche_rubrique_if($id_rubrique);
64
-		}
65
-		// ne publier que si c'est pas un postdate, ou si la date n'est pas dans le futur
66
-		if ($postdate) {
67
-			calculer_prochain_postdate(true);
68
-			$neuf |= (strtotime($postdate) <= time()); // par securite
69
-		} elseif (isset($modifs['id_rubrique'])) {
70
-			$neuf |= publier_branche_rubrique($modifs['id_rubrique']);
71
-		}
72
-	} elseif (isset($modifs['statut']) and $modifs['statut'] == 'publie') {
73
-		if ($postdate) {
74
-			calculer_prochain_postdate(true);
75
-			$neuf |= (strtotime($postdate) <= time()); // par securite
76
-		} else {
77
-			$neuf |= publier_branche_rubrique($id_rubrique);
78
-		}
79
-	}
80
-
81
-	if ($neuf) // Sauver la date de la derniere mise a jour (pour menu_rubriques)
82
-	{
83
-		ecrire_meta("date_calcul_rubriques", date("U"));
84
-	}
85
-
86
-	$langues = calculer_langues_utilisees();
87
-	ecrire_meta('langues_utilisees', $langues);
57
+    $neuf = false;
58
+    if ($statut_ancien == 'publie') {
59
+        if (isset($modifs['statut'])
60
+            or isset($modifs['id_rubrique'])
61
+            or ($postdate and strtotime($postdate) > time())
62
+        ) {
63
+            $neuf |= depublier_branche_rubrique_if($id_rubrique);
64
+        }
65
+        // ne publier que si c'est pas un postdate, ou si la date n'est pas dans le futur
66
+        if ($postdate) {
67
+            calculer_prochain_postdate(true);
68
+            $neuf |= (strtotime($postdate) <= time()); // par securite
69
+        } elseif (isset($modifs['id_rubrique'])) {
70
+            $neuf |= publier_branche_rubrique($modifs['id_rubrique']);
71
+        }
72
+    } elseif (isset($modifs['statut']) and $modifs['statut'] == 'publie') {
73
+        if ($postdate) {
74
+            calculer_prochain_postdate(true);
75
+            $neuf |= (strtotime($postdate) <= time()); // par securite
76
+        } else {
77
+            $neuf |= publier_branche_rubrique($id_rubrique);
78
+        }
79
+    }
80
+
81
+    if ($neuf) // Sauver la date de la derniere mise a jour (pour menu_rubriques)
82
+    {
83
+        ecrire_meta("date_calcul_rubriques", date("U"));
84
+    }
85
+
86
+    $langues = calculer_langues_utilisees();
87
+    ecrire_meta('langues_utilisees', $langues);
88 88
 }
89 89
 
90 90
 
@@ -102,19 +102,19 @@  discard block
 block discarded – undo
102 102
  *     true si le statut change effectivement
103 103
  */
104 104
 function publier_branche_rubrique($id_rubrique) {
105
-	$id_pred = $id_rubrique;
106
-	while (true) {
107
-		sql_updateq('spip_rubriques', array('statut' => 'publie', 'date' => date('Y-m-d H:i:s')),
108
-			"id_rubrique=" . intval($id_rubrique));
109
-		$id_parent = sql_getfetsel('id_parent', 'spip_rubriques AS R', "R.id_rubrique=" . intval($id_rubrique));
110
-		if (!$id_parent) {
111
-			break;
112
-		}
113
-		$id_rubrique = $id_parent;
114
-	}
105
+    $id_pred = $id_rubrique;
106
+    while (true) {
107
+        sql_updateq('spip_rubriques', array('statut' => 'publie', 'date' => date('Y-m-d H:i:s')),
108
+            "id_rubrique=" . intval($id_rubrique));
109
+        $id_parent = sql_getfetsel('id_parent', 'spip_rubriques AS R', "R.id_rubrique=" . intval($id_rubrique));
110
+        if (!$id_parent) {
111
+            break;
112
+        }
113
+        $id_rubrique = $id_parent;
114
+    }
115 115
 
116 116
 #	spip_log(" publier_branche_rubrique($id_rubrique $id_pred");
117
-	return $id_pred != $id_rubrique;
117
+    return $id_pred != $id_rubrique;
118 118
 }
119 119
 
120 120
 /**
@@ -132,21 +132,21 @@  discard block
 block discarded – undo
132 132
  *     true si le statut change effectivement
133 133
  */
134 134
 function depublier_branche_rubrique_if($id_rubrique) {
135
-	$date = date('Y-m-d H:i:s'); // figer la date
135
+    $date = date('Y-m-d H:i:s'); // figer la date
136 136
 
137
-	#	spip_log("depublier_branche_rubrique($id_rubrique ?");
138
-	$id_pred = $id_rubrique;
139
-	while ($id_pred) {
137
+    #	spip_log("depublier_branche_rubrique($id_rubrique ?");
138
+    $id_pred = $id_rubrique;
139
+    while ($id_pred) {
140 140
 
141
-		if (!depublier_rubrique_if($id_pred, $date)) {
142
-			return $id_pred != $id_rubrique;
143
-		}
144
-		// passer au parent si on a depublie
145
-		$r = sql_fetsel("id_parent", "spip_rubriques", "id_rubrique=" . intval($id_pred));
146
-		$id_pred = $r['id_parent'];
147
-	}
141
+        if (!depublier_rubrique_if($id_pred, $date)) {
142
+            return $id_pred != $id_rubrique;
143
+        }
144
+        // passer au parent si on a depublie
145
+        $r = sql_fetsel("id_parent", "spip_rubriques", "id_rubrique=" . intval($id_pred));
146
+        $id_pred = $r['id_parent'];
147
+    }
148 148
 
149
-	return $id_pred != $id_rubrique;
149
+    return $id_pred != $id_rubrique;
150 150
 }
151 151
 
152 152
 /**
@@ -163,55 +163,55 @@  discard block
 block discarded – undo
163 163
  *    true si la rubrique a été dépubliée
164 164
  */
165 165
 function depublier_rubrique_if($id_rubrique, $date = null) {
166
-	if (is_null($date)) {
167
-		$date = date('Y-m-d H:i:s');
168
-	}
169
-	$postdates = ($GLOBALS['meta']["post_dates"] == "non") ?
170
-		" AND date <= " . sql_quote($date) : '';
171
-
172
-	if (!$id_rubrique = intval($id_rubrique)) {
173
-		return false;
174
-	}
175
-
176
-	// verifier qu'elle existe et est bien publiee
177
-	$r = sql_fetsel('id_rubrique,statut', 'spip_rubriques', "id_rubrique=" . intval($id_rubrique));
178
-	if (!$r or $r['statut'] !== 'publie') {
179
-		return false;
180
-	}
181
-
182
-	// On met le nombre de chaque type d'enfants dans un tableau
183
-	// Le type de l'objet est au pluriel
184
-	$compte = array(
185
-		'articles' => sql_countsel("spip_articles",
186
-			"id_rubrique=" . intval($id_rubrique) . " AND statut='publie'$postdates"),
187
-		'rubriques' => sql_countsel("spip_rubriques", "id_parent=" . intval($id_rubrique) . " AND statut='publie'"),
188
-		'documents' => sql_countsel("spip_documents_liens", "id_objet=" . intval($id_rubrique) . " AND objet='rubrique'")
189
-	);
190
-
191
-	// On passe le tableau des comptes dans un pipeline pour que les plugins puissent ajouter (ou retirer) des enfants
192
-	$compte = pipeline('objet_compte_enfants',
193
-		array(
194
-			'args' => array(
195
-				'objet' => 'rubrique',
196
-				'id_objet' => $id_rubrique,
197
-				'statut' => 'publie',
198
-				'date' => $date
199
-			),
200
-			'data' => $compte
201
-		)
202
-	);
203
-
204
-	// S'il y a au moins un enfant de n'importe quoi, on ne dépublie pas
205
-	foreach ($compte as $objet => $n) {
206
-		if ($n) {
207
-			return false;
208
-		}
209
-	}
210
-
211
-	sql_updateq("spip_rubriques", array("statut" => 'prepa'), "id_rubrique=" . intval($id_rubrique));
166
+    if (is_null($date)) {
167
+        $date = date('Y-m-d H:i:s');
168
+    }
169
+    $postdates = ($GLOBALS['meta']["post_dates"] == "non") ?
170
+        " AND date <= " . sql_quote($date) : '';
171
+
172
+    if (!$id_rubrique = intval($id_rubrique)) {
173
+        return false;
174
+    }
175
+
176
+    // verifier qu'elle existe et est bien publiee
177
+    $r = sql_fetsel('id_rubrique,statut', 'spip_rubriques', "id_rubrique=" . intval($id_rubrique));
178
+    if (!$r or $r['statut'] !== 'publie') {
179
+        return false;
180
+    }
181
+
182
+    // On met le nombre de chaque type d'enfants dans un tableau
183
+    // Le type de l'objet est au pluriel
184
+    $compte = array(
185
+        'articles' => sql_countsel("spip_articles",
186
+            "id_rubrique=" . intval($id_rubrique) . " AND statut='publie'$postdates"),
187
+        'rubriques' => sql_countsel("spip_rubriques", "id_parent=" . intval($id_rubrique) . " AND statut='publie'"),
188
+        'documents' => sql_countsel("spip_documents_liens", "id_objet=" . intval($id_rubrique) . " AND objet='rubrique'")
189
+    );
190
+
191
+    // On passe le tableau des comptes dans un pipeline pour que les plugins puissent ajouter (ou retirer) des enfants
192
+    $compte = pipeline('objet_compte_enfants',
193
+        array(
194
+            'args' => array(
195
+                'objet' => 'rubrique',
196
+                'id_objet' => $id_rubrique,
197
+                'statut' => 'publie',
198
+                'date' => $date
199
+            ),
200
+            'data' => $compte
201
+        )
202
+    );
203
+
204
+    // S'il y a au moins un enfant de n'importe quoi, on ne dépublie pas
205
+    foreach ($compte as $objet => $n) {
206
+        if ($n) {
207
+            return false;
208
+        }
209
+    }
210
+
211
+    sql_updateq("spip_rubriques", array("statut" => 'prepa'), "id_rubrique=" . intval($id_rubrique));
212 212
 
213 213
 #		spip_log("depublier_rubrique $id_pred");
214
-	return true;
214
+    return true;
215 215
 }
216 216
 
217 217
 
@@ -234,18 +234,18 @@  discard block
 block discarded – undo
234 234
  **/
235 235
 function calculer_rubriques() {
236 236
 
237
-	calculer_rubriques_publiees();
237
+    calculer_rubriques_publiees();
238 238
 
239
-	// Apres chaque (de)publication 
240
-	// recalculer les langues utilisees sur le site
241
-	$langues = calculer_langues_utilisees();
242
-	ecrire_meta('langues_utilisees', $langues);
239
+    // Apres chaque (de)publication 
240
+    // recalculer les langues utilisees sur le site
241
+    $langues = calculer_langues_utilisees();
242
+    ecrire_meta('langues_utilisees', $langues);
243 243
 
244
-	// Sauver la date de la derniere mise a jour (pour menu_rubriques)
245
-	ecrire_meta("date_calcul_rubriques", date("U"));
244
+    // Sauver la date de la derniere mise a jour (pour menu_rubriques)
245
+    ecrire_meta("date_calcul_rubriques", date("U"));
246 246
 
247
-	// on calcule la date du prochain article post-date
248
-	calculer_prochain_postdate();
247
+    // on calcule la date du prochain article post-date
248
+    calculer_prochain_postdate();
249 249
 }
250 250
 
251 251
 
@@ -262,51 +262,51 @@  discard block
 block discarded – undo
262 262
  **/
263 263
 function calculer_rubriques_publiees() {
264 264
 
265
-	// Mettre les compteurs a zero
266
-	sql_updateq('spip_rubriques', array('date_tmp' => '0000-00-00 00:00:00', 'statut_tmp' => 'prepa'));
267
-
268
-	//
269
-	// Publier et dater les rubriques qui ont un article publie
270
-	//
271
-
272
-	// Afficher les articles post-dates ?
273
-	$postdates = ($GLOBALS['meta']["post_dates"] == "non") ?
274
-		"AND A.date <= " . sql_quote(date('Y-m-d H:i:s')) : '';
275
-
276
-	$r = sql_select(
277
-		"R.id_rubrique AS id, max(A.date) AS date_h",
278
-		"spip_rubriques AS R JOIN spip_articles AS A ON R.id_rubrique = A.id_rubrique",
279
-		"A.date>R.date_tmp AND A.statut='publie' $postdates ", "R.id_rubrique");
280
-	while ($row = sql_fetch($r)) {
281
-		sql_updateq("spip_rubriques", array("statut_tmp" => 'publie', "date_tmp" => $row['date_h']),
282
-			"id_rubrique=" . intval($row['id']));
283
-	}
284
-
285
-	// point d'entree pour permettre a des plugins de gerer le statut
286
-	// autrement (par ex: toute rubrique est publiee des sa creation)
287
-	// Ce pipeline fait ce qu'il veut, mais s'il touche aux statuts/dates
288
-	// c'est statut_tmp/date_tmp qu'il doit modifier
289
-	// [C'est un trigger... a renommer en trig_calculer_rubriques ?]
290
-	pipeline('calculer_rubriques', null);
291
-
292
-
293
-	// Les rubriques qui ont une rubrique fille plus recente
294
-	// on tourne tant que les donnees remontent vers la racine.
295
-	do {
296
-		$continuer = false;
297
-		$r = sql_select(
298
-			"R.id_rubrique AS id, max(SR.date_tmp) AS date_h",
299
-			"spip_rubriques AS R JOIN spip_rubriques AS SR ON R.id_rubrique = SR.id_parent",
300
-			"(SR.date_tmp>R.date_tmp OR R.statut_tmp<>'publie') AND SR.statut_tmp='publie' ", "R.id_rubrique");
301
-		while ($row = sql_fetch($r)) {
302
-			sql_updateq('spip_rubriques', array('statut_tmp' => 'publie', 'date_tmp' => $row['date_h']),
303
-				"id_rubrique=" . intval($row['id']));
304
-			$continuer = true;
305
-		}
306
-	} while ($continuer);
307
-
308
-	// Enregistrement des modifs
309
-	sql_update('spip_rubriques', array('date' => 'date_tmp', 'statut' => 'statut_tmp'));
265
+    // Mettre les compteurs a zero
266
+    sql_updateq('spip_rubriques', array('date_tmp' => '0000-00-00 00:00:00', 'statut_tmp' => 'prepa'));
267
+
268
+    //
269
+    // Publier et dater les rubriques qui ont un article publie
270
+    //
271
+
272
+    // Afficher les articles post-dates ?
273
+    $postdates = ($GLOBALS['meta']["post_dates"] == "non") ?
274
+        "AND A.date <= " . sql_quote(date('Y-m-d H:i:s')) : '';
275
+
276
+    $r = sql_select(
277
+        "R.id_rubrique AS id, max(A.date) AS date_h",
278
+        "spip_rubriques AS R JOIN spip_articles AS A ON R.id_rubrique = A.id_rubrique",
279
+        "A.date>R.date_tmp AND A.statut='publie' $postdates ", "R.id_rubrique");
280
+    while ($row = sql_fetch($r)) {
281
+        sql_updateq("spip_rubriques", array("statut_tmp" => 'publie', "date_tmp" => $row['date_h']),
282
+            "id_rubrique=" . intval($row['id']));
283
+    }
284
+
285
+    // point d'entree pour permettre a des plugins de gerer le statut
286
+    // autrement (par ex: toute rubrique est publiee des sa creation)
287
+    // Ce pipeline fait ce qu'il veut, mais s'il touche aux statuts/dates
288
+    // c'est statut_tmp/date_tmp qu'il doit modifier
289
+    // [C'est un trigger... a renommer en trig_calculer_rubriques ?]
290
+    pipeline('calculer_rubriques', null);
291
+
292
+
293
+    // Les rubriques qui ont une rubrique fille plus recente
294
+    // on tourne tant que les donnees remontent vers la racine.
295
+    do {
296
+        $continuer = false;
297
+        $r = sql_select(
298
+            "R.id_rubrique AS id, max(SR.date_tmp) AS date_h",
299
+            "spip_rubriques AS R JOIN spip_rubriques AS SR ON R.id_rubrique = SR.id_parent",
300
+            "(SR.date_tmp>R.date_tmp OR R.statut_tmp<>'publie') AND SR.statut_tmp='publie' ", "R.id_rubrique");
301
+        while ($row = sql_fetch($r)) {
302
+            sql_updateq('spip_rubriques', array('statut_tmp' => 'publie', 'date_tmp' => $row['date_h']),
303
+                "id_rubrique=" . intval($row['id']));
304
+            $continuer = true;
305
+        }
306
+    } while ($continuer);
307
+
308
+    // Enregistrement des modifs
309
+    sql_update('spip_rubriques', array('date' => 'date_tmp', 'statut' => 'statut_tmp'));
310 310
 }
311 311
 
312 312
 /**
@@ -321,99 +321,99 @@  discard block
 block discarded – undo
321 321
  * @return void
322 322
  **/
323 323
 function propager_les_secteurs() {
324
-	// Profondeur 0
325
-	// Toutes les rubriques racines sont de profondeur 0
326
-	// et fixer les id_secteur des rubriques racines
327
-	sql_update('spip_rubriques', array('id_secteur' => 'id_rubrique', 'profondeur' => 0), "id_parent=0");
328
-	// Toute rubrique non racine est de profondeur >0
329
-	sql_updateq('spip_rubriques', array('profondeur' => 1), "id_parent<>0 AND profondeur=0");
330
-
331
-	// securite : pas plus d'iteration que de rubriques dans la base
332
-	$maxiter = sql_countsel("spip_rubriques");
333
-
334
-	// reparer les rubriques qui n'ont pas l'id_secteur de leur parent
335
-	// on fait profondeur par profondeur
336
-
337
-	$prof = 0;
338
-	do {
339
-		$continuer = false;
340
-
341
-		// Par recursivite : si toutes les rubriques de profondeur $prof sont bonnes
342
-		// on fixe le profondeur $prof+1
343
-
344
-		// Toutes les rubriques dont le parent est de profondeur $prof ont une profondeur $prof+1
345
-		// on teste A.profondeur > $prof+1 car :
346
-		// - toutes les rubriques de profondeur 0 à $prof sont bonnes
347
-		// - si A.profondeur = $prof+1 c'est bon
348
-		// - cela nous protege de la boucle infinie en cas de reference circulaire dans les rubriques
349
-		$maxiter2 = $maxiter;
350
-		while ($maxiter2--
351
-			and $rows = sql_allfetsel(
352
-				"A.id_rubrique AS id, R.id_secteur AS id_secteur, R.profondeur+1 as profondeur",
353
-				"spip_rubriques AS A JOIN spip_rubriques AS R ON A.id_parent = R.id_rubrique",
354
-				"R.profondeur=" . intval($prof) . " AND (A.id_secteur <> R.id_secteur OR A.profondeur > R.profondeur+1)",
355
-				"", "R.id_secteur", "0,100")) {
356
-
357
-			$id_secteur = null;
358
-			$ids = array();
359
-			while ($row = array_shift($rows)) {
360
-				if ($row['id_secteur'] !== $id_secteur) {
361
-					if (count($ids)) {
362
-						sql_updateq("spip_rubriques", array("id_secteur" => $id_secteur, 'profondeur' => $prof + 1),
363
-							sql_in('id_rubrique', $ids));
364
-					}
365
-					$id_secteur = $row['id_secteur'];
366
-					$ids = array();
367
-				}
368
-				$ids[] = $row['id'];
369
-			}
370
-			if (count($ids)) {
371
-				sql_updateq("spip_rubriques", array("id_secteur" => $id_secteur, 'profondeur' => $prof + 1),
372
-					sql_in('id_rubrique', $ids));
373
-			}
374
-		}
375
-
376
-
377
-		// Toutes les rubriques de profondeur $prof+1 qui n'ont pas un parent de profondeur $prof sont decalees
378
-		$maxiter2 = $maxiter;
379
-		while ($maxiter2--
380
-			and $rows = sql_allfetsel(
381
-				"id_rubrique as id",
382
-				"spip_rubriques",
383
-				"profondeur=" . intval($prof + 1) . " AND id_parent NOT IN (" . sql_get_select("zzz.id_rubrique",
384
-					"spip_rubriques AS zzz", "zzz.profondeur=" . intval($prof)) . ")", '', '', '0,100')) {
385
-			$rows = array_column($rows, 'id');
386
-			sql_updateq("spip_rubriques", array('profondeur' => $prof + 2), sql_in("id_rubrique", $rows));
387
-		}
388
-
389
-		// ici on a fini de valider $prof+1, toutes les rubriques de prondeur 0 a $prof+1 sont OK
390
-		// si pas de rubrique a profondeur $prof+1 pas la peine de continuer
391
-		// si il reste des rubriques non vues, c'est une branche morte ou reference circulaire (base foireuse)
392
-		// on arrete les frais
393
-		if (sql_countsel("spip_rubriques", "profondeur=" . intval($prof + 1))) {
394
-			$prof++;
395
-			$continuer = true;
396
-		}
397
-	} while ($continuer and $maxiter--);
398
-
399
-	// loger si la table des rubriques semble foireuse
400
-	// et mettre un id_secteur=0 sur ces rubriques pour eviter toute selection par les boucles
401
-	if (sql_countsel("spip_rubriques", "profondeur>" . intval($prof + 1))) {
402
-		spip_log("Les rubriques de profondeur>" . ($prof + 1) . " semblent suspectes (branches morte ou reference circulaire dans les parents)",
403
-			_LOG_CRITIQUE);
404
-		sql_update("spip_rubriques", array('id_secteur' => 0), "profondeur>" . intval($prof + 1));
405
-	}
406
-
407
-	// reparer les articles
408
-	$r = sql_select("A.id_article AS id, R.id_secteur AS secteur", "spip_articles AS A, spip_rubriques AS R",
409
-		"A.id_rubrique = R.id_rubrique AND A.id_secteur <> R.id_secteur");
410
-
411
-	while ($row = sql_fetch($r)) {
412
-		sql_update("spip_articles", array("id_secteur" => $row['secteur']), "id_article=" . intval($row['id']));
413
-	}
414
-
415
-	// avertir les plugins qui peuvent faire leur mises a jour egalement
416
-	pipeline('trig_propager_les_secteurs', '');
324
+    // Profondeur 0
325
+    // Toutes les rubriques racines sont de profondeur 0
326
+    // et fixer les id_secteur des rubriques racines
327
+    sql_update('spip_rubriques', array('id_secteur' => 'id_rubrique', 'profondeur' => 0), "id_parent=0");
328
+    // Toute rubrique non racine est de profondeur >0
329
+    sql_updateq('spip_rubriques', array('profondeur' => 1), "id_parent<>0 AND profondeur=0");
330
+
331
+    // securite : pas plus d'iteration que de rubriques dans la base
332
+    $maxiter = sql_countsel("spip_rubriques");
333
+
334
+    // reparer les rubriques qui n'ont pas l'id_secteur de leur parent
335
+    // on fait profondeur par profondeur
336
+
337
+    $prof = 0;
338
+    do {
339
+        $continuer = false;
340
+
341
+        // Par recursivite : si toutes les rubriques de profondeur $prof sont bonnes
342
+        // on fixe le profondeur $prof+1
343
+
344
+        // Toutes les rubriques dont le parent est de profondeur $prof ont une profondeur $prof+1
345
+        // on teste A.profondeur > $prof+1 car :
346
+        // - toutes les rubriques de profondeur 0 à $prof sont bonnes
347
+        // - si A.profondeur = $prof+1 c'est bon
348
+        // - cela nous protege de la boucle infinie en cas de reference circulaire dans les rubriques
349
+        $maxiter2 = $maxiter;
350
+        while ($maxiter2--
351
+            and $rows = sql_allfetsel(
352
+                "A.id_rubrique AS id, R.id_secteur AS id_secteur, R.profondeur+1 as profondeur",
353
+                "spip_rubriques AS A JOIN spip_rubriques AS R ON A.id_parent = R.id_rubrique",
354
+                "R.profondeur=" . intval($prof) . " AND (A.id_secteur <> R.id_secteur OR A.profondeur > R.profondeur+1)",
355
+                "", "R.id_secteur", "0,100")) {
356
+
357
+            $id_secteur = null;
358
+            $ids = array();
359
+            while ($row = array_shift($rows)) {
360
+                if ($row['id_secteur'] !== $id_secteur) {
361
+                    if (count($ids)) {
362
+                        sql_updateq("spip_rubriques", array("id_secteur" => $id_secteur, 'profondeur' => $prof + 1),
363
+                            sql_in('id_rubrique', $ids));
364
+                    }
365
+                    $id_secteur = $row['id_secteur'];
366
+                    $ids = array();
367
+                }
368
+                $ids[] = $row['id'];
369
+            }
370
+            if (count($ids)) {
371
+                sql_updateq("spip_rubriques", array("id_secteur" => $id_secteur, 'profondeur' => $prof + 1),
372
+                    sql_in('id_rubrique', $ids));
373
+            }
374
+        }
375
+
376
+
377
+        // Toutes les rubriques de profondeur $prof+1 qui n'ont pas un parent de profondeur $prof sont decalees
378
+        $maxiter2 = $maxiter;
379
+        while ($maxiter2--
380
+            and $rows = sql_allfetsel(
381
+                "id_rubrique as id",
382
+                "spip_rubriques",
383
+                "profondeur=" . intval($prof + 1) . " AND id_parent NOT IN (" . sql_get_select("zzz.id_rubrique",
384
+                    "spip_rubriques AS zzz", "zzz.profondeur=" . intval($prof)) . ")", '', '', '0,100')) {
385
+            $rows = array_column($rows, 'id');
386
+            sql_updateq("spip_rubriques", array('profondeur' => $prof + 2), sql_in("id_rubrique", $rows));
387
+        }
388
+
389
+        // ici on a fini de valider $prof+1, toutes les rubriques de prondeur 0 a $prof+1 sont OK
390
+        // si pas de rubrique a profondeur $prof+1 pas la peine de continuer
391
+        // si il reste des rubriques non vues, c'est une branche morte ou reference circulaire (base foireuse)
392
+        // on arrete les frais
393
+        if (sql_countsel("spip_rubriques", "profondeur=" . intval($prof + 1))) {
394
+            $prof++;
395
+            $continuer = true;
396
+        }
397
+    } while ($continuer and $maxiter--);
398
+
399
+    // loger si la table des rubriques semble foireuse
400
+    // et mettre un id_secteur=0 sur ces rubriques pour eviter toute selection par les boucles
401
+    if (sql_countsel("spip_rubriques", "profondeur>" . intval($prof + 1))) {
402
+        spip_log("Les rubriques de profondeur>" . ($prof + 1) . " semblent suspectes (branches morte ou reference circulaire dans les parents)",
403
+            _LOG_CRITIQUE);
404
+        sql_update("spip_rubriques", array('id_secteur' => 0), "profondeur>" . intval($prof + 1));
405
+    }
406
+
407
+    // reparer les articles
408
+    $r = sql_select("A.id_article AS id, R.id_secteur AS secteur", "spip_articles AS A, spip_rubriques AS R",
409
+        "A.id_rubrique = R.id_rubrique AND A.id_secteur <> R.id_secteur");
410
+
411
+    while ($row = sql_fetch($r)) {
412
+        sql_update("spip_articles", array("id_secteur" => $row['secteur']), "id_article=" . intval($row['id']));
413
+    }
414
+
415
+    // avertir les plugins qui peuvent faire leur mises a jour egalement
416
+    pipeline('trig_propager_les_secteurs', '');
417 417
 }
418 418
 
419 419
 
@@ -428,17 +428,17 @@  discard block
 block discarded – undo
428 428
  *     true si un changement a eu lieu
429 429
  **/
430 430
 function calculer_langues_rubriques_etape() {
431
-	$s = sql_select("A.id_rubrique AS id_rubrique, R.lang AS lang", "spip_rubriques AS A, spip_rubriques AS R",
432
-		"A.id_parent = R.id_rubrique AND A.langue_choisie != 'oui' AND R.lang<>'' AND R.lang<>A.lang");
431
+    $s = sql_select("A.id_rubrique AS id_rubrique, R.lang AS lang", "spip_rubriques AS A, spip_rubriques AS R",
432
+        "A.id_parent = R.id_rubrique AND A.langue_choisie != 'oui' AND R.lang<>'' AND R.lang<>A.lang");
433 433
 
434
-	$t = false;
435
-	while ($row = sql_fetch($s)) {
436
-		$id_rubrique = $row['id_rubrique'];
437
-		$t = sql_updateq('spip_rubriques', array('lang' => $row['lang'], 'langue_choisie' => 'non'),
438
-			"id_rubrique=" . intval($id_rubrique));
439
-	}
434
+    $t = false;
435
+    while ($row = sql_fetch($s)) {
436
+        $id_rubrique = $row['id_rubrique'];
437
+        $t = sql_updateq('spip_rubriques', array('lang' => $row['lang'], 'langue_choisie' => 'non'),
438
+            "id_rubrique=" . intval($id_rubrique));
439
+    }
440 440
 
441
-	return $t;
441
+    return $t;
442 442
 }
443 443
 
444 444
 /**
@@ -458,30 +458,30 @@  discard block
 block discarded – undo
458 458
  **/
459 459
 function calculer_langues_rubriques() {
460 460
 
461
-	// rubriques (recursivite)
462
-	sql_updateq("spip_rubriques", array("lang" => $GLOBALS['meta']['langue_site'], "langue_choisie" => 'non'),
463
-		"id_parent=0 AND langue_choisie != 'oui'");
464
-	while (calculer_langues_rubriques_etape()) {
465
-		;
466
-	}
467
-
468
-	// articles
469
-	$s = sql_select("A.id_article AS id_article, R.lang AS lang", "spip_articles AS A, spip_rubriques AS R",
470
-		"A.id_rubrique = R.id_rubrique AND A.langue_choisie != 'oui' AND (length(A.lang)=0 OR length(R.lang)>0) AND R.lang<>A.lang");
471
-	while ($row = sql_fetch($s)) {
472
-		$id_article = $row['id_article'];
473
-		sql_updateq('spip_articles', array("lang" => $row['lang'], 'langue_choisie' => 'non'),
474
-			"id_article=" . intval($id_article));
475
-	}
476
-
477
-	if ($GLOBALS['meta']['multi_rubriques'] == 'oui') {
478
-
479
-		$langues = calculer_langues_utilisees();
480
-		ecrire_meta('langues_utilisees', $langues);
481
-	}
482
-
483
-	// avertir les plugins qui peuvent faire leur mises a jour egalement
484
-	pipeline('trig_calculer_langues_rubriques', '');
461
+    // rubriques (recursivite)
462
+    sql_updateq("spip_rubriques", array("lang" => $GLOBALS['meta']['langue_site'], "langue_choisie" => 'non'),
463
+        "id_parent=0 AND langue_choisie != 'oui'");
464
+    while (calculer_langues_rubriques_etape()) {
465
+        ;
466
+    }
467
+
468
+    // articles
469
+    $s = sql_select("A.id_article AS id_article, R.lang AS lang", "spip_articles AS A, spip_rubriques AS R",
470
+        "A.id_rubrique = R.id_rubrique AND A.langue_choisie != 'oui' AND (length(A.lang)=0 OR length(R.lang)>0) AND R.lang<>A.lang");
471
+    while ($row = sql_fetch($s)) {
472
+        $id_article = $row['id_article'];
473
+        sql_updateq('spip_articles', array("lang" => $row['lang'], 'langue_choisie' => 'non'),
474
+            "id_article=" . intval($id_article));
475
+    }
476
+
477
+    if ($GLOBALS['meta']['multi_rubriques'] == 'oui') {
478
+
479
+        $langues = calculer_langues_utilisees();
480
+        ecrire_meta('langues_utilisees', $langues);
481
+    }
482
+
483
+    // avertir les plugins qui peuvent faire leur mises a jour egalement
484
+    pipeline('trig_calculer_langues_rubriques', '');
485 485
 }
486 486
 
487 487
 
@@ -498,77 +498,77 @@  discard block
 block discarded – undo
498 498
  *    Liste des langues utilisées séparées par des virgules
499 499
  **/
500 500
 function calculer_langues_utilisees($serveur = '') {
501
-	include_spip('public/interfaces');
502
-	include_spip('public/compiler');
503
-	include_spip('public/composer');
504
-	include_spip('public/phraser_html');
505
-	$langues = array();
506
-
507
-	$langues[$GLOBALS['meta']['langue_site']] = 1;
508
-
509
-	include_spip('base/objets');
510
-	$tables = lister_tables_objets_sql();
511
-	$trouver_table = charger_fonction('trouver_table', 'base');
512
-
513
-	foreach (array_keys($tables) as $t) {
514
-		$desc = $trouver_table($t, $serveur);
515
-		// c'est une table avec des langues
516
-		if ($desc['exist']
517
-			and isset($desc['field']['lang'])
518
-			and isset($desc['field']['langue_choisie'])
519
-		) {
520
-
521
-			$boucle = new Boucle();
522
-			$boucle->show = $desc;
523
-			$boucle->nom = 'calculer_langues_utilisees';
524
-			$boucle->id_boucle = $desc['table_objet'];
525
-			$boucle->id_table = $desc['table_objet'];
526
-			$boucle->sql_serveur = $serveur;
527
-			$boucle->select[] = "DISTINCT lang";
528
-			$boucle->from[$desc['table_objet']] = $t;
529
-			$boucle->separateur[] = ',';
530
-			$boucle->return = '$Pile[$SP][\'lang\']';
531
-			$boucle->iterateur = 'sql';
532
-
533
-			$boucle->descr['nom'] = 'objet_test_si_publie'; // eviter notice php
534
-			$boucle->descr['sourcefile'] = 'internal';
535
-
536
-			$boucle = pipeline('pre_boucle', $boucle);
537
-
538
-			if (isset($desc['statut'])
539
-				and $desc['statut']
540
-			) {
541
-				$boucles = array(
542
-					'calculer_langues_utilisees' => $boucle,
543
-				);
544
-				// generer un nom de fonction "anonyme" unique
545
-				do {
546
-					$functionname = 'f_calculer_langues_utilisees_' . $boucle->id_table . '_' . time() . '_' . rand();
547
-				} while (function_exists($functionname));
548
-				$code = calculer_boucle('calculer_langues_utilisees', $boucles);
549
-				$code = '$SP=0; $command=array();$command["connect"] = $connect = "' . $serveur . '"; $Pile=array(0=>array());' . "\n" . $code;
550
-				$code = 'function ' . $functionname . '(){' . $code . '};$res = ' . $functionname . '();';
551
-				$res = '';
552
-				eval($code);
553
-				$res = explode(',', $res);
554
-				foreach ($res as $lang) {
555
-					$langues[$lang] = 1;
556
-				}
557
-			} else {
558
-				$res = sql_select(implode(',', $boucle->select), $boucle->from);
559
-				while ($row = sql_fetch($res)) {
560
-					$langues[$row['lang']] = 1;
561
-				}
562
-			}
563
-		}
564
-	}
565
-
566
-	$langues = array_filter(array_keys($langues));
567
-	sort($langues);
568
-	$langues = join(',', $langues);
569
-	spip_log("langues utilisees: $langues");
570
-
571
-	return $langues;
501
+    include_spip('public/interfaces');
502
+    include_spip('public/compiler');
503
+    include_spip('public/composer');
504
+    include_spip('public/phraser_html');
505
+    $langues = array();
506
+
507
+    $langues[$GLOBALS['meta']['langue_site']] = 1;
508
+
509
+    include_spip('base/objets');
510
+    $tables = lister_tables_objets_sql();
511
+    $trouver_table = charger_fonction('trouver_table', 'base');
512
+
513
+    foreach (array_keys($tables) as $t) {
514
+        $desc = $trouver_table($t, $serveur);
515
+        // c'est une table avec des langues
516
+        if ($desc['exist']
517
+            and isset($desc['field']['lang'])
518
+            and isset($desc['field']['langue_choisie'])
519
+        ) {
520
+
521
+            $boucle = new Boucle();
522
+            $boucle->show = $desc;
523
+            $boucle->nom = 'calculer_langues_utilisees';
524
+            $boucle->id_boucle = $desc['table_objet'];
525
+            $boucle->id_table = $desc['table_objet'];
526
+            $boucle->sql_serveur = $serveur;
527
+            $boucle->select[] = "DISTINCT lang";
528
+            $boucle->from[$desc['table_objet']] = $t;
529
+            $boucle->separateur[] = ',';
530
+            $boucle->return = '$Pile[$SP][\'lang\']';
531
+            $boucle->iterateur = 'sql';
532
+
533
+            $boucle->descr['nom'] = 'objet_test_si_publie'; // eviter notice php
534
+            $boucle->descr['sourcefile'] = 'internal';
535
+
536
+            $boucle = pipeline('pre_boucle', $boucle);
537
+
538
+            if (isset($desc['statut'])
539
+                and $desc['statut']
540
+            ) {
541
+                $boucles = array(
542
+                    'calculer_langues_utilisees' => $boucle,
543
+                );
544
+                // generer un nom de fonction "anonyme" unique
545
+                do {
546
+                    $functionname = 'f_calculer_langues_utilisees_' . $boucle->id_table . '_' . time() . '_' . rand();
547
+                } while (function_exists($functionname));
548
+                $code = calculer_boucle('calculer_langues_utilisees', $boucles);
549
+                $code = '$SP=0; $command=array();$command["connect"] = $connect = "' . $serveur . '"; $Pile=array(0=>array());' . "\n" . $code;
550
+                $code = 'function ' . $functionname . '(){' . $code . '};$res = ' . $functionname . '();';
551
+                $res = '';
552
+                eval($code);
553
+                $res = explode(',', $res);
554
+                foreach ($res as $lang) {
555
+                    $langues[$lang] = 1;
556
+                }
557
+            } else {
558
+                $res = sql_select(implode(',', $boucle->select), $boucle->from);
559
+                while ($row = sql_fetch($res)) {
560
+                    $langues[$row['lang']] = 1;
561
+                }
562
+            }
563
+        }
564
+    }
565
+
566
+    $langues = array_filter(array_keys($langues));
567
+    sort($langues);
568
+    $langues = join(',', $langues);
569
+    spip_log("langues utilisees: $langues");
570
+
571
+    return $langues;
572 572
 }
573 573
 
574 574
 /**
@@ -598,9 +598,9 @@  discard block
 block discarded – undo
598 598
  *     incluant les rubriques noeuds et toutes leurs descendances
599 599
  */
600 600
 function calcul_branche_in($id) {
601
-	$calcul_branche_in = charger_fonction('calcul_branche_in', 'inc');
601
+    $calcul_branche_in = charger_fonction('calcul_branche_in', 'inc');
602 602
 
603
-	return $calcul_branche_in($id);
603
+    return $calcul_branche_in($id);
604 604
 }
605 605
 
606 606
 /**
@@ -618,9 +618,9 @@  discard block
 block discarded – undo
618 618
  *     incluant les rubriques transmises et toutes leurs parentées
619 619
  */
620 620
 function calcul_hierarchie_in($id, $tout = true) {
621
-	$calcul_hierarchie_in = charger_fonction('calcul_hierarchie_in', 'inc');
621
+    $calcul_hierarchie_in = charger_fonction('calcul_hierarchie_in', 'inc');
622 622
 
623
-	return $calcul_hierarchie_in($id, $tout);
623
+    return $calcul_hierarchie_in($id, $tout);
624 624
 }
625 625
 
626 626
 
@@ -641,38 +641,38 @@  discard block
 block discarded – undo
641 641
  *     incluant les rubriques noeuds et toutes leurs descendances
642 642
  */
643 643
 function inc_calcul_branche_in_dist($id) {
644
-	static $b = array();
645
-
646
-	// normaliser $id qui a pu arriver comme un array, comme un entier, ou comme une chaine NN,NN,NN
647
-	if (!is_array($id)) {
648
-		$id = explode(',', $id);
649
-	}
650
-	$id = join(',', array_map('intval', $id));
651
-	if (isset($b[$id])) {
652
-		return $b[$id];
653
-	}
654
-
655
-	// Notre branche commence par la rubrique de depart
656
-	$branche = $r = $id;
657
-
658
-	// On ajoute une generation (les filles de la generation precedente)
659
-	// jusqu'a epuisement, en se protegeant des references circulaires
660
-	$maxiter = 10000;
661
-	while ($maxiter-- and $filles = sql_allfetsel(
662
-			'id_rubrique',
663
-			'spip_rubriques',
664
-			sql_in('id_parent', $r) . " AND " . sql_in('id_rubrique', $r, 'NOT')
665
-		)) {
666
-		$r = join(',', array_column($filles, 'id_rubrique'));
667
-		$branche .= ',' . $r;
668
-	}
669
-
670
-	# securite pour ne pas plomber la conso memoire sur les sites prolifiques
671
-	if (strlen($branche) < 10000) {
672
-		$b[$id] = $branche;
673
-	}
674
-
675
-	return $branche;
644
+    static $b = array();
645
+
646
+    // normaliser $id qui a pu arriver comme un array, comme un entier, ou comme une chaine NN,NN,NN
647
+    if (!is_array($id)) {
648
+        $id = explode(',', $id);
649
+    }
650
+    $id = join(',', array_map('intval', $id));
651
+    if (isset($b[$id])) {
652
+        return $b[$id];
653
+    }
654
+
655
+    // Notre branche commence par la rubrique de depart
656
+    $branche = $r = $id;
657
+
658
+    // On ajoute une generation (les filles de la generation precedente)
659
+    // jusqu'a epuisement, en se protegeant des references circulaires
660
+    $maxiter = 10000;
661
+    while ($maxiter-- and $filles = sql_allfetsel(
662
+            'id_rubrique',
663
+            'spip_rubriques',
664
+            sql_in('id_parent', $r) . " AND " . sql_in('id_rubrique', $r, 'NOT')
665
+        )) {
666
+        $r = join(',', array_column($filles, 'id_rubrique'));
667
+        $branche .= ',' . $r;
668
+    }
669
+
670
+    # securite pour ne pas plomber la conso memoire sur les sites prolifiques
671
+    if (strlen($branche) < 10000) {
672
+        $b[$id] = $branche;
673
+    }
674
+
675
+    return $branche;
676 676
 }
677 677
 
678 678
 
@@ -694,43 +694,43 @@  discard block
 block discarded – undo
694 694
  *     incluant les rubriques transmises et toutes leurs parentées
695 695
  */
696 696
 function inc_calcul_hierarchie_in_dist($id, $tout = true) {
697
-	static $b = array();
698
-
699
-	// normaliser $id qui a pu arriver comme un array, comme un entier, ou comme une chaine NN,NN,NN
700
-	if (!is_array($id)) {
701
-		$id = explode(',', $id);
702
-	}
703
-	$id = join(',', array_map('intval', $id));
704
-
705
-	if (isset($b[$id])) {
706
-		// Notre branche commence par la rubrique de depart si $tout=true
707
-		return $tout ? (strlen($b[$id]) ? $b[$id] . ",$id" : $id) : $b[$id];
708
-	}
709
-
710
-	$hier = "";
711
-
712
-	// On ajoute une generation (les filles de la generation precedente)
713
-	// jusqu'a epuisement, en se protegeant des references circulaires
714
-	$ids_nouveaux_parents = $id;
715
-	$maxiter = 10000;
716
-	while ($maxiter-- and $parents = sql_allfetsel(
717
-			'id_parent',
718
-			'spip_rubriques',
719
-			sql_in('id_rubrique', $ids_nouveaux_parents) . " AND " . sql_in('id_parent', $hier, 'NOT')
720
-		)) {
721
-		$ids_nouveaux_parents = join(',', array_column($parents, 'id_parent'));
722
-		$hier = $ids_nouveaux_parents . (strlen($hier) ? ',' . $hier : '');
723
-	}
724
-
725
-	# securite pour ne pas plomber la conso memoire sur les sites prolifiques
726
-	if (strlen($hier) < 10000) {
727
-		$b[$id] = $hier;
728
-	}
729
-
730
-	// Notre branche commence par la rubrique de depart si $tout=true
731
-	$hier = $tout ? (strlen($hier) ? "$hier,$id" : $id) : $hier;
732
-
733
-	return $hier;
697
+    static $b = array();
698
+
699
+    // normaliser $id qui a pu arriver comme un array, comme un entier, ou comme une chaine NN,NN,NN
700
+    if (!is_array($id)) {
701
+        $id = explode(',', $id);
702
+    }
703
+    $id = join(',', array_map('intval', $id));
704
+
705
+    if (isset($b[$id])) {
706
+        // Notre branche commence par la rubrique de depart si $tout=true
707
+        return $tout ? (strlen($b[$id]) ? $b[$id] . ",$id" : $id) : $b[$id];
708
+    }
709
+
710
+    $hier = "";
711
+
712
+    // On ajoute une generation (les filles de la generation precedente)
713
+    // jusqu'a epuisement, en se protegeant des references circulaires
714
+    $ids_nouveaux_parents = $id;
715
+    $maxiter = 10000;
716
+    while ($maxiter-- and $parents = sql_allfetsel(
717
+            'id_parent',
718
+            'spip_rubriques',
719
+            sql_in('id_rubrique', $ids_nouveaux_parents) . " AND " . sql_in('id_parent', $hier, 'NOT')
720
+        )) {
721
+        $ids_nouveaux_parents = join(',', array_column($parents, 'id_parent'));
722
+        $hier = $ids_nouveaux_parents . (strlen($hier) ? ',' . $hier : '');
723
+    }
724
+
725
+    # securite pour ne pas plomber la conso memoire sur les sites prolifiques
726
+    if (strlen($hier) < 10000) {
727
+        $b[$id] = $hier;
728
+    }
729
+
730
+    // Notre branche commence par la rubrique de depart si $tout=true
731
+    $hier = $tout ? (strlen($hier) ? "$hier,$id" : $id) : $hier;
732
+
733
+    return $hier;
734 734
 }
735 735
 
736 736
 
@@ -748,38 +748,38 @@  discard block
 block discarded – undo
748 748
  * @return void
749 749
  **/
750 750
 function calculer_prochain_postdate($check = false) {
751
-	include_spip('base/abstract_sql');
752
-	if ($check) {
753
-		$postdates = ($GLOBALS['meta']["post_dates"] == "non") ?
754
-			"AND A.date <= " . sql_quote(date('Y-m-d H:i:s')) : '';
755
-
756
-		$r = sql_select("DISTINCT A.id_rubrique AS id",
757
-			"spip_articles AS A LEFT JOIN spip_rubriques AS R ON A.id_rubrique=R.id_rubrique",
758
-			"R.statut != 'publie' AND A.statut='publie'$postdates");
759
-		while ($row = sql_fetch($r)) {
760
-			publier_branche_rubrique($row['id']);
761
-		}
762
-
763
-		pipeline('trig_calculer_prochain_postdate', '');
764
-	}
765
-
766
-	$t = sql_fetsel("date", "spip_articles", "statut='publie' AND date > " . sql_quote(date('Y-m-d H:i:s')), "", "date",
767
-		"1");
768
-
769
-	if ($t) {
770
-		$t = $t['date'];
771
-		if (!isset($GLOBALS['meta']['date_prochain_postdate'])
772
-			or $t <> $GLOBALS['meta']['date_prochain_postdate']
773
-		) {
774
-			ecrire_meta('date_prochain_postdate', strtotime($t));
775
-			ecrire_meta('derniere_modif', time());
776
-		}
777
-	} else {
778
-		effacer_meta('date_prochain_postdate');
779
-		ecrire_meta('derniere_modif', time());
780
-	}
781
-
782
-	spip_log("prochain postdate: $t");
751
+    include_spip('base/abstract_sql');
752
+    if ($check) {
753
+        $postdates = ($GLOBALS['meta']["post_dates"] == "non") ?
754
+            "AND A.date <= " . sql_quote(date('Y-m-d H:i:s')) : '';
755
+
756
+        $r = sql_select("DISTINCT A.id_rubrique AS id",
757
+            "spip_articles AS A LEFT JOIN spip_rubriques AS R ON A.id_rubrique=R.id_rubrique",
758
+            "R.statut != 'publie' AND A.statut='publie'$postdates");
759
+        while ($row = sql_fetch($r)) {
760
+            publier_branche_rubrique($row['id']);
761
+        }
762
+
763
+        pipeline('trig_calculer_prochain_postdate', '');
764
+    }
765
+
766
+    $t = sql_fetsel("date", "spip_articles", "statut='publie' AND date > " . sql_quote(date('Y-m-d H:i:s')), "", "date",
767
+        "1");
768
+
769
+    if ($t) {
770
+        $t = $t['date'];
771
+        if (!isset($GLOBALS['meta']['date_prochain_postdate'])
772
+            or $t <> $GLOBALS['meta']['date_prochain_postdate']
773
+        ) {
774
+            ecrire_meta('date_prochain_postdate', strtotime($t));
775
+            ecrire_meta('derniere_modif', time());
776
+        }
777
+    } else {
778
+        effacer_meta('date_prochain_postdate');
779
+        ecrire_meta('derniere_modif', time());
780
+    }
781
+
782
+    spip_log("prochain postdate: $t");
783 783
 }
784 784
 
785 785
 /**
@@ -804,42 +804,42 @@  discard block
 block discarded – undo
804 804
  */
805 805
 function creer_rubrique_nommee($titre, $id_parent = 0, $serveur = '') {
806 806
 
807
-	// eclater l'arborescence demandee
808
-	// echapper les </multi> et autres balises fermantes html
809
-	$titre = preg_replace(",</([a-z][^>]*)>,ims", "<@\\1>", $titre);
810
-	$arbo = explode('/', preg_replace(',^/,', '', $titre));
811
-	include_spip('base/abstract_sql');
812
-	foreach ($arbo as $titre) {
813
-		// retablir les </multi> et autres balises fermantes html
814
-		$titre = preg_replace(",<@([a-z][^>]*)>,ims", "</\\1>", $titre);
815
-		$r = sql_getfetsel("id_rubrique", "spip_rubriques",
816
-			"titre = " . sql_quote($titre) . " AND id_parent=" . intval($id_parent),
817
-			$groupby = array(), $orderby = array(), $limit = '', $having = array(), $serveur);
818
-		if ($r !== null) {
819
-			$id_parent = $r;
820
-		} else {
821
-			$id_rubrique = sql_insertq('spip_rubriques', array(
822
-					'titre' => $titre,
823
-					'id_parent' => $id_parent,
824
-					'statut' => 'prepa'
825
-				), $desc = array(), $serveur);
826
-			if ($id_parent > 0) {
827
-				$data = sql_fetsel("id_secteur,lang", "spip_rubriques", "id_rubrique=$id_parent",
828
-					$groupby = array(), $orderby = array(), $limit = '', $having = array(), $serveur);
829
-				$id_secteur = $data['id_secteur'];
830
-				$lang = $data['lang'];
831
-			} else {
832
-				$id_secteur = $id_rubrique;
833
-				$lang = $GLOBALS['meta']['langue_site'];
834
-			}
835
-
836
-			sql_updateq('spip_rubriques', array('id_secteur' => $id_secteur, "lang" => $lang),
837
-				"id_rubrique=" . intval($id_rubrique), $desc = '', $serveur);
838
-
839
-			// pour la recursion
840
-			$id_parent = $id_rubrique;
841
-		}
842
-	}
843
-
844
-	return intval($id_parent);
807
+    // eclater l'arborescence demandee
808
+    // echapper les </multi> et autres balises fermantes html
809
+    $titre = preg_replace(",</([a-z][^>]*)>,ims", "<@\\1>", $titre);
810
+    $arbo = explode('/', preg_replace(',^/,', '', $titre));
811
+    include_spip('base/abstract_sql');
812
+    foreach ($arbo as $titre) {
813
+        // retablir les </multi> et autres balises fermantes html
814
+        $titre = preg_replace(",<@([a-z][^>]*)>,ims", "</\\1>", $titre);
815
+        $r = sql_getfetsel("id_rubrique", "spip_rubriques",
816
+            "titre = " . sql_quote($titre) . " AND id_parent=" . intval($id_parent),
817
+            $groupby = array(), $orderby = array(), $limit = '', $having = array(), $serveur);
818
+        if ($r !== null) {
819
+            $id_parent = $r;
820
+        } else {
821
+            $id_rubrique = sql_insertq('spip_rubriques', array(
822
+                    'titre' => $titre,
823
+                    'id_parent' => $id_parent,
824
+                    'statut' => 'prepa'
825
+                ), $desc = array(), $serveur);
826
+            if ($id_parent > 0) {
827
+                $data = sql_fetsel("id_secteur,lang", "spip_rubriques", "id_rubrique=$id_parent",
828
+                    $groupby = array(), $orderby = array(), $limit = '', $having = array(), $serveur);
829
+                $id_secteur = $data['id_secteur'];
830
+                $lang = $data['lang'];
831
+            } else {
832
+                $id_secteur = $id_rubrique;
833
+                $lang = $GLOBALS['meta']['langue_site'];
834
+            }
835
+
836
+            sql_updateq('spip_rubriques', array('id_secteur' => $id_secteur, "lang" => $lang),
837
+                "id_rubrique=" . intval($id_rubrique), $desc = '', $serveur);
838
+
839
+            // pour la recursion
840
+            $id_parent = $id_rubrique;
841
+        }
842
+    }
843
+
844
+    return intval($id_parent);
845 845
 }
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
 	$id_pred = $id_rubrique;
106 106
 	while (true) {
107 107
 		sql_updateq('spip_rubriques', array('statut' => 'publie', 'date' => date('Y-m-d H:i:s')),
108
-			"id_rubrique=" . intval($id_rubrique));
109
-		$id_parent = sql_getfetsel('id_parent', 'spip_rubriques AS R', "R.id_rubrique=" . intval($id_rubrique));
108
+			"id_rubrique=".intval($id_rubrique));
109
+		$id_parent = sql_getfetsel('id_parent', 'spip_rubriques AS R', "R.id_rubrique=".intval($id_rubrique));
110 110
 		if (!$id_parent) {
111 111
 			break;
112 112
 		}
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 			return $id_pred != $id_rubrique;
143 143
 		}
144 144
 		// passer au parent si on a depublie
145
-		$r = sql_fetsel("id_parent", "spip_rubriques", "id_rubrique=" . intval($id_pred));
145
+		$r = sql_fetsel("id_parent", "spip_rubriques", "id_rubrique=".intval($id_pred));
146 146
 		$id_pred = $r['id_parent'];
147 147
 	}
148 148
 
@@ -167,14 +167,14 @@  discard block
 block discarded – undo
167 167
 		$date = date('Y-m-d H:i:s');
168 168
 	}
169 169
 	$postdates = ($GLOBALS['meta']["post_dates"] == "non") ?
170
-		" AND date <= " . sql_quote($date) : '';
170
+		" AND date <= ".sql_quote($date) : '';
171 171
 
172 172
 	if (!$id_rubrique = intval($id_rubrique)) {
173 173
 		return false;
174 174
 	}
175 175
 
176 176
 	// verifier qu'elle existe et est bien publiee
177
-	$r = sql_fetsel('id_rubrique,statut', 'spip_rubriques', "id_rubrique=" . intval($id_rubrique));
177
+	$r = sql_fetsel('id_rubrique,statut', 'spip_rubriques', "id_rubrique=".intval($id_rubrique));
178 178
 	if (!$r or $r['statut'] !== 'publie') {
179 179
 		return false;
180 180
 	}
@@ -183,9 +183,9 @@  discard block
 block discarded – undo
183 183
 	// Le type de l'objet est au pluriel
184 184
 	$compte = array(
185 185
 		'articles' => sql_countsel("spip_articles",
186
-			"id_rubrique=" . intval($id_rubrique) . " AND statut='publie'$postdates"),
187
-		'rubriques' => sql_countsel("spip_rubriques", "id_parent=" . intval($id_rubrique) . " AND statut='publie'"),
188
-		'documents' => sql_countsel("spip_documents_liens", "id_objet=" . intval($id_rubrique) . " AND objet='rubrique'")
186
+			"id_rubrique=".intval($id_rubrique)." AND statut='publie'$postdates"),
187
+		'rubriques' => sql_countsel("spip_rubriques", "id_parent=".intval($id_rubrique)." AND statut='publie'"),
188
+		'documents' => sql_countsel("spip_documents_liens", "id_objet=".intval($id_rubrique)." AND objet='rubrique'")
189 189
 	);
190 190
 
191 191
 	// On passe le tableau des comptes dans un pipeline pour que les plugins puissent ajouter (ou retirer) des enfants
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 		}
209 209
 	}
210 210
 
211
-	sql_updateq("spip_rubriques", array("statut" => 'prepa'), "id_rubrique=" . intval($id_rubrique));
211
+	sql_updateq("spip_rubriques", array("statut" => 'prepa'), "id_rubrique=".intval($id_rubrique));
212 212
 
213 213
 #		spip_log("depublier_rubrique $id_pred");
214 214
 	return true;
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 
272 272
 	// Afficher les articles post-dates ?
273 273
 	$postdates = ($GLOBALS['meta']["post_dates"] == "non") ?
274
-		"AND A.date <= " . sql_quote(date('Y-m-d H:i:s')) : '';
274
+		"AND A.date <= ".sql_quote(date('Y-m-d H:i:s')) : '';
275 275
 
276 276
 	$r = sql_select(
277 277
 		"R.id_rubrique AS id, max(A.date) AS date_h",
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 		"A.date>R.date_tmp AND A.statut='publie' $postdates ", "R.id_rubrique");
280 280
 	while ($row = sql_fetch($r)) {
281 281
 		sql_updateq("spip_rubriques", array("statut_tmp" => 'publie', "date_tmp" => $row['date_h']),
282
-			"id_rubrique=" . intval($row['id']));
282
+			"id_rubrique=".intval($row['id']));
283 283
 	}
284 284
 
285 285
 	// point d'entree pour permettre a des plugins de gerer le statut
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 			"(SR.date_tmp>R.date_tmp OR R.statut_tmp<>'publie') AND SR.statut_tmp='publie' ", "R.id_rubrique");
301 301
 		while ($row = sql_fetch($r)) {
302 302
 			sql_updateq('spip_rubriques', array('statut_tmp' => 'publie', 'date_tmp' => $row['date_h']),
303
-				"id_rubrique=" . intval($row['id']));
303
+				"id_rubrique=".intval($row['id']));
304 304
 			$continuer = true;
305 305
 		}
306 306
 	} while ($continuer);
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 			and $rows = sql_allfetsel(
352 352
 				"A.id_rubrique AS id, R.id_secteur AS id_secteur, R.profondeur+1 as profondeur",
353 353
 				"spip_rubriques AS A JOIN spip_rubriques AS R ON A.id_parent = R.id_rubrique",
354
-				"R.profondeur=" . intval($prof) . " AND (A.id_secteur <> R.id_secteur OR A.profondeur > R.profondeur+1)",
354
+				"R.profondeur=".intval($prof)." AND (A.id_secteur <> R.id_secteur OR A.profondeur > R.profondeur+1)",
355 355
 				"", "R.id_secteur", "0,100")) {
356 356
 
357 357
 			$id_secteur = null;
@@ -380,8 +380,8 @@  discard block
 block discarded – undo
380 380
 			and $rows = sql_allfetsel(
381 381
 				"id_rubrique as id",
382 382
 				"spip_rubriques",
383
-				"profondeur=" . intval($prof + 1) . " AND id_parent NOT IN (" . sql_get_select("zzz.id_rubrique",
384
-					"spip_rubriques AS zzz", "zzz.profondeur=" . intval($prof)) . ")", '', '', '0,100')) {
383
+				"profondeur=".intval($prof + 1)." AND id_parent NOT IN (".sql_get_select("zzz.id_rubrique",
384
+					"spip_rubriques AS zzz", "zzz.profondeur=".intval($prof)).")", '', '', '0,100')) {
385 385
 			$rows = array_column($rows, 'id');
386 386
 			sql_updateq("spip_rubriques", array('profondeur' => $prof + 2), sql_in("id_rubrique", $rows));
387 387
 		}
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
 		// si pas de rubrique a profondeur $prof+1 pas la peine de continuer
391 391
 		// si il reste des rubriques non vues, c'est une branche morte ou reference circulaire (base foireuse)
392 392
 		// on arrete les frais
393
-		if (sql_countsel("spip_rubriques", "profondeur=" . intval($prof + 1))) {
393
+		if (sql_countsel("spip_rubriques", "profondeur=".intval($prof + 1))) {
394 394
 			$prof++;
395 395
 			$continuer = true;
396 396
 		}
@@ -398,10 +398,10 @@  discard block
 block discarded – undo
398 398
 
399 399
 	// loger si la table des rubriques semble foireuse
400 400
 	// et mettre un id_secteur=0 sur ces rubriques pour eviter toute selection par les boucles
401
-	if (sql_countsel("spip_rubriques", "profondeur>" . intval($prof + 1))) {
402
-		spip_log("Les rubriques de profondeur>" . ($prof + 1) . " semblent suspectes (branches morte ou reference circulaire dans les parents)",
401
+	if (sql_countsel("spip_rubriques", "profondeur>".intval($prof + 1))) {
402
+		spip_log("Les rubriques de profondeur>".($prof + 1)." semblent suspectes (branches morte ou reference circulaire dans les parents)",
403 403
 			_LOG_CRITIQUE);
404
-		sql_update("spip_rubriques", array('id_secteur' => 0), "profondeur>" . intval($prof + 1));
404
+		sql_update("spip_rubriques", array('id_secteur' => 0), "profondeur>".intval($prof + 1));
405 405
 	}
406 406
 
407 407
 	// reparer les articles
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
 		"A.id_rubrique = R.id_rubrique AND A.id_secteur <> R.id_secteur");
410 410
 
411 411
 	while ($row = sql_fetch($r)) {
412
-		sql_update("spip_articles", array("id_secteur" => $row['secteur']), "id_article=" . intval($row['id']));
412
+		sql_update("spip_articles", array("id_secteur" => $row['secteur']), "id_article=".intval($row['id']));
413 413
 	}
414 414
 
415 415
 	// avertir les plugins qui peuvent faire leur mises a jour egalement
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 	while ($row = sql_fetch($s)) {
436 436
 		$id_rubrique = $row['id_rubrique'];
437 437
 		$t = sql_updateq('spip_rubriques', array('lang' => $row['lang'], 'langue_choisie' => 'non'),
438
-			"id_rubrique=" . intval($id_rubrique));
438
+			"id_rubrique=".intval($id_rubrique));
439 439
 	}
440 440
 
441 441
 	return $t;
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
 	while ($row = sql_fetch($s)) {
472 472
 		$id_article = $row['id_article'];
473 473
 		sql_updateq('spip_articles', array("lang" => $row['lang'], 'langue_choisie' => 'non'),
474
-			"id_article=" . intval($id_article));
474
+			"id_article=".intval($id_article));
475 475
 	}
476 476
 
477 477
 	if ($GLOBALS['meta']['multi_rubriques'] == 'oui') {
@@ -543,11 +543,11 @@  discard block
 block discarded – undo
543 543
 				);
544 544
 				// generer un nom de fonction "anonyme" unique
545 545
 				do {
546
-					$functionname = 'f_calculer_langues_utilisees_' . $boucle->id_table . '_' . time() . '_' . rand();
546
+					$functionname = 'f_calculer_langues_utilisees_'.$boucle->id_table.'_'.time().'_'.rand();
547 547
 				} while (function_exists($functionname));
548 548
 				$code = calculer_boucle('calculer_langues_utilisees', $boucles);
549
-				$code = '$SP=0; $command=array();$command["connect"] = $connect = "' . $serveur . '"; $Pile=array(0=>array());' . "\n" . $code;
550
-				$code = 'function ' . $functionname . '(){' . $code . '};$res = ' . $functionname . '();';
549
+				$code = '$SP=0; $command=array();$command["connect"] = $connect = "'.$serveur.'"; $Pile=array(0=>array());'."\n".$code;
550
+				$code = 'function '.$functionname.'(){'.$code.'};$res = '.$functionname.'();';
551 551
 				$res = '';
552 552
 				eval($code);
553 553
 				$res = explode(',', $res);
@@ -661,10 +661,10 @@  discard block
 block discarded – undo
661 661
 	while ($maxiter-- and $filles = sql_allfetsel(
662 662
 			'id_rubrique',
663 663
 			'spip_rubriques',
664
-			sql_in('id_parent', $r) . " AND " . sql_in('id_rubrique', $r, 'NOT')
664
+			sql_in('id_parent', $r)." AND ".sql_in('id_rubrique', $r, 'NOT')
665 665
 		)) {
666 666
 		$r = join(',', array_column($filles, 'id_rubrique'));
667
-		$branche .= ',' . $r;
667
+		$branche .= ','.$r;
668 668
 	}
669 669
 
670 670
 	# securite pour ne pas plomber la conso memoire sur les sites prolifiques
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
 
705 705
 	if (isset($b[$id])) {
706 706
 		// Notre branche commence par la rubrique de depart si $tout=true
707
-		return $tout ? (strlen($b[$id]) ? $b[$id] . ",$id" : $id) : $b[$id];
707
+		return $tout ? (strlen($b[$id]) ? $b[$id].",$id" : $id) : $b[$id];
708 708
 	}
709 709
 
710 710
 	$hier = "";
@@ -716,10 +716,10 @@  discard block
 block discarded – undo
716 716
 	while ($maxiter-- and $parents = sql_allfetsel(
717 717
 			'id_parent',
718 718
 			'spip_rubriques',
719
-			sql_in('id_rubrique', $ids_nouveaux_parents) . " AND " . sql_in('id_parent', $hier, 'NOT')
719
+			sql_in('id_rubrique', $ids_nouveaux_parents)." AND ".sql_in('id_parent', $hier, 'NOT')
720 720
 		)) {
721 721
 		$ids_nouveaux_parents = join(',', array_column($parents, 'id_parent'));
722
-		$hier = $ids_nouveaux_parents . (strlen($hier) ? ',' . $hier : '');
722
+		$hier = $ids_nouveaux_parents.(strlen($hier) ? ','.$hier : '');
723 723
 	}
724 724
 
725 725
 	# securite pour ne pas plomber la conso memoire sur les sites prolifiques
@@ -751,7 +751,7 @@  discard block
 block discarded – undo
751 751
 	include_spip('base/abstract_sql');
752 752
 	if ($check) {
753 753
 		$postdates = ($GLOBALS['meta']["post_dates"] == "non") ?
754
-			"AND A.date <= " . sql_quote(date('Y-m-d H:i:s')) : '';
754
+			"AND A.date <= ".sql_quote(date('Y-m-d H:i:s')) : '';
755 755
 
756 756
 		$r = sql_select("DISTINCT A.id_rubrique AS id",
757 757
 			"spip_articles AS A LEFT JOIN spip_rubriques AS R ON A.id_rubrique=R.id_rubrique",
@@ -763,7 +763,7 @@  discard block
 block discarded – undo
763 763
 		pipeline('trig_calculer_prochain_postdate', '');
764 764
 	}
765 765
 
766
-	$t = sql_fetsel("date", "spip_articles", "statut='publie' AND date > " . sql_quote(date('Y-m-d H:i:s')), "", "date",
766
+	$t = sql_fetsel("date", "spip_articles", "statut='publie' AND date > ".sql_quote(date('Y-m-d H:i:s')), "", "date",
767 767
 		"1");
768 768
 
769 769
 	if ($t) {
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
 		// retablir les </multi> et autres balises fermantes html
814 814
 		$titre = preg_replace(",<@([a-z][^>]*)>,ims", "</\\1>", $titre);
815 815
 		$r = sql_getfetsel("id_rubrique", "spip_rubriques",
816
-			"titre = " . sql_quote($titre) . " AND id_parent=" . intval($id_parent),
816
+			"titre = ".sql_quote($titre)." AND id_parent=".intval($id_parent),
817 817
 			$groupby = array(), $orderby = array(), $limit = '', $having = array(), $serveur);
818 818
 		if ($r !== null) {
819 819
 			$id_parent = $r;
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
 			}
835 835
 
836 836
 			sql_updateq('spip_rubriques', array('id_secteur' => $id_secteur, "lang" => $lang),
837
-				"id_rubrique=" . intval($id_rubrique), $desc = '', $serveur);
837
+				"id_rubrique=".intval($id_rubrique), $desc = '', $serveur);
838 838
 
839 839
 			// pour la recursion
840 840
 			$id_parent = $id_rubrique;
Please login to merge, or discard this patch.
ecrire/inc/texte.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 /**
32 32
  * Raccourcis dépendant du sens de la langue
33 33
  *
34
- * @return array Tablea ('','')
34
+ * @return string[] Tablea ('','')
35 35
  */
36 36
 function definir_raccourcis_alineas() {
37 37
 	return array('', '');
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
  * Ne fait rien ici. Voir plugin Textwheel
355 355
  *
356 356
  * @param string $letexte
357
- * @param null $forcer
357
+ * @param boolean|null $forcer
358 358
  * @return string
359 359
  */
360 360
 function paragrapher($letexte, $forcer = true) {
Please login to merge, or discard this patch.
Indentation   +220 added lines, -220 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 include_spip('inc/texte_mini');
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
  * @return array Tablea ('','')
35 35
  */
36 36
 function definir_raccourcis_alineas() {
37
-	return array('', '');
37
+    return array('', '');
38 38
 }
39 39
 
40 40
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
  * @return string
48 48
  */
49 49
 function traiter_tableau($bloc) {
50
-	return $bloc;
50
+    return $bloc;
51 51
 }
52 52
 
53 53
 
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
  * @return string
62 62
  */
63 63
 function traiter_listes($texte) {
64
-	return $texte;
64
+    return $texte;
65 65
 }
66 66
 
67 67
 /**
@@ -77,16 +77,16 @@  discard block
 block discarded – undo
77 77
  */
78 78
 function traiter_raccourcis($letexte) {
79 79
 
80
-	// Appeler les fonctions de pre_traitement
81
-	$letexte = pipeline('pre_propre', $letexte);
80
+    // Appeler les fonctions de pre_traitement
81
+    $letexte = pipeline('pre_propre', $letexte);
82 82
 
83
-	// APPELER ICI UN PIPELINE traiter_raccourcis ?
84
-	// $letexte = pipeline('traiter_raccourcis', $letexte);
83
+    // APPELER ICI UN PIPELINE traiter_raccourcis ?
84
+    // $letexte = pipeline('traiter_raccourcis', $letexte);
85 85
 
86
-	// Appeler les fonctions de post-traitement
87
-	$letexte = pipeline('post_propre', $letexte);
86
+    // Appeler les fonctions de post-traitement
87
+    $letexte = pipeline('post_propre', $letexte);
88 88
 
89
-	return $letexte;
89
+    return $letexte;
90 90
 }
91 91
 
92 92
 /*************************************************************************************************************************
@@ -102,19 +102,19 @@  discard block
 block discarded – undo
102 102
  * @return string
103 103
  */
104 104
 function echappe_js($t, $class = ' class = "echappe-js"') {
105
-	foreach (array('script', 'iframe') as $tag) {
106
-		if (stripos($t, "<$tag") !== false
107
-			and preg_match_all(',<' . $tag . '.*?($|</' . $tag . '.),isS', $t, $r, PREG_SET_ORDER)
108
-		) {
109
-			foreach ($r as $regs) {
110
-				$t = str_replace($regs[0],
111
-					"<code$class>" . nl2br(spip_htmlspecialchars($regs[0])) . '</code>',
112
-					$t);
113
-			}
114
-		}
115
-	}
116
-
117
-	return $t;
105
+    foreach (array('script', 'iframe') as $tag) {
106
+        if (stripos($t, "<$tag") !== false
107
+            and preg_match_all(',<' . $tag . '.*?($|</' . $tag . '.),isS', $t, $r, PREG_SET_ORDER)
108
+        ) {
109
+            foreach ($r as $regs) {
110
+                $t = str_replace($regs[0],
111
+                    "<code$class>" . nl2br(spip_htmlspecialchars($regs[0])) . '</code>',
112
+                    $t);
113
+            }
114
+        }
115
+    }
116
+
117
+    return $t;
118 118
 }
119 119
 
120 120
 
@@ -143,55 +143,55 @@  discard block
 block discarded – undo
143 143
  *     Code protégé
144 144
  **/
145 145
 function interdire_scripts($arg, $mode_filtre=null) {
146
-	// on memorise le resultat sur les arguments non triviaux
147
-	static $dejavu = array();
148
-
149
-	// Attention, si ce n'est pas une chaine, laisser intact
150
-	if (!$arg or !is_string($arg) or !strstr($arg, '<')) {
151
-		return $arg;
152
-	}
153
-
154
-	if (is_null($mode_filtre) or !in_array($mode_filtre, array(-1, 0, 1))) {
155
-		$mode_filtre = $GLOBALS['filtrer_javascript'];
156
-	}
157
-
158
-	if (isset($dejavu[$mode_filtre][$arg])) {
159
-		return $dejavu[$mode_filtre][$arg];
160
-	}
161
-
162
-	// echapper les tags asp/php
163
-	$t = str_replace('<' . '%', '&lt;%', $arg);
164
-
165
-	// echapper le php
166
-	$t = str_replace('<' . '?', '&lt;?', $t);
167
-
168
-	// echapper le < script language=php >
169
-	$t = preg_replace(',<(script\b[^>]+\blanguage\b[^\w>]+php\b),UimsS', '&lt;\1', $t);
170
-
171
-	// Pour le js, trois modes : parano (-1), prive (0), ok (1)
172
-	switch ($mode_filtre) {
173
-		case 0:
174
-			if (!_DIR_RESTREINT) {
175
-				$t = echappe_js($t);
176
-			}
177
-			break;
178
-		case -1:
179
-			$t = echappe_js($t);
180
-			break;
181
-	}
182
-
183
-	// pas de <base href /> svp !
184
-	$t = preg_replace(',<(base\b),iS', '&lt;\1', $t);
185
-
186
-	// Reinserer les echappements des modeles
187
-	if (defined('_PROTEGE_JS_MODELES')) {
188
-		$t = echappe_retour($t, "javascript" . _PROTEGE_JS_MODELES);
189
-	}
190
-	if (defined('_PROTEGE_PHP_MODELES')) {
191
-		$t = echappe_retour($t, "php" . _PROTEGE_PHP_MODELES);
192
-	}
193
-
194
-	return $dejavu[$mode_filtre][$arg] = $t;
146
+    // on memorise le resultat sur les arguments non triviaux
147
+    static $dejavu = array();
148
+
149
+    // Attention, si ce n'est pas une chaine, laisser intact
150
+    if (!$arg or !is_string($arg) or !strstr($arg, '<')) {
151
+        return $arg;
152
+    }
153
+
154
+    if (is_null($mode_filtre) or !in_array($mode_filtre, array(-1, 0, 1))) {
155
+        $mode_filtre = $GLOBALS['filtrer_javascript'];
156
+    }
157
+
158
+    if (isset($dejavu[$mode_filtre][$arg])) {
159
+        return $dejavu[$mode_filtre][$arg];
160
+    }
161
+
162
+    // echapper les tags asp/php
163
+    $t = str_replace('<' . '%', '&lt;%', $arg);
164
+
165
+    // echapper le php
166
+    $t = str_replace('<' . '?', '&lt;?', $t);
167
+
168
+    // echapper le < script language=php >
169
+    $t = preg_replace(',<(script\b[^>]+\blanguage\b[^\w>]+php\b),UimsS', '&lt;\1', $t);
170
+
171
+    // Pour le js, trois modes : parano (-1), prive (0), ok (1)
172
+    switch ($mode_filtre) {
173
+        case 0:
174
+            if (!_DIR_RESTREINT) {
175
+                $t = echappe_js($t);
176
+            }
177
+            break;
178
+        case -1:
179
+            $t = echappe_js($t);
180
+            break;
181
+    }
182
+
183
+    // pas de <base href /> svp !
184
+    $t = preg_replace(',<(base\b),iS', '&lt;\1', $t);
185
+
186
+    // Reinserer les echappements des modeles
187
+    if (defined('_PROTEGE_JS_MODELES')) {
188
+        $t = echappe_retour($t, "javascript" . _PROTEGE_JS_MODELES);
189
+    }
190
+    if (defined('_PROTEGE_PHP_MODELES')) {
191
+        $t = echappe_retour($t, "php" . _PROTEGE_PHP_MODELES);
192
+    }
193
+
194
+    return $dejavu[$mode_filtre][$arg] = $t;
195 195
 }
196 196
 
197 197
 
@@ -220,64 +220,64 @@  discard block
 block discarded – undo
220 220
  *     Texte transformé
221 221
  **/
222 222
 function typo($letexte, $echapper = true, $connect = null, $env = array()) {
223
-	// Plus vite !
224
-	if (!$letexte) {
225
-		return $letexte;
226
-	}
227
-
228
-	// les appels directs a cette fonction depuis le php de l'espace
229
-	// prive etant historiquement ecrit sans argment $connect
230
-	// on utilise la presence de celui-ci pour distinguer les cas
231
-	// ou il faut passer interdire_script explicitement
232
-	// les appels dans les squelettes (de l'espace prive) fournissant un $connect
233
-	// ne seront pas perturbes
234
-	$interdire_script = false;
235
-	if (is_null($connect)) {
236
-		$connect = '';
237
-		$interdire_script = true;
238
-		$env['espace_prive'] = test_espace_prive();
239
-	}
240
-
241
-	// Echapper les codes <html> etc
242
-	if ($echapper) {
243
-		$letexte = echappe_html($letexte, 'TYPO');
244
-	}
245
-
246
-	//
247
-	// Installer les modeles, notamment images et documents ;
248
-	//
249
-	// NOTE : propre() ne passe pas par ici mais directement par corriger_typo
250
-	// cf. inc/lien
251
-
252
-	$letexte = traiter_modeles($mem = $letexte, false, $echapper ? 'TYPO' : '', $connect, null, $env);
253
-	if ($letexte != $mem) {
254
-		$echapper = true;
255
-	}
256
-	unset($mem);
257
-
258
-	$letexte = corriger_typo($letexte);
259
-	$letexte = echapper_faux_tags($letexte);
260
-
261
-	// reintegrer les echappements
262
-	if ($echapper) {
263
-		$letexte = echappe_retour($letexte, 'TYPO');
264
-	}
265
-
266
-	// Dans les appels directs hors squelette, securiser ici aussi
267
-	if ($interdire_script) {
268
-		$letexte = interdire_scripts($letexte);
269
-	}
270
-
271
-	// Dans l'espace prive on se mefie de tout contenu dangereux
272
-	// https://core.spip.net/issues/3371
273
-	// et aussi dans l'espace public si la globale filtrer_javascript = -1
274
-	// https://core.spip.net/issues/4166
275
-	if ($GLOBALS['filtrer_javascript'] == -1
276
-	  or (isset($env['espace_prive']) and $env['espace_prive'] and $GLOBALS['filtrer_javascript']<=0)) {
277
-		$letexte = echapper_html_suspect($letexte);
278
-	}
279
-
280
-	return $letexte;
223
+    // Plus vite !
224
+    if (!$letexte) {
225
+        return $letexte;
226
+    }
227
+
228
+    // les appels directs a cette fonction depuis le php de l'espace
229
+    // prive etant historiquement ecrit sans argment $connect
230
+    // on utilise la presence de celui-ci pour distinguer les cas
231
+    // ou il faut passer interdire_script explicitement
232
+    // les appels dans les squelettes (de l'espace prive) fournissant un $connect
233
+    // ne seront pas perturbes
234
+    $interdire_script = false;
235
+    if (is_null($connect)) {
236
+        $connect = '';
237
+        $interdire_script = true;
238
+        $env['espace_prive'] = test_espace_prive();
239
+    }
240
+
241
+    // Echapper les codes <html> etc
242
+    if ($echapper) {
243
+        $letexte = echappe_html($letexte, 'TYPO');
244
+    }
245
+
246
+    //
247
+    // Installer les modeles, notamment images et documents ;
248
+    //
249
+    // NOTE : propre() ne passe pas par ici mais directement par corriger_typo
250
+    // cf. inc/lien
251
+
252
+    $letexte = traiter_modeles($mem = $letexte, false, $echapper ? 'TYPO' : '', $connect, null, $env);
253
+    if ($letexte != $mem) {
254
+        $echapper = true;
255
+    }
256
+    unset($mem);
257
+
258
+    $letexte = corriger_typo($letexte);
259
+    $letexte = echapper_faux_tags($letexte);
260
+
261
+    // reintegrer les echappements
262
+    if ($echapper) {
263
+        $letexte = echappe_retour($letexte, 'TYPO');
264
+    }
265
+
266
+    // Dans les appels directs hors squelette, securiser ici aussi
267
+    if ($interdire_script) {
268
+        $letexte = interdire_scripts($letexte);
269
+    }
270
+
271
+    // Dans l'espace prive on se mefie de tout contenu dangereux
272
+    // https://core.spip.net/issues/3371
273
+    // et aussi dans l'espace public si la globale filtrer_javascript = -1
274
+    // https://core.spip.net/issues/4166
275
+    if ($GLOBALS['filtrer_javascript'] == -1
276
+      or (isset($env['espace_prive']) and $env['espace_prive'] and $GLOBALS['filtrer_javascript']<=0)) {
277
+        $letexte = echapper_html_suspect($letexte);
278
+    }
279
+
280
+    return $letexte;
281 281
 }
282 282
 
283 283
 // Correcteur typographique
@@ -302,57 +302,57 @@  discard block
 block discarded – undo
302 302
  */
303 303
 function corriger_typo($letexte, $lang = '') {
304 304
 
305
-	// Plus vite !
306
-	if (!$letexte) {
307
-		return $letexte;
308
-	}
309
-
310
-	$letexte = pipeline('pre_typo', $letexte);
311
-
312
-	// Caracteres de controle "illegaux"
313
-	$letexte = corriger_caracteres($letexte);
314
-
315
-	// Proteger les caracteres typographiques a l'interieur des tags html
316
-	if (preg_match_all(_TYPO_BALISE, $letexte, $regs, PREG_SET_ORDER)) {
317
-		foreach ($regs as $reg) {
318
-			$insert = $reg[0];
319
-			// hack: on transforme les caracteres a proteger en les remplacant
320
-			// par des caracteres "illegaux". (cf corriger_caracteres())
321
-			$insert = strtr($insert, _TYPO_PROTEGER, _TYPO_PROTECTEUR);
322
-			$letexte = str_replace($reg[0], $insert, $letexte);
323
-		}
324
-	}
325
-
326
-	// trouver les blocs idiomes et les traiter à part
327
-	$letexte = extraire_idiome($ei = $letexte, $lang, true);
328
-	$ei = ($ei !== $letexte);
329
-
330
-	// trouver les blocs multi et les traiter a part
331
-	$letexte = extraire_multi($em = $letexte, $lang, true);
332
-	$em = ($em !== $letexte);
333
-
334
-	// Charger & appliquer les fonctions de typographie
335
-	$typographie = charger_fonction(lang_typo($lang), 'typographie');
336
-	$letexte = $typographie($letexte);
337
-
338
-	// Les citations en une autre langue, s'il y a lieu
339
-	if ($em) {
340
-		$letexte = echappe_retour($letexte, 'multi');
341
-	}
342
-	if ($ei) {
343
-		$letexte = echappe_retour($letexte, 'idiome');
344
-	}
345
-
346
-	// Retablir les caracteres proteges
347
-	$letexte = strtr($letexte, _TYPO_PROTECTEUR, _TYPO_PROTEGER);
348
-
349
-	// pipeline
350
-	$letexte = pipeline('post_typo', $letexte);
351
-
352
-	# un message pour abs_url - on est passe en mode texte
353
-	$GLOBALS['mode_abs_url'] = 'texte';
354
-
355
-	return $letexte;
305
+    // Plus vite !
306
+    if (!$letexte) {
307
+        return $letexte;
308
+    }
309
+
310
+    $letexte = pipeline('pre_typo', $letexte);
311
+
312
+    // Caracteres de controle "illegaux"
313
+    $letexte = corriger_caracteres($letexte);
314
+
315
+    // Proteger les caracteres typographiques a l'interieur des tags html
316
+    if (preg_match_all(_TYPO_BALISE, $letexte, $regs, PREG_SET_ORDER)) {
317
+        foreach ($regs as $reg) {
318
+            $insert = $reg[0];
319
+            // hack: on transforme les caracteres a proteger en les remplacant
320
+            // par des caracteres "illegaux". (cf corriger_caracteres())
321
+            $insert = strtr($insert, _TYPO_PROTEGER, _TYPO_PROTECTEUR);
322
+            $letexte = str_replace($reg[0], $insert, $letexte);
323
+        }
324
+    }
325
+
326
+    // trouver les blocs idiomes et les traiter à part
327
+    $letexte = extraire_idiome($ei = $letexte, $lang, true);
328
+    $ei = ($ei !== $letexte);
329
+
330
+    // trouver les blocs multi et les traiter a part
331
+    $letexte = extraire_multi($em = $letexte, $lang, true);
332
+    $em = ($em !== $letexte);
333
+
334
+    // Charger & appliquer les fonctions de typographie
335
+    $typographie = charger_fonction(lang_typo($lang), 'typographie');
336
+    $letexte = $typographie($letexte);
337
+
338
+    // Les citations en une autre langue, s'il y a lieu
339
+    if ($em) {
340
+        $letexte = echappe_retour($letexte, 'multi');
341
+    }
342
+    if ($ei) {
343
+        $letexte = echappe_retour($letexte, 'idiome');
344
+    }
345
+
346
+    // Retablir les caracteres proteges
347
+    $letexte = strtr($letexte, _TYPO_PROTECTEUR, _TYPO_PROTEGER);
348
+
349
+    // pipeline
350
+    $letexte = pipeline('post_typo', $letexte);
351
+
352
+    # un message pour abs_url - on est passe en mode texte
353
+    $GLOBALS['mode_abs_url'] = 'texte';
354
+
355
+    return $letexte;
356 356
 }
357 357
 
358 358
 
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
  * @return string
369 369
  */
370 370
 function paragrapher($letexte, $forcer = true) {
371
-	return $letexte;
371
+    return $letexte;
372 372
 }
373 373
 
374 374
 /**
@@ -380,11 +380,11 @@  discard block
 block discarded – undo
380 380
  * @return string Texte
381 381
  **/
382 382
 function traiter_retours_chariots($letexte) {
383
-	$letexte = preg_replace(",\r\n?,S", "\n", $letexte);
384
-	$letexte = preg_replace(",<p[>[:space:]],iS", "\n\n\\0", $letexte);
385
-	$letexte = preg_replace(",</p[>[:space:]],iS", "\\0\n\n", $letexte);
383
+    $letexte = preg_replace(",\r\n?,S", "\n", $letexte);
384
+    $letexte = preg_replace(",<p[>[:space:]],iS", "\n\n\\0", $letexte);
385
+    $letexte = preg_replace(",</p[>[:space:]],iS", "\\0\n\n", $letexte);
386 386
 
387
-	return $letexte;
387
+    return $letexte;
388 388
 }
389 389
 
390 390
 
@@ -410,37 +410,37 @@  discard block
 block discarded – undo
410 410
  *     Texte transformé
411 411
  **/
412 412
 function propre($t, $connect = null, $env = array()) {
413
-	// les appels directs a cette fonction depuis le php de l'espace
414
-	// prive etant historiquement ecrits sans argment $connect
415
-	// on utilise la presence de celui-ci pour distinguer les cas
416
-	// ou il faut passer interdire_script explicitement
417
-	// les appels dans les squelettes (de l'espace prive) fournissant un $connect
418
-	// ne seront pas perturbes
419
-	$interdire_script = false;
420
-	if (is_null($connect)) {
421
-		$connect = '';
422
-		$interdire_script = true;
423
-	}
424
-
425
-	if (!$t) {
426
-		return strval($t);
427
-	}
428
-
429
-	// Dans l'espace prive on se mefie de tout contenu dangereux
430
-	// avant echappement des balises <html>
431
-	// https://core.spip.net/issues/3371
432
-	// et aussi dans l'espace public si la globale filtrer_javascript = -1
433
-	// https://core.spip.net/issues/4166
434
-	if ($interdire_script
435
-		or $GLOBALS['filtrer_javascript'] == -1
436
-		or (isset($env['espace_prive']) and $env['espace_prive'] and $GLOBALS['filtrer_javascript']<=0)
437
-		or (isset($env['wysiwyg']) and $env['wysiwyg'] and $GLOBALS['filtrer_javascript']<=0)) {
438
-		$t = echapper_html_suspect($t, false);
439
-	}
440
-	$t = echappe_html($t);
441
-	$t = expanser_liens($t, $connect, $env);
442
-	$t = traiter_raccourcis($t);
443
-	$t = echappe_retour_modeles($t, $interdire_script);
444
-
445
-	return $t;
413
+    // les appels directs a cette fonction depuis le php de l'espace
414
+    // prive etant historiquement ecrits sans argment $connect
415
+    // on utilise la presence de celui-ci pour distinguer les cas
416
+    // ou il faut passer interdire_script explicitement
417
+    // les appels dans les squelettes (de l'espace prive) fournissant un $connect
418
+    // ne seront pas perturbes
419
+    $interdire_script = false;
420
+    if (is_null($connect)) {
421
+        $connect = '';
422
+        $interdire_script = true;
423
+    }
424
+
425
+    if (!$t) {
426
+        return strval($t);
427
+    }
428
+
429
+    // Dans l'espace prive on se mefie de tout contenu dangereux
430
+    // avant echappement des balises <html>
431
+    // https://core.spip.net/issues/3371
432
+    // et aussi dans l'espace public si la globale filtrer_javascript = -1
433
+    // https://core.spip.net/issues/4166
434
+    if ($interdire_script
435
+        or $GLOBALS['filtrer_javascript'] == -1
436
+        or (isset($env['espace_prive']) and $env['espace_prive'] and $GLOBALS['filtrer_javascript']<=0)
437
+        or (isset($env['wysiwyg']) and $env['wysiwyg'] and $GLOBALS['filtrer_javascript']<=0)) {
438
+        $t = echapper_html_suspect($t, false);
439
+    }
440
+    $t = echappe_html($t);
441
+    $t = expanser_liens($t, $connect, $env);
442
+    $t = traiter_raccourcis($t);
443
+    $t = echappe_retour_modeles($t, $interdire_script);
444
+
445
+    return $t;
446 446
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -104,11 +104,11 @@  discard block
 block discarded – undo
104 104
 function echappe_js($t, $class = ' class = "echappe-js"') {
105 105
 	foreach (array('script', 'iframe') as $tag) {
106 106
 		if (stripos($t, "<$tag") !== false
107
-			and preg_match_all(',<' . $tag . '.*?($|</' . $tag . '.),isS', $t, $r, PREG_SET_ORDER)
107
+			and preg_match_all(',<'.$tag.'.*?($|</'.$tag.'.),isS', $t, $r, PREG_SET_ORDER)
108 108
 		) {
109 109
 			foreach ($r as $regs) {
110 110
 				$t = str_replace($regs[0],
111
-					"<code$class>" . nl2br(spip_htmlspecialchars($regs[0])) . '</code>',
111
+					"<code$class>".nl2br(spip_htmlspecialchars($regs[0])).'</code>',
112 112
 					$t);
113 113
 			}
114 114
 		}
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
  * @return string
143 143
  *     Code protégé
144 144
  **/
145
-function interdire_scripts($arg, $mode_filtre=null) {
145
+function interdire_scripts($arg, $mode_filtre = null) {
146 146
 	// on memorise le resultat sur les arguments non triviaux
147 147
 	static $dejavu = array();
148 148
 
@@ -160,10 +160,10 @@  discard block
 block discarded – undo
160 160
 	}
161 161
 
162 162
 	// echapper les tags asp/php
163
-	$t = str_replace('<' . '%', '&lt;%', $arg);
163
+	$t = str_replace('<'.'%', '&lt;%', $arg);
164 164
 
165 165
 	// echapper le php
166
-	$t = str_replace('<' . '?', '&lt;?', $t);
166
+	$t = str_replace('<'.'?', '&lt;?', $t);
167 167
 
168 168
 	// echapper le < script language=php >
169 169
 	$t = preg_replace(',<(script\b[^>]+\blanguage\b[^\w>]+php\b),UimsS', '&lt;\1', $t);
@@ -185,10 +185,10 @@  discard block
 block discarded – undo
185 185
 
186 186
 	// Reinserer les echappements des modeles
187 187
 	if (defined('_PROTEGE_JS_MODELES')) {
188
-		$t = echappe_retour($t, "javascript" . _PROTEGE_JS_MODELES);
188
+		$t = echappe_retour($t, "javascript"._PROTEGE_JS_MODELES);
189 189
 	}
190 190
 	if (defined('_PROTEGE_PHP_MODELES')) {
191
-		$t = echappe_retour($t, "php" . _PROTEGE_PHP_MODELES);
191
+		$t = echappe_retour($t, "php"._PROTEGE_PHP_MODELES);
192 192
 	}
193 193
 
194 194
 	return $dejavu[$mode_filtre][$arg] = $t;
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 	// et aussi dans l'espace public si la globale filtrer_javascript = -1
274 274
 	// https://core.spip.net/issues/4166
275 275
 	if ($GLOBALS['filtrer_javascript'] == -1
276
-	  or (isset($env['espace_prive']) and $env['espace_prive'] and $GLOBALS['filtrer_javascript']<=0)) {
276
+	  or (isset($env['espace_prive']) and $env['espace_prive'] and $GLOBALS['filtrer_javascript'] <= 0)) {
277 277
 		$letexte = echapper_html_suspect($letexte);
278 278
 	}
279 279
 
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 define('_TYPO_PROTEGER', "!':;?~%-");
285 285
 define('_TYPO_PROTECTEUR', "\x1\x2\x3\x4\x5\x6\x7\x8");
286 286
 
287
-define('_TYPO_BALISE', ",</?[a-z!][^<>]*[" . preg_quote(_TYPO_PROTEGER) . "][^<>]*>,imsS");
287
+define('_TYPO_BALISE', ",</?[a-z!][^<>]*[".preg_quote(_TYPO_PROTEGER)."][^<>]*>,imsS");
288 288
 
289 289
 /**
290 290
  * Corrige la typographie
@@ -433,8 +433,8 @@  discard block
 block discarded – undo
433 433
 	// https://core.spip.net/issues/4166
434 434
 	if ($interdire_script
435 435
 		or $GLOBALS['filtrer_javascript'] == -1
436
-		or (isset($env['espace_prive']) and $env['espace_prive'] and $GLOBALS['filtrer_javascript']<=0)
437
-		or (isset($env['wysiwyg']) and $env['wysiwyg'] and $GLOBALS['filtrer_javascript']<=0)) {
436
+		or (isset($env['espace_prive']) and $env['espace_prive'] and $GLOBALS['filtrer_javascript'] <= 0)
437
+		or (isset($env['wysiwyg']) and $env['wysiwyg'] and $GLOBALS['filtrer_javascript'] <= 0)) {
438 438
 		$t = echapper_html_suspect($t, false);
439 439
 	}
440 440
 	$t = echappe_html($t);
Please login to merge, or discard this patch.