@@ -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 | /** |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | * @return string Texte |
| 54 | 54 | **/ |
| 55 | 55 | function filtre_identite_dist($texte) { |
| 56 | - return $texte; |
|
| 56 | + return $texte; |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /** |
@@ -77,38 +77,38 @@ discard block |
||
| 77 | 77 | * Fonction PHP correspondante du filtre demandé |
| 78 | 78 | */ |
| 79 | 79 | function chercher_filtre($fonc, $default = null) { |
| 80 | - if (!$fonc) { |
|
| 81 | - return $default; |
|
| 82 | - } |
|
| 83 | - // Cas des types mime, sans confondre avec les appels de fonction de classe |
|
| 84 | - // Foo::Bar |
|
| 85 | - // qui peuvent etre avec un namespace : space\Foo::Bar |
|
| 86 | - if (preg_match(',^[\w]+/,', $fonc)) { |
|
| 87 | - $nom = preg_replace(',\W,', '_', $fonc); |
|
| 88 | - $f = chercher_filtre($nom); |
|
| 89 | - // cas du sous-type MIME sans filtre associe, passer au type: |
|
| 90 | - // si filtre_text_plain pas defini, passe a filtre_text |
|
| 91 | - if (!$f and $nom !== $fonc) { |
|
| 92 | - $f = chercher_filtre(preg_replace(',\W.*$,', '', $fonc)); |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - return $f; |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - include_fichiers_fonctions(); |
|
| 99 | - foreach (['filtre_' . $fonc, 'filtre_' . $fonc . '_dist', $fonc] as $f) { |
|
| 100 | - trouver_filtre_matrice($f); // charge des fichiers spécifiques éventuels |
|
| 101 | - // fonction ou name\space\fonction |
|
| 102 | - if (is_callable($f)) { |
|
| 103 | - return $f; |
|
| 104 | - } |
|
| 105 | - // méthode statique d'une classe Classe::methode ou name\space\Classe::methode |
|
| 106 | - elseif (false === strpos($f, '::') and is_callable([$f])) { |
|
| 107 | - return $f; |
|
| 108 | - } |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - return $default; |
|
| 80 | + if (!$fonc) { |
|
| 81 | + return $default; |
|
| 82 | + } |
|
| 83 | + // Cas des types mime, sans confondre avec les appels de fonction de classe |
|
| 84 | + // Foo::Bar |
|
| 85 | + // qui peuvent etre avec un namespace : space\Foo::Bar |
|
| 86 | + if (preg_match(',^[\w]+/,', $fonc)) { |
|
| 87 | + $nom = preg_replace(',\W,', '_', $fonc); |
|
| 88 | + $f = chercher_filtre($nom); |
|
| 89 | + // cas du sous-type MIME sans filtre associe, passer au type: |
|
| 90 | + // si filtre_text_plain pas defini, passe a filtre_text |
|
| 91 | + if (!$f and $nom !== $fonc) { |
|
| 92 | + $f = chercher_filtre(preg_replace(',\W.*$,', '', $fonc)); |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + return $f; |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + include_fichiers_fonctions(); |
|
| 99 | + foreach (['filtre_' . $fonc, 'filtre_' . $fonc . '_dist', $fonc] as $f) { |
|
| 100 | + trouver_filtre_matrice($f); // charge des fichiers spécifiques éventuels |
|
| 101 | + // fonction ou name\space\fonction |
|
| 102 | + if (is_callable($f)) { |
|
| 103 | + return $f; |
|
| 104 | + } |
|
| 105 | + // méthode statique d'une classe Classe::methode ou name\space\Classe::methode |
|
| 106 | + elseif (false === strpos($f, '::') and is_callable([$f])) { |
|
| 107 | + return $f; |
|
| 108 | + } |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + return $default; |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
@@ -152,8 +152,8 @@ discard block |
||
| 152 | 152 | * Chaîne vide sinon. |
| 153 | 153 | **/ |
| 154 | 154 | function appliquer_filtre($arg, $filtre) { |
| 155 | - $args = func_get_args(); |
|
| 156 | - return appliquer_filtre_sinon($arg, $filtre, $args, ''); |
|
| 155 | + $args = func_get_args(); |
|
| 156 | + return appliquer_filtre_sinon($arg, $filtre, $args, ''); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /** |
@@ -178,8 +178,8 @@ discard block |
||
| 178 | 178 | * Texte d'origine sinon |
| 179 | 179 | **/ |
| 180 | 180 | function appliquer_si_filtre($arg, $filtre) { |
| 181 | - $args = func_get_args(); |
|
| 182 | - return appliquer_filtre_sinon($arg, $filtre, $args, $arg); |
|
| 181 | + $args = func_get_args(); |
|
| 182 | + return appliquer_filtre_sinon($arg, $filtre, $args, $arg); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | /** |
@@ -195,12 +195,12 @@ discard block |
||
| 195 | 195 | * Version de SPIP |
| 196 | 196 | **/ |
| 197 | 197 | function spip_version() { |
| 198 | - $version = $GLOBALS['spip_version_affichee']; |
|
| 199 | - if ($vcs_version = version_vcs_courante(_DIR_RACINE)) { |
|
| 200 | - $version .= " $vcs_version"; |
|
| 201 | - } |
|
| 198 | + $version = $GLOBALS['spip_version_affichee']; |
|
| 199 | + if ($vcs_version = version_vcs_courante(_DIR_RACINE)) { |
|
| 200 | + $version .= " $vcs_version"; |
|
| 201 | + } |
|
| 202 | 202 | |
| 203 | - return $version; |
|
| 203 | + return $version; |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | /** |
@@ -213,19 +213,19 @@ discard block |
||
| 213 | 213 | * - string|null si $raw = false |
| 214 | 214 | */ |
| 215 | 215 | function version_vcs_courante($dir, $raw = false) { |
| 216 | - $desc = decrire_version_git($dir); |
|
| 217 | - if ($desc === null) { |
|
| 218 | - $desc = decrire_version_svn($dir); |
|
| 219 | - } |
|
| 220 | - if ($desc === null or $raw) { |
|
| 221 | - return $desc; |
|
| 222 | - } |
|
| 223 | - // affichage "GIT [master: abcdef]" |
|
| 224 | - $commit = $desc['commit_short'] ?? $desc['commit']; |
|
| 225 | - if ($desc['branch']) { |
|
| 226 | - $commit = $desc['branch'] . ': ' . $commit; |
|
| 227 | - } |
|
| 228 | - return "{$desc['vcs']} [$commit]"; |
|
| 216 | + $desc = decrire_version_git($dir); |
|
| 217 | + if ($desc === null) { |
|
| 218 | + $desc = decrire_version_svn($dir); |
|
| 219 | + } |
|
| 220 | + if ($desc === null or $raw) { |
|
| 221 | + return $desc; |
|
| 222 | + } |
|
| 223 | + // affichage "GIT [master: abcdef]" |
|
| 224 | + $commit = $desc['commit_short'] ?? $desc['commit']; |
|
| 225 | + if ($desc['branch']) { |
|
| 226 | + $commit = $desc['branch'] . ': ' . $commit; |
|
| 227 | + } |
|
| 228 | + return "{$desc['vcs']} [$commit]"; |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | /** |
@@ -237,24 +237,24 @@ discard block |
||
| 237 | 237 | * array ['branch' => xx, 'commit' => yy] sinon. |
| 238 | 238 | **/ |
| 239 | 239 | function decrire_version_git($dir) { |
| 240 | - if (!$dir) { |
|
| 241 | - $dir = '.'; |
|
| 242 | - } |
|
| 240 | + if (!$dir) { |
|
| 241 | + $dir = '.'; |
|
| 242 | + } |
|
| 243 | 243 | |
| 244 | - // version installee par GIT |
|
| 245 | - if (lire_fichier($dir . '/.git/HEAD', $c)) { |
|
| 246 | - $currentHead = trim(substr($c, 4)); |
|
| 247 | - if (lire_fichier($dir . '/.git/' . $currentHead, $hash)) { |
|
| 248 | - return [ |
|
| 249 | - 'vcs' => 'GIT', |
|
| 250 | - 'branch' => basename($currentHead), |
|
| 251 | - 'commit' => trim($hash), |
|
| 252 | - 'commit_short' => substr(trim($hash), 0, 8), |
|
| 253 | - ]; |
|
| 254 | - } |
|
| 255 | - } |
|
| 244 | + // version installee par GIT |
|
| 245 | + if (lire_fichier($dir . '/.git/HEAD', $c)) { |
|
| 246 | + $currentHead = trim(substr($c, 4)); |
|
| 247 | + if (lire_fichier($dir . '/.git/' . $currentHead, $hash)) { |
|
| 248 | + return [ |
|
| 249 | + 'vcs' => 'GIT', |
|
| 250 | + 'branch' => basename($currentHead), |
|
| 251 | + 'commit' => trim($hash), |
|
| 252 | + 'commit_short' => substr(trim($hash), 0, 8), |
|
| 253 | + ]; |
|
| 254 | + } |
|
| 255 | + } |
|
| 256 | 256 | |
| 257 | - return null; |
|
| 257 | + return null; |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | |
@@ -267,25 +267,25 @@ discard block |
||
| 267 | 267 | * array ['commit' => yy, 'date' => xx, 'author' => xx] sinon. |
| 268 | 268 | **/ |
| 269 | 269 | function decrire_version_svn($dir) { |
| 270 | - if (!$dir) { |
|
| 271 | - $dir = '.'; |
|
| 272 | - } |
|
| 273 | - // version installee par SVN |
|
| 274 | - if (file_exists($dir . '/.svn/wc.db') && class_exists(\SQLite3::class)) { |
|
| 275 | - $db = new SQLite3($dir . '/.svn/wc.db'); |
|
| 276 | - $result = $db->query('SELECT changed_revision FROM nodes WHERE local_relpath = "" LIMIT 1'); |
|
| 277 | - if ($result) { |
|
| 278 | - $row = $result->fetchArray(); |
|
| 279 | - if ($row['changed_revision'] != '') { |
|
| 280 | - return [ |
|
| 281 | - 'vcs' => 'SVN', |
|
| 282 | - 'branch' => '', |
|
| 283 | - 'commit' => $row['changed_revision'], |
|
| 284 | - ]; |
|
| 285 | - } |
|
| 286 | - } |
|
| 287 | - } |
|
| 288 | - return null; |
|
| 270 | + if (!$dir) { |
|
| 271 | + $dir = '.'; |
|
| 272 | + } |
|
| 273 | + // version installee par SVN |
|
| 274 | + if (file_exists($dir . '/.svn/wc.db') && class_exists(\SQLite3::class)) { |
|
| 275 | + $db = new SQLite3($dir . '/.svn/wc.db'); |
|
| 276 | + $result = $db->query('SELECT changed_revision FROM nodes WHERE local_relpath = "" LIMIT 1'); |
|
| 277 | + if ($result) { |
|
| 278 | + $row = $result->fetchArray(); |
|
| 279 | + if ($row['changed_revision'] != '') { |
|
| 280 | + return [ |
|
| 281 | + 'vcs' => 'SVN', |
|
| 282 | + 'branch' => '', |
|
| 283 | + 'commit' => $row['changed_revision'], |
|
| 284 | + ]; |
|
| 285 | + } |
|
| 286 | + } |
|
| 287 | + } |
|
| 288 | + return null; |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | // La matrice est necessaire pour ne filtrer _que_ des fonctions definies dans filtres_images |
@@ -332,18 +332,18 @@ discard block |
||
| 332 | 332 | * Code HTML retourné par le filtre |
| 333 | 333 | **/ |
| 334 | 334 | function filtrer($filtre) { |
| 335 | - $tous = func_get_args(); |
|
| 336 | - if (trouver_filtre_matrice($filtre) and substr($filtre, 0, 6) == 'image_') { |
|
| 337 | - return image_filtrer($tous); |
|
| 338 | - } elseif ($f = chercher_filtre($filtre)) { |
|
| 339 | - array_shift($tous); |
|
| 340 | - return call_user_func_array($f, $tous); |
|
| 341 | - } else { |
|
| 342 | - // le filtre n'existe pas, on provoque une erreur |
|
| 343 | - $msg = ['zbug_erreur_filtre', ['filtre' => texte_script($filtre)]]; |
|
| 344 | - erreur_squelette($msg); |
|
| 345 | - return ''; |
|
| 346 | - } |
|
| 335 | + $tous = func_get_args(); |
|
| 336 | + if (trouver_filtre_matrice($filtre) and substr($filtre, 0, 6) == 'image_') { |
|
| 337 | + return image_filtrer($tous); |
|
| 338 | + } elseif ($f = chercher_filtre($filtre)) { |
|
| 339 | + array_shift($tous); |
|
| 340 | + return call_user_func_array($f, $tous); |
|
| 341 | + } else { |
|
| 342 | + // le filtre n'existe pas, on provoque une erreur |
|
| 343 | + $msg = ['zbug_erreur_filtre', ['filtre' => texte_script($filtre)]]; |
|
| 344 | + erreur_squelette($msg); |
|
| 345 | + return ''; |
|
| 346 | + } |
|
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | /** |
@@ -360,11 +360,11 @@ discard block |
||
| 360 | 360 | * @return bool true si on trouve le filtre dans la matrice, false sinon. |
| 361 | 361 | */ |
| 362 | 362 | function trouver_filtre_matrice($filtre) { |
| 363 | - if (isset($GLOBALS['spip_matrice'][$filtre]) and is_string($f = $GLOBALS['spip_matrice'][$filtre])) { |
|
| 364 | - find_in_path($f, '', true); |
|
| 365 | - $GLOBALS['spip_matrice'][$filtre] = true; |
|
| 366 | - } |
|
| 367 | - return !empty($GLOBALS['spip_matrice'][$filtre]); |
|
| 363 | + if (isset($GLOBALS['spip_matrice'][$filtre]) and is_string($f = $GLOBALS['spip_matrice'][$filtre])) { |
|
| 364 | + find_in_path($f, '', true); |
|
| 365 | + $GLOBALS['spip_matrice'][$filtre] = true; |
|
| 366 | + } |
|
| 367 | + return !empty($GLOBALS['spip_matrice'][$filtre]); |
|
| 368 | 368 | } |
| 369 | 369 | |
| 370 | 370 | |
@@ -392,8 +392,8 @@ discard block |
||
| 392 | 392 | * @return mixed |
| 393 | 393 | */ |
| 394 | 394 | function filtre_set(&$Pile, $val, $key, $continue = null) { |
| 395 | - $Pile['vars'][$key] = $val; |
|
| 396 | - return $continue ? $val : ''; |
|
| 395 | + $Pile['vars'][$key] = $val; |
|
| 396 | + return $continue ? $val : ''; |
|
| 397 | 397 | } |
| 398 | 398 | |
| 399 | 399 | /** |
@@ -419,8 +419,8 @@ discard block |
||
| 419 | 419 | * @return string|mixed Retourne `$val` si `$continue` présent, sinon ''. |
| 420 | 420 | */ |
| 421 | 421 | function filtre_setenv(&$Pile, $val, $key, $continue = null) { |
| 422 | - $Pile[0][$key] = $val; |
|
| 423 | - return $continue ? $val : ''; |
|
| 422 | + $Pile[0][$key] = $val; |
|
| 423 | + return $continue ? $val : ''; |
|
| 424 | 424 | } |
| 425 | 425 | |
| 426 | 426 | /** |
@@ -429,8 +429,8 @@ discard block |
||
| 429 | 429 | * @return string |
| 430 | 430 | */ |
| 431 | 431 | function filtre_sanitize_env(&$Pile, $keys) { |
| 432 | - $Pile[0] = spip_sanitize_from_request($Pile[0], $keys); |
|
| 433 | - return ''; |
|
| 432 | + $Pile[0] = spip_sanitize_from_request($Pile[0], $keys); |
|
| 433 | + return ''; |
|
| 434 | 434 | } |
| 435 | 435 | |
| 436 | 436 | |
@@ -453,18 +453,18 @@ discard block |
||
| 453 | 453 | * @return mixed Retourne la valeur (sans la modifier). |
| 454 | 454 | */ |
| 455 | 455 | function filtre_debug($val, $key = null) { |
| 456 | - $debug = ( |
|
| 457 | - is_null($key) ? '' : (var_export($key, true) . ' = ') |
|
| 458 | - ) . var_export($val, true); |
|
| 456 | + $debug = ( |
|
| 457 | + is_null($key) ? '' : (var_export($key, true) . ' = ') |
|
| 458 | + ) . var_export($val, true); |
|
| 459 | 459 | |
| 460 | - include_spip('inc/autoriser'); |
|
| 461 | - if (autoriser('webmestre')) { |
|
| 462 | - echo "<div class='spip_debug'>\n", $debug, "</div>\n"; |
|
| 463 | - } |
|
| 460 | + include_spip('inc/autoriser'); |
|
| 461 | + if (autoriser('webmestre')) { |
|
| 462 | + echo "<div class='spip_debug'>\n", $debug, "</div>\n"; |
|
| 463 | + } |
|
| 464 | 464 | |
| 465 | - spip_log($debug, 'debug'); |
|
| 465 | + spip_log($debug, 'debug'); |
|
| 466 | 466 | |
| 467 | - return $val; |
|
| 467 | + return $val; |
|
| 468 | 468 | } |
| 469 | 469 | |
| 470 | 470 | |
@@ -492,89 +492,89 @@ discard block |
||
| 492 | 492 | * Texte qui a reçu les filtres |
| 493 | 493 | **/ |
| 494 | 494 | function image_filtrer($args) { |
| 495 | - $filtre = array_shift($args); # enlever $filtre |
|
| 496 | - $texte = array_shift($args); |
|
| 497 | - if ($texte === null || !strlen($texte)) { |
|
| 498 | - return; |
|
| 499 | - } |
|
| 500 | - find_in_path('filtres_images_mini.php', 'inc/', true); |
|
| 501 | - statut_effacer_images_temporaires(true); // activer la suppression des images temporaires car le compilo finit la chaine par un image_graver |
|
| 502 | - // Cas du nom de fichier local |
|
| 503 | - $is_file = trim($texte); |
|
| 504 | - if ( |
|
| 505 | - strpos(substr($is_file, strlen(_DIR_RACINE)), '..') !== false |
|
| 506 | - or strpbrk($is_file, "<>\n\r\t") !== false |
|
| 507 | - or strpos($is_file, '/') === 0 |
|
| 508 | - ) { |
|
| 509 | - $is_file = false; |
|
| 510 | - } |
|
| 511 | - if ($is_file) { |
|
| 512 | - $is_local_file = function ($path) { |
|
| 513 | - if (strpos($path, '?') !== false) { |
|
| 514 | - $path = supprimer_timestamp($path); |
|
| 515 | - // remove ?24px added by find_in_theme on .svg files |
|
| 516 | - $path = preg_replace(',\?[[:digit:]]+(px)$,', '', $path); |
|
| 517 | - } |
|
| 518 | - return file_exists($path); |
|
| 519 | - }; |
|
| 520 | - if ($is_local_file($is_file) or tester_url_absolue($is_file)) { |
|
| 521 | - array_unshift($args, "<img src='$is_file' />"); |
|
| 522 | - $res = call_user_func_array($filtre, $args); |
|
| 523 | - statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo |
|
| 524 | - return $res; |
|
| 525 | - } |
|
| 526 | - } |
|
| 527 | - |
|
| 528 | - // Cas general : trier toutes les images, avec eventuellement leur <span> |
|
| 529 | - if ( |
|
| 530 | - preg_match_all( |
|
| 531 | - ',(<([a-z]+) [^<>]*spip_documents[^<>]*>)?\s*(<img\s.*>),UimsS', |
|
| 532 | - $texte, |
|
| 533 | - $tags, |
|
| 534 | - PREG_SET_ORDER |
|
| 535 | - ) |
|
| 536 | - ) { |
|
| 537 | - foreach ($tags as $tag) { |
|
| 538 | - $class = extraire_attribut($tag[3], 'class'); |
|
| 539 | - if ( |
|
| 540 | - !$class or |
|
| 541 | - (strpos($class, 'filtre_inactif') === false |
|
| 542 | - // compat historique a virer en 3.2 |
|
| 543 | - and strpos($class, 'no_image_filtrer') === false) |
|
| 544 | - ) { |
|
| 545 | - array_unshift($args, $tag[3]); |
|
| 546 | - if ($reduit = call_user_func_array($filtre, $args)) { |
|
| 547 | - // En cas de span spip_documents, modifier le style=...width: |
|
| 548 | - if ($tag[1]) { |
|
| 549 | - $w = extraire_attribut($reduit, 'width'); |
|
| 550 | - if (!$w and preg_match(',width:\s*(\d+)px,S', extraire_attribut($reduit, 'style'), $regs)) { |
|
| 551 | - $w = $regs[1]; |
|
| 552 | - } |
|
| 553 | - if ($w and ($style = extraire_attribut($tag[1], 'style'))) { |
|
| 554 | - $style = preg_replace(',width:\s*\d+px,S', "width:${w}px", $style); |
|
| 555 | - $replace = inserer_attribut($tag[1], 'style', $style); |
|
| 556 | - $texte = str_replace($tag[1], $replace, $texte); |
|
| 557 | - } |
|
| 558 | - } |
|
| 559 | - // traiter aussi un eventuel mouseover |
|
| 560 | - if ($mouseover = extraire_attribut($reduit, 'onmouseover')) { |
|
| 561 | - if (preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)) { |
|
| 562 | - $srcover = $match[1]; |
|
| 563 | - array_shift($args); |
|
| 564 | - array_unshift($args, "<img src='" . $match[1] . "' />"); |
|
| 565 | - $srcover_filter = call_user_func_array($filtre, $args); |
|
| 566 | - $srcover_filter = extraire_attribut($srcover_filter, 'src'); |
|
| 567 | - $reduit = str_replace($srcover, $srcover_filter, $reduit); |
|
| 568 | - } |
|
| 569 | - } |
|
| 570 | - $texte = str_replace($tag[3], $reduit, $texte); |
|
| 571 | - } |
|
| 572 | - array_shift($args); |
|
| 573 | - } |
|
| 574 | - } |
|
| 575 | - } |
|
| 576 | - statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo |
|
| 577 | - return $texte; |
|
| 495 | + $filtre = array_shift($args); # enlever $filtre |
|
| 496 | + $texte = array_shift($args); |
|
| 497 | + if ($texte === null || !strlen($texte)) { |
|
| 498 | + return; |
|
| 499 | + } |
|
| 500 | + find_in_path('filtres_images_mini.php', 'inc/', true); |
|
| 501 | + statut_effacer_images_temporaires(true); // activer la suppression des images temporaires car le compilo finit la chaine par un image_graver |
|
| 502 | + // Cas du nom de fichier local |
|
| 503 | + $is_file = trim($texte); |
|
| 504 | + if ( |
|
| 505 | + strpos(substr($is_file, strlen(_DIR_RACINE)), '..') !== false |
|
| 506 | + or strpbrk($is_file, "<>\n\r\t") !== false |
|
| 507 | + or strpos($is_file, '/') === 0 |
|
| 508 | + ) { |
|
| 509 | + $is_file = false; |
|
| 510 | + } |
|
| 511 | + if ($is_file) { |
|
| 512 | + $is_local_file = function ($path) { |
|
| 513 | + if (strpos($path, '?') !== false) { |
|
| 514 | + $path = supprimer_timestamp($path); |
|
| 515 | + // remove ?24px added by find_in_theme on .svg files |
|
| 516 | + $path = preg_replace(',\?[[:digit:]]+(px)$,', '', $path); |
|
| 517 | + } |
|
| 518 | + return file_exists($path); |
|
| 519 | + }; |
|
| 520 | + if ($is_local_file($is_file) or tester_url_absolue($is_file)) { |
|
| 521 | + array_unshift($args, "<img src='$is_file' />"); |
|
| 522 | + $res = call_user_func_array($filtre, $args); |
|
| 523 | + statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo |
|
| 524 | + return $res; |
|
| 525 | + } |
|
| 526 | + } |
|
| 527 | + |
|
| 528 | + // Cas general : trier toutes les images, avec eventuellement leur <span> |
|
| 529 | + if ( |
|
| 530 | + preg_match_all( |
|
| 531 | + ',(<([a-z]+) [^<>]*spip_documents[^<>]*>)?\s*(<img\s.*>),UimsS', |
|
| 532 | + $texte, |
|
| 533 | + $tags, |
|
| 534 | + PREG_SET_ORDER |
|
| 535 | + ) |
|
| 536 | + ) { |
|
| 537 | + foreach ($tags as $tag) { |
|
| 538 | + $class = extraire_attribut($tag[3], 'class'); |
|
| 539 | + if ( |
|
| 540 | + !$class or |
|
| 541 | + (strpos($class, 'filtre_inactif') === false |
|
| 542 | + // compat historique a virer en 3.2 |
|
| 543 | + and strpos($class, 'no_image_filtrer') === false) |
|
| 544 | + ) { |
|
| 545 | + array_unshift($args, $tag[3]); |
|
| 546 | + if ($reduit = call_user_func_array($filtre, $args)) { |
|
| 547 | + // En cas de span spip_documents, modifier le style=...width: |
|
| 548 | + if ($tag[1]) { |
|
| 549 | + $w = extraire_attribut($reduit, 'width'); |
|
| 550 | + if (!$w and preg_match(',width:\s*(\d+)px,S', extraire_attribut($reduit, 'style'), $regs)) { |
|
| 551 | + $w = $regs[1]; |
|
| 552 | + } |
|
| 553 | + if ($w and ($style = extraire_attribut($tag[1], 'style'))) { |
|
| 554 | + $style = preg_replace(',width:\s*\d+px,S', "width:${w}px", $style); |
|
| 555 | + $replace = inserer_attribut($tag[1], 'style', $style); |
|
| 556 | + $texte = str_replace($tag[1], $replace, $texte); |
|
| 557 | + } |
|
| 558 | + } |
|
| 559 | + // traiter aussi un eventuel mouseover |
|
| 560 | + if ($mouseover = extraire_attribut($reduit, 'onmouseover')) { |
|
| 561 | + if (preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)) { |
|
| 562 | + $srcover = $match[1]; |
|
| 563 | + array_shift($args); |
|
| 564 | + array_unshift($args, "<img src='" . $match[1] . "' />"); |
|
| 565 | + $srcover_filter = call_user_func_array($filtre, $args); |
|
| 566 | + $srcover_filter = extraire_attribut($srcover_filter, 'src'); |
|
| 567 | + $reduit = str_replace($srcover, $srcover_filter, $reduit); |
|
| 568 | + } |
|
| 569 | + } |
|
| 570 | + $texte = str_replace($tag[3], $reduit, $texte); |
|
| 571 | + } |
|
| 572 | + array_shift($args); |
|
| 573 | + } |
|
| 574 | + } |
|
| 575 | + } |
|
| 576 | + statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo |
|
| 577 | + return $texte; |
|
| 578 | 578 | } |
| 579 | 579 | |
| 580 | 580 | /** |
@@ -589,78 +589,78 @@ discard block |
||
| 589 | 589 | **/ |
| 590 | 590 | function taille_image($img, $force_refresh = false) { |
| 591 | 591 | |
| 592 | - static $largeur_img = [], $hauteur_img = []; |
|
| 593 | - $srcWidth = 0; |
|
| 594 | - $srcHeight = 0; |
|
| 595 | - |
|
| 596 | - $src = extraire_attribut($img, 'src'); |
|
| 597 | - |
|
| 598 | - if (!$src) { |
|
| 599 | - $src = $img; |
|
| 600 | - } else { |
|
| 601 | - $srcWidth = extraire_attribut($img, 'width'); |
|
| 602 | - $srcHeight = extraire_attribut($img, 'height'); |
|
| 603 | - } |
|
| 604 | - |
|
| 605 | - // ne jamais operer directement sur une image distante pour des raisons de perfo |
|
| 606 | - // la copie locale a toutes les chances d'etre la ou de resservir |
|
| 607 | - if (tester_url_absolue($src)) { |
|
| 608 | - include_spip('inc/distant'); |
|
| 609 | - $fichier = copie_locale($src); |
|
| 610 | - $src = $fichier ? _DIR_RACINE . $fichier : $src; |
|
| 611 | - } |
|
| 612 | - if (($p = strpos($src, '?')) !== false) { |
|
| 613 | - $src = substr($src, 0, $p); |
|
| 614 | - } |
|
| 615 | - |
|
| 616 | - $srcsize = false; |
|
| 617 | - if (isset($largeur_img[$src]) and !$force_refresh) { |
|
| 618 | - $srcWidth = $largeur_img[$src]; |
|
| 619 | - } |
|
| 620 | - if (isset($hauteur_img[$src]) and !$force_refresh) { |
|
| 621 | - $srcHeight = $hauteur_img[$src]; |
|
| 622 | - } |
|
| 623 | - if (!$srcWidth or !$srcHeight) { |
|
| 624 | - if ( |
|
| 625 | - file_exists($src) |
|
| 626 | - and $srcsize = spip_getimagesize($src) |
|
| 627 | - ) { |
|
| 628 | - if (!$srcWidth) { |
|
| 629 | - $largeur_img[$src] = $srcWidth = $srcsize[0]; |
|
| 630 | - } |
|
| 631 | - if (!$srcHeight) { |
|
| 632 | - $hauteur_img[$src] = $srcHeight = $srcsize[1]; |
|
| 633 | - } |
|
| 634 | - } |
|
| 635 | - elseif (strpos($src, '<svg') !== false) { |
|
| 636 | - include_spip('inc/svg'); |
|
| 637 | - if ($attrs = svg_lire_attributs($src)) { |
|
| 638 | - [$width, $height, $viewbox] = svg_getimagesize_from_attr($attrs); |
|
| 639 | - if (!$srcWidth) { |
|
| 640 | - $largeur_img[$src] = $srcWidth = $width; |
|
| 641 | - } |
|
| 642 | - if (!$srcHeight) { |
|
| 643 | - $hauteur_img[$src] = $srcHeight = $height; |
|
| 644 | - } |
|
| 645 | - } |
|
| 646 | - } |
|
| 647 | - // $src peut etre une reference a une image temporaire dont a n'a que le log .src |
|
| 648 | - // on s'y refere, l'image sera reconstruite en temps utile si necessaire |
|
| 649 | - elseif ( |
|
| 650 | - @file_exists($f = "$src.src") |
|
| 651 | - and lire_fichier($f, $valeurs) |
|
| 652 | - and $valeurs = unserialize($valeurs) |
|
| 653 | - ) { |
|
| 654 | - if (!$srcWidth) { |
|
| 655 | - $largeur_img[$src] = $srcWidth = $valeurs['largeur_dest']; |
|
| 656 | - } |
|
| 657 | - if (!$srcHeight) { |
|
| 658 | - $hauteur_img[$src] = $srcHeight = $valeurs['hauteur_dest']; |
|
| 659 | - } |
|
| 660 | - } |
|
| 661 | - } |
|
| 662 | - |
|
| 663 | - return [$srcHeight, $srcWidth]; |
|
| 592 | + static $largeur_img = [], $hauteur_img = []; |
|
| 593 | + $srcWidth = 0; |
|
| 594 | + $srcHeight = 0; |
|
| 595 | + |
|
| 596 | + $src = extraire_attribut($img, 'src'); |
|
| 597 | + |
|
| 598 | + if (!$src) { |
|
| 599 | + $src = $img; |
|
| 600 | + } else { |
|
| 601 | + $srcWidth = extraire_attribut($img, 'width'); |
|
| 602 | + $srcHeight = extraire_attribut($img, 'height'); |
|
| 603 | + } |
|
| 604 | + |
|
| 605 | + // ne jamais operer directement sur une image distante pour des raisons de perfo |
|
| 606 | + // la copie locale a toutes les chances d'etre la ou de resservir |
|
| 607 | + if (tester_url_absolue($src)) { |
|
| 608 | + include_spip('inc/distant'); |
|
| 609 | + $fichier = copie_locale($src); |
|
| 610 | + $src = $fichier ? _DIR_RACINE . $fichier : $src; |
|
| 611 | + } |
|
| 612 | + if (($p = strpos($src, '?')) !== false) { |
|
| 613 | + $src = substr($src, 0, $p); |
|
| 614 | + } |
|
| 615 | + |
|
| 616 | + $srcsize = false; |
|
| 617 | + if (isset($largeur_img[$src]) and !$force_refresh) { |
|
| 618 | + $srcWidth = $largeur_img[$src]; |
|
| 619 | + } |
|
| 620 | + if (isset($hauteur_img[$src]) and !$force_refresh) { |
|
| 621 | + $srcHeight = $hauteur_img[$src]; |
|
| 622 | + } |
|
| 623 | + if (!$srcWidth or !$srcHeight) { |
|
| 624 | + if ( |
|
| 625 | + file_exists($src) |
|
| 626 | + and $srcsize = spip_getimagesize($src) |
|
| 627 | + ) { |
|
| 628 | + if (!$srcWidth) { |
|
| 629 | + $largeur_img[$src] = $srcWidth = $srcsize[0]; |
|
| 630 | + } |
|
| 631 | + if (!$srcHeight) { |
|
| 632 | + $hauteur_img[$src] = $srcHeight = $srcsize[1]; |
|
| 633 | + } |
|
| 634 | + } |
|
| 635 | + elseif (strpos($src, '<svg') !== false) { |
|
| 636 | + include_spip('inc/svg'); |
|
| 637 | + if ($attrs = svg_lire_attributs($src)) { |
|
| 638 | + [$width, $height, $viewbox] = svg_getimagesize_from_attr($attrs); |
|
| 639 | + if (!$srcWidth) { |
|
| 640 | + $largeur_img[$src] = $srcWidth = $width; |
|
| 641 | + } |
|
| 642 | + if (!$srcHeight) { |
|
| 643 | + $hauteur_img[$src] = $srcHeight = $height; |
|
| 644 | + } |
|
| 645 | + } |
|
| 646 | + } |
|
| 647 | + // $src peut etre une reference a une image temporaire dont a n'a que le log .src |
|
| 648 | + // on s'y refere, l'image sera reconstruite en temps utile si necessaire |
|
| 649 | + elseif ( |
|
| 650 | + @file_exists($f = "$src.src") |
|
| 651 | + and lire_fichier($f, $valeurs) |
|
| 652 | + and $valeurs = unserialize($valeurs) |
|
| 653 | + ) { |
|
| 654 | + if (!$srcWidth) { |
|
| 655 | + $largeur_img[$src] = $srcWidth = $valeurs['largeur_dest']; |
|
| 656 | + } |
|
| 657 | + if (!$srcHeight) { |
|
| 658 | + $hauteur_img[$src] = $srcHeight = $valeurs['hauteur_dest']; |
|
| 659 | + } |
|
| 660 | + } |
|
| 661 | + } |
|
| 662 | + |
|
| 663 | + return [$srcHeight, $srcWidth]; |
|
| 664 | 664 | } |
| 665 | 665 | |
| 666 | 666 | |
@@ -678,12 +678,12 @@ discard block |
||
| 678 | 678 | * Largeur en pixels, NULL ou 0 si aucune image. |
| 679 | 679 | **/ |
| 680 | 680 | function largeur($img) { |
| 681 | - if (!$img) { |
|
| 682 | - return; |
|
| 683 | - } |
|
| 684 | - [$h, $l] = taille_image($img); |
|
| 681 | + if (!$img) { |
|
| 682 | + return; |
|
| 683 | + } |
|
| 684 | + [$h, $l] = taille_image($img); |
|
| 685 | 685 | |
| 686 | - return $l; |
|
| 686 | + return $l; |
|
| 687 | 687 | } |
| 688 | 688 | |
| 689 | 689 | /** |
@@ -700,12 +700,12 @@ discard block |
||
| 700 | 700 | * Hauteur en pixels, NULL ou 0 si aucune image. |
| 701 | 701 | **/ |
| 702 | 702 | function hauteur($img) { |
| 703 | - if (!$img) { |
|
| 704 | - return; |
|
| 705 | - } |
|
| 706 | - [$h, $l] = taille_image($img); |
|
| 703 | + if (!$img) { |
|
| 704 | + return; |
|
| 705 | + } |
|
| 706 | + [$h, $l] = taille_image($img); |
|
| 707 | 707 | |
| 708 | - return $h; |
|
| 708 | + return $h; |
|
| 709 | 709 | } |
| 710 | 710 | |
| 711 | 711 | |
@@ -725,11 +725,11 @@ discard block |
||
| 725 | 725 | * @return string |
| 726 | 726 | **/ |
| 727 | 727 | function corriger_entites_html($texte) { |
| 728 | - if (strpos($texte, '&') === false) { |
|
| 729 | - return $texte; |
|
| 730 | - } |
|
| 728 | + if (strpos($texte, '&') === false) { |
|
| 729 | + return $texte; |
|
| 730 | + } |
|
| 731 | 731 | |
| 732 | - return preg_replace(',&(#[0-9][0-9][0-9]+;|amp;),iS', '&\1', $texte); |
|
| 732 | + return preg_replace(',&(#[0-9][0-9][0-9]+;|amp;),iS', '&\1', $texte); |
|
| 733 | 733 | } |
| 734 | 734 | |
| 735 | 735 | /** |
@@ -744,11 +744,11 @@ discard block |
||
| 744 | 744 | * @return string |
| 745 | 745 | **/ |
| 746 | 746 | function corriger_toutes_entites_html($texte) { |
| 747 | - if (strpos($texte, '&') === false) { |
|
| 748 | - return $texte; |
|
| 749 | - } |
|
| 747 | + if (strpos($texte, '&') === false) { |
|
| 748 | + return $texte; |
|
| 749 | + } |
|
| 750 | 750 | |
| 751 | - return preg_replace(',&(#?[a-z0-9]+;),iS', '&\1', $texte); |
|
| 751 | + return preg_replace(',&(#?[a-z0-9]+;),iS', '&\1', $texte); |
|
| 752 | 752 | } |
| 753 | 753 | |
| 754 | 754 | /** |
@@ -758,7 +758,7 @@ discard block |
||
| 758 | 758 | * @return string |
| 759 | 759 | **/ |
| 760 | 760 | function proteger_amp($texte) { |
| 761 | - return str_replace('&', '&', $texte); |
|
| 761 | + return str_replace('&', '&', $texte); |
|
| 762 | 762 | } |
| 763 | 763 | |
| 764 | 764 | |
@@ -789,21 +789,21 @@ discard block |
||
| 789 | 789 | * @return mixed|string |
| 790 | 790 | */ |
| 791 | 791 | function entites_html($texte, $tout = false, $quote = true) { |
| 792 | - if ( |
|
| 793 | - !is_string($texte) or !$texte |
|
| 794 | - or strpbrk($texte, "&\"'<>") == false |
|
| 795 | - ) { |
|
| 796 | - return $texte; |
|
| 797 | - } |
|
| 798 | - include_spip('inc/texte'); |
|
| 799 | - $flags = ($quote ? ENT_QUOTES : ENT_NOQUOTES); |
|
| 800 | - $flags |= ENT_HTML401; |
|
| 801 | - $texte = spip_htmlspecialchars(echappe_retour(echappe_html($texte, '', true), '', 'proteger_amp'), $flags); |
|
| 802 | - if ($tout) { |
|
| 803 | - return corriger_toutes_entites_html($texte); |
|
| 804 | - } else { |
|
| 805 | - return corriger_entites_html($texte); |
|
| 806 | - } |
|
| 792 | + if ( |
|
| 793 | + !is_string($texte) or !$texte |
|
| 794 | + or strpbrk($texte, "&\"'<>") == false |
|
| 795 | + ) { |
|
| 796 | + return $texte; |
|
| 797 | + } |
|
| 798 | + include_spip('inc/texte'); |
|
| 799 | + $flags = ($quote ? ENT_QUOTES : ENT_NOQUOTES); |
|
| 800 | + $flags |= ENT_HTML401; |
|
| 801 | + $texte = spip_htmlspecialchars(echappe_retour(echappe_html($texte, '', true), '', 'proteger_amp'), $flags); |
|
| 802 | + if ($tout) { |
|
| 803 | + return corriger_toutes_entites_html($texte); |
|
| 804 | + } else { |
|
| 805 | + return corriger_entites_html($texte); |
|
| 806 | + } |
|
| 807 | 807 | } |
| 808 | 808 | |
| 809 | 809 | /** |
@@ -822,37 +822,37 @@ discard block |
||
| 822 | 822 | * Texte converti |
| 823 | 823 | **/ |
| 824 | 824 | function filtrer_entites($texte) { |
| 825 | - if (strpos($texte, '&') === false) { |
|
| 826 | - return $texte; |
|
| 827 | - } |
|
| 828 | - // filtrer |
|
| 829 | - $texte = html2unicode($texte); |
|
| 830 | - // remettre le tout dans le charset cible |
|
| 831 | - $texte = unicode2charset($texte); |
|
| 832 | - // cas particulier des " et ' qu'il faut filtrer aussi |
|
| 833 | - // (on le faisait deja avec un ") |
|
| 834 | - if (strpos($texte, '&#') !== false) { |
|
| 835 | - $texte = str_replace([''', ''', '"', '"'], ["'", "'", '"', '"'], $texte); |
|
| 836 | - } |
|
| 825 | + if (strpos($texte, '&') === false) { |
|
| 826 | + return $texte; |
|
| 827 | + } |
|
| 828 | + // filtrer |
|
| 829 | + $texte = html2unicode($texte); |
|
| 830 | + // remettre le tout dans le charset cible |
|
| 831 | + $texte = unicode2charset($texte); |
|
| 832 | + // cas particulier des " et ' qu'il faut filtrer aussi |
|
| 833 | + // (on le faisait deja avec un ") |
|
| 834 | + if (strpos($texte, '&#') !== false) { |
|
| 835 | + $texte = str_replace([''', ''', '"', '"'], ["'", "'", '"', '"'], $texte); |
|
| 836 | + } |
|
| 837 | 837 | |
| 838 | - return $texte; |
|
| 838 | + return $texte; |
|
| 839 | 839 | } |
| 840 | 840 | |
| 841 | 841 | |
| 842 | 842 | if (!function_exists('filtre_filtrer_entites_dist')) { |
| 843 | - /** |
|
| 844 | - * Version sécurisée de filtrer_entites |
|
| 845 | - * |
|
| 846 | - * @uses interdire_scripts() |
|
| 847 | - * @uses filtrer_entites() |
|
| 848 | - * |
|
| 849 | - * @param string $t |
|
| 850 | - * @return string |
|
| 851 | - */ |
|
| 852 | - function filtre_filtrer_entites_dist($t) { |
|
| 853 | - include_spip('inc/texte'); |
|
| 854 | - return interdire_scripts(filtrer_entites($t)); |
|
| 855 | - } |
|
| 843 | + /** |
|
| 844 | + * Version sécurisée de filtrer_entites |
|
| 845 | + * |
|
| 846 | + * @uses interdire_scripts() |
|
| 847 | + * @uses filtrer_entites() |
|
| 848 | + * |
|
| 849 | + * @param string $t |
|
| 850 | + * @return string |
|
| 851 | + */ |
|
| 852 | + function filtre_filtrer_entites_dist($t) { |
|
| 853 | + include_spip('inc/texte'); |
|
| 854 | + return interdire_scripts(filtrer_entites($t)); |
|
| 855 | + } |
|
| 856 | 856 | } |
| 857 | 857 | |
| 858 | 858 | |
@@ -867,18 +867,18 @@ discard block |
||
| 867 | 867 | * @return string|array |
| 868 | 868 | **/ |
| 869 | 869 | function supprimer_caracteres_illegaux($texte) { |
| 870 | - 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"; |
|
| 871 | - static $to = null; |
|
| 870 | + 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"; |
|
| 871 | + static $to = null; |
|
| 872 | 872 | |
| 873 | - if (is_array($texte)) { |
|
| 874 | - return array_map('supprimer_caracteres_illegaux', $texte); |
|
| 875 | - } |
|
| 873 | + if (is_array($texte)) { |
|
| 874 | + return array_map('supprimer_caracteres_illegaux', $texte); |
|
| 875 | + } |
|
| 876 | 876 | |
| 877 | - if (!$to) { |
|
| 878 | - $to = str_repeat('-', strlen($from)); |
|
| 879 | - } |
|
| 877 | + if (!$to) { |
|
| 878 | + $to = str_repeat('-', strlen($from)); |
|
| 879 | + } |
|
| 880 | 880 | |
| 881 | - return strtr($texte, $from, $to); |
|
| 881 | + return strtr($texte, $from, $to); |
|
| 882 | 882 | } |
| 883 | 883 | |
| 884 | 884 | /** |
@@ -890,10 +890,10 @@ discard block |
||
| 890 | 890 | * @return string|array |
| 891 | 891 | **/ |
| 892 | 892 | function corriger_caracteres($texte) { |
| 893 | - $texte = corriger_caracteres_windows($texte); |
|
| 894 | - $texte = supprimer_caracteres_illegaux($texte); |
|
| 893 | + $texte = corriger_caracteres_windows($texte); |
|
| 894 | + $texte = supprimer_caracteres_illegaux($texte); |
|
| 895 | 895 | |
| 896 | - return $texte; |
|
| 896 | + return $texte; |
|
| 897 | 897 | } |
| 898 | 898 | |
| 899 | 899 | /** |
@@ -910,44 +910,44 @@ discard block |
||
| 910 | 910 | * Texte encodé pour XML |
| 911 | 911 | */ |
| 912 | 912 | function texte_backend(string $texte): string { |
| 913 | - if ($texte === '') { |
|
| 914 | - return ''; |
|
| 915 | - } |
|
| 913 | + if ($texte === '') { |
|
| 914 | + return ''; |
|
| 915 | + } |
|
| 916 | 916 | |
| 917 | - static $apostrophe = ['’', "'"]; # n'allouer qu'une fois |
|
| 917 | + static $apostrophe = ['’', "'"]; # n'allouer qu'une fois |
|
| 918 | 918 | |
| 919 | - // si on a des liens ou des images, les passer en absolu |
|
| 920 | - $texte = liens_absolus($texte); |
|
| 919 | + // si on a des liens ou des images, les passer en absolu |
|
| 920 | + $texte = liens_absolus($texte); |
|
| 921 | 921 | |
| 922 | - // echapper les tags > < |
|
| 923 | - $texte = preg_replace(',&(gt|lt);,S', '&\1;', $texte); |
|
| 922 | + // echapper les tags > < |
|
| 923 | + $texte = preg_replace(',&(gt|lt);,S', '&\1;', $texte); |
|
| 924 | 924 | |
| 925 | - // importer les é |
|
| 926 | - $texte = filtrer_entites($texte); |
|
| 925 | + // importer les é |
|
| 926 | + $texte = filtrer_entites($texte); |
|
| 927 | 927 | |
| 928 | - // " -> " et tout ce genre de choses |
|
| 929 | - $u = $GLOBALS['meta']['pcre_u']; |
|
| 930 | - $texte = str_replace(' ', ' ', $texte); |
|
| 931 | - $texte = preg_replace('/\s{2,}/S' . $u, ' ', $texte); |
|
| 932 | - // ne pas echapper les sinqle quotes car certains outils de syndication gerent mal |
|
| 933 | - $texte = entites_html($texte, false, false); |
|
| 934 | - // mais bien echapper les double quotes ! |
|
| 935 | - $texte = str_replace('"', '"', $texte); |
|
| 928 | + // " -> " et tout ce genre de choses |
|
| 929 | + $u = $GLOBALS['meta']['pcre_u']; |
|
| 930 | + $texte = str_replace(' ', ' ', $texte); |
|
| 931 | + $texte = preg_replace('/\s{2,}/S' . $u, ' ', $texte); |
|
| 932 | + // ne pas echapper les sinqle quotes car certains outils de syndication gerent mal |
|
| 933 | + $texte = entites_html($texte, false, false); |
|
| 934 | + // mais bien echapper les double quotes ! |
|
| 935 | + $texte = str_replace('"', '"', $texte); |
|
| 936 | 936 | |
| 937 | - // verifier le charset |
|
| 938 | - $texte = charset2unicode($texte); |
|
| 937 | + // verifier le charset |
|
| 938 | + $texte = charset2unicode($texte); |
|
| 939 | 939 | |
| 940 | - // Caracteres problematiques en iso-latin 1 |
|
| 941 | - if (isset($GLOBALS['meta']['charset']) and $GLOBALS['meta']['charset'] == 'iso-8859-1') { |
|
| 942 | - $texte = str_replace(chr(156), 'œ', $texte); |
|
| 943 | - $texte = str_replace(chr(140), 'Œ', $texte); |
|
| 944 | - $texte = str_replace(chr(159), 'Ÿ', $texte); |
|
| 945 | - } |
|
| 940 | + // Caracteres problematiques en iso-latin 1 |
|
| 941 | + if (isset($GLOBALS['meta']['charset']) and $GLOBALS['meta']['charset'] == 'iso-8859-1') { |
|
| 942 | + $texte = str_replace(chr(156), 'œ', $texte); |
|
| 943 | + $texte = str_replace(chr(140), 'Œ', $texte); |
|
| 944 | + $texte = str_replace(chr(159), 'Ÿ', $texte); |
|
| 945 | + } |
|
| 946 | 946 | |
| 947 | - // l'apostrophe curly pose probleme a certains lecteure de RSS |
|
| 948 | - // et le caractere apostrophe alourdit les squelettes avec PHP |
|
| 949 | - // ==> on les remplace par l'entite HTML |
|
| 950 | - return str_replace($apostrophe, "'", $texte); |
|
| 947 | + // l'apostrophe curly pose probleme a certains lecteure de RSS |
|
| 948 | + // et le caractere apostrophe alourdit les squelettes avec PHP |
|
| 949 | + // ==> on les remplace par l'entite HTML |
|
| 950 | + return str_replace($apostrophe, "'", $texte); |
|
| 951 | 951 | } |
| 952 | 952 | |
| 953 | 953 | /** |
@@ -964,7 +964,7 @@ discard block |
||
| 964 | 964 | * Texte encodé et quote pour XML |
| 965 | 965 | */ |
| 966 | 966 | function texte_backendq(string $texte): string { |
| 967 | - return addslashes(texte_backend($texte)); |
|
| 967 | + return addslashes(texte_backend($texte)); |
|
| 968 | 968 | } |
| 969 | 969 | |
| 970 | 970 | |
@@ -987,11 +987,11 @@ discard block |
||
| 987 | 987 | * Numéro de titre, sinon chaîne vide |
| 988 | 988 | **/ |
| 989 | 989 | function supprimer_numero($texte) { |
| 990 | - return preg_replace( |
|
| 991 | - ',^[[:space:]]*([0-9]+)([.)]|' . chr(194) . '?' . chr(176) . ')[[:space:]]+,S', |
|
| 992 | - '', |
|
| 993 | - $texte |
|
| 994 | - ); |
|
| 990 | + return preg_replace( |
|
| 991 | + ',^[[:space:]]*([0-9]+)([.)]|' . chr(194) . '?' . chr(176) . ')[[:space:]]+,S', |
|
| 992 | + '', |
|
| 993 | + $texte |
|
| 994 | + ); |
|
| 995 | 995 | } |
| 996 | 996 | |
| 997 | 997 | /** |
@@ -1014,17 +1014,17 @@ discard block |
||
| 1014 | 1014 | * Numéro de titre, sinon chaîne vide |
| 1015 | 1015 | **/ |
| 1016 | 1016 | function recuperer_numero($texte) { |
| 1017 | - if ( |
|
| 1018 | - preg_match( |
|
| 1019 | - ',^[[:space:]]*([0-9]+)([.)]|' . chr(194) . '?' . chr(176) . ')[[:space:]]+,S', |
|
| 1020 | - $texte, |
|
| 1021 | - $regs |
|
| 1022 | - ) |
|
| 1023 | - ) { |
|
| 1024 | - return strval($regs[1]); |
|
| 1025 | - } else { |
|
| 1026 | - return ''; |
|
| 1027 | - } |
|
| 1017 | + if ( |
|
| 1018 | + preg_match( |
|
| 1019 | + ',^[[:space:]]*([0-9]+)([.)]|' . chr(194) . '?' . chr(176) . ')[[:space:]]+,S', |
|
| 1020 | + $texte, |
|
| 1021 | + $regs |
|
| 1022 | + ) |
|
| 1023 | + ) { |
|
| 1024 | + return strval($regs[1]); |
|
| 1025 | + } else { |
|
| 1026 | + return ''; |
|
| 1027 | + } |
|
| 1028 | 1028 | } |
| 1029 | 1029 | |
| 1030 | 1030 | /** |
@@ -1051,16 +1051,16 @@ discard block |
||
| 1051 | 1051 | * Texte converti |
| 1052 | 1052 | **/ |
| 1053 | 1053 | function supprimer_tags(?string $texte, $rempl = ''): string { |
| 1054 | - if ($texte === null || !strlen($texte)) { |
|
| 1055 | - return ''; |
|
| 1056 | - } |
|
| 1057 | - $texte = preg_replace(',<(!--|\w|/|!\[endif|!\[if)[^>]*>,US', $rempl, $texte); |
|
| 1058 | - // ne pas oublier un < final non ferme car coupe |
|
| 1059 | - $texte = preg_replace(',<(!--|\w|/).*$,US', $rempl, $texte); |
|
| 1060 | - // mais qui peut aussi etre un simple signe plus petit que |
|
| 1061 | - $texte = str_replace('<', '<', $texte); |
|
| 1054 | + if ($texte === null || !strlen($texte)) { |
|
| 1055 | + return ''; |
|
| 1056 | + } |
|
| 1057 | + $texte = preg_replace(',<(!--|\w|/|!\[endif|!\[if)[^>]*>,US', $rempl, $texte); |
|
| 1058 | + // ne pas oublier un < final non ferme car coupe |
|
| 1059 | + $texte = preg_replace(',<(!--|\w|/).*$,US', $rempl, $texte); |
|
| 1060 | + // mais qui peut aussi etre un simple signe plus petit que |
|
| 1061 | + $texte = str_replace('<', '<', $texte); |
|
| 1062 | 1062 | |
| 1063 | - return $texte; |
|
| 1063 | + return $texte; |
|
| 1064 | 1064 | } |
| 1065 | 1065 | |
| 1066 | 1066 | /** |
@@ -1083,9 +1083,9 @@ discard block |
||
| 1083 | 1083 | * Texte converti |
| 1084 | 1084 | **/ |
| 1085 | 1085 | function echapper_tags($texte, $rempl = '') { |
| 1086 | - $texte = preg_replace('/<([^>]*)>/', "<\\1>", $texte); |
|
| 1086 | + $texte = preg_replace('/<([^>]*)>/', "<\\1>", $texte); |
|
| 1087 | 1087 | |
| 1088 | - return $texte; |
|
| 1088 | + return $texte; |
|
| 1089 | 1089 | } |
| 1090 | 1090 | |
| 1091 | 1091 | /** |
@@ -1106,18 +1106,18 @@ discard block |
||
| 1106 | 1106 | * Texte converti |
| 1107 | 1107 | **/ |
| 1108 | 1108 | function textebrut($texte) { |
| 1109 | - $u = $GLOBALS['meta']['pcre_u']; |
|
| 1110 | - $texte = preg_replace('/\s+/S' . $u, ' ', $texte); |
|
| 1111 | - $texte = preg_replace('/<(p|br)( [^>]*)?' . '>/iS', "\n\n", $texte); |
|
| 1112 | - $texte = preg_replace("/^\n+/", '', $texte); |
|
| 1113 | - $texte = preg_replace("/\n+$/", '', $texte); |
|
| 1114 | - $texte = preg_replace("/\n +/", "\n", $texte); |
|
| 1115 | - $texte = supprimer_tags($texte); |
|
| 1116 | - $texte = preg_replace('/( | )+/S', ' ', $texte); |
|
| 1117 | - // nettoyer l'apostrophe curly qui pose probleme a certains rss-readers, lecteurs de mail... |
|
| 1118 | - $texte = str_replace('’', "'", $texte); |
|
| 1109 | + $u = $GLOBALS['meta']['pcre_u']; |
|
| 1110 | + $texte = preg_replace('/\s+/S' . $u, ' ', $texte); |
|
| 1111 | + $texte = preg_replace('/<(p|br)( [^>]*)?' . '>/iS', "\n\n", $texte); |
|
| 1112 | + $texte = preg_replace("/^\n+/", '', $texte); |
|
| 1113 | + $texte = preg_replace("/\n+$/", '', $texte); |
|
| 1114 | + $texte = preg_replace("/\n +/", "\n", $texte); |
|
| 1115 | + $texte = supprimer_tags($texte); |
|
| 1116 | + $texte = preg_replace('/( | )+/S', ' ', $texte); |
|
| 1117 | + // nettoyer l'apostrophe curly qui pose probleme a certains rss-readers, lecteurs de mail... |
|
| 1118 | + $texte = str_replace('’', "'", $texte); |
|
| 1119 | 1119 | |
| 1120 | - return $texte; |
|
| 1120 | + return $texte; |
|
| 1121 | 1121 | } |
| 1122 | 1122 | |
| 1123 | 1123 | |
@@ -1133,23 +1133,23 @@ discard block |
||
| 1133 | 1133 | * Texte avec liens ouvrants |
| 1134 | 1134 | **/ |
| 1135 | 1135 | function liens_ouvrants($texte) { |
| 1136 | - if ( |
|
| 1137 | - preg_match_all( |
|
| 1138 | - ",(<a\s+[^>]*https?://[^>]*class=[\"']spip_(out|url)\b[^>]+>),imsS", |
|
| 1139 | - $texte, |
|
| 1140 | - $liens, |
|
| 1141 | - PREG_PATTERN_ORDER |
|
| 1142 | - ) |
|
| 1143 | - ) { |
|
| 1144 | - foreach ($liens[0] as $a) { |
|
| 1145 | - $rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel'); |
|
| 1146 | - $ablank = inserer_attribut($a, 'rel', $rel); |
|
| 1147 | - $ablank = inserer_attribut($ablank, 'target', '_blank'); |
|
| 1148 | - $texte = str_replace($a, $ablank, $texte); |
|
| 1149 | - } |
|
| 1150 | - } |
|
| 1151 | - |
|
| 1152 | - return $texte; |
|
| 1136 | + if ( |
|
| 1137 | + preg_match_all( |
|
| 1138 | + ",(<a\s+[^>]*https?://[^>]*class=[\"']spip_(out|url)\b[^>]+>),imsS", |
|
| 1139 | + $texte, |
|
| 1140 | + $liens, |
|
| 1141 | + PREG_PATTERN_ORDER |
|
| 1142 | + ) |
|
| 1143 | + ) { |
|
| 1144 | + foreach ($liens[0] as $a) { |
|
| 1145 | + $rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel'); |
|
| 1146 | + $ablank = inserer_attribut($a, 'rel', $rel); |
|
| 1147 | + $ablank = inserer_attribut($ablank, 'target', '_blank'); |
|
| 1148 | + $texte = str_replace($a, $ablank, $texte); |
|
| 1149 | + } |
|
| 1150 | + } |
|
| 1151 | + |
|
| 1152 | + return $texte; |
|
| 1153 | 1153 | } |
| 1154 | 1154 | |
| 1155 | 1155 | /** |
@@ -1159,22 +1159,22 @@ discard block |
||
| 1159 | 1159 | * @return string |
| 1160 | 1160 | */ |
| 1161 | 1161 | function liens_nofollow($texte) { |
| 1162 | - if (stripos($texte, '<a') === false) { |
|
| 1163 | - return $texte; |
|
| 1164 | - } |
|
| 1162 | + if (stripos($texte, '<a') === false) { |
|
| 1163 | + return $texte; |
|
| 1164 | + } |
|
| 1165 | 1165 | |
| 1166 | - if (preg_match_all(",<a\b[^>]*>,UimsS", $texte, $regs, PREG_PATTERN_ORDER)) { |
|
| 1167 | - foreach ($regs[0] as $a) { |
|
| 1168 | - $rel = extraire_attribut($a, 'rel'); |
|
| 1169 | - if (strpos($rel, 'nofollow') === false) { |
|
| 1170 | - $rel = 'nofollow' . ($rel ? " $rel" : ''); |
|
| 1171 | - $anofollow = inserer_attribut($a, 'rel', $rel); |
|
| 1172 | - $texte = str_replace($a, $anofollow, $texte); |
|
| 1173 | - } |
|
| 1174 | - } |
|
| 1175 | - } |
|
| 1166 | + if (preg_match_all(",<a\b[^>]*>,UimsS", $texte, $regs, PREG_PATTERN_ORDER)) { |
|
| 1167 | + foreach ($regs[0] as $a) { |
|
| 1168 | + $rel = extraire_attribut($a, 'rel'); |
|
| 1169 | + if (strpos($rel, 'nofollow') === false) { |
|
| 1170 | + $rel = 'nofollow' . ($rel ? " $rel" : ''); |
|
| 1171 | + $anofollow = inserer_attribut($a, 'rel', $rel); |
|
| 1172 | + $texte = str_replace($a, $anofollow, $texte); |
|
| 1173 | + } |
|
| 1174 | + } |
|
| 1175 | + } |
|
| 1176 | 1176 | |
| 1177 | - return $texte; |
|
| 1177 | + return $texte; |
|
| 1178 | 1178 | } |
| 1179 | 1179 | |
| 1180 | 1180 | /** |
@@ -1193,12 +1193,12 @@ discard block |
||
| 1193 | 1193 | * Texte sans paraghaphes |
| 1194 | 1194 | **/ |
| 1195 | 1195 | function PtoBR($texte) { |
| 1196 | - $u = $GLOBALS['meta']['pcre_u']; |
|
| 1197 | - $texte = preg_replace('@</p>@iS', "\n", $texte); |
|
| 1198 | - $texte = preg_replace("@<p\b.*>@UiS", '<br />', $texte); |
|
| 1199 | - $texte = preg_replace('@^\s*<br />@S' . $u, '', $texte); |
|
| 1196 | + $u = $GLOBALS['meta']['pcre_u']; |
|
| 1197 | + $texte = preg_replace('@</p>@iS', "\n", $texte); |
|
| 1198 | + $texte = preg_replace("@<p\b.*>@UiS", '<br />', $texte); |
|
| 1199 | + $texte = preg_replace('@^\s*<br />@S' . $u, '', $texte); |
|
| 1200 | 1200 | |
| 1201 | - return $texte; |
|
| 1201 | + return $texte; |
|
| 1202 | 1202 | } |
| 1203 | 1203 | |
| 1204 | 1204 | |
@@ -1223,14 +1223,14 @@ discard block |
||
| 1223 | 1223 | * @return string Texte encadré du style CSS |
| 1224 | 1224 | */ |
| 1225 | 1225 | function lignes_longues($texte) { |
| 1226 | - if (!strlen(trim($texte))) { |
|
| 1227 | - return $texte; |
|
| 1228 | - } |
|
| 1229 | - include_spip('inc/texte'); |
|
| 1230 | - $tag = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $texte) ? |
|
| 1231 | - 'div' : 'span'; |
|
| 1226 | + if (!strlen(trim($texte))) { |
|
| 1227 | + return $texte; |
|
| 1228 | + } |
|
| 1229 | + include_spip('inc/texte'); |
|
| 1230 | + $tag = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $texte) ? |
|
| 1231 | + 'div' : 'span'; |
|
| 1232 | 1232 | |
| 1233 | - return "<$tag style='word-wrap:break-word;'>$texte</$tag>"; |
|
| 1233 | + return "<$tag style='word-wrap:break-word;'>$texte</$tag>"; |
|
| 1234 | 1234 | } |
| 1235 | 1235 | |
| 1236 | 1236 | /** |
@@ -1249,30 +1249,30 @@ discard block |
||
| 1249 | 1249 | * @return string Texte en majuscule |
| 1250 | 1250 | */ |
| 1251 | 1251 | function majuscules($texte) { |
| 1252 | - if (!strlen($texte)) { |
|
| 1253 | - return ''; |
|
| 1254 | - } |
|
| 1252 | + if (!strlen($texte)) { |
|
| 1253 | + return ''; |
|
| 1254 | + } |
|
| 1255 | 1255 | |
| 1256 | - // Cas du turc |
|
| 1257 | - if ($GLOBALS['spip_lang'] == 'tr') { |
|
| 1258 | - # remplacer hors des tags et des entites |
|
| 1259 | - if (preg_match_all(',<[^<>]+>|&[^;]+;,S', $texte, $regs, PREG_SET_ORDER)) { |
|
| 1260 | - foreach ($regs as $n => $match) { |
|
| 1261 | - $texte = str_replace($match[0], "@@SPIP_TURC$n@@", $texte); |
|
| 1262 | - } |
|
| 1263 | - } |
|
| 1256 | + // Cas du turc |
|
| 1257 | + if ($GLOBALS['spip_lang'] == 'tr') { |
|
| 1258 | + # remplacer hors des tags et des entites |
|
| 1259 | + if (preg_match_all(',<[^<>]+>|&[^;]+;,S', $texte, $regs, PREG_SET_ORDER)) { |
|
| 1260 | + foreach ($regs as $n => $match) { |
|
| 1261 | + $texte = str_replace($match[0], "@@SPIP_TURC$n@@", $texte); |
|
| 1262 | + } |
|
| 1263 | + } |
|
| 1264 | 1264 | |
| 1265 | - $texte = str_replace('i', 'İ', $texte); |
|
| 1265 | + $texte = str_replace('i', 'İ', $texte); |
|
| 1266 | 1266 | |
| 1267 | - if ($regs) { |
|
| 1268 | - foreach ($regs as $n => $match) { |
|
| 1269 | - $texte = str_replace("@@SPIP_TURC$n@@", $match[0], $texte); |
|
| 1270 | - } |
|
| 1271 | - } |
|
| 1272 | - } |
|
| 1267 | + if ($regs) { |
|
| 1268 | + foreach ($regs as $n => $match) { |
|
| 1269 | + $texte = str_replace("@@SPIP_TURC$n@@", $match[0], $texte); |
|
| 1270 | + } |
|
| 1271 | + } |
|
| 1272 | + } |
|
| 1273 | 1273 | |
| 1274 | - // Cas general |
|
| 1275 | - return "<span style='text-transform: uppercase;'>$texte</span>"; |
|
| 1274 | + // Cas general |
|
| 1275 | + return "<span style='text-transform: uppercase;'>$texte</span>"; |
|
| 1276 | 1276 | } |
| 1277 | 1277 | |
| 1278 | 1278 | /** |
@@ -1290,29 +1290,29 @@ discard block |
||
| 1290 | 1290 | * @return string |
| 1291 | 1291 | **/ |
| 1292 | 1292 | function taille_en_octets($taille) { |
| 1293 | - if (!defined('_KILOBYTE')) { |
|
| 1294 | - /** |
|
| 1295 | - * Définit le nombre d'octets dans un Kilobyte |
|
| 1296 | - * |
|
| 1297 | - * @var int |
|
| 1298 | - **/ |
|
| 1299 | - define('_KILOBYTE', 1024); |
|
| 1300 | - } |
|
| 1293 | + if (!defined('_KILOBYTE')) { |
|
| 1294 | + /** |
|
| 1295 | + * Définit le nombre d'octets dans un Kilobyte |
|
| 1296 | + * |
|
| 1297 | + * @var int |
|
| 1298 | + **/ |
|
| 1299 | + define('_KILOBYTE', 1024); |
|
| 1300 | + } |
|
| 1301 | 1301 | |
| 1302 | - if ($taille < 1) { |
|
| 1303 | - return ''; |
|
| 1304 | - } |
|
| 1305 | - if ($taille < _KILOBYTE) { |
|
| 1306 | - $taille = _T('taille_octets', ['taille' => $taille]); |
|
| 1307 | - } elseif ($taille < _KILOBYTE * _KILOBYTE) { |
|
| 1308 | - $taille = _T('taille_ko', ['taille' => round($taille / _KILOBYTE, 1)]); |
|
| 1309 | - } elseif ($taille < _KILOBYTE * _KILOBYTE * _KILOBYTE) { |
|
| 1310 | - $taille = _T('taille_mo', ['taille' => round($taille / _KILOBYTE / _KILOBYTE, 1)]); |
|
| 1311 | - } else { |
|
| 1312 | - $taille = _T('taille_go', ['taille' => round($taille / _KILOBYTE / _KILOBYTE / _KILOBYTE, 2)]); |
|
| 1313 | - } |
|
| 1302 | + if ($taille < 1) { |
|
| 1303 | + return ''; |
|
| 1304 | + } |
|
| 1305 | + if ($taille < _KILOBYTE) { |
|
| 1306 | + $taille = _T('taille_octets', ['taille' => $taille]); |
|
| 1307 | + } elseif ($taille < _KILOBYTE * _KILOBYTE) { |
|
| 1308 | + $taille = _T('taille_ko', ['taille' => round($taille / _KILOBYTE, 1)]); |
|
| 1309 | + } elseif ($taille < _KILOBYTE * _KILOBYTE * _KILOBYTE) { |
|
| 1310 | + $taille = _T('taille_mo', ['taille' => round($taille / _KILOBYTE / _KILOBYTE, 1)]); |
|
| 1311 | + } else { |
|
| 1312 | + $taille = _T('taille_go', ['taille' => round($taille / _KILOBYTE / _KILOBYTE / _KILOBYTE, 2)]); |
|
| 1313 | + } |
|
| 1314 | 1314 | |
| 1315 | - return $taille; |
|
| 1315 | + return $taille; |
|
| 1316 | 1316 | } |
| 1317 | 1317 | |
| 1318 | 1318 | |
@@ -1334,21 +1334,21 @@ discard block |
||
| 1334 | 1334 | * Texte prêt pour être utilisé en attribut HTML |
| 1335 | 1335 | **/ |
| 1336 | 1336 | function attribut_html(?string $texte, $textebrut = true): string { |
| 1337 | - if ($texte === null) { |
|
| 1338 | - return ''; |
|
| 1339 | - } |
|
| 1340 | - $u = $GLOBALS['meta']['pcre_u']; |
|
| 1341 | - if ($textebrut) { |
|
| 1342 | - $texte = preg_replace([",\n,", ',\s(?=\s),msS' . $u], [' ', ''], textebrut($texte)); |
|
| 1343 | - } |
|
| 1344 | - $texte = texte_backend($texte); |
|
| 1345 | - $texte = str_replace(["'", '"'], [''', '"'], $texte); |
|
| 1337 | + if ($texte === null) { |
|
| 1338 | + return ''; |
|
| 1339 | + } |
|
| 1340 | + $u = $GLOBALS['meta']['pcre_u']; |
|
| 1341 | + if ($textebrut) { |
|
| 1342 | + $texte = preg_replace([",\n,", ',\s(?=\s),msS' . $u], [' ', ''], textebrut($texte)); |
|
| 1343 | + } |
|
| 1344 | + $texte = texte_backend($texte); |
|
| 1345 | + $texte = str_replace(["'", '"'], [''', '"'], $texte); |
|
| 1346 | 1346 | |
| 1347 | - return preg_replace( |
|
| 1348 | - ['/&(amp;|#38;)/', '/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,5};)/'], |
|
| 1349 | - ['&', '&'], |
|
| 1350 | - $texte |
|
| 1351 | - ); |
|
| 1347 | + return preg_replace( |
|
| 1348 | + ['/&(amp;|#38;)/', '/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,5};)/'], |
|
| 1349 | + ['&', '&'], |
|
| 1350 | + $texte |
|
| 1351 | + ); |
|
| 1352 | 1352 | } |
| 1353 | 1353 | |
| 1354 | 1354 | |
@@ -1368,15 +1368,15 @@ discard block |
||
| 1368 | 1368 | * URL ou chaîne vide |
| 1369 | 1369 | **/ |
| 1370 | 1370 | function vider_url(?string $url, $entites = true): string { |
| 1371 | - if ($url === null) { |
|
| 1372 | - return ''; |
|
| 1373 | - } |
|
| 1374 | - # un message pour abs_url |
|
| 1375 | - $GLOBALS['mode_abs_url'] = 'url'; |
|
| 1376 | - $url = trim($url); |
|
| 1377 | - $r = ',^(?:' . _PROTOCOLES_STD . '):?/?/?$,iS'; |
|
| 1371 | + if ($url === null) { |
|
| 1372 | + return ''; |
|
| 1373 | + } |
|
| 1374 | + # un message pour abs_url |
|
| 1375 | + $GLOBALS['mode_abs_url'] = 'url'; |
|
| 1376 | + $url = trim($url); |
|
| 1377 | + $r = ',^(?:' . _PROTOCOLES_STD . '):?/?/?$,iS'; |
|
| 1378 | 1378 | |
| 1379 | - return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url); |
|
| 1379 | + return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url); |
|
| 1380 | 1380 | } |
| 1381 | 1381 | |
| 1382 | 1382 | |
@@ -1391,10 +1391,10 @@ discard block |
||
| 1391 | 1391 | * @return string Adresse email maquillée |
| 1392 | 1392 | **/ |
| 1393 | 1393 | function antispam($texte) { |
| 1394 | - include_spip('inc/acces'); |
|
| 1395 | - $masque = creer_pass_aleatoire(3); |
|
| 1394 | + include_spip('inc/acces'); |
|
| 1395 | + $masque = creer_pass_aleatoire(3); |
|
| 1396 | 1396 | |
| 1397 | - return preg_replace('/@/', " $masque ", $texte); |
|
| 1397 | + return preg_replace('/@/', " $masque ", $texte); |
|
| 1398 | 1398 | } |
| 1399 | 1399 | |
| 1400 | 1400 | /** |
@@ -1426,12 +1426,12 @@ discard block |
||
| 1426 | 1426 | * True si on a le droit d'accès, false sinon. |
| 1427 | 1427 | **/ |
| 1428 | 1428 | function securiser_acces($id_auteur, $cle, $dir, $op = '', $args = '') { |
| 1429 | - include_spip('inc/acces'); |
|
| 1430 | - if ($op) { |
|
| 1431 | - $dir .= " $op $args"; |
|
| 1432 | - } |
|
| 1429 | + include_spip('inc/acces'); |
|
| 1430 | + if ($op) { |
|
| 1431 | + $dir .= " $op $args"; |
|
| 1432 | + } |
|
| 1433 | 1433 | |
| 1434 | - return verifier_low_sec($id_auteur, $cle, $dir); |
|
| 1434 | + return verifier_low_sec($id_auteur, $cle, $dir); |
|
| 1435 | 1435 | } |
| 1436 | 1436 | |
| 1437 | 1437 | /** |
@@ -1456,13 +1456,13 @@ discard block |
||
| 1456 | 1456 | * Retourne $texte, sinon $sinon. |
| 1457 | 1457 | **/ |
| 1458 | 1458 | function sinon($texte, $sinon = '') { |
| 1459 | - if ($texte) { |
|
| 1460 | - return $texte; |
|
| 1461 | - } elseif (is_scalar($texte) and strlen($texte)) { |
|
| 1462 | - return $texte; |
|
| 1463 | - } else { |
|
| 1464 | - return $sinon; |
|
| 1465 | - } |
|
| 1459 | + if ($texte) { |
|
| 1460 | + return $texte; |
|
| 1461 | + } elseif (is_scalar($texte) and strlen($texte)) { |
|
| 1462 | + return $texte; |
|
| 1463 | + } else { |
|
| 1464 | + return $sinon; |
|
| 1465 | + } |
|
| 1466 | 1466 | } |
| 1467 | 1467 | |
| 1468 | 1468 | /** |
@@ -1486,7 +1486,7 @@ discard block |
||
| 1486 | 1486 | * @return mixed |
| 1487 | 1487 | **/ |
| 1488 | 1488 | function choixsivide($a, $vide, $pasvide) { |
| 1489 | - return $a ? $pasvide : $vide; |
|
| 1489 | + return $a ? $pasvide : $vide; |
|
| 1490 | 1490 | } |
| 1491 | 1491 | |
| 1492 | 1492 | /** |
@@ -1510,7 +1510,7 @@ discard block |
||
| 1510 | 1510 | * @return mixed |
| 1511 | 1511 | **/ |
| 1512 | 1512 | function choixsiegal($a1, $a2, $v, $f) { |
| 1513 | - return ($a1 == $a2) ? $v : $f; |
|
| 1513 | + return ($a1 == $a2) ? $v : $f; |
|
| 1514 | 1514 | } |
| 1515 | 1515 | |
| 1516 | 1516 | // |
@@ -1529,13 +1529,13 @@ discard block |
||
| 1529 | 1529 | * @return string |
| 1530 | 1530 | **/ |
| 1531 | 1531 | function filtrer_ical($texte) { |
| 1532 | - #include_spip('inc/charsets'); |
|
| 1533 | - $texte = html2unicode($texte); |
|
| 1534 | - $texte = unicode2charset(charset2unicode($texte, $GLOBALS['meta']['charset']), 'utf-8'); |
|
| 1535 | - $texte = preg_replace("/\n/", ' ', $texte); |
|
| 1536 | - $texte = preg_replace('/,/', '\,', $texte); |
|
| 1532 | + #include_spip('inc/charsets'); |
|
| 1533 | + $texte = html2unicode($texte); |
|
| 1534 | + $texte = unicode2charset(charset2unicode($texte, $GLOBALS['meta']['charset']), 'utf-8'); |
|
| 1535 | + $texte = preg_replace("/\n/", ' ', $texte); |
|
| 1536 | + $texte = preg_replace('/,/', '\,', $texte); |
|
| 1537 | 1537 | |
| 1538 | - return $texte; |
|
| 1538 | + return $texte; |
|
| 1539 | 1539 | } |
| 1540 | 1540 | |
| 1541 | 1541 | |
@@ -1560,54 +1560,54 @@ discard block |
||
| 1560 | 1560 | * @return string |
| 1561 | 1561 | **/ |
| 1562 | 1562 | function post_autobr($texte, $delim = "\n_ ") { |
| 1563 | - if (!function_exists('echappe_html')) { |
|
| 1564 | - include_spip('inc/texte_mini'); |
|
| 1565 | - } |
|
| 1566 | - $texte = str_replace("\r\n", "\r", $texte); |
|
| 1567 | - $texte = str_replace("\r", "\n", $texte); |
|
| 1568 | - |
|
| 1569 | - if (preg_match(",\n+$,", $texte, $fin)) { |
|
| 1570 | - $texte = substr($texte, 0, -strlen($fin = $fin[0])); |
|
| 1571 | - } else { |
|
| 1572 | - $fin = ''; |
|
| 1573 | - } |
|
| 1574 | - |
|
| 1575 | - $texte = echappe_html($texte, '', true); |
|
| 1576 | - |
|
| 1577 | - // echapper les modeles |
|
| 1578 | - if (strpos($texte, '<') !== false) { |
|
| 1579 | - include_spip('inc/lien'); |
|
| 1580 | - if (defined('_PREG_MODELE')) { |
|
| 1581 | - $preg_modeles = '@' . _PREG_MODELE . '@imsS'; |
|
| 1582 | - $texte = echappe_html($texte, '', true, $preg_modeles); |
|
| 1583 | - } |
|
| 1584 | - } |
|
| 1585 | - |
|
| 1586 | - $debut = ''; |
|
| 1587 | - $suite = $texte; |
|
| 1588 | - while ($t = strpos('-' . $suite, "\n", 1)) { |
|
| 1589 | - $debut .= substr($suite, 0, $t - 1); |
|
| 1590 | - $suite = substr($suite, $t); |
|
| 1591 | - $car = substr($suite, 0, 1); |
|
| 1592 | - if ( |
|
| 1593 | - ($car <> '-') and ($car <> '_') and ($car <> "\n") and ($car <> '|') and ($car <> '}') |
|
| 1594 | - and !preg_match(',^\s*(\n|</?(quote|div|dl|dt|dd)|$),S', ($suite)) |
|
| 1595 | - and !preg_match(',</?(quote|div|dl|dt|dd)> *$,iS', $debut) |
|
| 1596 | - ) { |
|
| 1597 | - $debut .= $delim; |
|
| 1598 | - } else { |
|
| 1599 | - $debut .= "\n"; |
|
| 1600 | - } |
|
| 1601 | - if (preg_match(",^\n+,", $suite, $regs)) { |
|
| 1602 | - $debut .= $regs[0]; |
|
| 1603 | - $suite = substr($suite, strlen($regs[0])); |
|
| 1604 | - } |
|
| 1605 | - } |
|
| 1606 | - $texte = $debut . $suite; |
|
| 1607 | - |
|
| 1608 | - $texte = echappe_retour($texte); |
|
| 1609 | - |
|
| 1610 | - return $texte . $fin; |
|
| 1563 | + if (!function_exists('echappe_html')) { |
|
| 1564 | + include_spip('inc/texte_mini'); |
|
| 1565 | + } |
|
| 1566 | + $texte = str_replace("\r\n", "\r", $texte); |
|
| 1567 | + $texte = str_replace("\r", "\n", $texte); |
|
| 1568 | + |
|
| 1569 | + if (preg_match(",\n+$,", $texte, $fin)) { |
|
| 1570 | + $texte = substr($texte, 0, -strlen($fin = $fin[0])); |
|
| 1571 | + } else { |
|
| 1572 | + $fin = ''; |
|
| 1573 | + } |
|
| 1574 | + |
|
| 1575 | + $texte = echappe_html($texte, '', true); |
|
| 1576 | + |
|
| 1577 | + // echapper les modeles |
|
| 1578 | + if (strpos($texte, '<') !== false) { |
|
| 1579 | + include_spip('inc/lien'); |
|
| 1580 | + if (defined('_PREG_MODELE')) { |
|
| 1581 | + $preg_modeles = '@' . _PREG_MODELE . '@imsS'; |
|
| 1582 | + $texte = echappe_html($texte, '', true, $preg_modeles); |
|
| 1583 | + } |
|
| 1584 | + } |
|
| 1585 | + |
|
| 1586 | + $debut = ''; |
|
| 1587 | + $suite = $texte; |
|
| 1588 | + while ($t = strpos('-' . $suite, "\n", 1)) { |
|
| 1589 | + $debut .= substr($suite, 0, $t - 1); |
|
| 1590 | + $suite = substr($suite, $t); |
|
| 1591 | + $car = substr($suite, 0, 1); |
|
| 1592 | + if ( |
|
| 1593 | + ($car <> '-') and ($car <> '_') and ($car <> "\n") and ($car <> '|') and ($car <> '}') |
|
| 1594 | + and !preg_match(',^\s*(\n|</?(quote|div|dl|dt|dd)|$),S', ($suite)) |
|
| 1595 | + and !preg_match(',</?(quote|div|dl|dt|dd)> *$,iS', $debut) |
|
| 1596 | + ) { |
|
| 1597 | + $debut .= $delim; |
|
| 1598 | + } else { |
|
| 1599 | + $debut .= "\n"; |
|
| 1600 | + } |
|
| 1601 | + if (preg_match(",^\n+,", $suite, $regs)) { |
|
| 1602 | + $debut .= $regs[0]; |
|
| 1603 | + $suite = substr($suite, strlen($regs[0])); |
|
| 1604 | + } |
|
| 1605 | + } |
|
| 1606 | + $texte = $debut . $suite; |
|
| 1607 | + |
|
| 1608 | + $texte = echappe_retour($texte); |
|
| 1609 | + |
|
| 1610 | + return $texte . $fin; |
|
| 1611 | 1611 | } |
| 1612 | 1612 | |
| 1613 | 1613 | |
@@ -1648,47 +1648,47 @@ discard block |
||
| 1648 | 1648 | * @return string |
| 1649 | 1649 | **/ |
| 1650 | 1650 | function extraire_idiome($letexte, $lang = null, $options = []) { |
| 1651 | - static $traduire = false; |
|
| 1652 | - if ( |
|
| 1653 | - $letexte |
|
| 1654 | - and preg_match_all(_EXTRAIRE_IDIOME, $letexte, $regs, PREG_SET_ORDER) |
|
| 1655 | - ) { |
|
| 1656 | - if (!$traduire) { |
|
| 1657 | - $traduire = charger_fonction('traduire', 'inc'); |
|
| 1658 | - include_spip('inc/lang'); |
|
| 1659 | - } |
|
| 1660 | - if (!$lang) { |
|
| 1661 | - $lang = $GLOBALS['spip_lang']; |
|
| 1662 | - } |
|
| 1663 | - // Compatibilité avec le prototype de fonction précédente qui utilisait un boolean |
|
| 1664 | - if (is_bool($options)) { |
|
| 1665 | - $options = ['echappe_span' => $options]; |
|
| 1666 | - } |
|
| 1667 | - if (!isset($options['echappe_span'])) { |
|
| 1668 | - $options = array_merge($options, ['echappe_span' => false]); |
|
| 1669 | - } |
|
| 1670 | - |
|
| 1671 | - foreach ($regs as $reg) { |
|
| 1672 | - $cle = ($reg[1] ? $reg[1] . ':' : '') . $reg[2]; |
|
| 1673 | - $desc = $traduire($cle, $lang, true); |
|
| 1674 | - $l = $desc->langue; |
|
| 1675 | - // si pas de traduction, on laissera l'écriture de l'idiome entier dans le texte. |
|
| 1676 | - if (strlen($desc->texte)) { |
|
| 1677 | - $trad = code_echappement($desc->texte, 'idiome', false); |
|
| 1678 | - if ($l !== $lang) { |
|
| 1679 | - $trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l)); |
|
| 1680 | - } |
|
| 1681 | - if (lang_dir($l) !== lang_dir($lang)) { |
|
| 1682 | - $trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l))); |
|
| 1683 | - } |
|
| 1684 | - if (!$options['echappe_span']) { |
|
| 1685 | - $trad = echappe_retour($trad, 'idiome'); |
|
| 1686 | - } |
|
| 1687 | - $letexte = str_replace($reg[0], $trad, $letexte); |
|
| 1688 | - } |
|
| 1689 | - } |
|
| 1690 | - } |
|
| 1691 | - return $letexte; |
|
| 1651 | + static $traduire = false; |
|
| 1652 | + if ( |
|
| 1653 | + $letexte |
|
| 1654 | + and preg_match_all(_EXTRAIRE_IDIOME, $letexte, $regs, PREG_SET_ORDER) |
|
| 1655 | + ) { |
|
| 1656 | + if (!$traduire) { |
|
| 1657 | + $traduire = charger_fonction('traduire', 'inc'); |
|
| 1658 | + include_spip('inc/lang'); |
|
| 1659 | + } |
|
| 1660 | + if (!$lang) { |
|
| 1661 | + $lang = $GLOBALS['spip_lang']; |
|
| 1662 | + } |
|
| 1663 | + // Compatibilité avec le prototype de fonction précédente qui utilisait un boolean |
|
| 1664 | + if (is_bool($options)) { |
|
| 1665 | + $options = ['echappe_span' => $options]; |
|
| 1666 | + } |
|
| 1667 | + if (!isset($options['echappe_span'])) { |
|
| 1668 | + $options = array_merge($options, ['echappe_span' => false]); |
|
| 1669 | + } |
|
| 1670 | + |
|
| 1671 | + foreach ($regs as $reg) { |
|
| 1672 | + $cle = ($reg[1] ? $reg[1] . ':' : '') . $reg[2]; |
|
| 1673 | + $desc = $traduire($cle, $lang, true); |
|
| 1674 | + $l = $desc->langue; |
|
| 1675 | + // si pas de traduction, on laissera l'écriture de l'idiome entier dans le texte. |
|
| 1676 | + if (strlen($desc->texte)) { |
|
| 1677 | + $trad = code_echappement($desc->texte, 'idiome', false); |
|
| 1678 | + if ($l !== $lang) { |
|
| 1679 | + $trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l)); |
|
| 1680 | + } |
|
| 1681 | + if (lang_dir($l) !== lang_dir($lang)) { |
|
| 1682 | + $trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l))); |
|
| 1683 | + } |
|
| 1684 | + if (!$options['echappe_span']) { |
|
| 1685 | + $trad = echappe_retour($trad, 'idiome'); |
|
| 1686 | + } |
|
| 1687 | + $letexte = str_replace($reg[0], $trad, $letexte); |
|
| 1688 | + } |
|
| 1689 | + } |
|
| 1690 | + } |
|
| 1691 | + return $letexte; |
|
| 1692 | 1692 | } |
| 1693 | 1693 | |
| 1694 | 1694 | /** |
@@ -1740,68 +1740,68 @@ discard block |
||
| 1740 | 1740 | **/ |
| 1741 | 1741 | function extraire_multi($letexte, $lang = null, $options = []) { |
| 1742 | 1742 | |
| 1743 | - if ( |
|
| 1744 | - $letexte |
|
| 1745 | - and preg_match_all(_EXTRAIRE_MULTI, $letexte, $regs, PREG_SET_ORDER) |
|
| 1746 | - ) { |
|
| 1747 | - if (!$lang) { |
|
| 1748 | - $lang = $GLOBALS['spip_lang']; |
|
| 1749 | - } |
|
| 1750 | - |
|
| 1751 | - // Compatibilité avec le prototype de fonction précédente qui utilisait un boolean |
|
| 1752 | - if (is_bool($options)) { |
|
| 1753 | - $options = ['echappe_span' => $options, 'lang_defaut' => _LANGUE_PAR_DEFAUT]; |
|
| 1754 | - } |
|
| 1755 | - if (!isset($options['echappe_span'])) { |
|
| 1756 | - $options = array_merge($options, ['echappe_span' => false]); |
|
| 1757 | - } |
|
| 1758 | - if (!isset($options['lang_defaut'])) { |
|
| 1759 | - $options = array_merge($options, ['lang_defaut' => _LANGUE_PAR_DEFAUT]); |
|
| 1760 | - } |
|
| 1761 | - |
|
| 1762 | - include_spip('inc/lang'); |
|
| 1763 | - foreach ($regs as $reg) { |
|
| 1764 | - // chercher la version de la langue courante |
|
| 1765 | - $trads = extraire_trads($reg[1]); |
|
| 1766 | - if ($l = approcher_langue($trads, $lang)) { |
|
| 1767 | - $trad = $trads[$l]; |
|
| 1768 | - } else { |
|
| 1769 | - if ($options['lang_defaut'] == 'aucune') { |
|
| 1770 | - $trad = ''; |
|
| 1771 | - } else { |
|
| 1772 | - // langue absente, prendre le fr ou une langue précisée (meme comportement que inc/traduire.php) |
|
| 1773 | - // ou la premiere dispo |
|
| 1774 | - // mais typographier le texte selon les regles de celle-ci |
|
| 1775 | - // Attention aux blocs multi sur plusieurs lignes |
|
| 1776 | - if (!$l = approcher_langue($trads, $options['lang_defaut'])) { |
|
| 1777 | - $l = key($trads); |
|
| 1778 | - } |
|
| 1779 | - $trad = $trads[$l]; |
|
| 1780 | - $typographie = charger_fonction(lang_typo($l), 'typographie'); |
|
| 1781 | - $trad = $typographie($trad); |
|
| 1782 | - // Tester si on echappe en span ou en div |
|
| 1783 | - // il ne faut pas echapper en div si propre produit un seul paragraphe |
|
| 1784 | - include_spip('inc/texte'); |
|
| 1785 | - $trad_propre = preg_replace(',(^<p[^>]*>|</p>$),Uims', '', propre($trad)); |
|
| 1786 | - $mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $trad_propre) ? 'div' : 'span'; |
|
| 1787 | - if ($mode === 'div') { |
|
| 1788 | - $trad = rtrim($trad) . "\n\n"; |
|
| 1789 | - } |
|
| 1790 | - $trad = code_echappement($trad, 'multi', false, $mode); |
|
| 1791 | - $trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l)); |
|
| 1792 | - if (lang_dir($l) !== lang_dir($lang)) { |
|
| 1793 | - $trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l))); |
|
| 1794 | - } |
|
| 1795 | - if (!$options['echappe_span']) { |
|
| 1796 | - $trad = echappe_retour($trad, 'multi'); |
|
| 1797 | - } |
|
| 1798 | - } |
|
| 1799 | - } |
|
| 1800 | - $letexte = str_replace($reg[0], $trad, $letexte); |
|
| 1801 | - } |
|
| 1802 | - } |
|
| 1803 | - |
|
| 1804 | - return $letexte; |
|
| 1743 | + if ( |
|
| 1744 | + $letexte |
|
| 1745 | + and preg_match_all(_EXTRAIRE_MULTI, $letexte, $regs, PREG_SET_ORDER) |
|
| 1746 | + ) { |
|
| 1747 | + if (!$lang) { |
|
| 1748 | + $lang = $GLOBALS['spip_lang']; |
|
| 1749 | + } |
|
| 1750 | + |
|
| 1751 | + // Compatibilité avec le prototype de fonction précédente qui utilisait un boolean |
|
| 1752 | + if (is_bool($options)) { |
|
| 1753 | + $options = ['echappe_span' => $options, 'lang_defaut' => _LANGUE_PAR_DEFAUT]; |
|
| 1754 | + } |
|
| 1755 | + if (!isset($options['echappe_span'])) { |
|
| 1756 | + $options = array_merge($options, ['echappe_span' => false]); |
|
| 1757 | + } |
|
| 1758 | + if (!isset($options['lang_defaut'])) { |
|
| 1759 | + $options = array_merge($options, ['lang_defaut' => _LANGUE_PAR_DEFAUT]); |
|
| 1760 | + } |
|
| 1761 | + |
|
| 1762 | + include_spip('inc/lang'); |
|
| 1763 | + foreach ($regs as $reg) { |
|
| 1764 | + // chercher la version de la langue courante |
|
| 1765 | + $trads = extraire_trads($reg[1]); |
|
| 1766 | + if ($l = approcher_langue($trads, $lang)) { |
|
| 1767 | + $trad = $trads[$l]; |
|
| 1768 | + } else { |
|
| 1769 | + if ($options['lang_defaut'] == 'aucune') { |
|
| 1770 | + $trad = ''; |
|
| 1771 | + } else { |
|
| 1772 | + // langue absente, prendre le fr ou une langue précisée (meme comportement que inc/traduire.php) |
|
| 1773 | + // ou la premiere dispo |
|
| 1774 | + // mais typographier le texte selon les regles de celle-ci |
|
| 1775 | + // Attention aux blocs multi sur plusieurs lignes |
|
| 1776 | + if (!$l = approcher_langue($trads, $options['lang_defaut'])) { |
|
| 1777 | + $l = key($trads); |
|
| 1778 | + } |
|
| 1779 | + $trad = $trads[$l]; |
|
| 1780 | + $typographie = charger_fonction(lang_typo($l), 'typographie'); |
|
| 1781 | + $trad = $typographie($trad); |
|
| 1782 | + // Tester si on echappe en span ou en div |
|
| 1783 | + // il ne faut pas echapper en div si propre produit un seul paragraphe |
|
| 1784 | + include_spip('inc/texte'); |
|
| 1785 | + $trad_propre = preg_replace(',(^<p[^>]*>|</p>$),Uims', '', propre($trad)); |
|
| 1786 | + $mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $trad_propre) ? 'div' : 'span'; |
|
| 1787 | + if ($mode === 'div') { |
|
| 1788 | + $trad = rtrim($trad) . "\n\n"; |
|
| 1789 | + } |
|
| 1790 | + $trad = code_echappement($trad, 'multi', false, $mode); |
|
| 1791 | + $trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l)); |
|
| 1792 | + if (lang_dir($l) !== lang_dir($lang)) { |
|
| 1793 | + $trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l))); |
|
| 1794 | + } |
|
| 1795 | + if (!$options['echappe_span']) { |
|
| 1796 | + $trad = echappe_retour($trad, 'multi'); |
|
| 1797 | + } |
|
| 1798 | + } |
|
| 1799 | + } |
|
| 1800 | + $letexte = str_replace($reg[0], $trad, $letexte); |
|
| 1801 | + } |
|
| 1802 | + } |
|
| 1803 | + |
|
| 1804 | + return $letexte; |
|
| 1805 | 1805 | } |
| 1806 | 1806 | |
| 1807 | 1807 | /** |
@@ -1817,21 +1817,21 @@ discard block |
||
| 1817 | 1817 | * Peut retourner un code de langue vide, lorsqu'un texte par défaut est indiqué. |
| 1818 | 1818 | **/ |
| 1819 | 1819 | function extraire_trads($bloc) { |
| 1820 | - $trads = []; |
|
| 1821 | - $lang = ''; |
|
| 1820 | + $trads = []; |
|
| 1821 | + $lang = ''; |
|
| 1822 | 1822 | // ce reg fait planter l'analyse multi s'il y a de l'{italique} dans le champ |
| 1823 | 1823 | // while (preg_match("/^(.*?)[{\[]([a-z_]+)[}\]]/siS", $bloc, $regs)) { |
| 1824 | - while (preg_match('/^(.*?)[\[]([a-z_]+)[\]]/siS', $bloc, $regs)) { |
|
| 1825 | - $texte = trim($regs[1]); |
|
| 1826 | - if ($texte or $lang) { |
|
| 1827 | - $trads[$lang] = $texte; |
|
| 1828 | - } |
|
| 1829 | - $bloc = substr($bloc, strlen($regs[0])); |
|
| 1830 | - $lang = $regs[2]; |
|
| 1831 | - } |
|
| 1832 | - $trads[$lang] = $bloc; |
|
| 1824 | + while (preg_match('/^(.*?)[\[]([a-z_]+)[\]]/siS', $bloc, $regs)) { |
|
| 1825 | + $texte = trim($regs[1]); |
|
| 1826 | + if ($texte or $lang) { |
|
| 1827 | + $trads[$lang] = $texte; |
|
| 1828 | + } |
|
| 1829 | + $bloc = substr($bloc, strlen($regs[0])); |
|
| 1830 | + $lang = $regs[2]; |
|
| 1831 | + } |
|
| 1832 | + $trads[$lang] = $bloc; |
|
| 1833 | 1833 | |
| 1834 | - return $trads; |
|
| 1834 | + return $trads; |
|
| 1835 | 1835 | } |
| 1836 | 1836 | |
| 1837 | 1837 | |
@@ -1842,7 +1842,7 @@ discard block |
||
| 1842 | 1842 | * @return string L'initiale en majuscule |
| 1843 | 1843 | */ |
| 1844 | 1844 | function filtre_initiale($nom) { |
| 1845 | - return spip_substr(trim(strtoupper(extraire_multi($nom))), 0, 1); |
|
| 1845 | + return spip_substr(trim(strtoupper(extraire_multi($nom))), 0, 1); |
|
| 1846 | 1846 | } |
| 1847 | 1847 | |
| 1848 | 1848 | |
@@ -1887,33 +1887,33 @@ discard block |
||
| 1887 | 1887 | * - null (interne) : si on empile |
| 1888 | 1888 | **/ |
| 1889 | 1889 | function unique($donnee, $famille = '', $cpt = false) { |
| 1890 | - static $mem = []; |
|
| 1891 | - // permettre de vider la pile et de la restaurer |
|
| 1892 | - // pour le calcul de introduction... |
|
| 1893 | - if ($famille == '_spip_raz_') { |
|
| 1894 | - $tmp = $mem; |
|
| 1895 | - $mem = []; |
|
| 1896 | - |
|
| 1897 | - return $tmp; |
|
| 1898 | - } elseif ($famille == '_spip_set_') { |
|
| 1899 | - $mem = $donnee; |
|
| 1900 | - |
|
| 1901 | - return; |
|
| 1902 | - } |
|
| 1903 | - // eviter une notice |
|
| 1904 | - if (!isset($mem[$famille])) { |
|
| 1905 | - $mem[$famille] = []; |
|
| 1906 | - } |
|
| 1907 | - if ($cpt) { |
|
| 1908 | - return is_countable($mem[$famille]) ? count($mem[$famille]) : 0; |
|
| 1909 | - } |
|
| 1910 | - // eviter une notice |
|
| 1911 | - if (!isset($mem[$famille][$donnee])) { |
|
| 1912 | - $mem[$famille][$donnee] = 0; |
|
| 1913 | - } |
|
| 1914 | - if (!($mem[$famille][$donnee]++)) { |
|
| 1915 | - return $donnee; |
|
| 1916 | - } |
|
| 1890 | + static $mem = []; |
|
| 1891 | + // permettre de vider la pile et de la restaurer |
|
| 1892 | + // pour le calcul de introduction... |
|
| 1893 | + if ($famille == '_spip_raz_') { |
|
| 1894 | + $tmp = $mem; |
|
| 1895 | + $mem = []; |
|
| 1896 | + |
|
| 1897 | + return $tmp; |
|
| 1898 | + } elseif ($famille == '_spip_set_') { |
|
| 1899 | + $mem = $donnee; |
|
| 1900 | + |
|
| 1901 | + return; |
|
| 1902 | + } |
|
| 1903 | + // eviter une notice |
|
| 1904 | + if (!isset($mem[$famille])) { |
|
| 1905 | + $mem[$famille] = []; |
|
| 1906 | + } |
|
| 1907 | + if ($cpt) { |
|
| 1908 | + return is_countable($mem[$famille]) ? count($mem[$famille]) : 0; |
|
| 1909 | + } |
|
| 1910 | + // eviter une notice |
|
| 1911 | + if (!isset($mem[$famille][$donnee])) { |
|
| 1912 | + $mem[$famille][$donnee] = 0; |
|
| 1913 | + } |
|
| 1914 | + if (!($mem[$famille][$donnee]++)) { |
|
| 1915 | + return $donnee; |
|
| 1916 | + } |
|
| 1917 | 1917 | } |
| 1918 | 1918 | |
| 1919 | 1919 | |
@@ -1943,16 +1943,16 @@ discard block |
||
| 1943 | 1943 | * Une des valeurs en fonction du compteur. |
| 1944 | 1944 | **/ |
| 1945 | 1945 | function alterner($i, ...$args) { |
| 1946 | - // recuperer les arguments (attention fonctions un peu space) |
|
| 1947 | - $num = count($args); |
|
| 1946 | + // recuperer les arguments (attention fonctions un peu space) |
|
| 1947 | + $num = count($args); |
|
| 1948 | 1948 | |
| 1949 | - if ($num === 1 && is_array($args[0])) { |
|
| 1950 | - $args = $args[0]; |
|
| 1951 | - $num = count($args); |
|
| 1952 | - } |
|
| 1949 | + if ($num === 1 && is_array($args[0])) { |
|
| 1950 | + $args = $args[0]; |
|
| 1951 | + $num = count($args); |
|
| 1952 | + } |
|
| 1953 | 1953 | |
| 1954 | - // renvoyer le i-ieme argument, modulo le nombre d'arguments |
|
| 1955 | - return $args[(intval($i) - 1) % $num]; |
|
| 1954 | + // renvoyer le i-ieme argument, modulo le nombre d'arguments |
|
| 1955 | + return $args[(intval($i) - 1) % $num]; |
|
| 1956 | 1956 | } |
| 1957 | 1957 | |
| 1958 | 1958 | |
@@ -1978,51 +1978,51 @@ discard block |
||
| 1978 | 1978 | * - null lorsque l’attribut n’existe pas. |
| 1979 | 1979 | **/ |
| 1980 | 1980 | function extraire_attribut($balise, $attribut, $complet = false) { |
| 1981 | - if (is_array($balise)) { |
|
| 1982 | - array_walk( |
|
| 1983 | - $balise, |
|
| 1984 | - function (&$a, $key, $t) { |
|
| 1985 | - $a = extraire_attribut($a, $t); |
|
| 1986 | - }, |
|
| 1987 | - $attribut |
|
| 1988 | - ); |
|
| 1989 | - |
|
| 1990 | - return $balise; |
|
| 1991 | - } |
|
| 1992 | - if ( |
|
| 1993 | - $balise |
|
| 1994 | - && preg_match( |
|
| 1995 | - ',(^.*?<(?:(?>\s*)(?>[\w:.-]+)(?>(?:=(?:"[^"]*"|\'[^\']*\'|[^\'"]\S*))?))*?)(\s+' |
|
| 1996 | - . $attribut |
|
| 1997 | - . '(?:=\s*("[^"]*"|\'[^\']*\'|[^\'"]\S*))?)()((?:[\s/][^>]*)?>.*),isS', |
|
| 1998 | - $balise, |
|
| 1999 | - $r |
|
| 2000 | - ) |
|
| 2001 | - ) { |
|
| 2002 | - if (isset($r[3][0]) and ($r[3][0] == '"' || $r[3][0] == "'")) { |
|
| 2003 | - $r[4] = substr($r[3], 1, -1); |
|
| 2004 | - $r[3] = $r[3][0]; |
|
| 2005 | - } elseif ($r[3] !== '') { |
|
| 2006 | - $r[4] = $r[3]; |
|
| 2007 | - $r[3] = ''; |
|
| 2008 | - } else { |
|
| 2009 | - $r[4] = trim($r[2]); |
|
| 2010 | - } |
|
| 2011 | - $att = $r[4]; |
|
| 2012 | - if (strpos($att, '&#') !== false) { |
|
| 2013 | - $att = str_replace([''', ''', '"', '"'], ["'", "'", '"', '"'], $att); |
|
| 2014 | - } |
|
| 2015 | - $att = filtrer_entites($att); |
|
| 2016 | - } else { |
|
| 2017 | - $att = null; |
|
| 2018 | - $r = []; |
|
| 2019 | - } |
|
| 2020 | - |
|
| 2021 | - if ($complet) { |
|
| 2022 | - return [$att, $r]; |
|
| 2023 | - } else { |
|
| 2024 | - return $att; |
|
| 2025 | - } |
|
| 1981 | + if (is_array($balise)) { |
|
| 1982 | + array_walk( |
|
| 1983 | + $balise, |
|
| 1984 | + function (&$a, $key, $t) { |
|
| 1985 | + $a = extraire_attribut($a, $t); |
|
| 1986 | + }, |
|
| 1987 | + $attribut |
|
| 1988 | + ); |
|
| 1989 | + |
|
| 1990 | + return $balise; |
|
| 1991 | + } |
|
| 1992 | + if ( |
|
| 1993 | + $balise |
|
| 1994 | + && preg_match( |
|
| 1995 | + ',(^.*?<(?:(?>\s*)(?>[\w:.-]+)(?>(?:=(?:"[^"]*"|\'[^\']*\'|[^\'"]\S*))?))*?)(\s+' |
|
| 1996 | + . $attribut |
|
| 1997 | + . '(?:=\s*("[^"]*"|\'[^\']*\'|[^\'"]\S*))?)()((?:[\s/][^>]*)?>.*),isS', |
|
| 1998 | + $balise, |
|
| 1999 | + $r |
|
| 2000 | + ) |
|
| 2001 | + ) { |
|
| 2002 | + if (isset($r[3][0]) and ($r[3][0] == '"' || $r[3][0] == "'")) { |
|
| 2003 | + $r[4] = substr($r[3], 1, -1); |
|
| 2004 | + $r[3] = $r[3][0]; |
|
| 2005 | + } elseif ($r[3] !== '') { |
|
| 2006 | + $r[4] = $r[3]; |
|
| 2007 | + $r[3] = ''; |
|
| 2008 | + } else { |
|
| 2009 | + $r[4] = trim($r[2]); |
|
| 2010 | + } |
|
| 2011 | + $att = $r[4]; |
|
| 2012 | + if (strpos($att, '&#') !== false) { |
|
| 2013 | + $att = str_replace([''', ''', '"', '"'], ["'", "'", '"', '"'], $att); |
|
| 2014 | + } |
|
| 2015 | + $att = filtrer_entites($att); |
|
| 2016 | + } else { |
|
| 2017 | + $att = null; |
|
| 2018 | + $r = []; |
|
| 2019 | + } |
|
| 2020 | + |
|
| 2021 | + if ($complet) { |
|
| 2022 | + return [$att, $r]; |
|
| 2023 | + } else { |
|
| 2024 | + return $att; |
|
| 2025 | + } |
|
| 2026 | 2026 | } |
| 2027 | 2027 | |
| 2028 | 2028 | /** |
@@ -2055,41 +2055,41 @@ discard block |
||
| 2055 | 2055 | **/ |
| 2056 | 2056 | function inserer_attribut(?string $balise, string $attribut, string $val, bool $proteger = true, bool $vider = false): string { |
| 2057 | 2057 | |
| 2058 | - if ($balise === null or $balise === '') { |
|
| 2059 | - return ''; |
|
| 2060 | - } |
|
| 2058 | + if ($balise === null or $balise === '') { |
|
| 2059 | + return ''; |
|
| 2060 | + } |
|
| 2061 | 2061 | |
| 2062 | - // preparer l'attribut |
|
| 2063 | - // supprimer les etc mais pas les balises html |
|
| 2064 | - // qui ont un sens dans un attribut value d'un input |
|
| 2065 | - if ($proteger) { |
|
| 2066 | - $val = attribut_html($val, false); |
|
| 2067 | - } |
|
| 2062 | + // preparer l'attribut |
|
| 2063 | + // supprimer les etc mais pas les balises html |
|
| 2064 | + // qui ont un sens dans un attribut value d'un input |
|
| 2065 | + if ($proteger) { |
|
| 2066 | + $val = attribut_html($val, false); |
|
| 2067 | + } |
|
| 2068 | 2068 | |
| 2069 | - // echapper les ' pour eviter tout bug |
|
| 2070 | - $val = str_replace("'", ''', $val); |
|
| 2071 | - if ($vider and strlen($val) === 0) { |
|
| 2072 | - $insert = ''; |
|
| 2073 | - } else { |
|
| 2074 | - $insert = " $attribut='$val'"; |
|
| 2075 | - } |
|
| 2069 | + // echapper les ' pour eviter tout bug |
|
| 2070 | + $val = str_replace("'", ''', $val); |
|
| 2071 | + if ($vider and strlen($val) === 0) { |
|
| 2072 | + $insert = ''; |
|
| 2073 | + } else { |
|
| 2074 | + $insert = " $attribut='$val'"; |
|
| 2075 | + } |
|
| 2076 | 2076 | |
| 2077 | - [$old, $r] = extraire_attribut($balise, $attribut, true); |
|
| 2077 | + [$old, $r] = extraire_attribut($balise, $attribut, true); |
|
| 2078 | 2078 | |
| 2079 | - if ($old !== null) { |
|
| 2080 | - // Remplacer l'ancien attribut du meme nom |
|
| 2081 | - $balise = $r[1] . $insert . $r[5]; |
|
| 2082 | - } else { |
|
| 2083 | - // preferer une balise " />" (comme <img />) |
|
| 2084 | - if (preg_match(',/>,', $balise)) { |
|
| 2085 | - $balise = preg_replace(',\s?/>,S', $insert . ' />', $balise, 1); |
|
| 2086 | - } // sinon une balise <a ...> ... </a> |
|
| 2087 | - else { |
|
| 2088 | - $balise = preg_replace(',\s?>,S', $insert . '>', $balise, 1); |
|
| 2089 | - } |
|
| 2090 | - } |
|
| 2079 | + if ($old !== null) { |
|
| 2080 | + // Remplacer l'ancien attribut du meme nom |
|
| 2081 | + $balise = $r[1] . $insert . $r[5]; |
|
| 2082 | + } else { |
|
| 2083 | + // preferer une balise " />" (comme <img />) |
|
| 2084 | + if (preg_match(',/>,', $balise)) { |
|
| 2085 | + $balise = preg_replace(',\s?/>,S', $insert . ' />', $balise, 1); |
|
| 2086 | + } // sinon une balise <a ...> ... </a> |
|
| 2087 | + else { |
|
| 2088 | + $balise = preg_replace(',\s?>,S', $insert . '>', $balise, 1); |
|
| 2089 | + } |
|
| 2090 | + } |
|
| 2091 | 2091 | |
| 2092 | - return $balise; |
|
| 2092 | + return $balise; |
|
| 2093 | 2093 | } |
| 2094 | 2094 | |
| 2095 | 2095 | /** |
@@ -2107,7 +2107,7 @@ discard block |
||
| 2107 | 2107 | * @return string Code HTML sans l'attribut |
| 2108 | 2108 | **/ |
| 2109 | 2109 | function vider_attribut(?string $balise, string $attribut): string { |
| 2110 | - return inserer_attribut($balise, $attribut, '', false, true); |
|
| 2110 | + return inserer_attribut($balise, $attribut, '', false, true); |
|
| 2111 | 2111 | } |
| 2112 | 2112 | |
| 2113 | 2113 | /** |
@@ -2119,53 +2119,53 @@ discard block |
||
| 2119 | 2119 | * @return string |
| 2120 | 2120 | */ |
| 2121 | 2121 | function modifier_class($balise, $class, $operation = 'ajouter') { |
| 2122 | - if (is_string($class)) { |
|
| 2123 | - $class = explode(' ', trim($class)); |
|
| 2124 | - } |
|
| 2125 | - $class = array_filter($class); |
|
| 2126 | - $class = array_unique($class); |
|
| 2127 | - if (!$class) { |
|
| 2128 | - return $balise; |
|
| 2129 | - } |
|
| 2130 | - |
|
| 2131 | - // si la ou les classes ont des caracteres invalides on ne fait rien |
|
| 2132 | - if (preg_match(',[^\w-],', implode('', $class))) { |
|
| 2133 | - return $balise; |
|
| 2134 | - } |
|
| 2135 | - |
|
| 2136 | - $class_courante = extraire_attribut($balise, 'class'); |
|
| 2137 | - $class_new = $class_courante; |
|
| 2138 | - foreach ($class as $c) { |
|
| 2139 | - $is_class_presente = false; |
|
| 2140 | - if ( |
|
| 2141 | - $class_courante |
|
| 2142 | - and strpos($class_courante, (string) $c) !== false |
|
| 2143 | - and preg_match('/(^|\s)' . preg_quote($c) . '($|\s)/', $class_courante) |
|
| 2144 | - ) { |
|
| 2145 | - $is_class_presente = true; |
|
| 2146 | - } |
|
| 2147 | - if ( |
|
| 2148 | - in_array($operation, ['ajouter', 'commuter']) |
|
| 2149 | - and !$is_class_presente |
|
| 2150 | - ) { |
|
| 2151 | - $class_new = ltrim(rtrim($class_new ?? '') . ' ' . $c); |
|
| 2152 | - } elseif ( |
|
| 2153 | - in_array($operation, ['supprimer', 'commuter']) |
|
| 2154 | - and $is_class_presente |
|
| 2155 | - ) { |
|
| 2156 | - $class_new = trim(preg_replace('/(^|\s)' . preg_quote($c) . '($|\s)/', "\\1", $class_new)); |
|
| 2157 | - } |
|
| 2158 | - } |
|
| 2159 | - |
|
| 2160 | - if ($class_new !== $class_courante) { |
|
| 2161 | - if (strlen($class_new)) { |
|
| 2162 | - $balise = inserer_attribut($balise, 'class', $class_new); |
|
| 2163 | - } elseif ($class_courante) { |
|
| 2164 | - $balise = vider_attribut($balise, 'class'); |
|
| 2165 | - } |
|
| 2166 | - } |
|
| 2167 | - |
|
| 2168 | - return $balise; |
|
| 2122 | + if (is_string($class)) { |
|
| 2123 | + $class = explode(' ', trim($class)); |
|
| 2124 | + } |
|
| 2125 | + $class = array_filter($class); |
|
| 2126 | + $class = array_unique($class); |
|
| 2127 | + if (!$class) { |
|
| 2128 | + return $balise; |
|
| 2129 | + } |
|
| 2130 | + |
|
| 2131 | + // si la ou les classes ont des caracteres invalides on ne fait rien |
|
| 2132 | + if (preg_match(',[^\w-],', implode('', $class))) { |
|
| 2133 | + return $balise; |
|
| 2134 | + } |
|
| 2135 | + |
|
| 2136 | + $class_courante = extraire_attribut($balise, 'class'); |
|
| 2137 | + $class_new = $class_courante; |
|
| 2138 | + foreach ($class as $c) { |
|
| 2139 | + $is_class_presente = false; |
|
| 2140 | + if ( |
|
| 2141 | + $class_courante |
|
| 2142 | + and strpos($class_courante, (string) $c) !== false |
|
| 2143 | + and preg_match('/(^|\s)' . preg_quote($c) . '($|\s)/', $class_courante) |
|
| 2144 | + ) { |
|
| 2145 | + $is_class_presente = true; |
|
| 2146 | + } |
|
| 2147 | + if ( |
|
| 2148 | + in_array($operation, ['ajouter', 'commuter']) |
|
| 2149 | + and !$is_class_presente |
|
| 2150 | + ) { |
|
| 2151 | + $class_new = ltrim(rtrim($class_new ?? '') . ' ' . $c); |
|
| 2152 | + } elseif ( |
|
| 2153 | + in_array($operation, ['supprimer', 'commuter']) |
|
| 2154 | + and $is_class_presente |
|
| 2155 | + ) { |
|
| 2156 | + $class_new = trim(preg_replace('/(^|\s)' . preg_quote($c) . '($|\s)/', "\\1", $class_new)); |
|
| 2157 | + } |
|
| 2158 | + } |
|
| 2159 | + |
|
| 2160 | + if ($class_new !== $class_courante) { |
|
| 2161 | + if (strlen($class_new)) { |
|
| 2162 | + $balise = inserer_attribut($balise, 'class', $class_new); |
|
| 2163 | + } elseif ($class_courante) { |
|
| 2164 | + $balise = vider_attribut($balise, 'class'); |
|
| 2165 | + } |
|
| 2166 | + } |
|
| 2167 | + |
|
| 2168 | + return $balise; |
|
| 2169 | 2169 | } |
| 2170 | 2170 | |
| 2171 | 2171 | /** |
@@ -2175,7 +2175,7 @@ discard block |
||
| 2175 | 2175 | * @return string |
| 2176 | 2176 | */ |
| 2177 | 2177 | function ajouter_class($balise, $class) { |
| 2178 | - return modifier_class($balise, $class, 'ajouter'); |
|
| 2178 | + return modifier_class($balise, $class, 'ajouter'); |
|
| 2179 | 2179 | } |
| 2180 | 2180 | |
| 2181 | 2181 | /** |
@@ -2185,7 +2185,7 @@ discard block |
||
| 2185 | 2185 | * @return string |
| 2186 | 2186 | */ |
| 2187 | 2187 | function supprimer_class($balise, $class) { |
| 2188 | - return modifier_class($balise, $class, 'supprimer'); |
|
| 2188 | + return modifier_class($balise, $class, 'supprimer'); |
|
| 2189 | 2189 | } |
| 2190 | 2190 | |
| 2191 | 2191 | /** |
@@ -2196,7 +2196,7 @@ discard block |
||
| 2196 | 2196 | * @return string |
| 2197 | 2197 | */ |
| 2198 | 2198 | function commuter_class($balise, $class) { |
| 2199 | - return modifier_class($balise, $class, 'commuter'); |
|
| 2199 | + return modifier_class($balise, $class, 'commuter'); |
|
| 2200 | 2200 | } |
| 2201 | 2201 | |
| 2202 | 2202 | /** |
@@ -2207,19 +2207,19 @@ discard block |
||
| 2207 | 2207 | * @return string |
| 2208 | 2208 | */ |
| 2209 | 2209 | function tester_config($id, $mode = '') { |
| 2210 | - include_spip('action/inscrire_auteur'); |
|
| 2210 | + include_spip('action/inscrire_auteur'); |
|
| 2211 | 2211 | |
| 2212 | - return tester_statut_inscription($mode, $id); |
|
| 2212 | + return tester_statut_inscription($mode, $id); |
|
| 2213 | 2213 | } |
| 2214 | 2214 | |
| 2215 | 2215 | // |
| 2216 | 2216 | // Quelques fonctions de calcul arithmetique |
| 2217 | 2217 | // |
| 2218 | 2218 | function floatstr($a) { |
| 2219 | - return str_replace(',', '.', (string)floatval($a)); |
|
| 2219 | + return str_replace(',', '.', (string)floatval($a)); |
|
| 2220 | 2220 | } |
| 2221 | 2221 | function strize($f, $a, $b) { |
| 2222 | - return floatstr($f(floatstr($a), floatstr($b))); |
|
| 2222 | + return floatstr($f(floatstr($a), floatstr($b))); |
|
| 2223 | 2223 | } |
| 2224 | 2224 | |
| 2225 | 2225 | /** |
@@ -2238,7 +2238,7 @@ discard block |
||
| 2238 | 2238 | * @return int $a+$b |
| 2239 | 2239 | **/ |
| 2240 | 2240 | function plus($a, $b) { |
| 2241 | - return $a + $b; |
|
| 2241 | + return $a + $b; |
|
| 2242 | 2242 | } |
| 2243 | 2243 | function strplus($a, $b) { |
| 2244 | 2244 | return strize('plus', $a, $b); |
@@ -2259,7 +2259,7 @@ discard block |
||
| 2259 | 2259 | * @return int $a-$b |
| 2260 | 2260 | **/ |
| 2261 | 2261 | function moins($a, $b) { |
| 2262 | - return $a - $b; |
|
| 2262 | + return $a - $b; |
|
| 2263 | 2263 | } |
| 2264 | 2264 | function strmoins($a, $b) { |
| 2265 | 2265 | return strize('moins', $a, $b); |
@@ -2282,7 +2282,7 @@ discard block |
||
| 2282 | 2282 | * @return int $a*$b |
| 2283 | 2283 | **/ |
| 2284 | 2284 | function mult($a, $b) { |
| 2285 | - return $a * $b; |
|
| 2285 | + return $a * $b; |
|
| 2286 | 2286 | } |
| 2287 | 2287 | function strmult($a, $b) { |
| 2288 | 2288 | return strize('mult', $a, $b); |
@@ -2305,7 +2305,7 @@ discard block |
||
| 2305 | 2305 | * @return int $a/$b (ou 0 si $b est nul) |
| 2306 | 2306 | **/ |
| 2307 | 2307 | function div($a, $b) { |
| 2308 | - return $b ? $a / $b : 0; |
|
| 2308 | + return $b ? $a / $b : 0; |
|
| 2309 | 2309 | } |
| 2310 | 2310 | function strdiv($a, $b) { |
| 2311 | 2311 | return strize('div', $a, $b); |
@@ -2329,7 +2329,7 @@ discard block |
||
| 2329 | 2329 | * @return int ($nb % $mod) + $add |
| 2330 | 2330 | **/ |
| 2331 | 2331 | function modulo($nb, $mod, $add = 0) { |
| 2332 | - return ($mod ? $nb % $mod : 0) + $add; |
|
| 2332 | + return ($mod ? $nb % $mod : 0) + $add; |
|
| 2333 | 2333 | } |
| 2334 | 2334 | |
| 2335 | 2335 | |
@@ -2344,26 +2344,26 @@ discard block |
||
| 2344 | 2344 | * - true sinon |
| 2345 | 2345 | **/ |
| 2346 | 2346 | function nom_acceptable($nom) { |
| 2347 | - $remp2 = []; |
|
| 2348 | - $remp1 = []; |
|
| 2349 | - if (!is_string($nom)) { |
|
| 2350 | - return false; |
|
| 2351 | - } |
|
| 2352 | - if (!defined('_TAGS_NOM_AUTEUR')) { |
|
| 2353 | - define('_TAGS_NOM_AUTEUR', ''); |
|
| 2354 | - } |
|
| 2355 | - $tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR)); |
|
| 2356 | - foreach ($tags_acceptes as $tag) { |
|
| 2357 | - if (strlen($tag)) { |
|
| 2358 | - $remp1[] = '<' . trim($tag) . '>'; |
|
| 2359 | - $remp1[] = '</' . trim($tag) . '>'; |
|
| 2360 | - $remp2[] = '\x60' . trim($tag) . '\x61'; |
|
| 2361 | - $remp2[] = '\x60/' . trim($tag) . '\x61'; |
|
| 2362 | - } |
|
| 2363 | - } |
|
| 2364 | - $v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom))); |
|
| 2365 | - |
|
| 2366 | - return str_replace('<', '<', $v_nom) == $nom; |
|
| 2347 | + $remp2 = []; |
|
| 2348 | + $remp1 = []; |
|
| 2349 | + if (!is_string($nom)) { |
|
| 2350 | + return false; |
|
| 2351 | + } |
|
| 2352 | + if (!defined('_TAGS_NOM_AUTEUR')) { |
|
| 2353 | + define('_TAGS_NOM_AUTEUR', ''); |
|
| 2354 | + } |
|
| 2355 | + $tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR)); |
|
| 2356 | + foreach ($tags_acceptes as $tag) { |
|
| 2357 | + if (strlen($tag)) { |
|
| 2358 | + $remp1[] = '<' . trim($tag) . '>'; |
|
| 2359 | + $remp1[] = '</' . trim($tag) . '>'; |
|
| 2360 | + $remp2[] = '\x60' . trim($tag) . '\x61'; |
|
| 2361 | + $remp2[] = '\x60/' . trim($tag) . '\x61'; |
|
| 2362 | + } |
|
| 2363 | + } |
|
| 2364 | + $v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom))); |
|
| 2365 | + |
|
| 2366 | + return str_replace('<', '<', $v_nom) == $nom; |
|
| 2367 | 2367 | } |
| 2368 | 2368 | |
| 2369 | 2369 | |
@@ -2379,14 +2379,14 @@ discard block |
||
| 2379 | 2379 | * - renvoie un tableau si l'entree est un tableau |
| 2380 | 2380 | **/ |
| 2381 | 2381 | function email_valide($adresses) { |
| 2382 | - if (is_array($adresses)) { |
|
| 2383 | - $adresses = array_map('email_valide', $adresses); |
|
| 2384 | - $adresses = array_filter($adresses); |
|
| 2385 | - return $adresses; |
|
| 2386 | - } |
|
| 2382 | + if (is_array($adresses)) { |
|
| 2383 | + $adresses = array_map('email_valide', $adresses); |
|
| 2384 | + $adresses = array_filter($adresses); |
|
| 2385 | + return $adresses; |
|
| 2386 | + } |
|
| 2387 | 2387 | |
| 2388 | - $email_valide = charger_fonction('email_valide', 'inc'); |
|
| 2389 | - return $email_valide($adresses); |
|
| 2388 | + $email_valide = charger_fonction('email_valide', 'inc'); |
|
| 2389 | + return $email_valide($adresses); |
|
| 2390 | 2390 | } |
| 2391 | 2391 | |
| 2392 | 2392 | /** |
@@ -2400,27 +2400,27 @@ discard block |
||
| 2400 | 2400 | * @return string Texte |
| 2401 | 2401 | **/ |
| 2402 | 2402 | function afficher_enclosures($tags) { |
| 2403 | - $s = []; |
|
| 2404 | - foreach (extraire_balises($tags, 'a') as $tag) { |
|
| 2405 | - if ( |
|
| 2406 | - extraire_attribut($tag, 'rel') == 'enclosure' |
|
| 2407 | - and $t = extraire_attribut($tag, 'href') |
|
| 2408 | - ) { |
|
| 2409 | - $s[] = preg_replace( |
|
| 2410 | - ',>[^<]+</a>,S', |
|
| 2411 | - '>' |
|
| 2412 | - . http_img_pack( |
|
| 2413 | - 'attachment-16.png', |
|
| 2414 | - $t, |
|
| 2415 | - 'title="' . attribut_html($t) . '"' |
|
| 2416 | - ) |
|
| 2417 | - . '</a>', |
|
| 2418 | - $tag |
|
| 2419 | - ); |
|
| 2420 | - } |
|
| 2421 | - } |
|
| 2422 | - |
|
| 2423 | - return join(' ', $s); |
|
| 2403 | + $s = []; |
|
| 2404 | + foreach (extraire_balises($tags, 'a') as $tag) { |
|
| 2405 | + if ( |
|
| 2406 | + extraire_attribut($tag, 'rel') == 'enclosure' |
|
| 2407 | + and $t = extraire_attribut($tag, 'href') |
|
| 2408 | + ) { |
|
| 2409 | + $s[] = preg_replace( |
|
| 2410 | + ',>[^<]+</a>,S', |
|
| 2411 | + '>' |
|
| 2412 | + . http_img_pack( |
|
| 2413 | + 'attachment-16.png', |
|
| 2414 | + $t, |
|
| 2415 | + 'title="' . attribut_html($t) . '"' |
|
| 2416 | + ) |
|
| 2417 | + . '</a>', |
|
| 2418 | + $tag |
|
| 2419 | + ); |
|
| 2420 | + } |
|
| 2421 | + } |
|
| 2422 | + |
|
| 2423 | + return join(' ', $s); |
|
| 2424 | 2424 | } |
| 2425 | 2425 | |
| 2426 | 2426 | /** |
@@ -2435,15 +2435,15 @@ discard block |
||
| 2435 | 2435 | * @return string Liens trouvés |
| 2436 | 2436 | **/ |
| 2437 | 2437 | function afficher_tags($tags, $rels = 'tag,directory') { |
| 2438 | - $s = []; |
|
| 2439 | - foreach (extraire_balises($tags, 'a') as $tag) { |
|
| 2440 | - $rel = extraire_attribut($tag, 'rel'); |
|
| 2441 | - if (strstr(",$rels,", (string) ",$rel,")) { |
|
| 2442 | - $s[] = $tag; |
|
| 2443 | - } |
|
| 2444 | - } |
|
| 2438 | + $s = []; |
|
| 2439 | + foreach (extraire_balises($tags, 'a') as $tag) { |
|
| 2440 | + $rel = extraire_attribut($tag, 'rel'); |
|
| 2441 | + if (strstr(",$rels,", (string) ",$rel,")) { |
|
| 2442 | + $s[] = $tag; |
|
| 2443 | + } |
|
| 2444 | + } |
|
| 2445 | 2445 | |
| 2446 | - return join(', ', $s); |
|
| 2446 | + return join(', ', $s); |
|
| 2447 | 2447 | } |
| 2448 | 2448 | |
| 2449 | 2449 | |
@@ -2465,21 +2465,21 @@ discard block |
||
| 2465 | 2465 | * @return string Tag HTML `<a>` avec microformat. |
| 2466 | 2466 | **/ |
| 2467 | 2467 | function enclosure2microformat($e) { |
| 2468 | - if (!$url = filtrer_entites(extraire_attribut($e, 'url'))) { |
|
| 2469 | - $url = filtrer_entites(extraire_attribut($e, 'href')); |
|
| 2470 | - } |
|
| 2471 | - $type = extraire_attribut($e, 'type'); |
|
| 2472 | - if (!$length = extraire_attribut($e, 'length')) { |
|
| 2473 | - # <media:content : longeur dans fileSize. On tente. |
|
| 2474 | - $length = extraire_attribut($e, 'fileSize'); |
|
| 2475 | - } |
|
| 2476 | - $fichier = basename($url); |
|
| 2468 | + if (!$url = filtrer_entites(extraire_attribut($e, 'url'))) { |
|
| 2469 | + $url = filtrer_entites(extraire_attribut($e, 'href')); |
|
| 2470 | + } |
|
| 2471 | + $type = extraire_attribut($e, 'type'); |
|
| 2472 | + if (!$length = extraire_attribut($e, 'length')) { |
|
| 2473 | + # <media:content : longeur dans fileSize. On tente. |
|
| 2474 | + $length = extraire_attribut($e, 'fileSize'); |
|
| 2475 | + } |
|
| 2476 | + $fichier = basename($url); |
|
| 2477 | 2477 | |
| 2478 | - return '<a rel="enclosure"' |
|
| 2479 | - . ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '') |
|
| 2480 | - . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '') |
|
| 2481 | - . ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '') |
|
| 2482 | - . '>' . $fichier . '</a>'; |
|
| 2478 | + return '<a rel="enclosure"' |
|
| 2479 | + . ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '') |
|
| 2480 | + . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '') |
|
| 2481 | + . ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '') |
|
| 2482 | + . '>' . $fichier . '</a>'; |
|
| 2483 | 2483 | } |
| 2484 | 2484 | |
| 2485 | 2485 | /** |
@@ -2497,24 +2497,24 @@ discard block |
||
| 2497 | 2497 | * @return string Tags RSS `<enclosure>`. |
| 2498 | 2498 | **/ |
| 2499 | 2499 | function microformat2enclosure($tags) { |
| 2500 | - $enclosures = []; |
|
| 2501 | - foreach (extraire_balises($tags, 'a') as $e) { |
|
| 2502 | - if (extraire_attribut($e, 'rel') == 'enclosure') { |
|
| 2503 | - $url = filtrer_entites(extraire_attribut($e, 'href')); |
|
| 2504 | - $type = extraire_attribut($e, 'type'); |
|
| 2505 | - if (!$length = intval(extraire_attribut($e, 'title'))) { |
|
| 2506 | - $length = intval(extraire_attribut($e, 'length')); |
|
| 2507 | - } # vieux data |
|
| 2508 | - $fichier = basename($url); |
|
| 2509 | - $enclosures[] = '<enclosure' |
|
| 2510 | - . ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '') |
|
| 2511 | - . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '') |
|
| 2512 | - . ($length ? ' length="' . $length . '"' : '') |
|
| 2513 | - . ' />'; |
|
| 2514 | - } |
|
| 2515 | - } |
|
| 2500 | + $enclosures = []; |
|
| 2501 | + foreach (extraire_balises($tags, 'a') as $e) { |
|
| 2502 | + if (extraire_attribut($e, 'rel') == 'enclosure') { |
|
| 2503 | + $url = filtrer_entites(extraire_attribut($e, 'href')); |
|
| 2504 | + $type = extraire_attribut($e, 'type'); |
|
| 2505 | + if (!$length = intval(extraire_attribut($e, 'title'))) { |
|
| 2506 | + $length = intval(extraire_attribut($e, 'length')); |
|
| 2507 | + } # vieux data |
|
| 2508 | + $fichier = basename($url); |
|
| 2509 | + $enclosures[] = '<enclosure' |
|
| 2510 | + . ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '') |
|
| 2511 | + . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '') |
|
| 2512 | + . ($length ? ' length="' . $length . '"' : '') |
|
| 2513 | + . ' />'; |
|
| 2514 | + } |
|
| 2515 | + } |
|
| 2516 | 2516 | |
| 2517 | - return join("\n", $enclosures); |
|
| 2517 | + return join("\n", $enclosures); |
|
| 2518 | 2518 | } |
| 2519 | 2519 | |
| 2520 | 2520 | |
@@ -2530,16 +2530,16 @@ discard block |
||
| 2530 | 2530 | * @return string Tags RSS Atom `<dc:subject>`. |
| 2531 | 2531 | **/ |
| 2532 | 2532 | function tags2dcsubject($tags) { |
| 2533 | - $subjects = ''; |
|
| 2534 | - foreach (extraire_balises($tags, 'a') as $e) { |
|
| 2535 | - if (extraire_attribut($e, 'rel') == 'tag') { |
|
| 2536 | - $subjects .= '<dc:subject>' |
|
| 2537 | - . texte_backend(textebrut($e)) |
|
| 2538 | - . '</dc:subject>' . "\n"; |
|
| 2539 | - } |
|
| 2540 | - } |
|
| 2533 | + $subjects = ''; |
|
| 2534 | + foreach (extraire_balises($tags, 'a') as $e) { |
|
| 2535 | + if (extraire_attribut($e, 'rel') == 'tag') { |
|
| 2536 | + $subjects .= '<dc:subject>' |
|
| 2537 | + . texte_backend(textebrut($e)) |
|
| 2538 | + . '</dc:subject>' . "\n"; |
|
| 2539 | + } |
|
| 2540 | + } |
|
| 2541 | 2541 | |
| 2542 | - return $subjects; |
|
| 2542 | + return $subjects; |
|
| 2543 | 2543 | } |
| 2544 | 2544 | |
| 2545 | 2545 | /** |
@@ -2568,27 +2568,27 @@ discard block |
||
| 2568 | 2568 | * - Tableau de résultats, si tableau en entrée. |
| 2569 | 2569 | **/ |
| 2570 | 2570 | function extraire_balise($texte, $tag = 'a') { |
| 2571 | - if (is_array($texte)) { |
|
| 2572 | - array_walk( |
|
| 2573 | - $texte, |
|
| 2574 | - function (&$a, $key, $t) { |
|
| 2575 | - $a = extraire_balise($a, $t); |
|
| 2576 | - }, |
|
| 2577 | - $tag |
|
| 2578 | - ); |
|
| 2579 | - |
|
| 2580 | - return $texte; |
|
| 2581 | - } |
|
| 2582 | - |
|
| 2583 | - if ( |
|
| 2584 | - preg_match( |
|
| 2585 | - ",<$tag\b[^>]*(/>|>.*</$tag\b[^>]*>|>),UimsS", |
|
| 2586 | - $texte, |
|
| 2587 | - $regs |
|
| 2588 | - ) |
|
| 2589 | - ) { |
|
| 2590 | - return $regs[0]; |
|
| 2591 | - } |
|
| 2571 | + if (is_array($texte)) { |
|
| 2572 | + array_walk( |
|
| 2573 | + $texte, |
|
| 2574 | + function (&$a, $key, $t) { |
|
| 2575 | + $a = extraire_balise($a, $t); |
|
| 2576 | + }, |
|
| 2577 | + $tag |
|
| 2578 | + ); |
|
| 2579 | + |
|
| 2580 | + return $texte; |
|
| 2581 | + } |
|
| 2582 | + |
|
| 2583 | + if ( |
|
| 2584 | + preg_match( |
|
| 2585 | + ",<$tag\b[^>]*(/>|>.*</$tag\b[^>]*>|>),UimsS", |
|
| 2586 | + $texte, |
|
| 2587 | + $regs |
|
| 2588 | + ) |
|
| 2589 | + ) { |
|
| 2590 | + return $regs[0]; |
|
| 2591 | + } |
|
| 2592 | 2592 | } |
| 2593 | 2593 | |
| 2594 | 2594 | /** |
@@ -2616,30 +2616,30 @@ discard block |
||
| 2616 | 2616 | * - Tableau de résultats, si tableau en entrée. |
| 2617 | 2617 | **/ |
| 2618 | 2618 | function extraire_balises($texte, $tag = 'a') { |
| 2619 | - if (is_array($texte)) { |
|
| 2620 | - array_walk( |
|
| 2621 | - $texte, |
|
| 2622 | - function (&$a, $key, $t) { |
|
| 2623 | - $a = extraire_balises($a, $t); |
|
| 2624 | - }, |
|
| 2625 | - $tag |
|
| 2626 | - ); |
|
| 2627 | - |
|
| 2628 | - return $texte; |
|
| 2629 | - } |
|
| 2630 | - |
|
| 2631 | - if ( |
|
| 2632 | - preg_match_all( |
|
| 2633 | - ",<${tag}\b[^>]*(/>|>.*</${tag}\b[^>]*>|>),UimsS", |
|
| 2634 | - $texte, |
|
| 2635 | - $regs, |
|
| 2636 | - PREG_PATTERN_ORDER |
|
| 2637 | - ) |
|
| 2638 | - ) { |
|
| 2639 | - return $regs[0]; |
|
| 2640 | - } else { |
|
| 2641 | - return []; |
|
| 2642 | - } |
|
| 2619 | + if (is_array($texte)) { |
|
| 2620 | + array_walk( |
|
| 2621 | + $texte, |
|
| 2622 | + function (&$a, $key, $t) { |
|
| 2623 | + $a = extraire_balises($a, $t); |
|
| 2624 | + }, |
|
| 2625 | + $tag |
|
| 2626 | + ); |
|
| 2627 | + |
|
| 2628 | + return $texte; |
|
| 2629 | + } |
|
| 2630 | + |
|
| 2631 | + if ( |
|
| 2632 | + preg_match_all( |
|
| 2633 | + ",<${tag}\b[^>]*(/>|>.*</${tag}\b[^>]*>|>),UimsS", |
|
| 2634 | + $texte, |
|
| 2635 | + $regs, |
|
| 2636 | + PREG_PATTERN_ORDER |
|
| 2637 | + ) |
|
| 2638 | + ) { |
|
| 2639 | + return $regs[0]; |
|
| 2640 | + } else { |
|
| 2641 | + return []; |
|
| 2642 | + } |
|
| 2643 | 2643 | } |
| 2644 | 2644 | |
| 2645 | 2645 | /** |
@@ -2668,11 +2668,11 @@ discard block |
||
| 2668 | 2668 | * - `$def` si on n'a pas transmis de tableau |
| 2669 | 2669 | **/ |
| 2670 | 2670 | function in_any($val, $vals, $def = '') { |
| 2671 | - if (!is_array($vals) and $vals and $v = unserialize($vals)) { |
|
| 2672 | - $vals = $v; |
|
| 2673 | - } |
|
| 2671 | + if (!is_array($vals) and $vals and $v = unserialize($vals)) { |
|
| 2672 | + $vals = $v; |
|
| 2673 | + } |
|
| 2674 | 2674 | |
| 2675 | - return (!is_array($vals) ? $def : (in_array($val, $vals) ? ' ' : '')); |
|
| 2675 | + return (!is_array($vals) ? $def : (in_array($val, $vals) ? ' ' : '')); |
|
| 2676 | 2676 | } |
| 2677 | 2677 | |
| 2678 | 2678 | |
@@ -2693,12 +2693,12 @@ discard block |
||
| 2693 | 2693 | * Résultat du calcul |
| 2694 | 2694 | **/ |
| 2695 | 2695 | function valeur_numerique($expr) { |
| 2696 | - $a = 0; |
|
| 2697 | - if (preg_match(',^[0-9]+(\s*[+*-]\s*[0-9]+)*$,S', trim($expr))) { |
|
| 2698 | - eval("\$a = $expr;"); |
|
| 2699 | - } |
|
| 2696 | + $a = 0; |
|
| 2697 | + if (preg_match(',^[0-9]+(\s*[+*-]\s*[0-9]+)*$,S', trim($expr))) { |
|
| 2698 | + eval("\$a = $expr;"); |
|
| 2699 | + } |
|
| 2700 | 2700 | |
| 2701 | - return intval($a); |
|
| 2701 | + return intval($a); |
|
| 2702 | 2702 | } |
| 2703 | 2703 | |
| 2704 | 2704 | /** |
@@ -2717,7 +2717,7 @@ discard block |
||
| 2717 | 2717 | * Retourne `$a*$b/$c` |
| 2718 | 2718 | **/ |
| 2719 | 2719 | function regledetrois($a, $b, $c) { |
| 2720 | - return round($a * $b / $c); |
|
| 2720 | + return round($a * $b / $c); |
|
| 2721 | 2721 | } |
| 2722 | 2722 | |
| 2723 | 2723 | |
@@ -2741,77 +2741,77 @@ discard block |
||
| 2741 | 2741 | **/ |
| 2742 | 2742 | function form_hidden($action) { |
| 2743 | 2743 | |
| 2744 | - $contexte = []; |
|
| 2745 | - include_spip('inc/urls'); |
|
| 2746 | - if ( |
|
| 2747 | - $p = urls_decoder_url($action, '') |
|
| 2748 | - and reset($p) |
|
| 2749 | - ) { |
|
| 2750 | - $fond = array_shift($p); |
|
| 2751 | - if ($fond != '404') { |
|
| 2752 | - $contexte = array_shift($p); |
|
| 2753 | - $contexte['page'] = $fond; |
|
| 2754 | - $action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action); |
|
| 2755 | - } |
|
| 2756 | - } |
|
| 2757 | - // defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url |
|
| 2758 | - if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) { |
|
| 2759 | - unset($contexte['type']); |
|
| 2760 | - } |
|
| 2761 | - if (!defined('_DEFINIR_CONTEXTE_TYPE_PAGE') or _DEFINIR_CONTEXTE_TYPE_PAGE) { |
|
| 2762 | - unset($contexte['type-page']); |
|
| 2763 | - } |
|
| 2764 | - |
|
| 2765 | - // on va remplir un tableau de valeurs en prenant bien soin de ne pas |
|
| 2766 | - // ecraser les elements de la forme mots[]=1&mots[]=2 |
|
| 2767 | - $values = []; |
|
| 2768 | - |
|
| 2769 | - // d'abord avec celles de l'url |
|
| 2770 | - if (false !== ($p = strpos($action, '?'))) { |
|
| 2771 | - foreach (preg_split('/&(amp;)?/S', substr($action, $p + 1)) as $c) { |
|
| 2772 | - $c = explode('=', $c, 2); |
|
| 2773 | - $var = array_shift($c); |
|
| 2774 | - $val = array_shift($c); |
|
| 2775 | - if ($var) { |
|
| 2776 | - $val = rawurldecode($val); |
|
| 2777 | - $var = rawurldecode($var); // decoder les [] eventuels |
|
| 2778 | - if (preg_match(',\[\]$,S', $var)) { |
|
| 2779 | - $values[] = [$var, $val]; |
|
| 2780 | - } else { |
|
| 2781 | - if (!isset($values[$var])) { |
|
| 2782 | - $values[$var] = [$var, $val]; |
|
| 2783 | - } |
|
| 2784 | - } |
|
| 2785 | - } |
|
| 2786 | - } |
|
| 2787 | - } |
|
| 2788 | - |
|
| 2789 | - // ensuite avec celles du contexte, sans doublonner ! |
|
| 2790 | - foreach ($contexte as $var => $val) { |
|
| 2791 | - if (preg_match(',\[\]$,S', $var)) { |
|
| 2792 | - $values[] = [$var, $val]; |
|
| 2793 | - } else { |
|
| 2794 | - if (!isset($values[$var])) { |
|
| 2795 | - $values[$var] = [$var, $val]; |
|
| 2796 | - } |
|
| 2797 | - } |
|
| 2798 | - } |
|
| 2799 | - |
|
| 2800 | - // puis on rassemble le tout |
|
| 2801 | - $hidden = []; |
|
| 2802 | - foreach ($values as $value) { |
|
| 2803 | - [$var, $val] = $value; |
|
| 2804 | - $hidden[] = '<input name="' |
|
| 2805 | - . entites_html($var) |
|
| 2806 | - . '"' |
|
| 2807 | - . (is_null($val) |
|
| 2808 | - ? '' |
|
| 2809 | - : ' value="' . entites_html($val) . '"' |
|
| 2810 | - ) |
|
| 2811 | - . ' type="hidden"' . "\n/>"; |
|
| 2812 | - } |
|
| 2813 | - |
|
| 2814 | - return join('', $hidden); |
|
| 2744 | + $contexte = []; |
|
| 2745 | + include_spip('inc/urls'); |
|
| 2746 | + if ( |
|
| 2747 | + $p = urls_decoder_url($action, '') |
|
| 2748 | + and reset($p) |
|
| 2749 | + ) { |
|
| 2750 | + $fond = array_shift($p); |
|
| 2751 | + if ($fond != '404') { |
|
| 2752 | + $contexte = array_shift($p); |
|
| 2753 | + $contexte['page'] = $fond; |
|
| 2754 | + $action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action); |
|
| 2755 | + } |
|
| 2756 | + } |
|
| 2757 | + // defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url |
|
| 2758 | + if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) { |
|
| 2759 | + unset($contexte['type']); |
|
| 2760 | + } |
|
| 2761 | + if (!defined('_DEFINIR_CONTEXTE_TYPE_PAGE') or _DEFINIR_CONTEXTE_TYPE_PAGE) { |
|
| 2762 | + unset($contexte['type-page']); |
|
| 2763 | + } |
|
| 2764 | + |
|
| 2765 | + // on va remplir un tableau de valeurs en prenant bien soin de ne pas |
|
| 2766 | + // ecraser les elements de la forme mots[]=1&mots[]=2 |
|
| 2767 | + $values = []; |
|
| 2768 | + |
|
| 2769 | + // d'abord avec celles de l'url |
|
| 2770 | + if (false !== ($p = strpos($action, '?'))) { |
|
| 2771 | + foreach (preg_split('/&(amp;)?/S', substr($action, $p + 1)) as $c) { |
|
| 2772 | + $c = explode('=', $c, 2); |
|
| 2773 | + $var = array_shift($c); |
|
| 2774 | + $val = array_shift($c); |
|
| 2775 | + if ($var) { |
|
| 2776 | + $val = rawurldecode($val); |
|
| 2777 | + $var = rawurldecode($var); // decoder les [] eventuels |
|
| 2778 | + if (preg_match(',\[\]$,S', $var)) { |
|
| 2779 | + $values[] = [$var, $val]; |
|
| 2780 | + } else { |
|
| 2781 | + if (!isset($values[$var])) { |
|
| 2782 | + $values[$var] = [$var, $val]; |
|
| 2783 | + } |
|
| 2784 | + } |
|
| 2785 | + } |
|
| 2786 | + } |
|
| 2787 | + } |
|
| 2788 | + |
|
| 2789 | + // ensuite avec celles du contexte, sans doublonner ! |
|
| 2790 | + foreach ($contexte as $var => $val) { |
|
| 2791 | + if (preg_match(',\[\]$,S', $var)) { |
|
| 2792 | + $values[] = [$var, $val]; |
|
| 2793 | + } else { |
|
| 2794 | + if (!isset($values[$var])) { |
|
| 2795 | + $values[$var] = [$var, $val]; |
|
| 2796 | + } |
|
| 2797 | + } |
|
| 2798 | + } |
|
| 2799 | + |
|
| 2800 | + // puis on rassemble le tout |
|
| 2801 | + $hidden = []; |
|
| 2802 | + foreach ($values as $value) { |
|
| 2803 | + [$var, $val] = $value; |
|
| 2804 | + $hidden[] = '<input name="' |
|
| 2805 | + . entites_html($var) |
|
| 2806 | + . '"' |
|
| 2807 | + . (is_null($val) |
|
| 2808 | + ? '' |
|
| 2809 | + : ' value="' . entites_html($val) . '"' |
|
| 2810 | + ) |
|
| 2811 | + . ' type="hidden"' . "\n/>"; |
|
| 2812 | + } |
|
| 2813 | + |
|
| 2814 | + return join('', $hidden); |
|
| 2815 | 2815 | } |
| 2816 | 2816 | |
| 2817 | 2817 | |
@@ -2833,7 +2833,7 @@ discard block |
||
| 2833 | 2833 | * - la première valeur du tableau sinon. |
| 2834 | 2834 | **/ |
| 2835 | 2835 | function filtre_reset($array) { |
| 2836 | - return !is_array($array) ? null : reset($array); |
|
| 2836 | + return !is_array($array) ? null : reset($array); |
|
| 2837 | 2837 | } |
| 2838 | 2838 | |
| 2839 | 2839 | /** |
@@ -2854,7 +2854,7 @@ discard block |
||
| 2854 | 2854 | * - la dernière valeur du tableau sinon. |
| 2855 | 2855 | **/ |
| 2856 | 2856 | function filtre_end($array) { |
| 2857 | - return !is_array($array) ? null : end($array); |
|
| 2857 | + return !is_array($array) ? null : end($array); |
|
| 2858 | 2858 | } |
| 2859 | 2859 | |
| 2860 | 2860 | /** |
@@ -2874,11 +2874,11 @@ discard block |
||
| 2874 | 2874 | * |
| 2875 | 2875 | **/ |
| 2876 | 2876 | function filtre_push($array, $val) { |
| 2877 | - if (!is_array($array) or !array_push($array, $val)) { |
|
| 2878 | - return ''; |
|
| 2879 | - } |
|
| 2877 | + if (!is_array($array) or !array_push($array, $val)) { |
|
| 2878 | + return ''; |
|
| 2879 | + } |
|
| 2880 | 2880 | |
| 2881 | - return $array; |
|
| 2881 | + return $array; |
|
| 2882 | 2882 | } |
| 2883 | 2883 | |
| 2884 | 2884 | /** |
@@ -2897,7 +2897,7 @@ discard block |
||
| 2897 | 2897 | * - `true` si la valeur existe dans le tableau, `false` sinon. |
| 2898 | 2898 | **/ |
| 2899 | 2899 | function filtre_find($array, $val) { |
| 2900 | - return (is_array($array) and in_array($val, $array)); |
|
| 2900 | + return (is_array($array) and in_array($val, $array)); |
|
| 2901 | 2901 | } |
| 2902 | 2902 | |
| 2903 | 2903 | |
@@ -2914,13 +2914,13 @@ discard block |
||
| 2914 | 2914 | * Contenu avec urls en absolus |
| 2915 | 2915 | **/ |
| 2916 | 2916 | function urls_absolues_css($contenu, $source) { |
| 2917 | - $path = suivre_lien(url_absolue($source), './'); |
|
| 2917 | + $path = suivre_lien(url_absolue($source), './'); |
|
| 2918 | 2918 | |
| 2919 | - return preg_replace_callback( |
|
| 2920 | - ",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims", |
|
| 2921 | - fn($x) => "url('" . suivre_lien($path, $x[1]) . "')", |
|
| 2922 | - $contenu |
|
| 2923 | - ); |
|
| 2919 | + return preg_replace_callback( |
|
| 2920 | + ",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims", |
|
| 2921 | + fn($x) => "url('" . suivre_lien($path, $x[1]) . "')", |
|
| 2922 | + $contenu |
|
| 2923 | + ); |
|
| 2924 | 2924 | } |
| 2925 | 2925 | |
| 2926 | 2926 | |
@@ -2949,119 +2949,119 @@ discard block |
||
| 2949 | 2949 | * Chemin du fichier CSS inversé |
| 2950 | 2950 | **/ |
| 2951 | 2951 | function direction_css($css, $voulue = '') { |
| 2952 | - if (!preg_match(',(_rtl)?\.css$,i', $css, $r)) { |
|
| 2953 | - return $css; |
|
| 2954 | - } |
|
| 2955 | - include_spip('inc/lang'); |
|
| 2956 | - // si on a precise le sens voulu en argument, le prendre en compte |
|
| 2957 | - if ($voulue = strtolower($voulue)) { |
|
| 2958 | - if ($voulue != 'rtl' and $voulue != 'ltr') { |
|
| 2959 | - $voulue = lang_dir($voulue); |
|
| 2960 | - } |
|
| 2961 | - } else { |
|
| 2962 | - $voulue = lang_dir(); |
|
| 2963 | - } |
|
| 2964 | - |
|
| 2965 | - $r = count($r) > 1; |
|
| 2966 | - $right = $r ? 'left' : 'right'; // 'right' de la css lue en entree |
|
| 2967 | - $dir = $r ? 'rtl' : 'ltr'; |
|
| 2968 | - $ndir = $r ? 'ltr' : 'rtl'; |
|
| 2969 | - |
|
| 2970 | - if ($voulue == $dir) { |
|
| 2971 | - return $css; |
|
| 2972 | - } |
|
| 2973 | - |
|
| 2974 | - if ( |
|
| 2975 | - // url absolue |
|
| 2976 | - preg_match(',^https?:,i', $css) |
|
| 2977 | - // ou qui contient un ? |
|
| 2978 | - or (($p = strpos($css, '?')) !== false) |
|
| 2979 | - ) { |
|
| 2980 | - $distant = true; |
|
| 2981 | - $cssf = parse_url($css); |
|
| 2982 | - $cssf = $cssf['path'] . ($cssf['query'] ? '?' . $cssf['query'] : ''); |
|
| 2983 | - $cssf = preg_replace(',[?:&=],', '_', $cssf); |
|
| 2984 | - } else { |
|
| 2985 | - $distant = false; |
|
| 2986 | - $cssf = $css; |
|
| 2987 | - // 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi |
|
| 2988 | - //propose (rien a faire dans ce cas) |
|
| 2989 | - $f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css); |
|
| 2990 | - if (@file_exists($f)) { |
|
| 2991 | - return $f; |
|
| 2992 | - } |
|
| 2993 | - } |
|
| 2994 | - |
|
| 2995 | - // 2. |
|
| 2996 | - $dir_var = sous_repertoire(_DIR_VAR, 'cache-css'); |
|
| 2997 | - $f = $dir_var |
|
| 2998 | - . preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf) |
|
| 2999 | - . '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css'; |
|
| 3000 | - |
|
| 3001 | - // la css peut etre distante (url absolue !) |
|
| 3002 | - if ($distant) { |
|
| 3003 | - include_spip('inc/distant'); |
|
| 3004 | - $res = recuperer_url($css); |
|
| 3005 | - if (!$res or !$contenu = $res['page']) { |
|
| 3006 | - return $css; |
|
| 3007 | - } |
|
| 3008 | - } else { |
|
| 3009 | - if ( |
|
| 3010 | - (@filemtime($f) > @filemtime($css)) |
|
| 3011 | - and (_VAR_MODE != 'recalcul') |
|
| 3012 | - ) { |
|
| 3013 | - return $f; |
|
| 3014 | - } |
|
| 3015 | - if (!lire_fichier($css, $contenu)) { |
|
| 3016 | - return $css; |
|
| 3017 | - } |
|
| 3018 | - } |
|
| 3019 | - |
|
| 3020 | - |
|
| 3021 | - // Inverser la direction gauche-droite en utilisant CSSTidy qui gere aussi les shorthands |
|
| 3022 | - include_spip('lib/csstidy/class.csstidy'); |
|
| 3023 | - $parser = new csstidy(); |
|
| 3024 | - $parser->set_cfg('optimise_shorthands', 0); |
|
| 3025 | - $parser->set_cfg('reverse_left_and_right', true); |
|
| 3026 | - $parser->parse($contenu); |
|
| 3027 | - |
|
| 3028 | - $contenu = $parser->print->plain(); |
|
| 3029 | - |
|
| 3030 | - |
|
| 3031 | - // reperer les @import auxquels il faut propager le direction_css |
|
| 3032 | - preg_match_all(",\@import\s*url\s*\(\s*['\"]?([^'\"/][^:]*)['\"]?\s*\),Uims", $contenu, $regs); |
|
| 3033 | - $src = []; |
|
| 3034 | - $src_direction_css = []; |
|
| 3035 | - $src_faux_abs = []; |
|
| 3036 | - $d = dirname($css); |
|
| 3037 | - foreach ($regs[1] as $k => $import_css) { |
|
| 3038 | - $css_direction = direction_css("$d/$import_css", $voulue); |
|
| 3039 | - // si la css_direction est dans le meme path que la css d'origine, on tronque le path, elle sera passee en absolue |
|
| 3040 | - if (substr($css_direction, 0, strlen($d) + 1) == "$d/") { |
|
| 3041 | - $css_direction = substr($css_direction, strlen($d) + 1); |
|
| 3042 | - } // si la css_direction commence par $dir_var on la fait passer pour une absolue |
|
| 3043 | - elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) { |
|
| 3044 | - $css_direction = substr($css_direction, strlen($dir_var)); |
|
| 3045 | - $src_faux_abs['/@@@@@@/' . $css_direction] = $css_direction; |
|
| 3046 | - $css_direction = '/@@@@@@/' . $css_direction; |
|
| 3047 | - } |
|
| 3048 | - $src[] = $regs[0][$k]; |
|
| 3049 | - $src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]); |
|
| 3050 | - } |
|
| 3051 | - $contenu = str_replace($src, $src_direction_css, $contenu); |
|
| 3052 | - |
|
| 3053 | - $contenu = urls_absolues_css($contenu, $css); |
|
| 3054 | - |
|
| 3055 | - // virer les fausses url absolues que l'on a mis dans les import |
|
| 3056 | - if (count($src_faux_abs)) { |
|
| 3057 | - $contenu = str_replace(array_keys($src_faux_abs), $src_faux_abs, $contenu); |
|
| 3058 | - } |
|
| 3059 | - |
|
| 3060 | - if (!ecrire_fichier($f, $contenu)) { |
|
| 3061 | - return $css; |
|
| 3062 | - } |
|
| 3063 | - |
|
| 3064 | - return $f; |
|
| 2952 | + if (!preg_match(',(_rtl)?\.css$,i', $css, $r)) { |
|
| 2953 | + return $css; |
|
| 2954 | + } |
|
| 2955 | + include_spip('inc/lang'); |
|
| 2956 | + // si on a precise le sens voulu en argument, le prendre en compte |
|
| 2957 | + if ($voulue = strtolower($voulue)) { |
|
| 2958 | + if ($voulue != 'rtl' and $voulue != 'ltr') { |
|
| 2959 | + $voulue = lang_dir($voulue); |
|
| 2960 | + } |
|
| 2961 | + } else { |
|
| 2962 | + $voulue = lang_dir(); |
|
| 2963 | + } |
|
| 2964 | + |
|
| 2965 | + $r = count($r) > 1; |
|
| 2966 | + $right = $r ? 'left' : 'right'; // 'right' de la css lue en entree |
|
| 2967 | + $dir = $r ? 'rtl' : 'ltr'; |
|
| 2968 | + $ndir = $r ? 'ltr' : 'rtl'; |
|
| 2969 | + |
|
| 2970 | + if ($voulue == $dir) { |
|
| 2971 | + return $css; |
|
| 2972 | + } |
|
| 2973 | + |
|
| 2974 | + if ( |
|
| 2975 | + // url absolue |
|
| 2976 | + preg_match(',^https?:,i', $css) |
|
| 2977 | + // ou qui contient un ? |
|
| 2978 | + or (($p = strpos($css, '?')) !== false) |
|
| 2979 | + ) { |
|
| 2980 | + $distant = true; |
|
| 2981 | + $cssf = parse_url($css); |
|
| 2982 | + $cssf = $cssf['path'] . ($cssf['query'] ? '?' . $cssf['query'] : ''); |
|
| 2983 | + $cssf = preg_replace(',[?:&=],', '_', $cssf); |
|
| 2984 | + } else { |
|
| 2985 | + $distant = false; |
|
| 2986 | + $cssf = $css; |
|
| 2987 | + // 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi |
|
| 2988 | + //propose (rien a faire dans ce cas) |
|
| 2989 | + $f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css); |
|
| 2990 | + if (@file_exists($f)) { |
|
| 2991 | + return $f; |
|
| 2992 | + } |
|
| 2993 | + } |
|
| 2994 | + |
|
| 2995 | + // 2. |
|
| 2996 | + $dir_var = sous_repertoire(_DIR_VAR, 'cache-css'); |
|
| 2997 | + $f = $dir_var |
|
| 2998 | + . preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf) |
|
| 2999 | + . '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css'; |
|
| 3000 | + |
|
| 3001 | + // la css peut etre distante (url absolue !) |
|
| 3002 | + if ($distant) { |
|
| 3003 | + include_spip('inc/distant'); |
|
| 3004 | + $res = recuperer_url($css); |
|
| 3005 | + if (!$res or !$contenu = $res['page']) { |
|
| 3006 | + return $css; |
|
| 3007 | + } |
|
| 3008 | + } else { |
|
| 3009 | + if ( |
|
| 3010 | + (@filemtime($f) > @filemtime($css)) |
|
| 3011 | + and (_VAR_MODE != 'recalcul') |
|
| 3012 | + ) { |
|
| 3013 | + return $f; |
|
| 3014 | + } |
|
| 3015 | + if (!lire_fichier($css, $contenu)) { |
|
| 3016 | + return $css; |
|
| 3017 | + } |
|
| 3018 | + } |
|
| 3019 | + |
|
| 3020 | + |
|
| 3021 | + // Inverser la direction gauche-droite en utilisant CSSTidy qui gere aussi les shorthands |
|
| 3022 | + include_spip('lib/csstidy/class.csstidy'); |
|
| 3023 | + $parser = new csstidy(); |
|
| 3024 | + $parser->set_cfg('optimise_shorthands', 0); |
|
| 3025 | + $parser->set_cfg('reverse_left_and_right', true); |
|
| 3026 | + $parser->parse($contenu); |
|
| 3027 | + |
|
| 3028 | + $contenu = $parser->print->plain(); |
|
| 3029 | + |
|
| 3030 | + |
|
| 3031 | + // reperer les @import auxquels il faut propager le direction_css |
|
| 3032 | + preg_match_all(",\@import\s*url\s*\(\s*['\"]?([^'\"/][^:]*)['\"]?\s*\),Uims", $contenu, $regs); |
|
| 3033 | + $src = []; |
|
| 3034 | + $src_direction_css = []; |
|
| 3035 | + $src_faux_abs = []; |
|
| 3036 | + $d = dirname($css); |
|
| 3037 | + foreach ($regs[1] as $k => $import_css) { |
|
| 3038 | + $css_direction = direction_css("$d/$import_css", $voulue); |
|
| 3039 | + // si la css_direction est dans le meme path que la css d'origine, on tronque le path, elle sera passee en absolue |
|
| 3040 | + if (substr($css_direction, 0, strlen($d) + 1) == "$d/") { |
|
| 3041 | + $css_direction = substr($css_direction, strlen($d) + 1); |
|
| 3042 | + } // si la css_direction commence par $dir_var on la fait passer pour une absolue |
|
| 3043 | + elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) { |
|
| 3044 | + $css_direction = substr($css_direction, strlen($dir_var)); |
|
| 3045 | + $src_faux_abs['/@@@@@@/' . $css_direction] = $css_direction; |
|
| 3046 | + $css_direction = '/@@@@@@/' . $css_direction; |
|
| 3047 | + } |
|
| 3048 | + $src[] = $regs[0][$k]; |
|
| 3049 | + $src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]); |
|
| 3050 | + } |
|
| 3051 | + $contenu = str_replace($src, $src_direction_css, $contenu); |
|
| 3052 | + |
|
| 3053 | + $contenu = urls_absolues_css($contenu, $css); |
|
| 3054 | + |
|
| 3055 | + // virer les fausses url absolues que l'on a mis dans les import |
|
| 3056 | + if (count($src_faux_abs)) { |
|
| 3057 | + $contenu = str_replace(array_keys($src_faux_abs), $src_faux_abs, $contenu); |
|
| 3058 | + } |
|
| 3059 | + |
|
| 3060 | + if (!ecrire_fichier($f, $contenu)) { |
|
| 3061 | + return $css; |
|
| 3062 | + } |
|
| 3063 | + |
|
| 3064 | + return $f; |
|
| 3065 | 3065 | } |
| 3066 | 3066 | |
| 3067 | 3067 | |
@@ -3084,46 +3084,46 @@ discard block |
||
| 3084 | 3084 | * - Chemin ou URL du fichier CSS source sinon. |
| 3085 | 3085 | **/ |
| 3086 | 3086 | function url_absolue_css($css) { |
| 3087 | - if (!preg_match(',\.css$,i', $css, $r)) { |
|
| 3088 | - return $css; |
|
| 3089 | - } |
|
| 3087 | + if (!preg_match(',\.css$,i', $css, $r)) { |
|
| 3088 | + return $css; |
|
| 3089 | + } |
|
| 3090 | 3090 | |
| 3091 | - $url_absolue_css = url_absolue($css); |
|
| 3091 | + $url_absolue_css = url_absolue($css); |
|
| 3092 | 3092 | |
| 3093 | - $f = basename($css, '.css'); |
|
| 3094 | - $f = sous_repertoire(_DIR_VAR, 'cache-css') |
|
| 3095 | - . preg_replace(',(.*?)(_rtl|_ltr)?$,', "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f) |
|
| 3096 | - . '.css'; |
|
| 3093 | + $f = basename($css, '.css'); |
|
| 3094 | + $f = sous_repertoire(_DIR_VAR, 'cache-css') |
|
| 3095 | + . preg_replace(',(.*?)(_rtl|_ltr)?$,', "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f) |
|
| 3096 | + . '.css'; |
|
| 3097 | 3097 | |
| 3098 | - if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) { |
|
| 3099 | - return $f; |
|
| 3100 | - } |
|
| 3098 | + if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) { |
|
| 3099 | + return $f; |
|
| 3100 | + } |
|
| 3101 | 3101 | |
| 3102 | - if ($url_absolue_css == $css) { |
|
| 3103 | - if ( |
|
| 3104 | - strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0 |
|
| 3105 | - or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu) |
|
| 3106 | - ) { |
|
| 3107 | - include_spip('inc/distant'); |
|
| 3108 | - $contenu = recuperer_url($css); |
|
| 3109 | - $contenu = $contenu['page'] ?? ''; |
|
| 3110 | - if (!$contenu) { |
|
| 3111 | - return $css; |
|
| 3112 | - } |
|
| 3113 | - } |
|
| 3114 | - } elseif (!lire_fichier($css, $contenu)) { |
|
| 3115 | - return $css; |
|
| 3116 | - } |
|
| 3102 | + if ($url_absolue_css == $css) { |
|
| 3103 | + if ( |
|
| 3104 | + strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0 |
|
| 3105 | + or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu) |
|
| 3106 | + ) { |
|
| 3107 | + include_spip('inc/distant'); |
|
| 3108 | + $contenu = recuperer_url($css); |
|
| 3109 | + $contenu = $contenu['page'] ?? ''; |
|
| 3110 | + if (!$contenu) { |
|
| 3111 | + return $css; |
|
| 3112 | + } |
|
| 3113 | + } |
|
| 3114 | + } elseif (!lire_fichier($css, $contenu)) { |
|
| 3115 | + return $css; |
|
| 3116 | + } |
|
| 3117 | 3117 | |
| 3118 | - // passer les url relatives a la css d'origine en url absolues |
|
| 3119 | - $contenu = urls_absolues_css($contenu, $css); |
|
| 3118 | + // passer les url relatives a la css d'origine en url absolues |
|
| 3119 | + $contenu = urls_absolues_css($contenu, $css); |
|
| 3120 | 3120 | |
| 3121 | - // ecrire la css |
|
| 3122 | - if (!ecrire_fichier($f, $contenu)) { |
|
| 3123 | - return $css; |
|
| 3124 | - } |
|
| 3121 | + // ecrire la css |
|
| 3122 | + if (!ecrire_fichier($f, $contenu)) { |
|
| 3123 | + return $css; |
|
| 3124 | + } |
|
| 3125 | 3125 | |
| 3126 | - return $f; |
|
| 3126 | + return $f; |
|
| 3127 | 3127 | } |
| 3128 | 3128 | |
| 3129 | 3129 | |
@@ -3157,24 +3157,24 @@ discard block |
||
| 3157 | 3157 | * Valeur trouvée ou valeur par défaut. |
| 3158 | 3158 | **/ |
| 3159 | 3159 | function table_valeur($table, $cle, $defaut = '', $conserver_null = false) { |
| 3160 | - foreach (explode('/', $cle) as $k) { |
|
| 3161 | - $table = (is_string($table) ? @unserialize($table) : $table); |
|
| 3160 | + foreach (explode('/', $cle) as $k) { |
|
| 3161 | + $table = (is_string($table) ? @unserialize($table) : $table); |
|
| 3162 | 3162 | |
| 3163 | - if (is_object($table)) { |
|
| 3164 | - $table = (($k !== '') and isset($table->$k)) ? $table->$k : $defaut; |
|
| 3165 | - } elseif (is_array($table)) { |
|
| 3166 | - if ($conserver_null) { |
|
| 3167 | - $table = array_key_exists($k, $table) ? $table[$k] : $defaut; |
|
| 3168 | - } else { |
|
| 3169 | - $table = ($table[$k] ?? $defaut); |
|
| 3170 | - } |
|
| 3171 | - } else { |
|
| 3172 | - $table = $defaut; |
|
| 3173 | - break; |
|
| 3174 | - } |
|
| 3175 | - } |
|
| 3163 | + if (is_object($table)) { |
|
| 3164 | + $table = (($k !== '') and isset($table->$k)) ? $table->$k : $defaut; |
|
| 3165 | + } elseif (is_array($table)) { |
|
| 3166 | + if ($conserver_null) { |
|
| 3167 | + $table = array_key_exists($k, $table) ? $table[$k] : $defaut; |
|
| 3168 | + } else { |
|
| 3169 | + $table = ($table[$k] ?? $defaut); |
|
| 3170 | + } |
|
| 3171 | + } else { |
|
| 3172 | + $table = $defaut; |
|
| 3173 | + break; |
|
| 3174 | + } |
|
| 3175 | + } |
|
| 3176 | 3176 | |
| 3177 | - return $table; |
|
| 3177 | + return $table; |
|
| 3178 | 3178 | } |
| 3179 | 3179 | |
| 3180 | 3180 | /** |
@@ -3207,22 +3207,22 @@ discard block |
||
| 3207 | 3207 | * - string : expression trouvée. |
| 3208 | 3208 | **/ |
| 3209 | 3209 | function filtre_match_dist(?string $texte, $expression, $modif = 'UimsS', $capte = 0) { |
| 3210 | - if (intval($modif) and $capte == 0) { |
|
| 3211 | - $capte = $modif; |
|
| 3212 | - $modif = 'UimsS'; |
|
| 3213 | - } |
|
| 3214 | - $expression = str_replace('\/', '/', $expression); |
|
| 3215 | - $expression = str_replace('/', '\/', $expression); |
|
| 3210 | + if (intval($modif) and $capte == 0) { |
|
| 3211 | + $capte = $modif; |
|
| 3212 | + $modif = 'UimsS'; |
|
| 3213 | + } |
|
| 3214 | + $expression = str_replace('\/', '/', $expression); |
|
| 3215 | + $expression = str_replace('/', '\/', $expression); |
|
| 3216 | 3216 | |
| 3217 | - if (preg_match('/' . $expression . '/' . $modif, $texte ?? '', $r)) { |
|
| 3218 | - if (isset($r[$capte])) { |
|
| 3219 | - return $r[$capte]; |
|
| 3220 | - } else { |
|
| 3221 | - return true; |
|
| 3222 | - } |
|
| 3223 | - } |
|
| 3217 | + if (preg_match('/' . $expression . '/' . $modif, $texte ?? '', $r)) { |
|
| 3218 | + if (isset($r[$capte])) { |
|
| 3219 | + return $r[$capte]; |
|
| 3220 | + } else { |
|
| 3221 | + return true; |
|
| 3222 | + } |
|
| 3223 | + } |
|
| 3224 | 3224 | |
| 3225 | - return false; |
|
| 3225 | + return false; |
|
| 3226 | 3226 | } |
| 3227 | 3227 | |
| 3228 | 3228 | |
@@ -3249,10 +3249,10 @@ discard block |
||
| 3249 | 3249 | * Texte |
| 3250 | 3250 | **/ |
| 3251 | 3251 | function replace($texte, $expression, $replace = '', $modif = 'UimsS') { |
| 3252 | - $expression = str_replace('\/', '/', $expression); |
|
| 3253 | - $expression = str_replace('/', '\/', $expression); |
|
| 3252 | + $expression = str_replace('\/', '/', $expression); |
|
| 3253 | + $expression = str_replace('/', '\/', $expression); |
|
| 3254 | 3254 | |
| 3255 | - return preg_replace('/' . $expression . '/' . $modif, $replace, $texte); |
|
| 3255 | + return preg_replace('/' . $expression . '/' . $modif, $replace, $texte); |
|
| 3256 | 3256 | } |
| 3257 | 3257 | |
| 3258 | 3258 | |
@@ -3270,25 +3270,25 @@ discard block |
||
| 3270 | 3270 | **/ |
| 3271 | 3271 | function traiter_doublons_documents(&$doublons, $letexte) { |
| 3272 | 3272 | |
| 3273 | - // Verifier dans le texte & les notes (pas beau, helas) |
|
| 3274 | - $t = $letexte . $GLOBALS['les_notes']; |
|
| 3273 | + // Verifier dans le texte & les notes (pas beau, helas) |
|
| 3274 | + $t = $letexte . $GLOBALS['les_notes']; |
|
| 3275 | 3275 | |
| 3276 | - if ( |
|
| 3277 | - strstr($t, 'spip_document_') // evite le preg_match_all si inutile |
|
| 3278 | - and preg_match_all( |
|
| 3279 | - ',<[^>]+\sclass=["\']spip_document_([0-9]+)[\s"\'],imsS', |
|
| 3280 | - $t, |
|
| 3281 | - $matches, |
|
| 3282 | - PREG_PATTERN_ORDER |
|
| 3283 | - ) |
|
| 3284 | - ) { |
|
| 3285 | - if (!isset($doublons['documents'])) { |
|
| 3286 | - $doublons['documents'] = ''; |
|
| 3287 | - } |
|
| 3288 | - $doublons['documents'] .= ',' . join(',', $matches[1]); |
|
| 3289 | - } |
|
| 3276 | + if ( |
|
| 3277 | + strstr($t, 'spip_document_') // evite le preg_match_all si inutile |
|
| 3278 | + and preg_match_all( |
|
| 3279 | + ',<[^>]+\sclass=["\']spip_document_([0-9]+)[\s"\'],imsS', |
|
| 3280 | + $t, |
|
| 3281 | + $matches, |
|
| 3282 | + PREG_PATTERN_ORDER |
|
| 3283 | + ) |
|
| 3284 | + ) { |
|
| 3285 | + if (!isset($doublons['documents'])) { |
|
| 3286 | + $doublons['documents'] = ''; |
|
| 3287 | + } |
|
| 3288 | + $doublons['documents'] .= ',' . join(',', $matches[1]); |
|
| 3289 | + } |
|
| 3290 | 3290 | |
| 3291 | - return $letexte; |
|
| 3291 | + return $letexte; |
|
| 3292 | 3292 | } |
| 3293 | 3293 | |
| 3294 | 3294 | /** |
@@ -3302,7 +3302,7 @@ discard block |
||
| 3302 | 3302 | * @return string Chaîne vide |
| 3303 | 3303 | **/ |
| 3304 | 3304 | function vide($texte) { |
| 3305 | - return ''; |
|
| 3305 | + return ''; |
|
| 3306 | 3306 | } |
| 3307 | 3307 | |
| 3308 | 3308 | // |
@@ -3331,23 +3331,23 @@ discard block |
||
| 3331 | 3331 | * Code HTML résultant |
| 3332 | 3332 | **/ |
| 3333 | 3333 | function env_to_params($env, $ignore_params = []) { |
| 3334 | - $ignore_params = array_merge( |
|
| 3335 | - ['id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'], |
|
| 3336 | - $ignore_params |
|
| 3337 | - ); |
|
| 3338 | - if (!is_array($env)) { |
|
| 3339 | - $env = unserialize($env); |
|
| 3340 | - } |
|
| 3341 | - $texte = ''; |
|
| 3342 | - if ($env) { |
|
| 3343 | - foreach ($env as $i => $j) { |
|
| 3344 | - if (is_string($j) and !in_array($i, $ignore_params)) { |
|
| 3345 | - $texte .= "<param name='" . attribut_html($i) . "'\n\tvalue='" . attribut_html($j) . "' />"; |
|
| 3346 | - } |
|
| 3347 | - } |
|
| 3348 | - } |
|
| 3349 | - |
|
| 3350 | - return $texte; |
|
| 3334 | + $ignore_params = array_merge( |
|
| 3335 | + ['id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'], |
|
| 3336 | + $ignore_params |
|
| 3337 | + ); |
|
| 3338 | + if (!is_array($env)) { |
|
| 3339 | + $env = unserialize($env); |
|
| 3340 | + } |
|
| 3341 | + $texte = ''; |
|
| 3342 | + if ($env) { |
|
| 3343 | + foreach ($env as $i => $j) { |
|
| 3344 | + if (is_string($j) and !in_array($i, $ignore_params)) { |
|
| 3345 | + $texte .= "<param name='" . attribut_html($i) . "'\n\tvalue='" . attribut_html($j) . "' />"; |
|
| 3346 | + } |
|
| 3347 | + } |
|
| 3348 | + } |
|
| 3349 | + |
|
| 3350 | + return $texte; |
|
| 3351 | 3351 | } |
| 3352 | 3352 | |
| 3353 | 3353 | /** |
@@ -3370,23 +3370,23 @@ discard block |
||
| 3370 | 3370 | * Code HTML résultant |
| 3371 | 3371 | **/ |
| 3372 | 3372 | function env_to_attributs($env, $ignore_params = []) { |
| 3373 | - $ignore_params = array_merge( |
|
| 3374 | - ['id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'], |
|
| 3375 | - $ignore_params |
|
| 3376 | - ); |
|
| 3377 | - if (!is_array($env)) { |
|
| 3378 | - $env = unserialize($env); |
|
| 3379 | - } |
|
| 3380 | - $texte = ''; |
|
| 3381 | - if ($env) { |
|
| 3382 | - foreach ($env as $i => $j) { |
|
| 3383 | - if (is_string($j) and !in_array($i, $ignore_params)) { |
|
| 3384 | - $texte .= attribut_html($i) . "='" . attribut_html($j) . "' "; |
|
| 3385 | - } |
|
| 3386 | - } |
|
| 3387 | - } |
|
| 3373 | + $ignore_params = array_merge( |
|
| 3374 | + ['id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'], |
|
| 3375 | + $ignore_params |
|
| 3376 | + ); |
|
| 3377 | + if (!is_array($env)) { |
|
| 3378 | + $env = unserialize($env); |
|
| 3379 | + } |
|
| 3380 | + $texte = ''; |
|
| 3381 | + if ($env) { |
|
| 3382 | + foreach ($env as $i => $j) { |
|
| 3383 | + if (is_string($j) and !in_array($i, $ignore_params)) { |
|
| 3384 | + $texte .= attribut_html($i) . "='" . attribut_html($j) . "' "; |
|
| 3385 | + } |
|
| 3386 | + } |
|
| 3387 | + } |
|
| 3388 | 3388 | |
| 3389 | - return $texte; |
|
| 3389 | + return $texte; |
|
| 3390 | 3390 | } |
| 3391 | 3391 | |
| 3392 | 3392 | |
@@ -3404,7 +3404,7 @@ discard block |
||
| 3404 | 3404 | * @return string Chaînes concaténés |
| 3405 | 3405 | **/ |
| 3406 | 3406 | function concat(...$args): string { |
| 3407 | - return join('', $args); |
|
| 3407 | + return join('', $args); |
|
| 3408 | 3408 | } |
| 3409 | 3409 | |
| 3410 | 3410 | |
@@ -3424,23 +3424,23 @@ discard block |
||
| 3424 | 3424 | * Contenu du ou des fichiers, concaténé |
| 3425 | 3425 | **/ |
| 3426 | 3426 | function charge_scripts($files, $script = true) { |
| 3427 | - $flux = ''; |
|
| 3428 | - foreach (is_array($files) ? $files : explode('|', $files) as $file) { |
|
| 3429 | - if (!is_string($file)) { |
|
| 3430 | - continue; |
|
| 3431 | - } |
|
| 3432 | - if ($script) { |
|
| 3433 | - $file = preg_match(',^\w+$,', $file) ? "javascript/$file.js" : ''; |
|
| 3434 | - } |
|
| 3435 | - if ($file) { |
|
| 3436 | - $path = find_in_path($file); |
|
| 3437 | - if ($path) { |
|
| 3438 | - $flux .= spip_file_get_contents($path); |
|
| 3439 | - } |
|
| 3440 | - } |
|
| 3441 | - } |
|
| 3442 | - |
|
| 3443 | - return $flux; |
|
| 3427 | + $flux = ''; |
|
| 3428 | + foreach (is_array($files) ? $files : explode('|', $files) as $file) { |
|
| 3429 | + if (!is_string($file)) { |
|
| 3430 | + continue; |
|
| 3431 | + } |
|
| 3432 | + if ($script) { |
|
| 3433 | + $file = preg_match(',^\w+$,', $file) ? "javascript/$file.js" : ''; |
|
| 3434 | + } |
|
| 3435 | + if ($file) { |
|
| 3436 | + $path = find_in_path($file); |
|
| 3437 | + if ($path) { |
|
| 3438 | + $flux .= spip_file_get_contents($path); |
|
| 3439 | + } |
|
| 3440 | + } |
|
| 3441 | + } |
|
| 3442 | + |
|
| 3443 | + return $flux; |
|
| 3444 | 3444 | } |
| 3445 | 3445 | |
| 3446 | 3446 | /** |
@@ -3451,22 +3451,22 @@ discard block |
||
| 3451 | 3451 | * @return string |
| 3452 | 3452 | */ |
| 3453 | 3453 | function http_img_variante_svg_si_possible($img_file) { |
| 3454 | - // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png |
|
| 3455 | - // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png |
|
| 3456 | - if ( |
|
| 3457 | - preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m) |
|
| 3458 | - and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . '-xx.svg' |
|
| 3459 | - and file_exists($variante_svg_generique) |
|
| 3460 | - ) { |
|
| 3461 | - if ($variante_svg_size = substr($variante_svg_generique, 0, -6) . $m[1] . '.svg' and file_exists($variante_svg_size)) { |
|
| 3462 | - $img_file = $variante_svg_size; |
|
| 3463 | - } |
|
| 3464 | - else { |
|
| 3465 | - $img_file = $variante_svg_generique; |
|
| 3466 | - } |
|
| 3467 | - } |
|
| 3454 | + // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png |
|
| 3455 | + // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png |
|
| 3456 | + if ( |
|
| 3457 | + preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m) |
|
| 3458 | + and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . '-xx.svg' |
|
| 3459 | + and file_exists($variante_svg_generique) |
|
| 3460 | + ) { |
|
| 3461 | + if ($variante_svg_size = substr($variante_svg_generique, 0, -6) . $m[1] . '.svg' and file_exists($variante_svg_size)) { |
|
| 3462 | + $img_file = $variante_svg_size; |
|
| 3463 | + } |
|
| 3464 | + else { |
|
| 3465 | + $img_file = $variante_svg_generique; |
|
| 3466 | + } |
|
| 3467 | + } |
|
| 3468 | 3468 | |
| 3469 | - return $img_file; |
|
| 3469 | + return $img_file; |
|
| 3470 | 3470 | } |
| 3471 | 3471 | |
| 3472 | 3472 | /** |
@@ -3487,54 +3487,54 @@ discard block |
||
| 3487 | 3487 | */ |
| 3488 | 3488 | function http_img_pack($img, $alt, $atts = '', $title = '', $options = []) { |
| 3489 | 3489 | |
| 3490 | - $img_file = $img; |
|
| 3491 | - if ($p = strpos($img_file, '?')) { |
|
| 3492 | - $img_file = substr($img_file, 0, $p); |
|
| 3493 | - } |
|
| 3494 | - if (!isset($options['chemin_image']) or $options['chemin_image'] == true) { |
|
| 3495 | - $img_file = chemin_image($img); |
|
| 3496 | - } |
|
| 3497 | - else { |
|
| 3498 | - if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true) { |
|
| 3499 | - $img_file = http_img_variante_svg_si_possible($img_file); |
|
| 3500 | - } |
|
| 3501 | - } |
|
| 3502 | - if (stripos($atts, 'width') === false) { |
|
| 3503 | - // utiliser directement l'info de taille presente dans le nom |
|
| 3504 | - if ( |
|
| 3505 | - (!isset($options['utiliser_suffixe_size']) |
|
| 3506 | - or $options['utiliser_suffixe_size'] == true |
|
| 3507 | - or strpos($img_file, '-xx.svg') !== false) |
|
| 3508 | - and (preg_match(',-([0-9]+)[.](png|gif|svg)$,', $img, $regs) |
|
| 3509 | - or preg_match(',\?([0-9]+)px$,', $img, $regs)) |
|
| 3510 | - ) { |
|
| 3511 | - $largeur = $hauteur = intval($regs[1]); |
|
| 3512 | - } else { |
|
| 3513 | - $taille = taille_image($img_file); |
|
| 3514 | - [$hauteur, $largeur] = $taille; |
|
| 3515 | - if (!$hauteur or !$largeur) { |
|
| 3516 | - return ''; |
|
| 3517 | - } |
|
| 3518 | - } |
|
| 3519 | - $atts .= " width='" . $largeur . "' height='" . $hauteur . "'"; |
|
| 3520 | - } |
|
| 3521 | - |
|
| 3522 | - if (file_exists($img_file)) { |
|
| 3523 | - $img_file = timestamp($img_file); |
|
| 3524 | - } |
|
| 3525 | - if ($alt === false) { |
|
| 3526 | - $alt = ''; |
|
| 3527 | - } |
|
| 3528 | - elseif ($alt or $alt === '') { |
|
| 3529 | - $alt = " alt='" . attribut_html($alt) . "'"; |
|
| 3530 | - } |
|
| 3531 | - else { |
|
| 3532 | - $alt = " alt='" . attribut_html($title) . "'"; |
|
| 3533 | - } |
|
| 3534 | - return "<img src='$img_file'$alt" |
|
| 3535 | - . ($title ? ' title="' . attribut_html($title) . '"' : '') |
|
| 3536 | - . ' ' . ltrim($atts) |
|
| 3537 | - . ' />'; |
|
| 3490 | + $img_file = $img; |
|
| 3491 | + if ($p = strpos($img_file, '?')) { |
|
| 3492 | + $img_file = substr($img_file, 0, $p); |
|
| 3493 | + } |
|
| 3494 | + if (!isset($options['chemin_image']) or $options['chemin_image'] == true) { |
|
| 3495 | + $img_file = chemin_image($img); |
|
| 3496 | + } |
|
| 3497 | + else { |
|
| 3498 | + if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true) { |
|
| 3499 | + $img_file = http_img_variante_svg_si_possible($img_file); |
|
| 3500 | + } |
|
| 3501 | + } |
|
| 3502 | + if (stripos($atts, 'width') === false) { |
|
| 3503 | + // utiliser directement l'info de taille presente dans le nom |
|
| 3504 | + if ( |
|
| 3505 | + (!isset($options['utiliser_suffixe_size']) |
|
| 3506 | + or $options['utiliser_suffixe_size'] == true |
|
| 3507 | + or strpos($img_file, '-xx.svg') !== false) |
|
| 3508 | + and (preg_match(',-([0-9]+)[.](png|gif|svg)$,', $img, $regs) |
|
| 3509 | + or preg_match(',\?([0-9]+)px$,', $img, $regs)) |
|
| 3510 | + ) { |
|
| 3511 | + $largeur = $hauteur = intval($regs[1]); |
|
| 3512 | + } else { |
|
| 3513 | + $taille = taille_image($img_file); |
|
| 3514 | + [$hauteur, $largeur] = $taille; |
|
| 3515 | + if (!$hauteur or !$largeur) { |
|
| 3516 | + return ''; |
|
| 3517 | + } |
|
| 3518 | + } |
|
| 3519 | + $atts .= " width='" . $largeur . "' height='" . $hauteur . "'"; |
|
| 3520 | + } |
|
| 3521 | + |
|
| 3522 | + if (file_exists($img_file)) { |
|
| 3523 | + $img_file = timestamp($img_file); |
|
| 3524 | + } |
|
| 3525 | + if ($alt === false) { |
|
| 3526 | + $alt = ''; |
|
| 3527 | + } |
|
| 3528 | + elseif ($alt or $alt === '') { |
|
| 3529 | + $alt = " alt='" . attribut_html($alt) . "'"; |
|
| 3530 | + } |
|
| 3531 | + else { |
|
| 3532 | + $alt = " alt='" . attribut_html($title) . "'"; |
|
| 3533 | + } |
|
| 3534 | + return "<img src='$img_file'$alt" |
|
| 3535 | + . ($title ? ' title="' . attribut_html($title) . '"' : '') |
|
| 3536 | + . ' ' . ltrim($atts) |
|
| 3537 | + . ' />'; |
|
| 3538 | 3538 | } |
| 3539 | 3539 | |
| 3540 | 3540 | /** |
@@ -3546,70 +3546,70 @@ discard block |
||
| 3546 | 3546 | * @return string |
| 3547 | 3547 | */ |
| 3548 | 3548 | function http_style_background($img, $att = '', $size = null) { |
| 3549 | - if ($size and is_numeric($size)) { |
|
| 3550 | - $size = trim($size) . 'px'; |
|
| 3551 | - } |
|
| 3552 | - return " style='background" . |
|
| 3553 | - ($att ? '' : '-image') . ': url("' . chemin_image($img) . '")' . ($att ? (' ' . $att) : '') . ';' |
|
| 3554 | - . ($size ? "background-size:{$size};" : '') |
|
| 3555 | - . "'"; |
|
| 3549 | + if ($size and is_numeric($size)) { |
|
| 3550 | + $size = trim($size) . 'px'; |
|
| 3551 | + } |
|
| 3552 | + return " style='background" . |
|
| 3553 | + ($att ? '' : '-image') . ': url("' . chemin_image($img) . '")' . ($att ? (' ' . $att) : '') . ';' |
|
| 3554 | + . ($size ? "background-size:{$size};" : '') |
|
| 3555 | + . "'"; |
|
| 3556 | 3556 | } |
| 3557 | 3557 | |
| 3558 | 3558 | |
| 3559 | 3559 | function helper_filtre_balise_img_svg_arguments($alt_or_size, $class_or_size, $size) { |
| 3560 | - $args = [$alt_or_size, $class_or_size, $size]; |
|
| 3561 | - while (is_null(end($args)) and count($args)) { |
|
| 3562 | - array_pop($args); |
|
| 3563 | - } |
|
| 3564 | - if (!count($args)) { |
|
| 3565 | - return [null, null, null]; |
|
| 3566 | - } |
|
| 3567 | - if (count($args) < 3) { |
|
| 3568 | - $maybe_size = array_pop($args); |
|
| 3569 | - // @2x |
|
| 3570 | - // @1.5x |
|
| 3571 | - // 512 |
|
| 3572 | - // 512x* |
|
| 3573 | - // 512x300 |
|
| 3574 | - if ( |
|
| 3575 | - !strlen($maybe_size) |
|
| 3576 | - or !preg_match(',^(@\d+(\.\d+)?x|\d+(x\*)?|\d+x\d+)$,', trim($maybe_size)) |
|
| 3577 | - ) { |
|
| 3578 | - $args[] = $maybe_size; |
|
| 3579 | - $maybe_size = null; |
|
| 3580 | - } |
|
| 3581 | - while (count($args) < 2) { |
|
| 3582 | - $args[] = null; // default alt or class |
|
| 3583 | - } |
|
| 3584 | - $args[] = $maybe_size; |
|
| 3585 | - } |
|
| 3586 | - return $args; |
|
| 3560 | + $args = [$alt_or_size, $class_or_size, $size]; |
|
| 3561 | + while (is_null(end($args)) and count($args)) { |
|
| 3562 | + array_pop($args); |
|
| 3563 | + } |
|
| 3564 | + if (!count($args)) { |
|
| 3565 | + return [null, null, null]; |
|
| 3566 | + } |
|
| 3567 | + if (count($args) < 3) { |
|
| 3568 | + $maybe_size = array_pop($args); |
|
| 3569 | + // @2x |
|
| 3570 | + // @1.5x |
|
| 3571 | + // 512 |
|
| 3572 | + // 512x* |
|
| 3573 | + // 512x300 |
|
| 3574 | + if ( |
|
| 3575 | + !strlen($maybe_size) |
|
| 3576 | + or !preg_match(',^(@\d+(\.\d+)?x|\d+(x\*)?|\d+x\d+)$,', trim($maybe_size)) |
|
| 3577 | + ) { |
|
| 3578 | + $args[] = $maybe_size; |
|
| 3579 | + $maybe_size = null; |
|
| 3580 | + } |
|
| 3581 | + while (count($args) < 2) { |
|
| 3582 | + $args[] = null; // default alt or class |
|
| 3583 | + } |
|
| 3584 | + $args[] = $maybe_size; |
|
| 3585 | + } |
|
| 3586 | + return $args; |
|
| 3587 | 3587 | } |
| 3588 | 3588 | |
| 3589 | 3589 | function helper_filtre_balise_img_svg_size($img, $size) { |
| 3590 | - // si size est de la forme '@2x' c'est un coeff multiplicateur sur la densite |
|
| 3591 | - if (strpos($size, '@') === 0 and substr($size, -1) === 'x') { |
|
| 3592 | - $coef = floatval(substr($size, 1, -1)); |
|
| 3593 | - [$h, $w] = taille_image($img); |
|
| 3594 | - $height = intval(round($h / $coef)); |
|
| 3595 | - $width = intval(round($w / $coef)); |
|
| 3596 | - } |
|
| 3597 | - // sinon c'est une valeur seule si image caree ou largeurxhauteur |
|
| 3598 | - else { |
|
| 3599 | - $size = explode('x', $size, 2); |
|
| 3600 | - $size = array_map('trim', $size); |
|
| 3601 | - $height = $width = intval(array_shift($size)); |
|
| 3602 | - |
|
| 3603 | - if (count($size) and reset($size)) { |
|
| 3604 | - $height = array_shift($size); |
|
| 3605 | - if ($height === '*') { |
|
| 3606 | - [$h, $w] = taille_image($img); |
|
| 3607 | - $height = intval(round($h * $width / $w)); |
|
| 3608 | - } |
|
| 3609 | - } |
|
| 3610 | - } |
|
| 3611 | - |
|
| 3612 | - return [$width, $height]; |
|
| 3590 | + // si size est de la forme '@2x' c'est un coeff multiplicateur sur la densite |
|
| 3591 | + if (strpos($size, '@') === 0 and substr($size, -1) === 'x') { |
|
| 3592 | + $coef = floatval(substr($size, 1, -1)); |
|
| 3593 | + [$h, $w] = taille_image($img); |
|
| 3594 | + $height = intval(round($h / $coef)); |
|
| 3595 | + $width = intval(round($w / $coef)); |
|
| 3596 | + } |
|
| 3597 | + // sinon c'est une valeur seule si image caree ou largeurxhauteur |
|
| 3598 | + else { |
|
| 3599 | + $size = explode('x', $size, 2); |
|
| 3600 | + $size = array_map('trim', $size); |
|
| 3601 | + $height = $width = intval(array_shift($size)); |
|
| 3602 | + |
|
| 3603 | + if (count($size) and reset($size)) { |
|
| 3604 | + $height = array_shift($size); |
|
| 3605 | + if ($height === '*') { |
|
| 3606 | + [$h, $w] = taille_image($img); |
|
| 3607 | + $height = intval(round($h * $width / $w)); |
|
| 3608 | + } |
|
| 3609 | + } |
|
| 3610 | + } |
|
| 3611 | + |
|
| 3612 | + return [$width, $height]; |
|
| 3613 | 3613 | } |
| 3614 | 3614 | |
| 3615 | 3615 | /** |
@@ -3645,43 +3645,43 @@ discard block |
||
| 3645 | 3645 | */ |
| 3646 | 3646 | function filtre_balise_img_dist($img, $alt = '', $class = null, $size = null) { |
| 3647 | 3647 | |
| 3648 | - [$alt, $class, $size] = helper_filtre_balise_img_svg_arguments($alt, $class, $size); |
|
| 3649 | - |
|
| 3650 | - $img = trim($img); |
|
| 3651 | - if (strpos($img, '<img') === 0) { |
|
| 3652 | - if (!is_null($alt)) { |
|
| 3653 | - $img = inserer_attribut($img, 'alt', $alt); |
|
| 3654 | - } |
|
| 3655 | - if (!is_null($class)) { |
|
| 3656 | - if (strlen($class)) { |
|
| 3657 | - $img = inserer_attribut($img, 'class', $class); |
|
| 3658 | - } |
|
| 3659 | - else { |
|
| 3660 | - $img = vider_attribut($img, 'class'); |
|
| 3661 | - } |
|
| 3662 | - } |
|
| 3663 | - } |
|
| 3664 | - else { |
|
| 3665 | - $img = http_img_pack( |
|
| 3666 | - $img, |
|
| 3667 | - $alt, |
|
| 3668 | - $class ? " class='" . attribut_html($class) . "'" : '', |
|
| 3669 | - '', |
|
| 3670 | - ['chemin_image' => false, 'utiliser_suffixe_size' => false] |
|
| 3671 | - ); |
|
| 3672 | - if (is_null($alt)) { |
|
| 3673 | - $img = vider_attribut($img, 'alt'); |
|
| 3674 | - } |
|
| 3675 | - } |
|
| 3676 | - |
|
| 3677 | - if ($img and !is_null($size) and strlen($size = trim($size))) { |
|
| 3678 | - [$width, $height] = helper_filtre_balise_img_svg_size($img, $size); |
|
| 3679 | - |
|
| 3680 | - $img = inserer_attribut($img, 'width', $width); |
|
| 3681 | - $img = inserer_attribut($img, 'height', $height); |
|
| 3682 | - } |
|
| 3683 | - |
|
| 3684 | - return $img; |
|
| 3648 | + [$alt, $class, $size] = helper_filtre_balise_img_svg_arguments($alt, $class, $size); |
|
| 3649 | + |
|
| 3650 | + $img = trim($img); |
|
| 3651 | + if (strpos($img, '<img') === 0) { |
|
| 3652 | + if (!is_null($alt)) { |
|
| 3653 | + $img = inserer_attribut($img, 'alt', $alt); |
|
| 3654 | + } |
|
| 3655 | + if (!is_null($class)) { |
|
| 3656 | + if (strlen($class)) { |
|
| 3657 | + $img = inserer_attribut($img, 'class', $class); |
|
| 3658 | + } |
|
| 3659 | + else { |
|
| 3660 | + $img = vider_attribut($img, 'class'); |
|
| 3661 | + } |
|
| 3662 | + } |
|
| 3663 | + } |
|
| 3664 | + else { |
|
| 3665 | + $img = http_img_pack( |
|
| 3666 | + $img, |
|
| 3667 | + $alt, |
|
| 3668 | + $class ? " class='" . attribut_html($class) . "'" : '', |
|
| 3669 | + '', |
|
| 3670 | + ['chemin_image' => false, 'utiliser_suffixe_size' => false] |
|
| 3671 | + ); |
|
| 3672 | + if (is_null($alt)) { |
|
| 3673 | + $img = vider_attribut($img, 'alt'); |
|
| 3674 | + } |
|
| 3675 | + } |
|
| 3676 | + |
|
| 3677 | + if ($img and !is_null($size) and strlen($size = trim($size))) { |
|
| 3678 | + [$width, $height] = helper_filtre_balise_img_svg_size($img, $size); |
|
| 3679 | + |
|
| 3680 | + $img = inserer_attribut($img, 'width', $width); |
|
| 3681 | + $img = inserer_attribut($img, 'height', $height); |
|
| 3682 | + } |
|
| 3683 | + |
|
| 3684 | + return $img; |
|
| 3685 | 3685 | } |
| 3686 | 3686 | |
| 3687 | 3687 | |
@@ -3715,80 +3715,80 @@ discard block |
||
| 3715 | 3715 | */ |
| 3716 | 3716 | function filtre_balise_svg_dist($img, $alt = '', $class = null, $size = null) { |
| 3717 | 3717 | |
| 3718 | - $svg = null; |
|
| 3719 | - $img = trim($img); |
|
| 3720 | - $img_file = $img; |
|
| 3721 | - if (strpos($img, '<svg') === false) { |
|
| 3722 | - if ($p = strpos($img_file, '?')) { |
|
| 3723 | - $img_file = substr($img_file, 0, $p); |
|
| 3724 | - } |
|
| 3725 | - |
|
| 3726 | - // ne jamais operer directement sur une image distante pour des raisons de perfo |
|
| 3727 | - // la copie locale a toutes les chances d'etre la ou de resservir |
|
| 3728 | - if (tester_url_absolue($img_file)) { |
|
| 3729 | - include_spip('inc/distant'); |
|
| 3730 | - $fichier = copie_locale($img_file); |
|
| 3731 | - $img_file = ($fichier ? _DIR_RACINE . $fichier : $img_file); |
|
| 3732 | - } |
|
| 3733 | - |
|
| 3734 | - if ( |
|
| 3735 | - !$img_file |
|
| 3736 | - or !file_exists($img_file) |
|
| 3737 | - or !$svg = file_get_contents($img_file) |
|
| 3738 | - ) { |
|
| 3739 | - return ''; |
|
| 3740 | - } |
|
| 3741 | - } |
|
| 3742 | - |
|
| 3743 | - if (!preg_match(",<svg\b[^>]*>,UimsS", $svg, $match)) { |
|
| 3744 | - return ''; |
|
| 3745 | - } |
|
| 3746 | - |
|
| 3747 | - [$alt, $class, $size] = helper_filtre_balise_img_svg_arguments($alt, $class, $size); |
|
| 3748 | - |
|
| 3749 | - $balise_svg = $match[0]; |
|
| 3750 | - $balise_svg_source = $balise_svg; |
|
| 3751 | - |
|
| 3752 | - // entete XML à supprimer |
|
| 3753 | - $svg = preg_replace(',^\s*<\?xml[^>]*\?' . '>,', '', $svg); |
|
| 3754 | - |
|
| 3755 | - // IE est toujours mon ami |
|
| 3756 | - $balise_svg = inserer_attribut($balise_svg, 'focusable', 'false'); |
|
| 3757 | - |
|
| 3758 | - // regler la classe |
|
| 3759 | - if (!is_null($class)) { |
|
| 3760 | - if (strlen($class)) { |
|
| 3761 | - $balise_svg = inserer_attribut($balise_svg, 'class', $class); |
|
| 3762 | - } |
|
| 3763 | - else { |
|
| 3764 | - $balise_svg = vider_attribut($balise_svg, 'class'); |
|
| 3765 | - } |
|
| 3766 | - } |
|
| 3767 | - |
|
| 3768 | - // regler le alt |
|
| 3769 | - if ($alt) { |
|
| 3770 | - $balise_svg = inserer_attribut($balise_svg, 'role', 'img'); |
|
| 3771 | - $id = 'img-svg-title-' . substr(md5("$img_file:$svg:$alt"), 0, 4); |
|
| 3772 | - $balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id); |
|
| 3773 | - $title = "<title id=\"$id\">" . entites_html($alt) . "</title>\n"; |
|
| 3774 | - $balise_svg .= $title; |
|
| 3775 | - } |
|
| 3776 | - else { |
|
| 3777 | - $balise_svg = inserer_attribut($balise_svg, 'aria-hidden', 'true'); |
|
| 3778 | - } |
|
| 3779 | - |
|
| 3780 | - $svg = str_replace($balise_svg_source, $balise_svg, $svg); |
|
| 3781 | - |
|
| 3782 | - if (!is_null($size) and strlen($size = trim($size))) { |
|
| 3783 | - [$width, $height] = helper_filtre_balise_img_svg_size($svg, $size); |
|
| 3784 | - |
|
| 3785 | - if (!function_exists('svg_redimensionner')) { |
|
| 3786 | - include_spip('inc/svg'); |
|
| 3787 | - } |
|
| 3788 | - $svg = svg_redimensionner($svg, $width, $height); |
|
| 3789 | - } |
|
| 3790 | - |
|
| 3791 | - return $svg; |
|
| 3718 | + $svg = null; |
|
| 3719 | + $img = trim($img); |
|
| 3720 | + $img_file = $img; |
|
| 3721 | + if (strpos($img, '<svg') === false) { |
|
| 3722 | + if ($p = strpos($img_file, '?')) { |
|
| 3723 | + $img_file = substr($img_file, 0, $p); |
|
| 3724 | + } |
|
| 3725 | + |
|
| 3726 | + // ne jamais operer directement sur une image distante pour des raisons de perfo |
|
| 3727 | + // la copie locale a toutes les chances d'etre la ou de resservir |
|
| 3728 | + if (tester_url_absolue($img_file)) { |
|
| 3729 | + include_spip('inc/distant'); |
|
| 3730 | + $fichier = copie_locale($img_file); |
|
| 3731 | + $img_file = ($fichier ? _DIR_RACINE . $fichier : $img_file); |
|
| 3732 | + } |
|
| 3733 | + |
|
| 3734 | + if ( |
|
| 3735 | + !$img_file |
|
| 3736 | + or !file_exists($img_file) |
|
| 3737 | + or !$svg = file_get_contents($img_file) |
|
| 3738 | + ) { |
|
| 3739 | + return ''; |
|
| 3740 | + } |
|
| 3741 | + } |
|
| 3742 | + |
|
| 3743 | + if (!preg_match(",<svg\b[^>]*>,UimsS", $svg, $match)) { |
|
| 3744 | + return ''; |
|
| 3745 | + } |
|
| 3746 | + |
|
| 3747 | + [$alt, $class, $size] = helper_filtre_balise_img_svg_arguments($alt, $class, $size); |
|
| 3748 | + |
|
| 3749 | + $balise_svg = $match[0]; |
|
| 3750 | + $balise_svg_source = $balise_svg; |
|
| 3751 | + |
|
| 3752 | + // entete XML à supprimer |
|
| 3753 | + $svg = preg_replace(',^\s*<\?xml[^>]*\?' . '>,', '', $svg); |
|
| 3754 | + |
|
| 3755 | + // IE est toujours mon ami |
|
| 3756 | + $balise_svg = inserer_attribut($balise_svg, 'focusable', 'false'); |
|
| 3757 | + |
|
| 3758 | + // regler la classe |
|
| 3759 | + if (!is_null($class)) { |
|
| 3760 | + if (strlen($class)) { |
|
| 3761 | + $balise_svg = inserer_attribut($balise_svg, 'class', $class); |
|
| 3762 | + } |
|
| 3763 | + else { |
|
| 3764 | + $balise_svg = vider_attribut($balise_svg, 'class'); |
|
| 3765 | + } |
|
| 3766 | + } |
|
| 3767 | + |
|
| 3768 | + // regler le alt |
|
| 3769 | + if ($alt) { |
|
| 3770 | + $balise_svg = inserer_attribut($balise_svg, 'role', 'img'); |
|
| 3771 | + $id = 'img-svg-title-' . substr(md5("$img_file:$svg:$alt"), 0, 4); |
|
| 3772 | + $balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id); |
|
| 3773 | + $title = "<title id=\"$id\">" . entites_html($alt) . "</title>\n"; |
|
| 3774 | + $balise_svg .= $title; |
|
| 3775 | + } |
|
| 3776 | + else { |
|
| 3777 | + $balise_svg = inserer_attribut($balise_svg, 'aria-hidden', 'true'); |
|
| 3778 | + } |
|
| 3779 | + |
|
| 3780 | + $svg = str_replace($balise_svg_source, $balise_svg, $svg); |
|
| 3781 | + |
|
| 3782 | + if (!is_null($size) and strlen($size = trim($size))) { |
|
| 3783 | + [$width, $height] = helper_filtre_balise_img_svg_size($svg, $size); |
|
| 3784 | + |
|
| 3785 | + if (!function_exists('svg_redimensionner')) { |
|
| 3786 | + include_spip('inc/svg'); |
|
| 3787 | + } |
|
| 3788 | + $svg = svg_redimensionner($svg, $width, $height); |
|
| 3789 | + } |
|
| 3790 | + |
|
| 3791 | + return $svg; |
|
| 3792 | 3792 | } |
| 3793 | 3793 | |
| 3794 | 3794 | |
@@ -3814,18 +3814,18 @@ discard block |
||
| 3814 | 3814 | * Code HTML résultant |
| 3815 | 3815 | **/ |
| 3816 | 3816 | function filtre_foreach_dist($tableau, $modele = 'foreach') { |
| 3817 | - $texte = ''; |
|
| 3818 | - if (is_array($tableau)) { |
|
| 3819 | - foreach ($tableau as $k => $v) { |
|
| 3820 | - $res = recuperer_fond( |
|
| 3821 | - 'modeles/' . $modele, |
|
| 3822 | - array_merge(['cle' => $k], (is_array($v) ? $v : ['valeur' => $v])) |
|
| 3823 | - ); |
|
| 3824 | - $texte .= $res; |
|
| 3825 | - } |
|
| 3826 | - } |
|
| 3817 | + $texte = ''; |
|
| 3818 | + if (is_array($tableau)) { |
|
| 3819 | + foreach ($tableau as $k => $v) { |
|
| 3820 | + $res = recuperer_fond( |
|
| 3821 | + 'modeles/' . $modele, |
|
| 3822 | + array_merge(['cle' => $k], (is_array($v) ? $v : ['valeur' => $v])) |
|
| 3823 | + ); |
|
| 3824 | + $texte .= $res; |
|
| 3825 | + } |
|
| 3826 | + } |
|
| 3827 | 3827 | |
| 3828 | - return $texte; |
|
| 3828 | + return $texte; |
|
| 3829 | 3829 | } |
| 3830 | 3830 | |
| 3831 | 3831 | |
@@ -3850,37 +3850,37 @@ discard block |
||
| 3850 | 3850 | * - tout : retourne toutes les informations du plugin actif |
| 3851 | 3851 | **/ |
| 3852 | 3852 | function filtre_info_plugin_dist($plugin, $type_info, $reload = false) { |
| 3853 | - include_spip('inc/plugin'); |
|
| 3854 | - $plugin = strtoupper($plugin); |
|
| 3855 | - $plugins_actifs = liste_plugin_actifs(); |
|
| 3856 | - |
|
| 3857 | - if (!$plugin) { |
|
| 3858 | - return serialize(array_keys($plugins_actifs)); |
|
| 3859 | - } elseif (empty($plugins_actifs[$plugin]) and !$reload) { |
|
| 3860 | - return ''; |
|
| 3861 | - } elseif (($type_info == 'est_actif') and !$reload) { |
|
| 3862 | - return $plugins_actifs[$plugin] ? 1 : 0; |
|
| 3863 | - } elseif (isset($plugins_actifs[$plugin][$type_info]) and !$reload) { |
|
| 3864 | - return $plugins_actifs[$plugin][$type_info]; |
|
| 3865 | - } else { |
|
| 3866 | - $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 3867 | - // On prend en compte les extensions |
|
| 3868 | - if (!is_dir($plugins_actifs[$plugin]['dir_type'])) { |
|
| 3869 | - $dir_plugins = constant($plugins_actifs[$plugin]['dir_type']); |
|
| 3870 | - } else { |
|
| 3871 | - $dir_plugins = $plugins_actifs[$plugin]['dir_type']; |
|
| 3872 | - } |
|
| 3873 | - if (!$infos = $get_infos($plugins_actifs[$plugin]['dir'], $reload, $dir_plugins)) { |
|
| 3874 | - return ''; |
|
| 3875 | - } |
|
| 3876 | - if ($type_info == 'tout') { |
|
| 3877 | - return $infos; |
|
| 3878 | - } elseif ($type_info == 'est_actif') { |
|
| 3879 | - return $infos ? 1 : 0; |
|
| 3880 | - } else { |
|
| 3881 | - return strval($infos[$type_info]); |
|
| 3882 | - } |
|
| 3883 | - } |
|
| 3853 | + include_spip('inc/plugin'); |
|
| 3854 | + $plugin = strtoupper($plugin); |
|
| 3855 | + $plugins_actifs = liste_plugin_actifs(); |
|
| 3856 | + |
|
| 3857 | + if (!$plugin) { |
|
| 3858 | + return serialize(array_keys($plugins_actifs)); |
|
| 3859 | + } elseif (empty($plugins_actifs[$plugin]) and !$reload) { |
|
| 3860 | + return ''; |
|
| 3861 | + } elseif (($type_info == 'est_actif') and !$reload) { |
|
| 3862 | + return $plugins_actifs[$plugin] ? 1 : 0; |
|
| 3863 | + } elseif (isset($plugins_actifs[$plugin][$type_info]) and !$reload) { |
|
| 3864 | + return $plugins_actifs[$plugin][$type_info]; |
|
| 3865 | + } else { |
|
| 3866 | + $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 3867 | + // On prend en compte les extensions |
|
| 3868 | + if (!is_dir($plugins_actifs[$plugin]['dir_type'])) { |
|
| 3869 | + $dir_plugins = constant($plugins_actifs[$plugin]['dir_type']); |
|
| 3870 | + } else { |
|
| 3871 | + $dir_plugins = $plugins_actifs[$plugin]['dir_type']; |
|
| 3872 | + } |
|
| 3873 | + if (!$infos = $get_infos($plugins_actifs[$plugin]['dir'], $reload, $dir_plugins)) { |
|
| 3874 | + return ''; |
|
| 3875 | + } |
|
| 3876 | + if ($type_info == 'tout') { |
|
| 3877 | + return $infos; |
|
| 3878 | + } elseif ($type_info == 'est_actif') { |
|
| 3879 | + return $infos ? 1 : 0; |
|
| 3880 | + } else { |
|
| 3881 | + return strval($infos[$type_info]); |
|
| 3882 | + } |
|
| 3883 | + } |
|
| 3884 | 3884 | } |
| 3885 | 3885 | |
| 3886 | 3886 | |
@@ -3907,9 +3907,9 @@ discard block |
||
| 3907 | 3907 | * Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent) |
| 3908 | 3908 | */ |
| 3909 | 3909 | function puce_changement_statut($id_objet, $statut, $id_rubrique, $type, $ajax = false) { |
| 3910 | - $puce_statut = charger_fonction('puce_statut', 'inc'); |
|
| 3910 | + $puce_statut = charger_fonction('puce_statut', 'inc'); |
|
| 3911 | 3911 | |
| 3912 | - return $puce_statut($id_objet, $statut, $id_rubrique, $type, $ajax); |
|
| 3912 | + return $puce_statut($id_objet, $statut, $id_rubrique, $type, $ajax); |
|
| 3913 | 3913 | } |
| 3914 | 3914 | |
| 3915 | 3915 | |
@@ -3939,19 +3939,19 @@ discard block |
||
| 3939 | 3939 | * Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent) |
| 3940 | 3940 | */ |
| 3941 | 3941 | function filtre_puce_statut_dist($statut, $objet, $id_objet = 0, $id_parent = 0) { |
| 3942 | - static $puce_statut = null; |
|
| 3943 | - if (!$puce_statut) { |
|
| 3944 | - $puce_statut = charger_fonction('puce_statut', 'inc'); |
|
| 3945 | - } |
|
| 3942 | + static $puce_statut = null; |
|
| 3943 | + if (!$puce_statut) { |
|
| 3944 | + $puce_statut = charger_fonction('puce_statut', 'inc'); |
|
| 3945 | + } |
|
| 3946 | 3946 | |
| 3947 | - return $puce_statut( |
|
| 3948 | - $id_objet, |
|
| 3949 | - $statut, |
|
| 3950 | - $id_parent, |
|
| 3951 | - $objet, |
|
| 3952 | - false, |
|
| 3953 | - objet_info($objet, 'editable') ? _ACTIVER_PUCE_RAPIDE : false |
|
| 3954 | - ); |
|
| 3947 | + return $puce_statut( |
|
| 3948 | + $id_objet, |
|
| 3949 | + $statut, |
|
| 3950 | + $id_parent, |
|
| 3951 | + $objet, |
|
| 3952 | + false, |
|
| 3953 | + objet_info($objet, 'editable') ? _ACTIVER_PUCE_RAPIDE : false |
|
| 3954 | + ); |
|
| 3955 | 3955 | } |
| 3956 | 3956 | |
| 3957 | 3957 | |
@@ -3978,98 +3978,98 @@ discard block |
||
| 3978 | 3978 | * hash du contexte |
| 3979 | 3979 | */ |
| 3980 | 3980 | function encoder_contexte_ajax($c, $form = '', $emboite = null, $ajaxid = '') { |
| 3981 | - $env = null; |
|
| 3982 | - if ( |
|
| 3983 | - is_string($c) |
|
| 3984 | - and @unserialize($c) !== false |
|
| 3985 | - ) { |
|
| 3986 | - $c = unserialize($c); |
|
| 3987 | - } |
|
| 3988 | - |
|
| 3989 | - // supprimer les parametres debut_x |
|
| 3990 | - // pour que la pagination ajax ne soit pas plantee |
|
| 3991 | - // si on charge la page &debut_x=1 : car alors en cliquant sur l'item 0, |
|
| 3992 | - // le debut_x=0 n'existe pas, et on resterait sur 1 |
|
| 3993 | - if (is_array($c)) { |
|
| 3994 | - foreach ($c as $k => $v) { |
|
| 3995 | - if (strpos($k, 'debut_') === 0) { |
|
| 3996 | - unset($c[$k]); |
|
| 3997 | - } |
|
| 3998 | - } |
|
| 3999 | - } |
|
| 4000 | - |
|
| 4001 | - if (!function_exists('calculer_cle_action')) { |
|
| 4002 | - include_spip('inc/securiser_action'); |
|
| 4003 | - } |
|
| 4004 | - |
|
| 4005 | - $c = serialize($c); |
|
| 4006 | - $cle = calculer_cle_action($form . $c); |
|
| 4007 | - $c = "$cle:$c"; |
|
| 4008 | - |
|
| 4009 | - // on ne stocke pas les contextes dans des fichiers en cache |
|
| 4010 | - // par defaut, sauf si cette configuration a été forcée |
|
| 4011 | - // OU que la longueur de l’argument géneré est plus long |
|
| 4012 | - // que ce qui est toléré. |
|
| 4013 | - $cache_contextes_ajax = (defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX); |
|
| 4014 | - if (!$cache_contextes_ajax) { |
|
| 4015 | - $env = $c; |
|
| 4016 | - if (function_exists('gzdeflate') && function_exists('gzinflate')) { |
|
| 4017 | - $env = gzdeflate($env); |
|
| 4018 | - } |
|
| 4019 | - $env = _xor($env); |
|
| 4020 | - $env = base64_encode($env); |
|
| 4021 | - $len = strlen($env); |
|
| 4022 | - // Si l’url est trop longue pour le navigateur |
|
| 4023 | - $max_len = _CACHE_CONTEXTES_AJAX_SUR_LONGUEUR; |
|
| 4024 | - if ($len > $max_len) { |
|
| 4025 | - $cache_contextes_ajax = true; |
|
| 4026 | - spip_log( |
|
| 4027 | - 'Contextes AJAX forces en fichiers !' |
|
| 4028 | - . ' Cela arrive lorsque la valeur du contexte' |
|
| 4029 | - . " depasse la longueur maximale autorisee ($max_len). Ici : $len.", |
|
| 4030 | - _LOG_AVERTISSEMENT |
|
| 4031 | - ); |
|
| 4032 | - } |
|
| 4033 | - // Sinon si Suhosin est actif et a une la valeur maximale des variables en GET... |
|
| 4034 | - elseif ( |
|
| 4035 | - $max_len = @ini_get('suhosin.get.max_value_length') |
|
| 4036 | - and $max_len < $len |
|
| 4037 | - ) { |
|
| 4038 | - $cache_contextes_ajax = true; |
|
| 4039 | - spip_log('Contextes AJAX forces en fichiers !' |
|
| 4040 | - . ' Cela arrive lorsque la valeur du contexte' |
|
| 4041 | - . ' depasse la longueur maximale autorisee par Suhosin' |
|
| 4042 | - . " ($max_len) dans 'suhosin.get.max_value_length'. Ici : $len." |
|
| 4043 | - . ' Vous devriez modifier les parametres de Suhosin' |
|
| 4044 | - . ' pour accepter au moins 1024 caracteres.', _LOG_AVERTISSEMENT); |
|
| 4045 | - } |
|
| 4046 | - } |
|
| 4047 | - |
|
| 4048 | - if ($cache_contextes_ajax) { |
|
| 4049 | - $dir = sous_repertoire(_DIR_CACHE, 'contextes'); |
|
| 4050 | - // stocker les contextes sur disque et ne passer qu'un hash dans l'url |
|
| 4051 | - $md5 = md5($c); |
|
| 4052 | - ecrire_fichier("$dir/c$md5", $c); |
|
| 4053 | - $env = $md5; |
|
| 4054 | - } |
|
| 4055 | - |
|
| 4056 | - if ($emboite === null) { |
|
| 4057 | - return $env; |
|
| 4058 | - } |
|
| 4059 | - if (!trim($emboite)) { |
|
| 4060 | - return ''; |
|
| 4061 | - } |
|
| 4062 | - // toujours encoder l'url source dans le bloc ajax |
|
| 4063 | - $r = self(); |
|
| 4064 | - $r = ' data-origin="' . $r . '"'; |
|
| 4065 | - $class = 'ajaxbloc'; |
|
| 4066 | - if ($ajaxid and is_string($ajaxid)) { |
|
| 4067 | - // ajaxid est normalement conforme a un nom de classe css |
|
| 4068 | - // on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution |
|
| 4069 | - $class .= ' ajax-id-' . entites_html($ajaxid); |
|
| 4070 | - } |
|
| 4071 | - |
|
| 4072 | - return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n"; |
|
| 3981 | + $env = null; |
|
| 3982 | + if ( |
|
| 3983 | + is_string($c) |
|
| 3984 | + and @unserialize($c) !== false |
|
| 3985 | + ) { |
|
| 3986 | + $c = unserialize($c); |
|
| 3987 | + } |
|
| 3988 | + |
|
| 3989 | + // supprimer les parametres debut_x |
|
| 3990 | + // pour que la pagination ajax ne soit pas plantee |
|
| 3991 | + // si on charge la page &debut_x=1 : car alors en cliquant sur l'item 0, |
|
| 3992 | + // le debut_x=0 n'existe pas, et on resterait sur 1 |
|
| 3993 | + if (is_array($c)) { |
|
| 3994 | + foreach ($c as $k => $v) { |
|
| 3995 | + if (strpos($k, 'debut_') === 0) { |
|
| 3996 | + unset($c[$k]); |
|
| 3997 | + } |
|
| 3998 | + } |
|
| 3999 | + } |
|
| 4000 | + |
|
| 4001 | + if (!function_exists('calculer_cle_action')) { |
|
| 4002 | + include_spip('inc/securiser_action'); |
|
| 4003 | + } |
|
| 4004 | + |
|
| 4005 | + $c = serialize($c); |
|
| 4006 | + $cle = calculer_cle_action($form . $c); |
|
| 4007 | + $c = "$cle:$c"; |
|
| 4008 | + |
|
| 4009 | + // on ne stocke pas les contextes dans des fichiers en cache |
|
| 4010 | + // par defaut, sauf si cette configuration a été forcée |
|
| 4011 | + // OU que la longueur de l’argument géneré est plus long |
|
| 4012 | + // que ce qui est toléré. |
|
| 4013 | + $cache_contextes_ajax = (defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX); |
|
| 4014 | + if (!$cache_contextes_ajax) { |
|
| 4015 | + $env = $c; |
|
| 4016 | + if (function_exists('gzdeflate') && function_exists('gzinflate')) { |
|
| 4017 | + $env = gzdeflate($env); |
|
| 4018 | + } |
|
| 4019 | + $env = _xor($env); |
|
| 4020 | + $env = base64_encode($env); |
|
| 4021 | + $len = strlen($env); |
|
| 4022 | + // Si l’url est trop longue pour le navigateur |
|
| 4023 | + $max_len = _CACHE_CONTEXTES_AJAX_SUR_LONGUEUR; |
|
| 4024 | + if ($len > $max_len) { |
|
| 4025 | + $cache_contextes_ajax = true; |
|
| 4026 | + spip_log( |
|
| 4027 | + 'Contextes AJAX forces en fichiers !' |
|
| 4028 | + . ' Cela arrive lorsque la valeur du contexte' |
|
| 4029 | + . " depasse la longueur maximale autorisee ($max_len). Ici : $len.", |
|
| 4030 | + _LOG_AVERTISSEMENT |
|
| 4031 | + ); |
|
| 4032 | + } |
|
| 4033 | + // Sinon si Suhosin est actif et a une la valeur maximale des variables en GET... |
|
| 4034 | + elseif ( |
|
| 4035 | + $max_len = @ini_get('suhosin.get.max_value_length') |
|
| 4036 | + and $max_len < $len |
|
| 4037 | + ) { |
|
| 4038 | + $cache_contextes_ajax = true; |
|
| 4039 | + spip_log('Contextes AJAX forces en fichiers !' |
|
| 4040 | + . ' Cela arrive lorsque la valeur du contexte' |
|
| 4041 | + . ' depasse la longueur maximale autorisee par Suhosin' |
|
| 4042 | + . " ($max_len) dans 'suhosin.get.max_value_length'. Ici : $len." |
|
| 4043 | + . ' Vous devriez modifier les parametres de Suhosin' |
|
| 4044 | + . ' pour accepter au moins 1024 caracteres.', _LOG_AVERTISSEMENT); |
|
| 4045 | + } |
|
| 4046 | + } |
|
| 4047 | + |
|
| 4048 | + if ($cache_contextes_ajax) { |
|
| 4049 | + $dir = sous_repertoire(_DIR_CACHE, 'contextes'); |
|
| 4050 | + // stocker les contextes sur disque et ne passer qu'un hash dans l'url |
|
| 4051 | + $md5 = md5($c); |
|
| 4052 | + ecrire_fichier("$dir/c$md5", $c); |
|
| 4053 | + $env = $md5; |
|
| 4054 | + } |
|
| 4055 | + |
|
| 4056 | + if ($emboite === null) { |
|
| 4057 | + return $env; |
|
| 4058 | + } |
|
| 4059 | + if (!trim($emboite)) { |
|
| 4060 | + return ''; |
|
| 4061 | + } |
|
| 4062 | + // toujours encoder l'url source dans le bloc ajax |
|
| 4063 | + $r = self(); |
|
| 4064 | + $r = ' data-origin="' . $r . '"'; |
|
| 4065 | + $class = 'ajaxbloc'; |
|
| 4066 | + if ($ajaxid and is_string($ajaxid)) { |
|
| 4067 | + // ajaxid est normalement conforme a un nom de classe css |
|
| 4068 | + // on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution |
|
| 4069 | + $class .= ' ajax-id-' . entites_html($ajaxid); |
|
| 4070 | + } |
|
| 4071 | + |
|
| 4072 | + return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n"; |
|
| 4073 | 4073 | } |
| 4074 | 4074 | |
| 4075 | 4075 | /** |
@@ -4089,37 +4089,37 @@ discard block |
||
| 4089 | 4089 | * - false : erreur de décodage |
| 4090 | 4090 | */ |
| 4091 | 4091 | function decoder_contexte_ajax($c, $form = '') { |
| 4092 | - if (!function_exists('calculer_cle_action')) { |
|
| 4093 | - include_spip('inc/securiser_action'); |
|
| 4094 | - } |
|
| 4095 | - if ( |
|
| 4096 | - ((defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX) or strlen($c) == 32) |
|
| 4097 | - and $dir = sous_repertoire(_DIR_CACHE, 'contextes') |
|
| 4098 | - and lire_fichier("$dir/c$c", $contexte) |
|
| 4099 | - ) { |
|
| 4100 | - $c = $contexte; |
|
| 4101 | - } else { |
|
| 4102 | - $c = @base64_decode($c); |
|
| 4103 | - $c = _xor($c); |
|
| 4104 | - if (function_exists('gzdeflate') && function_exists('gzinflate')) { |
|
| 4105 | - $c = @gzinflate($c); |
|
| 4106 | - } |
|
| 4107 | - } |
|
| 4108 | - |
|
| 4109 | - // extraire la signature en debut de contexte |
|
| 4110 | - // et la verifier avant de deserializer |
|
| 4111 | - // format : signature:donneesserializees |
|
| 4112 | - if ($p = strpos($c, ':')) { |
|
| 4113 | - $cle = substr($c, 0, $p); |
|
| 4114 | - $c = substr($c, $p + 1); |
|
| 4115 | - |
|
| 4116 | - if ($cle == calculer_cle_action($form . $c)) { |
|
| 4117 | - $env = @unserialize($c); |
|
| 4118 | - return $env; |
|
| 4119 | - } |
|
| 4120 | - } |
|
| 4121 | - |
|
| 4122 | - return false; |
|
| 4092 | + if (!function_exists('calculer_cle_action')) { |
|
| 4093 | + include_spip('inc/securiser_action'); |
|
| 4094 | + } |
|
| 4095 | + if ( |
|
| 4096 | + ((defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX) or strlen($c) == 32) |
|
| 4097 | + and $dir = sous_repertoire(_DIR_CACHE, 'contextes') |
|
| 4098 | + and lire_fichier("$dir/c$c", $contexte) |
|
| 4099 | + ) { |
|
| 4100 | + $c = $contexte; |
|
| 4101 | + } else { |
|
| 4102 | + $c = @base64_decode($c); |
|
| 4103 | + $c = _xor($c); |
|
| 4104 | + if (function_exists('gzdeflate') && function_exists('gzinflate')) { |
|
| 4105 | + $c = @gzinflate($c); |
|
| 4106 | + } |
|
| 4107 | + } |
|
| 4108 | + |
|
| 4109 | + // extraire la signature en debut de contexte |
|
| 4110 | + // et la verifier avant de deserializer |
|
| 4111 | + // format : signature:donneesserializees |
|
| 4112 | + if ($p = strpos($c, ':')) { |
|
| 4113 | + $cle = substr($c, 0, $p); |
|
| 4114 | + $c = substr($c, $p + 1); |
|
| 4115 | + |
|
| 4116 | + if ($cle == calculer_cle_action($form . $c)) { |
|
| 4117 | + $env = @unserialize($c); |
|
| 4118 | + return $env; |
|
| 4119 | + } |
|
| 4120 | + } |
|
| 4121 | + |
|
| 4122 | + return false; |
|
| 4123 | 4123 | } |
| 4124 | 4124 | |
| 4125 | 4125 | |
@@ -4137,20 +4137,20 @@ discard block |
||
| 4137 | 4137 | * Message décrypté ou encrypté |
| 4138 | 4138 | **/ |
| 4139 | 4139 | function _xor($message, $key = null) { |
| 4140 | - if (is_null($key)) { |
|
| 4141 | - if (!function_exists('calculer_cle_action')) { |
|
| 4142 | - include_spip('inc/securiser_action'); |
|
| 4143 | - } |
|
| 4144 | - $key = pack('H*', calculer_cle_action('_xor')); |
|
| 4145 | - } |
|
| 4140 | + if (is_null($key)) { |
|
| 4141 | + if (!function_exists('calculer_cle_action')) { |
|
| 4142 | + include_spip('inc/securiser_action'); |
|
| 4143 | + } |
|
| 4144 | + $key = pack('H*', calculer_cle_action('_xor')); |
|
| 4145 | + } |
|
| 4146 | 4146 | |
| 4147 | - $keylen = strlen($key); |
|
| 4148 | - $messagelen = strlen($message); |
|
| 4149 | - for ($i = 0; $i < $messagelen; $i++) { |
|
| 4150 | - $message[$i] = ~($message[$i] ^ $key[$i % $keylen]); |
|
| 4151 | - } |
|
| 4147 | + $keylen = strlen($key); |
|
| 4148 | + $messagelen = strlen($message); |
|
| 4149 | + for ($i = 0; $i < $messagelen; $i++) { |
|
| 4150 | + $message[$i] = ~($message[$i] ^ $key[$i % $keylen]); |
|
| 4151 | + } |
|
| 4152 | 4152 | |
| 4153 | - return $message; |
|
| 4153 | + return $message; |
|
| 4154 | 4154 | } |
| 4155 | 4155 | |
| 4156 | 4156 | /** |
@@ -4164,7 +4164,7 @@ discard block |
||
| 4164 | 4164 | * @return string |
| 4165 | 4165 | */ |
| 4166 | 4166 | function url_reponse_forum($texte) { |
| 4167 | - return $texte; |
|
| 4167 | + return $texte; |
|
| 4168 | 4168 | } |
| 4169 | 4169 | |
| 4170 | 4170 | /** |
@@ -4178,7 +4178,7 @@ discard block |
||
| 4178 | 4178 | * @return string |
| 4179 | 4179 | */ |
| 4180 | 4180 | function url_rss_forum($texte) { |
| 4181 | - return $texte; |
|
| 4181 | + return $texte; |
|
| 4182 | 4182 | } |
| 4183 | 4183 | |
| 4184 | 4184 | |
@@ -4217,37 +4217,37 @@ discard block |
||
| 4217 | 4217 | * Code HTML |
| 4218 | 4218 | */ |
| 4219 | 4219 | function lien_ou_expose($url, $libelle = null, $on = false, $class = '', $title = '', $rel = '', $evt = '') { |
| 4220 | - if ($on) { |
|
| 4221 | - $bal = 'strong'; |
|
| 4222 | - $class = ''; |
|
| 4223 | - $att = ''; |
|
| 4224 | - // si $on passe la balise et optionnelement une ou ++classe |
|
| 4225 | - // a.active span.selected.active etc.... |
|
| 4226 | - if (is_string($on) and (strncmp($on, 'a', 1) == 0 or strncmp($on, 'span', 4) == 0 or strncmp($on, 'strong', 6) == 0)) { |
|
| 4227 | - $on = explode('.', $on); |
|
| 4228 | - // on verifie que c'est exactement une des 3 balises a, span ou strong |
|
| 4229 | - if (in_array(reset($on), ['a', 'span', 'strong'])) { |
|
| 4230 | - $bal = array_shift($on); |
|
| 4231 | - $class = implode(' ', $on); |
|
| 4232 | - if ($bal == 'a') { |
|
| 4233 | - $att = 'href="#" '; |
|
| 4234 | - } |
|
| 4235 | - } |
|
| 4236 | - } |
|
| 4237 | - $att .= 'class="' . ($class ? attribut_html($class) . ' ' : '') . (defined('_LIEN_OU_EXPOSE_CLASS_ON') ? _LIEN_OU_EXPOSE_CLASS_ON : 'on') . '"'; |
|
| 4238 | - } else { |
|
| 4239 | - $bal = 'a'; |
|
| 4240 | - $att = "href='$url'" |
|
| 4241 | - . ($title ? " title='" . attribut_html($title) . "'" : '') |
|
| 4242 | - . ($class ? " class='" . attribut_html($class) . "'" : '') |
|
| 4243 | - . ($rel ? " rel='" . attribut_html($rel) . "'" : '') |
|
| 4244 | - . $evt; |
|
| 4245 | - } |
|
| 4246 | - if ($libelle === null) { |
|
| 4247 | - $libelle = $url; |
|
| 4248 | - } |
|
| 4249 | - |
|
| 4250 | - return "<$bal $att>$libelle</$bal>"; |
|
| 4220 | + if ($on) { |
|
| 4221 | + $bal = 'strong'; |
|
| 4222 | + $class = ''; |
|
| 4223 | + $att = ''; |
|
| 4224 | + // si $on passe la balise et optionnelement une ou ++classe |
|
| 4225 | + // a.active span.selected.active etc.... |
|
| 4226 | + if (is_string($on) and (strncmp($on, 'a', 1) == 0 or strncmp($on, 'span', 4) == 0 or strncmp($on, 'strong', 6) == 0)) { |
|
| 4227 | + $on = explode('.', $on); |
|
| 4228 | + // on verifie que c'est exactement une des 3 balises a, span ou strong |
|
| 4229 | + if (in_array(reset($on), ['a', 'span', 'strong'])) { |
|
| 4230 | + $bal = array_shift($on); |
|
| 4231 | + $class = implode(' ', $on); |
|
| 4232 | + if ($bal == 'a') { |
|
| 4233 | + $att = 'href="#" '; |
|
| 4234 | + } |
|
| 4235 | + } |
|
| 4236 | + } |
|
| 4237 | + $att .= 'class="' . ($class ? attribut_html($class) . ' ' : '') . (defined('_LIEN_OU_EXPOSE_CLASS_ON') ? _LIEN_OU_EXPOSE_CLASS_ON : 'on') . '"'; |
|
| 4238 | + } else { |
|
| 4239 | + $bal = 'a'; |
|
| 4240 | + $att = "href='$url'" |
|
| 4241 | + . ($title ? " title='" . attribut_html($title) . "'" : '') |
|
| 4242 | + . ($class ? " class='" . attribut_html($class) . "'" : '') |
|
| 4243 | + . ($rel ? " rel='" . attribut_html($rel) . "'" : '') |
|
| 4244 | + . $evt; |
|
| 4245 | + } |
|
| 4246 | + if ($libelle === null) { |
|
| 4247 | + $libelle = $url; |
|
| 4248 | + } |
|
| 4249 | + |
|
| 4250 | + return "<$bal $att>$libelle</$bal>"; |
|
| 4251 | 4251 | } |
| 4252 | 4252 | |
| 4253 | 4253 | |
@@ -4264,39 +4264,39 @@ discard block |
||
| 4264 | 4264 | * @return string : la chaine de langue finale en utilisant la fonction _T() |
| 4265 | 4265 | */ |
| 4266 | 4266 | function singulier_ou_pluriel($nb, $chaine_un, $chaine_plusieurs, $var = 'nb', $vars = []) { |
| 4267 | - static $local_singulier_ou_pluriel = []; |
|
| 4268 | - |
|
| 4269 | - // si nb=0 ou pas de $vars valide on retourne une chaine vide, a traiter par un |sinon |
|
| 4270 | - if (!is_numeric($nb) or $nb == 0) { |
|
| 4271 | - return ''; |
|
| 4272 | - } |
|
| 4273 | - if (!is_array($vars)) { |
|
| 4274 | - return ''; |
|
| 4275 | - } |
|
| 4276 | - |
|
| 4277 | - $langue = $GLOBALS['spip_lang']; |
|
| 4278 | - if (!isset($local_singulier_ou_pluriel[$langue])) { |
|
| 4279 | - $local_singulier_ou_pluriel[$langue] = false; |
|
| 4280 | - if ( |
|
| 4281 | - $f = charger_fonction("singulier_ou_pluriel_${langue}", 'inc', true) |
|
| 4282 | - or $f = charger_fonction('singulier_ou_pluriel', 'inc', true) |
|
| 4283 | - ) { |
|
| 4284 | - $local_singulier_ou_pluriel[$langue] = $f; |
|
| 4285 | - } |
|
| 4286 | - } |
|
| 4287 | - |
|
| 4288 | - // si on a une surcharge on l'utilise |
|
| 4289 | - if ($local_singulier_ou_pluriel[$langue]) { |
|
| 4290 | - return ($local_singulier_ou_pluriel[$langue])($nb, $chaine_un, $chaine_plusieurs, $var, $vars); |
|
| 4291 | - } |
|
| 4292 | - |
|
| 4293 | - // sinon traitement par defaut |
|
| 4294 | - $vars[$var] = $nb; |
|
| 4295 | - if ($nb >= 2) { |
|
| 4296 | - return _T($chaine_plusieurs, $vars); |
|
| 4297 | - } else { |
|
| 4298 | - return _T($chaine_un, $vars); |
|
| 4299 | - } |
|
| 4267 | + static $local_singulier_ou_pluriel = []; |
|
| 4268 | + |
|
| 4269 | + // si nb=0 ou pas de $vars valide on retourne une chaine vide, a traiter par un |sinon |
|
| 4270 | + if (!is_numeric($nb) or $nb == 0) { |
|
| 4271 | + return ''; |
|
| 4272 | + } |
|
| 4273 | + if (!is_array($vars)) { |
|
| 4274 | + return ''; |
|
| 4275 | + } |
|
| 4276 | + |
|
| 4277 | + $langue = $GLOBALS['spip_lang']; |
|
| 4278 | + if (!isset($local_singulier_ou_pluriel[$langue])) { |
|
| 4279 | + $local_singulier_ou_pluriel[$langue] = false; |
|
| 4280 | + if ( |
|
| 4281 | + $f = charger_fonction("singulier_ou_pluriel_${langue}", 'inc', true) |
|
| 4282 | + or $f = charger_fonction('singulier_ou_pluriel', 'inc', true) |
|
| 4283 | + ) { |
|
| 4284 | + $local_singulier_ou_pluriel[$langue] = $f; |
|
| 4285 | + } |
|
| 4286 | + } |
|
| 4287 | + |
|
| 4288 | + // si on a une surcharge on l'utilise |
|
| 4289 | + if ($local_singulier_ou_pluriel[$langue]) { |
|
| 4290 | + return ($local_singulier_ou_pluriel[$langue])($nb, $chaine_un, $chaine_plusieurs, $var, $vars); |
|
| 4291 | + } |
|
| 4292 | + |
|
| 4293 | + // sinon traitement par defaut |
|
| 4294 | + $vars[$var] = $nb; |
|
| 4295 | + if ($nb >= 2) { |
|
| 4296 | + return _T($chaine_plusieurs, $vars); |
|
| 4297 | + } else { |
|
| 4298 | + return _T($chaine_un, $vars); |
|
| 4299 | + } |
|
| 4300 | 4300 | } |
| 4301 | 4301 | |
| 4302 | 4302 | |
@@ -4324,73 +4324,73 @@ discard block |
||
| 4324 | 4324 | */ |
| 4325 | 4325 | function prepare_icone_base($type, $lien, $texte, $fond, $fonction = '', $class = '', $javascript = '') { |
| 4326 | 4326 | |
| 4327 | - $class_lien = $class_bouton = $class; |
|
| 4328 | - |
|
| 4329 | - // Normaliser la fonction et compléter la classe en fonction |
|
| 4330 | - if (in_array($fonction, ['del', 'supprimer.gif'])) { |
|
| 4331 | - $class_lien .= ' danger'; |
|
| 4332 | - $class_bouton .= ' btn_danger'; |
|
| 4333 | - } elseif ($fonction == 'rien.gif') { |
|
| 4334 | - $fonction = ''; |
|
| 4335 | - } elseif ($fonction == 'delsafe') { |
|
| 4336 | - $fonction = 'del'; |
|
| 4337 | - } |
|
| 4338 | - |
|
| 4339 | - $fond_origine = $fond; |
|
| 4340 | - // Remappage des icone : article-24.png+new => article-new-24.png |
|
| 4341 | - if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) { |
|
| 4342 | - [$fond, $fonction] = $icone_renommer($fond, $fonction); |
|
| 4343 | - } |
|
| 4344 | - |
|
| 4345 | - // Ajouter le type d'objet dans la classe |
|
| 4346 | - $objet_type = substr(basename($fond), 0, -4); |
|
| 4347 | - $class_lien .= " $objet_type"; |
|
| 4348 | - $class_bouton .= " $objet_type"; |
|
| 4349 | - |
|
| 4350 | - // Texte |
|
| 4351 | - $alt = attribut_html($texte); |
|
| 4352 | - $title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ? |
|
| 4353 | - |
|
| 4354 | - // Liens : préparer les classes ajax |
|
| 4355 | - $ajax = ''; |
|
| 4356 | - if ($type === 'lien') { |
|
| 4357 | - if (strpos($class_lien, 'ajax') !== false) { |
|
| 4358 | - $ajax = 'ajax'; |
|
| 4359 | - if (strpos($class_lien, 'preload') !== false) { |
|
| 4360 | - $ajax .= ' preload'; |
|
| 4361 | - } |
|
| 4362 | - if (strpos($class_lien, 'nocache') !== false) { |
|
| 4363 | - $ajax .= ' nocache'; |
|
| 4364 | - } |
|
| 4365 | - $ajax = " class='$ajax'"; |
|
| 4366 | - } |
|
| 4367 | - } |
|
| 4368 | - |
|
| 4369 | - // Repérer la taille et l'ajouter dans la classe |
|
| 4370 | - $size = 24; |
|
| 4371 | - if ( |
|
| 4372 | - preg_match('/-([0-9]{1,3})[.](gif|png|svg)$/i', $fond, $match) |
|
| 4373 | - or preg_match('/-([0-9]{1,3})([.](gif|png|svg))?$/i', $fond_origine, $match) |
|
| 4374 | - ) { |
|
| 4375 | - $size = $match[1]; |
|
| 4376 | - } |
|
| 4377 | - $class_lien .= " s$size"; |
|
| 4378 | - $class_bouton .= " s$size"; |
|
| 4379 | - |
|
| 4380 | - // Icône |
|
| 4381 | - $icone = http_img_pack($fond, $alt, "width='$size' height='$size'"); |
|
| 4382 | - $icone = '<span class="icone-image' . ($fonction ? " icone-fonction icone-fonction-$fonction" : '') . "\">$icone</span>"; |
|
| 4383 | - |
|
| 4384 | - // Markup final |
|
| 4385 | - if ($type == 'lien') { |
|
| 4386 | - return "<span class='icone $class_lien'>" |
|
| 4387 | - . "<a href='$lien'$title$ajax$javascript>" |
|
| 4388 | - . $icone |
|
| 4389 | - . "<b>$texte</b>" |
|
| 4390 | - . "</a></span>\n"; |
|
| 4391 | - } else { |
|
| 4392 | - return bouton_action("$icone $texte", $lien, $class_bouton, $javascript, $alt); |
|
| 4393 | - } |
|
| 4327 | + $class_lien = $class_bouton = $class; |
|
| 4328 | + |
|
| 4329 | + // Normaliser la fonction et compléter la classe en fonction |
|
| 4330 | + if (in_array($fonction, ['del', 'supprimer.gif'])) { |
|
| 4331 | + $class_lien .= ' danger'; |
|
| 4332 | + $class_bouton .= ' btn_danger'; |
|
| 4333 | + } elseif ($fonction == 'rien.gif') { |
|
| 4334 | + $fonction = ''; |
|
| 4335 | + } elseif ($fonction == 'delsafe') { |
|
| 4336 | + $fonction = 'del'; |
|
| 4337 | + } |
|
| 4338 | + |
|
| 4339 | + $fond_origine = $fond; |
|
| 4340 | + // Remappage des icone : article-24.png+new => article-new-24.png |
|
| 4341 | + if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) { |
|
| 4342 | + [$fond, $fonction] = $icone_renommer($fond, $fonction); |
|
| 4343 | + } |
|
| 4344 | + |
|
| 4345 | + // Ajouter le type d'objet dans la classe |
|
| 4346 | + $objet_type = substr(basename($fond), 0, -4); |
|
| 4347 | + $class_lien .= " $objet_type"; |
|
| 4348 | + $class_bouton .= " $objet_type"; |
|
| 4349 | + |
|
| 4350 | + // Texte |
|
| 4351 | + $alt = attribut_html($texte); |
|
| 4352 | + $title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ? |
|
| 4353 | + |
|
| 4354 | + // Liens : préparer les classes ajax |
|
| 4355 | + $ajax = ''; |
|
| 4356 | + if ($type === 'lien') { |
|
| 4357 | + if (strpos($class_lien, 'ajax') !== false) { |
|
| 4358 | + $ajax = 'ajax'; |
|
| 4359 | + if (strpos($class_lien, 'preload') !== false) { |
|
| 4360 | + $ajax .= ' preload'; |
|
| 4361 | + } |
|
| 4362 | + if (strpos($class_lien, 'nocache') !== false) { |
|
| 4363 | + $ajax .= ' nocache'; |
|
| 4364 | + } |
|
| 4365 | + $ajax = " class='$ajax'"; |
|
| 4366 | + } |
|
| 4367 | + } |
|
| 4368 | + |
|
| 4369 | + // Repérer la taille et l'ajouter dans la classe |
|
| 4370 | + $size = 24; |
|
| 4371 | + if ( |
|
| 4372 | + preg_match('/-([0-9]{1,3})[.](gif|png|svg)$/i', $fond, $match) |
|
| 4373 | + or preg_match('/-([0-9]{1,3})([.](gif|png|svg))?$/i', $fond_origine, $match) |
|
| 4374 | + ) { |
|
| 4375 | + $size = $match[1]; |
|
| 4376 | + } |
|
| 4377 | + $class_lien .= " s$size"; |
|
| 4378 | + $class_bouton .= " s$size"; |
|
| 4379 | + |
|
| 4380 | + // Icône |
|
| 4381 | + $icone = http_img_pack($fond, $alt, "width='$size' height='$size'"); |
|
| 4382 | + $icone = '<span class="icone-image' . ($fonction ? " icone-fonction icone-fonction-$fonction" : '') . "\">$icone</span>"; |
|
| 4383 | + |
|
| 4384 | + // Markup final |
|
| 4385 | + if ($type == 'lien') { |
|
| 4386 | + return "<span class='icone $class_lien'>" |
|
| 4387 | + . "<a href='$lien'$title$ajax$javascript>" |
|
| 4388 | + . $icone |
|
| 4389 | + . "<b>$texte</b>" |
|
| 4390 | + . "</a></span>\n"; |
|
| 4391 | + } else { |
|
| 4392 | + return bouton_action("$icone $texte", $lien, $class_bouton, $javascript, $alt); |
|
| 4393 | + } |
|
| 4394 | 4394 | } |
| 4395 | 4395 | |
| 4396 | 4396 | /** |
@@ -4414,7 +4414,7 @@ discard block |
||
| 4414 | 4414 | * Code HTML du lien |
| 4415 | 4415 | **/ |
| 4416 | 4416 | function icone_base($lien, $texte, $fond, $fonction = '', $class = '', $javascript = '') { |
| 4417 | - return prepare_icone_base('lien', $lien, $texte, $fond, $fonction, $class, $javascript); |
|
| 4417 | + return prepare_icone_base('lien', $lien, $texte, $fond, $fonction, $class, $javascript); |
|
| 4418 | 4418 | } |
| 4419 | 4419 | |
| 4420 | 4420 | /** |
@@ -4449,7 +4449,7 @@ discard block |
||
| 4449 | 4449 | * Code HTML du lien |
| 4450 | 4450 | **/ |
| 4451 | 4451 | function filtre_icone_verticale_dist($lien, $texte, $fond, $fonction = '', $class = '', $javascript = '') { |
| 4452 | - return icone_base($lien, $texte, $fond, $fonction, "verticale $class", $javascript); |
|
| 4452 | + return icone_base($lien, $texte, $fond, $fonction, "verticale $class", $javascript); |
|
| 4453 | 4453 | } |
| 4454 | 4454 | |
| 4455 | 4455 | /** |
@@ -4494,7 +4494,7 @@ discard block |
||
| 4494 | 4494 | * Code HTML du lien |
| 4495 | 4495 | **/ |
| 4496 | 4496 | function filtre_icone_horizontale_dist($lien, $texte, $fond, $fonction = '', $class = '', $javascript = '') { |
| 4497 | - return icone_base($lien, $texte, $fond, $fonction, "horizontale $class", $javascript); |
|
| 4497 | + return icone_base($lien, $texte, $fond, $fonction, "horizontale $class", $javascript); |
|
| 4498 | 4498 | } |
| 4499 | 4499 | |
| 4500 | 4500 | /** |
@@ -4525,7 +4525,7 @@ discard block |
||
| 4525 | 4525 | * Code HTML du lien |
| 4526 | 4526 | **/ |
| 4527 | 4527 | function filtre_bouton_action_horizontal_dist($lien, $texte, $fond, $fonction = '', $class = '', $confirm = '') { |
| 4528 | - return prepare_icone_base('bouton', $lien, $texte, $fond, $fonction, $class, $confirm); |
|
| 4528 | + return prepare_icone_base('bouton', $lien, $texte, $fond, $fonction, $class, $confirm); |
|
| 4529 | 4529 | } |
| 4530 | 4530 | |
| 4531 | 4531 | /** |
@@ -4556,7 +4556,7 @@ discard block |
||
| 4556 | 4556 | * Code HTML du lien |
| 4557 | 4557 | */ |
| 4558 | 4558 | function filtre_icone_dist($lien, $texte, $fond, $align = '', $fonction = '', $class = '', $javascript = '') { |
| 4559 | - return icone_base($lien, $texte, $fond, $fonction, "verticale $align $class", $javascript); |
|
| 4559 | + return icone_base($lien, $texte, $fond, $fonction, "verticale $align $class", $javascript); |
|
| 4560 | 4560 | } |
| 4561 | 4561 | |
| 4562 | 4562 | |
@@ -4578,7 +4578,7 @@ discard block |
||
| 4578 | 4578 | * @return array Liste des éléments |
| 4579 | 4579 | */ |
| 4580 | 4580 | function filtre_explode_dist($a, $b) { |
| 4581 | - return explode($b, $a); |
|
| 4581 | + return explode($b, $a); |
|
| 4582 | 4582 | } |
| 4583 | 4583 | |
| 4584 | 4584 | /** |
@@ -4599,7 +4599,7 @@ discard block |
||
| 4599 | 4599 | * @return string Texte |
| 4600 | 4600 | */ |
| 4601 | 4601 | function filtre_implode_dist($a, $b) { |
| 4602 | - return is_array($a) ? implode($b, $a) : $a; |
|
| 4602 | + return is_array($a) ? implode($b, $a) : $a; |
|
| 4603 | 4603 | } |
| 4604 | 4604 | |
| 4605 | 4605 | /** |
@@ -4608,24 +4608,24 @@ discard block |
||
| 4608 | 4608 | * @return string Code CSS |
| 4609 | 4609 | */ |
| 4610 | 4610 | function bando_images_background() { |
| 4611 | - include_spip('inc/bandeau'); |
|
| 4612 | - // recuperer tous les boutons et leurs images |
|
| 4613 | - $boutons = definir_barre_boutons(definir_barre_contexte(), true, false); |
|
| 4611 | + include_spip('inc/bandeau'); |
|
| 4612 | + // recuperer tous les boutons et leurs images |
|
| 4613 | + $boutons = definir_barre_boutons(definir_barre_contexte(), true, false); |
|
| 4614 | 4614 | |
| 4615 | - $res = ''; |
|
| 4616 | - foreach ($boutons as $page => $detail) { |
|
| 4617 | - $selecteur = (in_array($page, ['outils_rapides', 'outils_collaboratifs']) ? '' : '.navigation_avec_icones '); |
|
| 4618 | - if (is_array($detail->sousmenu)) { |
|
| 4619 | - foreach ($detail->sousmenu as $souspage => $sousdetail) { |
|
| 4620 | - if ($sousdetail->icone and strlen(trim($sousdetail->icone))) { |
|
| 4621 | - $img = http_img_variante_svg_si_possible($sousdetail->icone); |
|
| 4622 | - $res .= "\n$selecteur.bando2_$souspage {background-image:url($img);}"; |
|
| 4623 | - } |
|
| 4624 | - } |
|
| 4625 | - } |
|
| 4626 | - } |
|
| 4615 | + $res = ''; |
|
| 4616 | + foreach ($boutons as $page => $detail) { |
|
| 4617 | + $selecteur = (in_array($page, ['outils_rapides', 'outils_collaboratifs']) ? '' : '.navigation_avec_icones '); |
|
| 4618 | + if (is_array($detail->sousmenu)) { |
|
| 4619 | + foreach ($detail->sousmenu as $souspage => $sousdetail) { |
|
| 4620 | + if ($sousdetail->icone and strlen(trim($sousdetail->icone))) { |
|
| 4621 | + $img = http_img_variante_svg_si_possible($sousdetail->icone); |
|
| 4622 | + $res .= "\n$selecteur.bando2_$souspage {background-image:url($img);}"; |
|
| 4623 | + } |
|
| 4624 | + } |
|
| 4625 | + } |
|
| 4626 | + } |
|
| 4627 | 4627 | |
| 4628 | - return $res; |
|
| 4628 | + return $res; |
|
| 4629 | 4629 | } |
| 4630 | 4630 | |
| 4631 | 4631 | /** |
@@ -4650,27 +4650,27 @@ discard block |
||
| 4650 | 4650 | */ |
| 4651 | 4651 | function bouton_action($libelle, $url, $class = '', $confirm = '', $title = '', $callback = '') { |
| 4652 | 4652 | |
| 4653 | - // Classes : dispatcher `ajax` sur le formulaire |
|
| 4654 | - $class_form = ''; |
|
| 4655 | - if (strpos($class, 'ajax') !== false) { |
|
| 4656 | - $class_form = 'ajax'; |
|
| 4657 | - $class = str_replace('ajax', '', $class); |
|
| 4658 | - } |
|
| 4659 | - $class_btn = 'submit ' . trim($class); |
|
| 4653 | + // Classes : dispatcher `ajax` sur le formulaire |
|
| 4654 | + $class_form = ''; |
|
| 4655 | + if (strpos($class, 'ajax') !== false) { |
|
| 4656 | + $class_form = 'ajax'; |
|
| 4657 | + $class = str_replace('ajax', '', $class); |
|
| 4658 | + } |
|
| 4659 | + $class_btn = 'submit ' . trim($class); |
|
| 4660 | 4660 | |
| 4661 | - if ($confirm) { |
|
| 4662 | - $confirm = 'confirm("' . attribut_html($confirm) . '")'; |
|
| 4663 | - if ($callback) { |
|
| 4664 | - $callback = "$confirm?($callback):false"; |
|
| 4665 | - } else { |
|
| 4666 | - $callback = $confirm; |
|
| 4667 | - } |
|
| 4668 | - } |
|
| 4669 | - $onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : ''; |
|
| 4670 | - $title = $title ? " title='$title'" : ''; |
|
| 4661 | + if ($confirm) { |
|
| 4662 | + $confirm = 'confirm("' . attribut_html($confirm) . '")'; |
|
| 4663 | + if ($callback) { |
|
| 4664 | + $callback = "$confirm?($callback):false"; |
|
| 4665 | + } else { |
|
| 4666 | + $callback = $confirm; |
|
| 4667 | + } |
|
| 4668 | + } |
|
| 4669 | + $onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : ''; |
|
| 4670 | + $title = $title ? " title='$title'" : ''; |
|
| 4671 | 4671 | |
| 4672 | - return "<form class='bouton_action_post $class_form' method='post' action='$url'><div>" . form_hidden($url) |
|
| 4673 | - . "<button type='submit' class='$class_btn'$title$onclick>$libelle</button></div></form>"; |
|
| 4672 | + return "<form class='bouton_action_post $class_form' method='post' action='$url'><div>" . form_hidden($url) |
|
| 4673 | + . "<button type='submit' class='$class_btn'$title$onclick>$libelle</button></div></form>"; |
|
| 4674 | 4674 | } |
| 4675 | 4675 | |
| 4676 | 4676 | /** |
@@ -4693,101 +4693,101 @@ discard block |
||
| 4693 | 4693 | * @return string |
| 4694 | 4694 | */ |
| 4695 | 4695 | function generer_objet_info($id_objet, $type_objet, $info, $etoile = '', $params = []) { |
| 4696 | - static $trouver_table = null; |
|
| 4697 | - static $objets; |
|
| 4698 | - |
|
| 4699 | - // On verifie qu'on a tout ce qu'il faut |
|
| 4700 | - $id_objet = intval($id_objet); |
|
| 4701 | - if (!($id_objet and $type_objet and $info)) { |
|
| 4702 | - return ''; |
|
| 4703 | - } |
|
| 4704 | - |
|
| 4705 | - // si on a deja note que l'objet n'existe pas, ne pas aller plus loin |
|
| 4706 | - if (isset($objets[$type_objet]) and $objets[$type_objet] === false) { |
|
| 4707 | - return ''; |
|
| 4708 | - } |
|
| 4709 | - |
|
| 4710 | - // Si on demande l'url, on retourne direct la fonction |
|
| 4711 | - if ($info == 'url') { |
|
| 4712 | - return generer_objet_url($id_objet, $type_objet, ...$params); |
|
| 4713 | - } |
|
| 4714 | - |
|
| 4715 | - // Sinon on va tout chercher dans la table et on garde en memoire |
|
| 4716 | - $demande_titre = ($info === 'titre'); |
|
| 4717 | - $demande_introduction = ($info === 'introduction'); |
|
| 4718 | - |
|
| 4719 | - // 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 |
|
| 4720 | - if ( |
|
| 4721 | - !isset($objets[$type_objet][$id_objet]) |
|
| 4722 | - or |
|
| 4723 | - ($demande_titre and !isset($objets[$type_objet][$id_objet]['titre'])) |
|
| 4724 | - ) { |
|
| 4725 | - if (!$trouver_table) { |
|
| 4726 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 4727 | - } |
|
| 4728 | - $desc = $trouver_table(table_objet_sql($type_objet)); |
|
| 4729 | - if (!$desc) { |
|
| 4730 | - return $objets[$type_objet] = false; |
|
| 4731 | - } |
|
| 4732 | - |
|
| 4733 | - // Si on demande le titre, on le gere en interne |
|
| 4734 | - $champ_titre = ''; |
|
| 4735 | - if ($demande_titre) { |
|
| 4736 | - // si pas de titre declare mais champ titre, il sera peuple par le select * |
|
| 4737 | - $champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : ''; |
|
| 4738 | - } |
|
| 4739 | - include_spip('base/abstract_sql'); |
|
| 4740 | - include_spip('base/connect_sql'); |
|
| 4741 | - $objets[$type_objet][$id_objet] = sql_fetsel( |
|
| 4742 | - '*' . $champ_titre, |
|
| 4743 | - $desc['table_sql'], |
|
| 4744 | - id_table_objet($type_objet) . ' = ' . intval($id_objet) |
|
| 4745 | - ); |
|
| 4746 | - |
|
| 4747 | - // Toujours noter la longueur d'introduction, même si pas demandé cette fois-ci |
|
| 4748 | - $objets[$type_objet]['introduction_longueur'] = $desc['introduction_longueur'] ?? null; |
|
| 4749 | - } |
|
| 4750 | - |
|
| 4751 | - // Pour les fonction generer_xxx, si on demande l'introduction, |
|
| 4752 | - // ajouter la longueur au début des params supplémentaires |
|
| 4753 | - if ($demande_introduction) { |
|
| 4754 | - $introduction_longueur = $objets[$type_objet]['introduction_longueur']; |
|
| 4755 | - array_unshift($params, $introduction_longueur); |
|
| 4756 | - } |
|
| 4757 | - |
|
| 4758 | - // Si la fonction generer_TYPE_TRUC existe, on l'utilise pour formater $info_generee |
|
| 4759 | - if ( |
|
| 4760 | - $generer = charger_fonction("generer_${type_objet}_${info}", '', true) |
|
| 4761 | - // @deprecated 4.1 generer_TRUC_TYPE |
|
| 4762 | - or $generer = charger_fonction("generer_${info}_${type_objet}", '', true) |
|
| 4763 | - ) { |
|
| 4764 | - $info_generee = $generer($id_objet, $objets[$type_objet][$id_objet], ...$params); |
|
| 4765 | - } |
|
| 4766 | - // Si la fonction generer_objet_TRUC existe, on l'utilise pour formater $info_generee |
|
| 4767 | - elseif ( |
|
| 4768 | - $generer = charger_fonction("generer_objet_${info}", '', true) |
|
| 4769 | - // @deprecated 4.1 generer_TRUC_entite |
|
| 4770 | - or $generer = charger_fonction("generer_${info}_entite", '', true) |
|
| 4771 | - ) { |
|
| 4772 | - $info_generee = $generer($id_objet, $type_objet, $objets[$type_objet][$id_objet], ...$params); |
|
| 4773 | - } // Sinon on prend directement le champ SQL tel quel |
|
| 4774 | - else { |
|
| 4775 | - $info_generee = ($objets[$type_objet][$id_objet][$info] ?? ''); |
|
| 4776 | - } |
|
| 4777 | - |
|
| 4778 | - // On va ensuite appliquer les traitements automatiques si besoin |
|
| 4779 | - if (!$etoile) { |
|
| 4780 | - // FIXME: on fournit un ENV minimum avec id et type et connect='' |
|
| 4781 | - // mais ce fonctionnement est a ameliorer ! |
|
| 4782 | - $info_generee = appliquer_traitement_champ( |
|
| 4783 | - $info_generee, |
|
| 4784 | - $info, |
|
| 4785 | - table_objet($type_objet), |
|
| 4786 | - ['id_objet' => $id_objet, 'objet' => $type_objet, ''] |
|
| 4787 | - ); |
|
| 4788 | - } |
|
| 4789 | - |
|
| 4790 | - return $info_generee; |
|
| 4696 | + static $trouver_table = null; |
|
| 4697 | + static $objets; |
|
| 4698 | + |
|
| 4699 | + // On verifie qu'on a tout ce qu'il faut |
|
| 4700 | + $id_objet = intval($id_objet); |
|
| 4701 | + if (!($id_objet and $type_objet and $info)) { |
|
| 4702 | + return ''; |
|
| 4703 | + } |
|
| 4704 | + |
|
| 4705 | + // si on a deja note que l'objet n'existe pas, ne pas aller plus loin |
|
| 4706 | + if (isset($objets[$type_objet]) and $objets[$type_objet] === false) { |
|
| 4707 | + return ''; |
|
| 4708 | + } |
|
| 4709 | + |
|
| 4710 | + // Si on demande l'url, on retourne direct la fonction |
|
| 4711 | + if ($info == 'url') { |
|
| 4712 | + return generer_objet_url($id_objet, $type_objet, ...$params); |
|
| 4713 | + } |
|
| 4714 | + |
|
| 4715 | + // Sinon on va tout chercher dans la table et on garde en memoire |
|
| 4716 | + $demande_titre = ($info === 'titre'); |
|
| 4717 | + $demande_introduction = ($info === 'introduction'); |
|
| 4718 | + |
|
| 4719 | + // 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 |
|
| 4720 | + if ( |
|
| 4721 | + !isset($objets[$type_objet][$id_objet]) |
|
| 4722 | + or |
|
| 4723 | + ($demande_titre and !isset($objets[$type_objet][$id_objet]['titre'])) |
|
| 4724 | + ) { |
|
| 4725 | + if (!$trouver_table) { |
|
| 4726 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 4727 | + } |
|
| 4728 | + $desc = $trouver_table(table_objet_sql($type_objet)); |
|
| 4729 | + if (!$desc) { |
|
| 4730 | + return $objets[$type_objet] = false; |
|
| 4731 | + } |
|
| 4732 | + |
|
| 4733 | + // Si on demande le titre, on le gere en interne |
|
| 4734 | + $champ_titre = ''; |
|
| 4735 | + if ($demande_titre) { |
|
| 4736 | + // si pas de titre declare mais champ titre, il sera peuple par le select * |
|
| 4737 | + $champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : ''; |
|
| 4738 | + } |
|
| 4739 | + include_spip('base/abstract_sql'); |
|
| 4740 | + include_spip('base/connect_sql'); |
|
| 4741 | + $objets[$type_objet][$id_objet] = sql_fetsel( |
|
| 4742 | + '*' . $champ_titre, |
|
| 4743 | + $desc['table_sql'], |
|
| 4744 | + id_table_objet($type_objet) . ' = ' . intval($id_objet) |
|
| 4745 | + ); |
|
| 4746 | + |
|
| 4747 | + // Toujours noter la longueur d'introduction, même si pas demandé cette fois-ci |
|
| 4748 | + $objets[$type_objet]['introduction_longueur'] = $desc['introduction_longueur'] ?? null; |
|
| 4749 | + } |
|
| 4750 | + |
|
| 4751 | + // Pour les fonction generer_xxx, si on demande l'introduction, |
|
| 4752 | + // ajouter la longueur au début des params supplémentaires |
|
| 4753 | + if ($demande_introduction) { |
|
| 4754 | + $introduction_longueur = $objets[$type_objet]['introduction_longueur']; |
|
| 4755 | + array_unshift($params, $introduction_longueur); |
|
| 4756 | + } |
|
| 4757 | + |
|
| 4758 | + // Si la fonction generer_TYPE_TRUC existe, on l'utilise pour formater $info_generee |
|
| 4759 | + if ( |
|
| 4760 | + $generer = charger_fonction("generer_${type_objet}_${info}", '', true) |
|
| 4761 | + // @deprecated 4.1 generer_TRUC_TYPE |
|
| 4762 | + or $generer = charger_fonction("generer_${info}_${type_objet}", '', true) |
|
| 4763 | + ) { |
|
| 4764 | + $info_generee = $generer($id_objet, $objets[$type_objet][$id_objet], ...$params); |
|
| 4765 | + } |
|
| 4766 | + // Si la fonction generer_objet_TRUC existe, on l'utilise pour formater $info_generee |
|
| 4767 | + elseif ( |
|
| 4768 | + $generer = charger_fonction("generer_objet_${info}", '', true) |
|
| 4769 | + // @deprecated 4.1 generer_TRUC_entite |
|
| 4770 | + or $generer = charger_fonction("generer_${info}_entite", '', true) |
|
| 4771 | + ) { |
|
| 4772 | + $info_generee = $generer($id_objet, $type_objet, $objets[$type_objet][$id_objet], ...$params); |
|
| 4773 | + } // Sinon on prend directement le champ SQL tel quel |
|
| 4774 | + else { |
|
| 4775 | + $info_generee = ($objets[$type_objet][$id_objet][$info] ?? ''); |
|
| 4776 | + } |
|
| 4777 | + |
|
| 4778 | + // On va ensuite appliquer les traitements automatiques si besoin |
|
| 4779 | + if (!$etoile) { |
|
| 4780 | + // FIXME: on fournit un ENV minimum avec id et type et connect='' |
|
| 4781 | + // mais ce fonctionnement est a ameliorer ! |
|
| 4782 | + $info_generee = appliquer_traitement_champ( |
|
| 4783 | + $info_generee, |
|
| 4784 | + $info, |
|
| 4785 | + table_objet($type_objet), |
|
| 4786 | + ['id_objet' => $id_objet, 'objet' => $type_objet, ''] |
|
| 4787 | + ); |
|
| 4788 | + } |
|
| 4789 | + |
|
| 4790 | + return $info_generee; |
|
| 4791 | 4791 | } |
| 4792 | 4792 | |
| 4793 | 4793 | /** |
@@ -4795,7 +4795,7 @@ discard block |
||
| 4795 | 4795 | * @see generer_objet_info |
| 4796 | 4796 | */ |
| 4797 | 4797 | function generer_info_entite($id_objet, $type_objet, $info, $etoile = '', $params = []) { |
| 4798 | - return generer_objet_info($id_objet, $type_objet, $info, $etoile, $params); |
|
| 4798 | + return generer_objet_info($id_objet, $type_objet, $info, $etoile, $params); |
|
| 4799 | 4799 | } |
| 4800 | 4800 | |
| 4801 | 4801 | /** |
@@ -4828,36 +4828,36 @@ discard block |
||
| 4828 | 4828 | */ |
| 4829 | 4829 | function generer_objet_introduction($id_objet, $type_objet, $ligne_sql, $introduction_longueur = null, $longueur_ou_suite = null, $suite = null, string $connect = '') { |
| 4830 | 4830 | |
| 4831 | - $descriptif = $ligne_sql['descriptif'] ?? ''; |
|
| 4832 | - $texte = $ligne_sql['texte'] ?? ''; |
|
| 4833 | - // En absence de descriptif, on se rabat sur chapo + texte |
|
| 4834 | - if (isset($ligne_sql['chapo'])) { |
|
| 4835 | - $chapo = $ligne_sql['chapo']; |
|
| 4836 | - $texte = strlen($descriptif) ? |
|
| 4837 | - '' : |
|
| 4838 | - "$chapo \n\n $texte"; |
|
| 4839 | - } |
|
| 4831 | + $descriptif = $ligne_sql['descriptif'] ?? ''; |
|
| 4832 | + $texte = $ligne_sql['texte'] ?? ''; |
|
| 4833 | + // En absence de descriptif, on se rabat sur chapo + texte |
|
| 4834 | + if (isset($ligne_sql['chapo'])) { |
|
| 4835 | + $chapo = $ligne_sql['chapo']; |
|
| 4836 | + $texte = strlen($descriptif) ? |
|
| 4837 | + '' : |
|
| 4838 | + "$chapo \n\n $texte"; |
|
| 4839 | + } |
|
| 4840 | 4840 | |
| 4841 | - // Longueur en paramètre, sinon celle renseignée dans la description de l'objet, sinon valeur en dur |
|
| 4842 | - if (!intval($longueur_ou_suite)) { |
|
| 4843 | - $longueur = intval($introduction_longueur ?: 600); |
|
| 4844 | - } else { |
|
| 4845 | - $longueur = intval($longueur_ou_suite); |
|
| 4846 | - } |
|
| 4841 | + // Longueur en paramètre, sinon celle renseignée dans la description de l'objet, sinon valeur en dur |
|
| 4842 | + if (!intval($longueur_ou_suite)) { |
|
| 4843 | + $longueur = intval($introduction_longueur ?: 600); |
|
| 4844 | + } else { |
|
| 4845 | + $longueur = intval($longueur_ou_suite); |
|
| 4846 | + } |
|
| 4847 | 4847 | |
| 4848 | - // On peut optionnellement passer la suite en 1er paramètre de la balise |
|
| 4849 | - // Ex : #INTRODUCTION{...} |
|
| 4850 | - if ( |
|
| 4851 | - is_null($suite) |
|
| 4852 | - and !intval($longueur_ou_suite) |
|
| 4853 | - ) { |
|
| 4854 | - $suite = $longueur_ou_suite; |
|
| 4855 | - } |
|
| 4848 | + // On peut optionnellement passer la suite en 1er paramètre de la balise |
|
| 4849 | + // Ex : #INTRODUCTION{...} |
|
| 4850 | + if ( |
|
| 4851 | + is_null($suite) |
|
| 4852 | + and !intval($longueur_ou_suite) |
|
| 4853 | + ) { |
|
| 4854 | + $suite = $longueur_ou_suite; |
|
| 4855 | + } |
|
| 4856 | 4856 | |
| 4857 | - $f = chercher_filtre('introduction'); |
|
| 4858 | - $introduction = $f($descriptif, $texte, $longueur, $connect, $suite); |
|
| 4857 | + $f = chercher_filtre('introduction'); |
|
| 4858 | + $introduction = $f($descriptif, $texte, $longueur, $connect, $suite); |
|
| 4859 | 4859 | |
| 4860 | - return $introduction; |
|
| 4860 | + return $introduction; |
|
| 4861 | 4861 | } |
| 4862 | 4862 | |
| 4863 | 4863 | /** |
@@ -4865,7 +4865,7 @@ discard block |
||
| 4865 | 4865 | * @see generer_objet_introduction |
| 4866 | 4866 | */ |
| 4867 | 4867 | function generer_introduction_entite($id_objet, $type_objet, $ligne_sql, $introduction_longueur = null, $longueur_ou_suite = null, $suite = null, string $connect = '') { |
| 4868 | - return generer_objet_introduction($id_objet, $type_objet, $ligne_sql, $introduction_longueur, $longueur_ou_suite, $suite, $connect); |
|
| 4868 | + return generer_objet_introduction($id_objet, $type_objet, $ligne_sql, $introduction_longueur, $longueur_ou_suite, $suite, $connect); |
|
| 4869 | 4869 | } |
| 4870 | 4870 | |
| 4871 | 4871 | /** |
@@ -4879,44 +4879,44 @@ discard block |
||
| 4879 | 4879 | * @return string |
| 4880 | 4880 | */ |
| 4881 | 4881 | function appliquer_traitement_champ($texte, $champ, $table_objet = '', $env = [], string $connect = '') { |
| 4882 | - if (!$champ) { |
|
| 4883 | - return $texte; |
|
| 4884 | - } |
|
| 4882 | + if (!$champ) { |
|
| 4883 | + return $texte; |
|
| 4884 | + } |
|
| 4885 | 4885 | |
| 4886 | - // On charge les définitions des traitements (inc/texte et fichiers de fonctions) |
|
| 4887 | - // car il ne faut pas partir du principe que c'est déjà chargé (form ajax, etc) |
|
| 4888 | - include_fichiers_fonctions(); |
|
| 4886 | + // On charge les définitions des traitements (inc/texte et fichiers de fonctions) |
|
| 4887 | + // car il ne faut pas partir du principe que c'est déjà chargé (form ajax, etc) |
|
| 4888 | + include_fichiers_fonctions(); |
|
| 4889 | 4889 | |
| 4890 | - $champ = strtoupper($champ); |
|
| 4891 | - $traitements = $GLOBALS['table_des_traitements'][$champ] ?? false; |
|
| 4892 | - if (!$traitements or !is_array($traitements)) { |
|
| 4893 | - return $texte; |
|
| 4894 | - } |
|
| 4890 | + $champ = strtoupper($champ); |
|
| 4891 | + $traitements = $GLOBALS['table_des_traitements'][$champ] ?? false; |
|
| 4892 | + if (!$traitements or !is_array($traitements)) { |
|
| 4893 | + return $texte; |
|
| 4894 | + } |
|
| 4895 | 4895 | |
| 4896 | - $traitement = ''; |
|
| 4897 | - if ($table_objet and (!isset($traitements[0]) or count($traitements) > 1)) { |
|
| 4898 | - // necessaire pour prendre en charge les vieux appels avec un table_objet_sql en 3e arg |
|
| 4899 | - $table_objet = table_objet($table_objet); |
|
| 4900 | - if (isset($traitements[$table_objet])) { |
|
| 4901 | - $traitement = $traitements[$table_objet]; |
|
| 4902 | - } |
|
| 4903 | - } |
|
| 4904 | - if (!$traitement and isset($traitements[0])) { |
|
| 4905 | - $traitement = $traitements[0]; |
|
| 4906 | - } |
|
| 4907 | - // (sinon prendre le premier de la liste par defaut ?) |
|
| 4896 | + $traitement = ''; |
|
| 4897 | + if ($table_objet and (!isset($traitements[0]) or count($traitements) > 1)) { |
|
| 4898 | + // necessaire pour prendre en charge les vieux appels avec un table_objet_sql en 3e arg |
|
| 4899 | + $table_objet = table_objet($table_objet); |
|
| 4900 | + if (isset($traitements[$table_objet])) { |
|
| 4901 | + $traitement = $traitements[$table_objet]; |
|
| 4902 | + } |
|
| 4903 | + } |
|
| 4904 | + if (!$traitement and isset($traitements[0])) { |
|
| 4905 | + $traitement = $traitements[0]; |
|
| 4906 | + } |
|
| 4907 | + // (sinon prendre le premier de la liste par defaut ?) |
|
| 4908 | 4908 | |
| 4909 | - if (!$traitement) { |
|
| 4910 | - return $texte; |
|
| 4911 | - } |
|
| 4909 | + if (!$traitement) { |
|
| 4910 | + return $texte; |
|
| 4911 | + } |
|
| 4912 | 4912 | |
| 4913 | - $traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement); |
|
| 4913 | + $traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement); |
|
| 4914 | 4914 | |
| 4915 | - // Fournir $connect et $Pile[0] au traitement si besoin |
|
| 4916 | - $Pile = [0 => $env]; |
|
| 4917 | - eval("\$texte = $traitement;"); |
|
| 4915 | + // Fournir $connect et $Pile[0] au traitement si besoin |
|
| 4916 | + $Pile = [0 => $env]; |
|
| 4917 | + eval("\$texte = $traitement;"); |
|
| 4918 | 4918 | |
| 4919 | - return $texte; |
|
| 4919 | + return $texte; |
|
| 4920 | 4920 | } |
| 4921 | 4921 | |
| 4922 | 4922 | |
@@ -4930,21 +4930,21 @@ discard block |
||
| 4930 | 4930 | * @return string |
| 4931 | 4931 | */ |
| 4932 | 4932 | function generer_objet_lien($id_objet, $objet, $longueur = 80, $connect = null) { |
| 4933 | - include_spip('inc/liens'); |
|
| 4934 | - $titre = traiter_raccourci_titre($id_objet, $objet, $connect); |
|
| 4935 | - // lorsque l'objet n'est plus declare (plugin desactive par exemple) |
|
| 4936 | - // le raccourcis n'est plus valide |
|
| 4937 | - $titre = typo($titre['titre']) ?? ''; |
|
| 4938 | - // on essaye avec generer_info_entite ? |
|
| 4939 | - if (!strlen($titre) and !$connect) { |
|
| 4940 | - $titre = generer_objet_info($id_objet, $objet, 'titre'); |
|
| 4941 | - } |
|
| 4942 | - if (!strlen($titre)) { |
|
| 4943 | - $titre = _T('info_sans_titre'); |
|
| 4944 | - } |
|
| 4945 | - $url = generer_objet_url($id_objet, $objet, '', '', $connect); |
|
| 4933 | + include_spip('inc/liens'); |
|
| 4934 | + $titre = traiter_raccourci_titre($id_objet, $objet, $connect); |
|
| 4935 | + // lorsque l'objet n'est plus declare (plugin desactive par exemple) |
|
| 4936 | + // le raccourcis n'est plus valide |
|
| 4937 | + $titre = typo($titre['titre']) ?? ''; |
|
| 4938 | + // on essaye avec generer_info_entite ? |
|
| 4939 | + if (!strlen($titre) and !$connect) { |
|
| 4940 | + $titre = generer_objet_info($id_objet, $objet, 'titre'); |
|
| 4941 | + } |
|
| 4942 | + if (!strlen($titre)) { |
|
| 4943 | + $titre = _T('info_sans_titre'); |
|
| 4944 | + } |
|
| 4945 | + $url = generer_objet_url($id_objet, $objet, '', '', $connect); |
|
| 4946 | 4946 | |
| 4947 | - return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . '</a>'; |
|
| 4947 | + return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . '</a>'; |
|
| 4948 | 4948 | } |
| 4949 | 4949 | |
| 4950 | 4950 | /** |
@@ -4952,7 +4952,7 @@ discard block |
||
| 4952 | 4952 | * @see generer_objet_lien |
| 4953 | 4953 | */ |
| 4954 | 4954 | function generer_lien_entite($id_objet, $objet, $longueur = 80, $connect = null) { |
| 4955 | - return generer_objet_lien($id_objet, $objet, $longueur, $connect); |
|
| 4955 | + return generer_objet_lien($id_objet, $objet, $longueur, $connect); |
|
| 4956 | 4956 | } |
| 4957 | 4957 | |
| 4958 | 4958 | /** |
@@ -4968,15 +4968,15 @@ discard block |
||
| 4968 | 4968 | * @return string |
| 4969 | 4969 | */ |
| 4970 | 4970 | function wrap($texte, $wrap) { |
| 4971 | - $balises = extraire_balises($wrap); |
|
| 4972 | - if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) { |
|
| 4973 | - $texte = $wrap . $texte; |
|
| 4974 | - $regs = array_reverse($regs[1]); |
|
| 4975 | - $wrap = '</' . implode('></', $regs) . '>'; |
|
| 4976 | - $texte = $texte . $wrap; |
|
| 4977 | - } |
|
| 4971 | + $balises = extraire_balises($wrap); |
|
| 4972 | + if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) { |
|
| 4973 | + $texte = $wrap . $texte; |
|
| 4974 | + $regs = array_reverse($regs[1]); |
|
| 4975 | + $wrap = '</' . implode('></', $regs) . '>'; |
|
| 4976 | + $texte = $texte . $wrap; |
|
| 4977 | + } |
|
| 4978 | 4978 | |
| 4979 | - return $texte; |
|
| 4979 | + return $texte; |
|
| 4980 | 4980 | } |
| 4981 | 4981 | |
| 4982 | 4982 | |
@@ -4996,44 +4996,44 @@ discard block |
||
| 4996 | 4996 | * @return array|mixed|string |
| 4997 | 4997 | */ |
| 4998 | 4998 | function filtre_print_dist($u, $join = '<br />', $indent = 0) { |
| 4999 | - if (is_string($u)) { |
|
| 5000 | - $u = typo($u); |
|
| 4999 | + if (is_string($u)) { |
|
| 5000 | + $u = typo($u); |
|
| 5001 | 5001 | |
| 5002 | - return $u; |
|
| 5003 | - } |
|
| 5002 | + return $u; |
|
| 5003 | + } |
|
| 5004 | 5004 | |
| 5005 | - // caster $u en array si besoin |
|
| 5006 | - if (is_object($u)) { |
|
| 5007 | - $u = (array)$u; |
|
| 5008 | - } |
|
| 5005 | + // caster $u en array si besoin |
|
| 5006 | + if (is_object($u)) { |
|
| 5007 | + $u = (array)$u; |
|
| 5008 | + } |
|
| 5009 | 5009 | |
| 5010 | - if (is_array($u)) { |
|
| 5011 | - $out = ''; |
|
| 5012 | - // toutes les cles sont numeriques ? |
|
| 5013 | - // et aucun enfant n'est un tableau |
|
| 5014 | - // liste simple separee par des virgules |
|
| 5015 | - $numeric_keys = array_map('is_numeric', array_keys($u)); |
|
| 5016 | - $array_values = array_map('is_array', $u); |
|
| 5017 | - $object_values = array_map('is_object', $u); |
|
| 5018 | - if ( |
|
| 5019 | - array_sum($numeric_keys) == count($numeric_keys) |
|
| 5020 | - and !array_sum($array_values) |
|
| 5021 | - and !array_sum($object_values) |
|
| 5022 | - ) { |
|
| 5023 | - return join(', ', array_map('filtre_print_dist', $u)); |
|
| 5024 | - } |
|
| 5010 | + if (is_array($u)) { |
|
| 5011 | + $out = ''; |
|
| 5012 | + // toutes les cles sont numeriques ? |
|
| 5013 | + // et aucun enfant n'est un tableau |
|
| 5014 | + // liste simple separee par des virgules |
|
| 5015 | + $numeric_keys = array_map('is_numeric', array_keys($u)); |
|
| 5016 | + $array_values = array_map('is_array', $u); |
|
| 5017 | + $object_values = array_map('is_object', $u); |
|
| 5018 | + if ( |
|
| 5019 | + array_sum($numeric_keys) == count($numeric_keys) |
|
| 5020 | + and !array_sum($array_values) |
|
| 5021 | + and !array_sum($object_values) |
|
| 5022 | + ) { |
|
| 5023 | + return join(', ', array_map('filtre_print_dist', $u)); |
|
| 5024 | + } |
|
| 5025 | 5025 | |
| 5026 | - // sinon on passe a la ligne et on indente |
|
| 5027 | - $i_str = str_pad('', $indent, ' '); |
|
| 5028 | - foreach ($u as $k => $v) { |
|
| 5029 | - $out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2); |
|
| 5030 | - } |
|
| 5026 | + // sinon on passe a la ligne et on indente |
|
| 5027 | + $i_str = str_pad('', $indent, ' '); |
|
| 5028 | + foreach ($u as $k => $v) { |
|
| 5029 | + $out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2); |
|
| 5030 | + } |
|
| 5031 | 5031 | |
| 5032 | - return $out; |
|
| 5033 | - } |
|
| 5032 | + return $out; |
|
| 5033 | + } |
|
| 5034 | 5034 | |
| 5035 | - // on sait pas quoi faire... |
|
| 5036 | - return $u; |
|
| 5035 | + // on sait pas quoi faire... |
|
| 5036 | + return $u; |
|
| 5037 | 5037 | } |
| 5038 | 5038 | |
| 5039 | 5039 | |
@@ -5046,10 +5046,10 @@ discard block |
||
| 5046 | 5046 | * @return string|array |
| 5047 | 5047 | */ |
| 5048 | 5048 | function objet_info($objet, $info) { |
| 5049 | - $table = table_objet_sql($objet); |
|
| 5050 | - $infos = lister_tables_objets_sql($table); |
|
| 5049 | + $table = table_objet_sql($objet); |
|
| 5050 | + $infos = lister_tables_objets_sql($table); |
|
| 5051 | 5051 | |
| 5052 | - return ($infos[$info] ?? ''); |
|
| 5052 | + return ($infos[$info] ?? ''); |
|
| 5053 | 5053 | } |
| 5054 | 5054 | |
| 5055 | 5055 | /** |
@@ -5064,11 +5064,11 @@ discard block |
||
| 5064 | 5064 | * Texte traduit du comptage, tel que '3 articles' |
| 5065 | 5065 | */ |
| 5066 | 5066 | function objet_afficher_nb($nb, $objet) { |
| 5067 | - if (!$nb) { |
|
| 5068 | - return _T(objet_info($objet, 'info_aucun_objet')); |
|
| 5069 | - } else { |
|
| 5070 | - return _T(objet_info($objet, $nb == 1 ? 'info_1_objet' : 'info_nb_objets'), ['nb' => $nb]); |
|
| 5071 | - } |
|
| 5067 | + if (!$nb) { |
|
| 5068 | + return _T(objet_info($objet, 'info_aucun_objet')); |
|
| 5069 | + } else { |
|
| 5070 | + return _T(objet_info($objet, $nb == 1 ? 'info_1_objet' : 'info_nb_objets'), ['nb' => $nb]); |
|
| 5071 | + } |
|
| 5072 | 5072 | } |
| 5073 | 5073 | |
| 5074 | 5074 | /** |
@@ -5080,11 +5080,11 @@ discard block |
||
| 5080 | 5080 | * @return string |
| 5081 | 5081 | */ |
| 5082 | 5082 | function objet_icone($objet, $taille = 24, $class = '') { |
| 5083 | - $icone = objet_info($objet, 'icone_objet') . '-' . $taille . '.png'; |
|
| 5084 | - $icone = chemin_image($icone); |
|
| 5085 | - $balise_img = charger_filtre('balise_img'); |
|
| 5083 | + $icone = objet_info($objet, 'icone_objet') . '-' . $taille . '.png'; |
|
| 5084 | + $icone = chemin_image($icone); |
|
| 5085 | + $balise_img = charger_filtre('balise_img'); |
|
| 5086 | 5086 | |
| 5087 | - return $icone ? $balise_img($icone, _T(objet_info($objet, 'texte_objet')), $class, $taille) : ''; |
|
| 5087 | + return $icone ? $balise_img($icone, _T(objet_info($objet, 'texte_objet')), $class, $taille) : ''; |
|
| 5088 | 5088 | } |
| 5089 | 5089 | |
| 5090 | 5090 | /** |
@@ -5105,12 +5105,12 @@ discard block |
||
| 5105 | 5105 | * @return string |
| 5106 | 5106 | */ |
| 5107 | 5107 | function objet_T($objet, $chaine, $args = [], $options = []) { |
| 5108 | - $chaine = explode(':', $chaine); |
|
| 5109 | - if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, ['force' => false]))) { |
|
| 5110 | - return $t; |
|
| 5111 | - } |
|
| 5112 | - $chaine = implode(':', $chaine); |
|
| 5113 | - return _T($chaine, $args, $options); |
|
| 5108 | + $chaine = explode(':', $chaine); |
|
| 5109 | + if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, ['force' => false]))) { |
|
| 5110 | + return $t; |
|
| 5111 | + } |
|
| 5112 | + $chaine = implode(':', $chaine); |
|
| 5113 | + return _T($chaine, $args, $options); |
|
| 5114 | 5114 | } |
| 5115 | 5115 | |
| 5116 | 5116 | /** |
@@ -5124,18 +5124,18 @@ discard block |
||
| 5124 | 5124 | * @return string Code HTML |
| 5125 | 5125 | */ |
| 5126 | 5126 | function insert_head_css_conditionnel($flux) { |
| 5127 | - if ( |
|
| 5128 | - strpos($flux, '<!-- insert_head_css -->') === false |
|
| 5129 | - and $p = strpos($flux, '<!-- insert_head -->') |
|
| 5130 | - ) { |
|
| 5131 | - // plutot avant le premier js externe (jquery) pour etre non bloquant |
|
| 5132 | - if ($p1 = stripos($flux, '<script src=') and $p1 < $p) { |
|
| 5133 | - $p = $p1; |
|
| 5134 | - } |
|
| 5135 | - $flux = substr_replace($flux, pipeline('insert_head_css', '<!-- insert_head_css -->'), $p, 0); |
|
| 5136 | - } |
|
| 5127 | + if ( |
|
| 5128 | + strpos($flux, '<!-- insert_head_css -->') === false |
|
| 5129 | + and $p = strpos($flux, '<!-- insert_head -->') |
|
| 5130 | + ) { |
|
| 5131 | + // plutot avant le premier js externe (jquery) pour etre non bloquant |
|
| 5132 | + if ($p1 = stripos($flux, '<script src=') and $p1 < $p) { |
|
| 5133 | + $p = $p1; |
|
| 5134 | + } |
|
| 5135 | + $flux = substr_replace($flux, pipeline('insert_head_css', '<!-- insert_head_css -->'), $p, 0); |
|
| 5136 | + } |
|
| 5137 | 5137 | |
| 5138 | - return $flux; |
|
| 5138 | + return $flux; |
|
| 5139 | 5139 | } |
| 5140 | 5140 | |
| 5141 | 5141 | /** |
@@ -5158,72 +5158,72 @@ discard block |
||
| 5158 | 5158 | * @return string |
| 5159 | 5159 | */ |
| 5160 | 5160 | function produire_fond_statique($fond, $contexte = [], $options = [], string $connect = '') { |
| 5161 | - if (isset($contexte['format'])) { |
|
| 5162 | - $extension = $contexte['format']; |
|
| 5163 | - unset($contexte['format']); |
|
| 5164 | - } else { |
|
| 5165 | - $extension = 'html'; |
|
| 5166 | - if (preg_match(',[.](css|js|json|xml|svg)$,', $fond, $m)) { |
|
| 5167 | - $extension = $m[1]; |
|
| 5168 | - } |
|
| 5169 | - } |
|
| 5170 | - // recuperer le contenu produit par le squelette |
|
| 5171 | - $options['raw'] = true; |
|
| 5172 | - $cache = recuperer_fond($fond, $contexte, $options, $connect); |
|
| 5173 | - |
|
| 5174 | - // calculer le nom de la css |
|
| 5175 | - $dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension); |
|
| 5176 | - $nom_safe = preg_replace(',\W,', '_', str_replace('.', '_', $fond)); |
|
| 5177 | - $contexte_implicite = calculer_contexte_implicite(); |
|
| 5178 | - |
|
| 5179 | - // par defaut on hash selon les contextes qui sont a priori moins variables |
|
| 5180 | - // mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu |
|
| 5181 | - // reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine |
|
| 5182 | - if (isset($options['hash_on_content']) and $options['hash_on_content']) { |
|
| 5183 | - $hash = md5($contexte_implicite['host'] . '::' . $cache); |
|
| 5184 | - } |
|
| 5185 | - else { |
|
| 5186 | - unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js |
|
| 5187 | - ksort($contexte); |
|
| 5188 | - $hash = md5($fond . json_encode($contexte_implicite, JSON_THROW_ON_ERROR) . json_encode($contexte, JSON_THROW_ON_ERROR) . $connect); |
|
| 5189 | - } |
|
| 5190 | - $filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension"; |
|
| 5191 | - |
|
| 5192 | - // mettre a jour le fichier si il n'existe pas |
|
| 5193 | - // ou trop ancien |
|
| 5194 | - // le dernier fichier produit est toujours suffixe par .last |
|
| 5195 | - // et recopie sur le fichier cible uniquement si il change |
|
| 5196 | - if ( |
|
| 5197 | - !file_exists($filename) |
|
| 5198 | - or !file_exists($filename . '.last') |
|
| 5199 | - or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . '.last') < $cache['lastmodified']) |
|
| 5200 | - or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul') |
|
| 5201 | - ) { |
|
| 5202 | - $contenu = $cache['texte']; |
|
| 5203 | - // passer les urls en absolu si c'est une css |
|
| 5204 | - if ($extension == 'css') { |
|
| 5205 | - $contenu = urls_absolues_css( |
|
| 5206 | - $contenu, |
|
| 5207 | - test_espace_prive() ? generer_url_ecrire('accueil') : generer_url_public($fond) |
|
| 5208 | - ); |
|
| 5209 | - } |
|
| 5210 | - |
|
| 5211 | - $comment = ''; |
|
| 5212 | - // ne pas insérer de commentaire sur certains formats |
|
| 5213 | - if (!in_array($extension, ['json', 'xml', 'svg'])) { |
|
| 5214 | - $comment = "/* #PRODUIRE{fond=$fond"; |
|
| 5215 | - foreach ($contexte as $k => $v) { |
|
| 5216 | - $comment .= ",$k=$v"; |
|
| 5217 | - } |
|
| 5218 | - // pas de date dans le commentaire car sinon ca invalide le md5 et force la maj |
|
| 5219 | - // mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non |
|
| 5220 | - $comment .= "}\n md5:" . md5($contenu) . " */\n"; |
|
| 5221 | - } |
|
| 5222 | - // et ecrire le fichier si il change |
|
| 5223 | - ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true); |
|
| 5224 | - } |
|
| 5225 | - |
|
| 5226 | - return timestamp($filename); |
|
| 5161 | + if (isset($contexte['format'])) { |
|
| 5162 | + $extension = $contexte['format']; |
|
| 5163 | + unset($contexte['format']); |
|
| 5164 | + } else { |
|
| 5165 | + $extension = 'html'; |
|
| 5166 | + if (preg_match(',[.](css|js|json|xml|svg)$,', $fond, $m)) { |
|
| 5167 | + $extension = $m[1]; |
|
| 5168 | + } |
|
| 5169 | + } |
|
| 5170 | + // recuperer le contenu produit par le squelette |
|
| 5171 | + $options['raw'] = true; |
|
| 5172 | + $cache = recuperer_fond($fond, $contexte, $options, $connect); |
|
| 5173 | + |
|
| 5174 | + // calculer le nom de la css |
|
| 5175 | + $dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension); |
|
| 5176 | + $nom_safe = preg_replace(',\W,', '_', str_replace('.', '_', $fond)); |
|
| 5177 | + $contexte_implicite = calculer_contexte_implicite(); |
|
| 5178 | + |
|
| 5179 | + // par defaut on hash selon les contextes qui sont a priori moins variables |
|
| 5180 | + // mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu |
|
| 5181 | + // reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine |
|
| 5182 | + if (isset($options['hash_on_content']) and $options['hash_on_content']) { |
|
| 5183 | + $hash = md5($contexte_implicite['host'] . '::' . $cache); |
|
| 5184 | + } |
|
| 5185 | + else { |
|
| 5186 | + unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js |
|
| 5187 | + ksort($contexte); |
|
| 5188 | + $hash = md5($fond . json_encode($contexte_implicite, JSON_THROW_ON_ERROR) . json_encode($contexte, JSON_THROW_ON_ERROR) . $connect); |
|
| 5189 | + } |
|
| 5190 | + $filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension"; |
|
| 5191 | + |
|
| 5192 | + // mettre a jour le fichier si il n'existe pas |
|
| 5193 | + // ou trop ancien |
|
| 5194 | + // le dernier fichier produit est toujours suffixe par .last |
|
| 5195 | + // et recopie sur le fichier cible uniquement si il change |
|
| 5196 | + if ( |
|
| 5197 | + !file_exists($filename) |
|
| 5198 | + or !file_exists($filename . '.last') |
|
| 5199 | + or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . '.last') < $cache['lastmodified']) |
|
| 5200 | + or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul') |
|
| 5201 | + ) { |
|
| 5202 | + $contenu = $cache['texte']; |
|
| 5203 | + // passer les urls en absolu si c'est une css |
|
| 5204 | + if ($extension == 'css') { |
|
| 5205 | + $contenu = urls_absolues_css( |
|
| 5206 | + $contenu, |
|
| 5207 | + test_espace_prive() ? generer_url_ecrire('accueil') : generer_url_public($fond) |
|
| 5208 | + ); |
|
| 5209 | + } |
|
| 5210 | + |
|
| 5211 | + $comment = ''; |
|
| 5212 | + // ne pas insérer de commentaire sur certains formats |
|
| 5213 | + if (!in_array($extension, ['json', 'xml', 'svg'])) { |
|
| 5214 | + $comment = "/* #PRODUIRE{fond=$fond"; |
|
| 5215 | + foreach ($contexte as $k => $v) { |
|
| 5216 | + $comment .= ",$k=$v"; |
|
| 5217 | + } |
|
| 5218 | + // pas de date dans le commentaire car sinon ca invalide le md5 et force la maj |
|
| 5219 | + // mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non |
|
| 5220 | + $comment .= "}\n md5:" . md5($contenu) . " */\n"; |
|
| 5221 | + } |
|
| 5222 | + // et ecrire le fichier si il change |
|
| 5223 | + ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true); |
|
| 5224 | + } |
|
| 5225 | + |
|
| 5226 | + return timestamp($filename); |
|
| 5227 | 5227 | } |
| 5228 | 5228 | |
| 5229 | 5229 | /** |
@@ -5236,15 +5236,15 @@ discard block |
||
| 5236 | 5236 | * $fichier auquel on a ajouté le timestamp |
| 5237 | 5237 | */ |
| 5238 | 5238 | function timestamp($fichier) { |
| 5239 | - if ( |
|
| 5240 | - !$fichier |
|
| 5241 | - or !file_exists($fichier) |
|
| 5242 | - or !$m = filemtime($fichier) |
|
| 5243 | - ) { |
|
| 5244 | - return $fichier; |
|
| 5245 | - } |
|
| 5239 | + if ( |
|
| 5240 | + !$fichier |
|
| 5241 | + or !file_exists($fichier) |
|
| 5242 | + or !$m = filemtime($fichier) |
|
| 5243 | + ) { |
|
| 5244 | + return $fichier; |
|
| 5245 | + } |
|
| 5246 | 5246 | |
| 5247 | - return "$fichier?$m"; |
|
| 5247 | + return "$fichier?$m"; |
|
| 5248 | 5248 | } |
| 5249 | 5249 | |
| 5250 | 5250 | /** |
@@ -5254,11 +5254,11 @@ discard block |
||
| 5254 | 5254 | * @return string |
| 5255 | 5255 | */ |
| 5256 | 5256 | function supprimer_timestamp($url) { |
| 5257 | - if (strpos($url, '?') === false) { |
|
| 5258 | - return $url; |
|
| 5259 | - } |
|
| 5257 | + if (strpos($url, '?') === false) { |
|
| 5258 | + return $url; |
|
| 5259 | + } |
|
| 5260 | 5260 | |
| 5261 | - return preg_replace(',\?[[:digit:]]+$,', '', $url); |
|
| 5261 | + return preg_replace(',\?[[:digit:]]+$,', '', $url); |
|
| 5262 | 5262 | } |
| 5263 | 5263 | |
| 5264 | 5264 | /** |
@@ -5273,9 +5273,9 @@ discard block |
||
| 5273 | 5273 | * @return string |
| 5274 | 5274 | */ |
| 5275 | 5275 | function filtre_nettoyer_titre_email_dist($titre) { |
| 5276 | - include_spip('inc/envoyer_mail'); |
|
| 5276 | + include_spip('inc/envoyer_mail'); |
|
| 5277 | 5277 | |
| 5278 | - return nettoyer_titre_email($titre); |
|
| 5278 | + return nettoyer_titre_email($titre); |
|
| 5279 | 5279 | } |
| 5280 | 5280 | |
| 5281 | 5281 | /** |
@@ -5297,27 +5297,27 @@ discard block |
||
| 5297 | 5297 | * @return string |
| 5298 | 5298 | */ |
| 5299 | 5299 | function filtre_chercher_rubrique_dist( |
| 5300 | - $titre, |
|
| 5301 | - $id_objet, |
|
| 5302 | - $id_parent, |
|
| 5303 | - $objet, |
|
| 5304 | - $id_secteur, |
|
| 5305 | - $restreint, |
|
| 5306 | - $actionable = false, |
|
| 5307 | - $retour_sans_cadre = false |
|
| 5300 | + $titre, |
|
| 5301 | + $id_objet, |
|
| 5302 | + $id_parent, |
|
| 5303 | + $objet, |
|
| 5304 | + $id_secteur, |
|
| 5305 | + $restreint, |
|
| 5306 | + $actionable = false, |
|
| 5307 | + $retour_sans_cadre = false |
|
| 5308 | 5308 | ) { |
| 5309 | - include_spip('inc/filtres_ecrire'); |
|
| 5309 | + include_spip('inc/filtres_ecrire'); |
|
| 5310 | 5310 | |
| 5311 | - return chercher_rubrique( |
|
| 5312 | - $titre, |
|
| 5313 | - $id_objet, |
|
| 5314 | - $id_parent, |
|
| 5315 | - $objet, |
|
| 5316 | - $id_secteur, |
|
| 5317 | - $restreint, |
|
| 5318 | - $actionable, |
|
| 5319 | - $retour_sans_cadre |
|
| 5320 | - ); |
|
| 5311 | + return chercher_rubrique( |
|
| 5312 | + $titre, |
|
| 5313 | + $id_objet, |
|
| 5314 | + $id_parent, |
|
| 5315 | + $objet, |
|
| 5316 | + $id_secteur, |
|
| 5317 | + $restreint, |
|
| 5318 | + $actionable, |
|
| 5319 | + $retour_sans_cadre |
|
| 5320 | + ); |
|
| 5321 | 5321 | } |
| 5322 | 5322 | |
| 5323 | 5323 | /** |
@@ -5346,56 +5346,56 @@ discard block |
||
| 5346 | 5346 | * Chaîne vide si l'accès est autorisé |
| 5347 | 5347 | */ |
| 5348 | 5348 | function sinon_interdire_acces($ok = false, $url = '', $statut = 0, $message = null) { |
| 5349 | - if ($ok) { |
|
| 5350 | - return ''; |
|
| 5351 | - } |
|
| 5352 | - |
|
| 5353 | - // Vider tous les tampons |
|
| 5354 | - $level = @ob_get_level(); |
|
| 5355 | - while ($level--) { |
|
| 5356 | - @ob_end_clean(); |
|
| 5357 | - } |
|
| 5358 | - |
|
| 5359 | - include_spip('inc/headers'); |
|
| 5360 | - |
|
| 5361 | - // S'il y a une URL, on redirige (si pas de statut, la fonction mettra 302 par défaut) |
|
| 5362 | - if ($url) { |
|
| 5363 | - redirige_par_entete($url, '', $statut); |
|
| 5364 | - } |
|
| 5365 | - |
|
| 5366 | - // ecriture simplifiee avec message en 3eme argument (= statut 403) |
|
| 5367 | - if (!is_numeric($statut) and is_null($message)) { |
|
| 5368 | - $message = $statut; |
|
| 5369 | - $statut = 0; |
|
| 5370 | - } |
|
| 5371 | - if (!$message) { |
|
| 5372 | - $message = ''; |
|
| 5373 | - } |
|
| 5374 | - $statut = intval($statut); |
|
| 5375 | - |
|
| 5376 | - // Si on est dans l'espace privé, on génère du 403 Forbidden par defaut ou du 404 |
|
| 5377 | - if (test_espace_prive()) { |
|
| 5378 | - if (!$statut or !in_array($statut, [404, 403])) { |
|
| 5379 | - $statut = 403; |
|
| 5380 | - } |
|
| 5381 | - http_response_code(403); |
|
| 5382 | - $echec = charger_fonction('403', 'exec'); |
|
| 5383 | - $echec($message); |
|
| 5384 | - } else { |
|
| 5385 | - // Sinon dans l'espace public on redirige vers une 404 par défaut, car elle toujours présente normalement |
|
| 5386 | - if (!$statut) { |
|
| 5387 | - $statut = 404; |
|
| 5388 | - } |
|
| 5389 | - // Dans tous les cas on modifie l'entité avec ce qui est demandé |
|
| 5390 | - http_response_code($statut); |
|
| 5391 | - // Si le statut est une erreur et qu'il n'y a pas de redirection on va chercher le squelette du même nom |
|
| 5392 | - if ($statut >= 400) { |
|
| 5393 | - echo recuperer_fond("$statut", ['erreur' => $message]); |
|
| 5394 | - } |
|
| 5395 | - } |
|
| 5396 | - |
|
| 5397 | - |
|
| 5398 | - exit; |
|
| 5349 | + if ($ok) { |
|
| 5350 | + return ''; |
|
| 5351 | + } |
|
| 5352 | + |
|
| 5353 | + // Vider tous les tampons |
|
| 5354 | + $level = @ob_get_level(); |
|
| 5355 | + while ($level--) { |
|
| 5356 | + @ob_end_clean(); |
|
| 5357 | + } |
|
| 5358 | + |
|
| 5359 | + include_spip('inc/headers'); |
|
| 5360 | + |
|
| 5361 | + // S'il y a une URL, on redirige (si pas de statut, la fonction mettra 302 par défaut) |
|
| 5362 | + if ($url) { |
|
| 5363 | + redirige_par_entete($url, '', $statut); |
|
| 5364 | + } |
|
| 5365 | + |
|
| 5366 | + // ecriture simplifiee avec message en 3eme argument (= statut 403) |
|
| 5367 | + if (!is_numeric($statut) and is_null($message)) { |
|
| 5368 | + $message = $statut; |
|
| 5369 | + $statut = 0; |
|
| 5370 | + } |
|
| 5371 | + if (!$message) { |
|
| 5372 | + $message = ''; |
|
| 5373 | + } |
|
| 5374 | + $statut = intval($statut); |
|
| 5375 | + |
|
| 5376 | + // Si on est dans l'espace privé, on génère du 403 Forbidden par defaut ou du 404 |
|
| 5377 | + if (test_espace_prive()) { |
|
| 5378 | + if (!$statut or !in_array($statut, [404, 403])) { |
|
| 5379 | + $statut = 403; |
|
| 5380 | + } |
|
| 5381 | + http_response_code(403); |
|
| 5382 | + $echec = charger_fonction('403', 'exec'); |
|
| 5383 | + $echec($message); |
|
| 5384 | + } else { |
|
| 5385 | + // Sinon dans l'espace public on redirige vers une 404 par défaut, car elle toujours présente normalement |
|
| 5386 | + if (!$statut) { |
|
| 5387 | + $statut = 404; |
|
| 5388 | + } |
|
| 5389 | + // Dans tous les cas on modifie l'entité avec ce qui est demandé |
|
| 5390 | + http_response_code($statut); |
|
| 5391 | + // Si le statut est une erreur et qu'il n'y a pas de redirection on va chercher le squelette du même nom |
|
| 5392 | + if ($statut >= 400) { |
|
| 5393 | + echo recuperer_fond("$statut", ['erreur' => $message]); |
|
| 5394 | + } |
|
| 5395 | + } |
|
| 5396 | + |
|
| 5397 | + |
|
| 5398 | + exit; |
|
| 5399 | 5399 | } |
| 5400 | 5400 | |
| 5401 | 5401 | /** |
@@ -5406,11 +5406,11 @@ discard block |
||
| 5406 | 5406 | * @return string |
| 5407 | 5407 | */ |
| 5408 | 5408 | function filtre_compacte_dist($source, $format = null) { |
| 5409 | - if (function_exists('compacte')) { |
|
| 5410 | - return compacte($source, $format); |
|
| 5411 | - } |
|
| 5409 | + if (function_exists('compacte')) { |
|
| 5410 | + return compacte($source, $format); |
|
| 5411 | + } |
|
| 5412 | 5412 | |
| 5413 | - return $source; |
|
| 5413 | + return $source; |
|
| 5414 | 5414 | } |
| 5415 | 5415 | |
| 5416 | 5416 | |
@@ -5422,31 +5422,31 @@ discard block |
||
| 5422 | 5422 | * @return string |
| 5423 | 5423 | */ |
| 5424 | 5424 | function spip_affiche_mot_de_passe_masque($passe, $afficher_partiellement = false, $portion_pourcent = null) { |
| 5425 | - $l = strlen($passe); |
|
| 5426 | - |
|
| 5427 | - if ($l <= 8 or !$afficher_partiellement) { |
|
| 5428 | - if (!$l) { |
|
| 5429 | - return ''; // montrer qu'il y a pas de mot de passe si il y en a pas |
|
| 5430 | - } |
|
| 5431 | - return str_pad('', $afficher_partiellement ? $l : 16, '*'); |
|
| 5432 | - } |
|
| 5433 | - |
|
| 5434 | - if (is_null($portion_pourcent)) { |
|
| 5435 | - if (!defined('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT')) { |
|
| 5436 | - define('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT', 20); // 20% |
|
| 5437 | - } |
|
| 5438 | - $portion_pourcent = _SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT; |
|
| 5439 | - } |
|
| 5440 | - if ($portion_pourcent >= 100) { |
|
| 5441 | - return $passe; |
|
| 5442 | - } |
|
| 5443 | - $e = intval(ceil($l * $portion_pourcent / 100 / 2)); |
|
| 5444 | - $e = max($e, 0); |
|
| 5445 | - $mid = str_pad('', $l - 2 * $e, '*'); |
|
| 5446 | - if ($e > 0 and strlen($mid) > 8) { |
|
| 5447 | - $mid = '***...***'; |
|
| 5448 | - } |
|
| 5449 | - return substr($passe, 0, $e) . $mid . ($e > 0 ? substr($passe, -$e) : ''); |
|
| 5425 | + $l = strlen($passe); |
|
| 5426 | + |
|
| 5427 | + if ($l <= 8 or !$afficher_partiellement) { |
|
| 5428 | + if (!$l) { |
|
| 5429 | + return ''; // montrer qu'il y a pas de mot de passe si il y en a pas |
|
| 5430 | + } |
|
| 5431 | + return str_pad('', $afficher_partiellement ? $l : 16, '*'); |
|
| 5432 | + } |
|
| 5433 | + |
|
| 5434 | + if (is_null($portion_pourcent)) { |
|
| 5435 | + if (!defined('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT')) { |
|
| 5436 | + define('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT', 20); // 20% |
|
| 5437 | + } |
|
| 5438 | + $portion_pourcent = _SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT; |
|
| 5439 | + } |
|
| 5440 | + if ($portion_pourcent >= 100) { |
|
| 5441 | + return $passe; |
|
| 5442 | + } |
|
| 5443 | + $e = intval(ceil($l * $portion_pourcent / 100 / 2)); |
|
| 5444 | + $e = max($e, 0); |
|
| 5445 | + $mid = str_pad('', $l - 2 * $e, '*'); |
|
| 5446 | + if ($e > 0 and strlen($mid) > 8) { |
|
| 5447 | + $mid = '***...***'; |
|
| 5448 | + } |
|
| 5449 | + return substr($passe, 0, $e) . $mid . ($e > 0 ? substr($passe, -$e) : ''); |
|
| 5450 | 5450 | } |
| 5451 | 5451 | |
| 5452 | 5452 | |
@@ -5467,64 +5467,64 @@ discard block |
||
| 5467 | 5467 | */ |
| 5468 | 5468 | function identifiant_slug($texte, $type = '', $options = []) { |
| 5469 | 5469 | |
| 5470 | - $original = $texte; |
|
| 5471 | - $separateur = ($options['separateur'] ?? '_'); |
|
| 5472 | - $longueur_maxi = ($options['longueur_maxi'] ?? 60); |
|
| 5473 | - $longueur_mini = ($options['longueur_mini'] ?? 0); |
|
| 5470 | + $original = $texte; |
|
| 5471 | + $separateur = ($options['separateur'] ?? '_'); |
|
| 5472 | + $longueur_maxi = ($options['longueur_maxi'] ?? 60); |
|
| 5473 | + $longueur_mini = ($options['longueur_mini'] ?? 0); |
|
| 5474 | 5474 | |
| 5475 | - if (!function_exists('translitteration')) { |
|
| 5476 | - include_spip('inc/charsets'); |
|
| 5477 | - } |
|
| 5475 | + if (!function_exists('translitteration')) { |
|
| 5476 | + include_spip('inc/charsets'); |
|
| 5477 | + } |
|
| 5478 | 5478 | |
| 5479 | - // pas de balise html |
|
| 5480 | - if (strpos($texte, '<') !== false) { |
|
| 5481 | - $texte = strip_tags($texte); |
|
| 5482 | - } |
|
| 5483 | - if (strpos($texte, '&') !== false) { |
|
| 5484 | - $texte = unicode2charset($texte); |
|
| 5485 | - } |
|
| 5486 | - // On enlève les espaces indésirables |
|
| 5487 | - $texte = trim($texte); |
|
| 5479 | + // pas de balise html |
|
| 5480 | + if (strpos($texte, '<') !== false) { |
|
| 5481 | + $texte = strip_tags($texte); |
|
| 5482 | + } |
|
| 5483 | + if (strpos($texte, '&') !== false) { |
|
| 5484 | + $texte = unicode2charset($texte); |
|
| 5485 | + } |
|
| 5486 | + // On enlève les espaces indésirables |
|
| 5487 | + $texte = trim($texte); |
|
| 5488 | 5488 | |
| 5489 | - // On enlève les accents et cie |
|
| 5490 | - $texte = translitteration($texte); |
|
| 5489 | + // On enlève les accents et cie |
|
| 5490 | + $texte = translitteration($texte); |
|
| 5491 | 5491 | |
| 5492 | - // On remplace tout ce qui n'est pas un mot par un séparateur |
|
| 5493 | - $texte = preg_replace(',[\W_]+,ms', $separateur, $texte); |
|
| 5492 | + // On remplace tout ce qui n'est pas un mot par un séparateur |
|
| 5493 | + $texte = preg_replace(',[\W_]+,ms', $separateur, $texte); |
|
| 5494 | 5494 | |
| 5495 | - // nettoyer les doubles occurences du separateur si besoin |
|
| 5496 | - while (strpos($texte, (string) "$separateur$separateur") !== false) { |
|
| 5497 | - $texte = str_replace("$separateur$separateur", $separateur, $texte); |
|
| 5498 | - } |
|
| 5495 | + // nettoyer les doubles occurences du separateur si besoin |
|
| 5496 | + while (strpos($texte, (string) "$separateur$separateur") !== false) { |
|
| 5497 | + $texte = str_replace("$separateur$separateur", $separateur, $texte); |
|
| 5498 | + } |
|
| 5499 | 5499 | |
| 5500 | - // pas de separateur au debut ni a la fin |
|
| 5501 | - $texte = trim($texte, $separateur); |
|
| 5500 | + // pas de separateur au debut ni a la fin |
|
| 5501 | + $texte = trim($texte, $separateur); |
|
| 5502 | 5502 | |
| 5503 | - // en minuscules |
|
| 5504 | - $texte = strtolower($texte); |
|
| 5503 | + // en minuscules |
|
| 5504 | + $texte = strtolower($texte); |
|
| 5505 | 5505 | |
| 5506 | - switch ($type) { |
|
| 5507 | - case 'class': |
|
| 5508 | - case 'id': |
|
| 5509 | - case 'anchor': |
|
| 5510 | - if (preg_match(',^\d,', $texte)) { |
|
| 5511 | - $texte = substr($type, 0, 1) . $texte; |
|
| 5512 | - } |
|
| 5513 | - } |
|
| 5506 | + switch ($type) { |
|
| 5507 | + case 'class': |
|
| 5508 | + case 'id': |
|
| 5509 | + case 'anchor': |
|
| 5510 | + if (preg_match(',^\d,', $texte)) { |
|
| 5511 | + $texte = substr($type, 0, 1) . $texte; |
|
| 5512 | + } |
|
| 5513 | + } |
|
| 5514 | 5514 | |
| 5515 | - if (strlen($texte) > $longueur_maxi) { |
|
| 5516 | - $texte = substr($texte, 0, $longueur_maxi); |
|
| 5517 | - } |
|
| 5515 | + if (strlen($texte) > $longueur_maxi) { |
|
| 5516 | + $texte = substr($texte, 0, $longueur_maxi); |
|
| 5517 | + } |
|
| 5518 | 5518 | |
| 5519 | - if (strlen($texte) < $longueur_mini and $longueur_mini < $longueur_maxi) { |
|
| 5520 | - if (preg_match(',^\d,', $texte)) { |
|
| 5521 | - $texte = ($type ? substr($type, 0, 1) : 's') . $texte; |
|
| 5522 | - } |
|
| 5523 | - $texte .= $separateur . md5($original); |
|
| 5524 | - $texte = substr($texte, 0, $longueur_mini); |
|
| 5525 | - } |
|
| 5519 | + if (strlen($texte) < $longueur_mini and $longueur_mini < $longueur_maxi) { |
|
| 5520 | + if (preg_match(',^\d,', $texte)) { |
|
| 5521 | + $texte = ($type ? substr($type, 0, 1) : 's') . $texte; |
|
| 5522 | + } |
|
| 5523 | + $texte .= $separateur . md5($original); |
|
| 5524 | + $texte = substr($texte, 0, $longueur_mini); |
|
| 5525 | + } |
|
| 5526 | 5526 | |
| 5527 | - return $texte; |
|
| 5527 | + return $texte; |
|
| 5528 | 5528 | } |
| 5529 | 5529 | |
| 5530 | 5530 | |
@@ -5545,11 +5545,11 @@ discard block |
||
| 5545 | 5545 | * @exemple `<:info_maximum|label_nettoyer:>` |
| 5546 | 5546 | */ |
| 5547 | 5547 | function label_nettoyer(string $text, bool $ucfirst = true): string { |
| 5548 | - $label = preg_replace('#([\s:]|\ )+$#u', '', $text); |
|
| 5549 | - if ($ucfirst) { |
|
| 5550 | - $label = spip_ucfirst($label); |
|
| 5551 | - } |
|
| 5552 | - return $label; |
|
| 5548 | + $label = preg_replace('#([\s:]|\ )+$#u', '', $text); |
|
| 5549 | + if ($ucfirst) { |
|
| 5550 | + $label = spip_ucfirst($label); |
|
| 5551 | + } |
|
| 5552 | + return $label; |
|
| 5553 | 5553 | } |
| 5554 | 5554 | |
| 5555 | 5555 | /** |
@@ -5562,8 +5562,8 @@ discard block |
||
| 5562 | 5562 | * @exemple `<:info_maximum|label_ponctuer:>` |
| 5563 | 5563 | */ |
| 5564 | 5564 | function label_ponctuer(string $text, bool $ucfirst = true): string { |
| 5565 | - $label = label_nettoyer($text, $ucfirst); |
|
| 5566 | - return _T('label_ponctuer', ['label' => $label]); |
|
| 5565 | + $label = label_nettoyer($text, $ucfirst); |
|
| 5566 | + return _T('label_ponctuer', ['label' => $label]); |
|
| 5567 | 5567 | } |
| 5568 | 5568 | |
| 5569 | 5569 | |
@@ -5576,19 +5576,19 @@ discard block |
||
| 5576 | 5576 | * @return array |
| 5577 | 5577 | */ |
| 5578 | 5578 | function helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, $fonction) { |
| 5579 | - if (!in_array($fonction, ['objet_lister_parents', 'objet_lister_enfants', 'objet_lister_parents_par_type', 'objet_lister_enfants_par_type'])) { |
|
| 5580 | - return []; |
|
| 5581 | - } |
|
| 5579 | + if (!in_array($fonction, ['objet_lister_parents', 'objet_lister_enfants', 'objet_lister_parents_par_type', 'objet_lister_enfants_par_type'])) { |
|
| 5580 | + return []; |
|
| 5581 | + } |
|
| 5582 | 5582 | |
| 5583 | - // compatibilite signature inversee |
|
| 5584 | - if (is_numeric($objet) and !is_numeric($id_objet)) { |
|
| 5585 | - [$objet, $id_objet] = [$id_objet, $objet]; |
|
| 5586 | - } |
|
| 5583 | + // compatibilite signature inversee |
|
| 5584 | + if (is_numeric($objet) and !is_numeric($id_objet)) { |
|
| 5585 | + [$objet, $id_objet] = [$id_objet, $objet]; |
|
| 5586 | + } |
|
| 5587 | 5587 | |
| 5588 | - if (!function_exists($fonction)) { |
|
| 5589 | - include_spip('base/objets'); |
|
| 5590 | - } |
|
| 5591 | - return $fonction($objet, $id_objet); |
|
| 5588 | + if (!function_exists($fonction)) { |
|
| 5589 | + include_spip('base/objets'); |
|
| 5590 | + } |
|
| 5591 | + return $fonction($objet, $id_objet); |
|
| 5592 | 5592 | } |
| 5593 | 5593 | |
| 5594 | 5594 | |
@@ -5603,7 +5603,7 @@ discard block |
||
| 5603 | 5603 | * @return array |
| 5604 | 5604 | */ |
| 5605 | 5605 | function filtre_objet_lister_parents_dist($objet, $id_objet) { |
| 5606 | - return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_parents'); |
|
| 5606 | + return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_parents'); |
|
| 5607 | 5607 | } |
| 5608 | 5608 | |
| 5609 | 5609 | /** |
@@ -5617,7 +5617,7 @@ discard block |
||
| 5617 | 5617 | * @return array |
| 5618 | 5618 | */ |
| 5619 | 5619 | function filtre_objet_lister_parents_par_type_dist($objet, $id_objet) { |
| 5620 | - return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_parents_par_type'); |
|
| 5620 | + return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_parents_par_type'); |
|
| 5621 | 5621 | } |
| 5622 | 5622 | |
| 5623 | 5623 | /** |
@@ -5631,7 +5631,7 @@ discard block |
||
| 5631 | 5631 | * @return array |
| 5632 | 5632 | */ |
| 5633 | 5633 | function filtre_objet_lister_enfants_dist($objet, $id_objet) { |
| 5634 | - return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_enfants'); |
|
| 5634 | + return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_enfants'); |
|
| 5635 | 5635 | } |
| 5636 | 5636 | |
| 5637 | 5637 | /** |
@@ -5645,5 +5645,5 @@ discard block |
||
| 5645 | 5645 | * @return array |
| 5646 | 5646 | */ |
| 5647 | 5647 | function filtre_objet_lister_enfants_par_type_dist($objet, $id_objet) { |
| 5648 | - return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_enfants_par_type'); |
|
| 5648 | + return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_enfants_par_type'); |
|
| 5649 | 5649 | } |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | include_fichiers_fonctions(); |
| 99 | - foreach (['filtre_' . $fonc, 'filtre_' . $fonc . '_dist', $fonc] as $f) { |
|
| 99 | + foreach (['filtre_'.$fonc, 'filtre_'.$fonc.'_dist', $fonc] as $f) { |
|
| 100 | 100 | trouver_filtre_matrice($f); // charge des fichiers spécifiques éventuels |
| 101 | 101 | // fonction ou name\space\fonction |
| 102 | 102 | if (is_callable($f)) { |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | // affichage "GIT [master: abcdef]" |
| 224 | 224 | $commit = $desc['commit_short'] ?? $desc['commit']; |
| 225 | 225 | if ($desc['branch']) { |
| 226 | - $commit = $desc['branch'] . ': ' . $commit; |
|
| 226 | + $commit = $desc['branch'].': '.$commit; |
|
| 227 | 227 | } |
| 228 | 228 | return "{$desc['vcs']} [$commit]"; |
| 229 | 229 | } |
@@ -242,9 +242,9 @@ discard block |
||
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | // version installee par GIT |
| 245 | - if (lire_fichier($dir . '/.git/HEAD', $c)) { |
|
| 245 | + if (lire_fichier($dir.'/.git/HEAD', $c)) { |
|
| 246 | 246 | $currentHead = trim(substr($c, 4)); |
| 247 | - if (lire_fichier($dir . '/.git/' . $currentHead, $hash)) { |
|
| 247 | + if (lire_fichier($dir.'/.git/'.$currentHead, $hash)) { |
|
| 248 | 248 | return [ |
| 249 | 249 | 'vcs' => 'GIT', |
| 250 | 250 | 'branch' => basename($currentHead), |
@@ -271,8 +271,8 @@ discard block |
||
| 271 | 271 | $dir = '.'; |
| 272 | 272 | } |
| 273 | 273 | // version installee par SVN |
| 274 | - if (file_exists($dir . '/.svn/wc.db') && class_exists(\SQLite3::class)) { |
|
| 275 | - $db = new SQLite3($dir . '/.svn/wc.db'); |
|
| 274 | + if (file_exists($dir.'/.svn/wc.db') && class_exists(\SQLite3::class)) { |
|
| 275 | + $db = new SQLite3($dir.'/.svn/wc.db'); |
|
| 276 | 276 | $result = $db->query('SELECT changed_revision FROM nodes WHERE local_relpath = "" LIMIT 1'); |
| 277 | 277 | if ($result) { |
| 278 | 278 | $row = $result->fetchArray(); |
@@ -290,12 +290,12 @@ discard block |
||
| 290 | 290 | |
| 291 | 291 | // La matrice est necessaire pour ne filtrer _que_ des fonctions definies dans filtres_images |
| 292 | 292 | // et laisser passer les fonctions personnelles baptisees image_... |
| 293 | -$GLOBALS['spip_matrice']['image_graver'] = true;//'inc/filtres_images_mini.php'; |
|
| 294 | -$GLOBALS['spip_matrice']['image_select'] = true;//'inc/filtres_images_mini.php'; |
|
| 295 | -$GLOBALS['spip_matrice']['image_reduire'] = true;//'inc/filtres_images_mini.php'; |
|
| 296 | -$GLOBALS['spip_matrice']['image_reduire_par'] = true;//'inc/filtres_images_mini.php'; |
|
| 297 | -$GLOBALS['spip_matrice']['image_passe_partout'] = true;//'inc/filtres_images_mini.php'; |
|
| 298 | -$GLOBALS['spip_matrice']['image_recadre_avec_fallback'] = true;//'inc/filtres_images_mini.php'; |
|
| 293 | +$GLOBALS['spip_matrice']['image_graver'] = true; //'inc/filtres_images_mini.php'; |
|
| 294 | +$GLOBALS['spip_matrice']['image_select'] = true; //'inc/filtres_images_mini.php'; |
|
| 295 | +$GLOBALS['spip_matrice']['image_reduire'] = true; //'inc/filtres_images_mini.php'; |
|
| 296 | +$GLOBALS['spip_matrice']['image_reduire_par'] = true; //'inc/filtres_images_mini.php'; |
|
| 297 | +$GLOBALS['spip_matrice']['image_passe_partout'] = true; //'inc/filtres_images_mini.php'; |
|
| 298 | +$GLOBALS['spip_matrice']['image_recadre_avec_fallback'] = true; //'inc/filtres_images_mini.php'; |
|
| 299 | 299 | |
| 300 | 300 | $GLOBALS['spip_matrice']['couleur_html_to_hex'] = 'inc/filtres_images_mini.php'; |
| 301 | 301 | $GLOBALS['spip_matrice']['couleur_hex_to_hsl'] = 'inc/filtres_images_mini.php'; |
@@ -454,8 +454,8 @@ discard block |
||
| 454 | 454 | */ |
| 455 | 455 | function filtre_debug($val, $key = null) { |
| 456 | 456 | $debug = ( |
| 457 | - is_null($key) ? '' : (var_export($key, true) . ' = ') |
|
| 458 | - ) . var_export($val, true); |
|
| 457 | + is_null($key) ? '' : (var_export($key, true).' = ') |
|
| 458 | + ).var_export($val, true); |
|
| 459 | 459 | |
| 460 | 460 | include_spip('inc/autoriser'); |
| 461 | 461 | if (autoriser('webmestre')) { |
@@ -509,7 +509,7 @@ discard block |
||
| 509 | 509 | $is_file = false; |
| 510 | 510 | } |
| 511 | 511 | if ($is_file) { |
| 512 | - $is_local_file = function ($path) { |
|
| 512 | + $is_local_file = function($path) { |
|
| 513 | 513 | if (strpos($path, '?') !== false) { |
| 514 | 514 | $path = supprimer_timestamp($path); |
| 515 | 515 | // remove ?24px added by find_in_theme on .svg files |
@@ -561,7 +561,7 @@ discard block |
||
| 561 | 561 | if (preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)) { |
| 562 | 562 | $srcover = $match[1]; |
| 563 | 563 | array_shift($args); |
| 564 | - array_unshift($args, "<img src='" . $match[1] . "' />"); |
|
| 564 | + array_unshift($args, "<img src='".$match[1]."' />"); |
|
| 565 | 565 | $srcover_filter = call_user_func_array($filtre, $args); |
| 566 | 566 | $srcover_filter = extraire_attribut($srcover_filter, 'src'); |
| 567 | 567 | $reduit = str_replace($srcover, $srcover_filter, $reduit); |
@@ -928,7 +928,7 @@ discard block |
||
| 928 | 928 | // " -> " et tout ce genre de choses |
| 929 | 929 | $u = $GLOBALS['meta']['pcre_u']; |
| 930 | 930 | $texte = str_replace(' ', ' ', $texte); |
| 931 | - $texte = preg_replace('/\s{2,}/S' . $u, ' ', $texte); |
|
| 931 | + $texte = preg_replace('/\s{2,}/S'.$u, ' ', $texte); |
|
| 932 | 932 | // ne pas echapper les sinqle quotes car certains outils de syndication gerent mal |
| 933 | 933 | $texte = entites_html($texte, false, false); |
| 934 | 934 | // mais bien echapper les double quotes ! |
@@ -988,7 +988,7 @@ discard block |
||
| 988 | 988 | **/ |
| 989 | 989 | function supprimer_numero($texte) { |
| 990 | 990 | return preg_replace( |
| 991 | - ',^[[:space:]]*([0-9]+)([.)]|' . chr(194) . '?' . chr(176) . ')[[:space:]]+,S', |
|
| 991 | + ',^[[:space:]]*([0-9]+)([.)]|'.chr(194).'?'.chr(176).')[[:space:]]+,S', |
|
| 992 | 992 | '', |
| 993 | 993 | $texte |
| 994 | 994 | ); |
@@ -1016,7 +1016,7 @@ discard block |
||
| 1016 | 1016 | function recuperer_numero($texte) { |
| 1017 | 1017 | if ( |
| 1018 | 1018 | preg_match( |
| 1019 | - ',^[[:space:]]*([0-9]+)([.)]|' . chr(194) . '?' . chr(176) . ')[[:space:]]+,S', |
|
| 1019 | + ',^[[:space:]]*([0-9]+)([.)]|'.chr(194).'?'.chr(176).')[[:space:]]+,S', |
|
| 1020 | 1020 | $texte, |
| 1021 | 1021 | $regs |
| 1022 | 1022 | ) |
@@ -1107,8 +1107,8 @@ discard block |
||
| 1107 | 1107 | **/ |
| 1108 | 1108 | function textebrut($texte) { |
| 1109 | 1109 | $u = $GLOBALS['meta']['pcre_u']; |
| 1110 | - $texte = preg_replace('/\s+/S' . $u, ' ', $texte); |
|
| 1111 | - $texte = preg_replace('/<(p|br)( [^>]*)?' . '>/iS', "\n\n", $texte); |
|
| 1110 | + $texte = preg_replace('/\s+/S'.$u, ' ', $texte); |
|
| 1111 | + $texte = preg_replace('/<(p|br)( [^>]*)?'.'>/iS', "\n\n", $texte); |
|
| 1112 | 1112 | $texte = preg_replace("/^\n+/", '', $texte); |
| 1113 | 1113 | $texte = preg_replace("/\n+$/", '', $texte); |
| 1114 | 1114 | $texte = preg_replace("/\n +/", "\n", $texte); |
@@ -1142,7 +1142,7 @@ discard block |
||
| 1142 | 1142 | ) |
| 1143 | 1143 | ) { |
| 1144 | 1144 | foreach ($liens[0] as $a) { |
| 1145 | - $rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel'); |
|
| 1145 | + $rel = 'noopener noreferrer '.extraire_attribut($a, 'rel'); |
|
| 1146 | 1146 | $ablank = inserer_attribut($a, 'rel', $rel); |
| 1147 | 1147 | $ablank = inserer_attribut($ablank, 'target', '_blank'); |
| 1148 | 1148 | $texte = str_replace($a, $ablank, $texte); |
@@ -1167,7 +1167,7 @@ discard block |
||
| 1167 | 1167 | foreach ($regs[0] as $a) { |
| 1168 | 1168 | $rel = extraire_attribut($a, 'rel'); |
| 1169 | 1169 | if (strpos($rel, 'nofollow') === false) { |
| 1170 | - $rel = 'nofollow' . ($rel ? " $rel" : ''); |
|
| 1170 | + $rel = 'nofollow'.($rel ? " $rel" : ''); |
|
| 1171 | 1171 | $anofollow = inserer_attribut($a, 'rel', $rel); |
| 1172 | 1172 | $texte = str_replace($a, $anofollow, $texte); |
| 1173 | 1173 | } |
@@ -1196,7 +1196,7 @@ discard block |
||
| 1196 | 1196 | $u = $GLOBALS['meta']['pcre_u']; |
| 1197 | 1197 | $texte = preg_replace('@</p>@iS', "\n", $texte); |
| 1198 | 1198 | $texte = preg_replace("@<p\b.*>@UiS", '<br />', $texte); |
| 1199 | - $texte = preg_replace('@^\s*<br />@S' . $u, '', $texte); |
|
| 1199 | + $texte = preg_replace('@^\s*<br />@S'.$u, '', $texte); |
|
| 1200 | 1200 | |
| 1201 | 1201 | return $texte; |
| 1202 | 1202 | } |
@@ -1227,7 +1227,7 @@ discard block |
||
| 1227 | 1227 | return $texte; |
| 1228 | 1228 | } |
| 1229 | 1229 | include_spip('inc/texte'); |
| 1230 | - $tag = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $texte) ? |
|
| 1230 | + $tag = preg_match(',</?('._BALISES_BLOCS.')[>[:space:]],iS', $texte) ? |
|
| 1231 | 1231 | 'div' : 'span'; |
| 1232 | 1232 | |
| 1233 | 1233 | return "<$tag style='word-wrap:break-word;'>$texte</$tag>"; |
@@ -1339,7 +1339,7 @@ discard block |
||
| 1339 | 1339 | } |
| 1340 | 1340 | $u = $GLOBALS['meta']['pcre_u']; |
| 1341 | 1341 | if ($textebrut) { |
| 1342 | - $texte = preg_replace([",\n,", ',\s(?=\s),msS' . $u], [' ', ''], textebrut($texte)); |
|
| 1342 | + $texte = preg_replace([",\n,", ',\s(?=\s),msS'.$u], [' ', ''], textebrut($texte)); |
|
| 1343 | 1343 | } |
| 1344 | 1344 | $texte = texte_backend($texte); |
| 1345 | 1345 | $texte = str_replace(["'", '"'], [''', '"'], $texte); |
@@ -1374,7 +1374,7 @@ discard block |
||
| 1374 | 1374 | # un message pour abs_url |
| 1375 | 1375 | $GLOBALS['mode_abs_url'] = 'url'; |
| 1376 | 1376 | $url = trim($url); |
| 1377 | - $r = ',^(?:' . _PROTOCOLES_STD . '):?/?/?$,iS'; |
|
| 1377 | + $r = ',^(?:'._PROTOCOLES_STD.'):?/?/?$,iS'; |
|
| 1378 | 1378 | |
| 1379 | 1379 | return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url); |
| 1380 | 1380 | } |
@@ -1578,14 +1578,14 @@ discard block |
||
| 1578 | 1578 | if (strpos($texte, '<') !== false) { |
| 1579 | 1579 | include_spip('inc/lien'); |
| 1580 | 1580 | if (defined('_PREG_MODELE')) { |
| 1581 | - $preg_modeles = '@' . _PREG_MODELE . '@imsS'; |
|
| 1581 | + $preg_modeles = '@'._PREG_MODELE.'@imsS'; |
|
| 1582 | 1582 | $texte = echappe_html($texte, '', true, $preg_modeles); |
| 1583 | 1583 | } |
| 1584 | 1584 | } |
| 1585 | 1585 | |
| 1586 | 1586 | $debut = ''; |
| 1587 | 1587 | $suite = $texte; |
| 1588 | - while ($t = strpos('-' . $suite, "\n", 1)) { |
|
| 1588 | + while ($t = strpos('-'.$suite, "\n", 1)) { |
|
| 1589 | 1589 | $debut .= substr($suite, 0, $t - 1); |
| 1590 | 1590 | $suite = substr($suite, $t); |
| 1591 | 1591 | $car = substr($suite, 0, 1); |
@@ -1603,11 +1603,11 @@ discard block |
||
| 1603 | 1603 | $suite = substr($suite, strlen($regs[0])); |
| 1604 | 1604 | } |
| 1605 | 1605 | } |
| 1606 | - $texte = $debut . $suite; |
|
| 1606 | + $texte = $debut.$suite; |
|
| 1607 | 1607 | |
| 1608 | 1608 | $texte = echappe_retour($texte); |
| 1609 | 1609 | |
| 1610 | - return $texte . $fin; |
|
| 1610 | + return $texte.$fin; |
|
| 1611 | 1611 | } |
| 1612 | 1612 | |
| 1613 | 1613 | |
@@ -1669,7 +1669,7 @@ discard block |
||
| 1669 | 1669 | } |
| 1670 | 1670 | |
| 1671 | 1671 | foreach ($regs as $reg) { |
| 1672 | - $cle = ($reg[1] ? $reg[1] . ':' : '') . $reg[2]; |
|
| 1672 | + $cle = ($reg[1] ? $reg[1].':' : '').$reg[2]; |
|
| 1673 | 1673 | $desc = $traduire($cle, $lang, true); |
| 1674 | 1674 | $l = $desc->langue; |
| 1675 | 1675 | // si pas de traduction, on laissera l'écriture de l'idiome entier dans le texte. |
@@ -1783,9 +1783,9 @@ discard block |
||
| 1783 | 1783 | // il ne faut pas echapper en div si propre produit un seul paragraphe |
| 1784 | 1784 | include_spip('inc/texte'); |
| 1785 | 1785 | $trad_propre = preg_replace(',(^<p[^>]*>|</p>$),Uims', '', propre($trad)); |
| 1786 | - $mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $trad_propre) ? 'div' : 'span'; |
|
| 1786 | + $mode = preg_match(',</?('._BALISES_BLOCS.')[>[:space:]],iS', $trad_propre) ? 'div' : 'span'; |
|
| 1787 | 1787 | if ($mode === 'div') { |
| 1788 | - $trad = rtrim($trad) . "\n\n"; |
|
| 1788 | + $trad = rtrim($trad)."\n\n"; |
|
| 1789 | 1789 | } |
| 1790 | 1790 | $trad = code_echappement($trad, 'multi', false, $mode); |
| 1791 | 1791 | $trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l)); |
@@ -1981,7 +1981,7 @@ discard block |
||
| 1981 | 1981 | if (is_array($balise)) { |
| 1982 | 1982 | array_walk( |
| 1983 | 1983 | $balise, |
| 1984 | - function (&$a, $key, $t) { |
|
| 1984 | + function(&$a, $key, $t) { |
|
| 1985 | 1985 | $a = extraire_attribut($a, $t); |
| 1986 | 1986 | }, |
| 1987 | 1987 | $attribut |
@@ -2078,14 +2078,14 @@ discard block |
||
| 2078 | 2078 | |
| 2079 | 2079 | if ($old !== null) { |
| 2080 | 2080 | // Remplacer l'ancien attribut du meme nom |
| 2081 | - $balise = $r[1] . $insert . $r[5]; |
|
| 2081 | + $balise = $r[1].$insert.$r[5]; |
|
| 2082 | 2082 | } else { |
| 2083 | 2083 | // preferer une balise " />" (comme <img />) |
| 2084 | 2084 | if (preg_match(',/>,', $balise)) { |
| 2085 | - $balise = preg_replace(',\s?/>,S', $insert . ' />', $balise, 1); |
|
| 2085 | + $balise = preg_replace(',\s?/>,S', $insert.' />', $balise, 1); |
|
| 2086 | 2086 | } // sinon une balise <a ...> ... </a> |
| 2087 | 2087 | else { |
| 2088 | - $balise = preg_replace(',\s?>,S', $insert . '>', $balise, 1); |
|
| 2088 | + $balise = preg_replace(',\s?>,S', $insert.'>', $balise, 1); |
|
| 2089 | 2089 | } |
| 2090 | 2090 | } |
| 2091 | 2091 | |
@@ -2140,7 +2140,7 @@ discard block |
||
| 2140 | 2140 | if ( |
| 2141 | 2141 | $class_courante |
| 2142 | 2142 | and strpos($class_courante, (string) $c) !== false |
| 2143 | - and preg_match('/(^|\s)' . preg_quote($c) . '($|\s)/', $class_courante) |
|
| 2143 | + and preg_match('/(^|\s)'.preg_quote($c).'($|\s)/', $class_courante) |
|
| 2144 | 2144 | ) { |
| 2145 | 2145 | $is_class_presente = true; |
| 2146 | 2146 | } |
@@ -2148,12 +2148,12 @@ discard block |
||
| 2148 | 2148 | in_array($operation, ['ajouter', 'commuter']) |
| 2149 | 2149 | and !$is_class_presente |
| 2150 | 2150 | ) { |
| 2151 | - $class_new = ltrim(rtrim($class_new ?? '') . ' ' . $c); |
|
| 2151 | + $class_new = ltrim(rtrim($class_new ?? '').' '.$c); |
|
| 2152 | 2152 | } elseif ( |
| 2153 | 2153 | in_array($operation, ['supprimer', 'commuter']) |
| 2154 | 2154 | and $is_class_presente |
| 2155 | 2155 | ) { |
| 2156 | - $class_new = trim(preg_replace('/(^|\s)' . preg_quote($c) . '($|\s)/', "\\1", $class_new)); |
|
| 2156 | + $class_new = trim(preg_replace('/(^|\s)'.preg_quote($c).'($|\s)/', "\\1", $class_new)); |
|
| 2157 | 2157 | } |
| 2158 | 2158 | } |
| 2159 | 2159 | |
@@ -2216,7 +2216,7 @@ discard block |
||
| 2216 | 2216 | // Quelques fonctions de calcul arithmetique |
| 2217 | 2217 | // |
| 2218 | 2218 | function floatstr($a) { |
| 2219 | - return str_replace(',', '.', (string)floatval($a)); |
|
| 2219 | + return str_replace(',', '.', (string) floatval($a)); |
|
| 2220 | 2220 | } |
| 2221 | 2221 | function strize($f, $a, $b) { |
| 2222 | 2222 | return floatstr($f(floatstr($a), floatstr($b))); |
@@ -2352,13 +2352,13 @@ discard block |
||
| 2352 | 2352 | if (!defined('_TAGS_NOM_AUTEUR')) { |
| 2353 | 2353 | define('_TAGS_NOM_AUTEUR', ''); |
| 2354 | 2354 | } |
| 2355 | - $tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR)); |
|
| 2355 | + $tags_acceptes = array_unique(explode(',', 'multi,'._TAGS_NOM_AUTEUR)); |
|
| 2356 | 2356 | foreach ($tags_acceptes as $tag) { |
| 2357 | 2357 | if (strlen($tag)) { |
| 2358 | - $remp1[] = '<' . trim($tag) . '>'; |
|
| 2359 | - $remp1[] = '</' . trim($tag) . '>'; |
|
| 2360 | - $remp2[] = '\x60' . trim($tag) . '\x61'; |
|
| 2361 | - $remp2[] = '\x60/' . trim($tag) . '\x61'; |
|
| 2358 | + $remp1[] = '<'.trim($tag).'>'; |
|
| 2359 | + $remp1[] = '</'.trim($tag).'>'; |
|
| 2360 | + $remp2[] = '\x60'.trim($tag).'\x61'; |
|
| 2361 | + $remp2[] = '\x60/'.trim($tag).'\x61'; |
|
| 2362 | 2362 | } |
| 2363 | 2363 | } |
| 2364 | 2364 | $v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom))); |
@@ -2412,7 +2412,7 @@ discard block |
||
| 2412 | 2412 | . http_img_pack( |
| 2413 | 2413 | 'attachment-16.png', |
| 2414 | 2414 | $t, |
| 2415 | - 'title="' . attribut_html($t) . '"' |
|
| 2415 | + 'title="'.attribut_html($t).'"' |
|
| 2416 | 2416 | ) |
| 2417 | 2417 | . '</a>', |
| 2418 | 2418 | $tag |
@@ -2476,10 +2476,10 @@ discard block |
||
| 2476 | 2476 | $fichier = basename($url); |
| 2477 | 2477 | |
| 2478 | 2478 | return '<a rel="enclosure"' |
| 2479 | - . ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '') |
|
| 2480 | - . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '') |
|
| 2481 | - . ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '') |
|
| 2482 | - . '>' . $fichier . '</a>'; |
|
| 2479 | + . ($url ? ' href="'.spip_htmlspecialchars($url).'"' : '') |
|
| 2480 | + . ($type ? ' type="'.spip_htmlspecialchars($type).'"' : '') |
|
| 2481 | + . ($length ? ' title="'.spip_htmlspecialchars($length).'"' : '') |
|
| 2482 | + . '>'.$fichier.'</a>'; |
|
| 2483 | 2483 | } |
| 2484 | 2484 | |
| 2485 | 2485 | /** |
@@ -2507,9 +2507,9 @@ discard block |
||
| 2507 | 2507 | } # vieux data |
| 2508 | 2508 | $fichier = basename($url); |
| 2509 | 2509 | $enclosures[] = '<enclosure' |
| 2510 | - . ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '') |
|
| 2511 | - . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '') |
|
| 2512 | - . ($length ? ' length="' . $length . '"' : '') |
|
| 2510 | + . ($url ? ' url="'.spip_htmlspecialchars($url).'"' : '') |
|
| 2511 | + . ($type ? ' type="'.spip_htmlspecialchars($type).'"' : '') |
|
| 2512 | + . ($length ? ' length="'.$length.'"' : '') |
|
| 2513 | 2513 | . ' />'; |
| 2514 | 2514 | } |
| 2515 | 2515 | } |
@@ -2535,7 +2535,7 @@ discard block |
||
| 2535 | 2535 | if (extraire_attribut($e, 'rel') == 'tag') { |
| 2536 | 2536 | $subjects .= '<dc:subject>' |
| 2537 | 2537 | . texte_backend(textebrut($e)) |
| 2538 | - . '</dc:subject>' . "\n"; |
|
| 2538 | + . '</dc:subject>'."\n"; |
|
| 2539 | 2539 | } |
| 2540 | 2540 | } |
| 2541 | 2541 | |
@@ -2571,7 +2571,7 @@ discard block |
||
| 2571 | 2571 | if (is_array($texte)) { |
| 2572 | 2572 | array_walk( |
| 2573 | 2573 | $texte, |
| 2574 | - function (&$a, $key, $t) { |
|
| 2574 | + function(&$a, $key, $t) { |
|
| 2575 | 2575 | $a = extraire_balise($a, $t); |
| 2576 | 2576 | }, |
| 2577 | 2577 | $tag |
@@ -2619,7 +2619,7 @@ discard block |
||
| 2619 | 2619 | if (is_array($texte)) { |
| 2620 | 2620 | array_walk( |
| 2621 | 2621 | $texte, |
| 2622 | - function (&$a, $key, $t) { |
|
| 2622 | + function(&$a, $key, $t) { |
|
| 2623 | 2623 | $a = extraire_balises($a, $t); |
| 2624 | 2624 | }, |
| 2625 | 2625 | $tag |
@@ -2751,7 +2751,7 @@ discard block |
||
| 2751 | 2751 | if ($fond != '404') { |
| 2752 | 2752 | $contexte = array_shift($p); |
| 2753 | 2753 | $contexte['page'] = $fond; |
| 2754 | - $action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action); |
|
| 2754 | + $action = preg_replace('/([?]'.preg_quote($fond).'[^&=]*[0-9]+)(&|$)/', '?&', $action); |
|
| 2755 | 2755 | } |
| 2756 | 2756 | } |
| 2757 | 2757 | // defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url |
@@ -2806,9 +2806,9 @@ discard block |
||
| 2806 | 2806 | . '"' |
| 2807 | 2807 | . (is_null($val) |
| 2808 | 2808 | ? '' |
| 2809 | - : ' value="' . entites_html($val) . '"' |
|
| 2809 | + : ' value="'.entites_html($val).'"' |
|
| 2810 | 2810 | ) |
| 2811 | - . ' type="hidden"' . "\n/>"; |
|
| 2811 | + . ' type="hidden"'."\n/>"; |
|
| 2812 | 2812 | } |
| 2813 | 2813 | |
| 2814 | 2814 | return join('', $hidden); |
@@ -2918,7 +2918,7 @@ discard block |
||
| 2918 | 2918 | |
| 2919 | 2919 | return preg_replace_callback( |
| 2920 | 2920 | ",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims", |
| 2921 | - fn($x) => "url('" . suivre_lien($path, $x[1]) . "')", |
|
| 2921 | + fn($x) => "url('".suivre_lien($path, $x[1])."')", |
|
| 2922 | 2922 | $contenu |
| 2923 | 2923 | ); |
| 2924 | 2924 | } |
@@ -2979,14 +2979,14 @@ discard block |
||
| 2979 | 2979 | ) { |
| 2980 | 2980 | $distant = true; |
| 2981 | 2981 | $cssf = parse_url($css); |
| 2982 | - $cssf = $cssf['path'] . ($cssf['query'] ? '?' . $cssf['query'] : ''); |
|
| 2982 | + $cssf = $cssf['path'].($cssf['query'] ? '?'.$cssf['query'] : ''); |
|
| 2983 | 2983 | $cssf = preg_replace(',[?:&=],', '_', $cssf); |
| 2984 | 2984 | } else { |
| 2985 | 2985 | $distant = false; |
| 2986 | 2986 | $cssf = $css; |
| 2987 | 2987 | // 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi |
| 2988 | 2988 | //propose (rien a faire dans ce cas) |
| 2989 | - $f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css); |
|
| 2989 | + $f = preg_replace(',(_rtl)?\.css$,i', '_'.$ndir.'.css', $css); |
|
| 2990 | 2990 | if (@file_exists($f)) { |
| 2991 | 2991 | return $f; |
| 2992 | 2992 | } |
@@ -2996,7 +2996,7 @@ discard block |
||
| 2996 | 2996 | $dir_var = sous_repertoire(_DIR_VAR, 'cache-css'); |
| 2997 | 2997 | $f = $dir_var |
| 2998 | 2998 | . preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf) |
| 2999 | - . '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css'; |
|
| 2999 | + . '.'.substr(md5($cssf), 0, 4).'_'.$ndir.'.css'; |
|
| 3000 | 3000 | |
| 3001 | 3001 | // la css peut etre distante (url absolue !) |
| 3002 | 3002 | if ($distant) { |
@@ -3042,8 +3042,8 @@ discard block |
||
| 3042 | 3042 | } // si la css_direction commence par $dir_var on la fait passer pour une absolue |
| 3043 | 3043 | elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) { |
| 3044 | 3044 | $css_direction = substr($css_direction, strlen($dir_var)); |
| 3045 | - $src_faux_abs['/@@@@@@/' . $css_direction] = $css_direction; |
|
| 3046 | - $css_direction = '/@@@@@@/' . $css_direction; |
|
| 3045 | + $src_faux_abs['/@@@@@@/'.$css_direction] = $css_direction; |
|
| 3046 | + $css_direction = '/@@@@@@/'.$css_direction; |
|
| 3047 | 3047 | } |
| 3048 | 3048 | $src[] = $regs[0][$k]; |
| 3049 | 3049 | $src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]); |
@@ -3092,7 +3092,7 @@ discard block |
||
| 3092 | 3092 | |
| 3093 | 3093 | $f = basename($css, '.css'); |
| 3094 | 3094 | $f = sous_repertoire(_DIR_VAR, 'cache-css') |
| 3095 | - . preg_replace(',(.*?)(_rtl|_ltr)?$,', "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f) |
|
| 3095 | + . preg_replace(',(.*?)(_rtl|_ltr)?$,', "\\1-urlabs-".substr(md5("$css-urlabs"), 0, 4)."\\2", $f) |
|
| 3096 | 3096 | . '.css'; |
| 3097 | 3097 | |
| 3098 | 3098 | if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) { |
@@ -3102,7 +3102,7 @@ discard block |
||
| 3102 | 3102 | if ($url_absolue_css == $css) { |
| 3103 | 3103 | if ( |
| 3104 | 3104 | strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0 |
| 3105 | - or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu) |
|
| 3105 | + or !lire_fichier(_DIR_RACINE.substr($css, $l), $contenu) |
|
| 3106 | 3106 | ) { |
| 3107 | 3107 | include_spip('inc/distant'); |
| 3108 | 3108 | $contenu = recuperer_url($css); |
@@ -3214,7 +3214,7 @@ discard block |
||
| 3214 | 3214 | $expression = str_replace('\/', '/', $expression); |
| 3215 | 3215 | $expression = str_replace('/', '\/', $expression); |
| 3216 | 3216 | |
| 3217 | - if (preg_match('/' . $expression . '/' . $modif, $texte ?? '', $r)) { |
|
| 3217 | + if (preg_match('/'.$expression.'/'.$modif, $texte ?? '', $r)) { |
|
| 3218 | 3218 | if (isset($r[$capte])) { |
| 3219 | 3219 | return $r[$capte]; |
| 3220 | 3220 | } else { |
@@ -3252,7 +3252,7 @@ discard block |
||
| 3252 | 3252 | $expression = str_replace('\/', '/', $expression); |
| 3253 | 3253 | $expression = str_replace('/', '\/', $expression); |
| 3254 | 3254 | |
| 3255 | - return preg_replace('/' . $expression . '/' . $modif, $replace, $texte); |
|
| 3255 | + return preg_replace('/'.$expression.'/'.$modif, $replace, $texte); |
|
| 3256 | 3256 | } |
| 3257 | 3257 | |
| 3258 | 3258 | |
@@ -3271,7 +3271,7 @@ discard block |
||
| 3271 | 3271 | function traiter_doublons_documents(&$doublons, $letexte) { |
| 3272 | 3272 | |
| 3273 | 3273 | // Verifier dans le texte & les notes (pas beau, helas) |
| 3274 | - $t = $letexte . $GLOBALS['les_notes']; |
|
| 3274 | + $t = $letexte.$GLOBALS['les_notes']; |
|
| 3275 | 3275 | |
| 3276 | 3276 | if ( |
| 3277 | 3277 | strstr($t, 'spip_document_') // evite le preg_match_all si inutile |
@@ -3285,7 +3285,7 @@ discard block |
||
| 3285 | 3285 | if (!isset($doublons['documents'])) { |
| 3286 | 3286 | $doublons['documents'] = ''; |
| 3287 | 3287 | } |
| 3288 | - $doublons['documents'] .= ',' . join(',', $matches[1]); |
|
| 3288 | + $doublons['documents'] .= ','.join(',', $matches[1]); |
|
| 3289 | 3289 | } |
| 3290 | 3290 | |
| 3291 | 3291 | return $letexte; |
@@ -3342,7 +3342,7 @@ discard block |
||
| 3342 | 3342 | if ($env) { |
| 3343 | 3343 | foreach ($env as $i => $j) { |
| 3344 | 3344 | if (is_string($j) and !in_array($i, $ignore_params)) { |
| 3345 | - $texte .= "<param name='" . attribut_html($i) . "'\n\tvalue='" . attribut_html($j) . "' />"; |
|
| 3345 | + $texte .= "<param name='".attribut_html($i)."'\n\tvalue='".attribut_html($j)."' />"; |
|
| 3346 | 3346 | } |
| 3347 | 3347 | } |
| 3348 | 3348 | } |
@@ -3381,7 +3381,7 @@ discard block |
||
| 3381 | 3381 | if ($env) { |
| 3382 | 3382 | foreach ($env as $i => $j) { |
| 3383 | 3383 | if (is_string($j) and !in_array($i, $ignore_params)) { |
| 3384 | - $texte .= attribut_html($i) . "='" . attribut_html($j) . "' "; |
|
| 3384 | + $texte .= attribut_html($i)."='".attribut_html($j)."' "; |
|
| 3385 | 3385 | } |
| 3386 | 3386 | } |
| 3387 | 3387 | } |
@@ -3455,10 +3455,10 @@ discard block |
||
| 3455 | 3455 | // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png |
| 3456 | 3456 | if ( |
| 3457 | 3457 | preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m) |
| 3458 | - and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . '-xx.svg' |
|
| 3458 | + and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])).'-xx.svg' |
|
| 3459 | 3459 | and file_exists($variante_svg_generique) |
| 3460 | 3460 | ) { |
| 3461 | - if ($variante_svg_size = substr($variante_svg_generique, 0, -6) . $m[1] . '.svg' and file_exists($variante_svg_size)) { |
|
| 3461 | + if ($variante_svg_size = substr($variante_svg_generique, 0, -6).$m[1].'.svg' and file_exists($variante_svg_size)) { |
|
| 3462 | 3462 | $img_file = $variante_svg_size; |
| 3463 | 3463 | } |
| 3464 | 3464 | else { |
@@ -3516,7 +3516,7 @@ discard block |
||
| 3516 | 3516 | return ''; |
| 3517 | 3517 | } |
| 3518 | 3518 | } |
| 3519 | - $atts .= " width='" . $largeur . "' height='" . $hauteur . "'"; |
|
| 3519 | + $atts .= " width='".$largeur."' height='".$hauteur."'"; |
|
| 3520 | 3520 | } |
| 3521 | 3521 | |
| 3522 | 3522 | if (file_exists($img_file)) { |
@@ -3526,14 +3526,14 @@ discard block |
||
| 3526 | 3526 | $alt = ''; |
| 3527 | 3527 | } |
| 3528 | 3528 | elseif ($alt or $alt === '') { |
| 3529 | - $alt = " alt='" . attribut_html($alt) . "'"; |
|
| 3529 | + $alt = " alt='".attribut_html($alt)."'"; |
|
| 3530 | 3530 | } |
| 3531 | 3531 | else { |
| 3532 | - $alt = " alt='" . attribut_html($title) . "'"; |
|
| 3532 | + $alt = " alt='".attribut_html($title)."'"; |
|
| 3533 | 3533 | } |
| 3534 | 3534 | return "<img src='$img_file'$alt" |
| 3535 | - . ($title ? ' title="' . attribut_html($title) . '"' : '') |
|
| 3536 | - . ' ' . ltrim($atts) |
|
| 3535 | + . ($title ? ' title="'.attribut_html($title).'"' : '') |
|
| 3536 | + . ' '.ltrim($atts) |
|
| 3537 | 3537 | . ' />'; |
| 3538 | 3538 | } |
| 3539 | 3539 | |
@@ -3547,10 +3547,10 @@ discard block |
||
| 3547 | 3547 | */ |
| 3548 | 3548 | function http_style_background($img, $att = '', $size = null) { |
| 3549 | 3549 | if ($size and is_numeric($size)) { |
| 3550 | - $size = trim($size) . 'px'; |
|
| 3550 | + $size = trim($size).'px'; |
|
| 3551 | 3551 | } |
| 3552 | - return " style='background" . |
|
| 3553 | - ($att ? '' : '-image') . ': url("' . chemin_image($img) . '")' . ($att ? (' ' . $att) : '') . ';' |
|
| 3552 | + return " style='background". |
|
| 3553 | + ($att ? '' : '-image').': url("'.chemin_image($img).'")'.($att ? (' '.$att) : '').';' |
|
| 3554 | 3554 | . ($size ? "background-size:{$size};" : '') |
| 3555 | 3555 | . "'"; |
| 3556 | 3556 | } |
@@ -3665,7 +3665,7 @@ discard block |
||
| 3665 | 3665 | $img = http_img_pack( |
| 3666 | 3666 | $img, |
| 3667 | 3667 | $alt, |
| 3668 | - $class ? " class='" . attribut_html($class) . "'" : '', |
|
| 3668 | + $class ? " class='".attribut_html($class)."'" : '', |
|
| 3669 | 3669 | '', |
| 3670 | 3670 | ['chemin_image' => false, 'utiliser_suffixe_size' => false] |
| 3671 | 3671 | ); |
@@ -3750,7 +3750,7 @@ discard block |
||
| 3750 | 3750 | $balise_svg_source = $balise_svg; |
| 3751 | 3751 | |
| 3752 | 3752 | // entete XML à supprimer |
| 3753 | - $svg = preg_replace(',^\s*<\?xml[^>]*\?' . '>,', '', $svg); |
|
| 3753 | + $svg = preg_replace(',^\s*<\?xml[^>]*\?'.'>,', '', $svg); |
|
| 3754 | 3754 | |
| 3755 | 3755 | // IE est toujours mon ami |
| 3756 | 3756 | $balise_svg = inserer_attribut($balise_svg, 'focusable', 'false'); |
@@ -3768,9 +3768,9 @@ discard block |
||
| 3768 | 3768 | // regler le alt |
| 3769 | 3769 | if ($alt) { |
| 3770 | 3770 | $balise_svg = inserer_attribut($balise_svg, 'role', 'img'); |
| 3771 | - $id = 'img-svg-title-' . substr(md5("$img_file:$svg:$alt"), 0, 4); |
|
| 3771 | + $id = 'img-svg-title-'.substr(md5("$img_file:$svg:$alt"), 0, 4); |
|
| 3772 | 3772 | $balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id); |
| 3773 | - $title = "<title id=\"$id\">" . entites_html($alt) . "</title>\n"; |
|
| 3773 | + $title = "<title id=\"$id\">".entites_html($alt)."</title>\n"; |
|
| 3774 | 3774 | $balise_svg .= $title; |
| 3775 | 3775 | } |
| 3776 | 3776 | else { |
@@ -3818,7 +3818,7 @@ discard block |
||
| 3818 | 3818 | if (is_array($tableau)) { |
| 3819 | 3819 | foreach ($tableau as $k => $v) { |
| 3820 | 3820 | $res = recuperer_fond( |
| 3821 | - 'modeles/' . $modele, |
|
| 3821 | + 'modeles/'.$modele, |
|
| 3822 | 3822 | array_merge(['cle' => $k], (is_array($v) ? $v : ['valeur' => $v])) |
| 3823 | 3823 | ); |
| 3824 | 3824 | $texte .= $res; |
@@ -4003,7 +4003,7 @@ discard block |
||
| 4003 | 4003 | } |
| 4004 | 4004 | |
| 4005 | 4005 | $c = serialize($c); |
| 4006 | - $cle = calculer_cle_action($form . $c); |
|
| 4006 | + $cle = calculer_cle_action($form.$c); |
|
| 4007 | 4007 | $c = "$cle:$c"; |
| 4008 | 4008 | |
| 4009 | 4009 | // on ne stocke pas les contextes dans des fichiers en cache |
@@ -4061,15 +4061,15 @@ discard block |
||
| 4061 | 4061 | } |
| 4062 | 4062 | // toujours encoder l'url source dans le bloc ajax |
| 4063 | 4063 | $r = self(); |
| 4064 | - $r = ' data-origin="' . $r . '"'; |
|
| 4064 | + $r = ' data-origin="'.$r.'"'; |
|
| 4065 | 4065 | $class = 'ajaxbloc'; |
| 4066 | 4066 | if ($ajaxid and is_string($ajaxid)) { |
| 4067 | 4067 | // ajaxid est normalement conforme a un nom de classe css |
| 4068 | 4068 | // on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution |
| 4069 | - $class .= ' ajax-id-' . entites_html($ajaxid); |
|
| 4069 | + $class .= ' ajax-id-'.entites_html($ajaxid); |
|
| 4070 | 4070 | } |
| 4071 | 4071 | |
| 4072 | - return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n"; |
|
| 4072 | + return "<div class='$class' "."data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n"; |
|
| 4073 | 4073 | } |
| 4074 | 4074 | |
| 4075 | 4075 | /** |
@@ -4113,7 +4113,7 @@ discard block |
||
| 4113 | 4113 | $cle = substr($c, 0, $p); |
| 4114 | 4114 | $c = substr($c, $p + 1); |
| 4115 | 4115 | |
| 4116 | - if ($cle == calculer_cle_action($form . $c)) { |
|
| 4116 | + if ($cle == calculer_cle_action($form.$c)) { |
|
| 4117 | 4117 | $env = @unserialize($c); |
| 4118 | 4118 | return $env; |
| 4119 | 4119 | } |
@@ -4234,13 +4234,13 @@ discard block |
||
| 4234 | 4234 | } |
| 4235 | 4235 | } |
| 4236 | 4236 | } |
| 4237 | - $att .= 'class="' . ($class ? attribut_html($class) . ' ' : '') . (defined('_LIEN_OU_EXPOSE_CLASS_ON') ? _LIEN_OU_EXPOSE_CLASS_ON : 'on') . '"'; |
|
| 4237 | + $att .= 'class="'.($class ? attribut_html($class).' ' : '').(defined('_LIEN_OU_EXPOSE_CLASS_ON') ? _LIEN_OU_EXPOSE_CLASS_ON : 'on').'"'; |
|
| 4238 | 4238 | } else { |
| 4239 | 4239 | $bal = 'a'; |
| 4240 | 4240 | $att = "href='$url'" |
| 4241 | - . ($title ? " title='" . attribut_html($title) . "'" : '') |
|
| 4242 | - . ($class ? " class='" . attribut_html($class) . "'" : '') |
|
| 4243 | - . ($rel ? " rel='" . attribut_html($rel) . "'" : '') |
|
| 4241 | + . ($title ? " title='".attribut_html($title)."'" : '') |
|
| 4242 | + . ($class ? " class='".attribut_html($class)."'" : '') |
|
| 4243 | + . ($rel ? " rel='".attribut_html($rel)."'" : '') |
|
| 4244 | 4244 | . $evt; |
| 4245 | 4245 | } |
| 4246 | 4246 | if ($libelle === null) { |
@@ -4379,7 +4379,7 @@ discard block |
||
| 4379 | 4379 | |
| 4380 | 4380 | // Icône |
| 4381 | 4381 | $icone = http_img_pack($fond, $alt, "width='$size' height='$size'"); |
| 4382 | - $icone = '<span class="icone-image' . ($fonction ? " icone-fonction icone-fonction-$fonction" : '') . "\">$icone</span>"; |
|
| 4382 | + $icone = '<span class="icone-image'.($fonction ? " icone-fonction icone-fonction-$fonction" : '')."\">$icone</span>"; |
|
| 4383 | 4383 | |
| 4384 | 4384 | // Markup final |
| 4385 | 4385 | if ($type == 'lien') { |
@@ -4656,20 +4656,20 @@ discard block |
||
| 4656 | 4656 | $class_form = 'ajax'; |
| 4657 | 4657 | $class = str_replace('ajax', '', $class); |
| 4658 | 4658 | } |
| 4659 | - $class_btn = 'submit ' . trim($class); |
|
| 4659 | + $class_btn = 'submit '.trim($class); |
|
| 4660 | 4660 | |
| 4661 | 4661 | if ($confirm) { |
| 4662 | - $confirm = 'confirm("' . attribut_html($confirm) . '")'; |
|
| 4662 | + $confirm = 'confirm("'.attribut_html($confirm).'")'; |
|
| 4663 | 4663 | if ($callback) { |
| 4664 | 4664 | $callback = "$confirm?($callback):false"; |
| 4665 | 4665 | } else { |
| 4666 | 4666 | $callback = $confirm; |
| 4667 | 4667 | } |
| 4668 | 4668 | } |
| 4669 | - $onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : ''; |
|
| 4669 | + $onclick = $callback ? " onclick='return ".addcslashes($callback, "'")."'" : ''; |
|
| 4670 | 4670 | $title = $title ? " title='$title'" : ''; |
| 4671 | 4671 | |
| 4672 | - return "<form class='bouton_action_post $class_form' method='post' action='$url'><div>" . form_hidden($url) |
|
| 4672 | + return "<form class='bouton_action_post $class_form' method='post' action='$url'><div>".form_hidden($url) |
|
| 4673 | 4673 | . "<button type='submit' class='$class_btn'$title$onclick>$libelle</button></div></form>"; |
| 4674 | 4674 | } |
| 4675 | 4675 | |
@@ -4734,14 +4734,14 @@ discard block |
||
| 4734 | 4734 | $champ_titre = ''; |
| 4735 | 4735 | if ($demande_titre) { |
| 4736 | 4736 | // si pas de titre declare mais champ titre, il sera peuple par le select * |
| 4737 | - $champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : ''; |
|
| 4737 | + $champ_titre = (!empty($desc['titre'])) ? ', '.$desc['titre'] : ''; |
|
| 4738 | 4738 | } |
| 4739 | 4739 | include_spip('base/abstract_sql'); |
| 4740 | 4740 | include_spip('base/connect_sql'); |
| 4741 | 4741 | $objets[$type_objet][$id_objet] = sql_fetsel( |
| 4742 | - '*' . $champ_titre, |
|
| 4742 | + '*'.$champ_titre, |
|
| 4743 | 4743 | $desc['table_sql'], |
| 4744 | - id_table_objet($type_objet) . ' = ' . intval($id_objet) |
|
| 4744 | + id_table_objet($type_objet).' = '.intval($id_objet) |
|
| 4745 | 4745 | ); |
| 4746 | 4746 | |
| 4747 | 4747 | // Toujours noter la longueur d'introduction, même si pas demandé cette fois-ci |
@@ -4834,8 +4834,7 @@ discard block |
||
| 4834 | 4834 | if (isset($ligne_sql['chapo'])) { |
| 4835 | 4835 | $chapo = $ligne_sql['chapo']; |
| 4836 | 4836 | $texte = strlen($descriptif) ? |
| 4837 | - '' : |
|
| 4838 | - "$chapo \n\n $texte"; |
|
| 4837 | + '' : "$chapo \n\n $texte"; |
|
| 4839 | 4838 | } |
| 4840 | 4839 | |
| 4841 | 4840 | // Longueur en paramètre, sinon celle renseignée dans la description de l'objet, sinon valeur en dur |
@@ -4910,7 +4909,7 @@ discard block |
||
| 4910 | 4909 | return $texte; |
| 4911 | 4910 | } |
| 4912 | 4911 | |
| 4913 | - $traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement); |
|
| 4912 | + $traitement = str_replace('%s', "'".texte_script($texte)."'", $traitement); |
|
| 4914 | 4913 | |
| 4915 | 4914 | // Fournir $connect et $Pile[0] au traitement si besoin |
| 4916 | 4915 | $Pile = [0 => $env]; |
@@ -4944,7 +4943,7 @@ discard block |
||
| 4944 | 4943 | } |
| 4945 | 4944 | $url = generer_objet_url($id_objet, $objet, '', '', $connect); |
| 4946 | 4945 | |
| 4947 | - return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . '</a>'; |
|
| 4946 | + return "<a href='$url' class='$objet'>".couper($titre, $longueur).'</a>'; |
|
| 4948 | 4947 | } |
| 4949 | 4948 | |
| 4950 | 4949 | /** |
@@ -4970,10 +4969,10 @@ discard block |
||
| 4970 | 4969 | function wrap($texte, $wrap) { |
| 4971 | 4970 | $balises = extraire_balises($wrap); |
| 4972 | 4971 | if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) { |
| 4973 | - $texte = $wrap . $texte; |
|
| 4972 | + $texte = $wrap.$texte; |
|
| 4974 | 4973 | $regs = array_reverse($regs[1]); |
| 4975 | - $wrap = '</' . implode('></', $regs) . '>'; |
|
| 4976 | - $texte = $texte . $wrap; |
|
| 4974 | + $wrap = '</'.implode('></', $regs).'>'; |
|
| 4975 | + $texte = $texte.$wrap; |
|
| 4977 | 4976 | } |
| 4978 | 4977 | |
| 4979 | 4978 | return $texte; |
@@ -5004,7 +5003,7 @@ discard block |
||
| 5004 | 5003 | |
| 5005 | 5004 | // caster $u en array si besoin |
| 5006 | 5005 | if (is_object($u)) { |
| 5007 | - $u = (array)$u; |
|
| 5006 | + $u = (array) $u; |
|
| 5008 | 5007 | } |
| 5009 | 5008 | |
| 5010 | 5009 | if (is_array($u)) { |
@@ -5026,7 +5025,7 @@ discard block |
||
| 5026 | 5025 | // sinon on passe a la ligne et on indente |
| 5027 | 5026 | $i_str = str_pad('', $indent, ' '); |
| 5028 | 5027 | foreach ($u as $k => $v) { |
| 5029 | - $out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2); |
|
| 5028 | + $out .= $join.$i_str."$k: ".filtre_print_dist($v, $join, $indent + 2); |
|
| 5030 | 5029 | } |
| 5031 | 5030 | |
| 5032 | 5031 | return $out; |
@@ -5080,7 +5079,7 @@ discard block |
||
| 5080 | 5079 | * @return string |
| 5081 | 5080 | */ |
| 5082 | 5081 | function objet_icone($objet, $taille = 24, $class = '') { |
| 5083 | - $icone = objet_info($objet, 'icone_objet') . '-' . $taille . '.png'; |
|
| 5082 | + $icone = objet_info($objet, 'icone_objet').'-'.$taille.'.png'; |
|
| 5084 | 5083 | $icone = chemin_image($icone); |
| 5085 | 5084 | $balise_img = charger_filtre('balise_img'); |
| 5086 | 5085 | |
@@ -5106,7 +5105,7 @@ discard block |
||
| 5106 | 5105 | */ |
| 5107 | 5106 | function objet_T($objet, $chaine, $args = [], $options = []) { |
| 5108 | 5107 | $chaine = explode(':', $chaine); |
| 5109 | - if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, ['force' => false]))) { |
|
| 5108 | + if ($t = _T($objet.':'.end($chaine), $args, array_merge($options, ['force' => false]))) { |
|
| 5110 | 5109 | return $t; |
| 5111 | 5110 | } |
| 5112 | 5111 | $chaine = implode(':', $chaine); |
@@ -5172,7 +5171,7 @@ discard block |
||
| 5172 | 5171 | $cache = recuperer_fond($fond, $contexte, $options, $connect); |
| 5173 | 5172 | |
| 5174 | 5173 | // calculer le nom de la css |
| 5175 | - $dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension); |
|
| 5174 | + $dir_var = sous_repertoire(_DIR_VAR, 'cache-'.$extension); |
|
| 5176 | 5175 | $nom_safe = preg_replace(',\W,', '_', str_replace('.', '_', $fond)); |
| 5177 | 5176 | $contexte_implicite = calculer_contexte_implicite(); |
| 5178 | 5177 | |
@@ -5180,14 +5179,14 @@ discard block |
||
| 5180 | 5179 | // mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu |
| 5181 | 5180 | // reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine |
| 5182 | 5181 | if (isset($options['hash_on_content']) and $options['hash_on_content']) { |
| 5183 | - $hash = md5($contexte_implicite['host'] . '::' . $cache); |
|
| 5182 | + $hash = md5($contexte_implicite['host'].'::'.$cache); |
|
| 5184 | 5183 | } |
| 5185 | 5184 | else { |
| 5186 | 5185 | unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js |
| 5187 | 5186 | ksort($contexte); |
| 5188 | - $hash = md5($fond . json_encode($contexte_implicite, JSON_THROW_ON_ERROR) . json_encode($contexte, JSON_THROW_ON_ERROR) . $connect); |
|
| 5187 | + $hash = md5($fond.json_encode($contexte_implicite, JSON_THROW_ON_ERROR).json_encode($contexte, JSON_THROW_ON_ERROR).$connect); |
|
| 5189 | 5188 | } |
| 5190 | - $filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension"; |
|
| 5189 | + $filename = $dir_var.$extension."dyn-$nom_safe-".substr($hash, 0, 8).".$extension"; |
|
| 5191 | 5190 | |
| 5192 | 5191 | // mettre a jour le fichier si il n'existe pas |
| 5193 | 5192 | // ou trop ancien |
@@ -5195,8 +5194,8 @@ discard block |
||
| 5195 | 5194 | // et recopie sur le fichier cible uniquement si il change |
| 5196 | 5195 | if ( |
| 5197 | 5196 | !file_exists($filename) |
| 5198 | - or !file_exists($filename . '.last') |
|
| 5199 | - or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . '.last') < $cache['lastmodified']) |
|
| 5197 | + or !file_exists($filename.'.last') |
|
| 5198 | + or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename.'.last') < $cache['lastmodified']) |
|
| 5200 | 5199 | or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul') |
| 5201 | 5200 | ) { |
| 5202 | 5201 | $contenu = $cache['texte']; |
@@ -5217,10 +5216,10 @@ discard block |
||
| 5217 | 5216 | } |
| 5218 | 5217 | // pas de date dans le commentaire car sinon ca invalide le md5 et force la maj |
| 5219 | 5218 | // mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non |
| 5220 | - $comment .= "}\n md5:" . md5($contenu) . " */\n"; |
|
| 5219 | + $comment .= "}\n md5:".md5($contenu)." */\n"; |
|
| 5221 | 5220 | } |
| 5222 | 5221 | // et ecrire le fichier si il change |
| 5223 | - ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true); |
|
| 5222 | + ecrire_fichier_calcule_si_modifie($filename, $comment.$contenu, false, true); |
|
| 5224 | 5223 | } |
| 5225 | 5224 | |
| 5226 | 5225 | return timestamp($filename); |
@@ -5446,7 +5445,7 @@ discard block |
||
| 5446 | 5445 | if ($e > 0 and strlen($mid) > 8) { |
| 5447 | 5446 | $mid = '***...***'; |
| 5448 | 5447 | } |
| 5449 | - return substr($passe, 0, $e) . $mid . ($e > 0 ? substr($passe, -$e) : ''); |
|
| 5448 | + return substr($passe, 0, $e).$mid.($e > 0 ? substr($passe, -$e) : ''); |
|
| 5450 | 5449 | } |
| 5451 | 5450 | |
| 5452 | 5451 | |
@@ -5508,7 +5507,7 @@ discard block |
||
| 5508 | 5507 | case 'id': |
| 5509 | 5508 | case 'anchor': |
| 5510 | 5509 | if (preg_match(',^\d,', $texte)) { |
| 5511 | - $texte = substr($type, 0, 1) . $texte; |
|
| 5510 | + $texte = substr($type, 0, 1).$texte; |
|
| 5512 | 5511 | } |
| 5513 | 5512 | } |
| 5514 | 5513 | |
@@ -5518,9 +5517,9 @@ discard block |
||
| 5518 | 5517 | |
| 5519 | 5518 | if (strlen($texte) < $longueur_mini and $longueur_mini < $longueur_maxi) { |
| 5520 | 5519 | if (preg_match(',^\d,', $texte)) { |
| 5521 | - $texte = ($type ? substr($type, 0, 1) : 's') . $texte; |
|
| 5520 | + $texte = ($type ? substr($type, 0, 1) : 's').$texte; |
|
| 5522 | 5521 | } |
| 5523 | - $texte .= $separateur . md5($original); |
|
| 5522 | + $texte .= $separateur.md5($original); |
|
| 5524 | 5523 | $texte = substr($texte, 0, $longueur_mini); |
| 5525 | 5524 | } |
| 5526 | 5525 | |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | include_spip('base/objets'); |
| 23 | 23 | |
@@ -57,106 +57,106 @@ discard block |
||
| 57 | 57 | * |
| 58 | 58 | */ |
| 59 | 59 | function urls_decoder_url($url, $fond = '', $contexte = [], $assembler = false) { |
| 60 | - static $current_base = null; |
|
| 60 | + static $current_base = null; |
|
| 61 | 61 | |
| 62 | - // les anciennes fonctions modifient directement les globales |
|
| 63 | - // on les sauve avant l'appel, et on les retablit apres ! |
|
| 64 | - $save = [ |
|
| 65 | - $GLOBALS['fond'] ?? null, |
|
| 66 | - $GLOBALS['contexte'] ?? null, |
|
| 67 | - $_SERVER['REDIRECT_url_propre'] ?? null, |
|
| 68 | - $_ENV['url_propre'] ?? null, |
|
| 69 | - $GLOBALS['profondeur_url'] |
|
| 70 | - ]; |
|
| 62 | + // les anciennes fonctions modifient directement les globales |
|
| 63 | + // on les sauve avant l'appel, et on les retablit apres ! |
|
| 64 | + $save = [ |
|
| 65 | + $GLOBALS['fond'] ?? null, |
|
| 66 | + $GLOBALS['contexte'] ?? null, |
|
| 67 | + $_SERVER['REDIRECT_url_propre'] ?? null, |
|
| 68 | + $_ENV['url_propre'] ?? null, |
|
| 69 | + $GLOBALS['profondeur_url'] |
|
| 70 | + ]; |
|
| 71 | 71 | |
| 72 | - if (is_null($current_base)) { |
|
| 73 | - include_spip('inc/filtres_mini'); |
|
| 74 | - // le decodage des urls se fait toujours par rapport au site public |
|
| 75 | - $current_base = url_absolue(_DIR_RACINE ?: './'); |
|
| 76 | - } |
|
| 77 | - if (strncmp($url, $current_base, strlen($current_base)) == 0) { |
|
| 78 | - $url = substr($url, strlen($current_base)); |
|
| 79 | - } |
|
| 72 | + if (is_null($current_base)) { |
|
| 73 | + include_spip('inc/filtres_mini'); |
|
| 74 | + // le decodage des urls se fait toujours par rapport au site public |
|
| 75 | + $current_base = url_absolue(_DIR_RACINE ?: './'); |
|
| 76 | + } |
|
| 77 | + if (strncmp($url, $current_base, strlen($current_base)) == 0) { |
|
| 78 | + $url = substr($url, strlen($current_base)); |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - // si on est en train d'assembler la page principale, |
|
| 82 | - // recuperer l'url depuis les globales url propres si fournies |
|
| 83 | - // sinon extraire la bonne portion d'url |
|
| 84 | - if ($assembler) { |
|
| 85 | - if (isset($_SERVER['REDIRECT_url_propre'])) { |
|
| 86 | - $url = $_SERVER['REDIRECT_url_propre']; |
|
| 87 | - } elseif (isset($_ENV['url_propre'])) { |
|
| 88 | - $url = $_ENV['url_propre']; |
|
| 89 | - } else { |
|
| 90 | - $qs = explode('?', $url); |
|
| 91 | - // ne prendre que le segment d'url qui correspond, en fonction de la profondeur calculee |
|
| 92 | - $url = ltrim($qs[0], '/'); |
|
| 93 | - $url = explode('/', $url); |
|
| 94 | - while (count($url) > $GLOBALS['profondeur_url'] + 1) { |
|
| 95 | - array_shift($url); |
|
| 96 | - } |
|
| 97 | - $qs[0] = implode('/', $url); |
|
| 98 | - $url = implode('?', $qs); |
|
| 99 | - } |
|
| 100 | - } |
|
| 81 | + // si on est en train d'assembler la page principale, |
|
| 82 | + // recuperer l'url depuis les globales url propres si fournies |
|
| 83 | + // sinon extraire la bonne portion d'url |
|
| 84 | + if ($assembler) { |
|
| 85 | + if (isset($_SERVER['REDIRECT_url_propre'])) { |
|
| 86 | + $url = $_SERVER['REDIRECT_url_propre']; |
|
| 87 | + } elseif (isset($_ENV['url_propre'])) { |
|
| 88 | + $url = $_ENV['url_propre']; |
|
| 89 | + } else { |
|
| 90 | + $qs = explode('?', $url); |
|
| 91 | + // ne prendre que le segment d'url qui correspond, en fonction de la profondeur calculee |
|
| 92 | + $url = ltrim($qs[0], '/'); |
|
| 93 | + $url = explode('/', $url); |
|
| 94 | + while (count($url) > $GLOBALS['profondeur_url'] + 1) { |
|
| 95 | + array_shift($url); |
|
| 96 | + } |
|
| 97 | + $qs[0] = implode('/', $url); |
|
| 98 | + $url = implode('?', $qs); |
|
| 99 | + } |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - unset($_SERVER['REDIRECT_url_propre']); |
|
| 103 | - unset($_ENV['url_propre']); |
|
| 104 | - include_spip('inc/filtres_mini'); |
|
| 105 | - if (strpos($url, '://') === false) { |
|
| 106 | - $GLOBALS['profondeur_url'] = substr_count(ltrim(resolve_path("/$url"), '/'), '/'); |
|
| 107 | - } else { |
|
| 108 | - $GLOBALS['profondeur_url'] = max(0, substr_count($url, '/') - substr_count($current_base, '/')); |
|
| 109 | - } |
|
| 102 | + unset($_SERVER['REDIRECT_url_propre']); |
|
| 103 | + unset($_ENV['url_propre']); |
|
| 104 | + include_spip('inc/filtres_mini'); |
|
| 105 | + if (strpos($url, '://') === false) { |
|
| 106 | + $GLOBALS['profondeur_url'] = substr_count(ltrim(resolve_path("/$url"), '/'), '/'); |
|
| 107 | + } else { |
|
| 108 | + $GLOBALS['profondeur_url'] = max(0, substr_count($url, '/') - substr_count($current_base, '/')); |
|
| 109 | + } |
|
| 110 | 110 | |
| 111 | - $url_redirect = ''; |
|
| 112 | - $decoder = charger_fonction_url('decoder'); |
|
| 113 | - if ($decoder) { |
|
| 114 | - $a = $decoder($url, $fond, $contexte); |
|
| 115 | - if (is_array($a)) { |
|
| 116 | - [$ncontexte, $type, $url_redirect, $nfond] = array_pad($a, 4, null); |
|
| 117 | - $url_redirect ??= ''; |
|
| 118 | - if ($url_redirect === $url) { |
|
| 119 | - $url_redirect = ''; |
|
| 120 | - } // securite pour eviter une redirection infinie |
|
| 121 | - if ($assembler and strlen($url_redirect)) { |
|
| 122 | - spip_log("Redirige $url vers $url_redirect"); |
|
| 123 | - include_spip('inc/headers'); |
|
| 124 | - redirige_par_entete($url_redirect, '', 301); |
|
| 125 | - } |
|
| 126 | - if (isset($nfond)) { |
|
| 127 | - $fond = $nfond; |
|
| 128 | - } else { |
|
| 129 | - if ( |
|
| 130 | - $fond == '' |
|
| 131 | - or $fond == 'type_urls' /* compat avec htaccess 2.0.0 */ |
|
| 132 | - ) { |
|
| 133 | - $fond = $type; |
|
| 134 | - } |
|
| 135 | - } |
|
| 136 | - if (isset($ncontexte)) { |
|
| 137 | - $contexte = $ncontexte; |
|
| 138 | - } |
|
| 139 | - if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) { |
|
| 140 | - $contexte['type'] = $type; |
|
| 141 | - } |
|
| 142 | - if (!defined('_DEFINIR_CONTEXTE_TYPE_PAGE') or _DEFINIR_CONTEXTE_TYPE_PAGE) { |
|
| 143 | - $contexte['type-page'] = $type; |
|
| 144 | - } |
|
| 145 | - } |
|
| 146 | - } |
|
| 111 | + $url_redirect = ''; |
|
| 112 | + $decoder = charger_fonction_url('decoder'); |
|
| 113 | + if ($decoder) { |
|
| 114 | + $a = $decoder($url, $fond, $contexte); |
|
| 115 | + if (is_array($a)) { |
|
| 116 | + [$ncontexte, $type, $url_redirect, $nfond] = array_pad($a, 4, null); |
|
| 117 | + $url_redirect ??= ''; |
|
| 118 | + if ($url_redirect === $url) { |
|
| 119 | + $url_redirect = ''; |
|
| 120 | + } // securite pour eviter une redirection infinie |
|
| 121 | + if ($assembler and strlen($url_redirect)) { |
|
| 122 | + spip_log("Redirige $url vers $url_redirect"); |
|
| 123 | + include_spip('inc/headers'); |
|
| 124 | + redirige_par_entete($url_redirect, '', 301); |
|
| 125 | + } |
|
| 126 | + if (isset($nfond)) { |
|
| 127 | + $fond = $nfond; |
|
| 128 | + } else { |
|
| 129 | + if ( |
|
| 130 | + $fond == '' |
|
| 131 | + or $fond == 'type_urls' /* compat avec htaccess 2.0.0 */ |
|
| 132 | + ) { |
|
| 133 | + $fond = $type; |
|
| 134 | + } |
|
| 135 | + } |
|
| 136 | + if (isset($ncontexte)) { |
|
| 137 | + $contexte = $ncontexte; |
|
| 138 | + } |
|
| 139 | + if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) { |
|
| 140 | + $contexte['type'] = $type; |
|
| 141 | + } |
|
| 142 | + if (!defined('_DEFINIR_CONTEXTE_TYPE_PAGE') or _DEFINIR_CONTEXTE_TYPE_PAGE) { |
|
| 143 | + $contexte['type-page'] = $type; |
|
| 144 | + } |
|
| 145 | + } |
|
| 146 | + } |
|
| 147 | 147 | |
| 148 | - // retablir les globales |
|
| 149 | - [$GLOBALS['fond'], $GLOBALS['contexte'], $_SERVER['REDIRECT_url_propre'], $_ENV['url_propre'], $GLOBALS['profondeur_url']] = $save; |
|
| 148 | + // retablir les globales |
|
| 149 | + [$GLOBALS['fond'], $GLOBALS['contexte'], $_SERVER['REDIRECT_url_propre'], $_ENV['url_propre'], $GLOBALS['profondeur_url']] = $save; |
|
| 150 | 150 | |
| 151 | - // vider les globales url propres qui ne doivent plus etre utilisees en cas |
|
| 152 | - // d'inversion url => objet |
|
| 153 | - // maintenir pour compat ? |
|
| 154 | - #if ($assembler) { |
|
| 155 | - # unset($_SERVER['REDIRECT_url_propre']); |
|
| 156 | - # unset($_ENV['url_propre']); |
|
| 157 | - #} |
|
| 151 | + // vider les globales url propres qui ne doivent plus etre utilisees en cas |
|
| 152 | + // d'inversion url => objet |
|
| 153 | + // maintenir pour compat ? |
|
| 154 | + #if ($assembler) { |
|
| 155 | + # unset($_SERVER['REDIRECT_url_propre']); |
|
| 156 | + # unset($_ENV['url_propre']); |
|
| 157 | + #} |
|
| 158 | 158 | |
| 159 | - return [$fond, $contexte, $url_redirect]; |
|
| 159 | + return [$fond, $contexte, $url_redirect]; |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /** |
@@ -169,20 +169,20 @@ discard block |
||
| 169 | 169 | * @return array|false|string |
| 170 | 170 | */ |
| 171 | 171 | function urls_transition_retrouver_anciennes_url_propres(string $url_propre, string $entite, array $contexte = []): array { |
| 172 | - if ($url_propre) { |
|
| 173 | - if ($GLOBALS['profondeur_url'] <= 0) { |
|
| 174 | - $urls_anciennes = charger_fonction_url('decoder', 'propres'); |
|
| 175 | - } else { |
|
| 176 | - $urls_anciennes = charger_fonction_url('decoder', 'arbo'); |
|
| 177 | - } |
|
| 172 | + if ($url_propre) { |
|
| 173 | + if ($GLOBALS['profondeur_url'] <= 0) { |
|
| 174 | + $urls_anciennes = charger_fonction_url('decoder', 'propres'); |
|
| 175 | + } else { |
|
| 176 | + $urls_anciennes = charger_fonction_url('decoder', 'arbo'); |
|
| 177 | + } |
|
| 178 | 178 | |
| 179 | - if ($urls_anciennes) { |
|
| 180 | - $urls_anciennes = $urls_anciennes($url_propre, $entite, $contexte); |
|
| 181 | - } |
|
| 182 | - return $urls_anciennes ?: []; |
|
| 183 | - } |
|
| 179 | + if ($urls_anciennes) { |
|
| 180 | + $urls_anciennes = $urls_anciennes($url_propre, $entite, $contexte); |
|
| 181 | + } |
|
| 182 | + return $urls_anciennes ?: []; |
|
| 183 | + } |
|
| 184 | 184 | |
| 185 | - return []; |
|
| 185 | + return []; |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | /** |
@@ -195,41 +195,41 @@ discard block |
||
| 195 | 195 | * @return array|false|string |
| 196 | 196 | */ |
| 197 | 197 | function urls_transition_retrouver_anciennes_url_html(string $url, string $entite, array $contexte = []): array { |
| 198 | - // Migration depuis anciennes URLs ? |
|
| 199 | - // traiter les injections domain.tld/spip.php/n/importe/quoi/rubrique23 |
|
| 200 | - if ( |
|
| 201 | - $url |
|
| 202 | - and $GLOBALS['profondeur_url'] <= 0 |
|
| 203 | - ) { |
|
| 204 | - $r = nettoyer_url_page($url, $contexte); |
|
| 205 | - if ($r) { |
|
| 206 | - [$contexte, $type, , , $suite] = $r; |
|
| 207 | - $_id = id_table_objet($type); |
|
| 208 | - $id_objet = $contexte[$_id]; |
|
| 209 | - $url_propre = generer_objet_url($id_objet, $type); |
|
| 210 | - if ( |
|
| 211 | - strlen($url_propre) |
|
| 212 | - and !strstr($url, (string) $url_propre) |
|
| 213 | - and ( |
|
| 214 | - objet_test_si_publie($type, $id_objet) |
|
| 215 | - or (defined('_VAR_PREVIEW') and _VAR_PREVIEW and autoriser('voir', $type, $id_objet)) |
|
| 216 | - ) |
|
| 217 | - ) { |
|
| 218 | - [, $hash] = array_pad(explode('#', $url_propre), 2, null); |
|
| 219 | - $args = []; |
|
| 220 | - foreach (array_filter(explode('&', $suite)) as $fragment) { |
|
| 221 | - if ($fragment != "$_id=$id_objet") { |
|
| 222 | - $args[] = $fragment; |
|
| 223 | - } |
|
| 224 | - } |
|
| 225 | - $url_redirect = generer_objet_url($id_objet, $type, join('&', array_filter($args)), $hash); |
|
| 198 | + // Migration depuis anciennes URLs ? |
|
| 199 | + // traiter les injections domain.tld/spip.php/n/importe/quoi/rubrique23 |
|
| 200 | + if ( |
|
| 201 | + $url |
|
| 202 | + and $GLOBALS['profondeur_url'] <= 0 |
|
| 203 | + ) { |
|
| 204 | + $r = nettoyer_url_page($url, $contexte); |
|
| 205 | + if ($r) { |
|
| 206 | + [$contexte, $type, , , $suite] = $r; |
|
| 207 | + $_id = id_table_objet($type); |
|
| 208 | + $id_objet = $contexte[$_id]; |
|
| 209 | + $url_propre = generer_objet_url($id_objet, $type); |
|
| 210 | + if ( |
|
| 211 | + strlen($url_propre) |
|
| 212 | + and !strstr($url, (string) $url_propre) |
|
| 213 | + and ( |
|
| 214 | + objet_test_si_publie($type, $id_objet) |
|
| 215 | + or (defined('_VAR_PREVIEW') and _VAR_PREVIEW and autoriser('voir', $type, $id_objet)) |
|
| 216 | + ) |
|
| 217 | + ) { |
|
| 218 | + [, $hash] = array_pad(explode('#', $url_propre), 2, null); |
|
| 219 | + $args = []; |
|
| 220 | + foreach (array_filter(explode('&', $suite)) as $fragment) { |
|
| 221 | + if ($fragment != "$_id=$id_objet") { |
|
| 222 | + $args[] = $fragment; |
|
| 223 | + } |
|
| 224 | + } |
|
| 225 | + $url_redirect = generer_objet_url($id_objet, $type, join('&', array_filter($args)), $hash); |
|
| 226 | 226 | |
| 227 | - return [$contexte, $type, $url_redirect, $type]; |
|
| 228 | - } |
|
| 229 | - } |
|
| 230 | - } |
|
| 231 | - /* Fin compatibilite anciennes urls */ |
|
| 232 | - return []; |
|
| 227 | + return [$contexte, $type, $url_redirect, $type]; |
|
| 228 | + } |
|
| 229 | + } |
|
| 230 | + } |
|
| 231 | + /* Fin compatibilite anciennes urls */ |
|
| 232 | + return []; |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | /** |
@@ -242,24 +242,24 @@ discard block |
||
| 242 | 242 | * @return string|array |
| 243 | 243 | */ |
| 244 | 244 | function urls_liste_objets($preg = true) { |
| 245 | - static $url_objets = null; |
|
| 246 | - if (is_null($url_objets)) { |
|
| 247 | - $url_objets = []; |
|
| 248 | - // recuperer les tables_objets_sql declarees |
|
| 249 | - $tables_objets = lister_tables_objets_sql(); |
|
| 250 | - foreach ($tables_objets as $t => $infos) { |
|
| 251 | - if ($infos['page']) { |
|
| 252 | - $url_objets[] = $infos['type']; |
|
| 253 | - $url_objets = array_merge($url_objets, $infos['type_surnoms']); |
|
| 254 | - } |
|
| 255 | - } |
|
| 256 | - $url_objets = pipeline('declarer_url_objets', $url_objets); |
|
| 257 | - } |
|
| 258 | - if (!$preg) { |
|
| 259 | - return $url_objets; |
|
| 260 | - } |
|
| 245 | + static $url_objets = null; |
|
| 246 | + if (is_null($url_objets)) { |
|
| 247 | + $url_objets = []; |
|
| 248 | + // recuperer les tables_objets_sql declarees |
|
| 249 | + $tables_objets = lister_tables_objets_sql(); |
|
| 250 | + foreach ($tables_objets as $t => $infos) { |
|
| 251 | + if ($infos['page']) { |
|
| 252 | + $url_objets[] = $infos['type']; |
|
| 253 | + $url_objets = array_merge($url_objets, $infos['type_surnoms']); |
|
| 254 | + } |
|
| 255 | + } |
|
| 256 | + $url_objets = pipeline('declarer_url_objets', $url_objets); |
|
| 257 | + } |
|
| 258 | + if (!$preg) { |
|
| 259 | + return $url_objets; |
|
| 260 | + } |
|
| 261 | 261 | |
| 262 | - return implode('|', array_map('preg_quote', $url_objets)); |
|
| 262 | + return implode('|', array_map('preg_quote', $url_objets)); |
|
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | /** |
@@ -273,26 +273,26 @@ discard block |
||
| 273 | 273 | * @return array |
| 274 | 274 | */ |
| 275 | 275 | function nettoyer_url_page($url, $contexte = []) { |
| 276 | - $url_objets = urls_liste_objets(); |
|
| 277 | - $raccourci_url_page_html = ',^(?:[^?]*/)?(' . $url_objets . ')([0-9]+)(?:\.html)?([?&].*)?$,'; |
|
| 278 | - $raccourci_url_page_id = ',^(?:[^?]*/)?(' . $url_objets . ')\.php3?[?]id_\1=([0-9]+)([?&].*)?$,'; |
|
| 279 | - $raccourci_url_page_spip = ',^(?:[^?]*/)?(?:spip[.]php)?[?](' . $url_objets . ')([0-9]+)=?(&.*)?$,'; |
|
| 276 | + $url_objets = urls_liste_objets(); |
|
| 277 | + $raccourci_url_page_html = ',^(?:[^?]*/)?(' . $url_objets . ')([0-9]+)(?:\.html)?([?&].*)?$,'; |
|
| 278 | + $raccourci_url_page_id = ',^(?:[^?]*/)?(' . $url_objets . ')\.php3?[?]id_\1=([0-9]+)([?&].*)?$,'; |
|
| 279 | + $raccourci_url_page_spip = ',^(?:[^?]*/)?(?:spip[.]php)?[?](' . $url_objets . ')([0-9]+)=?(&.*)?$,'; |
|
| 280 | 280 | |
| 281 | - if ( |
|
| 282 | - preg_match($raccourci_url_page_html, $url, $regs) |
|
| 283 | - or preg_match($raccourci_url_page_id, $url, $regs) |
|
| 284 | - or preg_match($raccourci_url_page_spip, $url, $regs) |
|
| 285 | - ) { |
|
| 286 | - $regs = array_pad($regs, 4, null); |
|
| 287 | - $type = objet_type($regs[1]); |
|
| 288 | - $_id = id_table_objet($type); |
|
| 289 | - $contexte[$_id] = $regs[2]; |
|
| 290 | - $suite = $regs[3]; |
|
| 281 | + if ( |
|
| 282 | + preg_match($raccourci_url_page_html, $url, $regs) |
|
| 283 | + or preg_match($raccourci_url_page_id, $url, $regs) |
|
| 284 | + or preg_match($raccourci_url_page_spip, $url, $regs) |
|
| 285 | + ) { |
|
| 286 | + $regs = array_pad($regs, 4, null); |
|
| 287 | + $type = objet_type($regs[1]); |
|
| 288 | + $_id = id_table_objet($type); |
|
| 289 | + $contexte[$_id] = $regs[2]; |
|
| 290 | + $suite = $regs[3]; |
|
| 291 | 291 | |
| 292 | - return [$contexte, $type, null, $type, $suite]; |
|
| 293 | - } |
|
| 292 | + return [$contexte, $type, null, $type, $suite]; |
|
| 293 | + } |
|
| 294 | 294 | |
| 295 | - return []; |
|
| 295 | + return []; |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | /** |
@@ -311,37 +311,37 @@ discard block |
||
| 311 | 311 | * |
| 312 | 312 | */ |
| 313 | 313 | function generer_objet_url_ecrire($objet, $id, $args = '', $ancre = '', $public = null, string $connect = '') { |
| 314 | - static $furls = []; |
|
| 315 | - if (!isset($furls[$objet])) { |
|
| 316 | - if ( |
|
| 317 | - function_exists($f = 'generer_' . $objet . '_url_ecrire') |
|
| 318 | - // ou definie par un plugin |
|
| 319 | - or $f = charger_fonction($f, 'urls', true) |
|
| 320 | - // deprecated |
|
| 321 | - or function_exists($f = 'generer_url_ecrire_' . $objet) or $f = charger_fonction($f, 'urls', true) |
|
| 322 | - ) { |
|
| 323 | - $furls[$objet] = $f; |
|
| 324 | - } else { |
|
| 325 | - $furls[$objet] = ''; |
|
| 326 | - } |
|
| 327 | - } |
|
| 328 | - if ($furls[$objet]) { |
|
| 329 | - return $furls[$objet]($id, $args, $ancre, $public, $connect); |
|
| 330 | - } |
|
| 331 | - // si pas de flag public fourni |
|
| 332 | - // le calculer en fonction de la declaration de statut |
|
| 333 | - if (is_null($public) and !$connect) { |
|
| 334 | - $public = objet_test_si_publie($objet, $id, $connect); |
|
| 335 | - } |
|
| 336 | - if ($public or $connect) { |
|
| 337 | - return generer_objet_url_absolue($id, $objet, $args, $ancre, $connect); |
|
| 338 | - } |
|
| 339 | - $a = id_table_objet($objet) . '=' . intval($id); |
|
| 340 | - if (!function_exists('objet_info')) { |
|
| 341 | - include_spip('inc/filtres'); |
|
| 342 | - } |
|
| 314 | + static $furls = []; |
|
| 315 | + if (!isset($furls[$objet])) { |
|
| 316 | + if ( |
|
| 317 | + function_exists($f = 'generer_' . $objet . '_url_ecrire') |
|
| 318 | + // ou definie par un plugin |
|
| 319 | + or $f = charger_fonction($f, 'urls', true) |
|
| 320 | + // deprecated |
|
| 321 | + or function_exists($f = 'generer_url_ecrire_' . $objet) or $f = charger_fonction($f, 'urls', true) |
|
| 322 | + ) { |
|
| 323 | + $furls[$objet] = $f; |
|
| 324 | + } else { |
|
| 325 | + $furls[$objet] = ''; |
|
| 326 | + } |
|
| 327 | + } |
|
| 328 | + if ($furls[$objet]) { |
|
| 329 | + return $furls[$objet]($id, $args, $ancre, $public, $connect); |
|
| 330 | + } |
|
| 331 | + // si pas de flag public fourni |
|
| 332 | + // le calculer en fonction de la declaration de statut |
|
| 333 | + if (is_null($public) and !$connect) { |
|
| 334 | + $public = objet_test_si_publie($objet, $id, $connect); |
|
| 335 | + } |
|
| 336 | + if ($public or $connect) { |
|
| 337 | + return generer_objet_url_absolue($id, $objet, $args, $ancre, $connect); |
|
| 338 | + } |
|
| 339 | + $a = id_table_objet($objet) . '=' . intval($id); |
|
| 340 | + if (!function_exists('objet_info')) { |
|
| 341 | + include_spip('inc/filtres'); |
|
| 342 | + } |
|
| 343 | 343 | |
| 344 | - return generer_url_ecrire(objet_info($objet, 'url_voir'), $a . ($args ? "&$args" : '')) . ($ancre ? "#$ancre" : ''); |
|
| 344 | + return generer_url_ecrire(objet_info($objet, 'url_voir'), $a . ($args ? "&$args" : '')) . ($ancre ? "#$ancre" : ''); |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | /** |
@@ -349,5 +349,5 @@ discard block |
||
| 349 | 349 | * @see generer_objet_url_ecrire |
| 350 | 350 | */ |
| 351 | 351 | function generer_url_ecrire_objet($objet, $id, $args = '', $ancre = '', $public = null, string $connect = '') { |
| 352 | - return generer_objet_url_ecrire($objet, $id, $args, $ancre, $public, $connect); |
|
| 352 | + return generer_objet_url_ecrire($objet, $id, $args, $ancre, $public, $connect); |
|
| 353 | 353 | } |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | ) { |
| 204 | 204 | $r = nettoyer_url_page($url, $contexte); |
| 205 | 205 | if ($r) { |
| 206 | - [$contexte, $type, , , $suite] = $r; |
|
| 206 | + [$contexte, $type,,, $suite] = $r; |
|
| 207 | 207 | $_id = id_table_objet($type); |
| 208 | 208 | $id_objet = $contexte[$_id]; |
| 209 | 209 | $url_propre = generer_objet_url($id_objet, $type); |
@@ -274,9 +274,9 @@ discard block |
||
| 274 | 274 | */ |
| 275 | 275 | function nettoyer_url_page($url, $contexte = []) { |
| 276 | 276 | $url_objets = urls_liste_objets(); |
| 277 | - $raccourci_url_page_html = ',^(?:[^?]*/)?(' . $url_objets . ')([0-9]+)(?:\.html)?([?&].*)?$,'; |
|
| 278 | - $raccourci_url_page_id = ',^(?:[^?]*/)?(' . $url_objets . ')\.php3?[?]id_\1=([0-9]+)([?&].*)?$,'; |
|
| 279 | - $raccourci_url_page_spip = ',^(?:[^?]*/)?(?:spip[.]php)?[?](' . $url_objets . ')([0-9]+)=?(&.*)?$,'; |
|
| 277 | + $raccourci_url_page_html = ',^(?:[^?]*/)?('.$url_objets.')([0-9]+)(?:\.html)?([?&].*)?$,'; |
|
| 278 | + $raccourci_url_page_id = ',^(?:[^?]*/)?('.$url_objets.')\.php3?[?]id_\1=([0-9]+)([?&].*)?$,'; |
|
| 279 | + $raccourci_url_page_spip = ',^(?:[^?]*/)?(?:spip[.]php)?[?]('.$url_objets.')([0-9]+)=?(&.*)?$,'; |
|
| 280 | 280 | |
| 281 | 281 | if ( |
| 282 | 282 | preg_match($raccourci_url_page_html, $url, $regs) |
@@ -314,11 +314,11 @@ discard block |
||
| 314 | 314 | static $furls = []; |
| 315 | 315 | if (!isset($furls[$objet])) { |
| 316 | 316 | if ( |
| 317 | - function_exists($f = 'generer_' . $objet . '_url_ecrire') |
|
| 317 | + function_exists($f = 'generer_'.$objet.'_url_ecrire') |
|
| 318 | 318 | // ou definie par un plugin |
| 319 | 319 | or $f = charger_fonction($f, 'urls', true) |
| 320 | 320 | // deprecated |
| 321 | - or function_exists($f = 'generer_url_ecrire_' . $objet) or $f = charger_fonction($f, 'urls', true) |
|
| 321 | + or function_exists($f = 'generer_url_ecrire_'.$objet) or $f = charger_fonction($f, 'urls', true) |
|
| 322 | 322 | ) { |
| 323 | 323 | $furls[$objet] = $f; |
| 324 | 324 | } else { |
@@ -336,12 +336,12 @@ discard block |
||
| 336 | 336 | if ($public or $connect) { |
| 337 | 337 | return generer_objet_url_absolue($id, $objet, $args, $ancre, $connect); |
| 338 | 338 | } |
| 339 | - $a = id_table_objet($objet) . '=' . intval($id); |
|
| 339 | + $a = id_table_objet($objet).'='.intval($id); |
|
| 340 | 340 | if (!function_exists('objet_info')) { |
| 341 | 341 | include_spip('inc/filtres'); |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | - return generer_url_ecrire(objet_info($objet, 'url_voir'), $a . ($args ? "&$args" : '')) . ($ancre ? "#$ancre" : ''); |
|
| 344 | + return generer_url_ecrire(objet_info($objet, 'url_voir'), $a.($args ? "&$args" : '')).($ancre ? "#$ancre" : ''); |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | /** |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | **/ |
| 27 | 27 | |
| 28 | 28 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 29 | - return; |
|
| 29 | + return; |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | /** |
@@ -48,16 +48,16 @@ discard block |
||
| 48 | 48 | * Code PHP si cet argument est présent, sinon null |
| 49 | 49 | **/ |
| 50 | 50 | function interprete_argument_balise(int $n, Champ $p): ?string { |
| 51 | - if (($p->param) && (!$p->param[0][0]) && ((is_countable($p->param[0]) ? count($p->param[0]) : 0) > $n)) { |
|
| 52 | - return calculer_liste( |
|
| 53 | - $p->param[0][$n], |
|
| 54 | - $p->descr, |
|
| 55 | - $p->boucles, |
|
| 56 | - $p->id_boucle |
|
| 57 | - ); |
|
| 58 | - } else { |
|
| 59 | - return null; |
|
| 60 | - } |
|
| 51 | + if (($p->param) && (!$p->param[0][0]) && ((is_countable($p->param[0]) ? count($p->param[0]) : 0) > $n)) { |
|
| 52 | + return calculer_liste( |
|
| 53 | + $p->param[0][$n], |
|
| 54 | + $p->descr, |
|
| 55 | + $p->boucles, |
|
| 56 | + $p->id_boucle |
|
| 57 | + ); |
|
| 58 | + } else { |
|
| 59 | + return null; |
|
| 60 | + } |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | |
@@ -77,10 +77,10 @@ discard block |
||
| 77 | 77 | * Pile complétée par le code à générer |
| 78 | 78 | **/ |
| 79 | 79 | function balise_NOM_SITE_SPIP_dist($p) { |
| 80 | - $p->code = "\$GLOBALS['meta']['nom_site']"; |
|
| 80 | + $p->code = "\$GLOBALS['meta']['nom_site']"; |
|
| 81 | 81 | |
| 82 | - #$p->interdire_scripts = true; |
|
| 83 | - return $p; |
|
| 82 | + #$p->interdire_scripts = true; |
|
| 83 | + return $p; |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /** |
@@ -96,10 +96,10 @@ discard block |
||
| 96 | 96 | * Pile complétée par le code à générer |
| 97 | 97 | **/ |
| 98 | 98 | function balise_EMAIL_WEBMASTER_dist($p) { |
| 99 | - $p->code = "\$GLOBALS['meta']['email_webmaster']"; |
|
| 99 | + $p->code = "\$GLOBALS['meta']['email_webmaster']"; |
|
| 100 | 100 | |
| 101 | - #$p->interdire_scripts = true; |
|
| 102 | - return $p; |
|
| 101 | + #$p->interdire_scripts = true; |
|
| 102 | + return $p; |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
@@ -115,10 +115,10 @@ discard block |
||
| 115 | 115 | * Pile complétée par le code à générer |
| 116 | 116 | **/ |
| 117 | 117 | function balise_DESCRIPTIF_SITE_SPIP_dist($p) { |
| 118 | - $p->code = "\$GLOBALS['meta']['descriptif_site']"; |
|
| 118 | + $p->code = "\$GLOBALS['meta']['descriptif_site']"; |
|
| 119 | 119 | |
| 120 | - #$p->interdire_scripts = true; |
|
| 121 | - return $p; |
|
| 120 | + #$p->interdire_scripts = true; |
|
| 121 | + return $p; |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | |
@@ -139,10 +139,10 @@ discard block |
||
| 139 | 139 | * Pile complétée par le code à générer |
| 140 | 140 | **/ |
| 141 | 141 | function balise_CHARSET_dist($p) { |
| 142 | - $p->code = "\$GLOBALS['meta']['charset']"; |
|
| 142 | + $p->code = "\$GLOBALS['meta']['charset']"; |
|
| 143 | 143 | |
| 144 | - #$p->interdire_scripts = true; |
|
| 145 | - return $p; |
|
| 144 | + #$p->interdire_scripts = true; |
|
| 145 | + return $p; |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /** |
@@ -167,11 +167,11 @@ discard block |
||
| 167 | 167 | * Pile complétée par le code à générer |
| 168 | 168 | **/ |
| 169 | 169 | function balise_LANG_LEFT_dist($p) { |
| 170 | - $_lang = champ_sql('lang', $p); |
|
| 171 | - $p->code = "lang_dir($_lang, 'left','right')"; |
|
| 172 | - $p->interdire_scripts = false; |
|
| 170 | + $_lang = champ_sql('lang', $p); |
|
| 171 | + $p->code = "lang_dir($_lang, 'left','right')"; |
|
| 172 | + $p->interdire_scripts = false; |
|
| 173 | 173 | |
| 174 | - return $p; |
|
| 174 | + return $p; |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | /** |
@@ -191,11 +191,11 @@ discard block |
||
| 191 | 191 | * Pile complétée par le code à générer |
| 192 | 192 | **/ |
| 193 | 193 | function balise_LANG_RIGHT_dist($p) { |
| 194 | - $_lang = champ_sql('lang', $p); |
|
| 195 | - $p->code = "lang_dir($_lang, 'right','left')"; |
|
| 196 | - $p->interdire_scripts = false; |
|
| 194 | + $_lang = champ_sql('lang', $p); |
|
| 195 | + $p->code = "lang_dir($_lang, 'right','left')"; |
|
| 196 | + $p->interdire_scripts = false; |
|
| 197 | 197 | |
| 198 | - return $p; |
|
| 198 | + return $p; |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | /** |
@@ -220,11 +220,11 @@ discard block |
||
| 220 | 220 | * Pile complétée par le code à générer |
| 221 | 221 | **/ |
| 222 | 222 | function balise_LANG_DIR_dist($p) { |
| 223 | - $_lang = champ_sql('lang', $p); |
|
| 224 | - $p->code = "lang_dir($_lang, 'ltr','rtl')"; |
|
| 225 | - $p->interdire_scripts = false; |
|
| 223 | + $_lang = champ_sql('lang', $p); |
|
| 224 | + $p->code = "lang_dir($_lang, 'ltr','rtl')"; |
|
| 225 | + $p->interdire_scripts = false; |
|
| 226 | 226 | |
| 227 | - return $p; |
|
| 227 | + return $p; |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | |
@@ -241,10 +241,10 @@ discard block |
||
| 241 | 241 | * Pile complétée par le code à générer |
| 242 | 242 | **/ |
| 243 | 243 | function balise_PUCE_dist($p) { |
| 244 | - $p->code = 'definir_puce()'; |
|
| 245 | - $p->interdire_scripts = false; |
|
| 244 | + $p->code = 'definir_puce()'; |
|
| 245 | + $p->interdire_scripts = false; |
|
| 246 | 246 | |
| 247 | - return $p; |
|
| 247 | + return $p; |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | |
@@ -268,9 +268,9 @@ discard block |
||
| 268 | 268 | * Pile completée du code PHP d'exécution de la balise |
| 269 | 269 | */ |
| 270 | 270 | function balise_DATE_dist($p) { |
| 271 | - $p->code = champ_sql('date', $p); |
|
| 271 | + $p->code = champ_sql('date', $p); |
|
| 272 | 272 | |
| 273 | - return $p; |
|
| 273 | + return $p; |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | |
@@ -290,10 +290,10 @@ discard block |
||
| 290 | 290 | * Pile completée du code PHP d'exécution de la balise |
| 291 | 291 | */ |
| 292 | 292 | function balise_DATE_REDAC_dist($p) { |
| 293 | - $p->code = champ_sql('date_redac', $p); |
|
| 294 | - $p->interdire_scripts = false; |
|
| 293 | + $p->code = champ_sql('date_redac', $p); |
|
| 294 | + $p->interdire_scripts = false; |
|
| 295 | 295 | |
| 296 | - return $p; |
|
| 296 | + return $p; |
|
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | /** |
@@ -312,10 +312,10 @@ discard block |
||
| 312 | 312 | * Pile completée du code PHP d'exécution de la balise |
| 313 | 313 | */ |
| 314 | 314 | function balise_DATE_MODIF_dist($p) { |
| 315 | - $p->code = champ_sql('date_modif', $p); |
|
| 316 | - $p->interdire_scripts = false; |
|
| 315 | + $p->code = champ_sql('date_modif', $p); |
|
| 316 | + $p->interdire_scripts = false; |
|
| 317 | 317 | |
| 318 | - return $p; |
|
| 318 | + return $p; |
|
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 | /** |
@@ -333,13 +333,13 @@ discard block |
||
| 333 | 333 | * Pile completée du code PHP d'exécution de la balise |
| 334 | 334 | */ |
| 335 | 335 | function balise_DATE_NOUVEAUTES_dist($p) { |
| 336 | - $p->code = "((\$GLOBALS['meta']['quoi_de_neuf'] == 'oui' |
|
| 336 | + $p->code = "((\$GLOBALS['meta']['quoi_de_neuf'] == 'oui' |
|
| 337 | 337 | AND isset(\$GLOBALS['meta']['dernier_envoi_neuf'])) ? |
| 338 | 338 | \$GLOBALS['meta']['dernier_envoi_neuf'] : |
| 339 | 339 | \"'0000-00-00'\")"; |
| 340 | - $p->interdire_scripts = false; |
|
| 340 | + $p->interdire_scripts = false; |
|
| 341 | 341 | |
| 342 | - return $p; |
|
| 342 | + return $p; |
|
| 343 | 343 | } |
| 344 | 344 | |
| 345 | 345 | |
@@ -357,11 +357,11 @@ discard block |
||
| 357 | 357 | * Pile completée du code PHP d'exécution de la balise |
| 358 | 358 | */ |
| 359 | 359 | function balise_DOSSIER_SQUELETTE_dist($p) { |
| 360 | - $code = substr(addslashes(dirname($p->descr['sourcefile'])), strlen(_DIR_RACINE)); |
|
| 361 | - $p->code = "_DIR_RACINE . '$code'" . |
|
| 362 | - $p->interdire_scripts = false; |
|
| 360 | + $code = substr(addslashes(dirname($p->descr['sourcefile'])), strlen(_DIR_RACINE)); |
|
| 361 | + $p->code = "_DIR_RACINE . '$code'" . |
|
| 362 | + $p->interdire_scripts = false; |
|
| 363 | 363 | |
| 364 | - return $p; |
|
| 364 | + return $p; |
|
| 365 | 365 | } |
| 366 | 366 | |
| 367 | 367 | /** |
@@ -376,11 +376,11 @@ discard block |
||
| 376 | 376 | * Pile completée du code PHP d'exécution de la balise |
| 377 | 377 | */ |
| 378 | 378 | function balise_SQUELETTE_dist($p) { |
| 379 | - $code = addslashes($p->descr['sourcefile']); |
|
| 380 | - $p->code = "'$code'" . |
|
| 381 | - $p->interdire_scripts = false; |
|
| 379 | + $code = addslashes($p->descr['sourcefile']); |
|
| 380 | + $p->code = "'$code'" . |
|
| 381 | + $p->interdire_scripts = false; |
|
| 382 | 382 | |
| 383 | - return $p; |
|
| 383 | + return $p; |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | /** |
@@ -399,10 +399,10 @@ discard block |
||
| 399 | 399 | * Pile completée du code PHP d'exécution de la balise |
| 400 | 400 | */ |
| 401 | 401 | function balise_SPIP_VERSION_dist($p) { |
| 402 | - $p->code = 'spip_version()'; |
|
| 403 | - $p->interdire_scripts = false; |
|
| 402 | + $p->code = 'spip_version()'; |
|
| 403 | + $p->interdire_scripts = false; |
|
| 404 | 404 | |
| 405 | - return $p; |
|
| 405 | + return $p; |
|
| 406 | 406 | } |
| 407 | 407 | |
| 408 | 408 | |
@@ -428,18 +428,18 @@ discard block |
||
| 428 | 428 | * Pile complétée par le code à générer |
| 429 | 429 | **/ |
| 430 | 430 | function balise_NOM_SITE_dist($p) { |
| 431 | - if (!$p->etoile) { |
|
| 432 | - $p->code = 'supprimer_numero(calculer_url(' . |
|
| 433 | - champ_sql('url_site', $p) . ',' . |
|
| 434 | - champ_sql('nom_site', $p) . |
|
| 435 | - ", 'titre', \$connect, false))"; |
|
| 436 | - } else { |
|
| 437 | - $p->code = champ_sql('nom_site', $p); |
|
| 438 | - } |
|
| 431 | + if (!$p->etoile) { |
|
| 432 | + $p->code = 'supprimer_numero(calculer_url(' . |
|
| 433 | + champ_sql('url_site', $p) . ',' . |
|
| 434 | + champ_sql('nom_site', $p) . |
|
| 435 | + ", 'titre', \$connect, false))"; |
|
| 436 | + } else { |
|
| 437 | + $p->code = champ_sql('nom_site', $p); |
|
| 438 | + } |
|
| 439 | 439 | |
| 440 | - $p->interdire_scripts = true; |
|
| 440 | + $p->interdire_scripts = true; |
|
| 441 | 441 | |
| 442 | - return $p; |
|
| 442 | + return $p; |
|
| 443 | 443 | } |
| 444 | 444 | |
| 445 | 445 | |
@@ -456,11 +456,11 @@ discard block |
||
| 456 | 456 | * Pile complétée par le code à générer |
| 457 | 457 | **/ |
| 458 | 458 | function balise_NOTES_dist($p) { |
| 459 | - // Recuperer les notes |
|
| 460 | - $p->code = 'calculer_notes()'; |
|
| 459 | + // Recuperer les notes |
|
| 460 | + $p->code = 'calculer_notes()'; |
|
| 461 | 461 | |
| 462 | - #$p->interdire_scripts = true; |
|
| 463 | - return $p; |
|
| 462 | + #$p->interdire_scripts = true; |
|
| 463 | + return $p; |
|
| 464 | 464 | } |
| 465 | 465 | |
| 466 | 466 | |
@@ -482,10 +482,10 @@ discard block |
||
| 482 | 482 | * Pile complétée par le code à générer |
| 483 | 483 | **/ |
| 484 | 484 | function balise_RECHERCHE_dist($p) { |
| 485 | - $p->code = 'entites_html(_request("recherche"))'; |
|
| 486 | - $p->interdire_scripts = false; |
|
| 485 | + $p->code = 'entites_html(_request("recherche"))'; |
|
| 486 | + $p->interdire_scripts = false; |
|
| 487 | 487 | |
| 488 | - return $p; |
|
| 488 | + return $p; |
|
| 489 | 489 | } |
| 490 | 490 | |
| 491 | 491 | |
@@ -503,17 +503,17 @@ discard block |
||
| 503 | 503 | * Pile complétée par le code à générer |
| 504 | 504 | **/ |
| 505 | 505 | function balise_COMPTEUR_BOUCLE_dist($p) { |
| 506 | - $b = index_boucle_mere($p); |
|
| 507 | - if ($b === '') { |
|
| 508 | - $msg = ['zbug_champ_hors_boucle', ['champ' => zbug_presenter_champ($p)]]; |
|
| 509 | - erreur_squelette($msg, $p); |
|
| 510 | - } else { |
|
| 511 | - $p->code = "(\$Numrows['$b']['compteur_boucle'] ?? 0)"; |
|
| 512 | - $p->boucles[$b]->cptrows = true; |
|
| 513 | - $p->interdire_scripts = false; |
|
| 506 | + $b = index_boucle_mere($p); |
|
| 507 | + if ($b === '') { |
|
| 508 | + $msg = ['zbug_champ_hors_boucle', ['champ' => zbug_presenter_champ($p)]]; |
|
| 509 | + erreur_squelette($msg, $p); |
|
| 510 | + } else { |
|
| 511 | + $p->code = "(\$Numrows['$b']['compteur_boucle'] ?? 0)"; |
|
| 512 | + $p->boucles[$b]->cptrows = true; |
|
| 513 | + $p->interdire_scripts = false; |
|
| 514 | 514 | |
| 515 | - return $p; |
|
| 516 | - } |
|
| 515 | + return $p; |
|
| 516 | + } |
|
| 517 | 517 | } |
| 518 | 518 | |
| 519 | 519 | /** |
@@ -531,17 +531,17 @@ discard block |
||
| 531 | 531 | * Pile complétée par le code à générer |
| 532 | 532 | **/ |
| 533 | 533 | function balise_TOTAL_BOUCLE_dist($p) { |
| 534 | - $b = index_boucle_mere($p); |
|
| 535 | - if ($b === '') { |
|
| 536 | - $msg = ['zbug_champ_hors_boucle', ['champ' => zbug_presenter_champ($p)]]; |
|
| 537 | - erreur_squelette($msg, $p); |
|
| 538 | - } else { |
|
| 539 | - $p->code = "(\$Numrows['$b']['total'] ?? 0)"; |
|
| 540 | - $p->boucles[$b]->numrows = true; |
|
| 541 | - $p->interdire_scripts = false; |
|
| 542 | - } |
|
| 534 | + $b = index_boucle_mere($p); |
|
| 535 | + if ($b === '') { |
|
| 536 | + $msg = ['zbug_champ_hors_boucle', ['champ' => zbug_presenter_champ($p)]]; |
|
| 537 | + erreur_squelette($msg, $p); |
|
| 538 | + } else { |
|
| 539 | + $p->code = "(\$Numrows['$b']['total'] ?? 0)"; |
|
| 540 | + $p->boucles[$b]->numrows = true; |
|
| 541 | + $p->interdire_scripts = false; |
|
| 542 | + } |
|
| 543 | 543 | |
| 544 | - return $p; |
|
| 544 | + return $p; |
|
| 545 | 545 | } |
| 546 | 546 | |
| 547 | 547 | |
@@ -561,7 +561,7 @@ discard block |
||
| 561 | 561 | * Pile complétée par le code à générer |
| 562 | 562 | **/ |
| 563 | 563 | function balise_POINTS_dist($p) { |
| 564 | - return rindex_pile($p, 'points', 'recherche'); |
|
| 564 | + return rindex_pile($p, 'points', 'recherche'); |
|
| 565 | 565 | } |
| 566 | 566 | |
| 567 | 567 | |
@@ -582,12 +582,12 @@ discard block |
||
| 582 | 582 | * Pile complétée par le code à générer |
| 583 | 583 | **/ |
| 584 | 584 | function balise_POPULARITE_ABSOLUE_dist($p) { |
| 585 | - $p->code = 'ceil(' . |
|
| 586 | - champ_sql('popularite', $p) . |
|
| 587 | - ')'; |
|
| 588 | - $p->interdire_scripts = false; |
|
| 585 | + $p->code = 'ceil(' . |
|
| 586 | + champ_sql('popularite', $p) . |
|
| 587 | + ')'; |
|
| 588 | + $p->interdire_scripts = false; |
|
| 589 | 589 | |
| 590 | - return $p; |
|
| 590 | + return $p; |
|
| 591 | 591 | } |
| 592 | 592 | |
| 593 | 593 | /** |
@@ -607,10 +607,10 @@ discard block |
||
| 607 | 607 | * Pile complétée par le code à générer |
| 608 | 608 | **/ |
| 609 | 609 | function balise_POPULARITE_SITE_dist($p) { |
| 610 | - $p->code = 'ceil($GLOBALS["meta"][\'popularite_total\'])'; |
|
| 611 | - $p->interdire_scripts = false; |
|
| 610 | + $p->code = 'ceil($GLOBALS["meta"][\'popularite_total\'])'; |
|
| 611 | + $p->interdire_scripts = false; |
|
| 612 | 612 | |
| 613 | - return $p; |
|
| 613 | + return $p; |
|
| 614 | 614 | } |
| 615 | 615 | |
| 616 | 616 | /** |
@@ -631,10 +631,10 @@ discard block |
||
| 631 | 631 | * Pile complétée par le code à générer |
| 632 | 632 | **/ |
| 633 | 633 | function balise_POPULARITE_MAX_dist($p) { |
| 634 | - $p->code = 'ceil($GLOBALS["meta"][\'popularite_max\'])'; |
|
| 635 | - $p->interdire_scripts = false; |
|
| 634 | + $p->code = 'ceil($GLOBALS["meta"][\'popularite_max\'])'; |
|
| 635 | + $p->interdire_scripts = false; |
|
| 636 | 636 | |
| 637 | - return $p; |
|
| 637 | + return $p; |
|
| 638 | 638 | } |
| 639 | 639 | |
| 640 | 640 | |
@@ -660,15 +660,15 @@ discard block |
||
| 660 | 660 | * Pile complétée par le code à générer |
| 661 | 661 | **/ |
| 662 | 662 | function balise_VALEUR_dist($p) { |
| 663 | - $b = $p->nom_boucle ?: $p->id_boucle; |
|
| 664 | - $p->code = index_pile($p->id_boucle, 'valeur', $p->boucles, $b); |
|
| 663 | + $b = $p->nom_boucle ?: $p->id_boucle; |
|
| 664 | + $p->code = index_pile($p->id_boucle, 'valeur', $p->boucles, $b); |
|
| 665 | 665 | ; |
| 666 | - if (($v = interprete_argument_balise(1, $p)) !== null) { |
|
| 667 | - $p->code = 'table_valeur(' . $p->code . ', ' . $v . ')'; |
|
| 668 | - } |
|
| 669 | - $p->interdire_scripts = true; |
|
| 666 | + if (($v = interprete_argument_balise(1, $p)) !== null) { |
|
| 667 | + $p->code = 'table_valeur(' . $p->code . ', ' . $v . ')'; |
|
| 668 | + } |
|
| 669 | + $p->interdire_scripts = true; |
|
| 670 | 670 | |
| 671 | - return $p; |
|
| 671 | + return $p; |
|
| 672 | 672 | } |
| 673 | 673 | |
| 674 | 674 | /** |
@@ -697,16 +697,16 @@ discard block |
||
| 697 | 697 | * Pile complétée par le code à générer |
| 698 | 698 | **/ |
| 699 | 699 | function balise_EXPOSE_dist($p) { |
| 700 | - $on = "'on'"; |
|
| 701 | - $off = "''"; |
|
| 702 | - if (($v = interprete_argument_balise(1, $p)) !== null) { |
|
| 703 | - $on = $v; |
|
| 704 | - if (($v = interprete_argument_balise(2, $p)) !== null) { |
|
| 705 | - $off = $v; |
|
| 706 | - } |
|
| 707 | - } |
|
| 700 | + $on = "'on'"; |
|
| 701 | + $off = "''"; |
|
| 702 | + if (($v = interprete_argument_balise(1, $p)) !== null) { |
|
| 703 | + $on = $v; |
|
| 704 | + if (($v = interprete_argument_balise(2, $p)) !== null) { |
|
| 705 | + $off = $v; |
|
| 706 | + } |
|
| 707 | + } |
|
| 708 | 708 | |
| 709 | - return calculer_balise_expose($p, $on, $off); |
|
| 709 | + return calculer_balise_expose($p, $on, $off); |
|
| 710 | 710 | } |
| 711 | 711 | |
| 712 | 712 | /** |
@@ -724,35 +724,35 @@ discard block |
||
| 724 | 724 | * Pile complétée par le code à générer |
| 725 | 725 | **/ |
| 726 | 726 | function calculer_balise_expose($p, $on, $off) { |
| 727 | - $b = index_boucle($p); |
|
| 728 | - if (empty($p->boucles[$b]->primary)) { |
|
| 729 | - $msg = ['zbug_champ_hors_boucle', ['champ' => zbug_presenter_champ($p)]]; |
|
| 730 | - erreur_squelette($msg, $p); |
|
| 731 | - } else { |
|
| 732 | - $key = $p->boucles[$b]->primary; |
|
| 733 | - $type = $p->boucles[$p->id_boucle]->primary; |
|
| 734 | - $desc = $p->boucles[$b]->show; |
|
| 735 | - $connect = sql_quote($p->boucles[$b]->sql_serveur); |
|
| 727 | + $b = index_boucle($p); |
|
| 728 | + if (empty($p->boucles[$b]->primary)) { |
|
| 729 | + $msg = ['zbug_champ_hors_boucle', ['champ' => zbug_presenter_champ($p)]]; |
|
| 730 | + erreur_squelette($msg, $p); |
|
| 731 | + } else { |
|
| 732 | + $key = $p->boucles[$b]->primary; |
|
| 733 | + $type = $p->boucles[$p->id_boucle]->primary; |
|
| 734 | + $desc = $p->boucles[$b]->show; |
|
| 735 | + $connect = sql_quote($p->boucles[$b]->sql_serveur); |
|
| 736 | 736 | |
| 737 | - // Ne pas utiliser champ_sql, on jongle avec le nom boucle explicite |
|
| 738 | - $c = index_pile($p->id_boucle, $type, $p->boucles); |
|
| 737 | + // Ne pas utiliser champ_sql, on jongle avec le nom boucle explicite |
|
| 738 | + $c = index_pile($p->id_boucle, $type, $p->boucles); |
|
| 739 | 739 | |
| 740 | - if (isset($desc['field']['id_parent'])) { |
|
| 741 | - $parent = 0; // pour if (!$parent) dans calculer_expose |
|
| 742 | - } elseif (isset($desc['field']['id_rubrique'])) { |
|
| 743 | - $parent = index_pile($p->id_boucle, 'id_rubrique', $p->boucles, $b); |
|
| 744 | - } elseif (isset($desc['field']['id_groupe'])) { |
|
| 745 | - $parent = index_pile($p->id_boucle, 'id_groupe', $p->boucles, $b); |
|
| 746 | - } else { |
|
| 747 | - $parent = "''"; |
|
| 748 | - } |
|
| 740 | + if (isset($desc['field']['id_parent'])) { |
|
| 741 | + $parent = 0; // pour if (!$parent) dans calculer_expose |
|
| 742 | + } elseif (isset($desc['field']['id_rubrique'])) { |
|
| 743 | + $parent = index_pile($p->id_boucle, 'id_rubrique', $p->boucles, $b); |
|
| 744 | + } elseif (isset($desc['field']['id_groupe'])) { |
|
| 745 | + $parent = index_pile($p->id_boucle, 'id_groupe', $p->boucles, $b); |
|
| 746 | + } else { |
|
| 747 | + $parent = "''"; |
|
| 748 | + } |
|
| 749 | 749 | |
| 750 | - $p->code = "(calcul_exposer($c, '$type', \$Pile[0], $parent, '$key', $connect) ? $on : $off)"; |
|
| 751 | - } |
|
| 750 | + $p->code = "(calcul_exposer($c, '$type', \$Pile[0], $parent, '$key', $connect) ? $on : $off)"; |
|
| 751 | + } |
|
| 752 | 752 | |
| 753 | - $p->interdire_scripts = false; |
|
| 753 | + $p->interdire_scripts = false; |
|
| 754 | 754 | |
| 755 | - return $p; |
|
| 755 | + return $p; |
|
| 756 | 756 | } |
| 757 | 757 | |
| 758 | 758 | |
@@ -793,46 +793,46 @@ discard block |
||
| 793 | 793 | **/ |
| 794 | 794 | function balise_INTRODUCTION_dist($p) { |
| 795 | 795 | |
| 796 | - $type_objet = $p->type_requete; |
|
| 797 | - $cle_objet = id_table_objet($type_objet); |
|
| 798 | - $_id_objet = champ_sql($cle_objet, $p); |
|
| 799 | - |
|
| 800 | - // Récupérer les valeurs sql nécessaires : descriptif, texte et chapo |
|
| 801 | - // ainsi que le longueur d'introduction donnée dans la description de l'objet. |
|
| 802 | - $_introduction_longueur = 'null'; |
|
| 803 | - $_ligne = 'array('; |
|
| 804 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 805 | - if ($desc = $trouver_table(table_objet_sql($type_objet))) { |
|
| 806 | - if (isset($desc['field']['descriptif'])) { |
|
| 807 | - $_ligne .= "'descriptif' => " . champ_sql('descriptif', $p) . ','; |
|
| 808 | - } |
|
| 809 | - if (isset($desc['field']['texte'])) { |
|
| 810 | - $_ligne .= "'texte' => " . champ_sql('texte', $p) . ','; |
|
| 811 | - } |
|
| 812 | - if (isset($desc['field']['chapo'])) { |
|
| 813 | - $_ligne .= "'chapo' => " . champ_sql('chapo', $p) . ','; |
|
| 814 | - } |
|
| 815 | - if (isset($desc['introduction_longueur'])) { |
|
| 816 | - $_introduction_longueur = "'" . $desc['introduction_longueur'] . "'"; |
|
| 817 | - } |
|
| 818 | - } |
|
| 819 | - $_ligne .= ')'; |
|
| 820 | - |
|
| 821 | - // Récupérer la longueur et la suite passés en paramètres |
|
| 822 | - $_longueur_ou_suite = 'null'; |
|
| 823 | - if (($v1 = interprete_argument_balise(1, $p)) !== null) { |
|
| 824 | - $_longueur_ou_suite = $v1; |
|
| 825 | - } |
|
| 826 | - $_suite = 'null'; |
|
| 827 | - if (($v2 = interprete_argument_balise(2, $p)) !== null) { |
|
| 828 | - $_suite = $v2; |
|
| 829 | - } |
|
| 830 | - |
|
| 831 | - $p->code = "generer_objet_introduction($_id_objet, '$type_objet', $_ligne, $_introduction_longueur, $_longueur_ou_suite, $_suite, \$connect)"; |
|
| 832 | - |
|
| 833 | - #$p->interdire_scripts = true; |
|
| 834 | - $p->etoile = '*'; // propre est deja fait dans le calcul de l'intro |
|
| 835 | - return $p; |
|
| 796 | + $type_objet = $p->type_requete; |
|
| 797 | + $cle_objet = id_table_objet($type_objet); |
|
| 798 | + $_id_objet = champ_sql($cle_objet, $p); |
|
| 799 | + |
|
| 800 | + // Récupérer les valeurs sql nécessaires : descriptif, texte et chapo |
|
| 801 | + // ainsi que le longueur d'introduction donnée dans la description de l'objet. |
|
| 802 | + $_introduction_longueur = 'null'; |
|
| 803 | + $_ligne = 'array('; |
|
| 804 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 805 | + if ($desc = $trouver_table(table_objet_sql($type_objet))) { |
|
| 806 | + if (isset($desc['field']['descriptif'])) { |
|
| 807 | + $_ligne .= "'descriptif' => " . champ_sql('descriptif', $p) . ','; |
|
| 808 | + } |
|
| 809 | + if (isset($desc['field']['texte'])) { |
|
| 810 | + $_ligne .= "'texte' => " . champ_sql('texte', $p) . ','; |
|
| 811 | + } |
|
| 812 | + if (isset($desc['field']['chapo'])) { |
|
| 813 | + $_ligne .= "'chapo' => " . champ_sql('chapo', $p) . ','; |
|
| 814 | + } |
|
| 815 | + if (isset($desc['introduction_longueur'])) { |
|
| 816 | + $_introduction_longueur = "'" . $desc['introduction_longueur'] . "'"; |
|
| 817 | + } |
|
| 818 | + } |
|
| 819 | + $_ligne .= ')'; |
|
| 820 | + |
|
| 821 | + // Récupérer la longueur et la suite passés en paramètres |
|
| 822 | + $_longueur_ou_suite = 'null'; |
|
| 823 | + if (($v1 = interprete_argument_balise(1, $p)) !== null) { |
|
| 824 | + $_longueur_ou_suite = $v1; |
|
| 825 | + } |
|
| 826 | + $_suite = 'null'; |
|
| 827 | + if (($v2 = interprete_argument_balise(2, $p)) !== null) { |
|
| 828 | + $_suite = $v2; |
|
| 829 | + } |
|
| 830 | + |
|
| 831 | + $p->code = "generer_objet_introduction($_id_objet, '$type_objet', $_ligne, $_introduction_longueur, $_longueur_ou_suite, $_suite, \$connect)"; |
|
| 832 | + |
|
| 833 | + #$p->interdire_scripts = true; |
|
| 834 | + $p->etoile = '*'; // propre est deja fait dans le calcul de l'intro |
|
| 835 | + return $p; |
|
| 836 | 836 | } |
| 837 | 837 | |
| 838 | 838 | |
@@ -852,15 +852,15 @@ discard block |
||
| 852 | 852 | * Pile complétée par le code à générer |
| 853 | 853 | **/ |
| 854 | 854 | function balise_LANG_dist($p) { |
| 855 | - $_lang = champ_sql('lang', $p); |
|
| 856 | - if (!$p->etoile) { |
|
| 857 | - $p->code = "spip_htmlentities($_lang ? $_lang : \$GLOBALS['spip_lang'])"; |
|
| 858 | - } else { |
|
| 859 | - $p->code = "spip_htmlentities($_lang)"; |
|
| 860 | - } |
|
| 861 | - $p->interdire_scripts = false; |
|
| 855 | + $_lang = champ_sql('lang', $p); |
|
| 856 | + if (!$p->etoile) { |
|
| 857 | + $p->code = "spip_htmlentities($_lang ? $_lang : \$GLOBALS['spip_lang'])"; |
|
| 858 | + } else { |
|
| 859 | + $p->code = "spip_htmlentities($_lang)"; |
|
| 860 | + } |
|
| 861 | + $p->interdire_scripts = false; |
|
| 862 | 862 | |
| 863 | - return $p; |
|
| 863 | + return $p; |
|
| 864 | 864 | } |
| 865 | 865 | |
| 866 | 866 | /** |
@@ -882,48 +882,48 @@ discard block |
||
| 882 | 882 | * Pile complétée par le code à générer |
| 883 | 883 | */ |
| 884 | 884 | function balise_LESAUTEURS_dist($p) { |
| 885 | - // Cherche le champ 'lesauteurs' dans la pile |
|
| 886 | - $_lesauteurs = champ_sql('lesauteurs', $p, false); |
|
| 887 | - |
|
| 888 | - // Si le champ n'existe pas (cas de spip_articles), on applique |
|
| 889 | - // le modele lesauteurs.html en passant id_article dans le contexte; |
|
| 890 | - // dans le cas contraire on prend le champ 'lesauteurs' |
|
| 891 | - // (cf extension sites/) |
|
| 892 | - if ( |
|
| 893 | - $_lesauteurs |
|
| 894 | - and $_lesauteurs != '@$Pile[0][\'lesauteurs\']' |
|
| 895 | - ) { |
|
| 896 | - $p->code = "safehtml($_lesauteurs)"; |
|
| 897 | - // $p->interdire_scripts = true; |
|
| 898 | - } else { |
|
| 899 | - if (!$p->id_boucle) { |
|
| 900 | - $connect = ''; |
|
| 901 | - $objet = 'article'; |
|
| 902 | - $id_table_objet = 'id_article'; |
|
| 903 | - } else { |
|
| 904 | - $b = $p->nom_boucle ?: $p->id_boucle; |
|
| 905 | - $connect = $p->boucles[$b]->sql_serveur; |
|
| 906 | - $type_boucle = $p->boucles[$b]->type_requete; |
|
| 907 | - $objet = objet_type($type_boucle); |
|
| 908 | - $id_table_objet = id_table_objet($type_boucle); |
|
| 909 | - } |
|
| 910 | - $c = memoriser_contexte_compil($p); |
|
| 911 | - |
|
| 912 | - $p->code = sprintf( |
|
| 913 | - CODE_RECUPERER_FOND, |
|
| 914 | - "'modeles/lesauteurs'", |
|
| 915 | - "array('objet'=>'" . $objet . |
|
| 916 | - "','id_objet' => " . champ_sql($id_table_objet, $p) . |
|
| 917 | - ",'$id_table_objet' => " . champ_sql($id_table_objet, $p) . |
|
| 918 | - ($objet == 'article' ? '' : ",'id_article' => " . champ_sql('id_article', $p)) . |
|
| 919 | - ')', |
|
| 920 | - "'trim'=>true, 'compil'=>array($c)", |
|
| 921 | - _q($connect) |
|
| 922 | - ); |
|
| 923 | - $p->interdire_scripts = false; // securite apposee par recuperer_fond() |
|
| 924 | - } |
|
| 925 | - |
|
| 926 | - return $p; |
|
| 885 | + // Cherche le champ 'lesauteurs' dans la pile |
|
| 886 | + $_lesauteurs = champ_sql('lesauteurs', $p, false); |
|
| 887 | + |
|
| 888 | + // Si le champ n'existe pas (cas de spip_articles), on applique |
|
| 889 | + // le modele lesauteurs.html en passant id_article dans le contexte; |
|
| 890 | + // dans le cas contraire on prend le champ 'lesauteurs' |
|
| 891 | + // (cf extension sites/) |
|
| 892 | + if ( |
|
| 893 | + $_lesauteurs |
|
| 894 | + and $_lesauteurs != '@$Pile[0][\'lesauteurs\']' |
|
| 895 | + ) { |
|
| 896 | + $p->code = "safehtml($_lesauteurs)"; |
|
| 897 | + // $p->interdire_scripts = true; |
|
| 898 | + } else { |
|
| 899 | + if (!$p->id_boucle) { |
|
| 900 | + $connect = ''; |
|
| 901 | + $objet = 'article'; |
|
| 902 | + $id_table_objet = 'id_article'; |
|
| 903 | + } else { |
|
| 904 | + $b = $p->nom_boucle ?: $p->id_boucle; |
|
| 905 | + $connect = $p->boucles[$b]->sql_serveur; |
|
| 906 | + $type_boucle = $p->boucles[$b]->type_requete; |
|
| 907 | + $objet = objet_type($type_boucle); |
|
| 908 | + $id_table_objet = id_table_objet($type_boucle); |
|
| 909 | + } |
|
| 910 | + $c = memoriser_contexte_compil($p); |
|
| 911 | + |
|
| 912 | + $p->code = sprintf( |
|
| 913 | + CODE_RECUPERER_FOND, |
|
| 914 | + "'modeles/lesauteurs'", |
|
| 915 | + "array('objet'=>'" . $objet . |
|
| 916 | + "','id_objet' => " . champ_sql($id_table_objet, $p) . |
|
| 917 | + ",'$id_table_objet' => " . champ_sql($id_table_objet, $p) . |
|
| 918 | + ($objet == 'article' ? '' : ",'id_article' => " . champ_sql('id_article', $p)) . |
|
| 919 | + ')', |
|
| 920 | + "'trim'=>true, 'compil'=>array($c)", |
|
| 921 | + _q($connect) |
|
| 922 | + ); |
|
| 923 | + $p->interdire_scripts = false; // securite apposee par recuperer_fond() |
|
| 924 | + } |
|
| 925 | + |
|
| 926 | + return $p; |
|
| 927 | 927 | } |
| 928 | 928 | |
| 929 | 929 | |
@@ -950,76 +950,76 @@ discard block |
||
| 950 | 950 | * Pile complétée par le code à générer |
| 951 | 951 | */ |
| 952 | 952 | function balise_RANG_dist($p) { |
| 953 | - $b = index_boucle($p); |
|
| 954 | - if ($b === '') { |
|
| 955 | - $msg = [ |
|
| 956 | - 'zbug_champ_hors_boucle', |
|
| 957 | - ['champ' => '#RANG'] |
|
| 958 | - ]; |
|
| 959 | - erreur_squelette($msg, $p); |
|
| 960 | - } else { |
|
| 961 | - // chercher d'abord un champ sql rang (mais pas dans le env : defaut '' si on trouve pas de champ sql) |
|
| 962 | - // dans la boucle immediatement englobante uniquement |
|
| 963 | - // sinon on compose le champ calcule |
|
| 964 | - $_rang = champ_sql('rang', $p, '', false); |
|
| 965 | - |
|
| 966 | - // si pas trouve de champ sql rang : |
|
| 967 | - if (!$_rang or $_rang == "''") { |
|
| 968 | - $boucle = &$p->boucles[$b]; |
|
| 969 | - |
|
| 970 | - // on gere le cas ou #RANG est une extraction du numero dans le titre |
|
| 971 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 972 | - $desc = $trouver_table($boucle->id_table); |
|
| 973 | - $_titre = ''; # où extraire le numero ? |
|
| 974 | - |
|
| 975 | - if (isset($desc['titre'])) { |
|
| 976 | - $t = $desc['titre']; |
|
| 977 | - if ( |
|
| 978 | - // Soit on trouve avec la déclaration de la lang AVANT |
|
| 979 | - preg_match(';(?:lang\s*,)\s*(.*?titre)\s*(,|$);', $t, $m) |
|
| 980 | - // Soit on prend depuis le début |
|
| 981 | - or preg_match(';^(.*?titre)\s*(,|$);', $t, $m) |
|
| 982 | - ) { |
|
| 983 | - $m = preg_replace(',as\s+titre$,i', '', $m[1]); |
|
| 984 | - $m = trim($m); |
|
| 985 | - if ($m != "''") { |
|
| 986 | - if (!preg_match(',\W,', $m)) { |
|
| 987 | - $m = $boucle->id_table . ".$m"; |
|
| 988 | - } |
|
| 989 | - |
|
| 990 | - $m .= ' AS titre_rang'; |
|
| 991 | - |
|
| 992 | - $boucle->select[] = $m; |
|
| 993 | - $_titre = '$Pile[$SP][\'titre_rang\']'; |
|
| 994 | - } |
|
| 995 | - } |
|
| 996 | - } |
|
| 997 | - |
|
| 998 | - // si on n'a rien trouvé, on utilise le champ titre classique |
|
| 999 | - if (!$_titre) { |
|
| 1000 | - $_titre = champ_sql('titre', $p); |
|
| 1001 | - } |
|
| 1002 | - |
|
| 1003 | - // et on recupere aussi les infos de liaison si on est en train d'editer les liens justement |
|
| 1004 | - // cas des formulaires xxx_lies utilises par #FORMULAIRE_EDITER_LIENS |
|
| 1005 | - $type_boucle = $boucle->type_requete; |
|
| 1006 | - $objet = objet_type($type_boucle); |
|
| 1007 | - $id_table_objet = id_table_objet($type_boucle); |
|
| 1008 | - $_primary = champ_sql($id_table_objet, $p, '', false); |
|
| 1009 | - $_env = '$Pile[0]'; |
|
| 1010 | - |
|
| 1011 | - if (!$_titre) {$_titre = "''"; |
|
| 1012 | - } |
|
| 1013 | - if (!$_primary) {$_primary = "''"; |
|
| 1014 | - } |
|
| 1015 | - $_rang = "calculer_rang_smart($_titre, '$objet', $_primary, $_env)"; |
|
| 1016 | - } |
|
| 1017 | - |
|
| 1018 | - $p->code = $_rang; |
|
| 1019 | - $p->interdire_scripts = false; |
|
| 1020 | - } |
|
| 1021 | - |
|
| 1022 | - return $p; |
|
| 953 | + $b = index_boucle($p); |
|
| 954 | + if ($b === '') { |
|
| 955 | + $msg = [ |
|
| 956 | + 'zbug_champ_hors_boucle', |
|
| 957 | + ['champ' => '#RANG'] |
|
| 958 | + ]; |
|
| 959 | + erreur_squelette($msg, $p); |
|
| 960 | + } else { |
|
| 961 | + // chercher d'abord un champ sql rang (mais pas dans le env : defaut '' si on trouve pas de champ sql) |
|
| 962 | + // dans la boucle immediatement englobante uniquement |
|
| 963 | + // sinon on compose le champ calcule |
|
| 964 | + $_rang = champ_sql('rang', $p, '', false); |
|
| 965 | + |
|
| 966 | + // si pas trouve de champ sql rang : |
|
| 967 | + if (!$_rang or $_rang == "''") { |
|
| 968 | + $boucle = &$p->boucles[$b]; |
|
| 969 | + |
|
| 970 | + // on gere le cas ou #RANG est une extraction du numero dans le titre |
|
| 971 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 972 | + $desc = $trouver_table($boucle->id_table); |
|
| 973 | + $_titre = ''; # où extraire le numero ? |
|
| 974 | + |
|
| 975 | + if (isset($desc['titre'])) { |
|
| 976 | + $t = $desc['titre']; |
|
| 977 | + if ( |
|
| 978 | + // Soit on trouve avec la déclaration de la lang AVANT |
|
| 979 | + preg_match(';(?:lang\s*,)\s*(.*?titre)\s*(,|$);', $t, $m) |
|
| 980 | + // Soit on prend depuis le début |
|
| 981 | + or preg_match(';^(.*?titre)\s*(,|$);', $t, $m) |
|
| 982 | + ) { |
|
| 983 | + $m = preg_replace(',as\s+titre$,i', '', $m[1]); |
|
| 984 | + $m = trim($m); |
|
| 985 | + if ($m != "''") { |
|
| 986 | + if (!preg_match(',\W,', $m)) { |
|
| 987 | + $m = $boucle->id_table . ".$m"; |
|
| 988 | + } |
|
| 989 | + |
|
| 990 | + $m .= ' AS titre_rang'; |
|
| 991 | + |
|
| 992 | + $boucle->select[] = $m; |
|
| 993 | + $_titre = '$Pile[$SP][\'titre_rang\']'; |
|
| 994 | + } |
|
| 995 | + } |
|
| 996 | + } |
|
| 997 | + |
|
| 998 | + // si on n'a rien trouvé, on utilise le champ titre classique |
|
| 999 | + if (!$_titre) { |
|
| 1000 | + $_titre = champ_sql('titre', $p); |
|
| 1001 | + } |
|
| 1002 | + |
|
| 1003 | + // et on recupere aussi les infos de liaison si on est en train d'editer les liens justement |
|
| 1004 | + // cas des formulaires xxx_lies utilises par #FORMULAIRE_EDITER_LIENS |
|
| 1005 | + $type_boucle = $boucle->type_requete; |
|
| 1006 | + $objet = objet_type($type_boucle); |
|
| 1007 | + $id_table_objet = id_table_objet($type_boucle); |
|
| 1008 | + $_primary = champ_sql($id_table_objet, $p, '', false); |
|
| 1009 | + $_env = '$Pile[0]'; |
|
| 1010 | + |
|
| 1011 | + if (!$_titre) {$_titre = "''"; |
|
| 1012 | + } |
|
| 1013 | + if (!$_primary) {$_primary = "''"; |
|
| 1014 | + } |
|
| 1015 | + $_rang = "calculer_rang_smart($_titre, '$objet', $_primary, $_env)"; |
|
| 1016 | + } |
|
| 1017 | + |
|
| 1018 | + $p->code = $_rang; |
|
| 1019 | + $p->interdire_scripts = false; |
|
| 1020 | + } |
|
| 1021 | + |
|
| 1022 | + return $p; |
|
| 1023 | 1023 | } |
| 1024 | 1024 | |
| 1025 | 1025 | |
@@ -1041,12 +1041,12 @@ discard block |
||
| 1041 | 1041 | * Pile complétée par le code à générer |
| 1042 | 1042 | **/ |
| 1043 | 1043 | function balise_POPULARITE_dist($p) { |
| 1044 | - $_popularite = champ_sql('popularite', $p); |
|
| 1045 | - $p->code = "(ceil(min(100, 100 * $_popularite |
|
| 1044 | + $_popularite = champ_sql('popularite', $p); |
|
| 1045 | + $p->code = "(ceil(min(100, 100 * $_popularite |
|
| 1046 | 1046 | / max(1 , 0 + \$GLOBALS['meta']['popularite_max']))))"; |
| 1047 | - $p->interdire_scripts = false; |
|
| 1047 | + $p->interdire_scripts = false; |
|
| 1048 | 1048 | |
| 1049 | - return $p; |
|
| 1049 | + return $p; |
|
| 1050 | 1050 | } |
| 1051 | 1051 | |
| 1052 | 1052 | /** |
@@ -1057,8 +1057,8 @@ discard block |
||
| 1057 | 1057 | * l'absence peut-être due à une faute de frappe dans le contexte inclus. |
| 1058 | 1058 | */ |
| 1059 | 1059 | define( |
| 1060 | - 'CODE_PAGINATION', |
|
| 1061 | - '%s($Numrows["%s"]["grand_total"], |
|
| 1060 | + 'CODE_PAGINATION', |
|
| 1061 | + '%s($Numrows["%s"]["grand_total"], |
|
| 1062 | 1062 | %s, |
| 1063 | 1063 | isset($Pile[0][%4$s])?$Pile[0][%4$s]:intval(_request(%4$s)), |
| 1064 | 1064 | %5$s, %6$s, %7$s, %8$s, array(%9$s))' |
@@ -1095,75 +1095,75 @@ discard block |
||
| 1095 | 1095 | * Pile complétée par le code à générer |
| 1096 | 1096 | */ |
| 1097 | 1097 | function balise_PAGINATION_dist($p, $liste = 'true') { |
| 1098 | - $b = index_boucle_mere($p); |
|
| 1099 | - |
|
| 1100 | - // s'il n'y a pas de nom de boucle, on ne peut pas paginer |
|
| 1101 | - if ($b === '') { |
|
| 1102 | - $msg = [ |
|
| 1103 | - 'zbug_champ_hors_boucle', |
|
| 1104 | - ['champ' => $liste ? 'PAGINATION' : 'ANCRE_PAGINATION'] |
|
| 1105 | - ]; |
|
| 1106 | - erreur_squelette($msg, $p); |
|
| 1107 | - |
|
| 1108 | - return $p; |
|
| 1109 | - } |
|
| 1110 | - |
|
| 1111 | - // s'il n'y a pas de mode_partie, c'est qu'on se trouve |
|
| 1112 | - // dans un boucle recursive ou qu'on a oublie le critere {pagination} |
|
| 1113 | - if (!$p->boucles[$b]->mode_partie) { |
|
| 1114 | - if (!$p->boucles[$b]->table_optionnelle) { |
|
| 1115 | - $msg = [ |
|
| 1116 | - 'zbug_pagination_sans_critere', |
|
| 1117 | - ['champ' => '#PAGINATION'] |
|
| 1118 | - ]; |
|
| 1119 | - erreur_squelette($msg, $p); |
|
| 1120 | - } |
|
| 1121 | - |
|
| 1122 | - return $p; |
|
| 1123 | - } |
|
| 1124 | - |
|
| 1125 | - // a priori true |
|
| 1126 | - // si false, le compilo va bloquer sur des syntaxes avec un filtre sans argument qui suit la balise |
|
| 1127 | - // si true, les arguments simples (sans truc=chose) vont degager |
|
| 1128 | - $_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $p->id_boucle, false, false); |
|
| 1129 | - if (is_countable($_contexte) ? count($_contexte) : 0) { |
|
| 1130 | - $key = key($_contexte); |
|
| 1131 | - if (is_numeric($key)) { |
|
| 1132 | - array_shift($_contexte); |
|
| 1133 | - $__modele = interprete_argument_balise(1, $p); |
|
| 1134 | - } |
|
| 1135 | - } |
|
| 1136 | - |
|
| 1137 | - if (is_countable($_contexte) ? count($_contexte) : 0) { |
|
| 1138 | - $code_contexte = implode(',', $_contexte); |
|
| 1139 | - } else { |
|
| 1140 | - $code_contexte = ''; |
|
| 1141 | - } |
|
| 1142 | - |
|
| 1143 | - $connect = $p->boucles[$b]->sql_serveur; |
|
| 1144 | - $pas = $p->boucles[$b]->total_parties; |
|
| 1145 | - $f_pagination = chercher_filtre('pagination'); |
|
| 1146 | - $type = $p->boucles[$b]->modificateur['debut_nom']; |
|
| 1147 | - $modif = ($type[0] !== "'") ? "'debut'.$type" |
|
| 1148 | - : ("'debut" . substr($type, 1)); |
|
| 1149 | - |
|
| 1150 | - $p->code = sprintf( |
|
| 1151 | - CODE_PAGINATION, |
|
| 1152 | - $f_pagination, |
|
| 1153 | - $b, |
|
| 1154 | - $type, |
|
| 1155 | - $modif, |
|
| 1156 | - $pas, |
|
| 1157 | - $liste, |
|
| 1158 | - ((isset($__modele) and $__modele) ? $__modele : "''"), |
|
| 1159 | - _q($connect), |
|
| 1160 | - $code_contexte |
|
| 1161 | - ); |
|
| 1162 | - |
|
| 1163 | - $p->boucles[$b]->numrows = true; |
|
| 1164 | - $p->interdire_scripts = false; |
|
| 1165 | - |
|
| 1166 | - return $p; |
|
| 1098 | + $b = index_boucle_mere($p); |
|
| 1099 | + |
|
| 1100 | + // s'il n'y a pas de nom de boucle, on ne peut pas paginer |
|
| 1101 | + if ($b === '') { |
|
| 1102 | + $msg = [ |
|
| 1103 | + 'zbug_champ_hors_boucle', |
|
| 1104 | + ['champ' => $liste ? 'PAGINATION' : 'ANCRE_PAGINATION'] |
|
| 1105 | + ]; |
|
| 1106 | + erreur_squelette($msg, $p); |
|
| 1107 | + |
|
| 1108 | + return $p; |
|
| 1109 | + } |
|
| 1110 | + |
|
| 1111 | + // s'il n'y a pas de mode_partie, c'est qu'on se trouve |
|
| 1112 | + // dans un boucle recursive ou qu'on a oublie le critere {pagination} |
|
| 1113 | + if (!$p->boucles[$b]->mode_partie) { |
|
| 1114 | + if (!$p->boucles[$b]->table_optionnelle) { |
|
| 1115 | + $msg = [ |
|
| 1116 | + 'zbug_pagination_sans_critere', |
|
| 1117 | + ['champ' => '#PAGINATION'] |
|
| 1118 | + ]; |
|
| 1119 | + erreur_squelette($msg, $p); |
|
| 1120 | + } |
|
| 1121 | + |
|
| 1122 | + return $p; |
|
| 1123 | + } |
|
| 1124 | + |
|
| 1125 | + // a priori true |
|
| 1126 | + // si false, le compilo va bloquer sur des syntaxes avec un filtre sans argument qui suit la balise |
|
| 1127 | + // si true, les arguments simples (sans truc=chose) vont degager |
|
| 1128 | + $_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $p->id_boucle, false, false); |
|
| 1129 | + if (is_countable($_contexte) ? count($_contexte) : 0) { |
|
| 1130 | + $key = key($_contexte); |
|
| 1131 | + if (is_numeric($key)) { |
|
| 1132 | + array_shift($_contexte); |
|
| 1133 | + $__modele = interprete_argument_balise(1, $p); |
|
| 1134 | + } |
|
| 1135 | + } |
|
| 1136 | + |
|
| 1137 | + if (is_countable($_contexte) ? count($_contexte) : 0) { |
|
| 1138 | + $code_contexte = implode(',', $_contexte); |
|
| 1139 | + } else { |
|
| 1140 | + $code_contexte = ''; |
|
| 1141 | + } |
|
| 1142 | + |
|
| 1143 | + $connect = $p->boucles[$b]->sql_serveur; |
|
| 1144 | + $pas = $p->boucles[$b]->total_parties; |
|
| 1145 | + $f_pagination = chercher_filtre('pagination'); |
|
| 1146 | + $type = $p->boucles[$b]->modificateur['debut_nom']; |
|
| 1147 | + $modif = ($type[0] !== "'") ? "'debut'.$type" |
|
| 1148 | + : ("'debut" . substr($type, 1)); |
|
| 1149 | + |
|
| 1150 | + $p->code = sprintf( |
|
| 1151 | + CODE_PAGINATION, |
|
| 1152 | + $f_pagination, |
|
| 1153 | + $b, |
|
| 1154 | + $type, |
|
| 1155 | + $modif, |
|
| 1156 | + $pas, |
|
| 1157 | + $liste, |
|
| 1158 | + ((isset($__modele) and $__modele) ? $__modele : "''"), |
|
| 1159 | + _q($connect), |
|
| 1160 | + $code_contexte |
|
| 1161 | + ); |
|
| 1162 | + |
|
| 1163 | + $p->boucles[$b]->numrows = true; |
|
| 1164 | + $p->interdire_scripts = false; |
|
| 1165 | + |
|
| 1166 | + return $p; |
|
| 1167 | 1167 | } |
| 1168 | 1168 | |
| 1169 | 1169 | |
@@ -1190,11 +1190,11 @@ discard block |
||
| 1190 | 1190 | * Pile complétée par le code à générer |
| 1191 | 1191 | **/ |
| 1192 | 1192 | function balise_ANCRE_PAGINATION_dist($p) { |
| 1193 | - if ($f = charger_fonction('PAGINATION', 'balise', true)) { |
|
| 1194 | - return $f($p, $liste = 'false'); |
|
| 1195 | - } else { |
|
| 1196 | - return null; |
|
| 1197 | - } // ou une erreur ? |
|
| 1193 | + if ($f = charger_fonction('PAGINATION', 'balise', true)) { |
|
| 1194 | + return $f($p, $liste = 'false'); |
|
| 1195 | + } else { |
|
| 1196 | + return null; |
|
| 1197 | + } // ou une erreur ? |
|
| 1198 | 1198 | } |
| 1199 | 1199 | |
| 1200 | 1200 | |
@@ -1215,17 +1215,17 @@ discard block |
||
| 1215 | 1215 | * Pile complétée par le code à générer |
| 1216 | 1216 | **/ |
| 1217 | 1217 | function balise_GRAND_TOTAL_dist($p) { |
| 1218 | - $b = index_boucle_mere($p); |
|
| 1219 | - if ($b === '') { |
|
| 1220 | - $msg = ['zbug_champ_hors_boucle', ['champ' => zbug_presenter_champ($p)]]; |
|
| 1221 | - erreur_squelette($msg, $p); |
|
| 1222 | - } else { |
|
| 1223 | - $p->code = "(\$Numrows['$b']['grand_total'] ?? \$Numrows['$b']['total'] ?? 0)"; |
|
| 1224 | - $p->boucles[$b]->numrows = true; |
|
| 1225 | - $p->interdire_scripts = false; |
|
| 1226 | - } |
|
| 1218 | + $b = index_boucle_mere($p); |
|
| 1219 | + if ($b === '') { |
|
| 1220 | + $msg = ['zbug_champ_hors_boucle', ['champ' => zbug_presenter_champ($p)]]; |
|
| 1221 | + erreur_squelette($msg, $p); |
|
| 1222 | + } else { |
|
| 1223 | + $p->code = "(\$Numrows['$b']['grand_total'] ?? \$Numrows['$b']['total'] ?? 0)"; |
|
| 1224 | + $p->boucles[$b]->numrows = true; |
|
| 1225 | + $p->interdire_scripts = false; |
|
| 1226 | + } |
|
| 1227 | 1227 | |
| 1228 | - return $p; |
|
| 1228 | + return $p; |
|
| 1229 | 1229 | } |
| 1230 | 1230 | |
| 1231 | 1231 | |
@@ -1253,10 +1253,10 @@ discard block |
||
| 1253 | 1253 | * Pile complétée par le code à générer |
| 1254 | 1254 | **/ |
| 1255 | 1255 | function balise_SELF_dist($p) { |
| 1256 | - $p->code = 'self()'; |
|
| 1257 | - $p->interdire_scripts = false; |
|
| 1256 | + $p->code = 'self()'; |
|
| 1257 | + $p->interdire_scripts = false; |
|
| 1258 | 1258 | |
| 1259 | - return $p; |
|
| 1259 | + return $p; |
|
| 1260 | 1260 | } |
| 1261 | 1261 | |
| 1262 | 1262 | |
@@ -1283,17 +1283,17 @@ discard block |
||
| 1283 | 1283 | * Pile complétée par le code à générer |
| 1284 | 1284 | **/ |
| 1285 | 1285 | function balise_CHEMIN_dist($p) { |
| 1286 | - $arg = interprete_argument_balise(1, $p); |
|
| 1287 | - if (!$arg) { |
|
| 1288 | - $msg = ['zbug_balise_sans_argument', ['balise' => ' CHEMIN']]; |
|
| 1289 | - erreur_squelette($msg, $p); |
|
| 1290 | - } else { |
|
| 1291 | - $p->code = 'find_in_path(' . $arg . ')'; |
|
| 1292 | - } |
|
| 1286 | + $arg = interprete_argument_balise(1, $p); |
|
| 1287 | + if (!$arg) { |
|
| 1288 | + $msg = ['zbug_balise_sans_argument', ['balise' => ' CHEMIN']]; |
|
| 1289 | + erreur_squelette($msg, $p); |
|
| 1290 | + } else { |
|
| 1291 | + $p->code = 'find_in_path(' . $arg . ')'; |
|
| 1292 | + } |
|
| 1293 | 1293 | |
| 1294 | - $p->interdire_scripts = false; |
|
| 1294 | + $p->interdire_scripts = false; |
|
| 1295 | 1295 | |
| 1296 | - return $p; |
|
| 1296 | + return $p; |
|
| 1297 | 1297 | } |
| 1298 | 1298 | |
| 1299 | 1299 | /** |
@@ -1318,16 +1318,16 @@ discard block |
||
| 1318 | 1318 | * Pile complétée par le code à générer |
| 1319 | 1319 | **/ |
| 1320 | 1320 | function balise_CHEMIN_IMAGE_dist($p) { |
| 1321 | - $arg = interprete_argument_balise(1, $p); |
|
| 1322 | - if (!$arg) { |
|
| 1323 | - $msg = ['zbug_balise_sans_argument', ['balise' => ' CHEMIN_IMAGE']]; |
|
| 1324 | - erreur_squelette($msg, $p); |
|
| 1325 | - } else { |
|
| 1326 | - $p->code = 'chemin_image(' . $arg . ')'; |
|
| 1327 | - } |
|
| 1321 | + $arg = interprete_argument_balise(1, $p); |
|
| 1322 | + if (!$arg) { |
|
| 1323 | + $msg = ['zbug_balise_sans_argument', ['balise' => ' CHEMIN_IMAGE']]; |
|
| 1324 | + erreur_squelette($msg, $p); |
|
| 1325 | + } else { |
|
| 1326 | + $p->code = 'chemin_image(' . $arg . ')'; |
|
| 1327 | + } |
|
| 1328 | 1328 | |
| 1329 | - $p->interdire_scripts = false; |
|
| 1330 | - return $p; |
|
| 1329 | + $p->interdire_scripts = false; |
|
| 1330 | + return $p; |
|
| 1331 | 1331 | } |
| 1332 | 1332 | |
| 1333 | 1333 | |
@@ -1365,36 +1365,36 @@ discard block |
||
| 1365 | 1365 | **/ |
| 1366 | 1366 | function balise_ENV_dist($p, $src = null) { |
| 1367 | 1367 | |
| 1368 | - // cle du tableau desiree |
|
| 1369 | - $_nom = interprete_argument_balise(1, $p); |
|
| 1370 | - // valeur par defaut |
|
| 1371 | - $_sinon = interprete_argument_balise(2, $p); |
|
| 1368 | + // cle du tableau desiree |
|
| 1369 | + $_nom = interprete_argument_balise(1, $p); |
|
| 1370 | + // valeur par defaut |
|
| 1371 | + $_sinon = interprete_argument_balise(2, $p); |
|
| 1372 | 1372 | |
| 1373 | - // $src est un tableau de donnees sources eventuellement transmis |
|
| 1374 | - // en absence, on utilise l'environnement du squelette $Pile[0] |
|
| 1373 | + // $src est un tableau de donnees sources eventuellement transmis |
|
| 1374 | + // en absence, on utilise l'environnement du squelette $Pile[0] |
|
| 1375 | 1375 | |
| 1376 | - if (!$_nom) { |
|
| 1377 | - // cas de #ENV sans argument : on retourne le serialize() du tableau |
|
| 1378 | - // une belle fonction [(#ENV|affiche_env)] serait pratique |
|
| 1379 | - if ($src) { |
|
| 1380 | - $p->code = '(is_array($a = (' . $src . ')) ? serialize($a) : "")'; |
|
| 1381 | - } else { |
|
| 1382 | - $p->code = 'serialize($Pile[0]??[])'; |
|
| 1383 | - } |
|
| 1384 | - } else { |
|
| 1385 | - if (!$src) { |
|
| 1386 | - $src = '$Pile[0]??[]'; |
|
| 1387 | - } |
|
| 1388 | - if ($_sinon) { |
|
| 1389 | - $p->code = "sinon(table_valeur($src, (string)$_nom, null), $_sinon)"; |
|
| 1390 | - } else { |
|
| 1391 | - $p->code = "table_valeur($src, (string)$_nom, null)"; |
|
| 1392 | - } |
|
| 1393 | - } |
|
| 1376 | + if (!$_nom) { |
|
| 1377 | + // cas de #ENV sans argument : on retourne le serialize() du tableau |
|
| 1378 | + // une belle fonction [(#ENV|affiche_env)] serait pratique |
|
| 1379 | + if ($src) { |
|
| 1380 | + $p->code = '(is_array($a = (' . $src . ')) ? serialize($a) : "")'; |
|
| 1381 | + } else { |
|
| 1382 | + $p->code = 'serialize($Pile[0]??[])'; |
|
| 1383 | + } |
|
| 1384 | + } else { |
|
| 1385 | + if (!$src) { |
|
| 1386 | + $src = '$Pile[0]??[]'; |
|
| 1387 | + } |
|
| 1388 | + if ($_sinon) { |
|
| 1389 | + $p->code = "sinon(table_valeur($src, (string)$_nom, null), $_sinon)"; |
|
| 1390 | + } else { |
|
| 1391 | + $p->code = "table_valeur($src, (string)$_nom, null)"; |
|
| 1392 | + } |
|
| 1393 | + } |
|
| 1394 | 1394 | |
| 1395 | - #$p->interdire_scripts = true; |
|
| 1395 | + #$p->interdire_scripts = true; |
|
| 1396 | 1396 | |
| 1397 | - return $p; |
|
| 1397 | + return $p; |
|
| 1398 | 1398 | } |
| 1399 | 1399 | |
| 1400 | 1400 | /** |
@@ -1424,16 +1424,16 @@ discard block |
||
| 1424 | 1424 | * Pile completée du code PHP d'exécution de la balise |
| 1425 | 1425 | */ |
| 1426 | 1426 | function balise_CONFIG_dist($p) { |
| 1427 | - if (!$arg = interprete_argument_balise(1, $p)) { |
|
| 1428 | - $arg = "''"; |
|
| 1429 | - } |
|
| 1430 | - $_sinon = interprete_argument_balise(2, $p); |
|
| 1431 | - $_unserialize = sinon(interprete_argument_balise(3, $p), 'false'); |
|
| 1427 | + if (!$arg = interprete_argument_balise(1, $p)) { |
|
| 1428 | + $arg = "''"; |
|
| 1429 | + } |
|
| 1430 | + $_sinon = interprete_argument_balise(2, $p); |
|
| 1431 | + $_unserialize = sinon(interprete_argument_balise(3, $p), 'false'); |
|
| 1432 | 1432 | |
| 1433 | - $p->code = '(include_spip(\'inc/config\')?lire_config(' . $arg . ',' . |
|
| 1434 | - ($_sinon && $_sinon != "''" ? $_sinon : 'null') . ',' . $_unserialize . "):'')"; |
|
| 1433 | + $p->code = '(include_spip(\'inc/config\')?lire_config(' . $arg . ',' . |
|
| 1434 | + ($_sinon && $_sinon != "''" ? $_sinon : 'null') . ',' . $_unserialize . "):'')"; |
|
| 1435 | 1435 | |
| 1436 | - return $p; |
|
| 1436 | + return $p; |
|
| 1437 | 1437 | } |
| 1438 | 1438 | |
| 1439 | 1439 | |
@@ -1456,10 +1456,10 @@ discard block |
||
| 1456 | 1456 | * Pile completée du code PHP d'exécution de la balise |
| 1457 | 1457 | */ |
| 1458 | 1458 | function balise_CONNECT_dist($p) { |
| 1459 | - $p->code = '($connect ? $connect : NULL)'; |
|
| 1460 | - $p->interdire_scripts = false; |
|
| 1459 | + $p->code = '($connect ? $connect : NULL)'; |
|
| 1460 | + $p->interdire_scripts = false; |
|
| 1461 | 1461 | |
| 1462 | - return $p; |
|
| 1462 | + return $p; |
|
| 1463 | 1463 | } |
| 1464 | 1464 | |
| 1465 | 1465 | |
@@ -1487,15 +1487,15 @@ discard block |
||
| 1487 | 1487 | * Pile completée du code PHP d'exécution de la balise |
| 1488 | 1488 | **/ |
| 1489 | 1489 | function balise_SESSION_dist($p) { |
| 1490 | - $p->descr['session'] = true; |
|
| 1490 | + $p->descr['session'] = true; |
|
| 1491 | 1491 | |
| 1492 | - $f = function_exists('balise_ENV') |
|
| 1493 | - ? 'balise_ENV' |
|
| 1494 | - : 'balise_ENV_dist'; |
|
| 1492 | + $f = function_exists('balise_ENV') |
|
| 1493 | + ? 'balise_ENV' |
|
| 1494 | + : 'balise_ENV_dist'; |
|
| 1495 | 1495 | |
| 1496 | - $p = $f($p, '$GLOBALS["visiteur_session"]??[]'); |
|
| 1496 | + $p = $f($p, '$GLOBALS["visiteur_session"]??[]'); |
|
| 1497 | 1497 | |
| 1498 | - return $p; |
|
| 1498 | + return $p; |
|
| 1499 | 1499 | } |
| 1500 | 1500 | |
| 1501 | 1501 | |
@@ -1518,18 +1518,18 @@ discard block |
||
| 1518 | 1518 | * Pile completée du code PHP d'exécution de la balise |
| 1519 | 1519 | **/ |
| 1520 | 1520 | function balise_SESSION_SET_dist($p) { |
| 1521 | - $_nom = interprete_argument_balise(1, $p); |
|
| 1522 | - $_val = interprete_argument_balise(2, $p); |
|
| 1523 | - if (!$_nom or !$_val) { |
|
| 1524 | - $err_b_s_a = ['zbug_balise_sans_argument', ['balise' => 'SESSION_SET']]; |
|
| 1525 | - erreur_squelette($err_b_s_a, $p); |
|
| 1526 | - } else { |
|
| 1527 | - $p->code = '(include_spip("inc/session") AND session_set(' . $_nom . ',' . $_val . '))'; |
|
| 1528 | - } |
|
| 1521 | + $_nom = interprete_argument_balise(1, $p); |
|
| 1522 | + $_val = interprete_argument_balise(2, $p); |
|
| 1523 | + if (!$_nom or !$_val) { |
|
| 1524 | + $err_b_s_a = ['zbug_balise_sans_argument', ['balise' => 'SESSION_SET']]; |
|
| 1525 | + erreur_squelette($err_b_s_a, $p); |
|
| 1526 | + } else { |
|
| 1527 | + $p->code = '(include_spip("inc/session") AND session_set(' . $_nom . ',' . $_val . '))'; |
|
| 1528 | + } |
|
| 1529 | 1529 | |
| 1530 | - $p->interdire_scripts = false; |
|
| 1530 | + $p->interdire_scripts = false; |
|
| 1531 | 1531 | |
| 1532 | - return $p; |
|
| 1532 | + return $p; |
|
| 1533 | 1533 | } |
| 1534 | 1534 | |
| 1535 | 1535 | |
@@ -1560,30 +1560,30 @@ discard block |
||
| 1560 | 1560 | * Pile completée du code PHP d'exécution de la balise |
| 1561 | 1561 | **/ |
| 1562 | 1562 | function balise_EVAL_dist($p) { |
| 1563 | - $php = interprete_argument_balise(1, $p); |
|
| 1564 | - if ($php) { |
|
| 1565 | - # optimisation sur les #EVAL{une expression sans #BALISE} |
|
| 1566 | - # attention au commentaire "// x signes" qui precede |
|
| 1567 | - if ( |
|
| 1568 | - preg_match( |
|
| 1569 | - ",^([[:space:]]*//[^\n]*\n)'([^']+)'$,ms", |
|
| 1570 | - $php, |
|
| 1571 | - $r |
|
| 1572 | - ) |
|
| 1573 | - ) { |
|
| 1574 | - $p->code = /* $r[1]. */ |
|
| 1575 | - '(' . $r[2] . ')'; |
|
| 1576 | - } else { |
|
| 1577 | - $p->code = "eval('return '.$php.';')"; |
|
| 1578 | - } |
|
| 1579 | - } else { |
|
| 1580 | - $msg = ['zbug_balise_sans_argument', ['balise' => ' EVAL']]; |
|
| 1581 | - erreur_squelette($msg, $p); |
|
| 1582 | - } |
|
| 1583 | - |
|
| 1584 | - #$p->interdire_scripts = true; |
|
| 1585 | - |
|
| 1586 | - return $p; |
|
| 1563 | + $php = interprete_argument_balise(1, $p); |
|
| 1564 | + if ($php) { |
|
| 1565 | + # optimisation sur les #EVAL{une expression sans #BALISE} |
|
| 1566 | + # attention au commentaire "// x signes" qui precede |
|
| 1567 | + if ( |
|
| 1568 | + preg_match( |
|
| 1569 | + ",^([[:space:]]*//[^\n]*\n)'([^']+)'$,ms", |
|
| 1570 | + $php, |
|
| 1571 | + $r |
|
| 1572 | + ) |
|
| 1573 | + ) { |
|
| 1574 | + $p->code = /* $r[1]. */ |
|
| 1575 | + '(' . $r[2] . ')'; |
|
| 1576 | + } else { |
|
| 1577 | + $p->code = "eval('return '.$php.';')"; |
|
| 1578 | + } |
|
| 1579 | + } else { |
|
| 1580 | + $msg = ['zbug_balise_sans_argument', ['balise' => ' EVAL']]; |
|
| 1581 | + erreur_squelette($msg, $p); |
|
| 1582 | + } |
|
| 1583 | + |
|
| 1584 | + #$p->interdire_scripts = true; |
|
| 1585 | + |
|
| 1586 | + return $p; |
|
| 1587 | 1587 | } |
| 1588 | 1588 | |
| 1589 | 1589 | |
@@ -1613,19 +1613,19 @@ discard block |
||
| 1613 | 1613 | **/ |
| 1614 | 1614 | function balise_CHAMP_SQL_dist($p) { |
| 1615 | 1615 | |
| 1616 | - if ( |
|
| 1617 | - $p->param |
|
| 1618 | - and isset($p->param[0][1][0]) |
|
| 1619 | - and $champ = ($p->param[0][1][0]->texte) |
|
| 1620 | - ) { |
|
| 1621 | - $p->code = champ_sql($champ, $p); |
|
| 1622 | - } else { |
|
| 1623 | - $err_b_s_a = ['zbug_balise_sans_argument', ['balise' => ' CHAMP_SQL']]; |
|
| 1624 | - erreur_squelette($err_b_s_a, $p); |
|
| 1625 | - } |
|
| 1616 | + if ( |
|
| 1617 | + $p->param |
|
| 1618 | + and isset($p->param[0][1][0]) |
|
| 1619 | + and $champ = ($p->param[0][1][0]->texte) |
|
| 1620 | + ) { |
|
| 1621 | + $p->code = champ_sql($champ, $p); |
|
| 1622 | + } else { |
|
| 1623 | + $err_b_s_a = ['zbug_balise_sans_argument', ['balise' => ' CHAMP_SQL']]; |
|
| 1624 | + erreur_squelette($err_b_s_a, $p); |
|
| 1625 | + } |
|
| 1626 | 1626 | |
| 1627 | - #$p->interdire_scripts = true; |
|
| 1628 | - return $p; |
|
| 1627 | + #$p->interdire_scripts = true; |
|
| 1628 | + return $p; |
|
| 1629 | 1629 | } |
| 1630 | 1630 | |
| 1631 | 1631 | /** |
@@ -1651,13 +1651,13 @@ discard block |
||
| 1651 | 1651 | * Pile complétée par le code à générer |
| 1652 | 1652 | **/ |
| 1653 | 1653 | function balise_VAL_dist($p) { |
| 1654 | - $p->code = interprete_argument_balise(1, $p); |
|
| 1655 | - if ($p->code === null || !strlen($p->code)) { |
|
| 1656 | - $p->code = "''"; |
|
| 1657 | - } |
|
| 1658 | - $p->interdire_scripts = false; |
|
| 1654 | + $p->code = interprete_argument_balise(1, $p); |
|
| 1655 | + if ($p->code === null || !strlen($p->code)) { |
|
| 1656 | + $p->code = "''"; |
|
| 1657 | + } |
|
| 1658 | + $p->interdire_scripts = false; |
|
| 1659 | 1659 | |
| 1660 | - return $p; |
|
| 1660 | + return $p; |
|
| 1661 | 1661 | } |
| 1662 | 1662 | |
| 1663 | 1663 | /** |
@@ -1686,10 +1686,10 @@ discard block |
||
| 1686 | 1686 | * Pile complétée par le code à générer |
| 1687 | 1687 | **/ |
| 1688 | 1688 | function balise_REM_dist($p) { |
| 1689 | - $p->code = "''"; |
|
| 1690 | - $p->interdire_scripts = false; |
|
| 1689 | + $p->code = "''"; |
|
| 1690 | + $p->interdire_scripts = false; |
|
| 1691 | 1691 | |
| 1692 | - return $p; |
|
| 1692 | + return $p; |
|
| 1693 | 1693 | } |
| 1694 | 1694 | |
| 1695 | 1695 | /** |
@@ -1699,10 +1699,10 @@ discard block |
||
| 1699 | 1699 | * @return mixed |
| 1700 | 1700 | */ |
| 1701 | 1701 | function balise_NULL_dist($p) { |
| 1702 | - $p->code = 'null'; |
|
| 1703 | - $p->interdire_scripts = false; |
|
| 1702 | + $p->code = 'null'; |
|
| 1703 | + $p->interdire_scripts = false; |
|
| 1704 | 1704 | |
| 1705 | - return $p; |
|
| 1705 | + return $p; |
|
| 1706 | 1706 | } |
| 1707 | 1707 | |
| 1708 | 1708 | |
@@ -1726,18 +1726,18 @@ discard block |
||
| 1726 | 1726 | **/ |
| 1727 | 1727 | function balise_HTTP_HEADER_dist($p) { |
| 1728 | 1728 | |
| 1729 | - $header = interprete_argument_balise(1, $p); |
|
| 1730 | - if (!$header) { |
|
| 1731 | - $err_b_s_a = ['zbug_balise_sans_argument', ['balise' => 'HTTP_HEADER']]; |
|
| 1732 | - erreur_squelette($err_b_s_a, $p); |
|
| 1733 | - } else { |
|
| 1734 | - $p->code = "'<'.'?php header(' . _q(" |
|
| 1735 | - . $header |
|
| 1736 | - . ") . '); ?'.'>'"; |
|
| 1737 | - } |
|
| 1738 | - $p->interdire_scripts = false; |
|
| 1729 | + $header = interprete_argument_balise(1, $p); |
|
| 1730 | + if (!$header) { |
|
| 1731 | + $err_b_s_a = ['zbug_balise_sans_argument', ['balise' => 'HTTP_HEADER']]; |
|
| 1732 | + erreur_squelette($err_b_s_a, $p); |
|
| 1733 | + } else { |
|
| 1734 | + $p->code = "'<'.'?php header(' . _q(" |
|
| 1735 | + . $header |
|
| 1736 | + . ") . '); ?'.'>'"; |
|
| 1737 | + } |
|
| 1738 | + $p->interdire_scripts = false; |
|
| 1739 | 1739 | |
| 1740 | - return $p; |
|
| 1740 | + return $p; |
|
| 1741 | 1741 | } |
| 1742 | 1742 | |
| 1743 | 1743 | |
@@ -1762,20 +1762,20 @@ discard block |
||
| 1762 | 1762 | * Pile complétée par le code à générer |
| 1763 | 1763 | **/ |
| 1764 | 1764 | function balise_FILTRE_dist($p) { |
| 1765 | - if ($p->param) { |
|
| 1766 | - $args = []; |
|
| 1767 | - foreach ($p->param as $i => $ignore) { |
|
| 1768 | - $args[] = interprete_argument_balise($i + 1, $p); |
|
| 1769 | - } |
|
| 1770 | - $p->code = "'<' . '" |
|
| 1771 | - . '?php header("X-Spip-Filtre: \'.' |
|
| 1772 | - . join('.\'|\'.', $args) |
|
| 1773 | - . " . '\"); ?'.'>'"; |
|
| 1765 | + if ($p->param) { |
|
| 1766 | + $args = []; |
|
| 1767 | + foreach ($p->param as $i => $ignore) { |
|
| 1768 | + $args[] = interprete_argument_balise($i + 1, $p); |
|
| 1769 | + } |
|
| 1770 | + $p->code = "'<' . '" |
|
| 1771 | + . '?php header("X-Spip-Filtre: \'.' |
|
| 1772 | + . join('.\'|\'.', $args) |
|
| 1773 | + . " . '\"); ?'.'>'"; |
|
| 1774 | 1774 | |
| 1775 | - $p->interdire_scripts = false; |
|
| 1775 | + $p->interdire_scripts = false; |
|
| 1776 | 1776 | |
| 1777 | - return $p; |
|
| 1778 | - } |
|
| 1777 | + return $p; |
|
| 1778 | + } |
|
| 1779 | 1779 | } |
| 1780 | 1780 | |
| 1781 | 1781 | |
@@ -1811,55 +1811,55 @@ discard block |
||
| 1811 | 1811 | **/ |
| 1812 | 1812 | function balise_CACHE_dist($p) { |
| 1813 | 1813 | |
| 1814 | - if ($p->param) { |
|
| 1815 | - $duree = valeur_numerique($p->param[0][1][0]->texte); |
|
| 1816 | - |
|
| 1817 | - // noter la duree du cache dans un entete proprietaire |
|
| 1818 | - |
|
| 1819 | - $code = "'<'.'" . '?php header("X-Spip-Cache: ' |
|
| 1820 | - . $duree |
|
| 1821 | - . '"); ?' . "'.'>'"; |
|
| 1822 | - |
|
| 1823 | - // Remplir le header Cache-Control |
|
| 1824 | - // cas #CACHE{0} |
|
| 1825 | - if ($duree == 0) { |
|
| 1826 | - $code .= ".'<'.'" |
|
| 1827 | - . '?php header("Cache-Control: no-cache, must-revalidate"); ?' |
|
| 1828 | - . "'.'><'.'" |
|
| 1829 | - . '?php header("Pragma: no-cache"); ?' |
|
| 1830 | - . "'.'>'"; |
|
| 1831 | - } |
|
| 1832 | - |
|
| 1833 | - // recuperer les parametres suivants |
|
| 1834 | - $i = 1; |
|
| 1835 | - while (isset($p->param[0][++$i])) { |
|
| 1836 | - $pa = ($p->param[0][$i][0]->texte); |
|
| 1837 | - |
|
| 1838 | - if ( |
|
| 1839 | - $pa == 'cache-client' |
|
| 1840 | - and $duree > 0 |
|
| 1841 | - ) { |
|
| 1842 | - $code .= ".'<'.'" . '?php header("Cache-Control: max-age=' |
|
| 1843 | - . $duree |
|
| 1844 | - . '"); ?' . "'.'>'"; |
|
| 1845 | - // il semble logique, si on cache-client, de ne pas invalider |
|
| 1846 | - $pa = 'statique'; |
|
| 1847 | - } |
|
| 1848 | - |
|
| 1849 | - if ( |
|
| 1850 | - $pa == 'statique' |
|
| 1851 | - and $duree > 0 |
|
| 1852 | - ) { |
|
| 1853 | - $code .= ".'<'.'" . '?php header("X-Spip-Statique: oui"); ?' . "'.'>'"; |
|
| 1854 | - } |
|
| 1855 | - } |
|
| 1856 | - } else { |
|
| 1857 | - $code = "''"; |
|
| 1858 | - } |
|
| 1859 | - $p->code = $code; |
|
| 1860 | - $p->interdire_scripts = false; |
|
| 1861 | - |
|
| 1862 | - return $p; |
|
| 1814 | + if ($p->param) { |
|
| 1815 | + $duree = valeur_numerique($p->param[0][1][0]->texte); |
|
| 1816 | + |
|
| 1817 | + // noter la duree du cache dans un entete proprietaire |
|
| 1818 | + |
|
| 1819 | + $code = "'<'.'" . '?php header("X-Spip-Cache: ' |
|
| 1820 | + . $duree |
|
| 1821 | + . '"); ?' . "'.'>'"; |
|
| 1822 | + |
|
| 1823 | + // Remplir le header Cache-Control |
|
| 1824 | + // cas #CACHE{0} |
|
| 1825 | + if ($duree == 0) { |
|
| 1826 | + $code .= ".'<'.'" |
|
| 1827 | + . '?php header("Cache-Control: no-cache, must-revalidate"); ?' |
|
| 1828 | + . "'.'><'.'" |
|
| 1829 | + . '?php header("Pragma: no-cache"); ?' |
|
| 1830 | + . "'.'>'"; |
|
| 1831 | + } |
|
| 1832 | + |
|
| 1833 | + // recuperer les parametres suivants |
|
| 1834 | + $i = 1; |
|
| 1835 | + while (isset($p->param[0][++$i])) { |
|
| 1836 | + $pa = ($p->param[0][$i][0]->texte); |
|
| 1837 | + |
|
| 1838 | + if ( |
|
| 1839 | + $pa == 'cache-client' |
|
| 1840 | + and $duree > 0 |
|
| 1841 | + ) { |
|
| 1842 | + $code .= ".'<'.'" . '?php header("Cache-Control: max-age=' |
|
| 1843 | + . $duree |
|
| 1844 | + . '"); ?' . "'.'>'"; |
|
| 1845 | + // il semble logique, si on cache-client, de ne pas invalider |
|
| 1846 | + $pa = 'statique'; |
|
| 1847 | + } |
|
| 1848 | + |
|
| 1849 | + if ( |
|
| 1850 | + $pa == 'statique' |
|
| 1851 | + and $duree > 0 |
|
| 1852 | + ) { |
|
| 1853 | + $code .= ".'<'.'" . '?php header("X-Spip-Statique: oui"); ?' . "'.'>'"; |
|
| 1854 | + } |
|
| 1855 | + } |
|
| 1856 | + } else { |
|
| 1857 | + $code = "''"; |
|
| 1858 | + } |
|
| 1859 | + $p->code = $code; |
|
| 1860 | + $p->interdire_scripts = false; |
|
| 1861 | + |
|
| 1862 | + return $p; |
|
| 1863 | 1863 | } |
| 1864 | 1864 | |
| 1865 | 1865 | |
@@ -1891,13 +1891,13 @@ discard block |
||
| 1891 | 1891 | * Pile complétée par le code à générer |
| 1892 | 1892 | */ |
| 1893 | 1893 | function balise_INSERT_HEAD_dist($p) { |
| 1894 | - $p->code = "'<'.'" |
|
| 1895 | - . '?php header("X-Spip-Filtre: insert_head_css_conditionnel"); ?' |
|
| 1896 | - . "'.'>'"; |
|
| 1897 | - $p->code .= ". pipeline('insert_head','<!-- insert_head -->')"; |
|
| 1898 | - $p->interdire_scripts = false; |
|
| 1894 | + $p->code = "'<'.'" |
|
| 1895 | + . '?php header("X-Spip-Filtre: insert_head_css_conditionnel"); ?' |
|
| 1896 | + . "'.'>'"; |
|
| 1897 | + $p->code .= ". pipeline('insert_head','<!-- insert_head -->')"; |
|
| 1898 | + $p->interdire_scripts = false; |
|
| 1899 | 1899 | |
| 1900 | - return $p; |
|
| 1900 | + return $p; |
|
| 1901 | 1901 | } |
| 1902 | 1902 | |
| 1903 | 1903 | /** |
@@ -1915,10 +1915,10 @@ discard block |
||
| 1915 | 1915 | * Pile complétée par le code à générer |
| 1916 | 1916 | */ |
| 1917 | 1917 | function balise_INSERT_HEAD_CSS_dist($p) { |
| 1918 | - $p->code = "pipeline('insert_head_css','<!-- insert_head_css -->')"; |
|
| 1919 | - $p->interdire_scripts = false; |
|
| 1918 | + $p->code = "pipeline('insert_head_css','<!-- insert_head_css -->')"; |
|
| 1919 | + $p->interdire_scripts = false; |
|
| 1920 | 1920 | |
| 1921 | - return $p; |
|
| 1921 | + return $p; |
|
| 1922 | 1922 | } |
| 1923 | 1923 | |
| 1924 | 1924 | /** |
@@ -1933,11 +1933,11 @@ discard block |
||
| 1933 | 1933 | * Pile complétée par le code à générer |
| 1934 | 1934 | **/ |
| 1935 | 1935 | function balise_INCLUDE_dist($p) { |
| 1936 | - if (function_exists('balise_INCLURE')) { |
|
| 1937 | - return balise_INCLURE($p); |
|
| 1938 | - } else { |
|
| 1939 | - return balise_INCLURE_dist($p); |
|
| 1940 | - } |
|
| 1936 | + if (function_exists('balise_INCLURE')) { |
|
| 1937 | + return balise_INCLURE($p); |
|
| 1938 | + } else { |
|
| 1939 | + return balise_INCLURE_dist($p); |
|
| 1940 | + } |
|
| 1941 | 1941 | } |
| 1942 | 1942 | |
| 1943 | 1943 | /** |
@@ -1971,66 +1971,66 @@ discard block |
||
| 1971 | 1971 | * Pile complétée par le code à générer |
| 1972 | 1972 | **/ |
| 1973 | 1973 | function balise_INCLURE_dist($p) { |
| 1974 | - $id_boucle = $p->id_boucle; |
|
| 1975 | - // la lang n'est pas passe de facon automatique par argumenter |
|
| 1976 | - // mais le sera pas recuperer_fond, sauf si etoile=>true est passe |
|
| 1977 | - // en option |
|
| 1978 | - |
|
| 1979 | - $_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $id_boucle, false, false); |
|
| 1980 | - |
|
| 1981 | - // erreur de syntaxe = fond absent |
|
| 1982 | - // (2 messages d'erreur SPIP pour le prix d'un, mais pas d'erreur PHP |
|
| 1983 | - if (!$_contexte) { |
|
| 1984 | - $contexte = []; |
|
| 1985 | - } |
|
| 1986 | - |
|
| 1987 | - if (isset($_contexte['fond'])) { |
|
| 1988 | - $f = $_contexte['fond']; |
|
| 1989 | - // toujours vrai : |
|
| 1990 | - if (preg_match('/^.fond.\s*=>(.*)$/s', $f, $r)) { |
|
| 1991 | - $f = $r[1]; |
|
| 1992 | - unset($_contexte['fond']); |
|
| 1993 | - } else { |
|
| 1994 | - spip_log('compilation de #INCLURE a revoir'); |
|
| 1995 | - } |
|
| 1996 | - |
|
| 1997 | - // #INCLURE{doublons} |
|
| 1998 | - if (isset($_contexte['doublons'])) { |
|
| 1999 | - $_contexte['doublons'] = "'doublons' => \$doublons"; |
|
| 2000 | - } |
|
| 2001 | - |
|
| 2002 | - // Critere d'inclusion {env} (et {self} pour compatibilite ascendante) |
|
| 2003 | - $flag_env = false; |
|
| 2004 | - if (isset($_contexte['env']) or isset($_contexte['self'])) { |
|
| 2005 | - $flag_env = true; |
|
| 2006 | - unset($_contexte['env']); |
|
| 2007 | - } |
|
| 2008 | - |
|
| 2009 | - $_options = []; |
|
| 2010 | - if (isset($_contexte['ajax'])) { |
|
| 2011 | - $_options[] = preg_replace(',=>(.*)$,ims', '=> ($v=(\\1))?$v:true', $_contexte['ajax']); |
|
| 2012 | - unset($_contexte['ajax']); |
|
| 2013 | - } |
|
| 2014 | - if ($p->etoile) { |
|
| 2015 | - $_options[] = "'etoile'=>true"; |
|
| 2016 | - } |
|
| 2017 | - $_options[] = "'compil'=>array(" . memoriser_contexte_compil($p) . ')'; |
|
| 2018 | - |
|
| 2019 | - $_l = 'array(' . join(",\n\t", $_contexte) . ')'; |
|
| 2020 | - if ($flag_env) { |
|
| 2021 | - $_l = "array_merge(\$Pile[0],$_l)"; |
|
| 2022 | - } |
|
| 2023 | - |
|
| 2024 | - $p->code = sprintf(CODE_RECUPERER_FOND, $f, $_l, join(',', $_options), "_request('connect') ?? ''"); |
|
| 2025 | - } elseif (!isset($_contexte[1])) { |
|
| 2026 | - $msg = ['zbug_balise_sans_argument', ['balise' => ' INCLURE']]; |
|
| 2027 | - erreur_squelette($msg, $p); |
|
| 2028 | - } else { |
|
| 2029 | - $p->code = 'charge_scripts(' . $_contexte[1] . ',false)'; |
|
| 2030 | - } |
|
| 2031 | - |
|
| 2032 | - $p->interdire_scripts = false; // la securite est assuree par recuperer_fond |
|
| 2033 | - return $p; |
|
| 1974 | + $id_boucle = $p->id_boucle; |
|
| 1975 | + // la lang n'est pas passe de facon automatique par argumenter |
|
| 1976 | + // mais le sera pas recuperer_fond, sauf si etoile=>true est passe |
|
| 1977 | + // en option |
|
| 1978 | + |
|
| 1979 | + $_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $id_boucle, false, false); |
|
| 1980 | + |
|
| 1981 | + // erreur de syntaxe = fond absent |
|
| 1982 | + // (2 messages d'erreur SPIP pour le prix d'un, mais pas d'erreur PHP |
|
| 1983 | + if (!$_contexte) { |
|
| 1984 | + $contexte = []; |
|
| 1985 | + } |
|
| 1986 | + |
|
| 1987 | + if (isset($_contexte['fond'])) { |
|
| 1988 | + $f = $_contexte['fond']; |
|
| 1989 | + // toujours vrai : |
|
| 1990 | + if (preg_match('/^.fond.\s*=>(.*)$/s', $f, $r)) { |
|
| 1991 | + $f = $r[1]; |
|
| 1992 | + unset($_contexte['fond']); |
|
| 1993 | + } else { |
|
| 1994 | + spip_log('compilation de #INCLURE a revoir'); |
|
| 1995 | + } |
|
| 1996 | + |
|
| 1997 | + // #INCLURE{doublons} |
|
| 1998 | + if (isset($_contexte['doublons'])) { |
|
| 1999 | + $_contexte['doublons'] = "'doublons' => \$doublons"; |
|
| 2000 | + } |
|
| 2001 | + |
|
| 2002 | + // Critere d'inclusion {env} (et {self} pour compatibilite ascendante) |
|
| 2003 | + $flag_env = false; |
|
| 2004 | + if (isset($_contexte['env']) or isset($_contexte['self'])) { |
|
| 2005 | + $flag_env = true; |
|
| 2006 | + unset($_contexte['env']); |
|
| 2007 | + } |
|
| 2008 | + |
|
| 2009 | + $_options = []; |
|
| 2010 | + if (isset($_contexte['ajax'])) { |
|
| 2011 | + $_options[] = preg_replace(',=>(.*)$,ims', '=> ($v=(\\1))?$v:true', $_contexte['ajax']); |
|
| 2012 | + unset($_contexte['ajax']); |
|
| 2013 | + } |
|
| 2014 | + if ($p->etoile) { |
|
| 2015 | + $_options[] = "'etoile'=>true"; |
|
| 2016 | + } |
|
| 2017 | + $_options[] = "'compil'=>array(" . memoriser_contexte_compil($p) . ')'; |
|
| 2018 | + |
|
| 2019 | + $_l = 'array(' . join(",\n\t", $_contexte) . ')'; |
|
| 2020 | + if ($flag_env) { |
|
| 2021 | + $_l = "array_merge(\$Pile[0],$_l)"; |
|
| 2022 | + } |
|
| 2023 | + |
|
| 2024 | + $p->code = sprintf(CODE_RECUPERER_FOND, $f, $_l, join(',', $_options), "_request('connect') ?? ''"); |
|
| 2025 | + } elseif (!isset($_contexte[1])) { |
|
| 2026 | + $msg = ['zbug_balise_sans_argument', ['balise' => ' INCLURE']]; |
|
| 2027 | + erreur_squelette($msg, $p); |
|
| 2028 | + } else { |
|
| 2029 | + $p->code = 'charge_scripts(' . $_contexte[1] . ',false)'; |
|
| 2030 | + } |
|
| 2031 | + |
|
| 2032 | + $p->interdire_scripts = false; // la securite est assuree par recuperer_fond |
|
| 2033 | + return $p; |
|
| 2034 | 2034 | } |
| 2035 | 2035 | |
| 2036 | 2036 | |
@@ -2058,69 +2058,69 @@ discard block |
||
| 2058 | 2058 | **/ |
| 2059 | 2059 | function balise_MODELE_dist($p) { |
| 2060 | 2060 | |
| 2061 | - $_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $p->id_boucle, false); |
|
| 2062 | - |
|
| 2063 | - // erreur de syntaxe = fond absent |
|
| 2064 | - // (2 messages d'erreur SPIP pour le prix d'un, mais pas d'erreur PHP |
|
| 2065 | - if (!$_contexte) { |
|
| 2066 | - $_contexte = []; |
|
| 2067 | - } |
|
| 2068 | - |
|
| 2069 | - if (!isset($_contexte[1])) { |
|
| 2070 | - $msg = ['zbug_balise_sans_argument', ['balise' => ' MODELE']]; |
|
| 2071 | - erreur_squelette($msg, $p); |
|
| 2072 | - } else { |
|
| 2073 | - $nom = $_contexte[1]; |
|
| 2074 | - unset($_contexte[1]); |
|
| 2075 | - |
|
| 2076 | - if (preg_match("/^\s*'[^']*'/s", $nom)) { |
|
| 2077 | - $nom = "'modeles/" . substr($nom, 1); |
|
| 2078 | - } else { |
|
| 2079 | - $nom = "'modeles/' . $nom"; |
|
| 2080 | - } |
|
| 2081 | - |
|
| 2082 | - $flag_env = false; |
|
| 2083 | - if (isset($_contexte['env'])) { |
|
| 2084 | - $flag_env = true; |
|
| 2085 | - unset($_contexte['env']); |
|
| 2086 | - } |
|
| 2087 | - |
|
| 2088 | - // Incoherence dans la syntaxe du contexte. A revoir. |
|
| 2089 | - // Reserver la cle primaire de la boucle courante si elle existe |
|
| 2090 | - if (isset($p->boucles[$p->id_boucle]->primary)) { |
|
| 2091 | - $primary = $p->boucles[$p->id_boucle]->primary; |
|
| 2092 | - if (!strpos($primary, ',')) { |
|
| 2093 | - $id = champ_sql($primary, $p); |
|
| 2094 | - $_contexte[] = "'$primary'=>" . $id; |
|
| 2095 | - $_contexte[] = "'id'=>" . $id; |
|
| 2096 | - } |
|
| 2097 | - } |
|
| 2098 | - $_contexte[] = "'recurs'=>(++\$recurs)"; |
|
| 2099 | - $connect = ''; |
|
| 2100 | - if (isset($p->boucles[$p->id_boucle])) { |
|
| 2101 | - $connect = $p->boucles[$p->id_boucle]->sql_serveur; |
|
| 2102 | - } |
|
| 2103 | - |
|
| 2104 | - $_options = memoriser_contexte_compil($p); |
|
| 2105 | - $_options = "'compil'=>array($_options), 'trim'=>true"; |
|
| 2106 | - if (isset($_contexte['ajax'])) { |
|
| 2107 | - $_options .= ', ' . preg_replace(',=>(.*)$,ims', '=> ($v=(\\1))?$v:true', $_contexte['ajax']); |
|
| 2108 | - unset($_contexte['ajax']); |
|
| 2109 | - } |
|
| 2110 | - |
|
| 2111 | - $_l = 'array(' . join(",\n\t", $_contexte) . ')'; |
|
| 2112 | - if ($flag_env) { |
|
| 2113 | - $_l = "array_merge(\$Pile[0],$_l)"; |
|
| 2114 | - } |
|
| 2115 | - |
|
| 2116 | - $page = sprintf(CODE_RECUPERER_FOND, $nom, $_l, $_options, _q($connect)); |
|
| 2117 | - |
|
| 2118 | - $p->code = "\n\t(((\$recurs=(isset(\$Pile[0]['recurs'])?\$Pile[0]['recurs']:0))>=5)? '' :\n\t$page)\n"; |
|
| 2119 | - |
|
| 2120 | - $p->interdire_scripts = false; // securite assuree par le squelette |
|
| 2121 | - } |
|
| 2122 | - |
|
| 2123 | - return $p; |
|
| 2061 | + $_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $p->id_boucle, false); |
|
| 2062 | + |
|
| 2063 | + // erreur de syntaxe = fond absent |
|
| 2064 | + // (2 messages d'erreur SPIP pour le prix d'un, mais pas d'erreur PHP |
|
| 2065 | + if (!$_contexte) { |
|
| 2066 | + $_contexte = []; |
|
| 2067 | + } |
|
| 2068 | + |
|
| 2069 | + if (!isset($_contexte[1])) { |
|
| 2070 | + $msg = ['zbug_balise_sans_argument', ['balise' => ' MODELE']]; |
|
| 2071 | + erreur_squelette($msg, $p); |
|
| 2072 | + } else { |
|
| 2073 | + $nom = $_contexte[1]; |
|
| 2074 | + unset($_contexte[1]); |
|
| 2075 | + |
|
| 2076 | + if (preg_match("/^\s*'[^']*'/s", $nom)) { |
|
| 2077 | + $nom = "'modeles/" . substr($nom, 1); |
|
| 2078 | + } else { |
|
| 2079 | + $nom = "'modeles/' . $nom"; |
|
| 2080 | + } |
|
| 2081 | + |
|
| 2082 | + $flag_env = false; |
|
| 2083 | + if (isset($_contexte['env'])) { |
|
| 2084 | + $flag_env = true; |
|
| 2085 | + unset($_contexte['env']); |
|
| 2086 | + } |
|
| 2087 | + |
|
| 2088 | + // Incoherence dans la syntaxe du contexte. A revoir. |
|
| 2089 | + // Reserver la cle primaire de la boucle courante si elle existe |
|
| 2090 | + if (isset($p->boucles[$p->id_boucle]->primary)) { |
|
| 2091 | + $primary = $p->boucles[$p->id_boucle]->primary; |
|
| 2092 | + if (!strpos($primary, ',')) { |
|
| 2093 | + $id = champ_sql($primary, $p); |
|
| 2094 | + $_contexte[] = "'$primary'=>" . $id; |
|
| 2095 | + $_contexte[] = "'id'=>" . $id; |
|
| 2096 | + } |
|
| 2097 | + } |
|
| 2098 | + $_contexte[] = "'recurs'=>(++\$recurs)"; |
|
| 2099 | + $connect = ''; |
|
| 2100 | + if (isset($p->boucles[$p->id_boucle])) { |
|
| 2101 | + $connect = $p->boucles[$p->id_boucle]->sql_serveur; |
|
| 2102 | + } |
|
| 2103 | + |
|
| 2104 | + $_options = memoriser_contexte_compil($p); |
|
| 2105 | + $_options = "'compil'=>array($_options), 'trim'=>true"; |
|
| 2106 | + if (isset($_contexte['ajax'])) { |
|
| 2107 | + $_options .= ', ' . preg_replace(',=>(.*)$,ims', '=> ($v=(\\1))?$v:true', $_contexte['ajax']); |
|
| 2108 | + unset($_contexte['ajax']); |
|
| 2109 | + } |
|
| 2110 | + |
|
| 2111 | + $_l = 'array(' . join(",\n\t", $_contexte) . ')'; |
|
| 2112 | + if ($flag_env) { |
|
| 2113 | + $_l = "array_merge(\$Pile[0],$_l)"; |
|
| 2114 | + } |
|
| 2115 | + |
|
| 2116 | + $page = sprintf(CODE_RECUPERER_FOND, $nom, $_l, $_options, _q($connect)); |
|
| 2117 | + |
|
| 2118 | + $p->code = "\n\t(((\$recurs=(isset(\$Pile[0]['recurs'])?\$Pile[0]['recurs']:0))>=5)? '' :\n\t$page)\n"; |
|
| 2119 | + |
|
| 2120 | + $p->interdire_scripts = false; // securite assuree par le squelette |
|
| 2121 | + } |
|
| 2122 | + |
|
| 2123 | + return $p; |
|
| 2124 | 2124 | } |
| 2125 | 2125 | |
| 2126 | 2126 | |
@@ -2144,21 +2144,21 @@ discard block |
||
| 2144 | 2144 | * Pile complétée par le code à générer |
| 2145 | 2145 | **/ |
| 2146 | 2146 | function balise_SET_dist($p) { |
| 2147 | - $_nom = interprete_argument_balise(1, $p); |
|
| 2148 | - $_val = interprete_argument_balise(2, $p); |
|
| 2147 | + $_nom = interprete_argument_balise(1, $p); |
|
| 2148 | + $_val = interprete_argument_balise(2, $p); |
|
| 2149 | 2149 | |
| 2150 | - if (!$_nom or !$_val) { |
|
| 2151 | - $err_b_s_a = ['zbug_balise_sans_argument', ['balise' => 'SET']]; |
|
| 2152 | - erreur_squelette($err_b_s_a, $p); |
|
| 2153 | - } |
|
| 2154 | - // affectation $_zzz inutile, mais permet de contourner un bug OpCode cache sous PHP 5.5.4 |
|
| 2155 | - // cf https://bugs.php.net/bug.php?id=65845 |
|
| 2156 | - else { |
|
| 2157 | - $p->code = "vide(\$Pile['vars'][\$_zzz=(string)$_nom] = $_val)"; |
|
| 2158 | - } |
|
| 2150 | + if (!$_nom or !$_val) { |
|
| 2151 | + $err_b_s_a = ['zbug_balise_sans_argument', ['balise' => 'SET']]; |
|
| 2152 | + erreur_squelette($err_b_s_a, $p); |
|
| 2153 | + } |
|
| 2154 | + // affectation $_zzz inutile, mais permet de contourner un bug OpCode cache sous PHP 5.5.4 |
|
| 2155 | + // cf https://bugs.php.net/bug.php?id=65845 |
|
| 2156 | + else { |
|
| 2157 | + $p->code = "vide(\$Pile['vars'][\$_zzz=(string)$_nom] = $_val)"; |
|
| 2158 | + } |
|
| 2159 | 2159 | |
| 2160 | - $p->interdire_scripts = false; // la balise ne renvoie rien |
|
| 2161 | - return $p; |
|
| 2160 | + $p->interdire_scripts = false; // la balise ne renvoie rien |
|
| 2161 | + return $p; |
|
| 2162 | 2162 | } |
| 2163 | 2163 | |
| 2164 | 2164 | |
@@ -2188,12 +2188,12 @@ discard block |
||
| 2188 | 2188 | * Pile complétée par le code à générer |
| 2189 | 2189 | **/ |
| 2190 | 2190 | function balise_GET_dist($p) { |
| 2191 | - $p->interdire_scripts = false; // le contenu vient de #SET, donc il est de confiance |
|
| 2192 | - if (function_exists('balise_ENV')) { |
|
| 2193 | - return balise_ENV($p, '$Pile["vars"]??[]'); |
|
| 2194 | - } else { |
|
| 2195 | - return balise_ENV_dist($p, '$Pile["vars"]??[]'); |
|
| 2196 | - } |
|
| 2191 | + $p->interdire_scripts = false; // le contenu vient de #SET, donc il est de confiance |
|
| 2192 | + if (function_exists('balise_ENV')) { |
|
| 2193 | + return balise_ENV($p, '$Pile["vars"]??[]'); |
|
| 2194 | + } else { |
|
| 2195 | + return balise_ENV_dist($p, '$Pile["vars"]??[]'); |
|
| 2196 | + } |
|
| 2197 | 2197 | } |
| 2198 | 2198 | |
| 2199 | 2199 | |
@@ -2216,22 +2216,22 @@ discard block |
||
| 2216 | 2216 | * Pile complétée par le code à générer |
| 2217 | 2217 | **/ |
| 2218 | 2218 | function balise_DOUBLONS_dist($p) { |
| 2219 | - if ($type = interprete_argument_balise(1, $p)) { |
|
| 2220 | - if ($famille = interprete_argument_balise(2, $p)) { |
|
| 2221 | - $type .= '.' . $famille; |
|
| 2222 | - } |
|
| 2223 | - $p->code = '(isset($doublons[' . $type . ']) ? $doublons[' . $type . '] : "")'; |
|
| 2224 | - if (!$p->etoile) { |
|
| 2225 | - $p->code = 'array_filter(array_map("intval",explode(",",' |
|
| 2226 | - . $p->code . ')))'; |
|
| 2227 | - } |
|
| 2228 | - } else { |
|
| 2229 | - $p->code = '$doublons'; |
|
| 2230 | - } |
|
| 2219 | + if ($type = interprete_argument_balise(1, $p)) { |
|
| 2220 | + if ($famille = interprete_argument_balise(2, $p)) { |
|
| 2221 | + $type .= '.' . $famille; |
|
| 2222 | + } |
|
| 2223 | + $p->code = '(isset($doublons[' . $type . ']) ? $doublons[' . $type . '] : "")'; |
|
| 2224 | + if (!$p->etoile) { |
|
| 2225 | + $p->code = 'array_filter(array_map("intval",explode(",",' |
|
| 2226 | + . $p->code . ')))'; |
|
| 2227 | + } |
|
| 2228 | + } else { |
|
| 2229 | + $p->code = '$doublons'; |
|
| 2230 | + } |
|
| 2231 | 2231 | |
| 2232 | - $p->interdire_scripts = false; |
|
| 2232 | + $p->interdire_scripts = false; |
|
| 2233 | 2233 | |
| 2234 | - return $p; |
|
| 2234 | + return $p; |
|
| 2235 | 2235 | } |
| 2236 | 2236 | |
| 2237 | 2237 | |
@@ -2254,18 +2254,18 @@ discard block |
||
| 2254 | 2254 | * Pile complétée par le code à générer |
| 2255 | 2255 | **/ |
| 2256 | 2256 | function balise_PIPELINE_dist($p) { |
| 2257 | - $_pipe = interprete_argument_balise(1, $p); |
|
| 2258 | - if (!$_pipe) { |
|
| 2259 | - $err_b_s_a = ['zbug_balise_sans_argument', ['balise' => 'PIPELINE']]; |
|
| 2260 | - erreur_squelette($err_b_s_a, $p); |
|
| 2261 | - } else { |
|
| 2262 | - $_flux = interprete_argument_balise(2, $p); |
|
| 2263 | - $_flux = $_flux ?: "''"; |
|
| 2264 | - $p->code = "pipeline( $_pipe , $_flux )"; |
|
| 2265 | - $p->interdire_scripts = false; |
|
| 2266 | - } |
|
| 2257 | + $_pipe = interprete_argument_balise(1, $p); |
|
| 2258 | + if (!$_pipe) { |
|
| 2259 | + $err_b_s_a = ['zbug_balise_sans_argument', ['balise' => 'PIPELINE']]; |
|
| 2260 | + erreur_squelette($err_b_s_a, $p); |
|
| 2261 | + } else { |
|
| 2262 | + $_flux = interprete_argument_balise(2, $p); |
|
| 2263 | + $_flux = $_flux ?: "''"; |
|
| 2264 | + $p->code = "pipeline( $_pipe , $_flux )"; |
|
| 2265 | + $p->interdire_scripts = false; |
|
| 2266 | + } |
|
| 2267 | 2267 | |
| 2268 | - return $p; |
|
| 2268 | + return $p; |
|
| 2269 | 2269 | } |
| 2270 | 2270 | |
| 2271 | 2271 | |
@@ -2290,10 +2290,10 @@ discard block |
||
| 2290 | 2290 | * Pile complétée par le code à générer |
| 2291 | 2291 | **/ |
| 2292 | 2292 | function balise_EDIT_dist($p) { |
| 2293 | - $p->code = "''"; |
|
| 2294 | - $p->interdire_scripts = false; |
|
| 2293 | + $p->code = "''"; |
|
| 2294 | + $p->interdire_scripts = false; |
|
| 2295 | 2295 | |
| 2296 | - return $p; |
|
| 2296 | + return $p; |
|
| 2297 | 2297 | } |
| 2298 | 2298 | |
| 2299 | 2299 | |
@@ -2316,11 +2316,11 @@ discard block |
||
| 2316 | 2316 | * Pile complétée par le code à générer |
| 2317 | 2317 | **/ |
| 2318 | 2318 | function balise_TOTAL_UNIQUE_dist($p) { |
| 2319 | - $_famille = interprete_argument_balise(1, $p); |
|
| 2320 | - $_famille = $_famille ?: "''"; |
|
| 2321 | - $p->code = "unique('', $_famille, true)"; |
|
| 2319 | + $_famille = interprete_argument_balise(1, $p); |
|
| 2320 | + $_famille = $_famille ?: "''"; |
|
| 2321 | + $p->code = "unique('', $_famille, true)"; |
|
| 2322 | 2322 | |
| 2323 | - return $p; |
|
| 2323 | + return $p; |
|
| 2324 | 2324 | } |
| 2325 | 2325 | |
| 2326 | 2326 | /** |
@@ -2343,19 +2343,19 @@ discard block |
||
| 2343 | 2343 | * Pile complétée par le code à générer |
| 2344 | 2344 | **/ |
| 2345 | 2345 | function balise_ARRAY_dist($p) { |
| 2346 | - $_code = []; |
|
| 2347 | - $n = 1; |
|
| 2348 | - do { |
|
| 2349 | - $_key = interprete_argument_balise($n++, $p); |
|
| 2350 | - $_val = interprete_argument_balise($n++, $p); |
|
| 2351 | - if ($_key and $_val) { |
|
| 2352 | - $_code[] = "$_key => $_val"; |
|
| 2353 | - } |
|
| 2354 | - } while ($_key && $_val); |
|
| 2355 | - $p->code = 'array(' . join(', ', $_code) . ')'; |
|
| 2356 | - $p->interdire_scripts = false; |
|
| 2346 | + $_code = []; |
|
| 2347 | + $n = 1; |
|
| 2348 | + do { |
|
| 2349 | + $_key = interprete_argument_balise($n++, $p); |
|
| 2350 | + $_val = interprete_argument_balise($n++, $p); |
|
| 2351 | + if ($_key and $_val) { |
|
| 2352 | + $_code[] = "$_key => $_val"; |
|
| 2353 | + } |
|
| 2354 | + } while ($_key && $_val); |
|
| 2355 | + $p->code = 'array(' . join(', ', $_code) . ')'; |
|
| 2356 | + $p->interdire_scripts = false; |
|
| 2357 | 2357 | |
| 2358 | - return $p; |
|
| 2358 | + return $p; |
|
| 2359 | 2359 | } |
| 2360 | 2360 | |
| 2361 | 2361 | /** |
@@ -2374,15 +2374,15 @@ discard block |
||
| 2374 | 2374 | * Pile complétée par le code à générer |
| 2375 | 2375 | */ |
| 2376 | 2376 | function balise_LISTE_dist($p) { |
| 2377 | - $_code = []; |
|
| 2378 | - $n = 1; |
|
| 2379 | - while ($_val = interprete_argument_balise($n++, $p)) { |
|
| 2380 | - $_code[] = $_val; |
|
| 2381 | - } |
|
| 2382 | - $p->code = 'array(' . join(', ', $_code) . ')'; |
|
| 2383 | - $p->interdire_scripts = false; |
|
| 2377 | + $_code = []; |
|
| 2378 | + $n = 1; |
|
| 2379 | + while ($_val = interprete_argument_balise($n++, $p)) { |
|
| 2380 | + $_code[] = $_val; |
|
| 2381 | + } |
|
| 2382 | + $p->code = 'array(' . join(', ', $_code) . ')'; |
|
| 2383 | + $p->interdire_scripts = false; |
|
| 2384 | 2384 | |
| 2385 | - return $p; |
|
| 2385 | + return $p; |
|
| 2386 | 2386 | } |
| 2387 | 2387 | |
| 2388 | 2388 | |
@@ -2416,21 +2416,21 @@ discard block |
||
| 2416 | 2416 | * Pile complétée par le code à générer |
| 2417 | 2417 | **/ |
| 2418 | 2418 | function balise_AUTORISER_dist($p) { |
| 2419 | - $_code = []; |
|
| 2420 | - $p->descr['session'] = true; // faire un cache par session |
|
| 2419 | + $_code = []; |
|
| 2420 | + $p->descr['session'] = true; // faire un cache par session |
|
| 2421 | 2421 | |
| 2422 | - $n = 1; |
|
| 2423 | - while ($_v = interprete_argument_balise($n++, $p)) { |
|
| 2424 | - $_code[] = $_v; |
|
| 2425 | - } |
|
| 2422 | + $n = 1; |
|
| 2423 | + while ($_v = interprete_argument_balise($n++, $p)) { |
|
| 2424 | + $_code[] = $_v; |
|
| 2425 | + } |
|
| 2426 | 2426 | |
| 2427 | - $p->code = '((function_exists("autoriser")||include_spip("inc/autoriser"))&&autoriser(' . join( |
|
| 2428 | - ', ', |
|
| 2429 | - $_code |
|
| 2430 | - ) . ')?" ":"")'; |
|
| 2431 | - $p->interdire_scripts = false; |
|
| 2427 | + $p->code = '((function_exists("autoriser")||include_spip("inc/autoriser"))&&autoriser(' . join( |
|
| 2428 | + ', ', |
|
| 2429 | + $_code |
|
| 2430 | + ) . ')?" ":"")'; |
|
| 2431 | + $p->interdire_scripts = false; |
|
| 2432 | 2432 | |
| 2433 | - return $p; |
|
| 2433 | + return $p; |
|
| 2434 | 2434 | } |
| 2435 | 2435 | |
| 2436 | 2436 | |
@@ -2454,15 +2454,15 @@ discard block |
||
| 2454 | 2454 | * Pile complétée par le code à générer |
| 2455 | 2455 | **/ |
| 2456 | 2456 | function balise_PLUGIN_dist($p) { |
| 2457 | - $plugin = interprete_argument_balise(1, $p); |
|
| 2458 | - $plugin = isset($plugin) ? str_replace('\'', '"', $plugin) : '""'; |
|
| 2459 | - $type_info = interprete_argument_balise(2, $p); |
|
| 2460 | - $type_info = isset($type_info) ? str_replace('\'', '"', $type_info) : '"est_actif"'; |
|
| 2457 | + $plugin = interprete_argument_balise(1, $p); |
|
| 2458 | + $plugin = isset($plugin) ? str_replace('\'', '"', $plugin) : '""'; |
|
| 2459 | + $type_info = interprete_argument_balise(2, $p); |
|
| 2460 | + $type_info = isset($type_info) ? str_replace('\'', '"', $type_info) : '"est_actif"'; |
|
| 2461 | 2461 | |
| 2462 | - $f = chercher_filtre('info_plugin'); |
|
| 2463 | - $p->code = $f . '(' . $plugin . ', ' . $type_info . ')'; |
|
| 2462 | + $f = chercher_filtre('info_plugin'); |
|
| 2463 | + $p->code = $f . '(' . $plugin . ', ' . $type_info . ')'; |
|
| 2464 | 2464 | |
| 2465 | - return $p; |
|
| 2465 | + return $p; |
|
| 2466 | 2466 | } |
| 2467 | 2467 | |
| 2468 | 2468 | /** |
@@ -2483,9 +2483,9 @@ discard block |
||
| 2483 | 2483 | * Pile complétée par le code à générer |
| 2484 | 2484 | **/ |
| 2485 | 2485 | function balise_AIDER_dist($p) { |
| 2486 | - $_motif = interprete_argument_balise(1, $p); |
|
| 2487 | - $p->code = "((\$aider=charger_fonction('aide','inc',true))?\$aider($_motif):'')"; |
|
| 2488 | - return $p; |
|
| 2486 | + $_motif = interprete_argument_balise(1, $p); |
|
| 2487 | + $p->code = "((\$aider=charger_fonction('aide','inc',true))?\$aider($_motif):'')"; |
|
| 2488 | + return $p; |
|
| 2489 | 2489 | } |
| 2490 | 2490 | |
| 2491 | 2491 | /** |
@@ -2511,16 +2511,16 @@ discard block |
||
| 2511 | 2511 | * Pile complétée par le code à générer |
| 2512 | 2512 | **/ |
| 2513 | 2513 | function balise_ACTION_FORMULAIRE($p) { |
| 2514 | - if (!$_url = interprete_argument_balise(1, $p)) { |
|
| 2515 | - $_url = "(\$Pile[0]['action'] ?? '')"; |
|
| 2516 | - } |
|
| 2517 | - if (!$_form = interprete_argument_balise(2, $p)) { |
|
| 2518 | - $_form = "(\$Pile[0]['form'] ?? '')"; |
|
| 2519 | - } |
|
| 2520 | - |
|
| 2521 | - // envoyer le nom du formulaire que l'on traite |
|
| 2522 | - // transmettre les eventuels args de la balise formulaire |
|
| 2523 | - $p->code = " '<span class=\"form-hidden\">' . |
|
| 2514 | + if (!$_url = interprete_argument_balise(1, $p)) { |
|
| 2515 | + $_url = "(\$Pile[0]['action'] ?? '')"; |
|
| 2516 | + } |
|
| 2517 | + if (!$_form = interprete_argument_balise(2, $p)) { |
|
| 2518 | + $_form = "(\$Pile[0]['form'] ?? '')"; |
|
| 2519 | + } |
|
| 2520 | + |
|
| 2521 | + // envoyer le nom du formulaire que l'on traite |
|
| 2522 | + // transmettre les eventuels args de la balise formulaire |
|
| 2523 | + $p->code = " '<span class=\"form-hidden\">' . |
|
| 2524 | 2524 | form_hidden($_url) . |
| 2525 | 2525 | '<input name=\'formulaire_action\' type=\'hidden\' |
| 2526 | 2526 | value=\'' . $_form . '\' />' . |
@@ -2531,9 +2531,9 @@ discard block |
||
| 2531 | 2531 | (\$Pile[0]['_hidden'] ?? '') . |
| 2532 | 2532 | '</span>'"; |
| 2533 | 2533 | |
| 2534 | - $p->interdire_scripts = false; |
|
| 2534 | + $p->interdire_scripts = false; |
|
| 2535 | 2535 | |
| 2536 | - return $p; |
|
| 2536 | + return $p; |
|
| 2537 | 2537 | } |
| 2538 | 2538 | |
| 2539 | 2539 | |
@@ -2574,25 +2574,25 @@ discard block |
||
| 2574 | 2574 | */ |
| 2575 | 2575 | function balise_BOUTON_ACTION_dist($p) { |
| 2576 | 2576 | |
| 2577 | - $args = []; |
|
| 2578 | - for ($k = 1; $k <= 6; $k++) { |
|
| 2579 | - $_a = interprete_argument_balise($k, $p); |
|
| 2580 | - if (!$_a) { |
|
| 2581 | - $_a = "''"; |
|
| 2582 | - } |
|
| 2583 | - $args[] = $_a; |
|
| 2584 | - } |
|
| 2585 | - // supprimer les args vides |
|
| 2586 | - while (end($args) == "''" and count($args) > 2) { |
|
| 2587 | - array_pop($args); |
|
| 2588 | - } |
|
| 2589 | - $args = implode(',', $args); |
|
| 2577 | + $args = []; |
|
| 2578 | + for ($k = 1; $k <= 6; $k++) { |
|
| 2579 | + $_a = interprete_argument_balise($k, $p); |
|
| 2580 | + if (!$_a) { |
|
| 2581 | + $_a = "''"; |
|
| 2582 | + } |
|
| 2583 | + $args[] = $_a; |
|
| 2584 | + } |
|
| 2585 | + // supprimer les args vides |
|
| 2586 | + while (end($args) == "''" and count($args) > 2) { |
|
| 2587 | + array_pop($args); |
|
| 2588 | + } |
|
| 2589 | + $args = implode(',', $args); |
|
| 2590 | 2590 | |
| 2591 | - $bouton_action = chercher_filtre('bouton_action'); |
|
| 2592 | - $p->code = "$bouton_action($args)"; |
|
| 2593 | - $p->interdire_scripts = false; |
|
| 2591 | + $bouton_action = chercher_filtre('bouton_action'); |
|
| 2592 | + $p->code = "$bouton_action($args)"; |
|
| 2593 | + $p->interdire_scripts = false; |
|
| 2594 | 2594 | |
| 2595 | - return $p; |
|
| 2595 | + return $p; |
|
| 2596 | 2596 | } |
| 2597 | 2597 | |
| 2598 | 2598 | |
@@ -2611,10 +2611,10 @@ discard block |
||
| 2611 | 2611 | * Pile complétée par le code à générer |
| 2612 | 2612 | */ |
| 2613 | 2613 | function balise_SLOGAN_SITE_SPIP_dist($p) { |
| 2614 | - $p->code = "\$GLOBALS['meta']['slogan_site']"; |
|
| 2614 | + $p->code = "\$GLOBALS['meta']['slogan_site']"; |
|
| 2615 | 2615 | |
| 2616 | - #$p->interdire_scripts = true; |
|
| 2617 | - return $p; |
|
| 2616 | + #$p->interdire_scripts = true; |
|
| 2617 | + return $p; |
|
| 2618 | 2618 | } |
| 2619 | 2619 | |
| 2620 | 2620 | |
@@ -2638,10 +2638,10 @@ discard block |
||
| 2638 | 2638 | * Pile complétée par le code à générer |
| 2639 | 2639 | */ |
| 2640 | 2640 | function balise_HTML5_dist($p) { |
| 2641 | - $p->code = html5_permis() ? "' '" : "''"; |
|
| 2642 | - $p->interdire_scripts = false; |
|
| 2641 | + $p->code = html5_permis() ? "' '" : "''"; |
|
| 2642 | + $p->interdire_scripts = false; |
|
| 2643 | 2643 | |
| 2644 | - return $p; |
|
| 2644 | + return $p; |
|
| 2645 | 2645 | } |
| 2646 | 2646 | |
| 2647 | 2647 | |
@@ -2667,61 +2667,61 @@ discard block |
||
| 2667 | 2667 | * Pile complétée par le code à générer |
| 2668 | 2668 | */ |
| 2669 | 2669 | function balise_TRI_dist($p, $liste = 'true') { |
| 2670 | - $b = index_boucle_mere($p); |
|
| 2671 | - // s'il n'y a pas de nom de boucle, on ne peut pas trier |
|
| 2672 | - if ($b === '') { |
|
| 2673 | - $msg = ['zbug_champ_hors_boucle', ['champ' => zbug_presenter_champ($p)]]; |
|
| 2674 | - erreur_squelette($msg, $p); |
|
| 2675 | - $p->code = "''"; |
|
| 2670 | + $b = index_boucle_mere($p); |
|
| 2671 | + // s'il n'y a pas de nom de boucle, on ne peut pas trier |
|
| 2672 | + if ($b === '') { |
|
| 2673 | + $msg = ['zbug_champ_hors_boucle', ['champ' => zbug_presenter_champ($p)]]; |
|
| 2674 | + erreur_squelette($msg, $p); |
|
| 2675 | + $p->code = "''"; |
|
| 2676 | 2676 | |
| 2677 | - return $p; |
|
| 2678 | - } |
|
| 2679 | - $boucle = $p->boucles[$b]; |
|
| 2677 | + return $p; |
|
| 2678 | + } |
|
| 2679 | + $boucle = $p->boucles[$b]; |
|
| 2680 | 2680 | |
| 2681 | - // s'il n'y a pas de tri_champ, c'est qu'on se trouve |
|
| 2682 | - // dans un boucle recursive ou qu'on a oublie le critere {tri} |
|
| 2683 | - if (!isset($boucle->modificateur['tri_champ'])) { |
|
| 2684 | - $msg = ['zbug_champ_hors_critere', [ |
|
| 2685 | - 'champ' => zbug_presenter_champ($p), |
|
| 2686 | - 'critere' => 'tri' |
|
| 2687 | - ]]; |
|
| 2688 | - erreur_squelette($msg, $p); |
|
| 2689 | - $p->code = "''"; |
|
| 2681 | + // s'il n'y a pas de tri_champ, c'est qu'on se trouve |
|
| 2682 | + // dans un boucle recursive ou qu'on a oublie le critere {tri} |
|
| 2683 | + if (!isset($boucle->modificateur['tri_champ'])) { |
|
| 2684 | + $msg = ['zbug_champ_hors_critere', [ |
|
| 2685 | + 'champ' => zbug_presenter_champ($p), |
|
| 2686 | + 'critere' => 'tri' |
|
| 2687 | + ]]; |
|
| 2688 | + erreur_squelette($msg, $p); |
|
| 2689 | + $p->code = "''"; |
|
| 2690 | 2690 | |
| 2691 | - return $p; |
|
| 2692 | - } |
|
| 2691 | + return $p; |
|
| 2692 | + } |
|
| 2693 | 2693 | |
| 2694 | - $_champ = interprete_argument_balise(1, $p); |
|
| 2695 | - // si pas de champ, renvoyer le critere de tri utilise |
|
| 2696 | - if (!$_champ) { |
|
| 2697 | - $p->code = $boucle->modificateur['tri_champ']; |
|
| 2694 | + $_champ = interprete_argument_balise(1, $p); |
|
| 2695 | + // si pas de champ, renvoyer le critere de tri utilise |
|
| 2696 | + if (!$_champ) { |
|
| 2697 | + $p->code = $boucle->modificateur['tri_champ']; |
|
| 2698 | 2698 | |
| 2699 | - return $p; |
|
| 2700 | - } |
|
| 2701 | - // forcer la jointure si besoin, et si le champ est statique |
|
| 2702 | - if (preg_match(",^'([\w.]+)'$,i", $_champ, $m)) { |
|
| 2703 | - index_pile($b, $m[1], $p->boucles, '', null, true, false); |
|
| 2704 | - } |
|
| 2699 | + return $p; |
|
| 2700 | + } |
|
| 2701 | + // forcer la jointure si besoin, et si le champ est statique |
|
| 2702 | + if (preg_match(",^'([\w.]+)'$,i", $_champ, $m)) { |
|
| 2703 | + index_pile($b, $m[1], $p->boucles, '', null, true, false); |
|
| 2704 | + } |
|
| 2705 | 2705 | |
| 2706 | - $_libelle = interprete_argument_balise(2, $p); |
|
| 2707 | - $_libelle = $_libelle ?: $_champ; |
|
| 2706 | + $_libelle = interprete_argument_balise(2, $p); |
|
| 2707 | + $_libelle = $_libelle ?: $_champ; |
|
| 2708 | 2708 | |
| 2709 | - $_class = interprete_argument_balise(3, $p); |
|
| 2710 | - // si champ = ">" c'est un lien vers le tri croissant : de gauche a droite ==> 1 |
|
| 2711 | - // si champ = "<" c'est un lien vers le tri decroissant : (sens inverse) == -1 |
|
| 2712 | - $_issens = "in_array($_champ,array('>','<'))"; |
|
| 2713 | - $_sens = "(strpos('< >',$_champ)-1)"; |
|
| 2709 | + $_class = interprete_argument_balise(3, $p); |
|
| 2710 | + // si champ = ">" c'est un lien vers le tri croissant : de gauche a droite ==> 1 |
|
| 2711 | + // si champ = "<" c'est un lien vers le tri decroissant : (sens inverse) == -1 |
|
| 2712 | + $_issens = "in_array($_champ,array('>','<'))"; |
|
| 2713 | + $_sens = "(strpos('< >',$_champ)-1)"; |
|
| 2714 | 2714 | |
| 2715 | - $_variable = "((\$s=$_issens)?'sens':'tri')." . $boucle->modificateur['tri_nom']; |
|
| 2716 | - $_url = "parametre_url(self(),$_variable,\$s?$_sens:$_champ)"; |
|
| 2717 | - $_url = "parametre_url($_url,'var_memotri',strncmp(" . $boucle->modificateur['tri_nom'] . ",'session',7)==0?$_variable:'')"; |
|
| 2718 | - $_on = '$s?(' . $boucle->modificateur['tri_sens'] . "==$_sens" . '):(' . $boucle->modificateur['tri_champ'] . "==$_champ)"; |
|
| 2715 | + $_variable = "((\$s=$_issens)?'sens':'tri')." . $boucle->modificateur['tri_nom']; |
|
| 2716 | + $_url = "parametre_url(self(),$_variable,\$s?$_sens:$_champ)"; |
|
| 2717 | + $_url = "parametre_url($_url,'var_memotri',strncmp(" . $boucle->modificateur['tri_nom'] . ",'session',7)==0?$_variable:'')"; |
|
| 2718 | + $_on = '$s?(' . $boucle->modificateur['tri_sens'] . "==$_sens" . '):(' . $boucle->modificateur['tri_champ'] . "==$_champ)"; |
|
| 2719 | 2719 | |
| 2720 | - $p->code = "lien_ou_expose($_url,$_libelle,$_on" . ($_class ? ",$_class" : '') . ')'; |
|
| 2721 | - //$p->code = "''"; |
|
| 2722 | - $p->interdire_scripts = false; |
|
| 2720 | + $p->code = "lien_ou_expose($_url,$_libelle,$_on" . ($_class ? ",$_class" : '') . ')'; |
|
| 2721 | + //$p->code = "''"; |
|
| 2722 | + $p->interdire_scripts = false; |
|
| 2723 | 2723 | |
| 2724 | - return $p; |
|
| 2724 | + return $p; |
|
| 2725 | 2725 | } |
| 2726 | 2726 | |
| 2727 | 2727 | |
@@ -2742,21 +2742,21 @@ discard block |
||
| 2742 | 2742 | * Pile complétée par le code à générer |
| 2743 | 2743 | */ |
| 2744 | 2744 | function balise_SAUTER_dist($p) { |
| 2745 | - $id_boucle = $p->id_boucle; |
|
| 2745 | + $id_boucle = $p->id_boucle; |
|
| 2746 | 2746 | |
| 2747 | - if (empty($p->boucles[$id_boucle])) { |
|
| 2748 | - $msg = ['zbug_champ_hors_boucle', ['champ' => '#SAUTER']]; |
|
| 2749 | - erreur_squelette($msg, $p); |
|
| 2750 | - } else { |
|
| 2751 | - $_saut = interprete_argument_balise(1, $p); |
|
| 2752 | - $_compteur = "\$Numrows['$id_boucle']['compteur_boucle']"; |
|
| 2753 | - $_total = "(\$Numrows['$id_boucle']['total'] ?? null)"; |
|
| 2747 | + if (empty($p->boucles[$id_boucle])) { |
|
| 2748 | + $msg = ['zbug_champ_hors_boucle', ['champ' => '#SAUTER']]; |
|
| 2749 | + erreur_squelette($msg, $p); |
|
| 2750 | + } else { |
|
| 2751 | + $_saut = interprete_argument_balise(1, $p); |
|
| 2752 | + $_compteur = "\$Numrows['$id_boucle']['compteur_boucle']"; |
|
| 2753 | + $_total = "(\$Numrows['$id_boucle']['total'] ?? null)"; |
|
| 2754 | 2754 | |
| 2755 | - $p->code = "vide($_compteur=\$iter->skip($_saut,$_total))"; |
|
| 2756 | - } |
|
| 2757 | - $p->interdire_scripts = false; |
|
| 2755 | + $p->code = "vide($_compteur=\$iter->skip($_saut,$_total))"; |
|
| 2756 | + } |
|
| 2757 | + $p->interdire_scripts = false; |
|
| 2758 | 2758 | |
| 2759 | - return $p; |
|
| 2759 | + return $p; |
|
| 2760 | 2760 | } |
| 2761 | 2761 | |
| 2762 | 2762 | |
@@ -2778,22 +2778,22 @@ discard block |
||
| 2778 | 2778 | * Pile complétée par le code à générer |
| 2779 | 2779 | */ |
| 2780 | 2780 | function balise_PUBLIE_dist($p) { |
| 2781 | - if (!$_type = interprete_argument_balise(1, $p)) { |
|
| 2782 | - $_type = _q($p->type_requete); |
|
| 2783 | - $_id = champ_sql($p->boucles[$p->id_boucle]->primary, $p); |
|
| 2784 | - } else { |
|
| 2785 | - $_id = interprete_argument_balise(2, $p); |
|
| 2786 | - } |
|
| 2781 | + if (!$_type = interprete_argument_balise(1, $p)) { |
|
| 2782 | + $_type = _q($p->type_requete); |
|
| 2783 | + $_id = champ_sql($p->boucles[$p->id_boucle]->primary, $p); |
|
| 2784 | + } else { |
|
| 2785 | + $_id = interprete_argument_balise(2, $p); |
|
| 2786 | + } |
|
| 2787 | 2787 | |
| 2788 | - $connect = ''; |
|
| 2789 | - if (isset($p->boucles[$p->id_boucle])) { |
|
| 2790 | - $connect = $p->boucles[$p->id_boucle]->sql_serveur; |
|
| 2791 | - } |
|
| 2788 | + $connect = ''; |
|
| 2789 | + if (isset($p->boucles[$p->id_boucle])) { |
|
| 2790 | + $connect = $p->boucles[$p->id_boucle]->sql_serveur; |
|
| 2791 | + } |
|
| 2792 | 2792 | |
| 2793 | - $p->code = '(objet_test_si_publie(' . $_type . ',intval(' . $_id . '),' . _q($connect) . ")?' ':'')"; |
|
| 2794 | - $p->interdire_scripts = false; |
|
| 2793 | + $p->code = '(objet_test_si_publie(' . $_type . ',intval(' . $_id . '),' . _q($connect) . ")?' ':'')"; |
|
| 2794 | + $p->interdire_scripts = false; |
|
| 2795 | 2795 | |
| 2796 | - return $p; |
|
| 2796 | + return $p; |
|
| 2797 | 2797 | } |
| 2798 | 2798 | |
| 2799 | 2799 | /** |
@@ -2822,12 +2822,12 @@ discard block |
||
| 2822 | 2822 | * Pile complétée par le code à générer |
| 2823 | 2823 | */ |
| 2824 | 2824 | function balise_PRODUIRE_dist($p) { |
| 2825 | - $balise_inclure = charger_fonction('INCLURE', 'balise'); |
|
| 2826 | - $p = $balise_inclure($p); |
|
| 2825 | + $balise_inclure = charger_fonction('INCLURE', 'balise'); |
|
| 2826 | + $p = $balise_inclure($p); |
|
| 2827 | 2827 | |
| 2828 | - $p->code = str_replace('recuperer_fond(', 'produire_fond_statique(', $p->code); |
|
| 2828 | + $p->code = str_replace('recuperer_fond(', 'produire_fond_statique(', $p->code); |
|
| 2829 | 2829 | |
| 2830 | - return $p; |
|
| 2830 | + return $p; |
|
| 2831 | 2831 | } |
| 2832 | 2832 | |
| 2833 | 2833 | /** |
@@ -2846,13 +2846,13 @@ discard block |
||
| 2846 | 2846 | * Pile complétée par le code à générer |
| 2847 | 2847 | */ |
| 2848 | 2848 | function balise_LARGEUR_ECRAN_dist($p) { |
| 2849 | - $_class = interprete_argument_balise(1, $p); |
|
| 2850 | - if (!$_class) { |
|
| 2851 | - $_class = 'null'; |
|
| 2852 | - } |
|
| 2853 | - $p->code = "(is_string($_class)?vide(\$GLOBALS['largeur_ecran']=$_class):(isset(\$GLOBALS['largeur_ecran'])?\$GLOBALS['largeur_ecran']:''))"; |
|
| 2849 | + $_class = interprete_argument_balise(1, $p); |
|
| 2850 | + if (!$_class) { |
|
| 2851 | + $_class = 'null'; |
|
| 2852 | + } |
|
| 2853 | + $p->code = "(is_string($_class)?vide(\$GLOBALS['largeur_ecran']=$_class):(isset(\$GLOBALS['largeur_ecran'])?\$GLOBALS['largeur_ecran']:''))"; |
|
| 2854 | 2854 | |
| 2855 | - return $p; |
|
| 2855 | + return $p; |
|
| 2856 | 2856 | } |
| 2857 | 2857 | |
| 2858 | 2858 | |
@@ -2868,14 +2868,14 @@ discard block |
||
| 2868 | 2868 | * Pile complétée par le code à générer |
| 2869 | 2869 | **/ |
| 2870 | 2870 | function balise_CONST_dist($p) { |
| 2871 | - $_const = interprete_argument_balise(1, $p); |
|
| 2872 | - if (!strlen($_const)) { |
|
| 2873 | - $p->code = "''"; |
|
| 2874 | - } |
|
| 2875 | - else { |
|
| 2876 | - $p->code = "(defined($_const)?constant($_const):'')"; |
|
| 2877 | - } |
|
| 2878 | - $p->interdire_scripts = false; |
|
| 2879 | - |
|
| 2880 | - return $p; |
|
| 2871 | + $_const = interprete_argument_balise(1, $p); |
|
| 2872 | + if (!strlen($_const)) { |
|
| 2873 | + $p->code = "''"; |
|
| 2874 | + } |
|
| 2875 | + else { |
|
| 2876 | + $p->code = "(defined($_const)?constant($_const):'')"; |
|
| 2877 | + } |
|
| 2878 | + $p->interdire_scripts = false; |
|
| 2879 | + |
|
| 2880 | + return $p; |
|
| 2881 | 2881 | } |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | **/ |
| 20 | 20 | |
| 21 | 21 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 22 | - return; |
|
| 22 | + return; |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | |
@@ -33,16 +33,16 @@ discard block |
||
| 33 | 33 | * @return array|bool|null |
| 34 | 34 | */ |
| 35 | 35 | function quete_virtuel($id_article, $connect) { |
| 36 | - return sql_getfetsel( |
|
| 37 | - 'virtuel', |
|
| 38 | - 'spip_articles', |
|
| 39 | - ['id_article=' . intval($id_article), "statut='publie'"], |
|
| 40 | - '', |
|
| 41 | - '', |
|
| 42 | - '', |
|
| 43 | - '', |
|
| 44 | - $connect |
|
| 45 | - ); |
|
| 36 | + return sql_getfetsel( |
|
| 37 | + 'virtuel', |
|
| 38 | + 'spip_articles', |
|
| 39 | + ['id_article=' . intval($id_article), "statut='publie'"], |
|
| 40 | + '', |
|
| 41 | + '', |
|
| 42 | + '', |
|
| 43 | + '', |
|
| 44 | + $connect |
|
| 45 | + ); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -57,41 +57,41 @@ discard block |
||
| 57 | 57 | * @return array |
| 58 | 58 | */ |
| 59 | 59 | function quete_parent_lang($table, $id, string $connect = '') { |
| 60 | - static $cache_quete = []; |
|
| 61 | - |
|
| 62 | - if (!isset($cache_quete[$connect][$table][$id])) { |
|
| 63 | - if (!isset($cache_quete[$connect][$table]['_select'])) { |
|
| 64 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 65 | - if ( |
|
| 66 | - !$desc = $trouver_table( |
|
| 67 | - $table, |
|
| 68 | - $connect |
|
| 69 | - ) or !isset($desc['field']['id_rubrique']) |
|
| 70 | - ) { |
|
| 71 | - // pas de parent rubrique, on passe |
|
| 72 | - $cache_quete[$connect][$table]['_select'] = false; |
|
| 73 | - } else { |
|
| 74 | - $select = ($table == 'spip_rubriques' ? 'id_parent' : 'id_rubrique'); |
|
| 75 | - $select .= isset($desc['field']['lang']) ? ', lang' : ''; |
|
| 76 | - $cache_quete[$connect][$table]['_select'] = $select; |
|
| 77 | - $cache_quete[$connect][$table]['_id'] = id_table_objet(objet_type($table)); |
|
| 78 | - } |
|
| 79 | - } |
|
| 80 | - if ($cache_quete[$connect][$table]['_select']) { |
|
| 81 | - $cache_quete[$connect][$table][$id] = sql_fetsel( |
|
| 82 | - $cache_quete[$connect][$table]['_select'], |
|
| 83 | - $table, |
|
| 84 | - $cache_quete[$connect][$table]['_id'] . '=' . intval($id), |
|
| 85 | - '', |
|
| 86 | - '', |
|
| 87 | - '', |
|
| 88 | - '', |
|
| 89 | - $connect |
|
| 90 | - ); |
|
| 91 | - } |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - return $cache_quete[$connect][$table][$id] ?? null; |
|
| 60 | + static $cache_quete = []; |
|
| 61 | + |
|
| 62 | + if (!isset($cache_quete[$connect][$table][$id])) { |
|
| 63 | + if (!isset($cache_quete[$connect][$table]['_select'])) { |
|
| 64 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 65 | + if ( |
|
| 66 | + !$desc = $trouver_table( |
|
| 67 | + $table, |
|
| 68 | + $connect |
|
| 69 | + ) or !isset($desc['field']['id_rubrique']) |
|
| 70 | + ) { |
|
| 71 | + // pas de parent rubrique, on passe |
|
| 72 | + $cache_quete[$connect][$table]['_select'] = false; |
|
| 73 | + } else { |
|
| 74 | + $select = ($table == 'spip_rubriques' ? 'id_parent' : 'id_rubrique'); |
|
| 75 | + $select .= isset($desc['field']['lang']) ? ', lang' : ''; |
|
| 76 | + $cache_quete[$connect][$table]['_select'] = $select; |
|
| 77 | + $cache_quete[$connect][$table]['_id'] = id_table_objet(objet_type($table)); |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | + if ($cache_quete[$connect][$table]['_select']) { |
|
| 81 | + $cache_quete[$connect][$table][$id] = sql_fetsel( |
|
| 82 | + $cache_quete[$connect][$table]['_select'], |
|
| 83 | + $table, |
|
| 84 | + $cache_quete[$connect][$table]['_id'] . '=' . intval($id), |
|
| 85 | + '', |
|
| 86 | + '', |
|
| 87 | + '', |
|
| 88 | + '', |
|
| 89 | + $connect |
|
| 90 | + ); |
|
| 91 | + } |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + return $cache_quete[$connect][$table][$id] ?? null; |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | |
@@ -108,11 +108,11 @@ discard block |
||
| 108 | 108 | * @return int |
| 109 | 109 | */ |
| 110 | 110 | function quete_parent($id_rubrique, string $connect = '') { |
| 111 | - if (!$id_rubrique = intval($id_rubrique)) { |
|
| 112 | - return 0; |
|
| 113 | - } |
|
| 114 | - $id_parent = quete_parent_lang('spip_rubriques', $id_rubrique, $connect); |
|
| 115 | - return $id_parent ? $id_parent['id_parent'] : 0; |
|
| 111 | + if (!$id_rubrique = intval($id_rubrique)) { |
|
| 112 | + return 0; |
|
| 113 | + } |
|
| 114 | + $id_parent = quete_parent_lang('spip_rubriques', $id_rubrique, $connect); |
|
| 115 | + return $id_parent ? $id_parent['id_parent'] : 0; |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /** |
@@ -128,9 +128,9 @@ discard block |
||
| 128 | 128 | * @return int |
| 129 | 129 | */ |
| 130 | 130 | function quete_rubrique($id_article, $serveur) { |
| 131 | - $id_parent = quete_parent_lang('spip_articles', $id_article, $serveur); |
|
| 131 | + $id_parent = quete_parent_lang('spip_articles', $id_article, $serveur); |
|
| 132 | 132 | |
| 133 | - return $id_parent['id_rubrique']; |
|
| 133 | + return $id_parent['id_rubrique']; |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | |
@@ -144,13 +144,13 @@ discard block |
||
| 144 | 144 | * @return int |
| 145 | 145 | */ |
| 146 | 146 | function quete_profondeur($id, string $connect = '') { |
| 147 | - $n = 0; |
|
| 148 | - while ($id) { |
|
| 149 | - $n++; |
|
| 150 | - $id = quete_parent($id, $connect); |
|
| 151 | - } |
|
| 147 | + $n = 0; |
|
| 148 | + while ($id) { |
|
| 149 | + $n++; |
|
| 150 | + $id = quete_parent($id, $connect); |
|
| 151 | + } |
|
| 152 | 152 | |
| 153 | - return $n; |
|
| 153 | + return $n; |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | |
@@ -166,15 +166,15 @@ discard block |
||
| 166 | 166 | * Morceau de la requête SQL testant la date |
| 167 | 167 | */ |
| 168 | 168 | function quete_condition_postdates($champ_date, $serveur = '', $ignore_previsu = false) { |
| 169 | - if (defined('_VAR_PREVIEW') and _VAR_PREVIEW and !$ignore_previsu) { |
|
| 170 | - return '1=1'; |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - return |
|
| 174 | - (isset($GLOBALS['meta']['date_prochain_postdate']) |
|
| 175 | - and $GLOBALS['meta']['date_prochain_postdate'] > time()) |
|
| 176 | - ? "$champ_date<" . sql_quote(date('Y-m-d H:i:s', $GLOBALS['meta']['date_prochain_postdate']), $serveur) |
|
| 177 | - : '1=1'; |
|
| 169 | + if (defined('_VAR_PREVIEW') and _VAR_PREVIEW and !$ignore_previsu) { |
|
| 170 | + return '1=1'; |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + return |
|
| 174 | + (isset($GLOBALS['meta']['date_prochain_postdate']) |
|
| 175 | + and $GLOBALS['meta']['date_prochain_postdate'] > time()) |
|
| 176 | + ? "$champ_date<" . sql_quote(date('Y-m-d H:i:s', $GLOBALS['meta']['date_prochain_postdate']), $serveur) |
|
| 177 | + : '1=1'; |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | |
@@ -194,101 +194,101 @@ discard block |
||
| 194 | 194 | * @return array|string |
| 195 | 195 | */ |
| 196 | 196 | function quete_condition_statut($mstatut, $previsu, $publie, $serveur = '', $ignore_previsu = false) { |
| 197 | - static $cond = []; |
|
| 198 | - $key = func_get_args(); |
|
| 199 | - $key = implode('-', $key); |
|
| 200 | - if (isset($cond[$key])) { |
|
| 201 | - return $cond[$key]; |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - $liste_statuts = $publie; |
|
| 205 | - if (defined('_VAR_PREVIEW') and _VAR_PREVIEW and !$ignore_previsu) { |
|
| 206 | - $liste_statuts = $previsu; |
|
| 207 | - } |
|
| 208 | - $not = false; |
|
| 209 | - if (strncmp($liste_statuts, '!', 1) == 0) { |
|
| 210 | - $not = true; |
|
| 211 | - $liste_statuts = substr($liste_statuts, 1); |
|
| 212 | - } |
|
| 213 | - // '' => ne rien afficher, '!'=> ne rien filtrer |
|
| 214 | - if (!strlen($liste_statuts)) { |
|
| 215 | - return $cond[$key] = ($not ? '1=1' : '0=1'); |
|
| 216 | - } |
|
| 217 | - |
|
| 218 | - $liste_statuts = explode(',', $liste_statuts); |
|
| 219 | - $where = []; |
|
| 220 | - foreach ($liste_statuts as $k => $v) { |
|
| 221 | - // filtrage /auteur pour limiter les objets d'un statut (prepa en general) |
|
| 222 | - // a ceux de l'auteur identifie |
|
| 223 | - if (strpos($v, '/') !== false) { |
|
| 224 | - $v = explode('/', $v); |
|
| 225 | - $filtre = end($v); |
|
| 226 | - $v = reset($v); |
|
| 227 | - $v = preg_replace(',\W,', '', $v); |
|
| 228 | - if ( |
|
| 229 | - $filtre == 'auteur' |
|
| 230 | - and (strpos($mstatut, '.') !== false) |
|
| 231 | - and $objet = explode('.', $mstatut) |
|
| 232 | - and $id_table = reset($objet) |
|
| 233 | - and $objet = objet_type($id_table) |
|
| 234 | - ) { |
|
| 235 | - $w = "$mstatut<>" . sql_quote($v); |
|
| 236 | - |
|
| 237 | - // retrouver l’id_auteur qui a filé un lien de prévisu éventuellement, |
|
| 238 | - // sinon l’auteur en session |
|
| 239 | - include_spip('inc/securiser_action'); |
|
| 240 | - if ($desc = decrire_token_previsu()) { |
|
| 241 | - $id_auteur = $desc['id_auteur']; |
|
| 242 | - } elseif (isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 243 | - $id_auteur = intval($GLOBALS['visiteur_session']['id_auteur']); |
|
| 244 | - } else { |
|
| 245 | - $id_auteur = null; |
|
| 246 | - } |
|
| 247 | - |
|
| 248 | - // dans ce cas (admin en general), pas de filtrage sur ce statut |
|
| 249 | - if (!autoriser('previsualiser' . $v, $objet, '', $id_auteur)) { |
|
| 250 | - // si pas d'auteur identifie pas de sous-requete car pas d'article qui matche |
|
| 251 | - if (!$id_auteur) { |
|
| 252 | - $where[] = $w; |
|
| 253 | - } else { |
|
| 254 | - $primary = id_table_objet($objet); |
|
| 255 | - $where[] = "($w OR $id_table.$primary IN (" . sql_get_select( |
|
| 256 | - 'ssss.id_objet', |
|
| 257 | - 'spip_auteurs_liens AS ssss', |
|
| 258 | - 'ssss.objet=' . sql_quote($objet) . ' AND ssss.id_auteur=' . intval($id_auteur), |
|
| 259 | - '', |
|
| 260 | - '', |
|
| 261 | - '', |
|
| 262 | - '', |
|
| 263 | - $serveur |
|
| 264 | - ) . '))'; |
|
| 265 | - } |
|
| 266 | - } |
|
| 267 | - } // ignorer ce statut si on ne sait pas comment le filtrer |
|
| 268 | - else { |
|
| 269 | - $v = ''; |
|
| 270 | - } |
|
| 271 | - } |
|
| 272 | - // securite |
|
| 273 | - $liste_statuts[$k] = preg_replace(',\W,', '', $v); |
|
| 274 | - } |
|
| 275 | - $liste_statuts = array_filter($liste_statuts); |
|
| 276 | - if (count($liste_statuts) == 1) { |
|
| 277 | - $where[] = ['=', $mstatut, sql_quote(reset($liste_statuts), $serveur)]; |
|
| 278 | - } else { |
|
| 279 | - $where[] = sql_in($mstatut, $liste_statuts, $not, $serveur); |
|
| 280 | - } |
|
| 281 | - |
|
| 282 | - while (count($where) > 1) { |
|
| 283 | - $and = ['AND', array_pop($where), array_pop($where)]; |
|
| 284 | - $where[] = $and; |
|
| 285 | - } |
|
| 286 | - $cond[$key] = reset($where); |
|
| 287 | - if ($not) { |
|
| 288 | - $cond[$key] = ['NOT', $cond[$key]]; |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - return $cond[$key]; |
|
| 197 | + static $cond = []; |
|
| 198 | + $key = func_get_args(); |
|
| 199 | + $key = implode('-', $key); |
|
| 200 | + if (isset($cond[$key])) { |
|
| 201 | + return $cond[$key]; |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + $liste_statuts = $publie; |
|
| 205 | + if (defined('_VAR_PREVIEW') and _VAR_PREVIEW and !$ignore_previsu) { |
|
| 206 | + $liste_statuts = $previsu; |
|
| 207 | + } |
|
| 208 | + $not = false; |
|
| 209 | + if (strncmp($liste_statuts, '!', 1) == 0) { |
|
| 210 | + $not = true; |
|
| 211 | + $liste_statuts = substr($liste_statuts, 1); |
|
| 212 | + } |
|
| 213 | + // '' => ne rien afficher, '!'=> ne rien filtrer |
|
| 214 | + if (!strlen($liste_statuts)) { |
|
| 215 | + return $cond[$key] = ($not ? '1=1' : '0=1'); |
|
| 216 | + } |
|
| 217 | + |
|
| 218 | + $liste_statuts = explode(',', $liste_statuts); |
|
| 219 | + $where = []; |
|
| 220 | + foreach ($liste_statuts as $k => $v) { |
|
| 221 | + // filtrage /auteur pour limiter les objets d'un statut (prepa en general) |
|
| 222 | + // a ceux de l'auteur identifie |
|
| 223 | + if (strpos($v, '/') !== false) { |
|
| 224 | + $v = explode('/', $v); |
|
| 225 | + $filtre = end($v); |
|
| 226 | + $v = reset($v); |
|
| 227 | + $v = preg_replace(',\W,', '', $v); |
|
| 228 | + if ( |
|
| 229 | + $filtre == 'auteur' |
|
| 230 | + and (strpos($mstatut, '.') !== false) |
|
| 231 | + and $objet = explode('.', $mstatut) |
|
| 232 | + and $id_table = reset($objet) |
|
| 233 | + and $objet = objet_type($id_table) |
|
| 234 | + ) { |
|
| 235 | + $w = "$mstatut<>" . sql_quote($v); |
|
| 236 | + |
|
| 237 | + // retrouver l’id_auteur qui a filé un lien de prévisu éventuellement, |
|
| 238 | + // sinon l’auteur en session |
|
| 239 | + include_spip('inc/securiser_action'); |
|
| 240 | + if ($desc = decrire_token_previsu()) { |
|
| 241 | + $id_auteur = $desc['id_auteur']; |
|
| 242 | + } elseif (isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 243 | + $id_auteur = intval($GLOBALS['visiteur_session']['id_auteur']); |
|
| 244 | + } else { |
|
| 245 | + $id_auteur = null; |
|
| 246 | + } |
|
| 247 | + |
|
| 248 | + // dans ce cas (admin en general), pas de filtrage sur ce statut |
|
| 249 | + if (!autoriser('previsualiser' . $v, $objet, '', $id_auteur)) { |
|
| 250 | + // si pas d'auteur identifie pas de sous-requete car pas d'article qui matche |
|
| 251 | + if (!$id_auteur) { |
|
| 252 | + $where[] = $w; |
|
| 253 | + } else { |
|
| 254 | + $primary = id_table_objet($objet); |
|
| 255 | + $where[] = "($w OR $id_table.$primary IN (" . sql_get_select( |
|
| 256 | + 'ssss.id_objet', |
|
| 257 | + 'spip_auteurs_liens AS ssss', |
|
| 258 | + 'ssss.objet=' . sql_quote($objet) . ' AND ssss.id_auteur=' . intval($id_auteur), |
|
| 259 | + '', |
|
| 260 | + '', |
|
| 261 | + '', |
|
| 262 | + '', |
|
| 263 | + $serveur |
|
| 264 | + ) . '))'; |
|
| 265 | + } |
|
| 266 | + } |
|
| 267 | + } // ignorer ce statut si on ne sait pas comment le filtrer |
|
| 268 | + else { |
|
| 269 | + $v = ''; |
|
| 270 | + } |
|
| 271 | + } |
|
| 272 | + // securite |
|
| 273 | + $liste_statuts[$k] = preg_replace(',\W,', '', $v); |
|
| 274 | + } |
|
| 275 | + $liste_statuts = array_filter($liste_statuts); |
|
| 276 | + if (count($liste_statuts) == 1) { |
|
| 277 | + $where[] = ['=', $mstatut, sql_quote(reset($liste_statuts), $serveur)]; |
|
| 278 | + } else { |
|
| 279 | + $where[] = sql_in($mstatut, $liste_statuts, $not, $serveur); |
|
| 280 | + } |
|
| 281 | + |
|
| 282 | + while (count($where) > 1) { |
|
| 283 | + $and = ['AND', array_pop($where), array_pop($where)]; |
|
| 284 | + $where[] = $and; |
|
| 285 | + } |
|
| 286 | + $cond[$key] = reset($where); |
|
| 287 | + if ($not) { |
|
| 288 | + $cond[$key] = ['NOT', $cond[$key]]; |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + return $cond[$key]; |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | /** |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | * @return array|bool|null |
| 300 | 300 | */ |
| 301 | 301 | function quete_fichier($id_document, $serveur = '') { |
| 302 | - return sql_getfetsel('fichier', 'spip_documents', ('id_document=' . intval($id_document)), '', [], '', '', $serveur); |
|
| 302 | + return sql_getfetsel('fichier', 'spip_documents', ('id_document=' . intval($id_document)), '', [], '', '', $serveur); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | /** |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | * @return array|bool |
| 311 | 311 | */ |
| 312 | 312 | function quete_document($id_document, $serveur = '') { |
| 313 | - return sql_fetsel('*', 'spip_documents', ('id_document=' . intval($id_document)), '', [], '', '', $serveur); |
|
| 313 | + return sql_fetsel('*', 'spip_documents', ('id_document=' . intval($id_document)), '', [], '', '', $serveur); |
|
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | /** |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | * @return array|bool|null |
| 322 | 322 | */ |
| 323 | 323 | function quete_meta($nom, $serveur) { |
| 324 | - return sql_getfetsel('valeur', 'spip_meta', 'nom=' . sql_quote($nom), '', '', '', '', $serveur); |
|
| 324 | + return sql_getfetsel('valeur', 'spip_meta', 'nom=' . sql_quote($nom), '', '', '', '', $serveur); |
|
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | /** |
@@ -347,66 +347,66 @@ discard block |
||
| 347 | 347 | * Retourne soit un tableau, soit le chemin du fichier. |
| 348 | 348 | */ |
| 349 | 349 | function quete_logo($cle_objet, $onoff, $id, $id_rubrique, $flag) { |
| 350 | - include_spip('base/objets'); |
|
| 351 | - $nom = strtolower($onoff); |
|
| 352 | - |
|
| 353 | - $cle_objet = id_table_objet($cle_objet); |
|
| 354 | - |
|
| 355 | - while (1) { |
|
| 356 | - $objet = objet_type($cle_objet); |
|
| 357 | - |
|
| 358 | - $on = quete_logo_objet($id, $objet, $nom); |
|
| 359 | - |
|
| 360 | - if ($on) { |
|
| 361 | - if ($flag) { |
|
| 362 | - return basename($on['chemin']); |
|
| 363 | - } else { |
|
| 364 | - $taille = @spip_getimagesize($on['chemin']); |
|
| 365 | - |
|
| 366 | - // Si on a déjà demandé un survol directement ($onoff = off) |
|
| 367 | - // ou qu'on a demandé uniquement le normal ($onoff = on) |
|
| 368 | - // alors on ne cherche pas du tout le survol ici |
|
| 369 | - if ($onoff != 'ON') { |
|
| 370 | - $off = ''; |
|
| 371 | - } else { |
|
| 372 | - // Sinon, c'est qu'on demande normal ET survol à la fois, donc on cherche maintenant le survol |
|
| 373 | - $off = quete_logo_objet($id, $objet, 'off'); |
|
| 374 | - } |
|
| 375 | - |
|
| 376 | - // on retourne une url du type IMG/artonXX?timestamp |
|
| 377 | - // qui permet de distinguer le changement de logo |
|
| 378 | - // et placer un expire sur le dossier IMG/ |
|
| 379 | - $res = [ |
|
| 380 | - $on['chemin'] . ($on['timestamp'] ? "?{$on['timestamp']}" : ''), |
|
| 381 | - ($off ? $off['chemin'] . ($off['timestamp'] ? "?{$off['timestamp']}" : '') : ''), |
|
| 382 | - (!$taille ? '' : (' ' . $taille[3])) |
|
| 383 | - ]; |
|
| 384 | - $res['src'] = $res[0]; |
|
| 385 | - $res['logo_on'] = $res[0]; |
|
| 386 | - $res['logo_off'] = $res[1]; |
|
| 387 | - $res['width'] = ($taille ? $taille[0] : ''); |
|
| 388 | - $res['height'] = ($taille ? $taille[1] : ''); |
|
| 389 | - |
|
| 390 | - return $res; |
|
| 391 | - } |
|
| 392 | - } else { |
|
| 393 | - if (defined('_LOGO_RUBRIQUE_DESACTIVER_HERITAGE')) { |
|
| 394 | - return ''; |
|
| 395 | - } else { |
|
| 396 | - if ($id_rubrique) { |
|
| 397 | - $cle_objet = 'id_rubrique'; |
|
| 398 | - $id = $id_rubrique; |
|
| 399 | - $id_rubrique = 0; |
|
| 400 | - } else { |
|
| 401 | - if ($id and $cle_objet == 'id_rubrique') { |
|
| 402 | - $id = quete_parent($id); |
|
| 403 | - } else { |
|
| 404 | - return ''; |
|
| 405 | - } |
|
| 406 | - } |
|
| 407 | - } |
|
| 408 | - } |
|
| 409 | - } |
|
| 350 | + include_spip('base/objets'); |
|
| 351 | + $nom = strtolower($onoff); |
|
| 352 | + |
|
| 353 | + $cle_objet = id_table_objet($cle_objet); |
|
| 354 | + |
|
| 355 | + while (1) { |
|
| 356 | + $objet = objet_type($cle_objet); |
|
| 357 | + |
|
| 358 | + $on = quete_logo_objet($id, $objet, $nom); |
|
| 359 | + |
|
| 360 | + if ($on) { |
|
| 361 | + if ($flag) { |
|
| 362 | + return basename($on['chemin']); |
|
| 363 | + } else { |
|
| 364 | + $taille = @spip_getimagesize($on['chemin']); |
|
| 365 | + |
|
| 366 | + // Si on a déjà demandé un survol directement ($onoff = off) |
|
| 367 | + // ou qu'on a demandé uniquement le normal ($onoff = on) |
|
| 368 | + // alors on ne cherche pas du tout le survol ici |
|
| 369 | + if ($onoff != 'ON') { |
|
| 370 | + $off = ''; |
|
| 371 | + } else { |
|
| 372 | + // Sinon, c'est qu'on demande normal ET survol à la fois, donc on cherche maintenant le survol |
|
| 373 | + $off = quete_logo_objet($id, $objet, 'off'); |
|
| 374 | + } |
|
| 375 | + |
|
| 376 | + // on retourne une url du type IMG/artonXX?timestamp |
|
| 377 | + // qui permet de distinguer le changement de logo |
|
| 378 | + // et placer un expire sur le dossier IMG/ |
|
| 379 | + $res = [ |
|
| 380 | + $on['chemin'] . ($on['timestamp'] ? "?{$on['timestamp']}" : ''), |
|
| 381 | + ($off ? $off['chemin'] . ($off['timestamp'] ? "?{$off['timestamp']}" : '') : ''), |
|
| 382 | + (!$taille ? '' : (' ' . $taille[3])) |
|
| 383 | + ]; |
|
| 384 | + $res['src'] = $res[0]; |
|
| 385 | + $res['logo_on'] = $res[0]; |
|
| 386 | + $res['logo_off'] = $res[1]; |
|
| 387 | + $res['width'] = ($taille ? $taille[0] : ''); |
|
| 388 | + $res['height'] = ($taille ? $taille[1] : ''); |
|
| 389 | + |
|
| 390 | + return $res; |
|
| 391 | + } |
|
| 392 | + } else { |
|
| 393 | + if (defined('_LOGO_RUBRIQUE_DESACTIVER_HERITAGE')) { |
|
| 394 | + return ''; |
|
| 395 | + } else { |
|
| 396 | + if ($id_rubrique) { |
|
| 397 | + $cle_objet = 'id_rubrique'; |
|
| 398 | + $id = $id_rubrique; |
|
| 399 | + $id_rubrique = 0; |
|
| 400 | + } else { |
|
| 401 | + if ($id and $cle_objet == 'id_rubrique') { |
|
| 402 | + $id = quete_parent($id); |
|
| 403 | + } else { |
|
| 404 | + return ''; |
|
| 405 | + } |
|
| 406 | + } |
|
| 407 | + } |
|
| 408 | + } |
|
| 409 | + } |
|
| 410 | 410 | } |
| 411 | 411 | |
| 412 | 412 | /** |
@@ -420,37 +420,37 @@ discard block |
||
| 420 | 420 | * "on" ou "off" suivant le logo normal ou survol |
| 421 | 421 | **/ |
| 422 | 422 | function quete_logo_objet($id_objet, $objet, $mode) { |
| 423 | - static $chercher_logo; |
|
| 424 | - if (is_null($chercher_logo)) { |
|
| 425 | - $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 426 | - } |
|
| 427 | - $cle_objet = id_table_objet($objet); |
|
| 428 | - |
|
| 429 | - // On cherche pas la méthode classique |
|
| 430 | - $infos_logo = $chercher_logo($id_objet, $cle_objet, $mode); |
|
| 431 | - // Si la méthode classique a trouvé quelque chose, on utilise le nouveau format |
|
| 432 | - if (!empty($infos_logo)) { |
|
| 433 | - $infos_logo = [ |
|
| 434 | - 'chemin' => $infos_logo[0], |
|
| 435 | - 'timestamp' => $infos_logo[4], |
|
| 436 | - ]; |
|
| 437 | - } |
|
| 438 | - |
|
| 439 | - // On passe cette recherche de logo dans un pipeline |
|
| 440 | - $infos_logo = pipeline( |
|
| 441 | - 'quete_logo_objet', |
|
| 442 | - [ |
|
| 443 | - 'args' => [ |
|
| 444 | - 'id_objet' => $id_objet, |
|
| 445 | - 'objet' => $objet, |
|
| 446 | - 'cle_objet' => $cle_objet, |
|
| 447 | - 'mode' => $mode, |
|
| 448 | - ], |
|
| 449 | - 'data' => $infos_logo, |
|
| 450 | - ] |
|
| 451 | - ); |
|
| 452 | - |
|
| 453 | - return $infos_logo; |
|
| 423 | + static $chercher_logo; |
|
| 424 | + if (is_null($chercher_logo)) { |
|
| 425 | + $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 426 | + } |
|
| 427 | + $cle_objet = id_table_objet($objet); |
|
| 428 | + |
|
| 429 | + // On cherche pas la méthode classique |
|
| 430 | + $infos_logo = $chercher_logo($id_objet, $cle_objet, $mode); |
|
| 431 | + // Si la méthode classique a trouvé quelque chose, on utilise le nouveau format |
|
| 432 | + if (!empty($infos_logo)) { |
|
| 433 | + $infos_logo = [ |
|
| 434 | + 'chemin' => $infos_logo[0], |
|
| 435 | + 'timestamp' => $infos_logo[4], |
|
| 436 | + ]; |
|
| 437 | + } |
|
| 438 | + |
|
| 439 | + // On passe cette recherche de logo dans un pipeline |
|
| 440 | + $infos_logo = pipeline( |
|
| 441 | + 'quete_logo_objet', |
|
| 442 | + [ |
|
| 443 | + 'args' => [ |
|
| 444 | + 'id_objet' => $id_objet, |
|
| 445 | + 'objet' => $objet, |
|
| 446 | + 'cle_objet' => $cle_objet, |
|
| 447 | + 'mode' => $mode, |
|
| 448 | + ], |
|
| 449 | + 'data' => $infos_logo, |
|
| 450 | + ] |
|
| 451 | + ); |
|
| 452 | + |
|
| 453 | + return $infos_logo; |
|
| 454 | 454 | } |
| 455 | 455 | |
| 456 | 456 | /** |
@@ -463,25 +463,25 @@ discard block |
||
| 463 | 463 | * @return bool|string |
| 464 | 464 | */ |
| 465 | 465 | function quete_logo_file($row, $connect = null) { |
| 466 | - include_spip('inc/documents'); |
|
| 467 | - $logo = vignette_logo_document($row, $connect); |
|
| 468 | - if (!$logo) { |
|
| 469 | - $logo = image_du_document($row, $connect); |
|
| 470 | - } |
|
| 471 | - if (!$logo) { |
|
| 472 | - $f = charger_fonction('vignette', 'inc'); |
|
| 473 | - $logo = $f($row['extension'], false); |
|
| 474 | - } |
|
| 475 | - // si c'est une vignette type doc, la renvoyer direct |
|
| 476 | - if ( |
|
| 477 | - strcmp($logo, _DIR_PLUGINS) == 0 |
|
| 478 | - or strcmp($logo, _DIR_PLUGINS_DIST) == 0 |
|
| 479 | - or strcmp($logo, _DIR_RACINE . 'prive/') == 0 |
|
| 480 | - ) { |
|
| 481 | - return $logo; |
|
| 482 | - } |
|
| 483 | - |
|
| 484 | - return get_spip_doc($logo); |
|
| 466 | + include_spip('inc/documents'); |
|
| 467 | + $logo = vignette_logo_document($row, $connect); |
|
| 468 | + if (!$logo) { |
|
| 469 | + $logo = image_du_document($row, $connect); |
|
| 470 | + } |
|
| 471 | + if (!$logo) { |
|
| 472 | + $f = charger_fonction('vignette', 'inc'); |
|
| 473 | + $logo = $f($row['extension'], false); |
|
| 474 | + } |
|
| 475 | + // si c'est une vignette type doc, la renvoyer direct |
|
| 476 | + if ( |
|
| 477 | + strcmp($logo, _DIR_PLUGINS) == 0 |
|
| 478 | + or strcmp($logo, _DIR_PLUGINS_DIST) == 0 |
|
| 479 | + or strcmp($logo, _DIR_RACINE . 'prive/') == 0 |
|
| 480 | + ) { |
|
| 481 | + return $logo; |
|
| 482 | + } |
|
| 483 | + |
|
| 484 | + return get_spip_doc($logo); |
|
| 485 | 485 | } |
| 486 | 486 | |
| 487 | 487 | /** |
@@ -509,20 +509,20 @@ discard block |
||
| 509 | 509 | */ |
| 510 | 510 | function quete_logo_document($row, $lien, $align, $mode_logo, $x, $y, string $connect = '') { |
| 511 | 511 | |
| 512 | - include_spip('inc/documents'); |
|
| 513 | - $logo = ''; |
|
| 514 | - if (!in_array($mode_logo, ['icone', 'apercu'])) { |
|
| 515 | - $logo = vignette_logo_document($row, $connect); |
|
| 516 | - } |
|
| 517 | - // si on veut explicitement la vignette, ne rien renvoyer si il n'y en a pas |
|
| 518 | - if ($mode_logo == 'vignette' and !$logo) { |
|
| 519 | - return ''; |
|
| 520 | - } |
|
| 521 | - if ($mode_logo == 'icone') { |
|
| 522 | - $row['fichier'] = ''; |
|
| 523 | - } |
|
| 524 | - |
|
| 525 | - return vignette_automatique($logo, $row, $lien, $x, $y, $align, null, $connect); |
|
| 512 | + include_spip('inc/documents'); |
|
| 513 | + $logo = ''; |
|
| 514 | + if (!in_array($mode_logo, ['icone', 'apercu'])) { |
|
| 515 | + $logo = vignette_logo_document($row, $connect); |
|
| 516 | + } |
|
| 517 | + // si on veut explicitement la vignette, ne rien renvoyer si il n'y en a pas |
|
| 518 | + if ($mode_logo == 'vignette' and !$logo) { |
|
| 519 | + return ''; |
|
| 520 | + } |
|
| 521 | + if ($mode_logo == 'icone') { |
|
| 522 | + $row['fichier'] = ''; |
|
| 523 | + } |
|
| 524 | + |
|
| 525 | + return vignette_automatique($logo, $row, $lien, $x, $y, $align, null, $connect); |
|
| 526 | 526 | } |
| 527 | 527 | |
| 528 | 528 | /** |
@@ -534,19 +534,19 @@ discard block |
||
| 534 | 534 | */ |
| 535 | 535 | function quete_html_logo($logo, $align, $lien) { |
| 536 | 536 | |
| 537 | - if (!is_array($logo)) { |
|
| 538 | - return ''; |
|
| 539 | - } |
|
| 540 | - |
|
| 541 | - $contexte = []; |
|
| 542 | - foreach ($logo as $k => $v) { |
|
| 543 | - if (!is_numeric($k)) { |
|
| 544 | - $contexte[$k] = $v; |
|
| 545 | - } |
|
| 546 | - } |
|
| 547 | - $contexte['align'] = $align; |
|
| 548 | - $contexte['lien'] = $lien; |
|
| 549 | - return recuperer_fond('modeles/logo', $contexte); |
|
| 537 | + if (!is_array($logo)) { |
|
| 538 | + return ''; |
|
| 539 | + } |
|
| 540 | + |
|
| 541 | + $contexte = []; |
|
| 542 | + foreach ($logo as $k => $v) { |
|
| 543 | + if (!is_numeric($k)) { |
|
| 544 | + $contexte[$k] = $v; |
|
| 545 | + } |
|
| 546 | + } |
|
| 547 | + $contexte['align'] = $align; |
|
| 548 | + $contexte['lien'] = $lien; |
|
| 549 | + return recuperer_fond('modeles/logo', $contexte); |
|
| 550 | 550 | } |
| 551 | 551 | |
| 552 | 552 | /** |
@@ -560,14 +560,14 @@ discard block |
||
| 560 | 560 | * @return string|false |
| 561 | 561 | */ |
| 562 | 562 | function document_spip_externe($fichier, $connect) { |
| 563 | - if ($connect) { |
|
| 564 | - $site = quete_meta('adresse_site', $connect); |
|
| 565 | - if ($site) { |
|
| 566 | - $dir = quete_meta('dir_img', $connect); |
|
| 567 | - return "$site/$dir$fichier"; |
|
| 568 | - } |
|
| 569 | - } |
|
| 570 | - return false; |
|
| 563 | + if ($connect) { |
|
| 564 | + $site = quete_meta('adresse_site', $connect); |
|
| 565 | + if ($site) { |
|
| 566 | + $dir = quete_meta('dir_img', $connect); |
|
| 567 | + return "$site/$dir$fichier"; |
|
| 568 | + } |
|
| 569 | + } |
|
| 570 | + return false; |
|
| 571 | 571 | } |
| 572 | 572 | |
| 573 | 573 | /** |
@@ -581,23 +581,23 @@ discard block |
||
| 581 | 581 | */ |
| 582 | 582 | function vignette_logo_document($row, string $connect = '') { |
| 583 | 583 | |
| 584 | - if (!$row or empty($row['id_vignette'])) { |
|
| 585 | - return ''; |
|
| 586 | - } |
|
| 587 | - $fichier = quete_fichier($row['id_vignette'], $connect); |
|
| 588 | - if ($url = document_spip_externe($fichier, $connect)) { |
|
| 589 | - return $url; |
|
| 590 | - } |
|
| 591 | - |
|
| 592 | - $f = get_spip_doc($fichier); |
|
| 593 | - if ($f and @file_exists($f)) { |
|
| 594 | - return $f; |
|
| 595 | - } |
|
| 596 | - if ($row['mode'] !== 'vignette') { |
|
| 597 | - return ''; |
|
| 598 | - } |
|
| 599 | - |
|
| 600 | - return generer_objet_url($row['id_document'], 'document', '', '', $connect); |
|
| 584 | + if (!$row or empty($row['id_vignette'])) { |
|
| 585 | + return ''; |
|
| 586 | + } |
|
| 587 | + $fichier = quete_fichier($row['id_vignette'], $connect); |
|
| 588 | + if ($url = document_spip_externe($fichier, $connect)) { |
|
| 589 | + return $url; |
|
| 590 | + } |
|
| 591 | + |
|
| 592 | + $f = get_spip_doc($fichier); |
|
| 593 | + if ($f and @file_exists($f)) { |
|
| 594 | + return $f; |
|
| 595 | + } |
|
| 596 | + if ($row['mode'] !== 'vignette') { |
|
| 597 | + return ''; |
|
| 598 | + } |
|
| 599 | + |
|
| 600 | + return generer_objet_url($row['id_document'], 'document', '', '', $connect); |
|
| 601 | 601 | } |
| 602 | 602 | |
| 603 | 603 | /** |
@@ -613,66 +613,66 @@ discard block |
||
| 613 | 613 | * @return bool|string |
| 614 | 614 | */ |
| 615 | 615 | function calcul_exposer($id, $prim, $reference, $parent, $type, string $connect = '') { |
| 616 | - static $exposer = []; |
|
| 617 | - |
|
| 618 | - // Que faut-il exposer ? Tous les elements de $reference |
|
| 619 | - // ainsi que leur hierarchie ; on ne fait donc ce calcul |
|
| 620 | - // qu'une fois (par squelette) et on conserve le resultat |
|
| 621 | - // en static. |
|
| 622 | - if (!isset($exposer[$m = md5(serialize($reference))][$prim])) { |
|
| 623 | - $principal = $reference[$type] ?? $reference["@$type"] ?? ''; |
|
| 624 | - // le parent fournit en argument est le parent de $id, pas celui de $principal |
|
| 625 | - // il n'est donc pas utile |
|
| 626 | - $parent = 0; |
|
| 627 | - if (!$principal) { // regarder si un enfant est dans le contexte, auquel cas il expose peut etre le parent courant |
|
| 628 | - $enfants = ['id_rubrique' => ['id_article'], 'id_groupe' => ['id_mot']]; |
|
| 629 | - if (isset($enfants[$type])) { |
|
| 630 | - foreach ($enfants[$type] as $t) { |
|
| 631 | - if ( |
|
| 632 | - isset($reference[$t]) |
|
| 633 | - // cas de la reference donnee dynamiquement par la pagination |
|
| 634 | - or isset($reference["@$t"]) |
|
| 635 | - ) { |
|
| 636 | - $type = $t; |
|
| 637 | - $principal = $reference[$type] ?? $reference["@$type"]; |
|
| 638 | - continue; |
|
| 639 | - } |
|
| 640 | - } |
|
| 641 | - } |
|
| 642 | - } |
|
| 643 | - $exposer[$m][$type] = []; |
|
| 644 | - if ($principal) { |
|
| 645 | - $principaux = is_array($principal) ? $principal : [$principal]; |
|
| 646 | - foreach ($principaux as $principal) { |
|
| 647 | - $exposer[$m][$type][$principal] = true; |
|
| 648 | - if ($type == 'id_mot') { |
|
| 649 | - if (!$parent) { |
|
| 650 | - $parent = sql_getfetsel('id_groupe', 'spip_mots', 'id_mot=' . intval($principal), '', '', '', '', $connect); |
|
| 651 | - } |
|
| 652 | - if ($parent) { |
|
| 653 | - $exposer[$m]['id_groupe'][$parent] = true; |
|
| 654 | - } |
|
| 655 | - } else { |
|
| 656 | - if ($type != 'id_groupe') { |
|
| 657 | - if (!$parent) { |
|
| 658 | - if ($type == 'id_rubrique') { |
|
| 659 | - $parent = $principal; |
|
| 660 | - } |
|
| 661 | - if ($type == 'id_article') { |
|
| 662 | - $parent = quete_rubrique($principal, $connect); |
|
| 663 | - } |
|
| 664 | - } |
|
| 665 | - do { |
|
| 666 | - $exposer[$m]['id_rubrique'][$parent] = true; |
|
| 667 | - } while ($parent = quete_parent($parent, $connect)); |
|
| 668 | - } |
|
| 669 | - } |
|
| 670 | - } |
|
| 671 | - } |
|
| 672 | - } |
|
| 673 | - |
|
| 674 | - // And the winner is... |
|
| 675 | - return isset($exposer[$m][$prim]) ? isset($exposer[$m][$prim][$id]) : ''; |
|
| 616 | + static $exposer = []; |
|
| 617 | + |
|
| 618 | + // Que faut-il exposer ? Tous les elements de $reference |
|
| 619 | + // ainsi que leur hierarchie ; on ne fait donc ce calcul |
|
| 620 | + // qu'une fois (par squelette) et on conserve le resultat |
|
| 621 | + // en static. |
|
| 622 | + if (!isset($exposer[$m = md5(serialize($reference))][$prim])) { |
|
| 623 | + $principal = $reference[$type] ?? $reference["@$type"] ?? ''; |
|
| 624 | + // le parent fournit en argument est le parent de $id, pas celui de $principal |
|
| 625 | + // il n'est donc pas utile |
|
| 626 | + $parent = 0; |
|
| 627 | + if (!$principal) { // regarder si un enfant est dans le contexte, auquel cas il expose peut etre le parent courant |
|
| 628 | + $enfants = ['id_rubrique' => ['id_article'], 'id_groupe' => ['id_mot']]; |
|
| 629 | + if (isset($enfants[$type])) { |
|
| 630 | + foreach ($enfants[$type] as $t) { |
|
| 631 | + if ( |
|
| 632 | + isset($reference[$t]) |
|
| 633 | + // cas de la reference donnee dynamiquement par la pagination |
|
| 634 | + or isset($reference["@$t"]) |
|
| 635 | + ) { |
|
| 636 | + $type = $t; |
|
| 637 | + $principal = $reference[$type] ?? $reference["@$type"]; |
|
| 638 | + continue; |
|
| 639 | + } |
|
| 640 | + } |
|
| 641 | + } |
|
| 642 | + } |
|
| 643 | + $exposer[$m][$type] = []; |
|
| 644 | + if ($principal) { |
|
| 645 | + $principaux = is_array($principal) ? $principal : [$principal]; |
|
| 646 | + foreach ($principaux as $principal) { |
|
| 647 | + $exposer[$m][$type][$principal] = true; |
|
| 648 | + if ($type == 'id_mot') { |
|
| 649 | + if (!$parent) { |
|
| 650 | + $parent = sql_getfetsel('id_groupe', 'spip_mots', 'id_mot=' . intval($principal), '', '', '', '', $connect); |
|
| 651 | + } |
|
| 652 | + if ($parent) { |
|
| 653 | + $exposer[$m]['id_groupe'][$parent] = true; |
|
| 654 | + } |
|
| 655 | + } else { |
|
| 656 | + if ($type != 'id_groupe') { |
|
| 657 | + if (!$parent) { |
|
| 658 | + if ($type == 'id_rubrique') { |
|
| 659 | + $parent = $principal; |
|
| 660 | + } |
|
| 661 | + if ($type == 'id_article') { |
|
| 662 | + $parent = quete_rubrique($principal, $connect); |
|
| 663 | + } |
|
| 664 | + } |
|
| 665 | + do { |
|
| 666 | + $exposer[$m]['id_rubrique'][$parent] = true; |
|
| 667 | + } while ($parent = quete_parent($parent, $connect)); |
|
| 668 | + } |
|
| 669 | + } |
|
| 670 | + } |
|
| 671 | + } |
|
| 672 | + } |
|
| 673 | + |
|
| 674 | + // And the winner is... |
|
| 675 | + return isset($exposer[$m][$prim]) ? isset($exposer[$m][$prim][$id]) : ''; |
|
| 676 | 676 | } |
| 677 | 677 | |
| 678 | 678 | /** |
@@ -687,23 +687,23 @@ discard block |
||
| 687 | 687 | * @return int |
| 688 | 688 | */ |
| 689 | 689 | function quete_debut_pagination($primary, $valeur, $pas, $iter) { |
| 690 | - // on ne devrait pas arriver ici si la cle primaire est inexistante |
|
| 691 | - // ou composee, mais verifions |
|
| 692 | - if (!$primary or preg_match('/[,\s]/', $primary)) { |
|
| 693 | - return 0; |
|
| 694 | - } |
|
| 695 | - |
|
| 696 | - $pos = 0; |
|
| 697 | - while ($row = $iter->fetch() and $row[$primary] != $valeur) { |
|
| 698 | - $pos++; |
|
| 699 | - } |
|
| 700 | - // si on a pas trouve |
|
| 701 | - if (!$row or $row[$primary] != $valeur) { |
|
| 702 | - return 0; |
|
| 703 | - } |
|
| 704 | - |
|
| 705 | - // sinon, calculer le bon numero de page |
|
| 706 | - return floor($pos / $pas) * $pas; |
|
| 690 | + // on ne devrait pas arriver ici si la cle primaire est inexistante |
|
| 691 | + // ou composee, mais verifions |
|
| 692 | + if (!$primary or preg_match('/[,\s]/', $primary)) { |
|
| 693 | + return 0; |
|
| 694 | + } |
|
| 695 | + |
|
| 696 | + $pos = 0; |
|
| 697 | + while ($row = $iter->fetch() and $row[$primary] != $valeur) { |
|
| 698 | + $pos++; |
|
| 699 | + } |
|
| 700 | + // si on a pas trouve |
|
| 701 | + if (!$row or $row[$primary] != $valeur) { |
|
| 702 | + return 0; |
|
| 703 | + } |
|
| 704 | + |
|
| 705 | + // sinon, calculer le bon numero de page |
|
| 706 | + return floor($pos / $pas) * $pas; |
|
| 707 | 707 | } |
| 708 | 708 | |
| 709 | 709 | /** |
@@ -714,11 +714,11 @@ discard block |
||
| 714 | 714 | * @return boolean |
| 715 | 715 | */ |
| 716 | 716 | function is_whereable($value): bool { |
| 717 | - if (is_array($value) && count($value)) { |
|
| 718 | - return true; |
|
| 719 | - } |
|
| 720 | - if (is_scalar($value) && strlen($value)) { |
|
| 721 | - return true; |
|
| 722 | - } |
|
| 723 | - return false; |
|
| 717 | + if (is_array($value) && count($value)) { |
|
| 718 | + return true; |
|
| 719 | + } |
|
| 720 | + if (is_scalar($value) && strlen($value)) { |
|
| 721 | + return true; |
|
| 722 | + } |
|
| 723 | + return false; |
|
| 724 | 724 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | include_spip('inc/autoriser'); |
@@ -35,42 +35,42 @@ discard block |
||
| 35 | 35 | **/ |
| 36 | 36 | function action_menu_rubriques_dist() { |
| 37 | 37 | |
| 38 | - // si pas acces a ecrire, pas acces au menu |
|
| 39 | - // on renvoi un 401 qui fait echouer la requete ajax silencieusement |
|
| 40 | - if (!autoriser('ecrire')) { |
|
| 41 | - $retour = |
|
| 42 | - '<ul class="deroulant__sous-menu" data-profondeur="1">' . |
|
| 43 | - '<li class="deroulant__item deroulant__item_plan plan_site" data-profondeur="1">' . |
|
| 44 | - '<a class="deroulant__lien" href="' . generer_url_ecrire('accueil') . '" data-profondeur="1">' . |
|
| 45 | - '<span class="libelle">' . _T('public:lien_connecter') . '</span>' . |
|
| 46 | - '</a>' . |
|
| 47 | - '</li>' . |
|
| 48 | - '</ul>'; |
|
| 49 | - include_spip('inc/actions'); |
|
| 50 | - ajax_retour($retour); |
|
| 51 | - exit; |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - if ($date = intval(_request('date'))) { |
|
| 55 | - header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $date) . ' GMT'); |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - $r = gen_liste_rubriques(); |
|
| 59 | - if ( |
|
| 60 | - !$r |
|
| 61 | - and isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) |
|
| 62 | - and !strstr($_SERVER['SERVER_SOFTWARE'], 'IIS/') |
|
| 63 | - ) { |
|
| 64 | - include_spip('inc/headers'); |
|
| 65 | - header('Content-Type: text/html; charset=' . $GLOBALS['meta']['charset']); |
|
| 66 | - http_response_code(304); |
|
| 67 | - exit; |
|
| 68 | - } else { |
|
| 69 | - include_spip('inc/actions'); |
|
| 70 | - $ret = menu_rubriques(); |
|
| 71 | - ajax_retour($ret); |
|
| 72 | - exit; |
|
| 73 | - } |
|
| 38 | + // si pas acces a ecrire, pas acces au menu |
|
| 39 | + // on renvoi un 401 qui fait echouer la requete ajax silencieusement |
|
| 40 | + if (!autoriser('ecrire')) { |
|
| 41 | + $retour = |
|
| 42 | + '<ul class="deroulant__sous-menu" data-profondeur="1">' . |
|
| 43 | + '<li class="deroulant__item deroulant__item_plan plan_site" data-profondeur="1">' . |
|
| 44 | + '<a class="deroulant__lien" href="' . generer_url_ecrire('accueil') . '" data-profondeur="1">' . |
|
| 45 | + '<span class="libelle">' . _T('public:lien_connecter') . '</span>' . |
|
| 46 | + '</a>' . |
|
| 47 | + '</li>' . |
|
| 48 | + '</ul>'; |
|
| 49 | + include_spip('inc/actions'); |
|
| 50 | + ajax_retour($retour); |
|
| 51 | + exit; |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + if ($date = intval(_request('date'))) { |
|
| 55 | + header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $date) . ' GMT'); |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + $r = gen_liste_rubriques(); |
|
| 59 | + if ( |
|
| 60 | + !$r |
|
| 61 | + and isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) |
|
| 62 | + and !strstr($_SERVER['SERVER_SOFTWARE'], 'IIS/') |
|
| 63 | + ) { |
|
| 64 | + include_spip('inc/headers'); |
|
| 65 | + header('Content-Type: text/html; charset=' . $GLOBALS['meta']['charset']); |
|
| 66 | + http_response_code(304); |
|
| 67 | + exit; |
|
| 68 | + } else { |
|
| 69 | + include_spip('inc/actions'); |
|
| 70 | + $ret = menu_rubriques(); |
|
| 71 | + ajax_retour($ret); |
|
| 72 | + exit; |
|
| 73 | + } |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | /** |
@@ -84,44 +84,44 @@ discard block |
||
| 84 | 84 | * Code HTML présentant la liste des rubriques |
| 85 | 85 | **/ |
| 86 | 86 | function menu_rubriques($complet = true) { |
| 87 | - $ret = '<li class="deroulant__item deroulant__item_tout toutsite" data-profondeur="1">' |
|
| 88 | - . '<a class="deroulant__lien" href="' . generer_url_ecrire('plan') . '" data-profondeur="1">' |
|
| 89 | - . '<span class="libelle">' . _T('info_tout_site') . '</span>' |
|
| 90 | - . '</a>' |
|
| 91 | - . '</li>'; |
|
| 92 | - |
|
| 93 | - if (!$complet) { |
|
| 94 | - return "<ul class=\"deroulant__sous-menu\" data-profondeur=\"1\">$ret\n</ul>\n"; |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - if (!isset($GLOBALS['db_art_cache'])) { |
|
| 98 | - gen_liste_rubriques(); |
|
| 99 | - } |
|
| 100 | - $arr_low = extraire_article(0, $GLOBALS['db_art_cache']); |
|
| 101 | - |
|
| 102 | - $total_lignes = $i = sizeof($arr_low); |
|
| 103 | - |
|
| 104 | - if ($i > 0) { |
|
| 105 | - $nb_col = min(8, ceil($total_lignes / 30)); |
|
| 106 | - if ($nb_col <= 1) { |
|
| 107 | - $nb_col = ceil($total_lignes / 10); |
|
| 108 | - } |
|
| 109 | - foreach ($arr_low as $id_rubrique => $titre_rubrique) { |
|
| 110 | - if (autoriser('voir', 'rubrique', $id_rubrique)) { |
|
| 111 | - $ret .= bandeau_rubrique($id_rubrique, $titre_rubrique, $i); |
|
| 112 | - $i++; |
|
| 113 | - } |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - $class_cols = ($nb_col > 1 ? "cols-$nb_col" : ''); |
|
| 117 | - $ret = "<ul class=\"deroulant__sous-menu $class_cols\" data-profondeur=\"1\">" |
|
| 118 | - . $ret |
|
| 119 | - . "\n</ul>\n"; |
|
| 120 | - } else { |
|
| 121 | - $ret = "<ul class=\"deroulant__sous-menu\" data-profondeur=\"1\">$ret\n</ul>\n"; |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - return $ret; |
|
| 87 | + $ret = '<li class="deroulant__item deroulant__item_tout toutsite" data-profondeur="1">' |
|
| 88 | + . '<a class="deroulant__lien" href="' . generer_url_ecrire('plan') . '" data-profondeur="1">' |
|
| 89 | + . '<span class="libelle">' . _T('info_tout_site') . '</span>' |
|
| 90 | + . '</a>' |
|
| 91 | + . '</li>'; |
|
| 92 | + |
|
| 93 | + if (!$complet) { |
|
| 94 | + return "<ul class=\"deroulant__sous-menu\" data-profondeur=\"1\">$ret\n</ul>\n"; |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + if (!isset($GLOBALS['db_art_cache'])) { |
|
| 98 | + gen_liste_rubriques(); |
|
| 99 | + } |
|
| 100 | + $arr_low = extraire_article(0, $GLOBALS['db_art_cache']); |
|
| 101 | + |
|
| 102 | + $total_lignes = $i = sizeof($arr_low); |
|
| 103 | + |
|
| 104 | + if ($i > 0) { |
|
| 105 | + $nb_col = min(8, ceil($total_lignes / 30)); |
|
| 106 | + if ($nb_col <= 1) { |
|
| 107 | + $nb_col = ceil($total_lignes / 10); |
|
| 108 | + } |
|
| 109 | + foreach ($arr_low as $id_rubrique => $titre_rubrique) { |
|
| 110 | + if (autoriser('voir', 'rubrique', $id_rubrique)) { |
|
| 111 | + $ret .= bandeau_rubrique($id_rubrique, $titre_rubrique, $i); |
|
| 112 | + $i++; |
|
| 113 | + } |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + $class_cols = ($nb_col > 1 ? "cols-$nb_col" : ''); |
|
| 117 | + $ret = "<ul class=\"deroulant__sous-menu $class_cols\" data-profondeur=\"1\">" |
|
| 118 | + . $ret |
|
| 119 | + . "\n</ul>\n"; |
|
| 120 | + } else { |
|
| 121 | + $ret = "<ul class=\"deroulant__sous-menu\" data-profondeur=\"1\">$ret\n</ul>\n"; |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + return $ret; |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
@@ -142,48 +142,48 @@ discard block |
||
| 142 | 142 | * Code HTML présentant la liste des rubriques |
| 143 | 143 | **/ |
| 144 | 144 | function bandeau_rubrique($id_rubrique, $titre_rubrique, $zdecal, $profondeur = 1) { |
| 145 | - static $zmax = 6; |
|
| 146 | - $profondeur_next = $profondeur + 1; |
|
| 147 | - |
|
| 148 | - $nav = '<a class="deroulant__lien" href="' . generer_objet_url($id_rubrique, 'rubrique', '', '', false) . "\" data-profondeur=\"$profondeur\">" |
|
| 149 | - . '<span class="libelle">' . supprimer_tags(preg_replace(',[\x00-\x1f]+,', ' ', $titre_rubrique)) . '</span>' |
|
| 150 | - . "</a>\n"; |
|
| 151 | - |
|
| 152 | - // Limiter volontairement le nombre de sous-menus |
|
| 153 | - if (!(--$zmax)) { |
|
| 154 | - $zmax++; |
|
| 155 | - |
|
| 156 | - return "\n<li class=\"deroulant__item\" data-profondeur=\"$profondeur\">$nav</li>"; |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - $arr_rub = extraire_article($id_rubrique, $GLOBALS['db_art_cache']); |
|
| 160 | - $i = sizeof($arr_rub); |
|
| 161 | - if (!$i) { |
|
| 162 | - $zmax++; |
|
| 163 | - |
|
| 164 | - return "\n<li class=\"deroulant__item\" data-profondeur=\"$profondeur\">$nav</li>"; |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - |
|
| 168 | - $nb_col = 1; |
|
| 169 | - if ($nb_rub = count($arr_rub)) { |
|
| 170 | - $nb_col = min(10, max(1, ceil($nb_rub / 10))); |
|
| 171 | - } |
|
| 172 | - $class_cols = ($nb_col > 1 ? "cols-$nb_col" : ''); |
|
| 173 | - $ret = "<li class=\"deroulant__item deroulant__item_parent\" data-profondeur=\"$profondeur\">" |
|
| 174 | - . $nav |
|
| 175 | - . "<ul class=\"deroulant__sous-menu $class_cols\" data-profondeur=\"$profondeur_next\">"; |
|
| 176 | - foreach ($arr_rub as $id_rub => $titre_rub) { |
|
| 177 | - if (autoriser('voir', 'rubrique', $id_rub)) { |
|
| 178 | - $titre = supprimer_numero(typo($titre_rub)); |
|
| 179 | - $ret .= bandeau_rubrique($id_rub, $titre, $zdecal + $i, $profondeur_next); |
|
| 180 | - $i++; |
|
| 181 | - } |
|
| 182 | - } |
|
| 183 | - $ret .= "</ul></li>\n"; |
|
| 184 | - $zmax++; |
|
| 185 | - |
|
| 186 | - return $ret; |
|
| 145 | + static $zmax = 6; |
|
| 146 | + $profondeur_next = $profondeur + 1; |
|
| 147 | + |
|
| 148 | + $nav = '<a class="deroulant__lien" href="' . generer_objet_url($id_rubrique, 'rubrique', '', '', false) . "\" data-profondeur=\"$profondeur\">" |
|
| 149 | + . '<span class="libelle">' . supprimer_tags(preg_replace(',[\x00-\x1f]+,', ' ', $titre_rubrique)) . '</span>' |
|
| 150 | + . "</a>\n"; |
|
| 151 | + |
|
| 152 | + // Limiter volontairement le nombre de sous-menus |
|
| 153 | + if (!(--$zmax)) { |
|
| 154 | + $zmax++; |
|
| 155 | + |
|
| 156 | + return "\n<li class=\"deroulant__item\" data-profondeur=\"$profondeur\">$nav</li>"; |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + $arr_rub = extraire_article($id_rubrique, $GLOBALS['db_art_cache']); |
|
| 160 | + $i = sizeof($arr_rub); |
|
| 161 | + if (!$i) { |
|
| 162 | + $zmax++; |
|
| 163 | + |
|
| 164 | + return "\n<li class=\"deroulant__item\" data-profondeur=\"$profondeur\">$nav</li>"; |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + |
|
| 168 | + $nb_col = 1; |
|
| 169 | + if ($nb_rub = count($arr_rub)) { |
|
| 170 | + $nb_col = min(10, max(1, ceil($nb_rub / 10))); |
|
| 171 | + } |
|
| 172 | + $class_cols = ($nb_col > 1 ? "cols-$nb_col" : ''); |
|
| 173 | + $ret = "<li class=\"deroulant__item deroulant__item_parent\" data-profondeur=\"$profondeur\">" |
|
| 174 | + . $nav |
|
| 175 | + . "<ul class=\"deroulant__sous-menu $class_cols\" data-profondeur=\"$profondeur_next\">"; |
|
| 176 | + foreach ($arr_rub as $id_rub => $titre_rub) { |
|
| 177 | + if (autoriser('voir', 'rubrique', $id_rub)) { |
|
| 178 | + $titre = supprimer_numero(typo($titre_rub)); |
|
| 179 | + $ret .= bandeau_rubrique($id_rub, $titre, $zdecal + $i, $profondeur_next); |
|
| 180 | + $i++; |
|
| 181 | + } |
|
| 182 | + } |
|
| 183 | + $ret .= "</ul></li>\n"; |
|
| 184 | + $zmax++; |
|
| 185 | + |
|
| 186 | + return $ret; |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | * Liste des rubriques enfants de la rubrique (et leur titre) |
| 202 | 202 | **/ |
| 203 | 203 | function extraire_article($id_p, $t) { |
| 204 | - return array_key_exists($id_p, $t) ? $t[$id_p] : []; |
|
| 204 | + return array_key_exists($id_p, $t) ? $t[$id_p] : []; |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | /** |
@@ -217,42 +217,42 @@ discard block |
||
| 217 | 217 | **/ |
| 218 | 218 | function gen_liste_rubriques() { |
| 219 | 219 | |
| 220 | - $cache = null; |
|
| 221 | - include_spip('inc/config'); |
|
| 222 | - // ici, un petit fichier cache ne fait pas de mal |
|
| 223 | - $last = lire_config('date_calcul_rubriques', 0); |
|
| 224 | - if (lire_fichier(_CACHE_RUBRIQUES, $cache)) { |
|
| 225 | - [$date, $GLOBALS['db_art_cache']] = @unserialize($cache); |
|
| 226 | - if ($date == $last) { |
|
| 227 | - return false; |
|
| 228 | - } // c'etait en cache :-) |
|
| 229 | - } |
|
| 230 | - // se restreindre aux rubriques utilisees recemment +secteurs |
|
| 231 | - |
|
| 232 | - $where = sql_in_select( |
|
| 233 | - 'id_rubrique', |
|
| 234 | - 'id_rubrique', |
|
| 235 | - 'spip_rubriques', |
|
| 236 | - '', |
|
| 237 | - '', |
|
| 238 | - 'id_parent=0 DESC, date DESC', |
|
| 239 | - _CACHE_RUBRIQUES_MAX |
|
| 240 | - ); |
|
| 241 | - |
|
| 242 | - // puis refaire la requete pour avoir l'ordre alphabetique |
|
| 243 | - |
|
| 244 | - $res = sql_select('id_rubrique, titre, id_parent', 'spip_rubriques', $where, '', 'id_parent, 0+titre, titre'); |
|
| 245 | - |
|
| 246 | - // il ne faut pas filtrer le autoriser voir ici |
|
| 247 | - // car on met le resultat en cache, commun a tout le monde |
|
| 248 | - $GLOBALS['db_art_cache'] = []; |
|
| 249 | - while ($r = sql_fetch($res)) { |
|
| 250 | - $t = sinon($r['titre'], _T('ecrire:info_sans_titre')); |
|
| 251 | - $GLOBALS['db_art_cache'][$r['id_parent']][$r['id_rubrique']] = supprimer_numero(typo($t)); |
|
| 252 | - } |
|
| 253 | - |
|
| 254 | - $t = [$last ?: time(), $GLOBALS['db_art_cache']]; |
|
| 255 | - ecrire_fichier(_CACHE_RUBRIQUES, serialize($t)); |
|
| 256 | - |
|
| 257 | - return true; |
|
| 220 | + $cache = null; |
|
| 221 | + include_spip('inc/config'); |
|
| 222 | + // ici, un petit fichier cache ne fait pas de mal |
|
| 223 | + $last = lire_config('date_calcul_rubriques', 0); |
|
| 224 | + if (lire_fichier(_CACHE_RUBRIQUES, $cache)) { |
|
| 225 | + [$date, $GLOBALS['db_art_cache']] = @unserialize($cache); |
|
| 226 | + if ($date == $last) { |
|
| 227 | + return false; |
|
| 228 | + } // c'etait en cache :-) |
|
| 229 | + } |
|
| 230 | + // se restreindre aux rubriques utilisees recemment +secteurs |
|
| 231 | + |
|
| 232 | + $where = sql_in_select( |
|
| 233 | + 'id_rubrique', |
|
| 234 | + 'id_rubrique', |
|
| 235 | + 'spip_rubriques', |
|
| 236 | + '', |
|
| 237 | + '', |
|
| 238 | + 'id_parent=0 DESC, date DESC', |
|
| 239 | + _CACHE_RUBRIQUES_MAX |
|
| 240 | + ); |
|
| 241 | + |
|
| 242 | + // puis refaire la requete pour avoir l'ordre alphabetique |
|
| 243 | + |
|
| 244 | + $res = sql_select('id_rubrique, titre, id_parent', 'spip_rubriques', $where, '', 'id_parent, 0+titre, titre'); |
|
| 245 | + |
|
| 246 | + // il ne faut pas filtrer le autoriser voir ici |
|
| 247 | + // car on met le resultat en cache, commun a tout le monde |
|
| 248 | + $GLOBALS['db_art_cache'] = []; |
|
| 249 | + while ($r = sql_fetch($res)) { |
|
| 250 | + $t = sinon($r['titre'], _T('ecrire:info_sans_titre')); |
|
| 251 | + $GLOBALS['db_art_cache'][$r['id_parent']][$r['id_rubrique']] = supprimer_numero(typo($t)); |
|
| 252 | + } |
|
| 253 | + |
|
| 254 | + $t = [$last ?: time(), $GLOBALS['db_art_cache']]; |
|
| 255 | + ecrire_fichier(_CACHE_RUBRIQUES, serialize($t)); |
|
| 256 | + |
|
| 257 | + return true; |
|
| 258 | 258 | } |
@@ -39,12 +39,12 @@ discard block |
||
| 39 | 39 | // on renvoi un 401 qui fait echouer la requete ajax silencieusement |
| 40 | 40 | if (!autoriser('ecrire')) { |
| 41 | 41 | $retour = |
| 42 | - '<ul class="deroulant__sous-menu" data-profondeur="1">' . |
|
| 43 | - '<li class="deroulant__item deroulant__item_plan plan_site" data-profondeur="1">' . |
|
| 44 | - '<a class="deroulant__lien" href="' . generer_url_ecrire('accueil') . '" data-profondeur="1">' . |
|
| 45 | - '<span class="libelle">' . _T('public:lien_connecter') . '</span>' . |
|
| 46 | - '</a>' . |
|
| 47 | - '</li>' . |
|
| 42 | + '<ul class="deroulant__sous-menu" data-profondeur="1">'. |
|
| 43 | + '<li class="deroulant__item deroulant__item_plan plan_site" data-profondeur="1">'. |
|
| 44 | + '<a class="deroulant__lien" href="'.generer_url_ecrire('accueil').'" data-profondeur="1">'. |
|
| 45 | + '<span class="libelle">'._T('public:lien_connecter').'</span>'. |
|
| 46 | + '</a>'. |
|
| 47 | + '</li>'. |
|
| 48 | 48 | '</ul>'; |
| 49 | 49 | include_spip('inc/actions'); |
| 50 | 50 | ajax_retour($retour); |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | if ($date = intval(_request('date'))) { |
| 55 | - header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $date) . ' GMT'); |
|
| 55 | + header('Last-Modified: '.gmdate('D, d M Y H:i:s', $date).' GMT'); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | $r = gen_liste_rubriques(); |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | and !strstr($_SERVER['SERVER_SOFTWARE'], 'IIS/') |
| 63 | 63 | ) { |
| 64 | 64 | include_spip('inc/headers'); |
| 65 | - header('Content-Type: text/html; charset=' . $GLOBALS['meta']['charset']); |
|
| 65 | + header('Content-Type: text/html; charset='.$GLOBALS['meta']['charset']); |
|
| 66 | 66 | http_response_code(304); |
| 67 | 67 | exit; |
| 68 | 68 | } else { |
@@ -85,8 +85,8 @@ discard block |
||
| 85 | 85 | **/ |
| 86 | 86 | function menu_rubriques($complet = true) { |
| 87 | 87 | $ret = '<li class="deroulant__item deroulant__item_tout toutsite" data-profondeur="1">' |
| 88 | - . '<a class="deroulant__lien" href="' . generer_url_ecrire('plan') . '" data-profondeur="1">' |
|
| 89 | - . '<span class="libelle">' . _T('info_tout_site') . '</span>' |
|
| 88 | + . '<a class="deroulant__lien" href="'.generer_url_ecrire('plan').'" data-profondeur="1">' |
|
| 89 | + . '<span class="libelle">'._T('info_tout_site').'</span>' |
|
| 90 | 90 | . '</a>' |
| 91 | 91 | . '</li>'; |
| 92 | 92 | |
@@ -145,8 +145,8 @@ discard block |
||
| 145 | 145 | static $zmax = 6; |
| 146 | 146 | $profondeur_next = $profondeur + 1; |
| 147 | 147 | |
| 148 | - $nav = '<a class="deroulant__lien" href="' . generer_objet_url($id_rubrique, 'rubrique', '', '', false) . "\" data-profondeur=\"$profondeur\">" |
|
| 149 | - . '<span class="libelle">' . supprimer_tags(preg_replace(',[\x00-\x1f]+,', ' ', $titre_rubrique)) . '</span>' |
|
| 148 | + $nav = '<a class="deroulant__lien" href="'.generer_objet_url($id_rubrique, 'rubrique', '', '', false)."\" data-profondeur=\"$profondeur\">" |
|
| 149 | + . '<span class="libelle">'.supprimer_tags(preg_replace(',[\x00-\x1f]+,', ' ', $titre_rubrique)).'</span>' |
|
| 150 | 150 | . "</a>\n"; |
| 151 | 151 | |
| 152 | 152 | // Limiter volontairement le nombre de sous-menus |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | **/ |
| 19 | 19 | |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | /** |
@@ -36,56 +36,56 @@ discard block |
||
| 36 | 36 | * ``` |
| 37 | 37 | **/ |
| 38 | 38 | function action_redirect_dist() { |
| 39 | - $type = _request('type'); |
|
| 40 | - $id = intval(_request('id')); |
|
| 41 | - $page = false; |
|
| 39 | + $type = _request('type'); |
|
| 40 | + $id = intval(_request('id')); |
|
| 41 | + $page = false; |
|
| 42 | 42 | |
| 43 | - // verifier le type ou page transmis |
|
| 44 | - if (!preg_match('/^\w+$/', $type)) { |
|
| 45 | - $page = _request('page'); |
|
| 46 | - if (!preg_match('/^\w+$/', $page)) { |
|
| 47 | - return; |
|
| 48 | - } |
|
| 49 | - } |
|
| 43 | + // verifier le type ou page transmis |
|
| 44 | + if (!preg_match('/^\w+$/', $type)) { |
|
| 45 | + $page = _request('page'); |
|
| 46 | + if (!preg_match('/^\w+$/', $page)) { |
|
| 47 | + return; |
|
| 48 | + } |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - if ($var_mode = _request('var_mode')) { |
|
| 52 | - // forcer la mise a jour de l'url de cet objet ! |
|
| 53 | - if (!defined('_VAR_URLS')) { |
|
| 54 | - define('_VAR_URLS', true); |
|
| 55 | - } |
|
| 56 | - } |
|
| 51 | + if ($var_mode = _request('var_mode')) { |
|
| 52 | + // forcer la mise a jour de l'url de cet objet ! |
|
| 53 | + if (!defined('_VAR_URLS')) { |
|
| 54 | + define('_VAR_URLS', true); |
|
| 55 | + } |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - if ($page) { |
|
| 59 | - $url = generer_url_public($page, '', true); |
|
| 60 | - } else { |
|
| 61 | - $url = calculer_url_redirect_entite($type, $id, $var_mode); |
|
| 62 | - } |
|
| 58 | + if ($page) { |
|
| 59 | + $url = generer_url_public($page, '', true); |
|
| 60 | + } else { |
|
| 61 | + $url = calculer_url_redirect_entite($type, $id, $var_mode); |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - $status = '302'; |
|
| 65 | - if ($url) { |
|
| 66 | - if ($var_mode) { |
|
| 67 | - $url = parametre_url($url, 'var_mode', $var_mode, '&'); |
|
| 68 | - } |
|
| 64 | + $status = '302'; |
|
| 65 | + if ($url) { |
|
| 66 | + if ($var_mode) { |
|
| 67 | + $url = parametre_url($url, 'var_mode', $var_mode, '&'); |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - if ( |
|
| 71 | - $var_mode == 'preview' |
|
| 72 | - and defined('_PREVIEW_TOKEN') |
|
| 73 | - and _PREVIEW_TOKEN |
|
| 74 | - and autoriser('previsualiser') |
|
| 75 | - ) { |
|
| 76 | - include_spip('inc/securiser_action'); |
|
| 77 | - $token = calculer_token_previsu($url); |
|
| 78 | - $url = parametre_url($url, 'var_previewtoken', $token); |
|
| 79 | - } |
|
| 70 | + if ( |
|
| 71 | + $var_mode == 'preview' |
|
| 72 | + and defined('_PREVIEW_TOKEN') |
|
| 73 | + and _PREVIEW_TOKEN |
|
| 74 | + and autoriser('previsualiser') |
|
| 75 | + ) { |
|
| 76 | + include_spip('inc/securiser_action'); |
|
| 77 | + $token = calculer_token_previsu($url); |
|
| 78 | + $url = parametre_url($url, 'var_previewtoken', $token); |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - if (_request('status') and _request('status') == '301') { |
|
| 82 | - $status = '301'; |
|
| 83 | - } |
|
| 84 | - } else { |
|
| 85 | - $url = generer_url_public('404', '', true); |
|
| 86 | - } |
|
| 81 | + if (_request('status') and _request('status') == '301') { |
|
| 82 | + $status = '301'; |
|
| 83 | + } |
|
| 84 | + } else { |
|
| 85 | + $url = generer_url_public('404', '', true); |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - redirige_par_entete(str_replace('&', '&', $url), '', $status); |
|
| 88 | + redirige_par_entete(str_replace('&', '&', $url), '', $status); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | /** |
@@ -100,35 +100,35 @@ discard block |
||
| 100 | 100 | * @return string|null |
| 101 | 101 | */ |
| 102 | 102 | function calculer_url_redirect_entite($type, $id, $var_mode) { |
| 103 | - $desc = null; |
|
| 104 | - $publie = null; |
|
| 105 | - $url = null; |
|
| 106 | - // invalider le cache à chaque modif en bdd |
|
| 107 | - $date = 0; |
|
| 108 | - if (isset($GLOBALS['meta']['derniere_modif'])) { |
|
| 109 | - $date = $GLOBALS['meta']['derniere_modif']; |
|
| 110 | - } |
|
| 111 | - $key = "url-$date-$type-$id"; |
|
| 103 | + $desc = null; |
|
| 104 | + $publie = null; |
|
| 105 | + $url = null; |
|
| 106 | + // invalider le cache à chaque modif en bdd |
|
| 107 | + $date = 0; |
|
| 108 | + if (isset($GLOBALS['meta']['derniere_modif'])) { |
|
| 109 | + $date = $GLOBALS['meta']['derniere_modif']; |
|
| 110 | + } |
|
| 111 | + $key = "url-$date-$type-$id"; |
|
| 112 | 112 | |
| 113 | - // Obtenir l’url et si elle est publié du cache memoization |
|
| 114 | - if (function_exists('cache_get') and $desc = cache_get($key)) { |
|
| 115 | - [$url, $publie] = $desc; |
|
| 116 | - } |
|
| 117 | - // Si on ne l’a pas trouvé, ou si var mode, on calcule l’url et son état publie |
|
| 118 | - if (empty($desc) or $var_mode) { |
|
| 119 | - $publie = objet_test_si_publie($type, $id); |
|
| 120 | - $url = generer_objet_url_absolue($id, $type, '', '', true); |
|
| 121 | - if (function_exists('cache_set')) { |
|
| 122 | - cache_set($key, [$url, $publie], 3600); |
|
| 123 | - } |
|
| 124 | - } |
|
| 113 | + // Obtenir l’url et si elle est publié du cache memoization |
|
| 114 | + if (function_exists('cache_get') and $desc = cache_get($key)) { |
|
| 115 | + [$url, $publie] = $desc; |
|
| 116 | + } |
|
| 117 | + // Si on ne l’a pas trouvé, ou si var mode, on calcule l’url et son état publie |
|
| 118 | + if (empty($desc) or $var_mode) { |
|
| 119 | + $publie = objet_test_si_publie($type, $id); |
|
| 120 | + $url = generer_objet_url_absolue($id, $type, '', '', true); |
|
| 121 | + if (function_exists('cache_set')) { |
|
| 122 | + cache_set($key, [$url, $publie], 3600); |
|
| 123 | + } |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - // On valide l’url si elle est publiee ; sinon si preview on teste l’autorisation |
|
| 127 | - if ($publie) { |
|
| 128 | - return $url; |
|
| 129 | - } elseif (defined('_VAR_PREVIEW') and _VAR_PREVIEW and autoriser('voir', $type, $id)) { |
|
| 130 | - return $url; |
|
| 131 | - } |
|
| 126 | + // On valide l’url si elle est publiee ; sinon si preview on teste l’autorisation |
|
| 127 | + if ($publie) { |
|
| 128 | + return $url; |
|
| 129 | + } elseif (defined('_VAR_PREVIEW') and _VAR_PREVIEW and autoriser('voir', $type, $id)) { |
|
| 130 | + return $url; |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | - return; |
|
| 133 | + return; |
|
| 134 | 134 | } |