@@ -16,7 +16,7 @@ discard block |
||
| 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 |
||
| 42 | 42 | * @return string Fonction PHP correspondante du filtre |
| 43 | 43 | */ |
| 44 | 44 | function charger_filtre($fonc, $default = 'filtre_identite_dist') { |
| 45 | - include_fichiers_fonctions(); // inclure les fichiers fonctions |
|
| 46 | - return chercher_filtre($fonc, $default); |
|
| 45 | + include_fichiers_fonctions(); // inclure les fichiers fonctions |
|
| 46 | + return chercher_filtre($fonc, $default); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -75,38 +75,38 @@ discard block |
||
| 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 | - |
|
| 96 | - include_fichiers_fonctions(); |
|
| 97 | - foreach (array('filtre_' . $fonc, 'filtre_' . $fonc . '_dist', $fonc) as $f) { |
|
| 98 | - trouver_filtre_matrice($f); // charge des fichiers spécifiques éventuels |
|
| 99 | - // fonction ou name\space\fonction |
|
| 100 | - if (is_callable($f)) { |
|
| 101 | - return $f; |
|
| 102 | - } |
|
| 103 | - // méthode statique d'une classe Classe::methode ou name\space\Classe::methode |
|
| 104 | - elseif (false === strpos($f, '::') and is_callable(array($f))) { |
|
| 105 | - return $f; |
|
| 106 | - } |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - 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 | + |
|
| 96 | + include_fichiers_fonctions(); |
|
| 97 | + foreach (array('filtre_' . $fonc, 'filtre_' . $fonc . '_dist', $fonc) as $f) { |
|
| 98 | + trouver_filtre_matrice($f); // charge des fichiers spécifiques éventuels |
|
| 99 | + // fonction ou name\space\fonction |
|
| 100 | + if (is_callable($f)) { |
|
| 101 | + return $f; |
|
| 102 | + } |
|
| 103 | + // méthode statique d'une classe Classe::methode ou name\space\Classe::methode |
|
| 104 | + elseif (false === strpos($f, '::') and is_callable(array($f))) { |
|
| 105 | + return $f; |
|
| 106 | + } |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + return $default; |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | /** |
@@ -150,8 +150,8 @@ discard block |
||
| 150 | 150 | * Chaîne vide sinon. |
| 151 | 151 | **/ |
| 152 | 152 | function appliquer_filtre($arg, $filtre) { |
| 153 | - $args = func_get_args(); |
|
| 154 | - return appliquer_filtre_sinon($arg, $filtre, $args, ''); |
|
| 153 | + $args = func_get_args(); |
|
| 154 | + return appliquer_filtre_sinon($arg, $filtre, $args, ''); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | /** |
@@ -176,8 +176,8 @@ discard block |
||
| 176 | 176 | * Texte d'origine sinon |
| 177 | 177 | **/ |
| 178 | 178 | function appliquer_si_filtre($arg, $filtre) { |
| 179 | - $args = func_get_args(); |
|
| 180 | - return appliquer_filtre_sinon($arg, $filtre, $args, $arg); |
|
| 179 | + $args = func_get_args(); |
|
| 180 | + return appliquer_filtre_sinon($arg, $filtre, $args, $arg); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | /** |
@@ -193,12 +193,12 @@ discard block |
||
| 193 | 193 | * Version de SPIP |
| 194 | 194 | **/ |
| 195 | 195 | function spip_version() { |
| 196 | - $version = $GLOBALS['spip_version_affichee']; |
|
| 197 | - if ($vcs_version = version_vcs_courante(_DIR_RACINE)) { |
|
| 198 | - $version .= " $vcs_version"; |
|
| 199 | - } |
|
| 196 | + $version = $GLOBALS['spip_version_affichee']; |
|
| 197 | + if ($vcs_version = version_vcs_courante(_DIR_RACINE)) { |
|
| 198 | + $version .= " $vcs_version"; |
|
| 199 | + } |
|
| 200 | 200 | |
| 201 | - return $version; |
|
| 201 | + return $version; |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | /** |
@@ -211,19 +211,19 @@ discard block |
||
| 211 | 211 | * - string|null si $raw = false |
| 212 | 212 | */ |
| 213 | 213 | function version_vcs_courante($dir, $raw = false) { |
| 214 | - $desc = decrire_version_git($dir); |
|
| 215 | - if ($desc === null) { |
|
| 216 | - $desc = decrire_version_svn($dir); |
|
| 217 | - } |
|
| 218 | - if ($desc === null or $raw) { |
|
| 219 | - return $desc; |
|
| 220 | - } |
|
| 221 | - // affichage "GIT [master: abcdef]" |
|
| 222 | - $commit = isset($desc['commit_short']) ? $desc['commit_short'] : $desc['commit']; |
|
| 223 | - if ($desc['branch']) { |
|
| 224 | - $commit = $desc['branch'] . ': ' . $commit; |
|
| 225 | - } |
|
| 226 | - return "{$desc['vcs']} [$commit]"; |
|
| 214 | + $desc = decrire_version_git($dir); |
|
| 215 | + if ($desc === null) { |
|
| 216 | + $desc = decrire_version_svn($dir); |
|
| 217 | + } |
|
| 218 | + if ($desc === null or $raw) { |
|
| 219 | + return $desc; |
|
| 220 | + } |
|
| 221 | + // affichage "GIT [master: abcdef]" |
|
| 222 | + $commit = isset($desc['commit_short']) ? $desc['commit_short'] : $desc['commit']; |
|
| 223 | + if ($desc['branch']) { |
|
| 224 | + $commit = $desc['branch'] . ': ' . $commit; |
|
| 225 | + } |
|
| 226 | + return "{$desc['vcs']} [$commit]"; |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | /** |
@@ -235,24 +235,24 @@ discard block |
||
| 235 | 235 | * array ['branch' => xx, 'commit' => yy] sinon. |
| 236 | 236 | **/ |
| 237 | 237 | function decrire_version_git($dir) { |
| 238 | - if (!$dir) { |
|
| 239 | - $dir = '.'; |
|
| 240 | - } |
|
| 238 | + if (!$dir) { |
|
| 239 | + $dir = '.'; |
|
| 240 | + } |
|
| 241 | 241 | |
| 242 | - // version installee par GIT |
|
| 243 | - if (lire_fichier($dir . '/.git/HEAD', $c)) { |
|
| 244 | - $currentHead = trim(substr($c, 4)); |
|
| 245 | - if (lire_fichier($dir . '/.git/' . $currentHead, $hash)) { |
|
| 246 | - return [ |
|
| 247 | - 'vcs' => 'GIT', |
|
| 248 | - 'branch' => basename($currentHead), |
|
| 249 | - 'commit' => trim($hash), |
|
| 250 | - 'commit_short' => substr(trim($hash), 0, 8), |
|
| 251 | - ]; |
|
| 252 | - } |
|
| 253 | - } |
|
| 242 | + // version installee par GIT |
|
| 243 | + if (lire_fichier($dir . '/.git/HEAD', $c)) { |
|
| 244 | + $currentHead = trim(substr($c, 4)); |
|
| 245 | + if (lire_fichier($dir . '/.git/' . $currentHead, $hash)) { |
|
| 246 | + return [ |
|
| 247 | + 'vcs' => 'GIT', |
|
| 248 | + 'branch' => basename($currentHead), |
|
| 249 | + 'commit' => trim($hash), |
|
| 250 | + 'commit_short' => substr(trim($hash), 0, 8), |
|
| 251 | + ]; |
|
| 252 | + } |
|
| 253 | + } |
|
| 254 | 254 | |
| 255 | - return null; |
|
| 255 | + return null; |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | |
@@ -265,25 +265,25 @@ discard block |
||
| 265 | 265 | * array ['commit' => yy, 'date' => xx, 'author' => xx] sinon. |
| 266 | 266 | **/ |
| 267 | 267 | function decrire_version_svn($dir) { |
| 268 | - if (!$dir) { |
|
| 269 | - $dir = '.'; |
|
| 270 | - } |
|
| 271 | - // version installee par SVN |
|
| 272 | - if (file_exists($dir . '/.svn/wc.db') && class_exists('SQLite3')) { |
|
| 273 | - $db = new SQLite3($dir . '/.svn/wc.db'); |
|
| 274 | - $result = $db->query('SELECT changed_revision FROM nodes WHERE local_relpath = "" LIMIT 1'); |
|
| 275 | - if ($result) { |
|
| 276 | - $row = $result->fetchArray(); |
|
| 277 | - if ($row['changed_revision'] != "") { |
|
| 278 | - return [ |
|
| 279 | - 'vcs' => 'SVN', |
|
| 280 | - 'branch' => '', |
|
| 281 | - 'commit' => $row['changed_revision'], |
|
| 282 | - ]; |
|
| 283 | - } |
|
| 284 | - } |
|
| 285 | - } |
|
| 286 | - return null; |
|
| 268 | + if (!$dir) { |
|
| 269 | + $dir = '.'; |
|
| 270 | + } |
|
| 271 | + // version installee par SVN |
|
| 272 | + if (file_exists($dir . '/.svn/wc.db') && class_exists('SQLite3')) { |
|
| 273 | + $db = new SQLite3($dir . '/.svn/wc.db'); |
|
| 274 | + $result = $db->query('SELECT changed_revision FROM nodes WHERE local_relpath = "" LIMIT 1'); |
|
| 275 | + if ($result) { |
|
| 276 | + $row = $result->fetchArray(); |
|
| 277 | + if ($row['changed_revision'] != "") { |
|
| 278 | + return [ |
|
| 279 | + 'vcs' => 'SVN', |
|
| 280 | + 'branch' => '', |
|
| 281 | + 'commit' => $row['changed_revision'], |
|
| 282 | + ]; |
|
| 283 | + } |
|
| 284 | + } |
|
| 285 | + } |
|
| 286 | + return null; |
|
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | /** |
@@ -301,10 +301,10 @@ discard block |
||
| 301 | 301 | * |
| 302 | 302 | **/ |
| 303 | 303 | function version_svn_courante($dir) { |
| 304 | - if ($desc = decrire_version_svn($dir)) { |
|
| 305 | - return -$desc['commit']; |
|
| 306 | - } |
|
| 307 | - return 0; |
|
| 304 | + if ($desc = decrire_version_svn($dir)) { |
|
| 305 | + return -$desc['commit']; |
|
| 306 | + } |
|
| 307 | + return 0; |
|
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | // La matrice est necessaire pour ne filtrer _que_ des fonctions definies dans filtres_images |
@@ -351,18 +351,18 @@ discard block |
||
| 351 | 351 | * Code HTML retourné par le filtre |
| 352 | 352 | **/ |
| 353 | 353 | function filtrer($filtre) { |
| 354 | - $tous = func_get_args(); |
|
| 355 | - if (trouver_filtre_matrice($filtre) and substr($filtre, 0, 6) == 'image_') { |
|
| 356 | - return image_filtrer($tous); |
|
| 357 | - } elseif ($f = chercher_filtre($filtre)) { |
|
| 358 | - array_shift($tous); |
|
| 359 | - return call_user_func_array($f, $tous); |
|
| 360 | - } else { |
|
| 361 | - // le filtre n'existe pas, on provoque une erreur |
|
| 362 | - $msg = array('zbug_erreur_filtre', array('filtre' => texte_script($filtre))); |
|
| 363 | - erreur_squelette($msg); |
|
| 364 | - return ''; |
|
| 365 | - } |
|
| 354 | + $tous = func_get_args(); |
|
| 355 | + if (trouver_filtre_matrice($filtre) and substr($filtre, 0, 6) == 'image_') { |
|
| 356 | + return image_filtrer($tous); |
|
| 357 | + } elseif ($f = chercher_filtre($filtre)) { |
|
| 358 | + array_shift($tous); |
|
| 359 | + return call_user_func_array($f, $tous); |
|
| 360 | + } else { |
|
| 361 | + // le filtre n'existe pas, on provoque une erreur |
|
| 362 | + $msg = array('zbug_erreur_filtre', array('filtre' => texte_script($filtre))); |
|
| 363 | + erreur_squelette($msg); |
|
| 364 | + return ''; |
|
| 365 | + } |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | /** |
@@ -379,11 +379,11 @@ discard block |
||
| 379 | 379 | * @return bool true si on trouve le filtre dans la matrice, false sinon. |
| 380 | 380 | */ |
| 381 | 381 | function trouver_filtre_matrice($filtre) { |
| 382 | - if (isset($GLOBALS['spip_matrice'][$filtre]) and is_string($f = $GLOBALS['spip_matrice'][$filtre])) { |
|
| 383 | - find_in_path($f, '', true); |
|
| 384 | - $GLOBALS['spip_matrice'][$filtre] = true; |
|
| 385 | - } |
|
| 386 | - return !empty($GLOBALS['spip_matrice'][$filtre]); |
|
| 382 | + if (isset($GLOBALS['spip_matrice'][$filtre]) and is_string($f = $GLOBALS['spip_matrice'][$filtre])) { |
|
| 383 | + find_in_path($f, '', true); |
|
| 384 | + $GLOBALS['spip_matrice'][$filtre] = true; |
|
| 385 | + } |
|
| 386 | + return !empty($GLOBALS['spip_matrice'][$filtre]); |
|
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | |
@@ -411,8 +411,8 @@ discard block |
||
| 411 | 411 | * @return mixed |
| 412 | 412 | */ |
| 413 | 413 | function filtre_set(&$Pile, $val, $key, $continue = null) { |
| 414 | - $Pile['vars'][$key] = $val; |
|
| 415 | - return $continue ? $val : ''; |
|
| 414 | + $Pile['vars'][$key] = $val; |
|
| 415 | + return $continue ? $val : ''; |
|
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | /** |
@@ -438,8 +438,8 @@ discard block |
||
| 438 | 438 | * @return string|mixed Retourne `$val` si `$continue` présent, sinon ''. |
| 439 | 439 | */ |
| 440 | 440 | function filtre_setenv(&$Pile, $val, $key, $continue = null) { |
| 441 | - $Pile[0][$key] = $val; |
|
| 442 | - return $continue ? $val : ''; |
|
| 441 | + $Pile[0][$key] = $val; |
|
| 442 | + return $continue ? $val : ''; |
|
| 443 | 443 | } |
| 444 | 444 | |
| 445 | 445 | /** |
@@ -448,8 +448,8 @@ discard block |
||
| 448 | 448 | * @return string |
| 449 | 449 | */ |
| 450 | 450 | function filtre_sanitize_env(&$Pile, $keys) { |
| 451 | - $Pile[0] = spip_sanitize_from_request($Pile[0], $keys); |
|
| 452 | - return ''; |
|
| 451 | + $Pile[0] = spip_sanitize_from_request($Pile[0], $keys); |
|
| 452 | + return ''; |
|
| 453 | 453 | } |
| 454 | 454 | |
| 455 | 455 | |
@@ -472,18 +472,18 @@ discard block |
||
| 472 | 472 | * @return mixed Retourne la valeur (sans la modifier). |
| 473 | 473 | */ |
| 474 | 474 | function filtre_debug($val, $key = null) { |
| 475 | - $debug = ( |
|
| 476 | - is_null($key) ? '' : (var_export($key, true) . " = ") |
|
| 477 | - ) . var_export($val, true); |
|
| 475 | + $debug = ( |
|
| 476 | + is_null($key) ? '' : (var_export($key, true) . " = ") |
|
| 477 | + ) . var_export($val, true); |
|
| 478 | 478 | |
| 479 | - include_spip('inc/autoriser'); |
|
| 480 | - if (autoriser('webmestre')) { |
|
| 481 | - echo "<div class='spip_debug'>\n", $debug, "</div>\n"; |
|
| 482 | - } |
|
| 479 | + include_spip('inc/autoriser'); |
|
| 480 | + if (autoriser('webmestre')) { |
|
| 481 | + echo "<div class='spip_debug'>\n", $debug, "</div>\n"; |
|
| 482 | + } |
|
| 483 | 483 | |
| 484 | - spip_log($debug, 'debug'); |
|
| 484 | + spip_log($debug, 'debug'); |
|
| 485 | 485 | |
| 486 | - return $val; |
|
| 486 | + return $val; |
|
| 487 | 487 | } |
| 488 | 488 | |
| 489 | 489 | |
@@ -511,82 +511,82 @@ discard block |
||
| 511 | 511 | * Texte qui a reçu les filtres |
| 512 | 512 | **/ |
| 513 | 513 | function image_filtrer($args) { |
| 514 | - $filtre = array_shift($args); # enlever $filtre |
|
| 515 | - $texte = array_shift($args); |
|
| 516 | - if (!strlen($texte)) { |
|
| 517 | - return; |
|
| 518 | - } |
|
| 519 | - find_in_path('filtres_images_mini.php', 'inc/', true); |
|
| 520 | - statut_effacer_images_temporaires(true); // activer la suppression des images temporaires car le compilo finit la chaine par un image_graver |
|
| 521 | - // Cas du nom de fichier local |
|
| 522 | - $is_file = trim($texte); |
|
| 523 | - if (strpos(substr($is_file, strlen(_DIR_RACINE)), '..') !== false |
|
| 524 | - or strpbrk($is_file, "<>\n\r\t") !== false |
|
| 525 | - or strpos($is_file, '/') === 0 |
|
| 526 | - ) { |
|
| 527 | - $is_file = false; |
|
| 528 | - } |
|
| 529 | - if ($is_file) { |
|
| 530 | - $is_local_file = function($path) { |
|
| 531 | - if (strpos($path, "?") !== false) { |
|
| 532 | - $path = supprimer_timestamp($path); |
|
| 533 | - // remove ?24px added by find_in_theme on .svg files |
|
| 534 | - $path = preg_replace(",\?[[:digit:]]+(px)$,", "", $path); |
|
| 535 | - } |
|
| 536 | - return file_exists($path); |
|
| 537 | - }; |
|
| 538 | - if ($is_local_file($is_file) or tester_url_absolue($is_file)) { |
|
| 539 | - array_unshift($args, "<img src='$is_file' />"); |
|
| 540 | - $res = call_user_func_array($filtre, $args); |
|
| 541 | - statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo |
|
| 542 | - return $res; |
|
| 543 | - } |
|
| 544 | - } |
|
| 545 | - |
|
| 546 | - // Cas general : trier toutes les images, avec eventuellement leur <span> |
|
| 547 | - if (preg_match_all( |
|
| 548 | - ',(<([a-z]+) [^<>]*spip_documents[^<>]*>)?\s*(<img\s.*>),UimsS', |
|
| 549 | - $texte, $tags, PREG_SET_ORDER)) { |
|
| 550 | - foreach ($tags as $tag) { |
|
| 551 | - $class = extraire_attribut($tag[3], 'class'); |
|
| 552 | - if (!$class or |
|
| 553 | - (strpos($class, 'filtre_inactif') === false |
|
| 554 | - // compat historique a virer en 3.2 |
|
| 555 | - and strpos($class, 'no_image_filtrer') === false) |
|
| 556 | - ) { |
|
| 557 | - array_unshift($args, $tag[3]); |
|
| 558 | - if ($reduit = call_user_func_array($filtre, $args)) { |
|
| 559 | - // En cas de span spip_documents, modifier le style=...width: |
|
| 560 | - if ($tag[1]) { |
|
| 561 | - $w = extraire_attribut($reduit, 'width'); |
|
| 562 | - if (!$w and preg_match(",width:\s*(\d+)px,S", extraire_attribut($reduit, 'style'), $regs)) { |
|
| 563 | - $w = $regs[1]; |
|
| 564 | - } |
|
| 565 | - if ($w and ($style = extraire_attribut($tag[1], 'style'))) { |
|
| 566 | - $style = preg_replace(",width:\s*\d+px,S", "width:${w}px", $style); |
|
| 567 | - $replace = inserer_attribut($tag[1], 'style', $style); |
|
| 568 | - $texte = str_replace($tag[1], $replace, $texte); |
|
| 569 | - } |
|
| 570 | - } |
|
| 571 | - // traiter aussi un eventuel mouseover |
|
| 572 | - if ($mouseover = extraire_attribut($reduit, 'onmouseover')) { |
|
| 573 | - if (preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)) { |
|
| 574 | - $srcover = $match[1]; |
|
| 575 | - array_shift($args); |
|
| 576 | - array_unshift($args, "<img src='" . $match[1] . "' />"); |
|
| 577 | - $srcover_filter = call_user_func_array($filtre, $args); |
|
| 578 | - $srcover_filter = extraire_attribut($srcover_filter, 'src'); |
|
| 579 | - $reduit = str_replace($srcover, $srcover_filter, $reduit); |
|
| 580 | - } |
|
| 581 | - } |
|
| 582 | - $texte = str_replace($tag[3], $reduit, $texte); |
|
| 583 | - } |
|
| 584 | - array_shift($args); |
|
| 585 | - } |
|
| 586 | - } |
|
| 587 | - } |
|
| 588 | - statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo |
|
| 589 | - return $texte; |
|
| 514 | + $filtre = array_shift($args); # enlever $filtre |
|
| 515 | + $texte = array_shift($args); |
|
| 516 | + if (!strlen($texte)) { |
|
| 517 | + return; |
|
| 518 | + } |
|
| 519 | + find_in_path('filtres_images_mini.php', 'inc/', true); |
|
| 520 | + statut_effacer_images_temporaires(true); // activer la suppression des images temporaires car le compilo finit la chaine par un image_graver |
|
| 521 | + // Cas du nom de fichier local |
|
| 522 | + $is_file = trim($texte); |
|
| 523 | + if (strpos(substr($is_file, strlen(_DIR_RACINE)), '..') !== false |
|
| 524 | + or strpbrk($is_file, "<>\n\r\t") !== false |
|
| 525 | + or strpos($is_file, '/') === 0 |
|
| 526 | + ) { |
|
| 527 | + $is_file = false; |
|
| 528 | + } |
|
| 529 | + if ($is_file) { |
|
| 530 | + $is_local_file = function($path) { |
|
| 531 | + if (strpos($path, "?") !== false) { |
|
| 532 | + $path = supprimer_timestamp($path); |
|
| 533 | + // remove ?24px added by find_in_theme on .svg files |
|
| 534 | + $path = preg_replace(",\?[[:digit:]]+(px)$,", "", $path); |
|
| 535 | + } |
|
| 536 | + return file_exists($path); |
|
| 537 | + }; |
|
| 538 | + if ($is_local_file($is_file) or tester_url_absolue($is_file)) { |
|
| 539 | + array_unshift($args, "<img src='$is_file' />"); |
|
| 540 | + $res = call_user_func_array($filtre, $args); |
|
| 541 | + statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo |
|
| 542 | + return $res; |
|
| 543 | + } |
|
| 544 | + } |
|
| 545 | + |
|
| 546 | + // Cas general : trier toutes les images, avec eventuellement leur <span> |
|
| 547 | + if (preg_match_all( |
|
| 548 | + ',(<([a-z]+) [^<>]*spip_documents[^<>]*>)?\s*(<img\s.*>),UimsS', |
|
| 549 | + $texte, $tags, PREG_SET_ORDER)) { |
|
| 550 | + foreach ($tags as $tag) { |
|
| 551 | + $class = extraire_attribut($tag[3], 'class'); |
|
| 552 | + if (!$class or |
|
| 553 | + (strpos($class, 'filtre_inactif') === false |
|
| 554 | + // compat historique a virer en 3.2 |
|
| 555 | + and strpos($class, 'no_image_filtrer') === false) |
|
| 556 | + ) { |
|
| 557 | + array_unshift($args, $tag[3]); |
|
| 558 | + if ($reduit = call_user_func_array($filtre, $args)) { |
|
| 559 | + // En cas de span spip_documents, modifier le style=...width: |
|
| 560 | + if ($tag[1]) { |
|
| 561 | + $w = extraire_attribut($reduit, 'width'); |
|
| 562 | + if (!$w and preg_match(",width:\s*(\d+)px,S", extraire_attribut($reduit, 'style'), $regs)) { |
|
| 563 | + $w = $regs[1]; |
|
| 564 | + } |
|
| 565 | + if ($w and ($style = extraire_attribut($tag[1], 'style'))) { |
|
| 566 | + $style = preg_replace(",width:\s*\d+px,S", "width:${w}px", $style); |
|
| 567 | + $replace = inserer_attribut($tag[1], 'style', $style); |
|
| 568 | + $texte = str_replace($tag[1], $replace, $texte); |
|
| 569 | + } |
|
| 570 | + } |
|
| 571 | + // traiter aussi un eventuel mouseover |
|
| 572 | + if ($mouseover = extraire_attribut($reduit, 'onmouseover')) { |
|
| 573 | + if (preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)) { |
|
| 574 | + $srcover = $match[1]; |
|
| 575 | + array_shift($args); |
|
| 576 | + array_unshift($args, "<img src='" . $match[1] . "' />"); |
|
| 577 | + $srcover_filter = call_user_func_array($filtre, $args); |
|
| 578 | + $srcover_filter = extraire_attribut($srcover_filter, 'src'); |
|
| 579 | + $reduit = str_replace($srcover, $srcover_filter, $reduit); |
|
| 580 | + } |
|
| 581 | + } |
|
| 582 | + $texte = str_replace($tag[3], $reduit, $texte); |
|
| 583 | + } |
|
| 584 | + array_shift($args); |
|
| 585 | + } |
|
| 586 | + } |
|
| 587 | + } |
|
| 588 | + statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo |
|
| 589 | + return $texte; |
|
| 590 | 590 | } |
| 591 | 591 | |
| 592 | 592 | /** |
@@ -601,77 +601,77 @@ discard block |
||
| 601 | 601 | **/ |
| 602 | 602 | function taille_image($img, $force_refresh = false) { |
| 603 | 603 | |
| 604 | - static $largeur_img = array(), $hauteur_img = array(); |
|
| 605 | - $srcWidth = 0; |
|
| 606 | - $srcHeight = 0; |
|
| 607 | - |
|
| 608 | - $src = extraire_attribut($img, 'src'); |
|
| 609 | - |
|
| 610 | - if (!$src) { |
|
| 611 | - $src = $img; |
|
| 612 | - } else { |
|
| 613 | - $srcWidth = extraire_attribut($img, 'width'); |
|
| 614 | - $srcHeight = extraire_attribut($img, 'height'); |
|
| 615 | - } |
|
| 616 | - |
|
| 617 | - // ne jamais operer directement sur une image distante pour des raisons de perfo |
|
| 618 | - // la copie locale a toutes les chances d'etre la ou de resservir |
|
| 619 | - if (tester_url_absolue($src)) { |
|
| 620 | - include_spip('inc/distant'); |
|
| 621 | - $fichier = copie_locale($src); |
|
| 622 | - $src = $fichier ? _DIR_RACINE . $fichier : $src; |
|
| 623 | - } |
|
| 624 | - if (($p = strpos($src, '?')) !== false) { |
|
| 625 | - $src = substr($src, 0, $p); |
|
| 626 | - } |
|
| 627 | - |
|
| 628 | - $srcsize = false; |
|
| 629 | - if (isset($largeur_img[$src]) and !$force_refresh) { |
|
| 630 | - $srcWidth = $largeur_img[$src]; |
|
| 631 | - } |
|
| 632 | - if (isset($hauteur_img[$src]) and !$force_refresh) { |
|
| 633 | - $srcHeight = $hauteur_img[$src]; |
|
| 634 | - } |
|
| 635 | - if (!$srcWidth or !$srcHeight) { |
|
| 636 | - |
|
| 637 | - if (file_exists($src) |
|
| 638 | - and $srcsize = spip_getimagesize($src) |
|
| 639 | - ) { |
|
| 640 | - if (!$srcWidth) { |
|
| 641 | - $largeur_img[$src] = $srcWidth = $srcsize[0]; |
|
| 642 | - } |
|
| 643 | - if (!$srcHeight) { |
|
| 644 | - $hauteur_img[$src] = $srcHeight = $srcsize[1]; |
|
| 645 | - } |
|
| 646 | - } |
|
| 647 | - elseif(strpos($src, "<svg") !== false) { |
|
| 648 | - include_spip('inc/svg'); |
|
| 649 | - if ($attrs = svg_lire_attributs($src)){ |
|
| 650 | - list($width, $height, $viewbox) = svg_getimagesize_from_attr($attrs); |
|
| 651 | - if (!$srcWidth){ |
|
| 652 | - $largeur_img[$src] = $srcWidth = $width; |
|
| 653 | - } |
|
| 654 | - if (!$srcHeight){ |
|
| 655 | - $hauteur_img[$src] = $srcHeight = $height; |
|
| 656 | - } |
|
| 657 | - } |
|
| 658 | - } |
|
| 659 | - // $src peut etre une reference a une image temporaire dont a n'a que le log .src |
|
| 660 | - // on s'y refere, l'image sera reconstruite en temps utile si necessaire |
|
| 661 | - elseif (@file_exists($f = "$src.src") |
|
| 662 | - and lire_fichier($f, $valeurs) |
|
| 663 | - and $valeurs = unserialize($valeurs) |
|
| 664 | - ) { |
|
| 665 | - if (!$srcWidth) { |
|
| 666 | - $largeur_img[$src] = $srcWidth = $valeurs["largeur_dest"]; |
|
| 667 | - } |
|
| 668 | - if (!$srcHeight) { |
|
| 669 | - $hauteur_img[$src] = $srcHeight = $valeurs["hauteur_dest"]; |
|
| 670 | - } |
|
| 671 | - } |
|
| 672 | - } |
|
| 673 | - |
|
| 674 | - return array($srcHeight, $srcWidth); |
|
| 604 | + static $largeur_img = array(), $hauteur_img = array(); |
|
| 605 | + $srcWidth = 0; |
|
| 606 | + $srcHeight = 0; |
|
| 607 | + |
|
| 608 | + $src = extraire_attribut($img, 'src'); |
|
| 609 | + |
|
| 610 | + if (!$src) { |
|
| 611 | + $src = $img; |
|
| 612 | + } else { |
|
| 613 | + $srcWidth = extraire_attribut($img, 'width'); |
|
| 614 | + $srcHeight = extraire_attribut($img, 'height'); |
|
| 615 | + } |
|
| 616 | + |
|
| 617 | + // ne jamais operer directement sur une image distante pour des raisons de perfo |
|
| 618 | + // la copie locale a toutes les chances d'etre la ou de resservir |
|
| 619 | + if (tester_url_absolue($src)) { |
|
| 620 | + include_spip('inc/distant'); |
|
| 621 | + $fichier = copie_locale($src); |
|
| 622 | + $src = $fichier ? _DIR_RACINE . $fichier : $src; |
|
| 623 | + } |
|
| 624 | + if (($p = strpos($src, '?')) !== false) { |
|
| 625 | + $src = substr($src, 0, $p); |
|
| 626 | + } |
|
| 627 | + |
|
| 628 | + $srcsize = false; |
|
| 629 | + if (isset($largeur_img[$src]) and !$force_refresh) { |
|
| 630 | + $srcWidth = $largeur_img[$src]; |
|
| 631 | + } |
|
| 632 | + if (isset($hauteur_img[$src]) and !$force_refresh) { |
|
| 633 | + $srcHeight = $hauteur_img[$src]; |
|
| 634 | + } |
|
| 635 | + if (!$srcWidth or !$srcHeight) { |
|
| 636 | + |
|
| 637 | + if (file_exists($src) |
|
| 638 | + and $srcsize = spip_getimagesize($src) |
|
| 639 | + ) { |
|
| 640 | + if (!$srcWidth) { |
|
| 641 | + $largeur_img[$src] = $srcWidth = $srcsize[0]; |
|
| 642 | + } |
|
| 643 | + if (!$srcHeight) { |
|
| 644 | + $hauteur_img[$src] = $srcHeight = $srcsize[1]; |
|
| 645 | + } |
|
| 646 | + } |
|
| 647 | + elseif(strpos($src, "<svg") !== false) { |
|
| 648 | + include_spip('inc/svg'); |
|
| 649 | + if ($attrs = svg_lire_attributs($src)){ |
|
| 650 | + list($width, $height, $viewbox) = svg_getimagesize_from_attr($attrs); |
|
| 651 | + if (!$srcWidth){ |
|
| 652 | + $largeur_img[$src] = $srcWidth = $width; |
|
| 653 | + } |
|
| 654 | + if (!$srcHeight){ |
|
| 655 | + $hauteur_img[$src] = $srcHeight = $height; |
|
| 656 | + } |
|
| 657 | + } |
|
| 658 | + } |
|
| 659 | + // $src peut etre une reference a une image temporaire dont a n'a que le log .src |
|
| 660 | + // on s'y refere, l'image sera reconstruite en temps utile si necessaire |
|
| 661 | + elseif (@file_exists($f = "$src.src") |
|
| 662 | + and lire_fichier($f, $valeurs) |
|
| 663 | + and $valeurs = unserialize($valeurs) |
|
| 664 | + ) { |
|
| 665 | + if (!$srcWidth) { |
|
| 666 | + $largeur_img[$src] = $srcWidth = $valeurs["largeur_dest"]; |
|
| 667 | + } |
|
| 668 | + if (!$srcHeight) { |
|
| 669 | + $hauteur_img[$src] = $srcHeight = $valeurs["hauteur_dest"]; |
|
| 670 | + } |
|
| 671 | + } |
|
| 672 | + } |
|
| 673 | + |
|
| 674 | + return array($srcHeight, $srcWidth); |
|
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | |
@@ -689,12 +689,12 @@ discard block |
||
| 689 | 689 | * Largeur en pixels, NULL ou 0 si aucune image. |
| 690 | 690 | **/ |
| 691 | 691 | function largeur($img) { |
| 692 | - if (!$img) { |
|
| 693 | - return; |
|
| 694 | - } |
|
| 695 | - list($h, $l) = taille_image($img); |
|
| 692 | + if (!$img) { |
|
| 693 | + return; |
|
| 694 | + } |
|
| 695 | + list($h, $l) = taille_image($img); |
|
| 696 | 696 | |
| 697 | - return $l; |
|
| 697 | + return $l; |
|
| 698 | 698 | } |
| 699 | 699 | |
| 700 | 700 | /** |
@@ -711,12 +711,12 @@ discard block |
||
| 711 | 711 | * Hauteur en pixels, NULL ou 0 si aucune image. |
| 712 | 712 | **/ |
| 713 | 713 | function hauteur($img) { |
| 714 | - if (!$img) { |
|
| 715 | - return; |
|
| 716 | - } |
|
| 717 | - list($h, $l) = taille_image($img); |
|
| 714 | + if (!$img) { |
|
| 715 | + return; |
|
| 716 | + } |
|
| 717 | + list($h, $l) = taille_image($img); |
|
| 718 | 718 | |
| 719 | - return $h; |
|
| 719 | + return $h; |
|
| 720 | 720 | } |
| 721 | 721 | |
| 722 | 722 | |
@@ -736,11 +736,11 @@ discard block |
||
| 736 | 736 | * @return string |
| 737 | 737 | **/ |
| 738 | 738 | function corriger_entites_html($texte) { |
| 739 | - if (strpos($texte, '&') === false) { |
|
| 740 | - return $texte; |
|
| 741 | - } |
|
| 739 | + if (strpos($texte, '&') === false) { |
|
| 740 | + return $texte; |
|
| 741 | + } |
|
| 742 | 742 | |
| 743 | - return preg_replace(',&(#[0-9][0-9][0-9]+;|amp;),iS', '&\1', $texte); |
|
| 743 | + return preg_replace(',&(#[0-9][0-9][0-9]+;|amp;),iS', '&\1', $texte); |
|
| 744 | 744 | } |
| 745 | 745 | |
| 746 | 746 | /** |
@@ -755,11 +755,11 @@ discard block |
||
| 755 | 755 | * @return string |
| 756 | 756 | **/ |
| 757 | 757 | function corriger_toutes_entites_html($texte) { |
| 758 | - if (strpos($texte, '&') === false) { |
|
| 759 | - return $texte; |
|
| 760 | - } |
|
| 758 | + if (strpos($texte, '&') === false) { |
|
| 759 | + return $texte; |
|
| 760 | + } |
|
| 761 | 761 | |
| 762 | - return preg_replace(',&(#?[a-z0-9]+;),iS', '&\1', $texte); |
|
| 762 | + return preg_replace(',&(#?[a-z0-9]+;),iS', '&\1', $texte); |
|
| 763 | 763 | } |
| 764 | 764 | |
| 765 | 765 | /** |
@@ -769,7 +769,7 @@ discard block |
||
| 769 | 769 | * @return string |
| 770 | 770 | **/ |
| 771 | 771 | function proteger_amp($texte) { |
| 772 | - return str_replace('&', '&', $texte); |
|
| 772 | + return str_replace('&', '&', $texte); |
|
| 773 | 773 | } |
| 774 | 774 | |
| 775 | 775 | |
@@ -800,20 +800,20 @@ discard block |
||
| 800 | 800 | * @return mixed|string |
| 801 | 801 | */ |
| 802 | 802 | function entites_html($texte, $tout = false, $quote = true) { |
| 803 | - if (!is_string($texte) or !$texte |
|
| 804 | - or strpbrk($texte, "&\"'<>") == false |
|
| 805 | - ) { |
|
| 806 | - return $texte; |
|
| 807 | - } |
|
| 808 | - include_spip('inc/texte'); |
|
| 809 | - $flags = ($quote ? ENT_QUOTES : ENT_NOQUOTES); |
|
| 810 | - $flags |= ENT_HTML401; |
|
| 811 | - $texte = spip_htmlspecialchars(echappe_retour(echappe_html($texte, '', true), '', 'proteger_amp'), $flags); |
|
| 812 | - if ($tout) { |
|
| 813 | - return corriger_toutes_entites_html($texte); |
|
| 814 | - } else { |
|
| 815 | - return corriger_entites_html($texte); |
|
| 816 | - } |
|
| 803 | + if (!is_string($texte) or !$texte |
|
| 804 | + or strpbrk($texte, "&\"'<>") == false |
|
| 805 | + ) { |
|
| 806 | + return $texte; |
|
| 807 | + } |
|
| 808 | + include_spip('inc/texte'); |
|
| 809 | + $flags = ($quote ? ENT_QUOTES : ENT_NOQUOTES); |
|
| 810 | + $flags |= ENT_HTML401; |
|
| 811 | + $texte = spip_htmlspecialchars(echappe_retour(echappe_html($texte, '', true), '', 'proteger_amp'), $flags); |
|
| 812 | + if ($tout) { |
|
| 813 | + return corriger_toutes_entites_html($texte); |
|
| 814 | + } else { |
|
| 815 | + return corriger_entites_html($texte); |
|
| 816 | + } |
|
| 817 | 817 | } |
| 818 | 818 | |
| 819 | 819 | /** |
@@ -832,37 +832,37 @@ discard block |
||
| 832 | 832 | * Texte converti |
| 833 | 833 | **/ |
| 834 | 834 | function filtrer_entites($texte) { |
| 835 | - if (strpos($texte, '&') === false) { |
|
| 836 | - return $texte; |
|
| 837 | - } |
|
| 838 | - // filtrer |
|
| 839 | - $texte = html2unicode($texte); |
|
| 840 | - // remettre le tout dans le charset cible |
|
| 841 | - $texte = unicode2charset($texte); |
|
| 842 | - // cas particulier des " et ' qu'il faut filtrer aussi |
|
| 843 | - // (on le faisait deja avec un ") |
|
| 844 | - if (strpos($texte, "&#") !== false) { |
|
| 845 | - $texte = str_replace(array("'", "'", """, """), array("'", "'", '"', '"'), $texte); |
|
| 846 | - } |
|
| 835 | + if (strpos($texte, '&') === false) { |
|
| 836 | + return $texte; |
|
| 837 | + } |
|
| 838 | + // filtrer |
|
| 839 | + $texte = html2unicode($texte); |
|
| 840 | + // remettre le tout dans le charset cible |
|
| 841 | + $texte = unicode2charset($texte); |
|
| 842 | + // cas particulier des " et ' qu'il faut filtrer aussi |
|
| 843 | + // (on le faisait deja avec un ") |
|
| 844 | + if (strpos($texte, "&#") !== false) { |
|
| 845 | + $texte = str_replace(array("'", "'", """, """), array("'", "'", '"', '"'), $texte); |
|
| 846 | + } |
|
| 847 | 847 | |
| 848 | - return $texte; |
|
| 848 | + return $texte; |
|
| 849 | 849 | } |
| 850 | 850 | |
| 851 | 851 | |
| 852 | 852 | if (!function_exists('filtre_filtrer_entites_dist')) { |
| 853 | - /** |
|
| 854 | - * Version sécurisée de filtrer_entites |
|
| 855 | - * |
|
| 856 | - * @uses interdire_scripts() |
|
| 857 | - * @uses filtrer_entites() |
|
| 858 | - * |
|
| 859 | - * @param string $t |
|
| 860 | - * @return string |
|
| 861 | - */ |
|
| 862 | - function filtre_filtrer_entites_dist($t) { |
|
| 863 | - include_spip('inc/texte'); |
|
| 864 | - return interdire_scripts(filtrer_entites($t)); |
|
| 865 | - } |
|
| 853 | + /** |
|
| 854 | + * Version sécurisée de filtrer_entites |
|
| 855 | + * |
|
| 856 | + * @uses interdire_scripts() |
|
| 857 | + * @uses filtrer_entites() |
|
| 858 | + * |
|
| 859 | + * @param string $t |
|
| 860 | + * @return string |
|
| 861 | + */ |
|
| 862 | + function filtre_filtrer_entites_dist($t) { |
|
| 863 | + include_spip('inc/texte'); |
|
| 864 | + return interdire_scripts(filtrer_entites($t)); |
|
| 865 | + } |
|
| 866 | 866 | } |
| 867 | 867 | |
| 868 | 868 | |
@@ -877,18 +877,18 @@ discard block |
||
| 877 | 877 | * @return string|array |
| 878 | 878 | **/ |
| 879 | 879 | function supprimer_caracteres_illegaux($texte) { |
| 880 | - 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"; |
|
| 881 | - static $to = null; |
|
| 880 | + 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"; |
|
| 881 | + static $to = null; |
|
| 882 | 882 | |
| 883 | - if (is_array($texte)) { |
|
| 884 | - return array_map('supprimer_caracteres_illegaux', $texte); |
|
| 885 | - } |
|
| 883 | + if (is_array($texte)) { |
|
| 884 | + return array_map('supprimer_caracteres_illegaux', $texte); |
|
| 885 | + } |
|
| 886 | 886 | |
| 887 | - if (!$to) { |
|
| 888 | - $to = str_repeat('-', strlen($from)); |
|
| 889 | - } |
|
| 887 | + if (!$to) { |
|
| 888 | + $to = str_repeat('-', strlen($from)); |
|
| 889 | + } |
|
| 890 | 890 | |
| 891 | - return strtr($texte, $from, $to); |
|
| 891 | + return strtr($texte, $from, $to); |
|
| 892 | 892 | } |
| 893 | 893 | |
| 894 | 894 | /** |
@@ -900,10 +900,10 @@ discard block |
||
| 900 | 900 | * @return string|array |
| 901 | 901 | **/ |
| 902 | 902 | function corriger_caracteres($texte) { |
| 903 | - $texte = corriger_caracteres_windows($texte); |
|
| 904 | - $texte = supprimer_caracteres_illegaux($texte); |
|
| 903 | + $texte = corriger_caracteres_windows($texte); |
|
| 904 | + $texte = supprimer_caracteres_illegaux($texte); |
|
| 905 | 905 | |
| 906 | - return $texte; |
|
| 906 | + return $texte; |
|
| 907 | 907 | } |
| 908 | 908 | |
| 909 | 909 | /** |
@@ -921,40 +921,40 @@ discard block |
||
| 921 | 921 | */ |
| 922 | 922 | function texte_backend($texte) { |
| 923 | 923 | |
| 924 | - static $apostrophe = array("’", "'"); # n'allouer qu'une fois |
|
| 924 | + static $apostrophe = array("’", "'"); # n'allouer qu'une fois |
|
| 925 | 925 | |
| 926 | - // si on a des liens ou des images, les passer en absolu |
|
| 927 | - $texte = liens_absolus($texte); |
|
| 926 | + // si on a des liens ou des images, les passer en absolu |
|
| 927 | + $texte = liens_absolus($texte); |
|
| 928 | 928 | |
| 929 | - // echapper les tags > < |
|
| 930 | - $texte = preg_replace(',&(gt|lt);,S', '&\1;', $texte); |
|
| 929 | + // echapper les tags > < |
|
| 930 | + $texte = preg_replace(',&(gt|lt);,S', '&\1;', $texte); |
|
| 931 | 931 | |
| 932 | - // importer les é |
|
| 933 | - $texte = filtrer_entites($texte); |
|
| 932 | + // importer les é |
|
| 933 | + $texte = filtrer_entites($texte); |
|
| 934 | 934 | |
| 935 | - // " -> " et tout ce genre de choses |
|
| 936 | - $u = $GLOBALS['meta']['pcre_u']; |
|
| 937 | - $texte = str_replace(" ", " ", $texte); |
|
| 938 | - $texte = preg_replace('/\s{2,}/S' . $u, " ", $texte); |
|
| 939 | - // ne pas echapper les sinqle quotes car certains outils de syndication gerent mal |
|
| 940 | - $texte = entites_html($texte, false, false); |
|
| 941 | - // mais bien echapper les double quotes ! |
|
| 942 | - $texte = str_replace('"', '"', $texte); |
|
| 935 | + // " -> " et tout ce genre de choses |
|
| 936 | + $u = $GLOBALS['meta']['pcre_u']; |
|
| 937 | + $texte = str_replace(" ", " ", $texte); |
|
| 938 | + $texte = preg_replace('/\s{2,}/S' . $u, " ", $texte); |
|
| 939 | + // ne pas echapper les sinqle quotes car certains outils de syndication gerent mal |
|
| 940 | + $texte = entites_html($texte, false, false); |
|
| 941 | + // mais bien echapper les double quotes ! |
|
| 942 | + $texte = str_replace('"', '"', $texte); |
|
| 943 | 943 | |
| 944 | - // verifier le charset |
|
| 945 | - $texte = charset2unicode($texte); |
|
| 944 | + // verifier le charset |
|
| 945 | + $texte = charset2unicode($texte); |
|
| 946 | 946 | |
| 947 | - // Caracteres problematiques en iso-latin 1 |
|
| 948 | - if (isset($GLOBALS['meta']['charset']) and $GLOBALS['meta']['charset'] == 'iso-8859-1') { |
|
| 949 | - $texte = str_replace(chr(156), 'œ', $texte); |
|
| 950 | - $texte = str_replace(chr(140), 'Œ', $texte); |
|
| 951 | - $texte = str_replace(chr(159), 'Ÿ', $texte); |
|
| 952 | - } |
|
| 947 | + // Caracteres problematiques en iso-latin 1 |
|
| 948 | + if (isset($GLOBALS['meta']['charset']) and $GLOBALS['meta']['charset'] == 'iso-8859-1') { |
|
| 949 | + $texte = str_replace(chr(156), 'œ', $texte); |
|
| 950 | + $texte = str_replace(chr(140), 'Œ', $texte); |
|
| 951 | + $texte = str_replace(chr(159), 'Ÿ', $texte); |
|
| 952 | + } |
|
| 953 | 953 | |
| 954 | - // l'apostrophe curly pose probleme a certains lecteure de RSS |
|
| 955 | - // et le caractere apostrophe alourdit les squelettes avec PHP |
|
| 956 | - // ==> on les remplace par l'entite HTML |
|
| 957 | - return str_replace($apostrophe, "'", $texte); |
|
| 954 | + // l'apostrophe curly pose probleme a certains lecteure de RSS |
|
| 955 | + // et le caractere apostrophe alourdit les squelettes avec PHP |
|
| 956 | + // ==> on les remplace par l'entite HTML |
|
| 957 | + return str_replace($apostrophe, "'", $texte); |
|
| 958 | 958 | } |
| 959 | 959 | |
| 960 | 960 | /** |
@@ -971,7 +971,7 @@ discard block |
||
| 971 | 971 | * Texte encodé et quote pour XML |
| 972 | 972 | */ |
| 973 | 973 | function texte_backendq($texte) { |
| 974 | - return addslashes(texte_backend($texte)); |
|
| 974 | + return addslashes(texte_backend($texte)); |
|
| 975 | 975 | } |
| 976 | 976 | |
| 977 | 977 | |
@@ -994,9 +994,9 @@ discard block |
||
| 994 | 994 | * Numéro de titre, sinon chaîne vide |
| 995 | 995 | **/ |
| 996 | 996 | function supprimer_numero($texte) { |
| 997 | - return preg_replace( |
|
| 998 | - ",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S", |
|
| 999 | - "", $texte); |
|
| 997 | + return preg_replace( |
|
| 998 | + ",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S", |
|
| 999 | + "", $texte); |
|
| 1000 | 1000 | } |
| 1001 | 1001 | |
| 1002 | 1002 | /** |
@@ -1019,13 +1019,13 @@ discard block |
||
| 1019 | 1019 | * Numéro de titre, sinon chaîne vide |
| 1020 | 1020 | **/ |
| 1021 | 1021 | function recuperer_numero($texte) { |
| 1022 | - if (preg_match( |
|
| 1023 | - ",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S", |
|
| 1024 | - $texte, $regs)) { |
|
| 1025 | - return strval($regs[1]); |
|
| 1026 | - } else { |
|
| 1027 | - return ''; |
|
| 1028 | - } |
|
| 1022 | + if (preg_match( |
|
| 1023 | + ",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S", |
|
| 1024 | + $texte, $regs)) { |
|
| 1025 | + return strval($regs[1]); |
|
| 1026 | + } else { |
|
| 1027 | + return ''; |
|
| 1028 | + } |
|
| 1029 | 1029 | } |
| 1030 | 1030 | |
| 1031 | 1031 | /** |
@@ -1052,13 +1052,13 @@ discard block |
||
| 1052 | 1052 | * Texte converti |
| 1053 | 1053 | **/ |
| 1054 | 1054 | function supprimer_tags($texte, $rempl = "") { |
| 1055 | - $texte = preg_replace(",<(!--|\w|/|!\[endif|!\[if)[^>]*>,US", $rempl, $texte); |
|
| 1056 | - // ne pas oublier un < final non ferme car coupe |
|
| 1057 | - $texte = preg_replace(",<(!--|\w|/).*$,US", $rempl, $texte); |
|
| 1058 | - // mais qui peut aussi etre un simple signe plus petit que |
|
| 1059 | - $texte = str_replace('<', '<', $texte); |
|
| 1055 | + $texte = preg_replace(",<(!--|\w|/|!\[endif|!\[if)[^>]*>,US", $rempl, $texte); |
|
| 1056 | + // ne pas oublier un < final non ferme car coupe |
|
| 1057 | + $texte = preg_replace(",<(!--|\w|/).*$,US", $rempl, $texte); |
|
| 1058 | + // mais qui peut aussi etre un simple signe plus petit que |
|
| 1059 | + $texte = str_replace('<', '<', $texte); |
|
| 1060 | 1060 | |
| 1061 | - return $texte; |
|
| 1061 | + return $texte; |
|
| 1062 | 1062 | } |
| 1063 | 1063 | |
| 1064 | 1064 | /** |
@@ -1081,9 +1081,9 @@ discard block |
||
| 1081 | 1081 | * Texte converti |
| 1082 | 1082 | **/ |
| 1083 | 1083 | function echapper_tags($texte, $rempl = "") { |
| 1084 | - $texte = preg_replace("/<([^>]*)>/", "<\\1>", $texte); |
|
| 1084 | + $texte = preg_replace("/<([^>]*)>/", "<\\1>", $texte); |
|
| 1085 | 1085 | |
| 1086 | - return $texte; |
|
| 1086 | + return $texte; |
|
| 1087 | 1087 | } |
| 1088 | 1088 | |
| 1089 | 1089 | /** |
@@ -1104,18 +1104,18 @@ discard block |
||
| 1104 | 1104 | * Texte converti |
| 1105 | 1105 | **/ |
| 1106 | 1106 | function textebrut($texte) { |
| 1107 | - $u = $GLOBALS['meta']['pcre_u']; |
|
| 1108 | - $texte = preg_replace('/\s+/S' . $u, " ", $texte); |
|
| 1109 | - $texte = preg_replace("/<(p|br)( [^>]*)?" . ">/iS", "\n\n", $texte); |
|
| 1110 | - $texte = preg_replace("/^\n+/", "", $texte); |
|
| 1111 | - $texte = preg_replace("/\n+$/", "", $texte); |
|
| 1112 | - $texte = preg_replace("/\n +/", "\n", $texte); |
|
| 1113 | - $texte = supprimer_tags($texte); |
|
| 1114 | - $texte = preg_replace("/( | )+/S", " ", $texte); |
|
| 1115 | - // nettoyer l'apostrophe curly qui pose probleme a certains rss-readers, lecteurs de mail... |
|
| 1116 | - $texte = str_replace("’", "'", $texte); |
|
| 1107 | + $u = $GLOBALS['meta']['pcre_u']; |
|
| 1108 | + $texte = preg_replace('/\s+/S' . $u, " ", $texte); |
|
| 1109 | + $texte = preg_replace("/<(p|br)( [^>]*)?" . ">/iS", "\n\n", $texte); |
|
| 1110 | + $texte = preg_replace("/^\n+/", "", $texte); |
|
| 1111 | + $texte = preg_replace("/\n+$/", "", $texte); |
|
| 1112 | + $texte = preg_replace("/\n +/", "\n", $texte); |
|
| 1113 | + $texte = supprimer_tags($texte); |
|
| 1114 | + $texte = preg_replace("/( | )+/S", " ", $texte); |
|
| 1115 | + // nettoyer l'apostrophe curly qui pose probleme a certains rss-readers, lecteurs de mail... |
|
| 1116 | + $texte = str_replace("’", "'", $texte); |
|
| 1117 | 1117 | |
| 1118 | - return $texte; |
|
| 1118 | + return $texte; |
|
| 1119 | 1119 | } |
| 1120 | 1120 | |
| 1121 | 1121 | |
@@ -1131,17 +1131,17 @@ discard block |
||
| 1131 | 1131 | * Texte avec liens ouvrants |
| 1132 | 1132 | **/ |
| 1133 | 1133 | function liens_ouvrants($texte) { |
| 1134 | - if (preg_match_all(",(<a\s+[^>]*https?://[^>]*class=[\"']spip_(out|url)\b[^>]+>),imsS", |
|
| 1135 | - $texte, $liens, PREG_PATTERN_ORDER)) { |
|
| 1136 | - foreach ($liens[0] as $a) { |
|
| 1137 | - $rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel'); |
|
| 1138 | - $ablank = inserer_attribut($a, 'rel', $rel); |
|
| 1139 | - $ablank = inserer_attribut($ablank, 'target', '_blank'); |
|
| 1140 | - $texte = str_replace($a, $ablank, $texte); |
|
| 1141 | - } |
|
| 1142 | - } |
|
| 1134 | + if (preg_match_all(",(<a\s+[^>]*https?://[^>]*class=[\"']spip_(out|url)\b[^>]+>),imsS", |
|
| 1135 | + $texte, $liens, PREG_PATTERN_ORDER)) { |
|
| 1136 | + foreach ($liens[0] as $a) { |
|
| 1137 | + $rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel'); |
|
| 1138 | + $ablank = inserer_attribut($a, 'rel', $rel); |
|
| 1139 | + $ablank = inserer_attribut($ablank, 'target', '_blank'); |
|
| 1140 | + $texte = str_replace($a, $ablank, $texte); |
|
| 1141 | + } |
|
| 1142 | + } |
|
| 1143 | 1143 | |
| 1144 | - return $texte; |
|
| 1144 | + return $texte; |
|
| 1145 | 1145 | } |
| 1146 | 1146 | |
| 1147 | 1147 | /** |
@@ -1151,22 +1151,22 @@ discard block |
||
| 1151 | 1151 | * @return string |
| 1152 | 1152 | */ |
| 1153 | 1153 | function liens_nofollow($texte) { |
| 1154 | - if (stripos($texte, "<a") === false) { |
|
| 1155 | - return $texte; |
|
| 1156 | - } |
|
| 1154 | + if (stripos($texte, "<a") === false) { |
|
| 1155 | + return $texte; |
|
| 1156 | + } |
|
| 1157 | 1157 | |
| 1158 | - if (preg_match_all(",<a\b[^>]*>,UimsS", $texte, $regs, PREG_PATTERN_ORDER)) { |
|
| 1159 | - foreach ($regs[0] as $a) { |
|
| 1160 | - $rel = extraire_attribut($a, "rel"); |
|
| 1161 | - if (strpos($rel, "nofollow") === false) { |
|
| 1162 | - $rel = "nofollow" . ($rel ? " $rel" : ""); |
|
| 1163 | - $anofollow = inserer_attribut($a, "rel", $rel); |
|
| 1164 | - $texte = str_replace($a, $anofollow, $texte); |
|
| 1165 | - } |
|
| 1166 | - } |
|
| 1167 | - } |
|
| 1158 | + if (preg_match_all(",<a\b[^>]*>,UimsS", $texte, $regs, PREG_PATTERN_ORDER)) { |
|
| 1159 | + foreach ($regs[0] as $a) { |
|
| 1160 | + $rel = extraire_attribut($a, "rel"); |
|
| 1161 | + if (strpos($rel, "nofollow") === false) { |
|
| 1162 | + $rel = "nofollow" . ($rel ? " $rel" : ""); |
|
| 1163 | + $anofollow = inserer_attribut($a, "rel", $rel); |
|
| 1164 | + $texte = str_replace($a, $anofollow, $texte); |
|
| 1165 | + } |
|
| 1166 | + } |
|
| 1167 | + } |
|
| 1168 | 1168 | |
| 1169 | - return $texte; |
|
| 1169 | + return $texte; |
|
| 1170 | 1170 | } |
| 1171 | 1171 | |
| 1172 | 1172 | /** |
@@ -1185,12 +1185,12 @@ discard block |
||
| 1185 | 1185 | * Texte sans paraghaphes |
| 1186 | 1186 | **/ |
| 1187 | 1187 | function PtoBR($texte) { |
| 1188 | - $u = $GLOBALS['meta']['pcre_u']; |
|
| 1189 | - $texte = preg_replace("@</p>@iS", "\n", $texte); |
|
| 1190 | - $texte = preg_replace("@<p\b.*>@UiS", "<br />", $texte); |
|
| 1191 | - $texte = preg_replace("@^\s*<br />@S" . $u, "", $texte); |
|
| 1188 | + $u = $GLOBALS['meta']['pcre_u']; |
|
| 1189 | + $texte = preg_replace("@</p>@iS", "\n", $texte); |
|
| 1190 | + $texte = preg_replace("@<p\b.*>@UiS", "<br />", $texte); |
|
| 1191 | + $texte = preg_replace("@^\s*<br />@S" . $u, "", $texte); |
|
| 1192 | 1192 | |
| 1193 | - return $texte; |
|
| 1193 | + return $texte; |
|
| 1194 | 1194 | } |
| 1195 | 1195 | |
| 1196 | 1196 | |
@@ -1214,14 +1214,14 @@ discard block |
||
| 1214 | 1214 | * @return string Texte encadré du style CSS |
| 1215 | 1215 | */ |
| 1216 | 1216 | function lignes_longues($texte) { |
| 1217 | - if (!strlen(trim($texte))) { |
|
| 1218 | - return $texte; |
|
| 1219 | - } |
|
| 1220 | - include_spip('inc/texte'); |
|
| 1221 | - $tag = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $texte) ? |
|
| 1222 | - 'div' : 'span'; |
|
| 1217 | + if (!strlen(trim($texte))) { |
|
| 1218 | + return $texte; |
|
| 1219 | + } |
|
| 1220 | + include_spip('inc/texte'); |
|
| 1221 | + $tag = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $texte) ? |
|
| 1222 | + 'div' : 'span'; |
|
| 1223 | 1223 | |
| 1224 | - return "<$tag style='word-wrap:break-word;'>$texte</$tag>"; |
|
| 1224 | + return "<$tag style='word-wrap:break-word;'>$texte</$tag>"; |
|
| 1225 | 1225 | } |
| 1226 | 1226 | |
| 1227 | 1227 | /** |
@@ -1240,30 +1240,30 @@ discard block |
||
| 1240 | 1240 | * @return string Texte en majuscule |
| 1241 | 1241 | */ |
| 1242 | 1242 | function majuscules($texte) { |
| 1243 | - if (!strlen($texte)) { |
|
| 1244 | - return ''; |
|
| 1245 | - } |
|
| 1243 | + if (!strlen($texte)) { |
|
| 1244 | + return ''; |
|
| 1245 | + } |
|
| 1246 | 1246 | |
| 1247 | - // Cas du turc |
|
| 1248 | - if ($GLOBALS['spip_lang'] == 'tr') { |
|
| 1249 | - # remplacer hors des tags et des entites |
|
| 1250 | - if (preg_match_all(',<[^<>]+>|&[^;]+;,S', $texte, $regs, PREG_SET_ORDER)) { |
|
| 1251 | - foreach ($regs as $n => $match) { |
|
| 1252 | - $texte = str_replace($match[0], "@@SPIP_TURC$n@@", $texte); |
|
| 1253 | - } |
|
| 1254 | - } |
|
| 1247 | + // Cas du turc |
|
| 1248 | + if ($GLOBALS['spip_lang'] == 'tr') { |
|
| 1249 | + # remplacer hors des tags et des entites |
|
| 1250 | + if (preg_match_all(',<[^<>]+>|&[^;]+;,S', $texte, $regs, PREG_SET_ORDER)) { |
|
| 1251 | + foreach ($regs as $n => $match) { |
|
| 1252 | + $texte = str_replace($match[0], "@@SPIP_TURC$n@@", $texte); |
|
| 1253 | + } |
|
| 1254 | + } |
|
| 1255 | 1255 | |
| 1256 | - $texte = str_replace('i', 'İ', $texte); |
|
| 1256 | + $texte = str_replace('i', 'İ', $texte); |
|
| 1257 | 1257 | |
| 1258 | - if ($regs) { |
|
| 1259 | - foreach ($regs as $n => $match) { |
|
| 1260 | - $texte = str_replace("@@SPIP_TURC$n@@", $match[0], $texte); |
|
| 1261 | - } |
|
| 1262 | - } |
|
| 1263 | - } |
|
| 1258 | + if ($regs) { |
|
| 1259 | + foreach ($regs as $n => $match) { |
|
| 1260 | + $texte = str_replace("@@SPIP_TURC$n@@", $match[0], $texte); |
|
| 1261 | + } |
|
| 1262 | + } |
|
| 1263 | + } |
|
| 1264 | 1264 | |
| 1265 | - // Cas general |
|
| 1266 | - return "<span style='text-transform: uppercase;'>$texte</span>"; |
|
| 1265 | + // Cas general |
|
| 1266 | + return "<span style='text-transform: uppercase;'>$texte</span>"; |
|
| 1267 | 1267 | } |
| 1268 | 1268 | |
| 1269 | 1269 | /** |
@@ -1281,29 +1281,29 @@ discard block |
||
| 1281 | 1281 | * @return string |
| 1282 | 1282 | **/ |
| 1283 | 1283 | function taille_en_octets($taille) { |
| 1284 | - if (!defined('_KILOBYTE')) { |
|
| 1285 | - /** |
|
| 1286 | - * Définit le nombre d'octets dans un Kilobyte |
|
| 1287 | - * |
|
| 1288 | - * @var int |
|
| 1289 | - **/ |
|
| 1290 | - define('_KILOBYTE', 1024); |
|
| 1291 | - } |
|
| 1284 | + if (!defined('_KILOBYTE')) { |
|
| 1285 | + /** |
|
| 1286 | + * Définit le nombre d'octets dans un Kilobyte |
|
| 1287 | + * |
|
| 1288 | + * @var int |
|
| 1289 | + **/ |
|
| 1290 | + define('_KILOBYTE', 1024); |
|
| 1291 | + } |
|
| 1292 | 1292 | |
| 1293 | - if ($taille < 1) { |
|
| 1294 | - return ''; |
|
| 1295 | - } |
|
| 1296 | - if ($taille < _KILOBYTE) { |
|
| 1297 | - $taille = _T('taille_octets', array('taille' => $taille)); |
|
| 1298 | - } elseif ($taille < _KILOBYTE * _KILOBYTE) { |
|
| 1299 | - $taille = _T('taille_ko', array('taille' => round($taille / _KILOBYTE, 1))); |
|
| 1300 | - } elseif ($taille < _KILOBYTE * _KILOBYTE * _KILOBYTE) { |
|
| 1301 | - $taille = _T('taille_mo', array('taille' => round($taille / _KILOBYTE / _KILOBYTE, 1))); |
|
| 1302 | - } else { |
|
| 1303 | - $taille = _T('taille_go', array('taille' => round($taille / _KILOBYTE / _KILOBYTE / _KILOBYTE, 2))); |
|
| 1304 | - } |
|
| 1293 | + if ($taille < 1) { |
|
| 1294 | + return ''; |
|
| 1295 | + } |
|
| 1296 | + if ($taille < _KILOBYTE) { |
|
| 1297 | + $taille = _T('taille_octets', array('taille' => $taille)); |
|
| 1298 | + } elseif ($taille < _KILOBYTE * _KILOBYTE) { |
|
| 1299 | + $taille = _T('taille_ko', array('taille' => round($taille / _KILOBYTE, 1))); |
|
| 1300 | + } elseif ($taille < _KILOBYTE * _KILOBYTE * _KILOBYTE) { |
|
| 1301 | + $taille = _T('taille_mo', array('taille' => round($taille / _KILOBYTE / _KILOBYTE, 1))); |
|
| 1302 | + } else { |
|
| 1303 | + $taille = _T('taille_go', array('taille' => round($taille / _KILOBYTE / _KILOBYTE / _KILOBYTE, 2))); |
|
| 1304 | + } |
|
| 1305 | 1305 | |
| 1306 | - return $taille; |
|
| 1306 | + return $taille; |
|
| 1307 | 1307 | } |
| 1308 | 1308 | |
| 1309 | 1309 | |
@@ -1325,15 +1325,15 @@ discard block |
||
| 1325 | 1325 | * Texte prêt pour être utilisé en attribut HTML |
| 1326 | 1326 | **/ |
| 1327 | 1327 | function attribut_html($texte, $textebrut = true) { |
| 1328 | - $u = $GLOBALS['meta']['pcre_u']; |
|
| 1329 | - if ($textebrut) { |
|
| 1330 | - $texte = preg_replace(array(",\n,", ",\s(?=\s),msS" . $u), array(" ", ""), textebrut($texte)); |
|
| 1331 | - } |
|
| 1332 | - $texte = texte_backend($texte); |
|
| 1333 | - $texte = str_replace(array("'", '"'), array(''', '"'), $texte); |
|
| 1328 | + $u = $GLOBALS['meta']['pcre_u']; |
|
| 1329 | + if ($textebrut) { |
|
| 1330 | + $texte = preg_replace(array(",\n,", ",\s(?=\s),msS" . $u), array(" ", ""), textebrut($texte)); |
|
| 1331 | + } |
|
| 1332 | + $texte = texte_backend($texte); |
|
| 1333 | + $texte = str_replace(array("'", '"'), array(''', '"'), $texte); |
|
| 1334 | 1334 | |
| 1335 | - return preg_replace(array("/&(amp;|#38;)/", "/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,5};)/"), array("&", "&"), |
|
| 1336 | - $texte); |
|
| 1335 | + return preg_replace(array("/&(amp;|#38;)/", "/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,5};)/"), array("&", "&"), |
|
| 1336 | + $texte); |
|
| 1337 | 1337 | } |
| 1338 | 1338 | |
| 1339 | 1339 | |
@@ -1353,12 +1353,12 @@ discard block |
||
| 1353 | 1353 | * URL ou chaîne vide |
| 1354 | 1354 | **/ |
| 1355 | 1355 | function vider_url($url, $entites = true) { |
| 1356 | - # un message pour abs_url |
|
| 1357 | - $GLOBALS['mode_abs_url'] = 'url'; |
|
| 1358 | - $url = trim($url); |
|
| 1359 | - $r = ",^(?:" . _PROTOCOLES_STD . '):?/?/?$,iS'; |
|
| 1356 | + # un message pour abs_url |
|
| 1357 | + $GLOBALS['mode_abs_url'] = 'url'; |
|
| 1358 | + $url = trim($url); |
|
| 1359 | + $r = ",^(?:" . _PROTOCOLES_STD . '):?/?/?$,iS'; |
|
| 1360 | 1360 | |
| 1361 | - return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url); |
|
| 1361 | + return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url); |
|
| 1362 | 1362 | } |
| 1363 | 1363 | |
| 1364 | 1364 | |
@@ -1373,10 +1373,10 @@ discard block |
||
| 1373 | 1373 | * @return string Adresse email maquillée |
| 1374 | 1374 | **/ |
| 1375 | 1375 | function antispam($texte) { |
| 1376 | - include_spip('inc/acces'); |
|
| 1377 | - $masque = creer_pass_aleatoire(3); |
|
| 1376 | + include_spip('inc/acces'); |
|
| 1377 | + $masque = creer_pass_aleatoire(3); |
|
| 1378 | 1378 | |
| 1379 | - return preg_replace("/@/", " $masque ", $texte); |
|
| 1379 | + return preg_replace("/@/", " $masque ", $texte); |
|
| 1380 | 1380 | } |
| 1381 | 1381 | |
| 1382 | 1382 | /** |
@@ -1408,12 +1408,12 @@ discard block |
||
| 1408 | 1408 | * True si on a le droit d'accès, false sinon. |
| 1409 | 1409 | **/ |
| 1410 | 1410 | function securiser_acces($id_auteur, $cle, $dir, $op = '', $args = '') { |
| 1411 | - include_spip('inc/acces'); |
|
| 1412 | - if ($op) { |
|
| 1413 | - $dir .= " $op $args"; |
|
| 1414 | - } |
|
| 1411 | + include_spip('inc/acces'); |
|
| 1412 | + if ($op) { |
|
| 1413 | + $dir .= " $op $args"; |
|
| 1414 | + } |
|
| 1415 | 1415 | |
| 1416 | - return verifier_low_sec($id_auteur, $cle, $dir); |
|
| 1416 | + return verifier_low_sec($id_auteur, $cle, $dir); |
|
| 1417 | 1417 | } |
| 1418 | 1418 | |
| 1419 | 1419 | /** |
@@ -1438,11 +1438,11 @@ discard block |
||
| 1438 | 1438 | * Retourne $texte, sinon $sinon. |
| 1439 | 1439 | **/ |
| 1440 | 1440 | function sinon($texte, $sinon = '') { |
| 1441 | - if ($texte or (!is_array($texte) and strlen($texte))) { |
|
| 1442 | - return $texte; |
|
| 1443 | - } else { |
|
| 1444 | - return $sinon; |
|
| 1445 | - } |
|
| 1441 | + if ($texte or (!is_array($texte) and strlen($texte))) { |
|
| 1442 | + return $texte; |
|
| 1443 | + } else { |
|
| 1444 | + return $sinon; |
|
| 1445 | + } |
|
| 1446 | 1446 | } |
| 1447 | 1447 | |
| 1448 | 1448 | /** |
@@ -1466,7 +1466,7 @@ discard block |
||
| 1466 | 1466 | * @return mixed |
| 1467 | 1467 | **/ |
| 1468 | 1468 | function choixsivide($a, $vide, $pasvide) { |
| 1469 | - return $a ? $pasvide : $vide; |
|
| 1469 | + return $a ? $pasvide : $vide; |
|
| 1470 | 1470 | } |
| 1471 | 1471 | |
| 1472 | 1472 | /** |
@@ -1490,7 +1490,7 @@ discard block |
||
| 1490 | 1490 | * @return mixed |
| 1491 | 1491 | **/ |
| 1492 | 1492 | function choixsiegal($a1, $a2, $v, $f) { |
| 1493 | - return ($a1 == $a2) ? $v : $f; |
|
| 1493 | + return ($a1 == $a2) ? $v : $f; |
|
| 1494 | 1494 | } |
| 1495 | 1495 | |
| 1496 | 1496 | // |
@@ -1509,13 +1509,13 @@ discard block |
||
| 1509 | 1509 | * @return string |
| 1510 | 1510 | **/ |
| 1511 | 1511 | function filtrer_ical($texte) { |
| 1512 | - #include_spip('inc/charsets'); |
|
| 1513 | - $texte = html2unicode($texte); |
|
| 1514 | - $texte = unicode2charset(charset2unicode($texte, $GLOBALS['meta']['charset'], 1), 'utf-8'); |
|
| 1515 | - $texte = preg_replace("/\n/", " ", $texte); |
|
| 1516 | - $texte = preg_replace("/,/", "\,", $texte); |
|
| 1512 | + #include_spip('inc/charsets'); |
|
| 1513 | + $texte = html2unicode($texte); |
|
| 1514 | + $texte = unicode2charset(charset2unicode($texte, $GLOBALS['meta']['charset'], 1), 'utf-8'); |
|
| 1515 | + $texte = preg_replace("/\n/", " ", $texte); |
|
| 1516 | + $texte = preg_replace("/,/", "\,", $texte); |
|
| 1517 | 1517 | |
| 1518 | - return $texte; |
|
| 1518 | + return $texte; |
|
| 1519 | 1519 | } |
| 1520 | 1520 | |
| 1521 | 1521 | |
@@ -1540,53 +1540,53 @@ discard block |
||
| 1540 | 1540 | * @return string |
| 1541 | 1541 | **/ |
| 1542 | 1542 | function post_autobr($texte, $delim = "\n_ ") { |
| 1543 | - if (!function_exists('echappe_html')) { |
|
| 1544 | - include_spip('inc/texte_mini'); |
|
| 1545 | - } |
|
| 1546 | - $texte = str_replace("\r\n", "\r", $texte); |
|
| 1547 | - $texte = str_replace("\r", "\n", $texte); |
|
| 1548 | - |
|
| 1549 | - if (preg_match(",\n+$,", $texte, $fin)) { |
|
| 1550 | - $texte = substr($texte, 0, -strlen($fin = $fin[0])); |
|
| 1551 | - } else { |
|
| 1552 | - $fin = ''; |
|
| 1553 | - } |
|
| 1554 | - |
|
| 1555 | - $texte = echappe_html($texte, '', true); |
|
| 1556 | - |
|
| 1557 | - // echapper les modeles |
|
| 1558 | - if (strpos($texte, "<") !== false) { |
|
| 1559 | - include_spip('inc/lien'); |
|
| 1560 | - if (defined('_PREG_MODELE')) { |
|
| 1561 | - $preg_modeles = "@" . _PREG_MODELE . "@imsS"; |
|
| 1562 | - $texte = echappe_html($texte, '', true, $preg_modeles); |
|
| 1563 | - } |
|
| 1564 | - } |
|
| 1565 | - |
|
| 1566 | - $debut = ''; |
|
| 1567 | - $suite = $texte; |
|
| 1568 | - while ($t = strpos('-' . $suite, "\n", 1)) { |
|
| 1569 | - $debut .= substr($suite, 0, $t - 1); |
|
| 1570 | - $suite = substr($suite, $t); |
|
| 1571 | - $car = substr($suite, 0, 1); |
|
| 1572 | - if (($car <> '-') and ($car <> '_') and ($car <> "\n") and ($car <> "|") and ($car <> "}") |
|
| 1573 | - and !preg_match(',^\s*(\n|</?(quote|div|dl|dt|dd)|$),S', ($suite)) |
|
| 1574 | - and !preg_match(',</?(quote|div|dl|dt|dd)> *$,iS', $debut) |
|
| 1575 | - ) { |
|
| 1576 | - $debut .= $delim; |
|
| 1577 | - } else { |
|
| 1578 | - $debut .= "\n"; |
|
| 1579 | - } |
|
| 1580 | - if (preg_match(",^\n+,", $suite, $regs)) { |
|
| 1581 | - $debut .= $regs[0]; |
|
| 1582 | - $suite = substr($suite, strlen($regs[0])); |
|
| 1583 | - } |
|
| 1584 | - } |
|
| 1585 | - $texte = $debut . $suite; |
|
| 1586 | - |
|
| 1587 | - $texte = echappe_retour($texte); |
|
| 1588 | - |
|
| 1589 | - return $texte . $fin; |
|
| 1543 | + if (!function_exists('echappe_html')) { |
|
| 1544 | + include_spip('inc/texte_mini'); |
|
| 1545 | + } |
|
| 1546 | + $texte = str_replace("\r\n", "\r", $texte); |
|
| 1547 | + $texte = str_replace("\r", "\n", $texte); |
|
| 1548 | + |
|
| 1549 | + if (preg_match(",\n+$,", $texte, $fin)) { |
|
| 1550 | + $texte = substr($texte, 0, -strlen($fin = $fin[0])); |
|
| 1551 | + } else { |
|
| 1552 | + $fin = ''; |
|
| 1553 | + } |
|
| 1554 | + |
|
| 1555 | + $texte = echappe_html($texte, '', true); |
|
| 1556 | + |
|
| 1557 | + // echapper les modeles |
|
| 1558 | + if (strpos($texte, "<") !== false) { |
|
| 1559 | + include_spip('inc/lien'); |
|
| 1560 | + if (defined('_PREG_MODELE')) { |
|
| 1561 | + $preg_modeles = "@" . _PREG_MODELE . "@imsS"; |
|
| 1562 | + $texte = echappe_html($texte, '', true, $preg_modeles); |
|
| 1563 | + } |
|
| 1564 | + } |
|
| 1565 | + |
|
| 1566 | + $debut = ''; |
|
| 1567 | + $suite = $texte; |
|
| 1568 | + while ($t = strpos('-' . $suite, "\n", 1)) { |
|
| 1569 | + $debut .= substr($suite, 0, $t - 1); |
|
| 1570 | + $suite = substr($suite, $t); |
|
| 1571 | + $car = substr($suite, 0, 1); |
|
| 1572 | + if (($car <> '-') and ($car <> '_') and ($car <> "\n") and ($car <> "|") and ($car <> "}") |
|
| 1573 | + and !preg_match(',^\s*(\n|</?(quote|div|dl|dt|dd)|$),S', ($suite)) |
|
| 1574 | + and !preg_match(',</?(quote|div|dl|dt|dd)> *$,iS', $debut) |
|
| 1575 | + ) { |
|
| 1576 | + $debut .= $delim; |
|
| 1577 | + } else { |
|
| 1578 | + $debut .= "\n"; |
|
| 1579 | + } |
|
| 1580 | + if (preg_match(",^\n+,", $suite, $regs)) { |
|
| 1581 | + $debut .= $regs[0]; |
|
| 1582 | + $suite = substr($suite, strlen($regs[0])); |
|
| 1583 | + } |
|
| 1584 | + } |
|
| 1585 | + $texte = $debut . $suite; |
|
| 1586 | + |
|
| 1587 | + $texte = echappe_retour($texte); |
|
| 1588 | + |
|
| 1589 | + return $texte . $fin; |
|
| 1590 | 1590 | } |
| 1591 | 1591 | |
| 1592 | 1592 | |
@@ -1627,46 +1627,46 @@ discard block |
||
| 1627 | 1627 | * @return string |
| 1628 | 1628 | **/ |
| 1629 | 1629 | function extraire_idiome($letexte, $lang = null, $options = array()) { |
| 1630 | - static $traduire = false; |
|
| 1631 | - if ($letexte |
|
| 1632 | - and preg_match_all(_EXTRAIRE_IDIOME, $letexte, $regs, PREG_SET_ORDER) |
|
| 1633 | - ) { |
|
| 1634 | - if (!$traduire) { |
|
| 1635 | - $traduire = charger_fonction('traduire', 'inc'); |
|
| 1636 | - include_spip('inc/lang'); |
|
| 1637 | - } |
|
| 1638 | - if (!$lang) { |
|
| 1639 | - $lang = $GLOBALS['spip_lang']; |
|
| 1640 | - } |
|
| 1641 | - // Compatibilité avec le prototype de fonction précédente qui utilisait un boolean |
|
| 1642 | - if (is_bool($options)) { |
|
| 1643 | - $options = array('echappe_span' => $options); |
|
| 1644 | - } |
|
| 1645 | - if (!isset($options['echappe_span'])) { |
|
| 1646 | - $options = array_merge($options, array('echappe_span' => false)); |
|
| 1647 | - } |
|
| 1648 | - |
|
| 1649 | - foreach ($regs as $reg) { |
|
| 1650 | - $cle = ($reg[1] ? $reg[1] . ':' : '') . $reg[2]; |
|
| 1651 | - $desc = $traduire($cle, $lang, true); |
|
| 1652 | - $l = $desc->langue; |
|
| 1653 | - // si pas de traduction, on laissera l'écriture de l'idiome entier dans le texte. |
|
| 1654 | - if (strlen($desc->texte)) { |
|
| 1655 | - $trad = code_echappement($desc->texte, 'idiome', false); |
|
| 1656 | - if ($l !== $lang) { |
|
| 1657 | - $trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l)); |
|
| 1658 | - } |
|
| 1659 | - if (lang_dir($l) !== lang_dir($lang)) { |
|
| 1660 | - $trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l))); |
|
| 1661 | - } |
|
| 1662 | - if (!$options['echappe_span']) { |
|
| 1663 | - $trad = echappe_retour($trad, 'idiome'); |
|
| 1664 | - } |
|
| 1665 | - $letexte = str_replace($reg[0], $trad, $letexte); |
|
| 1666 | - } |
|
| 1667 | - } |
|
| 1668 | - } |
|
| 1669 | - return $letexte; |
|
| 1630 | + static $traduire = false; |
|
| 1631 | + if ($letexte |
|
| 1632 | + and preg_match_all(_EXTRAIRE_IDIOME, $letexte, $regs, PREG_SET_ORDER) |
|
| 1633 | + ) { |
|
| 1634 | + if (!$traduire) { |
|
| 1635 | + $traduire = charger_fonction('traduire', 'inc'); |
|
| 1636 | + include_spip('inc/lang'); |
|
| 1637 | + } |
|
| 1638 | + if (!$lang) { |
|
| 1639 | + $lang = $GLOBALS['spip_lang']; |
|
| 1640 | + } |
|
| 1641 | + // Compatibilité avec le prototype de fonction précédente qui utilisait un boolean |
|
| 1642 | + if (is_bool($options)) { |
|
| 1643 | + $options = array('echappe_span' => $options); |
|
| 1644 | + } |
|
| 1645 | + if (!isset($options['echappe_span'])) { |
|
| 1646 | + $options = array_merge($options, array('echappe_span' => false)); |
|
| 1647 | + } |
|
| 1648 | + |
|
| 1649 | + foreach ($regs as $reg) { |
|
| 1650 | + $cle = ($reg[1] ? $reg[1] . ':' : '') . $reg[2]; |
|
| 1651 | + $desc = $traduire($cle, $lang, true); |
|
| 1652 | + $l = $desc->langue; |
|
| 1653 | + // si pas de traduction, on laissera l'écriture de l'idiome entier dans le texte. |
|
| 1654 | + if (strlen($desc->texte)) { |
|
| 1655 | + $trad = code_echappement($desc->texte, 'idiome', false); |
|
| 1656 | + if ($l !== $lang) { |
|
| 1657 | + $trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l)); |
|
| 1658 | + } |
|
| 1659 | + if (lang_dir($l) !== lang_dir($lang)) { |
|
| 1660 | + $trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l))); |
|
| 1661 | + } |
|
| 1662 | + if (!$options['echappe_span']) { |
|
| 1663 | + $trad = echappe_retour($trad, 'idiome'); |
|
| 1664 | + } |
|
| 1665 | + $letexte = str_replace($reg[0], $trad, $letexte); |
|
| 1666 | + } |
|
| 1667 | + } |
|
| 1668 | + } |
|
| 1669 | + return $letexte; |
|
| 1670 | 1670 | } |
| 1671 | 1671 | |
| 1672 | 1672 | /** |
@@ -1718,67 +1718,67 @@ discard block |
||
| 1718 | 1718 | **/ |
| 1719 | 1719 | function extraire_multi($letexte, $lang = null, $options = array()) { |
| 1720 | 1720 | |
| 1721 | - if ($letexte |
|
| 1722 | - and preg_match_all(_EXTRAIRE_MULTI, $letexte, $regs, PREG_SET_ORDER) |
|
| 1723 | - ) { |
|
| 1724 | - if (!$lang) { |
|
| 1725 | - $lang = $GLOBALS['spip_lang']; |
|
| 1726 | - } |
|
| 1727 | - |
|
| 1728 | - // Compatibilité avec le prototype de fonction précédente qui utilisait un boolean |
|
| 1729 | - if (is_bool($options)) { |
|
| 1730 | - $options = array('echappe_span' => $options, 'lang_defaut' => _LANGUE_PAR_DEFAUT); |
|
| 1731 | - } |
|
| 1732 | - if (!isset($options['echappe_span'])) { |
|
| 1733 | - $options = array_merge($options, array('echappe_span' => false)); |
|
| 1734 | - } |
|
| 1735 | - if (!isset($options['lang_defaut'])) { |
|
| 1736 | - $options = array_merge($options, array('lang_defaut' => _LANGUE_PAR_DEFAUT)); |
|
| 1737 | - } |
|
| 1738 | - |
|
| 1739 | - include_spip('inc/lang'); |
|
| 1740 | - foreach ($regs as $reg) { |
|
| 1741 | - // chercher la version de la langue courante |
|
| 1742 | - $trads = extraire_trads($reg[1]); |
|
| 1743 | - if ($l = approcher_langue($trads, $lang)) { |
|
| 1744 | - $trad = $trads[$l]; |
|
| 1745 | - } else { |
|
| 1746 | - if ($options['lang_defaut'] == 'aucune') { |
|
| 1747 | - $trad = ''; |
|
| 1748 | - } else { |
|
| 1749 | - // langue absente, prendre le fr ou une langue précisée (meme comportement que inc/traduire.php) |
|
| 1750 | - // ou la premiere dispo |
|
| 1751 | - // mais typographier le texte selon les regles de celle-ci |
|
| 1752 | - // Attention aux blocs multi sur plusieurs lignes |
|
| 1753 | - if (!$l = approcher_langue($trads, $options['lang_defaut'])) { |
|
| 1754 | - $l = key($trads); |
|
| 1755 | - } |
|
| 1756 | - $trad = $trads[$l]; |
|
| 1757 | - $typographie = charger_fonction(lang_typo($l), 'typographie'); |
|
| 1758 | - $trad = $typographie($trad); |
|
| 1759 | - // Tester si on echappe en span ou en div |
|
| 1760 | - // il ne faut pas echapper en div si propre produit un seul paragraphe |
|
| 1761 | - include_spip('inc/texte'); |
|
| 1762 | - $trad_propre = preg_replace(",(^<p[^>]*>|</p>$),Uims", "", propre($trad)); |
|
| 1763 | - $mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $trad_propre) ? 'div' : 'span'; |
|
| 1764 | - if ($mode === 'div') { |
|
| 1765 | - $trad = rtrim($trad) . "\n\n"; |
|
| 1766 | - } |
|
| 1767 | - $trad = code_echappement($trad, 'multi', false, $mode); |
|
| 1768 | - $trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l)); |
|
| 1769 | - if (lang_dir($l) !== lang_dir($lang)) { |
|
| 1770 | - $trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l))); |
|
| 1771 | - } |
|
| 1772 | - if (!$options['echappe_span']) { |
|
| 1773 | - $trad = echappe_retour($trad, 'multi'); |
|
| 1774 | - } |
|
| 1775 | - } |
|
| 1776 | - } |
|
| 1777 | - $letexte = str_replace($reg[0], $trad, $letexte); |
|
| 1778 | - } |
|
| 1779 | - } |
|
| 1780 | - |
|
| 1781 | - return $letexte; |
|
| 1721 | + if ($letexte |
|
| 1722 | + and preg_match_all(_EXTRAIRE_MULTI, $letexte, $regs, PREG_SET_ORDER) |
|
| 1723 | + ) { |
|
| 1724 | + if (!$lang) { |
|
| 1725 | + $lang = $GLOBALS['spip_lang']; |
|
| 1726 | + } |
|
| 1727 | + |
|
| 1728 | + // Compatibilité avec le prototype de fonction précédente qui utilisait un boolean |
|
| 1729 | + if (is_bool($options)) { |
|
| 1730 | + $options = array('echappe_span' => $options, 'lang_defaut' => _LANGUE_PAR_DEFAUT); |
|
| 1731 | + } |
|
| 1732 | + if (!isset($options['echappe_span'])) { |
|
| 1733 | + $options = array_merge($options, array('echappe_span' => false)); |
|
| 1734 | + } |
|
| 1735 | + if (!isset($options['lang_defaut'])) { |
|
| 1736 | + $options = array_merge($options, array('lang_defaut' => _LANGUE_PAR_DEFAUT)); |
|
| 1737 | + } |
|
| 1738 | + |
|
| 1739 | + include_spip('inc/lang'); |
|
| 1740 | + foreach ($regs as $reg) { |
|
| 1741 | + // chercher la version de la langue courante |
|
| 1742 | + $trads = extraire_trads($reg[1]); |
|
| 1743 | + if ($l = approcher_langue($trads, $lang)) { |
|
| 1744 | + $trad = $trads[$l]; |
|
| 1745 | + } else { |
|
| 1746 | + if ($options['lang_defaut'] == 'aucune') { |
|
| 1747 | + $trad = ''; |
|
| 1748 | + } else { |
|
| 1749 | + // langue absente, prendre le fr ou une langue précisée (meme comportement que inc/traduire.php) |
|
| 1750 | + // ou la premiere dispo |
|
| 1751 | + // mais typographier le texte selon les regles de celle-ci |
|
| 1752 | + // Attention aux blocs multi sur plusieurs lignes |
|
| 1753 | + if (!$l = approcher_langue($trads, $options['lang_defaut'])) { |
|
| 1754 | + $l = key($trads); |
|
| 1755 | + } |
|
| 1756 | + $trad = $trads[$l]; |
|
| 1757 | + $typographie = charger_fonction(lang_typo($l), 'typographie'); |
|
| 1758 | + $trad = $typographie($trad); |
|
| 1759 | + // Tester si on echappe en span ou en div |
|
| 1760 | + // il ne faut pas echapper en div si propre produit un seul paragraphe |
|
| 1761 | + include_spip('inc/texte'); |
|
| 1762 | + $trad_propre = preg_replace(",(^<p[^>]*>|</p>$),Uims", "", propre($trad)); |
|
| 1763 | + $mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $trad_propre) ? 'div' : 'span'; |
|
| 1764 | + if ($mode === 'div') { |
|
| 1765 | + $trad = rtrim($trad) . "\n\n"; |
|
| 1766 | + } |
|
| 1767 | + $trad = code_echappement($trad, 'multi', false, $mode); |
|
| 1768 | + $trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l)); |
|
| 1769 | + if (lang_dir($l) !== lang_dir($lang)) { |
|
| 1770 | + $trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l))); |
|
| 1771 | + } |
|
| 1772 | + if (!$options['echappe_span']) { |
|
| 1773 | + $trad = echappe_retour($trad, 'multi'); |
|
| 1774 | + } |
|
| 1775 | + } |
|
| 1776 | + } |
|
| 1777 | + $letexte = str_replace($reg[0], $trad, $letexte); |
|
| 1778 | + } |
|
| 1779 | + } |
|
| 1780 | + |
|
| 1781 | + return $letexte; |
|
| 1782 | 1782 | } |
| 1783 | 1783 | |
| 1784 | 1784 | /** |
@@ -1794,20 +1794,20 @@ discard block |
||
| 1794 | 1794 | * Peut retourner un code de langue vide, lorsqu'un texte par défaut est indiqué. |
| 1795 | 1795 | **/ |
| 1796 | 1796 | function extraire_trads($bloc) { |
| 1797 | - $lang = ''; |
|
| 1797 | + $lang = ''; |
|
| 1798 | 1798 | // ce reg fait planter l'analyse multi s'il y a de l'{italique} dans le champ |
| 1799 | 1799 | // while (preg_match("/^(.*?)[{\[]([a-z_]+)[}\]]/siS", $bloc, $regs)) { |
| 1800 | - while (preg_match("/^(.*?)[\[]([a-z_]+)[\]]/siS", $bloc, $regs)) { |
|
| 1801 | - $texte = trim($regs[1]); |
|
| 1802 | - if ($texte or $lang) { |
|
| 1803 | - $trads[$lang] = $texte; |
|
| 1804 | - } |
|
| 1805 | - $bloc = substr($bloc, strlen($regs[0])); |
|
| 1806 | - $lang = $regs[2]; |
|
| 1807 | - } |
|
| 1808 | - $trads[$lang] = $bloc; |
|
| 1800 | + while (preg_match("/^(.*?)[\[]([a-z_]+)[\]]/siS", $bloc, $regs)) { |
|
| 1801 | + $texte = trim($regs[1]); |
|
| 1802 | + if ($texte or $lang) { |
|
| 1803 | + $trads[$lang] = $texte; |
|
| 1804 | + } |
|
| 1805 | + $bloc = substr($bloc, strlen($regs[0])); |
|
| 1806 | + $lang = $regs[2]; |
|
| 1807 | + } |
|
| 1808 | + $trads[$lang] = $bloc; |
|
| 1809 | 1809 | |
| 1810 | - return $trads; |
|
| 1810 | + return $trads; |
|
| 1811 | 1811 | } |
| 1812 | 1812 | |
| 1813 | 1813 | |
@@ -1818,7 +1818,7 @@ discard block |
||
| 1818 | 1818 | * @return string L'initiale en majuscule |
| 1819 | 1819 | */ |
| 1820 | 1820 | function filtre_initiale($nom) { |
| 1821 | - return spip_substr(trim(strtoupper(extraire_multi($nom))), 0, 1); |
|
| 1821 | + return spip_substr(trim(strtoupper(extraire_multi($nom))), 0, 1); |
|
| 1822 | 1822 | } |
| 1823 | 1823 | |
| 1824 | 1824 | |
@@ -1863,33 +1863,33 @@ discard block |
||
| 1863 | 1863 | * - null (interne) : si on empile |
| 1864 | 1864 | **/ |
| 1865 | 1865 | function unique($donnee, $famille = '', $cpt = false) { |
| 1866 | - static $mem = array(); |
|
| 1867 | - // permettre de vider la pile et de la restaurer |
|
| 1868 | - // pour le calcul de introduction... |
|
| 1869 | - if ($famille == '_spip_raz_') { |
|
| 1870 | - $tmp = $mem; |
|
| 1871 | - $mem = array(); |
|
| 1872 | - |
|
| 1873 | - return $tmp; |
|
| 1874 | - } elseif ($famille == '_spip_set_') { |
|
| 1875 | - $mem = $donnee; |
|
| 1876 | - |
|
| 1877 | - return; |
|
| 1878 | - } |
|
| 1879 | - // eviter une notice |
|
| 1880 | - if (!isset($mem[$famille])) { |
|
| 1881 | - $mem[$famille] = array(); |
|
| 1882 | - } |
|
| 1883 | - if ($cpt) { |
|
| 1884 | - return count($mem[$famille]); |
|
| 1885 | - } |
|
| 1886 | - // eviter une notice |
|
| 1887 | - if (!isset($mem[$famille][$donnee])) { |
|
| 1888 | - $mem[$famille][$donnee] = 0; |
|
| 1889 | - } |
|
| 1890 | - if (!($mem[$famille][$donnee]++)) { |
|
| 1891 | - return $donnee; |
|
| 1892 | - } |
|
| 1866 | + static $mem = array(); |
|
| 1867 | + // permettre de vider la pile et de la restaurer |
|
| 1868 | + // pour le calcul de introduction... |
|
| 1869 | + if ($famille == '_spip_raz_') { |
|
| 1870 | + $tmp = $mem; |
|
| 1871 | + $mem = array(); |
|
| 1872 | + |
|
| 1873 | + return $tmp; |
|
| 1874 | + } elseif ($famille == '_spip_set_') { |
|
| 1875 | + $mem = $donnee; |
|
| 1876 | + |
|
| 1877 | + return; |
|
| 1878 | + } |
|
| 1879 | + // eviter une notice |
|
| 1880 | + if (!isset($mem[$famille])) { |
|
| 1881 | + $mem[$famille] = array(); |
|
| 1882 | + } |
|
| 1883 | + if ($cpt) { |
|
| 1884 | + return count($mem[$famille]); |
|
| 1885 | + } |
|
| 1886 | + // eviter une notice |
|
| 1887 | + if (!isset($mem[$famille][$donnee])) { |
|
| 1888 | + $mem[$famille][$donnee] = 0; |
|
| 1889 | + } |
|
| 1890 | + if (!($mem[$famille][$donnee]++)) { |
|
| 1891 | + return $donnee; |
|
| 1892 | + } |
|
| 1893 | 1893 | } |
| 1894 | 1894 | |
| 1895 | 1895 | |
@@ -1917,18 +1917,18 @@ discard block |
||
| 1917 | 1917 | * Une des valeurs en fonction du compteur. |
| 1918 | 1918 | **/ |
| 1919 | 1919 | function alterner($i) { |
| 1920 | - // recuperer les arguments (attention fonctions un peu space) |
|
| 1921 | - $num = func_num_args(); |
|
| 1922 | - $args = func_get_args(); |
|
| 1920 | + // recuperer les arguments (attention fonctions un peu space) |
|
| 1921 | + $num = func_num_args(); |
|
| 1922 | + $args = func_get_args(); |
|
| 1923 | 1923 | |
| 1924 | - if ($num == 2 && is_array($args[1])) { |
|
| 1925 | - $args = $args[1]; |
|
| 1926 | - array_unshift($args, ''); |
|
| 1927 | - $num = count($args); |
|
| 1928 | - } |
|
| 1924 | + if ($num == 2 && is_array($args[1])) { |
|
| 1925 | + $args = $args[1]; |
|
| 1926 | + array_unshift($args, ''); |
|
| 1927 | + $num = count($args); |
|
| 1928 | + } |
|
| 1929 | 1929 | |
| 1930 | - // renvoyer le i-ieme argument, modulo le nombre d'arguments |
|
| 1931 | - return $args[(intval($i) - 1) % ($num - 1) + 1]; |
|
| 1930 | + // renvoyer le i-ieme argument, modulo le nombre d'arguments |
|
| 1931 | + return $args[(intval($i) - 1) % ($num - 1) + 1]; |
|
| 1932 | 1932 | } |
| 1933 | 1933 | |
| 1934 | 1934 | |
@@ -1953,46 +1953,46 @@ discard block |
||
| 1953 | 1953 | * - Tableau complet (si 2e argument) |
| 1954 | 1954 | **/ |
| 1955 | 1955 | function extraire_attribut($balise, $attribut, $complet = false) { |
| 1956 | - if (is_array($balise)) { |
|
| 1957 | - array_walk( |
|
| 1958 | - $balise, |
|
| 1959 | - function(&$a, $key, $t){ |
|
| 1960 | - $a = extraire_attribut($a, $t); |
|
| 1961 | - }, |
|
| 1962 | - $attribut |
|
| 1963 | - ); |
|
| 1964 | - |
|
| 1965 | - return $balise; |
|
| 1966 | - } |
|
| 1967 | - if (preg_match( |
|
| 1968 | - ',(^.*?<(?:(?>\s*)(?>[\w:.-]+)(?>(?:=(?:"[^"]*"|\'[^\']*\'|[^\'"]\S*))?))*?)(\s+' |
|
| 1969 | - . $attribut |
|
| 1970 | - . '(?:=\s*("[^"]*"|\'[^\']*\'|[^\'"]\S*))?)()((?:[\s/][^>]*)?>.*),isS', |
|
| 1971 | - |
|
| 1972 | - $balise, $r)) { |
|
| 1973 | - if (isset($r[3][0]) and ($r[3][0] == '"' || $r[3][0] == "'")) { |
|
| 1974 | - $r[4] = substr($r[3], 1, -1); |
|
| 1975 | - $r[3] = $r[3][0]; |
|
| 1976 | - } elseif ($r[3] !== '') { |
|
| 1977 | - $r[4] = $r[3]; |
|
| 1978 | - $r[3] = ''; |
|
| 1979 | - } else { |
|
| 1980 | - $r[4] = trim($r[2]); |
|
| 1981 | - } |
|
| 1982 | - $att = $r[4]; |
|
| 1983 | - if (strpos($att, "&#") !== false) { |
|
| 1984 | - $att = str_replace(array("'", "'", """, """), array("'", "'", '"', '"'), $att); |
|
| 1985 | - } |
|
| 1986 | - $att = filtrer_entites($att); |
|
| 1987 | - } else { |
|
| 1988 | - $att = null; |
|
| 1989 | - } |
|
| 1990 | - |
|
| 1991 | - if ($complet) { |
|
| 1992 | - return array($att, $r); |
|
| 1993 | - } else { |
|
| 1994 | - return $att; |
|
| 1995 | - } |
|
| 1956 | + if (is_array($balise)) { |
|
| 1957 | + array_walk( |
|
| 1958 | + $balise, |
|
| 1959 | + function(&$a, $key, $t){ |
|
| 1960 | + $a = extraire_attribut($a, $t); |
|
| 1961 | + }, |
|
| 1962 | + $attribut |
|
| 1963 | + ); |
|
| 1964 | + |
|
| 1965 | + return $balise; |
|
| 1966 | + } |
|
| 1967 | + if (preg_match( |
|
| 1968 | + ',(^.*?<(?:(?>\s*)(?>[\w:.-]+)(?>(?:=(?:"[^"]*"|\'[^\']*\'|[^\'"]\S*))?))*?)(\s+' |
|
| 1969 | + . $attribut |
|
| 1970 | + . '(?:=\s*("[^"]*"|\'[^\']*\'|[^\'"]\S*))?)()((?:[\s/][^>]*)?>.*),isS', |
|
| 1971 | + |
|
| 1972 | + $balise, $r)) { |
|
| 1973 | + if (isset($r[3][0]) and ($r[3][0] == '"' || $r[3][0] == "'")) { |
|
| 1974 | + $r[4] = substr($r[3], 1, -1); |
|
| 1975 | + $r[3] = $r[3][0]; |
|
| 1976 | + } elseif ($r[3] !== '') { |
|
| 1977 | + $r[4] = $r[3]; |
|
| 1978 | + $r[3] = ''; |
|
| 1979 | + } else { |
|
| 1980 | + $r[4] = trim($r[2]); |
|
| 1981 | + } |
|
| 1982 | + $att = $r[4]; |
|
| 1983 | + if (strpos($att, "&#") !== false) { |
|
| 1984 | + $att = str_replace(array("'", "'", """, """), array("'", "'", '"', '"'), $att); |
|
| 1985 | + } |
|
| 1986 | + $att = filtrer_entites($att); |
|
| 1987 | + } else { |
|
| 1988 | + $att = null; |
|
| 1989 | + } |
|
| 1990 | + |
|
| 1991 | + if ($complet) { |
|
| 1992 | + return array($att, $r); |
|
| 1993 | + } else { |
|
| 1994 | + return $att; |
|
| 1995 | + } |
|
| 1996 | 1996 | } |
| 1997 | 1997 | |
| 1998 | 1998 | /** |
@@ -2024,37 +2024,37 @@ discard block |
||
| 2024 | 2024 | * Code html modifié |
| 2025 | 2025 | **/ |
| 2026 | 2026 | function inserer_attribut($balise, $attribut, $val, $proteger = true, $vider = false) { |
| 2027 | - // preparer l'attribut |
|
| 2028 | - // supprimer les etc mais pas les balises html |
|
| 2029 | - // qui ont un sens dans un attribut value d'un input |
|
| 2030 | - if ($proteger) { |
|
| 2031 | - $val = attribut_html($val, false); |
|
| 2032 | - } |
|
| 2033 | - |
|
| 2034 | - // echapper les ' pour eviter tout bug |
|
| 2035 | - $val = str_replace("'", "'", $val); |
|
| 2036 | - if ($vider and strlen($val) == 0) { |
|
| 2037 | - $insert = ''; |
|
| 2038 | - } else { |
|
| 2039 | - $insert = " $attribut='$val'"; |
|
| 2040 | - } |
|
| 2041 | - |
|
| 2042 | - list($old, $r) = extraire_attribut($balise, $attribut, true); |
|
| 2043 | - |
|
| 2044 | - if ($old !== null) { |
|
| 2045 | - // Remplacer l'ancien attribut du meme nom |
|
| 2046 | - $balise = $r[1] . $insert . $r[5]; |
|
| 2047 | - } else { |
|
| 2048 | - // preferer une balise " />" (comme <img />) |
|
| 2049 | - if (preg_match(',/>,', $balise)) { |
|
| 2050 | - $balise = preg_replace(",\s?/>,S", $insert . " />", $balise, 1); |
|
| 2051 | - } // sinon une balise <a ...> ... </a> |
|
| 2052 | - else { |
|
| 2053 | - $balise = preg_replace(",\s?>,S", $insert . ">", $balise, 1); |
|
| 2054 | - } |
|
| 2055 | - } |
|
| 2056 | - |
|
| 2057 | - return $balise; |
|
| 2027 | + // preparer l'attribut |
|
| 2028 | + // supprimer les etc mais pas les balises html |
|
| 2029 | + // qui ont un sens dans un attribut value d'un input |
|
| 2030 | + if ($proteger) { |
|
| 2031 | + $val = attribut_html($val, false); |
|
| 2032 | + } |
|
| 2033 | + |
|
| 2034 | + // echapper les ' pour eviter tout bug |
|
| 2035 | + $val = str_replace("'", "'", $val); |
|
| 2036 | + if ($vider and strlen($val) == 0) { |
|
| 2037 | + $insert = ''; |
|
| 2038 | + } else { |
|
| 2039 | + $insert = " $attribut='$val'"; |
|
| 2040 | + } |
|
| 2041 | + |
|
| 2042 | + list($old, $r) = extraire_attribut($balise, $attribut, true); |
|
| 2043 | + |
|
| 2044 | + if ($old !== null) { |
|
| 2045 | + // Remplacer l'ancien attribut du meme nom |
|
| 2046 | + $balise = $r[1] . $insert . $r[5]; |
|
| 2047 | + } else { |
|
| 2048 | + // preferer une balise " />" (comme <img />) |
|
| 2049 | + if (preg_match(',/>,', $balise)) { |
|
| 2050 | + $balise = preg_replace(",\s?/>,S", $insert . " />", $balise, 1); |
|
| 2051 | + } // sinon une balise <a ...> ... </a> |
|
| 2052 | + else { |
|
| 2053 | + $balise = preg_replace(",\s?>,S", $insert . ">", $balise, 1); |
|
| 2054 | + } |
|
| 2055 | + } |
|
| 2056 | + |
|
| 2057 | + return $balise; |
|
| 2058 | 2058 | } |
| 2059 | 2059 | |
| 2060 | 2060 | /** |
@@ -2072,7 +2072,7 @@ discard block |
||
| 2072 | 2072 | * @return string Code HTML sans l'attribut |
| 2073 | 2073 | **/ |
| 2074 | 2074 | function vider_attribut($balise, $attribut) { |
| 2075 | - return inserer_attribut($balise, $attribut, '', false, true); |
|
| 2075 | + return inserer_attribut($balise, $attribut, '', false, true); |
|
| 2076 | 2076 | } |
| 2077 | 2077 | |
| 2078 | 2078 | /** |
@@ -2084,50 +2084,50 @@ discard block |
||
| 2084 | 2084 | * @return string |
| 2085 | 2085 | */ |
| 2086 | 2086 | function modifier_class($balise, $class, $operation='ajouter') { |
| 2087 | - if (is_string($class)) { |
|
| 2088 | - $class = explode(' ', trim($class)); |
|
| 2089 | - } |
|
| 2090 | - $class = array_filter($class); |
|
| 2091 | - |
|
| 2092 | - // si la ou les classes ont des caracteres invalides on ne fait rien |
|
| 2093 | - if (preg_match(",[^\w-],", implode('', $class))) { |
|
| 2094 | - return $balise; |
|
| 2095 | - } |
|
| 2096 | - |
|
| 2097 | - if ($class) { |
|
| 2098 | - $class = array_unique($class); |
|
| 2099 | - $class_courante = extraire_attribut($balise, 'class'); |
|
| 2100 | - |
|
| 2101 | - $class_new = $class_courante; |
|
| 2102 | - foreach ($class as $c) { |
|
| 2103 | - if ($c) { |
|
| 2104 | - $is_class_presente = false; |
|
| 2105 | - if (strpos($class_courante, $c) !== false |
|
| 2106 | - and preg_match("/(^|\s)".preg_quote($c)."($|\s)/", $class_courante)) { |
|
| 2107 | - $is_class_presente = true; |
|
| 2108 | - } |
|
| 2109 | - if (in_array($operation, ['ajouter', 'commuter']) |
|
| 2110 | - and !$is_class_presente) { |
|
| 2111 | - $class_new = rtrim($class_new) . " " . $c; |
|
| 2112 | - } |
|
| 2113 | - elseif (in_array($operation, ['supprimer', 'commuter']) |
|
| 2114 | - and $is_class_presente) { |
|
| 2115 | - $class_new = trim(preg_replace("/(^|\s)".preg_quote($c)."($|\s)/", "\\1", $class_new)); |
|
| 2116 | - } |
|
| 2117 | - } |
|
| 2118 | - } |
|
| 2119 | - |
|
| 2120 | - if ($class_new !== $class_courante) { |
|
| 2121 | - if (strlen($class_new)) { |
|
| 2122 | - $balise = inserer_attribut($balise, 'class', $class_new); |
|
| 2123 | - } |
|
| 2124 | - elseif ($class_courante) { |
|
| 2125 | - $balise = vider_attribut($balise, 'class'); |
|
| 2126 | - } |
|
| 2127 | - } |
|
| 2128 | - } |
|
| 2129 | - |
|
| 2130 | - return $balise; |
|
| 2087 | + if (is_string($class)) { |
|
| 2088 | + $class = explode(' ', trim($class)); |
|
| 2089 | + } |
|
| 2090 | + $class = array_filter($class); |
|
| 2091 | + |
|
| 2092 | + // si la ou les classes ont des caracteres invalides on ne fait rien |
|
| 2093 | + if (preg_match(",[^\w-],", implode('', $class))) { |
|
| 2094 | + return $balise; |
|
| 2095 | + } |
|
| 2096 | + |
|
| 2097 | + if ($class) { |
|
| 2098 | + $class = array_unique($class); |
|
| 2099 | + $class_courante = extraire_attribut($balise, 'class'); |
|
| 2100 | + |
|
| 2101 | + $class_new = $class_courante; |
|
| 2102 | + foreach ($class as $c) { |
|
| 2103 | + if ($c) { |
|
| 2104 | + $is_class_presente = false; |
|
| 2105 | + if (strpos($class_courante, $c) !== false |
|
| 2106 | + and preg_match("/(^|\s)".preg_quote($c)."($|\s)/", $class_courante)) { |
|
| 2107 | + $is_class_presente = true; |
|
| 2108 | + } |
|
| 2109 | + if (in_array($operation, ['ajouter', 'commuter']) |
|
| 2110 | + and !$is_class_presente) { |
|
| 2111 | + $class_new = rtrim($class_new) . " " . $c; |
|
| 2112 | + } |
|
| 2113 | + elseif (in_array($operation, ['supprimer', 'commuter']) |
|
| 2114 | + and $is_class_presente) { |
|
| 2115 | + $class_new = trim(preg_replace("/(^|\s)".preg_quote($c)."($|\s)/", "\\1", $class_new)); |
|
| 2116 | + } |
|
| 2117 | + } |
|
| 2118 | + } |
|
| 2119 | + |
|
| 2120 | + if ($class_new !== $class_courante) { |
|
| 2121 | + if (strlen($class_new)) { |
|
| 2122 | + $balise = inserer_attribut($balise, 'class', $class_new); |
|
| 2123 | + } |
|
| 2124 | + elseif ($class_courante) { |
|
| 2125 | + $balise = vider_attribut($balise, 'class'); |
|
| 2126 | + } |
|
| 2127 | + } |
|
| 2128 | + } |
|
| 2129 | + |
|
| 2130 | + return $balise; |
|
| 2131 | 2131 | } |
| 2132 | 2132 | |
| 2133 | 2133 | /** |
@@ -2137,7 +2137,7 @@ discard block |
||
| 2137 | 2137 | * @return string |
| 2138 | 2138 | */ |
| 2139 | 2139 | function ajouter_class($balise, $class){ |
| 2140 | - return modifier_class($balise, $class, 'ajouter'); |
|
| 2140 | + return modifier_class($balise, $class, 'ajouter'); |
|
| 2141 | 2141 | } |
| 2142 | 2142 | |
| 2143 | 2143 | /** |
@@ -2147,7 +2147,7 @@ discard block |
||
| 2147 | 2147 | * @return string |
| 2148 | 2148 | */ |
| 2149 | 2149 | function supprimer_class($balise, $class){ |
| 2150 | - return modifier_class($balise, $class, 'supprimer'); |
|
| 2150 | + return modifier_class($balise, $class, 'supprimer'); |
|
| 2151 | 2151 | } |
| 2152 | 2152 | |
| 2153 | 2153 | /** |
@@ -2158,7 +2158,7 @@ discard block |
||
| 2158 | 2158 | * @return string |
| 2159 | 2159 | */ |
| 2160 | 2160 | function commuter_class($balise, $class){ |
| 2161 | - return modifier_class($balise, $class, 'commuter'); |
|
| 2161 | + return modifier_class($balise, $class, 'commuter'); |
|
| 2162 | 2162 | } |
| 2163 | 2163 | |
| 2164 | 2164 | /** |
@@ -2169,9 +2169,9 @@ discard block |
||
| 2169 | 2169 | * @return string |
| 2170 | 2170 | */ |
| 2171 | 2171 | function tester_config($id, $mode = '') { |
| 2172 | - include_spip('action/inscrire_auteur'); |
|
| 2172 | + include_spip('action/inscrire_auteur'); |
|
| 2173 | 2173 | |
| 2174 | - return tester_statut_inscription($mode, $id); |
|
| 2174 | + return tester_statut_inscription($mode, $id); |
|
| 2175 | 2175 | } |
| 2176 | 2176 | |
| 2177 | 2177 | // |
@@ -2196,7 +2196,7 @@ discard block |
||
| 2196 | 2196 | * @return int $a+$b |
| 2197 | 2197 | **/ |
| 2198 | 2198 | function plus($a, $b) { |
| 2199 | - return $a + $b; |
|
| 2199 | + return $a + $b; |
|
| 2200 | 2200 | } |
| 2201 | 2201 | function strplus($a, $b) {return strize('plus', $a, $b);} |
| 2202 | 2202 | /** |
@@ -2215,7 +2215,7 @@ discard block |
||
| 2215 | 2215 | * @return int $a-$b |
| 2216 | 2216 | **/ |
| 2217 | 2217 | function moins($a, $b) { |
| 2218 | - return $a - $b; |
|
| 2218 | + return $a - $b; |
|
| 2219 | 2219 | } |
| 2220 | 2220 | function strmoins($a, $b) {return strize('moins', $a, $b);} |
| 2221 | 2221 | |
@@ -2236,7 +2236,7 @@ discard block |
||
| 2236 | 2236 | * @return int $a*$b |
| 2237 | 2237 | **/ |
| 2238 | 2238 | function mult($a, $b) { |
| 2239 | - return $a * $b; |
|
| 2239 | + return $a * $b; |
|
| 2240 | 2240 | } |
| 2241 | 2241 | function strmult($a, $b) {return strize('mult', $a, $b);} |
| 2242 | 2242 | |
@@ -2257,7 +2257,7 @@ discard block |
||
| 2257 | 2257 | * @return int $a/$b (ou 0 si $b est nul) |
| 2258 | 2258 | **/ |
| 2259 | 2259 | function div($a, $b) { |
| 2260 | - return $b ? $a / $b : 0; |
|
| 2260 | + return $b ? $a / $b : 0; |
|
| 2261 | 2261 | } |
| 2262 | 2262 | function strdiv($a, $b) {return strize('div', $a, $b);} |
| 2263 | 2263 | |
@@ -2279,7 +2279,7 @@ discard block |
||
| 2279 | 2279 | * @return int ($nb % $mod) + $add |
| 2280 | 2280 | **/ |
| 2281 | 2281 | function modulo($nb, $mod, $add = 0) { |
| 2282 | - return ($mod ? $nb % $mod : 0) + $add; |
|
| 2282 | + return ($mod ? $nb % $mod : 0) + $add; |
|
| 2283 | 2283 | } |
| 2284 | 2284 | |
| 2285 | 2285 | |
@@ -2294,24 +2294,24 @@ discard block |
||
| 2294 | 2294 | * - true sinon |
| 2295 | 2295 | **/ |
| 2296 | 2296 | function nom_acceptable($nom) { |
| 2297 | - if (!is_string($nom)) { |
|
| 2298 | - return false; |
|
| 2299 | - } |
|
| 2300 | - if (!defined('_TAGS_NOM_AUTEUR')) { |
|
| 2301 | - define('_TAGS_NOM_AUTEUR', ''); |
|
| 2302 | - } |
|
| 2303 | - $tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR)); |
|
| 2304 | - foreach ($tags_acceptes as $tag) { |
|
| 2305 | - if (strlen($tag)) { |
|
| 2306 | - $remp1[] = '<' . trim($tag) . '>'; |
|
| 2307 | - $remp1[] = '</' . trim($tag) . '>'; |
|
| 2308 | - $remp2[] = '\x60' . trim($tag) . '\x61'; |
|
| 2309 | - $remp2[] = '\x60/' . trim($tag) . '\x61'; |
|
| 2310 | - } |
|
| 2311 | - } |
|
| 2312 | - $v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom))); |
|
| 2297 | + if (!is_string($nom)) { |
|
| 2298 | + return false; |
|
| 2299 | + } |
|
| 2300 | + if (!defined('_TAGS_NOM_AUTEUR')) { |
|
| 2301 | + define('_TAGS_NOM_AUTEUR', ''); |
|
| 2302 | + } |
|
| 2303 | + $tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR)); |
|
| 2304 | + foreach ($tags_acceptes as $tag) { |
|
| 2305 | + if (strlen($tag)) { |
|
| 2306 | + $remp1[] = '<' . trim($tag) . '>'; |
|
| 2307 | + $remp1[] = '</' . trim($tag) . '>'; |
|
| 2308 | + $remp2[] = '\x60' . trim($tag) . '\x61'; |
|
| 2309 | + $remp2[] = '\x60/' . trim($tag) . '\x61'; |
|
| 2310 | + } |
|
| 2311 | + } |
|
| 2312 | + $v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom))); |
|
| 2313 | 2313 | |
| 2314 | - return str_replace('<', '<', $v_nom) == $nom; |
|
| 2314 | + return str_replace('<', '<', $v_nom) == $nom; |
|
| 2315 | 2315 | } |
| 2316 | 2316 | |
| 2317 | 2317 | |
@@ -2327,14 +2327,14 @@ discard block |
||
| 2327 | 2327 | * - renvoie un tableau si l'entree est un tableau |
| 2328 | 2328 | **/ |
| 2329 | 2329 | function email_valide($adresses) { |
| 2330 | - if (is_array($adresses)) { |
|
| 2331 | - $adresses = array_map('email_valide', $adresses); |
|
| 2332 | - $adresses = array_filter($adresses); |
|
| 2333 | - return $adresses; |
|
| 2334 | - } |
|
| 2330 | + if (is_array($adresses)) { |
|
| 2331 | + $adresses = array_map('email_valide', $adresses); |
|
| 2332 | + $adresses = array_filter($adresses); |
|
| 2333 | + return $adresses; |
|
| 2334 | + } |
|
| 2335 | 2335 | |
| 2336 | - $email_valide = charger_fonction('email_valide', 'inc'); |
|
| 2337 | - return $email_valide($adresses); |
|
| 2336 | + $email_valide = charger_fonction('email_valide', 'inc'); |
|
| 2337 | + return $email_valide($adresses); |
|
| 2338 | 2338 | } |
| 2339 | 2339 | |
| 2340 | 2340 | /** |
@@ -2348,20 +2348,20 @@ discard block |
||
| 2348 | 2348 | * @return string Texte |
| 2349 | 2349 | **/ |
| 2350 | 2350 | function afficher_enclosures($tags) { |
| 2351 | - $s = array(); |
|
| 2352 | - foreach (extraire_balises($tags, 'a') as $tag) { |
|
| 2353 | - if (extraire_attribut($tag, 'rel') == 'enclosure' |
|
| 2354 | - and $t = extraire_attribut($tag, 'href') |
|
| 2355 | - ) { |
|
| 2356 | - $s[] = preg_replace(',>[^<]+</a>,S', |
|
| 2357 | - '>' |
|
| 2358 | - . http_img_pack('attachment-16.png', $t, |
|
| 2359 | - 'title="' . attribut_html($t) . '"') |
|
| 2360 | - . '</a>', $tag); |
|
| 2361 | - } |
|
| 2362 | - } |
|
| 2351 | + $s = array(); |
|
| 2352 | + foreach (extraire_balises($tags, 'a') as $tag) { |
|
| 2353 | + if (extraire_attribut($tag, 'rel') == 'enclosure' |
|
| 2354 | + and $t = extraire_attribut($tag, 'href') |
|
| 2355 | + ) { |
|
| 2356 | + $s[] = preg_replace(',>[^<]+</a>,S', |
|
| 2357 | + '>' |
|
| 2358 | + . http_img_pack('attachment-16.png', $t, |
|
| 2359 | + 'title="' . attribut_html($t) . '"') |
|
| 2360 | + . '</a>', $tag); |
|
| 2361 | + } |
|
| 2362 | + } |
|
| 2363 | 2363 | |
| 2364 | - return join(' ', $s); |
|
| 2364 | + return join(' ', $s); |
|
| 2365 | 2365 | } |
| 2366 | 2366 | |
| 2367 | 2367 | /** |
@@ -2376,15 +2376,15 @@ discard block |
||
| 2376 | 2376 | * @return string Liens trouvés |
| 2377 | 2377 | **/ |
| 2378 | 2378 | function afficher_tags($tags, $rels = 'tag,directory') { |
| 2379 | - $s = array(); |
|
| 2380 | - foreach (extraire_balises($tags, 'a') as $tag) { |
|
| 2381 | - $rel = extraire_attribut($tag, 'rel'); |
|
| 2382 | - if (strstr(",$rels,", ",$rel,")) { |
|
| 2383 | - $s[] = $tag; |
|
| 2384 | - } |
|
| 2385 | - } |
|
| 2379 | + $s = array(); |
|
| 2380 | + foreach (extraire_balises($tags, 'a') as $tag) { |
|
| 2381 | + $rel = extraire_attribut($tag, 'rel'); |
|
| 2382 | + if (strstr(",$rels,", ",$rel,")) { |
|
| 2383 | + $s[] = $tag; |
|
| 2384 | + } |
|
| 2385 | + } |
|
| 2386 | 2386 | |
| 2387 | - return join(', ', $s); |
|
| 2387 | + return join(', ', $s); |
|
| 2388 | 2388 | } |
| 2389 | 2389 | |
| 2390 | 2390 | |
@@ -2406,21 +2406,21 @@ discard block |
||
| 2406 | 2406 | * @return string Tag HTML `<a>` avec microformat. |
| 2407 | 2407 | **/ |
| 2408 | 2408 | function enclosure2microformat($e) { |
| 2409 | - if (!$url = filtrer_entites(extraire_attribut($e, 'url'))) { |
|
| 2410 | - $url = filtrer_entites(extraire_attribut($e, 'href')); |
|
| 2411 | - } |
|
| 2412 | - $type = extraire_attribut($e, 'type'); |
|
| 2413 | - if (!$length = extraire_attribut($e, 'length')) { |
|
| 2414 | - # <media:content : longeur dans fileSize. On tente. |
|
| 2415 | - $length = extraire_attribut($e, 'fileSize'); |
|
| 2416 | - } |
|
| 2417 | - $fichier = basename($url); |
|
| 2409 | + if (!$url = filtrer_entites(extraire_attribut($e, 'url'))) { |
|
| 2410 | + $url = filtrer_entites(extraire_attribut($e, 'href')); |
|
| 2411 | + } |
|
| 2412 | + $type = extraire_attribut($e, 'type'); |
|
| 2413 | + if (!$length = extraire_attribut($e, 'length')) { |
|
| 2414 | + # <media:content : longeur dans fileSize. On tente. |
|
| 2415 | + $length = extraire_attribut($e, 'fileSize'); |
|
| 2416 | + } |
|
| 2417 | + $fichier = basename($url); |
|
| 2418 | 2418 | |
| 2419 | - return '<a rel="enclosure"' |
|
| 2420 | - . ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '') |
|
| 2421 | - . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '') |
|
| 2422 | - . ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '') |
|
| 2423 | - . '>' . $fichier . '</a>'; |
|
| 2419 | + return '<a rel="enclosure"' |
|
| 2420 | + . ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '') |
|
| 2421 | + . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '') |
|
| 2422 | + . ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '') |
|
| 2423 | + . '>' . $fichier . '</a>'; |
|
| 2424 | 2424 | } |
| 2425 | 2425 | |
| 2426 | 2426 | /** |
@@ -2438,24 +2438,24 @@ discard block |
||
| 2438 | 2438 | * @return string Tags RSS `<enclosure>`. |
| 2439 | 2439 | **/ |
| 2440 | 2440 | function microformat2enclosure($tags) { |
| 2441 | - $enclosures = array(); |
|
| 2442 | - foreach (extraire_balises($tags, 'a') as $e) { |
|
| 2443 | - if (extraire_attribut($e, 'rel') == 'enclosure') { |
|
| 2444 | - $url = filtrer_entites(extraire_attribut($e, 'href')); |
|
| 2445 | - $type = extraire_attribut($e, 'type'); |
|
| 2446 | - if (!$length = intval(extraire_attribut($e, 'title'))) { |
|
| 2447 | - $length = intval(extraire_attribut($e, 'length')); |
|
| 2448 | - } # vieux data |
|
| 2449 | - $fichier = basename($url); |
|
| 2450 | - $enclosures[] = '<enclosure' |
|
| 2451 | - . ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '') |
|
| 2452 | - . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '') |
|
| 2453 | - . ($length ? ' length="' . $length . '"' : '') |
|
| 2454 | - . ' />'; |
|
| 2455 | - } |
|
| 2456 | - } |
|
| 2441 | + $enclosures = array(); |
|
| 2442 | + foreach (extraire_balises($tags, 'a') as $e) { |
|
| 2443 | + if (extraire_attribut($e, 'rel') == 'enclosure') { |
|
| 2444 | + $url = filtrer_entites(extraire_attribut($e, 'href')); |
|
| 2445 | + $type = extraire_attribut($e, 'type'); |
|
| 2446 | + if (!$length = intval(extraire_attribut($e, 'title'))) { |
|
| 2447 | + $length = intval(extraire_attribut($e, 'length')); |
|
| 2448 | + } # vieux data |
|
| 2449 | + $fichier = basename($url); |
|
| 2450 | + $enclosures[] = '<enclosure' |
|
| 2451 | + . ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '') |
|
| 2452 | + . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '') |
|
| 2453 | + . ($length ? ' length="' . $length . '"' : '') |
|
| 2454 | + . ' />'; |
|
| 2455 | + } |
|
| 2456 | + } |
|
| 2457 | 2457 | |
| 2458 | - return join("\n", $enclosures); |
|
| 2458 | + return join("\n", $enclosures); |
|
| 2459 | 2459 | } |
| 2460 | 2460 | |
| 2461 | 2461 | |
@@ -2471,16 +2471,16 @@ discard block |
||
| 2471 | 2471 | * @return string Tags RSS Atom `<dc:subject>`. |
| 2472 | 2472 | **/ |
| 2473 | 2473 | function tags2dcsubject($tags) { |
| 2474 | - $subjects = ''; |
|
| 2475 | - foreach (extraire_balises($tags, 'a') as $e) { |
|
| 2476 | - if (extraire_attribut($e, 'rel') == 'tag') { |
|
| 2477 | - $subjects .= '<dc:subject>' |
|
| 2478 | - . texte_backend(textebrut($e)) |
|
| 2479 | - . '</dc:subject>' . "\n"; |
|
| 2480 | - } |
|
| 2481 | - } |
|
| 2474 | + $subjects = ''; |
|
| 2475 | + foreach (extraire_balises($tags, 'a') as $e) { |
|
| 2476 | + if (extraire_attribut($e, 'rel') == 'tag') { |
|
| 2477 | + $subjects .= '<dc:subject>' |
|
| 2478 | + . texte_backend(textebrut($e)) |
|
| 2479 | + . '</dc:subject>' . "\n"; |
|
| 2480 | + } |
|
| 2481 | + } |
|
| 2482 | 2482 | |
| 2483 | - return $subjects; |
|
| 2483 | + return $subjects; |
|
| 2484 | 2484 | } |
| 2485 | 2485 | |
| 2486 | 2486 | /** |
@@ -2509,23 +2509,23 @@ discard block |
||
| 2509 | 2509 | * - Tableau de résultats, si tableau en entrée. |
| 2510 | 2510 | **/ |
| 2511 | 2511 | function extraire_balise($texte, $tag = 'a') { |
| 2512 | - if (is_array($texte)) { |
|
| 2513 | - array_walk( |
|
| 2514 | - $texte, |
|
| 2515 | - function(&$a, $key, $t){ |
|
| 2516 | - $a = extraire_balise($a, $t); |
|
| 2517 | - }, |
|
| 2518 | - $tag |
|
| 2519 | - ); |
|
| 2512 | + if (is_array($texte)) { |
|
| 2513 | + array_walk( |
|
| 2514 | + $texte, |
|
| 2515 | + function(&$a, $key, $t){ |
|
| 2516 | + $a = extraire_balise($a, $t); |
|
| 2517 | + }, |
|
| 2518 | + $tag |
|
| 2519 | + ); |
|
| 2520 | 2520 | |
| 2521 | - return $texte; |
|
| 2522 | - } |
|
| 2521 | + return $texte; |
|
| 2522 | + } |
|
| 2523 | 2523 | |
| 2524 | - if (preg_match( |
|
| 2525 | - ",<$tag\b[^>]*(/>|>.*</$tag\b[^>]*>|>),UimsS", |
|
| 2526 | - $texte, $regs)) { |
|
| 2527 | - return $regs[0]; |
|
| 2528 | - } |
|
| 2524 | + if (preg_match( |
|
| 2525 | + ",<$tag\b[^>]*(/>|>.*</$tag\b[^>]*>|>),UimsS", |
|
| 2526 | + $texte, $regs)) { |
|
| 2527 | + return $regs[0]; |
|
| 2528 | + } |
|
| 2529 | 2529 | } |
| 2530 | 2530 | |
| 2531 | 2531 | /** |
@@ -2553,25 +2553,25 @@ discard block |
||
| 2553 | 2553 | * - Tableau de résultats, si tableau en entrée. |
| 2554 | 2554 | **/ |
| 2555 | 2555 | function extraire_balises($texte, $tag = 'a') { |
| 2556 | - if (is_array($texte)) { |
|
| 2557 | - array_walk( |
|
| 2558 | - $texte, |
|
| 2559 | - function(&$a, $key, $t){ |
|
| 2560 | - $a = extraire_balises($a, $t); |
|
| 2561 | - }, |
|
| 2562 | - $tag |
|
| 2563 | - ); |
|
| 2556 | + if (is_array($texte)) { |
|
| 2557 | + array_walk( |
|
| 2558 | + $texte, |
|
| 2559 | + function(&$a, $key, $t){ |
|
| 2560 | + $a = extraire_balises($a, $t); |
|
| 2561 | + }, |
|
| 2562 | + $tag |
|
| 2563 | + ); |
|
| 2564 | 2564 | |
| 2565 | - return $texte; |
|
| 2566 | - } |
|
| 2565 | + return $texte; |
|
| 2566 | + } |
|
| 2567 | 2567 | |
| 2568 | - if (preg_match_all( |
|
| 2569 | - ",<${tag}\b[^>]*(/>|>.*</${tag}\b[^>]*>|>),UimsS", |
|
| 2570 | - $texte, $regs, PREG_PATTERN_ORDER)) { |
|
| 2571 | - return $regs[0]; |
|
| 2572 | - } else { |
|
| 2573 | - return array(); |
|
| 2574 | - } |
|
| 2568 | + if (preg_match_all( |
|
| 2569 | + ",<${tag}\b[^>]*(/>|>.*</${tag}\b[^>]*>|>),UimsS", |
|
| 2570 | + $texte, $regs, PREG_PATTERN_ORDER)) { |
|
| 2571 | + return $regs[0]; |
|
| 2572 | + } else { |
|
| 2573 | + return array(); |
|
| 2574 | + } |
|
| 2575 | 2575 | } |
| 2576 | 2576 | |
| 2577 | 2577 | /** |
@@ -2600,11 +2600,11 @@ discard block |
||
| 2600 | 2600 | * - `$def` si on n'a pas transmis de tableau |
| 2601 | 2601 | **/ |
| 2602 | 2602 | function in_any($val, $vals, $def = '') { |
| 2603 | - if (!is_array($vals) and $v = unserialize($vals)) { |
|
| 2604 | - $vals = $v; |
|
| 2605 | - } |
|
| 2603 | + if (!is_array($vals) and $v = unserialize($vals)) { |
|
| 2604 | + $vals = $v; |
|
| 2605 | + } |
|
| 2606 | 2606 | |
| 2607 | - return (!is_array($vals) ? $def : (in_array($val, $vals) ? ' ' : '')); |
|
| 2607 | + return (!is_array($vals) ? $def : (in_array($val, $vals) ? ' ' : '')); |
|
| 2608 | 2608 | } |
| 2609 | 2609 | |
| 2610 | 2610 | |
@@ -2625,12 +2625,12 @@ discard block |
||
| 2625 | 2625 | * Résultat du calcul |
| 2626 | 2626 | **/ |
| 2627 | 2627 | function valeur_numerique($expr) { |
| 2628 | - $a = 0; |
|
| 2629 | - if (preg_match(',^[0-9]+(\s*[+*-]\s*[0-9]+)*$,S', trim($expr))) { |
|
| 2630 | - eval("\$a = $expr;"); |
|
| 2631 | - } |
|
| 2628 | + $a = 0; |
|
| 2629 | + if (preg_match(',^[0-9]+(\s*[+*-]\s*[0-9]+)*$,S', trim($expr))) { |
|
| 2630 | + eval("\$a = $expr;"); |
|
| 2631 | + } |
|
| 2632 | 2632 | |
| 2633 | - return intval($a); |
|
| 2633 | + return intval($a); |
|
| 2634 | 2634 | } |
| 2635 | 2635 | |
| 2636 | 2636 | /** |
@@ -2649,7 +2649,7 @@ discard block |
||
| 2649 | 2649 | * Retourne `$a*$b/$c` |
| 2650 | 2650 | **/ |
| 2651 | 2651 | function regledetrois($a, $b, $c) { |
| 2652 | - return round($a * $b / $c); |
|
| 2652 | + return round($a * $b / $c); |
|
| 2653 | 2653 | } |
| 2654 | 2654 | |
| 2655 | 2655 | |
@@ -2673,76 +2673,76 @@ discard block |
||
| 2673 | 2673 | **/ |
| 2674 | 2674 | function form_hidden($action) { |
| 2675 | 2675 | |
| 2676 | - $contexte = array(); |
|
| 2677 | - include_spip('inc/urls'); |
|
| 2678 | - if ($p = urls_decoder_url($action, '') |
|
| 2679 | - and reset($p) |
|
| 2680 | - ) { |
|
| 2681 | - $fond = array_shift($p); |
|
| 2682 | - if ($fond != '404') { |
|
| 2683 | - $contexte = array_shift($p); |
|
| 2684 | - $contexte['page'] = $fond; |
|
| 2685 | - $action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action); |
|
| 2686 | - } |
|
| 2687 | - } |
|
| 2688 | - // defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url |
|
| 2689 | - if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) { |
|
| 2690 | - unset($contexte['type']); |
|
| 2691 | - } |
|
| 2692 | - if (defined('_DEFINIR_CONTEXTE_TYPE_PAGE') and _DEFINIR_CONTEXTE_TYPE_PAGE) { |
|
| 2693 | - unset($contexte['type-page']); |
|
| 2694 | - } |
|
| 2695 | - |
|
| 2696 | - // on va remplir un tableau de valeurs en prenant bien soin de ne pas |
|
| 2697 | - // ecraser les elements de la forme mots[]=1&mots[]=2 |
|
| 2698 | - $values = array(); |
|
| 2699 | - |
|
| 2700 | - // d'abord avec celles de l'url |
|
| 2701 | - if (false !== ($p = strpos($action, '?'))) { |
|
| 2702 | - foreach (preg_split('/&(amp;)?/S', substr($action, $p + 1)) as $c) { |
|
| 2703 | - $c = explode('=', $c, 2); |
|
| 2704 | - $var = array_shift($c); |
|
| 2705 | - $val = array_shift($c); |
|
| 2706 | - if ($var) { |
|
| 2707 | - $val = rawurldecode($val); |
|
| 2708 | - $var = rawurldecode($var); // decoder les [] eventuels |
|
| 2709 | - if (preg_match(',\[\]$,S', $var)) { |
|
| 2710 | - $values[] = array($var, $val); |
|
| 2711 | - } else { |
|
| 2712 | - if (!isset($values[$var])) { |
|
| 2713 | - $values[$var] = array($var, $val); |
|
| 2714 | - } |
|
| 2715 | - } |
|
| 2716 | - } |
|
| 2717 | - } |
|
| 2718 | - } |
|
| 2719 | - |
|
| 2720 | - // ensuite avec celles du contexte, sans doublonner ! |
|
| 2721 | - foreach ($contexte as $var => $val) { |
|
| 2722 | - if (preg_match(',\[\]$,S', $var)) { |
|
| 2723 | - $values[] = array($var, $val); |
|
| 2724 | - } else { |
|
| 2725 | - if (!isset($values[$var])) { |
|
| 2726 | - $values[$var] = array($var, $val); |
|
| 2727 | - } |
|
| 2728 | - } |
|
| 2729 | - } |
|
| 2730 | - |
|
| 2731 | - // puis on rassemble le tout |
|
| 2732 | - $hidden = array(); |
|
| 2733 | - foreach ($values as $value) { |
|
| 2734 | - list($var, $val) = $value; |
|
| 2735 | - $hidden[] = '<input name="' |
|
| 2736 | - . entites_html($var) |
|
| 2737 | - . '"' |
|
| 2738 | - . (is_null($val) |
|
| 2739 | - ? '' |
|
| 2740 | - : ' value="' . entites_html($val) . '"' |
|
| 2741 | - ) |
|
| 2742 | - . ' type="hidden"' . "\n/>"; |
|
| 2743 | - } |
|
| 2744 | - |
|
| 2745 | - return join("", $hidden); |
|
| 2676 | + $contexte = array(); |
|
| 2677 | + include_spip('inc/urls'); |
|
| 2678 | + if ($p = urls_decoder_url($action, '') |
|
| 2679 | + and reset($p) |
|
| 2680 | + ) { |
|
| 2681 | + $fond = array_shift($p); |
|
| 2682 | + if ($fond != '404') { |
|
| 2683 | + $contexte = array_shift($p); |
|
| 2684 | + $contexte['page'] = $fond; |
|
| 2685 | + $action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action); |
|
| 2686 | + } |
|
| 2687 | + } |
|
| 2688 | + // defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url |
|
| 2689 | + if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) { |
|
| 2690 | + unset($contexte['type']); |
|
| 2691 | + } |
|
| 2692 | + if (defined('_DEFINIR_CONTEXTE_TYPE_PAGE') and _DEFINIR_CONTEXTE_TYPE_PAGE) { |
|
| 2693 | + unset($contexte['type-page']); |
|
| 2694 | + } |
|
| 2695 | + |
|
| 2696 | + // on va remplir un tableau de valeurs en prenant bien soin de ne pas |
|
| 2697 | + // ecraser les elements de la forme mots[]=1&mots[]=2 |
|
| 2698 | + $values = array(); |
|
| 2699 | + |
|
| 2700 | + // d'abord avec celles de l'url |
|
| 2701 | + if (false !== ($p = strpos($action, '?'))) { |
|
| 2702 | + foreach (preg_split('/&(amp;)?/S', substr($action, $p + 1)) as $c) { |
|
| 2703 | + $c = explode('=', $c, 2); |
|
| 2704 | + $var = array_shift($c); |
|
| 2705 | + $val = array_shift($c); |
|
| 2706 | + if ($var) { |
|
| 2707 | + $val = rawurldecode($val); |
|
| 2708 | + $var = rawurldecode($var); // decoder les [] eventuels |
|
| 2709 | + if (preg_match(',\[\]$,S', $var)) { |
|
| 2710 | + $values[] = array($var, $val); |
|
| 2711 | + } else { |
|
| 2712 | + if (!isset($values[$var])) { |
|
| 2713 | + $values[$var] = array($var, $val); |
|
| 2714 | + } |
|
| 2715 | + } |
|
| 2716 | + } |
|
| 2717 | + } |
|
| 2718 | + } |
|
| 2719 | + |
|
| 2720 | + // ensuite avec celles du contexte, sans doublonner ! |
|
| 2721 | + foreach ($contexte as $var => $val) { |
|
| 2722 | + if (preg_match(',\[\]$,S', $var)) { |
|
| 2723 | + $values[] = array($var, $val); |
|
| 2724 | + } else { |
|
| 2725 | + if (!isset($values[$var])) { |
|
| 2726 | + $values[$var] = array($var, $val); |
|
| 2727 | + } |
|
| 2728 | + } |
|
| 2729 | + } |
|
| 2730 | + |
|
| 2731 | + // puis on rassemble le tout |
|
| 2732 | + $hidden = array(); |
|
| 2733 | + foreach ($values as $value) { |
|
| 2734 | + list($var, $val) = $value; |
|
| 2735 | + $hidden[] = '<input name="' |
|
| 2736 | + . entites_html($var) |
|
| 2737 | + . '"' |
|
| 2738 | + . (is_null($val) |
|
| 2739 | + ? '' |
|
| 2740 | + : ' value="' . entites_html($val) . '"' |
|
| 2741 | + ) |
|
| 2742 | + . ' type="hidden"' . "\n/>"; |
|
| 2743 | + } |
|
| 2744 | + |
|
| 2745 | + return join("", $hidden); |
|
| 2746 | 2746 | } |
| 2747 | 2747 | |
| 2748 | 2748 | |
@@ -2764,7 +2764,7 @@ discard block |
||
| 2764 | 2764 | * - la première valeur du tableau sinon. |
| 2765 | 2765 | **/ |
| 2766 | 2766 | function filtre_reset($array) { |
| 2767 | - return !is_array($array) ? null : reset($array); |
|
| 2767 | + return !is_array($array) ? null : reset($array); |
|
| 2768 | 2768 | } |
| 2769 | 2769 | |
| 2770 | 2770 | /** |
@@ -2785,7 +2785,7 @@ discard block |
||
| 2785 | 2785 | * - la dernière valeur du tableau sinon. |
| 2786 | 2786 | **/ |
| 2787 | 2787 | function filtre_end($array) { |
| 2788 | - return !is_array($array) ? null : end($array); |
|
| 2788 | + return !is_array($array) ? null : end($array); |
|
| 2789 | 2789 | } |
| 2790 | 2790 | |
| 2791 | 2791 | /** |
@@ -2805,11 +2805,11 @@ discard block |
||
| 2805 | 2805 | * |
| 2806 | 2806 | **/ |
| 2807 | 2807 | function filtre_push($array, $val) { |
| 2808 | - if (!is_array($array) or !array_push($array, $val)) { |
|
| 2809 | - return ''; |
|
| 2810 | - } |
|
| 2808 | + if (!is_array($array) or !array_push($array, $val)) { |
|
| 2809 | + return ''; |
|
| 2810 | + } |
|
| 2811 | 2811 | |
| 2812 | - return $array; |
|
| 2812 | + return $array; |
|
| 2813 | 2813 | } |
| 2814 | 2814 | |
| 2815 | 2815 | /** |
@@ -2828,7 +2828,7 @@ discard block |
||
| 2828 | 2828 | * - `true` si la valeur existe dans le tableau, `false` sinon. |
| 2829 | 2829 | **/ |
| 2830 | 2830 | function filtre_find($array, $val) { |
| 2831 | - return (is_array($array) and in_array($val, $array)); |
|
| 2831 | + return (is_array($array) and in_array($val, $array)); |
|
| 2832 | 2832 | } |
| 2833 | 2833 | |
| 2834 | 2834 | |
@@ -2845,15 +2845,15 @@ discard block |
||
| 2845 | 2845 | * Contenu avec urls en absolus |
| 2846 | 2846 | **/ |
| 2847 | 2847 | function urls_absolues_css($contenu, $source) { |
| 2848 | - $path = suivre_lien(url_absolue($source), './'); |
|
| 2848 | + $path = suivre_lien(url_absolue($source), './'); |
|
| 2849 | 2849 | |
| 2850 | - return preg_replace_callback( |
|
| 2851 | - ",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims", |
|
| 2852 | - function($x) use ($path) { |
|
| 2853 | - return "url('" . suivre_lien($path, $x[1]) . "')"; |
|
| 2854 | - }, |
|
| 2855 | - $contenu |
|
| 2856 | - ); |
|
| 2850 | + return preg_replace_callback( |
|
| 2851 | + ",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims", |
|
| 2852 | + function($x) use ($path) { |
|
| 2853 | + return "url('" . suivre_lien($path, $x[1]) . "')"; |
|
| 2854 | + }, |
|
| 2855 | + $contenu |
|
| 2856 | + ); |
|
| 2857 | 2857 | } |
| 2858 | 2858 | |
| 2859 | 2859 | |
@@ -2882,118 +2882,118 @@ discard block |
||
| 2882 | 2882 | * Chemin du fichier CSS inversé |
| 2883 | 2883 | **/ |
| 2884 | 2884 | function direction_css($css, $voulue = '') { |
| 2885 | - if (!preg_match(',(_rtl)?\.css$,i', $css, $r)) { |
|
| 2886 | - return $css; |
|
| 2887 | - } |
|
| 2888 | - include_spip("inc/lang"); |
|
| 2889 | - // si on a precise le sens voulu en argument, le prendre en compte |
|
| 2890 | - if ($voulue = strtolower($voulue)) { |
|
| 2891 | - if ($voulue != 'rtl' and $voulue != 'ltr') { |
|
| 2892 | - $voulue = lang_dir($voulue); |
|
| 2893 | - } |
|
| 2894 | - } else { |
|
| 2895 | - $voulue = lang_dir(); |
|
| 2896 | - } |
|
| 2897 | - |
|
| 2898 | - $r = count($r) > 1; |
|
| 2899 | - $right = $r ? 'left' : 'right'; // 'right' de la css lue en entree |
|
| 2900 | - $dir = $r ? 'rtl' : 'ltr'; |
|
| 2901 | - $ndir = $r ? 'ltr' : 'rtl'; |
|
| 2902 | - |
|
| 2903 | - if ($voulue == $dir) { |
|
| 2904 | - return $css; |
|
| 2905 | - } |
|
| 2906 | - |
|
| 2907 | - if ( |
|
| 2908 | - // url absolue |
|
| 2909 | - preg_match(",^https?:,i", $css) |
|
| 2910 | - // ou qui contient un ? |
|
| 2911 | - or (($p = strpos($css, '?')) !== false) |
|
| 2912 | - ) { |
|
| 2913 | - $distant = true; |
|
| 2914 | - $cssf = parse_url($css); |
|
| 2915 | - $cssf = $cssf['path'] . ($cssf['query'] ? "?" . $cssf['query'] : ""); |
|
| 2916 | - $cssf = preg_replace(',[?:&=],', "_", $cssf); |
|
| 2917 | - } else { |
|
| 2918 | - $distant = false; |
|
| 2919 | - $cssf = $css; |
|
| 2920 | - // 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi |
|
| 2921 | - //propose (rien a faire dans ce cas) |
|
| 2922 | - $f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css); |
|
| 2923 | - if (@file_exists($f)) { |
|
| 2924 | - return $f; |
|
| 2925 | - } |
|
| 2926 | - } |
|
| 2927 | - |
|
| 2928 | - // 2. |
|
| 2929 | - $dir_var = sous_repertoire(_DIR_VAR, 'cache-css'); |
|
| 2930 | - $f = $dir_var |
|
| 2931 | - . preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf) |
|
| 2932 | - . '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css'; |
|
| 2933 | - |
|
| 2934 | - // la css peut etre distante (url absolue !) |
|
| 2935 | - if ($distant) { |
|
| 2936 | - include_spip('inc/distant'); |
|
| 2937 | - $res = recuperer_url($css); |
|
| 2938 | - if (!$res or !$contenu = $res['page']) { |
|
| 2939 | - return $css; |
|
| 2940 | - } |
|
| 2941 | - } else { |
|
| 2942 | - if ((@filemtime($f) > @filemtime($css)) |
|
| 2943 | - and (_VAR_MODE != 'recalcul') |
|
| 2944 | - ) { |
|
| 2945 | - return $f; |
|
| 2946 | - } |
|
| 2947 | - if (!lire_fichier($css, $contenu)) { |
|
| 2948 | - return $css; |
|
| 2949 | - } |
|
| 2950 | - } |
|
| 2951 | - |
|
| 2952 | - |
|
| 2953 | - // Inverser la direction gauche-droite en utilisant CSSTidy qui gere aussi les shorthands |
|
| 2954 | - include_spip("lib/csstidy/class.csstidy"); |
|
| 2955 | - $parser = new csstidy(); |
|
| 2956 | - $parser->set_cfg('optimise_shorthands', 0); |
|
| 2957 | - $parser->set_cfg('reverse_left_and_right', true); |
|
| 2958 | - $parser->parse($contenu); |
|
| 2959 | - |
|
| 2960 | - $contenu = $parser->print->plain(); |
|
| 2961 | - |
|
| 2962 | - |
|
| 2963 | - // reperer les @import auxquels il faut propager le direction_css |
|
| 2964 | - preg_match_all(",\@import\s*url\s*\(\s*['\"]?([^'\"/][^:]*)['\"]?\s*\),Uims", $contenu, $regs); |
|
| 2965 | - $src = array(); |
|
| 2966 | - $src_direction_css = array(); |
|
| 2967 | - $src_faux_abs = array(); |
|
| 2968 | - $d = dirname($css); |
|
| 2969 | - foreach ($regs[1] as $k => $import_css) { |
|
| 2970 | - $css_direction = direction_css("$d/$import_css", $voulue); |
|
| 2971 | - // si la css_direction est dans le meme path que la css d'origine, on tronque le path, elle sera passee en absolue |
|
| 2972 | - if (substr($css_direction, 0, strlen($d) + 1) == "$d/") { |
|
| 2973 | - $css_direction = substr($css_direction, strlen($d) + 1); |
|
| 2974 | - } // si la css_direction commence par $dir_var on la fait passer pour une absolue |
|
| 2975 | - elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) { |
|
| 2976 | - $css_direction = substr($css_direction, strlen($dir_var)); |
|
| 2977 | - $src_faux_abs["/@@@@@@/" . $css_direction] = $css_direction; |
|
| 2978 | - $css_direction = "/@@@@@@/" . $css_direction; |
|
| 2979 | - } |
|
| 2980 | - $src[] = $regs[0][$k]; |
|
| 2981 | - $src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]); |
|
| 2982 | - } |
|
| 2983 | - $contenu = str_replace($src, $src_direction_css, $contenu); |
|
| 2984 | - |
|
| 2985 | - $contenu = urls_absolues_css($contenu, $css); |
|
| 2986 | - |
|
| 2987 | - // virer les fausses url absolues que l'on a mis dans les import |
|
| 2988 | - if (count($src_faux_abs)) { |
|
| 2989 | - $contenu = str_replace(array_keys($src_faux_abs), $src_faux_abs, $contenu); |
|
| 2990 | - } |
|
| 2991 | - |
|
| 2992 | - if (!ecrire_fichier($f, $contenu)) { |
|
| 2993 | - return $css; |
|
| 2994 | - } |
|
| 2995 | - |
|
| 2996 | - return $f; |
|
| 2885 | + if (!preg_match(',(_rtl)?\.css$,i', $css, $r)) { |
|
| 2886 | + return $css; |
|
| 2887 | + } |
|
| 2888 | + include_spip("inc/lang"); |
|
| 2889 | + // si on a precise le sens voulu en argument, le prendre en compte |
|
| 2890 | + if ($voulue = strtolower($voulue)) { |
|
| 2891 | + if ($voulue != 'rtl' and $voulue != 'ltr') { |
|
| 2892 | + $voulue = lang_dir($voulue); |
|
| 2893 | + } |
|
| 2894 | + } else { |
|
| 2895 | + $voulue = lang_dir(); |
|
| 2896 | + } |
|
| 2897 | + |
|
| 2898 | + $r = count($r) > 1; |
|
| 2899 | + $right = $r ? 'left' : 'right'; // 'right' de la css lue en entree |
|
| 2900 | + $dir = $r ? 'rtl' : 'ltr'; |
|
| 2901 | + $ndir = $r ? 'ltr' : 'rtl'; |
|
| 2902 | + |
|
| 2903 | + if ($voulue == $dir) { |
|
| 2904 | + return $css; |
|
| 2905 | + } |
|
| 2906 | + |
|
| 2907 | + if ( |
|
| 2908 | + // url absolue |
|
| 2909 | + preg_match(",^https?:,i", $css) |
|
| 2910 | + // ou qui contient un ? |
|
| 2911 | + or (($p = strpos($css, '?')) !== false) |
|
| 2912 | + ) { |
|
| 2913 | + $distant = true; |
|
| 2914 | + $cssf = parse_url($css); |
|
| 2915 | + $cssf = $cssf['path'] . ($cssf['query'] ? "?" . $cssf['query'] : ""); |
|
| 2916 | + $cssf = preg_replace(',[?:&=],', "_", $cssf); |
|
| 2917 | + } else { |
|
| 2918 | + $distant = false; |
|
| 2919 | + $cssf = $css; |
|
| 2920 | + // 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi |
|
| 2921 | + //propose (rien a faire dans ce cas) |
|
| 2922 | + $f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css); |
|
| 2923 | + if (@file_exists($f)) { |
|
| 2924 | + return $f; |
|
| 2925 | + } |
|
| 2926 | + } |
|
| 2927 | + |
|
| 2928 | + // 2. |
|
| 2929 | + $dir_var = sous_repertoire(_DIR_VAR, 'cache-css'); |
|
| 2930 | + $f = $dir_var |
|
| 2931 | + . preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf) |
|
| 2932 | + . '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css'; |
|
| 2933 | + |
|
| 2934 | + // la css peut etre distante (url absolue !) |
|
| 2935 | + if ($distant) { |
|
| 2936 | + include_spip('inc/distant'); |
|
| 2937 | + $res = recuperer_url($css); |
|
| 2938 | + if (!$res or !$contenu = $res['page']) { |
|
| 2939 | + return $css; |
|
| 2940 | + } |
|
| 2941 | + } else { |
|
| 2942 | + if ((@filemtime($f) > @filemtime($css)) |
|
| 2943 | + and (_VAR_MODE != 'recalcul') |
|
| 2944 | + ) { |
|
| 2945 | + return $f; |
|
| 2946 | + } |
|
| 2947 | + if (!lire_fichier($css, $contenu)) { |
|
| 2948 | + return $css; |
|
| 2949 | + } |
|
| 2950 | + } |
|
| 2951 | + |
|
| 2952 | + |
|
| 2953 | + // Inverser la direction gauche-droite en utilisant CSSTidy qui gere aussi les shorthands |
|
| 2954 | + include_spip("lib/csstidy/class.csstidy"); |
|
| 2955 | + $parser = new csstidy(); |
|
| 2956 | + $parser->set_cfg('optimise_shorthands', 0); |
|
| 2957 | + $parser->set_cfg('reverse_left_and_right', true); |
|
| 2958 | + $parser->parse($contenu); |
|
| 2959 | + |
|
| 2960 | + $contenu = $parser->print->plain(); |
|
| 2961 | + |
|
| 2962 | + |
|
| 2963 | + // reperer les @import auxquels il faut propager le direction_css |
|
| 2964 | + preg_match_all(",\@import\s*url\s*\(\s*['\"]?([^'\"/][^:]*)['\"]?\s*\),Uims", $contenu, $regs); |
|
| 2965 | + $src = array(); |
|
| 2966 | + $src_direction_css = array(); |
|
| 2967 | + $src_faux_abs = array(); |
|
| 2968 | + $d = dirname($css); |
|
| 2969 | + foreach ($regs[1] as $k => $import_css) { |
|
| 2970 | + $css_direction = direction_css("$d/$import_css", $voulue); |
|
| 2971 | + // si la css_direction est dans le meme path que la css d'origine, on tronque le path, elle sera passee en absolue |
|
| 2972 | + if (substr($css_direction, 0, strlen($d) + 1) == "$d/") { |
|
| 2973 | + $css_direction = substr($css_direction, strlen($d) + 1); |
|
| 2974 | + } // si la css_direction commence par $dir_var on la fait passer pour une absolue |
|
| 2975 | + elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) { |
|
| 2976 | + $css_direction = substr($css_direction, strlen($dir_var)); |
|
| 2977 | + $src_faux_abs["/@@@@@@/" . $css_direction] = $css_direction; |
|
| 2978 | + $css_direction = "/@@@@@@/" . $css_direction; |
|
| 2979 | + } |
|
| 2980 | + $src[] = $regs[0][$k]; |
|
| 2981 | + $src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]); |
|
| 2982 | + } |
|
| 2983 | + $contenu = str_replace($src, $src_direction_css, $contenu); |
|
| 2984 | + |
|
| 2985 | + $contenu = urls_absolues_css($contenu, $css); |
|
| 2986 | + |
|
| 2987 | + // virer les fausses url absolues que l'on a mis dans les import |
|
| 2988 | + if (count($src_faux_abs)) { |
|
| 2989 | + $contenu = str_replace(array_keys($src_faux_abs), $src_faux_abs, $contenu); |
|
| 2990 | + } |
|
| 2991 | + |
|
| 2992 | + if (!ecrire_fichier($f, $contenu)) { |
|
| 2993 | + return $css; |
|
| 2994 | + } |
|
| 2995 | + |
|
| 2996 | + return $f; |
|
| 2997 | 2997 | } |
| 2998 | 2998 | |
| 2999 | 2999 | |
@@ -3016,43 +3016,43 @@ discard block |
||
| 3016 | 3016 | * - Chemin ou URL du fichier CSS source sinon. |
| 3017 | 3017 | **/ |
| 3018 | 3018 | function url_absolue_css($css) { |
| 3019 | - if (!preg_match(',\.css$,i', $css, $r)) { |
|
| 3020 | - return $css; |
|
| 3021 | - } |
|
| 3019 | + if (!preg_match(',\.css$,i', $css, $r)) { |
|
| 3020 | + return $css; |
|
| 3021 | + } |
|
| 3022 | 3022 | |
| 3023 | - $url_absolue_css = url_absolue($css); |
|
| 3023 | + $url_absolue_css = url_absolue($css); |
|
| 3024 | 3024 | |
| 3025 | - $f = basename($css, '.css'); |
|
| 3026 | - $f = sous_repertoire(_DIR_VAR, 'cache-css') |
|
| 3027 | - . preg_replace(",(.*?)(_rtl|_ltr)?$,", "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f) |
|
| 3028 | - . '.css'; |
|
| 3025 | + $f = basename($css, '.css'); |
|
| 3026 | + $f = sous_repertoire(_DIR_VAR, 'cache-css') |
|
| 3027 | + . preg_replace(",(.*?)(_rtl|_ltr)?$,", "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f) |
|
| 3028 | + . '.css'; |
|
| 3029 | 3029 | |
| 3030 | - if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) { |
|
| 3031 | - return $f; |
|
| 3032 | - } |
|
| 3030 | + if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) { |
|
| 3031 | + return $f; |
|
| 3032 | + } |
|
| 3033 | 3033 | |
| 3034 | - if ($url_absolue_css == $css) { |
|
| 3035 | - if (strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0 |
|
| 3036 | - or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu) |
|
| 3037 | - ) { |
|
| 3038 | - include_spip('inc/distant'); |
|
| 3039 | - if (!$contenu = recuperer_page($css)) { |
|
| 3040 | - return $css; |
|
| 3041 | - } |
|
| 3042 | - } |
|
| 3043 | - } elseif (!lire_fichier($css, $contenu)) { |
|
| 3044 | - return $css; |
|
| 3045 | - } |
|
| 3034 | + if ($url_absolue_css == $css) { |
|
| 3035 | + if (strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0 |
|
| 3036 | + or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu) |
|
| 3037 | + ) { |
|
| 3038 | + include_spip('inc/distant'); |
|
| 3039 | + if (!$contenu = recuperer_page($css)) { |
|
| 3040 | + return $css; |
|
| 3041 | + } |
|
| 3042 | + } |
|
| 3043 | + } elseif (!lire_fichier($css, $contenu)) { |
|
| 3044 | + return $css; |
|
| 3045 | + } |
|
| 3046 | 3046 | |
| 3047 | - // passer les url relatives a la css d'origine en url absolues |
|
| 3048 | - $contenu = urls_absolues_css($contenu, $css); |
|
| 3047 | + // passer les url relatives a la css d'origine en url absolues |
|
| 3048 | + $contenu = urls_absolues_css($contenu, $css); |
|
| 3049 | 3049 | |
| 3050 | - // ecrire la css |
|
| 3051 | - if (!ecrire_fichier($f, $contenu)) { |
|
| 3052 | - return $css; |
|
| 3053 | - } |
|
| 3050 | + // ecrire la css |
|
| 3051 | + if (!ecrire_fichier($f, $contenu)) { |
|
| 3052 | + return $css; |
|
| 3053 | + } |
|
| 3054 | 3054 | |
| 3055 | - return $f; |
|
| 3055 | + return $f; |
|
| 3056 | 3056 | } |
| 3057 | 3057 | |
| 3058 | 3058 | |
@@ -3086,24 +3086,24 @@ discard block |
||
| 3086 | 3086 | * Valeur trouvée ou valeur par défaut. |
| 3087 | 3087 | **/ |
| 3088 | 3088 | function table_valeur($table, $cle, $defaut = '', $conserver_null = false) { |
| 3089 | - foreach (explode('/', $cle) as $k) { |
|
| 3089 | + foreach (explode('/', $cle) as $k) { |
|
| 3090 | 3090 | |
| 3091 | - $table = is_string($table) ? @unserialize($table) : $table; |
|
| 3091 | + $table = is_string($table) ? @unserialize($table) : $table; |
|
| 3092 | 3092 | |
| 3093 | - if (is_object($table)) { |
|
| 3094 | - $table = (($k !== "") and isset($table->$k)) ? $table->$k : $defaut; |
|
| 3095 | - } elseif (is_array($table)) { |
|
| 3096 | - if ($conserver_null) { |
|
| 3097 | - $table = array_key_exists($k, $table) ? $table[$k] : $defaut; |
|
| 3098 | - } else { |
|
| 3099 | - $table = isset($table[$k]) ? $table[$k] : $defaut; |
|
| 3100 | - } |
|
| 3101 | - } else { |
|
| 3102 | - $table = $defaut; |
|
| 3103 | - } |
|
| 3104 | - } |
|
| 3093 | + if (is_object($table)) { |
|
| 3094 | + $table = (($k !== "") and isset($table->$k)) ? $table->$k : $defaut; |
|
| 3095 | + } elseif (is_array($table)) { |
|
| 3096 | + if ($conserver_null) { |
|
| 3097 | + $table = array_key_exists($k, $table) ? $table[$k] : $defaut; |
|
| 3098 | + } else { |
|
| 3099 | + $table = isset($table[$k]) ? $table[$k] : $defaut; |
|
| 3100 | + } |
|
| 3101 | + } else { |
|
| 3102 | + $table = $defaut; |
|
| 3103 | + } |
|
| 3104 | + } |
|
| 3105 | 3105 | |
| 3106 | - return $table; |
|
| 3106 | + return $table; |
|
| 3107 | 3107 | } |
| 3108 | 3108 | |
| 3109 | 3109 | /** |
@@ -3136,22 +3136,22 @@ discard block |
||
| 3136 | 3136 | * - string : expression trouvée. |
| 3137 | 3137 | **/ |
| 3138 | 3138 | function filtre_match_dist($texte, $expression, $modif = "UimsS", $capte = 0) { |
| 3139 | - if (intval($modif) and $capte == 0) { |
|
| 3140 | - $capte = $modif; |
|
| 3141 | - $modif = "UimsS"; |
|
| 3142 | - } |
|
| 3143 | - $expression = str_replace("\/", "/", $expression); |
|
| 3144 | - $expression = str_replace("/", "\/", $expression); |
|
| 3139 | + if (intval($modif) and $capte == 0) { |
|
| 3140 | + $capte = $modif; |
|
| 3141 | + $modif = "UimsS"; |
|
| 3142 | + } |
|
| 3143 | + $expression = str_replace("\/", "/", $expression); |
|
| 3144 | + $expression = str_replace("/", "\/", $expression); |
|
| 3145 | 3145 | |
| 3146 | - if (preg_match('/' . $expression . '/' . $modif, $texte, $r)) { |
|
| 3147 | - if (isset($r[$capte])) { |
|
| 3148 | - return $r[$capte]; |
|
| 3149 | - } else { |
|
| 3150 | - return true; |
|
| 3151 | - } |
|
| 3152 | - } |
|
| 3146 | + if (preg_match('/' . $expression . '/' . $modif, $texte, $r)) { |
|
| 3147 | + if (isset($r[$capte])) { |
|
| 3148 | + return $r[$capte]; |
|
| 3149 | + } else { |
|
| 3150 | + return true; |
|
| 3151 | + } |
|
| 3152 | + } |
|
| 3153 | 3153 | |
| 3154 | - return false; |
|
| 3154 | + return false; |
|
| 3155 | 3155 | } |
| 3156 | 3156 | |
| 3157 | 3157 | |
@@ -3178,10 +3178,10 @@ discard block |
||
| 3178 | 3178 | * Texte |
| 3179 | 3179 | **/ |
| 3180 | 3180 | function replace($texte, $expression, $replace = '', $modif = "UimsS") { |
| 3181 | - $expression = str_replace("\/", "/", $expression); |
|
| 3182 | - $expression = str_replace("/", "\/", $expression); |
|
| 3181 | + $expression = str_replace("\/", "/", $expression); |
|
| 3182 | + $expression = str_replace("/", "\/", $expression); |
|
| 3183 | 3183 | |
| 3184 | - return preg_replace('/' . $expression . '/' . $modif, $replace, $texte); |
|
| 3184 | + return preg_replace('/' . $expression . '/' . $modif, $replace, $texte); |
|
| 3185 | 3185 | } |
| 3186 | 3186 | |
| 3187 | 3187 | |
@@ -3199,21 +3199,21 @@ discard block |
||
| 3199 | 3199 | **/ |
| 3200 | 3200 | function traiter_doublons_documents(&$doublons, $letexte) { |
| 3201 | 3201 | |
| 3202 | - // Verifier dans le texte & les notes (pas beau, helas) |
|
| 3203 | - $t = $letexte . $GLOBALS['les_notes']; |
|
| 3202 | + // Verifier dans le texte & les notes (pas beau, helas) |
|
| 3203 | + $t = $letexte . $GLOBALS['les_notes']; |
|
| 3204 | 3204 | |
| 3205 | - if (strstr($t, 'spip_document_') // evite le preg_match_all si inutile |
|
| 3206 | - and preg_match_all( |
|
| 3207 | - ',<[^>]+\sclass=["\']spip_document_([0-9]+)[\s"\'],imsS', |
|
| 3208 | - $t, $matches, PREG_PATTERN_ORDER) |
|
| 3209 | - ) { |
|
| 3210 | - if (!isset($doublons['documents'])) { |
|
| 3211 | - $doublons['documents'] = ""; |
|
| 3212 | - } |
|
| 3213 | - $doublons['documents'] .= "," . join(',', $matches[1]); |
|
| 3214 | - } |
|
| 3205 | + if (strstr($t, 'spip_document_') // evite le preg_match_all si inutile |
|
| 3206 | + and preg_match_all( |
|
| 3207 | + ',<[^>]+\sclass=["\']spip_document_([0-9]+)[\s"\'],imsS', |
|
| 3208 | + $t, $matches, PREG_PATTERN_ORDER) |
|
| 3209 | + ) { |
|
| 3210 | + if (!isset($doublons['documents'])) { |
|
| 3211 | + $doublons['documents'] = ""; |
|
| 3212 | + } |
|
| 3213 | + $doublons['documents'] .= "," . join(',', $matches[1]); |
|
| 3214 | + } |
|
| 3215 | 3215 | |
| 3216 | - return $letexte; |
|
| 3216 | + return $letexte; |
|
| 3217 | 3217 | } |
| 3218 | 3218 | |
| 3219 | 3219 | /** |
@@ -3227,7 +3227,7 @@ discard block |
||
| 3227 | 3227 | * @return string Chaîne vide |
| 3228 | 3228 | **/ |
| 3229 | 3229 | function vide($texte) { |
| 3230 | - return ""; |
|
| 3230 | + return ""; |
|
| 3231 | 3231 | } |
| 3232 | 3232 | |
| 3233 | 3233 | // |
@@ -3256,23 +3256,23 @@ discard block |
||
| 3256 | 3256 | * Code HTML résultant |
| 3257 | 3257 | **/ |
| 3258 | 3258 | function env_to_params($env, $ignore_params = array()) { |
| 3259 | - $ignore_params = array_merge( |
|
| 3260 | - array('id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'), |
|
| 3261 | - $ignore_params |
|
| 3262 | - ); |
|
| 3263 | - if (!is_array($env)) { |
|
| 3264 | - $env = unserialize($env); |
|
| 3265 | - } |
|
| 3266 | - $texte = ""; |
|
| 3267 | - if ($env) { |
|
| 3268 | - foreach ($env as $i => $j) { |
|
| 3269 | - if (is_string($j) and !in_array($i, $ignore_params)) { |
|
| 3270 | - $texte .= "<param name='" . attribut_html($i) . "'\n\tvalue='" . attribut_html($j) . "' />"; |
|
| 3271 | - } |
|
| 3272 | - } |
|
| 3273 | - } |
|
| 3274 | - |
|
| 3275 | - return $texte; |
|
| 3259 | + $ignore_params = array_merge( |
|
| 3260 | + array('id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'), |
|
| 3261 | + $ignore_params |
|
| 3262 | + ); |
|
| 3263 | + if (!is_array($env)) { |
|
| 3264 | + $env = unserialize($env); |
|
| 3265 | + } |
|
| 3266 | + $texte = ""; |
|
| 3267 | + if ($env) { |
|
| 3268 | + foreach ($env as $i => $j) { |
|
| 3269 | + if (is_string($j) and !in_array($i, $ignore_params)) { |
|
| 3270 | + $texte .= "<param name='" . attribut_html($i) . "'\n\tvalue='" . attribut_html($j) . "' />"; |
|
| 3271 | + } |
|
| 3272 | + } |
|
| 3273 | + } |
|
| 3274 | + |
|
| 3275 | + return $texte; |
|
| 3276 | 3276 | } |
| 3277 | 3277 | |
| 3278 | 3278 | /** |
@@ -3295,23 +3295,23 @@ discard block |
||
| 3295 | 3295 | * Code HTML résultant |
| 3296 | 3296 | **/ |
| 3297 | 3297 | function env_to_attributs($env, $ignore_params = array()) { |
| 3298 | - $ignore_params = array_merge( |
|
| 3299 | - array('id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'), |
|
| 3300 | - $ignore_params |
|
| 3301 | - ); |
|
| 3302 | - if (!is_array($env)) { |
|
| 3303 | - $env = unserialize($env); |
|
| 3304 | - } |
|
| 3305 | - $texte = ""; |
|
| 3306 | - if ($env) { |
|
| 3307 | - foreach ($env as $i => $j) { |
|
| 3308 | - if (is_string($j) and !in_array($i, $ignore_params)) { |
|
| 3309 | - $texte .= attribut_html($i) . "='" . attribut_html($j) . "' "; |
|
| 3310 | - } |
|
| 3311 | - } |
|
| 3312 | - } |
|
| 3298 | + $ignore_params = array_merge( |
|
| 3299 | + array('id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'), |
|
| 3300 | + $ignore_params |
|
| 3301 | + ); |
|
| 3302 | + if (!is_array($env)) { |
|
| 3303 | + $env = unserialize($env); |
|
| 3304 | + } |
|
| 3305 | + $texte = ""; |
|
| 3306 | + if ($env) { |
|
| 3307 | + foreach ($env as $i => $j) { |
|
| 3308 | + if (is_string($j) and !in_array($i, $ignore_params)) { |
|
| 3309 | + $texte .= attribut_html($i) . "='" . attribut_html($j) . "' "; |
|
| 3310 | + } |
|
| 3311 | + } |
|
| 3312 | + } |
|
| 3313 | 3313 | |
| 3314 | - return $texte; |
|
| 3314 | + return $texte; |
|
| 3315 | 3315 | } |
| 3316 | 3316 | |
| 3317 | 3317 | |
@@ -3328,9 +3328,9 @@ discard block |
||
| 3328 | 3328 | * @return string Chaînes concaténés |
| 3329 | 3329 | **/ |
| 3330 | 3330 | function concat() { |
| 3331 | - $args = func_get_args(); |
|
| 3331 | + $args = func_get_args(); |
|
| 3332 | 3332 | |
| 3333 | - return join('', $args); |
|
| 3333 | + return join('', $args); |
|
| 3334 | 3334 | } |
| 3335 | 3335 | |
| 3336 | 3336 | |
@@ -3350,23 +3350,23 @@ discard block |
||
| 3350 | 3350 | * Contenu du ou des fichiers, concaténé |
| 3351 | 3351 | **/ |
| 3352 | 3352 | function charge_scripts($files, $script = true) { |
| 3353 | - $flux = ""; |
|
| 3354 | - foreach (is_array($files) ? $files : explode("|", $files) as $file) { |
|
| 3355 | - if (!is_string($file)) { |
|
| 3356 | - continue; |
|
| 3357 | - } |
|
| 3358 | - if ($script) { |
|
| 3359 | - $file = preg_match(",^\w+$,", $file) ? "javascript/$file.js" : ''; |
|
| 3360 | - } |
|
| 3361 | - if ($file) { |
|
| 3362 | - $path = find_in_path($file); |
|
| 3363 | - if ($path) { |
|
| 3364 | - $flux .= spip_file_get_contents($path); |
|
| 3365 | - } |
|
| 3366 | - } |
|
| 3367 | - } |
|
| 3353 | + $flux = ""; |
|
| 3354 | + foreach (is_array($files) ? $files : explode("|", $files) as $file) { |
|
| 3355 | + if (!is_string($file)) { |
|
| 3356 | + continue; |
|
| 3357 | + } |
|
| 3358 | + if ($script) { |
|
| 3359 | + $file = preg_match(",^\w+$,", $file) ? "javascript/$file.js" : ''; |
|
| 3360 | + } |
|
| 3361 | + if ($file) { |
|
| 3362 | + $path = find_in_path($file); |
|
| 3363 | + if ($path) { |
|
| 3364 | + $flux .= spip_file_get_contents($path); |
|
| 3365 | + } |
|
| 3366 | + } |
|
| 3367 | + } |
|
| 3368 | 3368 | |
| 3369 | - return $flux; |
|
| 3369 | + return $flux; |
|
| 3370 | 3370 | } |
| 3371 | 3371 | |
| 3372 | 3372 | |
@@ -3388,64 +3388,64 @@ discard block |
||
| 3388 | 3388 | */ |
| 3389 | 3389 | function http_img_pack($img, $alt, $atts = '', $title = '', $options = array()) { |
| 3390 | 3390 | |
| 3391 | - $img_file = $img; |
|
| 3392 | - if ($p = strpos($img_file, '?')) { |
|
| 3393 | - $img_file = substr($img_file,0, $p); |
|
| 3394 | - } |
|
| 3395 | - if (!isset($options['chemin_image']) or $options['chemin_image'] == true) { |
|
| 3396 | - $img_file = chemin_image($img); |
|
| 3397 | - } |
|
| 3398 | - else { |
|
| 3399 | - if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true){ |
|
| 3400 | - // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png |
|
| 3401 | - // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png |
|
| 3402 | - if (preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m) |
|
| 3403 | - and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . "-xx.svg" |
|
| 3404 | - and file_exists($variante_svg_generique)) { |
|
| 3405 | - if ($variante_svg_size = substr($variante_svg_generique,0,-6) . $m[1] . ".svg" and file_exists($variante_svg_size)) { |
|
| 3406 | - $img_file = $variante_svg_size; |
|
| 3407 | - } |
|
| 3408 | - else { |
|
| 3409 | - $img_file = $variante_svg_generique; |
|
| 3410 | - } |
|
| 3411 | - } |
|
| 3412 | - } |
|
| 3413 | - } |
|
| 3414 | - if (stripos($atts, 'width') === false) { |
|
| 3415 | - // utiliser directement l'info de taille presente dans le nom |
|
| 3416 | - if ((!isset($options['utiliser_suffixe_size']) |
|
| 3417 | - or $options['utiliser_suffixe_size'] == true |
|
| 3418 | - or strpos($img_file, '-xx.svg') !== false) |
|
| 3419 | - and (preg_match(',-([0-9]+)[.](png|gif|svg)$,', $img, $regs) |
|
| 3420 | - or preg_match(',\?([0-9]+)px$,', $img, $regs)) |
|
| 3421 | - ) { |
|
| 3422 | - $largeur = $hauteur = intval($regs[1]); |
|
| 3423 | - } else { |
|
| 3424 | - $taille = taille_image($img_file); |
|
| 3425 | - list($hauteur, $largeur) = $taille; |
|
| 3426 | - if (!$hauteur or !$largeur) { |
|
| 3427 | - return ""; |
|
| 3428 | - } |
|
| 3429 | - } |
|
| 3430 | - $atts .= " width='" . $largeur . "' height='" . $hauteur . "'"; |
|
| 3431 | - } |
|
| 3432 | - |
|
| 3433 | - if (file_exists($img_file)) { |
|
| 3434 | - $img_file = timestamp($img_file); |
|
| 3435 | - } |
|
| 3436 | - if ($alt === false) { |
|
| 3437 | - $alt = ''; |
|
| 3438 | - } |
|
| 3439 | - elseif($alt or $alt==='') { |
|
| 3440 | - $alt = " alt='".attribut_html($alt)."'"; |
|
| 3441 | - } |
|
| 3442 | - else { |
|
| 3443 | - $alt = " alt='".attribut_html($title)."'"; |
|
| 3444 | - } |
|
| 3445 | - return "<img src='$img_file'$alt" |
|
| 3446 | - . ($title ? ' title="' . attribut_html($title) . '"' : '') |
|
| 3447 | - . " " . ltrim($atts) |
|
| 3448 | - . " />"; |
|
| 3391 | + $img_file = $img; |
|
| 3392 | + if ($p = strpos($img_file, '?')) { |
|
| 3393 | + $img_file = substr($img_file,0, $p); |
|
| 3394 | + } |
|
| 3395 | + if (!isset($options['chemin_image']) or $options['chemin_image'] == true) { |
|
| 3396 | + $img_file = chemin_image($img); |
|
| 3397 | + } |
|
| 3398 | + else { |
|
| 3399 | + if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true){ |
|
| 3400 | + // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png |
|
| 3401 | + // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png |
|
| 3402 | + if (preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m) |
|
| 3403 | + and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . "-xx.svg" |
|
| 3404 | + and file_exists($variante_svg_generique)) { |
|
| 3405 | + if ($variante_svg_size = substr($variante_svg_generique,0,-6) . $m[1] . ".svg" and file_exists($variante_svg_size)) { |
|
| 3406 | + $img_file = $variante_svg_size; |
|
| 3407 | + } |
|
| 3408 | + else { |
|
| 3409 | + $img_file = $variante_svg_generique; |
|
| 3410 | + } |
|
| 3411 | + } |
|
| 3412 | + } |
|
| 3413 | + } |
|
| 3414 | + if (stripos($atts, 'width') === false) { |
|
| 3415 | + // utiliser directement l'info de taille presente dans le nom |
|
| 3416 | + if ((!isset($options['utiliser_suffixe_size']) |
|
| 3417 | + or $options['utiliser_suffixe_size'] == true |
|
| 3418 | + or strpos($img_file, '-xx.svg') !== false) |
|
| 3419 | + and (preg_match(',-([0-9]+)[.](png|gif|svg)$,', $img, $regs) |
|
| 3420 | + or preg_match(',\?([0-9]+)px$,', $img, $regs)) |
|
| 3421 | + ) { |
|
| 3422 | + $largeur = $hauteur = intval($regs[1]); |
|
| 3423 | + } else { |
|
| 3424 | + $taille = taille_image($img_file); |
|
| 3425 | + list($hauteur, $largeur) = $taille; |
|
| 3426 | + if (!$hauteur or !$largeur) { |
|
| 3427 | + return ""; |
|
| 3428 | + } |
|
| 3429 | + } |
|
| 3430 | + $atts .= " width='" . $largeur . "' height='" . $hauteur . "'"; |
|
| 3431 | + } |
|
| 3432 | + |
|
| 3433 | + if (file_exists($img_file)) { |
|
| 3434 | + $img_file = timestamp($img_file); |
|
| 3435 | + } |
|
| 3436 | + if ($alt === false) { |
|
| 3437 | + $alt = ''; |
|
| 3438 | + } |
|
| 3439 | + elseif($alt or $alt==='') { |
|
| 3440 | + $alt = " alt='".attribut_html($alt)."'"; |
|
| 3441 | + } |
|
| 3442 | + else { |
|
| 3443 | + $alt = " alt='".attribut_html($title)."'"; |
|
| 3444 | + } |
|
| 3445 | + return "<img src='$img_file'$alt" |
|
| 3446 | + . ($title ? ' title="' . attribut_html($title) . '"' : '') |
|
| 3447 | + . " " . ltrim($atts) |
|
| 3448 | + . " />"; |
|
| 3449 | 3449 | } |
| 3450 | 3450 | |
| 3451 | 3451 | /** |
@@ -3457,68 +3457,68 @@ discard block |
||
| 3457 | 3457 | * @return string |
| 3458 | 3458 | */ |
| 3459 | 3459 | function http_style_background($img, $att = '', $size=null) { |
| 3460 | - if ($size and is_numeric($size)){ |
|
| 3461 | - $size = trim($size) . "px"; |
|
| 3462 | - } |
|
| 3463 | - return " style='background" . |
|
| 3464 | - ($att ? "" : "-image") . ": url(\"" . chemin_image($img) . "\")" . ($att ? (' ' . $att) : '') . ";" |
|
| 3465 | - . ($size ? "background-size:{$size};" : '') |
|
| 3466 | - . "'"; |
|
| 3460 | + if ($size and is_numeric($size)){ |
|
| 3461 | + $size = trim($size) . "px"; |
|
| 3462 | + } |
|
| 3463 | + return " style='background" . |
|
| 3464 | + ($att ? "" : "-image") . ": url(\"" . chemin_image($img) . "\")" . ($att ? (' ' . $att) : '') . ";" |
|
| 3465 | + . ($size ? "background-size:{$size};" : '') |
|
| 3466 | + . "'"; |
|
| 3467 | 3467 | } |
| 3468 | 3468 | |
| 3469 | 3469 | |
| 3470 | 3470 | function helper_filtre_balise_img_svg_arguments($alt_or_size, $class_or_size, $size) { |
| 3471 | - $args = [$alt_or_size, $class_or_size, $size]; |
|
| 3472 | - while (is_null(end($args)) and count($args)) { |
|
| 3473 | - array_pop($args); |
|
| 3474 | - } |
|
| 3475 | - if (!count($args)) { |
|
| 3476 | - return [null, null, null]; |
|
| 3477 | - } |
|
| 3478 | - if (count($args) < 3) { |
|
| 3479 | - $maybe_size = array_pop($args); |
|
| 3480 | - // @2x |
|
| 3481 | - // @1.5x |
|
| 3482 | - // 512 |
|
| 3483 | - // 512x* |
|
| 3484 | - // 512x300 |
|
| 3485 | - if (!strlen($maybe_size) |
|
| 3486 | - or !preg_match(',^(@\d+(\.\d+)?x|\d+(x\*)?|\d+x\d+)$,', trim($maybe_size))) { |
|
| 3487 | - $args[] = $maybe_size; |
|
| 3488 | - $maybe_size = null; |
|
| 3489 | - } |
|
| 3490 | - while (count($args)<2) { |
|
| 3491 | - $args[] = null; // default alt or class |
|
| 3492 | - } |
|
| 3493 | - $args[] = $maybe_size; |
|
| 3494 | - } |
|
| 3495 | - return $args; |
|
| 3471 | + $args = [$alt_or_size, $class_or_size, $size]; |
|
| 3472 | + while (is_null(end($args)) and count($args)) { |
|
| 3473 | + array_pop($args); |
|
| 3474 | + } |
|
| 3475 | + if (!count($args)) { |
|
| 3476 | + return [null, null, null]; |
|
| 3477 | + } |
|
| 3478 | + if (count($args) < 3) { |
|
| 3479 | + $maybe_size = array_pop($args); |
|
| 3480 | + // @2x |
|
| 3481 | + // @1.5x |
|
| 3482 | + // 512 |
|
| 3483 | + // 512x* |
|
| 3484 | + // 512x300 |
|
| 3485 | + if (!strlen($maybe_size) |
|
| 3486 | + or !preg_match(',^(@\d+(\.\d+)?x|\d+(x\*)?|\d+x\d+)$,', trim($maybe_size))) { |
|
| 3487 | + $args[] = $maybe_size; |
|
| 3488 | + $maybe_size = null; |
|
| 3489 | + } |
|
| 3490 | + while (count($args)<2) { |
|
| 3491 | + $args[] = null; // default alt or class |
|
| 3492 | + } |
|
| 3493 | + $args[] = $maybe_size; |
|
| 3494 | + } |
|
| 3495 | + return $args; |
|
| 3496 | 3496 | } |
| 3497 | 3497 | |
| 3498 | 3498 | function helper_filtre_balise_img_svg_size($img, $size) { |
| 3499 | - // si size est de la forme '@2x' c'est un coeff multiplicateur sur la densite |
|
| 3500 | - if (strpos($size, '@') === 0 and substr($size,-1) === 'x') { |
|
| 3501 | - $coef = floatval(substr($size, 1, -1)); |
|
| 3502 | - list($h, $w) = taille_image($img); |
|
| 3503 | - $height = intval(round($h / $coef)); |
|
| 3504 | - $width = intval(round($w / $coef)); |
|
| 3505 | - } |
|
| 3506 | - // sinon c'est une valeur seule si image caree ou largeurxhauteur |
|
| 3507 | - else { |
|
| 3508 | - $size = explode('x', $size, 2); |
|
| 3509 | - $size = array_map('trim', $size); |
|
| 3510 | - $height = $width = intval(array_shift($size)); |
|
| 3511 | - |
|
| 3512 | - if (count($size) and reset($size)) { |
|
| 3513 | - $height = array_shift($size); |
|
| 3514 | - if ($height === '*') { |
|
| 3515 | - list($h, $w) = taille_image($img); |
|
| 3516 | - $height = intval(round($h * $width / $w)); |
|
| 3517 | - } |
|
| 3518 | - } |
|
| 3519 | - } |
|
| 3520 | - |
|
| 3521 | - return [$width, $height]; |
|
| 3499 | + // si size est de la forme '@2x' c'est un coeff multiplicateur sur la densite |
|
| 3500 | + if (strpos($size, '@') === 0 and substr($size,-1) === 'x') { |
|
| 3501 | + $coef = floatval(substr($size, 1, -1)); |
|
| 3502 | + list($h, $w) = taille_image($img); |
|
| 3503 | + $height = intval(round($h / $coef)); |
|
| 3504 | + $width = intval(round($w / $coef)); |
|
| 3505 | + } |
|
| 3506 | + // sinon c'est une valeur seule si image caree ou largeurxhauteur |
|
| 3507 | + else { |
|
| 3508 | + $size = explode('x', $size, 2); |
|
| 3509 | + $size = array_map('trim', $size); |
|
| 3510 | + $height = $width = intval(array_shift($size)); |
|
| 3511 | + |
|
| 3512 | + if (count($size) and reset($size)) { |
|
| 3513 | + $height = array_shift($size); |
|
| 3514 | + if ($height === '*') { |
|
| 3515 | + list($h, $w) = taille_image($img); |
|
| 3516 | + $height = intval(round($h * $width / $w)); |
|
| 3517 | + } |
|
| 3518 | + } |
|
| 3519 | + } |
|
| 3520 | + |
|
| 3521 | + return [$width, $height]; |
|
| 3522 | 3522 | } |
| 3523 | 3523 | |
| 3524 | 3524 | /** |
@@ -3554,38 +3554,38 @@ discard block |
||
| 3554 | 3554 | */ |
| 3555 | 3555 | function filtre_balise_img_dist($img, $alt = '', $class = null, $size=null) { |
| 3556 | 3556 | |
| 3557 | - list($alt, $class, $size) = helper_filtre_balise_img_svg_arguments($alt, $class, $size); |
|
| 3557 | + list($alt, $class, $size) = helper_filtre_balise_img_svg_arguments($alt, $class, $size); |
|
| 3558 | 3558 | |
| 3559 | - $img = trim($img); |
|
| 3560 | - if (strpos($img, '<img') === 0) { |
|
| 3561 | - if (!is_null($alt)) { |
|
| 3562 | - $img = inserer_attribut($img, 'alt', $alt); |
|
| 3563 | - } |
|
| 3564 | - if (!is_null($class)) { |
|
| 3565 | - if (strlen($class)) { |
|
| 3566 | - $img = inserer_attribut($img, 'class', $class); |
|
| 3567 | - } |
|
| 3568 | - else { |
|
| 3569 | - $img = vider_attribut($img, 'class'); |
|
| 3570 | - } |
|
| 3571 | - } |
|
| 3572 | - } |
|
| 3573 | - else { |
|
| 3574 | - $img = http_img_pack($img, $alt, $class ? " class='" . attribut_html($class) . "'" : '', '', |
|
| 3575 | - array('chemin_image' => false, 'utiliser_suffixe_size' => false)); |
|
| 3576 | - if (is_null($alt)) { |
|
| 3577 | - $img = vider_attribut($img, 'alt'); |
|
| 3578 | - } |
|
| 3579 | - } |
|
| 3559 | + $img = trim($img); |
|
| 3560 | + if (strpos($img, '<img') === 0) { |
|
| 3561 | + if (!is_null($alt)) { |
|
| 3562 | + $img = inserer_attribut($img, 'alt', $alt); |
|
| 3563 | + } |
|
| 3564 | + if (!is_null($class)) { |
|
| 3565 | + if (strlen($class)) { |
|
| 3566 | + $img = inserer_attribut($img, 'class', $class); |
|
| 3567 | + } |
|
| 3568 | + else { |
|
| 3569 | + $img = vider_attribut($img, 'class'); |
|
| 3570 | + } |
|
| 3571 | + } |
|
| 3572 | + } |
|
| 3573 | + else { |
|
| 3574 | + $img = http_img_pack($img, $alt, $class ? " class='" . attribut_html($class) . "'" : '', '', |
|
| 3575 | + array('chemin_image' => false, 'utiliser_suffixe_size' => false)); |
|
| 3576 | + if (is_null($alt)) { |
|
| 3577 | + $img = vider_attribut($img, 'alt'); |
|
| 3578 | + } |
|
| 3579 | + } |
|
| 3580 | 3580 | |
| 3581 | - if ($img and !is_null($size) and strlen($size = trim($size))) { |
|
| 3582 | - list($width, $height) = helper_filtre_balise_img_svg_size($img, $size); |
|
| 3581 | + if ($img and !is_null($size) and strlen($size = trim($size))) { |
|
| 3582 | + list($width, $height) = helper_filtre_balise_img_svg_size($img, $size); |
|
| 3583 | 3583 | |
| 3584 | - $img = inserer_attribut($img, 'width', $width); |
|
| 3585 | - $img = inserer_attribut($img, 'height', $height); |
|
| 3586 | - } |
|
| 3584 | + $img = inserer_attribut($img, 'width', $width); |
|
| 3585 | + $img = inserer_attribut($img, 'height', $height); |
|
| 3586 | + } |
|
| 3587 | 3587 | |
| 3588 | - return $img; |
|
| 3588 | + return $img; |
|
| 3589 | 3589 | } |
| 3590 | 3590 | |
| 3591 | 3591 | |
@@ -3619,67 +3619,67 @@ discard block |
||
| 3619 | 3619 | */ |
| 3620 | 3620 | function filtre_balise_svg_dist($img, $alt = '', $class = null, $size=null) { |
| 3621 | 3621 | |
| 3622 | - $img = trim($img); |
|
| 3623 | - $img_file = $img; |
|
| 3624 | - if (strpos($img, '<svg') === false){ |
|
| 3625 | - if ($p = strpos($img_file, '?')){ |
|
| 3626 | - $img_file = substr($img_file, 0, $p); |
|
| 3627 | - } |
|
| 3622 | + $img = trim($img); |
|
| 3623 | + $img_file = $img; |
|
| 3624 | + if (strpos($img, '<svg') === false){ |
|
| 3625 | + if ($p = strpos($img_file, '?')){ |
|
| 3626 | + $img_file = substr($img_file, 0, $p); |
|
| 3627 | + } |
|
| 3628 | 3628 | |
| 3629 | - if (!$img_file or !$svg = file_get_contents($img_file)){ |
|
| 3630 | - return ''; |
|
| 3631 | - } |
|
| 3632 | - } |
|
| 3629 | + if (!$img_file or !$svg = file_get_contents($img_file)){ |
|
| 3630 | + return ''; |
|
| 3631 | + } |
|
| 3632 | + } |
|
| 3633 | 3633 | |
| 3634 | - if (!preg_match(",<svg\b[^>]*>,UimsS", $svg, $match)) { |
|
| 3635 | - return ''; |
|
| 3636 | - } |
|
| 3634 | + if (!preg_match(",<svg\b[^>]*>,UimsS", $svg, $match)) { |
|
| 3635 | + return ''; |
|
| 3636 | + } |
|
| 3637 | 3637 | |
| 3638 | - list($alt, $class, $size) = helper_filtre_balise_img_svg_arguments($alt, $class, $size); |
|
| 3638 | + list($alt, $class, $size) = helper_filtre_balise_img_svg_arguments($alt, $class, $size); |
|
| 3639 | 3639 | |
| 3640 | - $balise_svg = $match[0]; |
|
| 3641 | - $balise_svg_source = $balise_svg; |
|
| 3640 | + $balise_svg = $match[0]; |
|
| 3641 | + $balise_svg_source = $balise_svg; |
|
| 3642 | 3642 | |
| 3643 | - // entete XML Ã supprimer |
|
| 3644 | - $svg = preg_replace(',^\s*<\?xml[^>]*\?' . '>,', '', $svg); |
|
| 3643 | + // entete XML Ã supprimer |
|
| 3644 | + $svg = preg_replace(',^\s*<\?xml[^>]*\?' . '>,', '', $svg); |
|
| 3645 | 3645 | |
| 3646 | - // IE est toujours mon ami |
|
| 3647 | - $balise_svg = inserer_attribut($balise_svg, 'focusable', 'false'); |
|
| 3646 | + // IE est toujours mon ami |
|
| 3647 | + $balise_svg = inserer_attribut($balise_svg, 'focusable', 'false'); |
|
| 3648 | 3648 | |
| 3649 | - // regler la classe |
|
| 3650 | - if (!is_null($class)) { |
|
| 3651 | - if (strlen($class)) { |
|
| 3652 | - $balise_svg = inserer_attribut($balise_svg, 'class', $class); |
|
| 3653 | - } |
|
| 3654 | - else { |
|
| 3655 | - $balise_svg = vider_attribut($balise_svg, 'class'); |
|
| 3656 | - } |
|
| 3657 | - } |
|
| 3649 | + // regler la classe |
|
| 3650 | + if (!is_null($class)) { |
|
| 3651 | + if (strlen($class)) { |
|
| 3652 | + $balise_svg = inserer_attribut($balise_svg, 'class', $class); |
|
| 3653 | + } |
|
| 3654 | + else { |
|
| 3655 | + $balise_svg = vider_attribut($balise_svg, 'class'); |
|
| 3656 | + } |
|
| 3657 | + } |
|
| 3658 | 3658 | |
| 3659 | - // regler le alt |
|
| 3660 | - if ($alt){ |
|
| 3661 | - $balise_svg = inserer_attribut($balise_svg, 'role', 'img'); |
|
| 3662 | - $id = "img-svg-title-" . substr(md5("$img_file:$svg:$alt"),0,4); |
|
| 3663 | - $balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id); |
|
| 3664 | - $title = "<title id=\"$id\">" . entites_html($alt)."</title>\n"; |
|
| 3665 | - $balise_svg .= $title; |
|
| 3666 | - } |
|
| 3667 | - else { |
|
| 3668 | - $balise_svg = inserer_attribut($balise_svg, 'aria-hidden', 'true'); |
|
| 3669 | - } |
|
| 3659 | + // regler le alt |
|
| 3660 | + if ($alt){ |
|
| 3661 | + $balise_svg = inserer_attribut($balise_svg, 'role', 'img'); |
|
| 3662 | + $id = "img-svg-title-" . substr(md5("$img_file:$svg:$alt"),0,4); |
|
| 3663 | + $balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id); |
|
| 3664 | + $title = "<title id=\"$id\">" . entites_html($alt)."</title>\n"; |
|
| 3665 | + $balise_svg .= $title; |
|
| 3666 | + } |
|
| 3667 | + else { |
|
| 3668 | + $balise_svg = inserer_attribut($balise_svg, 'aria-hidden', 'true'); |
|
| 3669 | + } |
|
| 3670 | 3670 | |
| 3671 | - $svg = str_replace($balise_svg_source, $balise_svg, $svg); |
|
| 3671 | + $svg = str_replace($balise_svg_source, $balise_svg, $svg); |
|
| 3672 | 3672 | |
| 3673 | - if (!is_null($size) and strlen($size = trim($size))) { |
|
| 3674 | - list($width, $height) = helper_filtre_balise_img_svg_size($svg, $size); |
|
| 3673 | + if (!is_null($size) and strlen($size = trim($size))) { |
|
| 3674 | + list($width, $height) = helper_filtre_balise_img_svg_size($svg, $size); |
|
| 3675 | 3675 | |
| 3676 | - if (!function_exists('svg_redimensionner')) { |
|
| 3677 | - include_spip('inc/svg'); |
|
| 3678 | - } |
|
| 3679 | - $svg = svg_redimensionner($svg, $width, $height); |
|
| 3680 | - } |
|
| 3676 | + if (!function_exists('svg_redimensionner')) { |
|
| 3677 | + include_spip('inc/svg'); |
|
| 3678 | + } |
|
| 3679 | + $svg = svg_redimensionner($svg, $width, $height); |
|
| 3680 | + } |
|
| 3681 | 3681 | |
| 3682 | - return $svg; |
|
| 3682 | + return $svg; |
|
| 3683 | 3683 | } |
| 3684 | 3684 | |
| 3685 | 3685 | |
@@ -3702,17 +3702,17 @@ discard block |
||
| 3702 | 3702 | * Code HTML résultant |
| 3703 | 3703 | **/ |
| 3704 | 3704 | function filtre_foreach_dist($tableau, $modele = 'foreach') { |
| 3705 | - $texte = ''; |
|
| 3706 | - if (is_array($tableau)) { |
|
| 3707 | - foreach ($tableau as $k => $v) { |
|
| 3708 | - $res = recuperer_fond('modeles/' . $modele, |
|
| 3709 | - array_merge(array('cle' => $k), (is_array($v) ? $v : array('valeur' => $v))) |
|
| 3710 | - ); |
|
| 3711 | - $texte .= $res; |
|
| 3712 | - } |
|
| 3713 | - } |
|
| 3705 | + $texte = ''; |
|
| 3706 | + if (is_array($tableau)) { |
|
| 3707 | + foreach ($tableau as $k => $v) { |
|
| 3708 | + $res = recuperer_fond('modeles/' . $modele, |
|
| 3709 | + array_merge(array('cle' => $k), (is_array($v) ? $v : array('valeur' => $v))) |
|
| 3710 | + ); |
|
| 3711 | + $texte .= $res; |
|
| 3712 | + } |
|
| 3713 | + } |
|
| 3714 | 3714 | |
| 3715 | - return $texte; |
|
| 3715 | + return $texte; |
|
| 3716 | 3716 | } |
| 3717 | 3717 | |
| 3718 | 3718 | |
@@ -3737,37 +3737,37 @@ discard block |
||
| 3737 | 3737 | * - tout : retourne toutes les informations du plugin actif |
| 3738 | 3738 | **/ |
| 3739 | 3739 | function filtre_info_plugin_dist($plugin, $type_info, $reload = false) { |
| 3740 | - include_spip('inc/plugin'); |
|
| 3741 | - $plugin = strtoupper($plugin); |
|
| 3742 | - $plugins_actifs = liste_plugin_actifs(); |
|
| 3743 | - |
|
| 3744 | - if (!$plugin) { |
|
| 3745 | - return serialize(array_keys($plugins_actifs)); |
|
| 3746 | - } elseif (empty($plugins_actifs[$plugin]) and !$reload) { |
|
| 3747 | - return ''; |
|
| 3748 | - } elseif (($type_info == 'est_actif') and !$reload) { |
|
| 3749 | - return $plugins_actifs[$plugin] ? 1 : 0; |
|
| 3750 | - } elseif (isset($plugins_actifs[$plugin][$type_info]) and !$reload) { |
|
| 3751 | - return $plugins_actifs[$plugin][$type_info]; |
|
| 3752 | - } else { |
|
| 3753 | - $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 3754 | - // On prend en compte les extensions |
|
| 3755 | - if (!is_dir($plugins_actifs[$plugin]['dir_type'])) { |
|
| 3756 | - $dir_plugins = constant($plugins_actifs[$plugin]['dir_type']); |
|
| 3757 | - } else { |
|
| 3758 | - $dir_plugins = $plugins_actifs[$plugin]['dir_type']; |
|
| 3759 | - } |
|
| 3760 | - if (!$infos = $get_infos($plugins_actifs[$plugin]['dir'], $reload, $dir_plugins)) { |
|
| 3761 | - return ''; |
|
| 3762 | - } |
|
| 3763 | - if ($type_info == 'tout') { |
|
| 3764 | - return $infos; |
|
| 3765 | - } elseif ($type_info == 'est_actif') { |
|
| 3766 | - return $infos ? 1 : 0; |
|
| 3767 | - } else { |
|
| 3768 | - return strval($infos[$type_info]); |
|
| 3769 | - } |
|
| 3770 | - } |
|
| 3740 | + include_spip('inc/plugin'); |
|
| 3741 | + $plugin = strtoupper($plugin); |
|
| 3742 | + $plugins_actifs = liste_plugin_actifs(); |
|
| 3743 | + |
|
| 3744 | + if (!$plugin) { |
|
| 3745 | + return serialize(array_keys($plugins_actifs)); |
|
| 3746 | + } elseif (empty($plugins_actifs[$plugin]) and !$reload) { |
|
| 3747 | + return ''; |
|
| 3748 | + } elseif (($type_info == 'est_actif') and !$reload) { |
|
| 3749 | + return $plugins_actifs[$plugin] ? 1 : 0; |
|
| 3750 | + } elseif (isset($plugins_actifs[$plugin][$type_info]) and !$reload) { |
|
| 3751 | + return $plugins_actifs[$plugin][$type_info]; |
|
| 3752 | + } else { |
|
| 3753 | + $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 3754 | + // On prend en compte les extensions |
|
| 3755 | + if (!is_dir($plugins_actifs[$plugin]['dir_type'])) { |
|
| 3756 | + $dir_plugins = constant($plugins_actifs[$plugin]['dir_type']); |
|
| 3757 | + } else { |
|
| 3758 | + $dir_plugins = $plugins_actifs[$plugin]['dir_type']; |
|
| 3759 | + } |
|
| 3760 | + if (!$infos = $get_infos($plugins_actifs[$plugin]['dir'], $reload, $dir_plugins)) { |
|
| 3761 | + return ''; |
|
| 3762 | + } |
|
| 3763 | + if ($type_info == 'tout') { |
|
| 3764 | + return $infos; |
|
| 3765 | + } elseif ($type_info == 'est_actif') { |
|
| 3766 | + return $infos ? 1 : 0; |
|
| 3767 | + } else { |
|
| 3768 | + return strval($infos[$type_info]); |
|
| 3769 | + } |
|
| 3770 | + } |
|
| 3771 | 3771 | } |
| 3772 | 3772 | |
| 3773 | 3773 | |
@@ -3794,9 +3794,9 @@ discard block |
||
| 3794 | 3794 | * Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent) |
| 3795 | 3795 | */ |
| 3796 | 3796 | function puce_changement_statut($id_objet, $statut, $id_rubrique, $type, $ajax = false) { |
| 3797 | - $puce_statut = charger_fonction('puce_statut', 'inc'); |
|
| 3797 | + $puce_statut = charger_fonction('puce_statut', 'inc'); |
|
| 3798 | 3798 | |
| 3799 | - return $puce_statut($id_objet, $statut, $id_rubrique, $type, $ajax); |
|
| 3799 | + return $puce_statut($id_objet, $statut, $id_rubrique, $type, $ajax); |
|
| 3800 | 3800 | } |
| 3801 | 3801 | |
| 3802 | 3802 | |
@@ -3826,13 +3826,13 @@ discard block |
||
| 3826 | 3826 | * Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent) |
| 3827 | 3827 | */ |
| 3828 | 3828 | function filtre_puce_statut_dist($statut, $objet, $id_objet = 0, $id_parent = 0) { |
| 3829 | - static $puce_statut = null; |
|
| 3830 | - if (!$puce_statut) { |
|
| 3831 | - $puce_statut = charger_fonction('puce_statut', 'inc'); |
|
| 3832 | - } |
|
| 3829 | + static $puce_statut = null; |
|
| 3830 | + if (!$puce_statut) { |
|
| 3831 | + $puce_statut = charger_fonction('puce_statut', 'inc'); |
|
| 3832 | + } |
|
| 3833 | 3833 | |
| 3834 | - return $puce_statut($id_objet, $statut, $id_parent, $objet, false, |
|
| 3835 | - objet_info($objet, 'editable') ? _ACTIVER_PUCE_RAPIDE : false); |
|
| 3834 | + return $puce_statut($id_objet, $statut, $id_parent, $objet, false, |
|
| 3835 | + objet_info($objet, 'editable') ? _ACTIVER_PUCE_RAPIDE : false); |
|
| 3836 | 3836 | } |
| 3837 | 3837 | |
| 3838 | 3838 | |
@@ -3859,95 +3859,95 @@ discard block |
||
| 3859 | 3859 | * hash du contexte |
| 3860 | 3860 | */ |
| 3861 | 3861 | function encoder_contexte_ajax($c, $form = '', $emboite = null, $ajaxid = '') { |
| 3862 | - if (is_string($c) |
|
| 3863 | - and @unserialize($c) !== false |
|
| 3864 | - ) { |
|
| 3865 | - $c = unserialize($c); |
|
| 3866 | - } |
|
| 3867 | - |
|
| 3868 | - // supprimer les parametres debut_x |
|
| 3869 | - // pour que la pagination ajax ne soit pas plantee |
|
| 3870 | - // si on charge la page &debut_x=1 : car alors en cliquant sur l'item 0, |
|
| 3871 | - // le debut_x=0 n'existe pas, et on resterait sur 1 |
|
| 3872 | - if (is_array($c)) { |
|
| 3873 | - foreach ($c as $k => $v) { |
|
| 3874 | - if (strpos($k, 'debut_') === 0) { |
|
| 3875 | - unset($c[$k]); |
|
| 3876 | - } |
|
| 3877 | - } |
|
| 3878 | - } |
|
| 3879 | - |
|
| 3880 | - if (!function_exists('calculer_cle_action')) { |
|
| 3881 | - include_spip("inc/securiser_action"); |
|
| 3882 | - } |
|
| 3883 | - |
|
| 3884 | - $c = serialize($c); |
|
| 3885 | - $cle = calculer_cle_action($form . $c); |
|
| 3886 | - $c = "$cle:$c"; |
|
| 3887 | - |
|
| 3888 | - // on ne stocke pas les contextes dans des fichiers en cache |
|
| 3889 | - // par defaut, sauf si cette configuration a été forcée |
|
| 3890 | - // OU que la longueur de l’argument géneré est plus long |
|
| 3891 | - // que ce qui est toléré. |
|
| 3892 | - $cache_contextes_ajax = (defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX); |
|
| 3893 | - if (!$cache_contextes_ajax) { |
|
| 3894 | - $env = $c; |
|
| 3895 | - if (function_exists('gzdeflate') && function_exists('gzinflate')) { |
|
| 3896 | - $env = gzdeflate($env); |
|
| 3897 | - } |
|
| 3898 | - $env = _xor($env); |
|
| 3899 | - $env = base64_encode($env); |
|
| 3900 | - $len = strlen($env); |
|
| 3901 | - // Si l’url est trop longue pour le navigateur |
|
| 3902 | - $max_len = _CACHE_CONTEXTES_AJAX_SUR_LONGUEUR; |
|
| 3903 | - if ($len > $max_len) { |
|
| 3904 | - $cache_contextes_ajax = true; |
|
| 3905 | - spip_log("Contextes AJAX forces en fichiers !" |
|
| 3906 | - . " Cela arrive lorsque la valeur du contexte" |
|
| 3907 | - . " depasse la longueur maximale autorisee ($max_len). Ici : $len." |
|
| 3908 | - , _LOG_AVERTISSEMENT); |
|
| 3909 | - } |
|
| 3910 | - // Sinon si Suhosin est actif et a une la valeur maximale des variables en GET... |
|
| 3911 | - elseif ( |
|
| 3912 | - $max_len = @ini_get('suhosin.get.max_value_length') |
|
| 3913 | - and $max_len < $len |
|
| 3914 | - ) { |
|
| 3915 | - $cache_contextes_ajax = true; |
|
| 3916 | - spip_log("Contextes AJAX forces en fichiers !" |
|
| 3917 | - . " Cela arrive lorsque la valeur du contexte" |
|
| 3918 | - . " depasse la longueur maximale autorisee par Suhosin" |
|
| 3919 | - . " ($max_len) dans 'suhosin.get.max_value_length'. Ici : $len." |
|
| 3920 | - . " Vous devriez modifier les parametres de Suhosin" |
|
| 3921 | - . " pour accepter au moins 1024 caracteres.", _LOG_AVERTISSEMENT); |
|
| 3922 | - } |
|
| 3923 | - |
|
| 3924 | - } |
|
| 3925 | - |
|
| 3926 | - if ($cache_contextes_ajax) { |
|
| 3927 | - $dir = sous_repertoire(_DIR_CACHE, 'contextes'); |
|
| 3928 | - // stocker les contextes sur disque et ne passer qu'un hash dans l'url |
|
| 3929 | - $md5 = md5($c); |
|
| 3930 | - ecrire_fichier("$dir/c$md5", $c); |
|
| 3931 | - $env = $md5; |
|
| 3932 | - } |
|
| 3933 | - |
|
| 3934 | - if ($emboite === null) { |
|
| 3935 | - return $env; |
|
| 3936 | - } |
|
| 3937 | - if (!trim($emboite)) { |
|
| 3938 | - return ""; |
|
| 3939 | - } |
|
| 3940 | - // toujours encoder l'url source dans le bloc ajax |
|
| 3941 | - $r = self(); |
|
| 3942 | - $r = ' data-origin="' . $r . '"'; |
|
| 3943 | - $class = 'ajaxbloc'; |
|
| 3944 | - if ($ajaxid and is_string($ajaxid)) { |
|
| 3945 | - // ajaxid est normalement conforme a un nom de classe css |
|
| 3946 | - // on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution |
|
| 3947 | - $class .= ' ajax-id-' . entites_html($ajaxid); |
|
| 3948 | - } |
|
| 3949 | - |
|
| 3950 | - return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n"; |
|
| 3862 | + if (is_string($c) |
|
| 3863 | + and @unserialize($c) !== false |
|
| 3864 | + ) { |
|
| 3865 | + $c = unserialize($c); |
|
| 3866 | + } |
|
| 3867 | + |
|
| 3868 | + // supprimer les parametres debut_x |
|
| 3869 | + // pour que la pagination ajax ne soit pas plantee |
|
| 3870 | + // si on charge la page &debut_x=1 : car alors en cliquant sur l'item 0, |
|
| 3871 | + // le debut_x=0 n'existe pas, et on resterait sur 1 |
|
| 3872 | + if (is_array($c)) { |
|
| 3873 | + foreach ($c as $k => $v) { |
|
| 3874 | + if (strpos($k, 'debut_') === 0) { |
|
| 3875 | + unset($c[$k]); |
|
| 3876 | + } |
|
| 3877 | + } |
|
| 3878 | + } |
|
| 3879 | + |
|
| 3880 | + if (!function_exists('calculer_cle_action')) { |
|
| 3881 | + include_spip("inc/securiser_action"); |
|
| 3882 | + } |
|
| 3883 | + |
|
| 3884 | + $c = serialize($c); |
|
| 3885 | + $cle = calculer_cle_action($form . $c); |
|
| 3886 | + $c = "$cle:$c"; |
|
| 3887 | + |
|
| 3888 | + // on ne stocke pas les contextes dans des fichiers en cache |
|
| 3889 | + // par defaut, sauf si cette configuration a été forcée |
|
| 3890 | + // OU que la longueur de l’argument géneré est plus long |
|
| 3891 | + // que ce qui est toléré. |
|
| 3892 | + $cache_contextes_ajax = (defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX); |
|
| 3893 | + if (!$cache_contextes_ajax) { |
|
| 3894 | + $env = $c; |
|
| 3895 | + if (function_exists('gzdeflate') && function_exists('gzinflate')) { |
|
| 3896 | + $env = gzdeflate($env); |
|
| 3897 | + } |
|
| 3898 | + $env = _xor($env); |
|
| 3899 | + $env = base64_encode($env); |
|
| 3900 | + $len = strlen($env); |
|
| 3901 | + // Si l’url est trop longue pour le navigateur |
|
| 3902 | + $max_len = _CACHE_CONTEXTES_AJAX_SUR_LONGUEUR; |
|
| 3903 | + if ($len > $max_len) { |
|
| 3904 | + $cache_contextes_ajax = true; |
|
| 3905 | + spip_log("Contextes AJAX forces en fichiers !" |
|
| 3906 | + . " Cela arrive lorsque la valeur du contexte" |
|
| 3907 | + . " depasse la longueur maximale autorisee ($max_len). Ici : $len." |
|
| 3908 | + , _LOG_AVERTISSEMENT); |
|
| 3909 | + } |
|
| 3910 | + // Sinon si Suhosin est actif et a une la valeur maximale des variables en GET... |
|
| 3911 | + elseif ( |
|
| 3912 | + $max_len = @ini_get('suhosin.get.max_value_length') |
|
| 3913 | + and $max_len < $len |
|
| 3914 | + ) { |
|
| 3915 | + $cache_contextes_ajax = true; |
|
| 3916 | + spip_log("Contextes AJAX forces en fichiers !" |
|
| 3917 | + . " Cela arrive lorsque la valeur du contexte" |
|
| 3918 | + . " depasse la longueur maximale autorisee par Suhosin" |
|
| 3919 | + . " ($max_len) dans 'suhosin.get.max_value_length'. Ici : $len." |
|
| 3920 | + . " Vous devriez modifier les parametres de Suhosin" |
|
| 3921 | + . " pour accepter au moins 1024 caracteres.", _LOG_AVERTISSEMENT); |
|
| 3922 | + } |
|
| 3923 | + |
|
| 3924 | + } |
|
| 3925 | + |
|
| 3926 | + if ($cache_contextes_ajax) { |
|
| 3927 | + $dir = sous_repertoire(_DIR_CACHE, 'contextes'); |
|
| 3928 | + // stocker les contextes sur disque et ne passer qu'un hash dans l'url |
|
| 3929 | + $md5 = md5($c); |
|
| 3930 | + ecrire_fichier("$dir/c$md5", $c); |
|
| 3931 | + $env = $md5; |
|
| 3932 | + } |
|
| 3933 | + |
|
| 3934 | + if ($emboite === null) { |
|
| 3935 | + return $env; |
|
| 3936 | + } |
|
| 3937 | + if (!trim($emboite)) { |
|
| 3938 | + return ""; |
|
| 3939 | + } |
|
| 3940 | + // toujours encoder l'url source dans le bloc ajax |
|
| 3941 | + $r = self(); |
|
| 3942 | + $r = ' data-origin="' . $r . '"'; |
|
| 3943 | + $class = 'ajaxbloc'; |
|
| 3944 | + if ($ajaxid and is_string($ajaxid)) { |
|
| 3945 | + // ajaxid est normalement conforme a un nom de classe css |
|
| 3946 | + // on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution |
|
| 3947 | + $class .= ' ajax-id-' . entites_html($ajaxid); |
|
| 3948 | + } |
|
| 3949 | + |
|
| 3950 | + return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n"; |
|
| 3951 | 3951 | } |
| 3952 | 3952 | |
| 3953 | 3953 | /** |
@@ -3967,36 +3967,36 @@ discard block |
||
| 3967 | 3967 | * - false : erreur de décodage |
| 3968 | 3968 | */ |
| 3969 | 3969 | function decoder_contexte_ajax($c, $form = '') { |
| 3970 | - if (!function_exists('calculer_cle_action')) { |
|
| 3971 | - include_spip("inc/securiser_action"); |
|
| 3972 | - } |
|
| 3973 | - if (((defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX) or strlen($c) == 32) |
|
| 3974 | - and $dir = sous_repertoire(_DIR_CACHE, 'contextes') |
|
| 3975 | - and lire_fichier("$dir/c$c", $contexte) |
|
| 3976 | - ) { |
|
| 3977 | - $c = $contexte; |
|
| 3978 | - } else { |
|
| 3979 | - $c = @base64_decode($c); |
|
| 3980 | - $c = _xor($c); |
|
| 3981 | - if (function_exists('gzdeflate') && function_exists('gzinflate')) { |
|
| 3982 | - $c = @gzinflate($c); |
|
| 3983 | - } |
|
| 3984 | - } |
|
| 3985 | - |
|
| 3986 | - // extraire la signature en debut de contexte |
|
| 3987 | - // et la verifier avant de deserializer |
|
| 3988 | - // format : signature:donneesserializees |
|
| 3989 | - if ($p = strpos($c,":")){ |
|
| 3990 | - $cle = substr($c,0,$p); |
|
| 3991 | - $c = substr($c,$p+1); |
|
| 3992 | - |
|
| 3993 | - if ($cle == calculer_cle_action($form . $c)) { |
|
| 3994 | - $env = @unserialize($c); |
|
| 3995 | - return $env; |
|
| 3996 | - } |
|
| 3997 | - } |
|
| 3998 | - |
|
| 3999 | - return false; |
|
| 3970 | + if (!function_exists('calculer_cle_action')) { |
|
| 3971 | + include_spip("inc/securiser_action"); |
|
| 3972 | + } |
|
| 3973 | + if (((defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX) or strlen($c) == 32) |
|
| 3974 | + and $dir = sous_repertoire(_DIR_CACHE, 'contextes') |
|
| 3975 | + and lire_fichier("$dir/c$c", $contexte) |
|
| 3976 | + ) { |
|
| 3977 | + $c = $contexte; |
|
| 3978 | + } else { |
|
| 3979 | + $c = @base64_decode($c); |
|
| 3980 | + $c = _xor($c); |
|
| 3981 | + if (function_exists('gzdeflate') && function_exists('gzinflate')) { |
|
| 3982 | + $c = @gzinflate($c); |
|
| 3983 | + } |
|
| 3984 | + } |
|
| 3985 | + |
|
| 3986 | + // extraire la signature en debut de contexte |
|
| 3987 | + // et la verifier avant de deserializer |
|
| 3988 | + // format : signature:donneesserializees |
|
| 3989 | + if ($p = strpos($c,":")){ |
|
| 3990 | + $cle = substr($c,0,$p); |
|
| 3991 | + $c = substr($c,$p+1); |
|
| 3992 | + |
|
| 3993 | + if ($cle == calculer_cle_action($form . $c)) { |
|
| 3994 | + $env = @unserialize($c); |
|
| 3995 | + return $env; |
|
| 3996 | + } |
|
| 3997 | + } |
|
| 3998 | + |
|
| 3999 | + return false; |
|
| 4000 | 4000 | } |
| 4001 | 4001 | |
| 4002 | 4002 | |
@@ -4014,20 +4014,20 @@ discard block |
||
| 4014 | 4014 | * Message décrypté ou encrypté |
| 4015 | 4015 | **/ |
| 4016 | 4016 | function _xor($message, $key = null) { |
| 4017 | - if (is_null($key)) { |
|
| 4018 | - if (!function_exists('calculer_cle_action')) { |
|
| 4019 | - include_spip("inc/securiser_action"); |
|
| 4020 | - } |
|
| 4021 | - $key = pack("H*", calculer_cle_action('_xor')); |
|
| 4022 | - } |
|
| 4017 | + if (is_null($key)) { |
|
| 4018 | + if (!function_exists('calculer_cle_action')) { |
|
| 4019 | + include_spip("inc/securiser_action"); |
|
| 4020 | + } |
|
| 4021 | + $key = pack("H*", calculer_cle_action('_xor')); |
|
| 4022 | + } |
|
| 4023 | 4023 | |
| 4024 | - $keylen = strlen($key); |
|
| 4025 | - $messagelen = strlen($message); |
|
| 4026 | - for ($i = 0; $i < $messagelen; $i++) { |
|
| 4027 | - $message[$i] = ~($message[$i] ^ $key[$i % $keylen]); |
|
| 4028 | - } |
|
| 4024 | + $keylen = strlen($key); |
|
| 4025 | + $messagelen = strlen($message); |
|
| 4026 | + for ($i = 0; $i < $messagelen; $i++) { |
|
| 4027 | + $message[$i] = ~($message[$i] ^ $key[$i % $keylen]); |
|
| 4028 | + } |
|
| 4029 | 4029 | |
| 4030 | - return $message; |
|
| 4030 | + return $message; |
|
| 4031 | 4031 | } |
| 4032 | 4032 | |
| 4033 | 4033 | /** |
@@ -4090,37 +4090,37 @@ discard block |
||
| 4090 | 4090 | * Code HTML |
| 4091 | 4091 | */ |
| 4092 | 4092 | function lien_ou_expose($url, $libelle = null, $on = false, $class = "", $title = "", $rel = "", $evt = '') { |
| 4093 | - if ($on) { |
|
| 4094 | - $bal = 'strong'; |
|
| 4095 | - $class = ""; |
|
| 4096 | - $att = ""; |
|
| 4097 | - // si $on passe la balise et optionnelement une ou ++classe |
|
| 4098 | - // a.active span.selected.active etc.... |
|
| 4099 | - if (is_string($on) and (strncmp($on, 'a', 1)==0 or strncmp($on, 'span', 4)==0 or strncmp($on, 'strong', 6)==0)){ |
|
| 4100 | - $on = explode(".", $on); |
|
| 4101 | - // on verifie que c'est exactement une des 3 balises a, span ou strong |
|
| 4102 | - if (in_array(reset($on), array('a', 'span', 'strong'))){ |
|
| 4103 | - $bal = array_shift($on); |
|
| 4104 | - $class = implode(" ", $on); |
|
| 4105 | - if ($bal=="a"){ |
|
| 4106 | - $att = 'href="#" '; |
|
| 4107 | - } |
|
| 4108 | - } |
|
| 4109 | - } |
|
| 4110 | - $att .= 'class="' . ($class ? attribut_html($class) . ' ' : '') . (defined('_LIEN_OU_EXPOSE_CLASS_ON') ? _LIEN_OU_EXPOSE_CLASS_ON : 'on') . '"'; |
|
| 4111 | - } else { |
|
| 4112 | - $bal = 'a'; |
|
| 4113 | - $att = "href='$url'" |
|
| 4114 | - . ($title ? " title='" . attribut_html($title) . "'" : '') |
|
| 4115 | - . ($class ? " class='" . attribut_html($class) . "'" : '') |
|
| 4116 | - . ($rel ? " rel='" . attribut_html($rel) . "'" : '') |
|
| 4117 | - . $evt; |
|
| 4118 | - } |
|
| 4119 | - if ($libelle === null) { |
|
| 4120 | - $libelle = $url; |
|
| 4121 | - } |
|
| 4122 | - |
|
| 4123 | - return "<$bal $att>$libelle</$bal>"; |
|
| 4093 | + if ($on) { |
|
| 4094 | + $bal = 'strong'; |
|
| 4095 | + $class = ""; |
|
| 4096 | + $att = ""; |
|
| 4097 | + // si $on passe la balise et optionnelement une ou ++classe |
|
| 4098 | + // a.active span.selected.active etc.... |
|
| 4099 | + if (is_string($on) and (strncmp($on, 'a', 1)==0 or strncmp($on, 'span', 4)==0 or strncmp($on, 'strong', 6)==0)){ |
|
| 4100 | + $on = explode(".", $on); |
|
| 4101 | + // on verifie que c'est exactement une des 3 balises a, span ou strong |
|
| 4102 | + if (in_array(reset($on), array('a', 'span', 'strong'))){ |
|
| 4103 | + $bal = array_shift($on); |
|
| 4104 | + $class = implode(" ", $on); |
|
| 4105 | + if ($bal=="a"){ |
|
| 4106 | + $att = 'href="#" '; |
|
| 4107 | + } |
|
| 4108 | + } |
|
| 4109 | + } |
|
| 4110 | + $att .= 'class="' . ($class ? attribut_html($class) . ' ' : '') . (defined('_LIEN_OU_EXPOSE_CLASS_ON') ? _LIEN_OU_EXPOSE_CLASS_ON : 'on') . '"'; |
|
| 4111 | + } else { |
|
| 4112 | + $bal = 'a'; |
|
| 4113 | + $att = "href='$url'" |
|
| 4114 | + . ($title ? " title='" . attribut_html($title) . "'" : '') |
|
| 4115 | + . ($class ? " class='" . attribut_html($class) . "'" : '') |
|
| 4116 | + . ($rel ? " rel='" . attribut_html($rel) . "'" : '') |
|
| 4117 | + . $evt; |
|
| 4118 | + } |
|
| 4119 | + if ($libelle === null) { |
|
| 4120 | + $libelle = $url; |
|
| 4121 | + } |
|
| 4122 | + |
|
| 4123 | + return "<$bal $att>$libelle</$bal>"; |
|
| 4124 | 4124 | } |
| 4125 | 4125 | |
| 4126 | 4126 | |
@@ -4137,37 +4137,37 @@ discard block |
||
| 4137 | 4137 | * @return string : la chaine de langue finale en utilisant la fonction _T() |
| 4138 | 4138 | */ |
| 4139 | 4139 | function singulier_ou_pluriel($nb, $chaine_un, $chaine_plusieurs, $var = 'nb', $vars = array()) { |
| 4140 | - static $local_singulier_ou_pluriel = array(); |
|
| 4140 | + static $local_singulier_ou_pluriel = array(); |
|
| 4141 | 4141 | |
| 4142 | - // si nb=0 ou pas de $vars valide on retourne une chaine vide, a traiter par un |sinon |
|
| 4143 | - if (!is_numeric($nb) or $nb == 0) { |
|
| 4144 | - return ""; |
|
| 4145 | - } |
|
| 4146 | - if (!is_array($vars)) { |
|
| 4147 | - return ""; |
|
| 4148 | - } |
|
| 4142 | + // si nb=0 ou pas de $vars valide on retourne une chaine vide, a traiter par un |sinon |
|
| 4143 | + if (!is_numeric($nb) or $nb == 0) { |
|
| 4144 | + return ""; |
|
| 4145 | + } |
|
| 4146 | + if (!is_array($vars)) { |
|
| 4147 | + return ""; |
|
| 4148 | + } |
|
| 4149 | 4149 | |
| 4150 | - $langue = $GLOBALS['spip_lang']; |
|
| 4151 | - if (!isset($local_singulier_ou_pluriel[$langue])) { |
|
| 4152 | - $local_singulier_ou_pluriel[$langue] = false; |
|
| 4153 | - if ($f = charger_fonction("singulier_ou_pluriel_${langue}", 'inc', true) |
|
| 4154 | - or $f = charger_fonction("singulier_ou_pluriel", 'inc', true)) { |
|
| 4155 | - $local_singulier_ou_pluriel[$langue] = $f; |
|
| 4156 | - } |
|
| 4157 | - } |
|
| 4150 | + $langue = $GLOBALS['spip_lang']; |
|
| 4151 | + if (!isset($local_singulier_ou_pluriel[$langue])) { |
|
| 4152 | + $local_singulier_ou_pluriel[$langue] = false; |
|
| 4153 | + if ($f = charger_fonction("singulier_ou_pluriel_${langue}", 'inc', true) |
|
| 4154 | + or $f = charger_fonction("singulier_ou_pluriel", 'inc', true)) { |
|
| 4155 | + $local_singulier_ou_pluriel[$langue] = $f; |
|
| 4156 | + } |
|
| 4157 | + } |
|
| 4158 | 4158 | |
| 4159 | - // si on a une surcharge on l'utilise |
|
| 4160 | - if ($local_singulier_ou_pluriel[$langue]) { |
|
| 4161 | - return ($local_singulier_ou_pluriel[$langue])($nb, $chaine_un, $chaine_plusieurs, $var, $vars); |
|
| 4162 | - } |
|
| 4159 | + // si on a une surcharge on l'utilise |
|
| 4160 | + if ($local_singulier_ou_pluriel[$langue]) { |
|
| 4161 | + return ($local_singulier_ou_pluriel[$langue])($nb, $chaine_un, $chaine_plusieurs, $var, $vars); |
|
| 4162 | + } |
|
| 4163 | 4163 | |
| 4164 | - // sinon traitement par defaut |
|
| 4165 | - $vars[$var] = $nb; |
|
| 4166 | - if ($nb >= 2) { |
|
| 4167 | - return _T($chaine_plusieurs, $vars); |
|
| 4168 | - } else { |
|
| 4169 | - return _T($chaine_un, $vars); |
|
| 4170 | - } |
|
| 4164 | + // sinon traitement par defaut |
|
| 4165 | + $vars[$var] = $nb; |
|
| 4166 | + if ($nb >= 2) { |
|
| 4167 | + return _T($chaine_plusieurs, $vars); |
|
| 4168 | + } else { |
|
| 4169 | + return _T($chaine_un, $vars); |
|
| 4170 | + } |
|
| 4171 | 4171 | } |
| 4172 | 4172 | |
| 4173 | 4173 | |
@@ -4195,71 +4195,71 @@ discard block |
||
| 4195 | 4195 | */ |
| 4196 | 4196 | function prepare_icone_base($type, $lien, $texte, $fond, $fonction = '', $class = '', $javascript = '') { |
| 4197 | 4197 | |
| 4198 | - $class_lien = $class_bouton = $class; |
|
| 4199 | - |
|
| 4200 | - // Normaliser la fonction et compléter la classe en fonction |
|
| 4201 | - if (in_array($fonction, ['del', 'supprimer.gif'])) { |
|
| 4202 | - $class_lien .= ' danger'; |
|
| 4203 | - $class_bouton .= ' btn_danger'; |
|
| 4204 | - } elseif ($fonction == 'rien.gif') { |
|
| 4205 | - $fonction = ''; |
|
| 4206 | - } elseif ($fonction == 'delsafe') { |
|
| 4207 | - $fonction = 'del'; |
|
| 4208 | - } |
|
| 4209 | - |
|
| 4210 | - $fond_origine = $fond; |
|
| 4211 | - // Remappage des icone : article-24.png+new => article-new-24.png |
|
| 4212 | - if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) { |
|
| 4213 | - list($fond, $fonction) = $icone_renommer($fond, $fonction); |
|
| 4214 | - } |
|
| 4215 | - |
|
| 4216 | - // Ajouter le type d'objet dans la classe |
|
| 4217 | - $objet_type = substr(basename($fond), 0, -4); |
|
| 4218 | - $class_lien .= " $objet_type"; |
|
| 4219 | - $class_bouton .= " $objet_type"; |
|
| 4220 | - |
|
| 4221 | - // Texte |
|
| 4222 | - $alt = attribut_html($texte); |
|
| 4223 | - $title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ? |
|
| 4224 | - |
|
| 4225 | - // Liens : préparer les classes ajax |
|
| 4226 | - $ajax = ''; |
|
| 4227 | - if ($type === 'lien') { |
|
| 4228 | - if (strpos($class_lien, 'ajax') !== false) { |
|
| 4229 | - $ajax = 'ajax'; |
|
| 4230 | - if (strpos($class_lien, 'preload') !== false) { |
|
| 4231 | - $ajax .= ' preload'; |
|
| 4232 | - } |
|
| 4233 | - if (strpos($class_lien, 'nocache') !== false) { |
|
| 4234 | - $ajax .= ' nocache'; |
|
| 4235 | - } |
|
| 4236 | - $ajax = " class='$ajax'"; |
|
| 4237 | - } |
|
| 4238 | - } |
|
| 4239 | - |
|
| 4240 | - // Repérer la taille et l'ajouter dans la classe |
|
| 4241 | - $size = 24; |
|
| 4242 | - if (preg_match("/-([0-9]{1,3})[.](gif|png|svg)$/i", $fond, $match) |
|
| 4243 | - or preg_match("/-([0-9]{1,3})([.](gif|png|svg))?$/i", $fond_origine, $match)) { |
|
| 4244 | - $size = $match[1]; |
|
| 4245 | - } |
|
| 4246 | - $class_lien .= " s$size"; |
|
| 4247 | - $class_bouton .= " s$size"; |
|
| 4248 | - |
|
| 4249 | - // Icône |
|
| 4250 | - $icone = http_img_pack($fond, $alt, "width='$size' height='$size'"); |
|
| 4251 | - $icone = "<span class=\"icone-image".($fonction ? " icone-fonction icone-fonction-$fonction" : "") . "\">$icone</span>"; |
|
| 4252 | - |
|
| 4253 | - // Markup final |
|
| 4254 | - if ($type == 'lien') { |
|
| 4255 | - return "<span class='icone $class_lien'>" |
|
| 4256 | - . "<a href='$lien'$title$ajax$javascript>" |
|
| 4257 | - . $icone |
|
| 4258 | - . "<b>$texte</b>" |
|
| 4259 | - . "</a></span>\n"; |
|
| 4260 | - } else { |
|
| 4261 | - return bouton_action("$icone $texte", $lien, $class_bouton, $javascript, $alt); |
|
| 4262 | - } |
|
| 4198 | + $class_lien = $class_bouton = $class; |
|
| 4199 | + |
|
| 4200 | + // Normaliser la fonction et compléter la classe en fonction |
|
| 4201 | + if (in_array($fonction, ['del', 'supprimer.gif'])) { |
|
| 4202 | + $class_lien .= ' danger'; |
|
| 4203 | + $class_bouton .= ' btn_danger'; |
|
| 4204 | + } elseif ($fonction == 'rien.gif') { |
|
| 4205 | + $fonction = ''; |
|
| 4206 | + } elseif ($fonction == 'delsafe') { |
|
| 4207 | + $fonction = 'del'; |
|
| 4208 | + } |
|
| 4209 | + |
|
| 4210 | + $fond_origine = $fond; |
|
| 4211 | + // Remappage des icone : article-24.png+new => article-new-24.png |
|
| 4212 | + if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) { |
|
| 4213 | + list($fond, $fonction) = $icone_renommer($fond, $fonction); |
|
| 4214 | + } |
|
| 4215 | + |
|
| 4216 | + // Ajouter le type d'objet dans la classe |
|
| 4217 | + $objet_type = substr(basename($fond), 0, -4); |
|
| 4218 | + $class_lien .= " $objet_type"; |
|
| 4219 | + $class_bouton .= " $objet_type"; |
|
| 4220 | + |
|
| 4221 | + // Texte |
|
| 4222 | + $alt = attribut_html($texte); |
|
| 4223 | + $title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ? |
|
| 4224 | + |
|
| 4225 | + // Liens : préparer les classes ajax |
|
| 4226 | + $ajax = ''; |
|
| 4227 | + if ($type === 'lien') { |
|
| 4228 | + if (strpos($class_lien, 'ajax') !== false) { |
|
| 4229 | + $ajax = 'ajax'; |
|
| 4230 | + if (strpos($class_lien, 'preload') !== false) { |
|
| 4231 | + $ajax .= ' preload'; |
|
| 4232 | + } |
|
| 4233 | + if (strpos($class_lien, 'nocache') !== false) { |
|
| 4234 | + $ajax .= ' nocache'; |
|
| 4235 | + } |
|
| 4236 | + $ajax = " class='$ajax'"; |
|
| 4237 | + } |
|
| 4238 | + } |
|
| 4239 | + |
|
| 4240 | + // Repérer la taille et l'ajouter dans la classe |
|
| 4241 | + $size = 24; |
|
| 4242 | + if (preg_match("/-([0-9]{1,3})[.](gif|png|svg)$/i", $fond, $match) |
|
| 4243 | + or preg_match("/-([0-9]{1,3})([.](gif|png|svg))?$/i", $fond_origine, $match)) { |
|
| 4244 | + $size = $match[1]; |
|
| 4245 | + } |
|
| 4246 | + $class_lien .= " s$size"; |
|
| 4247 | + $class_bouton .= " s$size"; |
|
| 4248 | + |
|
| 4249 | + // Icône |
|
| 4250 | + $icone = http_img_pack($fond, $alt, "width='$size' height='$size'"); |
|
| 4251 | + $icone = "<span class=\"icone-image".($fonction ? " icone-fonction icone-fonction-$fonction" : "") . "\">$icone</span>"; |
|
| 4252 | + |
|
| 4253 | + // Markup final |
|
| 4254 | + if ($type == 'lien') { |
|
| 4255 | + return "<span class='icone $class_lien'>" |
|
| 4256 | + . "<a href='$lien'$title$ajax$javascript>" |
|
| 4257 | + . $icone |
|
| 4258 | + . "<b>$texte</b>" |
|
| 4259 | + . "</a></span>\n"; |
|
| 4260 | + } else { |
|
| 4261 | + return bouton_action("$icone $texte", $lien, $class_bouton, $javascript, $alt); |
|
| 4262 | + } |
|
| 4263 | 4263 | } |
| 4264 | 4264 | |
| 4265 | 4265 | /** |
@@ -4283,7 +4283,7 @@ discard block |
||
| 4283 | 4283 | * Code HTML du lien |
| 4284 | 4284 | **/ |
| 4285 | 4285 | function icone_base($lien, $texte, $fond, $fonction = "", $class = "", $javascript = "") { |
| 4286 | - return prepare_icone_base('lien', $lien, $texte, $fond, $fonction, $class, $javascript); |
|
| 4286 | + return prepare_icone_base('lien', $lien, $texte, $fond, $fonction, $class, $javascript); |
|
| 4287 | 4287 | } |
| 4288 | 4288 | |
| 4289 | 4289 | /** |
@@ -4318,7 +4318,7 @@ discard block |
||
| 4318 | 4318 | * Code HTML du lien |
| 4319 | 4319 | **/ |
| 4320 | 4320 | function filtre_icone_verticale_dist($lien, $texte, $fond, $fonction = "", $class = "", $javascript = "") { |
| 4321 | - return icone_base($lien, $texte, $fond, $fonction, "verticale $class", $javascript); |
|
| 4321 | + return icone_base($lien, $texte, $fond, $fonction, "verticale $class", $javascript); |
|
| 4322 | 4322 | } |
| 4323 | 4323 | |
| 4324 | 4324 | /** |
@@ -4363,7 +4363,7 @@ discard block |
||
| 4363 | 4363 | * Code HTML du lien |
| 4364 | 4364 | **/ |
| 4365 | 4365 | function filtre_icone_horizontale_dist($lien, $texte, $fond, $fonction = "", $class = "", $javascript = "") { |
| 4366 | - return icone_base($lien, $texte, $fond, $fonction, "horizontale $class", $javascript); |
|
| 4366 | + return icone_base($lien, $texte, $fond, $fonction, "horizontale $class", $javascript); |
|
| 4367 | 4367 | } |
| 4368 | 4368 | |
| 4369 | 4369 | /** |
@@ -4394,7 +4394,7 @@ discard block |
||
| 4394 | 4394 | * Code HTML du lien |
| 4395 | 4395 | **/ |
| 4396 | 4396 | function filtre_bouton_action_horizontal_dist($lien, $texte, $fond, $fonction = "", $class = "", $confirm = "") { |
| 4397 | - return prepare_icone_base('bouton', $lien, $texte, $fond, $fonction, $class, $confirm); |
|
| 4397 | + return prepare_icone_base('bouton', $lien, $texte, $fond, $fonction, $class, $confirm); |
|
| 4398 | 4398 | } |
| 4399 | 4399 | |
| 4400 | 4400 | /** |
@@ -4424,7 +4424,7 @@ discard block |
||
| 4424 | 4424 | * Code HTML du lien |
| 4425 | 4425 | */ |
| 4426 | 4426 | function filtre_icone_dist($lien, $texte, $fond, $align = "", $fonction = "", $class = "", $javascript = "") { |
| 4427 | - return icone_base($lien, $texte, $fond, $fonction, "verticale $align $class", $javascript); |
|
| 4427 | + return icone_base($lien, $texte, $fond, $fonction, "verticale $align $class", $javascript); |
|
| 4428 | 4428 | } |
| 4429 | 4429 | |
| 4430 | 4430 | |
@@ -4472,23 +4472,23 @@ discard block |
||
| 4472 | 4472 | * @return string Code CSS |
| 4473 | 4473 | */ |
| 4474 | 4474 | function bando_images_background() { |
| 4475 | - include_spip('inc/bandeau'); |
|
| 4476 | - // recuperer tous les boutons et leurs images |
|
| 4477 | - $boutons = definir_barre_boutons(definir_barre_contexte(), true, false); |
|
| 4475 | + include_spip('inc/bandeau'); |
|
| 4476 | + // recuperer tous les boutons et leurs images |
|
| 4477 | + $boutons = definir_barre_boutons(definir_barre_contexte(), true, false); |
|
| 4478 | 4478 | |
| 4479 | - $res = ""; |
|
| 4480 | - foreach ($boutons as $page => $detail) { |
|
| 4481 | - $selecteur = (in_array($page, array('outils_rapides', 'outils_collaboratifs')) ? "" : ".navigation_avec_icones "); |
|
| 4482 | - if (is_array($detail->sousmenu)) { |
|
| 4483 | - foreach ($detail->sousmenu as $souspage => $sousdetail) { |
|
| 4484 | - if ($sousdetail->icone and strlen(trim($sousdetail->icone))) { |
|
| 4485 | - $res .= "\n$selecteur.bando2_$souspage {background-image:url(" . $sousdetail->icone . ");}"; |
|
| 4486 | - } |
|
| 4487 | - } |
|
| 4488 | - } |
|
| 4489 | - } |
|
| 4479 | + $res = ""; |
|
| 4480 | + foreach ($boutons as $page => $detail) { |
|
| 4481 | + $selecteur = (in_array($page, array('outils_rapides', 'outils_collaboratifs')) ? "" : ".navigation_avec_icones "); |
|
| 4482 | + if (is_array($detail->sousmenu)) { |
|
| 4483 | + foreach ($detail->sousmenu as $souspage => $sousdetail) { |
|
| 4484 | + if ($sousdetail->icone and strlen(trim($sousdetail->icone))) { |
|
| 4485 | + $res .= "\n$selecteur.bando2_$souspage {background-image:url(" . $sousdetail->icone . ");}"; |
|
| 4486 | + } |
|
| 4487 | + } |
|
| 4488 | + } |
|
| 4489 | + } |
|
| 4490 | 4490 | |
| 4491 | - return $res; |
|
| 4491 | + return $res; |
|
| 4492 | 4492 | } |
| 4493 | 4493 | |
| 4494 | 4494 | /** |
@@ -4513,27 +4513,27 @@ discard block |
||
| 4513 | 4513 | */ |
| 4514 | 4514 | function bouton_action($libelle, $url, $class = '', $confirm = '', $title = '', $callback = '') { |
| 4515 | 4515 | |
| 4516 | - // Classes : dispatcher `ajax` sur le formulaire |
|
| 4517 | - $class_form = ''; |
|
| 4518 | - if (strpos($class, 'ajax') !== false) { |
|
| 4519 | - $class_form = 'ajax'; |
|
| 4520 | - $class = str_replace('ajax', '', $class); |
|
| 4521 | - } |
|
| 4522 | - $class_btn = 'submit ' . trim($class); |
|
| 4516 | + // Classes : dispatcher `ajax` sur le formulaire |
|
| 4517 | + $class_form = ''; |
|
| 4518 | + if (strpos($class, 'ajax') !== false) { |
|
| 4519 | + $class_form = 'ajax'; |
|
| 4520 | + $class = str_replace('ajax', '', $class); |
|
| 4521 | + } |
|
| 4522 | + $class_btn = 'submit ' . trim($class); |
|
| 4523 | 4523 | |
| 4524 | - if ($confirm) { |
|
| 4525 | - $confirm = "confirm(\"" . attribut_html($confirm) . "\")"; |
|
| 4526 | - if ($callback) { |
|
| 4527 | - $callback = "$confirm?($callback):false"; |
|
| 4528 | - } else { |
|
| 4529 | - $callback = $confirm; |
|
| 4530 | - } |
|
| 4531 | - } |
|
| 4532 | - $onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : ""; |
|
| 4533 | - $title = $title ? " title='$title'" : ''; |
|
| 4524 | + if ($confirm) { |
|
| 4525 | + $confirm = "confirm(\"" . attribut_html($confirm) . "\")"; |
|
| 4526 | + if ($callback) { |
|
| 4527 | + $callback = "$confirm?($callback):false"; |
|
| 4528 | + } else { |
|
| 4529 | + $callback = $confirm; |
|
| 4530 | + } |
|
| 4531 | + } |
|
| 4532 | + $onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : ""; |
|
| 4533 | + $title = $title ? " title='$title'" : ''; |
|
| 4534 | 4534 | |
| 4535 | - return "<form class='bouton_action_post $class_form' method='post' action='$url'><div>" . form_hidden($url) |
|
| 4536 | - . "<button type='submit' class='$class_btn'$title$onclick>$libelle</button></div></form>"; |
|
| 4535 | + return "<form class='bouton_action_post $class_form' method='post' action='$url'><div>" . form_hidden($url) |
|
| 4536 | + . "<button type='submit' class='$class_btn'$title$onclick>$libelle</button></div></form>"; |
|
| 4537 | 4537 | } |
| 4538 | 4538 | |
| 4539 | 4539 | /** |
@@ -4554,78 +4554,78 @@ discard block |
||
| 4554 | 4554 | * @return string |
| 4555 | 4555 | */ |
| 4556 | 4556 | function generer_info_entite($id_objet, $type_objet, $info, $etoile = "") { |
| 4557 | - static $trouver_table = null; |
|
| 4558 | - static $objets; |
|
| 4559 | - |
|
| 4560 | - // On verifie qu'on a tout ce qu'il faut |
|
| 4561 | - $id_objet = intval($id_objet); |
|
| 4562 | - if (!($id_objet and $type_objet and $info)) { |
|
| 4563 | - return ''; |
|
| 4564 | - } |
|
| 4565 | - |
|
| 4566 | - // si on a deja note que l'objet n'existe pas, ne pas aller plus loin |
|
| 4567 | - if (isset($objets[$type_objet]) and $objets[$type_objet] === false) { |
|
| 4568 | - return ''; |
|
| 4569 | - } |
|
| 4570 | - |
|
| 4571 | - // Si on demande l'url, on retourne direct la fonction |
|
| 4572 | - if ($info == 'url') { |
|
| 4573 | - return generer_url_entite($id_objet, $type_objet); |
|
| 4574 | - } |
|
| 4575 | - |
|
| 4576 | - // Sinon on va tout chercher dans la table et on garde en memoire |
|
| 4577 | - $demande_titre = ($info == 'titre'); |
|
| 4578 | - |
|
| 4579 | - // 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 |
|
| 4580 | - if (!isset($objets[$type_objet][$id_objet]) |
|
| 4581 | - or |
|
| 4582 | - ($demande_titre and !isset($objets[$type_objet][$id_objet]['titre'])) |
|
| 4583 | - ) { |
|
| 4584 | - if (!$trouver_table) { |
|
| 4585 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 4586 | - } |
|
| 4587 | - $desc = $trouver_table(table_objet_sql($type_objet)); |
|
| 4588 | - if (!$desc) { |
|
| 4589 | - return $objets[$type_objet] = false; |
|
| 4590 | - } |
|
| 4591 | - |
|
| 4592 | - // Si on demande le titre, on le gere en interne |
|
| 4593 | - $champ_titre = ""; |
|
| 4594 | - if ($demande_titre) { |
|
| 4595 | - // si pas de titre declare mais champ titre, il sera peuple par le select * |
|
| 4596 | - $champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : ''; |
|
| 4597 | - } |
|
| 4598 | - include_spip('base/abstract_sql'); |
|
| 4599 | - include_spip('base/connect_sql'); |
|
| 4600 | - $objets[$type_objet][$id_objet] = sql_fetsel( |
|
| 4601 | - '*' . $champ_titre, |
|
| 4602 | - $desc['table_sql'], |
|
| 4603 | - id_table_objet($type_objet) . ' = ' . intval($id_objet) |
|
| 4604 | - ); |
|
| 4605 | - } |
|
| 4606 | - |
|
| 4607 | - // Si la fonction generer_TRUC_TYPE existe, on l'utilise pour formater $info_generee |
|
| 4608 | - if ($generer = charger_fonction("generer_${info}_${type_objet}", '', true)) { |
|
| 4609 | - $info_generee = $generer($id_objet, $objets[$type_objet][$id_objet]); |
|
| 4610 | - } // Si la fonction generer_TRUC_entite existe, on l'utilise pour formater $info_generee |
|
| 4611 | - else { |
|
| 4612 | - if ($generer = charger_fonction("generer_${info}_entite", '', true)) { |
|
| 4613 | - $info_generee = $generer($id_objet, $type_objet, $objets[$type_objet][$id_objet]); |
|
| 4614 | - } // Sinon on prend directement le champ SQL tel quel |
|
| 4615 | - else { |
|
| 4616 | - $info_generee = (isset($objets[$type_objet][$id_objet][$info]) ? $objets[$type_objet][$id_objet][$info] : ''); |
|
| 4617 | - } |
|
| 4618 | - } |
|
| 4619 | - |
|
| 4620 | - // On va ensuite appliquer les traitements automatiques si besoin |
|
| 4621 | - if (!$etoile) { |
|
| 4622 | - // FIXME: on fournit un ENV minimum avec id et type et connect='' |
|
| 4623 | - // mais ce fonctionnement est a ameliorer ! |
|
| 4624 | - $info_generee = appliquer_traitement_champ($info_generee, $info, table_objet($type_objet), |
|
| 4625 | - array('id_objet' => $id_objet, 'objet' => $type_objet, '')); |
|
| 4626 | - } |
|
| 4627 | - |
|
| 4628 | - return $info_generee; |
|
| 4557 | + static $trouver_table = null; |
|
| 4558 | + static $objets; |
|
| 4559 | + |
|
| 4560 | + // On verifie qu'on a tout ce qu'il faut |
|
| 4561 | + $id_objet = intval($id_objet); |
|
| 4562 | + if (!($id_objet and $type_objet and $info)) { |
|
| 4563 | + return ''; |
|
| 4564 | + } |
|
| 4565 | + |
|
| 4566 | + // si on a deja note que l'objet n'existe pas, ne pas aller plus loin |
|
| 4567 | + if (isset($objets[$type_objet]) and $objets[$type_objet] === false) { |
|
| 4568 | + return ''; |
|
| 4569 | + } |
|
| 4570 | + |
|
| 4571 | + // Si on demande l'url, on retourne direct la fonction |
|
| 4572 | + if ($info == 'url') { |
|
| 4573 | + return generer_url_entite($id_objet, $type_objet); |
|
| 4574 | + } |
|
| 4575 | + |
|
| 4576 | + // Sinon on va tout chercher dans la table et on garde en memoire |
|
| 4577 | + $demande_titre = ($info == 'titre'); |
|
| 4578 | + |
|
| 4579 | + // 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 |
|
| 4580 | + if (!isset($objets[$type_objet][$id_objet]) |
|
| 4581 | + or |
|
| 4582 | + ($demande_titre and !isset($objets[$type_objet][$id_objet]['titre'])) |
|
| 4583 | + ) { |
|
| 4584 | + if (!$trouver_table) { |
|
| 4585 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 4586 | + } |
|
| 4587 | + $desc = $trouver_table(table_objet_sql($type_objet)); |
|
| 4588 | + if (!$desc) { |
|
| 4589 | + return $objets[$type_objet] = false; |
|
| 4590 | + } |
|
| 4591 | + |
|
| 4592 | + // Si on demande le titre, on le gere en interne |
|
| 4593 | + $champ_titre = ""; |
|
| 4594 | + if ($demande_titre) { |
|
| 4595 | + // si pas de titre declare mais champ titre, il sera peuple par le select * |
|
| 4596 | + $champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : ''; |
|
| 4597 | + } |
|
| 4598 | + include_spip('base/abstract_sql'); |
|
| 4599 | + include_spip('base/connect_sql'); |
|
| 4600 | + $objets[$type_objet][$id_objet] = sql_fetsel( |
|
| 4601 | + '*' . $champ_titre, |
|
| 4602 | + $desc['table_sql'], |
|
| 4603 | + id_table_objet($type_objet) . ' = ' . intval($id_objet) |
|
| 4604 | + ); |
|
| 4605 | + } |
|
| 4606 | + |
|
| 4607 | + // Si la fonction generer_TRUC_TYPE existe, on l'utilise pour formater $info_generee |
|
| 4608 | + if ($generer = charger_fonction("generer_${info}_${type_objet}", '', true)) { |
|
| 4609 | + $info_generee = $generer($id_objet, $objets[$type_objet][$id_objet]); |
|
| 4610 | + } // Si la fonction generer_TRUC_entite existe, on l'utilise pour formater $info_generee |
|
| 4611 | + else { |
|
| 4612 | + if ($generer = charger_fonction("generer_${info}_entite", '', true)) { |
|
| 4613 | + $info_generee = $generer($id_objet, $type_objet, $objets[$type_objet][$id_objet]); |
|
| 4614 | + } // Sinon on prend directement le champ SQL tel quel |
|
| 4615 | + else { |
|
| 4616 | + $info_generee = (isset($objets[$type_objet][$id_objet][$info]) ? $objets[$type_objet][$id_objet][$info] : ''); |
|
| 4617 | + } |
|
| 4618 | + } |
|
| 4619 | + |
|
| 4620 | + // On va ensuite appliquer les traitements automatiques si besoin |
|
| 4621 | + if (!$etoile) { |
|
| 4622 | + // FIXME: on fournit un ENV minimum avec id et type et connect='' |
|
| 4623 | + // mais ce fonctionnement est a ameliorer ! |
|
| 4624 | + $info_generee = appliquer_traitement_champ($info_generee, $info, table_objet($type_objet), |
|
| 4625 | + array('id_objet' => $id_objet, 'objet' => $type_objet, '')); |
|
| 4626 | + } |
|
| 4627 | + |
|
| 4628 | + return $info_generee; |
|
| 4629 | 4629 | } |
| 4630 | 4630 | |
| 4631 | 4631 | /** |
@@ -4639,44 +4639,44 @@ discard block |
||
| 4639 | 4639 | * @return string |
| 4640 | 4640 | */ |
| 4641 | 4641 | function appliquer_traitement_champ($texte, $champ, $table_objet = '', $env = array(), $connect = '') { |
| 4642 | - if (!$champ) { |
|
| 4643 | - return $texte; |
|
| 4644 | - } |
|
| 4642 | + if (!$champ) { |
|
| 4643 | + return $texte; |
|
| 4644 | + } |
|
| 4645 | 4645 | |
| 4646 | - // On charge toujours les filtres de texte car la majorité des traitements les utilisent |
|
| 4647 | - // et il ne faut pas partir du principe que c'est déjà chargé (form ajax, etc) |
|
| 4648 | - include_spip('inc/texte'); |
|
| 4646 | + // On charge toujours les filtres de texte car la majorité des traitements les utilisent |
|
| 4647 | + // et il ne faut pas partir du principe que c'est déjà chargé (form ajax, etc) |
|
| 4648 | + include_spip('inc/texte'); |
|
| 4649 | 4649 | |
| 4650 | - $champ = strtoupper($champ); |
|
| 4651 | - $traitements = isset($GLOBALS['table_des_traitements'][$champ]) ? $GLOBALS['table_des_traitements'][$champ] : false; |
|
| 4652 | - if (!$traitements or !is_array($traitements)) { |
|
| 4653 | - return $texte; |
|
| 4654 | - } |
|
| 4650 | + $champ = strtoupper($champ); |
|
| 4651 | + $traitements = isset($GLOBALS['table_des_traitements'][$champ]) ? $GLOBALS['table_des_traitements'][$champ] : false; |
|
| 4652 | + if (!$traitements or !is_array($traitements)) { |
|
| 4653 | + return $texte; |
|
| 4654 | + } |
|
| 4655 | 4655 | |
| 4656 | - $traitement = ''; |
|
| 4657 | - if ($table_objet and (!isset($traitements[0]) or count($traitements) > 1)) { |
|
| 4658 | - // necessaire pour prendre en charge les vieux appels avec un table_objet_sql en 3e arg |
|
| 4659 | - $table_objet = table_objet($table_objet); |
|
| 4660 | - if (isset($traitements[$table_objet])) { |
|
| 4661 | - $traitement = $traitements[$table_objet]; |
|
| 4662 | - } |
|
| 4663 | - } |
|
| 4664 | - if (!$traitement and isset($traitements[0])) { |
|
| 4665 | - $traitement = $traitements[0]; |
|
| 4666 | - } |
|
| 4667 | - // (sinon prendre le premier de la liste par defaut ?) |
|
| 4656 | + $traitement = ''; |
|
| 4657 | + if ($table_objet and (!isset($traitements[0]) or count($traitements) > 1)) { |
|
| 4658 | + // necessaire pour prendre en charge les vieux appels avec un table_objet_sql en 3e arg |
|
| 4659 | + $table_objet = table_objet($table_objet); |
|
| 4660 | + if (isset($traitements[$table_objet])) { |
|
| 4661 | + $traitement = $traitements[$table_objet]; |
|
| 4662 | + } |
|
| 4663 | + } |
|
| 4664 | + if (!$traitement and isset($traitements[0])) { |
|
| 4665 | + $traitement = $traitements[0]; |
|
| 4666 | + } |
|
| 4667 | + // (sinon prendre le premier de la liste par defaut ?) |
|
| 4668 | 4668 | |
| 4669 | - if (!$traitement) { |
|
| 4670 | - return $texte; |
|
| 4671 | - } |
|
| 4669 | + if (!$traitement) { |
|
| 4670 | + return $texte; |
|
| 4671 | + } |
|
| 4672 | 4672 | |
| 4673 | - $traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement); |
|
| 4673 | + $traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement); |
|
| 4674 | 4674 | |
| 4675 | - // Fournir $connect et $Pile[0] au traitement si besoin |
|
| 4676 | - $Pile = array(0 => $env); |
|
| 4677 | - eval("\$texte = $traitement;"); |
|
| 4675 | + // Fournir $connect et $Pile[0] au traitement si besoin |
|
| 4676 | + $Pile = array(0 => $env); |
|
| 4677 | + eval("\$texte = $traitement;"); |
|
| 4678 | 4678 | |
| 4679 | - return $texte; |
|
| 4679 | + return $texte; |
|
| 4680 | 4680 | } |
| 4681 | 4681 | |
| 4682 | 4682 | |
@@ -4690,21 +4690,21 @@ discard block |
||
| 4690 | 4690 | * @return string |
| 4691 | 4691 | */ |
| 4692 | 4692 | function generer_lien_entite($id_objet, $objet, $longueur = 80, $connect = null) { |
| 4693 | - include_spip('inc/liens'); |
|
| 4694 | - $titre = traiter_raccourci_titre($id_objet, $objet, $connect); |
|
| 4695 | - // lorsque l'objet n'est plus declare (plugin desactive par exemple) |
|
| 4696 | - // le raccourcis n'est plus valide |
|
| 4697 | - $titre = isset($titre['titre']) ? typo($titre['titre']) : ''; |
|
| 4698 | - // on essaye avec generer_info_entite ? |
|
| 4699 | - if (!strlen($titre) and !$connect) { |
|
| 4700 | - $titre = generer_info_entite($id_objet, $objet, 'titre'); |
|
| 4701 | - } |
|
| 4702 | - if (!strlen($titre)) { |
|
| 4703 | - $titre = _T('info_sans_titre'); |
|
| 4704 | - } |
|
| 4705 | - $url = generer_url_entite($id_objet, $objet, '', '', $connect); |
|
| 4693 | + include_spip('inc/liens'); |
|
| 4694 | + $titre = traiter_raccourci_titre($id_objet, $objet, $connect); |
|
| 4695 | + // lorsque l'objet n'est plus declare (plugin desactive par exemple) |
|
| 4696 | + // le raccourcis n'est plus valide |
|
| 4697 | + $titre = isset($titre['titre']) ? typo($titre['titre']) : ''; |
|
| 4698 | + // on essaye avec generer_info_entite ? |
|
| 4699 | + if (!strlen($titre) and !$connect) { |
|
| 4700 | + $titre = generer_info_entite($id_objet, $objet, 'titre'); |
|
| 4701 | + } |
|
| 4702 | + if (!strlen($titre)) { |
|
| 4703 | + $titre = _T('info_sans_titre'); |
|
| 4704 | + } |
|
| 4705 | + $url = generer_url_entite($id_objet, $objet, '', '', $connect); |
|
| 4706 | 4706 | |
| 4707 | - return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . "</a>"; |
|
| 4707 | + return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . "</a>"; |
|
| 4708 | 4708 | } |
| 4709 | 4709 | |
| 4710 | 4710 | |
@@ -4721,15 +4721,15 @@ discard block |
||
| 4721 | 4721 | * @return string |
| 4722 | 4722 | */ |
| 4723 | 4723 | function wrap($texte, $wrap) { |
| 4724 | - $balises = extraire_balises($wrap); |
|
| 4725 | - if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) { |
|
| 4726 | - $texte = $wrap . $texte; |
|
| 4727 | - $regs = array_reverse($regs[1]); |
|
| 4728 | - $wrap = "</" . implode("></", $regs) . ">"; |
|
| 4729 | - $texte = $texte . $wrap; |
|
| 4730 | - } |
|
| 4724 | + $balises = extraire_balises($wrap); |
|
| 4725 | + if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) { |
|
| 4726 | + $texte = $wrap . $texte; |
|
| 4727 | + $regs = array_reverse($regs[1]); |
|
| 4728 | + $wrap = "</" . implode("></", $regs) . ">"; |
|
| 4729 | + $texte = $texte . $wrap; |
|
| 4730 | + } |
|
| 4731 | 4731 | |
| 4732 | - return $texte; |
|
| 4732 | + return $texte; |
|
| 4733 | 4733 | } |
| 4734 | 4734 | |
| 4735 | 4735 | |
@@ -4749,43 +4749,43 @@ discard block |
||
| 4749 | 4749 | * @return array|mixed|string |
| 4750 | 4750 | */ |
| 4751 | 4751 | function filtre_print_dist($u, $join = "<br />", $indent = 0) { |
| 4752 | - if (is_string($u)) { |
|
| 4753 | - $u = typo($u); |
|
| 4752 | + if (is_string($u)) { |
|
| 4753 | + $u = typo($u); |
|
| 4754 | 4754 | |
| 4755 | - return $u; |
|
| 4756 | - } |
|
| 4755 | + return $u; |
|
| 4756 | + } |
|
| 4757 | 4757 | |
| 4758 | - // caster $u en array si besoin |
|
| 4759 | - if (is_object($u)) { |
|
| 4760 | - $u = (array)$u; |
|
| 4761 | - } |
|
| 4758 | + // caster $u en array si besoin |
|
| 4759 | + if (is_object($u)) { |
|
| 4760 | + $u = (array)$u; |
|
| 4761 | + } |
|
| 4762 | 4762 | |
| 4763 | - if (is_array($u)) { |
|
| 4764 | - $out = ""; |
|
| 4765 | - // toutes les cles sont numeriques ? |
|
| 4766 | - // et aucun enfant n'est un tableau |
|
| 4767 | - // liste simple separee par des virgules |
|
| 4768 | - $numeric_keys = array_map('is_numeric', array_keys($u)); |
|
| 4769 | - $array_values = array_map('is_array', $u); |
|
| 4770 | - $object_values = array_map('is_object', $u); |
|
| 4771 | - if (array_sum($numeric_keys) == count($numeric_keys) |
|
| 4772 | - and !array_sum($array_values) |
|
| 4773 | - and !array_sum($object_values) |
|
| 4774 | - ) { |
|
| 4775 | - return join(", ", array_map('filtre_print_dist', $u)); |
|
| 4776 | - } |
|
| 4763 | + if (is_array($u)) { |
|
| 4764 | + $out = ""; |
|
| 4765 | + // toutes les cles sont numeriques ? |
|
| 4766 | + // et aucun enfant n'est un tableau |
|
| 4767 | + // liste simple separee par des virgules |
|
| 4768 | + $numeric_keys = array_map('is_numeric', array_keys($u)); |
|
| 4769 | + $array_values = array_map('is_array', $u); |
|
| 4770 | + $object_values = array_map('is_object', $u); |
|
| 4771 | + if (array_sum($numeric_keys) == count($numeric_keys) |
|
| 4772 | + and !array_sum($array_values) |
|
| 4773 | + and !array_sum($object_values) |
|
| 4774 | + ) { |
|
| 4775 | + return join(", ", array_map('filtre_print_dist', $u)); |
|
| 4776 | + } |
|
| 4777 | 4777 | |
| 4778 | - // sinon on passe a la ligne et on indente |
|
| 4779 | - $i_str = str_pad("", $indent, "Â "); |
|
| 4780 | - foreach ($u as $k => $v) { |
|
| 4781 | - $out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2); |
|
| 4782 | - } |
|
| 4778 | + // sinon on passe a la ligne et on indente |
|
| 4779 | + $i_str = str_pad("", $indent, "Â "); |
|
| 4780 | + foreach ($u as $k => $v) { |
|
| 4781 | + $out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2); |
|
| 4782 | + } |
|
| 4783 | 4783 | |
| 4784 | - return $out; |
|
| 4785 | - } |
|
| 4784 | + return $out; |
|
| 4785 | + } |
|
| 4786 | 4786 | |
| 4787 | - // on sait pas quoi faire... |
|
| 4788 | - return $u; |
|
| 4787 | + // on sait pas quoi faire... |
|
| 4788 | + return $u; |
|
| 4789 | 4789 | } |
| 4790 | 4790 | |
| 4791 | 4791 | |
@@ -4798,10 +4798,10 @@ discard block |
||
| 4798 | 4798 | * @return string|array |
| 4799 | 4799 | */ |
| 4800 | 4800 | function objet_info($objet, $info) { |
| 4801 | - $table = table_objet_sql($objet); |
|
| 4802 | - $infos = lister_tables_objets_sql($table); |
|
| 4801 | + $table = table_objet_sql($objet); |
|
| 4802 | + $infos = lister_tables_objets_sql($table); |
|
| 4803 | 4803 | |
| 4804 | - return (isset($infos[$info]) ? $infos[$info] : ''); |
|
| 4804 | + return (isset($infos[$info]) ? $infos[$info] : ''); |
|
| 4805 | 4805 | } |
| 4806 | 4806 | |
| 4807 | 4807 | /** |
@@ -4816,11 +4816,11 @@ discard block |
||
| 4816 | 4816 | * Texte traduit du comptage, tel que '3 articles' |
| 4817 | 4817 | */ |
| 4818 | 4818 | function objet_afficher_nb($nb, $objet) { |
| 4819 | - if (!$nb) { |
|
| 4820 | - return _T(objet_info($objet, 'info_aucun_objet')); |
|
| 4821 | - } else { |
|
| 4822 | - return _T(objet_info($objet, $nb == 1 ? 'info_1_objet' : 'info_nb_objets'), array('nb' => $nb)); |
|
| 4823 | - } |
|
| 4819 | + if (!$nb) { |
|
| 4820 | + return _T(objet_info($objet, 'info_aucun_objet')); |
|
| 4821 | + } else { |
|
| 4822 | + return _T(objet_info($objet, $nb == 1 ? 'info_1_objet' : 'info_nb_objets'), array('nb' => $nb)); |
|
| 4823 | + } |
|
| 4824 | 4824 | } |
| 4825 | 4825 | |
| 4826 | 4826 | /** |
@@ -4832,11 +4832,11 @@ discard block |
||
| 4832 | 4832 | * @return string |
| 4833 | 4833 | */ |
| 4834 | 4834 | function objet_icone($objet, $taille = 24, $class='') { |
| 4835 | - $icone = objet_info($objet, 'icone_objet') . "-" . $taille . ".png"; |
|
| 4836 | - $icone = chemin_image($icone); |
|
| 4837 | - $balise_img = charger_filtre('balise_img'); |
|
| 4835 | + $icone = objet_info($objet, 'icone_objet') . "-" . $taille . ".png"; |
|
| 4836 | + $icone = chemin_image($icone); |
|
| 4837 | + $balise_img = charger_filtre('balise_img'); |
|
| 4838 | 4838 | |
| 4839 | - return $icone ? $balise_img($icone, _T(objet_info($objet, 'texte_objet')), $class, $taille) : ''; |
|
| 4839 | + return $icone ? $balise_img($icone, _T(objet_info($objet, 'texte_objet')), $class, $taille) : ''; |
|
| 4840 | 4840 | } |
| 4841 | 4841 | |
| 4842 | 4842 | /** |
@@ -4857,12 +4857,12 @@ discard block |
||
| 4857 | 4857 | * @return string |
| 4858 | 4858 | */ |
| 4859 | 4859 | function objet_T($objet, $chaine, $args = array(), $options = array()){ |
| 4860 | - $chaine = explode(':',$chaine); |
|
| 4861 | - if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, array('force'=>false)))) { |
|
| 4862 | - return $t; |
|
| 4863 | - } |
|
| 4864 | - $chaine = implode(':',$chaine); |
|
| 4865 | - return _T($chaine, $args, $options); |
|
| 4860 | + $chaine = explode(':',$chaine); |
|
| 4861 | + if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, array('force'=>false)))) { |
|
| 4862 | + return $t; |
|
| 4863 | + } |
|
| 4864 | + $chaine = implode(':',$chaine); |
|
| 4865 | + return _T($chaine, $args, $options); |
|
| 4866 | 4866 | } |
| 4867 | 4867 | |
| 4868 | 4868 | /** |
@@ -4876,17 +4876,17 @@ discard block |
||
| 4876 | 4876 | * @return string Code HTML |
| 4877 | 4877 | */ |
| 4878 | 4878 | function insert_head_css_conditionnel($flux) { |
| 4879 | - if (strpos($flux, '<!-- insert_head_css -->') === false |
|
| 4880 | - and $p = strpos($flux, '<!-- insert_head -->') |
|
| 4881 | - ) { |
|
| 4882 | - // plutot avant le premier js externe (jquery) pour etre non bloquant |
|
| 4883 | - if ($p1 = stripos($flux, '<script src=') and $p1 < $p) { |
|
| 4884 | - $p = $p1; |
|
| 4885 | - } |
|
| 4886 | - $flux = substr_replace($flux, pipeline('insert_head_css', '<!-- insert_head_css -->'), $p, 0); |
|
| 4887 | - } |
|
| 4879 | + if (strpos($flux, '<!-- insert_head_css -->') === false |
|
| 4880 | + and $p = strpos($flux, '<!-- insert_head -->') |
|
| 4881 | + ) { |
|
| 4882 | + // plutot avant le premier js externe (jquery) pour etre non bloquant |
|
| 4883 | + if ($p1 = stripos($flux, '<script src=') and $p1 < $p) { |
|
| 4884 | + $p = $p1; |
|
| 4885 | + } |
|
| 4886 | + $flux = substr_replace($flux, pipeline('insert_head_css', '<!-- insert_head_css -->'), $p, 0); |
|
| 4887 | + } |
|
| 4888 | 4888 | |
| 4889 | - return $flux; |
|
| 4889 | + return $flux; |
|
| 4890 | 4890 | } |
| 4891 | 4891 | |
| 4892 | 4892 | /** |
@@ -4907,69 +4907,69 @@ discard block |
||
| 4907 | 4907 | * @return string |
| 4908 | 4908 | */ |
| 4909 | 4909 | function produire_fond_statique($fond, $contexte = array(), $options = array(), $connect = '') { |
| 4910 | - if (isset($contexte['format'])) { |
|
| 4911 | - $extension = $contexte['format']; |
|
| 4912 | - unset($contexte['format']); |
|
| 4913 | - } else { |
|
| 4914 | - $extension = "html"; |
|
| 4915 | - if (preg_match(',[.](css|js|json)$,', $fond, $m)) { |
|
| 4916 | - $extension = $m[1]; |
|
| 4917 | - } |
|
| 4918 | - } |
|
| 4919 | - // recuperer le contenu produit par le squelette |
|
| 4920 | - $options['raw'] = true; |
|
| 4921 | - $cache = recuperer_fond($fond, $contexte, $options, $connect); |
|
| 4922 | - |
|
| 4923 | - // calculer le nom de la css |
|
| 4924 | - $dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension); |
|
| 4925 | - $nom_safe = preg_replace(",\W,", '_', str_replace('.', '_', $fond)); |
|
| 4926 | - $contexte_implicite = calculer_contexte_implicite(); |
|
| 4927 | - |
|
| 4928 | - // par defaut on hash selon les contextes qui sont a priori moins variables |
|
| 4929 | - // mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu |
|
| 4930 | - // reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine |
|
| 4931 | - if (isset($options['hash_on_content']) and $options['hash_on_content']) { |
|
| 4932 | - $hash = md5($contexte_implicite['host'] . '::'. $cache); |
|
| 4933 | - } |
|
| 4934 | - else { |
|
| 4935 | - unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js |
|
| 4936 | - ksort($contexte); |
|
| 4937 | - $hash = md5($fond . json_encode($contexte_implicite) . json_encode($contexte) . $connect); |
|
| 4938 | - } |
|
| 4939 | - $filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension"; |
|
| 4940 | - |
|
| 4941 | - // mettre a jour le fichier si il n'existe pas |
|
| 4942 | - // ou trop ancien |
|
| 4943 | - // le dernier fichier produit est toujours suffixe par .last |
|
| 4944 | - // et recopie sur le fichier cible uniquement si il change |
|
| 4945 | - if (!file_exists($filename) |
|
| 4946 | - or !file_exists($filename . ".last") |
|
| 4947 | - or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . ".last") < $cache['lastmodified']) |
|
| 4948 | - or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul') |
|
| 4949 | - ) { |
|
| 4950 | - $contenu = $cache['texte']; |
|
| 4951 | - // passer les urls en absolu si c'est une css |
|
| 4952 | - if ($extension == "css") { |
|
| 4953 | - $contenu = urls_absolues_css($contenu, |
|
| 4954 | - test_espace_prive() ? generer_url_ecrire('accueil') : generer_url_public($fond)); |
|
| 4955 | - } |
|
| 4956 | - |
|
| 4957 | - $comment = ''; |
|
| 4958 | - // ne pas insérer de commentaire si c'est du json |
|
| 4959 | - if ($extension != "json") { |
|
| 4960 | - $comment = "/* #PRODUIRE{fond=$fond"; |
|
| 4961 | - foreach ($contexte as $k => $v) { |
|
| 4962 | - $comment .= ",$k=$v"; |
|
| 4963 | - } |
|
| 4964 | - // pas de date dans le commentaire car sinon ca invalide le md5 et force la maj |
|
| 4965 | - // mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non |
|
| 4966 | - $comment .= "}\n md5:" . md5($contenu) . " */\n"; |
|
| 4967 | - } |
|
| 4968 | - // et ecrire le fichier si il change |
|
| 4969 | - ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true); |
|
| 4970 | - } |
|
| 4971 | - |
|
| 4972 | - return timestamp($filename); |
|
| 4910 | + if (isset($contexte['format'])) { |
|
| 4911 | + $extension = $contexte['format']; |
|
| 4912 | + unset($contexte['format']); |
|
| 4913 | + } else { |
|
| 4914 | + $extension = "html"; |
|
| 4915 | + if (preg_match(',[.](css|js|json)$,', $fond, $m)) { |
|
| 4916 | + $extension = $m[1]; |
|
| 4917 | + } |
|
| 4918 | + } |
|
| 4919 | + // recuperer le contenu produit par le squelette |
|
| 4920 | + $options['raw'] = true; |
|
| 4921 | + $cache = recuperer_fond($fond, $contexte, $options, $connect); |
|
| 4922 | + |
|
| 4923 | + // calculer le nom de la css |
|
| 4924 | + $dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension); |
|
| 4925 | + $nom_safe = preg_replace(",\W,", '_', str_replace('.', '_', $fond)); |
|
| 4926 | + $contexte_implicite = calculer_contexte_implicite(); |
|
| 4927 | + |
|
| 4928 | + // par defaut on hash selon les contextes qui sont a priori moins variables |
|
| 4929 | + // mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu |
|
| 4930 | + // reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine |
|
| 4931 | + if (isset($options['hash_on_content']) and $options['hash_on_content']) { |
|
| 4932 | + $hash = md5($contexte_implicite['host'] . '::'. $cache); |
|
| 4933 | + } |
|
| 4934 | + else { |
|
| 4935 | + unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js |
|
| 4936 | + ksort($contexte); |
|
| 4937 | + $hash = md5($fond . json_encode($contexte_implicite) . json_encode($contexte) . $connect); |
|
| 4938 | + } |
|
| 4939 | + $filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension"; |
|
| 4940 | + |
|
| 4941 | + // mettre a jour le fichier si il n'existe pas |
|
| 4942 | + // ou trop ancien |
|
| 4943 | + // le dernier fichier produit est toujours suffixe par .last |
|
| 4944 | + // et recopie sur le fichier cible uniquement si il change |
|
| 4945 | + if (!file_exists($filename) |
|
| 4946 | + or !file_exists($filename . ".last") |
|
| 4947 | + or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . ".last") < $cache['lastmodified']) |
|
| 4948 | + or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul') |
|
| 4949 | + ) { |
|
| 4950 | + $contenu = $cache['texte']; |
|
| 4951 | + // passer les urls en absolu si c'est une css |
|
| 4952 | + if ($extension == "css") { |
|
| 4953 | + $contenu = urls_absolues_css($contenu, |
|
| 4954 | + test_espace_prive() ? generer_url_ecrire('accueil') : generer_url_public($fond)); |
|
| 4955 | + } |
|
| 4956 | + |
|
| 4957 | + $comment = ''; |
|
| 4958 | + // ne pas insérer de commentaire si c'est du json |
|
| 4959 | + if ($extension != "json") { |
|
| 4960 | + $comment = "/* #PRODUIRE{fond=$fond"; |
|
| 4961 | + foreach ($contexte as $k => $v) { |
|
| 4962 | + $comment .= ",$k=$v"; |
|
| 4963 | + } |
|
| 4964 | + // pas de date dans le commentaire car sinon ca invalide le md5 et force la maj |
|
| 4965 | + // mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non |
|
| 4966 | + $comment .= "}\n md5:" . md5($contenu) . " */\n"; |
|
| 4967 | + } |
|
| 4968 | + // et ecrire le fichier si il change |
|
| 4969 | + ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true); |
|
| 4970 | + } |
|
| 4971 | + |
|
| 4972 | + return timestamp($filename); |
|
| 4973 | 4973 | } |
| 4974 | 4974 | |
| 4975 | 4975 | /** |
@@ -4982,14 +4982,14 @@ discard block |
||
| 4982 | 4982 | * $fichier auquel on a ajouté le timestamp |
| 4983 | 4983 | */ |
| 4984 | 4984 | function timestamp($fichier) { |
| 4985 | - if (!$fichier |
|
| 4986 | - or !file_exists($fichier) |
|
| 4987 | - or !$m = filemtime($fichier) |
|
| 4988 | - ) { |
|
| 4989 | - return $fichier; |
|
| 4990 | - } |
|
| 4985 | + if (!$fichier |
|
| 4986 | + or !file_exists($fichier) |
|
| 4987 | + or !$m = filemtime($fichier) |
|
| 4988 | + ) { |
|
| 4989 | + return $fichier; |
|
| 4990 | + } |
|
| 4991 | 4991 | |
| 4992 | - return "$fichier?$m"; |
|
| 4992 | + return "$fichier?$m"; |
|
| 4993 | 4993 | } |
| 4994 | 4994 | |
| 4995 | 4995 | /** |
@@ -4999,11 +4999,11 @@ discard block |
||
| 4999 | 4999 | * @return string |
| 5000 | 5000 | */ |
| 5001 | 5001 | function supprimer_timestamp($url) { |
| 5002 | - if (strpos($url, "?") === false) { |
|
| 5003 | - return $url; |
|
| 5004 | - } |
|
| 5002 | + if (strpos($url, "?") === false) { |
|
| 5003 | + return $url; |
|
| 5004 | + } |
|
| 5005 | 5005 | |
| 5006 | - return preg_replace(",\?[[:digit:]]+$,", "", $url); |
|
| 5006 | + return preg_replace(",\?[[:digit:]]+$,", "", $url); |
|
| 5007 | 5007 | } |
| 5008 | 5008 | |
| 5009 | 5009 | /** |
@@ -5018,9 +5018,9 @@ discard block |
||
| 5018 | 5018 | * @return string |
| 5019 | 5019 | */ |
| 5020 | 5020 | function filtre_nettoyer_titre_email_dist($titre) { |
| 5021 | - include_spip('inc/envoyer_mail'); |
|
| 5021 | + include_spip('inc/envoyer_mail'); |
|
| 5022 | 5022 | |
| 5023 | - return nettoyer_titre_email($titre); |
|
| 5023 | + return nettoyer_titre_email($titre); |
|
| 5024 | 5024 | } |
| 5025 | 5025 | |
| 5026 | 5026 | /** |
@@ -5042,19 +5042,19 @@ discard block |
||
| 5042 | 5042 | * @return string |
| 5043 | 5043 | */ |
| 5044 | 5044 | function filtre_chercher_rubrique_dist( |
| 5045 | - $titre, |
|
| 5046 | - $id_objet, |
|
| 5047 | - $id_parent, |
|
| 5048 | - $objet, |
|
| 5049 | - $id_secteur, |
|
| 5050 | - $restreint, |
|
| 5051 | - $actionable = false, |
|
| 5052 | - $retour_sans_cadre = false |
|
| 5045 | + $titre, |
|
| 5046 | + $id_objet, |
|
| 5047 | + $id_parent, |
|
| 5048 | + $objet, |
|
| 5049 | + $id_secteur, |
|
| 5050 | + $restreint, |
|
| 5051 | + $actionable = false, |
|
| 5052 | + $retour_sans_cadre = false |
|
| 5053 | 5053 | ) { |
| 5054 | - include_spip('inc/filtres_ecrire'); |
|
| 5054 | + include_spip('inc/filtres_ecrire'); |
|
| 5055 | 5055 | |
| 5056 | - return chercher_rubrique($titre, $id_objet, $id_parent, $objet, $id_secteur, $restreint, $actionable, |
|
| 5057 | - $retour_sans_cadre); |
|
| 5056 | + return chercher_rubrique($titre, $id_objet, $id_parent, $objet, $id_secteur, $restreint, $actionable, |
|
| 5057 | + $retour_sans_cadre); |
|
| 5058 | 5058 | } |
| 5059 | 5059 | |
| 5060 | 5060 | /** |
@@ -5083,56 +5083,56 @@ discard block |
||
| 5083 | 5083 | * Chaîne vide si l'accès est autorisé |
| 5084 | 5084 | */ |
| 5085 | 5085 | function sinon_interdire_acces($ok = false, $url = '', $statut = 0, $message = null) { |
| 5086 | - if ($ok) { |
|
| 5087 | - return ''; |
|
| 5088 | - } |
|
| 5089 | - |
|
| 5090 | - // Vider tous les tampons |
|
| 5091 | - $level = @ob_get_level(); |
|
| 5092 | - while ($level--) { |
|
| 5093 | - @ob_end_clean(); |
|
| 5094 | - } |
|
| 5095 | - |
|
| 5096 | - include_spip('inc/headers'); |
|
| 5097 | - |
|
| 5098 | - // S'il y a une URL, on redirige (si pas de statut, la fonction mettra 302 par défaut) |
|
| 5099 | - if ($url) { |
|
| 5100 | - redirige_par_entete($url, '', $statut); |
|
| 5101 | - } |
|
| 5102 | - |
|
| 5103 | - // ecriture simplifiee avec message en 3eme argument (= statut 403) |
|
| 5104 | - if (!is_numeric($statut) and is_null($message)) { |
|
| 5105 | - $message = $statut; |
|
| 5106 | - $statut = 0; |
|
| 5107 | - } |
|
| 5108 | - if (!$message) { |
|
| 5109 | - $message = ''; |
|
| 5110 | - } |
|
| 5111 | - $statut = intval($statut); |
|
| 5112 | - |
|
| 5113 | - // Si on est dans l'espace privé, on génère du 403 Forbidden par defaut ou du 404 |
|
| 5114 | - if (test_espace_prive()) { |
|
| 5115 | - if (!$statut or !in_array($statut, array(404, 403))) { |
|
| 5116 | - $statut = 403; |
|
| 5117 | - } |
|
| 5118 | - http_status(403); |
|
| 5119 | - $echec = charger_fonction('403', 'exec'); |
|
| 5120 | - $echec($message); |
|
| 5121 | - } else { |
|
| 5122 | - // Sinon dans l'espace public on redirige vers une 404 par défaut, car elle toujours présente normalement |
|
| 5123 | - if (!$statut) { |
|
| 5124 | - $statut = 404; |
|
| 5125 | - } |
|
| 5126 | - // Dans tous les cas on modifie l'entité avec ce qui est demandé |
|
| 5127 | - http_status($statut); |
|
| 5128 | - // Si le statut est une erreur et qu'il n'y a pas de redirection on va chercher le squelette du même nom |
|
| 5129 | - if ($statut >= 400) { |
|
| 5130 | - echo recuperer_fond("$statut", array('erreur' => $message)); |
|
| 5131 | - } |
|
| 5132 | - } |
|
| 5133 | - |
|
| 5134 | - |
|
| 5135 | - exit; |
|
| 5086 | + if ($ok) { |
|
| 5087 | + return ''; |
|
| 5088 | + } |
|
| 5089 | + |
|
| 5090 | + // Vider tous les tampons |
|
| 5091 | + $level = @ob_get_level(); |
|
| 5092 | + while ($level--) { |
|
| 5093 | + @ob_end_clean(); |
|
| 5094 | + } |
|
| 5095 | + |
|
| 5096 | + include_spip('inc/headers'); |
|
| 5097 | + |
|
| 5098 | + // S'il y a une URL, on redirige (si pas de statut, la fonction mettra 302 par défaut) |
|
| 5099 | + if ($url) { |
|
| 5100 | + redirige_par_entete($url, '', $statut); |
|
| 5101 | + } |
|
| 5102 | + |
|
| 5103 | + // ecriture simplifiee avec message en 3eme argument (= statut 403) |
|
| 5104 | + if (!is_numeric($statut) and is_null($message)) { |
|
| 5105 | + $message = $statut; |
|
| 5106 | + $statut = 0; |
|
| 5107 | + } |
|
| 5108 | + if (!$message) { |
|
| 5109 | + $message = ''; |
|
| 5110 | + } |
|
| 5111 | + $statut = intval($statut); |
|
| 5112 | + |
|
| 5113 | + // Si on est dans l'espace privé, on génère du 403 Forbidden par defaut ou du 404 |
|
| 5114 | + if (test_espace_prive()) { |
|
| 5115 | + if (!$statut or !in_array($statut, array(404, 403))) { |
|
| 5116 | + $statut = 403; |
|
| 5117 | + } |
|
| 5118 | + http_status(403); |
|
| 5119 | + $echec = charger_fonction('403', 'exec'); |
|
| 5120 | + $echec($message); |
|
| 5121 | + } else { |
|
| 5122 | + // Sinon dans l'espace public on redirige vers une 404 par défaut, car elle toujours présente normalement |
|
| 5123 | + if (!$statut) { |
|
| 5124 | + $statut = 404; |
|
| 5125 | + } |
|
| 5126 | + // Dans tous les cas on modifie l'entité avec ce qui est demandé |
|
| 5127 | + http_status($statut); |
|
| 5128 | + // Si le statut est une erreur et qu'il n'y a pas de redirection on va chercher le squelette du même nom |
|
| 5129 | + if ($statut >= 400) { |
|
| 5130 | + echo recuperer_fond("$statut", array('erreur' => $message)); |
|
| 5131 | + } |
|
| 5132 | + } |
|
| 5133 | + |
|
| 5134 | + |
|
| 5135 | + exit; |
|
| 5136 | 5136 | } |
| 5137 | 5137 | |
| 5138 | 5138 | /** |
@@ -5143,11 +5143,11 @@ discard block |
||
| 5143 | 5143 | * @return string |
| 5144 | 5144 | */ |
| 5145 | 5145 | function filtre_compacte_dist($source, $format = null) { |
| 5146 | - if (function_exists('compacte')) { |
|
| 5147 | - return compacte($source, $format); |
|
| 5148 | - } |
|
| 5146 | + if (function_exists('compacte')) { |
|
| 5147 | + return compacte($source, $format); |
|
| 5148 | + } |
|
| 5149 | 5149 | |
| 5150 | - return $source; |
|
| 5150 | + return $source; |
|
| 5151 | 5151 | } |
| 5152 | 5152 | |
| 5153 | 5153 | |
@@ -5159,31 +5159,31 @@ discard block |
||
| 5159 | 5159 | * @return string |
| 5160 | 5160 | */ |
| 5161 | 5161 | function spip_affiche_mot_de_passe_masque($passe, $afficher_partiellement = false, $portion_pourcent = null) { |
| 5162 | - $l = strlen($passe); |
|
| 5163 | - |
|
| 5164 | - if ($l<=8 or !$afficher_partiellement){ |
|
| 5165 | - if (!$l) { |
|
| 5166 | - return ''; // montrer qu'il y a pas de mot de passe si il y en a pas |
|
| 5167 | - } |
|
| 5168 | - return str_pad('',$afficher_partiellement ? $l : 16,'*'); |
|
| 5169 | - } |
|
| 5170 | - |
|
| 5171 | - if (is_null($portion_pourcent)) { |
|
| 5172 | - if (!defined('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT')) { |
|
| 5173 | - define('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT', 20); // 20% |
|
| 5174 | - } |
|
| 5175 | - $portion_pourcent = _SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT; |
|
| 5176 | - } |
|
| 5177 | - if ($portion_pourcent >= 100) { |
|
| 5178 | - return $passe; |
|
| 5179 | - } |
|
| 5180 | - $e = intval(ceil($l * $portion_pourcent / 100 / 2)); |
|
| 5181 | - $e = max($e, 0); |
|
| 5182 | - $mid = str_pad('',$l-2*$e,'*'); |
|
| 5183 | - if ($e>0 and strlen($mid)>8){ |
|
| 5184 | - $mid = '***...***'; |
|
| 5185 | - } |
|
| 5186 | - return substr($passe,0,$e) . $mid . ($e > 0 ? substr($passe,-$e) : ''); |
|
| 5162 | + $l = strlen($passe); |
|
| 5163 | + |
|
| 5164 | + if ($l<=8 or !$afficher_partiellement){ |
|
| 5165 | + if (!$l) { |
|
| 5166 | + return ''; // montrer qu'il y a pas de mot de passe si il y en a pas |
|
| 5167 | + } |
|
| 5168 | + return str_pad('',$afficher_partiellement ? $l : 16,'*'); |
|
| 5169 | + } |
|
| 5170 | + |
|
| 5171 | + if (is_null($portion_pourcent)) { |
|
| 5172 | + if (!defined('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT')) { |
|
| 5173 | + define('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT', 20); // 20% |
|
| 5174 | + } |
|
| 5175 | + $portion_pourcent = _SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT; |
|
| 5176 | + } |
|
| 5177 | + if ($portion_pourcent >= 100) { |
|
| 5178 | + return $passe; |
|
| 5179 | + } |
|
| 5180 | + $e = intval(ceil($l * $portion_pourcent / 100 / 2)); |
|
| 5181 | + $e = max($e, 0); |
|
| 5182 | + $mid = str_pad('',$l-2*$e,'*'); |
|
| 5183 | + if ($e>0 and strlen($mid)>8){ |
|
| 5184 | + $mid = '***...***'; |
|
| 5185 | + } |
|
| 5186 | + return substr($passe,0,$e) . $mid . ($e > 0 ? substr($passe,-$e) : ''); |
|
| 5187 | 5187 | } |
| 5188 | 5188 | |
| 5189 | 5189 | |
@@ -5204,64 +5204,64 @@ discard block |
||
| 5204 | 5204 | */ |
| 5205 | 5205 | function identifiant_slug($texte, $type = '', $options = array()) { |
| 5206 | 5206 | |
| 5207 | - $original = $texte; |
|
| 5208 | - $separateur = (isset($options['separateur'])?$options['separateur']:'_'); |
|
| 5209 | - $longueur_maxi = (isset($options['longueur_maxi'])?$options['longueur_maxi']:60); |
|
| 5210 | - $longueur_mini = (isset($options['longueur_mini'])?$options['longueur_mini']:0); |
|
| 5207 | + $original = $texte; |
|
| 5208 | + $separateur = (isset($options['separateur'])?$options['separateur']:'_'); |
|
| 5209 | + $longueur_maxi = (isset($options['longueur_maxi'])?$options['longueur_maxi']:60); |
|
| 5210 | + $longueur_mini = (isset($options['longueur_mini'])?$options['longueur_mini']:0); |
|
| 5211 | 5211 | |
| 5212 | - if (!function_exists('translitteration')) { |
|
| 5213 | - include_spip('inc/charsets'); |
|
| 5214 | - } |
|
| 5212 | + if (!function_exists('translitteration')) { |
|
| 5213 | + include_spip('inc/charsets'); |
|
| 5214 | + } |
|
| 5215 | 5215 | |
| 5216 | - // pas de balise html |
|
| 5217 | - if (strpos($texte, '<') !== false) { |
|
| 5218 | - $texte = strip_tags($texte); |
|
| 5219 | - } |
|
| 5220 | - if (strpos($texte, '&') !== false) { |
|
| 5221 | - $texte = unicode2charset($texte); |
|
| 5222 | - } |
|
| 5223 | - // On enlève les espaces indésirables |
|
| 5224 | - $texte = trim($texte); |
|
| 5216 | + // pas de balise html |
|
| 5217 | + if (strpos($texte, '<') !== false) { |
|
| 5218 | + $texte = strip_tags($texte); |
|
| 5219 | + } |
|
| 5220 | + if (strpos($texte, '&') !== false) { |
|
| 5221 | + $texte = unicode2charset($texte); |
|
| 5222 | + } |
|
| 5223 | + // On enlève les espaces indésirables |
|
| 5224 | + $texte = trim($texte); |
|
| 5225 | 5225 | |
| 5226 | - // On enlève les accents et cie |
|
| 5227 | - $texte = translitteration($texte); |
|
| 5226 | + // On enlève les accents et cie |
|
| 5227 | + $texte = translitteration($texte); |
|
| 5228 | 5228 | |
| 5229 | - // On remplace tout ce qui n'est pas un mot par un séparateur |
|
| 5230 | - $texte = preg_replace(',[\W_]+,ms', $separateur, $texte); |
|
| 5229 | + // On remplace tout ce qui n'est pas un mot par un séparateur |
|
| 5230 | + $texte = preg_replace(',[\W_]+,ms', $separateur, $texte); |
|
| 5231 | 5231 | |
| 5232 | - // nettoyer les doubles occurences du separateur si besoin |
|
| 5233 | - while (strpos($texte, "$separateur$separateur") !== false) { |
|
| 5234 | - $texte = str_replace("$separateur$separateur", $separateur, $texte); |
|
| 5235 | - } |
|
| 5232 | + // nettoyer les doubles occurences du separateur si besoin |
|
| 5233 | + while (strpos($texte, "$separateur$separateur") !== false) { |
|
| 5234 | + $texte = str_replace("$separateur$separateur", $separateur, $texte); |
|
| 5235 | + } |
|
| 5236 | 5236 | |
| 5237 | - // pas de separateur au debut ni a la fin |
|
| 5238 | - $texte = trim($texte, $separateur); |
|
| 5237 | + // pas de separateur au debut ni a la fin |
|
| 5238 | + $texte = trim($texte, $separateur); |
|
| 5239 | 5239 | |
| 5240 | - // en minuscules |
|
| 5241 | - $texte = strtolower($texte); |
|
| 5240 | + // en minuscules |
|
| 5241 | + $texte = strtolower($texte); |
|
| 5242 | 5242 | |
| 5243 | - switch ($type) { |
|
| 5244 | - case 'class': |
|
| 5245 | - case 'id': |
|
| 5246 | - case 'anchor': |
|
| 5247 | - if (preg_match(',^\d,', $texte)) { |
|
| 5248 | - $texte = substr($type, 0, 1).$texte; |
|
| 5249 | - } |
|
| 5250 | - } |
|
| 5243 | + switch ($type) { |
|
| 5244 | + case 'class': |
|
| 5245 | + case 'id': |
|
| 5246 | + case 'anchor': |
|
| 5247 | + if (preg_match(',^\d,', $texte)) { |
|
| 5248 | + $texte = substr($type, 0, 1).$texte; |
|
| 5249 | + } |
|
| 5250 | + } |
|
| 5251 | 5251 | |
| 5252 | - if (strlen($texte)>$longueur_maxi) { |
|
| 5253 | - $texte = substr($texte, 0, $longueur_maxi); |
|
| 5254 | - } |
|
| 5252 | + if (strlen($texte)>$longueur_maxi) { |
|
| 5253 | + $texte = substr($texte, 0, $longueur_maxi); |
|
| 5254 | + } |
|
| 5255 | 5255 | |
| 5256 | - if (strlen($texte) < $longueur_mini and $longueur_mini < $longueur_maxi) { |
|
| 5257 | - if (preg_match(',^\d,', $texte)) { |
|
| 5258 | - $texte = ($type ? substr($type,0,1) : "s") . $texte; |
|
| 5259 | - } |
|
| 5260 | - $texte .= $separateur . md5($original); |
|
| 5261 | - $texte = substr($texte, 0, $longueur_mini); |
|
| 5262 | - } |
|
| 5256 | + if (strlen($texte) < $longueur_mini and $longueur_mini < $longueur_maxi) { |
|
| 5257 | + if (preg_match(',^\d,', $texte)) { |
|
| 5258 | + $texte = ($type ? substr($type,0,1) : "s") . $texte; |
|
| 5259 | + } |
|
| 5260 | + $texte .= $separateur . md5($original); |
|
| 5261 | + $texte = substr($texte, 0, $longueur_mini); |
|
| 5262 | + } |
|
| 5263 | 5263 | |
| 5264 | - return $texte; |
|
| 5264 | + return $texte; |
|
| 5265 | 5265 | } |
| 5266 | 5266 | |
| 5267 | 5267 | |
@@ -5276,14 +5276,14 @@ discard block |
||
| 5276 | 5276 | * @exemple `<:info_maximum|uniformiser_label:>` |
| 5277 | 5277 | */ |
| 5278 | 5278 | function uniformiser_label(string $text, bool $ucfirst = true) : string { |
| 5279 | - $label = rtrim($text, " : \t\n\r\0\x0B\xc2\xa0"); |
|
| 5280 | - if ($label and $label[-1] === ';') { |
|
| 5281 | - $label = preg_replace("#(\ )+$#", "", $label); |
|
| 5282 | - } |
|
| 5283 | - if ($ucfirst) { |
|
| 5284 | - $label = spip_ucfirst($label); |
|
| 5285 | - } |
|
| 5286 | - return $label; |
|
| 5279 | + $label = rtrim($text, " : \t\n\r\0\x0B\xc2\xa0"); |
|
| 5280 | + if ($label and $label[-1] === ';') { |
|
| 5281 | + $label = preg_replace("#(\ )+$#", "", $label); |
|
| 5282 | + } |
|
| 5283 | + if ($ucfirst) { |
|
| 5284 | + $label = spip_ucfirst($label); |
|
| 5285 | + } |
|
| 5286 | + return $label; |
|
| 5287 | 5287 | } |
| 5288 | 5288 | |
| 5289 | 5289 | |
@@ -5295,19 +5295,19 @@ discard block |
||
| 5295 | 5295 | * @return array |
| 5296 | 5296 | */ |
| 5297 | 5297 | function helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, $fonction) { |
| 5298 | - if (!in_array($fonction, ['objet_lister_parents', 'objet_lister_enfants', 'objet_lister_parents_par_type', 'objet_lister_enfants_par_type'])) { |
|
| 5299 | - return []; |
|
| 5300 | - } |
|
| 5298 | + if (!in_array($fonction, ['objet_lister_parents', 'objet_lister_enfants', 'objet_lister_parents_par_type', 'objet_lister_enfants_par_type'])) { |
|
| 5299 | + return []; |
|
| 5300 | + } |
|
| 5301 | 5301 | |
| 5302 | - // compatibilite signature inversee |
|
| 5303 | - if (is_numeric($objet) and !is_numeric($id_objet)) { |
|
| 5304 | - list($objet, $id_objet) = [$id_objet, $objet]; |
|
| 5305 | - } |
|
| 5302 | + // compatibilite signature inversee |
|
| 5303 | + if (is_numeric($objet) and !is_numeric($id_objet)) { |
|
| 5304 | + list($objet, $id_objet) = [$id_objet, $objet]; |
|
| 5305 | + } |
|
| 5306 | 5306 | |
| 5307 | - if (!function_exists($fonction)) { |
|
| 5308 | - include_spip('base/objets'); |
|
| 5309 | - } |
|
| 5310 | - return $fonction($objet, $id_objet); |
|
| 5307 | + if (!function_exists($fonction)) { |
|
| 5308 | + include_spip('base/objets'); |
|
| 5309 | + } |
|
| 5310 | + return $fonction($objet, $id_objet); |
|
| 5311 | 5311 | } |
| 5312 | 5312 | |
| 5313 | 5313 | |
@@ -5322,7 +5322,7 @@ discard block |
||
| 5322 | 5322 | * @return array |
| 5323 | 5323 | */ |
| 5324 | 5324 | function filtre_objet_lister_parents_dist($objet, $id_objet) { |
| 5325 | - return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_parents'); |
|
| 5325 | + return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_parents'); |
|
| 5326 | 5326 | } |
| 5327 | 5327 | |
| 5328 | 5328 | /** |
@@ -5336,7 +5336,7 @@ discard block |
||
| 5336 | 5336 | * @return array |
| 5337 | 5337 | */ |
| 5338 | 5338 | function filtre_objet_lister_parents_par_type_dist($objet, $id_objet) { |
| 5339 | - return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_parents_par_type'); |
|
| 5339 | + return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_parents_par_type'); |
|
| 5340 | 5340 | } |
| 5341 | 5341 | |
| 5342 | 5342 | /** |
@@ -5350,7 +5350,7 @@ discard block |
||
| 5350 | 5350 | * @return array |
| 5351 | 5351 | */ |
| 5352 | 5352 | function filtre_objet_lister_enfants_dist($objet, $id_objet) { |
| 5353 | - return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_enfants'); |
|
| 5353 | + return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_enfants'); |
|
| 5354 | 5354 | } |
| 5355 | 5355 | |
| 5356 | 5356 | /** |
@@ -5364,6 +5364,6 @@ discard block |
||
| 5364 | 5364 | * @return array |
| 5365 | 5365 | */ |
| 5366 | 5366 | function filtre_objet_lister_enfants_par_type_dist($objet, $id_objet) { |
| 5367 | - return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_enfants_par_type'); |
|
| 5367 | + return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_enfants_par_type'); |
|
| 5368 | 5368 | } |
| 5369 | 5369 | |