@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | function extraire_date($texte): string { |
| 40 | 40 | // format = 2001-08 |
| 41 | 41 | if (preg_match(',([1-2][0-9]{3})[^0-9]*(1[0-2]|0?[1-9]),', $texte, $regs)) { |
| 42 | - return $regs[1] . '-' . sprintf('%02d', $regs[2]) . '-01'; |
|
| 42 | + return $regs[1].'-'.sprintf('%02d', $regs[2]).'-01'; |
|
| 43 | 43 | } |
| 44 | 44 | return ''; |
| 45 | 45 | } |
@@ -70,11 +70,11 @@ discard block |
||
| 70 | 70 | } |
| 71 | 71 | if (preg_match('#^([12][0-9]{3})([-/]00)?( [-0-9:]+)?$#', $date, $regs)) { |
| 72 | 72 | $regs = array_pad($regs, 4, null); // eviter notice php |
| 73 | - $date = $regs[1] . '-00-00' . $regs[3]; |
|
| 73 | + $date = $regs[1].'-00-00'.$regs[3]; |
|
| 74 | 74 | } else { |
| 75 | 75 | if (preg_match('#^([12][0-9]{3}[-/][01]?[0-9])([-/]00)?( [-0-9:]+)?$#', $date, $regs)) { |
| 76 | 76 | $regs = array_pad($regs, 4, null); // eviter notice php |
| 77 | - $date = preg_replace('@/@', '-', $regs[1]) . '-00' . $regs[3]; |
|
| 77 | + $date = preg_replace('@/@', '-', $regs[1]).'-00'.$regs[3]; |
|
| 78 | 78 | } else { |
| 79 | 79 | $date = date('Y-m-d H:i:s', strtotime($date)); |
| 80 | 80 | } |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | $letexte ??= ''; |
| 102 | 102 | if ( |
| 103 | 103 | !$verif_format_date |
| 104 | - or (in_array(strlen($letexte), [10,19]) and |
|
| 104 | + or (in_array(strlen($letexte), [10, 19]) and |
|
| 105 | 105 | preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}(\s[0-9]{2}:[0-9]{2}:[0-9]{2})?$/', $letexte)) |
| 106 | 106 | ) { |
| 107 | 107 | if (strncmp('0000-00-00', $letexte, 10) == 0) { |
@@ -388,17 +388,17 @@ discard block |
||
| 388 | 388 | if ($decal > 3600 * 24 * 30) { |
| 389 | 389 | $mois = floor($decal / (3600 * 24 * 30)); |
| 390 | 390 | if ($mois < 2) { |
| 391 | - $delai = "$mois " . _T('date_un_mois'); |
|
| 391 | + $delai = "$mois "._T('date_un_mois'); |
|
| 392 | 392 | } else { |
| 393 | - $delai = "$mois " . _T('date_mois'); |
|
| 393 | + $delai = "$mois "._T('date_mois'); |
|
| 394 | 394 | } |
| 395 | 395 | } else { |
| 396 | 396 | if ($decal > 3600 * 24 * 7) { |
| 397 | 397 | $semaines = floor($decal / (3600 * 24 * 7)); |
| 398 | 398 | if ($semaines < 2) { |
| 399 | - $delai = "$semaines " . _T('date_une_semaine'); |
|
| 399 | + $delai = "$semaines "._T('date_une_semaine'); |
|
| 400 | 400 | } else { |
| 401 | - $delai = "$semaines " . _T('date_semaines'); |
|
| 401 | + $delai = "$semaines "._T('date_semaines'); |
|
| 402 | 402 | } |
| 403 | 403 | } else { |
| 404 | 404 | if ($decal > 3600 * 24) { |
@@ -406,30 +406,30 @@ discard block |
||
| 406 | 406 | if ($jours < 2) { |
| 407 | 407 | return $il_y_a == 'date_dans' ? _T('date_demain') : _T('date_hier'); |
| 408 | 408 | } else { |
| 409 | - $delai = "$jours " . _T('date_jours'); |
|
| 409 | + $delai = "$jours "._T('date_jours'); |
|
| 410 | 410 | } |
| 411 | 411 | } else { |
| 412 | 412 | if ($decal >= 3600) { |
| 413 | 413 | $heures = floor($decal / 3600); |
| 414 | 414 | if ($heures < 2) { |
| 415 | - $delai = "$heures " . _T('date_une_heure'); |
|
| 415 | + $delai = "$heures "._T('date_une_heure'); |
|
| 416 | 416 | } else { |
| 417 | - $delai = "$heures " . _T('date_heures'); |
|
| 417 | + $delai = "$heures "._T('date_heures'); |
|
| 418 | 418 | } |
| 419 | 419 | } else { |
| 420 | 420 | if ($decal >= 60) { |
| 421 | 421 | $minutes = floor($decal / 60); |
| 422 | 422 | if ($minutes < 2) { |
| 423 | - $delai = "$minutes " . _T('date_une_minute'); |
|
| 423 | + $delai = "$minutes "._T('date_une_minute'); |
|
| 424 | 424 | } else { |
| 425 | - $delai = "$minutes " . _T('date_minutes'); |
|
| 425 | + $delai = "$minutes "._T('date_minutes'); |
|
| 426 | 426 | } |
| 427 | 427 | } else { |
| 428 | 428 | $secondes = ceil($decal); |
| 429 | 429 | if ($secondes < 2) { |
| 430 | - $delai = "$secondes " . _T('date_une_seconde'); |
|
| 430 | + $delai = "$secondes "._T('date_une_seconde'); |
|
| 431 | 431 | } else { |
| 432 | - $delai = "$secondes " . _T('date_secondes'); |
|
| 432 | + $delai = "$secondes "._T('date_secondes'); |
|
| 433 | 433 | } |
| 434 | 434 | } |
| 435 | 435 | } |
@@ -522,7 +522,7 @@ discard block |
||
| 522 | 522 | $njour = 0; |
| 523 | 523 | } else { |
| 524 | 524 | $njour = intval($jour); |
| 525 | - if ($jourth = _T('date_jnum' . $jour)) { |
|
| 525 | + if ($jourth = _T('date_jnum'.$jour)) { |
|
| 526 | 526 | $jour = $jourth; |
| 527 | 527 | } |
| 528 | 528 | } |
@@ -530,10 +530,10 @@ discard block |
||
| 530 | 530 | $mois = intval($mois); |
| 531 | 531 | if ($mois > 0 and $mois < 13) { |
| 532 | 532 | /* Traiter le cas "abbr" pour les noms de mois */ |
| 533 | - $param = ((isset($options['param']) and $options['param'] === 'abbr') ? '_' . $options['param'] : ''); |
|
| 534 | - $nommois = _T('date_mois_' . $mois . $param); |
|
| 533 | + $param = ((isset($options['param']) and $options['param'] === 'abbr') ? '_'.$options['param'] : ''); |
|
| 534 | + $nommois = _T('date_mois_'.$mois.$param); |
|
| 535 | 535 | if ($jour) { |
| 536 | - $jourmois = _T('date_de_mois_' . $mois, ['j' => $jour, 'nommois' => $nommois]); |
|
| 536 | + $jourmois = _T('date_de_mois_'.$mois, ['j' => $jour, 'nommois' => $nommois]); |
|
| 537 | 537 | } else { |
| 538 | 538 | $jourmois = $nommois; |
| 539 | 539 | } |
@@ -543,7 +543,7 @@ discard block |
||
| 543 | 543 | } |
| 544 | 544 | |
| 545 | 545 | if ($annee < 0) { |
| 546 | - $annee = -$annee . ' ' . _T('date_avant_jc'); |
|
| 546 | + $annee = -$annee.' '._T('date_avant_jc'); |
|
| 547 | 547 | $avjc = true; |
| 548 | 548 | } else { |
| 549 | 549 | $avjc = false; |
@@ -569,11 +569,11 @@ discard block |
||
| 569 | 569 | } |
| 570 | 570 | } |
| 571 | 571 | if ($vue == 'saison') { |
| 572 | - return $saison ? _T('date_saison_' . $saison) : ''; |
|
| 572 | + return $saison ? _T('date_saison_'.$saison) : ''; |
|
| 573 | 573 | } else { |
| 574 | 574 | return $saison ? trim(_T( |
| 575 | 575 | 'date_fmt_saison_annee', |
| 576 | - ['saison' => _T('date_saison_' . $saison), 'annee' => $annee] |
|
| 576 | + ['saison' => _T('date_saison_'.$saison), 'annee' => $annee] |
|
| 577 | 577 | )) : ''; |
| 578 | 578 | } |
| 579 | 579 | |
@@ -650,9 +650,9 @@ discard block |
||
| 650 | 650 | } |
| 651 | 651 | $nom = mktime(1, 1, 1, $mois, $njour, $annee); |
| 652 | 652 | $nom = 1 + (int) date('w', $nom); |
| 653 | - $param = ((isset($options['param']) and $options['param']) ? '_' . $options['param'] : ''); |
|
| 653 | + $param = ((isset($options['param']) and $options['param']) ? '_'.$options['param'] : ''); |
|
| 654 | 654 | |
| 655 | - return _T('date_jour_' . $nom . $param); |
|
| 655 | + return _T('date_jour_'.$nom.$param); |
|
| 656 | 656 | |
| 657 | 657 | case 'mois_annee': |
| 658 | 658 | if ($avjc) { |
@@ -1047,8 +1047,8 @@ discard block |
||
| 1047 | 1047 | |
| 1048 | 1048 | $dtstart = $dtend = $dtabbr = ''; |
| 1049 | 1049 | if (strpos($forme, 'hcal') !== false) { |
| 1050 | - $dtstart = "<abbr class='dtstart' title='" . date_iso($date_debut) . "'>"; |
|
| 1051 | - $dtend = "<abbr class='dtend' title='" . date_iso($date_fin) . "'>"; |
|
| 1050 | + $dtstart = "<abbr class='dtstart' title='".date_iso($date_debut)."'>"; |
|
| 1051 | + $dtend = "<abbr class='dtend' title='".date_iso($date_fin)."'>"; |
|
| 1052 | 1052 | $dtabbr = '</abbr>'; |
| 1053 | 1053 | } |
| 1054 | 1054 | |
@@ -1096,7 +1096,7 @@ discard block |
||
| 1096 | 1096 | } |
| 1097 | 1097 | } else { |
| 1098 | 1098 | if ($dtabbr && $dtstart) { |
| 1099 | - $s = $dtstart . spip_ucfirst($s) . $dtabbr; |
|
| 1099 | + $s = $dtstart.spip_ucfirst($s).$dtabbr; |
|
| 1100 | 1100 | } else { |
| 1101 | 1101 | $s = spip_ucfirst($s); |
| 1102 | 1102 | } |
@@ -1119,8 +1119,8 @@ discard block |
||
| 1119 | 1119 | $date_debut = _T('date_fmt_jour_heure', ['jour' => $date_debut, 'heure' => $hd]); |
| 1120 | 1120 | $date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]); |
| 1121 | 1121 | } |
| 1122 | - $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1123 | - $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1122 | + $date_debut = $dtstart.$date_debut.$dtabbr; |
|
| 1123 | + $date_fin = $dtend.$date_fin.$dtabbr; |
|
| 1124 | 1124 | |
| 1125 | 1125 | $s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]); |
| 1126 | 1126 | } else { |
@@ -1137,8 +1137,8 @@ discard block |
||
| 1137 | 1137 | $date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]); |
| 1138 | 1138 | } |
| 1139 | 1139 | |
| 1140 | - $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1141 | - $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1140 | + $date_debut = $dtstart.$date_debut.$dtabbr; |
|
| 1141 | + $date_fin = $dtend.$date_fin.$dtabbr; |
|
| 1142 | 1142 | $s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]); |
| 1143 | 1143 | } |
| 1144 | 1144 | } |
@@ -1242,7 +1242,7 @@ discard block |
||
| 1242 | 1242 | $d = date('Y-m-d'); |
| 1243 | 1243 | } |
| 1244 | 1244 | |
| 1245 | - return substr($d, 0, 4) . substr($d, 5, 2) . substr($d, 8, 2); |
|
| 1245 | + return substr($d, 0, 4).substr($d, 5, 2).substr($d, 8, 2); |
|
| 1246 | 1246 | } |
| 1247 | 1247 | |
| 1248 | 1248 | /** |
@@ -1262,7 +1262,7 @@ discard block |
||
| 1262 | 1262 | $d = date('Y-m-d'); |
| 1263 | 1263 | } |
| 1264 | 1264 | |
| 1265 | - return substr($d, 0, 4) . substr($d, 5, 2); |
|
| 1265 | + return substr($d, 0, 4).substr($d, 5, 2); |
|
| 1266 | 1266 | } |
| 1267 | 1267 | |
| 1268 | 1268 | /** |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | * @package SPIP\Core\Filtres |
| 16 | 16 | **/ |
| 17 | 17 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 18 | - return; |
|
| 18 | + return; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | |
@@ -36,11 +36,11 @@ discard block |
||
| 36 | 36 | * Date au format SQL tel que `2008-04-01` sinon '' |
| 37 | 37 | **/ |
| 38 | 38 | function extraire_date($texte): string { |
| 39 | - // format = 2001-08 |
|
| 40 | - if (preg_match(',([1-2][0-9]{3})[^0-9]*(1[0-2]|0?[1-9]),', $texte, $regs)) { |
|
| 41 | - return $regs[1] . '-' . sprintf('%02d', $regs[2]) . '-01'; |
|
| 42 | - } |
|
| 43 | - return ''; |
|
| 39 | + // format = 2001-08 |
|
| 40 | + if (preg_match(',([1-2][0-9]{3})[^0-9]*(1[0-2]|0?[1-9]),', $texte, $regs)) { |
|
| 41 | + return $regs[1] . '-' . sprintf('%02d', $regs[2]) . '-01'; |
|
| 42 | + } |
|
| 43 | + return ''; |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | |
@@ -62,29 +62,29 @@ discard block |
||
| 62 | 62 | * - une chaîne vide si la date est considérée nulle |
| 63 | 63 | **/ |
| 64 | 64 | function normaliser_date($date, $forcer_jour = false): string { |
| 65 | - $date = vider_date($date); |
|
| 66 | - if ($date) { |
|
| 67 | - if (preg_match('/^[0-9]{8,10}$/', $date)) { |
|
| 68 | - $date = date('Y-m-d H:i:s', $date); |
|
| 69 | - } |
|
| 70 | - if (preg_match('#^([12][0-9]{3})([-/]00)?( [-0-9:]+)?$#', $date, $regs)) { |
|
| 71 | - $regs = array_pad($regs, 4, null); // eviter notice php |
|
| 72 | - $date = $regs[1] . '-00-00' . $regs[3]; |
|
| 73 | - } else { |
|
| 74 | - if (preg_match('#^([12][0-9]{3}[-/][01]?[0-9])([-/]00)?( [-0-9:]+)?$#', $date, $regs)) { |
|
| 75 | - $regs = array_pad($regs, 4, null); // eviter notice php |
|
| 76 | - $date = preg_replace('@/@', '-', $regs[1]) . '-00' . $regs[3]; |
|
| 77 | - } else { |
|
| 78 | - $date = date('Y-m-d H:i:s', strtotime($date)); |
|
| 79 | - } |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - if ($forcer_jour) { |
|
| 83 | - $date = str_replace('-00', '-01', $date); |
|
| 84 | - } |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - return $date; |
|
| 65 | + $date = vider_date($date); |
|
| 66 | + if ($date) { |
|
| 67 | + if (preg_match('/^[0-9]{8,10}$/', $date)) { |
|
| 68 | + $date = date('Y-m-d H:i:s', $date); |
|
| 69 | + } |
|
| 70 | + if (preg_match('#^([12][0-9]{3})([-/]00)?( [-0-9:]+)?$#', $date, $regs)) { |
|
| 71 | + $regs = array_pad($regs, 4, null); // eviter notice php |
|
| 72 | + $date = $regs[1] . '-00-00' . $regs[3]; |
|
| 73 | + } else { |
|
| 74 | + if (preg_match('#^([12][0-9]{3}[-/][01]?[0-9])([-/]00)?( [-0-9:]+)?$#', $date, $regs)) { |
|
| 75 | + $regs = array_pad($regs, 4, null); // eviter notice php |
|
| 76 | + $date = preg_replace('@/@', '-', $regs[1]) . '-00' . $regs[3]; |
|
| 77 | + } else { |
|
| 78 | + $date = date('Y-m-d H:i:s', strtotime($date)); |
|
| 79 | + } |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + if ($forcer_jour) { |
|
| 83 | + $date = str_replace('-00', '-01', $date); |
|
| 84 | + } |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + return $date; |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | /** |
@@ -97,23 +97,23 @@ discard block |
||
| 97 | 97 | * - Une chaine vide |
| 98 | 98 | **/ |
| 99 | 99 | function vider_date($letexte, $verif_format_date = false): string { |
| 100 | - $letexte ??= ''; |
|
| 101 | - if ( |
|
| 102 | - !$verif_format_date |
|
| 103 | - or (in_array(strlen($letexte), [10,19]) and |
|
| 104 | - preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}(\s[0-9]{2}:[0-9]{2}:[0-9]{2})?$/', $letexte)) |
|
| 105 | - ) { |
|
| 106 | - if (strncmp('0000-00-00', $letexte, 10) == 0) { |
|
| 107 | - return ''; |
|
| 108 | - } |
|
| 109 | - if (strncmp('0001-01-01', $letexte, 10) == 0) { |
|
| 110 | - return ''; |
|
| 111 | - } |
|
| 112 | - if (strncmp('1970-01-01', $letexte, 10) == 0) { |
|
| 113 | - return ''; |
|
| 114 | - } // eviter le bug GMT-1 |
|
| 115 | - } |
|
| 116 | - return $letexte; |
|
| 100 | + $letexte ??= ''; |
|
| 101 | + if ( |
|
| 102 | + !$verif_format_date |
|
| 103 | + or (in_array(strlen($letexte), [10,19]) and |
|
| 104 | + preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}(\s[0-9]{2}:[0-9]{2}:[0-9]{2})?$/', $letexte)) |
|
| 105 | + ) { |
|
| 106 | + if (strncmp('0000-00-00', $letexte, 10) == 0) { |
|
| 107 | + return ''; |
|
| 108 | + } |
|
| 109 | + if (strncmp('0001-01-01', $letexte, 10) == 0) { |
|
| 110 | + return ''; |
|
| 111 | + } |
|
| 112 | + if (strncmp('1970-01-01', $letexte, 10) == 0) { |
|
| 113 | + return ''; |
|
| 114 | + } // eviter le bug GMT-1 |
|
| 115 | + } |
|
| 116 | + return $letexte; |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | /** |
@@ -129,17 +129,17 @@ discard block |
||
| 129 | 129 | **/ |
| 130 | 130 | function recup_heure($date): array { |
| 131 | 131 | |
| 132 | - if (preg_match('#([0-9]{1,2}):([0-9]{1,2})(?::([0-9]{1,2}))?#', $date, $elements)) { |
|
| 133 | - array_shift($elements); |
|
| 134 | - if (!isset($elements[2])) { |
|
| 135 | - $elements[2] = 0; |
|
| 136 | - } |
|
| 137 | - $heure = $elements; |
|
| 138 | - } else { |
|
| 139 | - $heure = [0, 0, 0]; |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - return $heure; |
|
| 132 | + if (preg_match('#([0-9]{1,2}):([0-9]{1,2})(?::([0-9]{1,2}))?#', $date, $elements)) { |
|
| 133 | + array_shift($elements); |
|
| 134 | + if (!isset($elements[2])) { |
|
| 135 | + $elements[2] = 0; |
|
| 136 | + } |
|
| 137 | + $heure = $elements; |
|
| 138 | + } else { |
|
| 139 | + $heure = [0, 0, 0]; |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + return $heure; |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | /** |
@@ -153,13 +153,13 @@ discard block |
||
| 153 | 153 | * @return string heures, sinon 0 |
| 154 | 154 | **/ |
| 155 | 155 | function heures($numdate): string { |
| 156 | - $heures = null; |
|
| 157 | - $date_array = recup_heure($numdate); |
|
| 158 | - if ($date_array) { |
|
| 159 | - [$heures, $minutes, $secondes] = $date_array; |
|
| 160 | - } |
|
| 156 | + $heures = null; |
|
| 157 | + $date_array = recup_heure($numdate); |
|
| 158 | + if ($date_array) { |
|
| 159 | + [$heures, $minutes, $secondes] = $date_array; |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | - return $heures; |
|
| 162 | + return $heures; |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | /** |
@@ -173,13 +173,13 @@ discard block |
||
| 173 | 173 | * @return string minutes, sinon 0 |
| 174 | 174 | **/ |
| 175 | 175 | function minutes($numdate): string { |
| 176 | - $minutes = null; |
|
| 177 | - $date_array = recup_heure($numdate); |
|
| 178 | - if ($date_array) { |
|
| 179 | - [$heures, $minutes, $secondes] = $date_array; |
|
| 180 | - } |
|
| 176 | + $minutes = null; |
|
| 177 | + $date_array = recup_heure($numdate); |
|
| 178 | + if ($date_array) { |
|
| 179 | + [$heures, $minutes, $secondes] = $date_array; |
|
| 180 | + } |
|
| 181 | 181 | |
| 182 | - return $minutes; |
|
| 182 | + return $minutes; |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | /** |
@@ -193,13 +193,13 @@ discard block |
||
| 193 | 193 | * @return string secondes, sinon 0 |
| 194 | 194 | **/ |
| 195 | 195 | function secondes($numdate): string { |
| 196 | - $secondes = null; |
|
| 197 | - $date_array = recup_heure($numdate); |
|
| 198 | - if ($date_array) { |
|
| 199 | - [$heures, $minutes, $secondes] = $date_array; |
|
| 200 | - } |
|
| 196 | + $secondes = null; |
|
| 197 | + $date_array = recup_heure($numdate); |
|
| 198 | + if ($date_array) { |
|
| 199 | + [$heures, $minutes, $secondes] = $date_array; |
|
| 200 | + } |
|
| 201 | 201 | |
| 202 | - return $secondes; |
|
| 202 | + return $secondes; |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | /** |
@@ -218,11 +218,11 @@ discard block |
||
| 218 | 218 | * @return string L'heure formatée dans la langue en cours. |
| 219 | 219 | **/ |
| 220 | 220 | function heures_minutes($numdate, $forme = ''): string { |
| 221 | - if ($forme !== 'abbr') { |
|
| 222 | - return _T('date_fmt_heures_minutes', ['h' => heures($numdate), 'm' => minutes($numdate)]); |
|
| 223 | - } else { |
|
| 224 | - return _T('date_fmt_heures_minutes_court', ['h' => heures($numdate), 'm' => minutes($numdate)]); |
|
| 225 | - } |
|
| 221 | + if ($forme !== 'abbr') { |
|
| 222 | + return _T('date_fmt_heures_minutes', ['h' => heures($numdate), 'm' => minutes($numdate)]); |
|
| 223 | + } else { |
|
| 224 | + return _T('date_fmt_heures_minutes_court', ['h' => heures($numdate), 'm' => minutes($numdate)]); |
|
| 225 | + } |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | /** |
@@ -247,57 +247,57 @@ discard block |
||
| 247 | 247 | * @return array [année, mois, jour, heures, minutes, secondes] ou [] |
| 248 | 248 | **/ |
| 249 | 249 | function recup_date($numdate, $forcer_jour = true): array { |
| 250 | - if (!$numdate) { |
|
| 251 | - return []; |
|
| 252 | - } |
|
| 253 | - $heures = $minutes = $secondes = 0; |
|
| 254 | - if (preg_match('#([0-9]{1,2})/([0-9]{1,2})/([0-9]{4}|[0-9]{1,2})#', $numdate, $regs)) { |
|
| 255 | - $jour = $regs[1]; |
|
| 256 | - $mois = $regs[2]; |
|
| 257 | - $annee = $regs[3]; |
|
| 258 | - if ($annee < 90) { |
|
| 259 | - $annee = 2000 + $annee; |
|
| 260 | - } elseif ($annee < 100) { |
|
| 261 | - $annee = 1900 + $annee; |
|
| 262 | - } |
|
| 263 | - [$heures, $minutes, $secondes] = recup_heure($numdate); |
|
| 264 | - } elseif (preg_match('#([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})#', $numdate, $regs)) { |
|
| 265 | - $annee = $regs[1]; |
|
| 266 | - $mois = $regs[2]; |
|
| 267 | - $jour = $regs[3]; |
|
| 268 | - [$heures, $minutes, $secondes] = recup_heure($numdate); |
|
| 269 | - } elseif (preg_match('#([0-9]{4})-([0-9]{2})#', $numdate, $regs)) { |
|
| 270 | - $annee = $regs[1]; |
|
| 271 | - $mois = $regs[2]; |
|
| 272 | - $jour = ''; |
|
| 273 | - [$heures, $minutes, $secondes] = recup_heure($numdate); |
|
| 274 | - } elseif (preg_match('#^([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#', $numdate, $regs)) { |
|
| 275 | - $annee = $regs[1]; |
|
| 276 | - $mois = $regs[2]; |
|
| 277 | - $jour = $regs[3]; |
|
| 278 | - $heures = $regs[4]; |
|
| 279 | - $minutes = $regs[5]; |
|
| 280 | - $secondes = $regs[6]; |
|
| 281 | - } else { |
|
| 282 | - $annee = $mois = $jour = ''; |
|
| 283 | - } |
|
| 284 | - if ($annee > 4000) { |
|
| 285 | - $annee -= 9000; |
|
| 286 | - } |
|
| 287 | - if (strlen($jour) and substr($jour, 0, 1) == '0') { |
|
| 288 | - $jour = substr($jour, 1); |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - if ($forcer_jour and $jour == '0') { |
|
| 292 | - $jour = '1'; |
|
| 293 | - } |
|
| 294 | - if ($forcer_jour and $mois == '0') { |
|
| 295 | - $mois = '1'; |
|
| 296 | - } |
|
| 297 | - if ($annee or $mois or $jour or $heures or $minutes or $secondes) { |
|
| 298 | - return [$annee, $mois, $jour, $heures, $minutes, $secondes]; |
|
| 299 | - } |
|
| 300 | - return []; |
|
| 250 | + if (!$numdate) { |
|
| 251 | + return []; |
|
| 252 | + } |
|
| 253 | + $heures = $minutes = $secondes = 0; |
|
| 254 | + if (preg_match('#([0-9]{1,2})/([0-9]{1,2})/([0-9]{4}|[0-9]{1,2})#', $numdate, $regs)) { |
|
| 255 | + $jour = $regs[1]; |
|
| 256 | + $mois = $regs[2]; |
|
| 257 | + $annee = $regs[3]; |
|
| 258 | + if ($annee < 90) { |
|
| 259 | + $annee = 2000 + $annee; |
|
| 260 | + } elseif ($annee < 100) { |
|
| 261 | + $annee = 1900 + $annee; |
|
| 262 | + } |
|
| 263 | + [$heures, $minutes, $secondes] = recup_heure($numdate); |
|
| 264 | + } elseif (preg_match('#([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})#', $numdate, $regs)) { |
|
| 265 | + $annee = $regs[1]; |
|
| 266 | + $mois = $regs[2]; |
|
| 267 | + $jour = $regs[3]; |
|
| 268 | + [$heures, $minutes, $secondes] = recup_heure($numdate); |
|
| 269 | + } elseif (preg_match('#([0-9]{4})-([0-9]{2})#', $numdate, $regs)) { |
|
| 270 | + $annee = $regs[1]; |
|
| 271 | + $mois = $regs[2]; |
|
| 272 | + $jour = ''; |
|
| 273 | + [$heures, $minutes, $secondes] = recup_heure($numdate); |
|
| 274 | + } elseif (preg_match('#^([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#', $numdate, $regs)) { |
|
| 275 | + $annee = $regs[1]; |
|
| 276 | + $mois = $regs[2]; |
|
| 277 | + $jour = $regs[3]; |
|
| 278 | + $heures = $regs[4]; |
|
| 279 | + $minutes = $regs[5]; |
|
| 280 | + $secondes = $regs[6]; |
|
| 281 | + } else { |
|
| 282 | + $annee = $mois = $jour = ''; |
|
| 283 | + } |
|
| 284 | + if ($annee > 4000) { |
|
| 285 | + $annee -= 9000; |
|
| 286 | + } |
|
| 287 | + if (strlen($jour) and substr($jour, 0, 1) == '0') { |
|
| 288 | + $jour = substr($jour, 1); |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + if ($forcer_jour and $jour == '0') { |
|
| 292 | + $jour = '1'; |
|
| 293 | + } |
|
| 294 | + if ($forcer_jour and $mois == '0') { |
|
| 295 | + $mois = '1'; |
|
| 296 | + } |
|
| 297 | + if ($annee or $mois or $jour or $heures or $minutes or $secondes) { |
|
| 298 | + return [$annee, $mois, $jour, $heures, $minutes, $secondes]; |
|
| 299 | + } |
|
| 300 | + return []; |
|
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | /** |
@@ -324,10 +324,10 @@ discard block |
||
| 324 | 324 | * La date relative ou complète |
| 325 | 325 | **/ |
| 326 | 326 | function date_interface($date, $decalage_maxi = 43200 /* 12*3600 */): string { |
| 327 | - return sinon( |
|
| 328 | - date_relative($date, $decalage_maxi), |
|
| 329 | - affdate_heure($date) |
|
| 330 | - ); |
|
| 327 | + return sinon( |
|
| 328 | + date_relative($date, $decalage_maxi), |
|
| 329 | + affdate_heure($date) |
|
| 330 | + ); |
|
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | /** |
@@ -360,86 +360,86 @@ discard block |
||
| 360 | 360 | **/ |
| 361 | 361 | function date_relative($date, $decalage_maxi = 0, $ref_date = null): string { |
| 362 | 362 | |
| 363 | - if (!$date) { |
|
| 364 | - return ''; |
|
| 365 | - } |
|
| 366 | - |
|
| 367 | - if (is_null($ref_date)) { |
|
| 368 | - $ref_time = time(); |
|
| 369 | - } else { |
|
| 370 | - $ref_time = strtotime($ref_date); |
|
| 371 | - } |
|
| 372 | - |
|
| 373 | - $decal = date('U', $ref_time) - date('U', strtotime($date)); |
|
| 374 | - |
|
| 375 | - if ($decalage_maxi and ($decal > $decalage_maxi or $decal < 0)) { |
|
| 376 | - return ''; |
|
| 377 | - } |
|
| 378 | - |
|
| 379 | - if ($decal < 0) { |
|
| 380 | - $il_y_a = 'date_dans'; |
|
| 381 | - $decal = -1 * $decal; |
|
| 382 | - } else { |
|
| 383 | - $il_y_a = 'date_il_y_a'; |
|
| 384 | - } |
|
| 385 | - |
|
| 386 | - if ($decal > 3600 * 24 * 30 * 6) { |
|
| 387 | - return affdate_court($date); |
|
| 388 | - } |
|
| 389 | - |
|
| 390 | - if ($decal > 3600 * 24 * 30) { |
|
| 391 | - $mois = floor($decal / (3600 * 24 * 30)); |
|
| 392 | - if ($mois < 2) { |
|
| 393 | - $delai = "$mois " . _T('date_un_mois'); |
|
| 394 | - } else { |
|
| 395 | - $delai = "$mois " . _T('date_mois'); |
|
| 396 | - } |
|
| 397 | - } else { |
|
| 398 | - if ($decal > 3600 * 24 * 7) { |
|
| 399 | - $semaines = floor($decal / (3600 * 24 * 7)); |
|
| 400 | - if ($semaines < 2) { |
|
| 401 | - $delai = "$semaines " . _T('date_une_semaine'); |
|
| 402 | - } else { |
|
| 403 | - $delai = "$semaines " . _T('date_semaines'); |
|
| 404 | - } |
|
| 405 | - } else { |
|
| 406 | - if ($decal > 3600 * 24) { |
|
| 407 | - $jours = floor($decal / (3600 * 24)); |
|
| 408 | - if ($jours < 2) { |
|
| 409 | - return $il_y_a == 'date_dans' ? _T('date_demain') : _T('date_hier'); |
|
| 410 | - } else { |
|
| 411 | - $delai = "$jours " . _T('date_jours'); |
|
| 412 | - } |
|
| 413 | - } else { |
|
| 414 | - if ($decal >= 3600) { |
|
| 415 | - $heures = floor($decal / 3600); |
|
| 416 | - if ($heures < 2) { |
|
| 417 | - $delai = "$heures " . _T('date_une_heure'); |
|
| 418 | - } else { |
|
| 419 | - $delai = "$heures " . _T('date_heures'); |
|
| 420 | - } |
|
| 421 | - } else { |
|
| 422 | - if ($decal >= 60) { |
|
| 423 | - $minutes = floor($decal / 60); |
|
| 424 | - if ($minutes < 2) { |
|
| 425 | - $delai = "$minutes " . _T('date_une_minute'); |
|
| 426 | - } else { |
|
| 427 | - $delai = "$minutes " . _T('date_minutes'); |
|
| 428 | - } |
|
| 429 | - } else { |
|
| 430 | - $secondes = ceil($decal); |
|
| 431 | - if ($secondes < 2) { |
|
| 432 | - $delai = "$secondes " . _T('date_une_seconde'); |
|
| 433 | - } else { |
|
| 434 | - $delai = "$secondes " . _T('date_secondes'); |
|
| 435 | - } |
|
| 436 | - } |
|
| 437 | - } |
|
| 438 | - } |
|
| 439 | - } |
|
| 440 | - } |
|
| 441 | - |
|
| 442 | - return _T($il_y_a, ['delai' => $delai]); |
|
| 363 | + if (!$date) { |
|
| 364 | + return ''; |
|
| 365 | + } |
|
| 366 | + |
|
| 367 | + if (is_null($ref_date)) { |
|
| 368 | + $ref_time = time(); |
|
| 369 | + } else { |
|
| 370 | + $ref_time = strtotime($ref_date); |
|
| 371 | + } |
|
| 372 | + |
|
| 373 | + $decal = date('U', $ref_time) - date('U', strtotime($date)); |
|
| 374 | + |
|
| 375 | + if ($decalage_maxi and ($decal > $decalage_maxi or $decal < 0)) { |
|
| 376 | + return ''; |
|
| 377 | + } |
|
| 378 | + |
|
| 379 | + if ($decal < 0) { |
|
| 380 | + $il_y_a = 'date_dans'; |
|
| 381 | + $decal = -1 * $decal; |
|
| 382 | + } else { |
|
| 383 | + $il_y_a = 'date_il_y_a'; |
|
| 384 | + } |
|
| 385 | + |
|
| 386 | + if ($decal > 3600 * 24 * 30 * 6) { |
|
| 387 | + return affdate_court($date); |
|
| 388 | + } |
|
| 389 | + |
|
| 390 | + if ($decal > 3600 * 24 * 30) { |
|
| 391 | + $mois = floor($decal / (3600 * 24 * 30)); |
|
| 392 | + if ($mois < 2) { |
|
| 393 | + $delai = "$mois " . _T('date_un_mois'); |
|
| 394 | + } else { |
|
| 395 | + $delai = "$mois " . _T('date_mois'); |
|
| 396 | + } |
|
| 397 | + } else { |
|
| 398 | + if ($decal > 3600 * 24 * 7) { |
|
| 399 | + $semaines = floor($decal / (3600 * 24 * 7)); |
|
| 400 | + if ($semaines < 2) { |
|
| 401 | + $delai = "$semaines " . _T('date_une_semaine'); |
|
| 402 | + } else { |
|
| 403 | + $delai = "$semaines " . _T('date_semaines'); |
|
| 404 | + } |
|
| 405 | + } else { |
|
| 406 | + if ($decal > 3600 * 24) { |
|
| 407 | + $jours = floor($decal / (3600 * 24)); |
|
| 408 | + if ($jours < 2) { |
|
| 409 | + return $il_y_a == 'date_dans' ? _T('date_demain') : _T('date_hier'); |
|
| 410 | + } else { |
|
| 411 | + $delai = "$jours " . _T('date_jours'); |
|
| 412 | + } |
|
| 413 | + } else { |
|
| 414 | + if ($decal >= 3600) { |
|
| 415 | + $heures = floor($decal / 3600); |
|
| 416 | + if ($heures < 2) { |
|
| 417 | + $delai = "$heures " . _T('date_une_heure'); |
|
| 418 | + } else { |
|
| 419 | + $delai = "$heures " . _T('date_heures'); |
|
| 420 | + } |
|
| 421 | + } else { |
|
| 422 | + if ($decal >= 60) { |
|
| 423 | + $minutes = floor($decal / 60); |
|
| 424 | + if ($minutes < 2) { |
|
| 425 | + $delai = "$minutes " . _T('date_une_minute'); |
|
| 426 | + } else { |
|
| 427 | + $delai = "$minutes " . _T('date_minutes'); |
|
| 428 | + } |
|
| 429 | + } else { |
|
| 430 | + $secondes = ceil($decal); |
|
| 431 | + if ($secondes < 2) { |
|
| 432 | + $delai = "$secondes " . _T('date_une_seconde'); |
|
| 433 | + } else { |
|
| 434 | + $delai = "$secondes " . _T('date_secondes'); |
|
| 435 | + } |
|
| 436 | + } |
|
| 437 | + } |
|
| 438 | + } |
|
| 439 | + } |
|
| 440 | + } |
|
| 441 | + |
|
| 442 | + return _T($il_y_a, ['delai' => $delai]); |
|
| 443 | 443 | } |
| 444 | 444 | |
| 445 | 445 | |
@@ -465,32 +465,32 @@ discard block |
||
| 465 | 465 | **/ |
| 466 | 466 | function date_relativecourt($date, $decalage_maxi = 0): string { |
| 467 | 467 | |
| 468 | - if (!$date) { |
|
| 469 | - return ''; |
|
| 470 | - } |
|
| 471 | - $decal = date('U', strtotime(date('Y-m-d')) - strtotime(date('Y-m-d', strtotime($date)))); |
|
| 472 | - |
|
| 473 | - if ($decalage_maxi and ($decal > $decalage_maxi or $decal < 0)) { |
|
| 474 | - return ''; |
|
| 475 | - } |
|
| 476 | - |
|
| 477 | - if ($decal < -24 * 3600) { |
|
| 478 | - $retour = date_relative($date, $decalage_maxi); |
|
| 479 | - } elseif ($decal < 0) { |
|
| 480 | - $retour = _T('date_demain'); |
|
| 481 | - } else { |
|
| 482 | - if ($decal < (3600 * 24)) { |
|
| 483 | - $retour = _T('date_aujourdhui'); |
|
| 484 | - } else { |
|
| 485 | - if ($decal < (3600 * 24 * 2)) { |
|
| 486 | - $retour = _T('date_hier'); |
|
| 487 | - } else { |
|
| 488 | - $retour = date_relative($date, $decalage_maxi); |
|
| 489 | - } |
|
| 490 | - } |
|
| 491 | - } |
|
| 492 | - |
|
| 493 | - return $retour; |
|
| 468 | + if (!$date) { |
|
| 469 | + return ''; |
|
| 470 | + } |
|
| 471 | + $decal = date('U', strtotime(date('Y-m-d')) - strtotime(date('Y-m-d', strtotime($date)))); |
|
| 472 | + |
|
| 473 | + if ($decalage_maxi and ($decal > $decalage_maxi or $decal < 0)) { |
|
| 474 | + return ''; |
|
| 475 | + } |
|
| 476 | + |
|
| 477 | + if ($decal < -24 * 3600) { |
|
| 478 | + $retour = date_relative($date, $decalage_maxi); |
|
| 479 | + } elseif ($decal < 0) { |
|
| 480 | + $retour = _T('date_demain'); |
|
| 481 | + } else { |
|
| 482 | + if ($decal < (3600 * 24)) { |
|
| 483 | + $retour = _T('date_aujourdhui'); |
|
| 484 | + } else { |
|
| 485 | + if ($decal < (3600 * 24 * 2)) { |
|
| 486 | + $retour = _T('date_hier'); |
|
| 487 | + } else { |
|
| 488 | + $retour = date_relative($date, $decalage_maxi); |
|
| 489 | + } |
|
| 490 | + } |
|
| 491 | + } |
|
| 492 | + |
|
| 493 | + return $retour; |
|
| 494 | 494 | } |
| 495 | 495 | |
| 496 | 496 | /** |
@@ -507,175 +507,175 @@ discard block |
||
| 507 | 507 | * @return string |
| 508 | 508 | */ |
| 509 | 509 | function affdate_base($numdate, $vue, $options = []): string { |
| 510 | - if (is_string($options)) { |
|
| 511 | - $options = ['param' => $options]; |
|
| 512 | - } |
|
| 513 | - $date_array = recup_date($numdate, false); |
|
| 514 | - if (!$date_array) { |
|
| 515 | - return ''; |
|
| 516 | - } |
|
| 517 | - [$annee, $mois, $jour, $heures, $minutes, $secondes] = $date_array; |
|
| 518 | - |
|
| 519 | - // 1er, 21st, etc. |
|
| 520 | - $journum = $jour; |
|
| 521 | - |
|
| 522 | - if ($jour == 0) { |
|
| 523 | - $jour = ''; |
|
| 524 | - $njour = 0; |
|
| 525 | - } else { |
|
| 526 | - $njour = intval($jour); |
|
| 527 | - if ($jourth = _T('date_jnum' . $jour)) { |
|
| 528 | - $jour = $jourth; |
|
| 529 | - } |
|
| 530 | - } |
|
| 531 | - |
|
| 532 | - $mois = intval($mois); |
|
| 533 | - if ($mois > 0 and $mois < 13) { |
|
| 534 | - /* Traiter le cas "abbr" pour les noms de mois */ |
|
| 535 | - $param = ((isset($options['param']) and $options['param'] === 'abbr') ? '_' . $options['param'] : ''); |
|
| 536 | - $nommois = _T('date_mois_' . $mois . $param); |
|
| 537 | - if ($jour) { |
|
| 538 | - $jourmois = _T('date_de_mois_' . $mois, ['j' => $jour, 'nommois' => $nommois]); |
|
| 539 | - } else { |
|
| 540 | - $jourmois = $nommois; |
|
| 541 | - } |
|
| 542 | - } else { |
|
| 543 | - $nommois = ''; |
|
| 544 | - $jourmois = ''; |
|
| 545 | - } |
|
| 546 | - |
|
| 547 | - if ($annee < 0) { |
|
| 548 | - $annee = -$annee . ' ' . _T('date_avant_jc'); |
|
| 549 | - $avjc = true; |
|
| 550 | - } else { |
|
| 551 | - $avjc = false; |
|
| 552 | - } |
|
| 553 | - |
|
| 554 | - switch ($vue) { |
|
| 555 | - case 'saison': |
|
| 556 | - case 'saison_annee': |
|
| 557 | - $saison = ''; |
|
| 558 | - if ($mois > 0) { |
|
| 559 | - $saison = ($options['param'] == 'sud') ? 3 : 1; |
|
| 560 | - if (($mois == 3 and $jour >= 21) or $mois > 3) { |
|
| 561 | - $saison = ($options['param'] == 'sud') ? 4 : 2; |
|
| 562 | - } |
|
| 563 | - if (($mois == 6 and $jour >= 21) or $mois > 6) { |
|
| 564 | - $saison = ($options['param'] == 'sud') ? 1 : 3; |
|
| 565 | - } |
|
| 566 | - if (($mois == 9 and $jour >= 21) or $mois > 9) { |
|
| 567 | - $saison = ($options['param'] == 'sud') ? 2 : 4; |
|
| 568 | - } |
|
| 569 | - if (($mois == 12 and $jour >= 21) or $mois > 12) { |
|
| 570 | - $saison = ($options['param'] == 'sud') ? 3 : 1; |
|
| 571 | - } |
|
| 572 | - } |
|
| 573 | - if ($vue == 'saison') { |
|
| 574 | - return $saison ? _T('date_saison_' . $saison) : ''; |
|
| 575 | - } else { |
|
| 576 | - return $saison ? trim(_T( |
|
| 577 | - 'date_fmt_saison_annee', |
|
| 578 | - ['saison' => _T('date_saison_' . $saison), 'annee' => $annee] |
|
| 579 | - )) : ''; |
|
| 580 | - } |
|
| 581 | - |
|
| 582 | - case 'court': |
|
| 583 | - if ($avjc) { |
|
| 584 | - return $annee; |
|
| 585 | - } |
|
| 586 | - $a = ((isset($options['annee_courante']) and $options['annee_courante']) ? $options['annee_courante'] : date('Y')); |
|
| 587 | - if ($annee < ($a - 100) or $annee > ($a + 100)) { |
|
| 588 | - return $annee; |
|
| 589 | - } |
|
| 590 | - if ($annee != $a) { |
|
| 591 | - return _T( |
|
| 592 | - 'date_fmt_mois_annee', |
|
| 593 | - ['mois' => $mois, 'nommois' => spip_ucfirst($nommois), 'annee' => $annee] |
|
| 594 | - ); |
|
| 595 | - } |
|
| 596 | - |
|
| 597 | - return _T( |
|
| 598 | - 'date_fmt_jour_mois', |
|
| 599 | - ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 600 | - ); |
|
| 601 | - |
|
| 602 | - case 'jourcourt': |
|
| 603 | - if ($avjc) { |
|
| 604 | - return $annee; |
|
| 605 | - } |
|
| 606 | - $a = ((isset($options['annee_courante']) and $options['annee_courante']) ? $options['annee_courante'] : date('Y')); |
|
| 607 | - if ($annee < ($a - 100) or $annee > ($a + 100)) { |
|
| 608 | - return $annee; |
|
| 609 | - } |
|
| 610 | - if ($annee != $a) { |
|
| 611 | - return _T( |
|
| 612 | - 'date_fmt_jour_mois_annee', |
|
| 613 | - ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 614 | - ); |
|
| 615 | - } |
|
| 616 | - |
|
| 617 | - return _T( |
|
| 618 | - 'date_fmt_jour_mois', |
|
| 619 | - ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 620 | - ); |
|
| 621 | - |
|
| 622 | - case 'entier': |
|
| 623 | - if ($avjc) { |
|
| 624 | - return $annee; |
|
| 625 | - } |
|
| 626 | - if ($jour) { |
|
| 627 | - return _T( |
|
| 628 | - 'date_fmt_jour_mois_annee', |
|
| 629 | - ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 630 | - ); |
|
| 631 | - } elseif ($mois) { |
|
| 632 | - return trim(_T('date_fmt_mois_annee', ['mois' => $mois, 'nommois' => $nommois, 'annee' => $annee])); |
|
| 633 | - } else { |
|
| 634 | - return $annee; |
|
| 635 | - } |
|
| 636 | - |
|
| 637 | - case 'nom_mois': |
|
| 638 | - return $nommois; |
|
| 639 | - |
|
| 640 | - case 'mois': |
|
| 641 | - return sprintf('%02s', $mois); |
|
| 642 | - |
|
| 643 | - case 'jour': |
|
| 644 | - return $jour; |
|
| 645 | - |
|
| 646 | - case 'journum': |
|
| 647 | - return $journum; |
|
| 648 | - |
|
| 649 | - case 'nom_jour': |
|
| 650 | - if (!$mois or !$njour) { |
|
| 651 | - return ''; |
|
| 652 | - } |
|
| 653 | - $nom = mktime(1, 1, 1, $mois, $njour, $annee); |
|
| 654 | - $nom = 1 + (int) date('w', $nom); |
|
| 655 | - $param = ((isset($options['param']) and $options['param']) ? '_' . $options['param'] : ''); |
|
| 656 | - |
|
| 657 | - return _T('date_jour_' . $nom . $param); |
|
| 658 | - |
|
| 659 | - case 'mois_annee': |
|
| 660 | - if ($avjc) { |
|
| 661 | - return $annee; |
|
| 662 | - } |
|
| 663 | - |
|
| 664 | - return trim(_T('date_fmt_mois_annee', ['mois' => $mois, 'nommois' => $nommois, 'annee' => $annee])); |
|
| 665 | - |
|
| 666 | - case 'annee': |
|
| 667 | - return $annee; |
|
| 668 | - |
|
| 669 | - // Cas d'une vue non definie : retomber sur le format |
|
| 670 | - // de date propose par http://www.php.net/date |
|
| 671 | - default: |
|
| 672 | - [$annee, $mois, $jour, $heures, $minutes, $secondes] = $date_array; |
|
| 673 | - // il faut envoyer jour = 1 si jour pas défini, c'est le comportement qu'on avait historiquement en envoyant '' |
|
| 674 | - if (!$time = mktime($heures, $minutes, $secondes, $mois, is_numeric($jour) ? $jour : 1, $annee)) { |
|
| 675 | - $time = strtotime($numdate); |
|
| 676 | - } |
|
| 677 | - return date($vue, $time); |
|
| 678 | - } |
|
| 510 | + if (is_string($options)) { |
|
| 511 | + $options = ['param' => $options]; |
|
| 512 | + } |
|
| 513 | + $date_array = recup_date($numdate, false); |
|
| 514 | + if (!$date_array) { |
|
| 515 | + return ''; |
|
| 516 | + } |
|
| 517 | + [$annee, $mois, $jour, $heures, $minutes, $secondes] = $date_array; |
|
| 518 | + |
|
| 519 | + // 1er, 21st, etc. |
|
| 520 | + $journum = $jour; |
|
| 521 | + |
|
| 522 | + if ($jour == 0) { |
|
| 523 | + $jour = ''; |
|
| 524 | + $njour = 0; |
|
| 525 | + } else { |
|
| 526 | + $njour = intval($jour); |
|
| 527 | + if ($jourth = _T('date_jnum' . $jour)) { |
|
| 528 | + $jour = $jourth; |
|
| 529 | + } |
|
| 530 | + } |
|
| 531 | + |
|
| 532 | + $mois = intval($mois); |
|
| 533 | + if ($mois > 0 and $mois < 13) { |
|
| 534 | + /* Traiter le cas "abbr" pour les noms de mois */ |
|
| 535 | + $param = ((isset($options['param']) and $options['param'] === 'abbr') ? '_' . $options['param'] : ''); |
|
| 536 | + $nommois = _T('date_mois_' . $mois . $param); |
|
| 537 | + if ($jour) { |
|
| 538 | + $jourmois = _T('date_de_mois_' . $mois, ['j' => $jour, 'nommois' => $nommois]); |
|
| 539 | + } else { |
|
| 540 | + $jourmois = $nommois; |
|
| 541 | + } |
|
| 542 | + } else { |
|
| 543 | + $nommois = ''; |
|
| 544 | + $jourmois = ''; |
|
| 545 | + } |
|
| 546 | + |
|
| 547 | + if ($annee < 0) { |
|
| 548 | + $annee = -$annee . ' ' . _T('date_avant_jc'); |
|
| 549 | + $avjc = true; |
|
| 550 | + } else { |
|
| 551 | + $avjc = false; |
|
| 552 | + } |
|
| 553 | + |
|
| 554 | + switch ($vue) { |
|
| 555 | + case 'saison': |
|
| 556 | + case 'saison_annee': |
|
| 557 | + $saison = ''; |
|
| 558 | + if ($mois > 0) { |
|
| 559 | + $saison = ($options['param'] == 'sud') ? 3 : 1; |
|
| 560 | + if (($mois == 3 and $jour >= 21) or $mois > 3) { |
|
| 561 | + $saison = ($options['param'] == 'sud') ? 4 : 2; |
|
| 562 | + } |
|
| 563 | + if (($mois == 6 and $jour >= 21) or $mois > 6) { |
|
| 564 | + $saison = ($options['param'] == 'sud') ? 1 : 3; |
|
| 565 | + } |
|
| 566 | + if (($mois == 9 and $jour >= 21) or $mois > 9) { |
|
| 567 | + $saison = ($options['param'] == 'sud') ? 2 : 4; |
|
| 568 | + } |
|
| 569 | + if (($mois == 12 and $jour >= 21) or $mois > 12) { |
|
| 570 | + $saison = ($options['param'] == 'sud') ? 3 : 1; |
|
| 571 | + } |
|
| 572 | + } |
|
| 573 | + if ($vue == 'saison') { |
|
| 574 | + return $saison ? _T('date_saison_' . $saison) : ''; |
|
| 575 | + } else { |
|
| 576 | + return $saison ? trim(_T( |
|
| 577 | + 'date_fmt_saison_annee', |
|
| 578 | + ['saison' => _T('date_saison_' . $saison), 'annee' => $annee] |
|
| 579 | + )) : ''; |
|
| 580 | + } |
|
| 581 | + |
|
| 582 | + case 'court': |
|
| 583 | + if ($avjc) { |
|
| 584 | + return $annee; |
|
| 585 | + } |
|
| 586 | + $a = ((isset($options['annee_courante']) and $options['annee_courante']) ? $options['annee_courante'] : date('Y')); |
|
| 587 | + if ($annee < ($a - 100) or $annee > ($a + 100)) { |
|
| 588 | + return $annee; |
|
| 589 | + } |
|
| 590 | + if ($annee != $a) { |
|
| 591 | + return _T( |
|
| 592 | + 'date_fmt_mois_annee', |
|
| 593 | + ['mois' => $mois, 'nommois' => spip_ucfirst($nommois), 'annee' => $annee] |
|
| 594 | + ); |
|
| 595 | + } |
|
| 596 | + |
|
| 597 | + return _T( |
|
| 598 | + 'date_fmt_jour_mois', |
|
| 599 | + ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 600 | + ); |
|
| 601 | + |
|
| 602 | + case 'jourcourt': |
|
| 603 | + if ($avjc) { |
|
| 604 | + return $annee; |
|
| 605 | + } |
|
| 606 | + $a = ((isset($options['annee_courante']) and $options['annee_courante']) ? $options['annee_courante'] : date('Y')); |
|
| 607 | + if ($annee < ($a - 100) or $annee > ($a + 100)) { |
|
| 608 | + return $annee; |
|
| 609 | + } |
|
| 610 | + if ($annee != $a) { |
|
| 611 | + return _T( |
|
| 612 | + 'date_fmt_jour_mois_annee', |
|
| 613 | + ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 614 | + ); |
|
| 615 | + } |
|
| 616 | + |
|
| 617 | + return _T( |
|
| 618 | + 'date_fmt_jour_mois', |
|
| 619 | + ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 620 | + ); |
|
| 621 | + |
|
| 622 | + case 'entier': |
|
| 623 | + if ($avjc) { |
|
| 624 | + return $annee; |
|
| 625 | + } |
|
| 626 | + if ($jour) { |
|
| 627 | + return _T( |
|
| 628 | + 'date_fmt_jour_mois_annee', |
|
| 629 | + ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 630 | + ); |
|
| 631 | + } elseif ($mois) { |
|
| 632 | + return trim(_T('date_fmt_mois_annee', ['mois' => $mois, 'nommois' => $nommois, 'annee' => $annee])); |
|
| 633 | + } else { |
|
| 634 | + return $annee; |
|
| 635 | + } |
|
| 636 | + |
|
| 637 | + case 'nom_mois': |
|
| 638 | + return $nommois; |
|
| 639 | + |
|
| 640 | + case 'mois': |
|
| 641 | + return sprintf('%02s', $mois); |
|
| 642 | + |
|
| 643 | + case 'jour': |
|
| 644 | + return $jour; |
|
| 645 | + |
|
| 646 | + case 'journum': |
|
| 647 | + return $journum; |
|
| 648 | + |
|
| 649 | + case 'nom_jour': |
|
| 650 | + if (!$mois or !$njour) { |
|
| 651 | + return ''; |
|
| 652 | + } |
|
| 653 | + $nom = mktime(1, 1, 1, $mois, $njour, $annee); |
|
| 654 | + $nom = 1 + (int) date('w', $nom); |
|
| 655 | + $param = ((isset($options['param']) and $options['param']) ? '_' . $options['param'] : ''); |
|
| 656 | + |
|
| 657 | + return _T('date_jour_' . $nom . $param); |
|
| 658 | + |
|
| 659 | + case 'mois_annee': |
|
| 660 | + if ($avjc) { |
|
| 661 | + return $annee; |
|
| 662 | + } |
|
| 663 | + |
|
| 664 | + return trim(_T('date_fmt_mois_annee', ['mois' => $mois, 'nommois' => $nommois, 'annee' => $annee])); |
|
| 665 | + |
|
| 666 | + case 'annee': |
|
| 667 | + return $annee; |
|
| 668 | + |
|
| 669 | + // Cas d'une vue non definie : retomber sur le format |
|
| 670 | + // de date propose par http://www.php.net/date |
|
| 671 | + default: |
|
| 672 | + [$annee, $mois, $jour, $heures, $minutes, $secondes] = $date_array; |
|
| 673 | + // il faut envoyer jour = 1 si jour pas défini, c'est le comportement qu'on avait historiquement en envoyant '' |
|
| 674 | + if (!$time = mktime($heures, $minutes, $secondes, $mois, is_numeric($jour) ? $jour : 1, $annee)) { |
|
| 675 | + $time = strtotime($numdate); |
|
| 676 | + } |
|
| 677 | + return date($vue, $time); |
|
| 678 | + } |
|
| 679 | 679 | } |
| 680 | 680 | |
| 681 | 681 | |
@@ -702,11 +702,11 @@ discard block |
||
| 702 | 702 | * Nom du jour |
| 703 | 703 | **/ |
| 704 | 704 | function nom_jour($numdate, $forme = ''): string { |
| 705 | - if (!($forme === 'abbr' or $forme === 'initiale')) { |
|
| 706 | - $forme = ''; |
|
| 707 | - } |
|
| 705 | + if (!($forme === 'abbr' or $forme === 'initiale')) { |
|
| 706 | + $forme = ''; |
|
| 707 | + } |
|
| 708 | 708 | |
| 709 | - return affdate_base($numdate, 'nom_jour', ['param' => $forme]); |
|
| 709 | + return affdate_base($numdate, 'nom_jour', ['param' => $forme]); |
|
| 710 | 710 | } |
| 711 | 711 | |
| 712 | 712 | /** |
@@ -728,7 +728,7 @@ discard block |
||
| 728 | 728 | * Numéro du jour |
| 729 | 729 | **/ |
| 730 | 730 | function jour($numdate): string { |
| 731 | - return affdate_base($numdate, 'jour'); |
|
| 731 | + return affdate_base($numdate, 'jour'); |
|
| 732 | 732 | } |
| 733 | 733 | |
| 734 | 734 | /** |
@@ -746,7 +746,7 @@ discard block |
||
| 746 | 746 | * Numéro du jour |
| 747 | 747 | **/ |
| 748 | 748 | function journum($numdate): string { |
| 749 | - return affdate_base($numdate, 'journum'); |
|
| 749 | + return affdate_base($numdate, 'journum'); |
|
| 750 | 750 | } |
| 751 | 751 | |
| 752 | 752 | /** |
@@ -764,7 +764,7 @@ discard block |
||
| 764 | 764 | * Numéro du mois (sur 2 chiffres) |
| 765 | 765 | **/ |
| 766 | 766 | function mois($numdate): string { |
| 767 | - return affdate_base($numdate, 'mois'); |
|
| 767 | + return affdate_base($numdate, 'mois'); |
|
| 768 | 768 | } |
| 769 | 769 | |
| 770 | 770 | /** |
@@ -788,11 +788,11 @@ discard block |
||
| 788 | 788 | * Nom du mois |
| 789 | 789 | **/ |
| 790 | 790 | function nom_mois($numdate, $forme = ''): string { |
| 791 | - if (!($forme === 'abbr')) { |
|
| 792 | - $forme = ''; |
|
| 793 | - } |
|
| 791 | + if (!($forme === 'abbr')) { |
|
| 792 | + $forme = ''; |
|
| 793 | + } |
|
| 794 | 794 | |
| 795 | - return affdate_base($numdate, 'nom_mois', ['param' => $forme]); |
|
| 795 | + return affdate_base($numdate, 'nom_mois', ['param' => $forme]); |
|
| 796 | 796 | } |
| 797 | 797 | |
| 798 | 798 | /** |
@@ -810,7 +810,7 @@ discard block |
||
| 810 | 810 | * Année (sur 4 chiffres) |
| 811 | 811 | **/ |
| 812 | 812 | function annee($numdate): string { |
| 813 | - return affdate_base($numdate, 'annee'); |
|
| 813 | + return affdate_base($numdate, 'annee'); |
|
| 814 | 814 | } |
| 815 | 815 | |
| 816 | 816 | |
@@ -840,11 +840,11 @@ discard block |
||
| 840 | 840 | * La date formatée |
| 841 | 841 | **/ |
| 842 | 842 | function saison($numdate, $hemisphere = 'nord'): string { |
| 843 | - if ($hemisphere !== 'sud') { |
|
| 844 | - $hemisphere = 'nord'; |
|
| 845 | - } |
|
| 843 | + if ($hemisphere !== 'sud') { |
|
| 844 | + $hemisphere = 'nord'; |
|
| 845 | + } |
|
| 846 | 846 | |
| 847 | - return affdate_base($numdate, 'saison', ['param' => $hemisphere]); |
|
| 847 | + return affdate_base($numdate, 'saison', ['param' => $hemisphere]); |
|
| 848 | 848 | } |
| 849 | 849 | |
| 850 | 850 | |
@@ -873,11 +873,11 @@ discard block |
||
| 873 | 873 | * La date formatée |
| 874 | 874 | **/ |
| 875 | 875 | function saison_annee($numdate, $hemisphere = 'nord'): string { |
| 876 | - if ($hemisphere !== 'sud') { |
|
| 877 | - $hemisphere = 'nord'; |
|
| 878 | - } |
|
| 876 | + if ($hemisphere !== 'sud') { |
|
| 877 | + $hemisphere = 'nord'; |
|
| 878 | + } |
|
| 879 | 879 | |
| 880 | - return affdate_base($numdate, 'saison_annee', ['param' => $hemisphere]); |
|
| 880 | + return affdate_base($numdate, 'saison_annee', ['param' => $hemisphere]); |
|
| 881 | 881 | } |
| 882 | 882 | |
| 883 | 883 | /** |
@@ -905,7 +905,7 @@ discard block |
||
| 905 | 905 | * La date formatée |
| 906 | 906 | **/ |
| 907 | 907 | function affdate($numdate, $format = 'entier'): string { |
| 908 | - return affdate_base($numdate, $format); |
|
| 908 | + return affdate_base($numdate, $format); |
|
| 909 | 909 | } |
| 910 | 910 | |
| 911 | 911 | |
@@ -932,7 +932,7 @@ discard block |
||
| 932 | 932 | * La date formatée |
| 933 | 933 | **/ |
| 934 | 934 | function affdate_court($numdate, $annee_courante = null): string { |
| 935 | - return affdate_base($numdate, 'court', ['annee_courante' => $annee_courante]); |
|
| 935 | + return affdate_base($numdate, 'court', ['annee_courante' => $annee_courante]); |
|
| 936 | 936 | } |
| 937 | 937 | |
| 938 | 938 | |
@@ -959,7 +959,7 @@ discard block |
||
| 959 | 959 | * La date formatée |
| 960 | 960 | **/ |
| 961 | 961 | function affdate_jourcourt($numdate, $annee_courante = null): string { |
| 962 | - return affdate_base($numdate, 'jourcourt', ['annee_courante' => $annee_courante]); |
|
| 962 | + return affdate_base($numdate, 'jourcourt', ['annee_courante' => $annee_courante]); |
|
| 963 | 963 | } |
| 964 | 964 | |
| 965 | 965 | /** |
@@ -977,7 +977,7 @@ discard block |
||
| 977 | 977 | * La date formatée |
| 978 | 978 | **/ |
| 979 | 979 | function affdate_mois_annee($numdate): string { |
| 980 | - return affdate_base($numdate, 'mois_annee'); |
|
| 980 | + return affdate_base($numdate, 'mois_annee'); |
|
| 981 | 981 | } |
| 982 | 982 | |
| 983 | 983 | /** |
@@ -995,16 +995,16 @@ discard block |
||
| 995 | 995 | * La date formatée, sinon '' |
| 996 | 996 | **/ |
| 997 | 997 | function affdate_heure($numdate): string { |
| 998 | - $date_array = recup_date($numdate); |
|
| 999 | - if (!$date_array) { |
|
| 1000 | - return ''; |
|
| 1001 | - } |
|
| 1002 | - [$annee, $mois, $jour, $heures, $minutes, $sec] = $date_array; |
|
| 1003 | - |
|
| 1004 | - return _T('date_fmt_jour_heure', [ |
|
| 1005 | - 'jour' => affdate($numdate), |
|
| 1006 | - 'heure' => _T('date_fmt_heures_minutes', ['h' => $heures, 'm' => $minutes]) |
|
| 1007 | - ]); |
|
| 998 | + $date_array = recup_date($numdate); |
|
| 999 | + if (!$date_array) { |
|
| 1000 | + return ''; |
|
| 1001 | + } |
|
| 1002 | + [$annee, $mois, $jour, $heures, $minutes, $sec] = $date_array; |
|
| 1003 | + |
|
| 1004 | + return _T('date_fmt_jour_heure', [ |
|
| 1005 | + 'jour' => affdate($numdate), |
|
| 1006 | + 'heure' => _T('date_fmt_heures_minutes', ['h' => $heures, 'm' => $minutes]) |
|
| 1007 | + ]); |
|
| 1008 | 1008 | } |
| 1009 | 1009 | |
| 1010 | 1010 | /** |
@@ -1036,117 +1036,117 @@ discard block |
||
| 1036 | 1036 | * texte de la date |
| 1037 | 1037 | */ |
| 1038 | 1038 | function affdate_debut_fin($date_debut, $date_fin, $horaire = 'oui', $forme = ''): string { |
| 1039 | - $abbr = $jour = ''; |
|
| 1040 | - $affdate = 'affdate_jourcourt'; |
|
| 1041 | - if (strpos($forme, 'abbr') !== false) { |
|
| 1042 | - $abbr = 'abbr'; |
|
| 1043 | - } |
|
| 1044 | - if (strpos($forme, 'annee') !== false) { |
|
| 1045 | - $affdate = 'affdate'; |
|
| 1046 | - } |
|
| 1047 | - if (strpos($forme, 'jour') !== false) { |
|
| 1048 | - $jour = 'jour'; |
|
| 1049 | - } |
|
| 1050 | - |
|
| 1051 | - $dtstart = $dtend = $dtabbr = ''; |
|
| 1052 | - if (strpos($forme, 'hcal') !== false) { |
|
| 1053 | - $dtstart = "<abbr class='dtstart' title='" . date_iso($date_debut) . "'>"; |
|
| 1054 | - $dtend = "<abbr class='dtend' title='" . date_iso($date_fin) . "'>"; |
|
| 1055 | - $dtabbr = '</abbr>'; |
|
| 1056 | - } |
|
| 1057 | - |
|
| 1058 | - $date_debut = strtotime($date_debut); |
|
| 1059 | - $date_fin = strtotime($date_fin); |
|
| 1060 | - $d = date('Y-m-d', $date_debut); |
|
| 1061 | - $f = date('Y-m-d', $date_fin); |
|
| 1062 | - $h = ($horaire === 'oui' or $horaire === true); |
|
| 1063 | - $hd = _T('date_fmt_heures_minutes_court', ['h' => date('H', $date_debut), 'm' => date('i', $date_debut)]); |
|
| 1064 | - $hf = _T('date_fmt_heures_minutes_court', ['h' => date('H', $date_fin), 'm' => date('i', $date_fin)]); |
|
| 1065 | - |
|
| 1066 | - if ($d == $f) { // meme jour |
|
| 1067 | - $nomjour = nom_jour($d, $abbr); |
|
| 1068 | - $s = $affdate($d); |
|
| 1069 | - $s = _T('date_fmt_jour', ['nomjour' => $nomjour, 'jour' => $s]); |
|
| 1070 | - if ($h) { |
|
| 1071 | - if ($hd == $hf) { |
|
| 1072 | - // Lundi 20 fevrier a 18h25 |
|
| 1073 | - $s = spip_ucfirst(_T('date_fmt_jour_heure', ['jour' => $s, 'heure' => $hd])); |
|
| 1074 | - $s = "$dtstart$s$dtabbr"; |
|
| 1075 | - } else { |
|
| 1076 | - // Le <abbr...>lundi 20 fevrier de 18h00</abbr> a <abbr...>20h00</abbr> |
|
| 1077 | - if ($dtabbr && $dtstart && $dtend) { |
|
| 1078 | - $s = _T( |
|
| 1079 | - 'date_fmt_jour_heure_debut_fin_abbr', |
|
| 1080 | - [ |
|
| 1081 | - 'jour' => spip_ucfirst($s), |
|
| 1082 | - 'heure_debut' => $hd, |
|
| 1083 | - 'heure_fin' => $hf, |
|
| 1084 | - 'dtstart' => $dtstart, |
|
| 1085 | - 'dtend' => $dtend, |
|
| 1086 | - 'dtabbr' => $dtabbr |
|
| 1087 | - ], |
|
| 1088 | - [ |
|
| 1089 | - 'sanitize' => false |
|
| 1090 | - ] |
|
| 1091 | - ); |
|
| 1092 | - } // Le lundi 20 fevrier de 18h00 a 20h00 |
|
| 1093 | - else { |
|
| 1094 | - $s = spip_ucfirst(_T( |
|
| 1095 | - 'date_fmt_jour_heure_debut_fin', |
|
| 1096 | - ['jour' => $s, 'heure_debut' => $hd, 'heure_fin' => $hf] |
|
| 1097 | - )); |
|
| 1098 | - } |
|
| 1099 | - } |
|
| 1100 | - } else { |
|
| 1101 | - if ($dtabbr && $dtstart) { |
|
| 1102 | - $s = $dtstart . spip_ucfirst($s) . $dtabbr; |
|
| 1103 | - } else { |
|
| 1104 | - $s = spip_ucfirst($s); |
|
| 1105 | - } |
|
| 1106 | - } |
|
| 1107 | - } else { |
|
| 1108 | - if ((date('Y-m', $date_debut)) == date('Y-m', $date_fin)) { // meme annee et mois, jours differents |
|
| 1109 | - if (!$h) { |
|
| 1110 | - $date_debut = jour($d); |
|
| 1111 | - } else { |
|
| 1112 | - $date_debut = affdate_jourcourt($d, date('Y', $date_fin)); |
|
| 1113 | - } |
|
| 1114 | - $date_fin = $affdate($f); |
|
| 1115 | - if ($jour) { |
|
| 1116 | - $nomjour_debut = nom_jour($d, $abbr); |
|
| 1117 | - $date_debut = _T('date_fmt_jour', ['nomjour' => $nomjour_debut, 'jour' => $date_debut]); |
|
| 1118 | - $nomjour_fin = nom_jour($f, $abbr); |
|
| 1119 | - $date_fin = _T('date_fmt_jour', ['nomjour' => $nomjour_fin, 'jour' => $date_fin]); |
|
| 1120 | - } |
|
| 1121 | - if ($h) { |
|
| 1122 | - $date_debut = _T('date_fmt_jour_heure', ['jour' => $date_debut, 'heure' => $hd]); |
|
| 1123 | - $date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]); |
|
| 1124 | - } |
|
| 1125 | - $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1126 | - $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1127 | - |
|
| 1128 | - $s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]); |
|
| 1129 | - } else { |
|
| 1130 | - $date_debut = affdate_jourcourt($d, date('Y', $date_fin)); |
|
| 1131 | - $date_fin = $affdate($f); |
|
| 1132 | - if ($jour) { |
|
| 1133 | - $nomjour_debut = nom_jour($d, $abbr); |
|
| 1134 | - $date_debut = _T('date_fmt_jour', ['nomjour' => $nomjour_debut, 'jour' => $date_debut]); |
|
| 1135 | - $nomjour_fin = nom_jour($f, $abbr); |
|
| 1136 | - $date_fin = _T('date_fmt_jour', ['nomjour' => $nomjour_fin, 'jour' => $date_fin]); |
|
| 1137 | - } |
|
| 1138 | - if ($h) { |
|
| 1139 | - $date_debut = _T('date_fmt_jour_heure', ['jour' => $date_debut, 'heure' => $hd]); |
|
| 1140 | - $date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]); |
|
| 1141 | - } |
|
| 1142 | - |
|
| 1143 | - $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1144 | - $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1145 | - $s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]); |
|
| 1146 | - } |
|
| 1147 | - } |
|
| 1148 | - |
|
| 1149 | - return $s; |
|
| 1039 | + $abbr = $jour = ''; |
|
| 1040 | + $affdate = 'affdate_jourcourt'; |
|
| 1041 | + if (strpos($forme, 'abbr') !== false) { |
|
| 1042 | + $abbr = 'abbr'; |
|
| 1043 | + } |
|
| 1044 | + if (strpos($forme, 'annee') !== false) { |
|
| 1045 | + $affdate = 'affdate'; |
|
| 1046 | + } |
|
| 1047 | + if (strpos($forme, 'jour') !== false) { |
|
| 1048 | + $jour = 'jour'; |
|
| 1049 | + } |
|
| 1050 | + |
|
| 1051 | + $dtstart = $dtend = $dtabbr = ''; |
|
| 1052 | + if (strpos($forme, 'hcal') !== false) { |
|
| 1053 | + $dtstart = "<abbr class='dtstart' title='" . date_iso($date_debut) . "'>"; |
|
| 1054 | + $dtend = "<abbr class='dtend' title='" . date_iso($date_fin) . "'>"; |
|
| 1055 | + $dtabbr = '</abbr>'; |
|
| 1056 | + } |
|
| 1057 | + |
|
| 1058 | + $date_debut = strtotime($date_debut); |
|
| 1059 | + $date_fin = strtotime($date_fin); |
|
| 1060 | + $d = date('Y-m-d', $date_debut); |
|
| 1061 | + $f = date('Y-m-d', $date_fin); |
|
| 1062 | + $h = ($horaire === 'oui' or $horaire === true); |
|
| 1063 | + $hd = _T('date_fmt_heures_minutes_court', ['h' => date('H', $date_debut), 'm' => date('i', $date_debut)]); |
|
| 1064 | + $hf = _T('date_fmt_heures_minutes_court', ['h' => date('H', $date_fin), 'm' => date('i', $date_fin)]); |
|
| 1065 | + |
|
| 1066 | + if ($d == $f) { // meme jour |
|
| 1067 | + $nomjour = nom_jour($d, $abbr); |
|
| 1068 | + $s = $affdate($d); |
|
| 1069 | + $s = _T('date_fmt_jour', ['nomjour' => $nomjour, 'jour' => $s]); |
|
| 1070 | + if ($h) { |
|
| 1071 | + if ($hd == $hf) { |
|
| 1072 | + // Lundi 20 fevrier a 18h25 |
|
| 1073 | + $s = spip_ucfirst(_T('date_fmt_jour_heure', ['jour' => $s, 'heure' => $hd])); |
|
| 1074 | + $s = "$dtstart$s$dtabbr"; |
|
| 1075 | + } else { |
|
| 1076 | + // Le <abbr...>lundi 20 fevrier de 18h00</abbr> a <abbr...>20h00</abbr> |
|
| 1077 | + if ($dtabbr && $dtstart && $dtend) { |
|
| 1078 | + $s = _T( |
|
| 1079 | + 'date_fmt_jour_heure_debut_fin_abbr', |
|
| 1080 | + [ |
|
| 1081 | + 'jour' => spip_ucfirst($s), |
|
| 1082 | + 'heure_debut' => $hd, |
|
| 1083 | + 'heure_fin' => $hf, |
|
| 1084 | + 'dtstart' => $dtstart, |
|
| 1085 | + 'dtend' => $dtend, |
|
| 1086 | + 'dtabbr' => $dtabbr |
|
| 1087 | + ], |
|
| 1088 | + [ |
|
| 1089 | + 'sanitize' => false |
|
| 1090 | + ] |
|
| 1091 | + ); |
|
| 1092 | + } // Le lundi 20 fevrier de 18h00 a 20h00 |
|
| 1093 | + else { |
|
| 1094 | + $s = spip_ucfirst(_T( |
|
| 1095 | + 'date_fmt_jour_heure_debut_fin', |
|
| 1096 | + ['jour' => $s, 'heure_debut' => $hd, 'heure_fin' => $hf] |
|
| 1097 | + )); |
|
| 1098 | + } |
|
| 1099 | + } |
|
| 1100 | + } else { |
|
| 1101 | + if ($dtabbr && $dtstart) { |
|
| 1102 | + $s = $dtstart . spip_ucfirst($s) . $dtabbr; |
|
| 1103 | + } else { |
|
| 1104 | + $s = spip_ucfirst($s); |
|
| 1105 | + } |
|
| 1106 | + } |
|
| 1107 | + } else { |
|
| 1108 | + if ((date('Y-m', $date_debut)) == date('Y-m', $date_fin)) { // meme annee et mois, jours differents |
|
| 1109 | + if (!$h) { |
|
| 1110 | + $date_debut = jour($d); |
|
| 1111 | + } else { |
|
| 1112 | + $date_debut = affdate_jourcourt($d, date('Y', $date_fin)); |
|
| 1113 | + } |
|
| 1114 | + $date_fin = $affdate($f); |
|
| 1115 | + if ($jour) { |
|
| 1116 | + $nomjour_debut = nom_jour($d, $abbr); |
|
| 1117 | + $date_debut = _T('date_fmt_jour', ['nomjour' => $nomjour_debut, 'jour' => $date_debut]); |
|
| 1118 | + $nomjour_fin = nom_jour($f, $abbr); |
|
| 1119 | + $date_fin = _T('date_fmt_jour', ['nomjour' => $nomjour_fin, 'jour' => $date_fin]); |
|
| 1120 | + } |
|
| 1121 | + if ($h) { |
|
| 1122 | + $date_debut = _T('date_fmt_jour_heure', ['jour' => $date_debut, 'heure' => $hd]); |
|
| 1123 | + $date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]); |
|
| 1124 | + } |
|
| 1125 | + $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1126 | + $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1127 | + |
|
| 1128 | + $s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]); |
|
| 1129 | + } else { |
|
| 1130 | + $date_debut = affdate_jourcourt($d, date('Y', $date_fin)); |
|
| 1131 | + $date_fin = $affdate($f); |
|
| 1132 | + if ($jour) { |
|
| 1133 | + $nomjour_debut = nom_jour($d, $abbr); |
|
| 1134 | + $date_debut = _T('date_fmt_jour', ['nomjour' => $nomjour_debut, 'jour' => $date_debut]); |
|
| 1135 | + $nomjour_fin = nom_jour($f, $abbr); |
|
| 1136 | + $date_fin = _T('date_fmt_jour', ['nomjour' => $nomjour_fin, 'jour' => $date_fin]); |
|
| 1137 | + } |
|
| 1138 | + if ($h) { |
|
| 1139 | + $date_debut = _T('date_fmt_jour_heure', ['jour' => $date_debut, 'heure' => $hd]); |
|
| 1140 | + $date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]); |
|
| 1141 | + } |
|
| 1142 | + |
|
| 1143 | + $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1144 | + $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1145 | + $s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]); |
|
| 1146 | + } |
|
| 1147 | + } |
|
| 1148 | + |
|
| 1149 | + return $s; |
|
| 1150 | 1150 | } |
| 1151 | 1151 | |
| 1152 | 1152 | /** |
@@ -1167,10 +1167,10 @@ discard block |
||
| 1167 | 1167 | * Date au format ical |
| 1168 | 1168 | **/ |
| 1169 | 1169 | function date_ical($date, $addminutes = 0): string { |
| 1170 | - [$heures, $minutes, $secondes] = recup_heure($date); |
|
| 1171 | - [$annee, $mois, $jour] = recup_date($date); |
|
| 1170 | + [$heures, $minutes, $secondes] = recup_heure($date); |
|
| 1171 | + [$annee, $mois, $jour] = recup_date($date); |
|
| 1172 | 1172 | |
| 1173 | - return gmdate('Ymd\THis\Z', mktime($heures, $minutes + $addminutes, $secondes, $mois, $jour, $annee)); |
|
| 1173 | + return gmdate('Ymd\THis\Z', mktime($heures, $minutes + $addminutes, $secondes, $mois, $jour, $annee)); |
|
| 1174 | 1174 | } |
| 1175 | 1175 | |
| 1176 | 1176 | |
@@ -1194,14 +1194,14 @@ discard block |
||
| 1194 | 1194 | * La date formatée |
| 1195 | 1195 | **/ |
| 1196 | 1196 | function date_iso($date_heure): string { |
| 1197 | - $date = recup_date($date_heure); |
|
| 1198 | - $annee = $date[0] ?? null; |
|
| 1199 | - $mois = $date[1] ?? null; |
|
| 1200 | - $jour = $date[2] ?? null; |
|
| 1201 | - [$heures, $minutes, $secondes] = recup_heure($date_heure); |
|
| 1202 | - $time = @mktime($heures, $minutes, $secondes, $mois, $jour, $annee); |
|
| 1203 | - |
|
| 1204 | - return gmdate('Y-m-d\TH:i:s\Z', $time); |
|
| 1197 | + $date = recup_date($date_heure); |
|
| 1198 | + $annee = $date[0] ?? null; |
|
| 1199 | + $mois = $date[1] ?? null; |
|
| 1200 | + $jour = $date[2] ?? null; |
|
| 1201 | + [$heures, $minutes, $secondes] = recup_heure($date_heure); |
|
| 1202 | + $time = @mktime($heures, $minutes, $secondes, $mois, $jour, $annee); |
|
| 1203 | + |
|
| 1204 | + return gmdate('Y-m-d\TH:i:s\Z', $time); |
|
| 1205 | 1205 | } |
| 1206 | 1206 | |
| 1207 | 1207 | /** |
@@ -1224,11 +1224,11 @@ discard block |
||
| 1224 | 1224 | * La date formatée |
| 1225 | 1225 | **/ |
| 1226 | 1226 | function date_822($date_heure): string { |
| 1227 | - [$annee, $mois, $jour] = recup_date($date_heure); |
|
| 1228 | - [$heures, $minutes, $secondes] = recup_heure($date_heure); |
|
| 1229 | - $time = mktime($heures, $minutes, $secondes, $mois, $jour, $annee); |
|
| 1227 | + [$annee, $mois, $jour] = recup_date($date_heure); |
|
| 1228 | + [$heures, $minutes, $secondes] = recup_heure($date_heure); |
|
| 1229 | + $time = mktime($heures, $minutes, $secondes, $mois, $jour, $annee); |
|
| 1230 | 1230 | |
| 1231 | - return date('r', $time); |
|
| 1231 | + return date('r', $time); |
|
| 1232 | 1232 | } |
| 1233 | 1233 | |
| 1234 | 1234 | /** |
@@ -1244,11 +1244,11 @@ discard block |
||
| 1244 | 1244 | * Date au format `Ymd` |
| 1245 | 1245 | **/ |
| 1246 | 1246 | function date_anneemoisjour($d): string { |
| 1247 | - if (!$d) { |
|
| 1248 | - $d = date('Y-m-d'); |
|
| 1249 | - } |
|
| 1247 | + if (!$d) { |
|
| 1248 | + $d = date('Y-m-d'); |
|
| 1249 | + } |
|
| 1250 | 1250 | |
| 1251 | - return substr($d, 0, 4) . substr($d, 5, 2) . substr($d, 8, 2); |
|
| 1251 | + return substr($d, 0, 4) . substr($d, 5, 2) . substr($d, 8, 2); |
|
| 1252 | 1252 | } |
| 1253 | 1253 | |
| 1254 | 1254 | /** |
@@ -1264,11 +1264,11 @@ discard block |
||
| 1264 | 1264 | * Date au format `Ym` |
| 1265 | 1265 | **/ |
| 1266 | 1266 | function date_anneemois($d): string { |
| 1267 | - if (!$d) { |
|
| 1268 | - $d = date('Y-m-d'); |
|
| 1269 | - } |
|
| 1267 | + if (!$d) { |
|
| 1268 | + $d = date('Y-m-d'); |
|
| 1269 | + } |
|
| 1270 | 1270 | |
| 1271 | - return substr($d, 0, 4) . substr($d, 5, 2); |
|
| 1271 | + return substr($d, 0, 4) . substr($d, 5, 2); |
|
| 1272 | 1272 | } |
| 1273 | 1273 | |
| 1274 | 1274 | /** |
@@ -1284,13 +1284,13 @@ discard block |
||
| 1284 | 1284 | * Date au lundi de la même semaine au format `Ymd` |
| 1285 | 1285 | **/ |
| 1286 | 1286 | function date_debut_semaine($annee, $mois, $jour): string { |
| 1287 | - $w_day = date('w', mktime(0, 0, 0, $mois, $jour, $annee)); |
|
| 1288 | - if ($w_day == 0) { |
|
| 1289 | - $w_day = 7; |
|
| 1290 | - } // Gaffe: le dimanche est zero |
|
| 1291 | - $debut = $jour - $w_day + 1; |
|
| 1287 | + $w_day = date('w', mktime(0, 0, 0, $mois, $jour, $annee)); |
|
| 1288 | + if ($w_day == 0) { |
|
| 1289 | + $w_day = 7; |
|
| 1290 | + } // Gaffe: le dimanche est zero |
|
| 1291 | + $debut = $jour - $w_day + 1; |
|
| 1292 | 1292 | |
| 1293 | - return date('Ymd', mktime(0, 0, 0, $mois, $debut, $annee)); |
|
| 1293 | + return date('Ymd', mktime(0, 0, 0, $mois, $debut, $annee)); |
|
| 1294 | 1294 | } |
| 1295 | 1295 | |
| 1296 | 1296 | /** |
@@ -1306,11 +1306,11 @@ discard block |
||
| 1306 | 1306 | * Date au dimanche de la même semaine au format `Ymd` |
| 1307 | 1307 | **/ |
| 1308 | 1308 | function date_fin_semaine($annee, $mois, $jour): string { |
| 1309 | - $w_day = date('w', mktime(0, 0, 0, $mois, $jour, $annee)); |
|
| 1310 | - if ($w_day == 0) { |
|
| 1311 | - $w_day = 7; |
|
| 1312 | - } // Gaffe: le dimanche est zero |
|
| 1313 | - $debut = $jour - $w_day + 1; |
|
| 1309 | + $w_day = date('w', mktime(0, 0, 0, $mois, $jour, $annee)); |
|
| 1310 | + if ($w_day == 0) { |
|
| 1311 | + $w_day = 7; |
|
| 1312 | + } // Gaffe: le dimanche est zero |
|
| 1313 | + $debut = $jour - $w_day + 1; |
|
| 1314 | 1314 | |
| 1315 | - return date('Ymd', mktime(0, 0, 0, $mois, $debut + 6, $annee)); |
|
| 1315 | + return date('Ymd', mktime(0, 0, 0, $mois, $debut + 6, $annee)); |
|
| 1316 | 1316 | } |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | |
@@ -33,15 +33,15 @@ discard block |
||
| 33 | 33 | * JSON des différentes informations |
| 34 | 34 | */ |
| 35 | 35 | function informer_auteur($bof) { |
| 36 | - include_spip('inc/json'); |
|
| 37 | - include_spip('formulaires/login'); |
|
| 38 | - include_spip('inc/auth'); |
|
| 39 | - $login = (string) _request('var_login'); |
|
| 40 | - $row = auth_informer_login($login); |
|
| 41 | - if ($row && is_array($row) && isset($row['id_auteur'])) { |
|
| 42 | - unset($row['id_auteur']); |
|
| 43 | - } |
|
| 36 | + include_spip('inc/json'); |
|
| 37 | + include_spip('formulaires/login'); |
|
| 38 | + include_spip('inc/auth'); |
|
| 39 | + $login = (string) _request('var_login'); |
|
| 40 | + $row = auth_informer_login($login); |
|
| 41 | + if ($row && is_array($row) && isset($row['id_auteur'])) { |
|
| 42 | + unset($row['id_auteur']); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - // on encode tout pour ne pas avoir de probleme au deballage dans le JS |
|
| 46 | - return json_encode($row, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP); |
|
| 45 | + // on encode tout pour ne pas avoir de probleme au deballage dans le JS |
|
| 46 | + return json_encode($row, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP); |
|
| 47 | 47 | } |
@@ -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 | /** |
@@ -27,24 +27,24 @@ discard block |
||
| 27 | 27 | * Environnement du formulaire |
| 28 | 28 | **/ |
| 29 | 29 | function formulaires_configurer_reducteur_charger_dist() { |
| 30 | - $valeurs = []; |
|
| 31 | - foreach ( |
|
| 32 | - [ |
|
| 33 | - 'image_process', |
|
| 34 | - 'formats_graphiques', |
|
| 35 | - 'creer_preview', |
|
| 36 | - 'taille_preview', |
|
| 37 | - ] as $m |
|
| 38 | - ) { |
|
| 39 | - $valeurs[$m] = $GLOBALS['meta'][$m] ?? null; |
|
| 40 | - } |
|
| 30 | + $valeurs = []; |
|
| 31 | + foreach ( |
|
| 32 | + [ |
|
| 33 | + 'image_process', |
|
| 34 | + 'formats_graphiques', |
|
| 35 | + 'creer_preview', |
|
| 36 | + 'taille_preview', |
|
| 37 | + ] as $m |
|
| 38 | + ) { |
|
| 39 | + $valeurs[$m] = $GLOBALS['meta'][$m] ?? null; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - $valeurs['taille_preview'] = (int) $valeurs['taille_preview']; |
|
| 43 | - if ($valeurs['taille_preview'] < 10) { |
|
| 44 | - $valeurs['taille_preview'] = 120; |
|
| 45 | - } |
|
| 42 | + $valeurs['taille_preview'] = (int) $valeurs['taille_preview']; |
|
| 43 | + if ($valeurs['taille_preview'] < 10) { |
|
| 44 | + $valeurs['taille_preview'] = 120; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - return $valeurs; |
|
| 47 | + return $valeurs; |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | |
@@ -55,53 +55,53 @@ discard block |
||
| 55 | 55 | * Retours des traitements |
| 56 | 56 | **/ |
| 57 | 57 | function formulaires_configurer_reducteur_traiter_dist() { |
| 58 | - $res = ['editable' => true]; |
|
| 58 | + $res = ['editable' => true]; |
|
| 59 | 59 | |
| 60 | - if (is_array($image_process = _request('image_process_'))) { |
|
| 61 | - $image_process = array_keys($image_process); |
|
| 62 | - $image_process = reset($image_process); |
|
| 60 | + if (is_array($image_process = _request('image_process_'))) { |
|
| 61 | + $image_process = array_keys($image_process); |
|
| 62 | + $image_process = reset($image_process); |
|
| 63 | 63 | |
| 64 | - // application du choix de vignette |
|
| 65 | - if ($image_process) { |
|
| 66 | - // mettre a jour les formats graphiques lisibles |
|
| 67 | - switch ($image_process) { |
|
| 68 | - case 'gd1': |
|
| 69 | - case 'gd2': |
|
| 70 | - $formats_graphiques = $GLOBALS['meta']['gd_formats_read']; |
|
| 71 | - break; |
|
| 72 | - case 'netpbm': |
|
| 73 | - $formats_graphiques = $GLOBALS['meta']['netpbm_formats']; |
|
| 74 | - break; |
|
| 75 | - case 'convert': |
|
| 76 | - case 'imagick': |
|
| 77 | - $formats_graphiques = 'gif,jpg,png,webp'; |
|
| 78 | - break; |
|
| 79 | - default: #debug |
|
| 80 | - $formats_graphiques = ''; |
|
| 81 | - $image_process = 'non'; |
|
| 82 | - break; |
|
| 83 | - } |
|
| 84 | - ecrire_meta('formats_graphiques', $formats_graphiques, 'non'); |
|
| 85 | - ecrire_meta('image_process', $image_process, 'non'); |
|
| 86 | - } |
|
| 87 | - } |
|
| 64 | + // application du choix de vignette |
|
| 65 | + if ($image_process) { |
|
| 66 | + // mettre a jour les formats graphiques lisibles |
|
| 67 | + switch ($image_process) { |
|
| 68 | + case 'gd1': |
|
| 69 | + case 'gd2': |
|
| 70 | + $formats_graphiques = $GLOBALS['meta']['gd_formats_read']; |
|
| 71 | + break; |
|
| 72 | + case 'netpbm': |
|
| 73 | + $formats_graphiques = $GLOBALS['meta']['netpbm_formats']; |
|
| 74 | + break; |
|
| 75 | + case 'convert': |
|
| 76 | + case 'imagick': |
|
| 77 | + $formats_graphiques = 'gif,jpg,png,webp'; |
|
| 78 | + break; |
|
| 79 | + default: #debug |
|
| 80 | + $formats_graphiques = ''; |
|
| 81 | + $image_process = 'non'; |
|
| 82 | + break; |
|
| 83 | + } |
|
| 84 | + ecrire_meta('formats_graphiques', $formats_graphiques, 'non'); |
|
| 85 | + ecrire_meta('image_process', $image_process, 'non'); |
|
| 86 | + } |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - foreach ( |
|
| 90 | - [ |
|
| 91 | - 'creer_preview' |
|
| 92 | - ] as $m |
|
| 93 | - ) { |
|
| 94 | - if (!is_null($v = _request($m))) { |
|
| 95 | - ecrire_meta($m, $v == 'oui' ? 'oui' : 'non'); |
|
| 96 | - } |
|
| 97 | - } |
|
| 98 | - if (!is_null($v = _request('taille_preview'))) { |
|
| 99 | - ecrire_meta('taille_preview', (int) $v); |
|
| 100 | - } |
|
| 89 | + foreach ( |
|
| 90 | + [ |
|
| 91 | + 'creer_preview' |
|
| 92 | + ] as $m |
|
| 93 | + ) { |
|
| 94 | + if (!is_null($v = _request($m))) { |
|
| 95 | + ecrire_meta($m, $v == 'oui' ? 'oui' : 'non'); |
|
| 96 | + } |
|
| 97 | + } |
|
| 98 | + if (!is_null($v = _request('taille_preview'))) { |
|
| 99 | + ecrire_meta('taille_preview', (int) $v); |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - $res['message_ok'] = _T('config_info_enregistree'); |
|
| 102 | + $res['message_ok'] = _T('config_info_enregistree'); |
|
| 103 | 103 | |
| 104 | - return $res; |
|
| 104 | + return $res; |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /** |
@@ -114,33 +114,33 @@ discard block |
||
| 114 | 114 | * URL d'action pour tester la librairie graphique en créant une vignette |
| 115 | 115 | **/ |
| 116 | 116 | function url_vignette_choix($process) { |
| 117 | - switch ($process) { |
|
| 118 | - case 'gd2': |
|
| 119 | - if (!function_exists('ImageCreateTrueColor')) { |
|
| 120 | - return ''; |
|
| 121 | - } |
|
| 122 | - break; |
|
| 123 | - case 'gd1': |
|
| 124 | - if (!function_exists('ImageGif') && !function_exists('ImageJpeg') && !function_exists('ImagePng')) { |
|
| 125 | - return ''; |
|
| 126 | - } |
|
| 127 | - break; |
|
| 128 | - case 'netpbm': |
|
| 129 | - if (defined('_PNMSCALE_COMMAND') && _PNMSCALE_COMMAND == '') { |
|
| 130 | - return ''; |
|
| 131 | - } |
|
| 132 | - break; |
|
| 133 | - case 'imagick': |
|
| 134 | - if (!method_exists(\Imagick::class, 'readImage')) { |
|
| 135 | - return ''; |
|
| 136 | - } |
|
| 137 | - break; |
|
| 138 | - case 'convert': |
|
| 139 | - if (defined('_CONVERT_COMMAND') && _CONVERT_COMMAND == '') { |
|
| 140 | - return ''; |
|
| 141 | - } |
|
| 142 | - break; |
|
| 143 | - } |
|
| 117 | + switch ($process) { |
|
| 118 | + case 'gd2': |
|
| 119 | + if (!function_exists('ImageCreateTrueColor')) { |
|
| 120 | + return ''; |
|
| 121 | + } |
|
| 122 | + break; |
|
| 123 | + case 'gd1': |
|
| 124 | + if (!function_exists('ImageGif') && !function_exists('ImageJpeg') && !function_exists('ImagePng')) { |
|
| 125 | + return ''; |
|
| 126 | + } |
|
| 127 | + break; |
|
| 128 | + case 'netpbm': |
|
| 129 | + if (defined('_PNMSCALE_COMMAND') && _PNMSCALE_COMMAND == '') { |
|
| 130 | + return ''; |
|
| 131 | + } |
|
| 132 | + break; |
|
| 133 | + case 'imagick': |
|
| 134 | + if (!method_exists(\Imagick::class, 'readImage')) { |
|
| 135 | + return ''; |
|
| 136 | + } |
|
| 137 | + break; |
|
| 138 | + case 'convert': |
|
| 139 | + if (defined('_CONVERT_COMMAND') && _CONVERT_COMMAND == '') { |
|
| 140 | + return ''; |
|
| 141 | + } |
|
| 142 | + break; |
|
| 143 | + } |
|
| 144 | 144 | |
| 145 | - return generer_url_action('tester', "arg=$process&time=" . time()); |
|
| 145 | + return generer_url_action('tester', "arg=$process&time=" . time()); |
|
| 146 | 146 | } |
@@ -10,53 +10,53 @@ discard block |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | function formulaires_configurer_multilinguisme_charger_dist() { |
| 17 | - $valeurs = []; |
|
| 18 | - $valeurs['multi_secteurs'] = $GLOBALS['meta']['multi_secteurs']; |
|
| 19 | - foreach (['multi_objets', 'gerer_trad_objets'] as $m) { |
|
| 20 | - $valeurs[$m] = explode(',', $GLOBALS['meta'][$m] ?? ''); |
|
| 21 | - } |
|
| 22 | - |
|
| 23 | - if ( |
|
| 24 | - (is_countable($valeurs['multi_objets']) ? count($valeurs['multi_objets']) : 0) |
|
| 25 | - || count(explode(',', $GLOBALS['meta']['langues_utilisees'])) > 1 |
|
| 26 | - ) { |
|
| 27 | - $selection = (is_null(_request('multi_objets')) ? |
|
| 28 | - explode(',', $GLOBALS['meta']['langues_multilingue']) : _request('langues_auth')); |
|
| 29 | - $valeurs['_langues'] = saisie_langues_utiles('langues_auth', $selection ?: []); |
|
| 30 | - $valeurs['_nb_langues_selection'] = is_countable($selection) ? count($selection) : 0; |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - return $valeurs; |
|
| 17 | + $valeurs = []; |
|
| 18 | + $valeurs['multi_secteurs'] = $GLOBALS['meta']['multi_secteurs']; |
|
| 19 | + foreach (['multi_objets', 'gerer_trad_objets'] as $m) { |
|
| 20 | + $valeurs[$m] = explode(',', $GLOBALS['meta'][$m] ?? ''); |
|
| 21 | + } |
|
| 22 | + |
|
| 23 | + if ( |
|
| 24 | + (is_countable($valeurs['multi_objets']) ? count($valeurs['multi_objets']) : 0) |
|
| 25 | + || count(explode(',', $GLOBALS['meta']['langues_utilisees'])) > 1 |
|
| 26 | + ) { |
|
| 27 | + $selection = (is_null(_request('multi_objets')) ? |
|
| 28 | + explode(',', $GLOBALS['meta']['langues_multilingue']) : _request('langues_auth')); |
|
| 29 | + $valeurs['_langues'] = saisie_langues_utiles('langues_auth', $selection ?: []); |
|
| 30 | + $valeurs['_nb_langues_selection'] = is_countable($selection) ? count($selection) : 0; |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + return $valeurs; |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | |
| 37 | 37 | function formulaires_configurer_multilinguisme_traiter_dist() { |
| 38 | - $res = ['editable' => true]; |
|
| 39 | - // un checkbox seul de name X non coche n'est pas poste. |
|
| 40 | - // on verifie le champ X_check qui indique que la checkbox etait presente dans le formulaire. |
|
| 41 | - foreach (['multi_secteurs'] as $m) { |
|
| 42 | - if (!is_null(_request($m . '_check'))) { |
|
| 43 | - ecrire_meta($m, _request($m) ? 'oui' : 'non'); |
|
| 44 | - } |
|
| 45 | - } |
|
| 46 | - foreach (['multi_objets', 'gerer_trad_objets'] as $m) { |
|
| 47 | - if (!is_null($v = _request($m))) { |
|
| 48 | - // join et enlever la valeur vide '' |
|
| 49 | - ecrire_meta($m, implode(',', array_diff($v, ['']))); |
|
| 50 | - } |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - if (($i = _request('langues_auth')) && is_array($i)) { |
|
| 54 | - $i = array_unique(array_merge($i, explode(',', $GLOBALS['meta']['langues_utilisees']))); |
|
| 55 | - ecrire_meta('langues_multilingue', implode(',', $i)); |
|
| 56 | - } |
|
| 57 | - $res['message_ok'] = _T('config_info_enregistree'); |
|
| 58 | - |
|
| 59 | - return $res; |
|
| 38 | + $res = ['editable' => true]; |
|
| 39 | + // un checkbox seul de name X non coche n'est pas poste. |
|
| 40 | + // on verifie le champ X_check qui indique que la checkbox etait presente dans le formulaire. |
|
| 41 | + foreach (['multi_secteurs'] as $m) { |
|
| 42 | + if (!is_null(_request($m . '_check'))) { |
|
| 43 | + ecrire_meta($m, _request($m) ? 'oui' : 'non'); |
|
| 44 | + } |
|
| 45 | + } |
|
| 46 | + foreach (['multi_objets', 'gerer_trad_objets'] as $m) { |
|
| 47 | + if (!is_null($v = _request($m))) { |
|
| 48 | + // join et enlever la valeur vide '' |
|
| 49 | + ecrire_meta($m, implode(',', array_diff($v, ['']))); |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + if (($i = _request('langues_auth')) && is_array($i)) { |
|
| 54 | + $i = array_unique(array_merge($i, explode(',', $GLOBALS['meta']['langues_utilisees']))); |
|
| 55 | + ecrire_meta('langues_multilingue', implode(',', $i)); |
|
| 56 | + } |
|
| 57 | + $res['message_ok'] = _T('config_info_enregistree'); |
|
| 58 | + |
|
| 59 | + return $res; |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
@@ -66,13 +66,13 @@ discard block |
||
| 66 | 66 | * @return string |
| 67 | 67 | */ |
| 68 | 68 | function table_supporte_lang($table_sql) { |
| 69 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 70 | - $desc = $trouver_table($table_sql); |
|
| 71 | - if (!$desc || !isset($desc['field']['lang'])) { |
|
| 72 | - return ''; |
|
| 73 | - } |
|
| 69 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 70 | + $desc = $trouver_table($table_sql); |
|
| 71 | + if (!$desc || !isset($desc['field']['lang'])) { |
|
| 72 | + return ''; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - return ' '; |
|
| 75 | + return ' '; |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
@@ -82,65 +82,65 @@ discard block |
||
| 82 | 82 | * @return string |
| 83 | 83 | */ |
| 84 | 84 | function table_supporte_trad($table_sql) { |
| 85 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 86 | - $desc = $trouver_table($table_sql); |
|
| 87 | - if (!$desc || !isset($desc['field']['id_trad'])) { |
|
| 88 | - return ''; |
|
| 89 | - } |
|
| 85 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 86 | + $desc = $trouver_table($table_sql); |
|
| 87 | + if (!$desc || !isset($desc['field']['id_trad'])) { |
|
| 88 | + return ''; |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | - return ' '; |
|
| 91 | + return ' '; |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | |
| 95 | 95 | function saisie_langues_utiles($name, $selection) { |
| 96 | - include_spip('inc/lang_liste'); |
|
| 97 | - $langues = $GLOBALS['codes_langues']; |
|
| 98 | - |
|
| 99 | - $langues_installees = explode(',', $GLOBALS['meta']['langues_proposees']); |
|
| 100 | - $langues_trad = array_flip($langues_installees); |
|
| 101 | - |
|
| 102 | - $langues_bloquees = explode(',', $GLOBALS['meta']['langues_utilisees']); |
|
| 103 | - |
|
| 104 | - $res = ''; |
|
| 105 | - |
|
| 106 | - $i = 0; |
|
| 107 | - foreach ($langues_bloquees as $code_langue) { |
|
| 108 | - $nom_langue = $langues[$code_langue]; |
|
| 109 | - $res .= "<li class='choix " |
|
| 110 | - . alterner(++$i, 'odd', 'even') |
|
| 111 | - . (isset($langues_trad[$code_langue]) ? ' traduite' : '') |
|
| 112 | - . "'>" |
|
| 113 | - . "<input type='hidden' name='{$name}[]' value='$code_langue'>" // necessaire ... |
|
| 114 | - . "<input type='checkbox' name='{$name}[]' id='{$name}_$code_langue' value='$code_langue' checked='checked' disabled='disabled' />" |
|
| 115 | - . "<label for='{$name}_$code_langue'>" . $nom_langue . " <span class='code_langue'>[$code_langue]</span></label>" |
|
| 116 | - . '</li>'; |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - if ($res) { |
|
| 120 | - $res = "<ul id='langues_bloquees'>" . $res . "</ul><div class='nettoyeur'></div>"; |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - $res .= "<ul id='langues_proposees'>"; |
|
| 124 | - |
|
| 125 | - $i = 0; |
|
| 126 | - $langues_bloquees = array_flip($langues_bloquees); |
|
| 127 | - foreach ($langues as $code_langue => $nom_langue) { |
|
| 128 | - if (!isset($langues_bloquees[$code_langue])) { |
|
| 129 | - $checked = (in_array($code_langue, $selection) ? ' checked="checked"' : ''); |
|
| 130 | - $res .= "<li class='choix " |
|
| 131 | - . alterner(++$i, 'odd', 'even') |
|
| 132 | - . (isset($langues_trad[$code_langue]) ? ' traduite' : '') |
|
| 133 | - . "'>" |
|
| 134 | - . "<input type='checkbox' name='{$name}[]' id='{$name}_$code_langue' value='$code_langue'" |
|
| 135 | - . $checked |
|
| 136 | - . '/>' |
|
| 137 | - . "<label for='{$name}_$code_langue'" |
|
| 138 | - . ($checked ? " class='on'" : '') |
|
| 139 | - . '>' |
|
| 140 | - . $nom_langue . " <span class='code_langue'>[$code_langue]</span></label>" |
|
| 141 | - . '</li>'; |
|
| 142 | - } |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - return $res . "</ul><div class='nettoyeur'></div>"; |
|
| 96 | + include_spip('inc/lang_liste'); |
|
| 97 | + $langues = $GLOBALS['codes_langues']; |
|
| 98 | + |
|
| 99 | + $langues_installees = explode(',', $GLOBALS['meta']['langues_proposees']); |
|
| 100 | + $langues_trad = array_flip($langues_installees); |
|
| 101 | + |
|
| 102 | + $langues_bloquees = explode(',', $GLOBALS['meta']['langues_utilisees']); |
|
| 103 | + |
|
| 104 | + $res = ''; |
|
| 105 | + |
|
| 106 | + $i = 0; |
|
| 107 | + foreach ($langues_bloquees as $code_langue) { |
|
| 108 | + $nom_langue = $langues[$code_langue]; |
|
| 109 | + $res .= "<li class='choix " |
|
| 110 | + . alterner(++$i, 'odd', 'even') |
|
| 111 | + . (isset($langues_trad[$code_langue]) ? ' traduite' : '') |
|
| 112 | + . "'>" |
|
| 113 | + . "<input type='hidden' name='{$name}[]' value='$code_langue'>" // necessaire ... |
|
| 114 | + . "<input type='checkbox' name='{$name}[]' id='{$name}_$code_langue' value='$code_langue' checked='checked' disabled='disabled' />" |
|
| 115 | + . "<label for='{$name}_$code_langue'>" . $nom_langue . " <span class='code_langue'>[$code_langue]</span></label>" |
|
| 116 | + . '</li>'; |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + if ($res) { |
|
| 120 | + $res = "<ul id='langues_bloquees'>" . $res . "</ul><div class='nettoyeur'></div>"; |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + $res .= "<ul id='langues_proposees'>"; |
|
| 124 | + |
|
| 125 | + $i = 0; |
|
| 126 | + $langues_bloquees = array_flip($langues_bloquees); |
|
| 127 | + foreach ($langues as $code_langue => $nom_langue) { |
|
| 128 | + if (!isset($langues_bloquees[$code_langue])) { |
|
| 129 | + $checked = (in_array($code_langue, $selection) ? ' checked="checked"' : ''); |
|
| 130 | + $res .= "<li class='choix " |
|
| 131 | + . alterner(++$i, 'odd', 'even') |
|
| 132 | + . (isset($langues_trad[$code_langue]) ? ' traduite' : '') |
|
| 133 | + . "'>" |
|
| 134 | + . "<input type='checkbox' name='{$name}[]' id='{$name}_$code_langue' value='$code_langue'" |
|
| 135 | + . $checked |
|
| 136 | + . '/>' |
|
| 137 | + . "<label for='{$name}_$code_langue'" |
|
| 138 | + . ($checked ? " class='on'" : '') |
|
| 139 | + . '>' |
|
| 140 | + . $nom_langue . " <span class='code_langue'>[$code_langue]</span></label>" |
|
| 141 | + . '</li>'; |
|
| 142 | + } |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + return $res . "</ul><div class='nettoyeur'></div>"; |
|
| 146 | 146 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | // un checkbox seul de name X non coche n'est pas poste. |
| 40 | 40 | // on verifie le champ X_check qui indique que la checkbox etait presente dans le formulaire. |
| 41 | 41 | foreach (['multi_secteurs'] as $m) { |
| 42 | - if (!is_null(_request($m . '_check'))) { |
|
| 42 | + if (!is_null(_request($m.'_check'))) { |
|
| 43 | 43 | ecrire_meta($m, _request($m) ? 'oui' : 'non'); |
| 44 | 44 | } |
| 45 | 45 | } |
@@ -112,12 +112,12 @@ discard block |
||
| 112 | 112 | . "'>" |
| 113 | 113 | . "<input type='hidden' name='{$name}[]' value='$code_langue'>" // necessaire ... |
| 114 | 114 | . "<input type='checkbox' name='{$name}[]' id='{$name}_$code_langue' value='$code_langue' checked='checked' disabled='disabled' />" |
| 115 | - . "<label for='{$name}_$code_langue'>" . $nom_langue . " <span class='code_langue'>[$code_langue]</span></label>" |
|
| 115 | + . "<label for='{$name}_$code_langue'>".$nom_langue." <span class='code_langue'>[$code_langue]</span></label>" |
|
| 116 | 116 | . '</li>'; |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | if ($res) { |
| 120 | - $res = "<ul id='langues_bloquees'>" . $res . "</ul><div class='nettoyeur'></div>"; |
|
| 120 | + $res = "<ul id='langues_bloquees'>".$res."</ul><div class='nettoyeur'></div>"; |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | $res .= "<ul id='langues_proposees'>"; |
@@ -137,10 +137,10 @@ discard block |
||
| 137 | 137 | . "<label for='{$name}_$code_langue'" |
| 138 | 138 | . ($checked ? " class='on'" : '') |
| 139 | 139 | . '>' |
| 140 | - . $nom_langue . " <span class='code_langue'>[$code_langue]</span></label>" |
|
| 140 | + . $nom_langue." <span class='code_langue'>[$code_langue]</span></label>" |
|
| 141 | 141 | . '</li>'; |
| 142 | 142 | } |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - return $res . "</ul><div class='nettoyeur'></div>"; |
|
| 145 | + return $res."</ul><div class='nettoyeur'></div>"; |
|
| 146 | 146 | } |
@@ -10,33 +10,33 @@ |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | function formulaires_configurer_transcodeur_charger_dist() { |
| 17 | - return [ |
|
| 18 | - 'charset' => $GLOBALS['meta']['charset'], |
|
| 19 | - ]; |
|
| 17 | + return [ |
|
| 18 | + 'charset' => $GLOBALS['meta']['charset'], |
|
| 19 | + ]; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | function formulaires_configurer_transcodeur_verifier_dist() { |
| 23 | - include_spip('inc/charsets'); |
|
| 23 | + include_spip('inc/charsets'); |
|
| 24 | 24 | |
| 25 | - $erreurs = []; |
|
| 26 | - if (!$charset = _request('charset')) { |
|
| 27 | - $erreurs['charset'] = _T('info_obligatoire'); |
|
| 28 | - } elseif ($charset != 'utf-8' && !load_charset($charset)) { |
|
| 29 | - $erreurs['charset'] = _T('utf8_convert_erreur_orig', ['charset' => entites_html($charset)]); |
|
| 30 | - } |
|
| 25 | + $erreurs = []; |
|
| 26 | + if (!$charset = _request('charset')) { |
|
| 27 | + $erreurs['charset'] = _T('info_obligatoire'); |
|
| 28 | + } elseif ($charset != 'utf-8' && !load_charset($charset)) { |
|
| 29 | + $erreurs['charset'] = _T('utf8_convert_erreur_orig', ['charset' => entites_html($charset)]); |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - return $erreurs; |
|
| 32 | + return $erreurs; |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | |
| 36 | 36 | function formulaires_configurer_transcodeur_traiter_dist() { |
| 37 | - $res = ['editable' => true]; |
|
| 38 | - ecrire_meta('charset', _request('charset')); |
|
| 39 | - $res['message_ok'] = _T('config_info_enregistree'); |
|
| 37 | + $res = ['editable' => true]; |
|
| 38 | + ecrire_meta('charset', _request('charset')); |
|
| 39 | + $res['message_ok'] = _T('config_info_enregistree'); |
|
| 40 | 40 | |
| 41 | - return $res; |
|
| 41 | + return $res; |
|
| 42 | 42 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | **/ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | include_spip('inc/editer'); |
@@ -31,17 +31,17 @@ discard block |
||
| 31 | 31 | * @return array |
| 32 | 32 | */ |
| 33 | 33 | function lister_statuts_proposes($desc, $publiable = true) { |
| 34 | - if (!isset($desc['statut_textes_instituer'])) { |
|
| 35 | - return false; |
|
| 36 | - } |
|
| 34 | + if (!isset($desc['statut_textes_instituer'])) { |
|
| 35 | + return false; |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - $l = $desc['statut_textes_instituer']; |
|
| 39 | - if (!$publiable) { |
|
| 40 | - unset($l['publie']); |
|
| 41 | - unset($l['refuse']); |
|
| 42 | - } |
|
| 38 | + $l = $desc['statut_textes_instituer']; |
|
| 39 | + if (!$publiable) { |
|
| 40 | + unset($l['publie']); |
|
| 41 | + unset($l['refuse']); |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - return $l; |
|
| 44 | + return $l; |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
@@ -63,53 +63,53 @@ discard block |
||
| 63 | 63 | * Environnement du formulaire ou false si aucun affichage à faire. |
| 64 | 64 | */ |
| 65 | 65 | function formulaires_instituer_objet_charger_dist($objet, $id_objet, $retour = '', $editable = true) { |
| 66 | - $editable = (bool) $editable; |
|
| 67 | - |
|
| 68 | - $table = table_objet_sql($objet); |
|
| 69 | - $desc = lister_tables_objets_sql($table); |
|
| 70 | - |
|
| 71 | - if (!isset($desc['statut_textes_instituer'])) { |
|
| 72 | - return false; |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - if (!autoriser('modifier', $objet, $id_objet)) { |
|
| 76 | - $editable = false; |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - // charger le contenu de l'objet |
|
| 80 | - // dont son champ statut |
|
| 81 | - $v = formulaires_editer_objet_charger($objet, $id_objet, 0, 0, '', ''); |
|
| 82 | - |
|
| 83 | - $publiable = true; |
|
| 84 | - $statuts = lister_statuts_proposes($desc); |
|
| 85 | - // tester si on a le droit de publier, si un statut publie existe |
|
| 86 | - if ( |
|
| 87 | - isset($statuts['publie']) |
|
| 88 | - && !autoriser('instituer', $objet, $id_objet, null, ['statut' => 'publie']) |
|
| 89 | - ) { |
|
| 90 | - if ($v['statut'] == 'publie') { |
|
| 91 | - $editable = false; |
|
| 92 | - } else { |
|
| 93 | - $publiable = false; |
|
| 94 | - } |
|
| 95 | - } |
|
| 96 | - $statuts = lister_statuts_proposes($desc, $editable ? $publiable : true); |
|
| 97 | - if (count($statuts) == 1 && isset($statuts[$v['statut']])) { |
|
| 98 | - $editable = false; |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - #if (!count($valeurs['statuts'])) |
|
| 102 | - return [ |
|
| 103 | - 'editable' => $editable, |
|
| 104 | - 'statut' => $v['statut'], |
|
| 105 | - '_objet' => $objet, |
|
| 106 | - '_id_objet' => $id_objet, |
|
| 107 | - '_statuts' => $statuts, |
|
| 108 | - '_publiable' => $publiable, |
|
| 109 | - '_label' => $desc['texte_changer_statut'] ?? 'texte_article_statut', |
|
| 110 | - '_aide' => $desc['aide_changer_statut'] ?? '', |
|
| 111 | - '_hidden' => "<input type='hidden' name='statut_old' value='" . $v['statut'] . "' />", |
|
| 112 | - ]; |
|
| 66 | + $editable = (bool) $editable; |
|
| 67 | + |
|
| 68 | + $table = table_objet_sql($objet); |
|
| 69 | + $desc = lister_tables_objets_sql($table); |
|
| 70 | + |
|
| 71 | + if (!isset($desc['statut_textes_instituer'])) { |
|
| 72 | + return false; |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + if (!autoriser('modifier', $objet, $id_objet)) { |
|
| 76 | + $editable = false; |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + // charger le contenu de l'objet |
|
| 80 | + // dont son champ statut |
|
| 81 | + $v = formulaires_editer_objet_charger($objet, $id_objet, 0, 0, '', ''); |
|
| 82 | + |
|
| 83 | + $publiable = true; |
|
| 84 | + $statuts = lister_statuts_proposes($desc); |
|
| 85 | + // tester si on a le droit de publier, si un statut publie existe |
|
| 86 | + if ( |
|
| 87 | + isset($statuts['publie']) |
|
| 88 | + && !autoriser('instituer', $objet, $id_objet, null, ['statut' => 'publie']) |
|
| 89 | + ) { |
|
| 90 | + if ($v['statut'] == 'publie') { |
|
| 91 | + $editable = false; |
|
| 92 | + } else { |
|
| 93 | + $publiable = false; |
|
| 94 | + } |
|
| 95 | + } |
|
| 96 | + $statuts = lister_statuts_proposes($desc, $editable ? $publiable : true); |
|
| 97 | + if (count($statuts) == 1 && isset($statuts[$v['statut']])) { |
|
| 98 | + $editable = false; |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + #if (!count($valeurs['statuts'])) |
|
| 102 | + return [ |
|
| 103 | + 'editable' => $editable, |
|
| 104 | + 'statut' => $v['statut'], |
|
| 105 | + '_objet' => $objet, |
|
| 106 | + '_id_objet' => $id_objet, |
|
| 107 | + '_statuts' => $statuts, |
|
| 108 | + '_publiable' => $publiable, |
|
| 109 | + '_label' => $desc['texte_changer_statut'] ?? 'texte_article_statut', |
|
| 110 | + '_aide' => $desc['aide_changer_statut'] ?? '', |
|
| 111 | + '_hidden' => "<input type='hidden' name='statut_old' value='" . $v['statut'] . "' />", |
|
| 112 | + ]; |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
@@ -129,35 +129,35 @@ discard block |
||
| 129 | 129 | * Tableau des erreurs |
| 130 | 130 | */ |
| 131 | 131 | function formulaires_instituer_objet_verifier_dist($objet, $id_objet, $retour = '', $editable = true) { |
| 132 | - $erreurs = []; |
|
| 133 | - // charger le contenu de l'objet |
|
| 134 | - // dont son champ statut |
|
| 135 | - $v = formulaires_editer_objet_charger($objet, $id_objet, 0, 0, '', ''); |
|
| 136 | - |
|
| 137 | - if ($v['statut'] !== _request('statut_old')) { |
|
| 138 | - $erreurs['statut'] = _T('instituer_erreur_statut_a_change'); |
|
| 139 | - } else { |
|
| 140 | - $table = table_objet_sql($objet); |
|
| 141 | - $desc = lister_tables_objets_sql($table); |
|
| 142 | - |
|
| 143 | - $publiable = true; |
|
| 144 | - if ( |
|
| 145 | - isset($v['id_rubrique']) |
|
| 146 | - && !autoriser('publierdans', 'rubrique', $v['id_rubrique']) |
|
| 147 | - ) { |
|
| 148 | - $publiable = false; |
|
| 149 | - } |
|
| 150 | - $l = lister_statuts_proposes($desc, $publiable); |
|
| 151 | - $statut = _request('statut'); |
|
| 152 | - if ( |
|
| 153 | - !isset($l[$statut]) |
|
| 154 | - || !autoriser('instituer', $objet, $id_objet, '', ['statut' => $statut]) |
|
| 155 | - ) { |
|
| 156 | - $erreurs['statut'] = _T('instituer_erreur_statut_non_autorise'); |
|
| 157 | - } |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - return $erreurs; |
|
| 132 | + $erreurs = []; |
|
| 133 | + // charger le contenu de l'objet |
|
| 134 | + // dont son champ statut |
|
| 135 | + $v = formulaires_editer_objet_charger($objet, $id_objet, 0, 0, '', ''); |
|
| 136 | + |
|
| 137 | + if ($v['statut'] !== _request('statut_old')) { |
|
| 138 | + $erreurs['statut'] = _T('instituer_erreur_statut_a_change'); |
|
| 139 | + } else { |
|
| 140 | + $table = table_objet_sql($objet); |
|
| 141 | + $desc = lister_tables_objets_sql($table); |
|
| 142 | + |
|
| 143 | + $publiable = true; |
|
| 144 | + if ( |
|
| 145 | + isset($v['id_rubrique']) |
|
| 146 | + && !autoriser('publierdans', 'rubrique', $v['id_rubrique']) |
|
| 147 | + ) { |
|
| 148 | + $publiable = false; |
|
| 149 | + } |
|
| 150 | + $l = lister_statuts_proposes($desc, $publiable); |
|
| 151 | + $statut = _request('statut'); |
|
| 152 | + if ( |
|
| 153 | + !isset($l[$statut]) |
|
| 154 | + || !autoriser('instituer', $objet, $id_objet, '', ['statut' => $statut]) |
|
| 155 | + ) { |
|
| 156 | + $erreurs['statut'] = _T('instituer_erreur_statut_non_autorise'); |
|
| 157 | + } |
|
| 158 | + } |
|
| 159 | + |
|
| 160 | + return $erreurs; |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | /** |
@@ -176,25 +176,25 @@ discard block |
||
| 176 | 176 | */ |
| 177 | 177 | function formulaires_instituer_objet_traiter_dist($objet, $id_objet, $retour = '', $editable = true) { |
| 178 | 178 | |
| 179 | - $c = ['statut' => _request('statut')]; |
|
| 180 | - // si on a envoye une 'date_posterieure', l'enregistrer |
|
| 181 | - // todo dans le HTML |
|
| 182 | - if ($d = _request('date_posterieure')) { |
|
| 183 | - $c['date'] = $d; |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - |
|
| 187 | - include_spip('action/editer_objet'); |
|
| 188 | - if ($err = objet_instituer($objet, $id_objet, $c)) { |
|
| 189 | - $res = ['message_erreur' => $err]; |
|
| 190 | - } else { |
|
| 191 | - $res = ['message_ok' => _T('info_modification_enregistree')]; |
|
| 192 | - if ($retour) { |
|
| 193 | - $res['redirect'] = $retour; |
|
| 194 | - } |
|
| 195 | - set_request('statut'); |
|
| 196 | - set_request('date_posterieure'); |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - return $res; |
|
| 179 | + $c = ['statut' => _request('statut')]; |
|
| 180 | + // si on a envoye une 'date_posterieure', l'enregistrer |
|
| 181 | + // todo dans le HTML |
|
| 182 | + if ($d = _request('date_posterieure')) { |
|
| 183 | + $c['date'] = $d; |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + |
|
| 187 | + include_spip('action/editer_objet'); |
|
| 188 | + if ($err = objet_instituer($objet, $id_objet, $c)) { |
|
| 189 | + $res = ['message_erreur' => $err]; |
|
| 190 | + } else { |
|
| 191 | + $res = ['message_ok' => _T('info_modification_enregistree')]; |
|
| 192 | + if ($retour) { |
|
| 193 | + $res['redirect'] = $retour; |
|
| 194 | + } |
|
| 195 | + set_request('statut'); |
|
| 196 | + set_request('date_posterieure'); |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + return $res; |
|
| 200 | 200 | } |
@@ -108,7 +108,7 @@ |
||
| 108 | 108 | '_publiable' => $publiable, |
| 109 | 109 | '_label' => $desc['texte_changer_statut'] ?? 'texte_article_statut', |
| 110 | 110 | '_aide' => $desc['aide_changer_statut'] ?? '', |
| 111 | - '_hidden' => "<input type='hidden' name='statut_old' value='" . $v['statut'] . "' />", |
|
| 111 | + '_hidden' => "<input type='hidden' name='statut_old' value='".$v['statut']."' />", |
|
| 112 | 112 | ]; |
| 113 | 113 | } |
| 114 | 114 | |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | **/ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | |
@@ -44,136 +44,136 @@ discard block |
||
| 44 | 44 | **/ |
| 45 | 45 | function formulaires_dater_charger_dist($objet, $id_objet, $retour = '', $options = []) { |
| 46 | 46 | |
| 47 | - $jour = null; |
|
| 48 | - $mois = null; |
|
| 49 | - $annee = null; |
|
| 50 | - $heure = null; |
|
| 51 | - $minute = null; |
|
| 52 | - $objet = objet_type($objet); |
|
| 53 | - if (!$objet || !(int) $id_objet) { |
|
| 54 | - return false; |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - if (!is_array($options)) { |
|
| 58 | - $options = unserialize($options); |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - $_id_objet = id_table_objet($objet); |
|
| 62 | - $table = table_objet($objet); |
|
| 63 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 64 | - $desc = $trouver_table($table); |
|
| 65 | - |
|
| 66 | - if (!$desc) { |
|
| 67 | - return false; |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - $champ_date = $desc['date'] ?: 'date'; |
|
| 71 | - if (isset($options['champ_date']) && $options['champ_date']) { |
|
| 72 | - $champ_date = $options['champ_date']; |
|
| 73 | - } |
|
| 74 | - if (!isset($desc['field'][$champ_date])) { |
|
| 75 | - return false; |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - $valeurs = [ |
|
| 79 | - 'objet' => $objet, |
|
| 80 | - 'id_objet' => $id_objet, |
|
| 81 | - 'id' => $id_objet, |
|
| 82 | - ]; |
|
| 83 | - |
|
| 84 | - |
|
| 85 | - $select = "$champ_date as date"; |
|
| 86 | - $champ_date_redac = 'date_redac'; |
|
| 87 | - if (isset($options['champ_date_redac']) && $options['champ_date_redac']) { |
|
| 88 | - $champ_date_redac = $options['champ_date_redac']; |
|
| 89 | - } |
|
| 90 | - if (isset($desc['field'][$champ_date_redac])) { |
|
| 91 | - $select .= ",$champ_date_redac as date_redac"; |
|
| 92 | - } |
|
| 93 | - if (isset($desc['field']['statut'])) { |
|
| 94 | - $select .= ',statut'; |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - |
|
| 98 | - $row = sql_fetsel($select, $desc['table'], "$_id_objet=" . (int) $id_objet); |
|
| 99 | - $statut = $row['statut'] ?? 'publie'; // pas de statut => publie |
|
| 100 | - |
|
| 101 | - $valeurs['editable'] = autoriser('dater', $objet, $id_objet, null, ['statut' => $statut]); |
|
| 102 | - |
|
| 103 | - $possedeDateRedac = false; |
|
| 104 | - |
|
| 105 | - if ( |
|
| 106 | - isset($row['date_redac']) |
|
| 107 | - && ($regs = recup_date($row['date_redac'], false)) |
|
| 108 | - ) { |
|
| 109 | - $annee_redac = $regs[0]; |
|
| 110 | - $mois_redac = $regs[1]; |
|
| 111 | - $jour_redac = $regs[2]; |
|
| 112 | - $heure_redac = $regs[3]; |
|
| 113 | - $minute_redac = $regs[4]; |
|
| 114 | - $possedeDateRedac = true; |
|
| 115 | - // attention : les vrai dates de l'annee 1 sont stockee avec +9000 => 9001 |
|
| 116 | - // mais reviennent ici en annee 1 par recup_date |
|
| 117 | - // on verifie donc que le intval($row['date_redac']) qui ressort l'annee |
|
| 118 | - // est bien lui aussi <=1 : dans ce cas c'est une date sql 'nulle' ou presque, selon |
|
| 119 | - // le gestionnnaire sql utilise (0001-01-01 pour PG par exemple) |
|
| 120 | - if ((int) $row['date_redac'] <= 1 && $annee_redac <= 1 && $mois_redac <= 1 && $jour_redac <= 1) { |
|
| 121 | - $possedeDateRedac = false; |
|
| 122 | - } |
|
| 123 | - } else { |
|
| 124 | - $annee_redac = $mois_redac = $jour_redac = $heure_redac = $minute_redac = 0; |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - if ($regs = recup_date($row['date'], false)) { |
|
| 128 | - $annee = $regs[0]; |
|
| 129 | - $mois = $regs[1]; |
|
| 130 | - $jour = $regs[2]; |
|
| 131 | - $heure = $regs[3]; |
|
| 132 | - $minute = $regs[4]; |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - // attention, si la variable s'appelle date ou date_redac, le compilo va |
|
| 136 | - // la normaliser, ce qu'on ne veut pas ici. |
|
| 137 | - $valeurs['afficher_date_redac'] = ($possedeDateRedac ? $row['date_redac'] : ''); |
|
| 138 | - $valeurs['date_redac_jour'] = dater_formater_saisie_jour($jour_redac, $mois_redac, $annee_redac); |
|
| 139 | - $valeurs['date_redac_heure'] = "$heure_redac:$minute_redac"; |
|
| 140 | - |
|
| 141 | - $valeurs['afficher_date'] = $row['date']; |
|
| 142 | - $valeurs['date_jour'] = dater_formater_saisie_jour($jour, $mois, $annee); |
|
| 143 | - $valeurs['date_heure'] = "$heure:$minute"; |
|
| 144 | - |
|
| 145 | - $valeurs['sans_redac'] = !$possedeDateRedac; |
|
| 146 | - |
|
| 147 | - if (isset($options['date_redac'])) { |
|
| 148 | - $valeurs['_editer_date_anterieure'] = $options['date_redac']; |
|
| 149 | - } else { |
|
| 150 | - $valeurs['_editer_date_anterieure'] = ($objet == 'article' && ($GLOBALS['meta']['articles_redac'] != 'non' || $possedeDateRedac)); |
|
| 151 | - } |
|
| 152 | - $valeurs['_label_date'] = (($statut == 'publie') ? |
|
| 153 | - _T('texte_date_publication_objet') : _T('texte_date_creation_objet')); |
|
| 154 | - if (isset($options['label_date']) && $options['label_date']) { |
|
| 155 | - $valeurs['_label_date'] = $options['label_date']; |
|
| 156 | - } |
|
| 157 | - if (isset($options['label_date_redac']) && $options['label_date_redac']) { |
|
| 158 | - $valeurs['_label_date_redac'] = $options['label_date_redac']; |
|
| 159 | - } |
|
| 160 | - if (isset($options['texte_sans_date_redac']) && $options['texte_sans_date_redac']) { |
|
| 161 | - $valeurs['_texte_sans_date_redac'] = $options['texte_sans_date_redac']; |
|
| 162 | - } |
|
| 163 | - if (isset($options['class']) && $options['class']) { |
|
| 164 | - $valeurs['_class'] = $options['class']; |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - $valeurs['_saisie_en_cours'] = (_request('_saisie_en_cours') !== null || _request('date_jour') !== null); |
|
| 168 | - |
|
| 169 | - // cas ou l'on ne peut pas dater mais on peut modifier la date de redac anterieure |
|
| 170 | - // https://core.spip.net/issues/3494 |
|
| 171 | - $valeurs['_editer_date'] = $valeurs['editable']; |
|
| 172 | - if ($valeurs['_editer_date_anterieure'] && !$valeurs['editable']) { |
|
| 173 | - $valeurs['editable'] = autoriser('modifier', $objet, $id_objet); |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - return $valeurs; |
|
| 47 | + $jour = null; |
|
| 48 | + $mois = null; |
|
| 49 | + $annee = null; |
|
| 50 | + $heure = null; |
|
| 51 | + $minute = null; |
|
| 52 | + $objet = objet_type($objet); |
|
| 53 | + if (!$objet || !(int) $id_objet) { |
|
| 54 | + return false; |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + if (!is_array($options)) { |
|
| 58 | + $options = unserialize($options); |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + $_id_objet = id_table_objet($objet); |
|
| 62 | + $table = table_objet($objet); |
|
| 63 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 64 | + $desc = $trouver_table($table); |
|
| 65 | + |
|
| 66 | + if (!$desc) { |
|
| 67 | + return false; |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + $champ_date = $desc['date'] ?: 'date'; |
|
| 71 | + if (isset($options['champ_date']) && $options['champ_date']) { |
|
| 72 | + $champ_date = $options['champ_date']; |
|
| 73 | + } |
|
| 74 | + if (!isset($desc['field'][$champ_date])) { |
|
| 75 | + return false; |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + $valeurs = [ |
|
| 79 | + 'objet' => $objet, |
|
| 80 | + 'id_objet' => $id_objet, |
|
| 81 | + 'id' => $id_objet, |
|
| 82 | + ]; |
|
| 83 | + |
|
| 84 | + |
|
| 85 | + $select = "$champ_date as date"; |
|
| 86 | + $champ_date_redac = 'date_redac'; |
|
| 87 | + if (isset($options['champ_date_redac']) && $options['champ_date_redac']) { |
|
| 88 | + $champ_date_redac = $options['champ_date_redac']; |
|
| 89 | + } |
|
| 90 | + if (isset($desc['field'][$champ_date_redac])) { |
|
| 91 | + $select .= ",$champ_date_redac as date_redac"; |
|
| 92 | + } |
|
| 93 | + if (isset($desc['field']['statut'])) { |
|
| 94 | + $select .= ',statut'; |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + |
|
| 98 | + $row = sql_fetsel($select, $desc['table'], "$_id_objet=" . (int) $id_objet); |
|
| 99 | + $statut = $row['statut'] ?? 'publie'; // pas de statut => publie |
|
| 100 | + |
|
| 101 | + $valeurs['editable'] = autoriser('dater', $objet, $id_objet, null, ['statut' => $statut]); |
|
| 102 | + |
|
| 103 | + $possedeDateRedac = false; |
|
| 104 | + |
|
| 105 | + if ( |
|
| 106 | + isset($row['date_redac']) |
|
| 107 | + && ($regs = recup_date($row['date_redac'], false)) |
|
| 108 | + ) { |
|
| 109 | + $annee_redac = $regs[0]; |
|
| 110 | + $mois_redac = $regs[1]; |
|
| 111 | + $jour_redac = $regs[2]; |
|
| 112 | + $heure_redac = $regs[3]; |
|
| 113 | + $minute_redac = $regs[4]; |
|
| 114 | + $possedeDateRedac = true; |
|
| 115 | + // attention : les vrai dates de l'annee 1 sont stockee avec +9000 => 9001 |
|
| 116 | + // mais reviennent ici en annee 1 par recup_date |
|
| 117 | + // on verifie donc que le intval($row['date_redac']) qui ressort l'annee |
|
| 118 | + // est bien lui aussi <=1 : dans ce cas c'est une date sql 'nulle' ou presque, selon |
|
| 119 | + // le gestionnnaire sql utilise (0001-01-01 pour PG par exemple) |
|
| 120 | + if ((int) $row['date_redac'] <= 1 && $annee_redac <= 1 && $mois_redac <= 1 && $jour_redac <= 1) { |
|
| 121 | + $possedeDateRedac = false; |
|
| 122 | + } |
|
| 123 | + } else { |
|
| 124 | + $annee_redac = $mois_redac = $jour_redac = $heure_redac = $minute_redac = 0; |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + if ($regs = recup_date($row['date'], false)) { |
|
| 128 | + $annee = $regs[0]; |
|
| 129 | + $mois = $regs[1]; |
|
| 130 | + $jour = $regs[2]; |
|
| 131 | + $heure = $regs[3]; |
|
| 132 | + $minute = $regs[4]; |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + // attention, si la variable s'appelle date ou date_redac, le compilo va |
|
| 136 | + // la normaliser, ce qu'on ne veut pas ici. |
|
| 137 | + $valeurs['afficher_date_redac'] = ($possedeDateRedac ? $row['date_redac'] : ''); |
|
| 138 | + $valeurs['date_redac_jour'] = dater_formater_saisie_jour($jour_redac, $mois_redac, $annee_redac); |
|
| 139 | + $valeurs['date_redac_heure'] = "$heure_redac:$minute_redac"; |
|
| 140 | + |
|
| 141 | + $valeurs['afficher_date'] = $row['date']; |
|
| 142 | + $valeurs['date_jour'] = dater_formater_saisie_jour($jour, $mois, $annee); |
|
| 143 | + $valeurs['date_heure'] = "$heure:$minute"; |
|
| 144 | + |
|
| 145 | + $valeurs['sans_redac'] = !$possedeDateRedac; |
|
| 146 | + |
|
| 147 | + if (isset($options['date_redac'])) { |
|
| 148 | + $valeurs['_editer_date_anterieure'] = $options['date_redac']; |
|
| 149 | + } else { |
|
| 150 | + $valeurs['_editer_date_anterieure'] = ($objet == 'article' && ($GLOBALS['meta']['articles_redac'] != 'non' || $possedeDateRedac)); |
|
| 151 | + } |
|
| 152 | + $valeurs['_label_date'] = (($statut == 'publie') ? |
|
| 153 | + _T('texte_date_publication_objet') : _T('texte_date_creation_objet')); |
|
| 154 | + if (isset($options['label_date']) && $options['label_date']) { |
|
| 155 | + $valeurs['_label_date'] = $options['label_date']; |
|
| 156 | + } |
|
| 157 | + if (isset($options['label_date_redac']) && $options['label_date_redac']) { |
|
| 158 | + $valeurs['_label_date_redac'] = $options['label_date_redac']; |
|
| 159 | + } |
|
| 160 | + if (isset($options['texte_sans_date_redac']) && $options['texte_sans_date_redac']) { |
|
| 161 | + $valeurs['_texte_sans_date_redac'] = $options['texte_sans_date_redac']; |
|
| 162 | + } |
|
| 163 | + if (isset($options['class']) && $options['class']) { |
|
| 164 | + $valeurs['_class'] = $options['class']; |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + $valeurs['_saisie_en_cours'] = (_request('_saisie_en_cours') !== null || _request('date_jour') !== null); |
|
| 168 | + |
|
| 169 | + // cas ou l'on ne peut pas dater mais on peut modifier la date de redac anterieure |
|
| 170 | + // https://core.spip.net/issues/3494 |
|
| 171 | + $valeurs['_editer_date'] = $valeurs['editable']; |
|
| 172 | + if ($valeurs['_editer_date_anterieure'] && !$valeurs['editable']) { |
|
| 173 | + $valeurs['editable'] = autoriser('modifier', $objet, $id_objet); |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + return $valeurs; |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | /** |
@@ -191,20 +191,20 @@ discard block |
||
| 191 | 191 | * Date formatée tel que `02/10/2012` |
| 192 | 192 | **/ |
| 193 | 193 | function dater_formater_saisie_jour($jour, $mois, $annee, $sep = '/') { |
| 194 | - $annee = str_pad($annee, 4, '0', STR_PAD_LEFT); |
|
| 195 | - if ((int) $jour) { |
|
| 196 | - $jour = str_pad($jour, 2, '0', STR_PAD_LEFT); |
|
| 197 | - $mois = str_pad($mois, 2, '0', STR_PAD_LEFT); |
|
| 194 | + $annee = str_pad($annee, 4, '0', STR_PAD_LEFT); |
|
| 195 | + if ((int) $jour) { |
|
| 196 | + $jour = str_pad($jour, 2, '0', STR_PAD_LEFT); |
|
| 197 | + $mois = str_pad($mois, 2, '0', STR_PAD_LEFT); |
|
| 198 | 198 | |
| 199 | - return "$jour$sep$mois$sep$annee"; |
|
| 200 | - } |
|
| 201 | - if ((int) $mois) { |
|
| 202 | - $mois = str_pad($mois, 2, '0', STR_PAD_LEFT); |
|
| 199 | + return "$jour$sep$mois$sep$annee"; |
|
| 200 | + } |
|
| 201 | + if ((int) $mois) { |
|
| 202 | + $mois = str_pad($mois, 2, '0', STR_PAD_LEFT); |
|
| 203 | 203 | |
| 204 | - return "$mois$sep$annee"; |
|
| 205 | - } |
|
| 204 | + return "$mois$sep$annee"; |
|
| 205 | + } |
|
| 206 | 206 | |
| 207 | - return $annee; |
|
| 207 | + return $annee; |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | /** |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | * Hash du formulaire |
| 224 | 224 | **/ |
| 225 | 225 | function formulaires_dater_identifier_dist($objet, $id_objet, $retour = '', $options = []) { |
| 226 | - return serialize([$objet, $id_objet]); |
|
| 226 | + return serialize([$objet, $id_objet]); |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | /** |
@@ -241,30 +241,30 @@ discard block |
||
| 241 | 241 | * Tableau des erreurs |
| 242 | 242 | */ |
| 243 | 243 | function formulaires_dater_verifier_dist($objet, $id_objet, $retour = '', $options = []) { |
| 244 | - $erreurs = []; |
|
| 245 | - |
|
| 246 | - // ouvrir le formulaire en edition ? |
|
| 247 | - if (_request('_saisie_en_cours')) { |
|
| 248 | - $erreurs['message_erreur'] = ''; |
|
| 249 | - |
|
| 250 | - return $erreurs; |
|
| 251 | - } |
|
| 252 | - |
|
| 253 | - if (_request('changer')) { |
|
| 254 | - foreach (['date', 'date_redac'] as $k) { |
|
| 255 | - if (($v = _request($k . '_jour')) && !dater_recuperer_date_saisie($v, $k)) { |
|
| 256 | - $erreurs[$k] = _T('format_date_incorrecte'); |
|
| 257 | - } elseif (($v = _request($k . '_heure')) && !dater_recuperer_heure_saisie($v)) { |
|
| 258 | - $erreurs[$k] = _T('format_heure_incorrecte'); |
|
| 259 | - } |
|
| 260 | - } |
|
| 261 | - |
|
| 262 | - if (!_request('date_jour')) { |
|
| 263 | - $erreurs['date'] = _T('info_obligatoire'); |
|
| 264 | - } |
|
| 265 | - } |
|
| 266 | - |
|
| 267 | - return $erreurs; |
|
| 244 | + $erreurs = []; |
|
| 245 | + |
|
| 246 | + // ouvrir le formulaire en edition ? |
|
| 247 | + if (_request('_saisie_en_cours')) { |
|
| 248 | + $erreurs['message_erreur'] = ''; |
|
| 249 | + |
|
| 250 | + return $erreurs; |
|
| 251 | + } |
|
| 252 | + |
|
| 253 | + if (_request('changer')) { |
|
| 254 | + foreach (['date', 'date_redac'] as $k) { |
|
| 255 | + if (($v = _request($k . '_jour')) && !dater_recuperer_date_saisie($v, $k)) { |
|
| 256 | + $erreurs[$k] = _T('format_date_incorrecte'); |
|
| 257 | + } elseif (($v = _request($k . '_heure')) && !dater_recuperer_heure_saisie($v)) { |
|
| 258 | + $erreurs[$k] = _T('format_heure_incorrecte'); |
|
| 259 | + } |
|
| 260 | + } |
|
| 261 | + |
|
| 262 | + if (!_request('date_jour')) { |
|
| 263 | + $erreurs['date'] = _T('info_obligatoire'); |
|
| 264 | + } |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + return $erreurs; |
|
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | /** |
@@ -282,79 +282,79 @@ discard block |
||
| 282 | 282 | * Retours des traitements |
| 283 | 283 | */ |
| 284 | 284 | function formulaires_dater_traiter_dist($objet, $id_objet, $retour = '', $options = []) { |
| 285 | - $res = ['editable' => ' ']; |
|
| 286 | - |
|
| 287 | - if (_request('changer')) { |
|
| 288 | - $table = table_objet($objet); |
|
| 289 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 290 | - $desc = $trouver_table($table); |
|
| 291 | - |
|
| 292 | - if (!$desc) { |
|
| 293 | - return ['message_erreur' => _L('erreur')]; |
|
| 294 | - } #impossible en principe |
|
| 295 | - |
|
| 296 | - $champ_date = $desc['date'] ?: 'date'; |
|
| 297 | - if (isset($options['champ_date']) && $options['champ_date']) { |
|
| 298 | - $champ_date = $options['champ_date']; |
|
| 299 | - } |
|
| 300 | - |
|
| 301 | - $set = []; |
|
| 302 | - |
|
| 303 | - $charger = charger_fonction('charger', 'formulaires/dater/'); |
|
| 304 | - $v = $charger($objet, $id_objet, $retour, $options); |
|
| 305 | - |
|
| 306 | - if ($v['_editer_date']) { |
|
| 307 | - if (!$d = dater_recuperer_date_saisie(_request('date_jour'))) { |
|
| 308 | - $d = [date('Y'), date('m'), date('d')]; |
|
| 309 | - } |
|
| 310 | - if (!$h = dater_recuperer_heure_saisie(_request('date_heure'))) { |
|
| 311 | - $h = [0, 0]; |
|
| 312 | - } |
|
| 313 | - |
|
| 314 | - $set[$champ_date] = sql_format_date($d[0], $d[1], $d[2], $h[0], $h[1]); |
|
| 315 | - } |
|
| 316 | - |
|
| 317 | - $champ_date_redac = 'date_redac'; |
|
| 318 | - if (isset($options['champ_date_redac']) && $options['champ_date_redac']) { |
|
| 319 | - $champ_date_redac = $options['champ_date_redac']; |
|
| 320 | - } |
|
| 321 | - if (isset($desc['field'][$champ_date_redac]) && $v['_editer_date_anterieure']) { |
|
| 322 | - if (!_request('date_redac_jour') || _request('sans_redac')) { |
|
| 323 | - $set[$champ_date_redac] = sql_format_date(0, 0, 0, 0, 0, 0); |
|
| 324 | - } else { |
|
| 325 | - if (!$d = dater_recuperer_date_saisie(_request('date_redac_jour'), 'date_redac')) { |
|
| 326 | - $d = [date('Y'), date('m'), date('d')]; |
|
| 327 | - } |
|
| 328 | - if (!$h = dater_recuperer_heure_saisie(_request('date_redac_heure'))) { |
|
| 329 | - $h = [0, 0]; |
|
| 330 | - } |
|
| 331 | - $set[$champ_date_redac] = sql_format_date($d[0], $d[1], $d[2], $h[0], $h[1]); |
|
| 332 | - } |
|
| 333 | - } |
|
| 334 | - |
|
| 335 | - if ($set !== []) { |
|
| 336 | - $publie_avant = objet_test_si_publie($objet, $id_objet); |
|
| 337 | - include_spip('action/editer_objet'); |
|
| 338 | - objet_modifier($objet, $id_objet, $set); |
|
| 339 | - $publie_apres = objet_test_si_publie($objet, $id_objet); |
|
| 340 | - if ($publie_avant !== $publie_apres) { |
|
| 341 | - // on refuse ajax pour forcer le rechargement de la page ici |
|
| 342 | - // on refera traiter une 2eme fois, mais c'est sans consequence |
|
| 343 | - refuser_traiter_formulaire_ajax(); |
|
| 344 | - } |
|
| 345 | - } |
|
| 346 | - } |
|
| 347 | - |
|
| 348 | - if ($retour) { |
|
| 349 | - $res['redirect'] = $retour; |
|
| 350 | - } |
|
| 351 | - |
|
| 352 | - set_request('date_jour'); |
|
| 353 | - set_request('date_redac_jour'); |
|
| 354 | - set_request('date_heure'); |
|
| 355 | - set_request('date_redac_heure'); |
|
| 356 | - |
|
| 357 | - return $res; |
|
| 285 | + $res = ['editable' => ' ']; |
|
| 286 | + |
|
| 287 | + if (_request('changer')) { |
|
| 288 | + $table = table_objet($objet); |
|
| 289 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 290 | + $desc = $trouver_table($table); |
|
| 291 | + |
|
| 292 | + if (!$desc) { |
|
| 293 | + return ['message_erreur' => _L('erreur')]; |
|
| 294 | + } #impossible en principe |
|
| 295 | + |
|
| 296 | + $champ_date = $desc['date'] ?: 'date'; |
|
| 297 | + if (isset($options['champ_date']) && $options['champ_date']) { |
|
| 298 | + $champ_date = $options['champ_date']; |
|
| 299 | + } |
|
| 300 | + |
|
| 301 | + $set = []; |
|
| 302 | + |
|
| 303 | + $charger = charger_fonction('charger', 'formulaires/dater/'); |
|
| 304 | + $v = $charger($objet, $id_objet, $retour, $options); |
|
| 305 | + |
|
| 306 | + if ($v['_editer_date']) { |
|
| 307 | + if (!$d = dater_recuperer_date_saisie(_request('date_jour'))) { |
|
| 308 | + $d = [date('Y'), date('m'), date('d')]; |
|
| 309 | + } |
|
| 310 | + if (!$h = dater_recuperer_heure_saisie(_request('date_heure'))) { |
|
| 311 | + $h = [0, 0]; |
|
| 312 | + } |
|
| 313 | + |
|
| 314 | + $set[$champ_date] = sql_format_date($d[0], $d[1], $d[2], $h[0], $h[1]); |
|
| 315 | + } |
|
| 316 | + |
|
| 317 | + $champ_date_redac = 'date_redac'; |
|
| 318 | + if (isset($options['champ_date_redac']) && $options['champ_date_redac']) { |
|
| 319 | + $champ_date_redac = $options['champ_date_redac']; |
|
| 320 | + } |
|
| 321 | + if (isset($desc['field'][$champ_date_redac]) && $v['_editer_date_anterieure']) { |
|
| 322 | + if (!_request('date_redac_jour') || _request('sans_redac')) { |
|
| 323 | + $set[$champ_date_redac] = sql_format_date(0, 0, 0, 0, 0, 0); |
|
| 324 | + } else { |
|
| 325 | + if (!$d = dater_recuperer_date_saisie(_request('date_redac_jour'), 'date_redac')) { |
|
| 326 | + $d = [date('Y'), date('m'), date('d')]; |
|
| 327 | + } |
|
| 328 | + if (!$h = dater_recuperer_heure_saisie(_request('date_redac_heure'))) { |
|
| 329 | + $h = [0, 0]; |
|
| 330 | + } |
|
| 331 | + $set[$champ_date_redac] = sql_format_date($d[0], $d[1], $d[2], $h[0], $h[1]); |
|
| 332 | + } |
|
| 333 | + } |
|
| 334 | + |
|
| 335 | + if ($set !== []) { |
|
| 336 | + $publie_avant = objet_test_si_publie($objet, $id_objet); |
|
| 337 | + include_spip('action/editer_objet'); |
|
| 338 | + objet_modifier($objet, $id_objet, $set); |
|
| 339 | + $publie_apres = objet_test_si_publie($objet, $id_objet); |
|
| 340 | + if ($publie_avant !== $publie_apres) { |
|
| 341 | + // on refuse ajax pour forcer le rechargement de la page ici |
|
| 342 | + // on refera traiter une 2eme fois, mais c'est sans consequence |
|
| 343 | + refuser_traiter_formulaire_ajax(); |
|
| 344 | + } |
|
| 345 | + } |
|
| 346 | + } |
|
| 347 | + |
|
| 348 | + if ($retour) { |
|
| 349 | + $res['redirect'] = $retour; |
|
| 350 | + } |
|
| 351 | + |
|
| 352 | + set_request('date_jour'); |
|
| 353 | + set_request('date_redac_jour'); |
|
| 354 | + set_request('date_heure'); |
|
| 355 | + set_request('date_redac_heure'); |
|
| 356 | + |
|
| 357 | + return $res; |
|
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | /** |
@@ -365,24 +365,24 @@ discard block |
||
| 365 | 365 | * @return array|string Chaîne vide si date invalide, tableau (année, mois, jour) sinon. |
| 366 | 366 | */ |
| 367 | 367 | function dater_recuperer_date_saisie($post, $quoi = 'date') { |
| 368 | - if (!preg_match('#^(?:(?:(\d{1,2})[/-])?(\d{1,2})[/-])?(\d{4}|\d{1,2})#', $post, $regs)) { |
|
| 369 | - return ''; |
|
| 370 | - } |
|
| 371 | - if ($quoi == 'date_redac') { |
|
| 372 | - if ($regs[3] != '' && $regs[3] < 1001) { |
|
| 373 | - $regs[3] += 9000; |
|
| 374 | - } |
|
| 375 | - |
|
| 376 | - return [$regs[3], $regs[2], $regs[1]]; |
|
| 377 | - } else { |
|
| 378 | - if ( |
|
| 379 | - checkdate((int) $regs[2], (int) $regs[1], (int) $regs[3]) |
|
| 380 | - && ($t = mktime(0, 0, 0, $regs[2], $regs[1], $regs[3])) |
|
| 381 | - ) { |
|
| 382 | - return [date('Y', $t), date('m', $t), date('d', $t)]; |
|
| 383 | - } |
|
| 384 | - return ''; |
|
| 385 | - } |
|
| 368 | + if (!preg_match('#^(?:(?:(\d{1,2})[/-])?(\d{1,2})[/-])?(\d{4}|\d{1,2})#', $post, $regs)) { |
|
| 369 | + return ''; |
|
| 370 | + } |
|
| 371 | + if ($quoi == 'date_redac') { |
|
| 372 | + if ($regs[3] != '' && $regs[3] < 1001) { |
|
| 373 | + $regs[3] += 9000; |
|
| 374 | + } |
|
| 375 | + |
|
| 376 | + return [$regs[3], $regs[2], $regs[1]]; |
|
| 377 | + } else { |
|
| 378 | + if ( |
|
| 379 | + checkdate((int) $regs[2], (int) $regs[1], (int) $regs[3]) |
|
| 380 | + && ($t = mktime(0, 0, 0, $regs[2], $regs[1], $regs[3])) |
|
| 381 | + ) { |
|
| 382 | + return [date('Y', $t), date('m', $t), date('d', $t)]; |
|
| 383 | + } |
|
| 384 | + return ''; |
|
| 385 | + } |
|
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | /** |
@@ -392,12 +392,12 @@ discard block |
||
| 392 | 392 | * @return array |
| 393 | 393 | */ |
| 394 | 394 | function dater_recuperer_heure_saisie($post) { |
| 395 | - if (!preg_match('#(\d{1,2})(?:[h:](?:(\d{1,2}))?)?#', $post, $regs)) { |
|
| 396 | - return ''; |
|
| 397 | - } |
|
| 398 | - if ($regs[1] > 23 || $regs[2] > 59) { |
|
| 399 | - return ''; |
|
| 400 | - } |
|
| 401 | - |
|
| 402 | - return [$regs[1], $regs[2]]; |
|
| 395 | + if (!preg_match('#(\d{1,2})(?:[h:](?:(\d{1,2}))?)?#', $post, $regs)) { |
|
| 396 | + return ''; |
|
| 397 | + } |
|
| 398 | + if ($regs[1] > 23 || $regs[2] > 59) { |
|
| 399 | + return ''; |
|
| 400 | + } |
|
| 401 | + |
|
| 402 | + return [$regs[1], $regs[2]]; |
|
| 403 | 403 | } |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | |
| 98 | - $row = sql_fetsel($select, $desc['table'], "$_id_objet=" . (int) $id_objet); |
|
| 98 | + $row = sql_fetsel($select, $desc['table'], "$_id_objet=".(int) $id_objet); |
|
| 99 | 99 | $statut = $row['statut'] ?? 'publie'; // pas de statut => publie |
| 100 | 100 | |
| 101 | 101 | $valeurs['editable'] = autoriser('dater', $objet, $id_objet, null, ['statut' => $statut]); |
@@ -252,9 +252,9 @@ discard block |
||
| 252 | 252 | |
| 253 | 253 | if (_request('changer')) { |
| 254 | 254 | foreach (['date', 'date_redac'] as $k) { |
| 255 | - if (($v = _request($k . '_jour')) && !dater_recuperer_date_saisie($v, $k)) { |
|
| 255 | + if (($v = _request($k.'_jour')) && !dater_recuperer_date_saisie($v, $k)) { |
|
| 256 | 256 | $erreurs[$k] = _T('format_date_incorrecte'); |
| 257 | - } elseif (($v = _request($k . '_heure')) && !dater_recuperer_heure_saisie($v)) { |
|
| 257 | + } elseif (($v = _request($k.'_heure')) && !dater_recuperer_heure_saisie($v)) { |
|
| 258 | 258 | $erreurs[$k] = _T('format_heure_incorrecte'); |
| 259 | 259 | } |
| 260 | 260 | } |
@@ -10,46 +10,46 @@ |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | function formulaires_configurer_langage_charger_dist() { |
| 17 | 17 | |
| 18 | - include_spip('inc/lang'); |
|
| 19 | - $GLOBALS['meta']['langues_proposees'] = ''; |
|
| 20 | - init_langues(); |
|
| 21 | - $langues = explode(',', $GLOBALS['meta']['langues_proposees']); |
|
| 18 | + include_spip('inc/lang'); |
|
| 19 | + $GLOBALS['meta']['langues_proposees'] = ''; |
|
| 20 | + init_langues(); |
|
| 21 | + $langues = explode(',', $GLOBALS['meta']['langues_proposees']); |
|
| 22 | 22 | |
| 23 | - return [ |
|
| 24 | - 'var_lang_ecrire' => $GLOBALS['spip_lang'], |
|
| 25 | - '_langues' => $langues |
|
| 26 | - ]; |
|
| 23 | + return [ |
|
| 24 | + 'var_lang_ecrire' => $GLOBALS['spip_lang'], |
|
| 25 | + '_langues' => $langues |
|
| 26 | + ]; |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | |
| 30 | 30 | function formulaires_configurer_langage_traiter_dist() { |
| 31 | - include_spip('action/converser'); |
|
| 32 | - action_converser_changer_langue(true); |
|
| 31 | + include_spip('action/converser'); |
|
| 32 | + action_converser_changer_langue(true); |
|
| 33 | 33 | |
| 34 | - refuser_traiter_formulaire_ajax(); |
|
| 34 | + refuser_traiter_formulaire_ajax(); |
|
| 35 | 35 | |
| 36 | - // on ne peut pas changer la langue pour tout le hit ici, |
|
| 37 | - // car CVT repasse derriere et retablit la langue avant l'appel a traiter() |
|
| 38 | - // il faut rediriger ! |
|
| 39 | - return ['message_ok' => _T('config_info_enregistree'), 'editable' => true, 'redirect' => self()]; |
|
| 36 | + // on ne peut pas changer la langue pour tout le hit ici, |
|
| 37 | + // car CVT repasse derriere et retablit la langue avant l'appel a traiter() |
|
| 38 | + // il faut rediriger ! |
|
| 39 | + return ['message_ok' => _T('config_info_enregistree'), 'editable' => true, 'redirect' => self()]; |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | function afficher_langues_choix($langues, $name, $id, $selected) { |
| 43 | - include_spip('inc/lang'); |
|
| 44 | - $ret = ''; |
|
| 45 | - sort($langues); |
|
| 46 | - foreach ($langues as $l) { |
|
| 47 | - $checked = ($l == $selected) ? ' checked=\'checked\'' : ''; |
|
| 48 | - $ret .= "<div class='choix'>" |
|
| 49 | - . "<input type='radio' name='$name' id='{$id}_$l' value='$l'$checked />" |
|
| 50 | - . "<label for='{$id}_$l'>" . traduire_nom_langue($l) . '</label>' |
|
| 51 | - . '</div>'; |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - return $ret; |
|
| 43 | + include_spip('inc/lang'); |
|
| 44 | + $ret = ''; |
|
| 45 | + sort($langues); |
|
| 46 | + foreach ($langues as $l) { |
|
| 47 | + $checked = ($l == $selected) ? ' checked=\'checked\'' : ''; |
|
| 48 | + $ret .= "<div class='choix'>" |
|
| 49 | + . "<input type='radio' name='$name' id='{$id}_$l' value='$l'$checked />" |
|
| 50 | + . "<label for='{$id}_$l'>" . traduire_nom_langue($l) . '</label>' |
|
| 51 | + . '</div>'; |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + return $ret; |
|
| 55 | 55 | } |
@@ -10,138 +10,138 @@ |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | include_spip('inc/presentation'); |
| 16 | 16 | include_spip('inc/config'); |
| 17 | 17 | |
| 18 | 18 | function formulaires_configurer_relayeur_charger_dist() { |
| 19 | - return [ |
|
| 20 | - 'http_proxy' => no_password_proxy_url(lire_config('http_proxy', '')), |
|
| 21 | - 'http_noproxy' => lire_config('http_noproxy', ''), |
|
| 22 | - 'test_proxy' => 'https://www.spip.net/', |
|
| 23 | - ]; |
|
| 19 | + return [ |
|
| 20 | + 'http_proxy' => no_password_proxy_url(lire_config('http_proxy', '')), |
|
| 21 | + 'http_noproxy' => lire_config('http_noproxy', ''), |
|
| 22 | + 'test_proxy' => 'https://www.spip.net/', |
|
| 23 | + ]; |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | function formulaires_configurer_relayeur_verifier_dist() { |
| 27 | - $erreurs = []; |
|
| 28 | - $http_proxy = relayeur_saisie_ou_config(_request('http_proxy'), lire_config('http_proxy', '')); |
|
| 29 | - $http_noproxy = _request('http_noproxy'); |
|
| 30 | - |
|
| 31 | - if ($http_proxy && !tester_url_absolue($http_proxy)) { |
|
| 32 | - $erreurs['http_proxy'] = _T('info_url_proxy_pas_conforme'); |
|
| 33 | - } |
|
| 34 | - |
|
| 35 | - if (!isset($erreurs['http_proxy']) && _request('tester_proxy')) { |
|
| 36 | - if (!$http_proxy) { |
|
| 37 | - $erreurs['http_proxy'] = _T('info_obligatoire'); |
|
| 38 | - } else { |
|
| 39 | - include_spip('inc/distant'); |
|
| 40 | - $test_proxy = _request('test_proxy'); |
|
| 41 | - $t = parse_url($test_proxy); |
|
| 42 | - if (!@$t['host']) { |
|
| 43 | - $erreurs['test_proxy'] = _T('info_adresse_non_indiquee'); |
|
| 44 | - } else { |
|
| 45 | - include_spip('inc/texte'); // pour aide, couper, lang |
|
| 46 | - $info = ''; |
|
| 47 | - if (!need_proxy($t['host'], $http_proxy, $http_noproxy)) { |
|
| 48 | - $info = '<strong>' . _T('page_pas_proxy') . '</strong><br />'; |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - // il faut fausser le proxy actuel pour faire le test ! |
|
| 52 | - $cur_http_proxy = $GLOBALS['meta']['http_proxy']; |
|
| 53 | - $cur_http_noproxy = $GLOBALS['meta']['http_noproxy']; |
|
| 54 | - $GLOBALS['meta']['http_proxy'] = $http_proxy; |
|
| 55 | - $GLOBALS['meta']['http_noproxy'] = $http_noproxy; |
|
| 56 | - $page = recuperer_url($test_proxy, ['transcoder' => true]); |
|
| 57 | - $page = $page['page'] ?? ''; |
|
| 58 | - $GLOBALS['meta']['http_proxy'] = $cur_http_proxy; |
|
| 59 | - $GLOBALS['meta']['http_noproxy'] = $cur_http_noproxy; |
|
| 60 | - if ($page) { |
|
| 61 | - $erreurs['message_ok'] = _T('info_proxy_ok') . "<br />$info\n<tt>" . couper(entites_html($page), 300) . '</tt>'; |
|
| 62 | - $erreurs['message_erreur'] = ''; |
|
| 63 | - } else { |
|
| 64 | - $erreurs['message_erreur'] = $info . _T( |
|
| 65 | - 'info_impossible_lire_page', |
|
| 66 | - ['test_proxy' => "<tt>$test_proxy</tt>"] |
|
| 67 | - ) |
|
| 68 | - . ' <b><tt>' . no_password_proxy_url($http_proxy) . '</tt></b>.' |
|
| 69 | - . aider('confhttpproxy'); |
|
| 70 | - } |
|
| 71 | - } |
|
| 72 | - } |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - return $erreurs; |
|
| 27 | + $erreurs = []; |
|
| 28 | + $http_proxy = relayeur_saisie_ou_config(_request('http_proxy'), lire_config('http_proxy', '')); |
|
| 29 | + $http_noproxy = _request('http_noproxy'); |
|
| 30 | + |
|
| 31 | + if ($http_proxy && !tester_url_absolue($http_proxy)) { |
|
| 32 | + $erreurs['http_proxy'] = _T('info_url_proxy_pas_conforme'); |
|
| 33 | + } |
|
| 34 | + |
|
| 35 | + if (!isset($erreurs['http_proxy']) && _request('tester_proxy')) { |
|
| 36 | + if (!$http_proxy) { |
|
| 37 | + $erreurs['http_proxy'] = _T('info_obligatoire'); |
|
| 38 | + } else { |
|
| 39 | + include_spip('inc/distant'); |
|
| 40 | + $test_proxy = _request('test_proxy'); |
|
| 41 | + $t = parse_url($test_proxy); |
|
| 42 | + if (!@$t['host']) { |
|
| 43 | + $erreurs['test_proxy'] = _T('info_adresse_non_indiquee'); |
|
| 44 | + } else { |
|
| 45 | + include_spip('inc/texte'); // pour aide, couper, lang |
|
| 46 | + $info = ''; |
|
| 47 | + if (!need_proxy($t['host'], $http_proxy, $http_noproxy)) { |
|
| 48 | + $info = '<strong>' . _T('page_pas_proxy') . '</strong><br />'; |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + // il faut fausser le proxy actuel pour faire le test ! |
|
| 52 | + $cur_http_proxy = $GLOBALS['meta']['http_proxy']; |
|
| 53 | + $cur_http_noproxy = $GLOBALS['meta']['http_noproxy']; |
|
| 54 | + $GLOBALS['meta']['http_proxy'] = $http_proxy; |
|
| 55 | + $GLOBALS['meta']['http_noproxy'] = $http_noproxy; |
|
| 56 | + $page = recuperer_url($test_proxy, ['transcoder' => true]); |
|
| 57 | + $page = $page['page'] ?? ''; |
|
| 58 | + $GLOBALS['meta']['http_proxy'] = $cur_http_proxy; |
|
| 59 | + $GLOBALS['meta']['http_noproxy'] = $cur_http_noproxy; |
|
| 60 | + if ($page) { |
|
| 61 | + $erreurs['message_ok'] = _T('info_proxy_ok') . "<br />$info\n<tt>" . couper(entites_html($page), 300) . '</tt>'; |
|
| 62 | + $erreurs['message_erreur'] = ''; |
|
| 63 | + } else { |
|
| 64 | + $erreurs['message_erreur'] = $info . _T( |
|
| 65 | + 'info_impossible_lire_page', |
|
| 66 | + ['test_proxy' => "<tt>$test_proxy</tt>"] |
|
| 67 | + ) |
|
| 68 | + . ' <b><tt>' . no_password_proxy_url($http_proxy) . '</tt></b>.' |
|
| 69 | + . aider('confhttpproxy'); |
|
| 70 | + } |
|
| 71 | + } |
|
| 72 | + } |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + return $erreurs; |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | function formulaires_configurer_relayeur_traiter_dist() { |
| 79 | - $res = ['editable' => true]; |
|
| 79 | + $res = ['editable' => true]; |
|
| 80 | 80 | |
| 81 | - $http_proxy = relayeur_saisie_ou_config(_request('http_proxy'), lire_config('http_proxy', '')); |
|
| 82 | - $http_noproxy = _request('http_noproxy'); |
|
| 83 | - if ($http_proxy !== null) { |
|
| 84 | - ecrire_meta('http_proxy', $http_proxy); |
|
| 85 | - } |
|
| 81 | + $http_proxy = relayeur_saisie_ou_config(_request('http_proxy'), lire_config('http_proxy', '')); |
|
| 82 | + $http_noproxy = _request('http_noproxy'); |
|
| 83 | + if ($http_proxy !== null) { |
|
| 84 | + ecrire_meta('http_proxy', $http_proxy); |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - if ($http_noproxy !== null) { |
|
| 88 | - ecrire_meta('http_noproxy', $http_noproxy); |
|
| 89 | - } |
|
| 87 | + if ($http_noproxy !== null) { |
|
| 88 | + ecrire_meta('http_noproxy', $http_noproxy); |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | - $res['message_ok'] = _T('config_info_enregistree'); |
|
| 91 | + $res['message_ok'] = _T('config_info_enregistree'); |
|
| 92 | 92 | |
| 93 | - return $res; |
|
| 93 | + return $res; |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | function relayeur_saisie_ou_config($http_proxy, $default) { |
| 97 | - // http_proxy : ne pas prendre en compte la modif si le password est '****' |
|
| 98 | - if (preg_match(',:\*\*\*\*@,', $http_proxy)) { |
|
| 99 | - $http_proxy = $default; |
|
| 100 | - } |
|
| 97 | + // http_proxy : ne pas prendre en compte la modif si le password est '****' |
|
| 98 | + if (preg_match(',:\*\*\*\*@,', $http_proxy)) { |
|
| 99 | + $http_proxy = $default; |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - return $http_proxy; |
|
| 102 | + return $http_proxy; |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | // Function glue_url : le pendant de parse_url |
| 106 | 106 | function glue_url($url) { |
| 107 | - if (!is_array($url)) { |
|
| 108 | - return false; |
|
| 109 | - } |
|
| 110 | - // scheme |
|
| 111 | - $uri = (empty($url['scheme'])) ? '' : $url['scheme'] . '://'; |
|
| 112 | - // user & pass |
|
| 113 | - if (!empty($url['user'])) { |
|
| 114 | - $uri .= $url['user'] . ':' . $url['pass'] . '@'; |
|
| 115 | - } |
|
| 116 | - // host |
|
| 117 | - $uri .= $url['host']; |
|
| 118 | - // port |
|
| 119 | - $port = (empty($url['port'])) ? '' : ':' . $url['port']; |
|
| 120 | - $uri .= $port; |
|
| 121 | - // path |
|
| 122 | - $uri .= $url['path']; |
|
| 107 | + if (!is_array($url)) { |
|
| 108 | + return false; |
|
| 109 | + } |
|
| 110 | + // scheme |
|
| 111 | + $uri = (empty($url['scheme'])) ? '' : $url['scheme'] . '://'; |
|
| 112 | + // user & pass |
|
| 113 | + if (!empty($url['user'])) { |
|
| 114 | + $uri .= $url['user'] . ':' . $url['pass'] . '@'; |
|
| 115 | + } |
|
| 116 | + // host |
|
| 117 | + $uri .= $url['host']; |
|
| 118 | + // port |
|
| 119 | + $port = (empty($url['port'])) ? '' : ':' . $url['port']; |
|
| 120 | + $uri .= $port; |
|
| 121 | + // path |
|
| 122 | + $uri .= $url['path']; |
|
| 123 | 123 | // fragment or query |
| 124 | - if (isset($url['fragment'])) { |
|
| 125 | - $uri .= '#' . $url['fragment']; |
|
| 126 | - } elseif (isset($url['query'])) { |
|
| 127 | - $uri .= '?' . $url['query']; |
|
| 128 | - } |
|
| 124 | + if (isset($url['fragment'])) { |
|
| 125 | + $uri .= '#' . $url['fragment']; |
|
| 126 | + } elseif (isset($url['query'])) { |
|
| 127 | + $uri .= '?' . $url['query']; |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | - return $uri; |
|
| 130 | + return $uri; |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | |
| 134 | 134 | // Ne pas afficher la partie 'password' du proxy |
| 135 | 135 | function no_password_proxy_url($http_proxy) { |
| 136 | - if ( |
|
| 137 | - $http_proxy |
|
| 138 | - && ($p = @parse_url($http_proxy)) |
|
| 139 | - && isset($p['pass']) |
|
| 140 | - && $p['pass'] |
|
| 141 | - ) { |
|
| 142 | - $p['pass'] = '****'; |
|
| 143 | - $http_proxy = glue_url($p); |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - return $http_proxy; |
|
| 136 | + if ( |
|
| 137 | + $http_proxy |
|
| 138 | + && ($p = @parse_url($http_proxy)) |
|
| 139 | + && isset($p['pass']) |
|
| 140 | + && $p['pass'] |
|
| 141 | + ) { |
|
| 142 | + $p['pass'] = '****'; |
|
| 143 | + $http_proxy = glue_url($p); |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + return $http_proxy; |
|
| 147 | 147 | } |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | include_spip('inc/texte'); // pour aide, couper, lang |
| 46 | 46 | $info = ''; |
| 47 | 47 | if (!need_proxy($t['host'], $http_proxy, $http_noproxy)) { |
| 48 | - $info = '<strong>' . _T('page_pas_proxy') . '</strong><br />'; |
|
| 48 | + $info = '<strong>'._T('page_pas_proxy').'</strong><br />'; |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | // il faut fausser le proxy actuel pour faire le test ! |
@@ -58,14 +58,14 @@ discard block |
||
| 58 | 58 | $GLOBALS['meta']['http_proxy'] = $cur_http_proxy; |
| 59 | 59 | $GLOBALS['meta']['http_noproxy'] = $cur_http_noproxy; |
| 60 | 60 | if ($page) { |
| 61 | - $erreurs['message_ok'] = _T('info_proxy_ok') . "<br />$info\n<tt>" . couper(entites_html($page), 300) . '</tt>'; |
|
| 61 | + $erreurs['message_ok'] = _T('info_proxy_ok')."<br />$info\n<tt>".couper(entites_html($page), 300).'</tt>'; |
|
| 62 | 62 | $erreurs['message_erreur'] = ''; |
| 63 | 63 | } else { |
| 64 | - $erreurs['message_erreur'] = $info . _T( |
|
| 64 | + $erreurs['message_erreur'] = $info._T( |
|
| 65 | 65 | 'info_impossible_lire_page', |
| 66 | 66 | ['test_proxy' => "<tt>$test_proxy</tt>"] |
| 67 | 67 | ) |
| 68 | - . ' <b><tt>' . no_password_proxy_url($http_proxy) . '</tt></b>.' |
|
| 68 | + . ' <b><tt>'.no_password_proxy_url($http_proxy).'</tt></b>.' |
|
| 69 | 69 | . aider('confhttpproxy'); |
| 70 | 70 | } |
| 71 | 71 | } |
@@ -108,23 +108,23 @@ discard block |
||
| 108 | 108 | return false; |
| 109 | 109 | } |
| 110 | 110 | // scheme |
| 111 | - $uri = (empty($url['scheme'])) ? '' : $url['scheme'] . '://'; |
|
| 111 | + $uri = (empty($url['scheme'])) ? '' : $url['scheme'].'://'; |
|
| 112 | 112 | // user & pass |
| 113 | 113 | if (!empty($url['user'])) { |
| 114 | - $uri .= $url['user'] . ':' . $url['pass'] . '@'; |
|
| 114 | + $uri .= $url['user'].':'.$url['pass'].'@'; |
|
| 115 | 115 | } |
| 116 | 116 | // host |
| 117 | 117 | $uri .= $url['host']; |
| 118 | 118 | // port |
| 119 | - $port = (empty($url['port'])) ? '' : ':' . $url['port']; |
|
| 119 | + $port = (empty($url['port'])) ? '' : ':'.$url['port']; |
|
| 120 | 120 | $uri .= $port; |
| 121 | 121 | // path |
| 122 | 122 | $uri .= $url['path']; |
| 123 | 123 | // fragment or query |
| 124 | 124 | if (isset($url['fragment'])) { |
| 125 | - $uri .= '#' . $url['fragment']; |
|
| 125 | + $uri .= '#'.$url['fragment']; |
|
| 126 | 126 | } elseif (isset($url['query'])) { |
| 127 | - $uri .= '?' . $url['query']; |
|
| 127 | + $uri .= '?'.$url['query']; |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | return $uri; |