Completed
Push — master ( 978178...476e4b )
by cam
04:34
created
ecrire/inc/texte_mini.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	// celle du texte) et public (spip_lang est la langue du texte)
45 45
 	$dir = _DIR_RESTREINT ? lang_dir() : lang_dir($GLOBALS['spip_lang']);
46 46
 
47
-	$p = 'puce' . (test_espace_prive() ? '_prive' : '');
47
+	$p = 'puce'.(test_espace_prive() ? '_prive' : '');
48 48
 	if ($dir == 'rtl') {
49 49
 		$p .= '_rtl';
50 50
 	}
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 }
68 68
 
69 69
 if (!defined('_BALISES_BLOCS_REGEXP')) {
70
-	define('_BALISES_BLOCS_REGEXP', ',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS');
70
+	define('_BALISES_BLOCS_REGEXP', ',</?('._BALISES_BLOCS.')[>[:space:]],iS');
71 71
 }
72 72
 
73 73
 //
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 
86 86
 	// Tester si on echappe en span ou en div
87 87
 	if (is_null($mode) or !in_array($mode, array('div', 'span'))) {
88
-		$mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $rempl) ? 'div' : 'span';
88
+		$mode = preg_match(',</?('._BALISES_BLOCS.')[>[:space:]],iS', $rempl) ? 'div' : 'span';
89 89
 	}
90 90
 
91 91
 	// Decouper en morceaux, base64 a des probleme selon la taille de la pile
@@ -117,11 +117,11 @@  discard block
 block discarded – undo
117 117
 	// echapper les < dans <code>
118 118
 	// on utilise _PROTEGE_BLOCS pour simplifier le code et la maintenance, mais on est interesse que par <code>
119 119
 	if (strpos($pre, "<") !== false
120
-		and preg_match_all(_PROTEGE_BLOCS, $pre, $matches, PREG_SET_ORDER)){
120
+		and preg_match_all(_PROTEGE_BLOCS, $pre, $matches, PREG_SET_ORDER)) {
121 121
 
122
-		foreach ($matches as $m){
123
-			if ($m[1]==='code'){
124
-				$code = "<code" . $m[2] . ">" . spip_htmlspecialchars($m[3]) . "</code>";
122
+		foreach ($matches as $m) {
123
+			if ($m[1] === 'code') {
124
+				$code = "<code".$m[2].">".spip_htmlspecialchars($m[3])."</code>";
125 125
 				$pre = str_replace($m[0], $code, $pre);
126 126
 			}
127 127
 		}
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 // Echapper les <code>...</ code>
133 133
 // https://code.spip.net/@traiter_echap_code_dist
134 134
 function traiter_echap_code_dist($regs) {
135
-	list(, , $att, $corps) = $regs;
135
+	list(,, $att, $corps) = $regs;
136 136
 	$echap = spip_htmlspecialchars($corps); // il ne faut pas passer dans entites_html, ne pas transformer les &#xxx; du code !
137 137
 
138 138
 	// ne pas mettre le <div...> s'il n'y a qu'une ligne
@@ -143,9 +143,9 @@  discard block
 block discarded – undo
143 143
 		$echap = nl2br($echap);
144 144
 		$echap = "<div style='text-align: left;' "
145 145
 			. "class='spip_code' dir='ltr'><code$att>"
146
-			. $echap . "</code></div>";
146
+			. $echap."</code></div>";
147 147
 	} else {
148
-		$echap = "<code$att class='spip_code' dir='ltr'>" . $echap . "</code>";
148
+		$echap = "<code$att class='spip_code' dir='ltr'>".$echap."</code>";
149 149
 	}
150 150
 
151 151
 	$echap = str_replace("\t", "&nbsp; &nbsp; &nbsp; &nbsp; ", $echap);
@@ -222,10 +222,10 @@  discard block
 block discarded – undo
222 222
 				$echap = $regs[0];
223 223
 			} // sinon les traiter selon le cas
224 224
 			else {
225
-				if (function_exists($f = 'traiter_echap_' . strtolower($regs[1]))) {
225
+				if (function_exists($f = 'traiter_echap_'.strtolower($regs[1]))) {
226 226
 					$echap = $f($regs);
227 227
 				} else {
228
-					if (function_exists($f = $f . '_dist')) {
228
+					if (function_exists($f = $f.'_dist')) {
229 229
 						$echap = $f($regs);
230 230
 					}
231 231
 				}
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 	// (derogatoire car on ne peut pas faire passer < ? ... ? >
246 246
 	// dans une callback autonommee
247 247
 	if (strpos($preg ? $preg : _PROTEGE_BLOCS, 'script') !== false) {
248
-		if (strpos($letexte, "<" . "?") !== false and preg_match_all(',<[?].*($|[?]>),UisS',
248
+		if (strpos($letexte, "<"."?") !== false and preg_match_all(',<[?].*($|[?]>),UisS',
249 249
 				$letexte, $matches, PREG_SET_ORDER)
250 250
 		) {
251 251
 			foreach ($matches as $regs) {
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 		$max_prof = 5;
271 271
 		while (strpos($letexte, "<") !== false
272 272
 			and
273
-			preg_match_all(',<(span|div)\sclass=[\'"]base64' . $source . '[\'"]\s(.*)>\s*</\1>,UmsS',
273
+			preg_match_all(',<(span|div)\sclass=[\'"]base64'.$source.'[\'"]\s(.*)>\s*</\1>,UmsS',
274 274
 				$letexte, $regs, PREG_SET_ORDER)
275 275
 			and $max_prof--) {
276 276
 			foreach ($regs as $reg) {
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 					}
284 284
 				}
285 285
 				if ($at) {
286
-					$rempl = '<' . $reg[1] . '>' . $rempl . '</' . $reg[1] . '>';
286
+					$rempl = '<'.$reg[1].'>'.$rempl.'</'.$reg[1].'>';
287 287
 					foreach ($at as $attr => $a) {
288 288
 						$rempl = inserer_attribut($rempl, $attr, $a);
289 289
 					}
@@ -362,8 +362,8 @@  discard block
 block discarded – undo
362 362
 	$texte = nettoyer_raccourcis_typo($texte);
363 363
 
364 364
 	// balises de sauts de ligne et paragraphe
365
-	$texte = preg_replace("/<p( [^>]*)?" . ">/", "\r", $texte);
366
-	$texte = preg_replace("/<br( [^>]*)?" . ">/", "\n", $texte);
365
+	$texte = preg_replace("/<p( [^>]*)?".">/", "\r", $texte);
366
+	$texte = preg_replace("/<br( [^>]*)?".">/", "\n", $texte);
367 367
 
368 368
 	// on repasse les doubles \n en \r que nettoyer_raccourcis_typo() a pu modifier
369 369
 	$texte = str_replace("\n\n", "\r", $texte);
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 	// supprimer les tags
372 372
 	$texte = supprimer_tags($texte);
373 373
 	$texte = trim(str_replace("\n", " ", $texte));
374
-	$texte .= "\n";  // marquer la fin
374
+	$texte .= "\n"; // marquer la fin
375 375
 
376 376
 	// corriger la longueur de coupe
377 377
 	// en fonction de la presence de caracteres utf
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 	// couper au mot precedent
387 387
 	$long = spip_substr($texte, 0, max($taille - 4, 1));
388 388
 	$u = $GLOBALS['meta']['pcre_u'];
389
-	$court = preg_replace("/([^\s][\s]+)[^\s]*\n?$/" . $u, "\\1", $long);
389
+	$court = preg_replace("/([^\s][\s]+)[^\s]*\n?$/".$u, "\\1", $long);
390 390
 	if (is_null($suite)) {
391 391
 		$suite = (defined('_COUPER_SUITE') ? _COUPER_SUITE : '&nbsp;(...)');
392 392
 	}
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
 	if (spip_strlen($court) < max(0.75 * $taille, 2)) {
397 397
 		$points = '';
398 398
 		$long = spip_substr($texte, 0, $taille);
399
-		$texte = preg_replace("/([^\s][\s]+)[^\s]*\n?$/" . $u, "\\1", $long);
399
+		$texte = preg_replace("/([^\s][\s]+)[^\s]*\n?$/".$u, "\\1", $long);
400 400
 		// encore trop court ? couper au caractere
401 401
 		if (spip_strlen($texte) < 0.75 * $taille) {
402 402
 			$texte = $long;
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
 	// supprimer l'eventuelle entite finale mal coupee
417 417
 	$texte = preg_replace('/&#?[a-z0-9]*$/S', '', $texte);
418 418
 
419
-	return quote_amp(trim($texte)) . $points;
419
+	return quote_amp(trim($texte)).$points;
420 420
 }
421 421
 
422 422
 
@@ -429,16 +429,16 @@  discard block
 block discarded – undo
429 429
 				define('_PROTEGE_JS_MODELES', creer_uniqid());
430 430
 			}
431 431
 			foreach ($r as $regs) {
432
-				$t = str_replace($regs[0], code_echappement($regs[0], 'javascript' . _PROTEGE_JS_MODELES), $t);
432
+				$t = str_replace($regs[0], code_echappement($regs[0], 'javascript'._PROTEGE_JS_MODELES), $t);
433 433
 			}
434 434
 		}
435
-		if (preg_match_all(',<\?php.*?($|\?' . '>),isS', $t, $r, PREG_SET_ORDER)) {
435
+		if (preg_match_all(',<\?php.*?($|\?'.'>),isS', $t, $r, PREG_SET_ORDER)) {
436 436
 			if (!defined('_PROTEGE_PHP_MODELES')) {
437 437
 				include_spip('inc/acces');
438 438
 				define('_PROTEGE_PHP_MODELES', creer_uniqid());
439 439
 			}
440 440
 			foreach ($r as $regs) {
441
-				$t = str_replace($regs[0], code_echappement($regs[0], 'php' . _PROTEGE_PHP_MODELES), $t);
441
+				$t = str_replace($regs[0], code_echappement($regs[0], 'php'._PROTEGE_PHP_MODELES), $t);
442 442
 			}
443 443
 		}
444 444
 	}
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
  * @param bool $strict
474 474
  * @return string
475 475
  */
476
-function echapper_html_suspect($texte, $strict=true) {
476
+function echapper_html_suspect($texte, $strict = true) {
477 477
 	static $echapper_html_suspect;
478 478
 	if (!$texte or !is_string($texte)) {
479 479
 		return $texte;
@@ -495,8 +495,8 @@  discard block
 block discarded – undo
495 495
 	// quand c'est du texte qui passe par propre on est plus coulant tant qu'il y a pas d'attribut du type onxxx=
496 496
 	// car sinon on declenche sur les modeles ou ressources
497 497
 	if (!$strict and
498
-	  (strpos($texte,'on') === false or !preg_match(",<\w+.*\bon\w+\s*=,UimsS", $texte))
499
-	  ){
498
+	  (strpos($texte, 'on') === false or !preg_match(",<\w+.*\bon\w+\s*=,UimsS", $texte))
499
+	  ) {
500 500
 		return $texte;
501 501
 	}
502 502
 
@@ -575,9 +575,9 @@  discard block
 block discarded – undo
575 575
  **/
576 576
 function supprime_img($letexte, $message = null) {
577 577
 	if ($message === null) {
578
-		$message = '(' . _T('img_indisponible') . ')';
578
+		$message = '('._T('img_indisponible').')';
579 579
 	}
580 580
 
581
-	return preg_replace(',<(img|doc|emb)([0-9]+)(\|([^>]*))?' . '\s*/?' . '>,i',
581
+	return preg_replace(',<(img|doc|emb)([0-9]+)(\|([^>]*))?'.'\s*/?'.'>,i',
582 582
 		$message, $letexte);
583 583
 }
Please login to merge, or discard this patch.