Completed
Push — master ( 515cb3...63ef06 )
by cam
01:06
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);
@@ -234,8 +234,8 @@  discard block
 block discarded – undo
234 234
 				$echap = $regs[0];
235 235
 			} // sinon les traiter selon le cas
236 236
 			else {
237
-				if (function_exists($f = $callback_prefix . 'traiter_echap_' . strtolower($regs[1]))
238
-				  or function_exists($f = $f . '_dist')) {
237
+				if (function_exists($f = $callback_prefix.'traiter_echap_'.strtolower($regs[1]))
238
+				  or function_exists($f = $f.'_dist')) {
239 239
 					$echap = $f($regs);
240 240
 				}
241 241
 			}
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 	// (derogatoire car on ne peut pas faire passer < ? ... ? >
255 255
 	// dans une callback autonommee
256 256
 	if (strpos($preg ? $preg : _PROTEGE_BLOCS, 'script') !== false) {
257
-		if (strpos($letexte, "<" . "?") !== false and preg_match_all(',<[?].*($|[?]>),UisS',
257
+		if (strpos($letexte, "<"."?") !== false and preg_match_all(',<[?].*($|[?]>),UisS',
258 258
 				$letexte, $matches, PREG_SET_ORDER)
259 259
 		) {
260 260
 			foreach ($matches as $regs) {
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 		$max_prof = 5;
280 280
 		while (strpos($letexte, "<") !== false
281 281
 			and
282
-			preg_match_all(',<(span|div)\sclass=[\'"]base64' . $source . '[\'"]\s(.*)>\s*</\1>,UmsS',
282
+			preg_match_all(',<(span|div)\sclass=[\'"]base64'.$source.'[\'"]\s(.*)>\s*</\1>,UmsS',
283 283
 				$letexte, $regs, PREG_SET_ORDER)
284 284
 			and $max_prof--) {
285 285
 			foreach ($regs as $reg) {
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 					}
293 293
 				}
294 294
 				if ($at) {
295
-					$rempl = '<' . $reg[1] . '>' . $rempl . '</' . $reg[1] . '>';
295
+					$rempl = '<'.$reg[1].'>'.$rempl.'</'.$reg[1].'>';
296 296
 					foreach ($at as $attr => $a) {
297 297
 						$rempl = inserer_attribut($rempl, $attr, $a);
298 298
 					}
@@ -371,8 +371,8 @@  discard block
 block discarded – undo
371 371
 	$texte = nettoyer_raccourcis_typo($texte);
372 372
 
373 373
 	// balises de sauts de ligne et paragraphe
374
-	$texte = preg_replace("/<p( [^>]*)?" . ">/", "\r", $texte);
375
-	$texte = preg_replace("/<br( [^>]*)?" . ">/", "\n", $texte);
374
+	$texte = preg_replace("/<p( [^>]*)?".">/", "\r", $texte);
375
+	$texte = preg_replace("/<br( [^>]*)?".">/", "\n", $texte);
376 376
 
377 377
 	// on repasse les doubles \n en \r que nettoyer_raccourcis_typo() a pu modifier
378 378
 	$texte = str_replace("\n\n", "\r", $texte);
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
 	// supprimer les tags
381 381
 	$texte = supprimer_tags($texte);
382 382
 	$texte = trim(str_replace("\n", " ", $texte));
383
-	$texte .= "\n";  // marquer la fin
383
+	$texte .= "\n"; // marquer la fin
384 384
 
385 385
 	// corriger la longueur de coupe
386 386
 	// en fonction de la presence de caracteres utf
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 	// couper au mot precedent
396 396
 	$long = spip_substr($texte, 0, max($taille - 4, 1));
397 397
 	$u = $GLOBALS['meta']['pcre_u'];
398
-	$court = preg_replace("/([^\s][\s]+)[^\s]*\n?$/" . $u, "\\1", $long);
398
+	$court = preg_replace("/([^\s][\s]+)[^\s]*\n?$/".$u, "\\1", $long);
399 399
 	if (is_null($suite)) {
400 400
 		$suite = (defined('_COUPER_SUITE') ? _COUPER_SUITE : '&nbsp;(...)');
401 401
 	}
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
 	if (spip_strlen($court) < max(0.75 * $taille, 2)) {
406 406
 		$points = '';
407 407
 		$long = spip_substr($texte, 0, $taille);
408
-		$texte = preg_replace("/([^\s][\s]+)[^\s]*\n?$/" . $u, "\\1", $long);
408
+		$texte = preg_replace("/([^\s][\s]+)[^\s]*\n?$/".$u, "\\1", $long);
409 409
 		// encore trop court ? couper au caractere
410 410
 		if (spip_strlen($texte) < 0.75 * $taille) {
411 411
 			$texte = $long;
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
 	// supprimer l'eventuelle entite finale mal coupee
426 426
 	$texte = preg_replace('/&#?[a-z0-9]*$/S', '', $texte);
427 427
 
428
-	return quote_amp(trim($texte)) . $points;
428
+	return quote_amp(trim($texte)).$points;
429 429
 }
430 430
 
431 431
 
@@ -438,16 +438,16 @@  discard block
 block discarded – undo
438 438
 				define('_PROTEGE_JS_MODELES', creer_uniqid());
439 439
 			}
440 440
 			foreach ($r as $regs) {
441
-				$t = str_replace($regs[0], code_echappement($regs[0], 'javascript' . _PROTEGE_JS_MODELES), $t);
441
+				$t = str_replace($regs[0], code_echappement($regs[0], 'javascript'._PROTEGE_JS_MODELES), $t);
442 442
 			}
443 443
 		}
444
-		if (preg_match_all(',<\?php.*?($|\?' . '>),isS', $t, $r, PREG_SET_ORDER)) {
444
+		if (preg_match_all(',<\?php.*?($|\?'.'>),isS', $t, $r, PREG_SET_ORDER)) {
445 445
 			if (!defined('_PROTEGE_PHP_MODELES')) {
446 446
 				include_spip('inc/acces');
447 447
 				define('_PROTEGE_PHP_MODELES', creer_uniqid());
448 448
 			}
449 449
 			foreach ($r as $regs) {
450
-				$t = str_replace($regs[0], code_echappement($regs[0], 'php' . _PROTEGE_PHP_MODELES), $t);
450
+				$t = str_replace($regs[0], code_echappement($regs[0], 'php'._PROTEGE_PHP_MODELES), $t);
451 451
 			}
452 452
 		}
453 453
 	}
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
  * @param bool $strict
483 483
  * @return string
484 484
  */
485
-function echapper_html_suspect($texte, $strict=true) {
485
+function echapper_html_suspect($texte, $strict = true) {
486 486
 	static $echapper_html_suspect;
487 487
 	if (!$texte or !is_string($texte)) {
488 488
 		return $texte;
@@ -504,8 +504,8 @@  discard block
 block discarded – undo
504 504
 	// quand c'est du texte qui passe par propre on est plus coulant tant qu'il y a pas d'attribut du type onxxx=
505 505
 	// car sinon on declenche sur les modeles ou ressources
506 506
 	if (!$strict and
507
-	  (strpos($texte,'on') === false or !preg_match(",<\w+.*\bon\w+\s*=,UimsS", $texte))
508
-	  ){
507
+	  (strpos($texte, 'on') === false or !preg_match(",<\w+.*\bon\w+\s*=,UimsS", $texte))
508
+	  ) {
509 509
 		return $texte;
510 510
 	}
511 511
 
@@ -587,9 +587,9 @@  discard block
 block discarded – undo
587 587
  **/
588 588
 function supprime_img($letexte, $message = null) {
589 589
 	if ($message === null) {
590
-		$message = '(' . _T('img_indisponible') . ')';
590
+		$message = '('._T('img_indisponible').')';
591 591
 	}
592 592
 
593
-	return preg_replace(',<(img|doc|emb)([0-9]+)(\|([^>]*))?' . '\s*/?' . '>,i',
593
+	return preg_replace(',<(img|doc|emb)([0-9]+)(\|([^>]*))?'.'\s*/?'.'>,i',
594 594
 		$message, $letexte);
595 595
 }
Please login to merge, or discard this patch.